kic-2.4c/ 0000755 0000764 0000764 00000000000 12427514070 011716 5 ustar stevew stevew kic-2.4c/config.guess 0000555 0000764 0000764 00000127737 12427243557 014266 0 ustar stevew stevew #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2013-05-16'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# Originally written by Per Bothner.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
#
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
;;
esac
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
exit ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
*:SolidBSD:*:*)
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux${UNAME_RELEASE}
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c &&
dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`$dummy $dummyarg` &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos${UNAME_RELEASE}
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
then
echo "$SYSTEM_NAME"
else
echo rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
eval $set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep -q __LP64__
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:*)
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
authenticamd | genuineintel | EM64T)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
8664:Windows_NT:*)
echo x86_64-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i586-pc-interix
exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
frv:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
or1k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
*) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
echo ${UNAME_MACHINE}-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit ;;
SX-7:SUPER-UX:*:*)
echo sx7-nec-superux${UNAME_RELEASE}
exit ;;
SX-8:SUPER-UX:*:*)
echo sx8-nec-superux${UNAME_RELEASE}
exit ;;
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
eval $set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
exit ;;
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
exit ;;
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
exit ;;
esac
eval $set_cc_for_build
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\n"); 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 -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# 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 ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
exit ;;
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:
kic-2.4c/util/ 0000755 0000764 0000764 00000000000 12427314716 012700 5 ustar stevew stevew kic-2.4c/util/mkwinpkg 0000755 0000764 0000764 00000002620 12427312417 014451 0 ustar stevew stevew #! /bin/sh
# Script to build a Windows package file. This is called from the
# Makefile in ../msw_package.
version=$1
if [ x"$version" == x ]; then
echo "No version given!"
exit
fi
program=kic
# The inno packager exeutable.
inno="/inno-5.5.1/iscc"
topdir=data
rm -rf $topdir
mkdir $topdir
bin=$topdir/bin
lib=$topdir/lib
kic=$lib/kic
srclib=..
mkdir $bin
mkdir $lib
mkdir $kic
echo Copying files for export ...
install -sc -m 0755 $srclib/src/bin/kic.exe $bin
install -sc -m 0755 $srclib/src/bin/ciftokic.exe $bin
install -sc -m 0755 $srclib/src/bin/kichelp.exe $bin
install -sc -m 0755 $srclib/src/bin/kictocif.exe $bin
install -sc -m 0755 $srclib/src/bin/kictostr.exe $bin
install -sc -m 0755 $srclib/src/bin/kicscale.exe $bin
install -sc -m 0755 $srclib/src/bin/strmtext.exe $bin
install -sc -m 0755 $srclib/src/bin/strtokic.exe $bin
cp $srclib/startup/* $kic
utod $kic/*
utod $kic/README
utod $kic/kic_help.txt
utod $kic/kic_tech
utod $kic/kic_tech.110
utod $kic/kic_tech.220
utod $kic/kic_tech.300
utod $kic/kic_tech.hyp
utod $kic/kic_tech.scm
utod $kic/logofont.kic
utod $kic/ltab
utod $kic/ltab.hyp
utod $kic/ltab.trw
echo Completed copying files, building package ...
sed -e s/VERSION/$version/ < $program.iss.in > $program.iss
utod $program.iss
$inno $program.iss > build.log
if [ $? != 0 ]; then
echo Compile failed!
exit 1
fi
mv Output/*.exe .
rmdir Output
rm $program.iss
echo Done
kic-2.4c/util/mkdirpth 0000755 0000764 0000764 00000001302 07525346707 014454 0 ustar stevew stevew #!/bin/sh
# Make directory hierarchy.
# Written by Noah Friedman
# Public domain.
# $Id: mkdirpth,v 2.0 1996/12/11 03:06:20 stevew Exp $
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
errstatus=0
for file in ${1+"$@"} ; do
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
for d in ${1+"$@"} ; do
pathcomp="${pathcomp}${d}"
if test ! -d "${pathcomp}"; then
echo "mkdir $pathcomp" 1>&2
mkdir "${pathcomp}" || errstatus=$?
chmod 755 "${pathcomp}"
fi
pathcomp="${pathcomp}/"
done
done
exit $errstatus
# eof
kic-2.4c/util/utod.c 0000644 0000764 0000764 00000004032 12427313410 014004 0 ustar stevew stevew
#include
#include
#include
#include
#include
/* $Id: utod.c,v 1.3 2014/03/01 01:42:24 stevew Exp $ */
/* change unix format text files to DOS format */
const char *bins[] = { "exe", "dll", "zip", "gz", "dat", NULL };
int main(int argc, char **argv)
{
int i;
FILE *ip, *op;
char tname[32], *tf;
strcpy(tname, "duXXXXXX");
tf = mktemp(tname);
for (i = 1; i < argc; i++) {
struct stat st;
const char *e = strrchr(argv[i], '.');
if (e != NULL) {
e++;
const char **p;
for (p = bins; *p != NULL; p++) {
if (!strcasecmp(*p, e))
break;
}
if (*p != NULL)
continue;
}
if (stat(argv[i], &st) < 0) {
fprintf(stderr, "can't stat: %s\n",argv[i]);
continue;
}
if (!(st.st_mode & S_IFREG))
continue;
ip = fopen(argv[i], "rb");
if (ip == NULL) {
fprintf(stderr, "can't open: %s\n",argv[i]);
continue;
}
op = fopen(tf, "wb");
if (op == NULL) {
fprintf(stderr, "internal error: can't open temp file\n");
exit(1);
}
{
int c, lc = 0;
while ((c = getc(ip)) != EOF) {
if (c == 10 && lc != 13)
putc(13, op);
putc(c, op);
lc = c;
}
}
fclose(ip);
fclose(op);
op = fopen(argv[i], "wb");
if (op == NULL) {
fprintf(stderr, "can't open: %s\n",argv[i]);
continue;
}
ip = fopen(tf, "rb");
if (ip == NULL) {
fprintf(stderr, "internal error: can't open temp file\n");
exit(1);
}
{
int c;
while ((c = getc(ip)) != EOF) {
putc(c, op);
}
}
fclose(ip);
fclose(op);
}
unlink(tf);
return (0);
}
kic-2.4c/README 0000644 0000764 0000764 00000064537 12427513766 012630 0 ustar stevew stevew
README for KIC-2.4c 11/8/2014
Questions, comments, requests, and hate mail should be addressed to
Steve Whiteley, stevew@srware.com
KIC is distributed by Whiteley Research Inc., www.wrcad.com.
Disclaimer: Steve Whiteley and Whiteley Research Inc. don't guarantee
or imply that this software is suitable for any purpose. This is free
public domain software, use at your own risk.
######################################################################
# #
# KIC LAYOUT EDITOR #
# #
######################################################################
Release 2.4c 11/8/14
> Another round of fixes for compiler warnings, etc., and updates
for compatibility with newer Linux distributions.
Release 2.4b 1/11/09
> Fixed benign compiler warnings from gcc-4.2.1.
> Added patch so that coordinates entered as text are read as floating
values rather than integers, following the Debian patch by
Yargo C. Bonetti.
> Added the msw_package directory and the mkwinpkg script in util,
used for building Windows package files. This is mostly for my
convenience.
Release 2.4a 7/24/05 (re-re-release)
> Fixed layer counting in converter. The top layer would not be
added to output.
Release 2.4a 7/22/05 (re-release)
> The Windows binary package should now be relocatable, the previous
release would not work if not installed in the default location,
unless the environment variable KIC_LIB_DIR was set to the
installation directory.
> GDSII layer/datatype numbers can now extend from 0-255. Previously
the numbers were limited to 63, an old GDSII spec.
Release 2.4a 7/1/05
> Fixed a bug in the Donut command - creating a donut with inner
radius zero would cause garbage values when written to a file,
making the file invisible since the scaling sould be way off. It
is now impossible to create donuts with inner radius zero (use the
Flash command to create disk objects).
> Fixed bug - if the PATH has trailing white space (which it does by
default) then cells would be searched for spurriously in the root
directory.
> Misc. changes to avoid compiler warning messages.
Release 2.4 8/11/02
> Replaced the build control system with GNU configure. This avoids
using the (mostly) obsolete operating system specific configuration
files in the conf subdirectory (which no longer exists). The program
should build on just about any Unix/Linux system, plus Mingw and
Cygwin under Windows (Mingw is a native build, Cygwin requires X).
> Fixed a bug: The program would hang when prompting for input on
sparc (big endian) machines.
> The CIF parser can now handle nested comments.
> The "help" program is now named "kichelp" since "help" is too
> generic.
Release 2.3b 5/4/02
> The maximum number of layers was increased from 35 to 70.
> Native Windows release only: The Font command in the Attri menu can
be used to change the font size. The Updat command will save the
new font size in the technology file, using the FontName keyword.
Note that under Windows, the FontName is in the form "WxH", for
example "8x15", whereas under UNIX the FontName is the name of an
X font.
Release 2.3a 8/18/00
> Native Windows release only: The installer program places a key in
the registry
(HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Kic)
that locates the install.log file, which is installed with the startup
files. This is now used to locate the startup files, though the
KIC_LIB_DIR variable, if set, has precedence. This means that the
program works without setting KIC_LIB_DIR if installed in a non-
standard location, or if started from a different drive. But...
if you move these files later by hand to a different location, they
won't be found automatically, and uninstall won't work.
> Native Windows release only: Various fatal errors now pop up a
message box explaining the error.
> Native Windows release only: 256 color mode is now supported.
Note that when changing colors in 256 color mode, you have to redraw
the display to see the new colors (except that the layer table is
updated automatically), as in higher color modes. Windows does
not support dynamic hardware colormap changes reliably, so the
instant global color change seen in X-windows is absent. Also,
"blinking" layers is not supported in Windows.
> Native Windows release only: Fixed a scaling bug in hardcopy
generation.
Release 2.3 8/15/00
> This release was ported to Windows as a native application, using the
Mingw compiler (www.mingw.org). The port is as direct as possible,
using a single window, so operation should be very close to that on
unix, or the Cygwin release on NT (which requires an X server).
Since this required fairly substantial modifications to the program
structure, a new release minor number was given.
> Printing notes: In Windows, you can print to a file in either PCL
or PostScript format. It might work to set the "PRN" value to "prn",
which should instead stream the output to the default printer.
> In the native Windows port, you must use at least 16-bit graphics.
Support for 8-bits (256 colors) may be added later. The Font button
presently does nothing, and the Cursr button toggles the full screen
cursor. Otherwise, this version provides all of the features of
the unix releases (or at least that is the intention).
> Added a techfile for Mosis scalable cmos: kic_tech.scm. This will
require customization to specific processes. The default kic_tech
file is a copy of this file. The Conductus kic_tech.con file has
been removed since the process is no longer available.
> The native Windows port accepts drag/drop files, i.e., you can drag
kic cell files from the file manager and drop them into the kic window.
> When a menu name changes, such as TBRL -> TB -> RL, the accelerators
for the menu are recomputed, and the menu redisplayed. In particular,
when RL is displayed, the Rdraw entry becomes RDraw, so that there is
no longer a conflict. Previously, pressing "r" would redraw the screen,
so the "RL" was inaccessible from key presses. Now, "rd" redisplays
the screen when "RL" is present.
> Kic now uses a simplified transformation for placed cells, consisting
of a maximum of one each of MirrorY, Rotation, Translation. Previously,
if the LLREF option was used, a second translation was added, which
confused the kictostr program. This should no longer be a problem.
> Fixed a problem in strtokic where it would silently omit the layer
names from kic files if it couldn't parse the kic_tech file.
> The default file extension for GDSII files is now ".gds". It was
".str" in previous releases.
> The "cd" shell command in now recognized internally, and changes the
current working directory, i.e., the directory where kic writes
files. Previously, it changed the directory of the subshell that
executes the command and dies, so did nothing. Thus, to change
to /usr/mydir, type "!cd /usr/mydir". If no directory path is given,
the user's home directory is understood (in Windows, the value of
the HOME environment variable, or the root of the current drive if
HOME is undefined).
Release 2.2f 1/27/00
> Fixed a whole collection of compile-time fatal errors when compiling
under glibc-2.x (Linux). In this version of the C library, several
of the common string functions are defined as macros, and declarations
then generate an error. These have been fixed.
> Fixed the Xor command, which would as likely as not crash the program.
Release 2.2e 7/5/99
> Fixed a bug that would crash the program when an open failed on a file
under some circumstances.
> Fixed a bug that would sometimes crash after a deletion.
> Added "solaris" config file.
> Added "mkdirpth" script to fix install problems.
Release 2.2d 11/29/98
> Polygon entry no longer crashes program.
> Works with TrueColor graphics when PsuedoColor visual is also available
but not the default (i.e., it wouldn't start with certain PC X-servers).
Release 2.2c 11/4/98
> Fixed bug in cif in/out.
> Fixed other minor bugs.
DOS is no longer supported, since I no longer run DOS.
Release 2.2b 2/24/97
> Port to DEC Alpha OSF.
> Defines in the Stream conversion routines to change case conversion
policy of symbol names. Conversion policy has been changed to no
case conversion.
Release 2.2a 10/1/94
> bugs fixed.
######################################################################
# #
# OBTAINING KIC #
# #
######################################################################
The kic program is available in two files:
kic-x.x.tar.gz Source code (no binaries)
kic-x.x-setup.exe Binary for Windows NT/98/95/2000
sites:
www.wrcad.com
www.srware.com
ftp.srware.com
DOS is no longer directly supported, since I no longer run DOS. I can
supply the DOS direct-write graphics library if anyone wants to build
a DOS-only version (contact stevew@srware.com).
There is a fairly complete unix emulation package (Cygwin) for Windows
available from www.sourceware.cygnus.com. If you download the
development tools, kic can be built in this environment, though you
will also need the X libraries and an X server. See the links on the
Cygwin web page for sources.
Downloading the Cygwin user tools is a good idea, if you are used to
unix commands. In particular, the bash shell is very convenient
for scripting and general command-line interaction.
The Mingw compiler, used to build the Windows native version,
is available from www.mingw.org.
######################################################################
** This is free software, use at your own risk. **
** NO GUARANTEE OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE **
######################################################################
######################################################################
# #
# KIC LAYOUT EDITOR #
# #
######################################################################
This is an updated version of the venerable KIC layout editor. It
currently runs under various versions of UNIX, Cygnus NT/9x with X
support, and native Windows. Under UNIX, the X windowing system is
required.
Some of the features of this version of KIC are:
1. An on-line help system provides help for all KIC functions.
2. The CIF and Calma Stream conversion routines are now built into
KIC, under the "cnvrt" menu item in the basic menu. The free
standing conversion routines are also provided.
3. Most commands that previously operated on selected items now
allow the user to choose an item if none have been previously
selected.
4. Ghosting and rubber-banding have been added to several commands.
There is no manual for kic, only the on-line help system. With the
help button selected, clicking on other buttons will provide descriptions
and cross references. New users should spend some time reading the
help on the various commands.
Quick Introduction
- Kic works best with a three (or more) button pointing device.
* Button 1 (left): Button pressing, selections, etc.
* Button 2 (middle): Pan operation
* Button 3 (right): Zoom operation
* Button 4 (wherever): No operation, but updates coordinate display
If buttons are missing, kic can still be used, but less efficiently.
- By default, kic is in split-screen mode, with a coarse view and
a detail view. The Zoom command is used to change the window scale,
and to switch to/from single-window mode.
- The Help button, when active, supplies information about the
functions of the various buttons.
- The ESC key terminates the current operation or command.
- The uppercase part of the button labels represents the keyboard
accelerator for the button.
######################################################################
# #
# INSTALLATION #
# #
######################################################################
###########
# #
# UNIX #
# #
###########
This applies to the source code distributions (.tar.gz files).
kic-2.4 and later --
The portability of the build system is semi-dependent on use of the
gcc compiler. It will probably work with your non-gcc compiler, but
be prepared to tweek the CFLAGS in the Makefiles if there is trouble.
1) Unpack the distribution file. You will need the gzip program
and it is nice to have GNU tar. Both are available from
prep.ai.mit.edu.
With GNU tar:
tar xzf kic-2.4.tar.gz
note: GNU tar is sometimes installed as "gtar".
Without GNU tar:
gunzip kic-2.4.tar.gz
tar xf kic-2.4.tar
2) Go to the kic-2.4 directory and run the configuration script.
(See #4 for a modification that might be of interest)
cd kic-2.4
./configure
3) Build the programs.
make
4) Install the programs. You probably have to be root to do this.
make install
The programs are installed by default under /usr/local. Binary
executables go in /usr/local/bin, startup and help files go under
/usr/local/lib/kic.
You can install the programs in another location. The easiest way
to do this is to use the --prefix argument to the configure script.
As in step #2, type instead
./configure --prefix=/some/path
Where "/some/path" is the path to be used instead of "/usr/local".
The configure/build/install should work on just about any Unix/Linux
system, plus Mingw and Cygwin under Windows. If any trouble, contact
Steve Whiteley at stevew@srware.com.
This completes the build/install procedure for kic-2.4 and later.
To build under Mingw:
Same as above, but...
I use the Cygwin "helper" tools such as make and bash. The "Mingw"
bash window uses Cygwin bash that sets a path to the Mingw compiler
executables ahead of the Cygwin tools. The make suppled by Mingw is
moved to a different name. The make/configure will probably fail
using the Mingw-specific make and bash. You may be able to build
a native version under Cygwin using the -mingw option, but I haven't
tried this.
Earlier releases --
Use the FTP program to obtain the full source code distribution in
file kic-xxx.tar.gz. Uncompress and un-tar into a source tree.
(See #1 above).
Examine the files in the 'conf' subdirectory and select/create one
to work with your system.
From the top directory (the one with this file) run the configure script.
It will ask a question or two, then create and configure the makefiles.
You can enter the name of the configuration file on the command line,
otherwise you will be prompted for the name by the configure script.
When configure exits, cd to src/bin and run the 'make' program:
csh: make |& tee errs
bash: make 2>&1 |tee errs
If your make program is not named 'make' use your name on the command
line in place of 'make' as above. The command will compile all the
source code and create the executables, saving messages in the 'errs'
file.
The compilation will take a few minutes. If there is a problem that
you can't fix, mail the resulting errs file to stevew@srware.com,
with a brief explanation.
When finished, you can 'make install'. Usually, you have to be root
to do this. This copies the binaries into KIC_EXEC_DIR (which must
exist), and the startup files into KIC_LIB_DIR. The parent of
KIC_LIB_DIR must exist, and any existing KIC_LIB_DIR will be removed
before the new one is installed.
###########
# #
# WINDOWS #
# #
###########
The binary distribution for Windows comes in a self-extracting
archive. Simply execute the file, and answer a few questions.
The program will be installed (by default) under c:\usr\local,
with the executables in c:\usr\local\bin and the startup files
in c:\usr\local\lib\kic. A shortcut is installed in the Start
menu. An uninstall executable is also provided (UnGins.exe),
which is placed in the Windows directory.
Unless you have a good reason (such as an existing installation
that you don't want to clobber) it is recommended that the
default location be used, but feel free to change the drive
letter. If a different location is chosen, the KIC_LIB_DIR
environment variable must be set to the kic library directory
path, for kic to find the startup files.
Kic should be started from a DOS box, or (much) better yet a
bash box from Cygwin (www.sourceware.cygnus.com). If you start
by clicking on the kic icon, you should use the !cd command to
change to some known directory, or your saved files may end up
in odd places. Kic must be started in the save drive as the
setup files, unless a KIC_LIB_DIR environment variable is
defined with a full path to the setup files directory
including the drive letter.
In all directory paths, the '/' and '\' characters can be used
as directory separators interchangeably. Paths can include the
drive letter prefix.
######################################################################
# #
# NOTES #
# #
######################################################################
On UNIX versions, the hcopy command at 300 dpi resolution fails when
output is directed to the printer on many systems. This is because
the resulting file is too large. You can get around this by dumping
to a file, then using "lpr -s file", (the -s says use a symbolic link,
see the man page).
The GDSII (Stream) format uses symbol names that are upper case only.
KIC cell names are converted to upper case during conversion.
!!!There is currently no checking for case-insensitive name clashes!!!
You should make sure there are no clashes before converting to GDSII.
Be particularly careful of cells created with the logo command.
In back-conversion, GDSII names are converted to lower case KIC cells.
Previous versions of KIC used technology files named .KIC.xx in UNIX,
and dotkic.xx in DOS. These names are still supported for now. The
files are now named kic_tech.xx, under DOS or UNIX.
Things to remember:
1. The ESC key gets you out of any command.
2. When performing a conversion from CIF or Stream, BE SURE TO MOVE
TO A NEW DIRECTORY if kic versions of the cells exist in the current
directory. Otherwise, the original files will be clobbered.
A message reminds the user of this fact.
3. Under UNIX/X, the option "-d display" is supported, where "display"
is the X display name of the terminal to be used.
The default is found in the "DISPLAY" environment variable.
4. The "-t tech" option supplies an extension to the assumed name of
the tech file. For example, if "-t trw" is given, the layer
attributes startup file read and written would be kic_tech.trw
in both cases.
5. The startup files in the startup directory can be located if they
are moved by setting the environment variable "KIC_LIB_DIR". For
example, if the startup directory is moved to /foo/bar/kic/startup",
then "setenv KIC_LIB_DIR /foo/bar/kic/startup" lets kic know where
these files are (you could also change global.h and recompile).
This is similarly true for DOS.
######################################################################
# #
# UTILITIES #
# #
######################################################################
The KIC package also contains stand-alone utilities listed below. These
are mostly obsolete, as the functionality is built into KIC.
strtokic
Stand-alone stream to KIC conversion program.
Usage: strtokic [options] [streamfile]
options (case insensitive):
-P Convert manhattan polygons to boxes,
four-sided manhattan polygons are always converted.
-E Print errors in file "strtokic.err",
default is to screen (stderr).
-Csname sname = Root structure name to convert.
Default, convert all structures in file.
-Rfilename filename = Name of root cell (default "Root").
The root cell contains global library information, and
can usually be ignored.
-Xfilename Use filename as layer table reference ("ltab") file,
default is to use layers from dotkic file
(StreamData lines).
-Text Use layers from dotkic.ext (.KIC.ext in UNIX).
-N Use stream layer numbers for layer names. Will
reference layers as "L NNDD" where N is the layer
number and D is the data type, both as two character
fields. Supersedes -X, -T.
-Lmicprl Microns per lambda (default 1.0).
Will prompt for stream file name to convert if not supplied,
hit return for help.
Search path for dotkic file: . , KIC_LIB_DIR
If the data type supplied from the dotkic or ltab files is -1,
the datatype comparison is supressed, and all datatypes associated
with a given layer will be mapped to a single KIC layer.
Otherwise, the datatype, and of course the layer number, must
match those supplied. Valid stream layer and data type numbers
are 0-63. In DOS versions, the file "dos__str.als" is created or
added to, when it is necessary to change a cell name for DOS
compatibility.
kictostr
Stand-alone KIC to stream conversion program.
Usage: kictostr [options] [root_kic_cell]
options (case insensitive):
-C Convert only cells found in current directory.
-Zname Stream library name (default "KICTOSTREAM").
-Ostrname Stream file name to create. (default is root kic cell
name with .str extension)
-S Convert symbolic layers only.
-D Convert detail layers only.
-Xfilename Use filename as layer table reference ("ltab") file,
default is to use layers from dotkic file
(StreamData lines).
-Text Use layers in dotkic.ext (.KIC.ext in UNIX).
-N Parse layer names for stream layers, KIC layers
must be named "NNDD" (num datatype). Supersedes
-X, -T.
-Lmicprl Microns per lambda (default 1.0).
-Mupermic Database units per micron (default 100.0).
Will prompt for kic cell name to convert if not supplied,
hit return for help.
If the datatype obtained from the dotkic or ltab file is outside
of 0-63, the written datatype is 0.
The valid stream layer numbers and data types are 0-63.
In DOS versions, if the file "dos__str.als" is present, the
entries are used to map DOS cell names into stream cell names.
This file is created by the stream to KIC converters.
ciftokic
Stand-alone CIF to KIC converter
Usage: ciftokic [options] [cif_file]
options:
-Lmicprl Microns per lambda (default 1.0).
-prefix (cif dialect) where prefix =
k Generated from KIC
a Stanford: A Stanford symbol name follows a DS command as
in (PadIn);
b NCA: An NCA symbol name follows a DS command as in
(PadIn);
h IGS: A KIC or IGS symbol name follows a DS command as
in 9 PadIn;
i Icarus: An Icarus symbol name follows a DS command as in
(9 PadIn);
q Squid: A Squid symbol name follows a DS command as in
9 /usr/joe/PadIn;
s Sif: A Sif symbol name follows a DS command as in
(Name: PadIn);
n none of the above\n");
Will prompt for cif input file name if not specified, hit
return for help.
kictocif
Stand-alone KIC to CIF converter
Usage: kictocif [options] [root_kic_cell]
options (case insensitive):
-Ocifname CIF file name to create.
-S Convert symbolic layers only.
-D Convert detail layers only.
-Pc c = Program prefix (a,b NCA/Stanford, i Icarus, s SIF).
-Text Use layers in dotkic.ext (.KIC.ext in UNIX).
-Lmicprl Microns per lambda (default 1.0).
Will prompt for root kic cell if not specified, hit return for help.
strmtext
Stream to text file converter
Usage: strmtotext [-id] [-n2345678] [ streamfile [textfile] ]
options:
-id Prints the version of the program and copyright
information.
-n Indicates a non-standard Stream file is to be read,
that is, one structure beginning with BGBSTR and
ending with ENDSTR.
1-8 Indicate the number of Stream records per line in
the output text. (Default is one per line).
streamfile A Calma Stream file (3.0) input to this program.
(Standard input default).
textfile The name of the file to receive the program's output.
(Standard output default).
scale
KIC cell scaling program
Usage: scale [-a numerator] [-b denominator] [-t ext] [root_kic_file]
options:
-a numer Numerator of scale factor, positive integer >= 1
(default 1).
-b denom Denominator of scale factor, positive integer >= 1
(default 1).
-t ext Use dotkic.ext for layer definitions.
Will prompt for root kic file if not given. The program multiplies
all coordinates in the root cell and subcells by numer/denom, and
writes over the original cells. If you want to preserve the original
cells, they have to be copied to another name or directory. BE
CAREFUL, EXPERIMENTING WITH THIS PROGRAM CAN CLOBBER YOUR FILES.
kic-2.4c/Makefile 0000644 0000764 0000764 00000000526 12427251130 013354 0 ustar stevew stevew
dummy::
cd src/bin; $(MAKE) depend; $(MAKE)
install::
cd src/bin; $(MAKE) install
uninstall::
cd src/bin; $(MAKE) uninstall
clean::
cd src/bin; $(MAKE) clean
# cd msw_package; $(MAKE) clean
distclean::
cd src/bin; $(MAKE) distclean
# cd msw_package; $(MAKE) distclean
-rm -rf autom4te.cache config.cache config.log config.status
kic-2.4c/configure 0000755 0000764 0000764 00000560426 12427446044 013647 0 ustar stevew stevew #! /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="src/bin/kicmain.c"
# 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
X_EXTRA_LIBS
X_LIBS
X_PRE_LIBS
X_CFLAGS
XMKMF
EGREP
GREP
CPP
MFB
INSTALL_USER
INSTALL
DEPEND_PROG
RANLIB
SET_MAKE
NOCONS
RESOURCE
FILTER
NTSUFFIX
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
DATE
VERSION
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
with_x
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP
XMKMF'
# 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
X features:
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
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
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-x use the X Window System
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
XMKMF Path to xmkmf, Makefile generator for X Window System
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
VERSION="2.4c"
DATE=`/bin/date`
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
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
case $host_os in
*cygwin* ) CYGWIN=yes;;
* ) CYGWIN=no;;
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
case $host_os in
*mingw32* ) MINGW32=yes;;
* ) MINGW32=no;;
esac
WIN32=no
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
WIN32=yes
fi
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
if test $WIN32 = yes; then
NTSUFFIX=".exe"
FILTER="|sed -e s/
//"
RESOURCE="kicrc.o"
NOCONS="-mwindows"
INSTALL_USER="-o Administrator -g Everyone"
elif test x$CYGWIN = x"yes"; then
NTSUFFIX=".exe"
INSTALL_USER="-o Administrator -g Everyone"
fi
fi
{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
$as_echo_n "(cached) " >&6
else
cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
*@@@%%%=?*=@@@%%%*)
eval ac_cv_prog_make_${ac_make}_set=yes;;
*)
eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
SET_MAKE=
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
SET_MAKE="MAKE=${MAKE-make}"
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_RANLIB+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$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
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
{ $as_echo "$as_me:$LINENO: result: $RANLIB" >&5
$as_echo "$RANLIB" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_RANLIB"; then
ac_ct_RANLIB=$RANLIB
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_RANLIB"; then
ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { 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_RANLIB="ranlib"
$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_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
{ $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
$as_echo "$ac_ct_RANLIB" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_RANLIB" = x; then
RANLIB=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
RANLIB=$ac_ct_RANLIB
fi
else
RANLIB="$ac_cv_prog_RANLIB"
fi
if test -f /bin/arch; then
if test "`/bin/arch`" = "sun4"; then
SUN4=yes
fi
fi
if test "$GCC" = yes; then
DEPEND_PROG="cc -MM"
if test x$SUN4 = x"yes"; then
SUN4FLAGS="-Wno-implicit -Wno-char-subscripts -D__EXTENSIONS__"
CFLAGS="-O -Wall $SUN4FLAGS"
else
CFLAGS="-O -Wall"
CFLAGSG="-O -g -Wall"
fi
else
DEPEND_PROG="cc -M"
CFLAGS="-O"
fi
if test -x /usr/ucb/install; then
INSTALL="/usr/ucb/install"
else
INSTALL="install"
fi
if test x"$INSTALL_USER" = x; then
if test "`uname`" = Linux; then
INSTALL_USER="-o root -g root"
else
INSTALL_USER="-o root -g bin"
fi
fi
if test $WIN32 = no; then
MFB="../xmfb.a"
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
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 "sys_errlist" >/dev/null 2>&1; then
cat >>confdefs.h <<\_ACEOF
#define SYS_ERRLIST_DEF 1
_ACEOF
fi
rm -f conftest*
{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
if test "${ac_cv_c_const+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 ()
{
/* FIXME: Include the comments suggested by Paul. */
#ifndef __cplusplus
/* Ultrix mips cc rejects this. */
typedef int charset[2];
const charset cs;
/* SunOS 4.1.1 cc rejects this. */
char const *const *pcpcc;
char **ppc;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in
an arm of an if-expression whose if-part is not a constant
expression */
const char *g = "string";
pcpcc = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++pcpcc;
ppc = (char**) pcpcc;
pcpcc = (char const *const *) ppc;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
if (s) return 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
if (!foo) return 0;
}
return !cs[0] && !zero.x;
#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_const=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_c_const=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
$as_echo "$ac_cv_c_const" >&6; }
if test $ac_cv_c_const = no; then
cat >>confdefs.h <<\_ACEOF
#define const /**/
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
if test "${ac_cv_header_time+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
int
main ()
{
if ((struct tm *) 0)
return 0;
;
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_time=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_time=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
$as_echo "$ac_cv_header_time" >&6; }
if test $ac_cv_header_time = yes; then
cat >>confdefs.h <<\_ACEOF
#define TIME_WITH_SYS_TIME 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
if test "${ac_cv_struct_tm+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
int
main ()
{
struct tm tm;
int *p = &tm.tm_sec;
return !p;
;
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_struct_tm=time.h
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_struct_tm=sys/time.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
$as_echo "$ac_cv_struct_tm" >&6; }
if test $ac_cv_struct_tm = sys/time.h; then
cat >>confdefs.h <<\_ACEOF
#define TM_IN_SYS_TIME 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking for main in -lm" >&5
$as_echo_n "checking for main in -lm... " >&6; }
if test "${ac_cv_lib_m_main+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. */
int
main ()
{
return main ();
;
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_main=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_m_main=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_main" >&5
$as_echo "$ac_cv_lib_m_main" >&6; }
if test "x$ac_cv_lib_m_main" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBM 1
_ACEOF
LIBS="-lm $LIBS"
fi
{ $as_echo "$as_me:$LINENO: checking for main in -lX11" >&5
$as_echo_n "checking for main in -lX11... " >&6; }
if test "${ac_cv_lib_X11_main+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lX11 $LIBS"
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 main ();
;
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_X11_main=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_X11_main=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_X11_main" >&5
$as_echo "$ac_cv_lib_X11_main" >&6; }
if test "x$ac_cv_lib_X11_main" = x""yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBX11 1
_ACEOF
LIBS="-lX11 $LIBS"
fi
{ $as_echo "$as_me:$LINENO: checking for X" >&5
$as_echo_n "checking for X... " >&6; }
# Check whether --with-x was given.
if test "${with_x+set}" = set; then
withval=$with_x;
fi
# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
if test "x$with_x" = xno; then
# The user explicitly disabled X.
have_x=disabled
else
case $x_includes,$x_libraries in #(
*\'*) { { $as_echo "$as_me:$LINENO: error: cannot use X directory names containing '" >&5
$as_echo "$as_me: error: cannot use X directory names containing '" >&2;}
{ (exit 1); exit 1; }; };; #(
*,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
$as_echo_n "(cached) " >&6
else
# One or both of the vars are not set, and there is no cached value.
ac_x_includes=no ac_x_libraries=no
rm -f -r conftest.dir
if mkdir conftest.dir; then
cd conftest.dir
cat >Imakefile <<'_ACEOF'
incroot:
@echo incroot='${INCROOT}'
usrlibdir:
@echo usrlibdir='${USRLIBDIR}'
libdir:
@echo libdir='${LIBDIR}'
_ACEOF
if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
for ac_var in incroot usrlibdir libdir; do
eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
done
# Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
for ac_extension in a so sl dylib la dll; do
if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
test -f "$ac_im_libdir/libX11.$ac_extension"; then
ac_im_usrlibdir=$ac_im_libdir; break
fi
done
# Screen out bogus values from the imake configuration. They are
# bogus both because they are the default anyway, and because
# using them would break gcc on systems where it needs fixed includes.
case $ac_im_incroot in
/usr/include) ac_x_includes= ;;
*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
esac
case $ac_im_usrlibdir in
/usr/lib | /usr/lib64 | /lib | /lib64) ;;
*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
esac
fi
cd ..
rm -f -r conftest.dir
fi
# Standard set of common directories for X headers.
# Check X11 before X11Rn because it is often a symlink to the current release.
ac_x_header_dirs='
/usr/X11/include
/usr/X11R6/include
/usr/X11R5/include
/usr/X11R4/include
/usr/include/X11
/usr/include/X11R6
/usr/include/X11R5
/usr/include/X11R4
/usr/local/X11/include
/usr/local/X11R6/include
/usr/local/X11R5/include
/usr/local/X11R4/include
/usr/local/include/X11
/usr/local/include/X11R6
/usr/local/include/X11R5
/usr/local/include/X11R4
/usr/X386/include
/usr/x386/include
/usr/XFree86/include/X11
/usr/include
/usr/local/include
/usr/unsupported/include
/usr/athena/include
/usr/local/x11r5/include
/usr/lpp/Xamples/include
/usr/openwin/include
/usr/openwin/share/include'
if test "$ac_x_includes" = no; then
# Guess where to find include files, by looking for Xlib.h.
# First, try using that file with no special directory specified.
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
# We can compile using X headers with no special include directory.
ac_x_includes=
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
for ac_dir in $ac_x_header_dirs; do
if test -r "$ac_dir/X11/Xlib.h"; then
ac_x_includes=$ac_dir
break
fi
done
fi
rm -f conftest.err conftest.$ac_ext
fi # $ac_x_includes = no
if test "$ac_x_libraries" = no; then
# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS=$LIBS
LIBS="-lX11 $LIBS"
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 ()
{
XrmInitialize ()
;
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
LIBS=$ac_save_LIBS
# We can link X programs with no special library path.
ac_x_libraries=
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LIBS=$ac_save_LIBS
for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
do
# Don't even attempt the hair of trying to link an X program!
for ac_extension in a so sl dylib la dll; do
if test -r "$ac_dir/libX11.$ac_extension"; then
ac_x_libraries=$ac_dir
break 2
fi
done
done
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi # $ac_x_libraries = no
case $ac_x_includes,$ac_x_libraries in #(
no,* | *,no | *\'*)
# Didn't find X, or a directory has "'" in its name.
ac_cv_have_x="have_x=no";; #(
*)
# Record where we found X for the cache.
ac_cv_have_x="have_x=yes\
ac_x_includes='$ac_x_includes'\
ac_x_libraries='$ac_x_libraries'"
esac
fi
;; #(
*) have_x=yes;;
esac
eval "$ac_cv_have_x"
fi # $with_x != no
if test "$have_x" != yes; then
{ $as_echo "$as_me:$LINENO: result: $have_x" >&5
$as_echo "$have_x" >&6; }
no_x=yes
else
# If each of the values was on the command line, it overrides each guess.
test "x$x_includes" = xNONE && x_includes=$ac_x_includes
test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
# Update the cache value to reflect the command line values.
ac_cv_have_x="have_x=yes\
ac_x_includes='$x_includes'\
ac_x_libraries='$x_libraries'"
{ $as_echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
fi
if test "$no_x" = yes; then
# Not all programs may use this symbol, but it does not hurt to define it.
cat >>confdefs.h <<\_ACEOF
#define X_DISPLAY_MISSING 1
_ACEOF
X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
else
if test -n "$x_includes"; then
X_CFLAGS="$X_CFLAGS -I$x_includes"
fi
# It would also be nice to do this for all -L options, not just this one.
if test -n "$x_libraries"; then
X_LIBS="$X_LIBS -L$x_libraries"
# For Solaris; some versions of Sun CC require a space after -R and
# others require no space. Words are not sufficient . . . .
{ $as_echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5
$as_echo_n "checking whether -R must be followed by a space... " >&6; }
ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
ac_xsave_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
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 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: no" >&5
$as_echo "no" >&6; }
X_LIBS="$X_LIBS -R$x_libraries"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LIBS="$ac_xsave_LIBS -R $x_libraries"
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 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; }
X_LIBS="$X_LIBS -R $x_libraries"
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: neither works" >&5
$as_echo "neither works" >&6; }
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
ac_c_werror_flag=$ac_xsave_c_werror_flag
LIBS=$ac_xsave_LIBS
fi
# Check for system-dependent libraries X programs must link with.
# Do this before checking for the system-independent R6 libraries
# (-lICE), since we may need -lsocket or whatever for X linking.
if test "$ISC" = yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
else
# Martyn Johnson says this is needed for Ultrix, if the X
# libraries were built with DECnet support. And Karl Berry says
# the Alpha needs dnet_stub (dnet does not exist).
ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
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 XOpenDisplay ();
int
main ()
{
return XOpenDisplay ();
;
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
:
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5
$as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; }
if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldnet $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 dnet_ntoa ();
int
main ()
{
return dnet_ntoa ();
;
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_dnet_dnet_ntoa=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_dnet_dnet_ntoa=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_dnet_dnet_ntoa" >&5
$as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
fi
if test $ac_cv_lib_dnet_dnet_ntoa = no; then
{ $as_echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
$as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; }
if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldnet_stub $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 dnet_ntoa ();
int
main ()
{
return dnet_ntoa ();
;
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_dnet_stub_dnet_ntoa=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_dnet_stub_dnet_ntoa=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_dnet_stub_dnet_ntoa" >&5
$as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; }
if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
fi
fi
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_xsave_LIBS"
# msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
# to get the SysV transport functions.
# Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
# needs -lnsl.
# The nsl library prevents programs from opening the X display
# on Irix 5.2, according to T.E. Dickey.
# The functions gethostbyname, getservbyname, and inet_addr are
# in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
{ $as_echo "$as_me:$LINENO: checking for gethostbyname" >&5
$as_echo_n "checking for gethostbyname... " >&6; }
if test "${ac_cv_func_gethostbyname+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. */
/* Define gethostbyname to an innocuous variant, in case declares gethostbyname.
For example, HP-UX 11i declares gettimeofday. */
#define gethostbyname innocuous_gethostbyname
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef gethostbyname
/* 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 gethostbyname ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_gethostbyname || defined __stub___gethostbyname
choke me
#endif
int
main ()
{
return gethostbyname ();
;
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_func_gethostbyname=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_gethostbyname=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
$as_echo "$ac_cv_func_gethostbyname" >&6; }
if test $ac_cv_func_gethostbyname = no; then
{ $as_echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $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 gethostbyname ();
int
main ()
{
return gethostbyname ();
;
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_nsl_gethostbyname=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_nsl_gethostbyname=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_nsl_gethostbyname" >&5
$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
fi
if test $ac_cv_lib_nsl_gethostbyname = no; then
{ $as_echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
$as_echo_n "checking for gethostbyname in -lbsd... " >&6; }
if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lbsd $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 gethostbyname ();
int
main ()
{
return gethostbyname ();
;
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_bsd_gethostbyname=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_bsd_gethostbyname=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_bsd_gethostbyname" >&5
$as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; }
if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
fi
fi
fi
# lieder@skyler.mavd.honeywell.com says without -lsocket,
# socket/setsockopt and other routines are undefined under SCO ODT
# 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
# on later versions), says Simon Leinen: it contains gethostby*
# variants that don't use the name server (or something). -lsocket
# must be given before -lnsl if both are needed. We assume that
# if connect needs -lnsl, so does gethostbyname.
{ $as_echo "$as_me:$LINENO: checking for connect" >&5
$as_echo_n "checking for connect... " >&6; }
if test "${ac_cv_func_connect+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. */
/* Define connect to an innocuous variant, in case declares connect.
For example, HP-UX 11i declares gettimeofday. */
#define connect innocuous_connect
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char connect (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef connect
/* 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 connect ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_connect || defined __stub___connect
choke me
#endif
int
main ()
{
return connect ();
;
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_func_connect=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_connect=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5
$as_echo "$ac_cv_func_connect" >&6; }
if test $ac_cv_func_connect = no; then
{ $as_echo "$as_me:$LINENO: checking for connect in -lsocket" >&5
$as_echo_n "checking for connect in -lsocket... " >&6; }
if test "${ac_cv_lib_socket_connect+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $X_EXTRA_LIBS $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 connect ();
int
main ()
{
return connect ();
;
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_socket_connect=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_socket_connect=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_socket_connect" >&5
$as_echo "$ac_cv_lib_socket_connect" >&6; }
if test "x$ac_cv_lib_socket_connect" = x""yes; then
X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
fi
fi
# Guillermo Gomez says -lposix is necessary on A/UX.
{ $as_echo "$as_me:$LINENO: checking for remove" >&5
$as_echo_n "checking for remove... " >&6; }
if test "${ac_cv_func_remove+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. */
/* Define remove to an innocuous variant, in case declares remove.
For example, HP-UX 11i declares gettimeofday. */
#define remove innocuous_remove
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char remove (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef remove
/* 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 remove ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_remove || defined __stub___remove
choke me
#endif
int
main ()
{
return remove ();
;
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_func_remove=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_remove=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5
$as_echo "$ac_cv_func_remove" >&6; }
if test $ac_cv_func_remove = no; then
{ $as_echo "$as_me:$LINENO: checking for remove in -lposix" >&5
$as_echo_n "checking for remove in -lposix... " >&6; }
if test "${ac_cv_lib_posix_remove+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lposix $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 remove ();
int
main ()
{
return remove ();
;
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_posix_remove=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_posix_remove=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_posix_remove" >&5
$as_echo "$ac_cv_lib_posix_remove" >&6; }
if test "x$ac_cv_lib_posix_remove" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
fi
fi
# BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
{ $as_echo "$as_me:$LINENO: checking for shmat" >&5
$as_echo_n "checking for shmat... " >&6; }
if test "${ac_cv_func_shmat+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. */
/* Define shmat to an innocuous variant, in case declares shmat.
For example, HP-UX 11i declares gettimeofday. */
#define shmat innocuous_shmat
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char shmat (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef shmat
/* 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 shmat ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_shmat || defined __stub___shmat
choke me
#endif
int
main ()
{
return shmat ();
;
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_func_shmat=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_shmat=no
fi
rm -rf conftest.dSYM
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5
$as_echo "$ac_cv_func_shmat" >&6; }
if test $ac_cv_func_shmat = no; then
{ $as_echo "$as_me:$LINENO: checking for shmat in -lipc" >&5
$as_echo_n "checking for shmat in -lipc... " >&6; }
if test "${ac_cv_lib_ipc_shmat+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lipc $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 shmat ();
int
main ()
{
return shmat ();
;
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_ipc_shmat=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_ipc_shmat=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_ipc_shmat" >&5
$as_echo "$ac_cv_lib_ipc_shmat" >&6; }
if test "x$ac_cv_lib_ipc_shmat" = x""yes; then
X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
fi
fi
fi
# Check for libraries that X11R6 Xt/Xaw programs need.
ac_save_LDFLAGS=$LDFLAGS
test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
# SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
# check for ICE first), but we must link in the order -lSM -lICE or
# we get undefined symbols. So assume we have SM if we have ICE.
# These have to be linked with before -lX11, unlike the other
# libraries we check for below, so use a different variable.
# John Interrante, Karl Berry
{ $as_echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5
$as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; }
if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lICE $X_EXTRA_LIBS $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 IceConnectionNumber ();
int
main ()
{
return IceConnectionNumber ();
;
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_ICE_IceConnectionNumber=yes
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_ICE_IceConnectionNumber=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_ICE_IceConnectionNumber" >&5
$as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; }
if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then
X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
fi
LDFLAGS=$ac_save_LDFLAGS
fi
if test $WIN32 = yes; then
LIBS="-lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid \
-lodbc32 -lversion -lcomctl32 -lwsock32 -lws2_32 $LIBS"
else
LIBS="-L$ac_x_libraries -lX11 $LIBS"
fi
CFLAGS="$CFLAGS -DUSE_OLD_MALLOC"
# 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
if test "${ac_cv_header_sys_ioctl_h+set}" = set; then
{ $as_echo "$as_me:$LINENO: checking for sys/ioctl.h" >&5
$as_echo_n "checking for sys/ioctl.h... " >&6; }
if test "${ac_cv_header_sys_ioctl_h+set}" = set; then
$as_echo_n "(cached) " >&6
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_ioctl_h" >&5
$as_echo "$ac_cv_header_sys_ioctl_h" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:$LINENO: checking sys/ioctl.h usability" >&5
$as_echo_n "checking sys/ioctl.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 sys/ioctl.h presence" >&5
$as_echo_n "checking sys/ioctl.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: sys/ioctl.h: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: proceeding with the preprocessor's result" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: proceeding with the preprocessor's result" >&2;}
{ $as_echo "$as_me:$LINENO: WARNING: sys/ioctl.h: in the future, the compiler will take precedence" >&5
$as_echo "$as_me: WARNING: sys/ioctl.h: in the future, the compiler will take precedence" >&2;}
;;
esac
{ $as_echo "$as_me:$LINENO: checking for sys/ioctl.h" >&5
$as_echo_n "checking for sys/ioctl.h... " >&6; }
if test "${ac_cv_header_sys_ioctl_h+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_cv_header_sys_ioctl_h=$ac_header_preproc
fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_ioctl_h" >&5
$as_echo "$ac_cv_header_sys_ioctl_h" >&6; }
fi
if test "x$ac_cv_header_sys_ioctl_h" = x""yes; then
CFLAGS="$CFLAGS -DHAVE_SYS_IOCTL_H"
fi
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
pkg="msw_package/Makefile"
fi
if test $WIN32 = no; then
xmfb="src/xmfb/Makefile"
fi
ac_config_files="$ac_config_files src/bin/Makefile src/cd/Makefile src/convert/Makefile src/ginterf/Makefile src/help/Makefile src/kic/Makefile $xmfb $pkg"
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}'
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
#
# If the first sed substitution is executed (which looks for macros that
# take arguments), then branch to the quote section. Otherwise,
# look for a macro that doesn't take arguments.
ac_script='
:mline
/\\$/{
N
s,\\\n,,
b mline
}
t clear
:clear
s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
t quote
s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
t quote
b any
:quote
s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\[/\\&/g
s/\]/\\&/g
s/\$/$$/g
H
:any
${
g
s/^\n//
s/\n/ /g
p
}
'
DEFS=`sed -n "$ac_script" confdefs.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
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
_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
Configuration files:
$config_files
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;;
--he | --h | --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
"src/bin/Makefile") CONFIG_FILES="$CONFIG_FILES src/bin/Makefile" ;;
"src/cd/Makefile") CONFIG_FILES="$CONFIG_FILES src/cd/Makefile" ;;
"src/convert/Makefile") CONFIG_FILES="$CONFIG_FILES src/convert/Makefile" ;;
"src/ginterf/Makefile") CONFIG_FILES="$CONFIG_FILES src/ginterf/Makefile" ;;
"src/help/Makefile") CONFIG_FILES="$CONFIG_FILES src/help/Makefile" ;;
"src/kic/Makefile") CONFIG_FILES="$CONFIG_FILES src/kic/Makefile" ;;
"$xmfb") CONFIG_FILES="$CONFIG_FILES $xmfb" ;;
"$pkg") CONFIG_FILES="$CONFIG_FILES $pkg" ;;
*) { { $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
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"
eval set X " :F $CONFIG_FILES "
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; }; }
;;
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
kic-2.4c/install-sh 0000755 0000764 0000764 00000033255 12427243603 013733 0 ustar stevew stevew #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
kic-2.4c/configure.in 0000644 0000764 0000764 00000006261 12427443175 014243 0 ustar stevew stevew dnl Configure input script for kic
dnl Process this file with autoconf to produce a configure script.
dnl Copyright (C) Whiteley Research Inc, 2002
dnl $Id$
dnl *** Initialize
AC_INIT(src/bin/kicmain.c)
VERSION="2.4c"
DATE=`/bin/date`
AC_SUBST(prefix)
AC_SUBST(VERSION)
AC_SUBST(DATE)
dnl *** Check build environment
AC_PROG_CC
dnl text for MS Windows environmnet
AC_CYGWIN
AC_MINGW32
WIN32=no
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
dnl *** Use native graphics in Windows. We could alternatively build
dnl *** an X version, at least under Cygwin.
WIN32=yes
fi
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
if test $WIN32 = yes; then
NTSUFFIX=".exe"
FILTER="|sed -e s/
//"
RESOURCE="kicrc.o"
NOCONS="-mwindows"
INSTALL_USER="-o Administrator -g Everyone"
elif test x$CYGWIN = x"yes"; then
NTSUFFIX=".exe"
INSTALL_USER="-o Administrator -g Everyone"
fi
fi
AC_SUBST(NTSUFFIX)
AC_SUBST(FILTER)
AC_SUBST(RESOURCE)
AC_SUBST(NOCONS)
AC_PROG_MAKE_SET
AC_PROG_RANLIB
if test -f /bin/arch; then
if test "`/bin/arch`" = "sun4"; then
SUN4=yes
fi
fi
if test "$GCC" = yes; then
DEPEND_PROG="cc -MM"
if test x$SUN4 = x"yes"; then
dnl Solaris 8 with gcc: the ctype macros use arrays, which
dnl cause "char subscript" warnings, so these are turned off.
dnl The __EXTENSIONS__ macro is needed to make certain function
dnl prototypes visible
SUN4FLAGS="-Wno-implicit -Wno-char-subscripts -D__EXTENSIONS__"
CFLAGS="-O -Wall $SUN4FLAGS"
else
CFLAGS="-O -Wall"
CFLAGSG="-O -g -Wall"
fi
else
DEPEND_PROG="cc -M"
CFLAGS="-O"
fi
if test -x /usr/ucb/install; then
INSTALL="/usr/ucb/install"
else
INSTALL="install"
fi
if test x"$INSTALL_USER" = x; then
if test "`uname`" = Linux; then
INSTALL_USER="-o root -g root"
else
INSTALL_USER="-o root -g bin"
fi
fi
AC_SUBST(CFLAGS)
AC_SUBST(DEPEND_PROG)
AC_SUBST(INSTALL)
AC_SUBST(INSTALL_USER)
if test $WIN32 = no; then
MFB="../xmfb.a"
fi
AC_SUBST(MFB)
dnl *** Checks for header files
AC_HEADER_STDC
AC_EGREP_HEADER(sys_errlist, stdio.h, AC_DEFINE(SYS_ERRLIST_DEF))
dnl *** Checks for typedefs, structures, and compiler characteristics
AC_C_CONST
AC_HEADER_TIME
AC_STRUCT_TM
dnl *** Check for needed libraries
dnl reverse order of link, order is important
AC_CHECK_LIB(m, main)
AC_CHECK_LIB(X11, main)
AC_PATH_XTRA
if test $WIN32 = yes; then
LIBS="-lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid \
-lodbc32 -lversion -lcomctl32 -lwsock32 -lws2_32 $LIBS"
else
LIBS="-L$ac_x_libraries -lX11 $LIBS"
fi
CFLAGS="$CFLAGS -DUSE_OLD_MALLOC"
AC_CHECK_HEADER(sys/ioctl.h, CFLAGS="$CFLAGS -DHAVE_SYS_IOCTL_H")
dnl AC_CHECK_FUNC(strlwr, CFLAGS="$CFLAGS -DHAVE_STRLWR")
dnl AC_CHECK_FUNC(stricmp, CFLAGS="$CFLAGS -DHAVE_STRICMP")
dnl *** Perform subsitutions and create headers
if test x$MINGW32 = xyes -o x$CYGWIN = xyes; then
pkg="msw_package/Makefile"
fi
if test $WIN32 = no; then
xmfb="src/xmfb/Makefile"
fi
AC_OUTPUT(
src/bin/Makefile
src/cd/Makefile
src/convert/Makefile
src/ginterf/Makefile
src/help/Makefile
src/kic/Makefile
$xmfb
$pkg
)
kic-2.4c/src/ 0000755 0000764 0000764 00000000000 12427446157 012517 5 ustar stevew stevew kic-2.4c/src/cd/ 0000755 0000764 0000764 00000000000 12427446157 013105 5 ustar stevew stevew kic-2.4c/src/cd/parser.c 0000644 0000764 0000764 00000051710 07525554174 014553 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Fast CIF file parser.
*
* It is easy to use it to write programs that traverse a CIF file.
*
* Examples follows.
* 1. A program that translates CIF to STREAM.
* 2. A pattern factoring program for PG tape generation.
* See TI's PFP.
* 3. A statistics generation program.
* 4. A program that extracts each symbol, generates a name for it, and
* writes it to a file. See the CD package.
* 5. A program that builds a binary representation of the CIF file that can
* then be edited via procedure calls and then written back to the CIF
* file. See the CD package.
*
* Here's how you use it.
*
* First, you include the files actions.c and parser.h.
* Then you invoke PCIF(CIFFileName,StatusString,StatusInt).
* Each time the parser recognizes a CIF command, it invokes an action routine.
* You should fill in the action routines in the file Actions.c.
* Each action routine name is prefixed by A.
*
* Each parser routine and global variable name is prefixed by P.
* StatusInt == PFAILED if the parse failed and an error message along with
* about where in the CIF file the error is in the StatusString.
* Else StatusInt == PSUCCEEDED and StatusString == "".
*
*/
#include "prefix.h"
#include "cd.h"
#include "parser.h"
FILE *PCIFFileDesc;
char PStatus[80*3+1];
int PInt;
int PChar;
char PString[PSTRINGSIZE];
int PReturned;
void
PCIF(CIFFileName,StatusString,StatusInt)
char *CIFFileName,**StatusString;
int *StatusInt;
{
PStatus[0] = EOS;
*StatusString = PStatus;
if ((PCIFFileDesc = POpen(CIFFileName,"r",(char *)NULL,(char **)NULL))
== NULL) {
PChar = EOF;
PError("Can't open CIF file.");
*StatusInt = PFAILED;
return;
}
loop{
PReturned = PCharacter(PSTRIPWHITESPACE2,PDONTFAILONEOF);
if (PReturned == PFAILED) {
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
elif (PChar == 'D') {
PReturned = PCharacter(PSTRIPWHITESPACE2,PFAILONEOF);
if (PReturned == PFAILED) {
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
elif (PChar == 'S') {
if (PSymbol() == PFAILED) {
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
}
elif (PChar == 'D') {
if (PDeleteSymbol() == PFAILED) {
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
}
}
elif (PChar == 'E') {
*StatusInt = PEnd();
return;
}
elif ((PReturned = PPrimitiveCommand()) == PFAILED) {
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
elif (PReturned == PNOTAPPLICABLE) {
PError("Can't understand next command.");
fclose(PCIFFileDesc);
*StatusInt = PFAILED;
return;
}
}
}
int
PPrimitiveCommand()
{
if (PChar == 'P')
return (PPolygon());
elif (PChar == 'B')
return (PBox());
elif (PChar == 'W')
return (PWire());
elif (PChar == 'L')
return (PLayer());
elif (PChar == 'C')
return (PCall());
elif (PChar == 'R')
return (PRoundFlash());
elif ('0' <= PChar And PChar <= '9')
return (PUserExtension());
elif (PChar == '(')
return (PComment());
elif (PChar == ';')
return (PSUCCEEDED);
else
return (PNOTAPPLICABLE);
}
int
PEnd()
{
AEnd();
fclose(PCIFFileDesc);
return (PSUCCEEDED);
}
int
PSymbol()
{
char For;
int SymbolNum;
int A,B;
#ifdef TRACE
fprintf(stderr," ENTERING PSYMBOL\n");
#endif
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
SymbolNum = PInt;
A = B = 1;
/* look for scaling factor */
for (For = '0'; For <= '9'; ++For) {
PReturned = PLookAhead(PSTRIPWHITESPACE3,For);
if (PReturned == PFAILED)
return (PFAILED);
if (PChar == For) {
ungetc(For,PCIFFileDesc);
if (PPoint(&A,&B) == PFAILED)
return (PFAILED);
break;
}
}
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
if (ABeginSymbol((int)SymbolNum,(int)A,(int)B) == PFAILED) {
PErrorCD();
return (PFAILED);
}
if (PReturned == PFAILED)
return (PFAILED);
loop{
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
if ((PReturned = PPrimitiveCommand()) == PFAILED)
return (PFAILED);
elif (PReturned == PNOTAPPLICABLE)
break;
}
if (PChar != 'D')
return (PFAILED);
PReturned = PCharacter(PSTRIPWHITESPACE2,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
if (PChar != 'F')
return (PFAILED);
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
AEndSymbol();
return (PSUCCEEDED);
}
int
PDeleteSymbol()
{
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
else{
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
ADeleteSymbol(PInt);
return (PSUCCEEDED);
}
}
int
PCall()
{
int SymbolNum;
int X,Y;
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
SymbolNum = PInt;
if (ABeginCall(SymbolNum) == PFAILED) {
PErrorCD();
return (PFAILED);
}
loop{
PReturned = PCharacter(PSTRIPWHITESPACE2,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == 'T') {
if (PPoint(&X,&Y) == PFAILED) {
PError("Can't parse translation transform.");
return (PFAILED);
}
elif (AT(CDTRANSLATE,X,Y) == PFAILED) {
PErrorCD();
return (PFAILED);
}
}
elif (PChar == 'M') {
PReturned = PCharacter(PSTRIPWHITESPACE2,PFAILONEOF);
if (PReturned == PFAILED) {
PErrorEOF();
return (PFAILED);
}
elif (PChar == 'X') {
if (AT(CDMIRRORX,X,Y) == PFAILED) {
PErrorCD();
return (PFAILED);
}
}
elif (PChar == 'Y') {
if (AT(CDMIRRORY,X,Y) == PFAILED) {
PErrorCD();
return (PFAILED);
}
}
else{
PError("Can't parse mirror transform.");
return (PFAILED);
}
}
elif (PChar == 'R') {
if (PPoint(&X,&Y) == PFAILED) {
PError("Can't parse rotation transform.");
return (PFAILED);
}
if (AT(CDROTATE,X,Y) == PFAILED) {
PErrorCD();
return (PFAILED);
}
}
elif (PChar == ';')
break;
else{
PError("Can't parse transformation.");
return (PFAILED);
}
}
if (AEndCall() == PFAILED) {
PErrorCD();
return (PFAILED);
}
return (PSUCCEEDED);
}
int
PPolygon()
{
struct p *Path;
#ifdef TRACE
fprintf(stderr," ENTERING PPOLYGON\n");
#endif
if (PPath(&Path) == PFAILED)
return (PFAILED);
#ifdef TRACE
fprintf(stderr," LEAVING PPATH\n");
#endif
if (APolygon(Path) == PFAILED) {
PErrorCD();
return (PFAILED);
}
#ifdef TRACE
fprintf(stderr," LEAVING PPOLYGON\n");
#endif
return (PSUCCEEDED);
}
int
PBox()
{
int Length,Width,X,Y;
int XDirection,YDirection;
XDirection = 1L;
YDirection = 0L;
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
Length = PInt;
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
Width = PInt;
if (PPoint(&X,&Y) == PFAILED)
return (PFAILED);
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar != ';') {
if (PPoint(&XDirection,&YDirection) == PFAILED)
return (PFAILED);
PReturned = PLookForSemi();
if (PReturned == PFAILED Or PChar != ';') {
PErrorNoSemicolon();
return (PFAILED);
}
}
if (ABox(Length,Width,X,Y,(int)XDirection,(int)YDirection) == PFAILED) {
PErrorCD();
return (PFAILED);
}
return (PSUCCEEDED);
}
int
PRoundFlash()
{
int Width,X,Y;
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
Width = PInt;
if (PPoint(&X,&Y) == PFAILED)
return (PFAILED);
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar != ';') {
PErrorNoSemicolon();
return (PFAILED);
}
if (ARoundFlash(Width,X,Y) == PFAILED) {
PErrorCD();
return (PFAILED);
}
return (PSUCCEEDED);
}
int
PWire()
{
int Width;
struct p *Path;
#ifdef TRACE
fprintf(stderr," ENTERING PWIRE\n");
#endif
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
Width = PInt;
#ifdef TRACE
fprintf(stderr," ENTERING PPATH\n");
#endif
if (PPath(&Path) == PFAILED)
return (PFAILED);
if (AWire(Width,Path) == PFAILED) {
PErrorCD();
return (PFAILED);
}
return (PSUCCEEDED);
}
int
PPath(Path)
struct p **Path;
{
int X,Y;
struct p *Pair;
*Path = NULL;
loop{
PReturned = PLookForSemi();
#ifdef TRACE
if (PReturned == PFAILED)
fprintf(stderr," PPATH FAILED AFTER PLOOKAHEAD\n");
#endif
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';')
break;
else{
if (PPoint(&X,&Y) == PFAILED)
return (PFAILED);
#ifdef TRACE
fprintf(stderr," PPATH POINT %ld, %ld\n",X,Y);
#endif
if ((Pair = alloc(p)) == NULL) {
PError("Out of memory.");
return (PFAILED);
}
Pair->pSucc = *Path;
Pair->pX = X;
Pair->pY = Y;
*Path = Pair;
}
}
return (PSUCCEEDED);
}
int
PPoint(X,Y)
int *X,*Y;
{
/* it is assumed that a LookAhead is done prior to calling PPoint */
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
*X = PInt;
PReturned = PLookForSemi();
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
PError("Bad X,Y path element.");
return (PFAILED);
}
PReturned = PInteger(PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
*Y = PInt;
return (PSUCCEEDED);
}
int
PLayer()
{
char Technology,Mask[4];
int i;
Mask[0] = Mask[1] = Mask[2] = ' '; Mask[3] = '\0';
/* SRW ** used to be STRIPWHITESPACE2, let in lower case */
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
if (PChar == ';') {
PError("At least one character expected after L in layer command.");
return (PFAILED);
}
Technology = PChar;
for (i=0; i<3; ++i) {
if ((PChar = getc(PCIFFileDesc)) == EOF) {
PErrorEOF();
return (PFAILED);
}
elif (PChar == ';') {
if (ALayer(Technology,Mask) == PSUCCEEDED)
return (PSUCCEEDED);
else{
PErrorUndefinedLayer(Technology,Mask);
return (PFAILED);
}
}
Mask[i] = PChar;
/* check for valid CIF layer name character */
/* SRW ** what the hell, let in lower case,
* KIC can handle it.
*/
if (Not ((PChar >= '0' And PChar <= '9') Or
(PChar >= 'A' And PChar <= 'Z') Or
(PChar >= 'a' And PChar <= 'z'))) {
PErrorUndefinedLayer(Technology,Mask);
return (PFAILED);
}
}
/* clear the semicolon */
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
if (ALayer(Technology,Mask) == PSUCCEEDED)
return (PSUCCEEDED);
else{
PErrorUndefinedLayer(Technology,Mask);
return (PFAILED);
}
}
PError("Illegal CIF layer name with > 4 characters discovered.");
return (PFAILED);
}
int
PUserExtension()
{
char Digit;
int Int1;
Digit = PChar;
Int1 = 0;
loop{
PReturned = PCharacter(PLEAVEWHITESPACE,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
PString[Int1] = EOS;
if (AUserExtension(Digit,PString) == PFAILED) {
PErrorCD();
return (PFAILED);
}
#ifdef TRACE
fprintf(stderr,"PString = %s\n",PString);
#endif
return (PSUCCEEDED);
}
elif (Int1 == PSTRINGSIZE) {
PError("User extension command longer than 1920 characters.");
return (PFAILED);
}
else PString[Int1++] = PChar;
}
}
int
PComment()
{
int Int1;
int parenctr; /* keep track of and ignore nested parens */
Int1 = 0;
parenctr = 1;
loop{
PReturned = PCharacter(PLEAVEWHITESPACE,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ')' && !--parenctr) {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
PString[Int1] = EOS;
AComment(PString);
return (PSUCCEEDED);
}
elif (Int1 == PSTRINGSIZE) {
PError("Comment command longer than 1920 characters.");
return (PFAILED);
}
else{
PErrorNoSemicolon();
return (PFAILED);
}
}
else {
PString[Int1++] = PChar;
if (PChar == '(') parenctr++;
}
}
}
void
PError(PErrorMessage)
char *PErrorMessage;
{
int Int1;
for (Int1 = 0;Int1 < 20;++Int1) {
if (PChar == EOF)
break;
PReturned = PCharacter(PLEAVEWHITESPACE,PFAILONEOF);
if (PReturned == PFAILED)
break;
PString[Int1] = PChar;
}
PString[Int1] = EOS;
sprintf(PStatus,"%s Failed at around %s.",PErrorMessage,PString);
#ifdef TRACE
fprintf(stderr,"%s\n",PErrorMessage);
#endif
}
void
PErrorEOF()
{
PError("Early EOF.");
}
void
PErrorNoSemicolon()
{
PError("; expected and not found.");
}
void
PErrorUndefinedLayer(Tech,Mask)
char Tech,*Mask;
{
char buf[35];
sprintf(buf,"Undefined layer: %c%s. ",Tech,Mask);
PError(buf);
}
void
PErrorCD()
{
PError(CDStatusString);
}
/* the following functions used to be macros */
int
PCharacter(WhiteSpaceControl,EOFControl)
int WhiteSpaceControl,EOFControl;
{
int Returned;
Returned = PWhiteSpace(WhiteSpaceControl,EOFControl);
if (Returned != PFAILED) {
PChar = getc(PCIFFileDesc);
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
}
}
return (Returned);
}
int
PWhiteSpace(WhiteSpaceControl,EOFControl)
int WhiteSpaceControl,EOFControl;
{
int Returned = PSUCCEEDED;
if (WhiteSpaceControl == PSTRIPWHITESPACE1) {
while((PChar = getc(PCIFFileDesc)) == ' ' Or PChar == '\t' Or
PChar == '\n' Or PChar == ',') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
}
elif (WhiteSpaceControl == PSTRIPWHITESPACE2) {
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '('
And PChar != ')' And (PChar < 'A' Or PChar > 'Z')
And (PChar < '0' Or PChar > '9') And PChar != ';') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
}
elif (WhiteSpaceControl == PSTRIPWHITESPACE3) {
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '('
And PChar != ')' And (PChar< '0' Or PChar > '9') And
PChar != ';') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
}
return (Returned);
}
int
PWhiteSpace1(EOFControl)
int EOFControl;
{
int Returned = PSUCCEEDED;
while((PChar = getc(PCIFFileDesc)) == ' ' Or PChar == '\t' Or
PChar == '\n' Or PChar == ',') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
return (Returned);
}
int
PWhiteSpace2(EOFControl)
int EOFControl;
{
int Returned = PSUCCEEDED;
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '('
And PChar != ')' And (PChar < 'A' Or PChar > 'Z')
And (PChar < '0' Or PChar > '9') And PChar != ';') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
return (Returned);
}
int
PWhiteSpace3(EOFControl)
int EOFControl;
{
int Returned = PSUCCEEDED;
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '('
And PChar != ')' And (PChar< '0' Or PChar > '9') And
PChar != ';') {
if (PChar == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PErrorEOF();
Returned = PFAILED;
}
break;
}
}
ungetc((char)PChar,PCIFFileDesc);
return (Returned);
}
int
PLookAhead(WhiteSpaceControl, For)
int WhiteSpaceControl, For;
{
int Returned;
Returned = PCharacter(WhiteSpaceControl,PFAILONEOF);
if (PChar != For && Returned != PFAILED)
ungetc((char)PChar,PCIFFileDesc);
return (Returned);
}
int
PLookForSemi()
{
int Returned;
Returned = PWhiteSpace3(PFAILONEOF);
if (Returned != PFAILED) {
PChar = getc(PCIFFileDesc);
if (PChar == EOF) {
PErrorEOF();
Returned = PFAILED;
}
elif (PChar != ';')
ungetc((char)PChar,PCIFFileDesc);
}
return (Returned);
}
int
PInteger(EOFControl)
int EOFControl;
{
int Returned;
loop{
PReturned = PWhiteSpace3(EOFControl);
if (PReturned == PFAILED) {
Returned = PFAILED;
break;
}
if ((PChar >= '0' And PChar <= '9') Or
(PChar == '-' Or PChar == '+')) {
/* read integer */
if ((fscanf(PCIFFileDesc,"%d",&PInt)) == EOF) {
if (EOFControl != PDONTFAILONEOF) {
PChar = EOF;
PErrorEOF();
Returned = PFAILED;
}
}
Returned = PSUCCEEDED;
break;
}
/* drop unwanted characters */
PReturned = PCharacter(PSTRIPWHITESPACE1,EOFControl);
if (PReturned == PFAILED) {
Returned = PFAILED;
break;
}
}
return (Returned);
}
kic-2.4c/src/cd/cd.c 0000644 0000764 0000764 00000321732 10261421164 013630 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* cd.c
*
*/
/* SRW - changes:
* 1. The DX and DY parameters used in CDCall(), CDBeginMakeCall() and
* elsewhere now refer to center-to-center spacing. Previously,
* edge to adjacent edge spacing was used. This creates problems
* when converting from GDSII, and also means that cell placement
* changes if cell size changes. Now, arrayed cells stay put if the
* BB's change. There may be compatibility problems with files
* which use the old scheme.
*
* 2. Hooks have been added for manipulation of the property strings
* for use by a schematic layout program. See the notes in
* CDBeginMakeCall() and CDEndMakeCall().
*
* 3. A routine for searching libraries has been added to POpen() in
* paths.c. See the note there concerning use.
*
* 4. A callback to a user supplied routine
* void CDLabelBB(struct o *Pointer,int *L,int *B, int *R, int *T)
* has been added. This routine returns the effective window of
* of the label, which depends on font size, etc, This routine
* is called by the generators, not CDBB(), as the BB is window
* dependent.
* 5. Labels are always put in the residual bin, so the generator
* can find them if the origin is out of the AOI.
*
* 6. CDInit() now calls malloc() to set up arrays for CDDesc. The
* return value is True if malloc fails, False if OK.
*
* Two routines need to be supplied externally for 2,3 above. If the
* features are not used, add the following to the external code:
* void UpdateProperties() {}
* FILE *OpenDevice() {return NULL;}
*
*/
/*======================================================================*
* *
* CCCCCC DDDDDDD *
* CC CC DD DD *
* CC CC DD DD *
* CC DD DD *
* CC DD DD *
* CC CC DD DD *
* CC CC DD DD *
* CCCCCC DDDDDDD *
* *
* *
* CD package code. *
* *
* *
*======================================================================*/
#include "prefix.h"
#include "cd.h"
#include "parser.h"
/* callbacks */
#if __STDC__
extern void CDLabelBB(struct o*,int*,int*,int*,int*);
extern void UpdateProperties(struct o*);
#else
extern void CDLabelBB();
extern void UpdateProperties();
#endif
struct bu *CDSymbolTable[CDNUMLAYERS+1];
struct d CDDesc;
struct l CDLayer[CDNUMLAYERS+1];
/*
* The following is the policy for handling errors in CD:
* When a routine encounters difficulty, it will set CDStatusInt
* to some identifying value, copy a diagnostic string into
* CDStatusString, and return a 'False'. Otherwise, the routine
* will return 'True' and not alter the value of CDStatusInt.
* Every routine that uses malloc will test the returned value
* and return Flase via CDError() if malloc fails.
*/
char *CDStatusString;
int CDStatusInt;
int CDBogusPoly;
#define LARGEBUFFERSIZE 400
/*===========================================================================*
* *
* III N N III TTTTT III A L III ZZZZZ A TTTTT III OOO N N *
* I NN N I T I A A L I Z A A T I O O NN N *
* I N N N I T I A A L I Z A A T I O O N N N *
* I N NN I T I AAAAA L I Z AAAAA T I O O N NN *
* III N N III T III A A LLLLL III ZZZZZ A A T III OOO N N *
* *
* RRRR OOO U U TTTTT III N N EEEEE SSSS *
* R R O O U U T I NN N E S *
* RRRR O O U U T I N N N EEE SSS *
* R R O O U U T I N NN E S *
* R R OOO UUU T III N N EEEEE SSSS *
* *
* *
* *
* CDInit() *
* CDPath(Path) *
* CDSetLayer(Layer,Tech,Mask) *
* CDDebug(Flag) *
* *
*===========================================================================*/
int
CDInit()
{
/*
* This must be the first CD routine called. It initializes
* the layer table, search path, symbol table, and transform
* stack. Returns True if error, False otherwise.
*/
static char CDDiagnosticString[LARGEBUFFERSIZE];
int Layer,Int1;
char *c;
for (Int1 = 0;Int1 < CDNUMLAYERS;++Int1)
CDSymbolTable[Int1] = NULL;
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
CDLayer[Layer].lTechnology = ' ';
CDLayer[Layer].lMask[0] = ' ';
CDLayer[Layer].lMask[1] = ' ';
CDLayer[Layer].lMask[2] = ' ';
CDLayer[Layer].lCDFrom = False;
}
c = PGetPath();
if (*c == '\0')
CDPath(".");
CDDebug(False);
CDDesc.dPrptyList = NULL;
CDDesc.dNumSymbolsAllocated = 0;
CDStatusString = CDDiagnosticString;
/* Vanilla operation. */
CDDesc.dControl = DCONTROLVANILLA;
/* Alocate arrays if not already done */
if (CDDesc.dSymTabNames == NULL) {
CDDesc.dSymTabNames = (char(*)[FILENAMESIZE])
malloc(CDNUMREMEMBER*FILENAMESIZE);
if (CDDesc.dSymTabNames == NULL) {
CDStatusInt = CDError(CDMALLOCFAILED);
return True;
}
CDDesc.dSymTabNumbers = (int *) malloc(CDNUMREMEMBER*sizeof(int));
if (CDDesc.dSymTabNumbers == NULL) {
CDStatusInt = CDError(CDMALLOCFAILED);
return True;
}
}
TInit();
return False;
}
int
CDPath(Path)
char *Path;
{
/*
* Sets search rules for symbol name resolution.
* Path is a list of directory names to search separated by blanks.
* csh-style names are understood.
* False is returned if the search path argument is invalid.
*/
if (Not PSetPath(Path))
return (CDError(CDBADPATH));
else
return (True);
}
void
CDSetLayer(Layer,Technology,Mask)
int Layer;
char Technology,Mask[];
{
/*
* This routine sets the layer Layer to the name 'TechnologyMask'.
* There is no returned value.
*/
CDLayer[Layer].lTechnology = Technology;
CDLayer[Layer].lMask[0] = Mask[0];
CDLayer[Layer].lMask[1] = Mask[1];
CDLayer[Layer].lMask[2] = Mask[2];
}
void
CDDebug(Debug)
int Debug;
{
/*
* If Debug is true, then CD will run in debug mode. There is
* no returned value.
*/
CDDesc.dDebug = Debug;
}
/*======================================================================*
* *
* SSSS Y Y M M BBBB OOO L *
* S Y Y MM MM B B O O L *
* SSS Y M M M BBBB O O L *
* S Y M M B B O O L *
* SSSS Y M M BBBB OOO LLLLL *
* *
* M M A N N A GGG EEEEE M M EEEEE N N TTTTT *
* MM MM A A NN N A A G E MM MM E NN N T *
* M M M A A N N N A A G GGG EEE M M M EEE N N N T *
* M M AAAAA N NN AAAAA G G E M M E N NN T *
* M M A A N N A A GGG EEEEE M M EEEEE N N T *
* *
* *
* *
* CDOpen(SymbolName,SymbolDesc,Access) *
* CDSymbol(SymbolName,SymbolDesc) *
* CDClose(SymbolDesc) *
* CDReflect(SymbolDesc) *
* CDPatchInstances(SymbolDesc,MasterName) *
* *
*======================================================================*/
int
CDOpen(SymbolName,SymbolDesc,Access)
char Access;
char *SymbolName;
struct s **SymbolDesc;
{
/*
* Open symbol and return desc for it.
*
* CDOpen returns False if parse failed or out of memory. When CDOpen
* returns, CDStatusInt assumes one of the following values:
* (FATAL)-CDPARSEFAILED if parser failed or out of memory.
* CDOLDSYMBOL if success and symbol already exists in memory.
* CDNEWSYMBOL if success and symbol is a new (empty) one.
* CDSUCCEEDED if no problem was encountered.
* If the return is fatal, CDStatusString contains a diagnostic message.
* Only CDPARSEFAILED is returned as a fatal error; this simplifies
* the diagnostic test.
*
* If Access == 'w', then create the cell if it doesn't already exist.
* In other words, open cell for writing. This solves the following
* problem: if the user tries to create an instance of a cell that
* doesn't exist, it will not be created in the database. If the cell
* was added to the database, a second attempt to place the cell that
* doesn't exist would succeed. Bad News!
*
* If Access == 'n', then create a new cell if it doesn't already exist
* in the database. Unlike Access == 'w', the cell will not be parsed
* if it exists in the current search path.
*/
char *StatusString;
char *cp;
FILE *FDesc;
struct bu *Bucket;
struct m *MasterListDesc;
struct s *MasterSymbolDesc;
struct s *NewDesc;
struct prpty PrptyCopy;
int Key,Int1,Int2;
int Layer;
int StatusInt;
unsigned size;
static int RecursionLevel = 0;
#ifdef DEBUGREFLECT
printf("Begin CDOpen of symbol %s.\n",SymbolName);
#endif
if (SymbolName == NULL Or *SymbolName == '\0') {
CDStatusInt = CDPARSEFAILED;
sprintf(CDStatusString,"Null symbol name encountered.");
return (False);
}
CDDesc.dControl = DCONTROLCDOPEN;
++RecursionLevel;
/* Is symbol open already? */
Key = 0;
*SymbolDesc = NULL;
Int2 = strlen(SymbolName);
for (Int1 = 0; Int1 < Int2; ++Int1)
Key += SymbolName[Int1];
Bucket = CDSymbolTable[Key % CDNUMLAYERS];
while(Bucket != NULL) {
if (strcmp(Bucket->buSymbolDesc->sName,SymbolName) == 0) {
*SymbolDesc = Bucket->buSymbolDesc;
break;
}
Bucket = Bucket->buSucc;
}
if (*SymbolDesc != NULL) {
CDStatusInt = CDOLDSYMBOL;
*CDStatusString = '\0';
}
else {
/* first, try to allocate memory */
if ((NewDesc = alloc(s)) == NULL) {
CDStatusInt = CDError(CDMALLOCFAILED);
CDStatusInt = CDPARSEFAILED;
return (False);
}
size = Int2 + 2;
if ((cp = malloc(size)) == NULL) {
CDStatusInt = CDError(CDMALLOCFAILED);
CDStatusInt = CDPARSEFAILED;
return (False);
}
if ((Bucket = alloc(bu)) == NULL) {
CDStatusInt = CDError(CDMALLOCFAILED);
CDStatusInt = CDPARSEFAILED;
return (False);
}
if (Access != 'n' And (FDesc = POpen(SymbolName,"r",(char *)NULL,
(char **)NULL)) != NULL) {
/*
* Symbol already exists, so user probably intends
* to edit it or just read it.
*/
/* put symbol into symbol table */
*SymbolDesc = CDDesc.dSymbolDesc = NewDesc;
++CDDesc.dNumSymbolsAllocated;
for (Layer = 0;Layer <= CDNUMLAYERS;++Layer)
CDDesc.dSymbolDesc->sBin[Layer] = (struct o ***)NULL;
CDDesc.dSymbolDesc->sName = cp;
strcpy(CDDesc.dSymbolName,SymbolName);
strcpy(CDDesc.dSymbolDesc->sName,CDDesc.dSymbolName);
CDDesc.dNumX = CDDesc.dNumY = 1;
CDDesc.dDX = CDDesc.dDY = 0;
CDDesc.dSymbolDesc->sA = 1;
CDDesc.dSymbolDesc->sB = 1;
CDDesc.dSymbolDesc->sBBValid = True;
CDDesc.dSymbolDesc->sLeft = CDDesc.dSymbolDesc->sBottom =CDINFINITY;
CDDesc.dSymbolDesc->sRight = CDDesc.dSymbolDesc->sTop = -CDINFINITY;
CDDesc.dSymbolDesc->sInfo = 0;
CDDesc.dSymbolDesc->sMasterList = NULL;
CDDesc.dSymbolDesc->sPrptyList = NULL;
/* add property list information */
while(CDDesc.dPrptyList != NULL) {
if (Not CDAddProperty(CDDesc.dSymbolDesc,(struct o *)NULL,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String)) {
CDStatusInt = CDError(CDMALLOCFAILED);
CDStatusInt = CDPARSEFAILED;
return (False);
}
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
/*
* Insert symbol desc in symbol table.
* The hash table 'Key' was computed above.
*/
if (CDSymbolTable[Key % CDNUMLAYERS] != NULL)
CDSymbolTable[Key % CDNUMLAYERS]->buPred = Bucket;
Bucket->buPred = NULL;
Bucket->buSucc = CDSymbolTable[Key % CDNUMLAYERS];
Bucket->buSymbolDesc = *SymbolDesc;
CDSymbolTable[Key % CDNUMLAYERS] = Bucket;
fclose(FDesc);
PCIF(SymbolName,&StatusString,&StatusInt);
if (StatusInt == PSUCCEEDED)
CDStatusInt = CDOLDSYMBOL;
else {
CDStatusInt = CDPARSEFAILED;
strcpy(CDStatusString,StatusString);
/* SRW ** so CDGen() doesn't puke */
for (Layer = 0;Layer <= CDNUMLAYERS;++Layer)
CDDesc.dSymbolDesc->sBin[Layer] = (struct o ***)NULL;
return (False);
}
/*
* Now, the master list descs and instance descs, if any, have
* to be filled in. See the discussion in CDBeginMakeCall for
* why this wasn't done earlier.
*/
MasterListDesc = CDDesc.dSymbolDesc->sMasterList;
while(MasterListDesc != NULL) {
/*
* This recursive call is safe, because PCIF has done its work.
* Because StatusInt is checked, we ignore the returned value.
*/
CDOpen(MasterListDesc->mName,&MasterSymbolDesc,'r');
if (CDStatusInt == CDNEWSYMBOL Or CDStatusInt == CDPARSEFAILED) {
if (CDStatusInt == CDNEWSYMBOL) {
CDStatusInt = CDPARSEFAILED;
sprintf(CDStatusString,
"Master %s doesn't seem to be around.\n",
MasterListDesc->mName);
}
return (False);
}
if (Not CDReflect(MasterSymbolDesc)) {
CDStatusInt = CDPARSEFAILED;
return (False);
}
MasterListDesc = MasterListDesc->mSucc;
}
CDStatusInt = CDSUCCEEDED;
}
else {
if (Access == 'w' Or Access == 'n') {
/* create cell in database */
CDDesc.dSymbolDesc = NewDesc;
++CDDesc.dNumSymbolsAllocated;
for (Layer = 0;Layer <= CDNUMLAYERS;++Layer)
CDDesc.dSymbolDesc->sBin[Layer] = (struct o ***)NULL;
CDDesc.dSymbolDesc->sName = cp;
strcpy(CDDesc.dSymbolName,SymbolName);
strcpy(CDDesc.dSymbolDesc->sName,CDDesc.dSymbolName);
CDDesc.dNumX = CDDesc.dNumY = 1;
CDDesc.dDX = CDDesc.dDY = 0;
CDDesc.dSymbolDesc->sA = 1;
CDDesc.dSymbolDesc->sB = 1;
CDDesc.dSymbolDesc->sBBValid = True;
CDDesc.dSymbolDesc->sLeft
= CDDesc.dSymbolDesc->sBottom = CDINFINITY;
CDDesc.dSymbolDesc->sRight
= CDDesc.dSymbolDesc->sTop = -CDINFINITY;
CDDesc.dSymbolDesc->sInfo = 0;
CDDesc.dSymbolDesc->sMasterList = NULL;
CDDesc.dSymbolDesc->sPrptyList = NULL;
/* add property list information */
while(CDDesc.dPrptyList != NULL) {
if (Not CDAddProperty(CDDesc.dSymbolDesc,(struct o *)NULL,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String)) {
CDStatusInt = CDError(CDMALLOCFAILED);
CDStatusInt = CDPARSEFAILED;
return (False);
}
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
/*
* Insert symbol desc in symbol table.
* The hash table 'Key' was computed above.
*/
*SymbolDesc = CDDesc.dSymbolDesc;
if (CDSymbolTable[Key % CDNUMLAYERS] != NULL)
CDSymbolTable[Key % CDNUMLAYERS]->buPred = Bucket;
Bucket->buSucc = CDSymbolTable[Key % CDNUMLAYERS];
Bucket->buSymbolDesc = *SymbolDesc;
Bucket->buPred = NULL;
CDSymbolTable[Key % CDNUMLAYERS] = Bucket;
}
else {
*SymbolDesc = NULL;
/* free the previously allocated memory. It's not needed */
afree(NewDesc,s);
afree(Bucket,bu);
free(cp);
}
CDStatusInt = CDNEWSYMBOL;
}
}
--RecursionLevel;
if (RecursionLevel == 0 And CDDesc.dControl != DCONTROLPCIF)
CDDesc.dControl = DCONTROLVANILLA;
#ifdef DEBUGREFLECT
printf("End CDOpen of symbol %s.\n",SymbolName);
#endif
return (True);
}
void
CDSymbol(SymbolName,SymbolDesc)
char *SymbolName;
struct s **SymbolDesc;
{
/*
* Returns symbol desc if any for symbol.
* If SymbolName is not in symbol table, the pointer SymbolDesc
* is returned NULL.
*/
int Key,Int1,Int2;
struct bu *Bucket;
Key = 0;
*SymbolDesc = NULL;
if (SymbolName == NULL)
return;
Int2 = strlen(SymbolName);
for (Int1 = 0;Int1 < Int2;++Int1)
Key += SymbolName[Int1];
Bucket = CDSymbolTable[Key % CDNUMLAYERS];
while(Bucket != NULL) {
if (strcmp(Bucket->buSymbolDesc->sName,SymbolName) == 0) {
*SymbolDesc = Bucket->buSymbolDesc;
return;
}
Bucket = Bucket->buSucc;
}
}
int
CDClose(SymbolDesc)
struct s *SymbolDesc;
{
/*
* Close symbol. Free SymbolDesc.
* If malloc fails, False is returned. Otherwise, True is returned.
*/
struct bu *Bucket;
struct g *GenDesc;
struct o *Pointer;
struct prpty *PrptyDesc;
struct prpty PrptyCopy;
int Key,Int1,Int2;
int Layer;
/*
* Delete symbol desc from symbol table.
*/
Key = 0;
Int2 = strlen(SymbolDesc->sName);
for (Int1 = 0; Int1 < Int2; ++Int1)
Key += SymbolDesc->sName[Int1];
Bucket = CDSymbolTable[Key % CDNUMLAYERS];
while(Bucket != NULL) {
if (strcmp(Bucket->buSymbolDesc->sName,SymbolDesc->sName) == 0)
break;
Bucket = Bucket->buSucc;
}
if (Bucket == NULL)
return (True);
if (Bucket->buPred == NULL And Bucket->buSucc == NULL) {
/*
* Only desc--has no pred or succ.
*/
CDSymbolTable[Key % CDNUMLAYERS] = NULL;
}
elif (Bucket->buPred == NULL) {
/*
* First desc. Has a succ, but no pred.
*/
CDSymbolTable[Key % CDNUMLAYERS] = Bucket->buSucc;
Bucket->buSucc->buPred = NULL;
}
elif (Bucket->buSucc == NULL) {
/*
* Last desc--has a pred, but no succ.
*/
Bucket->buPred->buSucc = NULL;
}
else {
/*
* Vanilla desc has a pred and a succ.
*/
Bucket->buSucc->buPred = Bucket->buPred;
Bucket->buPred->buSucc = Bucket->buSucc;
}
/*
* Free storage taken up by symbol.
*/
for (Layer = 0;Layer <= CDNUMLAYERS;++Layer) {
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
else {
CDDelete(SymbolDesc,Pointer);
}
}
}
/*
* Free storage of property list;
*/
PrptyDesc = SymbolDesc->sPrptyList;
while(PrptyDesc != NULL) {
PrptyCopy = *PrptyDesc;
if (PrptyDesc->prpty_String != NULL)
free(PrptyDesc->prpty_String);
afree(PrptyDesc,prpty);
PrptyDesc = PrptyCopy.prpty_Succ;
}
afree(Bucket->buSymbolDesc,s);
afree(Bucket,bu);
return (True);
}
int
CDReflect(SymbolDesc)
struct s *SymbolDesc;
{
/*
* This routine must be invoked at certain times by the CD user.
* All bounding box information must be up-to-date if the indexing
* method is to work.
*
* CDReflect will return False if malloc fails. Otherwise, True is
* returned.
*
* Here's the problem.
* Suppose we have a symbol called Load and there is an instance
* of it in NAND. Then, there is a master list desc for Load in
* NAND's master list. Suppose Load is edited and its BB changes.
* Then, the instance desc for the instance of Load in NAND will be wrong.
* Calling CDReflect(Load) reflects the change to Load's BB to all
* symbols that DIRECTLY or INDIRECTLY reference it.
*
* In one sentence, here is when you must invoke CDReflect:
* You have opened a symbol and edited it so that its bounding box
* has changed and you are done editing it for the time being.
*/
int Int1;
int L,B,R,T;
struct bu *Bucket;
struct m *MasterListDesc;
/*
* Here's the algorithm.
* Let the name of the symbol we are reflecting be S.
*
* Recompute BB of S.
* CDUpdate does this.
*
* For each symbol named i, i != S, in CD's hash table of symbol descs,
* do the following.
*
* For each master named M, if any, in master list of i, do the following.
* If M == S and M's BB != S's BB, do the following.
* M's BB = S's BB.
* Patch up i's instance descs that reference M.
* Update i's BB.
* Invoke Reflect(i) recursively.
*/
#ifdef DEBUGREFLECT
printf("Begin Reflect(%s).\n",SymbolDesc->sName);
printf(" Old BB is %d %d %d %d.\n",SymbolDesc->sLeft,SymbolDesc->sBottom,
SymbolDesc->sRight,SymbolDesc->sTop);
#endif
/*
* Recompute BB of S.
*/
if (Not CDBB(SymbolDesc,(struct o *)NULL,&L,&B,&R,&T))
return (False);
#ifdef DEBUGREFLECT
printf(" New BB is %d %d %d %d.\n",SymbolDesc->sLeft,SymbolDesc->sBottom,
SymbolDesc->sRight,SymbolDesc->sTop);
#endif
for (Int1 = 0;Int1 < CDNUMLAYERS;++Int1) {
Bucket = CDSymbolTable[Int1];
loop
if (Bucket == NULL)
break;
/*
* SymbolDesc is the desc for S.
* Bucket->buSymbolDesc is the desc for i.
*/
elif (strcmp(Bucket->buSymbolDesc->sName,SymbolDesc->sName) == 0)
Bucket = Bucket->buSucc;
else {
#ifdef DEBUGREFLECT
printf(" Begin traversing master list of %s.\n",Bucket->buSymbolDesc->sName);
#endif
MasterListDesc = Bucket->buSymbolDesc->sMasterList;
loop
if (MasterListDesc == NULL) {
#ifdef DEBUGREFLECT
printf(" End traversing master list of %s.\n",Bucket->buSymbolDesc->sName);
#endif
break;
}
else {
/*
* MasterListDesc->mName is M.
*/
#ifdef DEBUGREFLECT
printf("Considering %s.\n",MasterListDesc->mName);
printf("BB is %d %d %d %d.\n",MasterListDesc->mLeft,MasterListDesc->mBottom,
MasterListDesc->mRight,MasterListDesc->mTop);
#endif
if (strcmp(MasterListDesc->mName,SymbolDesc->sName) == 0
And (MasterListDesc->mLeft != SymbolDesc->sLeft Or
MasterListDesc->mBottom != SymbolDesc->sBottom Or
MasterListDesc->mRight != SymbolDesc->sRight Or
MasterListDesc->mTop != SymbolDesc->sTop)) {
#ifdef DEBUGREFLECT
printf("BB conflict.\n");
#endif
MasterListDesc->mLeft = SymbolDesc->sLeft;
MasterListDesc->mBottom = SymbolDesc->sBottom;
MasterListDesc->mRight = SymbolDesc->sRight;
MasterListDesc->mTop = SymbolDesc->sTop;
/*
* Patch up instance descs.
* A very big loop.
* Warrants its own routine.
*/
if (Not CDPatchInstances(Bucket->buSymbolDesc,
MasterListDesc->mName)) return (False);
/*
* Recompute i's BB.
*/
Bucket->buSymbolDesc->sBBValid = False;
if (Not CDBB(Bucket->buSymbolDesc,(struct o *)NULL,
&L,&B,&R,&T)) return (False);
/*
* Reflect changes up the hierarchy of
* instance references.
*/
if (Not CDReflect(Bucket->buSymbolDesc))
return (False);
}
MasterListDesc = MasterListDesc->mSucc;
};
Bucket = Bucket->buSucc;
};
}
#ifdef DEBUGREFLECT
printf("End Reflect(%s).\n",SymbolDesc->sName);
#endif
return (True);
}
int
CDPatchInstances(SymbolDesc,MasterName)
struct s *SymbolDesc;
char *MasterName;
{
/*
* This routine will delete all instances of MasterName in the symbol
* pointed to by SymbolDesc, and then recreate the same instance in the
* symbol. The result is to reflect any change in the BB of MasterName
* in the symbol.
*
* CDPatchInstances will return False if malloc fails.
* Otherwise, True is returned.
*/
struct g *GenDesc;
struct o *OldPntr,*NewPntr;
struct t *TGen;
struct prpty *PrptyDesc;
char *SymbolName;
int X,Y;
int NumX,NumY;
int DX,DY;
int OldL,OldB,OldR,OldT;
int NewL,NewB,NewR,NewT;
char Type;
#ifdef DEBUGREFLECT
printf("Begin patching instances of master %s for symbol %s.\n",MasterName,SymbolDesc->sName);
#endif
if (MasterName == NULL)
return (True);
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&OldPntr);
if (OldPntr == NULL)
break;
CDCall(OldPntr,&SymbolName,&NumX,&DX,&NumY,&DY);
if (SymbolName == NULL)
continue;
if (*SymbolName == '\0' Or *MasterName == '\0')
continue;
if (strcmp(SymbolName,MasterName) != 0)
continue;
if (Not CDBB(SymbolDesc,OldPntr,&OldL,&OldB,&OldR,&OldT))
return (False);
#ifdef DEBUGREFLECT
printf(" Old BB is %d %d %d %d.\n",OldL,OldB,OldR,OldT);
#endif
/* we can assume here that the only error is CDMALLOCFAILED */
if (Not CDBeginMakeCall(SymbolDesc,SymbolName,NumX,DX,NumY,DY,&NewPntr))
if (CDStatusInt == CDMALLOCFAILED)
return (CDError(CDMALLOCFAILED));
CDInitTGen(OldPntr,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL)
break;
else
if (Not CDT(NewPntr,Type,X,Y))
return (CDError(CDMALLOCFAILED));
}
if (Not CDEndMakeCall(SymbolDesc,NewPntr))
return (CDError(CDMALLOCFAILED));
/* copy the property list */
CDProperty(SymbolDesc,OldPntr,&PrptyDesc);
while(PrptyDesc != NULL) {
if (Not (CDAddProperty(SymbolDesc,NewPntr,PrptyDesc->prpty_Value,
PrptyDesc->prpty_String))) {
return (CDError(CDMALLOCFAILED));
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
if (Not CDBB(SymbolDesc,NewPntr,&NewL,&NewB,&NewR,&NewT))
return (CDError(CDMALLOCFAILED));
#ifdef DEBUGREFLECT
printf(" New BB is %d %d %d %d.\n",NewL,NewB,NewR,NewT);
#endif
/*
* The generator may return an instance desc that was created in
* this loop. So, remove any duplicates.
*/
if (OldL != NewL Or OldB != NewB Or OldR != NewR Or OldT != NewT)
/*
* Remove desc with invalid BB.
*/
CDDelete(SymbolDesc,OldPntr);
else
/*
* Remove duplicate.
*/
CDDelete(SymbolDesc,NewPntr);
}
#ifdef DEBUGREFLECT
printf("End patching instances of master %s for symbol %s.\n",MasterName,SymbolDesc->sName);
#endif
return (True);
}
/*======================================================================*
* *
* OOO BBBB J EEEEE CCCC TTTTT *
* O O B B J E C T *
* O O BBBB J EEE C T *
* O O B B J J E C T *
* OOO BBBB JJJ EEEEE CCCC T *
* *
* CCCC RRRR EEEEE A TTTTT III OOO N N *
* C R R E A A T I O O NN N *
* C RRRR EEE A A T I O O N N N *
* C R R E AAAAA T I O O N NN *
* CCCC R R EEEEE A A T III OOO N N *
* *
* *
* *
* CDMakeBox(SymbolDesc,Layer,Length,Width,X,Y,Pointer) *
* CDMakeLabel(SymbolDesc,Layer,Label,X,Y,Xform,Pointer) *
* CDMakePolygon(SymbolDesc,Layer,Path,Pointer) *
* CDMakeWire(SymbolDesc,Layer,Width,Path,Pointer) *
* CDMakeRoundFlash(SymbolDesc,Layer,Width,X,Y,Pointer) *
* CDBeginMakeCall(SymbolDesc,SymbolName,NumX,DX,NumY,DY,Pointer) *
* CDEndMakeCall(SymbolDesc,Pointer) *
* CDInsertObjectDesc(SymbolDesc,ObjectDesc) *
* CDCheckPath(Path) *
* *
*======================================================================*/
int
CDMakeBox(SymbolDesc,Layer,Length,Width,X,Y,Pointer)
struct s *SymbolDesc;
int Layer;
int Length,Width,X,Y;
struct o **Pointer;
{
struct o *ObjectDesc;
if (Length == 0 Or Width == 0)
return (CDError(CDBADBOX));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
Length = abs(Length);
Width = abs(Width);
ObjectDesc->oRep = NULL;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDBOX;
ObjectDesc->oLayer = Layer;
ObjectDesc->oLeft = X-Length/2;
ObjectDesc->oBottom = Y-Width/2;
ObjectDesc->oRight = X+Length/2;
ObjectDesc->oTop = Y+Width/2;
*Pointer = ObjectDesc;
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
int
CDMakeLabel(SymbolDesc,Layer,Label,X,Y,Xform,Pointer)
struct s *SymbolDesc;
int Layer;
char *Label;
int X,Y;
char Xform;
struct o **Pointer;
{
struct la *LabelDesc;
struct o *ObjectDesc;
unsigned int size;
if ((LabelDesc = alloc(la)) == NULL)
return (CDError(CDMALLOCFAILED));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
size = strlen(Label) + 2;
if ((LabelDesc->laLabel = malloc(size)) == NULL)
return (CDError(CDMALLOCFAILED));
strcpy(LabelDesc->laLabel,Label);
LabelDesc->laX = X;
LabelDesc->laY = Y;
LabelDesc->laXform = Xform;
ObjectDesc->oRep = (struct o *)LabelDesc;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDLABEL;
ObjectDesc->oLayer = Layer;
/* give label a small BB */
ObjectDesc->oLeft = X;
ObjectDesc->oRight = X + 400;
ObjectDesc->oBottom = Y;
ObjectDesc->oTop = Y + 200;
/*
ObjectDesc->oLeft = ObjectDesc->oRight = X;
ObjectDesc->oBottom = ObjectDesc->oTop = Y;
*/
*Pointer = ObjectDesc;
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
int
CDMakePolygon(SymbolDesc,Layer,Path,Pointer)
struct s *SymbolDesc;
int Layer;
struct p *Path;
struct o **Pointer;
{
struct po *PolygonDesc;
struct o *ObjectDesc;
struct p *Pair;
int i;
CDCheckPath(Path);
for (i = 0, Pair = Path; Pair; Pair = Pair->pSucc, i++) ;
if (!CDBogusPoly && i < 4) {
*Pointer = NULL;
return (True);
}
if ((PolygonDesc = alloc(po)) == NULL)
return (CDError(CDMALLOCFAILED));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
PolygonDesc->poPath = Path;
ObjectDesc->oRep = (struct o *)PolygonDesc;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDPOLYGON;
ObjectDesc->oLayer = Layer;
ObjectDesc->oLeft = ObjectDesc->oBottom = CDINFINITY;
ObjectDesc->oRight = ObjectDesc->oTop = -CDINFINITY;
Pair = Path;
while(Pair != NULL) {
if (ObjectDesc->oLeft > Pair->pX)
ObjectDesc->oLeft = Pair->pX;
if (ObjectDesc->oRight < Pair->pX)
ObjectDesc->oRight = Pair->pX;
if (ObjectDesc->oBottom > Pair->pY)
ObjectDesc->oBottom = Pair->pY;
if (ObjectDesc->oTop < Pair->pY)
ObjectDesc->oTop = Pair->pY;
Pair = Pair->pSucc;
}
*Pointer = ObjectDesc;
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
int
CDMakeWire(SymbolDesc,Layer,Width,Path,Pointer)
struct s *SymbolDesc;
int Layer;
int Width;
struct p *Path;
struct o **Pointer;
{
struct w *WireDesc;
struct o *ObjectDesc;
struct p *Pair;
if ((WireDesc = alloc(w)) == NULL)
return (CDError(CDMALLOCFAILED));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
CDCheckPath(Path);
if (Width < 0) Width = -Width;
WireDesc->wWidth = Width;
WireDesc->wPath = Path;
ObjectDesc->oRep = (struct o *)WireDesc;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDWIRE;
ObjectDesc->oLayer = Layer;
ObjectDesc->oLeft = ObjectDesc->oBottom = CDINFINITY;
ObjectDesc->oRight = ObjectDesc->oTop = -CDINFINITY;
Pair = Path;
while(Pair != NULL) {
if (ObjectDesc->oLeft > Pair->pX-Width/2)
ObjectDesc->oLeft = Pair->pX-Width/2;
if (ObjectDesc->oRight < Pair->pX+Width/2)
ObjectDesc->oRight = Pair->pX+Width/2;
if (ObjectDesc->oBottom > Pair->pY-Width/2)
ObjectDesc->oBottom = Pair->pY-Width/2;
if (ObjectDesc->oTop < Pair->pY+Width/2)
ObjectDesc->oTop = Pair->pY+Width/2;
Pair = Pair->pSucc;
}
*Pointer = ObjectDesc;
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
int
CDMakeRoundFlash(SymbolDesc,Layer,Width,X,Y,Pointer)
struct s *SymbolDesc;
int Layer;
int Width,X,Y;
struct o **Pointer;
{
struct r *RoundFlashDesc;
struct o *ObjectDesc;
if ((RoundFlashDesc = alloc(r)) == NULL)
return (CDError(CDMALLOCFAILED));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
RoundFlashDesc->rWidth = Width;
RoundFlashDesc->rX = X;
RoundFlashDesc->rY = Y;
ObjectDesc->oRep = (struct o *)RoundFlashDesc;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDROUNDFLASH;
ObjectDesc->oLayer = Layer;
ObjectDesc->oLeft = X-Width/2;
ObjectDesc->oBottom = Y-Width/2;
ObjectDesc->oRight = X+Width/2;
ObjectDesc->oTop = Y+Width/2;
*Pointer = ObjectDesc;
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
int
CDBeginMakeCall(SymbolDesc,SymbolName,NumX,DX,NumY,DY,Pointer)
struct s *SymbolDesc;
char *SymbolName;
struct o **Pointer;
int NumX,NumY;
int DX,DY;
{
/*
* CDBeginMakeCall will return False if a CDMALLOCFAILED error
* occurs or if CDOpen fails. Possible values for CDStatusInt
* upon return are:
* (Fatal)-CDPARSEFAILED - Syntax error
* (Fatal)-CDMALLOCFAILED - Out of memory
* (Fatal)-CDNEWSYMBOL - symbol does not exist
* CDOLDSYMBOL - successful return, symbol exists
* Only CDOLDSYMBOL is not a fatal return (i.e., CDBeginMakeCall
* returns True).
*/
struct c *CallDesc;
struct o *ObjectDesc;
struct m *MasterListDesc;
struct s *MasterSymbolDesc;
struct prpty *PrptyDesc;
unsigned int size;
/* The symbol call is inserted into the database CDEndMakeCall */
if ((CallDesc = alloc(c)) == NULL)
return (CDError(CDMALLOCFAILED));
if ((ObjectDesc = alloc(o)) == NULL)
return (CDError(CDMALLOCFAILED));
CallDesc->cNumX = NumX;
CallDesc->cDX = DX;
CallDesc->cNumY = NumY;
CallDesc->cT = NULL;
CallDesc->cDY = DY;
ObjectDesc->oRep = (struct o *)CallDesc;
ObjectDesc->oPrptyList = NULL;
ObjectDesc->oInfo = 0;
ObjectDesc->oType = CDSYMBOLCALL;
ObjectDesc->oLayer = 0;
*Pointer = ObjectDesc;
MasterListDesc = SymbolDesc->sMasterList;
/*
* Search masterList for an instance of SymbolName.
* If not found, insert into the masterList (which is a linked list).
* An entry in the master list contains the symbol name, the bounding
* box, and the number of references.
*/
loop{
if (MasterListDesc == NULL) {
/*
* Insert into list
* Firstly, try to allocate memory
*/
if ((MasterListDesc = alloc(m)) == NULL)
return (CDError(CDMALLOCFAILED));
size = strlen(SymbolName) + 2;
if ((MasterListDesc->mName = malloc(size)) == NULL)
return (CDError(CDMALLOCFAILED));
/* insert new instance at end of (linked) masterList */
if (SymbolDesc->sMasterList != NULL)
SymbolDesc->sMasterList->mPred = MasterListDesc;
MasterListDesc->mSucc = SymbolDesc->sMasterList;
MasterListDesc->mPred = NULL;
SymbolDesc->sMasterList = MasterListDesc;
MasterListDesc->mReferenceCount = 0;
strcpy(MasterListDesc->mName,SymbolName);
if (CDDesc.dControl == DCONTROLVANILLA) {
/*
* DCONTROLVANILLA tells us that CDOpen is safe to call here.
* Because StatusInt is checked, we ignore the returned value.
*/
CDOpen(MasterListDesc->mName,&MasterSymbolDesc,'r');
if (CDStatusInt == CDPARSEFAILED Or CDStatusInt == CDNEWSYMBOL) {
/* CDOpen failed -- Don't put bad master in MasterList */
if (CDStatusInt == CDNEWSYMBOL)
sprintf(CDStatusString,"Symbol %s not found.",
MasterListDesc->mName);
if (SymbolDesc->sMasterList != NULL)
SymbolDesc->sMasterList->mPred = NULL;
strcpy(MasterListDesc->mName,"");
SymbolDesc->sMasterList = MasterListDesc->mSucc;
afree(MasterListDesc,m);
return (False);
}
if (Not CDBB(MasterSymbolDesc,(struct o *)NULL,
&(MasterListDesc->mLeft),&(MasterListDesc->mBottom),
&(MasterListDesc->mRight),&(MasterListDesc->mTop)))
return (False);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
/*
* We CANNOT invoke CDBB here, because if the master symbol
* hasn't already been mapped into main memory via CDOpen,
* CDBB will invoke CDOpen which will then invoke PCIF and
* since PCIF CANNOT be invoked recursively, all of PCIF's
* state will be broken. The solution is to defer filling
* in the bounding box information for master list descs and
* instance descs until PCIF has returned in CDOpen. Why not
* write PCIF so it can be invoked recursively? For a deep
* hierarchy, we might exceed the limit on open file
* descriptors and we clearly don't want to limit hierarchy
* depth.
*/
MasterListDesc->mLeft = MasterListDesc->mBottom =
MasterListDesc->mRight = MasterListDesc->mTop = 0;
}
break;
}
elif (strcmp(SymbolName,MasterListDesc->mName) == 0) {
/*
* A match! This symbol is already in memory.
*/
/* SRW */
if (CDDesc.dControl == DCONTROLVANILLA)
CDSymbol(MasterListDesc->mName,&MasterSymbolDesc);
CDStatusInt = CDOLDSYMBOL;
*CDStatusString = '\0';
break;
}
else
MasterListDesc = MasterListDesc->mSucc;
}
CallDesc->cMaster = MasterListDesc;
MasterListDesc->mReferenceCount++;
/* SRW
* This version of CD is used for a schematic editor, in which
* connectivity is established by maintaining terminal coordinates
* in property strings. As we add a cell (DCONTROLVANILLA set),
* the property strings contain connection nodes with coordinates
* relative to the cell. These coordinates are transformed to be
* relative to the parent cell by a routine called in
* CDEndMakeCall().
*/
if (CDDesc.dControl == DCONTROLVANILLA) {
CDProperty(MasterSymbolDesc,(struct o *)NULL,&PrptyDesc);
while (PrptyDesc) {
CDAddProperty(SymbolDesc,ObjectDesc,
PrptyDesc->prpty_Value,PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
return (True);
}
int
CDT(Pointer,Type,X,Y)
struct o *Pointer;
char Type;
int X,Y;
{
/*
* After invoking BeginMakeCall, invoke T for each transformation in
* the call. The transformation is a linked list of transformation
* descs headed by the ct field of the call desc. Finally, invoke
* EndMakeCall.
*/
struct c *CDesc;
struct t *TDesc;
CDesc = (struct c *)Pointer->oRep;
TDesc = CDesc->cT;
if (TDesc == NULL) {
if ((CDesc->cT = TDesc = alloc(t)) == NULL)
return (CDError(CDMALLOCFAILED));
TDesc->tSucc = NULL;
TDesc->tX = X;
TDesc->tY = Y;
TDesc->tType = Type;
return (True);
}
while(TDesc->tSucc != NULL)
TDesc = TDesc->tSucc;
if ((TDesc = TDesc->tSucc = alloc(t)) == NULL)
return (CDError(CDMALLOCFAILED));
TDesc->tSucc = NULL;
TDesc->tX = X;
TDesc->tY = Y;
TDesc->tType = Type;
return (True);
}
int
CDEndMakeCall(SymbolDesc,Pointer)
struct s *SymbolDesc;
struct o *Pointer;
{
struct c *CallDesc;
struct o *ObjectDesc;
struct m *MasterListDesc;
struct t *TGen;
int X,Y;
char Type;
int tf[9];
int a, b, c, d, tx, ty;
ObjectDesc = Pointer;
CallDesc = (struct c *)ObjectDesc->oRep;
MasterListDesc = CallDesc->cMaster;
if (TFull())
return (CDError(CDXFORMSTACKFULL));
TPush();
TIdentity();
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL)
break;
if (Type == CDROTATE)
TRotate(X,Y);
elif (Type == CDTRANSLATE)
TTranslate(X,Y);
elif (Type == CDMIRRORX)
TMX();
elif (Type == CDMIRRORY)
TMY();
}
/* Simplify the transform, since kictostr doesn't handle more than
* one translation, so that LLREF fails. The resulting transform
* uses a maximum of one each MY, rotation, translation. The matrix
* is in the form | a c 0 |
* | b d 0 |
* | tx ty 1 |
* where a = tf[0], c = tf[1], etc.
*/
TCurrent(tf);
a = tf[0];
c = tf[1];
b = tf[3];
d = tf[4];
tx = tf[6];
ty = tf[7];
TGen = CallDesc->cT;
CallDesc->cT = 0;
while (TGen) {
struct t *tn = TGen->tSucc;
free(TGen);
TGen = tn;
}
/* Now reset the cell's transform */
if ((a && (a == -d)) || (b && (b == c))) {
if (!CDT(Pointer,CDMIRRORY,0L,0L))
return (CDError(CDMALLOCFAILED));
}
if (!a && c) {
if (c > 0) {
/* 90 */
if (!CDT(Pointer,CDROTATE,0L,1L))
return (CDError(CDMALLOCFAILED));
}
else {
/* 270 */
if (!CDT(Pointer,CDROTATE,0L,-1L))
return (CDError(CDMALLOCFAILED));
}
}
else if (a && !c) {
if (a < 0) {
/* 180 */
if (!CDT(Pointer,CDROTATE,-1L,0L))
return (CDError(CDMALLOCFAILED));
}
}
if (tx || ty)
if (!CDT(Pointer,CDTRANSLATE,tx,ty))
return (CDError(CDMALLOCFAILED));
#ifdef DEBUGREFLECT
printf("Making call of master %s in symbol %s.\n",MasterListDesc->mName,
SymbolDesc->sName);
printf("Untransformed (master's) BB is %d %d %d %d.\n",
MasterListDesc->mLeft,MasterListDesc->mBottom,
MasterListDesc->mRight,MasterListDesc->mTop);
#endif
ObjectDesc->oLeft = MasterListDesc->mLeft;
ObjectDesc->oBottom = MasterListDesc->mBottom;
TPoint(&(ObjectDesc->oLeft),&(ObjectDesc->oBottom));
ObjectDesc->oRight = MasterListDesc->mRight;
ObjectDesc->oTop = MasterListDesc->mTop;
#ifdef DEBUGREFLECT
TPoint(&(ObjectDesc->oRight),&(ObjectDesc->oTop));
if (ObjectDesc->oRight < ObjectDesc->oLeft)
SwapInts(ObjectDesc->oLeft,ObjectDesc->oRight);
if (ObjectDesc->oTop < ObjectDesc->oBottom)
SwapInts(ObjectDesc->oBottom,ObjectDesc->oTop);
printf("Transformed, unarrayed BB is %d %d %d %d.\n",
ObjectDesc->oLeft,ObjectDesc->oBottom,
ObjectDesc->oRight,ObjectDesc->oTop);
#endif
ObjectDesc->oRight += (CallDesc->cNumX-1)*CallDesc->cDX;
ObjectDesc->oTop += (CallDesc->cNumY-1)*CallDesc->cDY;
TPoint(&(ObjectDesc->oRight),&(ObjectDesc->oTop));
if (ObjectDesc->oRight < ObjectDesc->oLeft)
SwapInts(ObjectDesc->oLeft,ObjectDesc->oRight);
if (ObjectDesc->oTop < ObjectDesc->oBottom)
SwapInts(ObjectDesc->oBottom,ObjectDesc->oTop);
#ifdef DEBUGREFLECT
printf("Transformed, arrayed BB is %d %d %d %d.\n",
ObjectDesc->oLeft,ObjectDesc->oBottom,
ObjectDesc->oRight,ObjectDesc->oTop);
#endif
/*
* UpdateProperties() must be supplied externally. The intended
* purpose of this routine is to update properties that require as
* input the transformed coordinates of points within the cell.
* The property strings may not be present unless DCONTROLVANILLA.
* See the note in CDBeginMakeCall().
*/
if (CDDesc.dControl == DCONTROLVANILLA)
UpdateProperties(ObjectDesc);
TPop();
if (Not CDInsertObjectDesc(SymbolDesc,ObjectDesc))
return (False);
return (True);
}
void
CDCheckPath(Path)
struct p *Path;
{
/*
* Check to see that the path does not have two identical and
* adjacent vertices.
*/
struct p *Pair;
struct p *Copy;
Pair = Path;
while(Pair->pSucc != NULL) {
if (Pair->pX == Pair->pSucc->pX And Pair->pY == Pair->pSucc->pY) {
Copy = Pair->pSucc;
Pair->pSucc = Copy->pSucc;
afree(Copy,p);
}
else
Pair = Pair->pSucc;
}
}
int
CDInsertObjectDesc(SymbolDesc,ObjectDesc)
struct s *SymbolDesc;
struct o *ObjectDesc;
{
int Int1,Int2,Layer;
int X,Y;
int BeginX,EndX,BeginY,EndY;
CDIntersect(ObjectDesc->oLeft,ObjectDesc->oBottom,ObjectDesc->oRight,
ObjectDesc->oTop,&BeginX,&EndX,&BeginY,&EndY);
/* SRW ** always put labels in residual bin, since the size is
* not known.
*/
if (BeginX != EndX Or BeginY != EndY Or ObjectDesc->oType == CDLABEL)
X = Y = 0;
else {
X = BeginX;
Y = BeginY;
}
Layer = ObjectDesc->oLayer;
if (SymbolDesc->sBin[Layer] == (struct o ***)NULL) {
/* allocate Bin */
if ((SymbolDesc->sBin[Layer] = (struct o ***)
malloc(sizeof(char*) * (CDNUMBINS+1))) == NULL)
return (CDError(CDMALLOCFAILED));
for (Int1 = 0; Int1 <= CDNUMBINS; ++Int1) {
if ((SymbolDesc->sBin[Layer][Int1] = (struct o **)
malloc(sizeof(char*) * (CDNUMBINS+1))) == NULL)
return (CDError(CDMALLOCFAILED));
for (Int2 = 0; Int2 <= CDNUMBINS; ++Int2) {
if ((SymbolDesc->sBin[Layer][Int1][Int2] = (struct o *)
malloc(sizeof(char*))) == NULL)
return (CDError(CDMALLOCFAILED));
SymbolDesc->sBin[Layer][Int1][Int2] = (struct o *)NULL;
}
}
}
elif (SymbolDesc->sBin[Layer][X][Y] != NULL)
SymbolDesc->sBin[Layer][X][Y]->oPred = ObjectDesc;
ObjectDesc->oSucc = SymbolDesc->sBin[Layer][X][Y];
SymbolDesc->sBin[Layer][X][Y] = ObjectDesc;
ObjectDesc->oPred = NULL;
SymbolDesc->sLeft = min(SymbolDesc->sLeft,ObjectDesc->oLeft);
SymbolDesc->sBottom = min(SymbolDesc->sBottom,ObjectDesc->oBottom);
SymbolDesc->sRight = max(SymbolDesc->sRight,ObjectDesc->oRight);
SymbolDesc->sTop = max(SymbolDesc->sTop,ObjectDesc->oTop);
#ifdef DEBUGGEN
if (X == 0 And Y == 0)
printf("Inserting a desc on layer %d in residual bin.\n",Layer);
else
printf("Inserting a desc on layer %d in bin (%d,%d).\n",Layer,X,Y);
#endif
#ifdef DEBUGREFLECT
if (X == 0 And Y == 0)
printf("Inserting a desc on layer %d in residual bin.\n",Layer);
else
printf("Inserting a desc on layer %d in bin (%d,%d).\n",Layer,X,Y);
#endif
return (True);
}
/*======================================================================*
* *
* OOO BBBB J EEEEE CCCC TTTTT *
* O O B B J E C T *
* O O BBBB J EEE C T *
* O O B B J J E C T *
* OOO BBBB JJJ EEEEE CCCC T *
* *
* DDDD EEEEE L EEEEE TTTTT III OOO N N *
* D D E L E T I O O NN N *
* D D EEE L EEE T I O O N N N *
* D D E L E T I O O N NN *
* DDDD EEEEE LLLLL EEEEE T III OOO N N *
* *
* *
* *
* CDDeleteObjectDesc(SymbolDesc,ObjectDesc) *
* *
*======================================================================*/
void
CDDeleteObjectDesc(SymbolDesc,ObjectDesc)
struct s *SymbolDesc;
struct o *ObjectDesc;
{
int Layer;
int X,Y;
int BeginX,EndX,BeginY,EndY;
struct p PCopy;
struct t TCopy;
struct prpty PrptyCopy;
struct prpty *PrptyDesc;
/* we should test the descriptors as valid pointers */
Layer = ObjectDesc->oLayer;
/* is the Bin allocated? */
if (SymbolDesc->sBin[Layer] == NULL Or ObjectDesc == NULL)
return;
CDIntersect(ObjectDesc->oLeft,ObjectDesc->oBottom,ObjectDesc->oRight,
ObjectDesc->oTop,&BeginX,&EndX,&BeginY,&EndY);
/* SRW ** labels are always in residual bin */
if (BeginX != EndX Or BeginY != EndY Or ObjectDesc->oType == CDLABEL)
X = Y = 0;
else {
X = BeginX;
Y = BeginY;
}
if (SymbolDesc->sBin[Layer][X][Y] == NULL)
/* Something's rotten */
return;
elif (ObjectDesc->oPred == NULL And ObjectDesc->oSucc == NULL)
/* Only desc--has no pred or succ */
SymbolDesc->sBin[Layer][X][Y] = NULL;
elif (ObjectDesc->oPred == NULL) {
/* First desc. Has a succ, but no pred */
SymbolDesc->sBin[Layer][X][Y] = ObjectDesc->oSucc;
ObjectDesc->oSucc->oPred = NULL;
}
elif (ObjectDesc->oSucc == NULL)
/* Last desc--has a pred, but no succ */
ObjectDesc->oPred->oSucc = NULL;
else {
/* Vanilla desc has a pred and a succ */
ObjectDesc->oSucc->oPred = ObjectDesc->oPred;
ObjectDesc->oPred->oSucc = ObjectDesc->oSucc;
}
/*
* Invalidate BB.
*/
SymbolDesc->sBBValid = False;
/*
* Free storage of property list;
*/
PrptyDesc = ObjectDesc->oPrptyList;
while(PrptyDesc != NULL) {
PrptyCopy = *PrptyDesc;
if (PrptyDesc->prpty_String != NULL)
free(PrptyDesc->prpty_String);
afree(PrptyDesc,prpty);
PrptyDesc = PrptyCopy.prpty_Succ;
}
/*
* Free storage of oRep;
*/
if (ObjectDesc->oType == CDROUNDFLASH)
afree(ObjectDesc->oRep,r);
elif (ObjectDesc->oType == CDSYMBOLCALL) {
struct c *CallDesc;
struct t *TDesc;
CallDesc = (struct c *)ObjectDesc->oRep;
/* SRW ** reduce the master reference count */
if (CallDesc->cMaster)
CallDesc->cMaster->mReferenceCount --;
TDesc = CallDesc->cT;
while(TDesc != NULL) {
TCopy = *TDesc;
afree(TDesc,t);
TDesc = TCopy.tSucc;
}
afree(CallDesc,c);
}
elif (ObjectDesc->oType == CDPOLYGON) {
struct po *PolygonDesc;
struct p *Pair;
PolygonDesc = (struct po *)ObjectDesc->oRep;
Pair = PolygonDesc->poPath;
while(Pair != NULL) {
PCopy = *Pair;
afree(Pair,p);
Pair = PCopy.pSucc;
}
afree(PolygonDesc,po);
}
elif (ObjectDesc->oType == CDWIRE) {
struct w *WireDesc;
struct p *Pair;
WireDesc = (struct w *)ObjectDesc->oRep;
Pair = WireDesc->wPath;
while(Pair != NULL) {
PCopy = *Pair;
afree(Pair,p);
Pair = PCopy.pSucc;
}
afree(WireDesc,w);
}
afree(ObjectDesc,o);
#ifdef DEBUGGEN
printf("Deleting a desc on layer %d in bin (%d,%d)\n.",Layer,X,Y);
#endif
}
/*======================================================================*
* *
* A CCCC CCCC EEEEE SSSS SSSS III N N GGGG *
* A A C C E S S I NN N G *
* A A C C EEE SSS SSS I N N N G GGG *
* AAAAA C C E S S I N NN G G *
* A A CCCC CCCC EEEEE SSSS SSSS III N N GGG *
* *
* OOO BBBB J EEEEE CCCC TTTTT SSSS *
* O O B B J E C T S *
* O O BBBB J EEE C T SSS *
* O O B B J J E C T S *
* OOO BBBB JJJ EEEEE CCCC T SSSS *
* *
* *
* *
* CDCall(Pointer,SymbolName,NumX,DX,NumY,DY) *
* CDBox(Pointer,Layer,Length,Width,X,Y) *
* CDLabel(Pointer,Layer,Label,X,Y,xform) *
* CDPolygon(Pointer,Layer,Path) *
* CDWire(Pointer,Layer,Width,Path) *
* CDRoundFlash(Pointer,Layer,Width,X,Y) *
* *
*======================================================================*/
void
CDCall(Pointer,SymbolName,NumX,DX,NumY,DY)
struct o *Pointer;
char **SymbolName;
int *NumX,*NumY;
int *DX,*DY;
{
struct c *CallDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDSYMBOLCALL) {
*SymbolName = NULL;
*NumX = 0;
*DX = 0;
*NumY = 0;
*DY = 0;
}
else {
CallDesc = (struct c *)Pointer->oRep;
*SymbolName = CallDesc->cMaster->mName;
*NumX = CallDesc->cNumX;
*DX = CallDesc->cDX;
*NumY = CallDesc->cNumY;
*DY = CallDesc->cDY;
}
}
void
CDBox(Pointer,Layer,Length,Width,X,Y)
struct o *Pointer;
int *Layer;
int *Length,*Width,*X,*Y;
{
if (Pointer == NULL)
return;
if (Pointer->oType != CDBOX)
*Layer = *Length = *Width = *X = *Y = 0;
else {
*Layer = Pointer->oLayer;
*Length = Pointer->oRight - Pointer->oLeft;
*Width = Pointer->oTop - Pointer->oBottom;
*X = Pointer->oLeft + (*Length >> 1);
*Y = Pointer->oBottom + (*Width >> 1);
}
}
void
CDLabel(Pointer,Layer,Label,X,Y,Xform)
struct o *Pointer;
int *Layer;
char **Label;
int *X,*Y;
char *Xform;
{
struct la *LabelDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDLABEL) {
*Layer = *X = *Y = 0;
*Label = NULL;
*Xform = (char)0;
}
else {
*Layer = Pointer->oLayer;
LabelDesc = (struct la *)Pointer->oRep;
*Label = LabelDesc->laLabel;
*X = LabelDesc->laX;
*Y = LabelDesc->laY;
*Xform = LabelDesc->laXform;
}
}
void
CDPolygon(Pointer,Layer,Path)
struct o *Pointer;
int *Layer;
struct p **Path;
{
struct po *PolygonDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDPOLYGON) {
*Layer = 0;
*Path = NULL;
}
else {
*Layer = Pointer->oLayer;
PolygonDesc = (struct po *)Pointer->oRep;
*Path = PolygonDesc->poPath;
}
}
void
CDWire(Pointer,Layer,Width,Path)
struct o *Pointer;
int *Layer;
int *Width;
struct p **Path;
{
struct w *WireDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDWIRE) {
*Layer = *Width = 0;
*Path = NULL;
}
else {
*Layer = Pointer->oLayer;
WireDesc = (struct w *)Pointer->oRep;
*Width = WireDesc->wWidth;
*Path = WireDesc->wPath;
}
}
void
CDRoundFlash(Pointer,Layer,Width,X,Y)
struct o *Pointer;
int *Layer;
int *Width,*X,*Y;
{
struct r *RoundFlashDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDROUNDFLASH)
return;
*Layer = Pointer->oLayer;
RoundFlashDesc = (struct r *)Pointer->oRep;
*Width = RoundFlashDesc->rWidth;
*X = RoundFlashDesc->rX;
*Y = RoundFlashDesc->rY;
}
/*======================================================================*
* *
* A CCCC CCCC EEEEE SSSS SSSS III N N GGGG *
* A A C C E S S I NN N G *
* A A C C EEE SSS SSS I N N N G GGG *
* AAAAA C C E S S I N NN G G *
* A A CCCC CCCC EEEEE SSSS SSSS III N N GGG *
* *
* III N N FFFFF OOO RRRR M M A TTTTT III OOO N N *
* I NN N F O O R R MM MM A A T I O O NN N *
* I N N N FFF O O RRRR M M M A A T I O O N N N *
* I N NN F O O R R M M AAAAA T I O O N NN *
* III N N F OOO R R M M A A T III OOO N N *
* *
* *
* *
* CDInfo(SymbolDesc,Pointer,Info) *
* CDSetInfo(SymbolDesc,Pointer,Info) *
* CDProperty(SymbolDesc,Pointer,Property) *
* CDAddProperty(SymbolDesc,Pointer,Value,String) *
* CDRemoveProperty(SymbolDesc,Pointer,Value) *
* CDType(Pointer,Type) *
* CDBB(SymbolDesc,Pointer,Left,Bottom,Right,Top) *
* CDIntersect(Left,Bottom,Right,Top,BeginX,EndX,BeginY,EndY) *
* *
*======================================================================*/
void
CDInfo(SymbolDesc,Pointer,Info)
struct s *SymbolDesc;
struct o *Pointer;
int *Info;
{
/*
* Return info field of object.
* If Pointer == NULL, object is symbol itself.
*/
if (Pointer == NULL)
*Info = SymbolDesc->sInfo;
else
*Info = Pointer->oInfo;
}
void
CDSetInfo(SymbolDesc,Pointer,Info)
struct s *SymbolDesc;
struct o *Pointer;
int Info;
{
/*
* Set info field of object.
* If Pointer == NULL, object is symbol itself.
*/
if (Pointer == NULL)
SymbolDesc->sInfo = Info;
else
Pointer->oInfo = Info;
}
void
CDProperty(SymbolDesc,Pointer,Property)
struct s *SymbolDesc;
struct o *Pointer;
struct prpty **Property;
{
/*
* Return info field of object.
* If Pointer == NULL, object is symbol itself.
*/
if (Pointer == NULL)
*Property = SymbolDesc->sPrptyList;
else
*Property = Pointer->oPrptyList;
}
int
CDAddProperty(SymbolDesc,Pointer,Value,String)
struct s *SymbolDesc;
struct o *Pointer;
int Value;
char *String;
{
char * cp;
struct prpty *prptyDesc;
unsigned int size;
if ((prptyDesc = alloc(prpty)) == NULL)
return (CDError(CDMALLOCFAILED));
size = strlen(String) + 2;
if ((cp = prptyDesc->prpty_String = malloc(size)) == NULL)
return (CDError(CDMALLOCFAILED));
prptyDesc->prpty_Value = Value;
/* CD does not use the Info field */
prptyDesc->prpty_Info = NULL;
strcpy(prptyDesc->prpty_String,String);
/* we can't allaow semicolons because of CIF */
while(cp != NULL && *cp != '\0') {
if (*cp == ';')
*cp = ' ';
++cp;
}
if (Pointer == NULL) {
prptyDesc->prpty_Succ = SymbolDesc->sPrptyList;
SymbolDesc->sPrptyList = prptyDesc;
}
else {
prptyDesc->prpty_Succ = Pointer->oPrptyList;
Pointer->oPrptyList = prptyDesc;
}
return (True);
}
int
CDRemoveProperty(SymbolDesc,Pointer,Value)
struct s *SymbolDesc;
struct o *Pointer;
int Value;
{
struct prpty *prptyDesc;
struct prpty *prptyHead;
struct prpty *prptyCopy;
struct prpty *prptyTemp;
if (Pointer == NULL)
prptyHead = prptyDesc = SymbolDesc->sPrptyList;
else
prptyHead = prptyDesc = Pointer->oPrptyList;
for (prptyCopy = NULL; prptyDesc != NULL;
prptyCopy = prptyDesc,prptyDesc = prptyTemp) {
prptyTemp = prptyDesc->prpty_Succ;
if (prptyDesc->prpty_Value == Value) {
if (prptyCopy == NULL)
prptyHead = prptyDesc->prpty_Succ;
else
prptyCopy->prpty_Succ = prptyDesc->prpty_Succ;
if (prptyDesc->prpty_String) free(prptyDesc->prpty_String);
if (prptyDesc->prpty_Info) free(prptyDesc->prpty_Info);
afree(prptyDesc,prpty);
prptyDesc = prptyCopy;
}
}
if (Pointer == NULL)
SymbolDesc->sPrptyList = prptyHead;
else
Pointer->oPrptyList = prptyHead;
return True;
}
void
CDType(Pointer,Type)
struct o *Pointer;
char *Type;
{
/*
* Returns type of object pointed to by Pointer.
*/
*Type = Pointer->oType;
}
int
CDBB(SymbolDesc,Pointer,Left,Bottom,Right,Top)
struct s *SymbolDesc;
struct o *Pointer;
int *Left,*Bottom,*Right,*Top;
{
/*
* Return BB of object pointed to by Pointer.
* If Pointer == NULL, return BB of symbol itself.
* Basically, we CAN'T afford to recompute the BB of the symbol each time
* CDDelete or an object creation routine is invoked.
*
* If malloc fails, CDBB will return False via CDError. Otherwise, True
* is returned.
*/
struct g *GenDesc;
int Layer;
if (Pointer == NULL And SymbolDesc->sBBValid) {
*Left = SymbolDesc->sLeft;
*Bottom = SymbolDesc->sBottom;
*Right = SymbolDesc->sRight;
*Top = SymbolDesc->sTop;
#ifdef DEBUGREFLECT
printf("CDBB1(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
#ifdef DEBUGGEN
printf("CDBB1(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
return (True);
}
elif (Pointer != NULL) {
*Left = Pointer->oLeft;
*Bottom = Pointer->oBottom;
*Right = Pointer->oRight;
*Top = Pointer->oTop;
#ifdef DEBUGREFLECT
printf("CDBB2(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
#ifdef DEBUGGEN
printf("CDBB2(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
return (True);
}
SymbolDesc->sLeft = SymbolDesc->sBottom = CDINFINITY;
SymbolDesc->sRight = SymbolDesc->sTop = -CDINFINITY;
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
SymbolDesc->sLeft = min(SymbolDesc->sLeft,Pointer->oLeft);
SymbolDesc->sBottom = min(SymbolDesc->sBottom,Pointer->oBottom);
SymbolDesc->sRight = max(SymbolDesc->sRight,Pointer->oRight);
SymbolDesc->sTop = max(SymbolDesc->sTop,Pointer->oTop);
}
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return (CDError(CDMALLOCFAILED));
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
continue;
loop {
SymbolDesc->sLeft = min(SymbolDesc->sLeft,Pointer->oLeft);
SymbolDesc->sBottom = min(SymbolDesc->sBottom,Pointer->oBottom);
SymbolDesc->sRight = max(SymbolDesc->sRight,Pointer->oRight);
SymbolDesc->sTop = max(SymbolDesc->sTop,Pointer->oTop);
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
}
}
if (SymbolDesc->sLeft == CDINFINITY)
SymbolDesc->sLeft = SymbolDesc->sBottom = SymbolDesc->sRight =
SymbolDesc->sTop = 0;
SymbolDesc->sBBValid = True;
*Left = SymbolDesc->sLeft;
*Bottom = SymbolDesc->sBottom;
*Right = SymbolDesc->sRight;
*Top = SymbolDesc->sTop;
#ifdef DEBUGGEN
printf("CDBB3(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
#ifdef DEBUGREFLECT
printf("CDBB3(%s,%d,%d,%d,%d)\n",SymbolDesc->sName,*Left,*Bottom,*Right,*Top);
#endif
return (True);
}
/*
* Test code for CDIntersect.
* main()
* {
* int Left,Bottom,Right,Top,BeginX,EndX,BeginY,EndY;
*
* printf("BB?");
* scanf("%d%d%d%d",&Left,&Bottom,&Right,&Top);
* CDIntersect(Left,Bottom,Right,Top,&BeginX,&EndX,&BeginY,&EndY);
* printf("Bin[.][%d..%d][%d..%d]\n",BeginX,EndX,BeginY,EndY);
* }
*/
void
CDIntersect(Left,Bottom,Right,Top,BeginX,EndX,BeginY,EndY)
int Left,Bottom,Right,Top;
int *BeginX,*EndX,*BeginY,*EndY;
{
/*
* Returns which bins overlap the AOI
* The residual bin is always searched
* Runs in constant time
*/
#ifdef FLOAT
*BeginX = (int)((float)(Left-CDBINMINX) * (float)(CDNUMBINS)/(float)(CDBINMAXX-CDBINMINX) + 1);
if (*BeginX > CDNUMBINS)
*BeginX = CDNUMBINS;
elif (*BeginX < 1)
*BeginX = 1;
*EndX = (int)((float)(Right-CDBINMINX) * (float)(CDNUMBINS)/(float)(CDBINMAXX-CDBINMINX) + 1);
if (*EndX > CDNUMBINS)
*EndX = CDNUMBINS;
elif (*EndX < 1)
*EndX = 1;
*BeginY = (int)((float)(Bottom-CDBINMINY) * (float)(CDNUMBINS)/(float)(CDBINMAXY-CDBINMINY) + 1);
if (*BeginY > CDNUMBINS)
*BeginY = CDNUMBINS;
elif (*BeginY < 1)
*BeginY = 1;
*EndY = (int)((float)(Top-CDBINMINY) * (float)(CDNUMBINS)/(float)(CDBINMAXY-CDBINMINY) + 1);
if (*EndY > CDNUMBINS)
*EndY = CDNUMBINS;
elif (*EndY < 1)
*EndY = 1;
#else
*BeginX = ((Left-CDBINMINX) * (CDNUMBINS)/(CDBINMAXX-CDBINMINX) + 1);
if (*BeginX > CDNUMBINS)
*BeginX = CDNUMBINS;
elif (*BeginX < 1)
*BeginX = 1;
*EndX = ((Right-CDBINMINX) * (CDNUMBINS)/(CDBINMAXX-CDBINMINX) + 1);
if (*EndX > CDNUMBINS)
*EndX = CDNUMBINS;
elif (*EndX < 1)
*EndX = 1;
*BeginY = ((Bottom-CDBINMINY) * (CDNUMBINS)/(CDBINMAXY-CDBINMINY) + 1);
if (*BeginY > CDNUMBINS)
*BeginY = CDNUMBINS;
elif (*BeginY < 1)
*BeginY = 1;
*EndY = ((Top-CDBINMINY) * (CDNUMBINS)/(CDBINMAXY-CDBINMINY) + 1);
if (*EndY > CDNUMBINS)
*EndY = CDNUMBINS;
elif (*EndY < 1)
*EndY = 1;
#endif
}
/*======================================================================*
* *
* GGGG EEEEE N N EEEEE RRRR A TTTTT OOO RRRR SSSS *
* G E NN N E R R A A T O O R R S *
* G GGG EEE N N N EEE RRRR A A T O O RRRR SSS *
* G G E N NN E R R AAAAA T O O R R S *
* GGG EEEEE N N EEEEE R R A A T OOO R R SSSS *
* *
* *
* *
* CDInitGen(SymbolDesc,Layer,Left,Bottom,Right,Top,GenDesc) *
* CDGen(SymbolDesc,GenDesc,Pointer) *
* CDInitTGen(Pointer,TGen) *
* CDTGen(TGen,Type,X,Y) *
* *
*======================================================================*/
int
CDInitGen(SymbolDesc,Layer,Left,Bottom,Right,Top,GenDesc)
struct s *SymbolDesc;
int Layer;
int Left,Bottom,Right,Top;
struct g **GenDesc;
{
/*
* Returns a pointer to a generator desc.
* Layer == 0 denotes calls.
*/
int BeginX,BeginY,EndX,EndY;
#ifdef DEBUGGEN
printf("Begin initializing generator to search symbol %s.\n",SymbolDesc->sName);
printf("Untransformed AOI is %d %d %d %d.\n",Left,Bottom,Right,Top);
#endif
/*
* Apply inverse of current transformation to AOI.
*/
TInverse();
TInversePoint(&Left,&Bottom);
TInversePoint(&Right,&Top);
if (Right < Left)
SwapInts(Left,Right);
if (Top < Bottom)
SwapInts(Bottom,Top);
#ifdef DEBUGGEN
printf("Transformed AOI is %d %d %d %d.\n",Left,Bottom,Right,Top);
#endif
CDIntersect(Left,Bottom,Right,Top,&BeginX,&EndX,&BeginY,&EndY);
#ifdef DEBUGGEN
printf("Initialized generator to search bins %d..%d,%d..%d on layer %d.\n",
BeginX,EndX,BeginY,EndY,Layer);
#endif
if ((*GenDesc = alloc(g)) == NULL)
return (CDError(CDMALLOCFAILED));
(*GenDesc)->gLeft = Left;
(*GenDesc)->gBottom = Bottom;
(*GenDesc)->gRight = Right;
(*GenDesc)->gTop = Top;
(*GenDesc)->gLayer = Layer;
(*GenDesc)->gX = (*GenDesc)->gBeginX = BeginX;
(*GenDesc)->gY = (*GenDesc)->gBeginY = EndY;
(*GenDesc)->gEndX = EndX;
(*GenDesc)->gEndY = BeginY;
/*
* CDGen will ALWAYS search the residual bin FIRST.
* The vanilla bins will be searched in the order
* for Y = EndY..BeginY
* for X = BeginX..EndX
* ...
* so that redisplays will flow top down.
*/
if (SymbolDesc->sBin[Layer] == NULL)
(*GenDesc)->gPointer = NULL;
else
(*GenDesc)->gPointer = SymbolDesc->sBin[Layer][0][0];
#ifdef DEBUGGEN
printf("End initializing generator to search symbol %s.\n",SymbolDesc->sName);
#endif
return (True);
}
void
CDGen(SymbolDesc,GenDesc,Pointer)
struct s *SymbolDesc;
struct g *GenDesc;
struct o **Pointer;
{
/*
* Returns pointer to next object.
* You should invoke CDType to access object's type and dispatch off
* of type. See traversal code in CDUpdate. Pointer == NULL if last
* object at which time GenDesc is freed.
*/
int i;
int L,B,R,T;
loop {
if (GenDesc->gPointer != NULL) {
/*
* gPointer points to an object desc. Is it in the AOI?
* This test is necessary, because of the granularity of the bins.
* Suppose AOI lies entirely within one bin.
* Then there may, in general, be descs in the bin whose BBs lie
* outside the AOI.
*/
/* callback to user supplied routine */
if (GenDesc->gPointer->oType == CDLABEL)
CDLabelBB(GenDesc->gPointer,&L,&B,&R,&T);
else {
L = GenDesc->gPointer->oLeft;
B = GenDesc->gPointer->oBottom;
R = GenDesc->gPointer->oRight;
T = GenDesc->gPointer->oTop;
}
#ifdef DEBUGGEN
printf("Generator intersecting %d %d %d %d to AOI.\n",L,B,R,T);
#endif
if (L > GenDesc->gRight Or B > GenDesc->gTop Or
R < GenDesc->gLeft Or T < GenDesc->gBottom) {
/*
* Object isn't visible, so consider the next one, if any, in
* the bin currently being searched.
*/
GenDesc->gPointer = GenDesc->gPointer->oSucc;
#ifdef DEBUGGEN
printf("Invisible.\n");
#endif
}
else {
#ifdef DEBUGGEN
printf("Visible.\n");
#endif
/*
* Object is visible, so return object desc.
*/
*Pointer = GenDesc->gPointer;
GenDesc->gPointer = GenDesc->gPointer->oSucc;
return;
}
}
else {
if (GenDesc->gY < GenDesc->gEndY) {
/* The generator is done */
afree(GenDesc,g);
*Pointer = NULL;
return;
}
/*
* Consider first object in next bin.
* If the bin is empty, we will pass through the loop again.
*/
i = GenDesc->gLayer;
if (SymbolDesc->sBin[i] == NULL) {
/* The generator is done */
afree(GenDesc,g);
*Pointer = NULL;
return;
}
GenDesc->gPointer = SymbolDesc->sBin[i][GenDesc->gX][GenDesc->gY];
++(GenDesc->gX);
if (GenDesc->gX > GenDesc->gEndX) {
GenDesc->gX = GenDesc->gBeginX;
--(GenDesc->gY);
}
}
}
}
void
CDInitTGen(Pointer,TGen)
struct o *Pointer;
struct t **TGen;
{
struct c *CallDesc;
if (Pointer == NULL)
return;
if (Pointer->oType != CDSYMBOLCALL)
return;
CallDesc = (struct c *)Pointer->oRep;
*TGen = CallDesc->cT;
}
void
CDTGen(TGen,Type,X,Y)
struct t **TGen;
char *Type;
int *X,*Y;
{
static int FirstDesc = True;
if (*TGen == NULL)
return;
elif (FirstDesc) {
FirstDesc = False;
*X = (*TGen)->tX;
*Y = (*TGen)->tY;
*Type = (*TGen)->tType;
}
else {
*TGen = (*TGen)->tSucc;
if (*TGen == NULL) {
FirstDesc = True;
return;
}
*X = (*TGen)->tX;
*Y = (*TGen)->tY;
*Type = (*TGen)->tType;
}
}
/*======================================================================*
* *
* CCCC III FFFFF *
* C I F *
* C I FFFF *
* C I F *
* CCCC III F *
* *
* TTTTT RRRR A N N SSSS L A TTTTT III OOO N N *
* T R R A A NN N S L A A T I O O NN N *
* T RRRR A A N N N SSS L A A T I O O N N N *
* T R R AAAAA N NN S L AAAAA T I O O N NN *
* T R R A A N N SSSS LLLLL A A T III OOO N N *
* *
* *
* *
* CDUpdate(SymbolDesc,SymbolFile) *
* CDGenCIF(FileDesc,SymbolDesc,SymbolNum,A,B) *
* CDTo(CIFFile,Root,A,B,Program) *
* CDFrom(Root,CIFFile,A,B,Layers,NumLayers,Program) *
* CDUnmark(SymbolDesc) *
* *
*======================================================================*/
int
CDUpdate(SymbolDesc,SymbolFile)
struct s *SymbolDesc;
char *SymbolFile;
{
/*
* Update symbol to symbol file.
* If SymbolFile == NULL, update to file SymbolDesc->sName.
* Returns True if success, else returns False.
*/
FILE *FileDesc;
struct g *GenDesc;
struct o *Pointer;
struct t *TGen;
struct p *Path;
struct prpty *PrptyDesc;
char *Label;
char *SymbolName;
int Layer;
int X,Y,Length,Width;
int NumX,NumY;
int DX,DY;
char Type,Xform;
if (SymbolFile == NULL) {
if ((FileDesc = POpen(SymbolDesc->sName,"w",(char *)NULL,(char **)NULL))
== NULL) return (False);
fprintf(FileDesc,"(Symbol %s);\n",SymbolDesc->sName);
}
else {
char *s, *strrchr();
int i;
if ((FileDesc = POpen(SymbolFile,"w",(char *)NULL,(char **)NULL))
== NULL) return (False);
/* SRW strip off path prefix */
s = strrchr(SymbolFile,DIRC);
if (s) {
*s = 0;
for (i = 0, s++; *s; i++, s++)
SymbolFile[i] = *s;
SymbolFile[i] = '\0';
}
fprintf(FileDesc,"(Symbol %s);\n",SymbolFile);
}
fprintf(FileDesc,"9 %s;\n",SymbolDesc->sName);
/* add property list info */
CDProperty(SymbolDesc,(struct o *)NULL,&PrptyDesc);
while(PrptyDesc != NULL) {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
GenBeginSymbol(FileDesc,0,1L,1L);
SymbolDesc->sLeft = SymbolDesc->sBottom = CDINFINITY;
SymbolDesc->sRight = SymbolDesc->sTop = -CDINFINITY;
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
/* add symbol name extension */
fprintf(FileDesc,"9 %s;\n",SymbolName);
/* add property list info */
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while(PrptyDesc != NULL) {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
/* add symbol array extension */
if (NumX != 1 Or NumY != 1)
fprintf(FileDesc,"1 Array %d %d %d %d;\n",NumX,DX,NumY,DY);
fprintf(FileDesc,"C 0");
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) {
fprintf(FileDesc,";\n");
break;
}
elif (Type == CDROTATE)
fprintf(FileDesc," R %d %d",X,Y);
elif (Type == CDTRANSLATE)
fprintf(FileDesc," T %d %d",X,Y);
elif (Type == CDMIRRORX)
fprintf(FileDesc," MX");
elif (Type == CDMIRRORY)
fprintf(FileDesc," MY");
}
SymbolDesc->sLeft = min(SymbolDesc->sLeft,Pointer->oLeft);
SymbolDesc->sBottom = min(SymbolDesc->sBottom,Pointer->oBottom);
SymbolDesc->sRight = max(SymbolDesc->sRight,Pointer->oRight);
SymbolDesc->sTop = max(SymbolDesc->sTop,Pointer->oTop);
}
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return (CDError(CDMALLOCFAILED));
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
continue;
GenLayer(FileDesc,CDLayer[Layer].lTechnology,CDLayer[Layer].lMask);
loop{
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while(PrptyDesc != NULL) {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
CDType(Pointer,&Type);
if (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
GenWire(FileDesc,Width,Path);
}
elif (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
GenPolygon(FileDesc,Path);
}
elif (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
fprintf(FileDesc,"94 %s %d %d %d",Label,X,Y,Xform);
fprintf(FileDesc,";\n");
}
elif (Type == CDBOX) {
CDBox(Pointer,&Layer,&Length,&Width,&X,&Y);
GenBox(FileDesc,Length,Width,X,Y,1,0);
}
SymbolDesc->sLeft = min(SymbolDesc->sLeft,Pointer->oLeft);
SymbolDesc->sBottom = min(SymbolDesc->sBottom,Pointer->oBottom);
SymbolDesc->sRight = max(SymbolDesc->sRight,Pointer->oRight);
SymbolDesc->sTop = max(SymbolDesc->sTop,Pointer->oTop);
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
}
}
if (SymbolDesc->sLeft == CDINFINITY)
SymbolDesc->sLeft = SymbolDesc->sBottom = SymbolDesc->sRight =
SymbolDesc->sTop = 0;
GenEndSymbol(FileDesc);
GenEnd(FileDesc);
fclose(FileDesc);
CDDesc.dSymbolDesc->sBBValid = True;
return (True);
}
int
CDGenCIF(FileDesc,SymbolDesc,SymbolNum,A,B,Program)
FILE *FileDesc;
struct s *SymbolDesc;
int *SymbolNum;
int A,B;
char Program;
{
struct g *GenDesc;
struct o *Pointer;
struct s *MasterDesc;
struct p *Pair,*Path;
struct t *TGen;
struct prpty *PrptyDesc;
char *SymbolName;
char *Label;
int Layer;
int X,Y,Length,Width;
int NumX,NumY;
int DX,DY;
int Info;
int i,j;
int Left,Bottom,Right,Top;
int OutputLayer;
char Type,Xform;
*SymbolNum += 1;
/*
* Mark symbol associated withSymbolDesc as visited by storing
* its symbol # in its info field. VERY NICE.
*/
CDSetInfo(SymbolDesc,(struct o *)NULL,*SymbolNum);
/*
* First write to the CIF file any symbol definitions below
* the symbol associated with SymbolDesc.
*/
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
if (Not CDOpen(SymbolName,&MasterDesc,'w'))
return (False);
CDInfo(MasterDesc,(struct o *)NULL,&Info);
if (Info == 0)
/* Write master's definition to CIF file. */
if (Not CDGenCIF(FileDesc,MasterDesc,SymbolNum,A,B,Program))
return (False);
}
/*
* Write to the CIF file the definition of the symbol associated with
* SymbolDesc. Instance calls first--then geometries.
*/
if (Program == 'e') {
CDProperty(SymbolDesc,(struct o *)NULL,&PrptyDesc);
while(PrptyDesc != NULL) {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
CDInfo(SymbolDesc,(struct o *)NULL,&Info);
fprintf(FileDesc,"DS %d 1 1;\n",Info);
/* write symbol rename extension */
if (Program == 'b' Or Program == 'a') /* NCA/Stanford CIF */
fprintf(FileDesc,"( %s );\n",SymbolDesc->sName);
elif (Program == 'i') /* Icarus style CIF */
fprintf(FileDesc,"( 9 %s );\n",SymbolDesc->sName);
elif (Program == 's') /* SIF style CIF */
fprintf(FileDesc,"( Name: %s );\n",SymbolDesc->sName);
else /* KIC/CD default */
fprintf(FileDesc,"9 %s;\n",SymbolDesc->sName);
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
if (Not CDOpen(SymbolName,&MasterDesc,'w'))
return (False);
CDInfo(MasterDesc,(struct o *)NULL,&Info);
if (Not CDBB(MasterDesc,(struct o *)NULL,&Left,&Bottom,&Right,&Top))
return (False);
for (i = 1;i <= NumY;++i) {
for (j = 1;j <= NumX;++j) {
/* write property list extension */
if (Program == 'e') {
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while(PrptyDesc != NULL) {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
fprintf(FileDesc,"C %d",Info);
if (i > 1 || j > 1)
fprintf(FileDesc," T %d %d",
((j-1)*DX)*A/B,((i-1)*DY)*A/B);
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) {
fprintf(FileDesc,";\n");
break;
}
elif (Type == CDROTATE)
fprintf(FileDesc," R %d %d",X,Y);
elif (Type == CDTRANSLATE)
fprintf(FileDesc," T %d %d",X*A/B,Y*A/B);
elif (Type == CDMIRRORX)
fprintf(FileDesc," MX");
elif (Type == CDMIRRORY)
fprintf(FileDesc," MY");
}
}
}
}
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
int FirstT = True;
if (CDLayer[Layer-1].lCDFrom) {
OutputLayer = True;
}
else
OutputLayer = False;
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return (CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
if (FirstT) {
if (Program == 'b') /* NCA style CIF */
fprintf(FileDesc,"L %d;\n",Layer);
else
GenLayer(FileDesc,CDLayer[Layer].lTechnology,
CDLayer[Layer].lMask);
FirstT = False;
}
/* write property list extension */
if (Program == 'e') {
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while(PrptyDesc != NULL And Program == 'e') {
fprintf(FileDesc,"5 %d %s;\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
CDType(Pointer,&Type);
if (!OutputLayer && Type != CDLABEL) {
continue;
/* output all labels */
}
elif (Type == CDBOX) {
CDBox(Pointer,&Layer,&Length,&Width,&X,&Y);
GenBox(FileDesc,Length*A/B,Width*A/B,X*A/B,Y*A/B,1,0);
}
elif (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
if (Path->pSucc == NULL)
fprintf(FileDesc,"W %d %d %d",Width*A/B,
Path->pX*A/B,Path->pY*A/B);
else {
fprintf(FileDesc,"W %d",Width*A/B);
Pair = Path;
while(Pair != NULL) {
fprintf(FileDesc," %d %d",Pair->pX*A/B,Pair->pY*A/B);
Pair = Pair->pSucc;
}
}
fprintf(FileDesc,";\n");
}
elif (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
fprintf(FileDesc,"P");
Pair = Path;
while(Pair != NULL) {
fprintf(FileDesc," %d %d",Pair->pX*A/B,Pair->pY*A/B);
Pair = Pair->pSucc;
}
fprintf(FileDesc,";\n");
}
elif (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
if (Program == 'k' Or Program == 'e') /* KIC/CD label */
fprintf(FileDesc,"94 %s %d %d %d;\n",
Label,X*A/B,Y*A/B,(char)Xform);
elif (Program == 'b') /* NCA label */
fprintf(FileDesc,"94 %s %d %d %d;\n",
Label,X*A/B,Y*A/B,Layer);
elif (Program == 'm') { /* mextra label */
fprintf(FileDesc,"94 %s %d %d",Label,X*A/B,Y*A/B);
if (CDLayer[Layer].lTechnology != ' ') {
fprintf(FileDesc," %c",CDLayer[Layer].lTechnology);
i = 0;
while(i < 3 And CDLayer[Layer].lMask[i] > 040) {
fprintf(FileDesc,"%c",CDLayer[Layer].lMask[i]);
i++;
}
}
fprintf(FileDesc,";\n");
}
}
}
}
GenEndSymbol(FileDesc);
return (True);
}
int
CDTo(CIFFile,Root,A,B,Program)
char *CIFFile,*Root;
int A,B;
char Program;
{
/*
* Translate from CIF file into symbol files.
* Each time we see a symbol definition, we write it in its own file.
* The problem is that commands may be in the file that aren't part of a
* symbol definition. The solution is to have a file named Root for
* the commands.
*/
int Int1;
int StatusInt;
char *StatusString;
CDDesc.dControl = DCONTROLCDTO;
/*
* On the first pass, we just fill the symbol name table.
*/
CDDesc.dFirstPass = True;
CDDesc.dNumSymbolTable = 0;
for (Int1 = 0;Int1 < CDNUMREMEMBER;++Int1) {
CDDesc.dSymTabNames[Int1][0] = EOS;
CDDesc.dSymTabNumbers[Int1] = -1;
}
if ((CDDesc.dProgram = Program) != 'n') {
PCIF(CIFFile,&StatusString,&StatusInt);
if (StatusInt == PFAILED) {
CDStatusInt = CDPARSEFAILED;
strcpy(CDStatusString,StatusString);
return (False);
}
}
/*
* On the second pass, we do the sequential translation.
*/
CDDesc.dFirstPass = False;
CDDesc.dPrptyList = NULL;
CDDesc.dA = A;
CDDesc.dB = B;
CDDesc.dDSA = CDDesc.dDSB = 1;
CDDesc.dRoot = True;
CDDesc.dSymbolName[0] = EOS;
if ((CDDesc.dRootFileDesc = POpen(Root,"w",(char *)NULL,(char **)NULL))
== NULL) {
sprintf(CDStatusString,"Can't open file Root.");
CDStatusInt = CDPARSEFAILED;
return (False);
}
fprintf(CDDesc.dRootFileDesc,"(Symbol %s.);\n",Root);
fprintf(CDDesc.dRootFileDesc,"(Microns/lambda = %d/%d);\n",A,B);
fprintf(CDDesc.dRootFileDesc,"9 %s;\n",Root);
GenBeginSymbol(CDDesc.dRootFileDesc,0,1,1);
PCIF(CIFFile,&StatusString,&StatusInt);
if (StatusInt == PFAILED) {
CDStatusInt = CDPARSEFAILED;
strcpy(CDStatusString,StatusString);
return (False);
}
else
CDStatusInt = CDSUCCEEDED;
GenEndSymbol(CDDesc.dRootFileDesc);
GenEnd(CDDesc.dRootFileDesc);
fclose(CDDesc.dRootFileDesc);
CDDesc.dControl = DCONTROLVANILLA;
return (True);
}
int
CDFrom(Root,CIFFile,A,B,Layers,NumLayers,Program)
char *Root,*CIFFile,Program;
int A,B;
int Layers[],NumLayers;
{
/*
* Translate symbol hierarchy rooted with symbol named Root into
* CIF file named CIFFile.
*/
struct s *SymbolDesc;
FILE *FileDesc;
int SymbolNum = 0;
int Info;
int Layer;
if ((FileDesc = POpen(CIFFile,"w",(char *)NULL,(char **)NULL)) == NULL) {
CDStatusInt = CDPARSEFAILED;
sprintf(CDStatusString,"Can't open CIF file.");
return (False);
}
if (Not CDOpen(Root,&SymbolDesc,'r')) {
CDStatusInt = CDPARSEFAILED;
return (False);
}
if (CDStatusInt == CDNEWSYMBOL) {
sprintf(CDStatusString,"Can't open file %s.",Root);
return (False);
}
if (Layers[0])
CDLayer[0].lCDFrom = True;
else
CDLayer[0].lCDFrom = False;
for (Layer = 1; Layer < NumLayers; ++Layer)
CDLayer[Layer].lCDFrom = True;
fprintf(FileDesc,"(CIF file of symbol hierarchy rooted at %s);\n",Root);
if (Not CDGenCIF(FileDesc,SymbolDesc,&SymbolNum,A,B,Program))
return (False);
CDInfo(SymbolDesc,(struct o *)NULL,&Info);
fprintf(FileDesc,"C %d;\nE\n",Info);
fclose(FileDesc);
/*
* Really should set all of the info fields in all symbol descs to 0.
* CDUnmark(SymbolDesc);
*/
return (True);
}
int
CDParseCIF(Root,CIFFile,Program)
char *Root,*CIFFile,Program;
{
/*
* Construct CD database from a CIF file rather than a hierarchy
* of cell files.
*/
struct m *MasterListDesc1;
struct m *MasterListDesc2;
struct s *MasterSymbolDesc1;
struct s *MasterSymbolDesc2;
char *StatusString;
int StatusInt;
int Int1;
CDDesc.dProgram = Program;
CDDesc.dA = CDDesc.dB = 1;
CDDesc.dDSA = CDDesc.dDSB = 1;
CDDesc.dRoot = True;
CDDesc.dControl = DCONTROLPCIF;
CDDesc.dSymbolDesc = CDDesc.dRootCellDesc;
if (Not CDOpen(Root,&CDDesc.dRootCellDesc,'n')) {
CDStatusInt = CDMALLOCFAILED;
return (False);
}
CDDesc.dControl = DCONTROLPCIF;
/*
* On the first pass, we just fill the symbol name table.
*/
CDDesc.dFirstPass = True;
CDDesc.dNumSymbolTable = 0;
for (Int1 = 0;Int1 < CDNUMREMEMBER;++Int1) {
CDDesc.dSymTabNames[Int1][0] = EOS;
CDDesc.dSymTabNumbers[Int1] = -1;
}
PCIF(CIFFile,&StatusString,&StatusInt);
if (StatusInt == PFAILED) {
CDStatusInt = CDPARSEFAILED;
strcpy(CDStatusString,StatusString);
return (False);
}
/*
* On the second pass, we do the sequential translation.
*/
CDDesc.dFirstPass = False;
PCIF(CIFFile,&StatusString,&StatusInt);
if (StatusInt == PFAILED) {
CDStatusInt = CDPARSEFAILED;
strcpy(CDStatusString,StatusString);
return (False);
}
MasterListDesc1 = CDDesc.dRootCellDesc->sMasterList;
while(MasterListDesc1 != NULL) {
CDOpen(MasterListDesc1->mName,&MasterSymbolDesc1,'r');
if (CDStatusInt == CDNEWSYMBOL Or CDStatusInt == CDPARSEFAILED) {
if (CDStatusInt == CDNEWSYMBOL) {
CDStatusInt = CDPARSEFAILED;
sprintf(CDStatusString,"Master %s doesn't seem to be around.\n",
MasterListDesc1->mName);
}
return (False);
}
MasterListDesc2 = MasterSymbolDesc1->sMasterList;
while(MasterListDesc2 != NULL) {
CDOpen(MasterListDesc2->mName,&MasterSymbolDesc2,'r');
if (CDStatusInt == CDNEWSYMBOL Or CDStatusInt == CDPARSEFAILED) {
if (CDStatusInt == CDNEWSYMBOL) {
CDStatusInt = CDPARSEFAILED;
sprintf(CDStatusString,
"Master %s doesn't seem to be around.\n",
MasterListDesc2->mName);
}
return (False);
}
if (Not CDReflect(MasterSymbolDesc2)) {
CDStatusInt = CDPARSEFAILED;
return (CDError(CDMALLOCFAILED));
}
MasterListDesc2 = MasterListDesc2->mSucc;
}
if (Not CDReflect(MasterSymbolDesc1)) {
CDStatusInt = CDPARSEFAILED;
return (CDError(CDMALLOCFAILED));
}
MasterListDesc1 = MasterListDesc1->mSucc;
}
if (Not CDReflect(CDDesc.dRootCellDesc)) {
CDStatusInt = CDPARSEFAILED;
return (CDError(CDMALLOCFAILED));
}
return (True);
}
int
CDUnmark(SymbolDesc)
struct s *SymbolDesc;
{
struct g *GenDesc;
struct o *Pointer;
char *SymbolName;
int NumX,NumY;
int DX,DY;
int Info;
int Layer;
struct s *MasterDesc;
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return (CDError(CDMALLOCFAILED));
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"\n\n");
fprintf(stderr,"1CDUnmark: Inititialezed generator on instance layer.\n\n");
#endif
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"2CDUnmark: CDGen found instance: Pointer = 0x%x\n\n",Pointer);
#endif
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"3CDUnmark: instance name = %s\n\n",SymbolName);
#endif
/*
* Cell has already been mapped into memory. Therefore,
* we can assume that CDOpen does not fail in the parse.
*/
if (Not CDOpen(SymbolName,&MasterDesc,'r'))
return (CDError(CDMALLOCFAILED));
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"4CDUnmark: CDOpen returned MasterDesc = 0x%x\n\n",MasterDesc);
#endif
CDInfo(MasterDesc,(struct o *)NULL,&Info);
if (Info != 0) {
/* Unmark master */
CDSetInfo(MasterDesc,(struct o *)NULL,0);
if (Not CDUnmark(MasterDesc))
return (False);
}
}
for (Layer = 1; Layer <= CDNUMLAYERS; ++Layer) {
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return (CDError(CDMALLOCFAILED));
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"5CDUnmark: Inititialezed generator on layer %d.\n\n",Layer);
#endif
loop{
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
#ifdef DEBUG_CDUNMARK
fprintf(stderr,"6CDUnmark: CDGen found instance: Pointer = 0x%x\n\n",Pointer);
#endif
CDInfo(SymbolDesc,(struct o *)NULL,&Info);
if (Info != 0) {
/* Unmark geometry */
CDSetInfo(SymbolDesc,Pointer,0);
}
}
}
return (True);
}
/*======================================================================*
* *
* EEEEE RRRR RRRR OOO RRRR *
* E R R R R O O R R *
* EEE RRRR RRRR O O RRRR *
* E R R R R O O R R *
* EEEEE R R R R OOO R R *
* *
* RRRR OOO U U TTTTT III N N EEEEE SSSS *
* R R O O U U T I NN N E S *
* RRRR O O U U T I N N N EEE SSS *
* R R O O U U T I N NN E S *
* R R OOO UUU T III N N EEEEE SSSS *
* *
* *
* *
* CDError(ID) *
* *
*======================================================================*/
int
CDError(ID)
int ID;
{
CDStatusInt = ID;
switch(ID) {
case CDMALLOCFAILED:
sprintf(CDStatusString,"CD Out of memory.");
return (False);
case CDBADBOX:
sprintf(CDStatusString,"Can't allow a zero width box.");
/* not a fatal error */
return (True);
case CDXFORMSTACKFULL:
sprintf(CDStatusString,"Transform stack is full.");
return (False);
case CDBADPATH:
sprintf(CDStatusString,"Can't set search path.");
return (False);
default:
sprintf(CDStatusString,"Unknown Error.");
return (False);
}
}
kic-2.4c/src/cd/nmalloc.c 0000644 0000764 0000764 00000015031 07525346710 014673 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Peter P. Moore, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* nmalloc.c
*
* A new malloc/free package for virtual memory machines.
*
* A seperate freelist is kept for each object of size
* sizeof(NM_ALIGN) to NM_MAX_INDEX*sizeof(NM_ALIGN), where NM_ALIGN is
* the smallest-sized type having the most stringent alignment
* requirement on the particular machine. ( i.e. an int on the VAX ).
* Any objects larger than NM_MAX_INDEX*sizeof(NM_ALIGN) is allocated
* and free'd by using the old malloc and free respectively. The space
* is allocated in blocks of size BLOCK_SIZE, but this can be changed
* by calling nm_set_block_size(new_size). The relevant routines are :
*
* nm_malloc(size) : same syntax and usage as the old malloc.
*
* nm_free(ptr, size) : free the object pointed to by ptr and
* of size 'size'.
*
* In order to allow compatibility with the old malloc and free
* three macros are defined in nmalloc.h : malloc(size), free(ptr), and
* alloc(type). Malloc and free are the same as of old, alloc returns
* a properly cast pointer to an object of type 'type' ( i.e. it will
* keep lint quiet ). So to replace the old malloc/free, simply put
* #include "nmalloc.h" in any file that does malloc or free and
* recompile with nmalloc.o.
*
* Keep the following dire warnings in mind :
*
* You may use the old and new mallocs in the same program,
* but DO NOT use my free on something the old malloc allocated
* or vice-versa.
*
* If you use the free(ptr) macro, sizeof(*ptr) better be
* the same as the size you used in the malloc, i.e.
*
* int *ptr;
* ptr = (int *)malloc(40);
* free(ptr);
*
* will cause the allocated object of size 40 to be placed
* in the freelist for objects of size 4 ( sizeof(int) = 4
* on a VAX). This could cause extreme difficulties. You
* don`t have to worry about this if all your allocations
* are of the form :
*
* thing *ptr;
* ptr = (thing *) malloc(sizeof(thing))
* (* usage of ptr *)
* free(ptr);
*
* or better yet :
*
* thing *ptr;
* ptr = alloc(thing);
* (* usage of pointers *)
* free(ptr);
*
* But if you are doing a lot of type casting of pointers or
* other jockish things, then explicit use of nm_free(ptr,size)
* is suggested.
*
*
* The *( (char **) ptr) constructs are used to recast portions
* of the objects as linking pointers to chain them to the
* freelist.
*/
#include "prefix.h"
#include "nmalloc.h"
#define BLOCK_SIZE 2048 /* the amount of space requested in
each block allocation */
static int nm_block_size = BLOCK_SIZE;
#ifndef USE_OLD_MALLOC
#define NM_MAX_INDEX 20 /* see above description */
#define NM_ALIGN int /* see above description */
#define nm_align(size)\
/* round size to next largest multiple of sizeof(NM_ALIGN) */\
(( int )(( (int) size + sizeof(NM_ALIGN) - 1)/sizeof(NM_ALIGN)))
#ifdef __STDC__
static char *nm_block_alloc(int);
#else
static char *nm_block_alloc();
#endif
static char *nm_freelist[NM_MAX_INDEX + 1];
char *
nm_malloc(size)
unsigned int size;
{
/*
* Return a pointer to an object of size 'size',
* allocating a new block of free space if necessary
*/
char *temp;
int index;
index = nm_align(size);
if (index > NM_MAX_INDEX) /* too large, use old malloc */
return malloc(size);
else if (nm_freelist[index] == (char *) 0) {
/* out of free space, allocate a new block */
return nm_block_alloc(index);
}
else {
/* return the top item on the freelist */
temp = nm_freelist[index];
nm_freelist[index] = *(char **) temp;
*(char **) temp = (char *) 0;
return temp;
}
}
void
nm_free(ptr,size)
char *ptr;
int size;
{
/*
* Free the object pointed to by ptr of size 'size'
*/
int index;
index = nm_align(size);
if (index > NM_MAX_INDEX) /* too large, use old free */
free(ptr);
else {
/* link to the top of the freelist */
*(char **) ptr = nm_freelist[index];
nm_freelist[index] = (char *) ptr;
}
}
static char *
nm_block_alloc(index)
int index;
{
/*
* Allocate a block of size nm_block_size, aligned to the
* sizeof(NM_ALIGN)
*/
char *ptr;
char *current_pos, *start_of_block, *end_of_block;
int size = sizeof(NM_ALIGN)*index;
#ifdef VMS
if ((start_of_block = (char *) malloc(nm_block_size)) == (char *) 0)
return (char *) 0;
#else
current_pos = sbrk(0);
start_of_block = (char *) (nm_align(current_pos)*sizeof(NM_ALIGN));
#endif
end_of_block = start_of_block + nm_block_size;
#ifndef VMS
if ((int)sbrk((int)(end_of_block - current_pos)) == -1L)
/* out of memory */
return( (char *) 0);
#endif
end_of_block -= 2*size;
for(ptr = start_of_block; ptr <= end_of_block; ptr += size) {
/* link all the objects in the new block together */
*(char **) ptr = ptr + size;
}
*(char **) ptr = (char *) 0;
nm_freelist[index] = start_of_block + size;
return start_of_block;
}
#endif /* USE_OLD_MALLOC */
void
nm_set_block_size(size)
int size;
{
nm_block_size = size;
}
kic-2.4c/src/cd/misc.c 0000644 0000764 0000764 00000001771 12427260403 014176 0 ustar stevew stevew #include
#include
/* Some library functions that might not be around. */
char *
to_lower_case(char *string)
{
char *s = string;
if (s == NULL) return NULL;
while (*s) {
if (isupper(*s)) *s = tolower(*s);
s++;
}
return string;
}
#ifndef NOTUSED
/* library does not have the stricmp(), strnicmp() functions */
int
stricmp(char *s1, char *s2)
{
char c, d;
while (*s2) {
c = *s1;
d = *s2;
if (c == '\0') return -1;
if (isupper(c)) c = tolower(c);
if (isupper(d)) d = tolower(d);
if (c != d) return c-d;
s1++;
s2++;
}
return 0;
}
int
strnicmp(char *s1, char *s2, int n)
{
char c, d;
while (n--) {
c = *s1;
d = *s2;
if (c == '\0') return -1;
if (d == '\0') return 1;
if (isupper(c)) c = tolower(c);
if (isupper(d)) d = tolower(d);
if (c != d) return c-d;
s1++;
s2++;
}
return 0;
}
#endif
kic-2.4c/src/cd/actions.c 0000644 0000764 0000764 00000117223 10261421055 014677 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Action routines for fast CIF parser.
*
* These routines handle both conversion from and to CIF.
* AEnd will be the last routine invoked in a successful parse.
*/
#include "prefix.h"
#include "cd.h"
#include "parser.h"
#ifdef VMS
#include
#include
#else
#include
#include
#endif
#define RADTODEG 57.29577951
static int CurrentLayer;
static char TypeOut[200];
static double ScaleFactor;
#define SCALE(x) ((int)(x*ScaleFactor))
void
AEnd()
{
/*
* The CIF parsing has ended.
*/
#ifdef TRACEPARSER
GenEnd(stderr);
#endif
}
int
ABeginSymbol(SymbolNum,A,B)
int SymbolNum;
int A,B;
{
/*
* This routine begins the parsing action for a symbol definition
* and performs all necessary initialization for the new symbol.
*
* DCONTROLCDTO:
* On the first pass, we add the symbol name to the symbol table
* which is in CDDesc.dSymTabNames. To do this we have to switch
* according to the value of 'CDDesc.dProgram' which specifies
* the style of the CIF. On the second pass, we open the FILE
* descriptor for the KIC cell that coresponds to the respective
* CIF symbol and write the header information in the KIC cell.
*
* DCONTROLPCIF:
* On the first pass, we add the symbol name to the symbol table
* which is in CDDesc.dSymTabNames. To do this we have to switch
* according to the value of 'CDDesc.dProgram' which specifies
* the style of the CIF. Also, we open the symbol in the database
* via CDOpen() which places the symbol name in the hash table
* which is in CDSymbolTable. We must not invoke CDClose since
* that will remove the symbol from memory; the purpose of
* DCONTROLPCIF is to construct the database in memory without
* relying on a KIC cell directory in the current search path.
* On the second pass, we need only invoke CDSymbol() to obtain
* the symbol desc. for the respective symbol.
*
* DCONTROLCDOPEN
* No action. It is assumed that the file being parsed is a KIC
* cell which will always contain exactly one CIF symbol.
*/
time_t Long1;
int Int1 = 0;
#ifdef TRACEPARSER
GenBeginSymbol(stderr,SymbolNum,A,B);
#endif
CurrentLayer = 0;
if (CDDesc.dControl == DCONTROLCDTO Or CDDesc.dControl == DCONTROLPCIF) {
CDDesc.dRoot = False;
CDDesc.dDSA = A;
CDDesc.dDSB = B;
/*
* We switch on the following:
* k KIC: A KIC symbol name follows a DS command as in 9 PadIn;
* a Stanford: Stanford symbol name follows a DS command as in (PadIn);
* b NCA: An NCA symbol name follows a DS command as in (PadIn);
* h IGS: An IGS symbol name follows a DS command as in 9 PadIn;
* i Icarus: An Icarus name follows a DS command as in (9 PadIn);
* s Sif: A Sif name follows a DS command as in (Name: PadIn);
* n none of the above
*/
if (CDDesc.dProgram == 'i') {
/*
* Icarus files have the symbol name in a comment of the form
* (9 SymbolName); after the DS command.
*/
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == '9')
break;
}
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ')') {
CDDesc.dSymbolName[Int1] = EOS;
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
strcpy(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
CDDesc.dSymbolName);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
}
elif (PChar == ';')
break;
else
if (Int1 < FILENAMESIZE)
CDDesc.dSymbolName[Int1++] = PChar;
}
}
elif (CDDesc.dProgram == 'a' Or CDDesc.dProgram == 'b') {
/*
* Some files have the symbol name in a comment of the form
* (SymbolName); after the DS command.
*/
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == '(')
break;
}
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ')') {
CDDesc.dSymbolName[Int1] = EOS;
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
strcpy(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
CDDesc.dSymbolName);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
}
elif (PChar == ';')
break;
else {
if (Int1 < FILENAMESIZE)
CDDesc.dSymbolName[Int1++] = PChar;
}
}
}
elif (CDDesc.dProgram == 's') {
/*
* Sif files have the symbol name in a comment of the form
* ( Name: SymbolName); after the DS command.
*/
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ':')
break;
}
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ')') {
CDDesc.dSymbolName[Int1] = EOS;
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
strcpy(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
CDDesc.dSymbolName);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
}
elif (PChar == ';')
break;
else
if (Int1 < FILENAMESIZE)
CDDesc.dSymbolName[Int1++] = PChar;
}
}
elif (CDDesc.dProgram == 'q') {
/*
* SQUID files have the symbol name in the form
* 9 FullName; after the DS command where FullName
* is the full pathname to the cell or directory.
*
* NOTE: This code only works for UNIX file names.
*/
char PrevName[FILENAMESIZE];
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == '9')
break;
}
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
CDDesc.dSymbolName[Int1] = EOS;
if (Int1 == 1 And CDDesc.dSymbolName[0] == '.')
strcpy(CDDesc.dSymbolName,PrevName);
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
strcpy(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
CDDesc.dSymbolName);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
break;
}
elif (PChar == '/') {
/* begin new name; last name was a directory */
Int1 = 0;
strcpy(PrevName,CDDesc.dSymbolName);
}
else
if (Int1 < FILENAMESIZE)
CDDesc.dSymbolName[Int1++] = PChar;
}
}
elif (CDDesc.dProgram == 'h' Or CDDesc.dProgram == 'k') {
/*
* IGS and KIC files have the symbol name in the form
* 9 SymbolName; after the DS command.
*/
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == '9')
break;
}
loop {
PReturned = PCharacter(PSTRIPWHITESPACE1,PFAILONEOF);
if (PReturned == PFAILED)
return (PFAILED);
elif (PChar == ';') {
CDDesc.dSymbolName[Int1] = EOS;
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
strcpy(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
CDDesc.dSymbolName);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
break;
}
else
if (Int1 < FILENAMESIZE)
CDDesc.dSymbolName[Int1++] = PChar;
}
}
if (CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass) {
/*
* Open the symbol, but don't search the current directory
* for a KIC cell. Also, don't close the symbol since
* that would remove the symbol from memory.
*/
for (Int1 = 0; Int1 < CDDesc.dNumSymbolTable; ++Int1)
if (CDDesc.dSymTabNumbers[Int1] == SymbolNum) break;
if (Int1 == CDDesc.dNumSymbolTable) {
if (CDDesc.dNumSymbolTable < CDNUMREMEMBER) {
sprintf(CDDesc.dSymTabNames[CDDesc.dNumSymbolTable],
"Symbol%d",SymbolNum);
CDDesc.dSymTabNumbers[CDDesc.dNumSymbolTable]
= SymbolNum;
++CDDesc.dNumSymbolTable;
}
else
return (PFAILED);
}
if (!CDOpen(CDDesc.dSymTabNames[Int1],
&CDDesc.dSymbolDesc,'n'))
return (PFAILED);
}
else{
/*
* Symbol is already open. Just get the desc for it.
*/
for (Int1 = 0; Int1 < CDDesc.dNumSymbolTable; ++Int1)
if (CDDesc.dSymTabNumbers[Int1] == SymbolNum) break;
if (Int1 == CDDesc.dNumSymbolTable)
return (PFAILED);
CDSymbol(CDDesc.dSymTabNames[Int1],&CDDesc.dSymbolDesc);
if (CDDesc.dSymbolDesc == NULL)
return (PFAILED);
}
CDDesc.dControl = DCONTROLPCIF;
}
elif (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
if (CDDesc.dSymbolName[0] == EOS)
sprintf(CDDesc.dSymbolName,"Symbol%d",SymbolNum);
if ((CDDesc.dSymbolFileDesc = POpen(CDDesc.dSymbolName,"w",
(char *)NULL,(char **)NULL)) == NULL)
return (PFAILED);
ScaleFactor = CDDesc.dB;
ScaleFactor *= CDDesc.dDSA;
ScaleFactor /= CDDesc.dA;
ScaleFactor /= CDDesc.dDSB;
sprintf(TypeOut," Symbol %s ",CDDesc.dSymbolName);
GenComment(CDDesc.dSymbolFileDesc,TypeOut);
Long1 = time((time_t *)NULL);
sprintf(TypeOut," Creation Date: %.24s ",ctime((time_t *)&Long1));
GenComment(CDDesc.dSymbolFileDesc,TypeOut);
GenUserExtension(CDDesc.dSymbolFileDesc,'9',CDDesc.dSymbolName);
GenBeginSymbol(CDDesc.dSymbolFileDesc,0,1,1);
CDDesc.dSymbolName[0] = EOS;
}
}
elif (CDDesc.dControl == DCONTROLCDOPEN) {
/* add property list information */
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,(struct o *)NULL,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
void
AEndSymbol()
{
/*
* This routine performs the necessary actions to close a symbol
* definition.
*
* DCONTROLCDTO:
* Return on first pass (we are only building the symbol table).
* On the second pass, we terminate and close the KIC cell
* containing the respective CIF symbol.
*
* DCONTROLPCIF:
* We set the current cell desc in CDDesc.dSymbolDesc to that of
* the root symbol.
*
* DCONTROLCDOPEN:
* No action.
*/
#ifdef TRACEPARSER
GenEndSymbol(stderr);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return;
GenEndSymbol(CDDesc.dSymbolFileDesc);
GenEnd(CDDesc.dSymbolFileDesc);
fclose(CDDesc.dSymbolFileDesc);
CDDesc.dRoot = True;
}
elif (CDDesc.dControl == DCONTROLPCIF) {
CDDesc.dSymbolDesc = CDDesc.dRootCellDesc;
CDDesc.dRoot = True;
}
elif (CDDesc.dControl == DCONTROLCDOPEN) {
if (CDDesc.dSymbolDesc->sLeft == CDINFINITY)
CDDesc.dSymbolDesc->sLeft = CDDesc.dSymbolDesc->sBottom
= CDDesc.dSymbolDesc->sRight = CDDesc.dSymbolDesc->sTop = 0;
/*
* Force the dummy call command at the end of the symbol
* to be ignored by ABeginCall.
*/
CDDesc.dSymbolName[0] = EOS;
}
}
void
ADeleteSymbol(SymbolNum)
int SymbolNum;
{
/*
* We do not deal with definition deletes.
* It could be handled by using the symbol table to obtain the
* respective symbol numbers, and invoking CDClose on those cell
* definitions to be deleted.
*/
#ifdef TRACEPARSER
fprintf(stderr,"DD %d;\n",SymbolNum);
#endif
/*
*Ignore DD commands.
*/
fprintf(stderr,"Definition Delete of Symbol %d - ignored\n",SymbolNum);
}
int
AEndCall()
{
#ifdef TRACEPARSER
fprintf(stderr,";\n");
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
if (CDDesc.dRoot)
GenEndCall(CDDesc.dRootFileDesc);
else
GenEndCall(CDDesc.dSymbolFileDesc);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
if (Not CDEndMakeCall(CDDesc.dSymbolDesc,CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,CDDesc.dPointer,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
int
AT(Type,X,Y)
char Type;
int X,Y;
{
#ifdef TRACEPARSER
fprintf(stderr," T:%c %d %d",Type,X,Y);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
if (Type == CDTRANSLATE) {
if (CDDesc.dRoot)
GenTranslation(CDDesc.dRootFileDesc,SCALE(X),SCALE(Y));
else
GenTranslation(CDDesc.dSymbolFileDesc,SCALE(X),SCALE(Y));
}
elif (Type == CDROTATE) {
if (abs(X) > 1 Or abs(Y) > 1) {
X = SCALE(X);
Y = SCALE(Y);
}
if (CDDesc.dRoot)
GenRotation(CDDesc.dRootFileDesc,X,Y);
else
GenRotation(CDDesc.dSymbolFileDesc,X,Y);
}
elif (Type == CDMIRRORX) {
if (CDDesc.dRoot)
GenMirrorX(CDDesc.dRootFileDesc);
else
GenMirrorX(CDDesc.dSymbolFileDesc);
}
elif (Type == CDMIRRORY) {
if (CDDesc.dRoot)
GenMirrorY(CDDesc.dRootFileDesc);
else
GenMirrorY(CDDesc.dSymbolFileDesc);
}
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
return (CDT(CDDesc.dPointer,Type,X,Y));
}
return (PSUCCEEDED);
}
int
ABeginCall(SymbolNum)
int SymbolNum;
{
int Int1 = 0;
#ifdef TRACEPARSER
fprintf(stderr,"C %d ",SymbolNum);
#endif
if (CDDesc.dControl == DCONTROLPCIF Or CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
if (CDDesc.dProgram != 'n') {
for (Int1 = 0; Int1 < CDDesc.dNumSymbolTable; ++Int1)
if (CDDesc.dSymTabNumbers[Int1] == SymbolNum) break;
}
}
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dProgram != 'n' And Int1 < CDDesc.dNumSymbolTable) {
sprintf(TypeOut," %s",CDDesc.dSymTabNames[Int1]);
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,'9',TypeOut);
else
GenUserExtension(CDDesc.dSymbolFileDesc,'9',TypeOut);
}
elif (CDDesc.dSymbolName[0] != EOS) {
sprintf(TypeOut," %s",CDDesc.dSymbolName);
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,'9',TypeOut);
else
GenUserExtension(CDDesc.dSymbolFileDesc,'9',TypeOut);
}
else {
sprintf(CDDesc.dSymbolName,"Symbol%d",SymbolNum);
sprintf(TypeOut," Symbol%d",SymbolNum);
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,'9',TypeOut);
else
GenUserExtension(CDDesc.dSymbolFileDesc,'9',TypeOut);
}
if (CDDesc.dRoot)
GenBeginCall(CDDesc.dRootFileDesc,0);
else
GenBeginCall(CDDesc.dSymbolFileDesc,SymbolNum);
CDDesc.dSymbolName[0] = EOS;
}
elif (CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dProgram != 'n' And Int1 < CDDesc.dNumSymbolTable)
strcpy(CDDesc.dSymbolName,CDDesc.dSymTabNames[Int1]);
else
sprintf(CDDesc.dSymbolName,"Symbol%d",SymbolNum);
if (Not CDBeginMakeCall(CDDesc.dSymbolDesc,CDDesc.dSymbolName,
CDDesc.dNumX,CDDesc.dDX,CDDesc.dNumY,CDDesc.dDY,
&CDDesc.dPointer))
return (PFAILED);
CDDesc.dSymbolName[0] = EOS;
CDDesc.dNumX = CDDesc.dNumY = 1;
CDDesc.dDX = CDDesc.dDY = 0;
CDDesc.dControl = DCONTROLPCIF;
}
elif (CDDesc.dControl == DCONTROLCDOPEN) {
if (CDDesc.dSymbolName[0] != EOS)
if (Not CDBeginMakeCall(CDDesc.dSymbolDesc,CDDesc.dSymbolName,
CDDesc.dNumX,CDDesc.dDX,CDDesc.dNumY,CDDesc.dDY,
&CDDesc.dPointer))
return (PFAILED);
CDDesc.dSymbolName[0] = EOS;
CDDesc.dNumX = CDDesc.dNumY = 1;
CDDesc.dDX = CDDesc.dDY = 0;
}
return (PSUCCEEDED);
}
int
APolygon(Path)
struct p *Path;
{
struct p *Pair;
#ifdef TRACEPARSER
GenPolygon(stderr,Path);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
int NumVertices;
int Left,Bottom,Right,Top;
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
Pair = Path;
NumVertices = 0;
Left = Bottom = CDINFINITY;
Right = Top = -CDINFINITY;
while(Pair != NULL) {
if (Pair->pX < Left)
Left = Pair->pX;
if (Pair->pX > Right)
Right = Pair->pX;
if (Pair->pY < Bottom)
Bottom = Pair->pY;
if (Pair->pY > Top)
Top = Pair->pY;
++NumVertices;
Pair = Pair->pSucc;
}
if (NumVertices == 4) {
if ((Path->pX == Path->pSucc->pX And
Path->pSucc->pY == Path->pSucc->pSucc->pY And
Path->pSucc->pSucc->pX == Path->pSucc->pSucc->pSucc->pX And
Path->pY == Path->pSucc->pSucc->pSucc->pY)
Or
(Path->pY == Path->pSucc->pY And
Path->pSucc->pX == Path->pSucc->pSucc->pX And
Path->pSucc->pSucc->pY == Path->pSucc->pSucc->pSucc->pY And
Path->pX == Path->pSucc->pSucc->pSucc->pX))
{
return (ABox(Right-Left,Top-Bottom,Left+((Right-Left)/2),
Bottom+((Top-Bottom)/2),1,0));
}
}
Pair = Path;
while(Pair != NULL) {
Pair->pX = SCALE(Pair->pX);
Pair->pY = SCALE(Pair->pY);
Pair = Pair->pSucc;
}
if (CDDesc.dRoot)
GenPolygon(CDDesc.dRootFileDesc,Path);
else
GenPolygon(CDDesc.dSymbolFileDesc,Path);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
if (Not CDMakePolygon(CDDesc.dSymbolDesc,CurrentLayer,Path,
&CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
/* ignore a low vertex count poly */
if (CDDesc.dPointer) {
if (Not CDAddProperty(CDDesc.dSymbolDesc,CDDesc.dPointer,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
}
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
int
AWire(Width,Path)
int Width;
struct p *Path;
{
struct p *Pair;
#ifdef TRACEPARSER
GenWire(stderr,Width,Path);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
Pair = Path;
while(Pair != NULL) {
Pair->pX = SCALE(Pair->pX);
Pair->pY = SCALE(Pair->pY);
Pair = Pair->pSucc;
}
if (CDDesc.dRoot)
GenWire(CDDesc.dRootFileDesc,SCALE(Width),Path);
else
GenWire(CDDesc.dSymbolFileDesc,SCALE(Width),Path);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
if (Not CDMakeWire(CDDesc.dSymbolDesc,CurrentLayer,Width,Path,
&CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,CDDesc.dPointer,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
int
ABox(Length,Width,X,Y,XDirection,YDirection)
int Length,Width,X,Y;
int XDirection,YDirection;
{
#ifdef TRACEPARSER
GenBox(stderr,Length,Width,X,Y,XDirection,YDirection);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
Length = SCALE(Length);
Width = SCALE(Width);
X = SCALE(X);
Y = SCALE(Y);
if (XDirection == 1 And YDirection == 0) {
if (CDDesc.dRoot)
GenBox(CDDesc.dRootFileDesc,Length,Width,X,Y,
XDirection,YDirection);
else
GenBox(CDDesc.dSymbolFileDesc,Length,Width,X,Y,
XDirection,YDirection);
}
else {
/*
* Transform non-Manhattan box to polygon.
*/
float C;
int Left,Bottom,Right,Top;
struct p *Path,*Pair;
Left = X-(Length >> 1);
Right = X+(Length >> 1);
Bottom = Y-(Width >> 1);
Top = Y+(Width >> 1);
C = sqrt((double)(XDirection*XDirection+YDirection*YDirection));
if ((Pair = Path = alloc(p)) == NULL)
return (AMallocFailed());
Pair->pX = (Left*XDirection-Bottom*YDirection-
XDirection*X+YDirection*Y)/C+X;
Pair->pY = (Left*YDirection+Bottom*XDirection-
YDirection*X-XDirection*Y)/C+Y;
if ((Pair = Pair->pSucc = alloc(p)) == NULL)
return (AMallocFailed());
Pair->pX = (Left*XDirection-Top*YDirection-
XDirection*X+YDirection*Y)/C+X;
Pair->pY = (Left*YDirection+Top*XDirection-
YDirection*X-XDirection*Y)/C+Y;
if ((Pair = Pair->pSucc = alloc(p)) == NULL)
return (AMallocFailed());
Pair->pX = (Right*XDirection-Top*YDirection-
XDirection*X+YDirection*Y)/C+X;
Pair->pY = (Right*YDirection+Top*XDirection-
YDirection*X-XDirection*Y)/C+Y;
if ((Pair = Pair->pSucc = alloc(p)) == NULL)
return (AMallocFailed());
Pair->pX = (Right*XDirection-Bottom*YDirection-
XDirection*X+YDirection*Y)/C+X;
Pair->pY = (Right*YDirection+Bottom*XDirection-
YDirection*X-XDirection*Y)/C+Y;
Pair->pSucc = NULL;
if (CDDesc.dRoot)
GenPolygon(CDDesc.dRootFileDesc,Path);
else
GenPolygon(CDDesc.dSymbolFileDesc,Path);
}
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
if (Not CDMakeBox(CDDesc.dSymbolDesc,CurrentLayer,Length,Width,
X,Y,&CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,CDDesc.dPointer,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
int
ARoundFlash(Width,X,Y)
int Width,X,Y;
{
struct p *Path, *NewPath;
struct p Pair;
/*
*KIC DOES NOT SUPPORT ROUND FLASHES: convert to a wire with one vertex.
*Therefore, KIC will never try to generate a Roundflash.
*/
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
Pair.pX = SCALE(X);
Pair.pY = SCALE(Y);
Pair.pSucc = NULL;
if (CDDesc.dRoot)
GenWire(CDDesc.dRootFileDesc,SCALE(Width),&Pair);
else
GenWire(CDDesc.dSymbolFileDesc,SCALE(Width),&Pair);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
if ((NewPath = Path = alloc(p)) != NULL)
return (AMallocFailed());
NewPath->pX = X;
NewPath->pY = Y;
NewPath->pSucc = NULL;
if (Not CDMakeWire(CDDesc.dSymbolDesc,CurrentLayer,Width,Path,
&CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,CDDesc.dPointer,
CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String))
return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
return (PSUCCEEDED);
}
int
ALayer(Technology,Mask)
char Technology,Mask[];
{
int Layer;
#ifdef TRACEPARSER
GenLayer(stderr,Technology,Mask);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass)
return (PSUCCEEDED);
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (CDLayer[Layer].lTechnology == Technology And
CDLayer[Layer].lMask[0] == Mask[0] And
CDLayer[Layer].lMask[1] == Mask[1] And
CDLayer[Layer].lMask[2] == Mask[2]) {
break;
}
}
if (Layer == CDNUMLAYERS+1) {
/* no matching layer name */
char lname[8];
int i, lnum;
lname[0] = Technology;
lname[1] = Mask[0];
lname[2] = Mask[1];
lname[3] = Mask[2];
lname[4] = '\0';
i = 0;
while (lname[i] != '\0') {
if (lname[i] != ' ') {
if (lname[i] < '0' || lname[i] > '9')
break;
}
i++;
}
if (lname[i] == '\0') {
/* layer name is an integer */
lnum = atoi(lname);
if (lnum > 0 && lnum <= CDNUMLAYERS) {
if (CDLayer[lnum].lTechnology != ' ' Or
CDLayer[lnum].lMask[0] != ' ' Or
CDLayer[lnum].lMask[1] != ' ' Or
CDLayer[lnum].lMask[2] != ' ') {
Technology = CDLayer[lnum].lTechnology;
Mask[0] = CDLayer[lnum].lMask[0];
Mask[1] = CDLayer[lnum].lMask[1];
Mask[2] = CDLayer[lnum].lMask[2];
}
}
}
}
if (CDDesc.dRoot)
GenLayer(CDDesc.dRootFileDesc,Technology,Mask);
else
GenLayer(CDDesc.dSymbolFileDesc,Technology,Mask);
return (PSUCCEEDED);
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (CDLayer[Layer].lTechnology == Technology And
CDLayer[Layer].lMask[0] == Mask[0] And
CDLayer[Layer].lMask[1] == Mask[1] And
CDLayer[Layer].lMask[2] == Mask[2]) {
CurrentLayer = Layer;
return (PSUCCEEDED);
}
}
/*
* Layer is not defined in CD layer table!
* If parsing CIF and layer is unknown, put it in the layer table.
* If opening a cell and layer is unknown, complain about it.
*/
if (CDDesc.dControl == DCONTROLPCIF) {
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (CDLayer[Layer].lTechnology == ' ') {
CDSetLayer(Layer, Technology, Mask);
CurrentLayer = Layer;
return (PSUCCEEDED);
}
}
}
CurrentLayer = 1;
}
return (PFAILED);
}
int
AUserExtension(Digit,Text)
char Digit;
char *Text;
{
int X,Y;
int Layer,Xform;
char Label[81];
#ifdef TRACEPARSER
GenUserExtension(stderr,Digit,Text);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (CDDesc.dFirstPass Or CDDesc.dProgram == 'n')
return (PSUCCEEDED);
/*
* When converting to KIC format, we pass CD user extensions only.
* If we find an illegal extension, we ignore it.
*/
if (Digit == '9') {
if (Text[0] == '4') {
if (CDDesc.dProgram == 'm') { /* mextra text label */
if (sscanf(&(Text[1]),"%s%d%d%s",Label,&X,&Y,TypeOut) < 4)
return (PFAILED);
if (CDDesc.dRoot)
GenLayer(CDDesc.dRootFileDesc,
TypeOut[0],&TypeOut[1]);
else
GenLayer(CDDesc.dSymbolFileDesc,
TypeOut[0],&TypeOut[1]);
}
else /* normal CD label */
sscanf(&(Text[1]),"%s%d%d",Label,&X,&Y);
sprintf(TypeOut,"4 %s %d %d",Label,SCALE(X),SCALE(Y));
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,'9',TypeOut);
else
GenUserExtension(CDDesc.dSymbolFileDesc,'9',TypeOut);
}
elif (Text[0] == '2') { /* NCA Label */
sscanf(&(Text[1]),"%s%d%d%d",Label,&X,&Y,&Layer);
sprintf(TypeOut,"%d ",Layer);
if (CDDesc.dRoot)
GenLayer(CDDesc.dRootFileDesc,TypeOut[0],&TypeOut[1]);
else
GenLayer(CDDesc.dSymbolFileDesc,TypeOut[0],&TypeOut[1]);
sprintf(TypeOut,"4 %s %d %d",Label,SCALE(X),SCALE(Y));
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,'9',TypeOut);
else
GenUserExtension(CDDesc.dSymbolFileDesc,'9',TypeOut);
}
else {
/* symbol name */
if (Text[0] == ' ')
strcpy(CDDesc.dSymbolName,&(Text[1]));
else strcpy(CDDesc.dSymbolName,Text);
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,Digit,Text);
else
GenUserExtension(CDDesc.dSymbolFileDesc,Digit,Text);
}
}
elif (Digit == '5' And (Text[0] < '0' Or Text[0] > '9')) {
/* Reserved for CD property list extensions */
if (CDDesc.dRoot)
GenUserExtension(CDDesc.dRootFileDesc,Digit,Text);
else
GenUserExtension(CDDesc.dSymbolFileDesc,Digit,Text);
}
}
elif (CDDesc.dControl == DCONTROLCDOPEN Or
CDDesc.dControl == DCONTROLPCIF) {
/*
* When parsing CIF, we accept only CD user extensions and
* ignore any illegal extensions.
*/
if (Digit == '9') {
if (Text[0] == '4') {
/* Label */
Xform = 0;
sscanf(&(Text[1]),"%s%d%d%d",Label,&X,&Y,&Xform);
if (CDDesc.dFirstPass And CDDesc.dControl == DCONTROLPCIF)
return (PSUCCEEDED);
#ifdef TRACEPARSER
fprintf(stderr,"Making label on layer %d\n",CurrentLayer);
#endif
if (Not CDMakeLabel(CDDesc.dSymbolDesc,CurrentLayer,Label,
X,Y,(char)Xform,&CDDesc.dPointer))
return (PFAILED);
while(CDDesc.dPrptyList != NULL) {
struct prpty PrptyCopy;
if (Not CDAddProperty(CDDesc.dSymbolDesc,
CDDesc.dPointer,CDDesc.dPrptyList->prpty_Value,
CDDesc.dPrptyList->prpty_String)) return (PFAILED);
/* free storage of CDDesc.dPrptyList */
PrptyCopy = *CDDesc.dPrptyList;
free(CDDesc.dPrptyList->prpty_String);
afree(CDDesc.dPrptyList,prpty);
CDDesc.dPrptyList = PrptyCopy.prpty_Succ;
}
}
elif (Text[0] < '0' Or Text[0] > '9') {
/* Symbol name */
X = 0;
while(Text[X] <= ' ') ++X;
strcpy(CDDesc.dSymbolName,Text+X);
}
}
elif (Digit == '1' And (Text[0] < '0' Or Text[0] > '9')) {
/* Reserved for CD Array extensions */
sscanf(Text,"%s",TypeOut);
if (strcmp(TypeOut,"Array") == 0) {
sscanf(Text,"%s%d%d%d%d",TypeOut,&CDDesc.dNumX,&CDDesc.dDX,
&CDDesc.dNumY,&CDDesc.dDY);
}
}
elif (Digit == '5' And (Text[0] < '0' Or Text[0] > '9')) {
/* Reserved for CD Property List extensions */
struct prpty *PDesc;
unsigned int size;
int i;
if ((PDesc = alloc(prpty))==NULL)
return (PFAILED);
if (sscanf(Text,"%d",&PDesc->prpty_Value) < 1)
return (PFAILED);
i = 0;
/* skip white space before property integer */
while((Text[i] < '0' Or Text[i] > '9') And Text[i] != '\0') ++i;
/* skip property integer */
while(Text[i] >= '0' And Text[i] <= '9') ++i;
/* skip white space and control chars after property integer */
while(Text[i] <= ' ' And Text[i] != '\0') ++i;
size = strlen(&(Text[i])) + 2;
if ((PDesc->prpty_String = malloc(size)) == NULL)
return (PFAILED);
strcpy(PDesc->prpty_String,&(Text[i]));
PDesc->prpty_Succ = CDDesc.dPrptyList;
CDDesc.dPrptyList = PDesc;
}
}
return (PSUCCEEDED);
}
void
AComment(Text)
char *Text;
{
#ifdef TRACEPARSER
GenComment(stderr,Text);
#endif
if (CDDesc.dControl == DCONTROLCDTO) {
if (Not CDDesc.dFirstPass) {
if (CDDesc.dRoot)
GenComment(CDDesc.dRootFileDesc,Text);
else
GenComment(CDDesc.dSymbolFileDesc,Text);
}
}
}
int
AMallocFailed()
{
sprintf(CDStatusString,"Out of memory.");
CDStatusInt = CDMALLOCFAILED;
return (PFAILED);
}
kic-2.4c/src/cd/paths.c 0000644 0000764 0000764 00000032351 10262143554 014362 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 John Ousterhout, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* paths.c
*
* This file contains routines that a) implement a path mechanism, whereby
* several places may be searched for files, and b) provide a defaulting
* mechanism for file name extensions.
*/
#include "prefix.h"
#include
#include
#include
#if !defined(MSDOS) && !defined(WIN32)
#include
#else
#if __NDPC__
#if __STDC__
static FILE *my_fopen(char*,char*);
#else
static FILE *my_fopen();
#endif
#define fopen my_fopen
#endif
#endif
/* callback, see note below */
#if __STDC__
extern FILE *OpenDevice(char*);
#else
extern FILE *OpenDevice();
#endif
#if __STDC__
extern int PConvertTilde(char**,char**,int*);
extern int PSetPath(char*);
extern char *PGetPath(void);
extern FILE *POpen(char*,char*,char*,char**);
#else
extern int PConvertTilde();
extern int PSetPath();
extern char *PGetPath();
extern FILE *POpen();
#endif
#define FALSE 0
#define TRUE 1
#define TILDA '~'
/* The following string holds the current path,which consists of a bunch
* of directory names separated by spaces.
*/
#define PATHSIZE 512
static char path[PATHSIZE];
/*-----------------------------------------------------------------------------
* This routine converts tilde notation into standard directory names.
*
* Results:
* If the conversion was done successfully, then TRUE is returned.
* If a user name couldn't be found in the password file, then
* FALSE is returned.
*
* Side Effects:
* If the first character of the string indicated by psource is a
* tilde ("~") then the subsequent user name is converted to a login
* directory name and stored in the string indicated by pdest. Then
* remaining characters in the file name at psource are copied to
* pdest and both pointers are updated. Upon return, psource points
* to the terminating character in the source file name and pdest
* points to the next character after the last character in the file
* name at that location. If a tilde cannot be converted because the
* user name cannot be found, psource is still advanced past the current
* entry, but pdest is unaffected. At most size characters will be
* stored at pdest, and the size is decremented by the number of
* characters we actually stored.
*-----------------------------------------------------------------------------
*/
int
PConvertTilde(psource, pdest, size)
char **psource; /* Pointer to a pointer to the source string */
char **pdest; /* Pointer to a pointer to the dest. string */
int *size; /* Pointer to no. bytes available at pdest */
{
char *ps, *pd;
#ifndef VMS
#if !defined(MSDOS) && !defined(WIN32)
struct passwd *passwd;
#endif
#endif
#if !defined(MSDOS) && !defined(WIN32)
char username[35];
int i, length;
#endif
ps = *psource;
#if !defined(MSDOS) && !defined(WIN32)
if (*ps == TILDA) {
/* Copy the user name into a string (at most 34 characters), then
* read the password file entry for the user, then grab out the
* login directory.
*/
#ifdef VMS
ps++;
if (getenv("HOME") == NULL)
#else
pd = username;
for (i=0; ; i++) {
*pd = *++ps;
if (isspace(*pd) || (*pd=='\0') || (*pd=='/')) break;
if (i < 34) pd++;
}
*pd = '\0';
passwd = getpwnam(username);
/* If the entry can't be found, skip the source entry and return */
if (passwd == NULL)
#endif
{
while ((*ps != '\0') && !isspace(*ps)) ps++;
*psource = ps;
return (FALSE);
}
#ifdef VMS
length = strlen(getenv("HOME"));
/* remove closing bracket */
--length;
if (length > *size) length = *size;
strncpy(*pdest, getenv("HOME"), length);
*size -= length;
pd = *pdest+length;
#else
length = strlen(passwd->pw_dir);
if (length > *size) length = *size;
strncpy(*pdest, passwd->pw_dir, length);
*size -= length;
pd = *pdest+length;
#endif
}
else
#endif
pd = *pdest;
/* Copy the rest of the directory name from the source to the dest. */
while ((*ps != '\0') && !isspace(*ps))
if (*size > 0) {
*pd++ = *ps++;
(*size)--;
}
else ps++;
#ifdef VMS
/* insert closing bracket for tilda expansion */
if (**psource == TILDA) {
if (*size > 0) {
*pd++ = ']';
(*size)--;
}
else
*(pd - 1) = ']';
}
#endif
*psource = ps;
*pdest = pd;
return (TRUE);
}
/*-----------------------------------------------------------------------------
* PSetPath sets up the current search path.
*
* Results:
* FALSE is returned if one or more of the paths contained a tilde
* notation that couldn't be converted. Otherwise TRUE is returned.
*
* Side Effects:
* The string is stored as the current path, and all entries with
* tilde notation are converted to non-tilde notation. Tilde entries
* that cannot be converted are ignored. Note: only PATHSIZE total
* bytes of path are stored, after tilde conversion. Excess bytes
* are truncated.
*-----------------------------------------------------------------------------
*/
int
PSetPath(string)
char *string; /* Pointer to a string that is to become
* the new fle search path. Must consist
* of one or more directory names separated
* by white space. ~ notation is ok.
*/
{
int result, spaceleft;
char *p;
if (string == NULL || string[0] == '\0')
return (path[0] = '\0');
result = TRUE;
spaceleft = PATHSIZE-1;
p = path;
while (*string != '\0') {
if (spaceleft <= 0) break;
while (isspace(*string)) string++;
if (!PConvertTilde(&string, &p, &spaceleft)) result = FALSE;
else if (spaceleft-- > 0) *p++ = ' ';
}
*p = '\0';
#ifdef WIN32
for (p = path; *p; p++)
if (*p == '\\')
*p = '/';
#endif
return (result);
}
/*-----------------------------------------------------------------------------
* This routine merely returns a pointer to the current path.
*
* Results:
* The address of the current path (with all tildes expanded).
*
* Side Effects: None.
*-----------------------------------------------------------------------------
*/
char *
PGetPath()
{
return (path);
}
/*-----------------------------------------------------------------------------
* This routine does a file lookup using the current path and
* supplying a default extension.
*
* Results:
* A pointer to a FILE, or NULL if the file couldn't be found.
*
* Side Effects:
* If the file name doesn't contain the first character of ext
* then ext is appended to the file name, and this routine is
* called recursively with the new name. If that succeeeds,
* then we are done. Otherwise, if the first character of the
* file name is "~" or "/" then we try to look up the file with
* the original name, doing tilde expansion of course. If the
* first character isn't one of those two characters, we go through
* the current path trying to look up the file once for each path
* entry by prepending the path entry to the original file name.
* This concatenated name is stored in a static string and made
* available to the caller through prealname if the open succeeds.
* Note: the static string will be trashed on the next call to this
* routine. Also, note that no individual file name is allowed to
* be more than NAMESIZE characters long. Excess characters are lost.
*-----------------------------------------------------------------------------
*/
FILE *
POpen(file, mode, ext, prealname)
char *file; /* Name of the file to be opened. */
char *mode; /* The file mode, as given to fopen. */
char *ext; /* The default extension of the file, or
* NULL if there is to be no default extension.
*/
char **prealname; /* Pointer to a location that will be filled
* in with the address of the real name of
* the file that was successfully opened.
* If NULL, then nothing is stored.
*/
{
#define NAMESIZE 80
static char realname[NAMESIZE];
char extendedname[NAMESIZE], *p, *p2;
int length, spaceleft;
FILE *f;
#ifdef WIN32
char nbuf[256];
#endif
if (!file || !*file)
return (0);
#ifdef WIN32
{
char *s = nbuf;
char *t = file;
while (*t) {
if (*t == '\\')
*s++ = '/';
else
*s++ = *t;
t++;
}
*s = 0;
file = nbuf;
}
#endif
/* See if we must supply a default extension. If so, then do it
* and call this routine recursively.
*/
if (prealname != NULL) *prealname = realname;
if (ext != NULL)
if (strchr(file, ext[0]) == NULL) {
length = strlen(file);
if (length >= NAMESIZE) length = NAMESIZE-1;
strncpy(extendedname, file, length);
p = &extendedname[length];
length = NAMESIZE-1-length;
if (length > 0) strncpy(p, ext, length);
extendedname[NAMESIZE-1] = '\0';
f = POpen(extendedname, mode, (char *) NULL, prealname);
if (f != NULL) return (f);
}
/* OK, the default extension either wasn't necessary or didn't work.
* Now try the original name. If it starts with a ~ or /, look it
* up directly.
*/
/* SRW
* The function OpenDevice() must be supplied externally. The intended
* purpose is to support multi-symbol files (libraries). OpenDevice()
* would check to see if "file" is included in the library, and if so,
* returns a file pointer suitably offset. Otherwise NULL is returned.
* Note that libraries are only opened for reading.
*/
if (!strcmp(mode,"r")) {
f = OpenDevice(file);
if (f) return (f);
}
if (path[0] == '\0'
#ifndef MSDOS
&& file[0] != TILDA
#endif
)
return (fopen(file,mode));
#ifdef VMS
if ((strchr(file,':') != 0) || (strchr(file,'[') != 0))
#else
if (file[0] == DIRC
#if defined(MSDOS) || defined(WIN32)
|| (isalpha(file[0]) && file[1] == ':')
#endif
)
#endif
{
strncpy(realname, file, NAMESIZE-1);
realname[NAMESIZE-1] = '\0';
return (fopen(realname, mode));
}
#ifndef VMS
#ifndef MSDOS
if (file[0] == TILDA) {
p = realname;
length = NAMESIZE-1;
if (!PConvertTilde(&file, &p, &length)) return (NULL);
*p = '\0';
return (fopen(realname, mode));
}
#endif
#endif
/* Last, but not least, try going through the path. */
p = path;
while (*p != '\0') {
spaceleft = NAMESIZE-1;
p2 = realname;
while (isspace(*p)) p++;
if (!*p)
break;
#ifdef VMS
if (*p == '.' && (isspace(*(p+1)) || *(p+1) == '\0')) {
++p;
if ((f = fopen(file, mode)) != NULL)
return (f);
else
continue;
}
#endif
while ((*p != '\0') && !isspace(*p))
if (spaceleft-- > 0) *p2++ = *p++;
else p++;
#ifndef VMS
if (spaceleft-- > 0) *p2++ = DIRC;
#endif
if (spaceleft > 0) strncpy(p2, file, spaceleft);
realname[NAMESIZE-1] = '\0';
f = fopen(realname, mode);
if (f != NULL) return (f);
}
return (NULL);
}
#if __NDPC__
#undef fopen
extern int _pmode;
static FILE*
my_fopen(what,how)
/* support for NDPC's silly pmode */
char *what, *how;
{
FILE *fp;
char *c, buf[8];
char *index();
strncpy(buf,how,8);
buf[7] = '\0';
if ((c = index(buf,'b')) != NULL) {
_pmode = 0x8000;
*c = '\0';
}
fp = fopen(what,buf);
_pmode = 0x4000;
return (fp);
}
#endif
kic-2.4c/src/cd/Makefile.in 0000644 0000764 0000764 00000002501 12427260661 015142 0 ustar stevew stevew #######################################################################
# src/cd/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
LIB_TARGET = ../cd.a
HFILES =
CFILES = actions.c cd.c gencif.c misc.c nmalloc.c parser.c paths.c xforms.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/cd
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/cd/xforms.c 0000644 0000764 0000764 00000022620 07525346710 014566 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Transforms package.
*
*/
#include "prefix.h"
#include "cd.h"
#ifdef __STDC__
extern void MallocFailed(void);
#else
extern void MallocFailed();
#endif
struct tt {
int ttMatrix[3][3];
struct tt *ttNext;
};
static struct tt *Transforms;
void
TInit()
{
struct tt *Tmp;
for (Tmp = Transforms; Tmp; Tmp = Transforms) {
Transforms = Tmp->ttNext;
afree(Tmp,tt);
}
Transforms = alloc(tt);
if (Transforms == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Transforms->ttNext = NULL;
TIdentity();
}
int
TEmpty()
{
if (Transforms == NULL)
return (True);
else
return (False);
}
int
TFull()
{
return (False);
}
void
TPush()
{
struct tt *Tmp;
Tmp = alloc(tt);
if (Tmp == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Tmp->ttNext = Transforms;
Transforms = Tmp;
}
void
TPop()
{
struct tt *Tmp;
Tmp = Transforms;
Transforms = Tmp->ttNext;
afree(Tmp,tt);
}
void
TCurrent(TFP)
int *TFP;
{
int i,j;
for(i = 0; i < 3; ++i)
for(j = 0; j<3; ++j)
TFP[(3 * i) + j] = Transforms->ttMatrix[i][j];
}
void
TLoadCurrent(TFP)
int *TFP;
{
int i,j;
for(i = 0; i < 3; ++i)
for(j = 0; j < 3; ++j)
Transforms->ttMatrix[i][j] = TFP[(3 * i) + j];
}
void
TTranslate(X,Y)
int X,Y;
{
Transforms->ttMatrix[2][0] += X;
Transforms->ttMatrix[2][1] += Y;
}
void
TMY()
{
Transforms->ttMatrix[0][1] = -Transforms->ttMatrix[0][1];
Transforms->ttMatrix[1][1] = -Transforms->ttMatrix[1][1];
Transforms->ttMatrix[2][1] = -Transforms->ttMatrix[2][1];
}
void
TMX()
{
Transforms->ttMatrix[0][0] = -Transforms->ttMatrix[0][0];
Transforms->ttMatrix[1][0] = -Transforms->ttMatrix[1][0];
Transforms->ttMatrix[2][0] = -Transforms->ttMatrix[2][0];
}
void
TRotate(XDirection,YDirection)
int XDirection,YDirection;
{
/*
Rotation angle is expressed as a CIF-style direction vector.
*/
int Int1;
if (XDirection == 0) {
if (abs(YDirection) > 1) {
if (YDirection < 0)
YDirection = -1;
else
YDirection = 1;
}
}
elif (YDirection == 0) {
if (abs(XDirection) > 1) {
if (XDirection < 0)
XDirection = -1;
else
XDirection = 1;
}
}
if (XDirection == 1 And YDirection == 0)
/*
Don't rotate at all.
*/
return;
elif (XDirection == 0 And YDirection == -1) {
/*
Rotate ccw by 270 degrees.
*/
Int1 = Transforms->ttMatrix[0][0];
Transforms->ttMatrix[0][0] = Transforms->ttMatrix[0][1];
Transforms->ttMatrix[0][1] = -Int1;
Int1 = Transforms->ttMatrix[1][0];
Transforms->ttMatrix[1][0] = Transforms->ttMatrix[1][1];
Transforms->ttMatrix[1][1] = -Int1;
Int1 = Transforms->ttMatrix[2][0];
Transforms->ttMatrix[2][0] = Transforms->ttMatrix[2][1];
Transforms->ttMatrix[2][1] = -Int1;
}
elif (XDirection == 0 And YDirection == 1) {
/*
Rotate ccw by 90 degrees.
*/
Int1 = Transforms->ttMatrix[0][0];
Transforms->ttMatrix[0][0] = -Transforms->ttMatrix[0][1];
Transforms->ttMatrix[0][1] = Int1;
Int1 = Transforms->ttMatrix[1][0];
Transforms->ttMatrix[1][0] = -Transforms->ttMatrix[1][1];
Transforms->ttMatrix[1][1] = Int1;
Int1 = Transforms->ttMatrix[2][0];
Transforms->ttMatrix[2][0] = -Transforms->ttMatrix[2][1];
Transforms->ttMatrix[2][1] = Int1;
}
elif (XDirection == -1 And YDirection == 0) {
/*
Rotate ccw by 180 degrees.
*/
Transforms->ttMatrix[0][0] = -Transforms->ttMatrix[0][0];
Transforms->ttMatrix[0][1] = -Transforms->ttMatrix[0][1];
Transforms->ttMatrix[1][0] = -Transforms->ttMatrix[1][0];
Transforms->ttMatrix[1][1] = -Transforms->ttMatrix[1][1];
Transforms->ttMatrix[2][0] = -Transforms->ttMatrix[2][0];
Transforms->ttMatrix[2][1] = -Transforms->ttMatrix[2][1];
}
}
void
TIdentity()
{
int *l;
l = (int *)Transforms->ttMatrix;
*l++ = 1; *l++ = 0; *l++ = 0;
*l++ = 0; *l++ = 1; *l++ = 0;
*l++ = 0; *l++ = 0; *l++ = 1;
}
void
TPoint(X,Y)
int *X,*Y;
{
/*
Transform the point.
*/
int Int1;
Int1 = *X*Transforms->ttMatrix[0][0] + *Y*Transforms->ttMatrix[1][0] +
Transforms->ttMatrix[2][0];
*Y = *X*Transforms->ttMatrix[0][1] + *Y*Transforms->ttMatrix[1][1] +
Transforms->ttMatrix[2][1];
*X = Int1;
}
void
TPremultiply()
{
/*
* Form the instance transform.
* This is done by computing
* Transforms->ttMatrix * Transforms->ttNext->ttMatrix and
* placing the product in Transforms.ttMatrix.
* So, the scenario for transforming the coordinates of a master follows.
* TPush();
* TIdentity();
* Invoke TMX, Translate, etc. to build instance transform.
* Form the instance transform.
* TPremultiply();
* Invoke TPoint to transform master points to instance points.
* TPop();
*/
int Int1,Int2,Int3,Int4,Int5,Int6;
struct tt *Next;
Next = Transforms->ttNext;
Int1 = Transforms->ttMatrix[0][0]*Next->ttMatrix[0][0] +
Transforms->ttMatrix[0][1]*Next->ttMatrix[1][0];
Int2 = Transforms->ttMatrix[0][0]*Next->ttMatrix[0][1] +
Transforms->ttMatrix[0][1]*Next->ttMatrix[1][1];
Int3 = Transforms->ttMatrix[1][0]*Next->ttMatrix[0][0] +
Transforms->ttMatrix[1][1]*Next->ttMatrix[1][0];
Int4 = Transforms->ttMatrix[1][0]*Next->ttMatrix[0][1] +
Transforms->ttMatrix[1][1]*Next->ttMatrix[1][1];
Int5 = Transforms->ttMatrix[2][0]*Next->ttMatrix[0][0] +
Transforms->ttMatrix[2][1]*Next->ttMatrix[1][0] +
Next->ttMatrix[2][0];
Int6 = Transforms->ttMatrix[2][0]*Next->ttMatrix[0][1] +
Transforms->ttMatrix[2][1]*Next->ttMatrix[1][1] +
Next->ttMatrix[2][1];
Transforms->ttMatrix[0][0] = Int1;
Transforms->ttMatrix[0][1] = Int2;
Transforms->ttMatrix[1][0] = Int3;
Transforms->ttMatrix[1][1] = Int4;
Transforms->ttMatrix[2][0] = Int5;
Transforms->ttMatrix[2][1] = Int6;
}
static int Storage[3][3];
static int InverseMatrix[3][3];
void
TInverse()
{
/*
Compute the inverse transform of the current transform.
Because all transformations are Manhattan, the
det of the current transform matrix is always -1 or +1.
*/
int Det;
Det =
Transforms->ttMatrix[0][0]*Transforms->ttMatrix[1][1] -
Transforms->ttMatrix[1][0]*Transforms->ttMatrix[0][1];
if (Det == 1) {
InverseMatrix[0][0] = Transforms->ttMatrix[1][1];
InverseMatrix[0][1] = -Transforms->ttMatrix[0][1];
InverseMatrix[1][0] = -Transforms->ttMatrix[1][0];
InverseMatrix[1][1] = Transforms->ttMatrix[0][0];
InverseMatrix[2][0] =
Transforms->ttMatrix[1][0]*Transforms->ttMatrix[2][1] -
Transforms->ttMatrix[2][0]*Transforms->ttMatrix[1][1];
InverseMatrix[2][1] =
- Transforms->ttMatrix[0][0]*Transforms->ttMatrix[2][1] +
Transforms->ttMatrix[0][1]*Transforms->ttMatrix[2][0];
}
else {
InverseMatrix[0][0] = -Transforms->ttMatrix[1][1];
InverseMatrix[0][1] = Transforms->ttMatrix[0][1];
InverseMatrix[1][0] = Transforms->ttMatrix[1][0];
InverseMatrix[1][1] = -Transforms->ttMatrix[0][0];
InverseMatrix[2][0] =
- Transforms->ttMatrix[1][0]*Transforms->ttMatrix[2][1] +
Transforms->ttMatrix[2][0]*Transforms->ttMatrix[1][1];
InverseMatrix[2][1] =
Transforms->ttMatrix[0][0]*Transforms->ttMatrix[2][1] -
Transforms->ttMatrix[0][1]*Transforms->ttMatrix[2][0];
}
InverseMatrix[0][2] = 0;
InverseMatrix[1][2] = 0;
InverseMatrix[2][2] = 1;
}
void
TInversePoint(X,Y)
int *X,*Y;
{
/*
Transform the point.
*/
int Int1;
Int1 = *X*InverseMatrix[0][0] + *Y*InverseMatrix[1][0]
+ InverseMatrix[2][0];
*Y = *X*InverseMatrix[0][1] + *Y*InverseMatrix[1][1]
+ InverseMatrix[2][1];
*X = Int1;
}
void
TStore()
{
memcpy((char *)Storage,
(char *)Transforms->ttMatrix,9*sizeof(int));
}
void
TLoad()
{
memcpy((char *)Transforms->ttMatrix,
(char *)Storage,9*sizeof(int));
}
void
TLoadInverse()
{
memcpy((char *)Transforms->ttMatrix,
(char *)InverseMatrix,9*sizeof(int));
}
kic-2.4c/src/cd/gencif.c 0000644 0000764 0000764 00000011440 07525346710 014501 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* CIF file generator.
* Here's an example.
* The following code
* {
* FileDesc = fopen("CIFFile","w");
* GenBeginSymbol(FileDesc,3,1,1);
* GenComment(FileDesc,"This is easy.");
* GenBox(FileDesc,1,2,3,4,1,0);
* GenEndSymbol(FileDesc);
* GenEnd(FileDesc);
* fclose(FileDesc;
* }
*
* generates
*
* DS 3 1 1;
* (This is easy.);
* B 1 2 3 4;
* DF;
* E
*
*/
#include "prefix.h"
#include "cd.h"
#if __STDC__
static void out_path(FILE*,struct p*,char*,int,int);
#else
static void out_path();
#endif
void
GenEnd(FileDesc)
FILE *FileDesc;
{
fprintf(FileDesc,"E\n");
}
void
GenBeginSymbol(FileDesc,SymbolNum,A,B)
FILE *FileDesc;
int SymbolNum;
int A,B;
{
fprintf(FileDesc,"DS %d %d %d;\n",SymbolNum,A,B);
}
void
GenEndSymbol(FileDesc)
FILE *FileDesc;
{
fprintf(FileDesc,"DF;\n");
}
void
GenBeginCall(FileDesc,Number)
FILE *FileDesc;
int Number;
{
fprintf(FileDesc,"C %d",Number);
}
void
GenEndCall(FileDesc)
FILE *FileDesc;
{
fprintf(FileDesc,";\n");
}
void
GenTranslation(FileDesc,X,Y)
FILE *FileDesc;
int X,Y;
{
fprintf(FileDesc," T %d %d",X,Y);
}
void
GenRotation(FileDesc,X,Y)
FILE *FileDesc;
int X,Y;
{
fprintf(FileDesc," R %d %d",X,Y);
}
void
GenMirrorX(FileDesc)
FILE *FileDesc;
{
fprintf(FileDesc," MX");
}
void
GenMirrorY(FileDesc)
FILE *FileDesc;
{
fprintf(FileDesc," MY");
}
void
GenPolygon(FileDesc,Path)
FILE *FileDesc;
struct p *Path;
{
char buf[80];
*buf = 'P';
*(buf+1) = '\0';
out_path(FileDesc,Path,buf,0L,0L);
}
void
GenPolygonOffset(FileDesc,Path,X,Y)
FILE *FileDesc;
struct p *Path;
int X,Y;
{
char buf[80];
*buf = 'P';
*(buf+1) = '\0';
out_path(FileDesc,Path,buf,X,Y);
}
void
GenWire(FileDesc,Width,Path)
FILE *FileDesc;
int Width;
struct p *Path;
{
char buf[80];
sprintf(buf,"W %d",Width);
out_path(FileDesc,Path,buf,0L,0L);
}
void
GenWireOffset(FileDesc,Width,Path,X,Y)
FILE *FileDesc;
struct p *Path;
int Width,X,Y;
{
char buf[80];
sprintf(buf,"W %d",Width);
out_path(FileDesc,Path,buf,X,Y);
}
static void
out_path(FileDesc,Path,buf,X,Y)
FILE *FileDesc;
struct p *Path;
char *buf;
int X,Y;
{
struct p *Pair;
char buf1[80];
int len, len1;
len = strlen(buf);
Pair = Path;
while(Pair != NULL) {
sprintf(buf1," %d %d",Pair->pX-X,Pair->pY-Y);
len1 = strlen(buf1);
if (len+len1 < 79) {
strcat(buf,buf1);
len += len1;
}
else {
fprintf(FileDesc,"%s\n ",buf);
strcpy(buf,buf1);
len = len1+1;
}
Pair = Pair->pSucc;
}
fprintf(FileDesc,"%s;\n",buf);
}
void
GenBox(FileDesc,Length,Width,X,Y,XDir,YDir)
FILE *FileDesc;
int Length;
int Width,X,Y;
int XDir,YDir;
{
fprintf(FileDesc,"B %d %d %d %d",Length,Width,X,Y);
if (XDir != 1 Or YDir != 0)
fprintf(FileDesc," %d %d",XDir,YDir);
fprintf(FileDesc,";\n");
}
/*
* GenRoundFlash(FileDesc,Width,X,Y)
* FILE *FileDesc;
* int Width,X,Y;
* {
* fprintf(FileDesc,"R %d %d %d;\n",Width,X,Y);
* }
*/
void
GenLayer(FileDesc,Technology,Mask)
FILE *FileDesc;
char Technology,Mask[];
{
if (Technology > ' ') {
fprintf(FileDesc,"L %c",Technology);
if (Mask[0] > ' ') {
fprintf(FileDesc,"%c",Mask[0]);
if (Mask[1] > ' ') {
fprintf(FileDesc,"%c",Mask[1]);
if (Mask[2] > ' ')
fprintf(FileDesc,"%c",Mask[2]);
}
}
fprintf(FileDesc,";\n");
}
}
void
GenUserExtension(FileDesc,Digit,Text)
FILE *FileDesc;
char Digit;
char *Text;
{
if (Text[0] >= '0' And Text[0] <= '9')
fprintf(FileDesc,"%c%s;\n",Digit,Text);
else
fprintf(FileDesc,"%c %s;\n",Digit,Text);
}
void
GenComment(FileDesc,Text)
FILE *FileDesc;
char *Text;
{
fprintf(FileDesc,"(%s);\n",Text);
}
kic-2.4c/src/xmfb/ 0000755 0000764 0000764 00000000000 12427446157 013453 5 ustar stevew stevew kic-2.4c/src/xmfb/text1.c 0000644 0000764 0000764 00000011624 10261421716 014654 0 ustar stevew stevew /*************************************************************************
MFB graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include "mfb.h"
#include
#include
static int Xl,Yl, Xu = 0x7fff, Yu = 0x7fff;
#if __STDC__
static int setcode(int);
static void xform_cell(unsigned short*,unsigned short*,int,int,int,int);
#else
static int setcode();
static void xform_cell();
#endif
extern unsigned short mfb_6X8font[];
extern unsigned short mfb_8X8font[];
extern unsigned short mfb_8X14font[];
extern unsigned short mfb_8X16font[];
void
MFBSetTextClip(xl,yl,xu,yu)
/* set up a clipping window for text */
int xl,yl,xu,yu;
{
Xl = xl;
Yl = yl;
Xu = xu;
Yu = yu;
}
int
MFBScaledText(text,x,y,degrees,scale)
char *text;
int x, y, degrees, scale;
{
int i, ii, j, k, tx;
int xnow, ynow;
int fheight, fwidth;
unsigned short rotbuf[16], *ctab, mask;
char *str0, *str1;
if (scale < 1 || scale > 10) return(-1);
if (text == NULL) return(-1);
if (mfb_chartab == NULL) return(-1);
if (degrees >= 90) degrees /= 90;
if (degrees & 1) {
fheight = mfb_charwidth;
fwidth = mfb_charheight;
if (degrees & 2) {
if (!(degrees & 4))
y -= strlen(text)*fheight*scale;
if (degrees & 8)
x -= fwidth*scale;
}
else {
if (!(degrees & 8))
x -= fwidth*scale;
if (degrees & 4)
y -= strlen(text)*fheight*scale;
}
}
else {
fheight = mfb_charheight;
fwidth = mfb_charwidth;
if (degrees & 2) {
if (!(degrees & 8))
x -= strlen(text)*fwidth*scale;
if (!(degrees & 4))
y -= fheight*scale;
}
else {
if (degrees & 8)
x -= strlen(text)*fwidth*scale;
if (degrees & 4)
y -= fheight*scale;
}
}
degrees = setcode(degrees);
str0 = text;
str1 = text + strlen(text);
while (str0 != str1) {
if (degrees & 8) {
if ((tx = (*--str1 & 0x7f) - ' ') < 0) tx = 0;
}
else
if ((tx = (*str0++ & 0x7f) - ' ') < 0) tx = 0;
ctab = mfb_chartab + tx*mfb_charheight;
xform_cell(rotbuf,ctab,fwidth,fheight,degrees,fwidth);
ctab = rotbuf + fheight - 1;
ynow = y;
for (i = fheight; i; i--, ctab--) {
for (j = scale; j; j--) {
if (ynow >= Yl && ynow <= Yu) {
xnow = x;
for (mask = 0x8000,ii = fwidth; ii; mask >>= 1,ii--) {
for (k = scale; k; k--) {
if (xnow >= Xl && xnow <= Xu) {
if (*ctab & mask)
MFBPixel(xnow,ynow);
}
xnow++;
}
}
}
else
x += fwidth*scale;
ynow++;
}
}
if (degrees & 4) {
y += fheight*scale;
continue;
}
x += fwidth*scale;
}
return MFBOK;
}
static int
setcode(deg)
int deg;
{
/*
* returned bit field:
* 0x8: load text backward
* 0x4: rotation
* 0x2: reverse y data
* 0x1: reverse x data
*
* Assumes input bit field:
* 0x8: mirror x
* 0x4: mirror y
* 0x3: 0-no rotation, 1-90, 2-180, 3-270
*/
int mx = 0,my = 0;
int rotn;
int xf = 0;
rotn = deg & 3;
if (deg & 8) mx = 1;
if (deg & 4) my = 1;
if ((mx && rotn == 0) || (!mx && rotn == 2) ||
(my && rotn == 1) || (!my && rotn == 3))
xf |= 8;
if (rotn & 1)
xf |= 4;
if ((my && (rotn == 0 || rotn == 1)) ||
(!my && (rotn == 2 || rotn == 3)))
xf |= 2;
if ((mx && (rotn == 0 || rotn == 3)) ||
(!mx && (rotn == 1 || rotn == 2)))
xf |= 1;
return xf;
}
static void
xform_cell(out,in,w,h,code,shift)
unsigned short *out,*in;
int w,h,code,shift;
{
int i, j, k, l;
for (i = 0; i < h; i++) {
k = ((code & 2) ? h-i-1 : i);
if (code & 4) {
for (j = 0,out[i] = 0; j < w; j++) {
l = ((code & 1) ? (w-j-1) : j);
out[i] |= ((in[j] >> k) & 1) << l;
}
}
else {
if (code & 1)
for (j = 0,out[i] = 0; j < w; j++)
out[i] |= ((in[k] >> j) & 1) << (w-j-1);
else
out[i] = in[k];
}
}
if (shift)
for (i = 0,j = 16-shift; i < h; i++)
out[i] <<= j;
}
void
MFBTextBB(string,x,y)
char *string;
int *x,*y;
{
*x = strlen(string) * mfb_charwidth;
*y = mfb_charheight;
}
kic-2.4c/src/xmfb/mfbcsdl.c 0000644 0000764 0000764 00000011354 07525346714 015236 0 ustar stevew stevew /*************************************************************************
XMFB X-Window MFB emulation package
Authore: Peter C. Vernam, C. S. Draper Laboratory, 1989
Stephen R. Whiteley, 1992
*************************************************************************/
#include "mfb.h" /* standard MFB header file */
#include
extern unsigned short mfb_6X8font[];
extern unsigned short mfb_8X8font[];
extern unsigned short mfb_8X14font[];
extern unsigned short mfb_8X16font[];
void
MFBBeep(volume)
/*
* Ring the bell at a percentage volume (0 - 100).
*/
int volume;
{
if (volume > 0)
XBell(mfb_display, volume * 2 - 100);
}
void
MFBRect(left,bottom,right,top)
/*
* Displays a rectangle (the outline of a box) with the given dimensions
* using the current ALU mode, fill pattern, and color.
* Leaves the "pen" at right, top.
*/
int left,bottom,right,top;
{
XDrawRectangle(mfb_display, mfb_window, mfb_lineGC,
left, TRAN(top), right-left+1, top-bottom+1);
mfb_X = right;
mfb_Y = top;
}
void
MFBSetName(wname,iname)
/*
* Sets the name in the title bar and the icon name.
*/
char *wname, *iname;
{
XStoreName(mfb_display, mfb_window, wname);
XSetIconName(mfb_display, mfb_window, iname);
}
int
MFBSelectFont(Left,Bottom,Right,Top)
/*
* Calls MFBScrollList to display all the available font names, and
* calls MFBSetFont to set a new font if one is selected.
* Returns 1 (true) if a new font is selected, else 0 (false).
*/
int Left, Bottom, Right, Top;
{
char **fontlist;
int ifont, nfonts;
int iret = 0;
fontlist = XListFonts(mfb_display, "*", 5000, &nfonts);
ifont =
MFBScrollList(Left, Bottom, Right, Top, fontlist, nfonts, 1, 1, 1);
if (ifont >= 0)
iret = MFBSetFont(fontlist[ifont]);
XFreeFontNames(fontlist);
return iret;
}
int
MFBSetFont(fontname)
/*
* Returns 1 (true) if specified font name exists, else 0 (false).
*/
char *fontname;
{
XFontStruct *myfont;
if (!strcmp(fontname,"MFB6X8")) {
mfb_chartab = mfb_6X8font;
mfb_charwidth = 6;
mfb_charheight = 8;
}
else if (!strcmp(fontname,"MFB8X8")) {
mfb_chartab = mfb_8X8font;
mfb_charwidth = 8;
mfb_charheight = 8;
}
else if (!strcmp(fontname,"MFB8X14")) {
mfb_chartab = mfb_8X14font;
mfb_charwidth = 8;
mfb_charheight = 14;
}
else if (!strcmp(fontname,"MFB8X16")) {
mfb_chartab = mfb_8X16font;
mfb_charwidth = 8;
mfb_charheight = 16;
}
else {
myfont = XLoadQueryFont(mfb_display, fontname);
if (myfont != NULL) {
XSetFont(mfb_display, mfb_lineGC, myfont->fid);
XFreeFont(mfb_display, mfb_font);
mfb_font = myfont;
mfb_fontWidth = myfont->max_bounds.width;
mfb_fontHeight = myfont->ascent + myfont->descent;
mfb_fontXOffset = 0;
mfb_fontYOffset = myfont->descent;
mfb_fontSize = myfont->max_char_or_byte2 + 1;
strncpy(mfb_fontName, fontname, 80);
mfb_fontName[80] = '\0';
return 1;
}
return 0;
}
return 1;
}
void
MFBSelectCursor(Left,Bottom,Right,Top)
/*
* Calls MFBScrollFont to display all the available characters in the
* cursor font "cursor", and calls MFBSetCursor to set the new cursor.
*/
int Left, Bottom, Right, Top;
{
static XFontStruct *cursorFont = NULL;
static GC cursorGC;
int index;
if (cursorFont == NULL) {
cursorFont = XLoadQueryFont(mfb_display, "cursor");
cursorGC = XCreateGC(mfb_display, mfb_window, 0, 0);
XSetFont(mfb_display, cursorGC, cursorFont->fid);
}
index =
MFBScrollFont(Left, Bottom, Right, Top, cursorFont, cursorGC, 1, 1);
if (index >= 0) {
if (index <= cursorFont->max_char_or_byte2 + 2) {
if (index > cursorFont->max_char_or_byte2)
index = -1;
MFBSetCursor(index);
MFBSetFullScreenCursor(false);
}
else
MFBSetFullScreenCursor(true);
}
}
void
MFBSetCursor(index)
int index;
{
XColor forg, bakg;
int screen;
if (mfb_cursor != mfb_cursorCross)
XFreeCursor(mfb_display, mfb_cursor);
if (index >= 0)
mfb_cursor = XCreateFontCursor(mfb_display, index);
else
mfb_cursor = mfb_cursorCross;
XDefineCursor(mfb_display, mfb_window, mfb_cursor);
screen = DefaultScreen(mfb_display);
forg.pixel = WhitePixel(mfb_display,screen);
bakg.pixel = BlackPixel(mfb_display,screen);
XQueryColor(mfb_display, mfb_cmap, &forg);
XQueryColor(mfb_display, mfb_cmap, &bakg);
XRecolorCursor(mfb_display, mfb_cursor, &forg, &bakg);
mfb_cursorShape = index;
}
kic-2.4c/src/xmfb/6x8font.c 0000644 0000764 0000764 00000011030 07525346715 015130 0 ustar stevew stevew /*************************************************************************
MFB graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include "mfb.h"
/* 6 X 8 character set */
unsigned short mfb_6X8font[] = {
/* */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ! */ 0x8,0x8,0x8,0x8,0x8,0x0,0x8,0x0,
/* " */ 0x14,0x14,0x14,0x0,0x0,0x0,0x0,0x0,
/* # */ 0x14,0x14,0x3e,0x14,0x3e,0x14,0x14,0x0,
/* $ */ 0x8,0x1e,0x28,0x1c,0xa,0x3c,0x8,0x0,
/* % */ 0x30,0x32,0x4,0x8,0x10,0x26,0x6,0x0,
/* & */ 0x10,0x28,0x28,0x10,0x2a,0x24,0x1a,0x0,
/* ' */ 0xc,0xc,0x8,0x10,0x0,0x0,0x0,0x0,
/* ( */ 0x4,0x8,0x10,0x10,0x10,0x8,0x4,0x0,
/* ) */ 0x10,0x8,0x4,0x4,0x4,0x8,0x10,0x0,
/* * */ 0x8,0x2a,0x1c,0x3e,0x1c,0x2a,0x8,0x0,
/* + */ 0x0,0x8,0x8,0x3e,0x8,0x8,0x0,0x0,
/* , */ 0x0,0x0,0x0,0x0,0xc,0xc,0x8,0x10,
/* - */ 0x0,0x0,0x0,0x3e,0x0,0x0,0x0,0x0,
/* . */ 0x0,0x0,0x0,0x0,0x0,0xc,0xc,0x0,
/* / */ 0x0,0x2,0x4,0x8,0x10,0x20,0x0,0x0,
/* 0 */ 0x1c,0x22,0x26,0x2a,0x32,0x22,0x1c,0x0,
/* 1 */ 0x8,0x18,0x8,0x8,0x8,0x8,0x1c,0x0,
/* 2 */ 0x1c,0x22,0x2,0x1c,0x20,0x20,0x3e,0x0,
/* 3 */ 0x3e,0x2,0x4,0xc,0x2,0x22,0x1c,0x0,
/* 4 */ 0x4,0xc,0x14,0x24,0x3e,0x4,0x4,0x0,
/* 5 */ 0x3e,0x20,0x3c,0x2,0x2,0x22,0x1c,0x0,
/* 6 */ 0xe,0x10,0x20,0x3c,0x22,0x22,0x1c,0x0,
/* 7 */ 0x3e,0x2,0x2,0x4,0x8,0x10,0x20,0x0,
/* 8 */ 0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c,0x0,
/* 9 */ 0x1c,0x22,0x22,0x1e,0x2,0x4,0x38,0x0,
/* : */ 0x0,0x0,0x8,0x0,0x8,0x0,0x0,0x0,
/* ; */ 0x0,0x0,0x8,0x0,0x8,0x8,0x10,0x0,
/* < */ 0x2,0x4,0x8,0x10,0x8,0x4,0x2,0x0,
/* = */ 0x0,0x0,0x3e,0x0,0x3e,0x0,0x0,0x0,
/* > */ 0x10,0x8,0x4,0x2,0x4,0x8,0x10,0x0,
/* ? */ 0x1c,0x22,0x2,0xc,0x8,0x0,0x8,0x0,
/* @ */ 0x1c,0x22,0x2a,0x2e,0x2c,0x20,0x1e,0x0,
/* A */ 0x8,0x14,0x22,0x22,0x3e,0x22,0x22,0x0,
/* B */ 0x3c,0x22,0x22,0x3c,0x22,0x22,0x3c,0x0,
/* C */ 0x1c,0x22,0x20,0x20,0x20,0x22,0x1c,0x0,
/* D */ 0x3c,0x22,0x22,0x22,0x22,0x22,0x3c,0x0,
/* E */ 0x3e,0x20,0x20,0x3c,0x20,0x20,0x3e,0x0,
/* F */ 0x3e,0x20,0x20,0x3c,0x20,0x20,0x20,0x0,
/* G */ 0x1e,0x22,0x20,0x20,0x26,0x22,0x1e,0x0,
/* H */ 0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x0,
/* I */ 0x1c,0x8,0x8,0x8,0x8,0x8,0x1c,0x0,
/* J */ 0xe,0x4,0x4,0x4,0x4,0x24,0x18,0x0,
/* K */ 0x22,0x24,0x28,0x30,0x28,0x24,0x22,0x0,
/* L */ 0x20,0x20,0x20,0x20,0x20,0x20,0x3e,0x0,
/* M */ 0x22,0x36,0x2a,0x2a,0x2a,0x22,0x22,0x0,
/* N */ 0x22,0x22,0x32,0x2a,0x26,0x22,0x22,0x0,
/* O */ 0x1c,0x22,0x22,0x22,0x22,0x22,0x1c,0x0,
/* P */ 0x3c,0x22,0x22,0x3c,0x20,0x20,0x20,0x0,
/* Q */ 0x1c,0x22,0x22,0x22,0x2a,0x24,0x1a,0x0,
/* R */ 0x3c,0x22,0x22,0x3c,0x28,0x24,0x22,0x0,
/* S */ 0x1c,0x22,0x20,0x1c,0x2,0x22,0x1c,0x0,
/* T */ 0x3e,0x2a,0x8,0x8,0x8,0x8,0x8,0x0,
/* U */ 0x22,0x22,0x22,0x22,0x22,0x22,0x1c,0x0,
/* V */ 0x22,0x22,0x22,0x22,0x22,0x14,0x8,0x0,
/* W */ 0x22,0x22,0x22,0x2a,0x2a,0x2a,0x14,0x0,
/* X */ 0x22,0x22,0x14,0x8,0x14,0x22,0x22,0x0,
/* Y */ 0x22,0x22,0x14,0x8,0x8,0x8,0x8,0x0,
/* Z */ 0x3e,0x2,0x4,0x1c,0x10,0x20,0x3e,0x0,
/* [ */ 0x1e,0x10,0x10,0x10,0x10,0x10,0x1e,0x0,
/* \ */ 0x0,0x20,0x10,0x8,0x4,0x2,0x0,0x0,
/* ] */ 0x1e,0x2,0x2,0x2,0x2,0x2,0x1e,0x0,
/* ^ */ 0x8,0x14,0x22,0x0,0x0,0x0,0x0,0x0,
/* _ */ 0x0,0x0,0x0,0x0,0x0,0x0,0x3e,0x0,
/* ` */ 0x18,0x18,0x8,0x4,0x0,0x0,0x0,0x0,
/* a */ 0x0,0x0,0x18,0x4,0x1c,0x24,0x1e,0x0,
/* b */ 0x20,0x20,0x2c,0x32,0x22,0x32,0x2c,0x0,
/* c */ 0x0,0x0,0x1c,0x22,0x20,0x22,0x1c,0x0,
/* d */ 0x2,0x2,0x1a,0x26,0x22,0x26,0x1a,0x0,
/* e */ 0x0,0x0,0x1c,0x22,0x3e,0x20,0x1c,0x0,
/* f */ 0x4,0xa,0x8,0x1c,0x8,0x8,0x8,0x0,
/* g */ 0x0,0x0,0x1c,0x26,0x26,0x1a,0x2,0x1c,
/* h */ 0x20,0x20,0x2c,0x32,0x22,0x22,0x22,0x0,
/* i */ 0x8,0x0,0x18,0x8,0x8,0x8,0x1c,0x0,
/* j */ 0x4,0x0,0x4,0x4,0x4,0x24,0x18,0x0,
/* k */ 0x20,0x20,0x24,0x28,0x30,0x28,0x24,0x0,
/* l */ 0x18,0x8,0x8,0x8,0x8,0x8,0x1c,0x0,
/* m */ 0x0,0x0,0x34,0x2a,0x2a,0x2a,0x2a,0x0,
/* n */ 0x0,0x0,0x2c,0x32,0x22,0x22,0x22,0x0,
/* o */ 0x0,0x0,0x1c,0x22,0x22,0x22,0x1c,0x0,
/* p */ 0x0,0x0,0x2c,0x32,0x32,0x2c,0x20,0x20,
/* q */ 0x0,0x0,0x1a,0x26,0x26,0x1a,0x2,0x2,
/* r */ 0x0,0x0,0x2c,0x32,0x20,0x20,0x20,0x0,
/* s */ 0x0,0x0,0x1e,0x20,0x1c,0x2,0x3c,0x0,
/* t */ 0x8,0x8,0x3e,0x8,0x8,0xa,0x4,0x0,
/* u */ 0x0,0x0,0x22,0x22,0x22,0x26,0x1a,0x0,
/* v */ 0x0,0x0,0x22,0x22,0x22,0x14,0x8,0x0,
/* w */ 0x0,0x0,0x22,0x22,0x2a,0x2a,0x14,0x0,
/* x */ 0x0,0x0,0x22,0x14,0x8,0x14,0x22,0x0,
/* y */ 0x0,0x0,0x22,0x22,0x1e,0x2,0x22,0x1c,
/* z */ 0x0,0x0,0x3e,0x4,0x8,0x10,0x3e,0x0,
/* { */ 0x4,0x8,0x8,0x10,0x8,0x8,0x4,0x0,
/* | */ 0x8,0x8,0x8,0x0,0x8,0x8,0x8,0x0,
/* } */ 0x10,0x8,0x8,0x4,0x8,0x8,0x10,0x0,
/* ~ */ 0x10,0x2a,0x4,0x0,0x0,0x0,0x0,0x0,
};
kic-2.4c/src/xmfb/8x16font.c 0000644 0000764 0000764 00000017475 07525346714 015233 0 ustar stevew stevew /*************************************************************************
MFB graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include "mfb.h"
/* 8 X 16 character set */
unsigned short mfb_8X16font[] = {
/* */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ! */ 0x0,0x0,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x18,0x0,0x18,0x18,0x0,0x0,0x0,0x0,
/* " */ 0x0,0x66,0x66,0x66,0x24,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* # */ 0x0,0x0,0x0,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c,0x0,0x0,0x0,0x0,
/* $ */ 0x18,0x18,0x7c,0xc6,0xc2,0xc0,0x7c,0x6,0x6,0x86,0xc6,0x7c,0x18,0x18,0x0,0x0,
/* % */ 0x0,0x0,0x0,0x0,0xc2,0xc6,0xc,0x18,0x30,0x60,0xc6,0x86,0x0,0x0,0x0,0x0,
/* & */ 0x0,0x0,0x38,0x6c,0x6c,0x38,0x76,0xdc,0xcc,0xcc,0xcc,0x76,0x0,0x0,0x0,0x0,
/* ' */ 0x0,0x30,0x30,0x30,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ( */ 0x0,0x0,0xc,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0xc,0x0,0x0,0x0,0x0,
/* ) */ 0x0,0x0,0x30,0x18,0xc,0xc,0xc,0xc,0xc,0xc,0x18,0x30,0x0,0x0,0x0,0x0,
/* * */ 0x0,0x0,0x0,0x0,0x0,0x66,0x3c,0xff,0x3c,0x66,0x0,0x0,0x0,0x0,0x0,0x0,
/* + */ 0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x7e,0x18,0x18,0x0,0x0,0x0,0x0,0x0,0x0,
/* , */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x18,0x30,0x0,0x0,0x0,
/* - */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* . */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x0,
/* / */ 0x0,0x0,0x0,0x0,0x2,0x6,0xc,0x18,0x30,0x60,0xc0,0x80,0x0,0x0,0x0,0x0,
/* 0 */ 0x0,0x0,0x7c,0xc6,0xc6,0xce,0xde,0xf6,0xe6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* 1 */ 0x0,0x0,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x0,0x0,0x0,0x0,
/* 2 */ 0x0,0x0,0x7c,0xc6,0x6,0xc,0x18,0x30,0x60,0xc0,0xc6,0xfe,0x0,0x0,0x0,0x0,
/* 3 */ 0x0,0x0,0x7c,0xc6,0x6,0x6,0x3c,0x6,0x6,0x6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* 4 */ 0x0,0x0,0xc,0x1c,0x3c,0x6c,0xcc,0xfe,0xc,0xc,0xc,0x1e,0x0,0x0,0x0,0x0,
/* 5 */ 0x0,0x0,0xfe,0xc0,0xc0,0xc0,0xfc,0x6,0x6,0x6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* 6 */ 0x0,0x0,0x38,0x60,0xc0,0xc0,0xfc,0xc6,0xc6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* 7 */ 0x0,0x0,0xfe,0xc6,0x6,0x6,0xc,0x18,0x30,0x30,0x30,0x30,0x0,0x0,0x0,0x0,
/* 8 */ 0x0,0x0,0x7c,0xc6,0xc6,0xc6,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* 9 */ 0x0,0x0,0x7c,0xc6,0xc6,0xc6,0x7e,0x6,0x6,0x6,0xc,0x78,0x0,0x0,0x0,0x0,
/* : */ 0x0,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x0,0x0,
/* ; */ 0x0,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x18,0x18,0x30,0x0,0x0,0x0,0x0,
/* < */ 0x0,0x0,0x0,0x6,0xc,0x18,0x30,0x60,0x30,0x18,0xc,0x6,0x0,0x0,0x0,0x0,
/* = */ 0x0,0x0,0x0,0x0,0x0,0x7e,0x0,0x0,0x7e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* > */ 0x0,0x0,0x0,0x60,0x30,0x18,0xc,0x6,0xc,0x18,0x30,0x60,0x0,0x0,0x0,0x0,
/* ? */ 0x0,0x0,0x7c,0xc6,0xc6,0xc,0x18,0x18,0x18,0x0,0x18,0x18,0x0,0x0,0x0,0x0,
/* @ */ 0x0,0x0,0x7c,0xc6,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x0,0x0,0x0,0x0,
/* A */ 0x0,0x0,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0x0,0x0,0x0,0x0,
/* B */ 0x0,0x0,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0x66,0xfc,0x0,0x0,0x0,0x0,
/* C */ 0x0,0x0,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x0,0x0,0x0,0x0,
/* D */ 0x0,0x0,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x0,0x0,0x0,0x0,
/* E */ 0x0,0x0,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xfe,0x0,0x0,0x0,0x0,
/* F */ 0x0,0x0,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xf0,0x0,0x0,0x0,0x0,
/* G */ 0x0,0x0,0x3c,0x66,0xc2,0xc0,0xc0,0xde,0xc6,0xc6,0x66,0x3a,0x0,0x0,0x0,0x0,
/* H */ 0x0,0x0,0xc6,0xc6,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0xc6,0x0,0x0,0x0,0x0,
/* I */ 0x0,0x0,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,0x0,
/* J */ 0x0,0x0,0x1e,0xc,0xc,0xc,0xc,0xc,0xcc,0xcc,0xcc,0x78,0x0,0x0,0x0,0x0,
/* K */ 0x0,0x0,0xe6,0x66,0x66,0x6c,0x78,0x78,0x6c,0x66,0x66,0xe6,0x0,0x0,0x0,0x0,
/* L */ 0x0,0x0,0xf0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xfe,0x0,0x0,0x0,0x0,
/* M */ 0x0,0x0,0xc6,0xee,0xfe,0xfe,0xd6,0xc6,0xc6,0xc6,0xc6,0xc6,0x0,0x0,0x0,0x0,
/* N */ 0x0,0x0,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0xc6,0xc6,0x0,0x0,0x0,0x0,
/* O */ 0x0,0x0,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* P */ 0x0,0x0,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0x60,0xf0,0x0,0x0,0x0,0x0,
/* Q */ 0x0,0x0,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xd6,0xde,0x7c,0xc,0xe,0x0,0x0,
/* R */ 0x0,0x0,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0x66,0xe6,0x0,0x0,0x0,0x0,
/* S */ 0x0,0x0,0x7c,0xc6,0xc6,0x60,0x38,0xc,0x6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* T */ 0x0,0x0,0x7e,0x7e,0x5a,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,0x0,
/* U */ 0x0,0x0,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* V */ 0x0,0x0,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x6c,0x38,0x10,0x0,0x0,0x0,0x0,
/* W */ 0x0,0x0,0xc6,0xc6,0xc6,0xc6,0xd6,0xd6,0xd6,0xfe,0xee,0x6c,0x0,0x0,0x0,0x0,
/* X */ 0x0,0x0,0xc6,0xc6,0x6c,0x7c,0x38,0x38,0x7c,0x6c,0xc6,0xc6,0x0,0x0,0x0,0x0,
/* Y */ 0x0,0x0,0x66,0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,0x0,
/* Z */ 0x0,0x0,0xfe,0xc6,0x86,0xc,0x18,0x30,0x60,0xc2,0xc6,0xfe,0x0,0x0,0x0,0x0,
/* [ */ 0x0,0x0,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x0,0x0,0x0,0x0,
/* \ */ 0x0,0x0,0x0,0x80,0xc0,0xe0,0x70,0x38,0x1c,0xe,0x6,0x2,0x0,0x0,0x0,0x0,
/* ] */ 0x0,0x0,0x3c,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x3c,0x0,0x0,0x0,0x0,
/* ^ */ 0x10,0x38,0x6c,0xc6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* _ */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0x0,
/* ` */ 0x30,0x30,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* a */ 0x0,0x0,0x0,0x0,0x0,0x78,0xc,0x7c,0xcc,0xcc,0xcc,0x76,0x0,0x0,0x0,0x0,
/* b */ 0x0,0x0,0xe0,0x60,0x60,0x78,0x6c,0x66,0x66,0x66,0x66,0x7c,0x0,0x0,0x0,0x0,
/* c */ 0x0,0x0,0x0,0x0,0x0,0x7c,0xc6,0xc0,0xc0,0xc0,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* d */ 0x0,0x0,0x1c,0xc,0xc,0x3c,0x6c,0xcc,0xcc,0xcc,0xcc,0x76,0x0,0x0,0x0,0x0,
/* e */ 0x0,0x0,0x0,0x0,0x0,0x7c,0xc6,0xfe,0xc0,0xc0,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* f */ 0x0,0x0,0x38,0x6c,0x64,0x60,0xf0,0x60,0x60,0x60,0x60,0xf0,0x0,0x0,0x0,0x0,
/* g */ 0x0,0x0,0x0,0x0,0x0,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0xc,0xcc,0x78,0x0,
/* h */ 0x0,0x0,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0x66,0xe6,0x0,0x0,0x0,0x0,
/* i */ 0x0,0x0,0x18,0x18,0x0,0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,0x0,
/* j */ 0x0,0x0,0x6,0x6,0x0,0xe,0x6,0x6,0x6,0x6,0x6,0x6,0x66,0x66,0x3c,0x0,
/* k */ 0x0,0x0,0xe0,0x60,0x60,0x66,0x6c,0x78,0x78,0x6c,0x66,0xe6,0x0,0x0,0x0,0x0,
/* l */ 0x0,0x0,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,0x0,
/* m */ 0x0,0x0,0x0,0x0,0x0,0xec,0xfe,0xd6,0xd6,0xd6,0xd6,0xc6,0x0,0x0,0x0,0x0,
/* n */ 0x0,0x0,0x0,0x0,0x0,0xdc,0x66,0x66,0x66,0x66,0x66,0x66,0x0,0x0,0x0,0x0,
/* o */ 0x0,0x0,0x0,0x0,0x0,0x7c,0xc6,0xc6,0xc6,0xc6,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* p */ 0x0,0x0,0x0,0x0,0x0,0xdc,0x66,0x66,0x66,0x66,0x66,0x7c,0x60,0x60,0xf0,0x0,
/* q */ 0x0,0x0,0x0,0x0,0x0,0x76,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0xc,0xc,0x1e,0x0,
/* r */ 0x0,0x0,0x0,0x0,0x0,0xdc,0x76,0x66,0x60,0x60,0x60,0xf0,0x0,0x0,0x0,0x0,
/* s */ 0x0,0x0,0x0,0x0,0x0,0x7c,0xc6,0x60,0x38,0xc,0xc6,0x7c,0x0,0x0,0x0,0x0,
/* t */ 0x0,0x0,0x10,0x30,0x30,0xfc,0x30,0x30,0x30,0x30,0x36,0x1c,0x0,0x0,0x0,0x0,
/* u */ 0x0,0x0,0x0,0x0,0x0,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x0,0x0,0x0,0x0,
/* v */ 0x0,0x0,0x0,0x0,0x0,0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x0,0x0,0x0,0x0,
/* w */ 0x0,0x0,0x0,0x0,0x0,0xc6,0xc6,0xd6,0xd6,0xd6,0xfe,0x6c,0x0,0x0,0x0,0x0,
/* x */ 0x0,0x0,0x0,0x0,0x0,0xc6,0x6c,0x38,0x38,0x38,0x6c,0xc6,0x0,0x0,0x0,0x0,
/* y */ 0x0,0x0,0x0,0x0,0x0,0xc6,0xc6,0xc6,0xc6,0xc6,0xc6,0x7e,0x6,0xc,0xf8,0x0,
/* z */ 0x0,0x0,0x0,0x0,0x0,0xfe,0xcc,0x18,0x30,0x60,0xc6,0xfe,0x0,0x0,0x0,0x0,
/* { */ 0x0,0x0,0xe,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0xe,0x0,0x0,0x0,0x0,
/* | */ 0x0,0x0,0x18,0x18,0x18,0x18,0x0,0x18,0x18,0x18,0x18,0x18,0x0,0x0,0x0,0x0,
/* } */ 0x0,0x0,0x70,0x18,0x18,0x18,0xe,0x18,0x18,0x18,0x18,0x70,0x0,0x0,0x0,0x0,
/* ~ */ 0x0,0x0,0x76,0xdc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
};
kic-2.4c/src/xmfb/mfbtext.c 0000644 0000764 0000764 00000137763 11133226646 015301 0 ustar stevew stevew /*************************************************************************
XMFB X-Window MFB emulation package
Authore: Peter C. Vernam, C. S. Draper Laboratory, 1989
Stephen R. Whiteley, 1992
*************************************************************************/
/**************************************************************************
*
* MFBText
*
* This module contains the MFB routines for the management of graphtext:
* MFBMore - display the contents of a file, one page at a time.
* MFBScroll - display the contents of a file, with the capability of
* scrolling forwards or backwards. (Note: The output from
* a pipe cannot be scrolled backwards.)
* MFBScrollList - display and scroll an array of text strings, with
* optional selection (and optional display of font if the
* text strings are font names).
* MFBScrollFont - display and scroll a text font, with optional selection.
*
**************************************************************************/
/*
* Modified October 1989 by Peter C. Vernam, Charles Stark Draper Laboratory:
* 08OCT89 - New routines MFBScrollList and MFBScrollFont added.
* 11OCT89 - Revised considerably to correctly handle the variable-width
* text fonts that are available in X.
* 06NOV89 - MFBScroll modified to use ftell() and fseek() for scrolling
* backwards through file.
*/
#include "mfb.h" /* standard MFB header file */
#include
#define MAXCHARLINE 200 /* maximum number of characters per line */
#define MAXLINEPAGE 100 /* maximum number of lines per page */
#define MAXPAGES 200 /* maximum number of page top pointers */
#if __STDC__
static int get_bg_color(void);
static void display_scroll_help(int,int,int,int,int,int,int,int,int);
#else
static int get_bg_color();
static void display_scroll_help();
#endif
void
MFBMore(Left,Bottom,Right,Top,Textfile)
int Left, Bottom, Right, Top;
FILE *Textfile;
{
char cbuf[MAXCHARLINE+9]; /* add extra space for tab expansion */
int key;
int i,j,x,y,c,button,dy;
int done;
int oldfillpattern;
int oldforeground;
int newbackground;
int nlines;
int pagecount;
int controlchar;
int width_screen; /* width of the box */
int width_string; /* width of the current string */
int width_space; /* width of a space character */
Bool variable_width; /* True if current font is variable width */
/* test to be sure of window area */
if (Top < Bottom)
MFBSwapInt(Top, Bottom);
if (Right < Left)
MFBSwapInt(Left, Right);
/* calculate parameters */
dy = mfb_fontHeight;
nlines = (Top - Bottom) / dy;
if (nlines <= 0)
return;
width_screen = Right - Left;
if (mfb_font->min_bounds.width != mfb_font->max_bounds.width) {
variable_width = True;
width_space = XTextWidth(mfb_font, " ", 1);
width_screen -= 3;
}
else {
variable_width = False;
width_space = mfb_font->max_bounds.width;
}
/* save old style ID's */
oldforeground = mfb_fgColorId;
oldfillpattern = mfb_fillPattern;
MFBSetFillPattern(0);
if (oldforeground == 0)
newbackground = get_bg_color();
else
newbackground = 0;
pagecount = 0;
done = 0;
while (!done) {
/* Display one page of text from the file */
MFBSetColor(newbackground);
MFBBox(Left, Bottom, Right, Top); /* Erase the screen */
MFBSetColor(oldforeground);
for (j = 1; j < nlines; ++j) {
/* Loop for each line of page */
i = 0;
width_string = 0;
controlchar = 0;
while ((c = getc(Textfile)) != '\n' && c != EOF) {
/* Get a char */
if (c == '\t') {
/* tab */
cbuf[i++] = ' ';
if ((width_string += width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
while (i % 8 != 0) {
cbuf[i++] = ' ';
width_string += width_space;
}
if (width_string > width_screen)
break;
}
else if (c < ' ') {
/* control character */
if (controlchar == 0) {
cbuf[i] = '^';
ungetc(c,Textfile);
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen)
break;
controlchar = 1;
}
else {
cbuf[i] = c + '@';
controlchar = 0;
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
--i;
break;
}
}
++i;
}
else if (c <= '~') {
/* < DEL character? */
if ((width_string += (variable_width) ?
XTextWidth(mfb_font,(char *) &c, 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
cbuf[i++] = c;
}
if (i >= MAXCHARLINE)
break;
}
cbuf[i] = '\0';
MFBText(cbuf, Left, Top - j * dy, 0);
if (c == EOF) {
done = 1;
break;
}
}
if (done)
strcpy(cbuf, "-DONE- (^U to scroll up, ? for help)");
else
strcpy(cbuf, "-MORE- (^U to scroll up, ^D to exit, ? for help)");
MFBText(cbuf, Left, Bottom, 0);
i = Left + XTextWidth(mfb_font, cbuf, strlen(cbuf));
sprintf(cbuf, "Page %d", ++pagecount);
j = Right - XTextWidth(mfb_font, cbuf, strlen(cbuf)) - 3;
if (j < i)
j = i;
MFBText(cbuf, j, Bottom, 0);
/* Wait for user interaction and perform requested function */
for (;;) {
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
/* Keyboard key pressed */
if (key == CTRLD)
done = 1;
}
else {
/* Mouse button pressed */
if (x < Left || x > Right || y < Bottom || y > Top)
done = 1;
else if (button == mfb_buttonMask[1]) {
/* MB2 - down */
if (done) {
MFBAudio();
continue;
}
}
else if (button != mfb_buttonMask[0]) {
MFBAudio();
continue;
}
}
break;
}
}
MFBSetFillPattern(oldfillpattern);
}
void
MFBScroll(Left,Bottom,Right,Top,Textfile)
int Left, Bottom, Right, Top;
FILE *Textfile;
{
char cbuf[MAXCHARLINE+9]; /* add extra space for tab expansion */
int key;
int i,j,x,y,c,button,dy;
int topline; /* line at top of box */
int curline; /* current line */
int pagecount; /* count of pages of text displayed */
int lastpage; /* last page number */
int pagetopline[MAXPAGES]; /* saved topline for each page */
int done;
int oldfillpattern;
int oldforeground;
int newbackground;
int nlines;
int controlchar;
int width_screen; /* width of the box */
int width_string; /* width of the current string */
int width_space; /* width of a space character */
Bool variable_width; /* True if current font is variable width */
Bool display_switch; /* True to display file; False to find end */
/* test to be sure of window area */
if (Top < Bottom)
MFBSwapInt(Top, Bottom);
if (Right < Left)
MFBSwapInt(Left, Right);
/* calculate parameters */
dy = mfb_fontHeight;
nlines = (Top - Bottom) / dy;
if (nlines <= 0)
return;
width_screen = Right - Left;
if (mfb_font->min_bounds.width != mfb_font->max_bounds.width) {
variable_width = True;
width_space = XTextWidth(mfb_font, " ", 1);
width_screen -= 3;
}
else {
variable_width = False;
width_space = mfb_font->max_bounds.width;
}
/* save old style ID's */
oldforeground = mfb_fgColorId;
oldfillpattern = mfb_fillPattern;
MFBSetFillPattern(0);
if (oldforeground == 0)
newbackground = get_bg_color();
else
newbackground = 0;
pagecount = 0;
lastpage = 0;
topline = 0;
display_switch = True;
done = 0;
while (!done ) {
/* Display one page of text from the file */
if (display_switch) {
MFBSetColor(newbackground);
MFBBox(Left, Bottom, Right, Top); /* Erase the screen */
MFBSetColor(oldforeground);
}
fseek(Textfile, topline, 0);
for (j = 1; j < nlines; ++j) {
/* Loop for each line of page */
i = 0;
width_string = 0;
controlchar = 0;
while ((c = getc(Textfile)) != '\n' && c != EOF) {
/* Get a char */
if (c == '\t') {
/* tab */
cbuf[i++] = ' ';
if ((width_string += width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
while (i % 8 != 0) {
cbuf[i++] = ' ';
width_string += width_space;
}
if (width_string > width_screen)
break;
}
else if (c < ' ') {
/* control character */
if (controlchar == 0) {
cbuf[i] = '^';
ungetc(c,Textfile);
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen)
break;
controlchar = 1;
}
else {
cbuf[i] = c + '@';
controlchar = 0;
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
--i;
break;
}
}
++i;
}
else if (c <= '~') {
/* < DEL character? */
if ((width_string += (variable_width) ?
XTextWidth(mfb_font,(char *) &c, 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
cbuf[i++] = c;
}
if (i >= MAXCHARLINE)
break;
}
if (display_switch) {
cbuf[i] = '\0';
MFBText(cbuf, Left, Top - j * dy, 0);
}
if (c == EOF) {
done = 1;
break;
}
}
curline = ftell(Textfile);
if (pagecount < MAXPAGES)
pagetopline[pagecount] = topline;
if (display_switch)
++pagecount;
else {
if (done) {
done = 0;
display_switch = True;
}
else {
topline = curline;
++pagecount;
}
continue;
}
if (done) {
lastpage = pagecount;
strcpy(cbuf, "-DONE- (^U to scroll up, ? for help)");
}
else
strcpy(cbuf, "-MORE- (^U to scroll up, ^D to exit, ? for help)");
MFBText(cbuf, Left, Bottom, 0);
i = Left + XTextWidth(mfb_font, cbuf, strlen(cbuf));
if (lastpage > 0)
sprintf(cbuf, "Page %d of %d", pagecount, lastpage);
else
sprintf(cbuf, "Page %d", pagecount);
j = Right - XTextWidth(mfb_font, cbuf, strlen(cbuf)) - 3;
if (j < i)
j = i;
MFBText(cbuf, j, Bottom, 0);
/* Wait for user interaction and perform requested function */
for (;;) {
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
/* Keyboard key pressed */
if (key == CTRLD)
/* - done */
done = 1;
else if (key == CTRLU) {
/* - scroll up */
if (topline == 0) {
MFBAudio();
continue;
}
--pagecount;
if (pagecount < 1)
pagecount = 1;
else if (pagecount > MAXPAGES)
pagecount = MAXPAGES;
topline = pagetopline[--pagecount];
done = 0;
}
else if (key == '?') {
/* '?' - help */
display_scroll_help(Left, Bottom, Right, Top, dy,
oldforeground, newbackground, 0, 0);
done = 0;
}
else
/* else - scroll down */
topline = curline;
}
else {
/* Mouse button pressed */
if (x < Left || x > Right || y < Bottom || y > Top)
done = 1;
else if (button == mfb_buttonMask[2]) {
/* MB3 - up */
if (topline == 0) {
MFBAudio();
continue;
}
--pagecount;
if (pagecount < 1)
pagecount = 1;
else if (pagecount > MAXPAGES)
pagecount = MAXPAGES;
topline = pagetopline[--pagecount];
done = 0;
}
else if (button == mfb_buttonMask[5]) {
/* Shift/MB3 - top */
if (topline == 0) {
MFBAudio();
continue;
}
pagecount = 0;
topline = 0;
done = 0;
}
else if (button == mfb_buttonMask[1]) {
/* MB2 - down */
if (done) {
MFBAudio();
continue;
}
topline = curline;
}
else if (button == mfb_buttonMask[4]) {
/* Shift/MB2 - bottom */
if (done) {
MFBAudio();
continue;
}
if (lastpage > 0) {
pagecount = lastpage;
if (pagecount > MAXPAGES) {
pagecount = MAXPAGES;
display_switch = False;
}
topline = pagetopline[--pagecount];
}
else {
topline = curline;
display_switch = False;
}
}
else if (button != mfb_buttonMask[0]) {
MFBAudio();
continue;
}
else
/* MB1 - down */
topline = curline;
}
break;
}
}
MFBSetFillPattern(oldfillpattern);
}
int
MFBScrollList(Left,Bottom,Right,Top,List,Nlist,SelectSW,FontSW,NumberSW)
int Left, Bottom, Right, Top;
char **List; /* array of character strings */
int Nlist; /* number of strings in array List */
int SelectSW; /* if true, list items may be selected. The
* index (beginning with 0) of the selected List
* item will be returned if a selection is made,
* otherwise -1 will be returned. */
int FontSW; /* if true, the List is assumed to be a list of
* font names. If one is selected and '+' is
* entered, the corresponding font table will
* be displayed. */
int NumberSW; /* if true, each string in the List will be
* displayed preceded by its number (beginning
* with 1), and ". " */
/*
* New routine created 08OCT89 by Peter C. Vernam, C. S. Draper Laboratory
*
* This routine performs much like MFBScroll except that, instead of scrolling
* through a file, an array of character strings (an in-memory text file, of
* a sort) is scrolled. This avoids the overhead of writing and then reading a
* file when this is not strictly necessary.
*/
{
char cbuf[MAXCHARLINE+9]; /* add extra space for tab expansion */
int ypos[MAXLINEPAGE];
char c;
int key;
int i,j,x,y,button,dy;
int topline; /* line at top of box */
int curline; /* current line */
int curchar; /* current character within line */
int linecount = 0; /* count of source lines displayed */
int pagecount; /* count of pages of text displayed */
int lastpage; /* last page number */
int pagetopline[MAXPAGES]; /* saved topline for each page */
int done;
int oldfillpattern;
int oldforeground;
int newbackground;
int nlines;
int controlchar;
int selection = -1; /* selection index return value */
int width_screen; /* width of the box */
int width_string; /* width of the current string */
int width_space; /* width of a space character */
int xorg; /* x coordinate of string origin */
int xcont = 0; /* x origin for continuation lines */
Bool variable_width; /* True if current font is variable width */
Bool display_switch; /* True to display file; False to find end */
static XFontStruct *myfont = NULL;
static char myfontname[129] = "";
static GC mygc = None;
/* test to be sure of window area */
if (Top < Bottom)
MFBSwapInt(Top, Bottom);
if (Right < Left)
MFBSwapInt(Left, Right);
/* calculate parameters */
dy = mfb_fontHeight;
nlines = (Top - Bottom) / dy;
if (nlines <= 0)
return (-1);
width_screen = Right - Left;
if (mfb_font->min_bounds.width != mfb_font->max_bounds.width) {
variable_width = True;
width_space = XTextWidth(mfb_font, " ", 1);
width_screen -= 3;
}
else {
variable_width = False;
width_space = mfb_font->max_bounds.width;
}
/* save old style ID's */
oldforeground = mfb_fgColorId;
oldfillpattern = mfb_fillPattern;
MFBSetFillPattern(0);
if (oldforeground == 0)
newbackground = get_bg_color();
else
newbackground = 0;
pagecount = 0;
lastpage = 0;
topline = 0;
display_switch = True;
done = 0;
while (!done ) {
/* Display one page of text from the List */
if (display_switch) {
MFBSetColor(newbackground);
MFBBox(Left, Bottom, Right, Top); /* Erase the screen */
MFBSetColor(oldforeground);
}
curline = topline;
curchar = 0;
for (j = 1; j < nlines; ++j) {
/* Loop to fill a page */
i = 0;
width_string = 0;
xorg = Left;
if (NumberSW) {
/* Prefix line with the line number */
if (curchar == 0) {
sprintf(cbuf, "%d. ", curline + 1);
i = strlen(cbuf);
if (variable_width)
width_string = XTextWidth(mfb_font, cbuf, i);
else
width_string = width_space * i;
xcont = xorg + width_string;
}
else {
width_string = xcont - xorg;
xorg = xcont;
}
}
controlchar = 0;
while ((c = List[curline][curchar]) != '\0') {
/* Get a char */
if (c == '\t') {
/* tab */
cbuf[i++] = ' ';
if ((width_string += width_space) > width_screen)
break;
++curchar;
while (i % 8 != 0) {
cbuf[i++] = ' ';
width_string += width_space;
}
if (width_string > width_screen)
break;
}
else if (c < ' ') {
/* control character */
if (controlchar == 0) {
cbuf[i] = '^';
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen)
break;
controlchar = 1;
}
else {
cbuf[i] = c + '@';
controlchar = 0;
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &cbuf[i], 1) :
width_space) > width_screen) {
--i;
break;
}
++curchar;
}
++i;
}
else if (c <= '~') {
/* < DEL character? */
if ((width_string += (variable_width) ?
XTextWidth(mfb_font, &c, 1) :
width_space) > width_screen)
break;
cbuf[i++] = c;
++curchar;
}
if (i >= MAXCHARLINE)
break;
}
if (display_switch) {
cbuf[i] = '\0';
linecount = curline - topline;
ypos[linecount] = Top - j * dy;
if (curline == selection) {
MFBSetColor(oldforeground);
MFBBox(Left, ypos[linecount], Right, ypos[linecount] + dy);
MFBSetColor(newbackground);
MFBText(cbuf, xorg, ypos[linecount], 0);
MFBSetColor(oldforeground);
}
else
MFBText(cbuf, xorg, ypos[linecount], 0);
}
if (c == '\0') {
curchar = 0;
if (++curline >= Nlist) {
done = 1;
break;
}
}
}
if (pagecount < MAXPAGES)
pagetopline[pagecount] = topline;
if (display_switch)
++pagecount;
else {
if (done) {
done = 0;
display_switch = True;
}
else {
topline = curline;
++pagecount;
}
continue;
}
if (done) {
lastpage = pagecount;
strcpy(cbuf, "-DONE- (^U to scroll up, ? for help)");
}
else
strcpy(cbuf, "-MORE- (^U to scroll up, ^D to exit, ? for help)");
MFBText(cbuf, Left, Bottom, 0);
i = Left + XTextWidth(mfb_font, cbuf, strlen(cbuf));
if (lastpage > 0)
sprintf(cbuf, "Page %d of %d", pagecount, lastpage);
else
sprintf(cbuf, "Page %d", pagecount);
j = Right - XTextWidth(mfb_font, cbuf, strlen(cbuf)) - 3;
if (j < i)
j = i;
MFBText(cbuf, j, Bottom, 0);
/* Wait for user interaction and perform requested function */
for (;;) {
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
/* Keyboard key pressed */
if (key == CTRLD)
/* - done */
done = 1;
else if (key == CTRLU) {
/* - scroll up */
if (topline == 0) {
MFBAudio();
continue;
}
--pagecount;
if (pagecount < 1)
pagecount = 1;
else if (pagecount > MAXPAGES)
pagecount = MAXPAGES;
topline = pagetopline[--pagecount];
done = 0;
}
else if (key == '?') {
/* '?' - help */
display_scroll_help(Left, Bottom, Right, Top, dy,
oldforeground, newbackground, SelectSW, FontSW);
done = 0;
}
else
/* else - scroll down */
topline = curline;
}
else {
/* Mouse button pressed */
if (x < Left || x > Right || y < Bottom || y > Top)
/* outside window - done */
done = 1;
else if (button == mfb_buttonMask[3] && FontSW) {
/* Shift/MB1 - show font */
for (i = 0; i <= linecount; ++i)
if (y >= ypos[i])
break;
if (i > linecount) {
MFBAudio();
continue;
}
if (mygc == None)
mygc = XCreateGC(mfb_display,mfb_window, 0, 0);
if (strcmp(myfontname, List[topline + i]) != 0) {
strcpy(myfontname, List[topline + i]);
if (myfont != NULL)
XFreeFont(mfb_display, myfont);
myfont = XLoadQueryFont(mfb_display, myfontname);
XSetFont(mfb_display, mygc, myfont->fid);
}
MFBScrollFont(Left,Bottom,Right,Top, myfont, mygc,0,0);
done = 0;
}
else if (button == mfb_buttonMask[2]) {
/* MB3 - up */
if (topline == 0) {
MFBAudio();
continue;
}
--pagecount;
if (pagecount < 1)
pagecount = 1;
else if (pagecount > MAXPAGES)
pagecount = MAXPAGES;
topline = pagetopline[--pagecount];
done = 0;
}
else if (button == mfb_buttonMask[5]) {
/* Shift/MB3 - top */
if (topline == 0) {
MFBAudio();
continue;
}
pagecount = 0;
topline = 0;
done = 0;
}
else if (button == mfb_buttonMask[1]) {
/* MB2 - down */
if (done) {
MFBAudio();
continue;
}
topline = curline;
}
else if (button == mfb_buttonMask[4]) {
/* Shift/MB2 - bottom */
if (done) {
MFBAudio();
continue;
}
if (lastpage > 0) {
pagecount = lastpage;
if (pagecount > MAXPAGES) {
pagecount = MAXPAGES;
display_switch = False;
}
topline = pagetopline[--pagecount];
}
else {
topline = curline;
display_switch = False;
}
}
else if (button != mfb_buttonMask[0]) {
MFBAudio();
continue;
}
else if (SelectSW) {
/* MB1 & selecting */
for (i = 0; i <= linecount; ++i)
if (y >= ypos[i]) {
if (selection != topline + i)
selection = topline + i;
else
selection = -1;
done = 0;
break;
}
if (i > linecount)
/* scroll down */
topline = curline;
}
else
/* MB1 & not selecting - down */
topline = curline;
}
break;
}
}
MFBSetFillPattern(oldfillpattern);
return selection;
}
int
MFBScrollFont(Left,Bottom,Right,Top,FontST,FontGC,SelectSW,CursorSW)
int Left, Bottom, Right, Top;
XFontStruct *FontST; /* pointer to an X font structure */
GC FontGC; /* GC to use for drawing this font */
int SelectSW; /* if true, list items may be selected. The
* index (beginning with 0) of the selected List
* item will be returned if a selection is made,
* otherwise -1 will be returned. */
int CursorSW; /* if true, Font is a cursor font (even number
* indices contain font bits, odd number
* indices contain font mask bits);
* show only the even-numbered entries */
/*
* New routine created 08OCT89 by Peter C. Vernam, C. S. Draper Laboratory
*
* This routine performs much like MFBScrollList except that, instead of
* scrolling through an array of character strings, a table of font
* characters is scrolled.
*/
{
char cbuf[81];
int key;
int i,j,n,x,y,button,x0,y0,xn,yn,dx,dy,dx2,dy2,fw,fh;
int dx2m1,dy2m1;
int topchar; /* character at top-left of box */
int curchar; /* current character being displayed */
int oldfillpattern;
int oldforeground;
int newbackground;
int nlines; /* number of lines that fit on a page */
int nchars; /* number of chars that fit on a line */
int nchars_per_page; /* number of chars that fit on a page */
int lastpage; /* page number of the last page */
int inc;
int done;
int selection = -1; /* selection index return value */
unsigned char1, charN, charn, charn1;
int cleft;
char ctext[9];
XCharStruct mychar;
int direct, ascent, descent;
/* test to be sure of window area */
if (Top < Bottom)
MFBSwapInt(Top, Bottom);
if (Right < Left)
MFBSwapInt(Left, Right);
/* calculate parameters */
char1 = FontST->min_char_or_byte2;
charN = FontST->max_char_or_byte2;
charn = charn1 = charN;
dx = FontST->ascent + FontST->descent;
fw = mfb_fontWidth;
fh = mfb_fontHeight;
if (CursorSW) {
topchar = char1;
inc = 2;
if (SelectSW) {
charn1 += 2;
charN += 4;
}
nchars = (Right - Left) / dx;
dx = (Right - Left) / nchars;
nlines = (Top - Bottom - fh) / dx;
}
else {
topchar = 0;
inc = 1;
dx *= 2;
nchars = MFBmin(32, (Right - Left - 3 * fw) / dx);
for (i = 1; i <= 64; i <<= 1)
if (nchars < i) {
nchars = i >> 1;
break;
}
nlines = (Top - Bottom - 3 * fh) / dx;
}
if (nlines <= 0)
return (-1);
nchars_per_page = nlines * nchars * inc;
lastpage = charN / nchars_per_page + 1;
dy = dx;
dx2 = dx / 2;
dy2 = dy / 2;
dx2m1 = dx2 - 1;
dy2m1 = dy2 - 1;
x0 = Left + dx2;
y0 = Top - dy2;
xn = Left + nchars * dx;
/* save old style ID's */
oldforeground = mfb_fgColorId;
oldfillpattern = mfb_fillPattern;
MFBSetFillPattern(0);
if (oldforeground == 0)
newbackground = get_bg_color();
else
newbackground = 0;
done = 0;
while (!done ) {
/* Display one page of characters from the Font */
MFBSetColor(newbackground);
MFBBox(Left, Bottom, Right, Top); /* Erase the screen */
MFBSetColor(oldforeground);
XSetBackground(mfb_display, FontGC, mfb_colors[newbackground]);
XSetForeground(mfb_display, FontGC, mfb_colors[oldforeground]);
curchar = topchar;
for (j = 0; j < nlines; ++j) {
/* Loop for each line of page */
y = y0 - j * dy;
cleft = curchar;
for (i = 0; i < nchars; ++i) {
/* Loop for each char of line */
x = x0 + i * dx;
if (curchar >= char1) {
cbuf[0] = curchar;
if (curchar == selection) {
/* Selected character: display in reverse video */
MFBBox(x-dx2m1, y-dy2m1, x+dx2m1, y+dy2m1);
if (curchar <= charn) {
/* Font character or cursor */
XSetForeground(mfb_display, FontGC,
mfb_colors[newbackground]);
XDrawString(mfb_display, mfb_window, FontGC,
x, TRAN(y), cbuf, 1);
XSetForeground(mfb_display, FontGC,
mfb_colors[oldforeground]);
}
else if (curchar <= charn1) {
/* MFB cursor */
XSetBackground(mfb_display, FontGC,
mfb_colors[oldforeground]);
XSetForeground(mfb_display, FontGC,
mfb_colors[newbackground]);
XPutImage(mfb_display, mfb_window, FontGC,
mfb_cursorImage, 0, 0,
x-7, TRAN(y)-7, 16, 16);
XSetBackground(mfb_display, FontGC,
mfb_colors[newbackground]);
XSetForeground(mfb_display, FontGC,
mfb_colors[oldforeground]);
}
else {
/* Full-screen cross-hair */
MFBSetColor(newbackground);
MFBLine(x-dx2m1, y, x+dx2m1, y);
MFBLine(x, y-dy2m1, x, y+dy2m1);
MFBSetColor(oldforeground);
}
}
else {
/* Not selected: display normally */
if (curchar <= charn)
/* Font character or cursor */
XDrawString(mfb_display, mfb_window, FontGC,
x, TRAN(y), cbuf, 1);
else if (curchar <= charn1)
/* MFB cursor */
XPutImage(mfb_display, mfb_window, FontGC,
mfb_cursorImage, 0, 0,
x-7, TRAN(y)-7, 16, 16);
else {
/* Full-screen cross-hair */
MFBLine(x-dx2m1, y, x+dx2m1, y);
MFBLine(x, y-dy2m1, x, y+dy2m1);
}
}
}
curchar += inc;
if (curchar > charN) {
done = 1;
break;
}
}
if (!CursorSW) {
sprintf(ctext, "%02X", cleft);
MFBText(ctext, xn+fw, y-fh/2, 0);
}
y -= dy2;
MFBLine(Left, y, xn, y);
if (done)
break;
}
yn = y - fh * 3 / 2;
for (i = 0; i < nchars; ++i) {
x = Left + i * dx;
if (!CursorSW) {
sprintf(ctext, "%02X", i);
XTextExtents(mfb_font, ctext, strlen(ctext),
&direct, &ascent, &descent, &mychar);
MFBText(ctext, x+dx2-mychar.width/2, yn, 0);
}
x += dx;
MFBLine(x, Top, x, y);
}
if (done)
strcpy(cbuf, "-DONE- (^U to scroll up, ? for help)");
else
strcpy(cbuf, "-MORE- (^U to scroll up, ^D to exit, ? for help)");
MFBText(cbuf, Left, Bottom, 0);
i = Left + XTextWidth(mfb_font, cbuf, strlen(cbuf));
sprintf(cbuf,
"Page %d of %d", topchar / nchars_per_page + 1, lastpage);
j = Right - XTextWidth(mfb_font, cbuf, strlen(cbuf)) - 3;
if (j < i)
j = i;
MFBText(cbuf, j, Bottom, 0);
/* Wait for user interaction and perform requested function */
for (;;) {
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
/* Keyboard key pressed */
if (key == CTRLD)
/* - done */
done = 1;
else if (key == CTRLU) {
/* - scroll up */
if (topchar == 0) {
MFBAudio();
continue;
}
else {
topchar -= nchars_per_page;
if (topchar < 0)
topchar = 0;
}
done = 0;
}
else if (key == '?') {
/* '?' - help */
display_scroll_help(Left, Bottom, Right, Top, fh,
oldforeground, newbackground, SelectSW, 0);
done = 0;
}
else
/* else - scroll down */
topchar = curchar;
}
else {
/* Mouse button pressed */
if (x < Left || x > Right || y < Bottom || y > Top)
/* outside window - done */
done = 1;
else if (button == mfb_buttonMask[2]) {
/* MB3 - up */
if (topchar == 0) {
MFBAudio();
continue;
}
else {
topchar -= nchars_per_page;
if (topchar < 0)
topchar = 0;
}
done = 0;
}
else if (button == mfb_buttonMask[5]) {
/* Shift/MB3 - top */
if (topchar == 0) {
MFBAudio();
continue;
}
topchar = 0;
done = 0;
}
else if (button == mfb_buttonMask[1]) {
/* MB2 - down */
if (done) {
MFBAudio();
continue;
}
topchar = curchar;
}
else if (button == mfb_buttonMask[4]) {
/* Shift/MB2 - bottom */
if (done) {
MFBAudio();
continue;
}
else {
for (topchar = 0; topchar <= charN;
topchar += nchars_per_page)
;
topchar -= nchars_per_page;
}
}
else if (SelectSW) { /* MB1 & selecting */
j = (Top - y) / dy;
if (j >= nlines)
topchar = curchar; /* scroll down */
else {
i = (x - Left) / dx;
n = (i + j * nchars + topchar) * inc;
if (n >= curchar) {
MFBAudio();
continue;
}
if (selection >= topchar && selection < curchar) {
if (selection == n) {
y = y0 - j * dy;
x = x0 + i * dx;
}
else {
int i, j, n;
n = (selection - topchar) / inc;
j = n / nchars;
i = n % nchars;
y = y0 - j * dy;
x = x0 + i * dx;
}
cbuf[0] = selection;
MFBSetColor(newbackground);
MFBBox(x-dx2m1, y-dy2m1, x+dx2m1, y+dy2m1);
if (selection <= charn) {
XSetForeground(mfb_display, FontGC,
mfb_colors[oldforeground]);
XDrawString(mfb_display, mfb_window, FontGC,
x, TRAN(y), cbuf, 1);
}
else if (selection <= charn1) {
XSetBackground(mfb_display, FontGC,
mfb_colors[newbackground]);
XSetForeground(mfb_display, FontGC,
mfb_colors[oldforeground]);
XPutImage(mfb_display, mfb_window, FontGC,
mfb_cursorImage, 0, 0,
x-7, TRAN(y)-7, 16, 16);
}
else {
MFBSetColor(oldforeground);
MFBLine(x-dx2m1, y, x+dx2m1, y);
MFBLine(x, y-dy2m1, x, y+dy2m1);
}
}
if (selection != n) {
y = y0 - j * dy;
x = x0 + i * dx;
cbuf[0] = n;
MFBSetColor(oldforeground);
MFBBox(x-dx2m1, y-dy2m1, x+dx2m1, y+dy2m1);
if (n <= charn) {
XSetForeground(mfb_display, FontGC,
mfb_colors[newbackground]);
XDrawString(mfb_display, mfb_window, FontGC,
x, TRAN(y), cbuf, 1);
}
else if (n <= charn1) {
XSetBackground(mfb_display, FontGC,
mfb_colors[oldforeground]);
XSetForeground(mfb_display, FontGC,
mfb_colors[newbackground]);
XPutImage(mfb_display, mfb_window, FontGC,
mfb_cursorImage, 0, 0,
x-7, TRAN(y)-7, 16, 16);
}
else {
MFBSetColor(newbackground);
MFBLine(x-dx2m1, y, x+dx2m1, y);
MFBLine(x, y-dy2m1, x, y+dy2m1);
}
selection = n;
}
else
selection = -1;
continue;
}
}
else /* MB1 & not selecting - down */
topchar = curchar;
}
break;
}
}
MFBSetFillPattern(oldfillpattern);
return selection;
}
static int
get_bg_color()
/*
* This routine returns the color index to use for the background when the
* KIC background color is requested as the foreground color. The new color
* created is an off-white, much like the default background color for
* DECterm and the Session Manager.
*
* This routine is called by MFBText(), MFBScroll(), MFBScrollList(), and
* MFBScrollFont().
*/
{
XColor mycolor;
static int index = -1;
if (index < 0) {
if (MFBCurrent->privateColors) {
index = mfb_maxColors - 2;
if (index <= 35)
index = 1;
else {
mycolor.pixel = mfb_colors[index];
mycolor.red = (235 * 65535) / 255;
mycolor.green = (235 * 65535) / 255;
mycolor.blue = (215 * 65535) / 255;
mycolor.flags = -1;
XStoreColor(mfb_display, mfb_cmap, &mycolor);
}
}
else {
for (index = mfb_maxColors; index > 0; --index)
if (mfb_colors[index] == -1)
break;
if (index <= 0)
index = 1;
else {
mycolor.red = (235 * 65535) / 255;
mycolor.green = (235 * 65535) / 255;
mycolor.blue = (215 * 65535) / 255;
if (XAllocColor(mfb_display, mfb_cmap, &mycolor))
mfb_colors[index] = mycolor.pixel;
else
index = 1;
}
}
}
return index;
}
static void
display_scroll_help(Left, Bottom, Right, Top, dy, fg, bg,
SelectSW, FontSW)
int Left, Bottom, Right, Top, dy, fg, bg, SelectSW, FontSW;
{
int key;
int x, button;
int y = Top;
MFBSetColor(bg);
MFBBox(Left, Bottom, Right, Top);
MFBSetColor(fg);
MFBText("From the keyboard:", Left, (y-=dy), 0);
MFBText(" => exit", Left, (y-=dy), 0);
MFBText(" => scroll up and stop at top",
Left, (y-=dy), 0);
MFBText(" any other key => scroll down and exit when done",
Left, (y-=dy), 0);
MFBText("Button clicks outside this text window:", Left, (y-=2*dy), 0);
MFBText(" any button => exit", Left, (y-=dy), 0);
MFBText("Button clicks inside this text window:", Left, (y-=2*dy), 0);
if (SelectSW)
MFBText(" Button_1 => select item", Left, (y-=dy), 0);
else
MFBText(" Button_1 => scroll down and exit when done",
Left, (y-=dy), 0);
MFBText(" Button_2 => scroll down and stop at bottom",
Left, (y-=dy), 0);
MFBText(" Button_3 => scroll up and stop at top",
Left, (y-=dy), 0);
if (FontSW)
MFBText(" Shift/Button_1=> display font", Left, (y-=dy), 0);
MFBText(" Shift/Button_2=> scroll to bottom", Left, (y-=dy), 0);
MFBText(" Shift/Button_3=> scroll to top", Left, (y-=dy), 0);
MFBText("press any key or button to continue", Left, (y-=2*dy), 0);
MFBPoint(&x, &y, &key, &button);
}
kic-2.4c/src/xmfb/mfb.c 0000644 0000764 0000764 00000176360 12427442315 014370 0 ustar stevew stevew /*************************************************************************
XMFB X-Window MFB emulation package
Authors: Peter C. Vernam, C. S. Draper Laboratory, 1989
Stephen R. Whiteley, 1992
*************************************************************************/
/*
* This is a hard-coded version of MFB written to work with the X
* window management package developed at MIT (the Athena Project).
* It supports one variable sized window.
* It should be possible to use this library without
* recompiling the source program.
*
* Some odd quirks:
* MFB assumes the origin is at the lower left. X assumes the
* origin is at the upper left. All Y coordinates must be
* translated. This is done using the macro TRAN.
*
* David Harrison, May 1985:
* Revised significantly June 1986.
* This version of MFB is valid for version 10 release 3 of
* the X window system. It should work on both the XDEV_QVSS and
* XDEV_QDSS displays.
*
* Peter C. Vernam, Charles Stark Draper Laboratory, October 1989:
* Revised completely for use with X Window System version 11.3 (in
* particular, VAX/VMS DECwindows version 5.1). Only Xlib is required
* (i.e., none of the higher-level DECwindows toolkit routines are used),
* since the intention was to preserve the look and feel of KIC, not make
* it conform to some other user interface style. The enhancements include:
* 1) All event handling has been centralized in MFBPoint. MFBGetchar and
* MFBKeyboard both call MFBPoint to get keyboard characters.
* 2) The text display routines MFBKeyboard, MFBMore, and MFBScroll have
* been revised considerably to correctly handle variable-width text
* fonts.
* 3) Considerable code has been added to provide support for rubber-banded
* lines and rectangles, and an optional (dragged) full-screen cursor.
* 4) Several new routines have been created, which are in mfbcsdl.c.
*
* This version is tailored specifically for KIC, the only application we
* have that makes calls to MFB routines. If it is to be used with any
* other applications, the following hard-coded details will have to be
* dealt with:
* 1) The window name and icon name are both set to "XKIC" in the call
* to XSetStandardProperties within MFBOpen.
* 2) Exposure events are handled (in MFBPoint) by calling XClearWindow
* and FullRedisplay (a KIC routine) at the end of the series of events.
* No attempt has been made to do partial redraws when a small portion
* of the top-level window becomes exposed (FullRedisplay was fast enough
* on a VS3200 that it was deemed to be not worth the effort to implement
* this).
* 3) The number of color cells allocated is 40. This is based on the fact
* that KIC requires 37 (35 layers + background + highlighting), leaving
* a few to spare. If MFB tries to allocate too many color cells, it
* may fail or not leave enough for other applications. No attempt has
* been made to gracefully recover from failure to allocate color cells.
*
* This version is also tailored specifically to run on a VAXstation 3200,
* running DECwindows version 1 (VMS 5.1). Although it should run just fine
* on any other X-server, the default size of the top-level window is set
* such that it nearly fills the entire VS3200 screen, after allowing for
* the decoration that is added by the DECwindows window manager.
*
* Modified by S. R. Whiteley, 1992.
* 1. Rubber banding improved. The function
* MFBSetGhost(void(*callback)(int x, int y,int refx, int refy),
* int refx,int refy)
* registers the function callback() to be called for ghosting,
* with the saved refx and refy (can be window or viewport coords),
* and x,y as the current viewport coords.
*
* 2. The XMFB defines were added to simplify window initialization.
*
* 3. MFB now calls a routine RepaintWindow() instead of FullRedisplay().
*
* 4. A stack of frames was added, so that multiple windows can be opened.
*
* 5. NUM_XMFB_COLORS (default 40) colors are allocated.
*
* 6. Callback
* SetDisplayWindow(int screen_width, int screen_height, int *x, int *y,
* int *width, int *height)
* was added so that window size and placement can be predefined through
* the pointers.
*
* 7. The default cursor was changed.
*
* Modified by S. R. Whiteley 1998
* 1. Support added for TrueColor visuals
*
*/
#ifndef XMFB_START_FONT
#define XMFB_START_FONT "9x15"
#endif
#ifndef XMFB_WIN_TITLE
#define XMFB_WIN_TITLE "KIC"
#endif
#ifndef XMFB_ICON_TITLE
#define XMFB_ICON_TITLE "KIC"
#endif
/* Choose one of these for mapping the white pixel */
#define WHITE_INDEX mfb_maxColors-1
/*
#define WHITE_INDEX 1
*/
/* this is the number of colors allocated */
int NUM_XMFB_COLORS = 40;
#define MFBALLOCATE
#include "mfb.h" /* standard MFB header file */
#include
#include
#include
#include
#include
MFB *MFBCurrent;
#if __STDC__
extern void fatal_error(const char*);
extern int MFBXError(Display*, XErrorEvent*);
static int fixup(int*);
static void draw_full_screen_cursor(void);
#else
extern void fatal_error();
extern int MFBXError();
static int fixup();
static void draw_full_screen_cursor();
#endif
/* Small cross-hair cursor */
#define cursor_width 16
#define cursor_height 16
#define cursor_x_hot 8
#define cursor_y_hot 7
static char cursorCross_bits[] = {
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x7e, 0xfc,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 };
static char cursorCross_mask[] = {
0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03,
0x80, 0x03, 0x80, 0x03, 0x7e, 0xfc, 0x7e, 0xfc,
0x7e, 0xfc, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03,
0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00 };
/* Tiny dot cursor (to display at the center of the full-screen cursor) */
static char cursorDot_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* Border is a tight hashing of black and white */
#define gray_width 16
#define gray_height 16
static char gray_bits[] = {
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa };
static char mfbInitMessage[81] =
"X-Windows initialization error for display \"";
typedef unsigned long Pixel;
#ifdef MFBFRAMES
struct frame {
MFB *f_mfb;
struct frame *f_next;
};
static struct frame *Frames;
#endif
// Return information about the user's graphics mode
//
static XVisualInfo *
find_visual(Display *display, int screen)
{
XVisualInfo vt, *vl;
int i, vmatch;
vt.screen = screen;
/* This sucks, there must be an easier way to get info on the
default visual */
vl = XGetVisualInfo(display, VisualScreenMask, &vt, &vmatch);
for (i = 0; i < vmatch; i++)
if (vl[i].visual == DefaultVisual(display, screen))
break;
if (vl[i].class == PseudoColor && vl[i].depth >= 8)
return (vl + i);
if (vl[i].class == TrueColor)
return (vl + i);
return (0);
}
MFB *
MFBOpen(TerminalName, DeviceName, errCode)
char *TerminalName, *DeviceName;
int *errCode;
/*
* This routine binds a terminal to an MFB driver and fills
* information in the MFB data structure. Under X, DeviceName
* is a null terminated string representing the host name and display
* number. These two items are seperated by a colon. If the display
* number is not provided, it defaults to '0'. X does not use the
* TerminalName field.
*/
{
Display *mydisplay;
Window mywindow;
int myscreen;
GC mygc;
Pixmap myborder, mycursor_data, mycursor_mask;
XWindowAttributes winInfo;
XSizeHints sizehint;
XFontStruct *myfont;
XColor mybackg, myforeg;
int index, fontheight;
int ht,wd,dw_x,dw_y,dw_w,dw_h;
unsigned long black_pixel, white_pixel;
if (!DeviceName)
DeviceName = ":0";
/* Open the connection to the X server */
if ((mydisplay = XOpenDisplay(DeviceName)) == NULL) {
strcat(mfbInitMessage, DeviceName ? DeviceName : "");
strcat(mfbInitMessage, "\"");
*errCode = MFBBADENT;
return NULL;
}
else {
strcat(mfbInitMessage, DisplayString(mydisplay));
strcat(mfbInitMessage, "\"");
}
/* Set up the error handler */
XSetErrorHandler(MFBXError);
/* Load the starting font */
myfont = XLoadQueryFont(mydisplay,XMFB_START_FONT);
if (myfont==NULL)
myfont = XLoadQueryFont(mydisplay,"fixed");
if (myfont==NULL)
fatal_error("Can't open font.");
fontheight = myfont->ascent + myfont->descent;
/* Open a new X window. The estimated size of the window is large:
* nearly the entire root window. However, the user can resize it to
* suit his taste.
* (Note: The margins subtracted from the display width and height
* below are to allow for the decoration that is added by the DECwindows
* window manager.)
*/
myscreen = DefaultScreen(mydisplay);
ht = DisplayHeight(mydisplay,myscreen);
wd = DisplayWidth(mydisplay,myscreen);
dw_x = 0;
dw_y = 0;
dw_w = wd - 18;
dw_h = ht - 40;
SetDisplayWindow(wd,ht,&dw_x,&dw_y,&dw_w,&dw_h);
sizehint.width = dw_w;
sizehint.height = dw_h;
sizehint.x = dw_x;
sizehint.y = dw_y;
sizehint.min_width = sizehint.width / 4;
sizehint.min_height = sizehint.height / 4;
sizehint.flags = PPosition | PSize | PMinSize;
/* Create window with border width 5, border white, background black. */
black_pixel = BlackPixel(mydisplay, myscreen);
white_pixel = WhitePixel(mydisplay, myscreen);
mywindow = XCreateSimpleWindow(mydisplay, DefaultRootWindow(mydisplay),
sizehint.x, sizehint.y, sizehint.width, sizehint.height,
5, white_pixel, black_pixel);
if (mywindow == (Window)0L) {
*errCode = MFBBADENT;
return NULL;
}
/* Create a GC to be used for line objects */
mygc = XCreateGC(mydisplay, mywindow, 0, 0);
if (mygc == NULL) {
*errCode = MFBBADENT;
return NULL;
}
XSetFont(mydisplay, mygc, myfont->fid);
XSetFunction(mydisplay, mygc, GXcopy); /* this is the default */
XSetArcMode(mydisplay, mygc, ArcPieSlice); /* this is the default */
XSetFillRule(mydisplay, mygc, WindingRule);
#if defined(MFBMALLOC) || defined(MFBFRAMES)
/* Create and fill the MFB record */
MFBCurrent = (MFB *) malloc(sizeof(MFB));
if (MFBCurrent == NULL) {
*errCode = MFBBADMEM;
return NULL;
}
memset(MFBCurrent,(char)0,sizeof(MFB));
#ifdef MFBFRAMES
{ struct frame *f = (struct frame *) malloc(sizeof(struct frame));
if (f == NULL) {
*errCode = MFBBADMEM;
return NULL;
}
f->f_mfb = MFBCurrent;
f->f_next = Frames;
Frames = f; }
#endif
#else
MFBCurrent = &MFBData;
#endif
MFBSetFont("MFB8X16");
mfb_display = mydisplay;
mfb_window = mywindow;
mfb_font = myfont;
mfb_curALUMode = MFBALUJAM;
mfb_lineGC = mygc;
/* Allocate color cells */
mfb_cmap = DefaultColormap(mydisplay, myscreen);
if (DisplayPlanes(mydisplay, myscreen) < 2)
/* On B/W, we make black color 0 and white color 1 */
mfb_maxColors = 2;
else
/* On a color display, we attempt to get NUM_XMFB_COLORS
* color cells for read/write. Other color applications
* may fail while MFB is running. */
mfb_maxColors = MFBmin(DisplayCells(mydisplay, myscreen),
NUM_XMFB_COLORS);
mfb_colors = (Pixel *) malloc((unsigned) (mfb_maxColors * sizeof(Pixel)));
{
XVisualInfo *vl = find_visual(mydisplay, myscreen);
if (!vl)
fatal_error("Graphics mode unsupported.");
if (vl->class == PseudoColor) {
MFBCurrent->privateColors = True;
if (!XAllocColorCells(mydisplay, mfb_cmap, 0, NULL, 0,
mfb_colors, mfb_maxColors)) {
fprintf(stderr,
"Unable to allocate %d color cells.\n", mfb_maxColors);
MFBClose();
*errCode = MFBBADENT;
return NULL;
}
XStoreNamedColor(mydisplay, mfb_cmap, "black", mfb_colors[0], -1);
XStoreNamedColor(mydisplay, mfb_cmap, "white",
mfb_colors[WHITE_INDEX], -1);
}
else {
MFBCurrent->privateColors = False;
for (index = 0; index < mfb_maxColors; ++index)
mfb_colors[index] = -1;
mfb_colors[0] = black_pixel;
mfb_colors[WHITE_INDEX] = white_pixel;
}
}
XSetWindowBackground(mydisplay, mywindow, mfb_colors[0]);
XSetBackground(mydisplay, mygc, mfb_colors[0]);
XSetForeground(mydisplay, mygc, mfb_colors[WHITE_INDEX]);
/* Create a GC to use for filled objects */
mfb_fillGC = XCreateGC(mydisplay, mywindow, 0, 0);
XCopyGC(mydisplay, mygc, -1, mfb_fillGC);
/* Create a GC to use for rubber-banded and dragged objects */
mfb_dragGC = XCreateGC(mydisplay, mywindow, 0, 0);
XCopyGC(mydisplay, mygc, -1, mfb_dragGC);
XSetForeground(mydisplay, mfb_dragGC,
mfb_colors[0] ^ mfb_colors[WHITE_INDEX]);
XSetBackground(mydisplay, mfb_dragGC, mfb_colors[0]);
XSetFunction(mydisplay, mfb_dragGC, GXxor);
/* Define a cursor. The cursor is a 15x15 vertical cross
* defined by cursor_bitmap. */
mybackg.pixel = mfb_colors[0];
myforeg.pixel = mfb_colors[WHITE_INDEX];
XQueryColor(mfb_display, mfb_cmap, &mybackg);
XQueryColor(mfb_display, mfb_cmap, &myforeg);
mycursor_data = XCreateBitmapFromData(mydisplay, mywindow,
cursorCross_bits, cursor_width, cursor_height);
mycursor_mask = XCreateBitmapFromData(mydisplay, mywindow,
cursorCross_mask, cursor_width, cursor_height);
mfb_cursorCross = XCreatePixmapCursor(mydisplay, mycursor_data,
mycursor_mask, &myforeg, &mybackg,
cursor_x_hot, cursor_y_hot);
XDefineCursor(mydisplay, mywindow, mfb_cursorCross);
mfb_cursor = mfb_cursorCross;
mfb_cursorShape = -1;
XFreePixmap(mydisplay, mycursor_data);
XFreePixmap(mydisplay, mycursor_mask);
mycursor_data = XCreateBitmapFromData(mydisplay, mywindow,
cursorDot_bits, cursor_width, cursor_height);
mfb_cursorDot = XCreatePixmapCursor(mydisplay, mycursor_data,
mycursor_data, &myforeg, &mybackg,
cursor_x_hot, cursor_y_hot);
XFreePixmap(mydisplay, mycursor_data);
/* Create an Image stucture for display of the the cross cursor by
* MFBScrollFont. */
mfb_cursorImage = XCreateImage(mydisplay, DefaultVisual(mydisplay,myscreen),
1, XYBitmap, 0, cursorCross_bits,
cursor_width, cursor_height, 16, 0);
mfb_cursorImage->byte_order = LSBFirst;
myborder = XCreatePixmapFromBitmapData(mydisplay, mywindow, gray_bits,
gray_width, gray_height, white_pixel, black_pixel,
DefaultDepth(mydisplay, myscreen));
XSetWindowBorderPixmap(mydisplay, mywindow, myborder);
XSetStandardProperties(mydisplay, mywindow, XMFB_WIN_TITLE,
XMFB_ICON_TITLE, None, NULL, 0, &sizehint);
XFreePixmap(mydisplay, myborder);
/* Specify the events we are interested in.
* These include keyboard pushes and button presses. */
mfb_eventMask = KeyPressMask |
ButtonPressMask |
ExposureMask |
OwnerGrabButtonMask |
/* VisibilityChangeMask | */
StructureNotifyMask;
mfb_visState = VisibilityUnobscured;
XSelectInput(mydisplay, mywindow, mfb_eventMask);
/* Get window width and height */
XGetWindowAttributes(mydisplay, mywindow, &winInfo);
mfb_maxX = winInfo.width;
mfb_maxY = winInfo.height;
/* Create an input-only window for the drawing area, to be used for
* handling the full-screen cursor. It will be moved and resized by a
* call to MFBResizeDrawingWindow from within InitViewports(). */
mfb_dwgwin = XCreateWindow(mydisplay, mywindow, 0, 0, mfb_maxX, mfb_maxY,
0, 0, InputOnly, CopyFromParent, 0, NULL);
mfb_dwgwinX = 0;
mfb_dwgwinY = 0;
mfb_dwgwinXmax = mfb_maxX;
mfb_dwgwinYmax = mfb_maxY;
mfb_inDwgwin = false; /* cursor not in dwg window */
mfb_fullScreenCursor = false; /* F-S cursor not active */
XMapWindow(mydisplay, mywindow);
XMapSubwindows(mydisplay, mywindow);
mfb_name = DisplayString(mydisplay);
mfb_memoryBlock = NULL;
MFBInitialize();
mfb_deviceType = TTY;
mfb_vltBool = (DisplayPlanes(mydisplay, myscreen) > 1) ? true : false;
mfb_vltUseHLSBool = false;
mfb_channelMaskBool = false; /* no channel mask req. */
mfb_readMaskBool = false;
mfb_pointingDeviceBool = true;
mfb_buttonsBool = true;
mfb_readImmediateBool = true;
mfb_keyboardBool = true;
mfb_linePatternDefineBool = true;
mfb_reissueLineStyleBool = true; /* Can change line style */
mfb_filledPlygnBool = true; /* Can draw filled polys */
mfb_textPositionableBool = true;
mfb_textRotateBool = false; /* Can't rotate text */
mfb_replaceTextBool = true; /* Can replace and overstr */
mfb_overstrikeTextBool = true;
mfb_blinkersBool = false;
mfb_rastCopyBool = true; /* Can copy rasters */
mfb_rastRSCSFBool = false; /* No funny raster ordering */
mfb_fillPtrnDefineBool = true; /* Full fill-pattern support */
mfb_fillDefineRowMajorBool = true;
/* Numerics */
mfb_hPixelsPerInch = DisplayWidth(mydisplay, myscreen) * 254 /
DisplayWidthMM(mydisplay, myscreen) / 10;
mfb_vPixelsPerInch = DisplayHeight(mydisplay, myscreen) * 254 /
DisplayHeightMM(mydisplay, myscreen) / 10;
/* No off screen memory */
mfb_minOffScreenX = 0;
mfb_minOffScreenY = 0;
mfb_offScreenDX = 0;
mfb_offScreenDY = 0;
mfb_maxIntensity = (DisplayPlanes(mydisplay, myscreen) > 0) ?
MFBntox(2,8) : 0;
mfb_lengthOfVLT = 7;
mfb_keyboardYOffset = 0; /* No keyboard positioning */
mfb_keyboardXOffset = 0;
mfb_lineDefineLength = 1; /* One byte line styles */
mfb_maxLineStyles = MAXLSTYLE;
mfb_fontWidth = myfont->max_bounds.width;
mfb_fontHeight = fontheight;
mfb_fontXOffset = 0;
mfb_fontYOffset = myfont->descent;
mfb_fontSize = myfont->max_char_or_byte2 + 1;
mfb_fontName[0] = '\0';
mfb_maxBlinkers = 0;
mfb_fillDefineHeight = 8; /* 8-bits down */
mfb_fillDefineWidth = 1; /* 8-bits across */
mfb_maxFillPatterns = MAXFPATT;
mfb_cursorColor1Id = 0;
mfb_cursorColor2Id = 0;
mfb_drawghost = NULL;
mfb_numberOfButtons = 5;
mfb_textMode = 1;
mfb_fgColorId = -1;
mfb_lineStyle = -1;
mfb_fillPattern = -1;
mfb_buttonMask[0] = 1<<0;
mfb_buttonMask[1] = 1<<1;
mfb_buttonMask[2] = 1<<2;
mfb_buttonMask[3] = 1<<3;
mfb_buttonMask[4] = 1<<4;
mfb_buttonMask[5] = 1<<5;
mfb_buttonMask[6] = 1<<6;
mfb_buttonMask[7] = 1<<7;
mfb_buttonMask[8] = 1<<8;
mfb_buttonMask[9] = 1<<9;
mfb_buttonMask[10] = 1<<10;
mfb_buttonMask[11] = 1<<11;
for (index = 0; index < MAXLSTYLE; ++index)
mfb_lStyles[index][1] = 0;
for (index = 0; index < MAXFPATT; ++index)
mfb_fillMap[index] = None;
mfb_initializedBool = true;
*errCode = MFBOK;
MFBSetLineStyle(0);
MFBSetFillPattern(0);
for (;;) {
/* wait for first Expose event */
XEvent event;
XNextEvent(mydisplay,&event);
if (event.type == Expose) break;
}
if ((fcntl(ConnectionNumber(mfb_display),F_SETFD,1)) == -1)
fprintf(stderr,"bad bad bad\n");
return MFBCurrent;
}
void
SetCurrentMFB(mfb)
MFB *mfb;
/*
* Sets current mfb device. Sets MFBCurrent.
*/
{
MFBCurrent = mfb;
}
int
MFBClose()
/*
* Wraps up the graphics display. Closes the X display and its window.
*/
{
XFlush(mfb_display);
XCloseDisplay(mfb_display);
free((char *) mfb_colors);
#ifdef MFBFRAMES
{ struct frame *f = Frames;
Frames = Frames->f_next;
free((char *)f); }
if (Frames != NULL)
MFBCurrent = Frames->f_mfb;
else
MFBCurrent = NULL;
#else
#ifdef MFBMALLOC
free((char *) MFBCurrent);
#endif
MFBCurrent = NULL;
#endif
return MFBOK;
}
int
MFBInitialize()
/*
* Sets up graphics display. All this does under X is flush the buffer.
*/
{
MFBUpdate();
return MFBOK;
}
int
MFBUpdate()
/*
* Flushes the output buffer to the graphics device. Using X, this
* routine flushes the current TCP/IP output stream buffer. This routine
* DOES NOT return the number of characters sent through the stream.
* It returns MFBOK.
*/
{
XFlush(mfb_display);
return MFBOK;
}
int
MFBHalt()
/*
* Temporarily releases the graphics device for pausing. In X,
* MFB will be running as a seperate process in a seperate window.
* It should not be necessary to call this routine. It returns
* a bad code.
*/
{
return MFBBADOPT;
}
int
MFBntox(n, x)
int n, x;
/*
* Raises n to the x power
*/
{
int temp;
if (x == 0)
return 1;
temp = MFBntox(n, x >> 1);
if ((x & 1) == 0)
return (temp * temp);
else
return (temp * temp * n);
}
char *
MFBError(errnum)
int errnum;
/*
* Returns a text message describing 'errnum'.
*/
{
char *retValue = NULL;
switch (errnum) {
case MFBOK:
retValue = "Successful return ";
break;
case MFBGENERR:
retValue = "General error ";
break;
case MFBBADENT:
retValue = mfbInitMessage;
break;
case MFBBADMCF:
retValue = "Can't open mfbcap file ";
break;
case MFBMCELNG:
retValue = "MFBCAP entry too long ";
break;
case MFBBADMCE:
retValue = "Bad mfbcap entry ";
break;
case MFBINFMCE:
retValue = "Infinite mfbcap entry ";
break;
case MFBBADTTY:
retValue = "stdout not in /dev ";
break;
case MFBBADLST:
retValue = "Illegal line style ";
break;
case MFBBADFST:
retValue = "Illegal fill style ";
break;
case MFBBADCST:
retValue = "Illegal color style ";
break;
case MFBBADTM1:
retValue = "No destructive text ";
break;
case MFBBADTM2:
retValue = "No overstriking text ";
break;
case MFBNODFLP:
retValue = "No definable line styles ";
break;
case MFBNODFFP:
retValue = "No definable fill styles ";
break;
case MFBNODFCO:
retValue = "No definable colors ";
break;
case MFBNOBLNK:
retValue = "No blinkers ";
break;
case MFBTMBLNK:
retValue = "Too many blinkers ";
break;
case MFBBADDEV:
retValue = "Can't open or close device ";
break;
case MFBBADOPT:
retValue = "Can't access or set device stat ";
break;
case MFBNOMASK:
retValue = "No definable read or write mask ";
break;
case MFBBADWRT:
retValue = "Error in write ";
break;
case MFBPNTERR:
retValue = "Error in pointing device ";
break;
case MFBNOPTFT:
retValue = "No format for pointing device ";
break;
case MFBNOPNT:
retValue = "No pointing device ";
break;
case MFBNORBND:
retValue = "No Rubberbanding ";
break;
case MFBBADALU:
retValue = "Cannot set ALU mode ";
break;
case MFBBADMEM:
retValue = "Memory allocation error ";
break;
}
return retValue;
}
static int getchar_flag = false;
int
MFBPoint(X,Y,key,button)
int *X,*Y,*key,*button;
/*
* Enables the graphics pointing device and waits for user
* input. If the user presses a key, the routine returns
* the ASCII code for that key in 'key'. If the user releases
* a mouse button, the routine returns the X,Y coordinates of
* the device along with the button mask. Evidently, MFB has
* no concept of pushing and releasing mouse buttons. Thus,
* button pressed events are not caught. The current drawing
* position is NOT changed.
*
* Note: The other MFB input routines (MFBGetchar and MFBKeyboard) are
* now implemented by calling MFBPoint and ignoring the returned button
* events. This centralizes the handling of X-windows events within
* this routine.
*/
{
XEvent newEvent, nextEvent;
KeySym mykey;
int nbytes, mybutton;
int done = 0;
char text[20];
#ifdef MFBFRAMES
int stk;
struct frame *f;
#endif
GC tmpGC;
if (mfb_drawghost) {
/* draw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,mfb_bandY);
mfb_lineGC = tmpGC;
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* draw full-screen cursor */
while (!done) { /* Wait for new event */
#ifdef MFBFRAMES
if (XPending(mfb_display) || !Frames->f_next) {
#else
if (1) {
#endif
XNextEvent(mfb_display, &newEvent);
switch (newEvent.type) {
case ButtonPress:
if (mfb_drawghost) {
/* undraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
if (newEvent.xbutton.x >= mfb_dwgwinX &&
newEvent.xbutton.x <= mfb_dwgwinXmax &&
newEvent.xbutton.y >= mfb_dwgwinY &&
newEvent.xbutton.y <= mfb_dwgwinYmax) {
mfb_lastX = newEvent.xbutton.x;
mfb_lastY = newEvent.xbutton.y;
mfb_inDwgwin = True;
}
else
mfb_inDwgwin = False;
mfb_actionTime = newEvent.xbutton.time;
mybutton = newEvent.xbutton.button;
if (newEvent.xbutton.state & ShiftMask)
mybutton += 3;
/*
if (newEvent.xbutton.state & ControlMask)
mybutton += 6;
*/
if (mybutton == 4) mybutton = 3;
else if (mybutton == 3) mybutton = 4;
*X = newEvent.xbutton.x;
*Y = TRAN(newEvent.xbutton.y);
*key = 0;
*button = mfb_buttonMask[mybutton - 1];
done = 1;
break;
case KeyPress:
nbytes = XLookupString((XKeyEvent *)&newEvent, text, 20,
&mykey,(XComposeStatus *) 0);
if (getchar_flag) {
if (nbytes <= 0)
*key = mykey;
else
*key = text[0];
if (fixup(key)) break;
*button = -1;
done = 1;
break;
}
if (nbytes <= 0)
break;
if (mfb_drawghost) {
/* undraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
if (newEvent.xkey.x >= mfb_dwgwinX &&
newEvent.xkey.x <= mfb_dwgwinXmax &&
newEvent.xkey.y >= mfb_dwgwinY &&
newEvent.xkey.y <= mfb_dwgwinYmax) {
mfb_lastX = newEvent.xkey.x;
mfb_lastY = newEvent.xkey.y;
mfb_inDwgwin = True;
}
else
mfb_inDwgwin = False;
mfb_actionTime = newEvent.xkey.time;
*key = text[0];
*button = -1;
done = 1;
break;
case MotionNotify:
/* draw rubber-band line or rectangle */
while (XEventsQueued(newEvent.xmotion.display,
QueuedAfterReading) > 0) {
XPeekEvent(newEvent.xmotion.display, &nextEvent);
if (nextEvent.type != MotionNotify)
break;
XNextEvent(newEvent.xmotion.display, &newEvent);
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* undraw full-screen cursor */
if (mfb_drawghost) {
/* undraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
mfb_lastX = mfb_dwgwinX + newEvent.xmotion.x;
mfb_lastY = mfb_dwgwinY + newEvent.xmotion.y;
mfb_inDwgwin = True;
if (mfb_drawghost) {
/* redraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* redraw full-screen cursor */
break;
case EnterNotify:
/* pointer entered the drawing window */
if (newEvent.xcrossing.mode != NotifyNormal)
break;
if (mfb_drawghost) {
/* undraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
mfb_lastX = mfb_dwgwinX + newEvent.xcrossing.x;
mfb_lastY = mfb_dwgwinY + newEvent.xcrossing.y;
mfb_inDwgwin = True;
if (mfb_drawghost) {
/* redraw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,mfb_bandX,
mfb_bandY);
mfb_lineGC = tmpGC;
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* redraw full-screen cursor */
break;
case LeaveNotify:
/* pointer left the drawing window */
if (newEvent.xcrossing.mode != NotifyNormal)
break;
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* undraw full-screen cursor */
mfb_inDwgwin = False;
break;
case ConfigureNotify:
/* save width and height on window re-size */
if (newEvent.xconfigure.window == mfb_window) {
mfb_maxX = newEvent.xconfigure.width;
mfb_maxY = newEvent.xconfigure.height;
}
break;
case VisibilityNotify:
/* save visibility state */
if (newEvent.xvisibility.window == mfb_window) {
mfb_visState = newEvent.xvisibility.state;
printf("VisibilityState = %d\n", mfb_visState);
}
break;
case Expose:
/* repaint window on expose events */
if (newEvent.xexpose.count == 0 &&
newEvent.xexpose.window == mfb_window &&
mfb_visState == VisibilityUnobscured) {
XClearWindow(newEvent.xexpose.display,
newEvent.xexpose.window);
RepaintWindow(0);
/* Eat any other expose events for
* this window (Motif hack)
*/
while (XCheckWindowEvent(mfb_display, mfb_window,
(long) ExposureMask, &newEvent)) ;
}
if (mfb_drawghost) {
/* draw any rubber-banding */
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
(*mfb_drawghost)(mfb_lastX,mfb_lastY,
mfb_bandX,mfb_bandY);
mfb_lineGC = tmpGC;
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor();
break;
default:
/* No action. All other events are ignored */
break;
}
}
#ifdef MFBFRAMES
/* Now look for exposure events in other windows */
for (stk = 1, f = Frames->f_next; f; stk++, f = f->f_next) {
if (XPending(f->f_mfb->display)) {
MFBCurrent = f->f_mfb;
while (XPending(mfb_display)) {
XNextEvent(mfb_display,&newEvent);
if (newEvent.type == ConfigureNotify) {
mfb_maxX = newEvent.xconfigure.width;
mfb_maxY = newEvent.xconfigure.height;
}
else if (newEvent.type == Expose) {
if (newEvent.xexpose.count == 0 &&
newEvent.xexpose.window == mfb_window &&
mfb_visState == VisibilityUnobscured) {
XClearWindow(newEvent.xexpose.display,
newEvent.xexpose.window);
RepaintWindow(stk);
/* Eat any other expose events for
* this window (Motif hack)
*/
while (XCheckWindowEvent(mfb_display, mfb_window,
(long) ExposureMask, &newEvent)) ;
}
}
}
}
}
MFBCurrent = Frames->f_mfb;
/* The -1 argument specifies a reinitialization to the top
* level frame of any parameters set by the application, without
* repainting anything.
*/
RepaintWindow(-1);
#endif
}
if (mfb_fullScreenCursor)
draw_full_screen_cursor(); /* undraw the full-screen cursor */
return MFBOK;
}
static int
fixup(k)
int *k;
{
if (*k == 0xff51) *k = 331;
else if (*k == 0xff52) *k = 328;
else if (*k == 0xff53) *k = 333;
else if (*k == 0xff54) *k = 336;
if (*k >= 0xff00) return true;
return false;
}
#ifdef MFBFRAMES
void
MFBNewContext()
/* This is a hack. After forking, we can't have two processes
* sharing the same display(s), as events get "lost". We also
* can't close the display in one process, as this destroys
* resources in the X server which causes errors and core
* dumps. The solution is to call this routine, which simply
* causes open windows to be ignored in the process from which
* this is called.
* The process MUST EXIT before any references to previously
* open displays/windows are encountered.
*/
{
Frames = NULL;
MFBCurrent = NULL;
}
#endif
int
MFBGetchar()
/*
* Returns a single character from the graphics input device.
*
* This routine is implemented by calling MFBPoint and ignoring
* any returned button events, permitting the handling of all
* X-windows events to be coded in one place.
*/
{
int x, y, button;
int key;
Bool fullScreenCursorSave;
getchar_flag = true;
fullScreenCursorSave = mfb_fullScreenCursor;
MFBSetFullScreenCursor(false);
for (;;) { /* Infinite loop */
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
MFBSetFullScreenCursor(fullScreenCursorSave);
break;
}
}
getchar_flag = false;
return key;
}
char *
MFBKeyboard(X, Y, background, foreground)
int X, Y; /* Position of input */
int background, foreground; /* Foreground and background colors */
/*
* Enables the graphics keyboard and waits for user input.
* Returns a pointer to a null terminated string of user input. This
* space is static - old input is erased each time MFBKeyboard is called.
* The routine echoes characters and does character and line editing.
* ^H and DEL are considered the erase characters and ^U and ^X are
* considered the kill characters. Carriage return terminates input.
*
* This routine is implemented by calling MFBPoint and ignoring
* any returned button events, permitting the handling of all
* X-windows events to be coded in one place.
*/
{
static char InputBuffer[200];
int key;
int curX, curY, curLen, ytop, width, x, y, button;
int cursorwidth;
Bool fullScreenCursorSave;
fullScreenCursorSave = mfb_fullScreenCursor;
MFBSetFullScreenCursor(false);
X += mfb_fontXOffset;
Y = TRAN(Y) - mfb_fontYOffset;
curX = X;
curY = Y;
ytop = curY - mfb_font->ascent;
curLen = 0;
cursorwidth = XTextWidth(mfb_font, "X", 1);
XFillRectangle(mfb_display, mfb_window, mfb_dragGC,
curX, ytop, cursorwidth, mfb_fontHeight);
for (;;) { /* Infinite loop */
MFBPoint(&x, &y, &key, &button);
if (button == -1) {
XFillRectangle(mfb_display, mfb_window, mfb_dragGC,
curX, ytop, cursorwidth, mfb_fontHeight);
if (key == CR || key == LF) {
InputBuffer[curLen] = '\0';
MFBSetFullScreenCursor(fullScreenCursorSave);
return InputBuffer;
}
else if ((key == BS || key == DEL) && curLen > 0) {
/* Delete a character */
width = XTextWidth(mfb_font, &InputBuffer[--curLen], 1);
curX -= width;
XClearArea(mfb_display, mfb_window, curX, ytop,
width, mfb_fontHeight, False);
}
else if ((key == CTRLU || key == CTRLX) && curLen > 0) {
/* Delete the line */
width = curX - X;
curX = X;
XClearArea(mfb_display, mfb_window, curX, ytop,
width, mfb_fontHeight, False);
curLen = 0;
}
else if (key >= ' ' && key < DEL) {
/* Add the character to the string and display */
char c = key;
InputBuffer[curLen++] = c;
XDrawImageString(mfb_display, mfb_window,
mfb_lineGC, curX, curY, &c, 1);
curX += XTextWidth(mfb_font, &c, 1);
}
XFillRectangle(mfb_display, mfb_window, mfb_dragGC,
curX, ytop, cursorwidth, mfb_fontHeight);
}
}
}
int
MFBDefineColor(colorID, red, green, blue)
int colorID;
int red, green, blue;
/*
* Defines the VLT entry 'colorID' to 'red','green', and 'blue'.
* Color intensities are normalized to 1000. If the display
* has color, this function will work according to spec. It
* sets the current color to the newly defined color.
*/
{
XColor mycolor;
if (!mfb_vltBool)
return MFBNODFCO;
if (colorID > mfb_maxColors || colorID < 0)
return MFBBADCST;
if (red > 1000 || green > 1000 || blue > 1000)
return MFBBADCST;
mycolor.red = (red * 65535) / 1000;
mycolor.green = (green * 65535) / 1000;
mycolor.blue = (blue * 65535) / 1000;
if (MFBCurrent->privateColors) {
mycolor.flags = -1;
mycolor.pixel = mfb_colors[colorID];
XStoreColor(mfb_display, mfb_cmap, &mycolor);
}
else {
if (mfb_colors[colorID] > -1)
XFreeColors(mfb_display, mfb_cmap, &mfb_colors[colorID], 1, 0);
if (!XAllocColor(mfb_display, mfb_cmap, &mycolor))
return MFBBADCST;
mfb_colors[colorID] = mycolor.pixel;
}
if (mfb_lineGC == mfb_dragGC)
return (MFBOK);
MFBSetColor(colorID);
if (colorID == 0) {
XSetWindowBackground(mfb_display, mfb_window, mycolor.pixel);
XSetBackground(mfb_display, mfb_lineGC, mycolor.pixel);
XSetBackground(mfb_display, mfb_fillGC, mycolor.pixel);
XSetBackground(mfb_display, mfb_dragGC, mycolor.pixel);
XSetForeground(mfb_display, mfb_dragGC,
mycolor.pixel ^ WhitePixel(mfb_display,DefaultScreen(mfb_display)));
}
return MFBOK;
}
int
MFBSetColor(colorID)
int colorID;
/*
* Sets the current foreground color to 'colorID'. Must be
* between 0 and the maximum number of colors for the device.
*/
{
if (colorID >= mfb_maxColors || colorID < 0)
return MFBBADCST;
if (mfb_lineGC != mfb_dragGC) {
XSetForeground(mfb_display, mfb_lineGC, mfb_colors[colorID]);
XSetForeground(mfb_display, mfb_fillGC, mfb_colors[colorID]);
mfb_fgColorId = colorID;
}
return MFBOK;
}
int
MFBSetCursorColor(colorID1,colorID2)
int colorID1,colorID2;
/*
* Sets up cursor to blink between colorID1 and colorID2.
*
* Cursor blinking is not supported in X, so we'll just
* set the cursor foreground color to colorID1 and its
* background color to 0, ignoring colorID2 (which is
* always identical to colorID1 when called from KIC).
*/
{
XColor myforeg, mybackg;
if (colorID1 >= mfb_maxColors || colorID1 < 0)
return MFBBADCST;
if (colorID1 == 0 || (int)mfb_colors[colorID1] < 0)
colorID1 = 1;
myforeg.pixel = mfb_colors[colorID1];
mybackg.pixel = mfb_colors[0];
XQueryColor(mfb_display, mfb_cmap, &myforeg);
XQueryColor(mfb_display, mfb_cmap, &mybackg);
XRecolorCursor(mfb_display, mfb_cursor, &myforeg, &mybackg);
return MFBOK;
}
int
MFBDefineFillPattern(styleID,BitArray)
int styleID;
int *BitArray;
/*
* Redefines fill pattern 'styleID' to that specified by
* 'BitArray'. 'BitArray' is a pointer to an array of
* eight integers of which the lower 8-bits are significant.
* Fill pattern zero is always solid and may not be redefined.
* The routine sets the current fill pattern to the one
* defined.
*/
{
int i, j, index;
char pattern[8];
if (styleID > mfb_maxFillPatterns || styleID <= 0)
return MFBBADFST;
for (i = 0, j = 7; i < 8; ++i, --j)
pattern[j] = BitArray[i] & 0xFF;
index = styleID - 1;
if (mfb_fillMap[index] != None)
XFreePixmap(mfb_display, mfb_fillMap[index]);
mfb_fillMap[index] = XCreateBitmapFromData(mfb_display,
mfb_window, pattern, 8, 8);
MFBSetFillPattern(styleID);
return MFBOK;
}
int
MFBSetFillPattern(styleID)
int styleID;
/*
* Sets the fill pattern to the one specified by 'styleID'. With
* X, definable fill patterns are fully supported. The maximum
* number of patterns is (arbitrarily) MAXFPATT.
*/
{
if (styleID > mfb_maxFillPatterns || styleID < 0)
return MFBBADFST;
if (styleID > 0 && mfb_fillMap[styleID - 1] != None) {
XSetFillStyle(mfb_display, mfb_fillGC, FillStippled);
XSetStipple(mfb_display, mfb_fillGC, mfb_fillMap[styleID - 1]);
}
else
XSetFillStyle(mfb_display, mfb_fillGC, FillSolid);
mfb_fillPattern = styleID;
return MFBOK;
}
int
MFBDefineLineStyle(styleID,mask)
int styleID;
int mask;
/*
* Defines line style 'styleID' to be the lowest eight bits
* of 'mask'. This must be converted into an X11 dash_list,
* which is stored in the lStyles array of the MFB structure.
*/
{
int i, j, n, index, shift, thisbit, lastbit, offset, count[9];
if (styleID > mfb_maxLineStyles || styleID <= 0)
return MFBBADLST;
mask &= 0xFF;
count[0] = n = i = 0;
lastbit = mask & 1;
for (shift = 0; shift < 8; ++shift) {
thisbit = mask & 1;
if (thisbit == lastbit)
count[n] += (thisbit) ? 2 : -2;
else
count[++n] = (thisbit) ? 2 : -2;
lastbit = thisbit;
mask >>= 1;
}
if (n & 1) {
++n;
offset = 0;
if (count[0] < 0) {
count[n++] = count[i++];
for (j = 1; j < n; ++j)
offset += MFBabs(count[j]);
}
}
else {
if (count[0] > 0) {
offset = count[n];
count[0] += count[n];
}
else {
offset = 0;
for (j = 0; j < n; ++j)
offset += MFBabs(count[j]);
count[n] += count[i++];
}
}
index = styleID - 1;
mfb_lStyles[index][0] = offset; /* set dash_offset */
mfb_lStyles[index][1] = n - i; /* set count */
for (j = 2; i < n; ++i, ++j)
mfb_lStyles[index][j] = MFBabs(count[i]);
MFBSetLineStyle(styleID);
return MFBOK;
}
int
MFBSetLineStyle(styleID)
int styleID;
/*
* Sets the current line style to 'styleID'. Implemented
* here by setting the appropriate field in the
* current mfb status record defined above. Now fully
* implemented.
*/
{
if (styleID > mfb_maxLineStyles || styleID < 0)
return MFBBADLST;
if (styleID > 0 && mfb_lStyles[styleID-1][1] > 0) {
int index = styleID - 1;
XSetLineAttributes(mfb_display, mfb_lineGC,
0, LineOnOffDash, CapButt, JoinMiter);
XSetDashes(mfb_display, mfb_lineGC,
(int) mfb_lStyles[index][0], /* dash_offset*/
&mfb_lStyles[index][2], /* dash_list */
(int) mfb_lStyles[index][1]); /* n */
}
else
XSetLineAttributes(mfb_display, mfb_lineGC,
0, LineSolid, CapButt, JoinMiter);
mfb_lineStyle = styleID;
return MFBOK;
}
int
MFBSetTextMode(destructiveBool)
Bool destructiveBool;
/*
* Sets the current text mode flag in the MFB structure. If destructive,
* text will replace what is under it according to the current
* ALU mode. Otherwise, it overwrites using OR.
*/
{
mfb_textMode = (int) destructiveBool;
return MFBOK;
}
int
MFBSetChannelMask(channelMask)
int channelMask;
/*
* This sets the current plane mask for writing. It is not supported
* under this version of XMFB.
*/
{
return MFBNOMASK;
}
int
MFBSetReadMask(readmask)
int readmask;
/*
* Sets the current plane mask for reading. Not supported.
*/
{
return MFBNOMASK;
}
void
MFBPixel(X,Y)
int X,Y;
/*
* Sets the pixel at X,Y to the current color.
*/
{
XDrawPoint(mfb_display, mfb_window, mfb_fillGC, X, TRAN(Y));
}
void
MFBCircle(X, Y, rad, nsides)
int X, Y, rad, nsides;
/*
* Draw the outline of a circle.
*/
{
XDrawArc(mfb_display, mfb_window, mfb_lineGC,
X-rad, TRAN(Y)-rad, rad, rad, 0, 23040);
}
void
MFBFlash(X, Y, rad, nsides)
int X, Y, rad, nsides;
/*
* Draw a filled circle.
*/
{
XFillArc(mfb_display, mfb_window, mfb_fillGC,
X-rad, TRAN(Y)-rad, rad, rad, 0, 23040);
}
void
MFBArc(X, Y, rad, angle1, angle2, nsides)
int X, Y, rad, angle1, angle2, nsides;
/*
* Draw the outline of an arc.
*/
{
XDrawArc(mfb_display, mfb_window, mfb_lineGC,
X-rad, TRAN(Y)-rad, rad, rad, angle1*64, angle2*64);
}
void
MFBBox(left,bottom,right,top)
int left,bottom,right,top;
/*
* Displays a box with the given dimensions using the current ALU mode,
* fill pattern, and color. Leaves the "pen" at right, top.
*/
{
XFillRectangle(mfb_display, mfb_window, mfb_fillGC,
left, TRAN(top), right-left+1, top-bottom+1);
mfb_X = right;
mfb_Y = top;
}
void
MFBNaiveBoxFill(left,bottom,right,top)
int left,bottom,right,top;
/*
* Used to draw filled boxes on devices which do not support
* filled regions. Since X supports filled regions directly,
* this routine is exactly the same as MFBBox.
*/
{
MFBBox(left, bottom, right, top);
}
void
MFBRasterCopy(X,Y,DX,DY,DestX,DestY)
int X,Y,DX,DY,DestX,DestY;
/*
* Copies a rectangular region specified by X,Y,DX,DY to
* DestX DestY. This is directly implementable under
* X. Note the routine uses the current ALU
* mode to determine the function used for output. Leaves
* the pen at DestX, DestY.
*/
{
mfb_X = DestX;
mfb_Y = DestY;
XCopyArea(mfb_display, mfb_window, mfb_window, mfb_fillGC,
X, TRAN(Y)-DY, DX, DY, DestX, TRAN(DestY)-DY);
}
void
MFBFlood()
/*
* Draws a solid box over the entire screen.
*/
{
if (mfb_fgColorId != 0) {
XSetWindowBackground(mfb_display, mfb_window,
mfb_colors[mfb_fgColorId]);
XClearWindow(mfb_display, mfb_window);
XSetWindowBackground(mfb_display, mfb_window, mfb_colors[0]);
}
else
XClearWindow(mfb_display, mfb_window);
}
void
MFBLine(X1,Y1,X2,Y2)
int X1,Y1,X2,Y2;
/*
* Draws a line in the current line style from (X1,Y1) to
* (X2,Y2). Leaves the "pen" positioned at (X2, Y2).
*/
{
XDrawLine(mfb_display, mfb_window, mfb_lineGC,
X1, TRAN(Y1), X2, TRAN(Y2));
mfb_X = X2;
mfb_Y = Y2;
}
void
MFBMoveTo(X1,Y1)
int X1,Y1;
/*
* Sets the current graphics position to X1,Y1. Directly
* supported.
*/
{
mfb_X = X1;
mfb_Y = Y1;
}
void
MFBDrawLineTo(X1,Y1)
int X1,Y1;
/*
* Draws a line from the current graphics position to X1,Y1.
* Supported using the current position and the MFBLine routine.
*/
{
MFBLine(mfb_X, mfb_Y, X1, Y1);
mfb_X = X1;
mfb_Y = Y1;
}
void
MFBDrawPath(path)
MFBPATH *path;
/*
* Draws a path of vectors in the current line style and color. Fully
* supported under X.
*/
{
int index;
XPoint *allPoints;
allPoints = (XPoint *) malloc( (unsigned) (sizeof(XPoint) *
(path->nvertices+1)) );
for (index = 0; index < path->nvertices; index++) {
allPoints[index].x = path->xy[index*2];
allPoints[index].y = TRAN(path->xy[index*2+1]);
}
XDrawLines(mfb_display, mfb_window, mfb_lineGC,
allPoints, index, CoordModeOrigin);
free( (char *) allPoints );
mfb_X = path->xy[0];
mfb_Y = path->xy[1];
}
void
MFBPolygon(poly)
MFBPOLYGON *poly;
/*
* Draws a filled polygon specified in 'poly'. The polygon must
* be translated and copied into the XPoint structure before
* handing it off to XFillPolygon.
*/
{
int index;
XPoint *allPoints;
allPoints = (XPoint *) malloc( (unsigned) (sizeof(XPoint) *
(poly->nvertices+1)) );
for (index = 0; index < poly->nvertices; index++) {
allPoints[index].x = poly->xy[index*2];
allPoints[index].y = TRAN(poly->xy[index*2+1]);
}
XFillPolygon(mfb_display, mfb_window, mfb_fillGC,
allPoints, index, Complex, CoordModeOrigin);
free( (char *) allPoints );
mfb_X = poly->xy[0];
mfb_Y = poly->xy[1];
}
MFBPATH *
MFBArcPath(x,y,r,astart,astop,s)
int x; /* x coordinate of center */
int y; /* y coordinate of center */
int r; /* radius of arc */
int astart; /* initial angle ( +x axis = 0 degrees ) */
int astop; /* final angle ( +x axis = 0 degrees ) */
int s; /* number of segments in a 360 degree arc */
/*
* Notes:
* Returns MFBPATH containing an arc.
*/
{
static MFBPATH pth;
static int xy[400];
int *ip, i, j;
double d;
pth.xy = ip = xy;
while (astart >= astop)
astop += 360;
if (s < 2 || s > 180)
s = 20;
pth.nvertices = 2;
j = MFBmax(1, (astop - astart)/s);
d = astart / RADTODEG;
*ip++ = x + (int)(r * cos(d));
*ip++ = y + (int)(r * sin(d));
for (i = astart + j; i <= astop; i += j) {
d = i / RADTODEG;
*ip++ = x + (int)(r * cos(d));
*ip++ = y + (int)(r * sin(d));
++pth.nvertices;
}
d = astop / RADTODEG;
*ip++ = x + (int)(r * cos(d));
*ip = y + (int)(r * sin(d));
return &pth;
}
MFBPOLYGON *
MFBEllipse(x,y,rx,ry,s)
int x; /* x coordinate of center */
int y; /* y coordinate of center */
int rx; /* radius of ellipse in x direction */
int ry; /* radius of ellipse in y direction */
int s; /* number of line segments in circle (default = 20) */
/*
* Notes:
* Returns MFBPOLYGON containing an ellipse with no more than 200 coords.
*/
{
static MFBPOLYGON poly;
static int xy[400];
int i=0;
int j;
int *ip;
double d=0;
poly.xy = ip = xy;
*ip++ = x + rx;
*ip++ = y;
if (s > 2 && s < 181)
j = 360 / s;
else {
j = 18;
s = 20;
}
poly.nvertices = s + 1;
while (--s) {
i += j;
d = i / RADTODEG;
*ip++ = x + (int)(rx * cos(d));
*ip++ = y + (int)(ry * sin(d));
}
*ip++ = x + rx;
*ip++ = y;
return &poly;
}
void
MFBText(text,X,Y,phi)
char *text;
int X,Y,phi;
/*
* Displays a null terminated string pointed to by 'text' with
* the lower corner at X,Y rotated 'phi' degrees. Currently
* does not support rotation. The routine adheres to the mode
* set by MFBSetTextMode.
*/
{
char *buf;
if (text == NULL || strlen(text) == 0)
return;
if (phi != 0) {
fprintf(stderr,
"Call to MFBText(\"%s\", %d, %d, %d) with non-zero phi\n",
text, X, Y, phi);
return;
}
/* convert tabs to space */
buf = malloc(strlen(text)+1);
if (buf != NULL)
strcpy(buf,text);
else
return;
/* don't print anything after \n */
for (text = buf; *text; text++) {
if (*text == '\t') {*text = ' '; continue;}
if (*text == '\n') {*text = '\0'; break;}
}
text = buf;
if (mfb_textMode) {
/* Destructive mode */
XDrawImageString(mfb_display, mfb_window, mfb_lineGC,
X + mfb_fontXOffset, TRAN(Y) - mfb_fontYOffset,
text, strlen(text));
}
else {
/* Non-destructive mode */
XDrawString(mfb_display, mfb_window, mfb_lineGC,
X + mfb_fontXOffset, TRAN(Y) - mfb_fontYOffset,
text, strlen(text));
}
free(text);
}
int
MFBSetALUMode(alumode)
int alumode;
/*
* Changes the way graphics display is changed when an overwrite
* occurs. Can be MFBALUJAM, MFBALUOR, MFBALUNOR, MFBALUEOR.
*/
{
int func;
switch (alumode) {
case MFBALUJAM:
func = GXcopy;
break;
case MFBALUOR:
func = GXor;
break;
case MFBALUNOR:
func = GXnor;
break;
case MFBALUEOR:
func = GXxor;
break;
default:
return MFBBADALU;
break;
}
XSetFunction(mfb_display, mfb_lineGC, func);
XSetFunction(mfb_display, mfb_fillGC, func);
mfb_curALUMode = alumode;
return MFBOK;
}
int
MFBSetGhost(callback,X,Y)
#if __STDC__
void (*callback)(int,int,int,int);
#else
void (*callback)();
#endif
int X,Y;
{
if (callback) {
mfb_bandX = X;
mfb_bandY = Y;
mfb_drawghost = callback;
XSelectInput(mfb_display, mfb_dwgwin,
PointerMotionMask | ButtonMotionMask |
EnterWindowMask | LeaveWindowMask);
return (MFBOK);
}
else if (!mfb_fullScreenCursor)
XSelectInput(mfb_display, mfb_dwgwin, 0);
mfb_drawghost = NULL;
return (MFBOK);
}
int
MFBSetFullScreenCursor(onFlag)
int onFlag;
{
mfb_fullScreenCursor = onFlag;
if (onFlag) {
XDefineCursor(mfb_display, mfb_dwgwin, mfb_cursorDot);
XSelectInput(mfb_display, mfb_dwgwin,
PointerMotionMask | ButtonMotionMask |
EnterWindowMask | LeaveWindowMask);
}
else {
XUndefineCursor(mfb_display, mfb_dwgwin);
if (!mfb_drawghost)
XSelectInput(mfb_display, mfb_dwgwin, 0);
}
return MFBOK;
}
static void
draw_full_screen_cursor()
{
if (mfb_inDwgwin) {
XDrawLine(mfb_display, mfb_window, mfb_dragGC,
mfb_dwgwinX, mfb_lastY, mfb_dwgwinXmax, mfb_lastY);
XDrawLine(mfb_display, mfb_window, mfb_dragGC,
mfb_lastX, mfb_dwgwinY, mfb_lastX, mfb_dwgwinYmax);
}
}
void
MFBResizeDrawingWindow(left,bottom,right,top)
int left,bottom,right,top;
{
mfb_dwgwinX = left;
mfb_dwgwinY = TRAN(top);
mfb_dwgwinXmax = right;
mfb_dwgwinYmax = TRAN(bottom);
XMoveResizeWindow(mfb_display, mfb_dwgwin,
mfb_dwgwinX, mfb_dwgwinY, right - left, top - bottom);
}
int
MFBSetBlinker(colorID, red, green, blue, onFlag)
int colorID;
int red, green, blue;
int onFlag;
/*
* MFBSetBlinker - Enables the color identified by colorID to blink between
* its currently defined color and the color defined
* by red, green, and blue. If onFlag is zero, blinking
* is disabled. Under X, this feature is not supported.
*/
{
return MFBNOBLNK;
}
int
MFBPutchar(c)
char c;
/*
* Places character 'c' on the output buffer. Under X, this
* is equiv. to output to stdout. NOTE: This means this
* type of output will go to the invoking window NOT the
* MFB window!
*/
{
putc(c, stdout);
return (0);
}
int
MFBPutstr(cp,nchars)
char *cp;
int nchars;
{
while (nchars-- > 0)
putc(*cp++, stdout);
return (0);
}
void
MFBAudio()
/*
* Rings the terminal's bell. Uses XBell.
*/
{
XBell(mfb_display, 0);
}
long
MFBInfo(int Info)
{
/*
* Notes:
* MFBInfo is the only routine for acquiring device
* specific information. The valid arguments to
* MFBInfo are defined in mfb.h. If an invalid argument
* is used, MFBInfo returns -1.
*/
switch(Info) {
case MAXX:
return mfb_maxX;
case MAXY:
return mfb_maxY;
case MAXCOLORS:
return mfb_maxColors;
case MAXINTENSITY:
return mfb_maxIntensity;
case MAXFILLPATTERNS:
return mfb_maxFillPatterns;
case MAXLINESTYLES:
return mfb_maxLineStyles;
case MAXBLINKERS:
return mfb_maxBlinkers;
case POINTINGDEVICE:
return (int)mfb_pointingDeviceBool;
case POINTINGBUTTONS:
return (int)mfb_buttonsBool;
case NUMBUTTONS:
return mfb_numberOfButtons;
case BUTTON1:
return mfb_buttonMask[0];
case BUTTON2:
return mfb_buttonMask[1];
case BUTTON3:
return mfb_buttonMask[2];
case BUTTON4:
return mfb_buttonMask[3];
case BUTTON5:
return mfb_buttonMask[4];
case BUTTON6:
return mfb_buttonMask[5];
case BUTTON7:
return mfb_buttonMask[6];
case BUTTON8:
return mfb_buttonMask[7];
case BUTTON9:
return mfb_buttonMask[8];
case BUTTON10:
return mfb_buttonMask[9];
case BUTTON11:
return mfb_buttonMask[10];
case BUTTON12:
return mfb_buttonMask[11];
case TEXTPOSITIONABLE:
return (int)mfb_textPositionableBool;
case TEXTROTATABLE:
return (int)mfb_textRotateBool;
case FONTHEIGHT:
return mfb_fontHeight;
case FONTWIDTH:
return mfb_fontWidth;
case FONTXOFFSET:
return 0;
/* return mfb_fontXOffset;*/
case FONTYOFFSET:
return 0;
/* return mfb_fontYOffset;*/
case DESTRUCTIVETEXT:
return (int)mfb_replaceTextBool;
case OVERSTRIKETEXT:
return (int)mfb_overstrikeTextBool;
case VLT:
return (int)mfb_vltBool;
case BLINKERS:
return (int)mfb_blinkersBool;
case FILLEDPOLYGONS:
return (int)mfb_filledPlygnBool;
case DEFFILLPATTERNS:
return (int)mfb_fillPtrnDefineBool;
case DEFREADMASK:
return (int)mfb_readMaskBool;
case DEFCHANNELMASK:
return (int)mfb_channelMaskBool;
case DEFLINEPATTERN:
return (int)mfb_linePatternDefineBool;
case CURFGCOLOR:
return mfb_fgColorId;
case CURFILLPATTERN:
return mfb_fillPattern;
case CURLINESTYLE:
return mfb_lineStyle;
case CURCHANNELMASK:
return mfb_channelMask;
case CURREADMASK:
return mfb_readMask;
case NUMBITPLANES:
return mfb_lengthOfVLT;
case RASTERCOPY:
return (int)mfb_rastCopyBool;
case OFFSCREENX:
return mfb_minOffScreenX;
case OFFSCREENY:
return mfb_minOffScreenY;
case OFFSCREENDX:
return mfb_offScreenDX;
case OFFSCREENDY:
return mfb_offScreenDY;
case CURFONTSIZE:
return mfb_fontWidth;
case HORTPIXPERINCH:
return mfb_hPixelsPerInch;
case VERTPIXPERINCH:
return mfb_vPixelsPerInch;
case ACTIONTIME:
return mfb_actionTime;
case FONTNAME:
return (long)mfb_fontName;
case CURSORSHAPE:
return mfb_cursorShape;
case FULLSCREENCURSOR:
return mfb_fullScreenCursor;
default:
return -1;
}
}
/* Some new get and set routines */
char *
MFBGetStorage()
/*
* Returns the user hook information in the MFB record
*/
{
return mfb_memoryBlock;
}
int
MFBSetStorage(ptr)
char *ptr;
/*
* Sets the user hook information in the MFB record
*/
{
mfb_memoryBlock = ptr;
return (0);
}
/* Very simple error handler: */
int
MFBXError(dsp, err)
Display *dsp;
XErrorEvent *err;
{
char errmsg[80];
XGetErrorText(dsp, err->error_code, errmsg, 80);
fprintf(stderr, "\
XError: %s\n\
Serial number = %ld\n\
Major op-code = %d\n\
Minor op-code = %d\n\7\7\7",
errmsg, err->serial,
(int) err->request_code, (int) err->minor_code);
return 0;
}
/***********************************************************************
*
* WINDOW CONTROL
*
***********************************************************************/
#define WNDW mfb_currentWindow
#define VWPRT mfb_currentViewport
int
MFBScaleX(X)
int X;
{
int XX;
XX = (int)(((double)(X-WNDW.left)*VWPRT.length)/WNDW.length) + VWPRT.left;
if (XX < VWPRT.left) XX = VWPRT.left;
else if (XX > VWPRT.right) XX = VWPRT.right;
return XX;
}
int
MFBScaleY(Y)
int Y;
{
int YY;
YY = (int)(((double)(Y-WNDW.bottom)*VWPRT.width)/WNDW.width) + VWPRT.bottom;
if(YY < VWPRT.bottom) YY = VWPRT.bottom;
else if(YY > VWPRT.top) YY = VWPRT.top;
return YY;
}
int
MFBDescaleX(X)
int X;
{
int XX;
XX = ((X-VWPRT.left)*WNDW.length)/VWPRT.length+WNDW.left;
return XX;
}
int
MFBDescaleY(Y)
int Y;
{
int YY;
YY = ((Y-VWPRT.bottom)*WNDW.width)/VWPRT.width+WNDW.bottom;
return YY;
}
void
MFBSetViewport(left,bottom,right,top)
int left,bottom,right,top;
{
VWPRT.bottom = bottom;
VWPRT.top = top;
VWPRT.left = left;
VWPRT.right = right;
VWPRT.length = VWPRT.right - VWPRT.left;
VWPRT.width = VWPRT.top - VWPRT.bottom;
}
void
MFBSetWindow(left,bottom,right,top)
int left,bottom,right,top;
{
WNDW.bottom = bottom;
WNDW.top = top;
WNDW.left = left;
WNDW.right = right;
WNDW.length = WNDW.right - WNDW.left;
WNDW.width = WNDW.top - WNDW.bottom;
}
void
MFBEraseCursor() {}
void
MFBDrawCursor(x,y)
int x,y;
{
XWarpPointer(mfb_display,None,mfb_window,0,0,0,0,x+7,TRAN(y)+7);
}
void
MFBPointerInit() {}
kic-2.4c/src/xmfb/8x8font.c 0000644 0000764 0000764 00000011176 07525346714 015144 0 ustar stevew stevew /*************************************************************************
MFB graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include "mfb.h"
/* 8 X 8 character set */
unsigned short mfb_8X8font[] = {
/* */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ! */ 0x30,0x78,0x78,0x30,0x30,0x0,0x30,0x0,
/* " */ 0x6c,0x6c,0x6c,0x0,0x0,0x0,0x0,0x0,
/* # */ 0x6c,0x6c,0xfe,0x6c,0xfe,0x6c,0x6c,0x0,
/* $ */ 0x18,0x3e,0x60,0x3c,0x6,0x7c,0x18,0x0,
/* % */ 0x0,0x63,0x66,0xc,0x18,0x33,0x63,0x0,
/* & */ 0x1c,0x36,0x1c,0x3b,0x6e,0x66,0x3b,0x0,
/* ' */ 0x30,0x30,0x60,0x0,0x0,0x0,0x0,0x0,
/* ( */ 0xc,0x18,0x30,0x30,0x30,0x18,0xc,0x0,
/* ) */ 0x30,0x18,0xc,0xc,0xc,0x18,0x30,0x0,
/* * */ 0x0,0x66,0x3c,0xff,0x3c,0x66,0x0,0x0,
/* + */ 0x0,0x30,0x30,0xfc,0x30,0x30,0x0,0x0,
/* , */ 0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x30,
/* - */ 0x0,0x0,0x0,0x7e,0x0,0x0,0x0,0x0,
/* . */ 0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x0,
/* / */ 0x3,0x6,0xc,0x18,0x30,0x60,0x40,0x0,
/* 0 */ 0x3e,0x63,0x67,0x6f,0x7b,0x73,0x3e,0x0,
/* 1 */ 0x18,0x38,0x58,0x18,0x18,0x18,0x7e,0x0,
/* 2 */ 0x3c,0x66,0x6,0x1c,0x30,0x66,0x7e,0x0,
/* 3 */ 0x3c,0x66,0x6,0x1c,0x6,0x66,0x3c,0x0,
/* 4 */ 0xe,0x1e,0x36,0x66,0x7f,0x6,0xf,0x0,
/* 5 */ 0x7e,0x60,0x7c,0x6,0x6,0x66,0x3c,0x0,
/* 6 */ 0x1c,0x30,0x60,0x7c,0x66,0x66,0x3c,0x0,
/* 7 */ 0x7e,0x66,0x6,0xc,0x18,0x18,0x18,0x0,
/* 8 */ 0x3c,0x66,0x66,0x3c,0x66,0x66,0x3c,0x0,
/* 9 */ 0x3c,0x66,0x66,0x3e,0x6,0xc,0x38,0x0,
/* : */ 0x0,0x18,0x18,0x0,0x0,0x18,0x18,0x0,
/* ; */ 0x0,0x18,0x18,0x0,0x0,0x18,0x18,0x30,
/* < */ 0xc,0x18,0x30,0x60,0x30,0x18,0xc,0x0,
/* = */ 0x0,0x0,0x7e,0x0,0x0,0x7e,0x0,0x0,
/* > */ 0x30,0x18,0xc,0x6,0xc,0x18,0x30,0x0,
/* ? */ 0x3c,0x66,0x6,0xc,0x18,0x0,0x18,0x0,
/* @ */ 0x3e,0x63,0x6f,0x69,0x6f,0x60,0x3e,0x0,
/* A */ 0x18,0x3c,0x66,0x66,0x7e,0x66,0x66,0x0,
/* B */ 0x7e,0x33,0x33,0x3e,0x33,0x33,0x7e,0x0,
/* C */ 0x1e,0x33,0x60,0x60,0x60,0x33,0x1e,0x0,
/* D */ 0x7c,0x36,0x33,0x33,0x33,0x36,0x7c,0x0,
/* E */ 0x7f,0x31,0x34,0x3c,0x34,0x31,0x7f,0x0,
/* F */ 0x7f,0x31,0x34,0x3c,0x34,0x30,0x78,0x0,
/* G */ 0x1e,0x33,0x60,0x60,0x67,0x33,0x1f,0x0,
/* H */ 0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x0,
/* I */ 0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,
/* J */ 0xf,0x6,0x6,0x6,0x66,0x66,0x3c,0x0,
/* K */ 0x73,0x33,0x36,0x3c,0x36,0x33,0x73,0x0,
/* L */ 0x78,0x30,0x30,0x30,0x31,0x33,0x7f,0x0,
/* M */ 0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x0,
/* N */ 0x63,0x73,0x7b,0x6f,0x67,0x63,0x63,0x0,
/* O */ 0x3e,0x63,0x63,0x63,0x63,0x63,0x3e,0x0,
/* P */ 0x7e,0x33,0x33,0x3e,0x30,0x30,0x78,0x0,
/* Q */ 0x3c,0x66,0x66,0x66,0x6e,0x3c,0xe,0x0,
/* R */ 0x7e,0x33,0x33,0x3e,0x36,0x33,0x73,0x0,
/* S */ 0x3c,0x66,0x30,0x18,0xc,0x66,0x3c,0x0,
/* T */ 0x7e,0x5a,0x18,0x18,0x18,0x18,0x3c,0x0,
/* U */ 0x66,0x66,0x66,0x66,0x66,0x66,0x7e,0x0,
/* V */ 0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x0,
/* W */ 0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x0,
/* X */ 0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x0,
/* Y */ 0x66,0x66,0x66,0x3c,0x18,0x18,0x3c,0x0,
/* Z */ 0x7f,0x63,0x46,0xc,0x19,0x33,0x7f,0x0,
/* [ */ 0x3c,0x30,0x30,0x30,0x30,0x30,0x3c,0x0,
/* \ */ 0x60,0x30,0x18,0xc,0x6,0x3,0x1,0x0,
/* ] */ 0x3c,0xc,0xc,0xc,0xc,0xc,0x3c,0x0,
/* ^ */ 0x8,0x1c,0x36,0x63,0x0,0x0,0x0,0x0,
/* _ */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,
/* ` */ 0x18,0x18,0xc,0x0,0x0,0x0,0x0,0x0,
/* a */ 0x0,0x0,0x3c,0x6,0x3e,0x66,0x3b,0x0,
/* b */ 0x70,0x30,0x30,0x3e,0x33,0x33,0x6e,0x0,
/* c */ 0x0,0x0,0x3c,0x66,0x60,0x66,0x3c,0x0,
/* d */ 0xe,0x6,0x6,0x3e,0x66,0x66,0x3b,0x0,
/* e */ 0x0,0x0,0x3c,0x66,0x7e,0x60,0x3c,0x0,
/* f */ 0x1c,0x36,0x30,0x78,0x30,0x30,0x78,0x0,
/* g */ 0x0,0x0,0x3b,0x66,0x66,0x3e,0x6,0x7c,
/* h */ 0x70,0x30,0x36,0x3b,0x33,0x33,0x73,0x0,
/* i */ 0x18,0x0,0x38,0x18,0x18,0x18,0x3c,0x0,
/* j */ 0x6,0x0,0x6,0x6,0x6,0x66,0x66,0x3c,
/* k */ 0x70,0x30,0x33,0x36,0x3c,0x36,0x73,0x0,
/* l */ 0x38,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,
/* m */ 0x0,0x0,0x66,0x7f,0x7f,0x6b,0x63,0x0,
/* n */ 0x0,0x0,0x7c,0x66,0x66,0x66,0x66,0x0,
/* o */ 0x0,0x0,0x3c,0x66,0x66,0x66,0x3c,0x0,
/* p */ 0x0,0x0,0x6e,0x33,0x33,0x3e,0x30,0x78,
/* q */ 0x0,0x0,0x3b,0x66,0x66,0x3e,0x6,0xf,
/* r */ 0x0,0x0,0x6e,0x3b,0x33,0x30,0x78,0x0,
/* s */ 0x0,0x0,0x3e,0x60,0x3c,0x6,0x7c,0x0,
/* t */ 0x8,0x18,0x3e,0x18,0x18,0x1a,0xc,0x0,
/* u */ 0x0,0x0,0x66,0x66,0x66,0x66,0x3b,0x0,
/* v */ 0x0,0x0,0x66,0x66,0x66,0x3c,0x18,0x0,
/* w */ 0x0,0x0,0x63,0x6b,0x7f,0x7f,0x36,0x0,
/* x */ 0x0,0x0,0x63,0x36,0x1c,0x36,0x63,0x0,
/* y */ 0x0,0x0,0x66,0x66,0x66,0x3e,0x6,0x7c,
/* z */ 0x0,0x0,0x7e,0x4c,0x18,0x32,0x7e,0x0,
/* { */ 0xe,0x18,0x18,0x70,0x18,0x18,0xe,0x0,
/* | */ 0xc,0xc,0xc,0x0,0xc,0xc,0xc,0x0,
/* } */ 0x70,0x18,0x18,0xe,0x18,0x18,0x70,0x0,
/* ~ */ 0x3b,0x6e,0x0,0x0,0x0,0x0,0x0,0x0
};
kic-2.4c/src/xmfb/xfb.c 0000644 0000764 0000764 00000011654 07525346714 014406 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/* Misc interfage routines for KIC, X graphics */
#include "prefix.h"
#include "kic.h"
#include "mfb.h"
#if __STDC__
extern void out_printf(char*, ...);
#else
extern void out_printf();
#endif
void
XORfineViewport()
{
char tmp;
GC tmpGC;
/*
* Erase or draw the fine positioning window in coarse window.
*/
tmp = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
tmpGC = mfb_lineGC;
mfb_lineGC = mfb_dragGC;
ShowEmptyBox(ColorTable[HighlightingColor].Ent,View->kvFineWindow);
mfb_lineGC = tmpGC;
Parameters.kpRedisplayControl = tmp;
}
int
GetWindowCoords(X,Y,Clip)
/* replace X,Y (in pixel coords) with the window coords if pointing
* in the Coarse or Fine viewports, and return True. Otherwise
* return False. Clip to grid if Clip is True.
*/
int Clip;
int *X,*Y;
{
int X1,Y1;
X1 = *X;
Y1 = TRAN(*Y);
if (InBox(X1,Y1,View->kvCoarseViewport)) {
PToL(View->kvCoarseWindow,&X1,&Y1);
if (Clip)
ClipToGridPoint(&X1,&Y1);
*X = X1;
*Y = Y1;
return (True);
}
if (InBox(X1,Y1,View->kvFineViewport)) {
PToL(View->kvFineWindow,&X1,&Y1);
if (Clip)
ClipToGridPoint(&X1,&Y1);
*X = X1;
*Y = Y1;
return (True);
}
return (False);
}
int *
SetButtonMask()
{
MFBCurrent->buttonMask[0] = FBInfo(BUTTON1);
MFBCurrent->buttonMask[1] = FBInfo(BUTTON2);
MFBCurrent->buttonMask[2] = FBInfo(BUTTON3);
MFBCurrent->buttonMask[3] = FBInfo(BUTTON4);
MFBCurrent->buttonMask[4] = FBInfo(BUTTON5);
MFBCurrent->buttonMask[5] = FBInfo(BUTTON6);
MFBCurrent->buttonMask[6] = FBInfo(BUTTON7);
MFBCurrent->buttonMask[7] = FBInfo(BUTTON8);
MFBCurrent->buttonMask[8] = FBInfo(BUTTON9);
MFBCurrent->buttonMask[9] = FBInfo(BUTTON10);
MFBCurrent->buttonMask[10] = FBInfo(BUTTON11);
MFBCurrent->buttonMask[11] = FBInfo(BUTTON12);
return (MFBCurrent->buttonMask);
}
extern char *MenuFONT, *MenuCURSR;
void
SelectKicFont()
{
char oldRedisplayControl;
int select;
MenuSelect(MenuFONT);
oldRedisplayControl = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
FBForeground(DISPLAY, 0);
select = FBSelectFont(View->kvFineViewport->kaLeft-1,
View->kvFineViewport->kaBottom-1,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop);
Parameters.kpRedisplayControl = oldRedisplayControl;
if (select) {
strncpy(Parameters.kpFontName, (char *)MFBInfo(FONTNAME), 80);
Parameters.kpFontName[80] = EOS;
FullRedisplay();
}
else
ShowFineViewport();
MenuDeselect(MenuFONT);
}
void
SelectKicCursor()
{
char oldRedisplayControl;
MenuSelect(MenuCURSR);
oldRedisplayControl = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
FBForeground(DISPLAY, 0);
FBSelectCursor(View->kvFineViewport->kaLeft-1,
View->kvFineViewport->kaBottom-1,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop);
Parameters.kpCursorShape = MFBInfo(CURSORSHAPE);
Parameters.kpFullScreenCursor = MFBInfo(FULLSCREENCURSOR);
Parameters.kpRedisplayControl = oldRedisplayControl;
ShowFineViewport();
MenuDeselect(MenuCURSR);
}
#ifdef notdef
SetBeepVolume()
{
char *TypeIn;
int volume;
MenuSelect(MenuBEEPV);
sprintf(TypeOut, "New beep volume [%d]?", Parameters.kpPointBeepVolume);
ShowPrompt(TypeOut);
FBKeyboard(&TypeIn);
if (sscanf(TypeIn, "%d", &Parameters.kpPointBeepVolume)) {
if (Parameters.kpPointBeepVolume < 0)
Parameters.kpPointBeepVolume = 0;
if (Parameters.kpPointBeepVolume > 100)
Parameters.kpPointBeepVolume = 100;
}
MenuDeselect(MenuBEEPV);
}
#endif
unsigned int
FBTime()
{
return (MFBInfo(ACTIONTIME));
}
/* ARGSUSED */
void
FBFuncKeys(y,dx) { }
int
Xcheck()
{
return (1);
}
/* ARGSUSED */
void
cprint(i,s)
int i;
char *s;
{
out_printf(s);
}
kic-2.4c/src/xmfb/8x14font.c 0000644 0000764 0000764 00000015720 07525346714 015220 0 ustar stevew stevew /*************************************************************************
MFB graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include "mfb.h"
/* 8 X 14 character set */
unsigned short mfb_8X14font[] = {
/* */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ! */ 0x0,0x0,0x18,0x3c,0x3c,0x3c,0x18,0x18,0x0,0x18,0x18,0x0,0x0,0x0,
/* " */ 0x0,0x63,0x63,0x63,0x22,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* # */ 0x0,0x0,0x36,0x36,0x7f,0x36,0x36,0x36,0x7f,0x36,0x36,0x0,0x0,0x0,
/* $ */ 0xc,0xc,0x3e,0x63,0x61,0x60,0x3e,0x3,0x43,0x63,0x3e,0xc,0xc,0x0,
/* % */ 0x0,0x0,0x0,0x0,0x61,0x63,0x6,0xc,0x18,0x33,0x63,0x0,0x0,0x0,
/* & */ 0x0,0x0,0x1c,0x36,0x36,0x1c,0x3b,0x6e,0x66,0x66,0x3b,0x0,0x0,0x0,
/* ' */ 0x0,0x30,0x30,0x30,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* ( */ 0x0,0x0,0xc,0x18,0x30,0x30,0x30,0x30,0x30,0x18,0xc,0x0,0x0,0x0,
/* ) */ 0x0,0x0,0x18,0xc,0x6,0x6,0x6,0x6,0x6,0xc,0x18,0x0,0x0,0x0,
/* * */ 0x0,0x0,0x0,0x0,0x36,0x1c,0x7f,0x1c,0x36,0x0,0x0,0x0,0x0,0x0,
/* + */ 0x0,0x0,0x0,0x8,0x8,0x8,0x7f,0x8,0x8,0x8,0x0,0x0,0x0,0x0,
/* , */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x18,0x30,0x0,0x0,
/* - */ 0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* . */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,
/* / */ 0x0,0x0,0x1,0x3,0x6,0xc,0x18,0x30,0x60,0x40,0x0,0x0,0x0,0x0,
/* 0 */ 0x0,0x0,0x3e,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x3e,0x0,0x0,0x0,
/* 1 */ 0x0,0x0,0xc,0x1c,0x3c,0xc,0xc,0xc,0xc,0xc,0x3f,0x0,0x0,0x0,
/* 2 */ 0x0,0x0,0x3e,0x63,0x3,0x6,0xc,0x18,0x30,0x63,0x7f,0x0,0x0,0x0,
/* 3 */ 0x0,0x0,0x3e,0x63,0x3,0x3,0x1e,0x3,0x3,0x63,0x3e,0x0,0x0,0x0,
/* 4 */ 0x0,0x0,0x6,0xe,0x1e,0x36,0x66,0x7f,0x6,0x6,0xf,0x0,0x0,0x0,
/* 5 */ 0x0,0x0,0x7f,0x60,0x60,0x60,0x7e,0x3,0x3,0x63,0x3e,0x0,0x0,0x0,
/* 6 */ 0x0,0x0,0x1c,0x30,0x60,0x60,0x7e,0x63,0x63,0x63,0x3e,0x0,0x0,0x0,
/* 7 */ 0x0,0x0,0x7f,0x63,0x3,0x6,0xc,0x18,0x18,0x18,0x18,0x0,0x0,0x0,
/* 8 */ 0x0,0x0,0x3e,0x63,0x63,0x63,0x3e,0x63,0x63,0x63,0x3e,0x0,0x0,0x0,
/* 9 */ 0x0,0x0,0x3e,0x63,0x63,0x63,0x3f,0x3,0x3,0x6,0x3c,0x0,0x0,0x0,
/* : */ 0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x0,
/* ; */ 0x0,0x0,0x0,0x18,0x18,0x0,0x0,0x0,0x18,0x18,0x30,0x0,0x0,0x0,
/* < */ 0x0,0x0,0x6,0xc,0x18,0x30,0x60,0x30,0x18,0xc,0x6,0x0,0x0,0x0,
/* = */ 0x0,0x0,0x0,0x0,0x0,0x7e,0x0,0x0,0x7e,0x0,0x0,0x0,0x0,0x0,
/* > */ 0x0,0x0,0x60,0x30,0x18,0xc,0x6,0xc,0x18,0x30,0x60,0x0,0x0,0x0,
/* ? */ 0x0,0x0,0x3e,0x63,0x63,0x6,0xc,0xc,0x0,0xc,0xc,0x0,0x0,0x0,
/* @ */ 0x0,0x0,0x3e,0x63,0x63,0x6f,0x6f,0x6f,0x6e,0x60,0x3e,0x0,0x0,0x0,
/* A */ 0x0,0x0,0x1c,0x36,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x0,0x0,0x0,
/* B */ 0x0,0x0,0x7e,0x33,0x33,0x33,0x3e,0x33,0x33,0x33,0x7e,0x0,0x0,0x0,
/* C */ 0x0,0x0,0x1e,0x33,0x61,0x60,0x60,0x60,0x61,0x33,0x1e,0x0,0x0,0x0,
/* D */ 0x0,0x0,0x7c,0x36,0x33,0x33,0x33,0x33,0x33,0x36,0x7c,0x0,0x0,0x0,
/* E */ 0x0,0x0,0x7f,0x33,0x31,0x34,0x3c,0x34,0x31,0x33,0x7f,0x0,0x0,0x0,
/* F */ 0x0,0x0,0x7f,0x33,0x31,0x34,0x3c,0x34,0x30,0x30,0x78,0x0,0x0,0x0,
/* G */ 0x0,0x0,0x1e,0x33,0x61,0x60,0x60,0x6f,0x63,0x33,0x1d,0x0,0x0,0x0,
/* H */ 0x0,0x0,0x63,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x0,0x0,0x0,
/* I */ 0x0,0x0,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,
/* J */ 0x0,0x0,0xf,0x6,0x6,0x6,0x6,0x6,0x66,0x66,0x3c,0x0,0x0,0x0,
/* K */ 0x0,0x0,0x73,0x33,0x36,0x36,0x3c,0x36,0x36,0x33,0x73,0x0,0x0,0x0,
/* L */ 0x0,0x0,0x78,0x30,0x30,0x30,0x30,0x30,0x31,0x33,0x7f,0x0,0x0,0x0,
/* M */ 0x0,0x0,0x63,0x77,0x7f,0x6b,0x63,0x63,0x63,0x63,0x63,0x0,0x0,0x0,
/* N */ 0x0,0x0,0x63,0x73,0x7b,0x7f,0x6f,0x67,0x63,0x63,0x63,0x0,0x0,0x0,
/* O */ 0x0,0x0,0x1c,0x36,0x63,0x63,0x63,0x63,0x63,0x36,0x1c,0x0,0x0,0x0,
/* P */ 0x0,0x0,0x7e,0x33,0x33,0x33,0x3e,0x30,0x30,0x30,0x78,0x0,0x0,0x0,
/* Q */ 0x0,0x0,0x3e,0x63,0x63,0x63,0x63,0x63,0x6b,0x6f,0x3e,0x6,0x7,0x0,
/* R */ 0x0,0x0,0x7e,0x33,0x33,0x33,0x3e,0x36,0x33,0x33,0x73,0x0,0x0,0x0,
/* S */ 0x0,0x0,0x3e,0x63,0x63,0x30,0x1c,0x6,0x63,0x63,0x3e,0x0,0x0,0x0,
/* T */ 0x0,0x0,0x7f,0x59,0x18,0x18,0x18,0x18,0x18,0x18,0x1c,0x0,0x0,0x0,
/* U */ 0x0,0x0,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3e,0x0,0x0,0x0,
/* V */ 0x0,0x0,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x36,0x1c,0x8,0x0,0x0,
/* W */ 0x0,0x0,0x63,0x63,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x0,0x0,0x0,
/* X */ 0x0,0x0,0x63,0x63,0x36,0x1c,0x1c,0x1c,0x36,0x63,0x63,0x0,0x0,0x0,
/* Y */ 0x0,0x0,0x66,0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x3c,0x0,0x0,0x0,
/* Z */ 0x0,0x0,0x7f,0x63,0x46,0xc,0x1c,0x18,0x31,0x63,0x7f,0x0,0x0,0x0,
/* [ */ 0x0,0x0,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x0,0x0,0x0,
/* \ */ 0x0,0x0,0x40,0x60,0x70,0x38,0x1c,0xe,0x7,0x3,0x1,0x0,0x0,0x0,
/* ] */ 0x0,0x0,0x3c,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x3c,0x0,0x0,0x0,
/* ^ */ 0x8,0x1c,0x36,0x63,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* _ */ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0x0,
/* ` */ 0x18,0x18,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
/* a */ 0x0,0x0,0x0,0x0,0x0,0x3c,0x6,0x3e,0x66,0x66,0x3b,0x0,0x0,0x0,
/* b */ 0x0,0x0,0x70,0x30,0x30,0x3c,0x36,0x33,0x33,0x33,0x6e,0x0,0x0,0x0,
/* c */ 0x0,0x0,0x0,0x0,0x0,0x3e,0x63,0x60,0x60,0x63,0x3e,0x0,0x0,0x0,
/* d */ 0x0,0x0,0xe,0x6,0x6,0x1e,0x36,0x66,0x66,0x66,0x3b,0x0,0x0,0x0,
/* e */ 0x0,0x0,0x0,0x0,0x0,0x3e,0x63,0x7f,0x60,0x63,0x3e,0x0,0x0,0x0,
/* f */ 0x0,0x0,0x1c,0x36,0x32,0x30,0x7c,0x30,0x30,0x30,0x78,0x0,0x0,0x0,
/* g */ 0x0,0x0,0x0,0x0,0x0,0x3b,0x66,0x66,0x66,0x3e,0x6,0x66,0x3c,0x0,
/* h */ 0x0,0x0,0x70,0x30,0x30,0x36,0x3b,0x33,0x33,0x33,0x73,0x0,0x0,0x0,
/* i */ 0x0,0x0,0xc,0xc,0x0,0x1c,0xc,0xc,0xc,0xc,0x1e,0x0,0x0,0x0,
/* j */ 0x0,0x0,0x6,0x6,0x0,0xe,0x6,0x6,0x6,0x6,0x66,0x66,0x3c,0x0,
/* k */ 0x0,0x0,0x70,0x30,0x30,0x33,0x36,0x3c,0x36,0x33,0x73,0x0,0x0,0x0,
/* l */ 0x0,0x0,0x1c,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x1e,0x0,0x0,0x0,
/* m */ 0x0,0x0,0x0,0x0,0x0,0x76,0x7f,0x6b,0x6b,0x6b,0x6b,0x0,0x0,0x0,
/* n */ 0x0,0x0,0x0,0x0,0x0,0x6e,0x33,0x33,0x33,0x33,0x33,0x0,0x0,0x0,
/* o */ 0x0,0x0,0x0,0x0,0x0,0x3e,0x63,0x63,0x63,0x63,0x3e,0x0,0x0,0x0,
/* p */ 0x0,0x0,0x0,0x0,0x0,0x6e,0x33,0x33,0x33,0x3e,0x30,0x30,0x78,0x0,
/* q */ 0x0,0x0,0x0,0x0,0x0,0x3b,0x66,0x66,0x66,0x3e,0x6,0x6,0xf,0x0,
/* r */ 0x0,0x0,0x0,0x0,0x0,0x6e,0x3b,0x33,0x30,0x30,0x78,0x0,0x0,0x0,
/* s */ 0x0,0x0,0x0,0x0,0x0,0x3e,0x63,0x38,0xe,0x63,0x3e,0x0,0x0,0x0,
/* t */ 0x0,0x0,0x8,0x18,0x18,0x7e,0x18,0x18,0x18,0x1b,0xe,0x0,0x0,0x0,
/* u */ 0x0,0x0,0x0,0x0,0x0,0x66,0x66,0x66,0x66,0x66,0x3b,0x0,0x0,0x0,
/* v */ 0x0,0x0,0x0,0x0,0x0,0x63,0x63,0x63,0x63,0x36,0x1c,0x8,0x0,0x0,
/* w */ 0x0,0x0,0x0,0x0,0x0,0x63,0x63,0x63,0x6b,0x7f,0x36,0x0,0x0,0x0,
/* x */ 0x0,0x0,0x0,0x0,0x0,0x63,0x36,0x1c,0x1c,0x36,0x63,0x0,0x0,0x0,
/* y */ 0x0,0x0,0x0,0x0,0x0,0x63,0x63,0x63,0x63,0x3f,0x3,0x6,0x3c,0x0,
/* z */ 0x0,0x0,0x0,0x0,0x0,0x7f,0x66,0xc,0x18,0x33,0x7f,0x0,0x0,0x0,
/* { */ 0x0,0x0,0xe,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0xe,0x0,0x0,0x0,
/* | */ 0x0,0x0,0x18,0x18,0x18,0x18,0x0,0x18,0x18,0x18,0x18,0x0,0x0,0x0,
/* } */ 0x0,0x0,0x70,0x18,0x18,0x18,0xe,0x18,0x18,0x18,0x70,0x0,0x0,0x0,
/* ~ */ 0x0,0x0,0x3b,0x6e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
kic-2.4c/src/xmfb/Makefile.in 0000644 0000764 0000764 00000002566 07525375573 015537 0 ustar stevew stevew #######################################################################
# src/xmfb/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
X_INC = @X_CFLAGS@
LIB_TARGET = ../xmfb.a
HFILES =
CFILES = 6x8font.c 8x14font.c 8x16font.c 8x8font.c mfb.c mfbcsdl.c mfbtext.c \
text1.c xfb.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include $(X_INC)
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/xmfb
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/bin/ 0000755 0000764 0000764 00000000000 12427446157 013267 5 ustar stevew stevew kic-2.4c/src/bin/kic.ico 0000644 0000764 0000764 00000015646 07525346711 014543 0 ustar stevew stevew F ( . V 00 ( @ DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDKDKDKDDKDKDKDDKDKDKDDDDDDDDDDDDDDDDDDDDDDDDʬKDDΞʬKDDʬKDDDDʬDDDDDDʬDDDDʬKDDʬKDD̪KDDDDʪDDDDDDDDDDʪKDDʚKDDʪKDDDDDDDDDDDDDDKDDKDDKDDDDDDDDDDDDDDDDDDDDDDDDKDKDKDDKDKDKDDKDKDKDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD ( DDDDDDDDKKKKKKDDDDDDDDKNKKKDDDDDKDKKNDKDDDDDDKDDKKDDDKDDDDDDDDKKKKKKDDDDDDDD ( @ ʦ """ ))) UUU MMM BBB 999 | PP 3 f 3 33 3f 3 3 3 f f3 ff f f f 3 f 3 f ̙ f 3 3 3 3 f 3 3 3 33 333 33f 33 33 33 3f 3f3 3ff 3f 3f 3f 3 33 3f 3 3 3 3 33 3f 3̙ 3 3 33 3f 3 3 3 f f 3 f f f f f f3 f33 f3f f3 f3 f3 ff ff3 fff ff ff f f3 ff f f f f f3 f̙ f f f f3 f f 3 33 f 3 f f3 3f f f 3 3 f 3 ff ̙ 3 f 3 f 3 33 3f 3 3 3 f f3 ff f f f ̙ ̙3 ̙f ̙ ̙ ̙ 3 f ̙ 3 f 3 f 3 33 3f 3 3 3 f f3 ff f f f 3 f 3 f ̙ 3 f ff ff f ff f f ! ___ www ( 0 `
ʦ """ ))) UUU MMM BBB 999 | PP 3 f 3 33 3f 3 3 3 f f3 ff f f f 3 f 3 f ̙ f 3 3 3 3 f 3 3 3 33 333 33f 33 33 33 3f 3f3 3ff 3f 3f 3f 3 33 3f 3 3 3 3 33 3f 3̙ 3 3 33 3f 3 3 3 f f 3 f f f f f f3 f33 f3f f3 f3 f3 ff ff3 fff ff ff f f3 ff f f f f f3 f̙ f f f f3 f f 3 33 f 3 f f3 3f f f 3 3 f 3 ff ̙ 3 f 3 f 3 33 3f 3 3 3 f f3 ff f f f ̙ ̙3 ̙f ̙ ̙ ̙ 3 f ̙ 3 f 3 f 3 33 3f 3 3 3 f f3 ff f f f 3 f 3 f ̙ 3 f ff ff f ff f f ! ___ www kic-2.4c/src/bin/kictostr.c 0000644 0000764 0000764 00000155456 12427255624 015312 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#define Allocate
#include "prefix.h"
#include "stream.h"
#include "kic.h"
#include
/* Define to 1 if GDS symbol and lib names are to be converted to
* upper case. This was true in the previous versions of Kic.
*/
#define TOUPR 0
#define DATA_TYPE(a) (((a)<0||(a)>255)?0:(a))
#define LONGSCALE(s,x) (int) (floor( (s * (double)(x)) + 0.5))
#define GDS_SUFFIX ".gds"
extern int CDStatusInt;
extern char *CDStatusString;
struct f FB = { 0 };
int LayerNumbers[CDNUMLAYERS+1];
int DataTypeNumbers[CDNUMLAYERS+1];
int SelectiveSearch; /* If set, only those symbols that exist in the
current working directory will be placed into
the output stream library file */
STRM_LIBRARY STRMLibrary;
STRM_STRCT STRMStructure;
STRM_BOUNDARY STRMBoundary;
STRM_PATH STRMPath;
STRM_TEXT STRMText;
STRM_SREF STRMSref;
STRM_AREF STRMAref;
STRM_TRANSFORM DefaultTransform;
STRM_PROPERTY DefaultProperty;
int NumLayerTable;
struct kl LayerTable[CDNUMLAYERS+1];
struct kp Parameters;
struct cl ColorTable[12];
FILE *StreamFile;
double Scale;
#if __STDC__
extern void help(void);
extern char *nextarg(void);
extern void GetLayerInfo(char*,int,int);
extern void SetLayerInfo(int,int);
extern int GenStream(char*,struct s*,int*);
extern void finish_path(int);
extern void out_poly(struct p*,Poly*);
extern void break_poly(Poly*);
extern void convert_pathtype(int*,int*,int,int,int);
extern void MallocFailed(void);
extern void strm_beginrecord(int,int,int);
extern void strm_adddate(struct tm*);
extern void strm_entrasc_rec(char*,int,int);
extern void strm_entrasc(char*,int);
extern int bgnlib(STRM_LIBRARY*);
extern int endlib(void);
extern int bgnstr(STRM_STRCT*);
extern int endstr(void);
extern int strm_endlmnt(STRM_PROPERTY*);
extern int bndry(STRM_BOUNDARY*);
extern int strm_strnsfm(STRM_TRANSFORM*);
extern int path(STRM_PATH*);
extern int sref(STRM_SREF*);
extern int aref(STRM_AREF*);
extern int text(STRM_TEXT*);
extern char *unalias(char*);
extern void strm_intcopy(int);
extern void strm_lngcopy(int);
extern void strm_dblcopy(double);
#else
extern void help();
extern char *nextarg();
extern void GetLayerInfo();
extern void SetLayerInfo();
extern int GenStream();
extern void finish_path();
extern void out_poly();
extern void break_poly();
extern void convert_pathtype();
extern void MallocFailed();
extern void strm_beginrecord();
extern void strm_adddate();
extern void strm_entrasc_rec();
extern void strm_entrasc();
extern int bgnlib();
extern int endlib();
extern int bgnstr();
extern int endstr();
extern int strm_endlmnt();
extern int bndry();
extern int strm_strnsfm();
extern int path();
extern int sref();
extern int aref();
extern int text();
extern void strm_intcopy();
extern void strm_lngcopy();
extern void strm_dblcopy();
extern char *unalias();
#endif
int argc;
char **argv;
int
main(ac, av)
char *av[];
{
double Float1 = 1.0;
double Float2;
struct s *SymbolDesc;
struct tm Now;
struct prpty *PrptyDesc;
char *cp;
time_t tloc;
int i = 0,k;
int detail = 0;
int symbolic = 0;
int DBUpermic = 0;
int SymbolNum = 0;
int UseStreamNames = 0;
int UseLayerTable = 0;
char Root[81];
char StreamFileName[81];
char LayerFile[81];
char Path[81];
char *Tmp, *Tech;
/* initialize */
InitGlobal();
SelectiveSearch = False;
tloc = time(NULL);
Now = *localtime(&tloc);
STRMLibrary.lib_name[0] = '\0';
STRMLibrary.lib_lib1[0] = '\0';
STRMLibrary.lib_lib2[44] = '\0';
STRMLibrary.lib_font0[0] = '\0';
STRMLibrary.lib_font1[0] = '\0';
STRMLibrary.lib_font2[0] = '\0';
STRMLibrary.lib_font3[0] = '\0';
STRMLibrary.lib_attr[0] = '\0';
STRMLibrary.lib_accessdate = Now;
STRMLibrary.lib_moddate = Now;
STRMLibrary.lib_uunit = .01;
STRMLibrary.lib_munit = 1e-8;
STRMLibrary.lib_gen = 3;
STRMStructure.str_moddate = Now;
STRMStructure.str_creatdate = Now;
DefaultTransform.trns_reflection = 0;
DefaultTransform.trns_abs_mag = 0;
DefaultTransform.trns_abs_angle = 0;
DefaultTransform.trns_mag = 1.0;
DefaultTransform.trns_angle = 0.0;
DefaultProperty.prp_npropval = 0;
argc = ac;
argv = av;
Float1 = 1.0;
*Root = '\0';
*StreamFileName = '\0';
while (argc > 1 && argv[1][0] == '-') {
switch (argv[1][1]) {
case 'L':
case 'l':
sscanf(nextarg(), "%lg", &Float1);
break;
case 'Z':
case 'z':
/* extract STREAM filename */
strcpy(STRMLibrary.lib_name,nextarg());
break;
case 'M':
case 'm':
++DBUpermic;
sscanf(nextarg(), "%lg", &Float2);
break;
case 'O':
case 'o':
strcpy(StreamFileName, nextarg());
break;
case 'S':
case 's':
symbolic++;
break;
case 'D':
case 'd':
detail++;
break;
case 'C':
case 'c':
SelectiveSearch++;
break;
case 'X':
case 'x':
strcpy(LayerFile, nextarg());
UseLayerTable = 1;
break;
case 'N':
case 'n':
UseStreamNames = 1;
break;
case 'T':
case 't':
Tech = nextarg();
#ifdef MSDOS
if (strlen(Tech) > 3)
Tech[3] = '\0';
#endif
TECH_EXT = tmalloc(strlen(Tech) + 1);
if (TECH_EXT == NULL) {
(void)fprintf(stderr,
"Memory allocation failure on startup.\n");
exit(1);
}
strcpy(TECH_EXT,Tech);
break;
default:
help();
}
argc--;
argv++;
}
if (argc > 1)
strcpy(Root,argv[1]);
else {
printf("Hierarchy's root cell? (hit return for help) ");
Tmp = tmalloc(81);
*Tmp = '\0';
fgets(Tmp,81,stdin);
if (sscanf(Tmp,"%s",Root) != 1)
help();
free(Tmp);
}
Path[0] = '\0';
Tmp = strrchr(Root,DIRC);
if (Tmp) {
*Tmp = '\0';
strcpy(Path,Root);
for (i = 0, Tmp++; *Tmp; i++, Tmp++)
Root[i] = *Tmp;
Root[i] = '\0';
}
/*
* Initializes CD package and reads in tech file so we
* know the layer names. Can't generate CIF without them.
*/
ReadTechFile();
if (!UseStreamNames) {
if (UseLayerTable)
printf("Using layer table file %s\n",LayerFile);
else {
printf("Using layers from %s\n",TECHFILE);
strcpy(LayerFile,TECHFILE);
}
}
else {
printf("Using layer names for stream layer data\n");
UseLayerTable = 0;
}
if (STRMLibrary.lib_name[0] == '\0')
sprintf(STRMLibrary.lib_name,"KICTOSTREAM");
printf("Microns per lambda: %15.8e\n",Float1);
if (StreamFileName[0] == '\0') {
cp = Root;
i = 0;
while (*cp != '.' And *cp != '\0') {
StreamFileName[i] = *cp;
++i;
++cp;
}
StreamFileName[i] = '\0';
strcat(StreamFileName, GDS_SUFFIX);
}
if (DBUpermic) {
STRMLibrary.lib_uunit = 1.0/Float2;
STRMLibrary.lib_munit = 1e-6 * STRMLibrary.lib_uunit;
Float1 *= (.01/STRMLibrary.lib_uunit);
}
/* add the root path */
if (*Path) {
Tmp = PGetPath();
strcat(Tmp,Path);
printf("KIC search path: %s\n",Tmp);
}
for (k = 0; k < NumLayerTable; k++) {
LayerNumbers[k] = LayerTable[k].klStreamNumber;
if (LayerNumbers[k] <= 0)
LayerNumbers[k] = k;
DataTypeNumbers[k] = LayerTable[i].klStreamDataType;
}
GetLayerInfo(LayerFile,UseLayerTable,UseStreamNames);
SetLayerInfo(detail,symbolic);
if ((StreamFile=POpen(StreamFileName,"wb",
(char *)NULL,(char **)NULL)) == NULL) {
fprintf(stderr,"Can't open STREAM file.");
exit(1);
}
if (Not CDOpen(Root,&SymbolDesc,'r')) {
fprintf(stderr,"Can't open root kic cell %s.\n",Root);
fprintf(stderr,"Parse failed at around: %s.\n",CDStatusString);
exit(1);
}
if (CDStatusInt == CDNEWSYMBOL) {
fprintf(stderr,"Can't find root kic cell %s.\n",Root);
exit(1);
}
/* add STREAM-specific property list info */
CDProperty(SymbolDesc,(struct o *)NULL,&PrptyDesc);
while (PrptyDesc != NULL) {
i = PrptyDesc->prpty_Value - PROPERTYOFFSET;
if (i == HEADER) {
/* version 3 is assumed */
}
else if (i == LIBNAME) {
sscanf(PrptyDesc->prpty_String,"%s",STRMLibrary.lib_name);
}
else if (i == REFLIBS) {
sscanf(PrptyDesc->prpty_String,"%s %s",STRMLibrary.lib_lib1,
STRMLibrary.lib_lib2);
}
else if (i == FONTS) {
sscanf(PrptyDesc->prpty_String,"%s %s %s %s",
STRMLibrary.lib_font0,STRMLibrary.lib_font1,
STRMLibrary.lib_font2,STRMLibrary.lib_font3);
}
else if (i == GENERATIONS) {
sscanf(PrptyDesc->prpty_String,"%d",&STRMLibrary.lib_gen);
}
else if (i == ATTRTABLE) {
sscanf(PrptyDesc->prpty_String,"%s",STRMLibrary.lib_attr);
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
#ifdef MSDOS
readalias();
#endif
bgnlib(&STRMLibrary);
SymbolNum = 1;
Scale = Float1;
if (Not GenStream(Root,SymbolDesc,&SymbolNum)) {
fprintf(stderr,"Unable to write stream file.\n");
fprintf(stderr,"Status string: %s.\n",CDStatusString);
exit(1);
}
endlib();
fclose(StreamFile);
printf("Translation of %s succeeded.\n",Root);
return (0);
}
void
help()
{
printf("\nkictostr-%s\n\n",VersionString);
printf("Usage: kictostr [options] [root_kic_cell]\n\n");
printf("options:\n");
printf(" -C convert only cells in current directory\n");
printf(" -Zname stream library name (default \"KICTOSTREAM\")\n");
printf(" -Ostrname stream file name to create (default is root kic\n");
printf(" cell name with .str extension)\n");
printf(" -S convert symbolic layers only\n");
printf(" -D convert detail layers only\n");
printf(" -Xfilename filename = layer table reference file\n");
printf(" -Text use layers in tech.ext\n");
printf(" -N parse layer names for stream layers, kic layers\n");
printf(" must be named \"NN NN\"\n");
printf(" -Lmicprl micron per lambda (default 1.0)\n");
printf(" -Mupermic units per micron (default 100.0)\n\n");
printf("N supersedes X,T, Default is layers from tech file.\n");
printf("Prompts for kic cell name if not supplied.\n");
exit(0);
}
char *
nextarg()
{
if (argv[1][2] != '\0')
return(&argv[1][2]);
argv++;
argc--;
return(argv[1]);
}
void
GetLayerInfo(LayerFile,UseLayerTable,UseStreamNames)
char *LayerFile;
int UseLayerTable,UseStreamNames;
{
FILE *ltable;
int i,j,k,l,n;
char buffer[80];
char *emesg = "Incorrect layer table format in %s.\n";
if (UseLayerTable) {
if ((ltable = fopen(LayerFile,"r")) == NULL) {
fprintf(stderr,"Can't open stream layer file %s.\n",LayerFile);
exit(1);
}
fscanf(ltable,"%d",&n);
if (n <= 0 || n > 127) {
fprintf(stderr,emesg,LayerFile);
exit(1);
}
for (i = 0; i < n; i++) {
buffer[0] = buffer[1] = buffer[2] = buffer[3] = ' ';
if (fscanf(ltable,"%s %d %d",buffer,&j,&k) < 3) {
fprintf(stderr,emesg,LayerFile);
exit(1);
}
for (l = 0; l < 4; l++) {
if (buffer[l] < ' ')
buffer[l] = ' ';
}
for (l = 1; l <= CDNUMLAYERS; l++) {
if (buffer[0] == CDLayer[l].lTechnology And
buffer[1] == CDLayer[l].lMask[0] And
buffer[2] == CDLayer[l].lMask[1] And
buffer[3] == CDLayer[l].lMask[2]) {
LayerNumbers[l] = j;
DataTypeNumbers[l] = k;
}
}
}
fclose(ltable);
return;
}
if (UseStreamNames) {
buffer[5] = '\0';;
for (k = 0; k < CDNUMLAYERS; k++) {
buffer[0] = CDLayer[k].lTechnology;
buffer[1] = CDLayer[k].lMask[0];
buffer[2] = ' ';
buffer[3] = CDLayer[k].lMask[1];
buffer[4] = CDLayer[k].lMask[2];
if (sscanf(buffer,"%d %d",
&LayerNumbers[k],&DataTypeNumbers[k]) < 2) {
fprintf(stderr,
"Internal error: trouble reading stream layer %c%s.\n",
CDLayer[k].lTechnology,CDLayer[k].lMask);
exit(1);
}
}
}
}
void
SetLayerInfo(detail,symbolic)
int detail,symbolic;
{
int Layers[CDNUMLAYERS];
int Layer;
if (!(detail ^ symbolic)) {
detail = 0;
symbolic = 0;
printf("Converting all layers\n");
}
else if (detail)
printf("Converting detail layers\n");
else
printf("Converting symbolic layers\n");
for (Layer = 0; Layer < NumLayerTable; Layer++)
Layers[Layer] = True;
if (detail) {
for (Layer = 0; Layer < NumLayerTable; Layer++)
if (LayerTable[Layer+1].klAttributes & SYMBOLIC)
Layers[Layer] = False;
}
else if (symbolic) {
for (Layer = 0; Layer < NumLayerTable; Layer++)
if (Not (LayerTable[Layer+1].klAttributes & SYMBOLIC))
Layers[Layer] = False;
}
for (Layer = 0; Layer < NumLayerTable; Layer++)
if (Layers[Layer])
CDLayer[Layer].lCDFrom = True;
else
CDLayer[Layer].lCDFrom = False;
}
int
GenStream(MasterName,SymbolDesc,SymbolNum)
char *MasterName;
struct s *SymbolDesc;
int *SymbolNum;
{
struct g *GenDesc;
struct o *Pointer;
struct s *MasterDesc;
struct p *Pair,*Path;
struct t *TGen;
struct prpty *PrptyDesc;
char *SymbolName;
char *Label;
char Type,Xform;
char garbage[120];
int Info;
int i;
int Layer;
int NumX,NumY;
unsigned int size;
int X,Y,Length,Width;
int DX,DY;
double a,b;
printf("Converting: %s\n",MasterName);
*SymbolNum += 1;
/*
* Mark symbol associated with SymbolDesc as visited by storing
* its symbol # in its info field.
*/
CDSetInfo(SymbolDesc,(struct o *)NULL,*SymbolNum);
/*
* First write to the stream file any symbol definitions below
* the symbol associated with SymbolDesc.
*/
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return(CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
if (Not CDOpen(SymbolName,&MasterDesc,'w')) {
fprintf(stderr,"Unable to open symbol %s.\n",SymbolName);
fprintf(stderr,"Status string: %s.\n",CDStatusString);
exit(1);
}
CDInfo(MasterDesc,(struct o *)NULL,&Info);
if (Info == 0) {
/* Write master's definition to stream file. */
if (Not GenStream(SymbolName,MasterDesc,SymbolNum)) {
fprintf(stderr,"Unable to write stream file.\n");
fprintf(stderr,"Status string: %s.\n",CDStatusString);
exit(1);
}
}
}
/*
* If the SelectiveSearch integer is set, only those symbols which
* exist in the current directory will be placed in the stream file.
*/
if (SelectiveSearch) {
if (access(MasterName,0) != 0) {
fprintf(stderr,"Symbol %s not found in current directory.\n",
MasterName);
return(True);
}
}
/*
* Write to the stream file the definition of the symbol associated with
* SymbolDesc. Instance calls first--then geometries.
*/
#ifdef MSDOS
strcpy(STRMStructure.str_name, unalias(MasterName));
#else
strcpy(STRMStructure.str_name, MasterName);
#endif
bgnstr(&STRMStructure);
if (Not CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return(CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
if (Not CDOpen(SymbolName,&MasterDesc,'w'))
return(False);
if (NumX > 1 || NumY > 1) {
/* create an AREF */
#ifdef MSDOS
strcpy(STRMAref.ar_name, unalias(SymbolName));
#else
strcpy(STRMAref.ar_name, SymbolName);
#endif
STRMAref.ar_transform = DefaultTransform;
STRMAref.ar_col = NumX;
STRMAref.ar_row = NumY;
STRMAref.ar_xy[0] = 0;
STRMAref.ar_xy[1] = 0;
/* copy the property list */
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while (PrptyDesc != NULL) {
if (STRMAref.ar_prop.prp_npropval >= 255) {
fprintf(stderr,"Too many properties for symbol %s.\n",
SymbolName);
STRMAref.ar_prop.prp_npropval = 255;
}
/* allow only valid STREAM property attributes */
i = PrptyDesc->prpty_Value;
if (i > 0 && i < 128) {
STRMAref.ar_prop.prp_propattr
[STRMAref.ar_prop.prp_npropval] = i;
size = strlen(PrptyDesc->prpty_String) + 2;
STRMAref.ar_prop.prp_propval
[STRMAref.ar_prop.prp_npropval] = tmalloc(size);
strcpy(STRMAref.ar_prop.prp_propval
[STRMAref.ar_prop.prp_npropval],
PrptyDesc->prpty_String);
++STRMAref.ar_prop.prp_npropval;
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
STRMAref.ar_transform.trns_angle = 0;
STRMAref.ar_transform.trns_reflection = 0;
CDInitTGen(Pointer,&TGen);
TPush();
TIdentity();
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) break;
elif (Type == CDROTATE) {
a = (double) X;
b = (double) Y;
STRMAref.ar_transform.trns_angle +=
(RADTODEG * atan2(b,a));
TRotate(X,Y);
}
elif (Type == CDTRANSLATE) {
TTranslate(LONGSCALE(Scale,X),LONGSCALE(Scale,Y));
}
elif (Type == CDMIRRORX) {
STRMAref.ar_transform.trns_reflection ^= 1;
STRMAref.ar_transform.trns_angle += 180.0;
TMX();
}
elif (Type == CDMIRRORY) {
STRMAref.ar_transform.trns_reflection ^= 1;
TMY();
}
}
TPremultiply();
STRMAref.ar_xy[0] = 0;
STRMAref.ar_xy[1] = 0;
STRMAref.ar_xy[2] = DX*NumX;
STRMAref.ar_xy[3] = 0;
STRMAref.ar_xy[4] = 0;
STRMAref.ar_xy[5] = DY*NumY;
TPoint(&STRMAref.ar_xy[0],&STRMAref.ar_xy[1]);
TPoint(&STRMAref.ar_xy[2],&STRMAref.ar_xy[3]);
TPoint(&STRMAref.ar_xy[4],&STRMAref.ar_xy[5]);
TPop();
aref(&STRMAref);
/* free storage of property values */
for (i = 0; i < STRMAref.ar_prop.prp_npropval; i++)
free(STRMAref.ar_prop.prp_propval[i]);
STRMAref.ar_prop.prp_npropval = 0;
}
else {
/* create an SREF */
#ifdef MSDOS
strcpy(STRMSref.sr_name, unalias(SymbolName));
#else
strcpy(STRMSref.sr_name, SymbolName);
#endif
STRMSref.sr_transform = DefaultTransform;
STRMSref.sr_xy[0] = STRMSref.sr_xy[1] = 0;
/* copy the property list */
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while (PrptyDesc != NULL) {
if (STRMSref.sr_prop.prp_npropval >= 255) {
fprintf(stderr,"Too many properties for symbol %s.\n",
SymbolName);
STRMSref.sr_prop.prp_npropval = 255;
}
/* allow only valid STREAM property attributes */
i = PrptyDesc->prpty_Value;
if (i > 0 && i < 128) {
STRMSref.sr_prop.prp_propattr
[STRMSref.sr_prop.prp_npropval] = i;
size = strlen(PrptyDesc->prpty_String) + 2;
STRMSref.sr_prop.prp_propval
[STRMSref.sr_prop.prp_npropval] = tmalloc(size);
strcpy(STRMSref.sr_prop.prp_propval
[STRMSref.sr_prop.prp_npropval],
PrptyDesc->prpty_String);
++STRMSref.sr_prop.prp_npropval;
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
STRMSref.sr_transform.trns_angle = 0;
STRMSref.sr_transform.trns_reflection = 0;
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) {
break;
}
elif (Type == CDROTATE) {
a = (double) X;
b = (double) Y;
STRMSref.sr_transform.trns_angle +=
(RADTODEG * atan2(b,a));
}
elif (Type == CDTRANSLATE) {
STRMSref.sr_xy[0]
= LONGSCALE(Scale,X);
STRMSref.sr_xy[1]
= LONGSCALE(Scale,Y);
}
elif (Type == CDMIRRORX) {
STRMSref.sr_transform.trns_reflection ^= 1;
STRMSref.sr_transform.trns_angle += 180.0;
}
elif (Type == CDMIRRORY)
STRMSref.sr_transform.trns_reflection ^= 1;
}
sref(&STRMSref);
/* free storage of property values */
for (i = 0; i < STRMSref.sr_prop.prp_npropval; ++i) {
free(STRMSref.sr_prop.prp_propval[i]);
}
STRMSref.sr_prop.prp_npropval = 0;
}
}
for (Layer = 1;Layer <= CDNUMLAYERS;++Layer) {
if (Not CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc))
return(CDError(CDMALLOCFAILED));
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
/* copy the property list */
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while (PrptyDesc != NULL) {
if (DefaultProperty.prp_npropval >= 255) {
fprintf(stderr,
"Too many properties for layer %d\n",Layer);
DefaultProperty.prp_npropval = 255;
}
i = PrptyDesc->prpty_Value;
/* allow only valid STREAM property attributes */
if (i > 0 && i < 128) {
DefaultProperty.prp_propattr
[DefaultProperty.prp_npropval] = i;
size = strlen(PrptyDesc->prpty_String) + 2;
DefaultProperty.prp_propval
[DefaultProperty.prp_npropval] = tmalloc(size);
strcpy(DefaultProperty.prp_propval
[DefaultProperty.prp_npropval],
PrptyDesc->prpty_String);
++DefaultProperty.prp_npropval;
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
CDType(Pointer,&Type);
if (Type == CDBOX) {
CDBox(Pointer,&Layer,&Length,&Width,&X,&Y);
Length /= 2;
Width /= 2;
X = LONGSCALE(Scale,X);
Y = LONGSCALE(Scale,Y);
Length = LONGSCALE(Scale,Length);
Width = LONGSCALE(Scale,Width);
STRMBoundary.bnd_layer = LayerNumbers[Layer];
STRMBoundary.bnd_datatype = DATA_TYPE(DataTypeNumbers[Layer]);
STRMBoundary.bnd_prop = DefaultProperty;
STRMBoundary.bnd_ncoord = 5;
STRMBoundary.bnd_xy[0] = (X + Length);
STRMBoundary.bnd_xy[1] = (Y + Width);
STRMBoundary.bnd_xy[2] = (X + Length);
STRMBoundary.bnd_xy[3] = (Y - Width);
STRMBoundary.bnd_xy[4] = (X - Length);
STRMBoundary.bnd_xy[5] = (Y - Width);
STRMBoundary.bnd_xy[6] = (X - Length);
STRMBoundary.bnd_xy[7] = (Y + Width);
STRMBoundary.bnd_xy[8] = (X + Length);
STRMBoundary.bnd_xy[9] = (Y + Width);
bndry(&STRMBoundary);
}
elif (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
STRMPath.pth_layer = LayerNumbers[Layer];
STRMPath.pth_datatype = DATA_TYPE(DataTypeNumbers[Layer]);
STRMPath.pth_width = LONGSCALE(Scale,Width);
STRMPath.pth_prop = DefaultProperty;
STRMPath.pth_pathtype = 2;
/*
* look at the property list for a STREAM pathtype definition
*/
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while (PrptyDesc != NULL) {
i = PrptyDesc->prpty_Value - PROPERTYOFFSET;
if (i == PATHTYPE) {
sscanf(PrptyDesc->prpty_String,"%s %d",garbage,&i);
if (i >= 0 && i < 3)
STRMPath.pth_pathtype = i;
break;
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
Pair = Path;
i = 0;
while (Pair != NULL) {
STRMPath.pth_xy[i++] = LONGSCALE(Scale,Pair->pX);
STRMPath.pth_xy[i++] = LONGSCALE(Scale,Pair->pY);
if (i == 2 && !Pair->pSucc) {
STRMPath.pth_xy[i++] = LONGSCALE(Scale,Pair->pX);
STRMPath.pth_xy[i++] = LONGSCALE(Scale,Pair->pY);
}
Pair = Pair->pSucc;
if (i == MAXSTRMCOORDS && Pair) {
printf("Breaking wire with too many vertices.\n");
finish_path(i);
i = 0;
}
}
finish_path(i);
}
elif (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
STRMBoundary.bnd_layer = LayerNumbers[Layer];
STRMBoundary.bnd_datatype = DATA_TYPE(DataTypeNumbers[Layer]);
STRMBoundary.bnd_prop = DefaultProperty;
out_poly(Path, (Poly*)NULL);
}
elif (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
STRMText.txt_layer = LayerNumbers[Layer];
STRMText.txt_texttype = DATA_TYPE(DataTypeNumbers[Layer]);
STRMText.txt_pathtype = 1;
STRMText.txt_horizontal = 0;
STRMText.txt_vertical = 0;
STRMText.txt_font = 0;
STRMText.txt_width = 0;
STRMText.txt_xy[0] = LONGSCALE(Scale,X);
STRMText.txt_xy[1] = LONGSCALE(Scale,Y);
STRMText.txt_prop = DefaultProperty;
STRMText.txt_transform = DefaultTransform;
STRMSref.sr_xy[0] = STRMSref.sr_xy[1] = 0;
memcpy(STRMText.txt_text,Label,44);
STRMText.txt_text[44] = '\0';
/* look at the property list for a STREAM text definition */
CDProperty(SymbolDesc,Pointer,&PrptyDesc);
while (PrptyDesc != NULL) {
int wdth;
int present,ptype,reflection;
double magn,rotn;
i = PrptyDesc->prpty_Value - PROPERTYOFFSET;
if (i == TEXT) {
sscanf(PrptyDesc->prpty_String,
"%s %d %s %d %s %d %s %lf %s %lf %s %d",
garbage,&wdth,garbage,&present,garbage,&ptype,
garbage,&magn,garbage,&rotn,garbage,&reflection);
STRMText.txt_pathtype = ptype;
STRMText.txt_horizontal = (present >> 8) & 3;
STRMText.txt_vertical = (present >> 10) & 3;
STRMText.txt_font = (present >> 12) & 3;
STRMText.txt_width = wdth;
STRMText.txt_transform.trns_reflection = reflection;
STRMText.txt_transform.trns_mag = magn;
STRMText.txt_transform.trns_angle = rotn;
break;
}
PrptyDesc = PrptyDesc->prpty_Succ;
}
text(&STRMText);
}
/* free storage of property values */
for (i = 0; i < DefaultProperty.prp_npropval; ++i) {
free(DefaultProperty.prp_propval[i]);
}
DefaultProperty.prp_npropval = 0;
}
}
endstr();
return(True);
}
void
finish_path(i)
int i;
{
if (STRMPath.pth_pathtype == 0 && i > 3) {
convert_pathtype(&STRMPath.pth_xy[0],&STRMPath.pth_xy[1],
STRMPath.pth_xy[2],STRMPath.pth_xy[3],
STRMPath.pth_width);
convert_pathtype(&STRMPath.pth_xy[i-1],
&STRMPath.pth_xy[i-2],STRMPath.pth_xy[i-3],
STRMPath.pth_xy[i-4],STRMPath.pth_width);
}
STRMPath.pth_ncoord = i/2;
path(&STRMPath);
}
void
out_poly(Path, po)
/* Output the poly data, or cut it into pieces if there are
* too many vertices.
*/
struct p *Path;
Poly *po;
{
int i;
struct p *pp;
Poly p1;
int *xy, *bxy;
if (!po) {
for (i = 0, pp = Path; pp; i++,pp = pp->pSucc) ;
p1.nvertices = i;
xy = (int*) tmalloc(i*2*sizeof(int));
p1.xy = xy;
for (pp = Path; pp; pp = pp->pSucc) {
*xy++ = pp->pX;
*xy++ = pp->pY;
}
}
else
p1 = *po;
if (p1.nvertices > MAXSTRMCOORDS/2) {
printf("Breaking polygon with too many vertices.\n");
break_poly(&p1);
}
else {
xy = p1.xy;
bxy = STRMBoundary.bnd_xy;
for (i = 0; i < p1.nvertices; i++) {
*bxy++ = LONGSCALE(Scale,*xy++);
*bxy++ = LONGSCALE(Scale,*xy++);
}
if (i < 4) {
/* close the triangle */
*bxy++ = STRMBoundary.bnd_xy[0];
*bxy++ = STRMBoundary.bnd_xy[1];
i++;
}
STRMBoundary.bnd_ncoord = i;
bndry(&STRMBoundary);
}
if (!po)
free(p1.xy);
}
void
break_poly(p1)
/* Break a polygon across the midlle of its BB horizontally and
* write out the resulting clipped polygons.
*/
Poly *p1;
{
int i, x, y, RefY;
struct ka BB;
Poly p2;
int *xy;
/* 4 * num vertices should be long enough */
p2.xy = (int*) tmalloc(p1->nvertices*8*sizeof(int));
BB.kaLeft = BB.kaRight = p1->xy[0];
BB.kaBottom = BB.kaTop = p1->xy[1];
xy = p1->xy;
for (i = 0; i < p1->nvertices; i++) {
x = *xy++;
y = *xy++;
if (x > BB.kaRight) BB.kaRight = x;
if (x < BB.kaLeft) BB.kaLeft = x;
if (y > BB.kaTop) BB.kaTop = y;
if (y < BB.kaBottom) BB.kaBottom = y;
}
RefY = (BB.kaBottom + BB.kaTop)/2;
PolygonClip(p1,BB.kaLeft,BB.kaBottom,BB.kaRight,RefY);
while (NewPolygon(&p2))
out_poly((struct p*)NULL,&p2);
PolygonClip(p1,BB.kaLeft,RefY,BB.kaRight,BB.kaTop);
while (NewPolygon(&p2))
out_poly((struct p*)NULL,&p2);
free(p2.xy);
}
void
convert_pathtype(xe,ye,xb,yb,width)
int *xe,*ye; /* coordinate of endpoint */
int xb,yb; /* coordinate of previous or next point in path */
int width; /* path width */
{
double angle;
double deltaX,deltaY;
if (width == 0)
return;
else if (width < 0)
width = -width;
width /= 2;
if (*xe == xb) {
if (*ye > yb)
*ye += width;
else
*ye -= width;
}
else if (*ye == yb) {
if (*xe > xb)
*xe += width;
else
*xe -= width;
}
else {
deltaX = (double)(*xe - xb);
deltaY = (double)(*ye - yb);
angle = atan2(deltaY,deltaX);
deltaX = (double)(width) * cos(angle);
deltaY = (double)(width) * sin(angle);
*xe += (int)(deltaX);
*ye += (int)(deltaY);
}
}
void
MallocFailed()
{
if (CDStatusInt != CDMALLOCFAILED)
return;
fprintf(stderr,"OUT OF MEMORY. This is a fatal error!\n");
exit(1);
}
/* for callbacks in cd, not used */
void UpdateProperties() {}
FILE *OpenDevice() {return NULL;}
/* ARGSUSED */
void CDLabelBB(p,a,b,c,d)
struct o *p;
int *a, *b, *c, *d;
{}
/*********************************************************************
*
* stream library
*
*********************************************************************/
struct STREAM_info streaminfo;
/***********************************************************************/
/* ******************************************************************* */
/* * * */
/* * The following functions will write a symbolic layout * */
/* * onto a disk file in STREAM format. The information may * */
/* * then be transfered to a magnetic tape by using the 'dd' * */
/* * system command. * */
/* * * */
/* * The order of the function calls is *not* arbitrary. * */
/* * The correct calling sequence is described below: * */
/* * * */
/* * 1) 'bgnlib' to begin library * */
/* * * */
/* * 2) 'bgnstr' to begin structure definition * */
/* * * */
/* * 3) 'bndry' or 'path' or 'sref' or 'aref' or 'text' * */
/* * or any combination thereof. * */
/* * * */
/* * 4) 'endstr' to end structure definition * */
/* * * */
/* * 5) 'endlib' to end library or 'bgnstr' to begin * */
/* * another structure definition * */
/* * * */
/* ******************************************************************* */
/***********************************************************************/
/***********************************************************************/
/* function STRM_BEGINRECORD */
/* Function to begin record on StreamFile. */
/* count = the number of bytes that will be contained within */
/* the record. */
/* type = the STREAM record type. */
/* datatype = the type of data contained in the STREAM record. */
/***********************************************************************/
void
strm_beginrecord(count, type, datatype)
int count;
int type;
int datatype;
{
/*
* count = number of bytes in record
* type = type of record
* datatype = type of data in data field
*/
strm_intcopy(count);
putc(type, StreamFile);
putc(datatype, StreamFile);
++streaminfo.rec_count;
streaminfo.byte_count += count;
}
/***********************************************************************/
/* function STRM_ADDATE */
/* Function to add date reference to the StreamFile. The date */
/* is stored in a 'tm' structure that is used by CTIME(3). */
/***********************************************************************/
void
strm_addate(datep)
struct tm *datep;
{
/*
* datep = pointer to the year spec. of the tm date structure.
*/
strm_intcopy(datep->tm_year);
strm_intcopy(datep->tm_mon);
strm_intcopy(datep->tm_mday);
strm_intcopy(datep->tm_hour);
strm_intcopy(datep->tm_min);
strm_intcopy(datep->tm_sec);
}
/***********************************************************************/
/* function STRM_ENTERASC_REC */
/* Function to enter a single ASCII record into StreamFile */
/* If 'conv' is set, conversion to upper case is performed. */
/***********************************************************************/
void
strm_entrasc_rec(cp, type, conv)
char *cp;
int type;
int conv;
{
int i = 0, j;
char c;
i = strlen(cp);
if (i & 1) ++i;
strm_beginrecord(i+4, type, 6);
for (j = 0; j < i; ++j) {
c = cp[j];
if (conv) {
if(c >= 'a' && c <= 'z')
c -= 32;
}
putc(c, StreamFile);
}
}
/***********************************************************************/
/* function STRM_ENTRASC */
/* Function to enter ascii string of 44 characters into the */
/* StreamFile. If 'conv' is set, conversion to upper case is */
/* performed. */
/***********************************************************************/
void
strm_entrasc(cp, conv)
char *cp;
int conv;
{
/*
* cp = pointer to character buffer.
*/
int i;
int n;
char c;
n = strlen(cp);
for (i = 0; i < n; ++i) {
c = *cp++;
if (conv) {
if (c >= 'a' && c <= 'z')
c -= 32;
}
putc(c, StreamFile);
}
for (i = n; i < 44; ++i)
putc('\0', StreamFile);
}
/***********************************************************************/
/* function BGNLIB */
/* Function to begin new library on the StreamFile. */
/***********************************************************************/
int
bgnlib(lib)
STRM_LIBRARY *lib;
{
int version = 3;
streaminfo.rec_count=0; /* initialize for new library */
streaminfo.struct_count=0;
streaminfo.byte_count=0;
streaminfo.level = 0;
strm_beginrecord(6, HEADER, 2);
strm_intcopy(version);
strm_beginrecord(28, BGNLIB, 2);
strm_addate(&(lib->lib_moddate));
strm_addate(&(lib->lib_accessdate));
strm_entrasc_rec(lib->lib_name, LIBNAME, TOUPR);
if (lib->lib_lib1[0] != '\0' || lib->lib_lib2[0] != '\0') {
strm_beginrecord(92, REFLIBS, 6);
strm_entrasc(lib->lib_lib1, TOUPR);
strm_entrasc(lib->lib_lib2, TOUPR);
}
if (lib->lib_font0[0] != '\0' || lib->lib_font1[0] != '\0'
|| lib->lib_font2[0] != '\0' || lib->lib_font3[0] != '\0') {
strm_beginrecord(180, FONTS, 6);
strm_entrasc(lib->lib_font0, TOUPR);
strm_entrasc(lib->lib_font1, TOUPR);
strm_entrasc(lib->lib_font2, TOUPR);
strm_entrasc(lib->lib_font3, TOUPR);
}
if (lib->lib_attr[0] != '\0')
strm_entrasc_rec(lib->lib_attr, ATTRTABLE, TOUPR);
strm_beginrecord(6, GENERATIONS, 2);
strm_intcopy(lib->lib_gen);
strm_beginrecord(20, UNITS, 5);
strm_dblcopy(lib->lib_uunit);
strm_dblcopy(lib->lib_munit);
return (0);
}
/***********************************************************************/
/* function ENDLIB */
/* Function to end library on the StreamFile. */
/***********************************************************************/
int
endlib()
{
int i, j;
if(streaminfo.level != 0 && streaminfo.test) return(-1);
strm_beginrecord(4, ENDLIB, 0);
/* pad with nulls */
i = (streaminfo.byte_count % 2048);
for(j = 0; j < i; ++j)
putc(0, StreamFile);
return(0);
}
/***********************************************************************/
/* function BGNSTR */
/* Function to structure definition in the StreamFile. */
/***********************************************************************/
int
bgnstr(strp)
STRM_STRCT *strp;
{
if(streaminfo.level != 0 && streaminfo.test) return(-1);
streaminfo.level = 1;
strm_beginrecord(28, BGNSTR, 2);
strm_addate(&(strp->str_creatdate));
strm_addate(&(strp->str_moddate));
strm_entrasc_rec(strp->str_name, STRNAME, TOUPR);
++streaminfo.struct_count;
return(0);
}
/***********************************************************************/
/* function ENDSTR */
/* Function to end structure on the StreamFile. */
/***********************************************************************/
int
endstr()
{
if(streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 0;
strm_beginrecord(4, ENDSTR, 0);
return(0);
}
/***********************************************************************/
/* function STRM_ENDLMNT */
/* Function to end element stream on the StreamFile. */
/***********************************************************************/
int
strm_endlmnt(propp)
STRM_PROPERTY *propp;
{
int i,k;
k = 0;
if (streaminfo.level != 2 && streaminfo.test) return(-1);
streaminfo.level = 1;
i = propp->prp_npropval;
while (i-- > 0) {
strm_beginrecord(6, PROPATTR, 2);
strm_intcopy(propp->prp_propattr[k]);
strm_entrasc_rec(propp->prp_propval[k++], PROPVALUE, 0);
}
strm_beginrecord(4, ENDEL, 0);
return (0);
}
/***********************************************************************/
/* function BNDRY */
/* Function to enter boundary element into the StreamFile. */
/***********************************************************************/
int
bndry(bndryp)
STRM_BOUNDARY *bndryp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return (-1);
streaminfo.level = 2;
strm_beginrecord(4, BOUNDARY, 0);
strm_beginrecord(6, LAYER, 2);
strm_intcopy(bndryp->bnd_layer);
strm_beginrecord(6, DATATYPE, 2);
strm_intcopy(bndryp->bnd_datatype);
if (bndryp->bnd_ncoord < 4) {
fprintf(stderr,"less than four boundary coordinates\n");
exit(1);
}
else {
strm_beginrecord(8 * bndryp->bnd_ncoord + 4, XY, 3);
for (i = 0; i < bndryp->bnd_ncoord + bndryp->bnd_ncoord; ++i) {
strm_lngcopy(bndryp->bnd_xy[i]);
}
}
i = strm_endlmnt(&(bndryp->bnd_prop));
return (i);
}
/***********************************************************************/
/* function STRM_STRNSFM */
/* Function to enter structure transformation record */
/***********************************************************************/
int
strm_strnsfm(trp)
STRM_TRANSFORM *trp;
{
int i;
i = 0;
if (trp->trns_reflection == 1) i |= 0100000;
if (trp->trns_abs_mag == 1) i |= 04;
if (trp->trns_abs_angle == 1) i |= 02;
strm_beginrecord(6, STRANS, 1);
strm_intcopy(i);
if (trp->trns_mag != 1) {
strm_beginrecord(12, MAG, 5);
strm_dblcopy(trp->trns_mag);
}
if (trp->trns_angle != 0) {
strm_beginrecord(12, ANGLE, 5);
strm_dblcopy(trp->trns_angle);
}
return (0);
}
/***********************************************************************/
/* function PATH */
/* Function to enter path element into the StreamFile. */
/***********************************************************************/
int
path(pathp)
STRM_PATH *pathp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, PATH, 0);
strm_beginrecord(6, LAYER, 2);
strm_intcopy(pathp->pth_layer);
strm_beginrecord(6, DATATYPE, 2);
strm_intcopy(pathp->pth_datatype);
strm_beginrecord(6, PATHTYPE, 2);
strm_intcopy(pathp->pth_pathtype);
strm_beginrecord(8, WIDTH, 3);
strm_lngcopy(pathp->pth_width);
if (pathp->pth_ncoord < 2) {
fprintf(stderr,"less than two path points\n");
exit(1);
}
else {
strm_beginrecord(8 * pathp->pth_ncoord + 4, XY, 3);
for (i = 0; i < pathp->pth_ncoord + pathp->pth_ncoord; ++i) {
strm_lngcopy(pathp->pth_xy[i]);
}
}
i = strm_endlmnt(&(pathp->pth_prop));
return (i);
}
/***********************************************************************/
/* function SREF */
/* Function to enter structure reference to the StreamFile. */
/***********************************************************************/
int
sref(srefp)
STRM_SREF *srefp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, SREF, 0); /* enter SREF record */
strm_entrasc_rec(srefp->sr_name, SNAME, TOUPR); /* enter SNAME record */
strm_strnsfm(&(srefp->sr_transform)); /* enter STRANS record */
strm_beginrecord(12, XY, 3); /* enter XY record */
strm_lngcopy(srefp->sr_xy[0]);
strm_lngcopy(srefp->sr_xy[1]);
i = strm_endlmnt(&(srefp->sr_prop));
return (i);
}
/***********************************************************************/
/* function AREF */
/* Function to enter array reference element in the StreamFile. */
/***********************************************************************/
int
aref(arefp)
STRM_AREF *arefp;
{
int *ip;
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, AREF, 0); /* enter AREF record */
strm_entrasc_rec(arefp->ar_name, SNAME, TOUPR); /* enter SNAME record */
strm_strnsfm(&(arefp->ar_transform)); /* enter STRANS record */
strm_beginrecord(8, COLROW, 2); /* enter COLROW record */
strm_intcopy(arefp->ar_col);
strm_intcopy(arefp->ar_row);
strm_beginrecord(28, XY, 3); /* enter XY record */
ip = arefp->ar_xy;
for (i = 1; i <= 6; ++i) {
strm_lngcopy(*ip);
++ip;
}
i = strm_endlmnt(&(arefp->ar_prop));
return (i);
}
/***********************************************************************/
/* function TEXT */
/* Function to enter text element into the StreamFile. */
/***********************************************************************/
int
text(textp)
STRM_TEXT *textp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, TEXT, 0); /* enter TEXT record */
strm_beginrecord(6, LAYER, 2); /* enter LAYER record */
strm_intcopy(textp->txt_layer);
strm_beginrecord(6, TEXTTYPE, 2); /* enter TEXTTYPE record */
strm_intcopy(textp->txt_texttype);
if (textp->txt_horizontal >= 0 && textp->txt_horizontal < 3) {
if (textp->txt_vertical >= 0 && textp->txt_vertical < 3) {
if (textp->txt_font >= 0 && textp->txt_font <= 3) {
i = textp->txt_horizontal + (textp->txt_vertical << 2)
+ (textp->txt_font << 4);
strm_beginrecord(6, PRESENTATION, 1);
strm_intcopy(i);
}
}
}
strm_beginrecord(6, PATHTYPE, 2); /* enter PATHTYPE record */
strm_intcopy(textp->txt_pathtype);
strm_beginrecord(8, WIDTH, 3);
strm_lngcopy(textp->txt_width);
strm_strnsfm(&(textp->txt_transform)); /* enter STRANS record */
strm_beginrecord(12, XY, 3); /* enter XY record */
strm_lngcopy(textp->txt_xy[0]);
strm_lngcopy(textp->txt_xy[1]);
strm_entrasc_rec(textp->txt_text, STRING, 0);
i = strm_endlmnt(&(textp->txt_prop));
return (i);
}
/*
* function STRM_INTCOPY
* Function to transfer the two bytes of a short integer to a
* Stream file. The most significant byte is sent first.
*/
void
strm_intcopy(i)
int i;
{
putc((char)((i >> 8) & 0xff),StreamFile);
putc((char)(i & 0xff),StreamFile);
}
/*
* function STRM_LNGCOPY
* Function to transfer the four bytes of a long integer to a
* Stream file. The most significant byte is sent first.
*/
void
strm_lngcopy(i)
int i;
{
putc((char)((i >> 24) & 0xff),StreamFile);
putc((char)((i >> 16) & 0xff),StreamFile);
putc((char)((i >> 8) & 0xff),StreamFile);
putc((char)((i) & 0xff),StreamFile);
}
/*
* function STRM_DBLCOPY
* Function to transfer double precision number to a character buffer.
* The first character of the buffer will contain the exponent field,
* the second character will contain the most significant byte of the
* mantissa field, etc.
*
*
* VAX's double precision field:
*
* Mantissa is base 2 (1/2 <= mantissa < 1). Exponent is excess-128.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFEEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
*
* CALMA's double precision field:
*
* Mantissa is base 16 (1/16 <= mantissa < 1). Exponent is excess-64.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFFEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
* where E = exponent field
* S = sign bit
* F = fraction field
* FL = least sig. bit of word or byte
* FM = most sig. bit of word or byte
*/
/*
* This routine is really inefficient, but there are typically few
* conversions required and portability is an issue.
*/
void
strm_dblcopy(r)
double r;
{
int i, exp, sign;
unsigned char b[8];
if (r == 0.0) {
for (i = 0; i < 8; i++)
b[i] = 0;
goto xfer;
}
sign = 0;
if (r < 0) {
sign = 1;
r = -r;
}
/* normalize to 1/16 < r <= 1 */
i = 0;
if (r >= 1.0) {
while (r >= 1.0) {
r /= 16.0;
i++;
}
if (i > 63) {
/* overflow */
for (i = 0; i < 8; i++)
b[i] = 0xff;
if (!sign)
b[0] &= 0x7f;
goto xfer;
}
exp = i + 64;
}
else if (r < 1/16.0) {
while (r < 1/16.0 && i < 64) {
r *= 16.0;
i++;
}
if (i > 63) {
/* underflow */
for (i = 0; i < 8; i++)
b[i] = 0;
goto xfer;
}
exp = 64 - i;
}
else
exp = 64;
for (i = 1; i <= 7; i++) {
r *= 256.0;
b[i] = r;
r -= b[i];
}
b[0] = exp;
if (sign)
b[0] |= 0x80;
xfer:
/* transfer bytes to char buffer */
putc(b[0], StreamFile);
putc(b[1], StreamFile);
putc(b[2], StreamFile);
putc(b[3], StreamFile);
putc(b[4], StreamFile);
putc(b[5], StreamFile);
putc(b[6], StreamFile);
putc(b[7], StreamFile);
}
/***** Alias For DOS **************************************************/
#ifdef MSDOS
/* Convert back to original stream structure names, if alias file is
* present.
*/
struct aliastab *aliasbase;
char *
unalias(dosname)
char *dosname;
{
int i;
struct aliastab *wl;
for (i = 0,wl = aliasbase; wl; wl = wl->next) {
if (!strcasecmp(dosname,wl->dosname))
return (wl->strname);
}
return (dosname);
}
void
readalias()
{
FILE *fp;
char s[80], *c;
struct aliastab *wl;
if ((fp = fopen(ALIASFILE,"r")) == NULL) return;
printf("Using alias file\n");
while (fgets(s,80,fp) != NULL) {
if (!aliasbase) {
aliasbase = (struct aliastab *) tmalloc(sizeof(struct aliastab));
wl = aliasbase;
}
else {
wl->next = (struct aliastab *) tmalloc(sizeof(struct aliastab));
wl = wl->next;
}
for (c = s; isspace(*c); c++) ;
if (*c == '\0') break;
if (sscanf(s,"%s %s",wl->dosname,wl->strname) != 2) {
aliasbase = NULL;
fclose(fp);
return;
}
}
wl->next = NULL;
fclose(fp);
}
#endif
/***** Memory Allocation ***********************************************/
char *
tmalloc(x)
unsigned x;
{
char *c = (char*)malloc(x);
if (c == NULL)
fprintf(stderr,"Out of memory");
return (c);
}
kic-2.4c/src/bin/helpmain.c 0000644 0000764 0000764 00000014561 12427254723 015233 0 ustar stevew stevew
/*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
/*
* The main routine for the help system in stand-alone mode.
*/
#include "prefix.h"
#include "hlpdefs.h"
#include
#include
#ifdef HAVE_SYS_IOCTL_H
#include
#endif
#ifdef WIN32
#include
#endif
#if __STDC__
static void moreprompt(void);
extern void cprint(int,char*);
static int getattr(void);
#else
static void moreprompt();
extern void cprint();
static int getattr();
#endif
int xsize;
int ysize;
int
main(ac, av)
int ac;
char **av;
{
#ifdef TIOCGWINSZ
struct winsize ws;
(void) ioctl(fileno(stdout), TIOCGWINSZ, (char *) &ws);
xsize = ws.ws_col;
ysize = ws.ws_row;
#else
#ifdef WIN32
if (!xsize || !ysize) {
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (h != INVALID_HANDLE_VALUE) {
CONSOLE_SCREEN_BUFFER_INFO sbi;
if (GetConsoleScreenBufferInfo(h, &sbi)) {
xsize = sbi.dwSize.X;
ysize = sbi.dwSize.Y;
}
}
}
#endif
#endif
if (!xsize) xsize = 80;
if (!ysize) ysize = 23;
InitGlobal();
HELPPATH = PATH_TO_HELP;
cp_in = stdin;
cp_out = stdout;
cp_err = stderr;
if (ac > 1)
hlp_main(HELPPATH,av[1]);
else
hlp_main(HELPPATH,"help");
return (0);
}
FILE *OpenDevice() {return NULL;}
void
fatal(s)
char *s;
{
fprintf(stderr, "fatal error: %s\n", s);
exit(1);
}
void
cp_printword(s)
char *s;
{
printf("%s", s);
return;
}
/* ARGSUSED */
bool
cp_getvar(n, t, r)
char *n, *r;
int t;
{
return (false);
}
char *
GetString(s,n,fp,p)
char *s;
int n;
FILE *fp;
char *p;
{ return fgets(s,n,fp); }
int noprint,nopause,xpos,ypos;
void
out_init()
{
xpos = ypos = 0;
}
void
PutString(string)
char *string;
{
if (noprint) return;
if (nopause) {
fputs(string, cp_out);
return;
}
while (*string) {
switch (*string) {
case '\n':
xpos = 0;
ypos++;
break;
case '\f':
ypos = ysize;
xpos = 0;
break;
case '\t':
xpos = xpos / 8 + 1;
xpos *= 8;
break;
default:
xpos++;
break;
}
if (xpos >= xsize) {
xpos -= xsize;
ypos++;
(void) putc('\n',cp_out);
}
else {
(void) putc(*string, cp_out);
string++;
}
moreprompt();
}
}
void
PutErrorString(string)
char *string;
{
fputs(string,cp_err);
}
void
PutBoldString(string)
char *string;
{
fputs(string,cp_out);
}
static void
moreprompt()
{
short key;
char *xx, attr;
char *menu =
"\nPossible responses:\n\
q : Discard the rest of the output.\n\
c : Continuously print the rest of the output.\n\
h,? : Print this help message.\n\
other : Print the next page of output.\n";
if (ypos >= ysize) {
attr = getattr();
for (;;) {
xx = " -- More -- (h for help) ";
if (cp_out == stdout)
cprint(4,xx);
else {
(void) fprintf(cp_out,"%s",xx);
(void) fflush(cp_out);
}
#ifdef MSDOS
while (!(key = getch()));
#else
key = getc(cp_in);
#endif
if (cp_out == stdout)
cprint(attr,"\r \r");
if (key == 'q') {noprint = true; break;}
if (key == 'c') {nopause = true; break;}
if (key == 'h' || key == '?') {
if (cp_out == stdout) {
cprint(2,menu);
cprint(attr," \n"); /* keeps the cursor the attr color */
}
else
(void) fprintf(cp_out,"%s",menu);
continue;
}
break;
}
if (cp_out != stdout) {
(void) putc('\n',cp_out);
(void) fflush(cp_out);
}
ypos = xpos = 0;
}
}
char *
tmalloc(x)
unsigned x;
{
char *c = (char*)malloc(x);
if (c == NULL) {
fprintf(cp_err,"Out of memory.\n");
exit(1);
}
memset(c,0,x);
return (c);
}
#ifdef MSDOS
/*************************************************************************
Graphics and miscellaneous library for protected mode MSDOS.
Copyright (c) Stephen R. Whiteley 1992
Author: Stephen R. Whiteley
*************************************************************************/
#include
#include
#if __NDPC__
#define REGS REGS16
#endif
#ifdef __STDC__
static short getpage(void);
#else
static short getpage();
#endif
void
cprint(clr,buf)
/* print buf in color clr */
int clr;
char *buf;
{
union REGS r;
while (*buf) {
/* change attribute by printing space */
r.x.bx = getpage() + clr & 0xff;
r.x.cx = 1;
r.x.ax = 0x0900 + ' ';
int86(0x10,&r,&r);
/* now print character, advance cursor */
r.x.bx = getpage();
r.x.ax = 0x0e00 + *buf;
int86(0x10,&r,&r);
/* special case, go to beginning of line */
if (*buf == '\n') {
r.x.bx = getpage();
r.x.ax = 0x0e00 + '\r';
int86(0x10,&r,&r);
}
buf++;
}
}
static int
getattr()
/* return the attribute at current position */
{
union REGS r;
r.x.bx = getpage();
r.x.ax = 0x0800;
int86(0x10,&r,&r);
return (r.x.ax >> 8);
}
static short
getpage()
/* return the current display page in upper byte */
{
union REGS r;
r.x.ax = 0x0f00;
int86(0x10,&r,&r);
return (r.x.bx & 0xff00);
}
#else
void
cprint(i,s)
int i;
char *s;
{
(void) fprintf(cp_out,"%s",s);
(void) fflush(cp_out);
}
static int
getattr()
{
return (0);
}
#endif
kic-2.4c/src/bin/kicmain.c 0000644 0000764 0000764 00000115450 12427260512 015041 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Main procedure for KIC.
*/
#ifdef WIN32
#include
#endif
#include "prefix.h"
#include "kic.h"
#include "hlpdefs.h"
#include
#define MAXCELLS 80 /* max number of cell names on the arg list */
static char *CellNames[MAXCELLS]; /* Cell names in argumnet list */
static int CurrentCell; /* Current cell in argument list */
static int NumCells; /* Number of cells in argument list */
#define Matching(string) !strcmp(Parameters.kpCommand,string)
/***********************************************************************
*
* Menu definition package;
*
***********************************************************************/
#ifdef __STDC__
static void init_basic_menu(void);
static void init_attribute_menu(void);
static void init_debug_menu(void);
static void init_property_menu(void);
#else
static void init_basic_menu();
static void init_attribute_menu();
static void init_debug_menu();
static void init_property_menu();
#endif
MENU *BasicMenu;
MENU *AttributeMenu;
MENU *DebugMenu;
MENU *PropertyMenu;
MENU AmbiguityMenu[81];
char *Menu0;
char *Menu90;
char *Menu180;
char *Menu270;
char *MenuMINSB;
char *MenuMINSG;
char *MenuMINSR;
char *MenuPLUSB;
char *MenuPLUSG;
char *MenuPLUSR;
char *Menu45S;
char *MenuADLYR;
char *MenuADPRP;
char *MenuALLOC;
char *MenuARC;
char *MenuAREA;
char *MenuARRAY;
char *MenuATTRI;
char *MenuBASIC;
char *MenuBLINK;
char *MenuBOXES;
char *MenuBREAK;
char *MenuBW;
char *MenuCHLYR;
char *MenuCNAMS;
char *MenuCNTXT;
char *MenuCNVRT;
char *MenuCOLOR;
char *MenuCOPY;
char *MenuCRSYM;
char *MenuCURSR;
char *MenuDEBUG;
char *MenuDELET;
char *MenuDESEL;
char *MenuDIMEN;
char *MenuDIR;
char *MenuDONUT;
char *MenuEDIT;
char *MenuERASE;
char *MenuEXIT;
char *MenuEXPND;
char *MenuFILL;
char *MenuFLASH;
char *MenuFLATN;
char *MenuFONT;
char *MenuGRID;
char *MenuHCOPY;
char *MenuHELP;
char *MenuLABEL;
char *MenuLABLS;
char *MenuLAST;
char *MenuLAYER;
char *MenuLLREF;
char *MenuLOGO;
char *MenuMARK;
char *MenuMOVE;
char *MenuMX;
char *MenuMY;
char *MenuPAN;
char *MenuPEEK;
char *MenuPLACE;
char *MenuPOLYG;
char *MenuPOP;
char *MenuPRPTY;
char *MenuPUSH;
char *MenuRDRAW;
char *MenuRGB;
char *MenuRL;
char *MenuRMOVE;
char *MenuRMPRP;
char *MenuSAVE;
char *MenuSELEC;
char *MenuSHOW;
char *MenuSIDES;
char *MenuSNAP;
char *MenuSTBOX;
char *MenuSTRCH;
char *MenuTB;
char *MenuTBRL;
char *MenuUNDO;
char *MenuUPDAT;
char *MenuVIEW;
char *MenuVISIB;
char *MenuWIDTH;
char *MenuWINDO;
char *MenuWIRES;
char *MenuXOR;
char *MenuZOOM;
static char *MenuSpace;
void
InitMenus()
{
Menu0 = "0 ";
Menu90 = "90 ";
Menu180 = "180 ";
Menu270 = "270 ";
MenuMINSB = "-b ";
MenuMINSG = "-g ";
MenuMINSR = "-r ";
MenuPLUSB = "+b ";
MenuPLUSG = "+g ";
MenuPLUSR = "+r ";
Menu45S = "45s ";
MenuADLYR = "adlyr";
MenuADPRP = "adprp";
MenuALLOC = "alloc";
MenuARC = "arc ";
MenuAREA = "area ";
MenuARRAY = "array";
MenuATTRI = "attri";
MenuBASIC = "basic";
MenuBLINK = "blink";
MenuBOXES = "boxes";
MenuBREAK = "break";
MenuBW = "bw ";
MenuCHLYR = "chlyr";
MenuCNAMS = "cnams";
MenuCNTXT = "cntxt";
MenuCNVRT = "cnvrt";
MenuCOLOR = "color";
MenuCOPY = "copy ";
MenuCRSYM = "crsym";
MenuCURSR = "cursr";
MenuDEBUG = "debug";
MenuDELET = "delet";
MenuDESEL = "desel";
MenuDIMEN = "dimen";
MenuDIR = "dir ";
MenuDONUT = "donut";
MenuEDIT = "edit ";
MenuEXIT = "quit ";
MenuERASE = "erase";
MenuEXPND = "expnd";
MenuFILL = "fill ";
MenuFLASH = "flash";
MenuFLATN = "flatn";
MenuFONT = "font ";
MenuGRID = "grid ";
MenuHCOPY = "hcopy";
MenuHELP = "help ";
MenuLABEL = "label";
MenuLABLS = "labls";
MenuLAST = "last ";
MenuLAYER = "layer";
MenuLLREF = "llref";
MenuLOGO = "logo ";
MenuMARK = "mark ";
MenuMOVE = "move ";
MenuMX = "mx ";
MenuMY = "my ";
MenuPAN = "pan ";
MenuPEEK = "peek ";
MenuPLACE = "place";
MenuPOLYG = "polyg";
MenuPOP = "pop ";
MenuPRPTY = "prpty";
MenuPUSH = "push ";
MenuRDRAW = "rdraw";
MenuRGB = "rgb ";
MenuRL = "rl ";
MenuRMOVE = "rmove";
MenuRMPRP = "rmprp";
MenuSAVE = "save ";
MenuSELEC = "selec";
MenuSHOW = "show ";
MenuSIDES = "sides";
MenuSNAP = "snap ";
MenuSTRCH = "strch";
MenuTB = "tb ";
MenuTBRL = "tbrl ";
MenuUNDO = "undo ";
MenuUPDAT = "updat";
MenuVIEW = "view ";
MenuVISIB = "visib";
MenuWIDTH = "width";
MenuWINDO = "windo";
MenuWIRES = "wires";
MenuXOR = "xor ";
MenuZOOM = "zoom ";
MenuSpace = " ";
init_basic_menu();
init_attribute_menu();
init_debug_menu();
init_property_menu();
}
int NumBasicMenu = 60;
static void
init_basic_menu()
{
int i = 0;
if (BasicMenu == NULL)
BasicMenu = (MENU *) tmalloc(NumBasicMenu*sizeof(MENU));
memset(BasicMenu,0,NumBasicMenu*sizeof(MENU));
BasicMenu[i++].mEntry = MenuHELP;
BasicMenu[i++].mEntry = MenuATTRI;
BasicMenu[i++].mEntry = MenuEDIT;
BasicMenu[i++].mEntry = MenuDIR;
BasicMenu[i++].mEntry = MenuSAVE;
BasicMenu[i++].mEntry = MenuCNVRT;
BasicMenu[i++].mEntry = MenuPRPTY;
BasicMenu[i++].mEntry = MenuDEBUG;
BasicMenu[i++].mEntry = MenuEXIT;
BasicMenu[i++].mEntry = MenuSpace;
BasicMenu[i++].mEntry = MenuEXPND;
BasicMenu[i++].mEntry = MenuPEEK;
BasicMenu[i++].mEntry = MenuPAN;
BasicMenu[i++].mEntry = MenuZOOM;
BasicMenu[i++].mEntry = MenuWINDO;
BasicMenu[i++].mEntry = MenuVIEW;
BasicMenu[i++].mEntry = MenuLAST;
BasicMenu[i++].mEntry = MenuRDRAW;
BasicMenu[i++].mEntry = MenuGRID;
BasicMenu[i++].mEntry = MenuSNAP;
BasicMenu[i++].mEntry = MenuSpace;
BasicMenu[i++].mEntry = MenuBOXES;
BasicMenu[i++].mEntry = MenuLABEL;
BasicMenu[i++].mEntry = MenuWIRES;
BasicMenu[i++].mEntry = MenuWIDTH;
BasicMenu[i++].mEntry = Menu45S;
BasicMenu[i++].mEntry = MenuPOLYG;
BasicMenu[i++].mEntry = MenuDONUT;
BasicMenu[i++].mEntry = MenuFLASH;
BasicMenu[i++].mEntry = MenuARC;
BasicMenu[i++].mEntry = MenuSpace;
BasicMenu[i++].mEntry = MenuMOVE;
BasicMenu[i++].mEntry = MenuCOPY;
BasicMenu[i++].mEntry = MenuUNDO;
BasicMenu[i++].mEntry = MenuSpace;
BasicMenu[i++].mEntry = MenuLAYER;
BasicMenu[i++].mEntry = MenuAREA;
BasicMenu[i++].mEntry = MenuSELEC;
BasicMenu[i++].mEntry = MenuDESEL;
BasicMenu[i++].mEntry = MenuCHLYR;
BasicMenu[i++].mEntry = MenuDELET;
BasicMenu[i++].mEntry = MenuSTRCH;
BasicMenu[i++].mEntry = MenuTBRL;
BasicMenu[i++].mEntry = MenuERASE;
BasicMenu[i++].mEntry = MenuXOR;
BasicMenu[i++].mEntry = MenuBREAK;
BasicMenu[i++].mEntry = MenuMX;
BasicMenu[i++].mEntry = MenuMY;
BasicMenu[i++].mEntry = Menu0;
BasicMenu[i++].mEntry = MenuSpace;
BasicMenu[i++].mEntry = MenuPLACE;
BasicMenu[i++].mEntry = MenuLLREF;
BasicMenu[i++].mEntry = MenuARRAY;
BasicMenu[i++].mEntry = MenuCRSYM;
BasicMenu[i++].mEntry = MenuFLATN;
BasicMenu[i++].mEntry = MenuPUSH;
BasicMenu[i++].mEntry = MenuCNTXT;
BasicMenu[i++].mEntry = MenuPOP;
BasicMenu[i++].mEntry = MenuLOGO;
BasicMenu[i++].mEntry = NULL;
}
static void
init_attribute_menu()
{
int i = 0;
int NumAttributeMenu = 33;
if (AttributeMenu == NULL)
AttributeMenu = (MENU *) tmalloc(NumAttributeMenu*sizeof(MENU));
memset(AttributeMenu,0,NumAttributeMenu*sizeof(MENU));
AttributeMenu[i++].mEntry = MenuHELP;
AttributeMenu[i++].mEntry = MenuBASIC;
AttributeMenu[i++].mEntry = MenuSpace;
AttributeMenu[i++].mEntry = MenuPAN;
AttributeMenu[i++].mEntry = MenuZOOM;
AttributeMenu[i++].mEntry = MenuRDRAW;
AttributeMenu[i++].mEntry = MenuSpace;
AttributeMenu[i++].mEntry = MenuLABLS;
AttributeMenu[i++].mEntry = MenuCNAMS;
AttributeMenu[i++].mEntry = MenuMARK;
AttributeMenu[i++].mEntry = MenuGRID;
AttributeMenu[i++].mEntry = MenuSIDES;
AttributeMenu[i++].mEntry = MenuFONT;
AttributeMenu[i++].mEntry = MenuCURSR;
AttributeMenu[i++].mEntry = MenuDIMEN;
AttributeMenu[i++].mEntry = MenuVISIB;
AttributeMenu[i++].mEntry = MenuADLYR;
AttributeMenu[i++].mEntry = MenuRMOVE;
AttributeMenu[i++].mEntry = MenuSpace;
AttributeMenu[i++].mEntry = MenuUPDAT;
AttributeMenu[i++].mEntry = MenuHCOPY;
AttributeMenu[i++].mEntry = MenuSpace;
AttributeMenu[i++].mEntry = MenuFILL;
AttributeMenu[i++].mEntry = MenuCOLOR;
AttributeMenu[i++].mEntry = MenuSpace;
AttributeMenu[i++].mEntry = MenuPLUSR;
AttributeMenu[i++].mEntry = MenuMINSR;
AttributeMenu[i++].mEntry = MenuPLUSG;
AttributeMenu[i++].mEntry = MenuMINSG;
AttributeMenu[i++].mEntry = MenuPLUSB;
AttributeMenu[i++].mEntry = MenuMINSB;
AttributeMenu[i++].mEntry = MenuRGB;
AttributeMenu[i++].mEntry = NULL;
}
static void
init_debug_menu()
{
int i = 0;
int NumDebugMenu = 7;
if (DebugMenu == NULL)
DebugMenu = (MENU *) tmalloc(NumDebugMenu*sizeof(MENU));
memset(DebugMenu,0,NumDebugMenu*sizeof(MENU));
DebugMenu[i++].mEntry = MenuHELP;
DebugMenu[i++].mEntry = MenuSpace;
DebugMenu[i++].mEntry = MenuBASIC;
DebugMenu[i++].mEntry = MenuSpace;
DebugMenu[i++].mEntry = MenuBW;
DebugMenu[i++].mEntry = MenuALLOC;
DebugMenu[i++].mEntry = NULL;
}
static void
init_property_menu()
{
int i = 0;
int NumPropertyMenu = 13;
if (PropertyMenu == NULL)
PropertyMenu = (MENU *) tmalloc(NumPropertyMenu*sizeof(MENU));
memset(PropertyMenu,0,NumPropertyMenu*sizeof(MENU));
PropertyMenu[i++].mEntry = MenuHELP;
PropertyMenu[i++].mEntry = MenuSpace;
PropertyMenu[i++].mEntry = MenuBASIC;
PropertyMenu[i++].mEntry = MenuSpace;
PropertyMenu[i++].mEntry = MenuLAYER;
PropertyMenu[i++].mEntry = MenuAREA;
PropertyMenu[i++].mEntry = MenuSELEC;
PropertyMenu[i++].mEntry = MenuDESEL;
PropertyMenu[i++].mEntry = MenuSpace;
PropertyMenu[i++].mEntry = MenuSHOW;
PropertyMenu[i++].mEntry = MenuADPRP;
PropertyMenu[i++].mEntry = MenuRMPRP;
PropertyMenu[i++].mEntry = NULL;
}
int
main(argc,argv)
int argc;
char *argv[];
{
int Int1;
char *Tech;
CurrentCell = 0;
NumCells = 0;
/* partial initialization */
Parameters.kpMenu = BASICMENU;
#ifndef USE_OLD_MALLOC
nm_set_block_size(NMALLOC_BLOCK_SIZE);
#endif
#ifdef WIN32
{
// If started from an icon, ditch the console
char *t;
STARTUPINFO si;
GetStartupInfo(&si);
if (!si.lpTitle ||
((t = strrchr(si.lpTitle, '.')) != 0 && !strcasecmp(t, ".lnk")))
FreeConsole();
}
#endif
FB.fInitialized = False;
FB.fDisplay = CopyString(getenv("DISPLAY"));
for (Int1 = 1; Int1 < argc; ++Int1) {
if (*argv[Int1] == '-' && *(argv[Int1]+1) == 'd') {
++argv[Int1];
if (*(++argv[Int1]) == '\0')
FB.fDisplay = argv[++Int1];
else
FB.fDisplay = argv[Int1];
}
else if (*argv[Int1] == '-' && *(argv[Int1]+1) == 't') {
if (*(argv[Int1]+2) == '\0')
Tech = argv[++Int1];
else
Tech = argv[Int1]+2;
#ifdef MSDOS
if (strlen(Tech) > 3)
Tech[3] = '\0';
#endif
TECH_EXT = malloc(strlen(Tech) + 1);
if (TECH_EXT == NULL)
fatal_error("Memory allocation failure.");
strcpy(TECH_EXT,Tech);
}
else
CellNames[NumCells++] = argv[Int1];
if (NumCells >= MAXCELLS) {
fprintf(stderr,"Too many file names.\n");
NumCells = MAXCELLS - 1;
#ifdef WIN32
Sleep(3000);
#else
sleep(3);
#endif
break;
}
}
CellNames[NumCells] = NULL;
InitGlobal();
Init();
/* Edit default cell name if no command line cell */
if (!NumCells) {
NumCells++;
CellNames[0] = DEFAULT_EDIT_FILE;
CellNames[1] = NULL;
}
if (NumCells) strcpy(Parameters.kpCellName,CellNames[CurrentCell]);
InitMenus();
KICMain();
return (0);
}
void
KICMain()
{
int LookedAhead = False;
char *TypeIn;
InitVLT();
FBForeground(ERASE,0);
FBFlood();
Basic((int*)&TypeIn); /* dummy variable */
ShowLayerTable();
Edit(True,True,False);
loop {
InitSignals();
if (Not LookedAhead)
Point();
else
LookedAhead = False;
if (Parameters.kpCellName[0] == EOS) {
/*
* The CD package doesn't check the integrity of symbol
* descriptors and now Parameters.kpCellDesc == NULL.
* Except for a few commands, each command invokes the
* CD package. If such a command is invoked now, the
* CD package will crash and thus KIC will. So, force user
* to select a cell to edit before invoking any such command.
*/
if (Not (Matching(MenuEDIT) Or Matching(MenuDEBUG) Or
Matching(MenuDIR) Or Matching(MenuEXIT) Or
Matching(MenuHELP))) {
ShowPrompt("You haven't selected a cell to edit.");
continue;
}
}
if (SafeCmds(&LookedAhead)) continue;
if (Matching(MenuEXIT)) { AbortKIC(); continue; }
if (Matching(MenuADLYR)) { AddLayer(); continue; }
if (Matching(MenuADPRP)) { AddProperty(); continue; }
if (Matching(MenuARC)) { Arcs(&LookedAhead); continue; }
if (Matching(MenuAREA)) { Area(&LookedAhead); continue; }
if (Matching(MenuATTRI)) { Attri(&LookedAhead); continue; }
if (Matching(MenuBASIC)) { Basic(&LookedAhead); continue; }
if (Matching(MenuBOXES)) { Boxes(&LookedAhead); continue; }
if (Matching(MenuBREAK)) { Break(&LookedAhead); continue; }
if (Matching(MenuCHLYR)) { ChangeLayer(&LookedAhead); continue; }
if (Matching(MenuCOPY)) { Copy(&LookedAhead); continue; }
if (Matching(MenuCRSYM)) { NewSymbol(); continue; }
if (Matching(MenuDELET)) { Del(&LookedAhead); continue; }
if (Matching(MenuDESEL)) { Desel(); continue; }
if (Matching(MenuDONUT)) { Doughnut(&LookedAhead); continue; }
if (Matching(MenuEDIT)) { Edit(False,True,False); continue; }
if (Matching(MenuERASE)) { Erase(&LookedAhead); continue; }
if (Matching(MenuFLASH)) { Flash(&LookedAhead); continue; }
if (Matching(MenuFLATN)) { Flatten(&LookedAhead); continue; }
if (Matching(MenuLABEL)) { Label(&LookedAhead); continue; }
if (Matching(MenuLOGO)) { Logo(&LookedAhead); continue; }
if (Matching(MenuMOVE)) { Move(&LookedAhead); continue; }
if (Matching(MenuPLACE)) { Place(&LookedAhead); continue; }
if (Matching(MenuPOLYG)) { Polygons(&LookedAhead); continue; }
if (Matching(MenuPOP)) { Pop(); continue; }
if (Matching(MenuPRPTY)) { Properties(&LookedAhead); continue; }
if (Matching(MenuPUSH)) { Push(&LookedAhead); continue; }
if (Matching(MenuRMOVE)) { RemoveLayer(&LookedAhead); continue; }
if (Matching(MenuRMPRP)) { RemoveProperty(); continue; }
if (Matching(MenuSAVE)) { WriteCell(); continue; }
if (Matching(MenuSELEC)) { Sel(&LookedAhead); continue; }
if (Matching(MenuSHOW)) { DoShowProperties(); continue; }
if (Matching(MenuSTRCH)) { Stretch(&LookedAhead); continue; }
if (Matching(MenuUNDO)) { Undo(); continue; }
if (Matching(MenuUPDAT)) { Updat(); continue; }
if (Matching(MenuWIDTH)) { Width(&LookedAhead); continue; }
if (Matching(MenuWIRES)) { Wires(&LookedAhead); continue; }
if (Matching(MenuXOR)) { XORbox(&LookedAhead); continue; }
}
}
int
SafeCmds(LookedAhead)
int *LookedAhead;
{
if (Matching(Menu0)) { Rotat0(); return True; }
if (Matching(Menu90)) { Rotat90(); return True; }
if (Matching(Menu180)) { Rotat180(); return True; }
if (Matching(Menu270)) { Rotat270(); return True; }
if (Matching(Menu45S)) { DoSet45(); return True; }
if (Matching(MenuALLOC)) { DoAlloc(); return True; }
if (Matching(MenuARRAY)) { GetArraySpec(); return True; }
if (Matching(MenuBLINK)) { Blink(LookedAhead); return True; }
if (Matching(MenuBW)) { DoBW(); return True; }
if (Matching(MenuCNTXT)) { ShowContext(); return True; }
if (Matching(MenuCNVRT)) { Convert(); return True; }
if (Matching(MenuCNAMS)) { LabelInstances(); return True; }
if (Matching(MenuCOLOR)) { AttribColor(LookedAhead); return True; }
if (Matching(MenuCURSR)) { SelectKicCursor(); return True; }
if (Matching(MenuDEBUG)) { Debug(LookedAhead); return True; }
if (Matching(MenuDIMEN)) { Dimen(LookedAhead); return True; }
if (Matching(MenuDIR)) { Dir(); return True; }
if (Matching(MenuEXPND)) { Expand(); return True; }
if (Matching(MenuFILL)) { Fill(LookedAhead); return True; }
if (Matching(MenuFONT)) { SelectKicFont(); return True; }
if (Matching(MenuGRID)) { SetGrid(LookedAhead); return True; }
if (Matching(MenuHCOPY)) { Hcopy(); return True; }
if (Matching(MenuHELP)) { Help(); return True; }
if (Matching(MenuLABLS)) { DisplayLabels(); return True; }
if (Matching(MenuLAST)) { LastView(); return True; }
if (Matching(MenuLAYER)) { Layer(); return True; }
if (Matching(MenuLLREF)) { Handle(); return True; }
if (Matching(MenuMARK)) { Mark(); return True; }
if (Matching(MenuMINSB)) { SetColor('b','-'); return True; }
if (Matching(MenuMINSG)) { SetColor('g','-'); return True; }
if (Matching(MenuMINSR)) { SetColor('r','-'); return True; }
if (Matching(MenuMX)) { MX(); return True; }
if (Matching(MenuMY)) { MY(); return True; }
if (Matching(MenuPAN)) { Pan(LookedAhead); return True; }
if (Matching(MenuPEEK)) { Peek(); return True; }
if (Matching(MenuPLUSB)) { SetColor('b','+'); return True; }
if (Matching(MenuPLUSG)) { SetColor('g','+'); return True; }
if (Matching(MenuPLUSR)) { SetColor('r','+'); return True; }
if (Matching(MenuRDRAW)) { Rdraw(); return True; }
if (Matching(MenuRGB)) { ShowRGB(); return True; }
if (Matching(MenuRL)) { SetStretchMode(); return True; }
if (Matching(MenuSIDES)) { Sides(); return True; }
if (Matching(MenuSNAP)) { Snap(); return True; }
if (Matching(MenuTB)) { SetStretchMode(); return True; }
if (Matching(MenuTBRL)) { SetStretchMode(); return True; }
if (Matching(MenuVIEW)) { ShowFull(); return True; }
if (Matching(MenuVISIB)) { Visib(LookedAhead); return True; }
if (Matching(MenuWINDO)) { Windo(LookedAhead); return True; }
if (Matching(MenuZOOM)) { Zoom(LookedAhead); return True; }
return False;
}
char
*NextCellName()
{
if (++CurrentCell >= NumCells) {
if (NumCells > 0) {
--CurrentCell;
ShowPromptAndWait("No more cells to edit.");
}
else
ShowPromptAndWait("No current cell name.");
return NULL;
}
else
return CellNames[CurrentCell];
}
void
SaveTechFile()
{
char String[161];
int Layer,i;
FILE *TechFileDesc;
struct eparms *e;
#ifdef CIFPLOT
char *patbuf;
FILE *cifplot;
FILE *patterns;
int n;
#endif
if (TECH_EXT)
sprintf(String,"%s.%s",TECHNAME,TECH_EXT);
else
strcpy(String,TECHNAME);
if ((TechFileDesc = fopen(String,"w")) == NULL) {
sprintf(TypeOut,"Can't write %s file.",String);
ShowPrompt(TypeOut);
return;
}
/* print path */
fprintf(TechFileDesc,"Path? ( %s ) \n",PGetPath());
fprintf(TechFileDesc,"\n");
for (Layer = 1; Layer <= NumLayerTable; ++Layer) {
/*
* LayerName?
*/
fprintf(TechFileDesc,"LayerName? %c%c%c%c\n",
LayerTable[Layer].klTechnology ,
LayerTable[Layer].klMask[0] ,
LayerTable[Layer].klMask[1] ,
LayerTable[Layer].klMask[2] );
/*
* RGB?
*/
fprintf(TechFileDesc,"RGB? %d %d %d\n",LayerTable[Layer].klR,
LayerTable[Layer].klG,LayerTable[Layer].klB);
/*
* Symbolic?
*/
if (LayerTable[Layer].klAttributes & SYMBOLIC)
fprintf(TechFileDesc,"Symbolic? y\n");
else
fprintf(TechFileDesc,"Symbolic? n\n");
/*
* Filled?
*/
fprintf(TechFileDesc,"Filled?");
if (!(LayerTable[Layer].klAttributes & FILLED))
fprintf(TechFileDesc," n\n");
else {
if (LayerTable[Layer].klStyle[0] == 0 And
LayerTable[Layer].klStyle[1] == 0 And
LayerTable[Layer].klStyle[2] == 0 And
LayerTable[Layer].klStyle[3] == 0 And
LayerTable[Layer].klStyle[4] == 0 And
LayerTable[Layer].klStyle[5] == 0 And
LayerTable[Layer].klStyle[6] == 0 And
LayerTable[Layer].klStyle[7] == 0 ) {
fprintf(TechFileDesc," y\n");
}
else {
for (i=0; i<8; ++i)
fprintf(TechFileDesc," %02x",
LayerTable[Layer].klStyle[i]);
if (LayerTable[Layer].klAttributes & OUTLINED)
fprintf(TechFileDesc," outline\n");
else
fprintf(TechFileDesc,"\n");
}
}
/*
* AltFilled?
*/
fprintf(TechFileDesc,"AltFilled?");
if (!(LayerTable[Layer].klAttributes & ALT_FILLED))
fprintf(TechFileDesc," n\n");
else {
if (LayerTable[Layer].klAltStyle[0] == 0 And
LayerTable[Layer].klAltStyle[1] == 0 And
LayerTable[Layer].klAltStyle[2] == 0 And
LayerTable[Layer].klAltStyle[3] == 0 And
LayerTable[Layer].klAltStyle[4] == 0 And
LayerTable[Layer].klAltStyle[5] == 0 And
LayerTable[Layer].klAltStyle[6] == 0 And
LayerTable[Layer].klAltStyle[7] == 0 ) {
fprintf(TechFileDesc," y\n");
}
else {
for (i=0; i<8; ++i)
fprintf(TechFileDesc," %02x",
LayerTable[Layer].klAltStyle[i]);
if (LayerTable[Layer].klAttributes & ALT_OUTLINED)
fprintf(TechFileDesc," outline\n");
else
fprintf(TechFileDesc,"\n");
}
}
/*
* Invisible?
*/
if (!(LayerTable[Layer].klAttributes & VISIBLE))
fprintf(TechFileDesc,"Invisible\n");
/*
* AltInvisible?
*/
if (!(LayerTable[Layer].klAttributes & ALT_VISIBLE))
fprintf(TechFileDesc,"AltInvisible\n");
/*
* Blinkers?
*/
if (LayerTable[Layer].klAttributes & BLINK)
fprintf(TechFileDesc,"Blink\n");
/*
* MinDimensions?
*/
fprintf(TechFileDesc,"MinDimensions %g %g\n",
(double)LayerTable[Layer].klMinDimensions/RESOLUTION,
(double)LayerTable[Layer].klWireWidth/RESOLUTION);
/*
* StreamData?
*/
fprintf(TechFileDesc,"StreamData? %d %d\n",
LayerTable[Layer].klStreamNumber,
LayerTable[Layer].klStreamDataType);
/*
* Electrical info?
*/
if ((e = LayerTable[Layer].klElectrical) != NULL) {
switch (e->e_type) {
case ERESIS:
fprintf(TechFileDesc,
"resistance %g\n",*e->e_parms);
break;
case ECAP:
fprintf(TechFileDesc,
"capacitance %g\n",*e->e_parms);
break;
case ETRANS:
fprintf(TechFileDesc,
"tranline %g %g %g %g %g %g\n",
e->e_parms[0],e->e_parms[1],e->e_parms[2],
e->e_parms[3],e->e_parms[4],e->e_parms[5]);
break;
}
}
fprintf(TechFileDesc,"\n");
}
fprintf(TechFileDesc,"Highlighting %d %d %d\n",
ColorTable[HighlightingColor].R,
ColorTable[HighlightingColor].G,
ColorTable[HighlightingColor].B);
fprintf(TechFileDesc,"Background %d %d %d\n",
ColorTable[0].R,
ColorTable[0].G,
ColorTable[0].B);
if (Parameters.kpMergeColors) {
fprintf(TechFileDesc,"MenuText %d\n",
ColorTable[MenuTextColor].Ent);
fprintf(TechFileDesc,"MenuSelect %d\n",
ColorTable[MenuSelectColor].Ent);
fprintf(TechFileDesc,"MenuHighlighting %d\n",
ColorTable[MenuHighlightingColor].Ent);
fprintf(TechFileDesc,"MenuPrompt %d\n",
ColorTable[MenuPromptColor].Ent);
fprintf(TechFileDesc,"MoreText %d\n",
ColorTable[MoreTextColor].Ent);
fprintf(TechFileDesc,"FineGrid %d\n",
ColorTable[FineGridColor].Ent);
fprintf(TechFileDesc,"CoarseGrid %d\n",
ColorTable[CoarseGridColor].Ent);
fprintf(TechFileDesc,"InstanceBox %d\n",
ColorTable[InstanceBBColor].Ent);
fprintf(TechFileDesc,"InstanceName %d\n",
ColorTable[InstanceNameColor].Ent);
fprintf(TechFileDesc,"InstanceSize %d\n",
ColorTable[InstanceSizeColor].Ent);
}
else {
fprintf(TechFileDesc,"MenuText %d %d %d\n",
ColorTable[MenuTextColor].R,
ColorTable[MenuTextColor].G,
ColorTable[MenuTextColor].B);
fprintf(TechFileDesc,"MenuSelect %d %d %d\n",
ColorTable[MenuSelectColor].R,
ColorTable[MenuSelectColor].G,
ColorTable[MenuSelectColor].B);
fprintf(TechFileDesc,"MenuHighlighting %d %d %d\n",
ColorTable[MenuHighlightingColor].R,
ColorTable[MenuHighlightingColor].G,
ColorTable[MenuHighlightingColor].B);
fprintf(TechFileDesc,"MenuPrompt %d %d %d\n",
ColorTable[MenuPromptColor].R,
ColorTable[MenuPromptColor].G,
ColorTable[MenuPromptColor].B);
fprintf(TechFileDesc,"MoreText %d %d %d\n",
ColorTable[MoreTextColor].R,
ColorTable[MoreTextColor].G,
ColorTable[MoreTextColor].B);
fprintf(TechFileDesc,"FineGrid %d %d %d\n",
ColorTable[FineGridColor].R,
ColorTable[FineGridColor].G,
ColorTable[FineGridColor].B);
fprintf(TechFileDesc,"CoarseGrid %d %d %d\n",
ColorTable[CoarseGridColor].R,
ColorTable[CoarseGridColor].G,
ColorTable[CoarseGridColor].B);
fprintf(TechFileDesc,"InstanceBox %d %d %d\n",
ColorTable[InstanceBBColor].R,
ColorTable[InstanceBBColor].G,
ColorTable[InstanceBBColor].B);
fprintf(TechFileDesc,"InstanceName %d %d %d\n",
ColorTable[InstanceNameColor].R,
ColorTable[InstanceNameColor].G,
ColorTable[InstanceNameColor].B);
fprintf(TechFileDesc,"InstanceSize %d %d %d\n",
ColorTable[InstanceSizeColor].R,
ColorTable[InstanceSizeColor].G,
ColorTable[InstanceSizeColor].B);
}
fprintf(TechFileDesc,"GridSpacing %g\n",
(double)Parameters.kpGrid/RESOLUTION);
fprintf(TechFileDesc,"GridStyle %d\n",
Parameters.kpGridLineStyle);
if (Not Parameters.kpGridOnTop)
fprintf(TechFileDesc,"GridOnBottom\n");
if (Parameters.kpShowGridInLargeViewport)
fprintf(TechFileDesc,"ShowGrid\n");
if (Parameters.kpHardcopyGrid)
fprintf(TechFileDesc,"AltShowGrid\n");
if (Parameters.kpDisplayAllLabels)
fprintf(TechFileDesc,"DisplayAllText\n");
if (Parameters.kpLabelAllInstances)
fprintf(TechFileDesc,"LabelAllInstances\n");
fprintf(TechFileDesc,"RoundFlashSides %d\n",
Parameters.kpNumRoundFlashSides);
if (Parameters.kpHardcopyDevice)
fprintf(TechFileDesc,"AltDevice %s\n",
Parameters.kpHardcopyDevice);
fprintf(TechFileDesc,"AltResolution %d\n",
Parameters.kpHardcopyResolution);
fprintf(TechFileDesc,"AltFormat %c\n",
*Parameters.kpHardcopyFormat);
fprintf(TechFileDesc,"Snapping %d\n",
Parameters.kpPixToLambdaSnapping);
if (View->kvFineViewportOnBottom == False)
fprintf(TechFileDesc,"FineViewportOnSide\n");
if (View->kvControl == SPLITSCREEN)
fprintf(TechFileDesc,"SplitScreen\n");
if (Parameters.kpFontName != NULL)
fprintf(TechFileDesc,"FontName %s\n",
Parameters.kpFontName);
if (Parameters.kpCursorShape >= 0)
fprintf(TechFileDesc,"CursorShape %d\n",
Parameters.kpCursorShape);
if (Parameters.kpFullScreenCursor == True)
fprintf(TechFileDesc,"FullScreenCursor\n");
fprintf(TechFileDesc,"BeepVolume %d\n",
Parameters.kpPointBeepVolume);
fclose(TechFileDesc);
sprintf(TypeOut,"Current attributes updated in %s file",String);
ShowPrompt(TypeOut);
/*
* cifplot pattern file
*/
#ifdef CIFPLOT
patbuf = String;
if ((patterns = POpen(CIFPLOT_PATTERNS, "r", (char *)NULL, (char **)NULL))
== NULL) {
ShowPrompt("Can't open cifplot pattern file.\n");
return;
}
if ((cifplot = fopen("cifplot","w")) == NULL) {
ShowPrompt("Can't create cifplot pattern file.\n");
return;
}
fprintf(cifplot, "\n");
Layer = 0;
while (++Layer <= NumLayerTable) {
if (fscanf(patterns,"%s",patbuf) <= 0) {
rewind(patterns);
--Layer;
continue;
}
if (LayerTable[Layer].klTechnology != ' ') {
fprintf(cifplot, "\"%c", LayerTable[Layer].klTechnology);
for (i=0; i<3; ++i) {
if (LayerTable[Layer].klMask[i] == ' ')
break;
else
fprintf(cifplot, "%c", LayerTable[Layer].klMask[i]);
}
fprintf(cifplot, "\"%s\n", patbuf);
}
}
fprintf(cifplot, "\n");
fclose(patterns);
fclose(cifplot);
#endif
}
/* Interrupt handling */
#if __STDC__
static void segv_err_handler();
#ifdef SIGBUS
static void bus_err_handler();
#endif
static void ill_err_handler();
static void fpe_err_handler();
static void int_handler();
#else
static void segv_err_handler();
static void bus_err_handler();
static void ill_err_handler();
static void fpe_err_handler();
static void int_handler();
#endif
void
InitSignals()
{
Parameters.kpSIGINTERRUPT = False;
(void) signal(SIGSEGV, segv_err_handler);
#ifdef SIGBUS
(void) signal(SIGBUS, bus_err_handler);
#endif
(void) signal(SIGILL, ill_err_handler);
(void) signal(SIGFPE, fpe_err_handler);
(void) signal(SIGINT, int_handler);
}
static void
segv_err_handler()
{
(void) signal(SIGSEGV,SIG_DFL);
ShowPromptAndWait("Fatal internal error: segmentation violation.");
AbortKIC();
FBEnd();
exit(0);
}
#ifdef SIGBUS
static void
bus_err_handler()
{
(void) signal(SIGBUS,SIG_DFL);
ShowPromptAndWait("Fatal internal error: bus error.");
AbortKIC();
FBEnd();
exit(0);
}
#endif
static void
ill_err_handler()
{
(void) signal(SIGILL,SIG_DFL);
ShowPromptAndWait("Fatal internal error: illegal instruction.");
AbortKIC();
FBEnd();
exit(0);
}
static void
fpe_err_handler()
{
(void) signal(SIGFPE,SIG_DFL);
ShowPromptAndWait("Fatal internal error: floating point exception.");
AbortKIC();
FBEnd();
exit(0);
}
static void
int_handler()
{
Parameters.kpSIGINTERRUPT = True;
}
char *
CopyString(s)
char *s;
{
char *t;
if (s) {
t = tmalloc(strlen(s)+1);
strcpy(t,s);
return t;
}
return s;
}
char *
tmalloc(x)
unsigned x;
{
char *c = (char*)malloc(x);
if (c == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
memset(c,0,x);
return c;
}
void
MallocFailed()
{
char *cp, buf[256];
char tn[32];
if (CDStatusInt != CDMALLOCFAILED)
return;
strcpy(tn, "KcXXXXXX");
cp = mktemp(tn);
FBEnd();
strcpy(buf, "Memory allocation error. ");
if (Parameters.kpCellName[0] != EOS) {
if (Not CDUpdate(Parameters.kpCellDesc,cp))
strcat(buf,"Sorry, couldn't save current cell.");
else {
strcat(buf,"Current cell saved in ");
strcat(buf,cp);
strcat(buf,".");
}
}
fatal_error(buf);
}
/* unused features for CD */
/* Called from CDEndMakeCall() */
void
UpdateProperties() {}
/* Called from POpen() */
FILE *
OpenDevice()
{ return NULL; }
/***********************************************************************
*
* Help interface.
*
*
***********************************************************************/
extern FILE *cp_in,*cp_out,*cp_err;
extern char *MenuHELP;
extern char *MenuPLUSR,*MenuMINSR;
extern char *MenuPLUSG,*MenuMINSG;
extern char *MenuPLUSB,*MenuMINSB;
extern char *Menu0,*Menu90,*Menu180,*Menu270;
extern char *MenuMX,*MenuMY;
extern char *MenuTB,*MenuRL;
extern char *Menu45S;
/* PATH_TO_HELP should have been defined */
extern char *HELPPATH;
void
Help()
{
int dummy;
char cmd[32], *c;
MenuSelect(MenuHELP);
*TypeOut = '\0';
HELPPATH = PATH_TO_HELP;
cp_in = stdin;
cp_err = stderr;
#ifdef MSDOS
cp_out = fopen("NUL","w");
c = getenv("SRWDRV");
if (c && isalpha(*c) && (*c = tolower(*c)) > 'b')
*HELPPATH = *c;
#else
#ifdef WIN32
cp_out = fopen("NUL","w");
#else
cp_out = fopen("/dev/null","w");
#endif
#endif
ShowPrompt("Point to menu item for help (ESC to exit help).");
loop {
switch (PointLoopSafe(&dummy)) {
case PL_ESC:
fclose(cp_out);
MenuDeselect(MenuHELP);
ErasePrompt();
EnableMore(False);
FullRedisplay();
return;
case PL_PCW:
*TypeOut = '\0';
continue;
case PL_CMD:
if (Matching(MenuMINSR) ||
Matching(MenuPLUSR) ||
Matching(MenuMINSG) ||
Matching(MenuPLUSG) ||
Matching(MenuMINSB) ||
Matching(MenuPLUSB))
strcpy(Parameters.kpCommand,"plusretc");
else
if (Matching(Menu0) ||
Matching(Menu90) ||
Matching(Menu180) ||
Matching(Menu270))
strcpy(Parameters.kpCommand,"rotate");
else
if (Matching(MenuMX) ||
Matching(MenuMY))
strcpy(Parameters.kpCommand,"mirror");
else
if (Matching(MenuTB) ||
Matching(MenuRL))
strcpy(Parameters.kpCommand,"tbrl");
else
if (Matching(Menu45S))
strcpy(Parameters.kpCommand,"a45s");
sprintf(cmd,"%s",Parameters.kpCommand);
to_lower_case(cmd);
if ((c = strchr(cmd,' ')) != NULL) *c = '\0';
if (!cmd[0])
continue;
EnableMore(False);
EnableMore(True);
hlp_main(HELPPATH,cmd);
MorePageDisplay();
}
}
}
/* for help */
void
out_init() {}
void
PutString(string)
char *string;
{
if (strlen(TypeOut) + strlen(string) < 200)
strcat(TypeOut,string);
else
strcat(TypeOut,"\n");
if (strchr(TypeOut,'\n') == NULL) return;
if (MoreLine(TypeOut))
EnableMore(False);
*TypeOut = '\0';
}
void
PutErrorString(string)
char *string;
{
PutString(string);
}
void
PutBoldString(string)
char *string;
{
int tmp;
tmp = ColorTable[MoreTextColor].Ent;
ColorTable[MoreTextColor].Ent = ColorTable[HighlightingColor].Ent;
PutString(string);
ColorTable[MoreTextColor].Ent = tmp;
}
char *
GetString(s,n,fp,prompt)
char *s;
int n;
FILE *fp;
char *prompt;
{
char *c;
if (!prompt) {
ErasePrompt();
return NULL;
}
ShowPrompt(prompt);
MorePageDisplay();
c = FBEdit(NULL);
ErasePrompt();
if (c == NULL || *c == '\0' || *c == '\n') return NULL;
strcpy(s,c);
return s;
}
void
RepaintWindow(i)
int i;
{
if (i < 0) return;
RedisplayKIC();
}
void
SetDisplayWindow() {}
kic-2.4c/src/bin/kictocif.c 0000644 0000764 0000764 00000013264 07525564336 015237 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#define Allocate
#include "prefix.h"
#include "kic.h"
int NumLayerTable;
struct kl LayerTable[CDNUMLAYERS+1];
struct kp Parameters;
struct cl ColorTable[12];
struct f FB = { 0 };
int argc;
char **argv;
#if __STDC__
extern void help(void);
extern char *nextarg(void);
#else
extern void help();
extern char *nextarg();
#endif
int
main(ac, av)
int ac;
char *av[];
{
float Float1 = 1.0;
char *cp;
int i;
int Layer;
int Layers[CDNUMLAYERS];
int detail = 0;
int symbolic = 0;
char Root[81];
char Path[81];
char CIFFile[81];
char Program;
char *Tmp, *Tech;
argc = ac;
argv = av;
Float1 = 1.0;
Program = 'k';
InitGlobal();
Root[0] = '\0';
CIFFile[0] = '\0';
while (argc > 1 && argv[1][0] == '-') {
switch (argv[1][1]) {
case 'L':
case 'l':
sscanf(nextarg(), "%f", &Float1);
break;
case 'O':
case 'o':
strcpy(CIFFile, nextarg());
break;
case 'S':
case 's':
symbolic++;
break;
case 'D':
case 'd':
detail++;
break;
case 'P':
case 'p':
Program = *nextarg();
break;
case 'T':
case 't':
Tech = nextarg();
#ifdef MSDOS
if (strlen(Tech) > 3)
Tech[3] = '\0';
#endif
TECH_EXT = malloc(strlen(Tech) + 1);
if (TECH_EXT == NULL) {
(void)fprintf(stderr,
"Memory allocation failure on startup.\n");
exit(1);
}
strcpy(TECH_EXT,Tech);
break;
default:
help();
}
argc--;
argv++;
}
if (argc > 1)
strcpy(Root,argv[1]);
else {
printf("Hierarchy's root cell? (hit return for help) ");
Tmp = malloc(81);
*Tmp = '\0';
fgets(Tmp,81,stdin);
if (sscanf(Tmp,"%s",Root) != 1)
help();
free(Tmp);
}
Path[0] = '\0';
Tmp = strrchr(Root,DIRC);
if (Tmp) {
*Tmp = '\0';
strcpy(Path,Root);
for (i = 0, Tmp++; *Tmp; i++, Tmp++)
Root[i] = *Tmp;
Root[i] = '\0';
}
printf("Microns per lambda: %15.8e\n",Float1);
if (CIFFile[0] == '\0') {
cp = Root;
i = 0;
while (*cp != '.' And *cp != '\0') {
CIFFile[i] = *cp;
++i;
++cp;
}
CIFFile[i] = '\0';
strcat(CIFFile, ".cif");
}
/*
* Initializes CD package and reads in tech file so we
* know the layer names. Can't generate CIF without them.
*/
ReadTechFile();
/* add the root path */
if (*Path) {
Tmp = PGetPath();
strcat(Tmp,Path);
printf("KIC search path: %s\n",Tmp);
}
if (!(detail ^ symbolic)) {
detail = 0;
symbolic = 0;
printf("Converting all layers\n");
}
else if (detail)
printf("Converting detail layers\n");
else
printf("Converting symbolic layers\n");
for (Layer = 1; Layer <= NumLayerTable; ++Layer)
Layers[Layer-1] = True;
if (detail) {
for (Layer = 1; Layer <= NumLayerTable; ++Layer)
if (LayerTable[Layer].klAttributes & SYMBOLIC)
Layers[Layer-1] = False;
}
else if(symbolic) {
for (Layer = 1;Layer <= NumLayerTable;++Layer)
if (Not (LayerTable[Layer].klAttributes & SYMBOLIC))
Layers[Layer-1] = False;
}
if (Not CDFrom(Root,CIFFile,(int)(Float1*RESOLUTION),RESOLUTION,
Layers,NumLayerTable,Program))
printf("Translation of %s failed.\n%s\n", Root, CDStatusString);
else
printf("Translation of %s succeeded.\n", Root);
return (0);
}
void
help()
{
printf("\nkictocif-%s\n\n",VersionString);
printf("Usage: kictocif [options] [root_kic_cell]\n\n");
printf("options:\n");
printf(" -Ocifname cif file name to create\n");
printf(" -S convert symbolic layers only\n");
printf(" -D convert detail layers only\n");
printf(" -Pc c = program prefix (a,b NCA/Stanford, i Icarus, s SIF)\n");
printf(" -Text use %s.ext file for layers\n",TECHNAME);
printf(" -Lmicprl micron per lambda (default 1.0)\n\n");
exit(0);
}
char *
nextarg()
{
if (argv[1][2] != '\0')
return &argv[1][2];
argv++;
argc--;
return argv[1];
}
void
MallocFailed()
{
if (CDStatusInt != CDMALLOCFAILED)
return;
fprintf(stderr,"OUT OF MEMORY. This is a fatal error!\n");
exit(1);
}
/* for callbacks in cd, not used */
void UpdateProperties() {}
FILE *OpenDevice() {return NULL;}
/* ARGSUSED */
void CDLabelBB(p,a,b,c,d)
struct o *p;
int *a, *b, *c, *d;
{}
kic-2.4c/src/bin/ciftokic.c 0000644 0000764 0000764 00000015415 07525564320 015230 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include
#include
#include "prefix.h"
#include "cd.h"
int argc;
char **argv;
#if __STDC__
extern void help(void);
extern void blather(void);
extern char *nextarg(void);
extern char get_cif_file_type(FILE*);
#else
extern void help();
extern void blather();
extern char *nextarg();
extern char get_cif_file_type();
#endif
int
main(ac, av)
int ac;
char *av[];
{
float Float1 = 1.0;
char Program = '\0';
char CIFFile[81], *Tmp;
FILE *fp;
argc = ac;
argv = av;
InitGlobal();
CIFFile[0] = '\0';
while (argc > 1 && argv[1][0] == '-') {
switch (argv[1][1]) {
case 'L':
sscanf(nextarg(), "%f", &Float1);
break;
case 'a':
case 'b':
case 'h':
case 'i':
case 'k':
case 'n':
case 'q':
case 's':
Program = argv[1][1];
break;
default:
help();
}
argc--;
argv++;
}
if (argc > 1)
strcpy(CIFFile,argv[1]);
else {
printf("CIF file's name? (hit return for help) ");
Tmp = malloc(81);
*Tmp = '\0';
fgets(Tmp,81,stdin);
if (sscanf(Tmp,"%s",CIFFile) != 1)
help();
free(Tmp);
}
if (Program == '\0') {
fp = fopen(CIFFile,"r");
if (fp == NULL) {
printf("Error: can't read CIF input file %s\n",CIFFile);
exit(1);
}
Program = get_cif_file_type(fp);
fclose(fp);
}
printf("CIF file type: %c\n",Program);
printf("Microns per lambda: %15.8e\n",Float1);
CDInit();
CDPath(".");
if (Not CDTo(CIFFile,"Root",(int)(Float1*RESOLUTION),RESOLUTION,Program))
printf("Translation of %s failed.\n%s\n",CIFFile,CDStatusString);
else
printf("Translation of %s succeeded.\n",CIFFile);
return (0);
}
void
help()
{
printf("\nciftokic-%s\n\n",VersionString);
printf("Usage: ciftokic [options] [cif_file]\n\n");
printf("options:\n");
printf(" -Lmicprl micron per lambda (default 1.0)\n");
printf(" -prefix (cif dialect) where prefix =\n");
blather();
printf("\n");
exit(0);
}
void
blather()
{
printf("k Generated from KIC\n");
printf(
"a Stanford: A Stanford symbol name follows a DS command as in (PadIn);\n");
printf(
"b NCA: An NCA symbol name follows a DS command as in (PadIn);\n");
printf(
"h IGS: A KIC or IGS symbol name follows a DS command as in 9 PadIn;\n");
printf(
"i Icarus: An Icarus symbol name follows a DS command as in (9 PadIn);\n");
printf(
"q Squid: A Squid symbol name follows a DS command as in 9 /usr/joe/PadIn;\n");
printf(
"s Sif: A Sif symbol name follows a DS command as in (Name: PadIn);\n");
printf(
"n none of the above\n");
}
char
*nextarg()
{
if (argv[1][2] != '\0')
return &argv[1][2];
argv++;
argc--;
return argv[1];
}
void
MallocFailed()
{
if (CDStatusInt != CDMALLOCFAILED) return;
fprintf(stderr,"OUT OF MEMORY. This is a fatal error!\n");
exit(1);
}
/* for callbacks in cd, not used */
void UpdateProperties() {}
FILE *OpenDevice() {return NULL;}
/* ARGSUSED */
void CDLabelBB(p,a,b,c,d)
struct o *p;
int *a, *b, *c, *d;
{}
char
get_cif_file_type(cfile)
/* Return the code for the structure name. Skip to the first DS command,
* and look at the following line.
*
* a Stanford: A Stanford symbol name follows a DS command as in (PadIn);
* b NCA: An NCA symbol name follows a DS command as in (PadIn);
* h IGS: A KIC or IGS symbol name follows a DS command as in 9 PadIn;
* k KIC: A KIC or IGS symbol name follows a DS command as in 9 PadIn;
* i Icarus: An Icarus symbol name follows a DS command as in (9 PadIn);
* q Squid: A Squid symbol name follows a DS command as in 9 /usr/joe/PadIn;
* s Sif: A Sif symbol name follows a DS command as in (Name: PadIn);
* n none of the above
*/
FILE *cfile;
{
int c;
if (cfile == NULL)
return ('n');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c != 'D') {
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
continue;
}
if ((c = getc(cfile)) == EOF)
return ('n');
if (c != 'S') {
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
continue;
}
/* found a DS command, skip to ; */
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
if (c == EOF)
return ('n');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == '(') {
/* a comment line */
while ((c = getc(cfile)) != EOF)
if (isspace(c)) continue;
if (c == EOF)
return ('n');
if (c == '9')
/* Icarus */
return ('i');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == ':')
/* Sif */
return ('s');
if (c == ';')
/* Stanford/NCA */
return ('a');
}
return ('n');
}
else if (c == '9') {
/* user extension line */
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == '/')
/* Squid */
return ('q');
if (c == ';')
/* IGS/KIC */
return ('k');
}
return ('n');
}
else
return ('n');
}
}
return ('n');
}
kic-2.4c/src/bin/strmtext.c 0000644 0000764 0000764 00000065051 10261422042 015311 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/* */
/* Confidential -- All proprietary rights reserved */
/* Licensed Material -- Property of Tektronix */
/* */
/* STRMTOTEXT -- converts a Calma Stream file (3.0) to */
/* a text image. */
/* */
/* strmtotext [-id] [-n12345678] [streamfile */
/* [textfile]] */
/* */
/* -id prints the version of the program */
/* and copyright information. */
/* -n indicates a non-standard Stream file */
/* is to be read, that is, one struc- */
/* ture beginning with BGBSTR and end- */
/* ing with ENDSTR. */
/* 1-8 indicate the number of Stream rec- */
/* ords per line in the output text. */
/* (Default is one per line). */
/* streamfile a Calma Stream file (3.0) input to */
/* this program. (Standard input de- */
/* fault). */
/* textfile the name of the file to receive the */
/* program's output. (Standard output */
/* default). */
/* */
/* */
/* Author: Giles Billingsley */
/* */
/* Maintenance: David Inman */
/* (503) 627-4083 */
/* */
/*----------------------------------------------------------------------
* Modified by S. R. Whiteley 12/3/91
*
* In read_stream(), the original version defined 2 buffers of length
* MAXRECSIZE: int buf[] and char cbuf[]. The arrays were filled
* as
* buf[i] = getc(workfile);
* cbuf[i] = buf[i];
*
* In the following code, &buf[] was used as an argument to strm_ival(),
* and elsewhere, except when an 8 bit char was specifically needed.
* This works on some systems because getc() actually returns an int,
* which is not always true. Here, the buf buffer is not used, and
* an index into cbuf is always passed.
*
* This version is self-contained, as the (modified) routines from
* stream.c have been appended to this file. Defining the variable IEEE
* below specifies IEEE floating point. Comment this out for DEC
* floating point.
*---------------------------------------------------------------------
*/
#include "prefix.h"
#include
#include
#include "stream.h"
/* undefine this for DEC floating point */
#define IEEE
FILE *STREAMFILE;
int IbigEndian;
int FbigEndian;
char *version[] ={
/*
"strmtotext 1.6 4/7/83",
"strmtotext 1.7 12/3/91",
*/
"strmtext 1.8 1/6/94",
/*
"@(#)version.c 1.6 (Tektronix) 4/7/83",
*/
0
};
char *Trade_Secret_License[] ={
/* This is BS
"This program is the property of Tektronix, Inc. or others from",
"whom Tektronix has obtained a licensing right, and is considered",
"by Tektronix to be confidential. It is protected by U.S. copy-",
"right law as an unpublished work and is furnished pursuant to a",
"written license agreement. It may not be used, copied or other-",
"wise reproduced, or disclosed to others except in accordance with",
"the terms and conditions of that agreement.",
*/
"Written by Kenneth H. Keller and Giles C. Billingsley, 1981,",
"under funding from Tektronix, Inc.",
"",
"Modified to work with IEEE floating point on a larger class of",
"machines, by S. R. Whiteley (12/3/91).",
0
};
#if __STDC__
extern void read_stream(FILE*,FILE*,int,int);
extern int fptest(int*,int*);
extern short strm_ival(char*);
extern int strm_longval(char*);
extern double strm_doubleval(char*);
#else
extern void read_stream();
extern int fptest();
extern short strm_ival();
extern int strm_longval();
extern double strm_doubleval();
#endif
int
main(argc,argv)
int argc;
char *argv[];
{
FILE *outfile = NULL;
char *p;
int jobtype = 0,lcount = 1,i;
#ifdef TEKTRONIX
setname(*argv); /* set name of program for prterr */
#else
#define prterr fprintf
#endif
usage:
if(--argc == 0){
printf("Usage: strmtotext [-id] [-n2345678] [ streamfile [textfile] ]\n");
exit(1);
}
if (fptest(&IbigEndian,&FbigEndian)) {
fprintf(stderr,"Error: incompatible floating point format.\n");
exit(1);
}
/* evaluate options, if any */
while(*(p = *++argv) == '-'){
--argc;
while(*++p != '\0'){
if(*p == 'n')
jobtype = 1;
else if( (i = *p) > 48 && i < 57)
lcount = i - 48;
else if(*p == 'i'){ /* id flag */
if(*(p+1) == 'd'){
extern char *version[];
extern char *Trade_Secret_License[];
int j;
fprintf(stdout,"%s\n\n",version[0]);
for(j = 0;Trade_Secret_License[j];j++)
fprintf(stdout,"%s\n",Trade_Secret_License[j]);
exit(0);
}
}
else{
argc = 0;
goto usage;
}
}
}
--argv;
/* evaluate arguments */
/* one argument = streamfile */
if(argc >= 1){
#if (__NDPC__)
/* SRW ** Under DOS, need to open stream file in binary mode. With my
* compiler (Microway NDP C), setting the external _pmode does this.
* Other compilers do this differently, e.g., by using "rb" as the mode
* string to fopen().
*/
_pmode = 0x8000;
#endif
if((STREAMFILE = fopen(*++argv,"rb")) == NULL){
prterr(stderr,"Can't open %s\n",*argv);
exit(1);
}
if(argc == 1)
outfile = stdout;
}
/* two arguments = streamfile and textfile */
if(argc == 2){
if((outfile = fopen(*++argv,"w")) == NULL){
prterr(stderr,"Can't open %s\n",*argv);
exit(1);
}
}
/* no arguments = stdio */
if(argc == 0){
STREAMFILE = stdin;
outfile = stdout;
}
read_stream(outfile,STREAMFILE,jobtype,lcount);
return (0);
}
/* */
/* function READ_STREAM */
/* Function to transfer STREAM to ASCII output file. If the */
/* transfer variable 'jobtype' equals unity, this function */
/* will terminate with the appearance of ENDLIB or ENDSTR. */
/* This allows processing of non-standard STREAM libraries. */
/* Concatenated records are separated by a semicolon. */
/* */
void
read_stream(outfile,workfile,jobtype,lcount)
FILE *outfile,*workfile;
int jobtype,lcount;
{
unsigned type = 0; /* current record type */
unsigned numb; /* number of bytes in current record */
int datatype;
int level=0;
int colcntr = 0;
int lmod[6],lacc[6]; /* library modification and access dates */
int cred[6],accd[6]; /* structure creation and access dates */
char cbuf[MAXRECSIZE];
int i,l;
while(type != 4){
numb = (unsigned char)getc(workfile);
numb = numb * 256 + (unsigned char)getc(workfile) - 4;
type = (unsigned char)getc(workfile);
datatype = getc(workfile);
for(i=0; i= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"\t\tPCOL\t\t%d, %d;",
strm_longval(&cbuf[8]),strm_longval(&cbuf[12]));
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"\t\tPROW\t\t%d, %d;",
strm_longval(&cbuf[16]),strm_longval(&cbuf[20]));
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
}
else{
if(l > 1){
if(colcntr) fprintf(outfile,"\n");
fprintf(outfile,"\t\tCOORDINATES\t%d\t%d, %d\n",
l,strm_longval(cbuf),strm_longval(&cbuf[4]));
for(i=1; i= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"\t\tROWS\t\t%d;",strm_ival(&cbuf[2]));
++colcntr;
break;
case TEXTNODE:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"\t\tTEXTNODE;\n");
break;
case SNAPNODE:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"\tSNAPNODE;\n");
break;
case TEXTTYPE:
fprintf(outfile,"\t\tTEXTTYPE\t%d;",strm_ival(cbuf));
++colcntr;
break;
case PRESENTATION:
l = 3;
l = (cbuf[1] & l);
fprintf(outfile,"\t\tHJUSTIFICATION\t%d;",l);
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
l = 12;
l = (cbuf[1] & l) >> 2;
fprintf(outfile,"\t\tVJUSTIFICATION\t%d;",l);
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
l = 48;
l = (cbuf[1] & l) >> 4;
fprintf(outfile,"\t\tFONT\t\t%d;",l);
++colcntr;
break;
case SPACING:
break;
case STRING:
fprintf(outfile,"\t\tSTRING\t\t%s;",cbuf);
++colcntr;
break;
case STRANS:
l = 128;
l = (cbuf[0] & l) >> 7;
if(l == 1){
fprintf(outfile,"\t\tREFLECTION;");
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
}
l = 4;
l = (cbuf[1] & l);
if(l == 4){
fprintf(outfile,"\t\tABSOLUTE MAGNIFICATION;");
if(++colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
}
l = 2;
l = (cbuf[1] & l);
if(l == 2){
fprintf(outfile,"\t\tABSOLUTE ANGLE;");
++colcntr;
}
break;
case MAG:
fprintf(outfile,"\t\tMAGNIFICATION\t%f;",strm_doubleval(cbuf));
++colcntr;
break;
case ANGLE:
fprintf(outfile,"\t\tANGLE\t\t%f;",strm_doubleval(cbuf));
++colcntr;
break;
case UINTEGER:
break;
case USTRING:
break;
case REFLIBS:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"REFLIB\t\t%s;\n",cbuf);
fprintf(outfile,"REFLIB\t\t%s;\n",&cbuf[44]);
break;
case FONTS:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"FONT0\t\t%s;\n",cbuf);
fprintf(outfile,"FONT1\t\t%s;\n",&cbuf[44]);
fprintf(outfile,"FONT2\t\t%s;\n",&cbuf[88]);
fprintf(outfile,"FONT3\t\t%s;\n",&cbuf[132]);
break;
case PATHTYPE:
fprintf(outfile,"\t\tPATHTYPE\t%d;",strm_ival(cbuf));
++colcntr;
break;
case GENERATIONS:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"GENERATIONS\t%d;\n",strm_ival(cbuf));
break;
case ATTRTABLE:
if(colcntr){
colcntr = 0;
fprintf(outfile,"\n");
}
fprintf(outfile,"ATTRIBUTE-FILE\t%s;\n",cbuf);
break;
case PROPATTR:
if(colcntr) fprintf(outfile,"\n");
colcntr = 0;
fprintf(outfile,"\t\tATTRIBUTES\t%d=",strm_ival(cbuf));
break;
case PROPVALUE:
fprintf(outfile,"%s;\n",cbuf);
break;
default:
fprintf(outfile,"\n");
/*
fprintf(outfile,"ERROR HAS OCCURRED\n");
*/
fprintf(outfile,"WARNING: UNKNOWN RECORD TYPE\n");
fprintf(outfile,"RECORD TYPE = %d\tLENGTH = %d\tDATATYPE = %d\n",type,numb,datatype);
/*
exit(0);
*/
}
if(colcntr >= lcount){
colcntr = 0;
fprintf(outfile,"\n");
}
}
}
#define False 0
#define True 1
int
fptest(iflg,dflg)
/* Determine whether the CPU stores integers and doubles in big or little
* endian format. If the least significant bits are found in the
* char at the data item address, then the format is little endian.
* The sign bit and exponent are the most significant bits of the
* double.
* The flags are set true if big endian. If either format is not
* recognized, true is returned.
*/
int *iflg, *dflg;
{
union {double d; unsigned int l[2];
unsigned short i[4]; unsigned char c[8];} u;
u.d = -2.0;
if (u.c[7] == 0xc0)
*dflg = False;
else if (u.c[0] == 0xc0)
*dflg = True;
else
return (True);
u.l[0] = 1L;
if (u.c[0] == 1)
*iflg = False;
else if (u.c[3] == 1)
*iflg = True;
else
return (True);
return (False);
}
/* Functions used in reading stream format */
typedef union {
short w[4]; /* double precision number as four shorts */
int l[2]; /* double precision value as two int */
double dval; /* value of double precision number */
}
dbltype;
#if __STDC__
static double ieeed(dbltype);
static void rev_bytes(double*);
static unsigned int getbits(unsigned int,int,int);
#else
static double ieeed();
static void rev_bytes();
static unsigned int getbits();
#endif
/***********************************************************************/
/* function STRM_IVAL */
/* Function to evaluate STREAM short integer. */
/***********************************************************************/
short
strm_ival(b)
char *b;
{
union { short i; char c[2];} si;
/* Stream format is big-endian */
if (IbigEndian) {
si.c[0] = b[0];
si.c[1] = b[1];
}
else {
si.c[0] = b[1];
si.c[1] = b[0];
}
return si.i;
}
/***********************************************************************/
/* function STRM_LONGVAL */
/* Function to evaluate STREAM long integer. */
/***********************************************************************/
int
strm_longval(b)
char *b;
{
union {int l; char c[4];} sl;
/* Stream format is big-endian */
if (IbigEndian) {
sl.c[0] = b[0];
sl.c[1] = b[1];
sl.c[2] = b[2];
sl.c[3] = b[3];
}
else {
sl.c[0] = b[3];
sl.c[1] = b[2];
sl.c[2] = b[1];
sl.c[3] = b[0];
}
return sl.l;
}
/*
* function STRM_DOUBLEVAL
* Function to convert from STREAM to VAX double precision.
* The argument is a integer buffer containing the eight bytes
* of the STREAM double precision field. The first character in
* the buffer contains the exponent, the second contains the most
* significant byte of the mantissa, etc.
*
*
* VAX's double precision field:
*
* Mantissa is base 2 (1/2 <= mantissa < 1). Exponent is excess-128.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFEEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
*
* CALMA's double precision field:
*
* Mantissa is base 16 (1/16 <= mantissa < 1). Exponent is excess-64.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFFEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
* where E = exponent field
* S = sign bit
* F = fraction field
* FL = least sig. bit of word or byte
* FM = most sig. bit of word or byte
*/
double
strm_doubleval(ip)
char *ip;
{
int exp;
int sign;
int i,j;
dbltype Strm_DblAndShrt;
union { short i; char c[2];} si;
sign = 0;
i = j = 0;
exp = ip[0];
/* test the sign bit */
if (exp & 0x80) {
sign = 1;
exp &= 0x7f;
}
/*
* We will transfer the chars of the double precision field to
* simplify this routine. i.e., it is easier to keep track of
* all the bits when we shift 16 bit fields rather than 8 bit
* fields.
*/
for (i = 0; i <= 3; ++i) {
if (IbigEndian) {
si.c[1] = ip[i+i+1];
si.c[0] = ip[i+i];
}
else {
si.c[0] = ip[i+i+1];
si.c[1] = ip[i+i];
}
Strm_DblAndShrt.w[i] = si.i;
}
/* mask the exponent */
Strm_DblAndShrt.w[0] &= 0xff;
/* multiply by 2 until the most significant mantissa bit is set */
while (!(Strm_DblAndShrt.w[0] & 0x80) && (j < 64)) {
++j;
for (i = 0; i <= 2; ++i) {
Strm_DblAndShrt.w[i] = (Strm_DblAndShrt.w[i] << 1);
if (Strm_DblAndShrt.w[i+1] & 0x8000) Strm_DblAndShrt.w[i] |= 1;
}
Strm_DblAndShrt.w[3] = (Strm_DblAndShrt.w[3] << 1) & 0xffff;
}
if (j == 64) return (0.0);
/*
* Add exponent to the first word in the working buffer.
* We must subtract j from the exponent which is the number of
* times the mantissa was multiplied by 2.
*
* There is another trick which is not so obvious. We multiplied
* by 2 until the most significant bit of the STREAM mantissa was
* set. By dropping that bit, we convert from excess-64 to
* excess-128.
*/
Strm_DblAndShrt.w[0] =
((Strm_DblAndShrt.w[0] & 0x7f) | (((exp << 2)+128-j) << 7)) & 0x7fff;
/* is it negative? */
if (sign)
Strm_DblAndShrt.w[0] |= 0x8000;
#ifdef IEEE
return ieeed(Strm_DblAndShrt); /* IEEE double */
#else
return(Strm_DblAndShrt.dval); /* VAX double */
#endif
}
#ifdef IEEE
/* SRW */
static double
ieeed(d) /* return IEEE double given DEC double */
dbltype d;
{
unsigned int e, m;
if (!IbigEndian) {
e = d.w[1];
d.w[1] = d.w[0];
d.w[0] = e;
e = d.w[3];
d.w[3] = d.w[2];
d.w[2] = e;
}
e = (getbits(d.l[0],30,8) + 01576) << 20;
e += (d.l[0] & 0x80000000);
m = getbits(d.l[0],22,23);
d.l[0] = (d.l[1] >> 3) + ((m & 7) << 29);
d.l[1] = e + (m >> 3);
if (IbigEndian && FbigEndian) {
m = d.l[0];
d.l[0] = d.l[1];
d.l[1] = m;
}
else if (IbigEndian || FbigEndian) {
rev_bytes(&d.dval);
}
return (d.dval);
}
static void
rev_bytes(d)
double *d;
{
union {double d; char c[8];} bf;
char *c;
bf.d = *d;
c = (char*)d;
c[0] = bf.c[7];
c[1] = bf.c[6];
c[2] = bf.c[5];
c[3] = bf.c[4];
c[4] = bf.c[3];
c[5] = bf.c[2];
c[6] = bf.c[1];
c[7] = bf.c[0];
}
static unsigned int
getbits(x,p,n) /* get n bits from position p */
unsigned int x;
int p, n;
{ return((x >> (p + 1 - n)) & ~(~0L << n)); }
#endif
kic-2.4c/src/bin/kicscale.c 0000644 0000764 0000764 00000012531 11133216747 015204 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* KIC scaling program
* Calling sequence
*
* kicscale [-a numerator] [-b denominator] [-t ext] [rootfile]
*
* where numerator and denominator are ints and equal to unity by default,
* and ext implies calling .KIC.ext for layer definitions.
*
* Giles Billingsley
*/
#define Allocate
#include "prefix.h"
#include "kic.h"
int NumLayerTable;
struct kp Parameters;
struct kl LayerTable[CDNUMLAYERS+1];
struct cl ColorTable[12];
struct f FB = { 0 };
int argc;
char **argv;
#if __STDC__
extern char *nextarg(void);
extern void help(void);
#else
extern char *nextarg();
extern void help();
#endif
int
main(ac, av)
char *av[];
{
int Layer;
int Layers[CDNUMLAYERS];
int ScaleA = 1;
int ScaleB = 1;
char *tmp;
char Root[81];
char TmpFile[81];
char JnkFile[81];
char *Tech;
char tf1[32], tf2[32];
argc = ac;
argv = av;
Root[0] = '\0';
InitGlobal();
while (argc > 1 && argv[1][0] == '-') {
switch(argv[1][1]) {
case 'a':
case 'A':
sscanf(nextarg(), "%d", &ScaleA);
if(ScaleA < 1){
fprintf(stderr,"Invalid scaling factor A = %d.\n",ScaleA);
fprintf(stderr,"Must be positive integer.\n");
exit(1);
}
break;
case 'b':
case 'B':
sscanf(nextarg(), "%d", &ScaleB);
if(ScaleB < 1){
fprintf(stderr,"Invalid scaling factor B = %d.\n",ScaleB);
fprintf(stderr,"Must be positive integer.\n");
exit(1);
}
break;
case 'T':
case 't':
Tech = nextarg();
#ifdef MSDOS
if (strlen(Tech) > 3)
Tech[3] = '\0';
#endif
TECH_EXT = malloc(strlen(Tech) + 1);
if (TECH_EXT == NULL) {
(void)fprintf(stderr,
"Memory allocation failure on startup.\n");
exit(1);
}
strcpy(TECH_EXT,Tech);
break;
default:
help();
}
argc--;
argv++;
}
printf("WARNING!!! This program will overwrite the specified KIC\n");
printf("file and all of the subcell files.");
printf("Enter y to continue: ");
if (getchar() != 'y')
exit(0);
if (argc > 1)
strcpy(Root, argv[1]);
else {
printf("Hierarchy's root cell? (hit return for help) ");
tmp = malloc(81);
*tmp = '\0';
fgets(tmp,81,stdin);
if (sscanf(tmp,"%s",Root) != 1)
help();
free(tmp);
}
strcpy(tf1,"SCLXXXXXX");
tmp = mktemp(tf1);
sprintf(TmpFile,"%s.CIF",tmp);
strcpy(tf2,"SCLXXXXXX");
tmp = mktemp(tf2);
sprintf(JnkFile,"%s.KIC",tmp);
/*
* Initializes CD package and reads in tech file so we know
* the layer names. Can't generate CIF without them.
*/
ReadTechFile();
for (Layer = 1; Layer <= NumLayerTable; ++Layer)
Layers[Layer-1] = True;
if (Not CDFrom(Root,TmpFile,ScaleA*RESOLUTION,RESOLUTION,
Layers,NumLayerTable,'k')){
fprintf(stderr,
"Translation of %s failed.\n%s\n", Root, CDStatusString);
exit(1);
}
if (Not CDTo(TmpFile,JnkFile,ScaleB*RESOLUTION,RESOLUTION,'k')) {
printf("Translation of %s failed.\n%s\n",TmpFile,CDStatusString);
exit(1);
}
#ifdef vms
sprintf(Root,"DEL %s;*",TmpFile);
system(Root);
sprintf(Root,"DEL %s;*",JnkFile);
system(Root);
#else
unlink(TmpFile);
unlink(JnkFile);
#endif
return (0);
}
char *
nextarg()
{
if(argv[1][2] != '\0')
return(&argv[1][2]);
argv++;
argc--;
return (argv[1]);
}
void
MallocFailed()
{
if (CDStatusInt != CDMALLOCFAILED) return;
fprintf(stderr,"OUT OF MEMORY. This is a fatal error!\n");
exit(1);
}
/* for callbacks in cd, not used */
void UpdateProperties() {}
FILE *OpenDevice() {return NULL;}
/* ARGSUSED */
void CDLabelBB(p,a,b,c,d)
struct o *p;
int *a, *b, *c, *d;
{}
void
help()
{
printf("\nUsage: scale [options] [root_kic_cell]\n\n");
printf("options (case insensitive):\n");
printf(" -A numer numerator, positive >= 1\n");
printf(" -B denom denominator, positive >= 1\n");
printf(" -Text use %s.ext file for layers\n\n",TECHNAME);
printf("Multiplies cell coordinates by numer/denom, and\n");
printf("OVERWRITES THE CELLS REFERENCED!!!\n");
exit(0);
}
kic-2.4c/src/bin/kic.rc 0000644 0000764 0000764 00000000230 07525346711 014354 0 ustar stevew stevew
#include "windows.h"
#include "winver.h"
#define IDR_MAINFRAME 1
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDR_MAINFRAME ICON DISCARDABLE "kic.ico"
kic-2.4c/src/bin/global.c 0000644 0000764 0000764 00000021151 12427441573 014670 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
#ifdef WIN32
#include
#endif
#include "prefix.h"
#include
#include
#include
#include
#include
char *VersionString = VERSION_STR;
char *TECHFILE;
char *TECH_EXT;
char *PATH_TO_HELP;
char *DEFAULTLTAB;
char *MFBRCD;
#ifdef __STDC__
static char *_copy_str(char*);
#else
static char *_copy_str();
#endif
#ifdef WIN32
/* The following stuff determines the installation location. */
/*
Advance past the terminating quote character, copying into bf if
given. If inclq, include the quotes in bf. The character
referenced by s should be a single or double quote (no checking
here). This keeps track of nesting. Note that bf is *not* given a
terminating 0.
*/
void
advq(char **s, char **bf, int inclq)
{
int bs = 0;
char quotechar = **s;
if (bf && inclq)
*(*bf)++ = quotechar;
(*s)++;
while (**s && (**s != quotechar || bs)) {
if (**s == '\\') {
bs = 1;
if (bf)
*(*bf)++ = **s;
(*s)++;
}
else if ((**s == '"' || **s == '\'') && !bs)
advq(s, bf, 1);
else {
if (bf) {
if (**s == quotechar && bs && !inclq)
(*bf)--;
*(*bf)++ = **s;
}
bs = 0;
(*s)++;
}
}
if (**s == quotechar) {
if (bf && inclq)
*(*bf)++ = **s;
(*s)++;
}
}
/*
As for gettok(), but handle single and double quoted substrings.
The outermost quotes are stripped, and the enclosing characters are
added to adjacent tokens, if any. Alternate nested quoting is
preserved. The backslash can be used to hide the quote marks.
Unlike gettok(), this can return an empty string.
*/
char *
getqtok(char **s)
{
char *st, *cbuf, *c;
int bs = 0;
if (s == 0 || *s == 0)
return (0);
while (isspace(**s))
(*s)++;
if (!**s)
return (0);
st = *s;
while (**s && !isspace(**s)) {
if (**s == '\\') {
bs = 1;
(*s)++;
}
else if ((**s == '"' || **s == '\'') && !bs)
advq(s, 0, 0);
else {
bs = 0;
(*s)++;
}
}
cbuf = (char*)malloc(*s - st + 1);
c = cbuf;
while (st < *s) {
if (*st == '\\') {
bs = 1;
*c++ = *st++;
}
else if ((*st == '"' || *st == '\'') && !bs)
advq(&st, &c, 0);
else {
if ((*st == '"' || *st == '\'') && bs)
c--;
bs = 0;
*c++ = *st++;
}
}
*c = 0;
while (isspace(**s))
(*s)++;
return (cbuf);
}
/*
Convert to UNIX style path
*/
void
unix_path(char *path)
{
if (path) {
char *s;
for (s = path; *s; s++) {
if (*s == '\\')
*s = '/';
}
}
}
/*
The inno installer places an item in the registry which gives the
location of the uninstall directory. Return the full path to the
directory containing this directory. The returned path uses '/' as
the separator character.
This assumes admin install only.
*/
static char *
get_inno_uninst(const char *program)
{
/* note that "program" is the name used by the installer */
char buf[1024], *s, *p;
DWORD len, type;
HKEY key;
long ret;
sprintf(buf,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s_is1",
program);
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, KEY_READ, &key);
if (ret != ERROR_SUCCESS)
return (0);
len = 1024;
ret = RegQueryValueEx(key, "UninstallString", 0, &type, (BYTE*)buf, &len);
RegCloseKey(key);
/* The string should contain the full path to the uninstall program, */
if (ret != ERROR_SUCCESS || type != REG_SZ || len < 20)
return (0);
s = buf;
p = getqtok(&s);
s = strrchr(p, '\\');
if (!s) {
free(p);
return (0);
}
*s = 0;
s = strrchr(p, '\\');
if (!s) {
free(p);
return (0);
}
*s = 0;
unix_path(p);
return (p);
}
/*
Return a pointer to the last directory separator character found
in string
*/
char *
strrdirsep(char *string)
{
char *s;
if (!string)
return (0);
for (s = string + strlen(string) - 1; s >= string; s--) {
if (*s == '/' || *s == '\\')
return (s);
}
return (0);
}
/*
The Ghost Installer places an item in the registry which gives the
location of the uninstall.log file. Return the full path to the
directory containing this file. The returned path uses '/' as the
separator character
*/
static char *
get_gins_uninst(const char *program)
{
/* note that "program" is the name used by the installer */
char buf[1024], *s, *t, *dir;
DWORD len, type;
HKEY key;
long ret;
int ok;
sprintf(buf, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s",
program);
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, KEY_READ, &key);
if (ret != ERROR_SUCCESS)
return (0);
len = 1024;
ret = RegQueryValueEx(key, "UninstallString", 0, &type, (BYTE*)buf, &len);
RegCloseKey(key);
/*
The string should contain the full path to the uninstall program,
followed by the path to the uninstall log file, possibly quoted.
If the string length is too short to make sense, abort
*/
if (ret != ERROR_SUCCESS || type != REG_SZ || len < 20)
return (0);
s = _copy_str(buf);
/*
Remove any quotes, and peel off the argument of the uninstall
command, which is the full path to install.log
*/
t = s + strlen(s) - 1;
while (t >= s && *t == '"')
*t-- = '\0';
while (t > s && *t != '"' && (!isalpha(*t) || *(t+1) != ':' ||
(*(t+2) != '/' && *(t+2) != '\\')))
t--;
dir = 0;
ok = 0;
if (t > s && *t != '"') {
/* found the start of the path */
dir = _copy_str(t);
t = strrdirsep(dir);
if (t) {
*t = 0; /* stripped "/uninstall.log"; */
ok = 1;
}
}
free(s);
if (!ok) {
free(dir);
dir = 0;
}
unix_path(dir);
return (dir);
}
/*
Return the path to the uninstall data.
*/
static char *
get_from_registry()
{
char *dir = get_inno_uninst("Kic");
if (!dir)
dir = get_gins_uninst("Kic");
return (dir);
}
#endif
void
fatal_error(const char *msg)
{
if (!msg)
msg = "Unknown error.";
#ifdef WIN32
MessageBox(0, msg, "KIC Fatal Error", MB_ICONSTOP);
#else
fprintf(stderr, "Fatal Error: %s\n", msg);
#endif
exit(1);
}
void
InitGlobal()
{
char *startupdir, *s;
startupdir = getenv("KIC_LIB_DIR");
#ifdef WIN32
if (startupdir == NULL)
startupdir = get_from_registry();
#endif
if (startupdir == NULL)
startupdir = KIC_LIB_DIR;
s = malloc(strlen(startupdir) + 1);
if (s == NULL)
goto bad;
(void)strcpy(s,startupdir);
startupdir = s;
MFBRCD = startupdir;
DEFAULTLTAB = startupdir;
PATH_TO_HELP = startupdir;
return;
bad:
fatal_error("Memory allocation failure.");
}
/* subsidiary basename for layer description file */
#ifdef MSDOS
#define TECHNAMETOO "dotkic"
#else
#define TECHNAMETOO ".KIC"
#endif
static char *
_copy_str(src)
char *src;
{
char *dst = (char*)malloc(strlen(src)+1);
if (!dst)
fatal_error("Memory allocation failure.");
strcpy(dst,src);
return (dst);
}
FILE *
OpenTechFile()
{
FILE *fp;
char buf[256];
if (TECH_EXT)
sprintf(buf,"%s.%s",TECHNAME,TECH_EXT);
else
strcpy(buf,TECHNAME);
fp = fopen(buf, "r");
if (fp) {
TECHFILE = _copy_str(buf);
return (fp);
}
if (TECH_EXT)
sprintf(buf,"%s.%s",TECHNAMETOO,TECH_EXT);
else
strcpy(buf,TECHNAMETOO);
fp = fopen(buf, "r");
if (fp) {
TECHFILE = _copy_str(buf);
return (fp);
}
if (TECH_EXT)
sprintf(buf,"%s%c%s.%s",DEFAULTLTAB,DIRC,TECHNAME,TECH_EXT);
else
sprintf(buf,"%s%c%s",DEFAULTLTAB,DIRC,TECHNAME);
fp = fopen(buf,"r");
if (fp) {
TECHFILE = _copy_str(buf);
return (fp);
}
if (TECH_EXT)
sprintf(buf,"%s%c%s.%s",DEFAULTLTAB,DIRC,TECHNAMETOO,TECH_EXT);
else
sprintf(buf,"%s%c%s",DEFAULTLTAB,DIRC,TECHNAMETOO);
fp = fopen(buf,"r");
if (fp) {
TECHFILE = _copy_str(buf);
return (fp);
}
return (NULL);
}
kic-2.4c/src/bin/Makefile.in 0000644 0000764 0000764 00000011074 11133216577 015331 0 ustar stevew stevew #######################################################################
# src/bin/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
prefix = @prefix@
CC = @CC@
CFLAGS = @CFLAGS@
LIBS = @LIBS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
INSTALL = @INSTALL@
INSTALL_USER = @INSTALL_USER@
FILTER = @FILTER@
NTSUFFIX = @NTSUFFIX@
RESOURCE = @RESOURCE@
MFB = @MFB@
KIC_LIB_DIR = $(prefix)/lib/kic
KIC_EXEC_DIR = $(prefix)/bin
####### Executable targets ############################################
INCLUDE = -I../include
TARGETS = kic kichelp kictocif ciftokic kictostr strtokic strmtext kicscale
all: $(TARGETS:.exe=)
kic: kicmain.o global.o $(RESOURCE) ../kic.a ../cd.a ../convert.a ../help.a \
../ginterf.a $(MFB)
$(CC) -o kic kicmain.o global.o $(RESOURCE) \
../kic.a ../cd.a ../convert.a ../help.a ../ginterf.a \
$(MFB) $(LIBS)
kichelp: helpmain.o global.o ../help.a $(MFB) ../cd.a
$(CC) $(CC_OPT) -o kichelp helpmain.o global.o ../help.a $(MFB) \
../cd.a $(LIBS)
cif: ciftokic kictocif
kictocif: kictocif.o global.o ../kic.a ../cd.a
$(CC) -o kictocif kictocif.o global.o ../kic.a ../cd.a -lm
ciftokic: ciftokic.o global.o ../cd.a
$(CC) -o ciftokic ciftokic.o global.o ../cd.a -lm
stream: kictostr strtokic strmtext
kictostr: kictostr.o global.o ../kic.a ../cd.a
$(CC) -o kictostr kictostr.o global.o ../kic.a ../cd.a -lm
strtokic: strtokic.o global.o ../cd.a
$(CC) -o strtokic strtokic.o global.o ../cd.a -lm
strmtext: strmtext.o
$(CC) -o strmtext strmtext.o -lm
kicscale: kicscale.o global.o ../kic.a ../cd.a
$(CC) -o kicscale kicscale.o global.o ../kic.a ../cd.a -lm
####### Object file targets ###########################################
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
global.o:
$(CC) $(CFLAGS) -DKIC_LIB_DIR=\"$(KIC_LIB_DIR)\" \
-DVERSION_STR="\"$(VERSION)\"" $(INCLUDE) -c $*.c
kicrc.o: kic.rc
windres kic.rc kicrc.o
####### Recursively generate libraries ################################
LIBRARIES = ../cd.a ../convert.a ../ginterf.a ../help.a ../kic.a $(MFB)
$(LIBRARIES)::
cd $(@:.a=); $(MAKE)
####### Dependencies ##################################################
CFILES = ciftokic.c helpmain.c kictocif.c kicscale.c strtokic.c global.c \
kicmain.c kictostr.c strmtext.c
depend::
@echo depending in src/bin
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
-@cd ../cd; $(MAKE) depend
-@cd ../convert; $(MAKE) depend
-@cd ../ginterf; $(MAKE) depend
-@cd ../help; $(MAKE) depend
-@cd ../kic; $(MAKE) depend
-@if [ x$(MFB) != "x" ]; then \
cd ../xmfb; $(MAKE) depend; \
fi
####### Clean up ######################################################
clean:
-cd ../cd; $(MAKE) clean
-cd ../convert; $(MAKE) clean
-cd ../ginterf; $(MAKE) clean
-cd ../help; $(MAKE) clean
-cd ../kic; $(MAKE) clean
-@if [ x$(MFB) != "x" ]; then \
cd ../xmfb; $(MAKE) clean; \
fi
-rm *.o kic$(NTSUFFIX) ciftokic$(NTSUFFIX) kictocif$(NTSUFFIX) \
strtokic$(NTSUFFIX) kictostr$(NTSUFFIX) strmtext$(NTSUFFIX) \
kicscale$(NTSUFFIX) kichelp$(NTSUFFIX)
distclean::
-cd ../cd; $(MAKE) distclean
-cd ../convert; $(MAKE) distclean
-cd ../ginterf; $(MAKE) distclean
-cd ../help; $(MAKE) distclean
-cd ../kic; $(MAKE) distclean
-@if [ x$(MFB) != "x" ]; then \
cd ../xmfb; $(MAKE) distclean; \
fi
-rm *.o kic$(NTSUFFIX) ciftokic$(NTSUFFIX) kictocif$(NTSUFFIX) \
strtokic$(NTSUFFIX) kictostr$(NTSUFFIX) strmtext$(NTSUFFIX) \
kicscale$(NTSUFFIX) kichelp$(NTSUFFIX) Makefile
####### Install #######################################################
INSTALL_BIN = $(INSTALL) -sc -m 0755 $(INSTALL_USER)
INSTALL_LIB = $(INSTALL) -c -m 0644 $(INSTALL_USER)
install: $(TARGETS) $(KIC_EXEC_DIR) $(KIC_LIB_DIR)
$(KIC_EXEC_DIR)::
@../../util/mkdirpth $@
@for aa in $(TARGETS); \
do \
if [ -x $$aa$(NTSUFFIX) ]; then \
echo installing $$aa in $(prefix)/bin; \
$(INSTALL_BIN) $$aa$(NTSUFFIX) $(prefix)/bin; \
else \
echo Warning: executable $$aa$(NTSUFFIX) not found.; \
fi \
done
$(KIC_LIB_DIR)::
@../../util/mkdirpth $@
$(INSTALL_LIB) ../../startup/* $@
uninstall::
-for aa in $(TARGETS); \
do \
if [ -x $(KIC_EXEC_DIR)/$$aa$(NTSUFFIX) ]; then \
rm -f $(KIC_EXEC_DIR)/$$aa$(NTSUFFIX); \
fi \
done
-if [ -d $(KIC_LIB_DIR) ]; then \
rm -rf $(KIC_LIB_DIR); \
fi
#######################################################################
kic-2.4c/src/bin/strtokic.c 0000644 0000764 0000764 00000165467 12427443524 015313 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1983 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* strmtokic.c
*
* This program was extensively modified by S.R. Whiteley 2/20/91.
* Notes:
* 1. Convert to rectangles is off by default. The -P option turns
* conversion on. Originally, this logic was reversed. However,
* four sided manhattan polygons are always converted to rectangles.
* 2. Arrays are created in-place rather than as new symbols. The
* Array user extension stores the unrotated center to center
* spacing in the DX and DY fields, which is not compatible with
* the original KIC format.
*/
#include "prefix.h"
#include "stream.h"
#include
#include
#include
#include
#include
/* Define to 1 to convert symbol names to lower case. This was true in
* previous versions of Kic.
*/
#define TOLWR 0
/*
* We use the property list of KIC symbols to save the library information;
* The value of the property is the numeric value of the STREAM record
* type offset by 7000 (e.g. 7000 is the KIC property value describing the
* STREAM version number, 7002 is the KIC property value describing the
* STREAM library name, etc.) The offset of 7000 was arbitrarily selected,
* and care must be taken so that this value does not conflict with any
* other convention. The PROPERTYOFFSET define is for convenience.
*
* The STREAM-specific property list is attributed to every KIC symbol,
* and 'kictostrm' will look for this information.
*/
struct headerlist{
int hd_RecordType;
char hd_Text[512];
struct headerlist *hd_Succ;
};
typedef struct headerlist HEADLIST;
int IbigEndian;
int FbigEndian;
#define TMPFILE "yyXXXXXX"
int ByteSwap;
int ConvertToRectangles;
int NumLayerTable;
int LayerNumbers[256];
int CurrentLayer;
int CurrentAttribute;
int DataTypeNumbers[256];
int CurrentDataType;
int NumSymbols;
int UseLayerTable;
int struct_dates[12];
int CurrentSize;
int Root_flag;
int CurrentOffset;
int XYbuf[MAXSTRMCOORDS];
FILE *stderror;
FILE *SymDesc;
char *SymbolNames[MAXSYMBOLS];
char *LayerNames[256];
char CurrentSymbol[45];
char RootSymbol[45];
double ScaleFactor;
FILE *STREAMFILE;
static int NumArefs;
static int RootSymbolNumber = -1;
#if __STDC__
extern void help(void);
extern int fptest(int*,int*);
extern void symdef(char*,HEADLIST*);
extern void s_bndry(char*);
extern void s_path(char*);
extern void s_sref(char*);
extern void s_aref(char*);
extern void s_text(char*);
extern char *nextarg(void);
extern int get_record(char*);
extern int struct_index(char*);
extern void PrintLayer(int,int);
extern FILE *open_symbol(char*);
extern void new_symbol(char*);
extern void set_property_value(char*,int);
extern int path_to_rect(int,int*);
extern void set_path(char*,int,int*);
extern void set_instance(int,int,int,int,double);
extern void set_array(int,int,int,int,double,int*);
extern void read_layer_table(FILE*);
extern void read_tech_layers(FILE*);
extern int set_angle(double,int*,int*);
extern int strm_ival(char*);
extern int strm_longval(char*);
extern double strm_doubleval(char*);
extern void err_fatal(char*,char*);
extern void err_fatal_1(char*,char*);
extern void err_fatal_2(char*,int);
extern void err_warn_1(char*,char*,char*);
extern void err_warn_2(char*,int,char*);
extern char *alias(char*);
extern void dumpalias(void);
extern void convert_pathtype(int*,int*,int,int,int);
extern RECT *pgtorex(PATHLIST*);
extern int lowx(const void*,const void*);
extern int lowy(const void*,const void*);
extern int orient(PATHLIST**,int,int*);
extern int cross(PATHLIST*,int,int,int);
extern RECT* makerect(int,int,int,int,RECT*);
extern void freepath(PATHLIST**);
extern char *tmalloc(unsigned);
static void file_open(char*);
static char *get_token(FILE*);
#else
extern void help();
extern int fptest();
extern void symdef();
extern void s_bndry();
extern void s_path();
extern void s_sref();
extern void s_aref();
extern void s_text();
extern char *nextarg();
extern int get_record();
extern int struct_index();
extern void PrintLayer();
extern FILE *open_symbol();
extern void new_symbol();
extern void set_property_value();
extern int path_to_rect();
extern void set_path();
extern void set_instance();
extern void set_array();
extern void read_layer_table();
extern void read_tech_layers();
extern int set_angle();
extern int strm_ival();
extern int strm_longval();
extern double strm_doubleval();
extern void err_fatal();
extern void err_fatal_1();
extern void err_fatal_2();
extern void err_warn_1();
extern void err_warn_2();
extern char *alias();
extern void dumpalias();
extern void convert_pathtype();
extern RECT *pgtorex();
extern int lowx();
extern int lowy();
extern int orient();
extern int cross();
extern RECT* makerect();
extern void freepath();
extern char *tmalloc();
static void file_open();
static char *get_token();
#endif
#define LONGSCALE(n) (int)(floor(ScaleFactor * ((double)(n)) + 0.5))
#define NEWPATH (PATHLIST *) tmalloc((unsigned) sizeof(PATHLIST))
#define NEWHEAD (HEADLIST *) tmalloc((unsigned) sizeof(HEADLIST))
char **argv;
int argc;
int
main(ac, av)
int ac;
char *av[];
{
double a,b;
double micprl;
FILE *RootDesc;
HEADLIST *HeaderCopy;
HEADLIST *SymbolProps;
char *cp;
int StandardError;
int i;
int type;
int UseStreamNames = 0;
char cbuf[MAXRECSIZE + 4];
char RootFileName[81];
char StreamFile[81];
char LayerFile[81];
char *Tmp, *Tech;
/* STREAMTOKIC
*
* Giles Billingsley 3/30/83
*
* options:
* -P convert manhattan polygons to boxes
* -E print errors in file "strtokic.err"
* -Csname sname = Root structure name
* -Rfilename filename = name of root cell
* -Xfilename filename = cif layer reference file
* -N use stream names
* -Lmicprl micron per lambda
*/
if (fptest(&IbigEndian,&FbigEndian)) {
fprintf(stderr,"Error: incompatible floating point format.\n");
exit(1);
}
InitGlobal();
#ifdef MSDOS
readalias();
#endif
stderror = stderr;
RootSymbol[0] = '\0';
RootFileName[0] = '\0';
LayerFile[0] = '\0';
SymbolProps = NULL;
Root_flag = 0;
UseLayerTable = 0;
StandardError = 0;
ScaleFactor = 1.0;
micprl = 1.0;
argc = ac;
argv = av;
while (argc > 1 && argv[1][0] == '-') {
switch (argv[1][1]) {
case 'C':
case 'c':
strcpy(RootSymbol,nextarg());
Root_flag = 1;
/* convert to upper case */
i = 0;
while (RootSymbol[i] != '\0') {
if (RootSymbol[i] >= 'a' && RootSymbol[i] <= 'z')
RootSymbol[i] -= 32;
i++;
}
break;
case 'R':
case 'r':
strcpy(RootFileName,nextarg());
break;
case 'L':
case 'l':
if (sscanf(nextarg(),"%lg",&micprl) != 1)
err_fatal("Incorrect microns per lambda",*argv);
break;
case 'E':
case 'e':
StandardError = 1;
break;
case 'X':
case 'x':
strcpy(LayerFile,nextarg());
break;
case 'P':
case 'p':
ConvertToRectangles = 1;
break;
case 'N':
case 'n':
UseStreamNames = 1;
break;
case 'T':
case 't':
Tech = nextarg();
#ifdef MSDOS
if (strlen(Tech) > 3)
Tech[3] = '\0';
#endif
TECH_EXT = malloc(strlen(Tech) + 1);
if (TECH_EXT == NULL) {
(void)fprintf(stderr,
"Memory allocation failure on startup.\n");
exit(1);
}
strcpy(TECH_EXT,Tech);
break;
default:
help();
}
argc--;
argv++;
}
if (argc > 1) {
if ((STREAMFILE = fopen((cp = argv[1]),"rb")) == NULL) {
err_fatal_1("Can't open stream file",cp);
}
printf("Opening Stream file: %s\n",cp);
}
else {
printf("Stream file to convert? (hit return for help) ");
Tmp = malloc(81);
*Tmp = '\0';
fgets(Tmp,81,stdin);
if (sscanf(Tmp,"%s",StreamFile) != 1)
help();
free(Tmp);
if ((STREAMFILE = fopen(StreamFile,"rb")) == NULL)
err_fatal_1("Can't open stream file",StreamFile);
}
if (!UseStreamNames) {
if (LayerFile[0]) {
file_open(LayerFile);
UseLayerTable = 1;
}
else {
FILE *fp = OpenTechFile();
if (fp) {
printf("Using tech file %s\n",TECHFILE);
read_tech_layers(fp);
sprintf(LayerFile,"%s",TECHFILE);
UseLayerTable = 1;
fclose(fp);
}
else {
sprintf(LayerFile,"%s%c%s",DEFAULTLTAB,DIRC,"ltab");
if ((fp = fopen(LayerFile,"r")) != NULL) {
printf("Using default layer table %s\n",LayerFile);
read_layer_table(fp);
UseLayerTable = 1;
fclose(fp);
}
}
if (!UseLayerTable) {
err_fatal("Layer table not found,","(use -n option?)");
}
if (!NumLayerTable) {
err_fatal("Layer table has no entries,","(use -n option?)");
}
}
}
else {
printf("Using stream input layer data for layer names\n");
}
if (StandardError) {
if ((stderror = fopen(cp = "strtokic.err","w")) == NULL)
err_fatal_1("Can't open errors file",cp);
}
else
stderror = stderr;
if (RootFileName[0] == '\0')
strcpy(RootFileName,"Root");
if ((RootDesc = fopen(RootFileName,"w")) == NULL)
err_fatal_1("Can't open root file file",RootFileName);
printf("Root file name : %s\n",RootFileName);
if (Root_flag)
printf("Root Symbol : %s\n",RootSymbol);
printf("Microns Per Lambda : %f\n",micprl);
if (ConvertToRectangles)
printf("Will convert manhattan polygons to rectangles.\n");
else
printf("Will NOT convert manhattan polygons to rectangles.\n");
NumSymbols = 0;
/* byte swap test */
if ((i = getc(STREAMFILE)) != 0) {
printf("Swapping bytes of input file.\n");
ByteSwap = 1;
}
ungetc(i,STREAMFILE);
/* build the symbol table */
printf("Creating symbol table... ");
while ((type = get_record(cbuf)) != 4)
if (type == 6) {
if (TOLWR)
to_lower_case(cbuf);
new_symbol(cbuf);
}
printf("done.\n");
rewind(STREAMFILE);
/* loop through the records and exit on ENDLIB */
while ((type = get_record(cbuf))!= ENDLIB) {
switch(type) {
case HEADER:
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = HEADER + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
sprintf(HeaderCopy->hd_Text,"%d",strm_ival(cbuf));
fprintf(RootDesc,"( VERSION %d );\n",strm_ival(cbuf));
fprintf(RootDesc,"5 %d %d;\n",PROPERTYOFFSET + HEADER,
strm_ival(cbuf));
break;
case BGNLIB:
fprintf(RootDesc,"( MOD DATE ");
for (i = 0; i < 12; i += 2)
fprintf(RootDesc,"%d ",strm_ival(cbuf+i));
fprintf(RootDesc,": ACCESS DATE ");
for (i = 12; i < 24; i += 2)
fprintf(RootDesc,"%d ",strm_ival(cbuf+i));
fprintf(RootDesc,");\n");
break;
case LIBNAME:
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = LIBNAME + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
strcpy(HeaderCopy->hd_Text,cbuf);
fprintf(RootDesc,"( LIBNAME %s );\n",cbuf);
fprintf(RootDesc,"5 %d %s;\n",PROPERTYOFFSET + LIBNAME,cbuf);
break;
case UNITS:
a = strm_doubleval(cbuf);
b = strm_doubleval(cbuf+8);
fprintf(RootDesc,"( SCALE: %e UNITS/DBU, %e METERS/DBU );\n",
a,b);
fprintf(RootDesc,"( MICRONS PER LAMBDA = %f );\n",micprl);
/*
* The length of the database unit is 1e-8 meters.
*
* meters .01 microns lambdas lambdas
* ------ * ----------- * ----------- = -------
* DBU meter .01 microns DBU
*/
ScaleFactor = (1e8 * b)/(micprl);
break;
case BGNSTR:
for (i = 0; i < 12; i++)
struct_dates[i] = strm_ival(cbuf + (i << 1));
break;
case STRNAME:
symdef(cbuf,SymbolProps);
fprintf(SymDesc,"DF;\n");
fprintf(SymDesc,"E\n");
fclose(SymDesc);
break;
case REFLIBS:
if (cbuf[0] != '\0')
fprintf(RootDesc,"( REFLIB1 %s );\n",cbuf);
if (cbuf[44] != '\0')
fprintf(RootDesc,"( REFLIB2 %s );\n",cbuf+44);
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = REFLIBS + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
sprintf(HeaderCopy->hd_Text,"%s %s",cbuf,cbuf+44);
fprintf(RootDesc,"5 %d %s %s;\n",
PROPERTYOFFSET + REFLIBS,cbuf,cbuf+44);
break;
case FONTS:
if (cbuf[0] != '\0')
fprintf(RootDesc,"( FONT1 %s );\n",cbuf);
if (cbuf[44] != '\0')
fprintf(RootDesc,"( FONT2 %s );\n",cbuf+44);
if (cbuf[88] != '\0')
fprintf(RootDesc,"( FONT3 %s );\n",cbuf+88);
if (cbuf[132] != '\0')
fprintf(RootDesc,"( FONT4 %s );\n",cbuf+132);
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = FONTS + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
sprintf(HeaderCopy->hd_Text,"%s %s %s %s",cbuf,
cbuf+44,cbuf+88,cbuf+132);
fprintf(RootDesc,"5 %d %s %s %s %s;\n",
PROPERTYOFFSET + FONTS,cbuf,cbuf+44,cbuf+88,cbuf+132);
break;
case GENERATIONS:
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = GENERATIONS + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
sprintf(HeaderCopy->hd_Text,"%d",strm_ival(cbuf));
fprintf(RootDesc,"( GENERATIONS %d );\n",strm_ival(cbuf));
fprintf(RootDesc,"5 %d %d;\n",PROPERTYOFFSET + GENERATIONS,
strm_ival(cbuf));
break;
case ATTRTABLE:
HeaderCopy = NEWHEAD;
HeaderCopy->hd_RecordType = ATTRTABLE + PROPERTYOFFSET;
HeaderCopy->hd_Succ = SymbolProps;
SymbolProps = HeaderCopy;
strcpy(HeaderCopy->hd_Text,cbuf);
if (cbuf[0] != '\0')
fprintf(RootDesc,"( ATTRIBUTE TABLE %s );\n",cbuf);
fprintf(RootDesc,"5 %d %s;\n",PROPERTYOFFSET + ATTRTABLE,cbuf);
break;
default:
/*
err_fatal_2("Illegal record type",type);
*/
fprintf(stderr,"Warning: unknown record type %d\n",type);
}
}
fprintf(RootDesc,"9 %s;\n",RootFileName);
fprintf(RootDesc,"DS 0 1 1;\n");
if (Root_flag) {
if (RootSymbolNumber < 0) {
fprintf(RootDesc,"( Root structure %s not found. );\n",RootSymbol);
fprintf(RootDesc,"9 %s;\n",SymbolNames[0]);
fprintf(RootDesc,"C 1;\n");
fprintf(stderror,"Warning: Root structure not found.\n");
}
else {
fprintf(RootDesc,"9 %s;\n",SymbolNames[RootSymbolNumber-1]);
fprintf(RootDesc,"C %d;\n",RootSymbolNumber);
}
}
else {
if (NumSymbols > 0) {
fprintf(RootDesc,"9 %s;\n",SymbolNames[0]);
fprintf(RootDesc,"C 1;\n");
}
}
fprintf(RootDesc,"(** STREAM-KIC SYMBOL TABLE **);\n");
for (i = 0; i < NumSymbols; ++i)
fprintf(RootDesc,"( %-16s = %d );\n",SymbolNames[i],i+1);
fprintf(RootDesc,"DF;\n");
fprintf(RootDesc,"E\n");
fclose(RootDesc);
#ifdef MSDOS
dumpalias();
#endif
return (0);
}
void
help()
{
printf("\nstrtokic-%s\n\n",VersionString);
printf("Usage: strtokic [options] [streamfile]\n\n");
printf("options (case insensitive):\n");
printf(" -P convert manhattan polygons to boxes,\n");
printf(" four-sided polygons are always converted\n");
printf(" -E print errors in file \"strmtokic.err\" (default stderr)\n");
printf(" -Csname sname = Root structure name (default, convert everything)\n");
printf(" -Rfilename filename = name of root cell (default \"Root\")\n");
printf(" -Xfilename filename = layer table reference file\n");
printf(" -N use stream layer numbers for layer names\n");
printf(" -Text use tech.ext for layers\n");
printf(" -Lmicprl micron per lambda (default 1.0)\n\n");
printf("Default layer info is from tech file.\n\n");
exit(0);
}
#define False 0
#define True 1
int
fptest(iflg,dflg)
/* Determine whether the CPU stores integers and doubles in big or little
* endian format. If the least significant bits are found in the
* char at the data item address, then the format is little endian.
* The sign bit and exponent are the most significant bits of the
* double.
* The flags are set true if big endian. If either format is not
* recognized, true is returned.
*/
int *iflg, *dflg;
{
union {double d; unsigned int l[2];
unsigned short i[4]; unsigned char c[8];} u;
u.d = -2.0;
if (u.c[7] == 0xc0)
*dflg = False;
else if (u.c[0] == 0xc0)
*dflg = True;
else
return (True);
u.l[0] = 1L;
if (u.c[0] == 1)
*iflg = False;
else if (u.c[3] == 1)
*iflg = True;
else
return (True);
return (False);
}
void
symdef(cbuf,SymbolProps)
char *cbuf;
HEADLIST *SymbolProps;
{
/*
* BEGIN SYMBOL DEFINITION
*/
int i;
int index;
int type;
if (TOLWR)
to_lower_case(cbuf);
CurrentLayer = CurrentDataType = CurrentAttribute = -1;
/* search for symbol number */
index = struct_index(cbuf);
strcpy(CurrentSymbol,cbuf);
#ifdef MSDOS
{ char *c;
SymDesc = open_symbol(c = alias(cbuf));
if (!strcmp(c,cbuf))
printf("Converting: %s\n",cbuf);
else
printf("Converting: %-30s(new name: %s)\n",cbuf,c);}
#else
SymDesc = open_symbol(cbuf);
printf("Converting: %s\n",cbuf);
#endif
/* test for RootSymbol */
if (Root_flag) {
if (strcmp(RootSymbol,cbuf) == 0)
RootSymbolNumber = index;
}
/* add the symbol property list */
while (SymbolProps != NULL) {
fprintf(SymDesc,"5 %d %s;\n",SymbolProps->hd_RecordType,
SymbolProps->hd_Text);
SymbolProps = SymbolProps->hd_Succ;
}
fprintf(SymDesc,"9 %s;\n",cbuf);
fprintf(SymDesc,"DS %d 1 1;\n",index);
fprintf(SymDesc,"( CREATION DATE ");
for (i = 0; i < 6; ++i)
fprintf(SymDesc,"%d ",struct_dates[i]);
fprintf(SymDesc,": MOD DATE ");
for (i = 0; i < 6; ++i)
fprintf(SymDesc,"%d ",struct_dates[i+6]);
fprintf(SymDesc,");\n");
/*
* loop through records and exit on ENDSTR
*/
while ((type = get_record(cbuf)) != ENDSTR) {
switch(type) {
case BOUNDARY:
s_bndry(cbuf);
break;
case PATH:
s_path(cbuf);
break;
case SREF:
s_sref(cbuf);
break;
case AREF:
s_aref(cbuf);
break;
case TEXT:
s_text(cbuf);
break;
case SNAPNODE:
/*
* snapnodes are not used
*/
while ((type = get_record(cbuf)) != 17) ;
break;
default:
err_fatal_2("Illegal record type",type);
}
}
}
void
s_bndry(cbuf)
char *cbuf;
{
/*
* loop through records and exit on ENDEL
*/
int i;
int type;
int ncoords = 0;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case DATATYPE:
dtype = strm_ival(cbuf);
break;
case XY:
ncoords = CurrentSize/4;
for (i = 0; i < ncoords; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
ncoords /= 2;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
PrintLayer(layer,dtype);
if (ConvertToRectangles || ncoords == 5)
if (path_to_rect(ncoords,XYbuf)) return;
/* limit to 80 cols per line */
*cbuf = 'P';
*(cbuf+1) = '\0';
set_path(cbuf,ncoords,XYbuf);
}
void
s_path(cbuf)
char *cbuf;
{
/*
* loop through records and exit on ENDEL
*/
int pathwidth = 0;
int ptype = 0;
int i;
int type;
int ncoords = 0;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case DATATYPE:
dtype = strm_ival(cbuf);
break;
case WIDTH:
pathwidth = LONGSCALE( strm_longval(cbuf) );
break;
case XY:
ncoords = CurrentSize/4;
for (i = 0; i < ncoords; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
ncoords /= 2;
break;
case PATHTYPE:
/*
* STREAM pathtypes
* 0 = square ended paths with ends that are flush
* with the endpoints
* 1 = round ended (CIF like) paths
* 2 = square ended paths with ends that are
* offset from the endpoint by a half width.
*
* In KIC, we assume a pathtype of 2.
*/
if ((ptype = strm_ival(cbuf)) != 2)
fprintf(SymDesc,"( PATHTYPE %d CONVERTED TO PATHTYPE 2 );\n",ptype);
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
CurrentAttribute = -1;
break;
default:
err_fatal_2("Illegal record type",type);
}
}
PrintLayer(layer,dtype);
if (ptype == 0 && ncoords > 1) {
/*
* subtract a half width from the endpoints.
*/
convert_pathtype(&XYbuf[0],&XYbuf[1],XYbuf[2],XYbuf[3],pathwidth);
i = ncoords+ncoords-2;
convert_pathtype(&XYbuf[i],&XYbuf[i+1],XYbuf[i-2],XYbuf[i-1],pathwidth);
}
if (ptype != 2)
fprintf(SymDesc,"5 %d PATHTYPE %d;\n",PROPERTYOFFSET + PATHTYPE,ptype);
sprintf(cbuf,"W %d",pathwidth);
set_path(cbuf,ncoords,XYbuf);
}
void
s_sref(cbuf)
char *cbuf;
{
/*
* loop through records and exit on ENDEL
*/
double magn = 1,rotn = 0;
FILE *afile;
int cx = 0,cy = 0;
int lone;
int reflection = 0;
int j;
int index = 0;
int type;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case XY:
cx = LONGSCALE( strm_longval(cbuf) );
cy = LONGSCALE( strm_longval(cbuf+4) );
break;
case SNAME:
if (TOLWR)
to_lower_case(cbuf);
index = struct_index(cbuf);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf)/RADTODEG;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
if (magn == 1.0)
set_instance(index,reflection,cx,cy,rotn);
else {
err_warn_1("Magnification not unity",
SymbolNames[index-1],CurrentSymbol);
lone = (int)(100.0 * magn);
/*
* If magn is less than .01, then KIC does not
* have the resolution.
*/
if (lone > 0) {
j = 100;
while ( !(lone % 10) ) {
j /= 10;
lone /= 10;
}
++NumArefs;
new_symbol("AREF ");
sprintf(SymbolNames[NumSymbols-1]+4,"%d",NumArefs);
afile = open_symbol(SymbolNames[NumSymbols-1]);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-1]);
fprintf(afile,"DS %d %d %d;\n",NumSymbols,lone,j);
fprintf(afile,"9 %s;\n",SymbolNames[index-1]);
fprintf(afile,"C %d;\n",index);
fprintf(afile,"DF;\n");
fprintf(afile,"E\n");
fclose(afile);
set_instance(NumSymbols,reflection,cx,cy,rotn);
}
else
err_warn_1("Magnification too small",SymbolNames[index-1],
CurrentSymbol);
}
}
void
s_aref(cbuf)
char *cbuf;
{
/*
* loop through records and exit on ENDEL
*/
double magn = 1,rotn = 0;
FILE *afile;
int lone;
int reflection = 0;
int nx = 0,ny = 0;
int i,j;
int index = 0;
int type;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case XY:
for (i = 0; i < 6; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
break;
case SNAME:
if (TOLWR)
to_lower_case(cbuf);
index = struct_index(cbuf);
break;
case COLROW:
nx = strm_ival(cbuf);
ny = strm_ival(cbuf+2);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf)/RADTODEG;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
if (magn == 1.0)
set_array(index,reflection,nx,ny,rotn,XYbuf);
else {
err_warn_1("Magnification not unity",
SymbolNames[index-1],CurrentSymbol);
lone = (int)(100.0 * magn);
/*
* If magn is less than .01, then KIC does not
* have the resolution.
*/
if (lone > 0) {
j = 100;
while ( !(lone % 10) ) {
j /= 10;
lone /= 10;
}
++NumArefs;
new_symbol("AREF ");
sprintf(SymbolNames[NumSymbols-1]+4,"%d",NumArefs);
afile = open_symbol(SymbolNames[NumSymbols-1]);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-1]);
fprintf(afile,"DS %d %d %d;\n",NumSymbols,lone,j);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-2]);
fprintf(afile,"C %d;\n",index);
fprintf(afile,"DF;\n");
fprintf(afile,"E\n");
fclose(afile);
set_array(NumSymbols,reflection,nx,ny,rotn,XYbuf);
}
else
err_warn_1("Magnification too small",SymbolNames[index-1],
CurrentSymbol);
}
}
void
s_text(cbuf)
char *cbuf;
{
double magn = 1,rotn = 0;
char *cp, string[48];
int cx = 0,cy = 0;
int width = 0;
int ptype = 0;
int reflection = 0;
int present = 0;
int type;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case WIDTH:
width = LONGSCALE( strm_longval(cbuf) );
break;
case XY:
cx = LONGSCALE( strm_longval(cbuf) );
cy = LONGSCALE( strm_longval(cbuf+4) );
break;
case TEXTTYPE:
dtype = strm_ival(cbuf);
break;
case PRESENTATION:
present = strm_ival(cbuf);
break;
case STRING:
cp = cbuf;
while (*cp != '\0') {
if (*cp == ' ')
*cp = '_';
cp++;
}
strcpy(string,cbuf);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
else
reflection = 0;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf);
break;
case PATHTYPE:
/*
* STREAM pathtypes
* 0 = square ended paths with ends that are flush
* with the endpoints
* 1 = round ended (CIF like) paths
* 2 = square ended paths with ends that are
* offset from the endpoint by a half width.
*
* In KIC, we assume a pathtype of 2.
*/
ptype = strm_ival(cbuf);
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
PrintLayer(layer,dtype);
fprintf(SymDesc,
"5 %d WIDTH %d PRESENT %d PTYPE %d MAG %f ANGLE %f REFLECT %d;\n",
PROPERTYOFFSET + TEXT,width,present,ptype,magn,rotn,reflection);
fprintf(SymDesc,"94 %s %d %d;\n",string,cx,cy);
}
char *
nextarg()
{
if (argv[1][2] != '\0')
return(&argv[1][2]);
argv++;
argc--;
return(argv[1]);
}
int
get_record(cbuf)
char *cbuf;
{
int i;
int size;
unsigned byte0;
unsigned byte1;
unsigned dtype;
unsigned rtype;
CurrentOffset = ftell(STREAMFILE);
if (!ByteSwap) {
byte0 = getc(STREAMFILE);
byte1 = getc(STREAMFILE);
rtype = getc(STREAMFILE);
dtype = getc(STREAMFILE);
}
else {
byte1 = getc(STREAMFILE);
byte0 = getc(STREAMFILE);
dtype = getc(STREAMFILE);
rtype = getc(STREAMFILE);
}
(void)dtype;
size = byte0*256 + byte1 - 4;
if (size < 0) size = 0;
if (size > MAXRECSIZE)
err_fatal_2("Oversized record, size",size);
CurrentSize = size;
size >>= 1;
if (size && fread(cbuf,(size_t)size,(size_t)2,STREAMFILE) != 2)
err_fatal_1("Read error on input","");
size <<= 1;
if (CurrentSize != size) {
cbuf[size] = getc(STREAMFILE);
cbuf[size+1] = getc(STREAMFILE);
}
if (ByteSwap) {
for (i = 0; i < size; i += 2) {
byte0 = cbuf[i];
cbuf[i] = cbuf[i+1];
cbuf[i+1] = byte0;
}
if (CurrentSize != size)
cbuf[size] = cbuf[size+1];
}
if (CurrentSize != size)
ungetc(cbuf[size+1],STREAMFILE);
cbuf[CurrentSize] = '\0';
return rtype;
}
int
struct_index(cbuf)
char *cbuf;
{
int i;
/* the symbol table should be complete at this point */
for (i = 0; i < NumSymbols; ++i) {
#ifdef MSDOS
if (strcmp(SymbolNames[i],alias(cbuf)) == 0)
#else
if (strcmp(SymbolNames[i],cbuf) == 0)
#endif
return(i+1);
}
fprintf(stderror,"Warning: Undefined symbol %s.\n",cbuf);
new_symbol(cbuf);
return(NumSymbols);
}
void
PrintLayer(layer,datatype)
int layer;
int datatype;
{
int l;
char buf[128];
if (layer < 0 || datatype < 0 || layer > 255 || datatype > 255) {
sprintf(buf,"Illegal layer %d datatype",layer);
err_fatal_2(buf,datatype);
}
if (layer == CurrentLayer && datatype == CurrentDataType) return;
if (UseLayerTable) {
for (l = 0; l < NumLayerTable; ++l) {
if (LayerNumbers[l] == layer &&
(DataTypeNumbers[l] < 0 ||
DataTypeNumbers[l] == datatype)) {
if (layer == CurrentLayer && DataTypeNumbers[l] < 0)
return;
fprintf(SymDesc,"L %s;\n",LayerNames[l]);
break;
}
else if (l == NumLayerTable-1) {
sprintf(buf,"Undefined layer %d datatype",layer);
err_warn_2(buf,datatype,CurrentSymbol);
fprintf(SymDesc,"L %02d\n",layer);
return;
}
}
}
else {
if (layer < 10)
fprintf(SymDesc,"L 0%d",layer);
else
fprintf(SymDesc,"L %d",layer);
if (datatype < 10)
fprintf(SymDesc,"0%d;\n",datatype);
else
fprintf(SymDesc,"%d;\n",datatype);
}
CurrentLayer = layer;
CurrentDataType = datatype;
}
FILE *
open_symbol(name)
char *name;
{
FILE *fp;
if ((fp = fopen(name,"w")) == 0)
err_fatal_1("Can't open symbol",name);
return fp;
}
void
new_symbol(name)
char *name;
{
#ifdef MSDOS
name = alias(name);
#endif
if (NumSymbols >= MAXSYMBOLS)
err_fatal_2("Exceeded maximum symbol count of",MAXSYMBOLS);
SymbolNames[NumSymbols] = tmalloc(strlen(name)+1);
strcpy(SymbolNames[NumSymbols],name);
NumSymbols++;
}
void
set_property_value(string,type)
char *string;
int type;
{
if (CurrentAttribute < 1 || CurrentAttribute > 127) {
err_warn_2("Bad property record",type,CurrentSymbol);
CurrentAttribute = 127;
}
fprintf(SymDesc,"5 %d %s;\n",CurrentAttribute,string);
CurrentAttribute = -1;
}
int
path_to_rect(ncoords,xy)
int ncoords;
int *xy;
{
PATHLIST *StartPolyPathp;
PATHLIST *PolyPathp;
RECT *rectp;
RECT *reclistp;
int i;
int cx,cy;
int width,length;
PolyPathp = StartPolyPathp = NEWPATH;
PolyPathp->pathlink = StartPolyPathp;
for (i = 0; i < ncoords; ++i) {
PolyPathp = PolyPathp->pathlink;
PolyPathp->pathpoint.pointx = xy[i+i];
PolyPathp->pathpoint.pointy = xy[i+i+1];
PolyPathp->pathlink = NEWPATH;
}
PolyPathp->pathlink = NULL;
if ((reclistp = pgtorex(StartPolyPathp)) != NULL) {
rectp = reclistp;
while (rectp != NULL) {
length = (rectp->right - rectp->left);
width = (rectp->top - rectp->bottom);
cx = (rectp->left) + length/2;
cy = (rectp->bottom) + width/2;
if (length < 0)
length = -length;
if (width < 0)
width = -width;
fprintf(SymDesc,"B %d %d %d %d;\n",length,width,cx,cy);
reclistp = rectp;
rectp = rectp->r_next;
free(reclistp);
}
freepath(&StartPolyPathp);
return 1;
}
freepath(&StartPolyPathp);
return 0;
}
void
set_path(cbuf,ncoords,xy)
char *cbuf;
int ncoords;
int *xy;
{
int i, len, len1;
char buf1[40];
len = strlen(cbuf);
for (i = 0; i < ncoords; ++i) {
sprintf(buf1," %d %d",xy[i+i],xy[i+i+1]);
len1 = strlen(buf1);
if (len+len1 < 79) {
strcat(cbuf,buf1);
len += len1;
}
else {
fprintf(SymDesc,"%s\n ",cbuf);
strcpy(cbuf,buf1);
len = len1+1;
}
}
fprintf(SymDesc,"%s;\n",cbuf);
}
void
set_instance(index,reflection,cx,cy,rotn)
int index, reflection;
int cx,cy;
double rotn;
{
int i, j;
fprintf(SymDesc,"9 %s;\n",SymbolNames[index-1]);
fprintf(SymDesc,"C %d",index);
if (reflection) fprintf(SymDesc," MY");
if (set_angle(rotn,&i,&j))
fprintf(SymDesc," R %d %d",i,j);
fprintf(SymDesc," T %d %d;\n",cx,cy);
}
#define MIN(x,y) ((x) < (y) ? (x) : (y))
void
set_array(index,reflection,nx,ny,rotn,xy)
int index, reflection;
int nx,ny;
double rotn;
int *xy;
{
int i, j, k;
int dx,dy;
fprintf(SymDesc,"9 %s;\n",SymbolNames[index-1]);
k = set_angle(rotn,&i,&j);
/* xy[0] - xy[5] are coords of 3 points of BB, 0,1 reference */
/* one of two terms is zero */
dx = ((xy[2]-xy[0]) + (xy[3]-xy[1]))/nx;
if (dx < 0) dx = -dx;
dy = ((xy[5]-xy[1]) + (xy[4]-xy[0]))/ny;
if (dy < 0) dy = -dy;
fprintf(SymDesc,"1 Array %d %d %d %d;\n",nx,dx,ny,dy);
fprintf(SymDesc,"C 0");
if (reflection) fprintf(SymDesc," MY");
if (k == 1) /* 90 */
fprintf(SymDesc," R 0 1");
else if (k == 2) /* 180 */
fprintf(SymDesc," R -1 0");
else if (k == 3) /* 270 */
fprintf(SymDesc," R 0 -1");
fprintf(SymDesc," T %d %d;\n",xy[0],xy[1]);
}
void
read_layer_table(fp)
FILE *fp;
{
int i;
char buf[16];
char *errmsg = "Incorrect layer table format in";
fscanf(fp,"%d",&NumLayerTable);
if (NumLayerTable <= 0 || NumLayerTable > 127)
err_fatal(errmsg,"line 1");
for (i = 0; i < NumLayerTable; i++) {
LayerNames[i] = tmalloc(45);
if (fscanf(fp,"%s %d %d",LayerNames[i],
&LayerNumbers[i],&DataTypeNumbers[i]) != 3) {
sprintf(buf,"line %d",i+2);
err_fatal(errmsg,buf);
}
}
fclose(fp);
}
void
read_tech_layers(fp)
FILE *fp;
{
char buf[512], name[45];
char *errmsg = "Syntax error in tech file:";
int lnum = -1, dtyp = -1;
NumLayerTable = 0;
name[0] = '\0';
while (fgets(buf,512,fp) != NULL) {
if (!strncasecmp(buf,"layername",9)) {
if (sscanf(buf + 10,"%s",name) != 1)
err_fatal(errmsg,buf);
continue;
}
if (!strncasecmp(buf,"streamdata",10)) {
char *t = buf + 10;
if (!name[0])
err_fatal(errmsg,"misplaced streamdata");
while (*t == '?' || isspace(*t))
t++;
if (isdigit(*t))
lnum = atoi(t);
else
err_fatal(errmsg,buf);
while (isdigit(*t))
t++;
while (*t == ',' || isspace(*t))
t++;
if (isdigit(*t))
dtyp = atoi(t);
else
err_fatal(errmsg,buf);
if (lnum < 0 || lnum > 255 || dtyp < -1 || dtyp > 255)
err_fatal(errmsg,buf);
LayerNames[NumLayerTable] = tmalloc(45);
strcpy(LayerNames[NumLayerTable],name);
LayerNumbers[NumLayerTable] = lnum;
DataTypeNumbers[NumLayerTable] = dtyp;
NumLayerTable++;
name[0] = '\0';
}
}
fclose(fp);
}
int
set_angle(rotn,i,j)
double rotn;
int *i, *j;
{
int ii, jj;
ii = 100*cos(rotn);
jj = 100*sin(rotn);
if (ii == -99) ii = -100;
else if (ii == 99) ii = 100;
else if (jj == -99) jj = -100;
else if (jj == 99) jj = 100;
*i = ii/100;
*j = jj/100;
if (*i == 1 && *j == 0) /* 0 */
return 0;
if (*i == 0 && *j == 1) /* 90 */
return 1;
if (*i == -1 && *j == 0) /* 180 */
return 2;
if (*i == 0 && *j == -1) /* 270 */
return 3;
err_warn_1("Nonorthogonal rotation","",CurrentSymbol);
*i = *j = 0;
return 0;
}
/***********************************************************************
*
* Functions used in reading stream format
*
***********************************************************************/
extern int CurrentOffset;
extern FILE *stderror;
/***********************************************************************/
/* function STRM_IVAL */
/* Function to evaluate STREAM short integer. */
/***********************************************************************/
int
strm_ival(s)
char *s;
{
unsigned int i;
unsigned char *b = (unsigned char *)s;
/* Stream format is big-endian */
i = b[1] | ((b[0] & 0x7f) << 8);
if (b[0] & 0x80)
i |= (-1 << 15);
return ((int)i);
}
/***********************************************************************/
/* function STRM_LONGVAL */
/* Function to evaluate STREAM long integer. */
/***********************************************************************/
int
strm_longval(s)
char *s;
{
unsigned int i;
unsigned char *b = (unsigned char *)s;
/* Stream format is big-endian */
i = b[3] | (b[2] << 8) | (b[1] << 16) | ((b[0] & 0x7f) << 24);
if (b[0] & 0x80)
i |= (-1 << 31);
return ((int)i);
}
/*
* function STRM_DOUBLEVAL
* Function to convert from STREAM to VAX double precision.
* The argument is a integer buffer containing the eight bytes
* of the STREAM double precision field. The first character in
* the buffer contains the exponent, the second contains the most
* significant byte of the mantissa, etc.
*
*
* VAX's double precision field:
*
* Mantissa is base 2 (1/2 <= mantissa < 1). Exponent is excess-128.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFEEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
*
* CALMA's double precision field:
*
* Mantissa is base 16 (1/16 <= mantissa < 1). Exponent is excess-64.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFFEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
* where E = exponent field
* S = sign bit
* F = fraction field
* FL = least sig. bit of word or byte
* FM = most sig. bit of word or byte
*/
/*
* This function is really inefficient, but there are typically few
* conversions required, and protability is an issue.
*/
double
strm_doubleval(s)
char *s;
{
int exp, sign, i;
double d, mantissa;
unsigned char *b = (unsigned char*)s;
sign = 0;
exp = s[0];
/* test the sign bit */
if (exp & 0x80) {
sign = 1;
exp &= 0x7f;
}
exp -= 64;
/* Construct the mantissa */
mantissa = 0.0;
for (i = 7; i > 0; i--) {
mantissa += b[i];
mantissa /= 256.0;
}
/* Now raise the mantissa to the exponent */
d = mantissa;
if (exp > 0) {
while (exp-- > 0)
d *= 16.0;
}
else if (exp < 0) {
while (exp++ < 0)
d /= 16.0;
}
/* Make it negative if necessary */
if (sign)
d = -d;
return (d);
}
/***** Error Functions *************************************************/
void
err_fatal(str,what)
char *str,*what;
{
char buf[128];
sprintf(buf,"\nError: %s %s.\n",str,what);
fprintf(stderror,"%s",buf);
exit(1);
}
void
err_fatal_1(str,what)
char *str,*what;
{
char buf[128];
sprintf(buf,"\nError: %s %s at offset %d.\n",str,what,CurrentOffset);
fprintf(stderror,"%s",buf);
exit(1);
}
void
err_fatal_2(str,type)
char *str;
int type;
{
char buf[128];
sprintf(buf,"\nError: %s %d at offset %d.\n",str,type,CurrentOffset);
fprintf(stderror,"%s",buf);
exit(1);
}
void
err_warn_1(str,which,what)
char *str,*which,*what;
{
char buf[128];
sprintf(buf,"\nWarning: %s for instance %s in symbol %s at offset %d.\n",
str,which,what,CurrentOffset);
fprintf(stderror,"%s",buf);
}
void
err_warn_2(str,type,what)
char *str,*what;
int type;
{
char buf[128];
sprintf(buf,"\nWarning: %s %d in symbol %s at offset %d.\n",
str,type,what,CurrentOffset);
fprintf(stderror,"%s\nIgnored.\n",buf);
}
/***** Alias For DOS **************************************************/
#ifdef MSDOS
/* Map the symbol names into a DOS compatible file name, i.e., 8 */
/* characters. The first 6 are mapped directly, last 2 are index digits */
struct aliastab *aliasbase;
char *
alias(strname)
char *strname;
{
char dosname[10], *ext;
char *valid = "_^$~!#%&-{}()@'`.";
struct aliastab *wl;
int i;
char *index();
for (ext = strname; *ext; ext++) {
if (isalpha(*ext) || isdigit(*ext) || index(valid,*ext))
continue;
break;
}
if (!*ext) {
if (strlen(strname) <= 8)
return (strname);
ext = index(strname,'.');
if (ext && ((int)(ext - strname) <= 8) && strlen(ext) <= 3)
return (strname);
strncpy(dosname,strname,6);
}
else {
strncpy(dosname,strname,6);
for (i = ext - strname; i < 6; i++) {
ext = dosname + i;
if (isalpha(*ext) || isdigit(*ext) || index(valid,*ext))
continue;
dosname[i] = '_';
}
}
dosname[6] = '\0';
for (i = 0,wl = aliasbase; wl; wl = wl->next) {
if (!strcmp(strname,wl->strname)) return (wl->dosname);
if (!strncmp(dosname,wl->dosname,6)) i++;
if (!wl->next) {
wl->next = (struct aliastab*) tmalloc(sizeof(struct aliastab));
wl = wl->next;
strcpy(wl->strname,strname);
strncpy(wl->dosname,dosname,7);
wl->next = NULL;
wl->dosname[6] = '0' + i/10;
wl->dosname[7] = '0' + i%10;
wl->dosname[8] = '\0';
return (wl->dosname);
}
}
wl = (struct aliastab*) tmalloc(sizeof(struct aliastab));
aliasbase = wl;
strcpy(wl->strname,strname);
strncpy(wl->dosname,dosname,7);
wl->next = NULL;
wl->dosname[6] = '0' + i/10;
wl->dosname[7] = '0' + i%10;
wl->dosname[8] = '\0';
return (wl->dosname);
}
void
dumpalias()
{
FILE *fp;
struct aliastab *wl;
if (aliasbase == NULL) return;
fp = fopen(ALIASFILE,"w");
if (fp == NULL) return;
for (wl = aliasbase; wl; wl = wl->next)
fprintf(fp,"%-10s%s\n",wl->dosname,wl->strname);
fclose(fp);
}
void
readalias()
{
FILE *fp;
char s[80], *c;
struct aliastab *wl;
if ((fp = fopen(ALIASFILE,"r")) == NULL) return;
while (fgets(s,80,fp) != NULL) {
if (!aliasbase) {
aliasbase = (struct aliastab *) tmalloc(sizeof(struct aliastab));
wl = aliasbase;
}
else {
wl->next = (struct aliastab *) tmalloc(sizeof(struct aliastab));
wl = wl->next;
}
for (c = s; isspace(*c); c++) ;
if (*c == '\0') break;
if (sscanf(s,"%s %s",wl->dosname,wl->strname) != 2) {
aliasbase = NULL;
fclose(fp);
return;
}
}
wl->next = NULL;
fclose(fp);
}
#endif
/***** Convert Path Type ***********************************************/
void
convert_pathtype(xe,ye,xb,yb,width)
int *xe,*ye; /* coordinate of endpoint */
int xb,yb; /* coordinate of previous or next point in path */
int width; /* path width */
{
double angle;
double deltaX,deltaY;
if(width == 0)
return;
else if(width < 0)
width = -width;
width /= 2;
if(*xe == xb){
if(*ye > yb)
*ye -= width;
else
*ye += width;
}
else if(*ye == yb){
if(*xe > xb)
*xe -= width;
else
*xe += width;
}
else{
deltaX = (double)(*xe - xb);
deltaY = (double)(*ye - yb);
angle = atan2(deltaY,deltaX);
deltaX = (double)(width) * cos(angle);
deltaY = (double)(width) * sin(angle);
*xe -= (int)(deltaX);
*ye -= (int)(deltaY);
}
}
/***** Path To Rectangle Conversion ************************************/
/***********************************************************************
* This file contains the following functions:
* RECT *pgtorex(PATHLIST *pg)
* convert path list for polygon to rectangle list
* int lowx(void *a, void *b)
* qsort compare routine for comparison by low x coordinate
* int lowy(void *a, void *b)
* qsort compare routine for comparison by low y coordinate
* int orient(PATHLIST *edges, int nedges, int dir[])
* assign direction to edges and insure manhattanness
* int cross(PATHLIST *edge, int dir, int ybot, int ytop)
* would horizontal line at height between ybot and ytop cross edge?
* RECT *makerect (int xbot, int ybot, int xtop, int ytop, RECT *next)
* make a new rectangle and assign values to its components
************************************************************************/
#define MAXPG 500 /* maximum # of points in polygon */
#define HEDGE 0 /* Horizontal edge */
#define REDGE 1 /* Rising edge */
#define FEDGE -1 /* Falling edge */
RECT *
pgtorex(pg)
PATHLIST *pg;
{
/*
* Convert path list representing manhattan polygon into
* linked list of rectangles.
* Return rectangle list, or null pointer if something goes wrong.
*/
int npts = 0, n, dir[MAXPG], curr, wrapno;
int xbot = 0, xtop, ybot, ytop;
POINT *pts[MAXPG];
PATHLIST *p, *edges[MAXPG], *tail = 0;
RECT *rex = 0;
for(p = pg; p; p = p->pathlink){
if(++npts >= MAXPG){
/*Polygon with more than 200 points*/
goto exit;
}
pts[npts-1] = &(p->pathpoint);
edges[npts-1] = p;
}
if(npts < 4){
/*Polygon with fewer than 4 points*/
goto exit;
}
/* close path list - don't worry, it's disconnected later */
(tail = edges[npts-1])->pathlink = pg;
/* sort points by low y, edges by low x */
qsort ((char *) pts, npts, (int) sizeof (POINT *), lowy);
qsort ((char *) edges, npts, (int) sizeof (PATHLIST *), lowx);
/* orient edges */
if(!orient (edges, npts, dir)){
/*WARNING , non-manhattan Polygon*/
goto exit;
}
/*
* Start at the bottom of the polygon and scan upwards,
* building rectangles as you go.
*/
for(curr = 1; curr < npts; curr++){
ybot = pts[curr-1]->pointy;
while (ybot == pts[curr]->pointy)
if(++curr >= npts)
/* At top of polygon and done */
goto done;
ytop = pts[curr]->pointy;
for(wrapno=0, n=0; n < npts; n++){
if(wrapno == 0)
xbot = edges[n]->pathpoint.pointx;
if(!cross (edges[n], dir[n], ybot, ytop))
continue;
wrapno += dir[n] == REDGE ? 1 : -1;
if(wrapno == 0){
xtop = edges[n]->pathpoint.pointx;
if(xbot == xtop)
continue;
rex = makerect (xbot, ybot, xtop, ytop, rex);
if(!rex){
/*makerect ran out of memory*/
goto exit;
}
}
}
}
exit:
/* shouldn't get here ... */
rex = (RECT *) 0;
done:
/* this is the ONLY way out of pgtorex */
/* disconnect start of polygon from its tail */
if(tail)
tail->pathlink = (PATHLIST *) 0;
return (rex);
}
int
lowx(a,b)
#ifdef __STDC__
const void *a;
const void *b;
#else
char **a, **b;
#endif
{
/*
* compare points a and b, after following indirection.
* Return
* 0 if identical
* 1 if a.x > b.x
* -1 if a.x < b.x
*/
POINT *p, *q;
p = &(**(PATHLIST**)a).pathpoint;
q = &(**(PATHLIST**)b).pathpoint;
if(p->pointx < q->pointx)
return (-1);
if(p->pointx > q->pointx)
return (1);
return (0);
}
int
lowy(a,b)
#ifdef __STDC__
const void *a;
const void *b;
#else
char **a, **b;
#endif
{
/*
* compare points a and b, after following indirection.
* Return
* 0 if identical
* 1 if a.y > b.y
* -1 if a.y < b.y
*/
if((**(POINT**)a).pointy < (**(POINT**)b).pointy)
return (-1);
if((**(POINT**)a).pointy > (**(POINT**)b).pointy)
return (1);
return (0);
}
int
orient(edges, nedges, dir)
PATHLIST *edges[];
int dir[], nedges;
{
/*
* Assign a direction, "dir[i]" to each of the "nedges" edges "edges[i]".
* "Start" points to the first PATHLIST in the path list "edges".
* Return 1 if all of the edges are horizontal or vertical, 0 otherwise.
*/
int n;
POINT *p, *q;
for(n = 0; n < nedges; n++){
/* note - path list should close on itself */
p = &edges[n]->pathpoint;
q = &edges[n]->pathlink->pathpoint;
if(p->pointy == q->pointy){
/* note - point may connect to itself here */
dir[n] = HEDGE;
continue;
}
if(p->pointx == q->pointx){
if(p->pointy < q->pointy){
dir[n] = REDGE;
continue;
}
if(p->pointy > q->pointy){
dir [n] = FEDGE;
continue;
}
/* Point connects to itself */
dir[n] = HEDGE;
continue;
}
/* It's not manhattan folks. */
return (0);
}
return (1);
}
int
cross(edge, dir, ybot, ytop)
PATHLIST *edge;
int dir;
int ybot, ytop;
{
/*
* return 1 if a horizontal line at height between ybot and ytop
* (ybot < ytop) crosses the edge from edge->pathpoint to
* edge->pathlink->pathpoint, 0 otherwise. Dir is the direction
* of the edge.
*/
int ebot, etop;
switch (dir){
case REDGE:
ebot = edge->pathpoint.pointy;
etop = edge->pathlink->pathpoint.pointy;
return (ebot <= ybot && etop >= ytop);
case FEDGE:
ebot = edge->pathlink->pathpoint.pointy;
etop = edge->pathpoint.pointy;
return (ebot <= ybot && etop >= ytop);
default:
return (0);
}
}
RECT *
makerect(xbot, ybot, xtop, ytop, next)
int xbot, ybot, xtop, ytop;
RECT *next;
{
/*
* allocate space for a RECT structure and assign values to its
* components from parameters. Return pointer to structure or
* null pointer if can't allocate space.
*/
RECT *r;
r = (RECT *) tmalloc (sizeof (RECT));
if(r){
r->left = xbot;
r->bottom = ybot;
r->right = xtop;
r->top = ytop;
r->r_next = next;
}
return (r);
}
void
freepath(pathheadpp)
PATHLIST **pathheadpp;
{
PATHLIST *herep;
PATHLIST *therep;
for( herep = *pathheadpp ; herep != NULL ; herep = therep ){
therep = herep -> pathlink;
free( (char *) herep );
}
*pathheadpp = NULL;
}
/***** Memory Allocation ***********************************************/
char *
tmalloc(x)
unsigned x;
{
char *c = (char*)malloc(x);
if (c == NULL)
err_fatal("Out of memory","");
return (c);
}
/***** Etc ************************************************************/
#define Matching(string) (!strcmp(buf,string))
static void
file_open(name)
char *name;
{
FILE *fp;
char *cp, buf[80];
fp = fopen(name,"r");
if (fp == NULL) {
sprintf(buf,"can't open file %s for reading",name);
err_fatal("Error:",buf);
}
cp = get_token(fp);
if (cp) {
while (*cp) {
if (*cp < '0' || *cp > '9')
break;
cp++;
}
rewind(fp);
if (!*cp) {
printf("Using layer table %s\n",name);
read_layer_table(fp);
return;
}
while ((cp = get_token(fp)) != NULL) {
if (Matching("LAYERNAME") || Matching("LAYER")) {
rewind(fp);
printf("Using layers from tech file %s\n",name);
read_tech_layers(fp);
return;
}
}
}
sprintf(buf,"format error in %s",name);
err_fatal("Error:",buf);
}
static char *
get_token(file)
FILE *file;
{
char *cp;
int c;
static char keyword[40];
/* look for first key word */
while ( (c = getc(file)) < '0' ||
(c > '9' && c < 'A') ||
(c > 'Z' && c < 'a') ||
(c > 'z') )
if (c == EOF) return (NULL);
/* scan to end of keyword and convert to upper case */
cp = keyword;
while (c != 040 && c != '\t' && c != 077 && c != '\n' && c != EOF) {
if (c >= 'a' && c <= 'z') c -= 32;
*cp++ = c;
if (cp - keyword > 39)
break;
c = getc(file);
}
*cp = 0;
/* scan to end of line */
while (c != '\n' && c != EOF) {
c = getc(file);
}
return (keyword);
}
FILE *OpenDevice() {return NULL;}
kic-2.4c/src/include/ 0000755 0000764 0000764 00000000000 12427444606 014137 5 ustar stevew stevew kic-2.4c/src/include/cdext.h 0000644 0000764 0000764 00000015763 07525346712 015435 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/* actions.c */
#if __STDC__
extern void AEnd(void);
extern int ABeginSymbol(int,int,int);
extern void AEndSymbol(void);
extern void ADeleteSymbol(int);
extern int AEndCall(void);
extern int AT(int,int,int);
extern int ABeginCall(int);
extern int APolygon(struct p*);
extern int AWire(int,struct p*);
extern int ABox(int,int,int,int,int,int);
extern int ARoundFlash(int,int,int);
extern int ALayer(int,char*);
extern int AUserExtension(int,char*);
extern void AComment(char*);
extern int AMallocFailed(void);
#else
extern void AEnd();
extern int ABeginSymbol();
extern void AEndSymbol();
extern void ADeleteSymbol();
extern int AEndCall();
extern int AT();
extern int ABeginCall();
extern int APolygon();
extern int AWire();
extern int ABox();
extern int ARoundFlash();
extern int ALayer();
extern int AUserExtension();
extern void AComment();
extern int AMallocFailed();
#endif
/* cd.c */
extern struct bu *CDSymbolTable[CDNUMLAYERS+1];
extern struct d CDDesc;
extern struct l CDLayer[CDNUMLAYERS+1];
extern char *CDStatusString;
extern int CDStatusInt;
#if __STDC__
extern int CDInit(void);
extern int CDPath(char*);
extern void CDSetLayer(int,int,char*);
extern void CDDebug(int);
extern int CDOpen(char*,struct s**,int);
extern void CDSymbol(char*,struct s**);
extern int CDClose(struct s*);
extern int CDReflect(struct s*);
extern int CDPatchInstances(struct s*,char*);
extern int CDMakeBox(struct s*,int,int,int,int,int,struct o**);
extern int CDMakeLabel(struct s*,int,char*,int,int,int,struct o**);
extern int CDMakePolygon(struct s*,int,struct p*,struct o**);
extern int CDMakeWire(struct s*,int,int,struct p*,struct o**);
extern int CDMakeRoundFlash(struct s*,int,int,int,int,struct o**);
extern int CDBeginMakeCall(struct s*,char*,int,int,int,int,struct o**);
extern int CDT(struct o*,int,int,int);
extern int CDEndMakeCall(struct s*,struct o*);
extern void CDCheckPath(struct p*);
extern int CDInsertObjectDesc(struct s*,struct o*);
extern void CDDeleteObjectDesc(struct s*,struct o*);
extern void CDCall(struct o*,char**,int*,int*,int*,int*);
extern void CDBox(struct o*,int*,int*,int*,int*,int*);
extern void CDLabel(struct o*,int*,char**,int*,int*,char*);
extern void CDPolygon(struct o*,int*,struct p**);
extern void CDWire(struct o*,int*,int*,struct p**);
extern void CDRoundFlash(struct o*,int*,int*,int*,int*);
extern void CDInfo(struct s*,struct o*,int*);
extern void CDSetInfo(struct s*,struct o*,int);
extern void CDProperty(struct s*,struct o*,struct prpty**);
extern int CDAddProperty(struct s*,struct o*,int,char*);
extern int CDRemoveProperty(struct s*,struct o*,int);
extern void CDType(struct o*,char*);
extern int CDBB(struct s*,struct o*,int*,int*,int*,int*);
extern void CDIntersect(int,int,int,int,int*,int*,int*,int*);
extern int CDInitGen(struct s*,int,int,int,int,int,struct g**);
extern void CDGen(struct s*,struct g*,struct o**);
extern void CDInitTGen(struct o*,struct t**);
extern void CDTGen(struct t**,char*,int*,int*);
extern int CDUpdate(struct s*,char*);
extern int CDGenCIF(FILE*,struct s*,int*,int,int,int);
extern int CDTo(char*,char*,int,int,int);
extern int CDFrom(char*,char*,int,int,int*,int,int);
extern int CDParseCIF(char*,char*,int);
extern int CDUnmark(struct s*);
extern int CDError(int);
#else
extern int CDInit();
extern int CDPath();
extern void CDSetLayer();
extern void CDDebug();
extern int CDOpen();
extern void CDSymbol();
extern int CDClose();
extern int CDReflect();
extern int CDPatchInstances();
extern int CDMakeBox();
extern int CDMakeLabel();
extern int CDMakePolygon();
extern int CDMakeWire();
extern int CDMakeRoundFlash();
extern int CDBeginMakeCall();
extern int CDT();
extern int CDEndMakeCall();
extern void CDCheckPath();
extern int CDInsertObjectDesc();
extern void CDDeleteObjectDesc();
extern void CDCall();
extern void CDBox();
extern void CDLabel();
extern void CDPolygon();
extern void CDWire();
extern void CDRoundFlash();
extern void CDInfo();
extern void CDSetInfo();
extern void CDProperty();
extern int CDAddProperty();
extern int CDRemoveProperty();
extern void CDType();
extern int CDBB();
extern void CDIntersect();
extern int CDInitGen();
extern void CDGen();
extern void CDInitTGen();
extern void CDTGen();
extern int CDUpdate();
extern int CDGenCIF();
extern int CDTo();
extern int CDFrom();
extern int CDParseCIF();
extern int CDUnmark();
extern int CDError();
#endif
/* gencif.c */
#if __STDC__
extern void GenEnd(FILE*);
extern void GenBeginSymbol(FILE*,int,int,int);
extern void GenEndSymbol(FILE*);
extern void GenBeginCall(FILE*,int);
extern void GenEndCall(FILE*);
extern void GenTranslation(FILE*,int,int);
extern void GenRotation(FILE*,int,int);
extern void GenMirrorX(FILE*);
extern void GenMirrorY(FILE*);
extern void GenPolygon(FILE*,struct p*);
extern void GenPolygonOffset(FILE*,struct p*,int,int);
extern void GenWire(FILE*,int,struct p*);
extern void GenWireOffset(FILE*,int,struct p*,int,int);
extern void GenBox(FILE*,int,int,int,int,int,int);
extern void GenLayer(FILE*,int,char*);
extern void GenUserExtension(FILE*,int,char*);
extern void GenComment(FILE*,char*);
#else
extern void GenEnd();
extern void GenBeginSymbol();
extern void GenEndSymbol();
extern void GenBeginCall();
extern void GenEndCall();
extern void GenTranslation();
extern void GenRotation();
extern void GenMirrorX();
extern void GenMirrorY();
extern void GenPolygon();
extern void GenPolygonOffset();
extern void GenWire();
extern void GenWireOffset();
extern void GenBox();
extern void GenLayer();
extern void GenUserExtension();
extern void GenComment();
#endif
/* paths.c */
#if __STDC__
extern int PConvertTilde(char**,char**,int*);
extern int PSetPath(char*);
extern char *PGetPath(void);
extern FILE *POpen(char*,char*,char*,char**);
#else
extern int PConvertTilde();
extern int PSetPath();
extern char *PGetPath();
extern FILE *POpen();
#endif
/* xforms.c */
#if __STDC__
extern void TInit(void);
extern int TEmpty(void);
extern int TFull(void);
extern void TPush(void);
extern void TPop(void);
extern void TCurrent(int*);
extern void TLoadCurrent(int*);
extern void TTranslate(int,int);
extern void TMY(void);
extern void TMX(void);
extern void TRotate(int,int);
extern void TIdentity(void);
extern void TPoint(int*,int*);
extern void TPremultiply(void);
extern void TInverse(void);
extern void TInversePoint(int*,int*);
extern void TStore(void);
extern void TLoad(void);
extern void TLoadInverse(void);
#else
extern void TInit();
extern int TEmpty();
extern int TFull();
extern void TPush();
extern void TPop();
extern void TCurrent();
extern void TLoadCurrent();
extern void TTranslate();
extern void TMY();
extern void TMX();
extern void TRotate();
extern void TIdentity();
extern void TPoint();
extern void TPremultiply();
extern void TInverse();
extern void TInversePoint();
extern void TStore();
extern void TLoad();
extern void TLoadInverse();
#endif
kic-2.4c/src/include/kic.h 0000644 0000764 0000764 00000026406 07525346712 015070 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* KIC data structures.
*
*/
#include
#include
#include "cd.h"
#include "fb.h"
#include "coords.h"
/*
* Size of memory blocks to be managed by nmalloc
*/
#define NMALLOC_BLOCK_SIZE 4096
/*
* Viewport control flags
*/
#define SPLITSCREEN 'b'
#define FULLSCREEN 'o'
#define FINEVIEWPORTONLY 'f'
#define COARSEVIEWPORTONLY 'c'
/*
* Menu names
*/
#define BASICMENU 'b'
#define DEBUGMENU 'd'
#define ATTRIBUTESMENU 'a'
#define PROPERTYMENU 'p'
#define AMBIGUITYMENU 'A'
/*
* Returns from PointLoop() function.
*/
#define PL_ESC 1
#define PL_UND 2
#define PL_CMD 3
#define PL_PCW 4
#define PL_PLT 5
/* character that terminates most commands */
#define ESCAPE 27
struct kl {
/*
* The following info is read from the .KIC file.
*/
int klMinDimensions; /* minimum lambda*RESOLUTION */
int klWireWidth; /* wire width >= mindimensions */
struct eparms *klElectrical; /* electrical parameters */
short klR,klG,klB; /* RGB color */
unsigned char klStyle[8]; /* bit array for fill pattern */
unsigned char klAltStyle[8]; /* array for alt fill pattern */
short klStyleID; /* style ID */
short klAltStyleID; /* alternate style ID */
short klAttributes; /* presentation attributes */
short klStreamNumber; /* layer number for Stream */
short klStreamDataType; /* datatype for Stream */
#define SYMBOLIC 0x1 /* layer is symbolic */
#define BLINK 0x2 /* blinking layer */
#define VISIBLE 0x4 /* layer is visible */
#define FINE_FILL 0x8 /* show fill in fine viewport */
#define COARSE_FILL 0x10 /* show fill in coarse viewport*/
#define OUTLINED 0x20 /* outline figure */
#define FILLED 0x40 /* layer is filled */
#define ALT_FILLED 0x80 /* alternate pattern filled */
#define ALT_OUTLINED 0x100 /* alternate pattern outlined */
#define ALT_VISIBLE 0x200 /* alternate visiblilty */
char klTechnology,klMask[5]; /* layer name */
};
struct cl {
short Ent,R,G,B;
};
extern struct cl ColorTable[];
#define HighlightingColor 1
#define MenuPromptColor 2
#define MenuTextColor 3
#define MenuHighlightingColor 4
#define MenuSelectColor 5
#define MoreTextColor 6
#define InstanceBBColor 7
#define InstanceNameColor 8
#define InstanceSizeColor 9
#define CoarseGridColor 10
#define FineGridColor 11
struct eparms {
int e_type;
double e_parms[8];
};
/* defines for e_type */
#define ERESIS 1
#define ECAP 2
#define ETRANS 3
extern char TypeOut[200];
extern int NumLayerTable;
extern struct kl LayerTable[CDNUMLAYERS+1];
/*
* Cursor desc.
*/
struct kc {
int kcPredX,kcPredY,kcX,kcY;
int kcRawX,kcRawY;
int kcDX,kcDY;
int kcInFine;
};
extern struct kc KicCursor;
/*
* Area structure.
*/
struct ka {
int kaLeft,kaBottom,kaRight,kaTop;
int kaX,kaY;
double kaWidth,kaHeight;
};
/*
* KIC text viewports.
*/
extern struct ka MenuViewport;
extern struct ka LayerTableViewport;
extern struct ka ParameterViewport;
/*
* Structure to keep current area of interest.
*/
struct a {
int aLF,aBF,aRF,aTF;
int aLC,aBC,aRC,aTC;
int aInFine;
int aInCoarse;
};
extern struct a CurrentAOI;
/*
* Structure used to save windows in window stack.
*/
struct kw {
int kwLastWindowX;
int kwLastWindowY;
int kwLastWindowWidth;
int kwLastFineWindowX;
int kwLastFineWindowY;
int kwLastFineWindowWidth;
struct kw *kwNext;
char kwExpand;
char kwExpandFineOnly;
char kwName[8];
};
/*
* Layout windows and the viewports they map to.
*/
struct kv {
struct ka *kvFineWindow;
struct ka *kvFineViewport;
struct ka *kvCoarseWindow;
struct ka *kvCoarseViewport;
struct ka *kvLargeCoarseViewport;
struct ka *kvSmallCoarseViewport;
/* viewport/window */
double kvFineRatio;
double kvCoarseRatio;
int kvFineViewportOnBottom;
char kvControl;
};
extern struct kv *View;
/*
* Parameters that control KIC.
*/
struct kp {
/* Symbol desc for current cell */
struct s *kpCellDesc;
/* Symbol name for current cell */
char *kpCellName;
/* Symbol desc for top level cell */
struct s *kpTopDesc;
/* Symbol name for top level cell */
char *kpTopName;
/* Command selected if any from command menu */
char *kpCommand;
/* Linked list of saved views */
struct kw *kpWindowStack;
/* current instance array parameters */
int kpNumX;
int kpNumY;
double kpDX;
double kpDY;
/* Number of RESOLUTION*lambda between grid points. */
int kpGrid;
/* Debug parameters */
int kpNumGeometries;
/*
* PixToLambdaSnapping is the number of points between grid lines
* to which a cursor input point is snapped.
*/
int kpPixToLambdaSnapping;
/* True if layers and screen attributes have combined color map */
short kpMergeColors;
/* True if instances should be expanded */
short kpExpandInstances;
/* True if context is shown in subedit */
short kpShowContext;
/* True if instance is expanded in fine viewport only */
short kpExpandFineViewportOnly;
/* If False then the SelectQ is never redisplayed (for speed) */
short kpEnableSelectQRedisplay;
/* If True, user pointed inside layer table and Command[0] == EOS */
short kpPointLayerTable;
/* If True, user pointed inside coarse viewport and Command[0] == EOS */
short kpPointCoarseWindow;
/* True if all selection commands (SELec and Area) are LayerSpecific */
short kpLayerSpecificSelection;
/* If True, polygon vertices are clipped to the nearest grid point */
short kpClipVerticesToGrid;
/* If True, display grid */
short kpGridDisplayed;
/* If True, put grid below layout geometries */
short kpGridOnTop;
/* If True, grid will be shown in large viewport */
short kpShowGridInLargeViewport;
/* If True, then show redisplay bandwidth */
short kpShowBandwidth;
/* If True, user has just pressed the interrupt key */
short kpSIGINTERRUPT;
/* If True, all text is displayed */
short kpDisplayAllLabels;
/* If True, all instances will be labeled in the viewport */
short kpLabelAllInstances;
/* If True, instances will be marked when selected */
short kpShowInstanceMarkers;
/* True if wires and polygons should be constrained to 45s */
short kp45s;
/* If true, use lower left corner when placing cells */
short kpSubrefLowerLeft;
/* True if making hard copy */
short kpDoingHardcopy;
/* If True, show grid in hardcopy */
short kpHardcopyGrid;
/* True if current cell has been modified */
short kpModified;
/* Line style of grid lines (0 for point grid) */
short kpGridLineStyle;
/* Current layer */
short kpLayer;
/* Control of the Layer Menu */
short kpNumLayerMenuRows;
short kpLayersPerMenuRow;
short kpVisibleLayerMenuRow;
/* Number of sides for round flashes */
short kpNumRoundFlashSides;
/* Parameters for modifying geometries with stretch command */
short kpStretchType;
#define STR_TBRL 0
#define STR_TB 1
#define STR_RL 2
/* Which types of object will be selected */
char kpSelectTypes[8];
/*
* PointingThreshold is the minimum value of ViewportWidth/WindowWidth
* such that it is still comfortable to point with lambda precision.
*/
short kpPointingThreshold;
/* Current transform */
short kpRotationAngle; /* 0, 90, 180, or 270 */
short kpMX;
short kpMY;
/* At what level in the hierarchy are we? See Redisplay */
short kpHierarchyLevel;
/* Factor for scaling text labels for hard copy */
short kpHardcopyTextScale;
/* Device driver name for hardcopy support */
char *kpHardcopyDevice;
/* Format code for hardcopy support */
char kpHardcopyFormat[2];
/* Hardcopy resolution */
short kpHardcopyResolution;
/*
* == COARSEVIEWPORTONLY if coarse window-viewport to be redisplayed
* == FINEVIEWPORTONLY if fine window-viewport should be redisplayed
* == SPLITSCREEN if both should be redisplayed
*/
char kpRedisplayControl;
/*
* Current command menu
* == INSTANCEMENU denotes instance menu
* == ATTRIBUTESMENU denotes attribute menu
* == PROPERTYMENU denotes property menu
* == BASICMENU denotes basic menu
* == SELECTIONMENU denotes selection menu
* == DEBUGMENU denotes debug menu
* == AMBIGUITYMENU denotes ambiguity menu
*/
char kpMenu;
/* Type of cursor chosen */
short kpCursorShape;
/* True if full screen cursor in use */
short kpFullScreenCursor;
/* Beep volume */
short kpPointBeepVolume;
/* Name of X font used */
char kpFontName[81];
};
extern struct kp Parameters;
/*
* Selection queue.
*
*
* The select Q is a single-linked list of select Q descriptors.
* Each desc points to the object descriptor for a selected object.
* SelectQHead is the head of the list.
* SelectQBB is the BB of ALL of the selected objects.
* Move and delete are easily implemented as operations on the Q.
*/
struct ks {
struct ks *ksSucc;
struct o *ksPointer;
};
extern struct ks *SelectQHead;
extern struct ka SelectQBB;
/* Values of Info parameter used to manage objects in SelectQ */
/* Previous object not in Q */
#define SQ_OLD 0
/* Previous object in Q, selected */
#define SQ_OLDSEL 1
/* Conditionally deleted object */
#define SQ_GONE 2
/* Newly created object, not selected */
#define SQ_NEW 3
/* Newly created object, selected */
#define SQ_NEWSEL 4
/* Partially created object */
#define SQ_INCMPLT 5
/*
* KIC menus.
*/
struct menu {
char *mEntry;
short mActive;
char mPrefix[6];
};
typedef struct menu MENU;
extern MENU *BasicMenu;
extern MENU *AttributeMenu;
extern MENU *DebugMenu;
extern MENU *PropertyMenu;
extern MENU AmbiguityMenu[];
#include "kicext.h"
kic-2.4c/src/include/mfbext.h 0000644 0000764 0000764 00000025164 07525346712 015607 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************
* Original header: (X support)
*
* Copyright -C- 1981 Giles C. Billingsley, Kenneth H. Keller, Brian Lee
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/* declarations of MFB functions */
/* application supplied routines */
#if __STDC__
extern void SetDisplayWindow(int,int,int*,int*,int*,int*);
extern void RepaintWindow(int);
#else
extern void SetDisplayWindow();
extern void RepaintWindow();
#endif
#ifdef __STDC__
/* Library routines */
extern void MFBArc(int,int,int,int,int,int);
extern MFBPATH *MFBArcPath(int,int,int,int,int,int);
extern void MFBAudio(void);
extern void MFBBox(int,int,int,int); /* draw box cur colr, fillpatt */
extern void MFBCircle(int,int,int,int);
extern int MFBClose(void); /* exit MFB */
extern int MFBDefineColor(int,int,int,int);/* define new color */
extern int MFBDefineFillPattern(int,int*);/* define new fill pattern */
extern int MFBDefineLineStyle(int,int); /* define new line style */
extern int MFBDescaleX(int);
extern int MFBDescaleY(int);
extern void MFBDrawLineTo(int,int); /* line from last move, draw */
extern void MFBDrawPath(MFBPATH*);
extern MFBPOLYGON *MFBEllipse(int,int,int,int,int);
extern char *MFBError(int); /* error handler */
extern void MFBFlash(int,int,int,int);
extern void MFBFlood(void); /* flood screen in current colr */
extern int MFBGetchar(void); /* get character from keybrd */
extern char *MFBGetStorage(void);
extern int MFBHalt(void); /* exit MFB */
extern int MFBInfo(int); /* return MFB info */
extern int MFBInitialize(void); /* initialize MFB */
extern char *MFBKeyboard(int,int,int,int);
extern void MFBLine(int,int,int,int); /* draw line, cur colr, style */
extern Bool MFBLineClip(int*,int*,int*,int*,int,int,int,int);
/* line clipping routine */
extern void MFBMore(int,int,int,int,FILE*);/* display text by page */
extern void MFBMoveTo(int,int); /* move internal coordinates */
extern void MFBNaiveBoxFill(int,int,int,int);
extern MFB *MFBOpen(char*,char*,int*); /* start graphics */
extern void MFBPixel(int,int); /* draw pixel in current color */
extern int MFBPoint(int*,int*,int*,int*);/* enable pointing device */
extern void MFBPolygon(MFBPOLYGON*); /* draw polygon */
extern int MFBPutchar(int);
extern int MFBPutstr(char*,int);
extern void MFBRasterCopy(int,int,int,int,int,int);
extern int MFBScaleX(int);
extern int MFBScaleY(int);
extern int MFBSetALUMode(int); /* set pixel update mode */
extern int MFBSetBlinker(int,int,int,int,int); /* no operation */
extern int MFBSetChannelMask(int);
extern int MFBSetColor(int); /* set current color */
extern void SetCurrentMFB(MFB*);
extern int MFBSetCursorColor(int,int); /* set cursor color */
extern int MFBSetFillPattern(int); /* set fill pattern */
extern int MFBSetLineStyle(int); /* set current line style */
extern int MFBSetReadMask(int);
extern int MFBSetRubberBanding(int,int,int);
extern int MFBSetStorage(char*);
extern int MFBSetTextMode(Bool); /* no operation */
extern void MFBSetViewport(int,int,int,int);
extern void MFBSetWindow(int,int,int,int);
extern void MFBText(char*,int,int,int); /* display text */
extern int MFBUpdate(void); /* update screen (nop here) */
extern void MFB_X_Intercept(int,int,int,int,int,int*);
extern void MFB_Y_Intercept(int,int,int,int,int,int*);
/* line intercepts */
extern int MFBntox(int, int); /* raise int to poser */
/* Nonstandard library routines */
extern void MFBBeep(int);
extern void MFBDrawCursor(int,int); /* save background, draw marker */
extern void MFBEraseCursor(int,int); /* restore background */
extern void MFBFuncKeys(int,int); /* set function key returns */
extern int MFBGetPixel(int,int); /* get pixel color */
extern int MFBNewPolygon(MFBPOLYGON*); /* polygon rendering */
extern void MFBNewPolygonClip(MFBPOLYGON*,int,int,int,int);
/* polygon clipping routine */
extern void MFBPointerClose(void); /* close pointing device */
extern void MFBPointerInit(void); /* initialize pointing device */
extern void MFBRect(int,int,int,int);
extern void MFBResizeDrawingWindow(int,int,int,int);
extern void MFBScroll(int,int,int,int,FILE*);
#ifdef MFB_H
#ifndef VGAMFB
extern int MFBScrollFont(int,int,int,int,XFontStruct*,GC,int,int);
#endif
#endif
extern int MFBScrollList(int,int,int,int,char**,int,int,int,int);
extern void MFBSelectCursor(int,int,int,int);
extern int MFBSelectFont(int,int,int,int);
extern void MFBSetCursor(int);
extern int MFBSetFont(char*);
extern int MFBSetFullScreenCursor(int);
extern void MFBSetName(char*,char*);
extern void MFBScaledText(char*,int,int,int,int);/* text with big pixels */
extern int MFBSetGhost(void(*)(int,int,int,int),int,int); /* xor image */
extern void MFBSetTextClip(int,int,int,int);/* clipping box for text */
extern void MFBTextBB(char*,int*,int*); /* get pix wid and ht of string */
#else
/* Library routines */
extern void MFBArc();
extern MFBPATH *MFBArcPath();
extern void MFBAudio();
extern void MFBBox(); /* draw box cur colr, fillpatt */
extern void MFBCircle();
extern int MFBClose(); /* exit MFB */
extern int MFBDefineColor(); /* define new color */
extern int MFBDefineFillPattern(); /* define new fill pattern */
extern int MFBDefineLineStyle(); /* define new line style */
extern int MFBDescaleX();
extern int MFBDescaleY();
extern void MFBDrawLineTo(); /* line from last move, draw */
extern void MFBDrawPath();
extern MFBPOLYGON *MFBEllipse();
extern char *MFBError(); /* error handler */
extern void MFBFlash();
extern void MFBFlood(); /* flood screen in current colr */
extern int MFBGetchar(); /* get character from keybrd */
extern char *MFBGetStorage();
extern int MFBHalt(); /* exit MFB */
extern int MFBInfo(); /* return MFB info */
extern int MFBInitialize(); /* initialize MFB */
extern char *MFBKeyboard();
extern void MFBLine(); /* draw line, cur colr, style */
extern Bool MFBLineClip(); /* line clipping routine */
extern void MFBMore(); /* display text by page */
extern void MFBMoveTo(); /* move internal coordinates */
extern void MFBNaiveBoxFill();
extern MFB *MFBOpen(); /* start graphics */
extern void MFBPixel(); /* draw pixel in current color */
extern int MFBPoint(); /* enable pointing device */
extern void MFBPolygon(); /* draw polygon */
extern int MFBPutchar();
extern int MFBPutstr();
extern void MFBRasterCopy();
extern int MFBScaleX();
extern int MFBScaleY();
extern int MFBSetALUMode(); /* set pixel update mode */
extern int MFBSetBlinker(); /* no operation */
extern int MFBSetChannelMask();
extern int MFBSetColor(); /* set current color */
extern void SetCurrentMFB();
extern int MFBSetCursorColor(); /* set cursor color */
extern int MFBSetFillPattern(); /* set fill pattern */
extern int MFBSetLineStyle(); /* set current line style */
extern int MFBSetStorage();
extern int MFBSetReadMask();
extern int MFBSetRubberBanding();
extern int MFBSetTextMode(); /* no operation */
extern void MFBSetViewport();
extern void MFBSetWindow();
extern void MFBText(); /* display text */
extern int MFBUpdate(); /* update screen (nop here) */
extern void MFB_X_Intercept();
extern void MFB_Y_Intercept(); /* line intercepts */
extern int MFBntox(); /* raise int to poser */
/* Nonstandard library routines */
extern void MFBBeep();
extern void MFBDrawCursor(); /* save background, draw marker */
extern void MFBEraseCursor(); /* restore background */
extern void MFBFuncKeys(); /* set function key returns */
extern int MFBGetPixel(); /* get pixel color */
extern int MFBNewPolygon(); /* polygon rendering */
extern void MFBNewPolygonClip(); /* polygon clipping routine */
extern void MFBPointerClose(); /* close pointing device */
extern void MFBPointerInit(); /* initialize pointing device */
extern void MFBRect();
extern void MFBResizeDrawingWindow();
extern void MFBScroll();
extern int MFBScrollFont();
extern int MFBScrollList();
extern void MFBSelectCursor();
extern int MFBSelectFont();
extern void MFBSetCursor();
extern int MFBSetFont();
extern int MFBSetFullScreenCursor();
extern void MFBSetName();
extern void MFBScaledText(); /* text with big pixels */
extern int MFBSetGhost(); /* turn on xor image */
extern void MFBSetTextClip(); /* clipping box for text */
extern void MFBTextBB(); /* get pix wid and ht of string */
#endif
kic-2.4c/src/include/parser.h 0000644 0000764 0000764 00000020610 07525346712 015605 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Fast CIF parser's data structures.
*
*/
#include "macros.h"
#include
/*
* 24*80+1=1921 characters of string.
*/
#define PSTRINGSIZE 1921
/*
* Status of parse when parser returns.
*/
extern char PStatus[80*3+1];
/*
* CIF file desc.
*/
extern FILE *PCIFFileDesc;
/*
* string for input line buffering
*/
extern char PString[PSTRINGSIZE];
/*
* Global token variables.
*/
extern int PChar;
extern int PInt;
extern int PReturned;
/*
* Ousterhout's path package.
*/
extern FILE *POpen();
/*
* Values routines return.
*/
#define PSUCCEEDED 1 /* successful return */
#define PFAILED 2 /* parser failed */
#define PNOTAPPLICABLE 3 /* parser failed due to syntax */
/*
* Arguments to handle an EOF in PCharacter and PInteger
*/
#define PFAILONEOF 1
#define PDONTFAILONEOF 2
/*
* Arguments to specify characters to be ignored by PWhiteSpace
*/
#define PSTRIPWHITESPACE1 1 /* strip blanks, tabs, commas, or */
/* new lines. */
#define PSTRIPWHITESPACE2 2 /* strip everything but upper case, */
/* hyphens, digits, parens, and ;'s. */
#define PSTRIPWHITESPACE3 3 /* strip everything but digits, */
/* hyphens, parens, and ;'s. */
#define PLEAVEWHITESPACE 4
/* parser.c */
extern FILE *PCIFFileDesc;
extern char PStatus[80*3+1];
extern int PInt;
extern int PChar;
extern char PString[PSTRINGSIZE];
extern int PReturned;
#if __STDC__
extern void PCIF(char*,char**,int*);
extern int PPrimitiveCommand(void);
extern int PEnd(void);
extern int PSymbol(void);
extern int PDeleteSymbol(void);
extern int PCall(void);
extern int PPolygon(void);
extern int PBox(void);
extern int PRoundFlash(void);
extern int PWire(void);
extern int PPath(struct p**);
extern int PPoint(int*,int*);
extern int PLayer(void);
extern int PUserExtension(void);
extern int PComment(void);
extern void PError(char*);
extern void PErrorEOF(void);
extern void PErrorNoSemicolon(void);
extern void PErrorUndefinedLayer(int,char*);
extern void PErrorCD(void);
extern int PCharacter(int,int);
extern int PWhiteSpace(int,int);
extern int PWhiteSpace1(int);
extern int PWhiteSpace2(int);
extern int PWhiteSpace3(int);
extern int PLookAhead(int,int);
extern int PLookForSemi(void);
extern int PInteger(int);
#else
extern void PCIF();
extern int PPrimitiveCommand();
extern int PEnd();
extern int PSymbol();
extern int PDeleteSymbol();
extern int PCall();
extern int PPolygon();
extern int PBox();
extern int PRoundFlash();
extern int PWire();
extern int PPath();
extern int PPoint();
extern int PLayer();
extern int PUserExtension();
extern int PComment();
extern void PError();
extern void PErrorEOF();
extern void PErrorNoSemicolon();
extern void PErrorUndefinedLayer();
extern void PErrorCD();
extern int PCharacter();
extern int PWhiteSpace();
extern int PWhiteSpace1();
extern int PWhiteSpace2();
extern int PWhiteSpace3();
extern int PLookAhead();
extern int PLookForSemi();
extern int PInteger();
#endif
/* the following macros are now functions in parser.c */
#ifdef notdef
/* PWhiteSpace returns either PSUCCEEDED or PFAILED */
#define PCharacter(Returned,WhiteSpaceControl,EOFControl){ \
PWhiteSpace(Returned,WhiteSpaceControl,EOFControl); \
if(Returned != PFAILED){ \
PChar = getc(PCIFFileDesc); \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF) { \
PErrorEOF(); \
Returned = PFAILED; \
} \
} \
} \
}
#define PWhiteSpace(Returned,WhiteSpaceControl,EOFControl){ \
Returned = PSUCCEEDED; \
if(WhiteSpaceControl == PSTRIPWHITESPACE1){ \
while((PChar = getc(PCIFFileDesc)) == ' ' Or PChar == '\t' Or \
PChar == '\n' Or PChar == ','){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF){ \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
} \
elif(WhiteSpaceControl == PSTRIPWHITESPACE2){ \
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '(' \
And PChar != ')' And (PChar < 'A' Or PChar > 'Z') \
And (PChar < '0' Or PChar > '9') And PChar != ';'){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF) { \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
} \
elif(WhiteSpaceControl == PSTRIPWHITESPACE3){ \
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '(' \
And PChar != ')' And (PChar< '0' Or PChar > '9') And \
PChar != ';'){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF){ \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
} \
}
#define PWhiteSpace1(Returned,EOFControl){ \
Returned = PSUCCEEDED; \
while((PChar = getc(PCIFFileDesc)) == ' ' Or PChar == '\t' Or \
PChar == '\n' Or PChar == ','){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF){ \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
}
#define PWhiteSpace2(Returned,EOFControl){ \
Returned = PSUCCEEDED; \
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '(' \
And PChar != ')' And (PChar < 'A' Or PChar > 'Z') \
And (PChar < '0' Or PChar > '9') And PChar != ';'){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF) { \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
}
#define PWhiteSpace3(Returned,EOFControl){ \
Returned = PSUCCEEDED; \
while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '(' \
And PChar != ')' And (PChar< '0' Or PChar > '9') And \
PChar != ';'){ \
if(PChar == EOF){ \
if(EOFControl != PDONTFAILONEOF){ \
PErrorEOF(); \
Returned = PFAILED; \
} \
break; \
} \
} \
ungetc((char)PChar,PCIFFileDesc); \
}
#define PLookAhead(Returned, WhiteSpaceControl, For){ \
/* PCharaceter will return either PSUCCEEDED or PFAILED */ \
PCharacter(Returned,WhiteSpaceControl,PFAILONEOF); \
if(PChar != For && Returned != PFAILED){ \
ungetc((char)PChar,PCIFFileDesc); \
} \
}
#define PLookForSemi(Returned){ \
/* PWhiteSpace returns either PSUCCEEDED or PFAILED */ \
PWhiteSpace3(Returned,PFAILONEOF); \
if(Returned != PFAILED){ \
PChar = getc(PCIFFileDesc); \
if(PChar == EOF){ \
PErrorEOF(); \
Returned = PFAILED; \
} \
elif(PChar != ';'){ \
ungetc((char)PChar,PCIFFileDesc); \
} \
} \
}
#define PInteger(Returned,EOFControl) { \
loop{ \
PWhiteSpace3(PReturned,EOFControl); \
if(PReturned == PFAILED){ \
Returned = PFAILED; \
break; \
} \
if((PChar >= '0' And PChar <= '9') Or \
(PChar == '-' Or PChar == '+')) { \
/* read integer */ \
if((fscanf(PCIFFileDesc,"%ld",&PInt)) == EOF){ \
if(EOFControl != PDONTFAILONEOF){ \
PChar = EOF; \
PErrorEOF(); \
Returned = PFAILED; \
} \
} \
Returned = PSUCCEEDED; \
break; \
} \
/* drop unwanted characters */ \
PCharacter(PReturned,PSTRIPWHITESPACE1,EOFControl); \
if(PReturned == PFAILED){ \
Returned = PFAILED; \
break; \
} \
} \
}
#endif
kic-2.4c/src/include/fb.h 0000644 0000764 0000764 00000020157 07525346712 014706 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
struct polygn {
int nvertices;
int *xy;
};
typedef struct polygn Poly;
/*
* Frame Buffer Desc;
*/
struct f {
char *fDisplay; /* display name */
int fInterface; /* index of graphics interface */
int *fButtonMask; /* pointer to array of button masks */
int fMaxX,fMaxY; /* raster dimensions of viewport */
int fFontHeight,fFontWidth; /* standard font size */
int fNumRows; /* maximum number of horizontal rows */
int fMaxIntensity; /* always set to 255 (normalized intensity) */
int fMaxP; /* maximum pixel intensity */
int fNumColumns; /* maximum number of vertical columns */
int fNumColors; /* maximum color index */
int fNumFillPatterns; /* maximum fill index */
int fInitialized; /* true if FB structure is initialized */
int fNonDestructiveText; /* true if text does not wipe background */
int fLastCursorColumn; /* last cursor column used by ShowPrompt() */
int fFilledPolygons; /* true if frame buffer has filled polygons */
int fDefinableFillPatterns; /* true if fill styles are definable */
int fButtons; /* true if pointing device has buttons */
int fNumButtons; /* number of pointing device buttons */
int fBlinkers; /* true if layers can blink */
};
extern struct f FB;
/*
* Interface Function Table
*/
struct sGinterface {
#ifdef __STDC__
int (*gInfo)(int);
int (*gOpen)(char*);
int (*gClose)(void);
int (*gUpdate)(void);
void (*gPixel)(int,int);
void (*gLine)(int,int,int,int);
void (*gBox)(int,int,int,int);
void (*gPolygon)(Poly*);
int (*gDefLs)(int,int);
int (*gSetLs)(int);
int (*gDefFp)(int,int*);
int (*gSetFp)(int);
int (*gDefColor)(int,int,int,int);
int (*gSetColor)(int);
void (*gText)(char*,int,int,int);
void (*gScText)(char*,int,int,int,int);
/* these are defined for the screen driver only */
void (*gClear)(void);
int (*gPoint)(int*, int*, int*, int*);
void (*gBeep)(int);
int (*gSetFullScreenCursor)(int);
void (*gTextBB)(char*, int*, int*);
void (*gMore)(int, int, int, int, FILE*);
void (*gSetName)(char*, char*);
int (*gBlink)(int, int, int, int, int);
int (*gSelectFont)(int, int, int, int);
void (*gSelectCursor)(int, int, int, int);
void (*gSetTextClip)(int, int, int, int);
void (*gResize)(int, int, int, int);
#else
int (*gInfo)();
int (*gOpen)();
int (*gClose)();
int (*gUpdate)();
void (*gPixel)();
void (*gLine)();
void (*gBox)();
void (*gPolygon)();
int (*gDefLs)();
int (*gSetLs)();
int (*gDefFp)();
int (*gSetFp)();
int (*gDefColor)();
int (*gSetColor)();
void (*gText)();
void (*gScText)();
void (*gClear)();
int (*gPoint)();
void (*gBeep)();
int (*gSetFullScreenCursor)();
void (*gTextBB)();
void (*gMore)();
void (*gSetName)(*);
int (*gBlink)();
int (*gSelectFont)();
void (*gSelectCursor)();
void (*gSetTextClip)();
void (*gResize)();
#endif
};
#define FBNUMINTERFACE 2
extern struct sGinterface GR[FBNUMINTERFACE];
/* printer driver codes */
#define HPLASER 'h'
#define POSTSC 'p'
#define ERASE 'e'
#define DISPLAY 'd'
#define FILL 'f'
#define OUTLINE 'o'
#define ROW_COLUMN 'r'
#define PIXEL_COORDINATE 'p'
#ifdef __STDC__
struct ka;
extern void FBBegin(char*);
extern void FBForeground(int,int);
extern void FBVLT(int,int,int,int);
extern void FBText(int,int,int,char*);
extern int FBGetchar(int);
extern char *FBEdit(char*);
extern void FBSetCursorColor(int);
extern void FBPolygon(int,int,int,int*,int);
extern void FBPolygonClip(int*,int*,struct ka*);
extern void FBSetRubberBanding(int);
extern void FBKbRepaint(int,int);
extern unsigned int FBTime(void);
extern void FBFuncKeys(int,int);
extern void XORfineViewport(void);
extern int GetWindowCoords(int*,int*,int);
extern int *SetButtonMask(void);
extern void SelectKicFont(void);
extern void SelectKicCursor(void);
extern int Xcheck(void);
extern void cprint(int,char*);
#else
extern void FBBegin();
extern void FBForeground();
extern void FBVLT();
extern void FBText();
extern int FBGetchar();
extern char *FBEdit();
extern void FBSetCursorColor();
extern void FBPolygon();
extern void FBPolygonClip();
extern void FBSetRubberBanding();
extern void FBKbRepaint();
extern unsigned int FBTime();
extern void FBFuncKeys();
extern void XORfineViewport();
extern int GetWindowCoords();
extern int *SetButtonMask();
extern void SelectKicFont();
extern void SelectKicCursor();
extern int Xcheck();
extern void cprint();
#endif
#define FBInfo (*GR[FB.fInterface].gInfo)
#define FBEnd (*GR[FB.fInterface].gClose)
#define FBTransfer (*GR[FB.fInterface].gUpdate)
#define FBLine (*GR[FB.fInterface].gLine)
#define FBPixel (*GR[FB.fInterface].gPixel)
#define FBDefineFillPattern (*GR[FB.fInterface].gDefFp)
#define FBDefineLineStyle (*GR[FB.fInterface].gDefLs)
#define FBSetFillPattern (*GR[FB.fInterface].gSetFp)
#define FBSetLineStyle (*GR[FB.fInterface].gSetLs)
#define FBScaledText (*GR[FB.fInterface].gScText)
#define FBSetColor (*GR[0].gSetColor)
#define FBFlood (*GR[0].gClear)
#define FBPoint (*GR[0].gPoint)
#define FBBeep (*GR[0].gBeep)
#define FBSetFullScreenCursor (*GR[0].gSetFullScreenCursor)
#define FBTextBB (*GR[0].gTextBB)
#define FBMore (*GR[0].gMore)
#define FBSetName (*GR[0].gSetName)
#define FBBlink (*GR[0].gBlink)
#define FBSelectFont (*GR[0].gSelectFont)
#define FBSelectCursor (*GR[0].gSelectCursor)
#define FBSetTextClip (*GR[0].gSetTextClip)
#define FBLineClip (*GR[0].gLineClip)
#define FBResizeDrawingWindow (*GR[0].gResize)
#define FBFilledBox(Pixel,DisplayOrErase,StyleId,L,B,R,T) { \
FBForeground(DisplayOrErase,Pixel); \
(*GR[FB.fInterface].gSetFp)(StyleId); \
(*GR[FB.fInterface].gBox)((int)(L),(int)(B),(int)(R),(int)(T)); \
} \
#define FBEmptyBox(Pixel,DisplayOrErase,StyleId,L,B,R,T) { \
FBForeground(DisplayOrErase,Pixel); \
(*GR[FB.fInterface].gLine)((int)(L),(int)(B),(int)(R),(int)(B)); \
(*GR[FB.fInterface].gLine)((int)(R),(int)(B),(int)(R),(int)(T)); \
(*GR[FB.fInterface].gLine)((int)(R),(int)(T),(int)(L),(int)(T)); \
(*GR[FB.fInterface].gLine)((int)(L),(int)(T),(int)(L),(int)(B)); \
} \
#define FBBox(Pixel,DisplayOrErase,Type,StyleId,L,B,R,T) { \
FBForeground(DisplayOrErase,Pixel); \
if(Type == OUTLINE){ \
(*GR[FB.fInterface].gLine)((int)(L),(int)(B),(int)(R),(int)(B)); \
(*GR[FB.fInterface].gLine)((int)(R),(int)(B),(int)(R),(int)(T)); \
(*GR[FB.fInterface].gLine)((int)(R),(int)(T),(int)(L),(int)(T)); \
(*GR[FB.fInterface].gLine)((int)(L),(int)(T),(int)(L),(int)(B)); \
} \
else { \
(*GR[FB.fInterface].gSetFp)(StyleId); \
(*GR[FB.fInterface].gBox)((int)(L),(int)(B),(int)(R),(int)(T)); \
} \
}
kic-2.4c/src/include/nmalloc.h 0000644 0000764 0000764 00000003047 07525346712 015743 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Peter P. Moore, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* for nonvirtual UNIX versions, use the old malloc by defining
* USE_OLD_MALLOC.
*
* #ifdef mc500
* #define USE_OLD_MALLOC
* #endif
*/
#ifdef USE_OLD_MALLOC
#define alloc(type) (struct type *) malloc(sizeof(struct type))
#define afree(ptr,type) free((char *) ptr)
#else
#if __STDC__
extern char *nm_malloc(unsigned);
extern void nm_free(char*,int);
extern void nm_set_block_size(int);
#else
extern char *nm_malloc();
extern void nm_free();
extern void nm_set_block_size();
#endif
#define alloc(type) (struct type *) nm_malloc(sizeof(struct type))
#define afree(ptr,type) nm_free((char *) ptr, sizeof(struct type))
#endif
kic-2.4c/src/include/sline.h 0000644 0000764 0000764 00000001126 12427444606 015422 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/* Superconducting Microstripline Model */
#ifndef SLINE_H
#define SLINE_H
struct params {
double lthick;
double ldepth;
double gpthick;
double gpdepth;
double dthick;
double dielcon;
double lwidth;
double llength;
};
struct output {
double L;
double C;
double Z;
double T;
};
void sline(struct params*, struct output*);
#endif
kic-2.4c/src/include/mfb.h 0000644 0000764 0000764 00000101374 12427442173 015057 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header: (X support)
*
* Copyright -C- 1981 Giles C. Billingsley, Kenneth H. Keller, Brian Lee
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include
#include
#include
#include
/* define this to malloc the main data area */
/*
#define MFBMALLOC
*/
/* define this to enable multiple windows, undefine MFBMALLOC */
/*
#define MFBFRAMES
*/
/* MFBInfo defines */
#define DEVICETYPE 0 /* type of device (TTY or HCOPY) */
#define MAXX 1 /* max x coordinate */
#define MAXY 2 /* max y coordinate */
#define MAXCOLORS 3 /* max number of colors */
#define MAXINTENSITY 4 /* max color intensity */
#define MAXFILLPATTERNS 5 /* max number of fill patterns */
#define MAXLINESTYLES 6 /* max number of line styles */
#define MAXBLINKERS 7 /* max number of blinkers */
#define POINTINGDEVICE 8 /* Bool: terminal has pointing device */
#define POINTINGBUTTONS 9 /* Bool: pointing device has buttons */
#define NUMBUTTONS 10 /* number of pointing device buttons */
#define BUTTON1 11 /* button value returned by button 1 */
#define BUTTON2 12 /* button value returned by button 2 */
#define BUTTON3 13 /* button value returned by button 3 */
#define BUTTON4 14 /* button value returned by button 4 */
#define BUTTON5 15 /* button value returned by button 5 */
#define BUTTON6 16 /* button value returned by button 6 */
#define BUTTON7 17 /* button value returned by button 7 */
#define BUTTON8 18 /* button value returned by button 8 */
#define BUTTON9 19 /* button value returned by button 9 */
#define BUTTON10 20 /* button value returned by button 10 */
#define BUTTON11 21 /* button value returned by button 11 */
#define BUTTON12 22 /* button value returned by button 12 */
#define TEXTPOSITIONABLE 30 /* Bool: accurately positionable text */
#define TEXTROTATABLE 31 /* Bool: rotateable text */
#define FONTHEIGHT 32 /* font height in pixels */
#define FONTWIDTH 33 /* font width in pixels */
#define FONTXOFFSET 34 /* font x offset in pixels */
#define FONTYOFFSET 35 /* font y offset in pixels */
#define DESTRUCTIVETEXT 36 /* Bool: text can be destructive */
#define OVERSTRIKETEXT 37 /* Bool: text can be overstrike */
#define VLT 38 /* Bool: definable colors (color table)*/
#define BLINKERS 39 /* Bool: terminal has blinkers */
#define FILLEDPOLYGONS 40 /* Bool: terminal has filled polygons */
#define DEFFILLPATTERNS 41 /* Bool: definable fill patterns */
#define DEFCHANNELMASK 42 /* Bool: definable write mask */
#define DEFLINEPATTERN 43 /* Bool: definable line styles */
#define CURFGCOLOR 44 /* current foreground color */
#define CURFILLPATTERN 45 /* current fill pattern */
#define CURLINESTYLE 46 /* current line style */
#define CURCHANNELMASK 47 /* current write mask */
#define CURREADMASK 48 /* current read mask */
#define NUMBITPLANES 49 /* number of bit planes */
#define DEFREADMASK 50 /* Bool: definable read mask */
#define RASTERCOPY 51 /* Bool: terminal has raster copy */
#define OFFSCREENX 52 /* left value of off screen memory */
#define OFFSCREENY 53 /* bottom value of off screen memory */
#define OFFSCREENDX 54 /* length of off screen memory */
#define OFFSCREENDY 55 /* width of off screen memory */
#define CURFONTSIZE 56 /* current text font size */
#define HORTPIXPERINCH 57 /* pixels per inch horizontally */
#define VERTPIXPERINCH 58 /* pixels per inch vertically */
#define ACTIONTIME 59 /* time of last user input action */
#define FONTNAME 60 /* pointer to current font name */
#define CURSORSHAPE 61 /* cursor shape index */
#define FULLSCREENCURSOR 62 /* full-screen cursor (true/false) */
extern long MFBInfo(int);
#define FALSE 0
#define TRUE 1
#ifndef Bool
#define Bool short
#endif
#define false FALSE
#define true TRUE
/*
* By define DEBUG we enable the MFBCounters routine for measuring bandwidth
*/
/* #define DEBUG */
#define BUFSIZE 4096 /* format string storage */
#ifndef POLYGONBUFSIZE
#define POLYGONBUFSIZE 600 /* storage for polygons */
#endif
#ifndef MAXPOLYGONVERTICES
#define MAXPOLYGONVERTICES 300 /* max number of vertices */
#endif
#define RADTODEG 57.29577951
#define UNINITIALIZED -1
#define MAXLSTYLE 32 /* max number of line styles */
#define MAXFPATT 32 /* max number of fill patterns*/
#define MFBabs(a) (a >= 0 ? a : -(a))
#define MFBmax(a,b) (a > b ? a : b)
#define MFBmin(a,b) (a < b ? a : b)
#define MFBSwapInt(f1,f2) {int f3; f3 = f1; f1 = f2; f2 = f3;}
#define MFBRound(x) ( (x)-(int)(x) >= .5 ? (int)(x)+1 : (int)(x) )
#define TTY 't'
#define HCOPY 'r'
/* Character control constants */
#define CR 015
#define LF 012
#define BS 010
#define DEL 0177
#define CTRLD 004
#define CTRLU 025
#define CTRLX 030
struct mfbwindow {
int left;
int right;
int top;
int bottom;
double length,width;
};
typedef struct mfbwindow MFBWINDOW;
typedef struct mfbwindow VIEWPORT;
struct mfbpath {
int nvertices;
int *xy;
};
typedef struct mfbpath MFBPOLYGON;
typedef struct mfbpath MFBPATH;
struct mfb {
/* Pointers */
char *name; /* display name */
char *memoryBlock; /* mem for special drivers */
int fileDesc; /* for compatibility */
/* Numerics */
int X,Y; /* saved coords for move/draw */
int maxX; /* Horizontal resolution */
int maxY; /* Vertical resolution */
int hPixelsPerInch; /* # pixels per horizontal inch */
int vPixelsPerInch; /* # pixels per vertical inch */
int maxColors; /* maximum number of colors */
int minOffScreenX; /* left of off screen memory */
int minOffScreenY; /* bottom of off screen mem. */
int offScreenDX; /* length of off screen mem. */
int offScreenDY; /* width of off screen mem. */
int maxIntensity; /* max RGB or LS intensity */
int lengthOfVLT; /* number of bit planes */
int keyboardYOffset;
int keyboardXOffset;
int lineDefineLength; /* number of bytes in array */
int maxLineStyles; /* number of line styles */
int fontHeight; /* font height in pixels */
int fontWidth; /* font width in pixels */
int fontXOffset;
int fontYOffset;
int fontSize;
int maxBlinkers; /* number of blinkers */
int fillDefineHeight; /* number of byte rows */
int fillDefineWidth; /* number of byte columns */
int maxFillPatterns; /* number of fill patterns */
int cursorColor1Id; /* blinked cursor color ID */
int cursorColor2Id; /* unblinked cursor color ID */
int fgColorId; /* cur. foreground color ID */
int fillPattern; /* cur. fill pattern ID */
int lineStyle; /* cur. line style ID */
int channelMask; /* cur. write mask */
int readMask; /* cur. read mask */
int textMode; /* text mode (1=dest, 0=rep) */
int numBlinkers; /* cur. number of blinkers */
int stipplePattern[8]; /* cur. stipple pattern */
int numberOfButtons; /* 12 maximum */
int buttonMask[12]; /* returned button masks */
#ifdef DEBUG
int nChars;
int nBoxes,sumBoxArea;
int nLines,sumLineLength;
#endif
/* Boolean Fields */
Bool initializedBool;
Bool vltBool;
Bool vltUseHLSBool;
Bool channelMaskBool;
Bool readMaskBool;
Bool pointingDeviceBool;
Bool buttonsBool;
Bool readImmediateBool;
Bool keyboardBool;
Bool linePatternDefineBool;
Bool reissueLineStyleBool;
Bool filledPlygnBool;
Bool textPositionableBool;
Bool textRotateBool;
Bool replaceTextBool;
Bool overstrikeTextBool;
Bool blinkersBool;
Bool rastCopyBool;
Bool rastRSCSFBool;
Bool fillPtrnDefineBool;
Bool fillDefineRowMajorBool;
Bool privateColors;
MFBWINDOW currentWindow; /* current window */
VIEWPORT currentViewport; /* current viewport */
/* CHARACTERS */
char deviceType; /* TTY=tty, HCOPY=hard copy */
/* X-WINDOWS structures, resource IDs, and other data */
Display *display; /* X display */
Window window; /* X window */
GC lineGC; /* X GC for drawing lines */
GC fillGC; /* X GC for filled areas */
GC dragGC; /* X GC for rubber banding */
Colormap cmap; /* X color map */
Cursor cursor; /* X cursor (current) */
Cursor cursorCross; /* X cursor (cross) */
Cursor cursorDot; /* X cursor (dot) */
XImage *cursorImage; /* X cursor image (cross) */
int cursorShape; /* X cursor shape index */
XFontStruct *font; /* X text font */
unsigned short *chartab; /* character table */
int charwidth; /* character width in table */
int charheight; /* character height in table */
char fontName[81]; /* X font name text string */
unsigned long eventMask; /* X event mask */
int visState; /* X visibility state */
Pixmap fillMap[MAXFPATT]; /* X fill pattern bitmaps */
char lStyles[MAXLSTYLE][10]; /* All defined line styles */
unsigned long *colors; /* All defined color entries */
int curALUMode; /* Current ALU mode */
Time actionTime; /* Time of last user input action */
/* Fields for dealing with rubberbanding and the full-screen cursor */
int lastX,lastY; /* last cursor position */
int bandX,bandY; /* rubber-banding origin */
#if __STDC__ /* ghost rendering function */
void (*drawghost)(int,int,int,int);
#else
void (*drawghost)();
#endif
Bool fullScreenCursor; /* full screen cursor active? */
Bool inDwgwin; /* cursor is inside drawing window */
Window dwgwin; /* drawing window */
int dwgwinX; /* drawing window origin X */
int dwgwinY; /* drawing window origin Y */
int dwgwinXmax; /* drawing window maximum X */
int dwgwinYmax; /* drawing window maximum Y */
};
typedef struct mfb MFB;
#ifdef MFBALLOCATE
/* this is called only from mfb.c */
MFB *MFBCurrent;
#if !defined(MFBFRAMES) && !defined(MFBMALLOC)
MFB MFBData;
#endif
#else
extern MFB *MFBCurrent;
#if !defined(MFBFRAMES) && !defined(MFBMALLOC)
extern MFB MFBData;
#endif
#endif
/* Define macros to reference the MFB structure via a pointer or directly */
#if defined(MFBMALLOC) || defined(MFBFRAMES)
#define mfb_name MFBCurrent->name
#define mfb_memoryBlock MFBCurrent->memoryBlock
#define mfb_X MFBCurrent->X
#define mfb_Y MFBCurrent->Y
#define mfb_maxX MFBCurrent->maxX
#define mfb_maxY MFBCurrent->maxY
#define mfb_hPixelsPerInch MFBCurrent->hPixelsPerInch
#define mfb_vPixelsPerInch MFBCurrent->vPixelsPerInch
#define mfb_maxColors MFBCurrent->maxColors
#define mfb_minOffScreenX MFBCurrent->minOffScreenX
#define mfb_minOffScreenY MFBCurrent->minOffScreenY
#define mfb_offScreenDX MFBCurrent->offScreenDX
#define mfb_offScreenDY MFBCurrent->offScreenDY
#define mfb_maxIntensity MFBCurrent->maxIntensity
#define mfb_lengthOfVLT MFBCurrent->lengthOfVLT
#define mfb_keyboardYOffset MFBCurrent->keyboardYOffset
#define mfb_keyboardXOffset MFBCurrent->keyboardXOffset
#define mfb_lineDefineLength MFBCurrent->lineDefineLength
#define mfb_maxLineStyles MFBCurrent->maxLineStyles
#define mfb_fontHeight MFBCurrent->fontHeight
#define mfb_fontWidth MFBCurrent->fontWidth
#define mfb_fontXOffset MFBCurrent->fontXOffset
#define mfb_fontYOffset MFBCurrent->fontYOffset
#define mfb_fontSize MFBCurrent->fontSize
#define mfb_maxBlinkers MFBCurrent->maxBlinkers
#define mfb_fillDefineHeight MFBCurrent->fillDefineHeight
#define mfb_fillDefineWidth MFBCurrent->fillDefineWidth
#define mfb_maxFillPatterns MFBCurrent->maxFillPatterns
#define mfb_cursorColor1Id MFBCurrent->cursorColor1Id
#define mfb_cursorColor2Id MFBCurrent->cursorColor2Id
#define mfb_fgColorId MFBCurrent->fgColorId
#define mfb_fillPattern MFBCurrent->fillPattern
#define mfb_lineStyle MFBCurrent->lineStyle
#define mfb_channelMask MFBCurrent->channelMask
#define mfb_readMask MFBCurrent->readMask
#define mfb_textMode MFBCurrent->textMode
#define mfb_numBlinkers MFBCurrent->numBlinkers
#define mfb_stipplePattern MFBCurrent->stipplePattern
#define mfb_numberOfButtons MFBCurrent->numberOfButtons
#define mfb_buttonMask MFBCurrent->buttonMask
#ifdef DEBUG
#define mfb_nChars MFBCurrent->nChars
#define mfb_nBoxes MFBCurrent->nBoxes
#define mfb_sumBoxArea MFBCurrent->sumBoxArea
#define mfb_nLines MFBCurrent->nLines
#define mfb_sumLineLength MFBCurrent->sumLineLength
#endif
#define mfb_initializedBool MFBCurrent->initializedBool
#define mfb_vltBool MFBCurrent->vltBool
#define mfb_vltUseHLSBool MFBCurrent->vltUseHLSBool
#define mfb_channelMaskBool MFBCurrent->channelMaskBool
#define mfb_readMaskBool MFBCurrent->readMaskBool
#define mfb_pointingDeviceBool MFBCurrent->pointingDeviceBool
#define mfb_buttonsBool MFBCurrent->buttonsBool
#define mfb_readImmediateBool MFBCurrent->readImmediateBool
#define mfb_keyboardBool MFBCurrent->keyboardBool
#define mfb_linePatternDefineBool MFBCurrent->linePatternDefineBool
#define mfb_reissueLineStyleBool MFBCurrent->reissueLineStyleBool
#define mfb_filledPlygnBool MFBCurrent->filledPlygnBool
#define mfb_textPositionableBool MFBCurrent->textPositionableBool
#define mfb_textRotateBool MFBCurrent->textRotateBool
#define mfb_replaceTextBool MFBCurrent->replaceTextBool
#define mfb_overstrikeTextBool MFBCurrent->overstrikeTextBool
#define mfb_blinkersBool MFBCurrent->blinkersBool
#define mfb_rastCopyBool MFBCurrent->rastCopyBool
#define mfb_rastRSCSFBool MFBCurrent->rastRSCSFBool
#define mfb_fillPtrnDefineBool MFBCurrent->fillPtrnDefineBool
#define mfb_fillDefineRowMajorBool MFBCurrent->fillDefineRowMajorBool
#define mfb_currentWindow MFBCurrent->currentWindow
#define mfb_currentViewport MFBCurrent->currentViewport
#define mfb_deviceType MFBCurrent->deviceType
#define mfb_display MFBCurrent->display
#define mfb_window MFBCurrent->window
#define mfb_lineGC MFBCurrent->lineGC
#define mfb_fillGC MFBCurrent->fillGC
#define mfb_dragGC MFBCurrent->dragGC
#define mfb_cmap MFBCurrent->cmap
#define mfb_cursor MFBCurrent->cursor
#define mfb_cursorCross MFBCurrent->cursorCross
#define mfb_cursorDot MFBCurrent->cursorDot
#define mfb_cursorImage MFBCurrent->cursorImage
#define mfb_cursorShape MFBCurrent->cursorShape
#define mfb_font MFBCurrent->font
#define mfb_chartab MFBCurrent->chartab
#define mfb_charwidth MFBCurrent->charwidth
#define mfb_charheight MFBCurrent->charheight
#define mfb_fontName MFBCurrent->fontName
#define mfb_eventMask MFBCurrent->eventMask
#define mfb_visState MFBCurrent->visState
#define mfb_fillMap MFBCurrent->fillMap
#define mfb_lStyles MFBCurrent->lStyles
#define mfb_colors MFBCurrent->colors
#define mfb_curALUMode MFBCurrent->curALUMode
#define mfb_actionTime MFBCurrent->actionTime
#define mfb_lastX MFBCurrent->lastX
#define mfb_lastY MFBCurrent->lastY
#define mfb_bandX MFBCurrent->bandX
#define mfb_bandY MFBCurrent->bandY
#define mfb_drawghost MFBCurrent->drawghost
#define mfb_fullScreenCursor MFBCurrent->fullScreenCursor
#define mfb_inDwgwin MFBCurrent->inDwgwin
#define mfb_dwgwin MFBCurrent->dwgwin
#define mfb_dwgwinX MFBCurrent->dwgwinX
#define mfb_dwgwinY MFBCurrent->dwgwinY
#define mfb_dwgwinXmax MFBCurrent->dwgwinXmax
#define mfb_dwgwinYmax MFBCurrent->dwgwinYmax
#else
#define mfb_name MFBData.name
#define mfb_memoryBlock MFBData.memoryBlock
#define mfb_X MFBData.X
#define mfb_Y MFBData.Y
#define mfb_maxX MFBData.maxX
#define mfb_maxY MFBData.maxY
#define mfb_hPixelsPerInch MFBData.hPixelsPerInch
#define mfb_vPixelsPerInch MFBData.vPixelsPerInch
#define mfb_maxColors MFBData.maxColors
#define mfb_minOffScreenX MFBData.minOffScreenX
#define mfb_minOffScreenY MFBData.minOffScreenY
#define mfb_offScreenDX MFBData.offScreenDX
#define mfb_offScreenDY MFBData.offScreenDY
#define mfb_maxIntensity MFBData.maxIntensity
#define mfb_lengthOfVLT MFBData.lengthOfVLT
#define mfb_keyboardYOffset MFBData.keyboardYOffset
#define mfb_keyboardXOffset MFBData.keyboardXOffset
#define mfb_lineDefineLength MFBData.lineDefineLength
#define mfb_maxLineStyles MFBData.maxLineStyles
#define mfb_fontHeight MFBData.fontHeight
#define mfb_fontWidth MFBData.fontWidth
#define mfb_fontXOffset MFBData.fontXOffset
#define mfb_fontYOffset MFBData.fontYOffset
#define mfb_fontSize MFBData.fontSize
#define mfb_maxBlinkers MFBData.maxBlinkers
#define mfb_fillDefineHeight MFBData.fillDefineHeight
#define mfb_fillDefineWidth MFBData.fillDefineWidth
#define mfb_maxFillPatterns MFBData.maxFillPatterns
#define mfb_cursorColor1Id MFBData.cursorColor1Id
#define mfb_cursorColor2Id MFBData.cursorColor2Id
#define mfb_fgColorId MFBData.fgColorId
#define mfb_fillPattern MFBData.fillPattern
#define mfb_lineStyle MFBData.lineStyle
#define mfb_channelMask MFBData.channelMask
#define mfb_readMask MFBData.readMask
#define mfb_textMode MFBData.textMode
#define mfb_numBlinkers MFBData.numBlinkers
#define mfb_stipplePattern MFBData.stipplePattern
#define mfb_numberOfButtons MFBData.numberOfButtons
#define mfb_buttonMask MFBData.buttonMask
#ifdef DEBUG
#define mfb_nChars MFBData.nChars
#define mfb_nBoxes MFBData.nBoxes
#define mfb_sumBoxArea MFBData.sumBoxArea
#define mfb_nLines MFBData.nLines
#define mfb_sumLineLength MFBData.sumLineLength
#endif
#define mfb_initializedBool MFBData.initializedBool
#define mfb_vltBool MFBData.vltBool
#define mfb_vltUseHLSBool MFBData.vltUseHLSBool
#define mfb_channelMaskBool MFBData.channelMaskBool
#define mfb_readMaskBool MFBData.readMaskBool
#define mfb_pointingDeviceBool MFBData.pointingDeviceBool
#define mfb_buttonsBool MFBData.buttonsBool
#define mfb_readImmediateBool MFBData.readImmediateBool
#define mfb_keyboardBool MFBData.keyboardBool
#define mfb_linePatternDefineBool MFBData.linePatternDefineBool
#define mfb_reissueLineStyleBool MFBData.reissueLineStyleBool
#define mfb_filledPlygnBool MFBData.filledPlygnBool
#define mfb_textPositionableBool MFBData.textPositionableBool
#define mfb_textRotateBool MFBData.textRotateBool
#define mfb_replaceTextBool MFBData.replaceTextBool
#define mfb_overstrikeTextBool MFBData.overstrikeTextBool
#define mfb_blinkersBool MFBData.blinkersBool
#define mfb_rastCopyBool MFBData.rastCopyBool
#define mfb_rastRSCSFBool MFBData.rastRSCSFBool
#define mfb_fillPtrnDefineBool MFBData.fillPtrnDefineBool
#define mfb_fillDefineRowMajorBool MFBData.fillDefineRowMajorBool
#define mfb_currentWindow MFBData.currentWindow
#define mfb_currentViewport MFBData.currentViewport
#define mfb_deviceType MFBData.deviceType
#define mfb_display MFBData.display
#define mfb_window MFBData.window
#define mfb_lineGC MFBData.lineGC
#define mfb_fillGC MFBData.fillGC
#define mfb_dragGC MFBData.dragGC
#define mfb_cmap MFBData.cmap
#define mfb_cursor MFBData.cursor
#define mfb_cursorCross MFBData.cursorCross
#define mfb_cursorDot MFBData.cursorDot
#define mfb_cursorImage MFBData.cursorImage
#define mfb_cursorShape MFBData.cursorShape
#define mfb_font MFBData.font
#define mfb_chartab MFBData.chartab
#define mfb_charwidth MFBData.charwidth
#define mfb_charheight MFBData.charheight
#define mfb_fontName MFBData.fontName
#define mfb_eventMask MFBData.eventMask
#define mfb_visState MFBData.visState
#define mfb_fillMap MFBData.fillMap
#define mfb_lStyles MFBData.lStyles
#define mfb_colors MFBData.colors
#define mfb_curALUMode MFBData.curALUMode
#define mfb_actionTime MFBData.actionTime
#define mfb_lastX MFBData.lastX
#define mfb_lastY MFBData.lastY
#define mfb_bandX MFBData.bandX
#define mfb_bandY MFBData.bandY
#define mfb_drawghost MFBData.drawghost
#define mfb_fullScreenCursor MFBData.fullScreenCursor
#define mfb_inDwgwin MFBData.inDwgwin
#define mfb_dwgwin MFBData.dwgwin
#define mfb_dwgwinX MFBData.dwgwinX
#define mfb_dwgwinY MFBData.dwgwinY
#define mfb_dwgwinXmax MFBData.dwgwinXmax
#define mfb_dwgwinYmax MFBData.dwgwinYmax
#endif
/* Define Macros for general program usage. */
#define TRAN(y) (MFBCurrent->maxY - y)
#define ON 1
#define OFF 0
/* MFBSetALUMode defines */
#define MFBALUJAM 0
#define MFBALUAND 1
#define MFBALUOR 2
#define MFBALUEOR 3
#define MFBALUNOR 4
/* Error defines */
#define MFBOK 1 /* Successful return */
#define MFBGENERR -5 /* General error */
#define MFBBADENT -10 /* Unknown terminal type */
#define MFBBADMCF -20 /* Can't open mfbcap file */
#define MFBMCELNG -30 /* MFBCAP entry too long */
#define MFBBADMCE -40 /* Bad mfbcap entry */
#define MFBINFMCE -50 /* Infinite mfbcap entry */
#define MFBBADTTY -60 /* stdout not in /dev */
#define MFBBADLST -70 /* Illegal line style */
#define MFBBADFST -80 /* Illegal fill style */
#define MFBBADCST -90 /* Illegal color style */
#define MFBBADTM1 -100 /* No destructive text */
#define MFBBADTM2 -110 /* No overstriking text */
#define MFBNODFLP -120 /* No definable line styles */
#define MFBNODFFP -130 /* No definable fill styles */
#define MFBNODFCO -140 /* No definable colors */
#define MFBNOBLNK -150 /* No blinkers */
#define MFBTMBLNK -160 /* Too many blinkers */
#define MFBBADDEV -180 /* Can't open or close device */
#define MFBBADOPT -190 /* Can't access or set device stat */
#define MFBNOMASK -170 /* No definable read or write mask */
#define MFBBADWRT -200 /* Error in write */
#define MFBPNTERR -210 /* Error in pointing device */
#define MFBNOPTFT -220 /* No format for pointing device */
#define MFBNOPNT -230 /* No pointing device */
#define MFBNORBND -240 /* No Rubberbanding */
#define MFBBADALU -250 /* Cannot set ALU mode */
#define MFBBADMEM -260 /* Memory allocation error */
/* number of colors to allocate (default 40) */
extern int NUM_XMFB_COLORS;
/* application supplied routines */
#if __STDC__
extern void SetDisplayWindow(int,int,int*,int*,int*,int*);
extern void RepaintWindow(int);
#else
extern void SetDisplayWindow();
extern void RepaintWindow();
#endif
/* mfb.c */
#if __STDC__
extern MFB *MFBOpen(char*,char*,int*);
extern int MFBPutchar(int);
extern int MFBPutstr(char*,int);
extern int MFBGetchar(void);
extern int MFBScaleX(int);
extern int MFBScaleY(int);
extern int MFBDescaleX(int);
extern int MFBDescaleY(int);
extern MFBPOLYGON *MFBEllipse(int,int,int,int,int);
extern MFBPATH *MFBArcPath(int,int,int,int,int,int);
extern void SetCurrentMFB(MFB*);
extern void MFBDrawPath(MFBPATH*);
extern void MFBSetViewport(int,int,int,int);
extern void MFBSetWindow(int,int,int,int);
extern void MFBNaiveBoxFill(int,int,int,int);
extern int MFBUpdate(void);
extern int MFBInitialize(void);
extern int MFBClose(void);
extern int MFBHalt(void);
extern int MFBSetLineStyle(int);
extern int MFBSetFillPattern(int);
extern int MFBSetChannelMask(int);
extern int MFBSetReadMask(int);
extern int MFBSetColor(int);
extern int MFBSetTextMode(Bool);
extern int MFBSetCursorColor(int,int);
extern int MFBSetBlinker(int,int,int,int,int);
extern int MFBSetALUMode(int);
extern int MFBSetRubberBanding(int,int,int);
extern int MFBSetGhost(void(*)(int,int,int,int),int,int);
extern int MFBSetStorage(char*);
extern char *MFBGetStorage(void);
extern int MFBDefineColor(int,int,int,int);
extern int MFBDefineFillPattern(int,int*);
extern int MFBDefineLineStyle(int,int);
extern int MFBPoint(int*,int*,int*,int*);
extern void MFBAudio(void);
extern void MFBMoveTo(int,int);
extern void MFBDrawLineTo(int,int);
extern void MFBLine(int,int,int,int);
extern void MFBBox(int,int,int,int);
extern void MFBArc(int,int,int,int,int,int);
extern void MFBCircle(int,int,int,int);
extern void MFBFlash(int,int,int,int);
extern void MFBPolygon(MFBPOLYGON*);
extern void MFBText(char*,int,int,int);
extern void MFBFlood(void);
extern void MFBPixel(int,int);
extern void MFBRasterCopy(int,int,int,int,int,int);
extern char *MFBKeyboard(int,int,int,int);
extern char *MFBError(int);
extern int MFBSetFullScreenCursor(int);
extern void MFBResizeDrawingWindow(int,int,int,int);
extern int MFBntox(int, int);
#else
extern MFB *MFBOpen();
extern int MFBPutchar();
extern int MFBPutstr();
extern int MFBGetchar();
extern int MFBScaleX();
extern int MFBScaleY();
extern int MFBDescaleX();
extern int MFBDescaleY();
extern MFBPOLYGON *MFBEllipse();
extern MFBPATH *MFBArcPath();
extern void SetCurrentMFB();
extern void MFBDrawPath();
extern void MFBSetViewport();
extern void MFBSetWindow();
extern void MFBNaiveBoxFill();
extern int MFBUpdate();
extern int MFBInitialize();
extern int MFBClose();
extern int MFBHalt();
extern int MFBSetLineStyle();
extern int MFBSetFillPattern();
extern int MFBSetChannelMask();
extern int MFBSetReadMask();
extern int MFBSetColor();
extern int MFBSetTextMode();
extern int MFBSetCursorColor();
extern int MFBSetBlinker();
extern int MFBSetALUMode();
extern int MFBSetRubberBanding();
extern int MFBSetGhost();
extern int MFBSetStorage();
extern char *MFBGetStorage();
extern int MFBDefineColor();
extern int MFBDefineFillPattern();
extern int MFBDefineLineStyle();
extern int MFBPoint();
extern void MFBAudio();
extern void MFBMoveTo();
extern void MFBDrawLineTo();
extern void MFBLine();
extern void MFBBox();
extern void MFBArc();
extern void MFBCircle();
extern void MFBFlash();
extern void MFBPolygon();
extern void MFBText();
extern void MFBFlood();
extern void MFBPixel();
extern void MFBRasterCopy();
extern char *MFBKeyboard();
extern char *MFBError();
extern int MFBSetFullScreenCursor();
extern void MFBResizeDrawingWindow();
extern int MFBntox();
#endif
/* mfbcsdl.c */
#if __STDC__
extern void MFBBeep(int);
extern void MFBRect(int,int,int,int);
extern void MFBSetName(char*,char*);
extern int MFBSelectFont(int,int,int,int);
extern int MFBSetFont(char*);
extern void MFBSelectCursor(int,int,int,int);
extern void MFBSetCursor(int);
#else
extern void MFBBeep();
extern void MFBRect();
extern void MFBSetName();
extern int MFBSelectFont();
extern int MFBSetFont();
extern void MFBSelectCursor();
extern void MFBSetCursor();
#endif
/* mfblclip.c */
#if __STDC__
extern void MFB_Y_Intercept(long,long,long,long,long,long*);
extern void MFB_X_Intercept(long,long,long,long,long,long*);
extern Bool MFBLineClip(long*,long*,long*,long*,long,long,long,long);
#else
extern void MFB_Y_Intercept();
extern void MFB_X_Intercept();
extern Bool MFBLineClip();
#endif
/* mfbtext.c */
#if __STDC__
extern int MFBScrollList(int,int,int,int,char**,int,int,int,int);
extern int MFBScrollFont(int,int,int,int,XFontStruct*,GC,int,int);
extern void MFBMore(int,int,int,int,FILE*);
extern void MFBScroll(int,int,int,int,FILE*);
#else
extern int MFBScrollList();
extern int MFBScrollFont();
extern void MFBMore();
extern void MFBScroll();
#endif
/* newpclip.c */
#if __STDC__
extern void MFBNewPolygonClip(MFBPOLYGON*,long,long,long,long);
extern int MFBNewPolygon(MFBPOLYGON*);
#else
extern void MFBNewPolygonClip();
extern int MFBNewPolygon();
#endif
/* text1.c */
#if __STDC__
extern void MFBSetTextClip(int,int,int,int);
extern int MFBScaledText(char*,int,int,int,int);
extern void MFBTextBB(char*,int*,int*);
#else
extern void MFBSetTextClip();
extern int MFBScaledText();
extern void MFBTextBB();
#endif
kic-2.4c/src/include/hlpdefs.h 0000644 0000764 0000764 00000006517 12427255655 015752 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
#include
#include
#include
#define KIC
/* name of help database file */
#define DBFILE "kic_help.txt"
typedef int bool;
#define false 0
#define true 1
/* Doubly linked lists of words. */
struct wordlist {
char *wl_word;
struct wordlist *wl_next;
struct wordlist *wl_prev;
};
typedef struct wordlist wordlist;
#define BSIZE 256
#ifndef alloc
#define alloc(zz) (struct zz *) tmalloc(sizeof(struct zz))
#endif
#define TMALLOC tmalloc
#define eq(x,y) (!strcmp((x),(y)))
#define cieq(x,y) (!strcasecmp((x),(y)))
#if __STDC__
extern char *tmalloc(unsigned);
extern char *GetString(char*,int,FILE*,char*);
extern void PutString(char*);
#else
extern char *tmalloc();
extern char *GetString();
extern void PutString();
#endif
typedef struct button {
char *text;
char *tag;
int x;
int y;
int width;
int height;
} button;
typedef struct toplink {
char *description;
char *keyword;
struct toplink *next;
button button;
} toplink;
typedef struct topic {
char *title;
char *keyword;
wordlist *text;
toplink *subtopics;
toplink *seealso;
int xposition;
int yposition;
struct topic *parent;
struct topic *children;
struct topic *next;
struct topic *winlink;
struct topic *readlink;
int numlines;
int maxcols;
int curtopline;
} topic;
/* External symbols. */
/* help.c */
extern char *hlp_directory;
extern FILE *cp_in;
extern FILE *cp_out;
extern FILE *cp_err;
extern char *HELPPATH;
extern int out_isatty;
#if __STDC__
extern void hlp_main(char*,char*);
extern void hlp_pathfix(char*);
#else
extern void hlp_main();
extern void hlp_pathfix();
#endif
/* provide.c */
#if __STDC__
extern void hlp_provide(topic*);
#else
extern void hlp_provide();
#endif
/* readhelp.c */
#if __STDC__
extern topic *hlp_read(char*);
extern void hlp_free(void);
#else
extern topic *hlp_read();
extern void hlp_free();
#endif
/* textdisp.c */
#if __STDC__
extern bool hlp_tdisplay(topic*);
extern toplink *hlp_thandle(topic**);
extern void hlp_tkillwin(topic*);
extern void out_init(void);
extern void out_printf(char*, ...);
extern void err_printf(char*, ...);
extern void out_cprint(char*, ...);
extern char *copy(char*);
extern bool ciprefix(char*,char*);
extern void wl_free(wordlist*);
extern char *dostemp(char*);
extern void cprint(int, char*);
extern void PutErrorString(char*);
extern void PutBoldString(char*);
#else
extern bool hlp_tdisplay();
extern toplink *hlp_thandle();
extern void hlp_tkillwin();
extern void out_init();
extern void out_printf();
extern void err_printf();
extern void out_cprint();
extern char *copy();
extern bool ciprefix();
extern void wl_free();
extern char *dostemp();
extern void cprint();
extern void PutErrorString();
extern void PutBoldString();
#endif
kic-2.4c/src/include/cd.h 0000644 0000764 0000764 00000020515 10261420573 014670 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* CD is a CIF database package that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The programs in
* CD are available free of charge to any interested party.
* The sale, resale, or use of these programs for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* CD package data structures.
*
* Giles Billingsley
* Ken Keller
*/
#include
#include
#include
#include
#include
#include "nmalloc.h"
#include "macros.h"
#ifdef vms
#define void int
#endif
#define CDDelete CDDeleteObjectDesc
#define FILENAMESIZE 32 /* maximum size of a file name */
/*
* Values routines return in StatusInt of CDOpen, CDBeginMakeCall,
* CDTo, CDFrom, or CDParseCIF.
*/
#define CDPARSEFAILED 1 /* (FATAL) parse failed */
#define CDOLDSYMBOL 2 /* symbol already exists in database */
#define CDNEWSYMBOL 3 /* (empty) symbol not in search path */
#define CDSUCCEEDED 4 /* new symbol(s) found in search path */
/*
* Valid arguments to CDError().
*/
#define CDMALLOCFAILED 11 /* (FATAL) out of memory */
#define CDBADBOX 12 /* zero width or length box */
#define CDXFORMSTACKFULL 13 /* transform stack overflow */
#define CDBADPATH 14 /* bad directory name in search path */
/*
* Types of geometries
*/
#define CDSYMBOLCALL 'c'
#define CDPOLYGON 'p'
#define CDROUNDFLASH 'r'
#define CDLABEL 'l'
#define CDWIRE 'w'
#define CDBOX 'b'
/*
* Types of transformations
*/
#define CDMIRRORX 'x' /* mirror in the direction of x */
#define CDMIRRORY 'y' /* mirror in the direction of y */
#define CDROTATE 'r' /* rotate by vector X,Y */
#define CDTRANSLATE 't' /* translate to X,Y */
/*
* CD Control flags; See struct d below.
*/
#define DCONTROLCDOPEN 'o'
#define DCONTROLPCIF 'p'
#define DCONTROLCDTO 't'
#define DCONTROLVANILLA 'v'
/*
* Coordinate system with 1 micron features and 1 cm dice.
* Remember that there are 100 CIF units per micron.
*/
#define CDINFINITY 100000000L
/*
* These are the numbers that CD uses to determine which bin an object
* resides in. They should reflect the average size of a layout being
* edited by KIC. KIC will not fail if the numbers are too small.
* Anything outside of this window is placed in the residual bin.
* If these numbers become too large, CDIntersect() must use floating
* point calculations.
*/
#define CDBINMAXX 500000L
#define CDBINMAXY 500000L
#define CDBINMINX (-CDBINMAXX)
#define CDBINMINY (-CDBINMAXY)
/*
* PLEASE NOTE
* ^^^^^^^^^^^
* Because a char is used as the layer fields, the absolute maximum
* number of layers is 127. The may be increase by recompiling
* KIC and CD with the Layer typed as ints.
*/
#define CDNUMBINS 10
#define CDNUMLAYERS 70
/*
* Number of symbols stored in the symbol table for any given CIF file.
*/
#define CDNUMREMEMBER 3000
/*
* Storage for diagnostics of CDError().
*/
extern char *CDStatusString;
extern int CDStatusInt;
/*
* Relax polygon min vertex requirement
*/
extern int CDBogusPoly;
/*
* Master list desc.
*/
struct m {
int mLeft,mBottom,mRight,mTop;
char *mName;
struct m *mPred,*mSucc;
int mReferenceCount;
};
/*
* Propety List desc.
* SRW ** added Info field.
* CD itself doesn't use it.
*/
struct prpty {
char *prpty_String;
char *prpty_Info;
struct prpty *prpty_Succ;
int prpty_Value;
};
/*
* Symbol desc.
*/
struct s {
int sLeft,sBottom,sRight,sTop;
int sA,sB;
char *sName;
/*
* One bin foe each layer. Layer 0 is for call descs.
* Each bin points to a double linked list of object descs.
* Bin[.][0][0] are the RESIDUAL bins--Bin[.][0][1] and Bin[.][1][0]
* are unused TUNABLE. NumBins should be as big as it can be.
* For 20 layers and 100 bins per layer,
* the data structure becomes 2000 words.
*/
struct o ***sBin[CDNUMLAYERS+1];
struct m *sMasterList;
struct prpty *sPrptyList;
short sInfo;
short sBBValid;
};
/*
* Object desc.
*/
struct o {
int oLeft,oBottom,oRight,oTop;
struct o *oRep;
struct o *oPred,*oSucc;
struct prpty *oPrptyList;
short oInfo;
char oType;
char oLayer;
};
/*
* Polygon desc.
*/
struct po {
struct p *poPath;
};
/*
* Round flash desc.
*/
struct r {
int rWidth,rX,rY;
};
/*
* Wire desc.
*/
struct w {
int wWidth;
struct p *wPath;
};
/*
* Call desc.
*/
struct c {
int cDX,cDY; /* center to center array spacing */
struct t *cT; /* Pointer to transformation descriptor. */
struct m *cMaster; /* Pointer to master list descriptor. */
short cNumX,cNumY; /* Array parameters. */
int cNum;
};
/*
* Transform desc.
* If MX, tType == CDMIRRORX.
* If MY, tType == CDMIRRORX.
* If R, tType == CDROTATE, tX == XDirection, tY == YDirection.
* If T, tType == CDTRANSLATE, tX == TX, tY = TY;
*/
struct t {
int tX,tY;
struct t *tSucc;
char tType;
};
/*
* Label desc.
*/
struct la {
int laX,laY;
char *laLabel;
char laXform;
/* laXform bits:
* 0-1, 0-no rotation, 1-90, 2-180, 3-270.
* 2, mirror y
* 3, mirror x
*/
};
/*
* Linked path structure
*/
struct p {
int pX,pY;
struct p *pSucc;
};
/*
* Generator desc.
* Search Bin[Layer][0][0] first.
* Then Bin[Layer][BeginX..EndX][BeginY..EndY].
* Bin[Layer][X][Y] is the current bin.
* Pointer points to the current desc in the current bin.
*/
struct g {
int gLeft,gBottom,gRight,gTop;
int gBeginX,gX,gEndX,gBeginY,gY,gEndY;
struct o *gPointer;
int gLayer;
};
/*
* CD's current parameter struct
*/
struct d {
/* Current parameters for symbol being parsed in CDOpen. */
int dNumX,dNumY;
int dDX,dDY;
/* Scale factors for CDTo and CDFrom. */
int dA,dB;
/* Symbol scale factors. */
int dDSA,dDSB;
struct o *dPointer;
struct s *dSymbolDesc;
struct s *dRootCellDesc;
FILE *dSymbolFileDesc;
/*
* Fields used in CDTo follow.
*/
/* True if parsing root symbol. */
int dRoot;
/* Root's file desc. */
FILE *dRootFileDesc;
/* Current property list for symbol being parsed */
struct prpty *dPrptyList;
/*
* Symbol name table.
* Big arrays are allocated in CDInit().
*/
char (*dSymTabNames)[FILENAMESIZE];
int *dSymTabNumbers;
int dNumSymbolTable;
/*
* Because CIF files may have FORWARD references, CDTo must pass
* over the CIF file TWICE.
* On the first pass, it just fills up the symbol name table.
* On the second pass, it does the translation to KIC format.
*/
int dFirstPass;
/*
* True if debugging.
*/
int dDebug;
int dNumSymbolsAllocated;
/*
* DCONTROLCDOPEN => CD is in CDOpen
* DCONTROLPCIF => CD is in CDOpen and parsing CIF rather than kic
* DCONTROLCDTO => CD is in CDTo
* DCONTROLVANILLA => CD is in none of the above
*/
char dControl;
/*
* dProgram == 'h' if IGS gened it.
* == 'i' if Icarus gened it.
* == 's' if Sif gened it.
* == 'n' if none of the above.
*/
char dProgram;
char dSymbolName[FILENAMESIZE];
};
extern struct d CDDesc;
/*
* CD layer table
*/
struct l {
char lTechnology;
char lMask[3];
/*True if CDFrom should output layer.*/
char lCDFrom;
};
extern struct l CDLayer[CDNUMLAYERS+1];
/*
* Hash table of symbol descs keyed on symbol's name.
*/
struct bu {
struct s *buSymbolDesc;
struct bu *buPred;
struct bu *buSucc;
};
extern struct bu *CDSymbolTable[CDNUMLAYERS+1];
#include "cdext.h"
kic-2.4c/src/include/driver.h 0000644 0000764 0000764 00000015114 07525346712 015607 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************/
#ifndef MFB_H
/* Defines for MFBInfo */
#define DEVICETYPE 0 /* type of device (TTY or HCOPY) */
#define MAXX 1 /* max x coordinate */
#define MAXY 2 /* max y coordinate */
#define MAXCOLORS 3 /* max number of colors */
#define MAXINTENSITY 4 /* max color intensity */
#define MAXFILLPATTERNS 5 /* max number of fill patterns */
#define MAXLINESTYLES 6 /* max number of line styles */
#define MAXBLINKERS 7 /* max number of blinkers */
#define POINTINGDEVICE 8 /* Bool: terminal has pointing device */
#define POINTINGBUTTONS 9 /* Bool: pointing device has buttons */
#define NUMBUTTONS 10 /* number of pointing device buttons */
#define BUTTON1 11 /* button value returned by button 1 */
#define BUTTON2 12 /* button value returned by button 2 */
#define BUTTON3 13 /* button value returned by button 3 */
#define BUTTON4 14 /* button value returned by button 4 */
#define BUTTON5 15 /* button value returned by button 5 */
#define BUTTON6 16 /* button value returned by button 6 */
#define BUTTON7 17 /* button value returned by button 7 */
#define BUTTON8 18 /* button value returned by button 8 */
#define BUTTON9 19 /* button value returned by button 9 */
#define BUTTON10 20 /* button value returned by button 10 */
#define BUTTON11 21 /* button value returned by button 11 */
#define BUTTON12 22 /* button value returned by button 12 */
#define TEXTPOSITIONABLE 30 /* Bool: accurately positionable text */
#define TEXTROTATABLE 31 /* Bool: rotateable text */
#define FONTHEIGHT 32 /* font height in pixels */
#define FONTWIDTH 33 /* font width in pixels */
#define FONTXOFFSET 34 /* font x offset in pixels */
#define FONTYOFFSET 35 /* font y offset in pixels */
#define DESTRUCTIVETEXT 36 /* Bool: text can be destructive */
#define OVERSTRIKETEXT 37 /* Bool: text can be overstrike */
#define VLT 38 /* Bool: terminal has VLT */
#define BLINKERS 39 /* Bool: terminal has blinkers */
#define FILLEDPOLYGONS 40 /* Bool: terminal has filled polygons */
#define DEFFILLPATTERNS 41 /* Bool: defineable fill patterns */
#define DEFCHANNELMASK 42 /* Bool: defineable write mask */
#define DEFLINEPATTERN 43 /* Bool: defineable line styles */
#define CURFGCOLOR 44 /* current foreground color */
#define CURFILLPATTERN 45 /* current fill pattern */
#define CURLINESTYLE 46 /* current line style */
#define CURCHANNELMASK 47 /* current write mask */
#define CURREADMASK 48 /* current read mask */
#define NUMBITPLANES 49 /* number of bit planes */
#define DEFREADMASK 50 /* Bool: definable read mask */
#define RASTERCOPY 51 /* Bool: terminal has raster copy */
#define OFFSCREENX 52 /* left value of off screen memory */
#define OFFSCREENY 53 /* bottom value of off screen memory */
#define OFFSCREENDX 54 /* length of off screen memory */
#define OFFSCREENDY 55 /* width of off screen memory */
#define CURFONTSIZE 56 /* current text font size */
#define HORTPIXPERINCH 57 /* pixels per inch horizontally */
#define VERTPIXPERINCH 58 /* pixels per inch vertically */
#define ACTIONTIME 59 /* time of last user input action */
#define FONTNAME 60 /* pointer to current font name */
#define CURSORSHAPE 61 /* cursor shape index */
#define FULLSCREENCURSOR 62 /* full-screen cursor (true/false) */
struct mfbpath {
int nvertices;
int *xy;
};
typedef struct mfbpath MFBPOLYGON;
typedef struct mfbpath MFBPATH;
typedef short Bool;
typedef char MFB;
#endif
#ifdef __STDC__
extern int GR_info(int); /* return info */
extern int GR_open(char*); /* start graphics */
extern int GR_close(void); /* exit */
extern int GR_update(void); /* update screen (nop here) */
extern void GR_pixel(int,int); /* draw pixel in current color */
extern void GR_line(int,int,int,int); /* draw line, cur colr, style */
extern void GR_box(int,int,int,int); /* draw box cur colr, fillpatt */
extern void GR_polygon(Poly*); /* draw polygon */
extern int GR_defLs(int,int); /* define new line style */
extern int GR_setLs(int); /* set current line style */
extern int GR_defFp(int,int*); /* define new fill pattern */
extern int GR_setFp(int); /* set fill pattern */
extern int GR_defColor(int,int,int,int); /* define new color */
extern int GR_setColor(int); /* set current color */
extern void GR_text(char*,int,int,int); /* display text */
extern void GR_scText(char*,int,int,int,int);/* text with big pixels */
#else
extern int GR_info(); /* return info */
extern int GR_open(); /* start graphics */
extern int GR_close(); /* exit */
extern int GR_update(); /* update screen (nop here) */
extern void GR_pixel(); /* draw pixel in current color */
extern void GR_line(); /* draw line, cur colr, style */
extern void GR_box(); /* draw box cur colr, fillpatt */
extern void GR_polygon(); /* draw polygon */
extern int GR_defLs(); /* define new line style */
extern int GR_setLs(); /* set current line style */
extern int GR_defFp(); /* define new fill pattern */
extern int GR_setFp(); /* set fill pattern */
extern int GR_defColor(); /* define new color */
extern int GR_setColor(); /* set current color */
extern void GR_text(); /* display text */
extern void GR_scText(); /* text with big pixels */
#endif
kic-2.4c/src/include/stream.h 0000644 0000764 0000764 00000015677 07525346712 015625 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include
#include
/* if the target machine uses IEEE floating point format, */
#define IEEE
/* otherwise a DEC VAX format is assumed */
/*
* We use the property list of KIC symbols to save the library information;
* The value of the property is the numeric value of the STREAM record
* type offset by 7000 (e.g. 7000 is the KIC property value describing the
* STREAM version number, 7002 is the KIC property value describing the
* STREAM library name, etc.) The offset of 7000 was arbitrarily selected,
* and care must be taken so that this value does not conflict with any
* other convention. The PROPERTYOFFSET define is for convenience.
*
* The STREAM-specific property list is attributed to every KIC symbol
* by 'strmtokic', and 'kictostrm' will look for this information.
*/
#define PROPERTYOFFSET 7000
#define MAXSTRMCOORDS 500
#define MAXSYMBOLS 2000
#define MAXRECSIZE 2048
#define RADTODEG 57.29577951
typedef struct rct1{
int left;
int bottom;
int right;
int top;
struct rct1 *r_next;
}
RECT;
typedef struct{
int pointx;
int pointy;
}
POINT;
struct pathlist{
POINT pathpoint;
struct pathlist *pathlink;
};
typedef struct pathlist PATHLIST;
struct STREAM_info {
int byte_count; /* counter of the number of bytes */
/* currently in the streamfile */
int rec_count; /* number of records in streamfile */
int struct_count; /* number of structures in streamfile */
int level; /* current level in STREAM library */
int test; /* activates STREAM level test */
};
extern FILE *STREAMFILE; /* STREAM output file */
struct strans { /* structure with strm_strnsfm info. */
int trns_reflection; /* x-axis reflection flag */
int trns_abs_mag; /* absolute magnification flag */
int trns_abs_angle; /* absolute angle flag */
double trns_mag; /* magnification factor */
double trns_angle; /* angular rotation factor */
};
typedef struct strans STRM_TRANSFORM;
struct property_element {
int prp_npropval; /* number of property-attribute pairs */
int prp_propattr[256];
char *prp_propval[256]; /* pointers to the property strings */
};
typedef struct property_element STRM_PROPERTY;
struct library_information {
struct tm lib_moddate; /* modification date structure */
struct tm lib_accessdate; /* access date structure */
int lib_gen; /* number of generations */
double lib_uunit, lib_munit; /* length of database unit */
char lib_name[45]; /* pointer to library name */
char lib_lib1[45]; /* pointers to reflib names */
char lib_lib2[45];
char lib_font0[45]; /* pointers to font names */
char lib_font1[45];
char lib_font2[45];
char lib_font3[45];
char lib_attr[45]; /* attribute filename */
};
typedef struct library_information STRM_LIBRARY;
struct stream_strct_data {
struct tm str_moddate;
struct tm str_creatdate;
char str_name[45];
};
typedef struct stream_strct_data STRM_STRCT;
struct text_element {
int txt_layer;
int txt_texttype;
int txt_horizontal; /* 0=left justified, 1=center, 2=right */
int txt_vertical; /* 0=top justified, 1=middle, 2=bottom */
int txt_pathtype;
int txt_font;
int txt_width;
int txt_xy[2];
struct strans txt_transform;
struct property_element txt_prop;
char txt_text[45];
};
typedef struct text_element STRM_TEXT;
struct aref_element {
int ar_col;
int ar_row;
int ar_xy[6];
struct strans ar_transform;
struct property_element ar_prop;
char ar_name[45];
};
typedef struct aref_element STRM_AREF;
struct sref_element {
int sr_xy[2];
struct strans sr_transform;
struct property_element sr_prop;
char sr_name[45];
};
typedef struct sref_element STRM_SREF;
struct path_element {
int pth_layer;
int pth_datatype;
int pth_pathtype;
int pth_ncoord;
int pth_width;
int pth_xy[MAXSTRMCOORDS];
struct property_element pth_prop;
};
typedef struct path_element STRM_PATH;
struct bndry_element {
int bnd_layer;
int bnd_datatype;
int bnd_ncoord;
int bnd_xy[MAXSTRMCOORDS];
struct property_element bnd_prop;
};
typedef struct bndry_element STRM_BOUNDARY;
/* The following are definitions of CALMA Stream elements */
/* that would otherwise be noted by number. */
#define HEADER 0
#define BGNLIB 1
#define LIBNAME 2
#define UNITS 3
#define ENDLIB 4
#define BGNSTR 5
#define STRNAME 6
#define ENDSTR 7
#define BOUNDARY 8
#define PATH 9
#define SREF 10
#define AREF 11
#define TEXT 12
#define LAYER 13
#define DATATYPE 14
#define WIDTH 15
#define XY 16
#define ENDEL 17
#define SNAME 18
#define COLROW 19
#define TEXTNODE 20
#define SNAPNODE 21
#define TEXTTYPE 22
#define PRESENTATION 23
#define SPACING 24
#define STRING 25
#define STRANS 26
#define MAG 27
#define ANGLE 28
#define UINTEGER 29
#define USTRING 30
#define REFLIBS 31
#define FONTS 32
#define PATHTYPE 33
#define GENERATIONS 34
#define ATTRTABLE 35
#define STYPTABLE 36
#define STRTYPE 37
#define ELFLAGS 38
#define ELKEY 39
#define LINKTYPE 40
#define LINKKEYS 41
#define NODETYPE 42
#define PROPATTR 43
#define PROPVALUE 44
/* DOS filename mapping */
#define ALIASFILE "dos__str.als"
struct aliastab {
char strname[48];
char dosname[10];
struct aliastab *next;
};
#ifdef __STDC__
extern void readalias(void);
#else
extern void readalias();
#endif
kic-2.4c/src/include/macros.h 0000644 0000764 0000764 00000002622 07525346712 015600 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#define EOS '\0'
#define elif else if
#define loop for(;;)
#define True 1
#define False 0
#define And &&
#define Or ||
#define Not !
#ifndef max
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#endif
#ifndef min
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#endif
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#define SwapInts(Dragon,Eagle) {int ShakingCrane; \
ShakingCrane = Dragon; Dragon = Eagle; Eagle = ShakingCrane;}
kic-2.4c/src/include/coords.h 0000644 0000764 0000764 00000003217 07525346712 015606 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#define CoarseLToP(X,Y,XT,YT) \
XT = .5+(X-View->kvCoarseWindow->kaLeft)*View->kvCoarseRatio; \
XT += View->kvCoarseViewport->kaLeft; \
YT = .5+(Y-View->kvCoarseWindow->kaBottom)*View->kvCoarseRatio; \
YT += View->kvCoarseViewport->kaBottom;
#define FineLToP(X,Y,XT,YT) \
XT = .5+(X-View->kvFineWindow->kaLeft)*View->kvFineRatio; \
XT += View->kvFineViewport->kaLeft; \
YT = .5+(Y-View->kvFineWindow->kaBottom)*View->kvFineRatio; \
YT += View->kvFineViewport->kaBottom;
#define ClipVP(Viewport,X,Y) \
if(X < Viewport->kaLeft) X = Viewport->kaLeft; \
else if(X > Viewport->kaRight) X = Viewport->kaRight; \
if(Y < Viewport->kaBottom) Y = Viewport->kaBottom; \
else if(Y > Viewport->kaTop) Y = Viewport->kaTop;
kic-2.4c/src/include/kicext.h 0000644 0000764 0000764 00000040124 12427444574 015604 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
#ifdef __STDC__
extern void fatal_error(const char*);
#else
extern void fatal_error();
#endif
/* 45s.c */
#ifdef __STDC__
extern void To45(int,int,int*,int*);
extern int IsManhattan(int,int,int,int);
#else
extern void To45();
extern int IsManhattan();
#endif
/* attri.c */
extern int NoMakeVisible;
#ifdef __STDC__
extern void Attri(int*);
extern void Updat(void);
extern void DisplayLabels(void);
extern void LabelInstances(void);
extern void Mark(void);
extern void Sides(void);
extern void AttribColor(int*);
extern void ShowRGB(void);
extern void SetColor(int,int);
extern void SetGrid(int*);
extern void Visib(int*);
extern void MakeLayerVisible(int);
extern void MakeLayerInvisible(int);
extern void Blink(int*);
extern void Dimen(int*);
extern void RemoveLayer(int*);
extern void AddLayer(void);
extern void Fill(int*);
extern int RepaintFILL(void);
#else
extern void Attri();
extern void Updat();
extern void DisplayLabels();
extern void LabelInstances();
extern void Mark();
extern void Sides();
extern void AttribColor();
extern void ShowRGB();
extern void SetColor();
extern void SetGrid();
extern void Visib();
extern void MakeLayerVisible();
extern void MakeLayerInvisible();
extern void Blink();
extern void Dimen();
extern void RemoveLayer();
extern void AddLayer();
extern void Fill();
extern int RepaintFILL();
#endif
/* basic.c */
#ifdef __STDC__
extern void Basic(int*);
extern void Rdraw(void);
extern void Undo(void);
extern void DoSet45(void);
extern void AbortKIC(void);
extern void ShowFull(void);
extern void Snap(void);
extern void Edit(int,int,int);
extern void TitleWindow(void);
extern void Save(void);
extern void WriteCell(void);
extern void Peek(void);
extern void Expand(void);
extern void CenterFullView(void);
extern int FixCellName(char*);
#else
extern void Basic();
extern void Rdraw();
extern void Undo();
extern void DoSet45();
extern void AbortKIC();
extern void ShowFull();
extern void Snap();
extern void Edit();
extern void TitleWindow();
extern void Save();
extern void WriteCell();
extern void Peek();
extern void Expand();
extern void CenterFullView();
extern int FixCellName();
#endif
/* boxes.c */
extern int MakingBoxes;
#ifdef __STDC__
extern int InBox(int,int,struct ka*);
extern void ShowBox(int,struct ka*);
extern void ShowEmptyBox(int,struct ka*);
extern void EraseBox(struct ka*);
extern void Boxes(int*);
extern void OversizeBox(struct ka*,int);
extern void OutlineBox(struct ka*);
#else
extern int InBox();
extern void ShowBox();
extern void ShowEmptyBox();
extern void EraseBox();
extern void Boxes();
extern void OversizeBox();
extern void OutlineBox();
#endif
/* break.c */
#ifdef __STDC__
extern void Break(int*);
extern struct p *CopyPath(struct p*);
#else
extern void Break();
extern struct p *CopyPath();
#endif
/* change.c */
#ifdef __STDC__
extern void ChangeLayer(int*);
#else
extern void ChangeLayer();
#endif
/* contexts.c */
#ifdef __STDC__
extern void Push(int*);
extern void ShowContext(void);
extern void UpdateParent(char*);
extern void Pop(void);
extern int CheckModified(void);
extern void ClearContext(void);
#else
extern void Push();
extern void ShowContext();
extern void UpdateParent();
extern void Pop();
extern int CheckModified();
extern void ClearContext();
#endif
/* copy.c */
#ifdef __STDC__
extern void Copy(int*);
extern void Move(int*);
extern void CopyPathWithXForm(struct p**);
extern void ShowMove(int,int,int,int);
extern void SetNewTransform(int,int,int,int);
#else
extern void Copy();
extern void Move();
extern void CopyPathWithXForm();
extern void ShowGhost();
extern void SetNewTransform();
#endif
/* debug.c */
#ifdef __STDC__
extern void Debug(int*);
extern void DoBW(void);
extern void DoAlloc(void);
#else
extern void Debug();
extern void DoBW();
extern void DoAlloc();
#endif
/* delete.c */
#ifdef __STDC__
extern void Del(int*);
#else
extern void Del();
#endif
/* dir.c */
#ifdef __STDC__
extern void Dir(void);
#else
extern void Dir();
#endif
/* erase.c */
#ifdef __STDC__
extern void Erase(int*);
extern void NewBox(int,int,int,int,int);
extern void NewPoly(Poly*,int);
#else
extern void Erase();
extern void NewBox();
extern void NewPoly();
#endif
/* flatten.c */
#ifdef __STDC__
extern void Flatten(int*);
#else
extern void Flatten();
#endif
/* grid.c */
#ifdef __STDC__
extern void ShowGrid(void);
extern void ShowAxes(void);
#else
extern void ShowGrid();
extern void ShowAxes();
#endif
/* hcopy.c */
#ifdef __STDC__
extern void Hcopy(void);
#else
extern void Hcopy();
#endif
/* init.c */
extern struct kv *View;
extern struct ka MenuViewport;
extern struct ka ParameterViewport;
extern struct ka LayerTableViewport;
extern struct kp Parameters;
extern struct kl LayerTable[CDNUMLAYERS+1];
extern struct kc KicCursor;
extern struct a CurrentAOI;
extern int NumLayerTable;
extern char TypeOut[200];
#ifdef __STDC__
extern void Init(void);
extern void InitColorTable(void);
extern void InitVLT(void);
extern void InitParameters(void);
extern void DefaultWindows(void);
extern void InitCoarseWindow(int,int,int);
extern void InitFineWindow(int,int);
extern void SetPositioning(void);
extern void InitViewport(void);
extern void SetCurrentAOI(struct ka*);
#else
extern void Init();
extern void InitColorTable();
extern void InitVLT();
extern void InitParameters();
extern void DefaultWindows();
extern void InitCoarseWindow();
extern void InitFineWindow();
extern void SetPositioning();
extern void InitViewport();
extern void SetCurrentAOI();
#endif
/* instance.c */
#ifdef __STDC__
extern void Place(int*);
extern void Handle(void);
extern void ShowNewInstance(int,int,int,int);
extern void MakeInstance(int*,char*);
extern void GetArraySpec(void);
extern void NewSymbol(void);
extern int OpenCell(char*,struct s**);
#else
extern void Place();
extern void Handle();
extern void ShowNewInstance();
extern void MakeInstance();
extern void GetArraySpec();
extern void NewSymbol();
extern int OpenCell();
#endif
/* kicmain.c */
#ifdef __STDC__
extern void InitMenus(void);
extern void KICMain(void);
extern int SafeCmds(int*);
extern char *NextCellName(void);
extern void SaveTechFile(void);
extern void InitSignals(void);
extern char *CopyString(char*);
extern char *tmalloc(unsigned);
extern void MallocFailed(void);
extern void UpdatePpoperties();
extern FILE *OpenDevice();
extern void Help(void);
extern void PutString(char*);
extern void PutErrorString(char*);
extern void PutBoldString(char*);
extern char *GetString(char*,int,FILE*,char*);
extern void RepaintWindow(int);
#else
extern void InitMenus();
extern void KICMain();
extern int SafeCmds();
extern char *NextCellName();
extern void SaveTechFile();
extern void InitSignals();
extern char *CopyString();
extern char *tmalloc();
extern void MallocFailed();
extern void UpdatePpoperties();
extern FILE *OpenDevice();
extern void Help();
extern void PutString();
extern void PutErrorString();
extern void PutBoldString();
extern char *GetString();
extern void RepaintWindow();
#endif
/* labels.c */
#ifdef __STDC__
extern void Label(int*);
extern void BBLabel(struct ka*,struct o*,struct ka*);
extern void CDLabelBB(struct o*,int*,int*,int*,int*);
extern void ShowLabel(int,char*,int,int,int,int);
extern char SetXform(int*);
#else
extern void Label();
extern void BBLabel();
extern void CDLabelBB();
extern void ShowLabel();
extern char SetXform();
#endif
/* lineclip.c */
#ifdef __STDC__
extern void Y_Intercept(int,int,int,int,int,int*);
extern void X_Intercept(int,int,int,int,int,int*);
extern int LineClip(int*,int*,int*,int*,int,int,int,int);
#else
extern void Y_Intercept();
extern void X_Intercept();
extern int LineClip();
#endif
/* lines.c */
#ifdef __STDC__
extern void ShowLine(int,int,int,int,int);
extern void ShowManhattanLine(int,int,int,int,int);
#else
extern void ShowLine();
extern void ShowManhattanLine();
#endif
/* logo.c */
#ifdef __STDC__
extern void Logo(int*);
#else
extern void Logo();
#endif
/* measure.c */
#ifdef __STDC__
extern void StartTiming(void);
extern void StopTiming(void);
extern int ElapsedRealTime(void);
extern int ElapsedUserTime(void);
extern int ElapsedSystemTime(void);
extern void ShowRatio(char*,int,char*,int);
#else
extern void StartTiming();
extern void StopTiming();
extern int ElapsedRealTime();
extern int ElapsedUserTime();
extern int ElapsedSystemTime();
extern void ShowRatio();
#endif
/* modify.c */
#ifdef __STDC__
extern void Stretch(int*);
extern void SetStretchMode(void);
extern void ShowStretch(int,int,int,int);
#else
extern void Stretch();
extern void SetStretchMode();
extern void ShowStretch();
#endif
/* more.c */
#ifdef __STDC__
extern int MoreLine(char*);
extern void EnableMore(int);
extern int RepaintMore(void);
extern int MorePageDisplay(void);
#else
extern int MoreLine();
extern void EnableMore();
extern int RepaintMore();
extern int MorePageDisplay();
#endif
/* point.c */
extern int LockOut;
#ifdef __STDC__
extern void Point(void);
extern int PointLoop(int*);
extern int PointLoopCreate(int*);
extern int PointLoopSafe(int*);
extern int PointLoopLayer(int*);
extern void NotPointingAtLayout(void);
extern void RedisplayKIC(void);
extern void FullRedisplay(void);
extern void FinePosition(int,int,int);
#else
extern void Point();
extern int PointLoop();
extern int PointLoopCreate();
extern int PointLoopSafe();
extern int PointLoopLayer();
extern void NotPointingAtLayout();
extern void RedisplayKIC();
extern void FullRedisplay();
extern void FinePosition();
#endif
/* polyclip.c */
#ifdef __STDC__
extern void PolygonClip(Poly*,int,int,int,int);
extern int NewPolygon(Poly*);
#else
extern void PolygonClip();
extern int NewPolygon();
#endif
/* polygns.c */
#ifdef __STDC__
extern void Polygons(int*);
extern void Flash(int*);
extern void Doughnut(int*);
extern void Arcs(int*);
extern void ShowPath(int,struct p*,int);
extern void ShowPolygon(int,struct p*);
extern void LastPointInPath(int*,int*,struct p*);
extern struct p *AllocatePath(int,int);
#else
extern void Polygons();
extern void Flash();
extern void Doughnut();
extern void Arcs();
extern void ShowPath();
extern void ShowPolygon();
extern void LastPointInPath();
extern struct p *AllocatePath();
#endif
/* prpty.c */
#ifdef __STDC__
extern void Properties(int*);
extern void DoShowProperties(void);
extern void AddProperty(void);
extern void RemoveProperty(void);
extern void RemovePropertyList(struct o*,struct prpty**);
extern void RestorePropertyList(struct o*,struct prpty*);
#else
extern void Properties();
extern void DoShowProperties();
extern void AddProperty();
extern void RemoveProperty();
extern void RemovePropertyList();
extern void RestorePropertyList();
#endif
/* redispla.c */
#ifdef __STDC__
extern void Redisplay(struct ka*);
extern void RedisplayAfterInterrupt(void);
extern int TCheck(void);
extern void SetTransform(struct o*);
#else
extern void Redisplay();
extern void RedisplayAfterInterrupt();
extern int TCheck();
extern void SetTransform();
#endif
/* select.c */
extern struct ka SelectQBB;
extern struct ks *SelectQHead;
#ifdef __STDC__
extern void MX(void);
extern void MY(void);
extern void Rotat0(void);
extern void Rotat90(void);
extern void Rotat180(void);
extern void Rotat270(void);
extern void Sel(int*);
extern void Area(int*);
extern void Desel(void);
extern int Layer(void);
extern void Selection(struct ka*);
extern struct ks *SelectItems(struct ka*,int);
extern void SLFree(struct ks*);
extern void SLBB(struct ks*,struct ka*);
extern void GetBB(struct o*,struct ka*);
extern int BBVisible(struct o*);
extern int AreTypesInQ(char*);
extern void SelectTypes(char*);
extern void SQInit(void);
extern void SQClear(void);
extern void SQInsert(struct o*);
extern void SQDelete(struct o*);
extern void SQComputeBB(void);
extern void SQRestore(int);
extern void SQDesel(char*);
extern void SQShow(void);
extern int *InPath(int,struct p*,int,int);
#else
extern void MX();
extern void MY();
extern void Rotat0();
extern void Rotat90();
extern void Rotat180();
extern void Rotat270();
extern void Sel();
extern void Area();
extern void Desel();
extern int Layer();
extern void Selection();
extern struct ks *SelectItems();
extern void SLFree();
extern void SLBB();
extern void GetBB();
extern int BBVisible();
extern int AreTypesInQ();
extern void SelectTypes();
extern void SQInit();
extern void SQClear();
extern void SQInsert();
extern void SQDelete();
extern void SQComputeBB();
extern void SQRestore();
extern void SQDesel();
extern void SQShow();
extern int *InPath();
#endif
/* techfile.c */
extern int FineVPonBottom;
extern char InitScreenMode;
#ifdef __STDC__
extern void ReadTechFile(void);
#else
extern void ReadTechFile();
#endif
/* viewport.c */
#ifdef __STDC__
extern void PToL(struct ka*,int*,int*);
extern void ClipToGridPoint(int*,int*);
extern void ShowParameters(void);
extern void SetRelative(int,int,int);
extern void ShowElectrical(void);
extern void ShowLayerTable(void);
extern void LtMore(void);
extern void LtBox(int,int,int,int);
extern int PointLayerTable(int,int);
extern void ShowCommandMenu(void);
extern void ShowMenu(MENU*);
extern int GetMenuIndex(MENU*,char*);
extern MENU *GetCurrentMenu(void);
extern void AlterMenuEntries(char*,char*);
extern void MenuSelect(char*);
extern void MenuDeselect(char*);
extern void FixMenuPrefix(MENU*);
extern void FixMenuEntryPrefix(MENU*,int);
extern void ShowPrompt(char*);
extern void ShowPromptAndWait(char*);
extern void ShowPromptWithColor(char*,int);
extern void RedrawPrompt(void);
extern void AppendToOldPrompt(int);
extern void ErasePrompt(void);
extern void OutlineText(int,int,int,int,int,int,int);
extern void EraseLargeCoarseViewport(void);
extern void RedisplayViewports(void);
extern void ShowFineViewport(void);
extern void ShowCurrentObject(struct o*,int);
extern void ShowInstanceMarker(int,int,struct o*);
extern void ShowMarker(int,int,int,int,int);
extern void ShowProcess(char*);
#else
extern void PToL();
extern void ClipToGridPoint();
extern void ShowParameters();
extern void SetRelative();
extern void ShowElectrical();
extern void ShowLayerTable();
extern void LtMore();
extern void LtBox();
extern int PointLayerTable();
extern void ShowCommandMenu();
extern void ShowMenu();
extern int GetMenuIndex();
extern MENU *GetCurrentMenu();
extern void AlterMenuEntries();
extern void MenuSelect();
extern void MenuDeselect();
extern void FixMenuPrefix();
extern void FixMenuEntryPrefix();
extern void ShowPrompt();
extern void ShowPromptAndWait();
extern void ShowPromptWithColor();
extern void RedrawPrompt();
extern void AppendToOldPrompt();
extern void ErasePrompt();
extern void OutlineText();
extern void EraseLargeCoarseViewport();
extern void RedisplayViewports();
extern void ShowFineViewport();
extern void ShowCurrentObject();
extern void ShowInstanceMarker();
extern void ShowMarker();
extern void ShowProcess();
#endif
/* wires.c */
#ifdef __STDC__
extern void Wires(int*);
extern void ShowWire(int,int,struct p*);
extern void Width(int*);
extern void RemoveLastPointInPath(struct p**);
extern void AppendPointToPath(int*,int*,struct p**);
#else
extern void Wires();
extern void ShowWire();
extern void Width();
extern void RemoveLastPointInPath();
extern void AppendPointToPath();
#endif
/* xorbox.c */
#ifdef __STDC__
extern void XORbox(int*);
#else
extern void XORbox();
#endif
/* zoom.c */
#ifdef __STDC__
extern void Pan(int*);
extern void Zoom(int*);
extern void Windo(int*);
extern void LastView(void);
extern void RestoreLastView(void);
extern void SaveLastView(void);
extern void SaveViewOnStack(void);
#else
extern void Pan();
extern void Zoom();
extern void Windo();
extern void LastView();
extern void RestoreLastView();
extern void SaveLastView();
extern void SaveViewOnStack();
#endif
/* database conversion */
/* convert.c */
#ifdef __STDC__
extern void Convert(void);
extern void OutPrompt(char*);
extern void ToGDSII(void);
extern void ConvertPathtype(int*,int*,int,int,int,int);
extern void ToCIF(void);
extern void FromCIF(void);
#else
extern void Convert();
extern void OutPrompt();
extern void ToGDSII();
extern void ConvertPathtype();
extern void ToCIF();
extern void FromCIF();
#endif
/* convert1.c */
#ifdef __STDC__
extern void FromGDSII(void);
#else
extern void FromGDSII();
#endif
kic-2.4c/src/include/prefix.h 0000644 0000764 0000764 00000003037 12427260414 015601 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/*
* KIC environmental data
*
*/
#include
/* default basename for layer description file */
#define TECHNAME "kic_tech"
extern char *to_lower_case(char*);
/* where file locations are set */
#if __STDC__
extern void InitGlobal(void);
extern FILE *OpenTechFile(void);
#else
extern void InitGlobal();
extern FILE *OpenTechFile();
#endif
/* version string, defined in makefile */
extern char *VersionString;
/* name of the layer attributes file */
extern char *TECHFILE;
/* extension of the layer attributes file */
extern char *TECH_EXT;
/* full path to help database */
extern char *PATH_TO_HELP;
/* full path to default layer table (stand-alone stream converter only) */
extern char *DEFAULTLTAB;
/* full path to mfb.rc file (DOS MFB only) */
extern char *MFBRCD;
/* name of default file to edit */
#define DEFAULT_EDIT_FILE "noname"
/* separator character in path string (used in paths.c) */
#ifdef MSDOS
#define DIRC '\\'
#else
#define DIRC '/'
#endif
/*
* There are 100 data base units per micron
*/
#define RESOLUTION 100
#define HALFRESOLUTION 50
/* debugging stuff for cd */
/* print trace from actions.c
#define TRACEPARSER
*/
/* print trace from parser.c
#define TRACE
*/
/* debugging from cd.c
#define DEBUGREFLECT
#define DEBUGGEN
#define DEBUG_CDUNMARK
*/
/* for CDIntersect()
#define FLOAT
*/
kic-2.4c/src/ginterf/ 0000755 0000764 0000764 00000000000 12427446157 014155 5 ustar stevew stevew kic-2.4c/src/ginterf/ginterf.c 0000644 0000764 0000764 00000053616 07525346711 015770 0 ustar stevew stevew /***************************************************************************
JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1994
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1992 Stephen R. Whiteley
1994 SRW modified for KIC
****************************************************************************/
/*
* Hardcopy driver (Postscript and HP Laserjet)
*/
#include
#ifdef MSDOS
#include
#endif
#include "kic.h"
#include "driver.h"
/* define this for Postscript RLL/Ascii85 encoding (Level 2 feature) */
/*
#define PSRLL85
*/
extern char *tmalloc();
#define NFILLPAT 20
static FILE *plotfile;
struct sGText {
int x;
int y;
int xform;
char *text;
struct sGText *next;
};
struct sGParams {
int bytpline;
int maxx;
int maxy;
char *base;
struct sGText *textlist;
unsigned char linestyle;
unsigned char linestyle_stored;
int stipples[NFILLPAT][8];
int curfillpatt;
int fontwidth;
int fontheight;
int numcolors;
int numlinestyles;
};
static struct sGParams GP;
#define ror(x,n) ((x >> n) | (x << (8-n)))
#define swap(a,b) {int t=a; a=b; b=t;}
#define pswap(tab,i,j) {int temp; temp = *((tab)+(i));\
*((tab)+(i)) = *((tab)+(j));\
*((tab)+(j)) = temp; }
/* dots per inch (75, 100, 150, 300) */
#define RESOL Parameters.kpHardcopyResolution
/* US Letter defaults for Postscript */
#define Uxoff 18
#define Uyoff 18
#define Uwidth 576
#define Uheight 756
/* how big the font is in points=1/72 inch */
#define FONTPTS 12
#ifdef __STDC__
extern void HP_dump(void);
extern void PS_dump(void);
static void sort(int*,int,int);
static void zoids(int*,int*,int,int,int);
extern void PS_rll85dump(char*,int);
#ifdef MSDOS
static void dos_fopen(char*);
#endif
#else
extern void HP_dump();
extern void PS_dump();
static void sort();
static void zoids();
extern void PS_rll85dump();
#ifdef MSDOS
static void dos_fopen();
#endif
#endif
int
GR_info(int num)
{
switch (num) {
case MAXX: return (GP.maxx);
case MAXY: return (GP.maxy);
case MAXCOLORS: return (GP.numcolors-1);
case MAXINTENSITY: return (255);
case MAXFILLPATTERNS: return (0);
case MAXLINESTYLES: return (GP.numlinestyles-1);
case MAXBLINKERS: return (0);
case POINTINGDEVICE: return (0);
case POINTINGBUTTONS: return (0);
case NUMBUTTONS: return (0);
case BUTTON1: return (1);
case BUTTON2: return (2);
case BUTTON3: return (3);
case BUTTON4: return (4);
case BUTTON5: return (0);
case BUTTON6: return (0);
case BUTTON7: return (0);
case BUTTON8: return (0);
case BUTTON9: return (0);
case BUTTON10: return (0);
case BUTTON11: return (0);
case BUTTON12: return (0);
case TEXTPOSITIONABLE: return (1);
case TEXTROTATABLE: return (1);
case FONTHEIGHT: return (GP.fontheight);
case FONTWIDTH: return (GP.fontwidth);
case FONTXOFFSET: return (0);
case FONTYOFFSET: return (0);
case DESTRUCTIVETEXT: return (0);
case OVERSTRIKETEXT: return (1);
case VLT: return (0);
case BLINKERS: return (0);
case FILLEDPOLYGONS: return (1);
case DEFFILLPATTERNS: return (1);
case DEFLINEPATTERN: return (1);
case CURFGCOLOR: return (1);
case CURFILLPATTERN: return (GP.curfillpatt);
case CURLINESTYLE: return (GP.linestyle);
case NUMBITPLANES: return (1);
default: return (-1);
}
}
int
GR_open(char *name)
{
struct sGParams *gp = &GP;
int bpline;
#ifdef MSDOS
dos_fopen(name);
#else
plotfile = fopen(name, "w");
#endif
if (!plotfile) {
return (1);
}
/* 8" X 10.5" drawable area */
gp->maxx = 8*RESOL - 1;
gp->maxy = 10*RESOL + RESOL/2 - 1;
/* bytes per line */
bpline = gp->maxx/8 + 1;
gp->base = tmalloc((gp->maxy+1)*bpline);
memset(gp->base,0,(gp->maxy+1)*bpline);
gp->bytpline = bpline;
gp->linestyle = 0xff;
gp->linestyle_stored = 0xcc;
gp->curfillpatt = 0;
gp->textlist = NULL;
gp->fontheight = FONTPTS*RESOL/72;
gp->fontwidth = 2*gp->fontheight/3;
gp->numcolors = 2;
gp->numlinestyles = 2;
return (0);
}
int
GR_close(void)
{
struct sGParams *gp = &GP;
struct sGText *t, *tn;
/* dump the stuff */
switch (*Parameters.kpHardcopyFormat) {
case HPLASER:
HP_dump();
break;
case POSTSC:
PS_dump();
break;
default:
break;
}
for (t = gp->textlist; t; t = tn) {
tn = t->next;
free(t->text);
free(t);
}
gp->textlist = NULL;
free(gp->base);
gp->base = NULL;
fclose(plotfile);
return (0);
}
/* upper left of image in pcl coordinates */
#define OFFSETX 0
#define OFFSETY 90
void
HP_dump(void)
{
struct sGParams *gp = &GP;
struct sGText *t;
char *buf, *rgen, *c;
int len, i;
int x, y;
/* dump the stuff */
/* reset printer
* top margin 10
* X cursor position OFFSETX
* Y cursor position OFFSETY
* resolution RESOL dpi
* start raster graphics at current position
*/
fprintf(plotfile,
"\033E\033&l0E\033*p%dX\033*p%dY\033*t%dR\033*r1A",
OFFSETX,OFFSETY,RESOL);
buf = tmalloc(gp->bytpline+8);
sprintf(buf,"\033*b%dW",gp->bytpline);
len = strlen(buf);
c = buf + len;
rgen = gp->base;
for (i = 0; i <= gp->maxy; i++) {
memcpy(c,rgen,gp->bytpline);
rgen += gp->bytpline;
if (fwrite(buf,1,gp->bytpline+len,plotfile) != gp->bytpline+len) {
break;
}
}
/* end raster graphics */
fprintf(plotfile,"\033*rB");
/* now for the text */
for (t = gp->textlist; t; t = t->next) {
x = t->x*(300/RESOL) + OFFSETX;
y = (gp->maxy - t->y)*(300/RESOL) + OFFSETY;
/* x position, y position, text */
fprintf(plotfile,"\033*p%dX\033*p%dY%s",x,y,t->text);
}
/* form feed
* reset printer
*/
fprintf(plotfile,"\033*rB\014\033E");
free(buf);
}
static char hexc[16] =
{ '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
void
PS_dump(void)
{
struct sGParams *gp = &GP;
struct sGText *t;
int x, y;
int w, h, i, j;
int deg;
int cnt;
char *ptr, *s, *text, tbuf[512];
unsigned char c;
w = gp->maxx + 1;
h = gp->maxy + 1;
/* start file off with a % */
fprintf(plotfile, "%%! kic plot\n");
/* set up a reasonable font */
fprintf(plotfile, "/Helvetica findfont %d scalefont setfont\n",
(int)(FONTPTS*((double)w/Uwidth)));
#ifndef PSRLL85
fprintf(plotfile, "/pixbuf %d string def\n",gp->bytpline);
#endif
fprintf(plotfile, "%d %d translate\n",Uxoff,Uyoff);
fprintf(plotfile, "%f %f scale\n",(double)Uwidth/w,(double)Uheight/h);
fprintf(plotfile, "%d %d 1\n",w,h);
fprintf(plotfile, "matrix\n");
#ifdef PSRLL85
fprintf(plotfile, "currentfile\n");
fprintf(plotfile, "/Ascii85Decode filter\n");
fprintf(plotfile, "/RunLengthDecode filter\n");
fprintf(plotfile, "image\n");
#else
fprintf(plotfile, "{currentfile pixbuf readhexstring pop}\nimage\n");
#endif
/* write data */
#ifdef PSRLL85
PS_rll85dump(gp->base,(gp->maxy+1)*gp->bytpline);
#else
ptr = gp->base + gp->maxy*gp->bytpline;
cnt = 0;
for (j = gp->maxy; j >= 0; j--) {
for (i = 0; i < gp->bytpline; i++) {
c = ~*(unsigned char*)ptr; /* reverse black/white */
putc(hexc[c>>4],plotfile);
putc(hexc[c&0xf],plotfile);
ptr++;
cnt++;
if (cnt > 38) {
cnt = 0;
putc('\n',plotfile);
}
}
ptr -= gp->bytpline << 1;
}
#endif
/*
fprintf(plotfile, "\n~>\n");
*/
fprintf(plotfile, "\n");
/* now for the text */
for (t = gp->textlist; t; t = t->next) {
x = t->x;
y = t->y;
s = tbuf;
text = t->text;
while (*text) {
if (*text == '(' || *text == ')' || *text == '\\')
*s++ = '\\';
*s++ = *text++;
}
*s = '\0';
fprintf(plotfile,"gsave\n");
fprintf(plotfile,"%d %d translate\n",x,y);
if (t->xform & 12)
fprintf(plotfile,"%d %d scale\n",
(t->xform & 8) ? -1 : 1, (t->xform & 4) ? -1 : 1);
deg = (t->xform & 3) * 90;
if (deg)
fprintf(plotfile,"%d rotate\n",deg);
fprintf(plotfile,"0 0 moveto\n");
fprintf(plotfile,"(%s) show\n",tbuf);
fprintf(plotfile,"grestore\n");
}
fprintf(plotfile, "showpage\n");
}
int
GR_update(void)
{
return (0);
}
void
GR_pixel(int x, int y)
{
unsigned char c;
struct sGParams *gp = &GP;
c = 0x80 >> (x & 7);
*(gp->base + ((x >> 3) + (gp->maxy-y)*gp->bytpline)) |= c;
}
void
GR_line(int x1, int y1, int x2, int y2)
{
struct sGParams *gp = &GP;
int dx, dy, dy2, errterm = 0, next, lcnt;
char *rgen;
unsigned char cbuf, left, right;
if (x2 < x1) {
swap(x1,x2);
swap(y1,y2);
}
dx = x2 - x1;
next = gp->bytpline;
dy = y1 - y2;
lcnt = gp->maxy - y1;
rgen = gp->base + (x1 >> 3) + lcnt*next;
left = 0x80 >> ((lcnt+x1) & 7);
right = gp->linestyle;
if (y1 < y2) {
next = -next;
dy = -dy;
}
dy2 = dy;
cbuf = 0x80 >> (x1 & 7);
for (dy++; dy; dy--) {
errterm += dx;
if (errterm <= 0) {
if (left & right) *rgen |= cbuf;
rgen += next;
left = ror(left,1);
continue;
}
while (errterm > 0 && x1 != x2) {
if (left & right) *rgen |= cbuf;
left = ror(left,1);
cbuf = ror(cbuf,1);
if (cbuf & 0x80) rgen++;
x1++;
errterm -= dy2;
}
rgen += next;
left = ror(left,1);
}
}
void
GR_box(int xl, int yl, int xu, int yu)
{
struct sGParams *gp = &GP;
int lnum, dx, tx, dy, next, *st = NULL;
char *rgen;
unsigned char left, right, cbuf;
if (yu < yl) swap(yu,yl);
if (xu < xl) swap(xu,xl);
/* expand box so that it covers a box formed of lines with the
* same coordinates
*/
xu++;
yl--;
if (xl < 0)
xl = 0;
else if (xl > gp->maxx)
return;
if (xu > gp->maxx)
xu = gp->maxx;
else if (xu < 0)
return;
if (yl < 0)
yl = 0;
else if (yl > gp->maxy)
return;
if (yu > gp->maxy)
yu = gp->maxy;
else if (yu < 0)
return;
if (gp->curfillpatt)
st = gp->stipples[gp->curfillpatt];
lnum = (gp->maxy - yu);
dy = yu - yl;
left = (0xff >> (xl & 7));
right = ~(0xff >> (xu & 7));
dx = (xu >> 3) - (xl >>= 3) - 1;
if (dx < 0) { left &= right; dx = 0; right = 0; }
rgen = gp->base + xl + (int) lnum*gp->bytpline;
next = gp->bytpline - 1 - dx;
cbuf = 0xff;
while (dy--) {
if (st)
cbuf = st[lnum++ & 7];
*rgen |= left & cbuf;
rgen++;
tx = dx;
while (tx--) {
*rgen |= cbuf;
rgen++;
}
*rgen |= right & cbuf;
rgen += next;
}
}
void
GR_polygon(Poly *poly)
{
int i, twonvert, *line, *line0 = NULL, stored = 0;
int *xup, *ll, ny;
int *xlp, *xip;
int yl, yu;
int *ylist;
int *xulist;
int *xllist;
int *xilist;
twonvert = poly->nvertices << 1;
line = (int *) poly->xy;
if ((line[0] != line[twonvert-2]) || (line[1] != line[twonvert-1])) {
/* no closure, copy and add first point */
twonvert += 2;
line0 = (int*)tmalloc(twonvert*2*sizeof(int));
line = line0;
memcpy(line,(int*)poly->xy,(twonvert-2)*2*sizeof(int));
line[twonvert-2] = line[0];
line[twonvert-1] = line[1];
stored = 1;
}
ylist = (int*)tmalloc(twonvert*4*sizeof(int));
xulist = ylist + twonvert;
xllist = xulist + twonvert;
xilist = xllist + twonvert;
xip = line + twonvert;
ll = ylist;
while (line < xip) {
*ll++ = *(line+1);
line += 2;
}
ny = ll-ylist-1;
sort(ylist,0,ny);
xip = xilist;
ll = ylist;
while (ny--) {
yl = *ll;
yu = *(++ll);
while (yu == yl) {
if (!ny) goto done;
ny--;
yu = *(++ll);
}
memcpy(xllist,xilist,(int)((char *) xip - (char *) xilist));
xlp = xllist + (int) (xip - xilist);
xup = xulist;
xip = xilist;
for (i = twonvert - 4; i >= 0; i -= 2) {
line = (int *) poly->xy + i;
if (((line[1] > yu) && (line[3] < yu)) ||
((line[3] > yu) && (line[1] < yu))) {
*xup++ = *xip++ = line[0] +
((int)(yu-line[1])*(line[2]-line[0])) /
(line[3]-line[1]);
}
if (line[1] == yu) {
if (line[3] < yu)
*xup++ = line[0];
if (i) {
if (*(line-1) < yu)
*xup++ = line[0];
}
else
if (line[twonvert-3] < yu)
*xup++ = line[0];
}
if (line[1] == yl) {
if (line[3] > yl)
*xlp++ = line[0];
if (i) {
if (*(line-1) > yl)
*xlp++ = line[0];
}
else
if (line[twonvert-3] > yl)
*xlp++ = line[0];
}
}
sort(xulist,0,(int)(xup-xulist-1));
sort(xllist,0,(int)(xlp-xllist-1));
zoids(xllist,xulist,(int)(xlp-xllist),yl,yu);
}
done:
if (stored)
free(line0);
free(ylist);
}
static void
sort(int *tab, int left, int right)
{
int i, last;
if (right <= left) return;
i = (left + right) >> 1;
pswap(tab,left,i);
last = left;
for (i = left + 1; i <= right; i++)
if (tab[i] < tab[left]) {
last++;
pswap(tab,last,i);
}
pswap(tab,left,last);
sort(tab,left,last-1);
sort(tab,last+1,right);
}
static void
zoids(int *xll, int *xul, int num, int yl, int yu)
{
struct sGParams *gp = &GP;
int x1, x2, x3, x4;
int dx, dy, dy2, dx1, dx2, errterm1, errterm2;
int i, s1, s2, lnum, lcnt, next, *st = NULL;
char *rgen, *rgen0, *rgen1;
unsigned char left, right, cbuf;
if (gp->curfillpatt)
st = gp->stipples[gp->curfillpatt];
lnum = (gp->maxy - yu);
dy2 = yu - yl;
next = gp->bytpline;
rgen1 = gp->base + (int) lnum*next;
for (i = 0; i < num; i += 2) {
rgen0 = rgen1;
x1 = xll[i];
x4 = xll[i+1];
x2 = xul[i];
x3 = xul[i+1];
dy = dy2 + 1;
dx1 = x1 - x2;
dx2 = x3 - x4;
s1 = 1;
s2 = -1;
if (x2 >= x1) { dx1 = -dx1; s1 = -1; }
if (x4 >= x3) { dx2 = -dx2; s2 = 1; }
errterm1 = errterm2 = 0;
x3++;
x4++;
cbuf = 0xff;
lcnt = lnum;
while (dy--) {
left = (0xff >> (x2 & 7));
right = ~(0xff >> (x3 & 7));
dx = (x3 >> 3) - (x2 >> 3) - 1;
if (dx < 0) { left &= right; dx = 0; right = 0; }
rgen = rgen0 + (x2 >> 3);
if (st)
cbuf = st[lcnt++ & 7];
if (rgen >= gp->base) {
*rgen |= cbuf & left;
}
rgen++;
while (dx--) {
if (rgen >= gp->base) {
*rgen |= cbuf;
}
rgen++;
}
if (rgen >= gp->base) {
*rgen |= cbuf & right;
}
rgen0 += next;
errterm1 += dx1;
errterm2 += dx2;
while (errterm1 > 0 && x1 != x2) {
errterm1 -= dy2;
x2 += s1;
}
while (errterm2 > 0 && x3 != x4) {
errterm2 -= dy2;
x3 += s2;
}
}
}
}
int
GR_defLs(int linestyleid, int mask)
{
struct sGParams *gp = &GP;
if (linestyleid) {
gp->linestyle_stored = mask;
gp->linestyle = mask;
}
return (0);
}
int
GR_setLs(int linestyleid)
{
struct sGParams *gp = &GP;
if (linestyleid)
gp->linestyle = gp->linestyle_stored;
else
gp->linestyle = 0xff;
return (0);
}
int
GR_defFp(int num, int *pat)
{
struct sGParams *gp = &GP;
int i = 0, j;
int ba, sp;
if (num < 1 || num >= NFILLPAT)
return (1);
/* reverse bytes and bits */
pat += 7;
while (i < 8) {
ba = *(pat--);
sp = 0;
for (j = 0; j < 8; j++) {
sp <<= 1;
if (ba & 1) sp |= 1;
ba >>= 1;
}
gp->stipples[num][i++] = sp;
}
gp->curfillpatt = num;
return (0);
}
int
GR_setFp( int num)
{
struct sGParams *gp = &GP;
if (num < 0 || num >= NFILLPAT)
return (1);
gp->curfillpatt = num;
return (0);
}
/* ARGSUSED */
int
GR_defColor(int num, int r, int g, int b)
{
return (0);
}
/* ARGSUSED */
int
GR_setColor(int num)
{
return (0);
}
void
GR_text(char *text, int x, int y, int xform)
{
struct sGParams *gp = &GP;
struct sGText *gpt;
gpt = (struct sGText *)tmalloc(sizeof(struct sGText));
gpt->x = x;
gpt->y = y;
gpt->xform = xform;
gpt->text = CopyString(text);
gpt->next = gp->textlist;
gp->textlist = gpt;
}
/* ARGSUSED */
void
GR_scText(char *text, int x, int y, int Xform, int sc)
{
GR_text(text,x,y,Xform);
}
#ifdef PSRLL85
/**************************************************
* *
* Run length and ascii85 encoding for Postscript *
* *
**************************************************/
struct sRL {
unsigned char key;
unsigned char data[128];
};
#ifdef __STDC__
static struct sRL *get_rllrec(char**,char*);
static void ascii85dump(struct sRL*);
static void enc85(unsigned char *, unsigned char*);
#else
static struct sRL *get_rllrec();
static void ascii85dump();
static void enc85();
#endif
static int Ocnt;
static int I4;
void
PS_rll85dump(char *data, int size)
{
char *end;
struct sRL *rl;
end = data + size;
Ocnt = 0;
I4 = 0;
for (;;) {
rl = get_rllrec(&data,end);
ascii85dump(rl);
if (rl->key == 128)
break;
}
return;
}
static struct sRL *
get_rllrec(char **data, char *end)
{
static struct sRL rl;
unsigned char c1, c2, *d;
int i;
d = (unsigned char *)*data;
if (d == (unsigned char*)end) {
rl.key = 128;
rl.data[0] = 0;
return (&rl);
}
c1 = *d++;
if (d == (unsigned char*)end) {
rl.key = 129;
rl.data[0] = c1;
*data = (char*)d;
return (&rl);
}
if (*d == c1) {
for (i = 0; i < 127; i++) {
c2 = *d++;
if (c2 != c1) {
break;
}
if (d == (unsigned char*)end)
break;
}
rl.key = 256 - i;
rl.data[0] = c1;
*data = (char*)d;
return (&rl);
}
rl.data[0] = c1;
for (i = 1; i < 128; i++) {
if (*d == *(d+1))
break;
rl.data[i] = *d;
d++;
}
rl.key = i-1;
*data = (char*)d;
return (&rl);
}
#define outc(c) { \
putc(c,plotfile); \
Ocnt++; \
if (Ocnt==72){putc('\n',plotfile); Ocnt = 0;} \
}
static void
ascii85dump(struct sRL *rl)
{
unsigned char cout[5];
static unsigned char cin[4];
unsigned int l;
int i, n;
if (rl->key == 128) {
for (i = I4; i < 4; i++)
cin[i] = 0;
enc85(cout,cin);
if (cout[0] == 'z') {
cout[0] = cout[1] = cout[2] = cout[3] = cout[4] = '!';
}
outc(cout[0]);
outc(cout[1]);
if (I4 > 0)
outc(cout[2]);
if (I4 > 1)
outc(cout[3]);
if (I4 > 2)
outc(cout[4]);
return;
}
if (rl->key > 128)
n = 257 - rl->key;
else
n = rl->key + 1;
for (i = 0; i < n; i++) {
cin[I4] = rl->key > 128 ? rl->data[0] : rl->data[i];
I4++;
if (I4 == 4) {
I4 = 0;
enc85(cout,cin);
outc(cout[0]);
if (cout[0] != 'z') {
outc(cout[1]);
outc(cout[2]);
outc(cout[3]);
outc(cout[4]);
}
}
}
}
#define A4 (85*85*85*85)
#define A3 (85*85*85)
#define A2 (85*85)
#define A1 85
static void
enc85(unsigned char *co, unsigned char *ci)
{
unsigned int l, n;
l = (ci[0] << 24) + (ci[1] << 16) + (ci[2] << 8) + ci[3];
if (l == 0) {
co[0] = 'z';
return;
}
n = l/A4;
co[0] = n+33;
l -= n*A4;
n = l/A3;
co[1] = n+33;
l -= n*A3;
n = l/A2;
co[2] = n+33;
l -= n*A2;
n = l/A1;
co[3] = n+33;
l -= n*A1;
co[4] = l+33;
}
#endif /* PSRLL85 */
#ifdef MSDOS
static void
dos_fopen(char *name)
{
#ifdef NDPC
/* silliness */
union REGS16 r;
if (*Parameters.kpHardcopyFormat == POSTSC) {
_pmode = 0x4000; /* O_TEXT */
plotfile = fopen(name, "w");
return;
}
_pmode = 0x8000; /* O_BINARY */
plotfile = fopen(name, "w");
_pmode = 0x4000;
#else
union REGS r;
if (*Parameters.kpHardcopyFormat == POSTSC) {
plotfile = fopen(name, "w");
return;
}
plotfile = fopen(name, "wb");
#endif
if (plotfile == NULL)
return;
/* put the port driver into binary mode,
* if we are outputting to the printer
*/
r.x.bx = fileno(plotfile);
r.x.ax = 0x4400;
int86(0x21,&r,&r);
if (r.x.dx & 0x80) { /* output is a device */
/* put driver in raw mode */
r.x.bx = fileno(plotfile);
r.x.dx = 0xa0;
r.x.ax = 0x4401;
int86(0x21,&r,&r);
}
}
#endif
kic-2.4c/src/ginterf/fb.c 0000644 0000764 0000764 00000043025 12427244645 014712 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#include "driver.h"
#include "mfbext.h"
#include
#ifndef WIN32
#ifdef __STDC__
static int MY_MFBOpen(char*);
static void ghost_line(int,int,int,int);
static void ghost_line_snap(int,int,int,int);
static void ghost_box(int,int,int,int);
static void ghost_box_snap(int,int,int,int);
static void ghost_stretch(int,int,int,int);
static void ghost_move(int,int,int,int);
static void ghost_place(int,int,int,int);
static char *kbedit(char*,int,int,int,int,int);
static void textcursor(int,int);
#else
static int MY_MFBOpen();
static void ghost_line();
static void ghost_line_snap();
static void ghost_box();
static void ghost_box_snap();
static void ghost_stretch();
static void ghost_move();
static void ghost_place();
static char *kbedit();
static void textcursor();
#endif
struct f FB = { 0 };
struct sGinterface GR[FBNUMINTERFACE] = {
{ MFBInfo,
MY_MFBOpen,
MFBClose,
MFBUpdate,
MFBPixel,
MFBLine,
MFBBox,
(void(*)(Poly*))MFBPolygon,
MFBDefineLineStyle,
MFBSetLineStyle,
MFBDefineFillPattern,
MFBSetFillPattern,
MFBDefineColor,
MFBSetColor,
MFBText,
MFBScaledText,
MFBFlood,
MFBPoint,
MFBBeep,
MFBSetFullScreenCursor,
MFBTextBB,
MFBMore,
MFBSetName,
MFBSetBlinker,
MFBSelectFont,
MFBSelectCursor,
MFBSetTextClip,
MFBResizeDrawingWindow
},
{ GR_info,
GR_open,
GR_close,
GR_update,
GR_pixel,
GR_line,
GR_box,
GR_polygon,
GR_defLs,
GR_setLs,
GR_defFp,
GR_setFp,
GR_defColor,
GR_setColor,
GR_text,
GR_scText,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0 }
};
static int
MY_MFBOpen(name)
char *name;
{
int error;
if (MFBOpen(name,name,&error) == NULL) {
fprintf(stderr,"%s\n",MFBError(error));
return (1);
}
return (0);
}
void
FBBegin(Dspl)
char *Dspl;
{
FB.fDisplay = Dspl;
if (!(FB.fInitialized)) {
if ((*GR[FB.fInterface].gOpen)(FB.fDisplay))
fatal_error("Unable to open display.");
else {
if (Parameters.kpFontName[0] != '\0')
MFBSetFont(Parameters.kpFontName);
if (Parameters.kpCursorShape >= 0)
MFBSetCursor(Parameters.kpCursorShape);
if (Parameters.kpFullScreenCursor)
MFBSetFullScreenCursor(True);
}
}
FBSetLineStyle(0);
FB.fMaxX = FBInfo(MAXX);
FB.fMaxY = FBInfo(MAXY);
FB.fMaxP = 1000;
FB.fMaxIntensity = 255;
FB.fNumColors = FBInfo(MAXCOLORS) - 1;
if (FB.fNumColors >= 32)
Parameters.kpMergeColors = False;
else
Parameters.kpMergeColors = True;
FB.fNumFillPatterns = FBInfo(MAXFILLPATTERNS) - 1;
FB.fButtonMask = SetButtonMask();
FB.fButtons = FBInfo(POINTINGBUTTONS);
FB.fNumButtons = FBInfo(NUMBUTTONS);
/*
* Font width and height is henceforth assumed to
* include the X and Y offsets.
*/
FB.fFontWidth = FBInfo(FONTWIDTH);
FB.fFontHeight = FBInfo(FONTHEIGHT);
FB.fFontWidth += FBInfo(FONTXOFFSET);
FB.fFontHeight += FBInfo(FONTYOFFSET);
FB.fNumRows = FB.fMaxY/FB.fFontHeight;
FB.fNumColumns = FB.fMaxX/FB.fFontWidth;
FB.fFilledPolygons = FBInfo(FILLEDPOLYGONS);
FB.fDefinableFillPatterns = FBInfo(DEFFILLPATTERNS);
FB.fNonDestructiveText = FBInfo(OVERSTRIKETEXT);
FB.fLastCursorColumn = 0;
FB.fBlinkers = FBInfo(BLINKERS);
FB.fInitialized = True;
MFBSetTextMode(False);
FBSetTextClip(0,0,FB.fMaxX,FB.fMaxY);
}
void
FBForeground(DisplayOrErase,Pixel)
int DisplayOrErase;
int Pixel;
{
if (DisplayOrErase == ERASE) Pixel = 0;
Pixel = min(FB.fNumColors,Pixel);
(*GR[FB.fInterface].gSetColor)(Pixel);
}
void
FBVLT(Pixel,R,G,B)
int Pixel,R,G,B;
{
if (FBInfo(VLT)) {
R = ((int)R * FB.fMaxP)/FB.fMaxIntensity;
G = ((int)G * FB.fMaxP)/FB.fMaxIntensity;
B = ((int)B * FB.fMaxP)/FB.fMaxIntensity;
(*GR[FB.fInterface].gDefColor)(Pixel,R,G,B);
}
}
void
FBText(Mode,RowOrX,ColumnOrY,Text)
int Mode;
int RowOrX,ColumnOrY;
char *Text;
{
int i;
if (Mode == ROW_COLUMN) {
i = FB.fMaxY - RowOrX * FB.fFontHeight;
RowOrX = (ColumnOrY - 1) * FB.fFontWidth;
ColumnOrY = i;
}
(*GR[FB.fInterface].gText)(Text,RowOrX,ColumnOrY,0);
}
int
FBGetchar(DisplayOrErase)
int DisplayOrErase;
{
int x,y;
short c;
char s[2];
if (DisplayOrErase == ERASE)
return (MFBGetchar());
y = FB.fMaxY - FB.fNumRows*FB.fFontHeight;
x = FB.fLastCursorColumn*FB.fFontWidth;
FBForeground(DISPLAY,ColorTable[HighlightingColor].Ent);
textcursor(x,y);
c = MFBGetchar();
s[0] = (char)(c & 0xff);
s[1] = '\0';
FBForeground(DISPLAY,ColorTable[MenuPromptColor].Ent);
(*GR[FB.fInterface].gText)(s,x,y,0);
AppendToOldPrompt(s[0]);
FBForeground(ERASE,0);
textcursor(x,y);
return (c);
}
char *
FBEdit(string)
char *string;
{
int x,y;
y = FB.fMaxY - (FB.fNumRows - 2)*FB.fFontHeight;
x = FB.fLastCursorColumn*FB.fFontWidth;
return (kbedit(string,x,y,0,ColorTable[MenuPromptColor].Ent,
ColorTable[HighlightingColor].Ent));
}
void
FBSetCursorColor(colorId)
int colorId;
{
MFBSetCursorColor(colorId,colorId); /* no blinking */
}
void
FBPolygon(Pixel,Type,StyleId,xy,n)
int Pixel,Type,StyleId,n;
int *xy;
{
/*
* Type == FILL means fill
* Type == OUTLINE means outline
* StyleId defines stipple pattern (0 = SOLID)
*/
int j,n2,X,Y,Z,T,Xo,Yo;
Poly poly;
FBForeground(DISPLAY,Pixel);
(*GR[FB.fInterface].gSetFp)(StyleId);
poly.xy = xy;
while (NewPolygon(&poly)) {
n = poly.nvertices;
if (Type == OUTLINE) {
n2 = n + n;
j = 2;
Xo = X = xy[0];
Yo = Y = xy[1];
while (j < n2) {
Z = xy[j++];
T = xy[j++];
(*GR[FB.fInterface].gLine)(X,Y,Z,T);
X = Z;
Y = T;
}
(*GR[FB.fInterface].gLine)(X,Y,Xo,Yo);
}
else {
if (n < 2) return;
(*GR[FB.fInterface].gPolygon)(&poly);
}
}
}
void
FBPolygonClip(coord,n,window)
int *coord;
int *n;
struct ka *window;
{
Poly poly;
poly.nvertices = *n;
if (*n < 3) return;
poly.xy = coord;
PolygonClip(&poly,window->kaLeft,window->kaBottom,
window->kaRight,window->kaTop);
}
/* Warning: 16 bit ints will not work below */
void
FBSetRubberBanding(mode)
/* if mode is lower case will clip to grid point */
int mode;
{
/* need some hokum for button 3 box */
#ifdef __STDC__
static void (*func)(int,int,int,int);
#else
static void (*func)();
#endif
static int X, Y;
static int lastR;
switch (mode) {
case 'l':
func = ghost_line_snap;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
MFBSetGhost(func,X,Y);
return;
case 'L':
func = ghost_line;
X = (int)KicCursor.kcRawX;
Y = (int)KicCursor.kcRawY;
MFBSetGhost(func,X,Y);
return;
case 'r':
func = ghost_box_snap;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
MFBSetGhost(func,X,Y);
return;
case 'R':
if (func) {
lastR = True;
MFBSetGhost(ghost_box,
(int)KicCursor.kcRawX,(int)KicCursor.kcRawY);
return;
}
func = ghost_box;
X = (int)KicCursor.kcRawX;
Y = (int)KicCursor.kcRawY;
MFBSetGhost(func,X,Y);
return;
case 's':
func = ghost_stretch;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
MFBSetGhost(func,X,Y);
return;
case 'm':
case 'M':
func = ghost_move;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
MFBSetGhost(func,X,Y);
return;
case 'p':
case 'P':
func = ghost_place;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
MFBSetGhost(func,X,Y);
return;
case 0:
if (lastR) {
MFBSetGhost(func,X,Y);
}
else {
MFBSetGhost(NULL,0,0);
#ifdef __STDC__
func = (void(*)(int,int,int,int))NULL;
#else
func = (void(*)())NULL;
#endif
}
lastR = False;
return;
}
}
static void
ghost_line(x,y,refx,refy)
int x, y, refx, refy;
{
if (!GetWindowCoords((int*)&x,(int*)&y,False))
return;
if (Parameters.kpRotationAngle == 0 ||
Parameters.kpRotationAngle == 180)
ShowLine(ColorTable[HighlightingColor].Ent,x,
View->kvCoarseWindow->kaBottom,
x,View->kvCoarseWindow->kaTop);
else
ShowLine(ColorTable[HighlightingColor].Ent,
View->kvCoarseWindow->kaLeft,
y,View->kvCoarseWindow->kaRight,y);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_line_snap(x,y,refx,refy)
int x, y, refx, refy;
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
if (Parameters.kpRotationAngle == 0 ||
Parameters.kpRotationAngle == 180)
ShowLine(ColorTable[HighlightingColor].Ent,x,
View->kvCoarseWindow->kaBottom,
x,View->kvCoarseWindow->kaTop);
else
ShowLine(ColorTable[HighlightingColor].Ent,
View->kvCoarseWindow->kaLeft,
y,View->kvCoarseWindow->kaRight,y);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_box(x,y,refx,refy)
int x, y, refx, refy;
{
struct ka BB;
if (!GetWindowCoords((int*)&x,(int*)&y,False))
return;
BB.kaLeft = refx;
BB.kaBottom = refy;
BB.kaRight = x;
BB.kaTop = y;
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_box_snap(x,y,refx,refy)
int x, y, refx, refy;
{
struct ka BB;
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
BB.kaLeft = refx;
BB.kaBottom = refy;
BB.kaRight = x;
BB.kaTop = y;
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_stretch(x,y,refx,refy)
int x, y, refx, refy;
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowStretch(x,y,refx,refy);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_move(x,y,refx,refy)
int x, y, refx, refy;
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowMove(refx,refy,x,y);
MFBSetColor(Parameters.kpLayer);
}
static void
ghost_place(x,y,refx,refy)
int x, y, refx, refy;
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowNewInstance(x,y,refx,refy);
MFBSetColor(Parameters.kpLayer);
}
/* cursor height - 1 */
#define CURHT 0
/* What a pain - have to be able to redraw during editing
* when a resize event occurs.
*/
static int doing_edit;
static int editX, editY, editFg, editCc;
static char editBuf[128], *editC;
static char *
kbedit(s,x,y,bg,fg,cc)
/*
* s Initial string to edit.
* x,y Lower left coordinates.
* bg,fg Background and foreground colors.
* cc Background color at cursor location.
* Returns edited string (static!).
*/
char *s;
int x, y, bg, fg, cc;
{
char tbuf[128];
int k;
char *end, ctmp[2];
doing_edit = True;
editFg = fg;
editCc = cc;
editX = x;
editY = y;
MFBSetColor(fg);
*editBuf = '\0';
if (s) {
/* s can be NULL */
MFBText(s, editX, editY, 0);
strcpy(editBuf,s);
}
ctmp[1] = '\0';
editC = editBuf;
end = strchr(editBuf,'\0');
*(end+1) = '\0';
ctmp[0] = *editC;
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp, editX + (int)(editC-editBuf)*FB.fFontWidth, editY, 0);
for (;;) {
k = MFBGetchar();
if ((char) k == '\r') break;
switch (k) {
case 333: /* right arrow */
if (editC >= end) continue;
ctmp[0] = *editC;
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC++;
ctmp[0] = *editC;
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case 331: /* left arrow */
if (editC <= editBuf) continue;
ctmp[0] = *editC;
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
ctmp[0] = *editC;
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case '\b':
if (editC == editBuf) continue;
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
editC--;
MFBText(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
MFBSetColor(fg);
*editC = '\0';
strcat(editBuf,++editC);
MFBText(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
if (end > editBuf) end--;
ctmp[0] = *editC;
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case 339: /* DEL, in DOS */
case 127:
if (editC == end) continue;
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBText(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
MFBSetColor(fg);
*editC = '\0';
strcat(editBuf,++editC);
MFBText(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
if (end > editBuf) end--;
ctmp[0] = *editC;
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case '\025': /* ^U */
case '\030': /* ^X */
case '\033': /* ESC */
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBText(editBuf,editX,editY,0);
editC = end = editBuf;
*editC = '\0';
if ((char) k == '\033') {
doing_edit = False;
return (NULL);
}
MFBSetColor(cc);
textcursor(editX,editY);
MFBSetColor(fg);
continue;
default:
if (k > 255) continue;
if (((char) k < ' ') || ((char) k > '~')) continue;
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBText(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
strcpy(tbuf,editC);
*editC = (char) k;
strcpy(++editC,tbuf);
ctmp[0] = *editC;
MFBSetColor(fg);
MFBText(editC-1,
editX+(int)(editC-1-editBuf)*FB.fFontWidth,editY,0);
MFBSetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
end++;
*(end+1) = '\0';
}
}
MFBSetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(fg);
ctmp[0] = *editC;
MFBText(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
doing_edit = False;
return (editBuf);
}
void
FBKbRepaint(x,y)
int x,y;
{
if (!doing_edit) return;
editX = x;
editY = y;
MFBSetColor(editCc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
MFBSetColor(editFg);
MFBText(editBuf,editX,editY,0);
}
static void
textcursor(x,y)
int x,y;
{
MFBBox(x,y-1,x+FB.fFontWidth,y+CURHT);
}
#endif
kic-2.4c/src/ginterf/Makefile.in 0000644 0000764 0000764 00000002442 07525375334 016225 0 ustar stevew stevew #######################################################################
# src/ginterf/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
LIB_TARGET = ../ginterf.a
HFILES =
CFILES = fb.c ginterf.c wfb.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/ginterf
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/ginterf/wfb.c 0000644 0000764 0000764 00000144066 07525346711 015110 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#ifdef WIN32
#include
#include
#ifndef _WINDOWS
#define _WINDOWS
#endif
#include "prefix.h"
#include "kic.h"
#include "driver.h"
#include
#include
#define IDR_MAINFRAME 1
#define DEF_FWID 6
#define DEF_FHEI 12
extern void out_printf(char*, ...);
static int w_Info(int);
static int w_Open(char*);
static int w_Close(void);
static int w_Update(void);
static void w_Pixel(int,int);
static void w_Line(int,int,int,int);
static void w_Box(int,int,int,int);
static void w_Polygon(Poly*);
static int w_DefLs(int,int);
static int w_SetLs(int);
static int w_DefFp(int,int*);
static int w_SetFp(int);
static int w_DefColor(int,int,int,int);
static int w_SetColor(int);
static void w_Text(char*,int,int,int);
static void w_ScText(char*,int,int,int,int);
static void w_Clear(void);
static int w_Point(int*, int*, int*, int*);
static void w_Beep(int);
static int w_SetFullScreenCursor(int);
static void w_TextBB(char*, int*, int*);
static void w_More(int, int, int, int, FILE*);
static void w_SetName(char*, char*);
static int w_Blink(int, int, int, int, int);
static int w_SelectFont(int, int, int, int);
static void w_SelectCursor(int, int, int, int);
static void w_SetTextClip(int, int, int, int);
static void w_Resize(int, int, int, int);
typedef ATOM (WINAPI* REGISTERCLASSEXPROC)(const LPWNDCLASSEX);
static ATOM msw_RegisterClass(const LPWNDCLASSEX);
static LRESULT CALLBACK mainFrameWndProc(HWND, UINT, WPARAM, LPARAM);
static HFONT msw_GetFixedFont(int, int);
static void draw_fs_cursor(int, int);
static int w_SetGhost(void(*)(int, int, int, int), int, int);
static void ghost_line(int,int,int,int);
static void ghost_line_snap(int,int,int,int);
static void ghost_box(int,int,int,int);
static void ghost_box_snap(int,int,int,int);
static void ghost_stretch(int,int,int,int);
static void ghost_move(int,int,int,int);
static void ghost_place(int,int,int,int);
static char *kbedit(char*,int,int,int,int,int);
static void textcursor(int,int);
static int textwidth(char*, int);
static int w_Getchar(void);
#define INV(y) (FB.fMaxY - (y))
#define MAXCHARLINE 128
struct f FB = { 0 };
struct sGinterface GR[FBNUMINTERFACE] = {
{ w_Info,
w_Open,
w_Close,
w_Update,
w_Pixel,
w_Line,
w_Box,
w_Polygon,
w_DefLs,
w_SetLs,
w_DefFp,
w_SetFp,
w_DefColor,
w_SetColor,
w_Text,
w_ScText,
w_Clear,
w_Point,
w_Beep,
w_SetFullScreenCursor,
w_TextBB,
w_More,
w_SetName,
w_Blink,
w_SelectFont,
w_SelectCursor,
w_SetTextClip,
w_Resize },
{ GR_info,
GR_open,
GR_close,
GR_update,
GR_pixel,
GR_line,
GR_box,
GR_polygon,
GR_defLs,
GR_setLs,
GR_defFp,
GR_setFp,
GR_defColor,
GR_setColor,
GR_text,
GR_scText,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0 },
};
static HWND w_hwnd; /* main window handle */
static HDC w_dc; /* window DC */
static int w_fg_indx; /* current color index */
static COLORREF w_fg; /* color pixel value */
static COLORREF w_colors[64]; /* color pixel table */
static int w_linestyle; /* cur linestyle (0/1) */
static int w_lsmask; /* linestyle mask */
static void(*w_drawghost)(int, int, int, int); /* ghost draw function */
static int w_lastx, w_lasty, w_refx, w_refy; /* ghost draw values */
static int w_firstghost; /* ghost draw flag */
static int w_fs_cursor; /* using fs curser */
static int w_fs_first; /* fs cursor flag */
static int w_curfp; /* fill pattern index */
static HBITMAP w_fp[64]; /* fill pattern table */
static int w_cmap_max_size;
static int w_cmap_size;
static HPALETTE w_cmap;
/*=========================================================================
*
* Global Exports
*
*========================================================================*/
void
FBBegin(char *Dspl)
{
FB.fDisplay = Dspl;
if (!(FB.fInitialized)) {
if ((*GR[FB.fInterface].gOpen)(Dspl))
fatal_error("Unable to open display.");
else {
/*
if (Parameters.kpFontName[0] != '\0')
MFBSetFont(Parameters.kpFontName);
if (Parameters.kpCursorShape >= 0)
MFBSetCursor(Parameters.kpCursorShape);
*/
if (Parameters.kpFullScreenCursor)
w_SetFullScreenCursor(True);
}
FB.fInitialized = 1;
}
FBSetLineStyle(0);
FB.fMaxX = FBInfo(MAXX);
FB.fMaxY = FBInfo(MAXY);
FB.fMaxP = 255;
FB.fMaxIntensity = 255;
FB.fNumColors = FBInfo(MAXCOLORS);
if (FB.fNumColors >= 32)
Parameters.kpMergeColors = False;
else
Parameters.kpMergeColors = True;
FB.fNumFillPatterns = FBInfo(MAXFILLPATTERNS);
FB.fButtonMask = SetButtonMask();
FB.fButtons = 1;
FB.fNumButtons = 4;
FB.fFontWidth = FBInfo(FONTWIDTH);
FB.fFontHeight = FBInfo(FONTHEIGHT);
FB.fNumRows = FB.fMaxY/FB.fFontHeight;
FB.fNumColumns = FB.fMaxX/FB.fFontWidth;
FB.fFilledPolygons = 1;
FB.fDefinableFillPatterns = 1;
FB.fNonDestructiveText = 1;
FB.fLastCursorColumn = 0;
FB.fBlinkers = 0;
FB.fInitialized = True;
{
HBRUSH brush = CreateSolidBrush(w_colors[0]);
brush = (HBRUSH)SetClassLong(w_hwnd, GCL_HBRBACKGROUND, (DWORD)brush);
if (brush)
DeleteBrush(brush);
}
}
void
FBForeground(int DisplayOrErase, int Pixel)
{
if (DisplayOrErase == ERASE) Pixel = 0;
Pixel = min(FB.fNumColors,Pixel);
(*GR[FB.fInterface].gSetColor)(Pixel);
}
void
FBVLT(int Pixel, int R, int G, int B)
{
R = ((int)R * FB.fMaxP)/FB.fMaxIntensity;
G = ((int)G * FB.fMaxP)/FB.fMaxIntensity;
B = ((int)B * FB.fMaxP)/FB.fMaxIntensity;
(*GR[FB.fInterface].gDefColor)(Pixel,R,G,B);
}
void
FBText(int Mode, int RowOrX, int ColumnOrY, char *Text)
{
int i;
if (Mode == ROW_COLUMN) {
i = FB.fMaxY - RowOrX * FB.fFontHeight;
RowOrX = (ColumnOrY - 1) * FB.fFontWidth;
ColumnOrY = i;
}
(*GR[FB.fInterface].gText)(Text,RowOrX,ColumnOrY,0);
}
int
FBGetchar(int DisplayOrErase)
{
int x,y;
short c;
char s[2];
if (DisplayOrErase == ERASE)
return (w_Getchar());
y = FB.fMaxY - FB.fNumRows*FB.fFontHeight;
x = FB.fLastCursorColumn*FB.fFontWidth;
FBForeground(DISPLAY,ColorTable[HighlightingColor].Ent);
textcursor(x,y);
c = w_Getchar();
s[0] = (char)(c & 0xff);
s[1] = '\0';
FBForeground(DISPLAY,ColorTable[MenuPromptColor].Ent);
(*GR[FB.fInterface].gText)(s,x,y,0);
AppendToOldPrompt(s[0]);
FBForeground(ERASE,0);
textcursor(x,y);
return (c);
}
char *
FBEdit(char *string)
{
int x,y;
y = FB.fMaxY - (FB.fNumRows - 2)*FB.fFontHeight;
x = FB.fLastCursorColumn*FB.fFontWidth;
return (kbedit(string,x,y,0,ColorTable[MenuPromptColor].Ent,
ColorTable[HighlightingColor].Ent));
}
void
FBSetCursorColor(int colorId)
{
/* MFBSetCursorColor(colorId,colorId); */ /* no blinking */
}
void
FBPolygon(int Pixel, int Type, int StyleId, int *xy, int n)
{
/*
* Type == FILL means fill
* Type == OUTLINE means outline
* StyleId defines stipple pattern (0 = SOLID)
*/
int j,n2,X,Y,Z,T,Xo,Yo;
Poly poly;
FBForeground(DISPLAY,Pixel);
(*GR[FB.fInterface].gSetFp)(StyleId);
poly.xy = xy;
while (NewPolygon(&poly)) {
n = poly.nvertices;
if (Type == OUTLINE) {
n2 = n + n;
j = 2;
Xo = X = xy[0];
Yo = Y = xy[1];
while (j < n2) {
Z = xy[j++];
T = xy[j++];
(*GR[FB.fInterface].gLine)(X,Y,Z,T);
X = Z;
Y = T;
}
(*GR[FB.fInterface].gLine)(X,Y,Xo,Yo);
}
else {
if (n < 2) return;
(*GR[FB.fInterface].gPolygon)(&poly);
}
}
}
void
FBPolygonClip(int *coord, int *n, struct ka *window)
{
Poly poly;
poly.nvertices = *n;
if (*n < 3) return;
poly.xy = coord;
PolygonClip(&poly,window->kaLeft,window->kaBottom,
window->kaRight,window->kaTop);
}
void
FBSetRubberBanding(int mode)
/* if mode is lower case will clip to grid point */
{
/* need some hokum for button 3 box */
static void (*func)(int,int,int,int);
static int X, Y;
static int lastR;
switch (mode) {
case 'l':
func = ghost_line_snap;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
w_SetGhost(func,X,Y);
return;
case 'L':
func = ghost_line;
X = (int)KicCursor.kcRawX;
Y = (int)KicCursor.kcRawY;
w_SetGhost(func,X,Y);
return;
case 'r':
func = ghost_box_snap;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
w_SetGhost(func,X,Y);
return;
case 'R':
if (func) {
lastR = True;
w_SetGhost(ghost_box,
(int)KicCursor.kcRawX,(int)KicCursor.kcRawY);
return;
}
func = ghost_box;
X = (int)KicCursor.kcRawX;
Y = (int)KicCursor.kcRawY;
w_SetGhost(func,X,Y);
return;
case 's':
func = ghost_stretch;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
w_SetGhost(func,X,Y);
return;
case 'm':
case 'M':
func = ghost_move;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
w_SetGhost(func,X,Y);
return;
case 'p':
case 'P':
func = ghost_place;
X = (int)KicCursor.kcX;
Y = (int)KicCursor.kcY;
w_SetGhost(func,X,Y);
return;
case 0:
if (lastR) {
w_SetGhost(func,X,Y);
}
else {
w_SetGhost(NULL,0,0);
func = (void(*)(int,int,int,int))NULL;
}
lastR = False;
return;
}
}
/* cursor height - 1 */
#define CURHT 0
/* What a pain - have to be able to redraw during editing
* when a resize event occurs.
*/
static int doing_edit;
static int editX, editY, editFg, editCc;
static char editBuf[128], *editC;
void
FBKbRepaint(int x, int y)
{
if (!doing_edit) return;
editX = x;
editY = y;
w_SetColor(editCc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(editFg);
w_Text(editBuf,editX,editY,0);
}
/* Return a time stamp
*/
unsigned int
FBTime()
{
return (time(0));
}
/* Used only in DOS
*/
void
FBFuncKeys(int y, int dx)
{
}
/* Erase or draw the fine positioning window in coarse window.
*/
void
XORfineViewport(void)
{
char tmp = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
SetROP2(w_dc, R2_XORPEN);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,View->kvFineWindow);
SetROP2(w_dc, R2_COPYPEN);
Parameters.kpRedisplayControl = tmp;
}
/* replace X,Y (in pixel coords) with the window coords if pointing
* in the Coarse or Fine viewports, and return True. Otherwise
* return False. Clip to grid if Clip is True.
*/
int
GetWindowCoords(int *X, int *Y, int Clip)
{
int X1,Y1;
RECT r;
GetClientRect(w_hwnd, &r);
X1 = *X;
Y1 = (r.bottom - r.top) - *Y;
if (InBox(X1,Y1,View->kvCoarseViewport)) {
PToL(View->kvCoarseWindow,&X1,&Y1);
if (Clip)
ClipToGridPoint(&X1,&Y1);
*X = X1;
*Y = Y1;
return (True);
}
if (InBox(X1,Y1,View->kvFineViewport)) {
PToL(View->kvFineWindow,&X1,&Y1);
if (Clip)
ClipToGridPoint(&X1,&Y1);
*X = X1;
*Y = Y1;
return (True);
}
return (False);
}
int *
SetButtonMask(void)
{
static int mask[4];
mask[0] = 1;
mask[1] = 2;
mask[2] = 4;
mask[3] = 3;
return (mask);
}
/* Menu command to select font
*/
void
SelectKicFont()
{
extern char *MenuFONT;
char *in, buf[80];
int w, h;
sprintf(buf, "Enter char size WxH (currently %dx%d)",
FB.fFontWidth, FB.fFontHeight);
ShowPrompt(buf);
in = FBEdit(0);
if (in && sscanf(in, "%dx%d", &w, &h) == 2) {
HFONT f = msw_GetFixedFont(w, h);
if (f) {
f = SelectFont(w_dc, f);
DeleteFont(f);
FullRedisplay();
sprintf(Parameters.kpFontName, "%dx%d",
FB.fFontWidth, FB.fFontHeight);
}
else {
ShowPrompt("Failed to set font.");
MenuDeselect(MenuFONT);
return;
}
}
MenuDeselect(MenuFONT);
ErasePrompt();
}
/* Menu command to set/unset full-screen cursor
*/
void
SelectKicCursor()
{
extern char *MenuCURSR;
if (w_fs_cursor) {
w_SetFullScreenCursor(False);
MenuDeselect(MenuCURSR);
}
else {
w_SetFullScreenCursor(True);
MenuSelect(MenuCURSR);
}
}
/* Return True if using X
*/
int
Xcheck()
{
return (0);
}
/* color print in DOS
*/
void
cprint(int i, char *s)
{
out_printf(s);
}
/*=========================================================================
*
* Local Interface Functions
*
*========================================================================*/
static int
w_Info(int num)
{
RECT r;
SIZE size;
GetClientRect(w_hwnd, &r);
GetTextExtentPoint32(w_dc, "x", 1, &size);
switch (num) {
case MAXX: return (r.right - r.left - 1);
case MAXY: return (r.bottom - r.top - 1);
case MAXCOLORS: return (32);
case MAXINTENSITY: return (255);
case MAXFILLPATTERNS: return (16);
case MAXLINESTYLES: return (1);
case MAXBLINKERS: return (0);
case POINTINGDEVICE: return (0);
case POINTINGBUTTONS: return (0);
case NUMBUTTONS: return (0);
case BUTTON1: return (1);
case BUTTON2: return (2);
case BUTTON3: return (3);
case BUTTON4: return (4);
case BUTTON5: return (0);
case BUTTON6: return (0);
case BUTTON7: return (0);
case BUTTON8: return (0);
case BUTTON9: return (0);
case BUTTON10: return (0);
case BUTTON11: return (0);
case BUTTON12: return (0);
case TEXTPOSITIONABLE: return (1);
case TEXTROTATABLE: return (1);
case FONTHEIGHT: return (size.cy);
case FONTWIDTH: return (size.cx);
case FONTXOFFSET: return (0);
case FONTYOFFSET: return (0);
case DESTRUCTIVETEXT: return (0);
case OVERSTRIKETEXT: return (1);
case VLT: return (0);
case BLINKERS: return (0);
case FILLEDPOLYGONS: return (1);
case DEFFILLPATTERNS: return (1);
case DEFLINEPATTERN: return (1);
case CURFGCOLOR: return (1);
case CURFILLPATTERN: return (w_curfp);
case CURLINESTYLE: return (w_linestyle);
case NUMBITPLANES: return (1);
default: return (-1);
}
}
static int
w_Open(char *name)
{
HINSTANCE instance = GetModuleHandle(0);
WNDCLASSEX wcex;
char *title = "Kic Layout Editor";
int rcaps;
int fw, fh;
// The application's main frame window
//
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcex.lpfnWndProc = mainFrameWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = instance;
wcex.hIcon = LoadIcon(instance, MAKEINTRESOURCE(IDR_MAINFRAME));
wcex.hCursor = LoadCursor(0, IDC_CROSS);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME);
wcex.lpszClassName = MAKEINTRESOURCE(IDR_MAINFRAME);
wcex.hIconSm = (HICON)LoadImage(instance,
MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
LR_SHARED);
// Register the window class and return success/failure code.
if (!msw_RegisterClass(&wcex))
return (1);
// Create the main frame window
w_hwnd = CreateWindowEx(
0, // Extended window styles
MAKEINTRESOURCE(IDR_MAINFRAME), // registered class name
title, // Address of window name
WS_OVERLAPPEDWINDOW,// Window style
CW_USEDEFAULT, // Horizontal position of window
0, // Vertical position of window
800, // Window width
600, // Window height
0, // Handle of parent or owner window
0, // Handle of menu for this window
instance, // Handle of application instance
0); // Address of window-creation data
if (!w_hwnd)
return (1);
w_dc = GetDC(w_hwnd);
#define CNUM 2
if (sscanf(Parameters.kpFontName, "%dx%d", &fw, &fh) == 2 &&
fw > 2 && fw < 15 && fh > 4 && fh < 30)
SelectFont(w_dc, msw_GetFixedFont(fw, fh));
else
SelectFont(w_dc, msw_GetFixedFont(DEF_FWID, DEF_FHEI));
SetBkMode(w_dc, TRANSPARENT);
SetTextAlign(w_dc, TA_LEFT | TA_BOTTOM | TA_NOUPDATECP);
rcaps = GetDeviceCaps(w_dc, RASTERCAPS);
if (rcaps & RC_PALETTE) {
char logPalBuf[sizeof(LOGPALETTE) + CNUM*sizeof(PALETTEENTRY)];
LOGPALETTE *logPalPtr = (LOGPALETTE*)logPalBuf;
PALETTEENTRY *p = logPalPtr->palPalEntry;
int i;
logPalPtr->palVersion = 0x300;
logPalPtr->palNumEntries = CNUM;
for (i = 0; i < CNUM; i++) {
if (i == 0) {
p->peRed = 0;
p->peGreen = 0;
p->peBlue = 0;
p->peFlags = 0;
}
else {
p->peRed = 255;
p->peGreen = 255;
p->peBlue = 255;
p->peFlags = 0;
}
p++;
w_colors[i] = PALETTEINDEX(i);
}
w_cmap_max_size = GetDeviceCaps(w_dc, SIZEPALETTE);
w_cmap_size = logPalPtr->palNumEntries;
w_cmap = CreatePalette(logPalPtr);
SelectPalette(w_dc, w_cmap, False);
RealizePalette(w_dc);
SetBkColor(w_dc, PALETTEINDEX(0));
SetTextColor(w_dc, PALETTEINDEX(1));
}
else {
SetBkColor(w_dc, RGB(0, 0, 0));
SetTextColor(w_dc, RGB(255, 255, 255));
}
DragAcceptFiles(w_hwnd, True);
ShowWindow(w_hwnd, SW_SHOW);
return (0);
}
static int
w_Close(void)
{
return (0);
}
static int
w_Update(void)
{
UpdateWindow(w_hwnd);
return (0);
}
static void
w_Pixel(int x, int y)
{
SetPixelV(w_dc, x, INV(y), w_fg);
}
static void
w_Line(int x1, int y1, int x2, int y2)
{
MoveToEx(w_dc, x1, INV(y1), 0);
LineTo(w_dc, x2, INV(y2));
}
// Some ROP3's
#define COPYFG 0x00ca0749 // dst = (pat & src) | (!pat & dst)
#define COPYBG 0x00ac0744 // dst = (!pat & src) | (pat & dst)
static void
w_Box(int x1, int y1, int x2, int y2)
{
y1 = INV(y1);
y2 = INV(y2);
if (x1 > x2) {
int temp = x1;
x1 = x2;
x2 = temp;
}
if (y1 > y2) {
int temp = y1;
y1 = y2;
y2 = temp;
}
x2++;
y2++;
if (w_fp[w_curfp]) {
HDC dcMem;
HBITMAP bm;
RECT r;
r.left = r.top = 0;
r.right = x2-x1;
r.bottom = y2-y1;
dcMem = CreateCompatibleDC(w_dc);
if (w_cmap)
SelectPalette(dcMem, w_cmap, False);
bm = CreateCompatibleBitmap(w_dc, r.right, r.bottom);
bm = (HBITMAP)SelectObject(dcMem, bm);
SetBkColor(dcMem, w_fg);
ExtTextOut(dcMem, 0, 0, ETO_OPAQUE, &r, 0, 0, 0);
SetTextColor(w_dc, RGB(255,255,255));
BitBlt(w_dc, x1, y1, r.right, r.bottom, dcMem, 0, 0, COPYFG);
SetTextColor(w_dc, w_fg);
bm = (HBITMAP)SelectObject(dcMem, bm);
DeleteBitmap(bm);
DeleteDC(dcMem);
}
else {
COLORREF oldc;
RECT r;
r.left = x1;
r.top = y1;
r.right = x2;
r.bottom = y2;
// faster? Ousterhout claims so in tk
oldc = SetBkColor(w_dc, w_fg);
SetBkMode(w_dc, OPAQUE);
ExtTextOut(w_dc, 0, 0, ETO_OPAQUE, &r, 0, 0, 0);
SetBkColor(w_dc, oldc);
SetBkMode(w_dc, TRANSPARENT);
/*
FillRect(w_dc, &r,
(HBRUSH)GetCurrentObject(w_dc, OBJ_BRUSH));
*/
}
}
static void
w_Polygon(Poly *poly)
{
POINT *pl = (POINT*)malloc(poly->nvertices * sizeof(POINT));
POINT *data = (POINT*)poly->xy;
RECT r;
int i;
r.left = r.right = data[0].x;
r.top = r.bottom = data[0].y;
for (i = 0; i < poly->nvertices; i++) {
pl[i].x = data[i].x;
pl[i].y = INV(data[i].y);
if (r.left > pl[i].x)
r.left = pl[i].x;
if (r.top > pl[i].y)
r.top = pl[i].y;
if (r.right < pl[i].x)
r.right = pl[i].x;
if (r.bottom < pl[i].y)
r.bottom = pl[i].y;
}
if (w_fp[w_curfp]) {
int i, x1, y1;
HDC dcMem;
HBITMAP bm;
HBRUSH brush;
for (i = 0; i < poly->nvertices; i++) {
pl[i].x -= r.left;
pl[i].y -= r.top;
}
x1 = r.left;
r.right -= r.left;
r.left = 0;
y1 = r.top;
r.bottom -= r.top;
r.top = 0;
dcMem = CreateCompatibleDC(w_dc);
if (w_cmap)
SelectPalette(dcMem, w_cmap, False);
bm = CreateCompatibleBitmap(w_dc, r.right, r.bottom);
bm = (HBITMAP)SelectObject(dcMem, bm);
BitBlt(dcMem, 0, 0, r.right, r.bottom, w_dc, x1, y1, SRCCOPY);
brush = CreateSolidBrush(w_fg);
brush = SelectBrush(dcMem, brush);
Polygon(dcMem, pl, poly->nvertices);
brush = SelectBrush(dcMem, brush);
DeleteBrush(brush);
SetTextColor(w_dc, RGB(255,255,255));
BitBlt(w_dc, x1, y1, r.right, r.bottom, dcMem, 0, 0, COPYFG);
SetTextColor(w_dc, w_fg);
bm = (HBITMAP)SelectObject(dcMem, bm);
DeleteBitmap(bm);
DeleteDC(dcMem);
}
else
Polygon(w_dc, pl, poly->nvertices);
free(pl);
}
static HPEN
new_pen(COLORREF cref, int mask)
{
HPEN pen;
if (mask == 0 || mask == 255)
pen = CreatePen(PS_SOLID, 0, cref);
else {
DWORD cnt, st[8];
int i, len, lst;
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = cref;
len = 1;
cnt = 0;
lst = mask & 1;
for (i = 1; i < 8; i++) {
if (mask & (1 << i)) {
if (!lst) {
st[cnt++] = len;
len = 1;
lst = 1;
}
else
len++;
}
else {
if (lst) {
st[cnt++] = len;
len = 1;
lst = 0;
}
else
len++;
}
}
st[cnt++] = len;
pen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 0, &lb, cnt, st);
}
return (pen);
}
static int
w_DefLs(int id, int mask)
{
if (id) {
w_lsmask = mask;
w_SetLs(id);
}
return (0);
}
static int
w_SetLs(int id)
{
HPEN pen = new_pen(w_fg, (id && w_lsmask) ? w_lsmask : 0);
w_linestyle = id ? 1 : 0;
pen = SelectPen(w_dc, pen);
if (pen)
DeletePen(pen);
return (0);
}
// Reverse bit order and complement
//
unsigned char
revnotbits(unsigned char c)
{
unsigned char out = 0;
int i;
for (i = 0;;) {
if (!(c & 1))
out |= 1;
i++;
if (i == 8)
break;
c >>= 1;
out <<= 1;
}
return (out);
}
static int
w_DefFp(int id, int *map)
{
if (id < 0 || id >= 64)
return (1);
if (w_fp[id]) {
DeleteBitmap(w_fp[id]);
w_fp[id] = 0;
}
if (map) {
unsigned short invmap[16];
int nx = 8;
int ny = 8;
int sx = nx/8;
int i, j = 0;
// 0 -> text fg color, 1 -> text bg color, so invert map pixels
for (i = 0; i < ny; i++) {
if (sx == 1) {
invmap[i] = revnotbits(map[j]);
j++;
}
else {
invmap[i] = (revnotbits(map[j]) << 8) |
revnotbits(map[j+1]);
j += 2;
}
}
w_fp[id] = CreateBitmap(nx, ny, 1, 1, invmap);
}
return (0);
}
static int
w_SetFp(int id)
{
HBRUSH brush;
if (id < 0 || id >= 64)
return (1);
w_curfp = id;
if (!w_fp[w_curfp])
brush = CreateSolidBrush(w_fg);
else
brush = CreatePatternBrush(w_fp[w_curfp]);
brush = SelectBrush(w_dc, brush);
if (brush)
DeleteBrush(brush);
return (0);
}
static int
w_DefColor(int pix, int r, int g, int b)
{
if (!w_cmap)
w_colors[pix] = RGB(r, g, b);
else {
if (w_colors[pix] & 0xff000000) {
/* already have an allocated entry for pix, reset the color */
PALETTEENTRY p;
p.peRed = r;
p.peGreen = g;
p.peBlue = b;
/* This doesn't work reliably. How to find out how many unused
* system entries are available?
*/
/*
if (pix && pix < CNUM) {
*/
if (0) {
p.peFlags = PC_RESERVED;
AnimatePalette(w_cmap, pix, 1, &p);
}
else {
p.peFlags = 0;
SetPaletteEntries(w_cmap, w_colors[pix], 1, &p);
RealizePalette(w_dc);
}
}
else {
/* allocate a new color table entry */
PALETTEENTRY entry;
entry.peRed = r;
entry.peGreen = g;
entry.peBlue = b;
entry.peFlags = 0;
w_cmap_size++;
ResizePalette(w_cmap, w_cmap_size);
SetPaletteEntries(w_cmap, w_cmap_size - 1, 1, &entry);
w_colors[pix] = PALETTEINDEX(w_cmap_size - 1);
RealizePalette(w_dc);
}
}
w_SetColor(pix);
return (0);
}
static int
w_SetColor(int pix)
{
HPEN pen;
w_fg = w_colors[pix];
w_fg_indx = pix;
SetTextColor(w_dc, w_fg);
pen = new_pen(w_fg, (w_linestyle && w_lsmask) ? w_lsmask : 0);
pen = SelectPen(w_dc, pen);
if (pen)
DeletePen(pen);
if (!w_fp[w_curfp]) {
HBRUSH brush = CreateSolidBrush(w_fg);
brush = SelectBrush(w_dc, brush);
if (brush)
DeleteBrush(brush);
}
return (0);
}
static void
w_Text(char *text, int x, int y, int notused)
{
if (!text)
return;
TextOut(w_dc, x, INV(y), text, strlen(text));
}
static void
w_ScText(char *text, int x, int y, int notused1, int notused2)
{
if (!text)
return;
TextOut(w_dc, x, INV(y), text, strlen(text));
}
void
w_Clear()
{
RECT r;
HBRUSH brush;
GetClientRect(w_hwnd, &r);
r.right++;
r.bottom++;
brush = (HBRUSH)GetClassLong(w_hwnd, GCL_HBRBACKGROUND);
if (!brush) {
brush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
FillRect(w_dc, &r, brush);
DeleteBrush(brush);
}
else
FillRect(w_dc, &r, brush);
}
int
w_Point(int *xret, int *yret, int *keyret, int *butret)
{
MSG msg;
int done = 0;
*keyret = *butret = 0;
*xret = *yret = 0;
while (!done && GetMessage(&msg, 0, 0, 0)) {
switch (msg.message) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
if (msg.message == WM_LBUTTONDOWN)
*butret = 1;
else if (msg.message == WM_MBUTTONDOWN)
*butret = 2;
else
*butret = 3;
*xret = msg.lParam & 0xffff;
*yret = INV(msg.lParam >> 16);
done = 1;
break;
case WM_CHAR:
*keyret = msg.wParam & 0xff;
*xret = 0;
*yret = INV(0);
*butret = -1;
done = 1;
break;
default:
if (msg.message == WM_KEYDOWN && msg.wParam == VK_LEFT) {
*keyret = 331;
*xret = 0;
*yret = INV(0);
*butret = -1;
done = 1;
break;
}
if (msg.message == WM_KEYDOWN && msg.wParam == VK_RIGHT) {
*keyret = 333;
*xret = 0;
*yret = INV(0);
*butret = -1;
done = 1;
break;
}
if (msg.message == WM_KEYDOWN && msg.wParam == VK_DELETE) {
*keyret = 127;
*xret = 0;
*yret = INV(0);
*butret = -1;
done = 1;
break;
}
if (!TranslateAccelerator(msg.hwnd, 0, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
if (w_drawghost && w_firstghost == False) {
int tmpfg;
SetROP2(w_dc, R2_XORPEN);
tmpfg = w_fg_indx;
w_SetColor(ColorTable[HighlightingColor].Ent);
(*w_drawghost)(w_lastx, w_lasty, w_refx, w_refy);
w_SetColor(tmpfg);
SetROP2(w_dc, R2_COPYPEN);
w_firstghost = True;
}
if (w_fs_cursor && w_fs_first == False) {
int tmpfg;
SetROP2(w_dc, R2_XORPEN);
tmpfg = w_fg_indx;
w_SetColor(ColorTable[HighlightingColor].Ent);
draw_fs_cursor(w_lastx, w_lasty);
w_SetColor(tmpfg);
SetROP2(w_dc, R2_COPYPEN);
w_fs_first = True;
}
return (0);
}
static void
w_Beep(int i)
{
putchar('\007');
}
static int
w_SetFullScreenCursor(int onflag)
{
w_fs_cursor = onflag;
if (onflag) {
SetCursor(0);
w_fs_first = True;
}
return (0);
}
static void
w_TextBB(char *t, int *x, int *y)
{
int hei = 0, wid = 0, cnt = 0;
char *s, *s0;
if (!t)
t = "x";
s0 = t;
for (s = t; *s; s++) {
if (*s == '\n') {
int w = textwidth(s0, cnt);
if (w > wid)
wid = w;
hei += FB.fFontHeight;
s0 = s+1;
cnt = 0;
continue;
}
cnt++;
if (*(s+1) == 0) {
int w = textwidth(s0, cnt);
if (w > wid)
wid = w;
}
}
if (wid == 0)
wid = FB.fFontWidth;
*x = wid;
if (hei == 0)
hei = FB.fFontHeight;
*y = hei;
}
void
w_More(int Left, int Bottom, int Right, int Top, FILE *Textfile)
{
char cbuf[MAXCHARLINE+9]; /* add extra space for tab expansion */
int key;
int i,j,x,y,c,button,dy;
int done;
int oldfillpattern;
int oldforeground;
int newbackground;
int nlines;
int pagecount;
int controlchar;
int width_screen; /* width of the box */
int width_string; /* width of the current string */
int width_space; /* width of a space character */
int variable_width; /* True if current font is variable width */
/* test to be sure of window area */
if (Top < Bottom) {
int tmp = Top;
Top = Bottom;
Bottom = tmp;
}
if (Right < Left) {
int tmp = Right;
Right = Left;
Left = tmp;
}
/* calculate parameters */
dy = FB.fFontHeight;
nlines = (Top - Bottom) / dy;
if (nlines <= 0)
return;
width_screen = Right - Left;
width_space = textwidth(" ", 1);
variable_width = False;
if (textwidth("x", 1) != textwidth("M", 1)) {
variable_width = True;
width_screen -= 3;
}
/* save old style ID's */
oldforeground = w_fg_indx;
oldfillpattern = w_curfp;
w_SetFp(0);
if (oldforeground == 0)
newbackground = ColorTable[HighlightingColor].Ent;
else
newbackground = 0;
pagecount = 0;
done = 0;
while (!done) {
/* Display one page of text from the file */
w_SetColor(newbackground);
w_Box(Left, Bottom, Right, Top); /* Erase the screen */
w_SetColor(oldforeground);
for (j = 1; j < nlines; ++j) {
/* Loop for each line of page */
i = 0;
width_string = 0;
controlchar = 0;
while ((c = getc(Textfile)) != '\n' && c != EOF) {
/* Get a char */
if (c == '\t') {
/* tab */
cbuf[i++] = ' ';
if ((width_string += width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
while (i % 8 != 0) {
cbuf[i++] = ' ';
width_string += width_space;
}
if (width_string > width_screen)
break;
}
else if (c < ' ') {
/* control character */
if (controlchar == 0) {
cbuf[i] = '^';
ungetc(c,Textfile);
if ((width_string += (variable_width) ?
textwidth(&cbuf[i], 1) :
width_space) > width_screen)
break;
controlchar = 1;
}
else {
cbuf[i] = c + '@';
controlchar = 0;
if ((width_string += (variable_width) ?
textwidth(&cbuf[i], 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
--i;
break;
}
}
++i;
}
else if (c <= '~') {
/* < DEL character? */
if ((width_string += (variable_width) ?
textwidth((char *) &c, 1) :
width_space) > width_screen) {
ungetc(c,Textfile);
break;
}
cbuf[i++] = c;
}
if (i >= MAXCHARLINE)
break;
}
cbuf[i] = '\0';
w_Text(cbuf, Left, Top - j * dy, 0);
if (c == EOF) {
done = 1;
break;
}
}
if (done)
strcpy(cbuf, "-DONE- (^U to scroll up, ? for help)");
else
strcpy(cbuf, "-MORE- (^U to scroll up, ^D to exit, ? for help)");
w_Text(cbuf, Left, Bottom, 0);
i = Left + textwidth(cbuf, strlen(cbuf));
sprintf(cbuf, "Page %d", ++pagecount);
j = Right - textwidth(cbuf, strlen(cbuf)) - 3;
if (j < i)
j = i;
w_Text(cbuf, j, Bottom, 0);
/* Wait for user interaction and perform requested function */
for (;;) {
w_Point(&x, &y, &key, &button);
if (button == -1) {
/* Keyboard key pressed */
if (key == 4) /* ^D */
done = 1;
}
else {
/* Mouse button pressed */
if (x < Left || x > Right || y < Bottom || y > Top)
done = 1;
else if (button == FB.fButtonMask[1]) {
/* MB2 - down */
if (done)
continue;
}
else if (button != FB.fButtonMask[0])
continue;
}
break;
}
}
w_SetFp(oldfillpattern);
}
static void
w_SetName(char *wname, char *iname)
{
SetWindowText(w_hwnd, wname);
}
static int
w_Blink(int colorId, int r, int g, int b, int onflag)
{
return (1);
}
static int
w_SelectFont(int l, int b, int r, int t)
{
return (1);
}
static void
w_SelectCursor(int l, int b, int r, int t)
{
}
static void
w_SetTextClip(int l, int b, int r, int t)
{
}
static void
w_Resize(int l, int b, int r, int t)
{
}
/*=========================================================================
*
* Local MS Windows Functions
*
*========================================================================*/
// Register the window class using RegisterClassEx if it is available.
// If not, registers the class using RegisterClass.
//
static ATOM
msw_RegisterClass(const LPWNDCLASSEX lpwcex)
{
// Get the module handle of the 32-bit USER DLL
HANDLE hModule = GetModuleHandle (TEXT("USER32"));
WNDCLASS wc;
if (hModule != 0) {
// If we're running on a Win32 version supporting RegisterClassEx
// get the address of the function so we can call it
REGISTERCLASSEXPROC proc =
(REGISTERCLASSEXPROC)GetProcAddress((HINSTANCE)hModule,
"RegisterClassExA");
if (proc != 0)
// RegisterClassEx exists...
// return RegisterClassEx(&wcex);
return (*proc)(lpwcex);
}
/* Convert the WNDCLASSEX structure to a WNDCLASS structure */
wc.style = lpwcex->style;
wc.lpfnWndProc = lpwcex->lpfnWndProc;
wc.cbClsExtra = lpwcex->cbClsExtra;
wc.cbWndExtra = lpwcex->cbWndExtra;
wc.hInstance = lpwcex->hInstance;
wc.hIcon = lpwcex->hIcon;
wc.hCursor = lpwcex->hCursor;
wc.hbrBackground = lpwcex->hbrBackground;
wc.lpszMenuName = lpwcex->lpszMenuName;
wc.lpszClassName = lpwcex->lpszClassName;
return (RegisterClass(&wc));
}
// Process messages for the main (shell) window and the subwindow shells
//
static LRESULT CALLBACK
mainFrameWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
char buf[256];
int x, y;
switch (message) {
case WM_PAINT:
BeginPaint(w_hwnd, &ps);
EndPaint(w_hwnd, &ps);
if (FB.fInitialized)
RedisplayKIC();
return (0);
case WM_MOUSEMOVE:
x = LOWORD(lParam);
y = HIWORD(lParam);
if (w_drawghost) {
if (!w_firstghost) {
SetROP2(w_dc, R2_XORPEN);
(*w_drawghost)(w_lastx, w_lasty, w_refx, w_refy);
SetROP2(w_dc, R2_COPYPEN);
}
SetROP2(w_dc, R2_XORPEN);
(*w_drawghost)(x, y, w_refx, w_refy);
SetROP2(w_dc, R2_COPYPEN);
w_firstghost = False;
}
if (w_fs_cursor) {
if (!w_fs_first) {
SetROP2(w_dc, R2_XORPEN);
draw_fs_cursor(w_lastx, w_lasty);
SetROP2(w_dc, R2_COPYPEN);
}
SetROP2(w_dc, R2_XORPEN);
draw_fs_cursor(x, y);
SetROP2(w_dc, R2_COPYPEN);
w_fs_first = False;
}
w_lastx = x;
w_lasty = y;
return (0);
case WM_DROPFILES:
if (DragQueryFile((HDROP)wParam, 0, buf, 255) > 0) {
strcpy(Parameters.kpCellName, buf);
Edit(True, True, False);
}
DragFinish((HDROP)wParam);
return (0);
case WM_CLOSE:
AbortKIC();
return (0);
}
return (DefWindowProc(hwnd, message, wParam, lParam));
}
#define MSW_FIXED_FONT "Lucida Console"
//#define MSW_FIXED_FONT "Andale Mono"
// Return a "suitable" fixed font
//
static HFONT
msw_GetFixedFont(int width, int height)
{
HFONT fixed;
LOGFONT lf;
lf.lfHeight = height;
lf.lfWidth = width;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = FW_DONTCARE;
lf.lfItalic = 0;
lf.lfUnderline = 0;
lf.lfStrikeOut = 0;
lf.lfCharSet = ANSI_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = 0;
lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
strcpy(lf.lfFaceName, MSW_FIXED_FONT);
fixed = CreateFontIndirect(&lf);
return (fixed);
}
/*=========================================================================
*
* Misc. Local Functions
*
*========================================================================*/
static void
draw_fs_cursor(int x, int y)
{
int xmin = MenuViewport.kaRight * FB.fFontWidth;
int xmax = FB.fMaxX;
int ymin = INV(FB.fMaxY);
int ymax = INV(ParameterViewport.kaTop);
int tmpfg = w_fg_indx;
SetCursor(0); /* hide the regular cursor */
w_SetColor(ColorTable[HighlightingColor].Ent);
if (x < xmin || x > xmax || y < ymin || y > ymax) {
w_Line(x-5, INV(y), x+6, INV(y));
w_Line(x, INV(y-5), x, INV(y+6));
}
else {
w_Line(xmin, INV(y), xmax, INV(y));
w_Line(x, INV(ymin), x, INV(ymax));
}
w_SetColor(tmpfg);
}
static int
w_SetGhost(void(*callback)(int, int, int, int), int x, int y)
{
if (callback) {
w_refx = x;
w_refy = y;
w_drawghost = callback;
w_firstghost = True;
return (0);
}
w_drawghost = NULL;
return (0);
}
static void
ghost_line(int x, int y, int refx, int refy)
{
if (!GetWindowCoords((int*)&x,(int*)&y,False))
return;
if (Parameters.kpRotationAngle == 0 ||
Parameters.kpRotationAngle == 180)
ShowLine(ColorTable[HighlightingColor].Ent,x,
View->kvCoarseWindow->kaBottom,
x,View->kvCoarseWindow->kaTop);
else
ShowLine(ColorTable[HighlightingColor].Ent,
View->kvCoarseWindow->kaLeft,
y,View->kvCoarseWindow->kaRight,y);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_line_snap(int x, int y, int refx, int refy)
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
if (Parameters.kpRotationAngle == 0 ||
Parameters.kpRotationAngle == 180)
ShowLine(ColorTable[HighlightingColor].Ent,x,
View->kvCoarseWindow->kaBottom,
x,View->kvCoarseWindow->kaTop);
else
ShowLine(ColorTable[HighlightingColor].Ent,
View->kvCoarseWindow->kaLeft,
y,View->kvCoarseWindow->kaRight,y);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_box(int x, int y, int refx, int refy)
{
struct ka BB;
if (!GetWindowCoords((int*)&x,(int*)&y,False))
return;
BB.kaLeft = refx;
BB.kaBottom = refy;
BB.kaRight = x;
BB.kaTop = y;
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_box_snap(int x, int y, int refx, int refy)
{
struct ka BB;
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
BB.kaLeft = refx;
BB.kaBottom = refy;
BB.kaRight = x;
BB.kaTop = y;
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_stretch(int x, int y, int refx, int refy)
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowStretch(x,y,refx,refy);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_move(int x, int y, int refx, int refy)
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowMove(refx,refy,x,y);
w_SetColor(Parameters.kpLayer);
}
static void
ghost_place(int x, int y, int refx, int refy)
{
if (!GetWindowCoords((int*)&x,(int*)&y,True))
return;
ShowNewInstance(x,y,refx,refy);
w_SetColor(Parameters.kpLayer);
}
static char *
kbedit(char *s, int x, int y, int bg, int fg, int cc)
/*
* s Initial string to edit.
* x,y Lower left coordinates.
* bg,fg Background and foreground colors.
* cc Background color at cursor location.
* Returns edited string (static!).
*/
{
char tbuf[128];
int k;
char *end, ctmp[2];
doing_edit = True;
editFg = fg;
editCc = cc;
editX = x;
editY = y;
w_SetColor(fg);
*editBuf = '\0';
if (s) {
/* s can be NULL */
w_Text(s, editX, editY, 0);
strcpy(editBuf,s);
}
ctmp[1] = '\0';
editC = editBuf;
end = strchr(editBuf,'\0');
*(end+1) = '\0';
ctmp[0] = *editC;
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp, editX + (int)(editC-editBuf)*FB.fFontWidth, editY, 0);
for (;;) {
k = w_Getchar();
if ((char) k == '\r') break;
switch (k) {
case 333: /* right arrow */
if (editC >= end) continue;
ctmp[0] = *editC;
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC++;
ctmp[0] = *editC;
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case 331: /* left arrow */
if (editC <= editBuf) continue;
ctmp[0] = *editC;
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
ctmp[0] = *editC;
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case '\b':
if (editC == editBuf) continue;
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
editC--;
w_Text(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
w_SetColor(fg);
*editC = '\0';
strcat(editBuf,++editC);
w_Text(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
if (end > editBuf) end--;
ctmp[0] = *editC;
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case 339: /* DEL, in DOS */
case 127:
if (editC == end) continue;
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_Text(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
w_SetColor(fg);
*editC = '\0';
strcat(editBuf,++editC);
w_Text(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
editC--;
if (end > editBuf) end--;
ctmp[0] = *editC;
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
continue;
case '\025': /* ^U */
case '\030': /* ^X */
case '\033': /* ESC */
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_Text(editBuf,editX,editY,0);
editC = end = editBuf;
*editC = '\0';
if ((char) k == '\033') {
doing_edit = False;
return (NULL);
}
w_SetColor(cc);
textcursor(editX,editY);
w_SetColor(fg);
continue;
default:
if (k > 255) continue;
if (((char) k < ' ') || ((char) k > '~')) continue;
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_Text(editC,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
strcpy(tbuf,editC);
*editC = (char) k;
sprintf(++editC,tbuf);
ctmp[0] = *editC;
w_SetColor(fg);
w_Text(editC-1,
editX+(int)(editC-1-editBuf)*FB.fFontWidth,editY,0);
w_SetColor(cc);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
end++;
*(end+1) = '\0';
}
}
w_SetColor(bg);
textcursor(editX+(int)(editC-editBuf)*FB.fFontWidth,editY);
w_SetColor(fg);
ctmp[0] = *editC;
w_Text(ctmp,editX + (int)(editC-editBuf)*FB.fFontWidth,editY,0);
doing_edit = False;
return (editBuf);
}
static void
textcursor(int x, int y)
{
w_Box(x,y-1,x+FB.fFontWidth,y+CURHT);
}
static int
textwidth(char *t, int len)
{
SIZE sz;
if (!t) {
t = "x";
len = 1;
}
else if (len < 0)
len = strlen(t);
else if (len == 0)
return (0);
GetTextExtentPoint32(w_dc, t, len, &sz);
return (sz.cx);
}
static int
w_Getchar(void)
{
int x, y, key, button;
int fs_save = w_fs_cursor;
w_SetFullScreenCursor(False);
for (;;) {
w_Point(&x, &y, &key, &button);
if (button == -1) {
w_SetFullScreenCursor(fs_save);
break;
}
}
return (key);
}
#endif
kic-2.4c/src/convert/ 0000755 0000764 0000764 00000000000 12427446157 014177 5 ustar stevew stevew kic-2.4c/src/convert/convert1.c 0000644 0000764 0000764 00000105137 12427260553 016105 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/* This converts all structure names and references to lower case */
#include "prefix.h"
#include "kic.h"
#include "stream.h"
#include
#include
/* Define to 1 to convert GDS symbol names to lower case. This was true in
* previous versions of Kic.
*/
#define TOLWR 0
#define LONGSCALE(n) (int)(floor(ScaleFactor * ((double)(n)) + 0.5))
static int ByteSwap;
static int CurrentLayer;
static int CurrentAttribute;
static int CurrentDataType;
static int NumSymbols;
static int CurrentSize;
/* static int NumArefs; */
static int CurrentOffset;
static int *XYbuf;
static FILE *SymDesc;
static char **SymbolNames;
static char CurrentSymbol[45];
static double ScaleFactor;
static FILE *StreamFile;
static jmp_buf jbuf;
extern char *MenuFRGDS;
struct headerlist {
int hd_RecordType;
char *hd_Text;
char *hd_Comment;
struct headerlist *hd_Succ;
};
typedef struct headerlist HEADLIST;
#if __STDC__
static HEADLIST* newhead(HEADLIST**,int);
static void symdef(char*,HEADLIST*,int*);
static void s_bndry(char*);
static void s_path(char*);
static void s_sref(char*);
static void s_aref(char*);
static void s_text(char*);
static int get_record(char*);
static int struct_index(char*);
static void print_layer(int,int);
static FILE *open_symbol(char*);
static void new_symbol(char*);
static void set_property_value(char*,int);
static void set_xy(char*,int*,int);
static void path_to_rect(int*);
static void set_path(char*,int,int*);
static void set_instance(int,int,int,int,double,double);
static void set_array(int,int,int,int,double,int*,double);
static int set_angle(double,int*,int*);
static void err_fatal_1(char*,char*);
static void err_fatal_2(char*,int);
static void err_warn_1(char*,char*,char*);
static void err_warn_2(char*,int,char*);
static int strm_ival(char*);
static int strm_longval(char*);
static double strm_doubleval(char*);
static char *alias(char*);
static void dumpalias(void);
#else
static HEADLIST* newhead();
static void symdef();
static void s_bndry();
static void s_path();
static void s_sref();
static void s_aref();
static void s_text();
static int get_record();
static int struct_index();
static void print_layer();
static FILE *open_symbol();
static void new_symbol();
static void set_property_value();
static void set_xy();
static void path_to_rect();
static void set_path();
static void set_instance();
static void set_array();
static int set_angle();
static void err_fatal_1();
static void err_fatal_2();
static void err_warn_1();
static void err_warn_2();
static int strm_ival();
static int strm_longval();
static double strm_doubleval();
static char *alias();
static void dumpalias();
#endif
void
FromGDSII()
{
HEADLIST *HeaderCopy;
HEADLIST *SymbolProps;
int i;
int type;
int struct_dates[12];
char *cp;
char cbuf[MAXRECSIZE + 4];
MenuSelect(MenuFRGDS);
ShowPrompt("Stream file name? ");
cp = FBEdit(NULL);
if (cp == NULL || *cp == '\0' || *cp == '\n') {
MenuDeselect(MenuFRGDS);
return;
}
SymbolNames = (char **) tmalloc(MAXSYMBOLS*sizeof(char *));
XYbuf = (int *) tmalloc(MAXSTRMCOORDS*sizeof(int));
readalias();
SymbolProps = NULL;
NumSymbols = 0;
StreamFile = fopen(cp,"rb");
if (StreamFile == NULL) {
sprintf(TypeOut,"Can't open stream file %s.",cp);
ShowPrompt(TypeOut);
goto quit;
}
/* byte swap test */
ByteSwap = False;
if ((i = getc(StreamFile)) != 0)
ByteSwap = True;
ungetc(i,StreamFile);
if (setjmp(jbuf) == 1) {
sprintf(TypeOut,"Translation failed.");
OutPrompt(TypeOut);
goto quit;
}
/* build the symbol table */
sprintf(TypeOut,"Building symbol table.");
OutPrompt(TypeOut);
while ((type = get_record(cbuf)) != 4)
if (type == 6) {
if (TOLWR)
to_lower_case(cbuf);
new_symbol(cbuf);
}
rewind(StreamFile);
while ((type = get_record(cbuf))!= ENDLIB) {
switch(type) {
case HEADER:
HeaderCopy = newhead(&SymbolProps,HEADER);
sprintf(TypeOut,"%d",strm_ival(cbuf));
HeaderCopy->hd_Text = CopyString(TypeOut);
sprintf(TypeOut,"( VERSION %d )",strm_ival(cbuf));
HeaderCopy->hd_Comment = CopyString(TypeOut);
break;
case BGNLIB:
break;
case LIBNAME:
HeaderCopy = newhead(&SymbolProps,LIBNAME);
HeaderCopy->hd_Text = CopyString(cbuf);
sprintf(TypeOut,"( LIBNAME %s )",cbuf);
HeaderCopy->hd_Comment = CopyString(TypeOut);
break;
case UNITS:
ScaleFactor = (1e8 * strm_doubleval(cbuf+8));
break;
case BGNSTR:
for (i = 0; i < 12; i++)
struct_dates[i] = strm_ival(cbuf + (i << 1));
break;
case STRNAME:
symdef(cbuf,SymbolProps,struct_dates);
fprintf(SymDesc,"DF;\n");
fprintf(SymDesc,"E\n");
fclose(SymDesc);
break;
case REFLIBS:
HeaderCopy = newhead(&SymbolProps,REFLIBS);
sprintf(TypeOut,"%s %s",cbuf,cbuf+44);
HeaderCopy->hd_Text = CopyString(TypeOut);
HeaderCopy->hd_Comment = CopyString("( REFLIBS )");
break;
case FONTS:
HeaderCopy = newhead(&SymbolProps,FONTS);
sprintf(TypeOut,"%s %s %s %s",cbuf,cbuf+44,cbuf+88,cbuf+132);
HeaderCopy->hd_Text = CopyString(TypeOut);
HeaderCopy->hd_Comment = CopyString("( FONTS )");
break;
case GENERATIONS:
HeaderCopy = newhead(&SymbolProps,GENERATIONS);
sprintf(TypeOut,"%d",strm_ival(cbuf));
HeaderCopy->hd_Text = CopyString(TypeOut);
sprintf(TypeOut,"( GENERATIONS %d )",strm_ival(cbuf));
HeaderCopy->hd_Comment = CopyString(TypeOut);
break;
case ATTRTABLE:
HeaderCopy = newhead(&SymbolProps,ATTRTABLE);
HeaderCopy->hd_Text = CopyString(cbuf);
sprintf(TypeOut,"( ATTRIBUTE TABLE %s )",cbuf);
HeaderCopy->hd_Comment = CopyString(TypeOut);
break;
default:
/*
err_fatal_2("Illegal record type",type);
*/
sprintf(TypeOut,"Warning: unknown record type %d",type);
OutPrompt(TypeOut);
}
}
quit:
dumpalias();
for (HeaderCopy = SymbolProps; HeaderCopy; HeaderCopy = SymbolProps) {
SymbolProps = HeaderCopy->hd_Succ;
free(HeaderCopy->hd_Text);
if (HeaderCopy->hd_Comment)
free(HeaderCopy->hd_Comment);
free(HeaderCopy);
}
for (i = 0; i < NumSymbols; i++)
free(SymbolNames[i]);
free(SymbolNames);
free(XYbuf);
sprintf(TypeOut,"Translation complete.");
OutPrompt(TypeOut);
MenuDeselect(MenuFRGDS);
}
static HEADLIST *
newhead(sprops,which)
HEADLIST **sprops;
int which;
{
HEADLIST *Hc,*Hn;
Hc = (HEADLIST *) tmalloc(sizeof(HEADLIST));
Hc->hd_RecordType = PROPERTYOFFSET + which;
Hc->hd_Succ = NULL;
if (*sprops == NULL) *sprops = Hc;
else {
for (Hn = *sprops; Hn->hd_Succ; Hn = Hn->hd_Succ) ;
Hn->hd_Succ = Hc;
}
return (Hc);
}
static void
symdef(cbuf,sprops,struct_dates)
char *cbuf;
HEADLIST *sprops;
int *struct_dates;
{
/*
* BEGIN SYMBOL DEFINITION
*/
int i;
int index;
int type;
char *c;
if (TOLWR)
to_lower_case(cbuf);
CurrentLayer = CurrentDataType = CurrentAttribute = -1;
/* search for symbol number */
index = struct_index(cbuf);
strcpy(CurrentSymbol,cbuf);
SymDesc = open_symbol(c = alias(cbuf));
if (!strcmp(c,cbuf))
sprintf(TypeOut,"Converting: %s",cbuf);
else
sprintf(TypeOut,"Converting: %-30s(new name: %s)",cbuf,c);
OutPrompt(TypeOut);
/* add the symbol property list */
for ( ; sprops != NULL; sprops = sprops->hd_Succ) {
if (sprops->hd_Comment)
fprintf(SymDesc,"%s;\n",sprops->hd_Comment);
fprintf(SymDesc,"5 %d %s;\n",sprops->hd_RecordType,sprops->hd_Text);
}
fprintf(SymDesc,"( CREATION DATE ");
for (i = 0; i < 6; i++)
fprintf(SymDesc,"%d ",struct_dates[i]);
fprintf(SymDesc,": MOD DATE ");
for (i = 0; i < 6; i++)
fprintf(SymDesc,"%d ",struct_dates[i+6]);
fprintf(SymDesc,");\n");
fprintf(SymDesc,"( Symbol %s );\n",c);
fprintf(SymDesc,"9 %s;\n",c);
fprintf(SymDesc,"DS %d 1 1;\n",index);
while ((type = get_record(cbuf)) != ENDSTR) {
switch(type) {
case BOUNDARY:
s_bndry(cbuf);
break;
case PATH:
s_path(cbuf);
break;
case SREF:
s_sref(cbuf);
break;
case AREF:
s_aref(cbuf);
break;
case TEXT:
s_text(cbuf);
break;
case SNAPNODE:
/*
* snapnodes are not used
*/
while ((type = get_record(cbuf)) != 17) ;
break;
default:
err_fatal_2("Illegal record type",type);
}
}
}
static void
s_bndry(cbuf)
char *cbuf;
{
int i;
int type;
int ncoords = 0;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case DATATYPE:
dtype = strm_ival(cbuf);
break;
case XY:
ncoords = CurrentSize/4;
for (i = 0; i < ncoords; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
ncoords /= 2;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
print_layer(layer,dtype);
set_xy(cbuf,XYbuf,ncoords);
}
static void
s_path(cbuf)
char *cbuf;
{
int pathwidth = 0;
int ptype = 0;
int i;
int type;
int ncoords = 0;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case DATATYPE:
dtype = strm_ival(cbuf);
break;
case WIDTH:
pathwidth = LONGSCALE( strm_longval(cbuf) );
break;
case XY:
ncoords = CurrentSize/4;
for (i = 0; i < ncoords; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
ncoords /= 2;
break;
case PATHTYPE:
/*
* STREAM pathtypes
* 0 = square ended paths with ends that are flush
* with the endpoints
* 1 = round ended (CIF like) paths
* 2 = square ended paths with ends that are
* offset from the endpoint by a half width.
*
* In KIC, we assume a pathtype of 2.
*/
if ((ptype = strm_ival(cbuf)) != 2)
fprintf(SymDesc,"( PATHTYPE %d CONVERTED TO PATHTYPE 2 );\n",ptype);
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
CurrentAttribute = -1;
break;
default:
err_fatal_2("Illegal record type",type);
}
}
print_layer(layer,dtype);
if (ptype == 0 && ncoords > 1) {
/*
* subtract a half width from the endpoints.
*/
ConvertPathtype(&XYbuf[0],&XYbuf[1],XYbuf[2],XYbuf[3],pathwidth,0);
i = ncoords+ncoords-2;
ConvertPathtype(&XYbuf[i],&XYbuf[i+1],XYbuf[i-2],XYbuf[i-1],pathwidth,0);
}
if (ptype != 2)
fprintf(SymDesc,"5 %d PATHTYPE %d;\n",PROPERTYOFFSET + PATHTYPE,ptype);
sprintf(cbuf,"W %d",pathwidth);
set_path(cbuf,ncoords,XYbuf);
}
static void
s_sref(cbuf)
char *cbuf;
{
double magn = 1,rotn = 0;
int cx = 0,cy = 0;
int reflection = 0;
int index = 0;
int type;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case XY:
cx = LONGSCALE( strm_longval(cbuf) );
cy = LONGSCALE( strm_longval(cbuf+4) );
break;
case SNAME:
if (TOLWR)
to_lower_case(cbuf);
index = struct_index(cbuf);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf)/RADTODEG;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
set_instance(index,reflection,cx,cy,rotn,magn);
#ifdef notdef
else {
err_warn_1("Magnification not unity",
SymbolNames[index],CurrentSymbol);
lone = (int)(100.0 * magn);
/*
* If magn is less than .01, then KIC does not
* have the resolution.
*/
if (lone > 0) {
j = 100;
while ( !(lone % 10) ) {
j /= 10;
lone /= 10;
}
++NumArefs;
new_symbol("AREF ");
sprintf(SymbolNames[NumSymbols-1]+4,"%d",NumArefs);
afile = open_symbol(SymbolNames[NumSymbols-1]);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-1]);
fprintf(afile,"DS %d %ld %d;\n",NumSymbols,lone,j);
fprintf(afile,"9 %s;\n",SymbolNames[index]);
fprintf(afile,"C %d;\n",index);
fprintf(afile,"DF;\n");
fprintf(afile,"E\n");
fclose(afile);
set_instance(NumSymbols,reflection,cx,cy,rotn);
}
else
err_warn_1("Magnification too small",SymbolNames[index],
CurrentSymbol);
}
#endif
}
static void
s_aref(cbuf)
char *cbuf;
{
double magn = 1,rotn = 0;
int reflection = 0;
int nx = 0,ny = 0;
int i;
int index = 0;
int type;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case XY:
for (i = 0; i < 6; ++i)
XYbuf[i] = LONGSCALE( strm_longval(cbuf + (i << 2)) );
break;
case SNAME:
if (TOLWR)
to_lower_case(cbuf);
index = struct_index(cbuf);
break;
case COLROW:
nx = strm_ival(cbuf);
ny = strm_ival(cbuf+2);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf)/RADTODEG;
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
set_array(index,reflection,nx,ny,rotn,XYbuf,magn);
#ifdef notdef
else {
err_warn_1("Magnification not unity",
SymbolNames[index],CurrentSymbol);
lone = (int)(100.0 * magn);
/*
* If magn is less than .01, then KIC does not
* have the resolution.
*/
if (lone > 0) {
j = 100;
while ( !(lone % 10) ) {
j /= 10;
lone /= 10;
}
++NumArefs;
new_symbol("AREF ");
sprintf(SymbolNames[NumSymbols-1]+4,"%d",NumArefs);
afile = open_symbol(SymbolNames[NumSymbols-1]);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-1]);
fprintf(afile,"DS %d %ld %d;\n",NumSymbols,lone,j);
fprintf(afile,"9 %s;\n",SymbolNames[NumSymbols-2]);
fprintf(afile,"C %d;\n",index);
fprintf(afile,"DF;\n");
fprintf(afile,"E\n");
fclose(afile);
set_array(NumSymbols,reflection,nx,ny,rotn,XYbuf);
}
else
err_warn_1("Magnification too small",SymbolNames[index],
CurrentSymbol);
}
#endif
}
static void
s_text(cbuf)
char *cbuf;
{
double magn = 1,rotn = 0;
char *cp, string[48];
int cx = 0,cy = 0;
int width = 0;
int ptype = 0;
int reflection = 0;
int present = 0;
int type;
int dtype = CurrentDataType;
int layer = CurrentLayer;
while ((type = get_record(cbuf)) != ENDEL) {
switch(type) {
case LAYER:
layer = strm_ival(cbuf);
break;
case WIDTH:
width = LONGSCALE( strm_longval(cbuf) );
break;
case XY:
cx = LONGSCALE( strm_longval(cbuf) );
cy = LONGSCALE( strm_longval(cbuf+4) );
break;
case TEXTTYPE:
dtype = strm_ival(cbuf);
break;
case PRESENTATION:
present = strm_ival(cbuf);
break;
case STRING:
cp = cbuf;
while (*cp != '\0') {
if (*cp == ' ')
*cp = '_';
cp++;
}
strcpy(string,cbuf);
break;
case STRANS:
if (cbuf[1] & 4)
err_warn_2("Absolute magnification",1,CurrentSymbol);
if (cbuf[1] & 2)
err_warn_2("Absolute angle",1,CurrentSymbol);
if (cbuf[0] & 128)
reflection = 1;
else
reflection = 0;
break;
case MAG:
magn = strm_doubleval(cbuf);
break;
case ANGLE:
rotn = strm_doubleval(cbuf);
break;
case PATHTYPE:
/*
* STREAM pathtypes
* 0 = square ended paths with ends that are flush
* with the endpoints
* 1 = round ended (CIF like) paths
* 2 = square ended paths with ends that are
* offset from the endpoint by a half width.
*
* In KIC, we assume a pathtype of 2.
*/
ptype = strm_ival(cbuf);
break;
case PROPATTR:
CurrentAttribute = strm_ival(cbuf);
break;
case PROPVALUE:
set_property_value(cbuf,type);
break;
default:
err_fatal_2("Illegal record type",type);
}
}
print_layer(layer,dtype);
fprintf(SymDesc,
"5 %d WIDTH %d PRESENT %d PTYPE %d MAG %f ANGLE %f REFLECT %d;\n",
PROPERTYOFFSET + TEXT,width,present,ptype,magn,rotn,reflection);
fprintf(SymDesc,"94 %s %d %d 0;\n",string,cx,cy);
}
static int
get_record(cbuf)
char *cbuf;
{
int i;
int size;
unsigned byte0;
unsigned byte1;
unsigned rtype;
CurrentOffset = ftell(StreamFile);
if (!ByteSwap) {
byte0 = getc(StreamFile);
byte1 = getc(StreamFile);
rtype = getc(StreamFile);
(void) getc(StreamFile);
}
else {
byte1 = getc(StreamFile);
byte0 = getc(StreamFile);
(void) getc(StreamFile);
rtype = getc(StreamFile);
}
size = byte0*256 + byte1 - 4;
if (size < 0) size = 0;
if (size > MAXRECSIZE)
err_fatal_2("Oversized record, size",size);
CurrentSize = size;
size >>= 1;
if (size && fread(cbuf,(size_t)size,(size_t)2,StreamFile) != 2)
err_fatal_1("Read error on input","");
size <<= 1;
if (CurrentSize != size) {
cbuf[size] = getc(StreamFile);
cbuf[size+1] = getc(StreamFile);
}
if (ByteSwap) {
for (i = 0; i < size; i += 2) {
byte0 = cbuf[i];
cbuf[i] = cbuf[i+1];
cbuf[i+1] = byte0;
}
if (CurrentSize != size)
cbuf[size] = cbuf[size+1];
}
if (CurrentSize != size)
ungetc(cbuf[size+1],StreamFile);
cbuf[CurrentSize] = '\0';
return (rtype);
}
static int
struct_index(cbuf)
char *cbuf;
{
int i;
/* the symbol table should be complete at this point */
for (i = 0; i < NumSymbols; i++)
if (!strcmp(SymbolNames[i],alias(cbuf))) return (i);
sprintf(TypeOut,"Warning: Undefined symbol %s.",cbuf);
OutPrompt(TypeOut);
new_symbol(cbuf);
return (NumSymbols-1);
}
static void
print_layer(layer,datatype)
int layer;
int datatype;
{
int l;
char buf[128];
if (layer < 0 || datatype < 0 || layer > 255 || datatype > 255) {
sprintf(buf,"Illegal layer %d datatype",layer);
err_fatal_2(buf,datatype);
}
if (layer == CurrentLayer && datatype == CurrentDataType) return;
for (l = 1; l <= NumLayerTable; l++) {
if (LayerTable[l].klStreamNumber == layer &&
(LayerTable[l].klStreamDataType < 0 ||
LayerTable[l].klStreamDataType == datatype)) {
if (layer == CurrentLayer && LayerTable[l].klStreamDataType < 0)
return;
buf[0] = LayerTable[l].klTechnology;
buf[1] = LayerTable[l].klMask[0];
buf[2] = LayerTable[l].klMask[1];
buf[3] = LayerTable[l].klMask[2];
if (isspace(buf[1])) buf[1] = '\0';
else if (isspace(buf[2])) buf[2] = '\0';
else if (isspace(buf[3])) buf[3] = '\0';
else buf[4] = '\0';
fprintf(SymDesc,"L %s;\n",buf);
break;
}
else if (l == NumLayerTable) {
sprintf(buf,"Undefined layer %d datatype",layer);
err_warn_2(buf,datatype,CurrentSymbol);
fprintf(SymDesc,"L %02d\n",layer);
}
}
CurrentLayer = layer;
CurrentDataType = datatype;
}
static FILE *
open_symbol(name)
char *name;
{
FILE *fp;
if ((fp = fopen(name,"w")) == 0)
err_fatal_1("Can't open symbol",name);
return (fp);
}
static void
new_symbol(name)
char *name;
{
name = alias(name);
if (NumSymbols >= MAXSYMBOLS)
err_fatal_2("Exceeded maximum symbol count of",MAXSYMBOLS);
SymbolNames[NumSymbols] = CopyString(name);
NumSymbols++;
}
static void
set_property_value(string,type)
char *string;
int type;
{
if (CurrentAttribute < 1 || CurrentAttribute > 127) {
err_warn_2("Bad property record",type,CurrentSymbol);
CurrentAttribute = 127;
}
fprintf(SymDesc,"5 %d %s;\n",CurrentAttribute,string);
CurrentAttribute = -1;
}
static void
set_xy(s,xy,n)
/* save it as a box if rectangular, otherwise create a polygon */
char *s;
int *xy;
int n;
{
s[0] = 'P';
s[1] = '\0';
if (n != 5) {
set_path(s,n,xy);
return;
}
if (xy[0] == xy[2] && xy[3] == xy[5] &&
xy[4] == xy[6] && xy[7] == xy[1]) {
path_to_rect(xy);
return;
}
if (xy[1] == xy[3] && xy[2] == xy[4] &&
xy[5] == xy[7] && xy[6] == xy[0]) {
path_to_rect(xy);
return;
}
set_path(s,n,xy);
}
static void
path_to_rect(xy)
int *xy;
{
int cx,cy,length,width;
cx = (xy[0] + xy[4])/2;
cy = (xy[1] + xy[5])/2;
length = xy[4] - xy[0];
width = xy[5] - xy[1];
if (width < 0) width = -width;
if (length < 0) length = -length;
fprintf(SymDesc,"B %d %d %d %d;\n",length,width,cx,cy);
}
static void
set_path(cbuf,ncoords,xy)
char *cbuf;
int ncoords;
int *xy;
{
int i, len, len1;
char buf1[40];
len = strlen(cbuf);
for (i = 0; i < ncoords; ++i) {
sprintf(buf1," %d %d",xy[i+i],xy[i+i+1]);
len1 = strlen(buf1);
if (len+len1 < 79) {
strcat(cbuf,buf1);
len += len1;
}
else {
fprintf(SymDesc,"%s\n ",cbuf);
strcpy(cbuf,buf1);
len = len1+1;
}
}
fprintf(SymDesc,"%s;\n",cbuf);
}
static void
set_instance(index,reflection,cx,cy,rotn,magn)
int index, reflection;
int cx,cy;
double rotn;
double magn;
{
int i, j;
fprintf(SymDesc,"9 %s;\n",SymbolNames[index]);
if (magn != 1.0) {
err_warn_1("Magnification not unity",
SymbolNames[index],CurrentSymbol);
fprintf(SymDesc,"( Scale %g );\n",magn);
}
fprintf(SymDesc,"C %d",index);
if (reflection) fprintf(SymDesc," MY");
if (set_angle(rotn,&i,&j))
fprintf(SymDesc," R %d %d",i,j);
fprintf(SymDesc," T %d %d;\n",cx,cy);
}
static void
set_array(index,reflection,nx,ny,rotn,xy,magn)
int index, reflection;
int nx,ny;
double rotn;
int *xy;
double magn;
{
int i, j, k;
int dx,dy;
fprintf(SymDesc,"9 %s;\n",SymbolNames[index]);
if (magn != 1.0) {
err_warn_1("Magnification not unity",
SymbolNames[index],CurrentSymbol);
fprintf(SymDesc,"( Scale %g );\n",magn);
}
k = set_angle(rotn,&i,&j);
/* xy[0] - xy[5] are coords of 3 points of BB, 0,1 reference */
/* one of two terms is zero */
dx = ((xy[2]-xy[0]) + (xy[3]-xy[1]))/nx;
if (dx < 0) dx = -dx;
dy = ((xy[5]-xy[1]) + (xy[4]-xy[0]))/ny;
if (dy < 0) dy = -dy;
fprintf(SymDesc,"1 Array %d %d %d %d;\n",nx,dx,ny,dy);
fprintf(SymDesc,"C 0");
if (reflection) fprintf(SymDesc," MY");
if (k == 1) /* 90 */
fprintf(SymDesc," R 0 1");
else if (k == 2) /* 180 */
fprintf(SymDesc," R -1 0");
else if (k == 3) /* 270 */
fprintf(SymDesc," R 0 -1");
fprintf(SymDesc," T %d %d;\n",xy[0],xy[1]);
}
static int
set_angle(rotn,i,j)
double rotn;
int *i, *j;
{
int ii, jj;
ii = 100*cos(rotn);
jj = 100*sin(rotn);
if (ii == -99) ii = -100;
else if (ii == 99) ii = 100;
else if (jj == -99) jj = -100;
else if (jj == 99) jj = 100;
*i = ii/100;
*j = jj/100;
if (*i == 1 && *j == 0) /* 0 */
return (0);
if (*i == 0 && *j == 1) /* 90 */
return (1);
if (*i == -1 && *j == 0) /* 180 */
return (2);
if (*i == 0 && *j == -1) /* 270 */
return (3);
err_warn_1("Nonorthogonal rotation","",CurrentSymbol);
fprintf(SymDesc,"( Rotate %g );\n",rotn);
*i = *j = 0;
return (0);
}
static void
err_fatal_1(str,what)
char *str,*what;
{
sprintf(TypeOut,"Error: %s %s at offset %d.",str,what,CurrentOffset);
OutPrompt(TypeOut);
longjmp(jbuf,1);
}
static void
err_fatal_2(str,type)
char *str;
int type;
{
sprintf(TypeOut,"Error: %s %d at offset %d.",str,type,CurrentOffset);
OutPrompt(TypeOut);
longjmp(jbuf,1);
}
static void
err_warn_1(str,which,what)
char *str,*which,*what;
{
sprintf(TypeOut,"Warning: %s for instance %s in symbol %s at offset %d.",
str,which,what,CurrentOffset);
OutPrompt(TypeOut);
}
static void
err_warn_2(str,type,what)
char *str,*what;
int type;
{
sprintf(TypeOut,"Warning: %s %d in symbol %s at offset %d.",
str,type,what,CurrentOffset);
OutPrompt(TypeOut);
}
/***********************************************************************
* Stream number conversion.
***********************************************************************/
/***********************************************************************/
/* function STRM_IVAL */
/* Function to evaluate STREAM short integer. */
/***********************************************************************/
static int
strm_ival(s)
char *s;
{
unsigned int i;
unsigned char *b = (unsigned char *)s;
/* Stream format is big-endian */
i = b[1] | ((b[0] & 0x7f) << 8);
if (b[0] & 0x80)
i |= (-1 << 15);
return ((int)i);
}
/***********************************************************************/
/* function STRM_LONGVAL */
/* Function to evaluate STREAM long integer. */
/***********************************************************************/
static int
strm_longval(s)
char *s;
{
unsigned int i;
unsigned char *b = (unsigned char *)s;
/* Stream format is big-endian */
i = b[3] | (b[2] << 8) | (b[1] << 16) | ((b[0] & 0x7f) << 24);
if (b[0] & 0x80)
i |= (-1 << 31);
return ((int)i);
}
/*
* function STRM_DOUBLEVAL
* Function to convert from STREAM to VAX double precision.
* The argument is a integer buffer containing the eight bytes
* of the STREAM double precision field. The first character in
* the buffer contains the exponent, the second contains the most
* significant byte of the mantissa, etc.
*
* CALMA's double precision field:
*
* Mantissa is base 16 (1/16 <= mantissa < 1). Exponent is excess-64.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFFEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
* where E = exponent field
* S = sign bit
* F = fraction field
* FL = least sig. bit of word or byte
* FM = most sig. bit of word or byte
*/
/*
* This function is really inefficient, but there are typically few
* conversions required, and protability is an issue.
*/
static double
strm_doubleval(s)
char *s;
{
int exp, sign, i;
double d, mantissa;
unsigned char *b = (unsigned char*)s;
sign = 0;
exp = s[0];
/* test the sign bit */
if (exp & 0x80) {
sign = 1;
exp &= 0x7f;
}
exp -= 64;
/* Construct the mantissa */
mantissa = 0.0;
for (i = 7; i > 0; i--) {
mantissa += b[i];
mantissa /= 256.0;
}
/* Now raise the mantissa to the exponent */
d = mantissa;
if (exp > 0) {
while (exp-- > 0)
d *= 16.0;
}
else if (exp < 0) {
while (exp++ < 0)
d /= 16.0;
}
/* Make it negative if necessary */
if (sign)
d = -d;
return (d);
}
/************************************************************************
* Map the symbol names into a DOS compatible file name, i.e., 8
* characters. The first 6 are mapped directly, last 2 are index digits.
************************************************************************/
#ifdef MSDOS
static struct aliastab *aliasbase;
static char *
alias(strname)
char *strname;
{
char dosname[10], *ext;
char *valid = "_^$~!#%&-{}()@'`.";
struct aliastab *wl;
int i;
char *index();
for (ext = strname; *ext; ext++) {
if (isalpha(*ext) || isdigit(*ext) || index(valid,*ext))
continue;
break;
}
if (!*ext) {
if (strlen(strname) <= 8)
return (strname);
ext = index(strname,'.');
if (ext && ((int)(ext - strname) <= 8) && strlen(ext) <= 3)
return (strname);
strncpy(dosname,strname,6);
}
else {
strncpy(dosname,strname,6);
for (i = ext - strname; i < 6; i++) {
ext = dosname + i;
if (isalpha(*ext) || isdigit(*ext) || index(valid,*ext))
continue;
dosname[i] = '_';
}
}
dosname[6] = '\0';
for (i = 0,wl = aliasbase; wl; wl = wl->next) {
if (!strcmp(strname,wl->strname)) return (wl->dosname);
if (!strncmp(dosname,wl->dosname,6)) i++;
if (!wl->next) {
wl->next = alloc(aliastab);
wl = wl->next;
strcpy(wl->strname,strname);
strncpy(wl->dosname,dosname,7);
wl->next = NULL;
wl->dosname[6] = '0' + i/10;
wl->dosname[7] = '0' + i%10;
wl->dosname[8] = '\0';
return (wl->dosname);
}
}
wl = alloc(aliastab);
aliasbase = wl;
strcpy(wl->strname,strname);
strncpy(wl->dosname,dosname,7);
wl->next = NULL;
wl->dosname[6] = '0' + i/10;
wl->dosname[7] = '0' + i%10;
wl->dosname[8] = '\0';
return (wl->dosname);
}
static void
dumpalias()
{
FILE *fp;
struct aliastab *wl,*wn;
if (aliasbase == NULL) return;
fp = fopen(ALIASFILE,"w");
if (fp == NULL) return;
for (wl = aliasbase; wl; wl = wn) {
wn = wl->next;
fprintf(fp,"%-10s%s\n",wl->dosname,wl->strname);
afree(wl,aliastab);
}
fclose(fp);
aliasbase = NULL;
}
void
readalias()
{
FILE *fp;
char s[80], *c;
struct aliastab *wl;
if ((fp = fopen(ALIASFILE,"r")) == NULL) return;
while (fgets(s,80,fp) != NULL) {
if (!aliasbase) {
aliasbase = alloc(aliastab);
wl = aliasbase;
}
else {
wl->next = alloc(aliastab);
wl = wl->next;
}
for (c = s; isspace(*c); c++) ;
if (*c == '\0') break;
if (sscanf(s,"%s %s",wl->dosname,wl->strname) != 2) {
aliasbase = NULL;
fclose(fp);
return;
}
}
wl->next = NULL;
fclose(fp);
}
#else
/* assume UNIX, strip any bad characters */
static char *
alias(strname)
char *strname;
{
char *s;
for (s = strname; *s; s++) {
if (*s == '/')
*s = '_';
}
return (strname);
}
void
readalias() {}
static void
dumpalias() {}
#endif
kic-2.4c/src/convert/convert.c 0000644 0000764 0000764 00000152477 12427255640 016036 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#include "stream.h"
/* Define to 1 if GDS symbol and lib names are to be converted to
* upper case. This was true in the previous versions of Kic.
*/
#define TOUPR 0
extern char *MenuHELP;
extern char *MenuCNVRT;
char *MenuTOGDS = "togds";
char *MenuTOCIF = "tocif";
char *MenuFRGDS = "frgds";
char *MenuFRCIF = "frcif";
static FILE *logfp;
#define Matching(string) (!strcmp(string,Parameters.kpCommand))
#define GDS_SUFFIX ".gds"
#if __STDC__
static int clobber_check(int);
static int gen_stream(char*,struct s*,int*);
static int gen_stream_call(char*,struct s*);
static int gen_stream_struc(struct s*);
static void finish_path(int);
static void out_poly(struct p*,Poly*);
static void break_poly(Poly*);
static void reset_info(struct s*);
static char *unalias(char*);
static void freealias(void);
static void strm_beginrecord(int,int,int);
static void strm_addate(struct tm*);
static void strm_entrasc_rec(char*,int,int);
static void strm_entrasc(char*,int);
static int bgnlib(STRM_LIBRARY*);
static int endlib(void);
static int bgnstr(STRM_STRCT*);
static int endstr(void);
static int strm_endlmnt(STRM_PROPERTY*);
static int bndry(STRM_BOUNDARY*);
static int strm_strnsfm(STRM_TRANSFORM*);
static int path(STRM_PATH*);
static int sref(STRM_SREF*);
static int aref(STRM_AREF*);
static int text(STRM_TEXT*);
static void strm_intcopy(int);
static void strm_lngcopy(int);
static void strm_dblcopy(double);
static char get_cif_file_type(FILE*);
#else
static int clobber_check();
static int gen_stream();
static int gen_stream_call();
static int gen_stream_struc();
static void finish_path();
static void out_poly();
static void break_poly();
static void reset_info();
static char *unalias();
static void freealias();
static void strm_beginrecord();
static void strm_addate();
static void strm_entrasc_rec();
static void strm_entrasc();
static int bgnlib();
static int endlib();
static int bgnstr();
static int endstr();
static int strm_endlmnt();
static int bndry();
static int strm_strnsfm();
static int path();
static int sref();
static int aref();
static int text();
static void strm_intcopy();
static void strm_lngcopy();
static void strm_dblcopy();
static char get_cif_file_type();
#endif
void
Convert()
{
int dummy;
char OldMenu;
char *logfile = "convert.log";
OldMenu = Parameters.kpMenu;
Parameters.kpMenu = AMBIGUITYMENU;
AmbiguityMenu[0].mEntry = MenuHELP;
AmbiguityMenu[1].mEntry = MenuTOGDS;
AmbiguityMenu[2].mEntry = MenuTOCIF;
AmbiguityMenu[3].mEntry = MenuFRGDS;
AmbiguityMenu[4].mEntry = MenuFRCIF;
AmbiguityMenu[5].mEntry = NULL;
FixMenuPrefix(AmbiguityMenu);
ShowMenu(AmbiguityMenu);
loop {
switch (PointLoopSafe(&dummy)) {
case PL_ESC:
break;
case PL_PCW:
continue;
case PL_CMD:
if (Matching(MenuHELP)) {
Help();
continue;
}
if (Matching(MenuTOGDS)) {
logfp = fopen(logfile,"w");
ToGDSII();
if (logfp) fclose(logfp);
break;
}
if (Matching(MenuFRGDS)) {
if (clobber_check(True)) break;
logfp = fopen(logfile,"w");
FromGDSII();
if (logfp) fclose(logfp);
break;
}
if (Matching(MenuTOCIF)) {
logfp = fopen(logfile,"w");
ToCIF();
if (logfp) fclose(logfp);
break;
}
if (Matching(MenuFRCIF)) {
if (clobber_check(True)) break;
logfp = fopen(logfile,"w");
FromCIF();
if (logfp) fclose(logfp);
break;
}
continue;
}
break;
}
Parameters.kpMenu = OldMenu;
ShowCommandMenu();
}
void
OutPrompt(s)
char *s;
{
char c;
if (logfp) (void)fprintf(logfp,"%s\n",s);
if (strlen(s) > FB.fNumColumns - 8) {
/* avoid "MORE" prompt */
c = s[FB.fNumColumns - 8];
s[FB.fNumColumns - 8] = '\0';
ShowPrompt(s);
s[FB.fNumColumns - 8] = c;
}
else
ShowPrompt(s);
}
static int
clobber_check(dospeak)
int dospeak;
{
char *TypeIn;
ShowPrompt(
"Warning, conversion may overwrite file(s). OK to continue? (n)");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL) {
if (*TypeIn == 'y' || *TypeIn == 'Y')
return (False);
}
if (dospeak)
ShowPrompt(
"Move to a clear directory before performing conversion.");
return (True);
}
/*************************************************************************
*
* GDSII conversion (also see convert1.c).
*
*************************************************************************/
#define DATA_TYPE(a) (((a)<0||(a)>255)?0:(a))
/*
#define LONGSCALE(n) (int) (floor( (ScaleFactor * (double)(n)) + 0.5))
*/
#define LONGSCALE(n) (n)
static STRM_LIBRARY *STRMLibrary;
static STRM_STRCT *STRMStructure;
static STRM_BOUNDARY *STRMBoundary;
static STRM_PATH *STRMPath;
static STRM_TEXT *STRMText;
static STRM_SREF *STRMSref;
static STRM_AREF *STRMAref;
static STRM_TRANSFORM *DefaultTransform;
static STRM_PROPERTY *DefaultProperty;
static int StrmNoGo;
static FILE *StreamFile;
void
ToGDSII()
{
struct tm Now, *localtime();
struct prpty *PDesc;
time_t tloc;
int SymbolNum = 0;
char StreamFileName[81];
char *s;
MenuSelect(MenuTOGDS);
STRMLibrary = (STRM_LIBRARY *)tmalloc(sizeof(STRM_LIBRARY));
STRMStructure = (STRM_STRCT *)tmalloc(sizeof(STRM_STRCT));
STRMBoundary = (STRM_BOUNDARY *)tmalloc(sizeof(STRM_BOUNDARY));
STRMPath = (STRM_PATH *)tmalloc(sizeof(STRM_PATH));
STRMText = (STRM_TEXT *)tmalloc(sizeof(STRM_TEXT));
STRMSref = (STRM_SREF *)tmalloc(sizeof(STRM_SREF));
STRMAref = (STRM_AREF *)tmalloc(sizeof(STRM_AREF));
DefaultTransform = (STRM_TRANSFORM *)tmalloc(sizeof(STRM_TRANSFORM));
DefaultProperty = (STRM_PROPERTY *)tmalloc(sizeof(STRM_PROPERTY));
/* initialize */
tloc = time(NULL);
Now = *localtime(&tloc);
Now.tm_mon++;
StrmNoGo = False;
STRMLibrary->lib_name[0] = '\0';
STRMLibrary->lib_lib1[0] = '\0';
STRMLibrary->lib_lib2[0] = '\0';
STRMLibrary->lib_font0[0] = '\0';
STRMLibrary->lib_font1[0] = '\0';
STRMLibrary->lib_font2[0] = '\0';
STRMLibrary->lib_font3[0] = '\0';
STRMLibrary->lib_attr[0] = '\0';
STRMLibrary->lib_accessdate = Now;
STRMLibrary->lib_moddate = Now;
STRMLibrary->lib_uunit = .01;
STRMLibrary->lib_munit = 1e-8;
STRMLibrary->lib_gen = 3;
STRMStructure->str_moddate = Now;
STRMStructure->str_creatdate = Now;
DefaultTransform->trns_reflection = 0;
DefaultTransform->trns_abs_mag = 0;
DefaultTransform->trns_abs_angle = 0;
DefaultTransform->trns_mag = 1.0;
DefaultTransform->trns_angle = 0.0;
DefaultProperty->prp_npropval = 0;
ShowPrompt("Stream file name? ");
strcpy(StreamFileName,Parameters.kpCellName);
if ((s = strchr(StreamFileName,'.')) != NULL) *s = '\0';
strcat(StreamFileName, GDS_SUFFIX);
s = FBEdit(StreamFileName);
if (s == NULL) goto quit;
if (*s != '\0' && *s != '\n')
strcpy(StreamFileName,s);
strcpy(STRMLibrary->lib_name,"KICTOSTREAM");
if (!access(StreamFileName,0))
if (clobber_check(False))
return;
StreamFile = POpen(StreamFileName,"wb",(char *)NULL,(char **)NULL);
if (StreamFile == NULL) {
ShowPrompt("Can't open STREAM file.");
goto quit;
}
readalias();
/* add STREAM-specific property list info */
/*
* We use the property list of KIC symbols to save the library information;
* The value of the property is the numeric value of the STREAM record
* type offset by 7000 (e.g. 7000 is the KIC property value describing the
* STREAM version number, 7002 is the KIC property value describing the
* STREAM library name, etc.) The offset of 7000 was arbitrarily selected,
* and care must be taken so that this value does not conflict with any
* other convention. The PROPERTYOFFSET define is for convenience.
*/
for (PDesc = Parameters.kpCellDesc->sPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
switch (PDesc->prpty_Value - PROPERTYOFFSET) {
case HEADER:
/* version 3 is assumed */
break;
case LIBNAME:
sscanf(PDesc->prpty_String,"%s",STRMLibrary->lib_name);
break;
case REFLIBS:
sscanf(PDesc->prpty_String,"%s %s",STRMLibrary->lib_lib1,
STRMLibrary->lib_lib2);
break;
case FONTS:
sscanf(PDesc->prpty_String,"%s %s %s %s",
STRMLibrary->lib_font0,STRMLibrary->lib_font1,
STRMLibrary->lib_font2,STRMLibrary->lib_font3);
break;
case GENERATIONS:
sscanf(PDesc->prpty_String,"%d",&STRMLibrary->lib_gen);
break;
case ATTRTABLE:
sscanf(PDesc->prpty_String,"%s",STRMLibrary->lib_attr);
break;
}
}
bgnlib(STRMLibrary);
SymbolNum = 1;
if (!gen_stream(Parameters.kpCellName,Parameters.kpCellDesc,&SymbolNum)) {
ShowPrompt("Unable to write stream file. MORE");
(void) FBGetchar(ERASE);
ShowPrompt(CDStatusString);
fclose(StreamFile);
goto quit;
}
endlib();
fclose(StreamFile);
if (StrmNoGo) {
sprintf(TypeOut,"Translation of %s failed.",Parameters.kpCellName);
unlink(StreamFileName);
}
else
sprintf(TypeOut,"Translation of %s succeeded.",Parameters.kpCellName);
OutPrompt(TypeOut);
quit:
freealias();
reset_info(Parameters.kpCellDesc);
free(STRMLibrary);
free(STRMStructure);
free(STRMBoundary);
free(STRMPath);
free(STRMText);
free(STRMSref);
free(STRMAref);
free(DefaultTransform);
free(DefaultProperty);
MenuDeselect(MenuTOGDS);
}
static int
gen_stream(MasterName,SymbolDesc,SymbolNum)
char *MasterName;
struct s *SymbolDesc;
int *SymbolNum;
{
struct g *GenDesc;
struct o *Pointer;
struct s *MasterDesc;
char *SymbolName;
sprintf(TypeOut,"Converting: %s",MasterName);
OutPrompt(TypeOut);
(*SymbolNum)++;
/*
* Mark symbol associated with SymbolDesc as visited by storing
* its symbol # in its info field.
*/
SymbolDesc->sInfo = *SymbolNum;
/*
* First write to the stream file any symbol definitions below
* the symbol associated with SymbolDesc.
*/
if (!CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return CDError(CDMALLOCFAILED);
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
SymbolName = ((struct c *)Pointer->oRep)->cMaster->mName;
if (Not CDOpen(SymbolName,&MasterDesc,'w'))
return False;
if (MasterDesc->sInfo == 0) {
/* Write master's definition to stream file. */
if (!gen_stream(SymbolName,MasterDesc,SymbolNum))
return False;
}
}
if (!gen_stream_call(MasterName,SymbolDesc))
return False;
if (!gen_stream_struc(SymbolDesc))
return False;
return True;
}
static int
gen_stream_call(MasterName,SymbolDesc)
char *MasterName;
struct s *SymbolDesc;
{
struct g *GenDesc;
struct o *Pointer;
struct t *TGen;
struct s *MasterDesc;
struct prpty *PDesc;
int X,Y;
int DX,DY;
int NumX,NumY;
int i;
char Type;
char *SymbolName;
double a,b;
strcpy(STRMStructure->str_name,unalias(MasterName));
bgnstr(STRMStructure);
if (!CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return CDError(CDMALLOCFAILED);
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
if (!CDOpen(SymbolName,&MasterDesc,'w'))
return False;
if (NumX > 1 || NumY > 1) {
/* create an AREF */
strcpy(STRMAref->ar_name,unalias(SymbolName));
STRMAref->ar_transform = *DefaultTransform;
STRMAref->ar_col = NumX;
STRMAref->ar_row = NumY;
STRMAref->ar_xy[0] = 0;
STRMAref->ar_xy[1] = 0;
/* copy the property list */
for (PDesc = Pointer->oPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
/* allow only valid STREAM property attributes */
i = PDesc->prpty_Value;
if (i > 0 && i < 128) {
STRMAref->ar_prop.prp_propattr
[STRMAref->ar_prop.prp_npropval] = i;
STRMAref->ar_prop.prp_propval
[STRMAref->ar_prop.prp_npropval] =
CopyString(PDesc->prpty_String);
++STRMAref->ar_prop.prp_npropval;
if (STRMAref->ar_prop.prp_npropval >= 255) break;
}
}
STRMAref->ar_transform.trns_angle = 0;
STRMAref->ar_transform.trns_reflection = 0;
CDInitTGen(Pointer,&TGen);
TPush();
TIdentity();
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) break;
elif (Type == CDROTATE) {
a = (double) X;
b = (double) Y;
STRMAref->ar_transform.trns_angle +=
(RADTODEG * atan2(b,a));
TRotate(X,Y);
}
elif (Type == CDTRANSLATE) {
TTranslate(X,Y);
}
elif (Type == CDMIRRORX) {
STRMAref->ar_transform.trns_reflection ^= 1;
STRMAref->ar_transform.trns_angle += 180.0;
TMX();
}
elif (Type == CDMIRRORY) {
STRMAref->ar_transform.trns_reflection ^= 1;
TMY();
}
}
TPremultiply();
STRMAref->ar_xy[0] = 0;
STRMAref->ar_xy[1] = 0;
STRMAref->ar_xy[2] = DX*NumX;
STRMAref->ar_xy[3] = 0;
STRMAref->ar_xy[4] = 0;
STRMAref->ar_xy[5] = DY*NumY;
TPoint(&STRMAref->ar_xy[0],&STRMAref->ar_xy[1]);
TPoint(&STRMAref->ar_xy[2],&STRMAref->ar_xy[3]);
TPoint(&STRMAref->ar_xy[4],&STRMAref->ar_xy[5]);
TPop();
aref(STRMAref);
/* free storage of property values */
for (i = 0; i < STRMAref->ar_prop.prp_npropval; i++)
free(STRMAref->ar_prop.prp_propval[i]);
STRMAref->ar_prop.prp_npropval = 0;
}
else {
/* create an SREF */
strcpy(STRMSref->sr_name,unalias(SymbolName));
STRMSref->sr_transform = *DefaultTransform;
STRMSref->sr_xy[0] = STRMSref->sr_xy[1] = 0;
/* copy the property list */
for (PDesc = Pointer->oPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
/* allow only valid STREAM property attributes */
i = PDesc->prpty_Value;
if (i > 0 && i < 128) {
STRMSref->sr_prop.prp_propattr
[STRMSref->sr_prop.prp_npropval] = i;
STRMSref->sr_prop.prp_propval
[STRMSref->sr_prop.prp_npropval] =
CopyString(PDesc->prpty_String);
++STRMSref->sr_prop.prp_npropval;
if (STRMSref->sr_prop.prp_npropval >= 255) break;
}
}
STRMSref->sr_transform.trns_angle = 0;
STRMSref->sr_transform.trns_reflection = 0;
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) break;
elif (Type == CDROTATE) {
a = (double) X;
b = (double) Y;
STRMSref->sr_transform.trns_angle +=
(RADTODEG * atan2(b,a));
}
elif (Type == CDTRANSLATE) {
STRMSref->sr_xy[0] = LONGSCALE(X);
STRMSref->sr_xy[1] = LONGSCALE(Y);
}
elif (Type == CDMIRRORX) {
STRMSref->sr_transform.trns_reflection ^= 1;
STRMSref->sr_transform.trns_angle += 180.0;
}
elif (Type == CDMIRRORY)
STRMSref->sr_transform.trns_reflection ^= 1;
}
sref(STRMSref);
/* free storage of property values */
for (i = 0; i < STRMSref->sr_prop.prp_npropval; i++)
free(STRMSref->sr_prop.prp_propval[i]);
STRMSref->sr_prop.prp_npropval = 0;
}
}
return True;
}
static int
gen_stream_struc(SymbolDesc)
struct s *SymbolDesc;
{
struct g *GenDesc;
struct o *Pointer;
struct p *Pair,*Path;
struct prpty *PDesc;
int X,Y,Length,Width;
int Layer,i;
char Type,Xform;
char garbage[80],*Label;
for (Layer = 1; Layer <= NumLayerTable; Layer++) {
if (!CDInitGen(SymbolDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc)) return CDError(CDMALLOCFAILED);
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
/* copy the property list */
for (PDesc = Pointer->oPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
i = PDesc->prpty_Value;
/* allow only valid STREAM property attributes */
if (i > 0 && i < 128) {
DefaultProperty->prp_propattr
[DefaultProperty->prp_npropval] = i;
DefaultProperty->prp_propval
[DefaultProperty->prp_npropval] =
CopyString(PDesc->prpty_String);
++DefaultProperty->prp_npropval;
if (DefaultProperty->prp_npropval >= 255)
break;
}
}
Type = Pointer->oType;
if (Type == CDBOX) {
CDBox(Pointer,&Layer,&Length,&Width,&X,&Y);
Length /= 2;
Width /= 2;
X = LONGSCALE(X);
Y = LONGSCALE(Y);
Length = LONGSCALE(Length);
Width = LONGSCALE(Width);
STRMBoundary->bnd_layer = LayerTable[Layer].klStreamNumber;
STRMBoundary->bnd_datatype =
DATA_TYPE(LayerTable[Layer].klStreamDataType);
STRMBoundary->bnd_prop = *DefaultProperty;
STRMBoundary->bnd_ncoord = 5;
STRMBoundary->bnd_xy[0] = (X + Length);
STRMBoundary->bnd_xy[1] = (Y + Width);
STRMBoundary->bnd_xy[2] = (X + Length);
STRMBoundary->bnd_xy[3] = (Y - Width);
STRMBoundary->bnd_xy[4] = (X - Length);
STRMBoundary->bnd_xy[5] = (Y - Width);
STRMBoundary->bnd_xy[6] = (X - Length);
STRMBoundary->bnd_xy[7] = (Y + Width);
STRMBoundary->bnd_xy[8] = (X + Length);
STRMBoundary->bnd_xy[9] = (Y + Width);
bndry(STRMBoundary);
}
elif (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
STRMPath->pth_layer = LayerTable[Layer].klStreamNumber;
STRMPath->pth_datatype =
DATA_TYPE(LayerTable[Layer].klStreamDataType);
STRMPath->pth_width = LONGSCALE(Width);
STRMPath->pth_prop = *DefaultProperty;
STRMPath->pth_pathtype = 2;
/* look at the property list for a STREAM pathtype definition */
for (PDesc = Pointer->oPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
if (PDesc->prpty_Value - PROPERTYOFFSET == PATHTYPE) {
sscanf(PDesc->prpty_String,"%s %d",garbage,&i);
if (i >= 0 && i < 3)
STRMPath->pth_pathtype = i;
break;
}
}
Pair = Path;
i = 0;
while (Pair != NULL) {
STRMPath->pth_xy[i++] = LONGSCALE(Pair->pX);
STRMPath->pth_xy[i++] = LONGSCALE(Pair->pY);
if (i == 2 && !Pair->pSucc) {
STRMPath->pth_xy[i++] = LONGSCALE(Pair->pX);
STRMPath->pth_xy[i++] = LONGSCALE(Pair->pY);
}
Pair = Pair->pSucc;
if (i == MAXSTRMCOORDS && Pair) {
OutPrompt("Breaking wire with too many vertices.");
finish_path(i);
i = 0;
}
}
finish_path(i);
}
elif (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
STRMBoundary->bnd_layer = LayerTable[Layer].klStreamNumber;
STRMBoundary->bnd_datatype =
DATA_TYPE(LayerTable[Layer].klStreamDataType);
STRMBoundary->bnd_prop = *DefaultProperty;
out_poly(Path, (Poly*)NULL);
}
elif (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
STRMText->txt_layer = LayerTable[Layer].klStreamNumber;
STRMText->txt_texttype =
DATA_TYPE(LayerTable[Layer].klStreamDataType);
STRMText->txt_pathtype = 1;
STRMText->txt_horizontal = 0;
STRMText->txt_vertical = 0;
STRMText->txt_font = 0;
STRMText->txt_width = 0;
STRMText->txt_xy[0] = LONGSCALE(X);
STRMText->txt_xy[1] = LONGSCALE(Y);
STRMText->txt_prop = *DefaultProperty;
STRMText->txt_transform = *DefaultTransform;
STRMSref->sr_xy[0] = STRMSref->sr_xy[1] = 0;
memcpy(STRMText->txt_text,Label,44);
STRMText->txt_text[44] = '\0';
/* look at the property list for a STREAM text definition */
for (PDesc = Pointer->oPrptyList; PDesc;
PDesc = PDesc->prpty_Succ) {
int wdth;
int present,ptype,reflection;
double magn,rotn;
if (PDesc->prpty_Value - PROPERTYOFFSET == TEXT) {
sscanf(PDesc->prpty_String,
"%s %d %s %d %s %d %s %lf %s %lf %s %d",
garbage,&wdth,garbage,&present,garbage,&ptype,
garbage,&magn,garbage,&rotn,garbage,&reflection);
STRMText->txt_pathtype = ptype;
STRMText->txt_horizontal = (present >> 8) & 3;
STRMText->txt_vertical = (present >> 10) & 3;
STRMText->txt_font = (present >> 12) & 3;
STRMText->txt_width = wdth;
STRMText->txt_transform.trns_reflection = reflection;
STRMText->txt_transform.trns_mag = magn;
STRMText->txt_transform.trns_angle = rotn;
break;
}
}
text(STRMText);
}
/* free storage of property values */
for (i = 0; i < DefaultProperty->prp_npropval; i++)
free(DefaultProperty->prp_propval[i]);
DefaultProperty->prp_npropval = 0;
}
}
endstr();
return True;
}
static void
finish_path(i)
int i;
{
if (STRMPath->pth_pathtype == 0 && i > 3) {
ConvertPathtype(&STRMPath->pth_xy[0],&STRMPath->pth_xy[1],
STRMPath->pth_xy[2],STRMPath->pth_xy[3],
STRMPath->pth_width,1);
ConvertPathtype(&STRMPath->pth_xy[i-1],&STRMPath->pth_xy[i-2],
STRMPath->pth_xy[i-3],STRMPath->pth_xy[i-4],
STRMPath->pth_width,1);
}
STRMPath->pth_ncoord = i/2;
path(STRMPath);
}
static void
out_poly(Path, po)
/* Output the poly data, or cut it into pieces if there are
* too many vertices.
*/
struct p *Path;
Poly *po;
{
int i;
struct p *pp;
Poly p1;
int *xy, *bxy;
if (!po) {
for (i = 0, pp = Path; pp; i++,pp = pp->pSucc) ;
p1.nvertices = i;
xy = (int*) tmalloc(i*2*sizeof(int));
p1.xy = xy;
for (pp = Path; pp; pp = pp->pSucc) {
*xy++ = pp->pX;
*xy++ = pp->pY;
}
}
else
p1 = *po;
if (p1.nvertices > MAXSTRMCOORDS/2) {
OutPrompt("Breaking polygon with too many vertices.");
break_poly(&p1);
}
else {
xy = p1.xy;
bxy = STRMBoundary->bnd_xy;
for (i = 0; i < p1.nvertices; i++) {
*bxy++ = LONGSCALE(*xy++);
*bxy++ = LONGSCALE(*xy++);
}
if (i < 4) {
/* close the triangle */
*bxy++ = STRMBoundary->bnd_xy[0];
*bxy++ = STRMBoundary->bnd_xy[1];
i++;
}
STRMBoundary->bnd_ncoord = i;
bndry(STRMBoundary);
}
if (!po)
free(p1.xy);
}
static void
break_poly(p1)
/* Break a polygon across the middle of its BB horizontally and
* write out the resulting clipped polygons.
*/
Poly *p1;
{
int i, x, y, RefY;
struct ka BB;
Poly p2;
int *xy;
/* 4 * num vertices should be long enough */
p2.xy = (int*) tmalloc(p1->nvertices*8*sizeof(int));
BB.kaLeft = BB.kaRight = p1->xy[0];
BB.kaBottom = BB.kaTop = p1->xy[1];
xy = p1->xy;
for (i = 0; i < p1->nvertices; i++) {
x = *xy++;
y = *xy++;
if (x > BB.kaRight) BB.kaRight = x;
if (x < BB.kaLeft) BB.kaLeft = x;
if (y > BB.kaTop) BB.kaTop = y;
if (y < BB.kaBottom) BB.kaBottom = y;
}
RefY = (BB.kaBottom + BB.kaTop)/2;
PolygonClip(p1,BB.kaLeft,BB.kaBottom,BB.kaRight,RefY);
while (NewPolygon(&p2))
out_poly((struct p*)NULL,&p2);
PolygonClip(p1,BB.kaLeft,RefY,BB.kaRight,BB.kaTop);
while (NewPolygon(&p2))
out_poly((struct p*)NULL,&p2);
free(p2.xy);
}
void
ConvertPathtype(xe,ye,xb,yb,width,togds)
int *xe,*ye; /* coordinate of endpoint */
int xb,yb; /* coordinate of previous or next point in path */
int width; /* path width */
int togds;
{
double angle;
double deltaX,deltaY;
if (width == 0) return;
if (width < 0) width = -width;
width /= 2;
if (togds) {
if (*xe == xb) {
if (*ye > yb)
*ye += width;
else
*ye -= width;
}
else if (*ye == yb) {
if (*xe > xb)
*xe += width;
else
*xe -= width;
}
else {
deltaX = (double)(*xe - xb);
deltaY = (double)(*ye - yb);
angle = atan2(deltaY,deltaX);
deltaX = (double)(width) * cos(angle);
deltaY = (double)(width) * sin(angle);
*xe += (int)(deltaX);
*ye += (int)(deltaY);
}
}
else {
if (*xe == xb) {
if (*ye > yb)
*ye -= width;
else
*ye += width;
}
else if (*ye == yb) {
if (*xe > xb)
*xe -= width;
else
*xe += width;
}
else {
deltaX = (double)(*xe - xb);
deltaY = (double)(*ye - yb);
angle = atan2(deltaY,deltaX);
deltaX = (double)(width) * cos(angle);
deltaY = (double)(width) * sin(angle);
*xe -= (int)(deltaX);
*ye -= (int)(deltaY);
}
}
}
static void
reset_info(SymbolDesc)
/* reset the info parameter to zero */
struct s *SymbolDesc;
{
struct g *GenDesc;
struct o *Pointer;
struct s *MasterDesc;
char *SymbolName;
SymbolDesc->sInfo = 0;
if (!CDInitGen(SymbolDesc,0,-CDINFINITY,-CDINFINITY,CDINFINITY,
CDINFINITY,&GenDesc)) return;
loop {
CDGen(SymbolDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
SymbolName = ((struct c *)Pointer->oRep)->cMaster->mName;
if (Not CDOpen(SymbolName,&MasterDesc,'w')) return;
if (MasterDesc->sInfo != 0)
reset_info(MasterDesc);
}
}
#ifdef MSDOS
static struct aliastab *aliasbase;
#endif
static char *
unalias(dosname)
char *dosname;
{
#ifdef MSDOS
int i;
struct aliastab *wl;
for (i = 0,wl = aliasbase; wl; wl = wl->next) {
if (!strcasecmp(dosname,wl->dosname))
return (wl->strname);
}
#endif
return (dosname);
}
static void
freealias()
{
#ifdef MSDOS
struct aliastab *wl,*wn;
for (wl = aliasbase; wl; wl = wn) {
wn = wl->next;
afree(wl,aliastab);
}
aliasbase = NULL;
#endif
}
/***********************************************************************/
/* ******************************************************************* */
/* * * */
/* * The following functions will write a symbolic layout * */
/* * onto a disk file in STREAM format. The information may * */
/* * then be transfered to a magnetic tape by using the 'dd' * */
/* * system command. * */
/* * * */
/* * The order of the function calls is *not* arbitrary. * */
/* * The correct calling sequence is described below: * */
/* * * */
/* * 1) 'bgnlib' to begin library * */
/* * * */
/* * 2) 'bgnstr' to begin structure definition * */
/* * * */
/* * 3) 'bndry' or 'path' or 'sref' or 'aref' or 'text' * */
/* * or any combination thereof. * */
/* * * */
/* * 4) 'endstr' to end structure definition * */
/* * * */
/* * 5) 'endlib' to end library or 'bgnstr' to begin * */
/* * another structure definition * */
/* * * */
/* ******************************************************************* */
/***********************************************************************/
static struct STREAM_info streaminfo;
/***********************************************************************/
/* function STRM_BEGINRECORD */
/* Function to begin record on StreamFile. */
/* count = the number of bytes that will be contained within */
/* the record. */
/* type = the STREAM record type. */
/* datatype = the type of data contained in the STREAM record. */
/***********************************************************************/
static void
strm_beginrecord(count, type, datatype)
int count;
int type;
int datatype;
{
/*
* count = number of bytes in record
* type = type of record
* datatype = type of data in data field
*/
strm_intcopy(count);
putc((unsigned char)type, StreamFile);
putc((unsigned char)datatype, StreamFile);
++streaminfo.rec_count;
streaminfo.byte_count += count;
}
/***********************************************************************/
/* function STRM_ADDATE */
/* Function to add date reference to the StreamFile. The date */
/* is stored in a 'tm' structure that is used by CTIME(3). */
/***********************************************************************/
static void
strm_addate(datep)
struct tm *datep;
{
/*
* datep = pointer to the year spec. of the tm date structure.
*/
strm_intcopy(datep->tm_year);
strm_intcopy(datep->tm_mon);
strm_intcopy(datep->tm_mday);
strm_intcopy(datep->tm_hour);
strm_intcopy(datep->tm_min);
strm_intcopy(datep->tm_sec);
}
/***********************************************************************/
/* function STRM_ENTERASC_REC */
/* Function to enter a single ASCII record into StreamFile */
/* If 'conv' is set, conversion to upper case is performed. */
/***********************************************************************/
static void
strm_entrasc_rec(cp, type, conv)
char *cp;
int type;
int conv;
{
int i = 0, j;
char c;
i = strlen(cp);
if (i & 1) ++i;
strm_beginrecord(i+4, type, 6);
for (j = 0; j < i; ++j) {
c = cp[j];
if (conv) {
if (c >= 'a' && c <= 'z')
c -= 32;
}
putc(c, StreamFile);
}
}
/***********************************************************************/
/* function STRM_ENTRASC */
/* Function to enter ascii string of 44 characters into the */
/* StreamFile. If 'conv' is set, conversion to upper case is */
/* performed. */
/***********************************************************************/
static void
strm_entrasc(cp, conv)
char *cp;
int conv;
{
/*
* cp = pointer to character buffer.
*/
int i;
int n;
char c;
n = strlen(cp);
for (i = 0; i < n; ++i) {
c = *cp++;
if (conv) {
if (c >= 'a' && c <= 'z')
c -= 32;
}
putc(c, StreamFile);
}
for (i = n; i < 44; ++i)
putc('\0', StreamFile);
}
/***********************************************************************/
/* function BGNLIB */
/* Function to begin new library on the StreamFile. */
/***********************************************************************/
static int
bgnlib(lib)
STRM_LIBRARY *lib;
{
int version = 3;
streaminfo.rec_count=0; /* initialize for new library */
streaminfo.struct_count=0;
streaminfo.byte_count=0;
streaminfo.level = 0;
strm_beginrecord(6, HEADER, 2);
strm_intcopy(version);
strm_beginrecord(28, BGNLIB, 2);
strm_addate(&(lib->lib_moddate));
strm_addate(&(lib->lib_accessdate));
strm_entrasc_rec(lib->lib_name, LIBNAME, TOUPR);
if (lib->lib_lib1[0] != '\0' || lib->lib_lib2[0] != '\0') {
strm_beginrecord(92, REFLIBS, 6);
strm_entrasc(lib->lib_lib1, TOUPR);
strm_entrasc(lib->lib_lib2, TOUPR);
}
if (lib->lib_font0[0] != '\0' || lib->lib_font1[0] != '\0'
|| lib->lib_font2[0] != '\0' || lib->lib_font3[0] != '\0') {
strm_beginrecord(180, FONTS, 6);
strm_entrasc(lib->lib_font0, TOUPR);
strm_entrasc(lib->lib_font1, TOUPR);
strm_entrasc(lib->lib_font2, TOUPR);
strm_entrasc(lib->lib_font3, TOUPR);
}
if (lib->lib_attr[0] != '\0')
strm_entrasc_rec(lib->lib_attr, ATTRTABLE, TOUPR);
strm_beginrecord(6, GENERATIONS, 2);
strm_intcopy(lib->lib_gen);
strm_beginrecord(20, UNITS, 5);
strm_dblcopy(lib->lib_uunit);
strm_dblcopy(lib->lib_munit);
return (0);
}
/***********************************************************************/
/* function ENDLIB */
/* Function to end library on the StreamFile. */
/***********************************************************************/
static int
endlib()
{
int i, j;
if (streaminfo.level != 0 && streaminfo.test) return(-1);
strm_beginrecord(4, ENDLIB, 0);
/* pad with nulls */
i = (streaminfo.byte_count % 2048);
for (j = 0; j < i; ++j)
putc(0, StreamFile);
return (0);
}
/***********************************************************************/
/* function BGNSTR */
/* Function to structure definition in the StreamFile. */
/***********************************************************************/
static int
bgnstr(strp)
STRM_STRCT *strp;
{
if (streaminfo.level != 0 && streaminfo.test) return(-1);
streaminfo.level = 1;
strm_beginrecord(28, BGNSTR, 2);
strm_addate(&(strp->str_creatdate));
strm_addate(&(strp->str_moddate));
strm_entrasc_rec(strp->str_name, STRNAME, TOUPR);
++streaminfo.struct_count;
return (0);
}
/***********************************************************************/
/* function ENDSTR */
/* Function to end structure on the StreamFile. */
/***********************************************************************/
static int
endstr()
{
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 0;
strm_beginrecord(4, ENDSTR, 0);
return (0);
}
/***********************************************************************/
/* function STRM_ENDLMNT */
/* Function to end element stream on the StreamFile. */
/***********************************************************************/
static int
strm_endlmnt(propp)
STRM_PROPERTY *propp;
{
int i,k;
k = 0;
if (streaminfo.level != 2 && streaminfo.test) return(-1);
streaminfo.level = 1;
i = propp->prp_npropval;
while (i-- > 0) {
strm_beginrecord(6, PROPATTR, 2);
strm_intcopy(propp->prp_propattr[k]);
strm_entrasc_rec(propp->prp_propval[k++], PROPVALUE, 0);
}
strm_beginrecord(4, ENDEL, 0);
return (0);
}
/***********************************************************************/
/* function BNDRY */
/* Function to enter boundary element into the StreamFile. */
/***********************************************************************/
static int
bndry(bndryp)
STRM_BOUNDARY *bndryp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, BOUNDARY, 0);
strm_beginrecord(6, LAYER, 2);
strm_intcopy(bndryp->bnd_layer);
strm_beginrecord(6, DATATYPE, 2);
strm_intcopy(bndryp->bnd_datatype);
if (bndryp->bnd_ncoord < 4) {
OutPrompt("Error: less than four boundary coordinates");
StrmNoGo = True;
}
else {
strm_beginrecord(8 * bndryp->bnd_ncoord + 4, XY, 3);
for (i = 0; i < bndryp->bnd_ncoord + bndryp->bnd_ncoord; ++i) {
strm_lngcopy(bndryp->bnd_xy[i]);
}
}
i = strm_endlmnt(&(bndryp->bnd_prop));
return (i);
}
/***********************************************************************/
/* function STRM_STRNSFM */
/* Function to enter structure transformation record */
/***********************************************************************/
static int
strm_strnsfm(trp)
STRM_TRANSFORM *trp;
{
int i;
i = 0;
if (trp->trns_reflection == 1) i |= 0100000;
if (trp->trns_abs_mag == 1) i |= 04;
if (trp->trns_abs_angle == 1) i |= 02;
strm_beginrecord(6, STRANS, 1);
strm_intcopy(i);
if (trp->trns_mag != 1) {
strm_beginrecord(12, MAG, 5);
strm_dblcopy(trp->trns_mag);
}
if (trp->trns_angle != 0) {
strm_beginrecord(12, ANGLE, 5);
strm_dblcopy(trp->trns_angle);
}
return (0);
}
/***********************************************************************/
/* function PATH */
/* Function to enter path element into the StreamFile. */
/***********************************************************************/
static int
path(pathp)
STRM_PATH *pathp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, PATH, 0);
strm_beginrecord(6, LAYER, 2);
strm_intcopy(pathp->pth_layer);
strm_beginrecord(6, DATATYPE, 2);
strm_intcopy(pathp->pth_datatype);
strm_beginrecord(6, PATHTYPE, 2);
strm_intcopy(pathp->pth_pathtype);
strm_beginrecord(8, WIDTH, 3);
strm_lngcopy(pathp->pth_width);
if (pathp->pth_ncoord < 2) {
OutPrompt("Error: less than two path points");
StrmNoGo = True;
}
else {
strm_beginrecord(8 * pathp->pth_ncoord + 4, XY, 3);
for (i = 0; i < pathp->pth_ncoord + pathp->pth_ncoord; ++i) {
strm_lngcopy(pathp->pth_xy[i]);
}
}
i = strm_endlmnt(&(pathp->pth_prop));
return (i);
}
/***********************************************************************/
/* function SREF */
/* Function to enter structure reference to the StreamFile. */
/***********************************************************************/
static int
sref(srefp)
STRM_SREF *srefp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, SREF, 0); /* enter SREF record */
strm_entrasc_rec(srefp->sr_name, SNAME, TOUPR); /* enter SNAME record */
strm_strnsfm(&(srefp->sr_transform)); /* enter STRANS record */
strm_beginrecord(12, XY, 3); /* enter XY record */
strm_lngcopy(srefp->sr_xy[0]);
strm_lngcopy(srefp->sr_xy[1]);
i = strm_endlmnt(&(srefp->sr_prop));
return (i);
}
/***********************************************************************/
/* function AREF */
/* Function to enter array reference element in the StreamFile. */
/***********************************************************************/
static int
aref(arefp)
STRM_AREF *arefp;
{
int *ip;
int i;
if (streaminfo.level != 1 && streaminfo.test) return (-1);
streaminfo.level = 2;
strm_beginrecord(4, AREF, 0); /* enter AREF record */
strm_entrasc_rec(arefp->ar_name, SNAME, TOUPR); /* enter SNAME record */
strm_strnsfm(&(arefp->ar_transform)); /* enter STRANS record */
strm_beginrecord(8, COLROW, 2); /* enter COLROW record */
strm_intcopy(arefp->ar_col);
strm_intcopy(arefp->ar_row);
strm_beginrecord(28, XY, 3); /* enter XY record */
ip = arefp->ar_xy;
for (i = 1; i <= 6; ++i) {
strm_lngcopy(*ip);
++ip;
}
i = strm_endlmnt(&(arefp->ar_prop));
return (i);
}
/***********************************************************************/
/* function TEXT */
/* Function to enter text element into the StreamFile. */
/***********************************************************************/
static int
text(textp)
STRM_TEXT *textp;
{
int i;
if (streaminfo.level != 1 && streaminfo.test) return(-1);
streaminfo.level = 2;
strm_beginrecord(4, TEXT, 0); /* enter TEXT record */
strm_beginrecord(6, LAYER, 2); /* enter LAYER record */
strm_intcopy(textp->txt_layer);
strm_beginrecord(6, TEXTTYPE, 2); /* enter TEXTTYPE record */
strm_intcopy(textp->txt_texttype);
if (textp->txt_horizontal >= 0 && textp->txt_horizontal < 3) {
if (textp->txt_vertical >= 0 && textp->txt_vertical < 3) {
if (textp->txt_font >= 0 && textp->txt_font <= 3) {
i = textp->txt_horizontal + (textp->txt_vertical << 2)
+ (textp->txt_font << 4);
strm_beginrecord(6, PRESENTATION, 1);
strm_intcopy(i);
}
}
}
strm_beginrecord(6, PATHTYPE, 2); /* enter PATHTYPE record */
strm_intcopy(textp->txt_pathtype);
strm_beginrecord(8, WIDTH, 3);
strm_lngcopy(textp->txt_width);
strm_strnsfm(&(textp->txt_transform)); /* enter STRANS record */
strm_beginrecord(12, XY, 3); /* enter XY record */
strm_lngcopy(textp->txt_xy[0]);
strm_lngcopy(textp->txt_xy[1]);
strm_entrasc_rec(textp->txt_text, STRING, 0);
i = strm_endlmnt(&(textp->txt_prop));
return (i);
}
/*
* function STRM_INTCOPY
* Function to transfer the two bytes of a short integer to a
* Stream file. The most significant byte is sent first.
*/
static void
strm_intcopy(i)
int i;
{
putc((char)((i >> 8) & 0xff),StreamFile);
putc((char)(i & 0xff),StreamFile);
}
/*
* function STRM_LNGCOPY
* Function to transfer the four bytes of a long integer to a
* Stream file. The most significant byte is sent first.
*/
static void
strm_lngcopy(i)
int i;
{
putc((char)((i >> 24) & 0xff),StreamFile);
putc((char)((i >> 16) & 0xff),StreamFile);
putc((char)((i >> 8) & 0xff),StreamFile);
putc((char)((i) & 0xff),StreamFile);
}
/*
* function STRM_DBLCOPY
* Function to transfer double precision number to a Stream file.
*
* CALMA's double precision field:
*
* Mantissa is base 16 (1/16 <= mantissa < 1). Exponent is excess-64.
*
* 111111 1111222222222233 3333333344444444 4455555555556666
* 0123456789012345 6789012345678901 2345678901234567 8901234567890123
* ---------------- ---------------- ---------------- ----------------
* FFFFFFFFEEEEEEES FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* L M L M L M L M
*
*
* where E = exponent field
* S = sign bit
* F = fraction field
* FL = least sig. bit of word or byte
* FM = most sig. bit of word or byte
*/
/*
* This routine is really inefficient, but there are typically few
* conversions required and portability is an issue.
*/
static void
strm_dblcopy(r)
double r;
{
int i, exp, sign;
unsigned char b[8];
if (r == 0.0) {
for (i = 0; i < 8; i++)
b[i] = 0;
goto xfer;
}
sign = 0;
if (r < 0) {
sign = 1;
r = -r;
}
/* normalize to 1/16 < r <= 1 */
i = 0;
if (r >= 1.0) {
while (r >= 1.0) {
r /= 16.0;
i++;
}
if (i > 63) {
/* overflow */
for (i = 0; i < 8; i++)
b[i] = 0xff;
if (!sign)
b[0] &= 0x7f;
goto xfer;
}
exp = i + 64;
}
else if (r < 1/16.0) {
while (r < 1/16.0 && i < 64) {
r *= 16.0;
i++;
}
if (i > 63) {
/* underflow */
for (i = 0; i < 8; i++)
b[i] = 0;
goto xfer;
}
exp = 64 - i;
}
else
exp = 64;
for (i = 1; i <= 7; i++) {
r *= 256.0;
b[i] = r;
r -= b[i];
}
b[0] = exp;
if (sign)
b[0] |= 0x80;
xfer:
/* transfer bytes to char buffer */
putc(b[0], StreamFile);
putc(b[1], StreamFile);
putc(b[2], StreamFile);
putc(b[3], StreamFile);
putc(b[4], StreamFile);
putc(b[5], StreamFile);
putc(b[6], StreamFile);
putc(b[7], StreamFile);
}
/*************************************************************************
*
* CIF conversion.
*
*************************************************************************/
void
ToCIF()
{
char *s;
char CIFFile[81];
int Layer;
int Layers[CDNUMLAYERS+1];
MenuSelect(MenuTOCIF);
ShowPrompt("CIF file name? ");
strcpy(CIFFile,Parameters.kpCellName);
if ((s = strchr(CIFFile,'.')) != NULL) *s = '\0';
strcat(CIFFile,".cif");
s = FBEdit(CIFFile);
if (s != NULL) {
if (*s != '\0' && *s != '\n')
strcpy(CIFFile,s);
if (!access(CIFFile,0))
if (clobber_check(False))
return;
for (Layer = 0; Layer <= NumLayerTable; Layer++)
Layers[Layer] = True;
if (!CDFrom(Parameters.kpCellName,CIFFile,RESOLUTION,RESOLUTION,
Layers,NumLayerTable+1,'k')) {
sprintf(TypeOut,"Translation of %s failed. MORE",
Parameters.kpCellName);
OutPrompt(TypeOut);
(void)FBGetchar(ERASE);
OutPrompt(CDStatusString);
}
else {
sprintf(TypeOut,"Translation of %s succeeded.",
Parameters.kpCellName);
OutPrompt(TypeOut);
}
}
MenuDeselect(MenuTOCIF);
}
void
FromCIF()
{
char *s,CIFFile[81],type;
FILE *fp;
MenuSelect(MenuFRCIF);
ShowPrompt("CIF file name? ");
s = FBEdit(NULL);
if (s != NULL && *s != '\0' && *s != '\n') {
strcpy(CIFFile,s);
if ((fp = POpen(CIFFile,"r",(char *)NULL,(char **)NULL)) == NULL) {
sprintf(TypeOut,"CIF file %s not found.",CIFFile);
ShowPrompt(TypeOut);
MenuDeselect(MenuFRCIF);
return;
}
type = get_cif_file_type(fp);
fclose(fp);
sprintf(TypeOut,"CIF file type: %c",type);
OutPrompt(TypeOut);
if (!CDTo(CIFFile,"Root",RESOLUTION,RESOLUTION,type)) {
sprintf(TypeOut,"Translation of %s failed. MORE",CIFFile);
OutPrompt(TypeOut);
(void)FBGetchar(ERASE);
OutPrompt(CDStatusString);
}
else {
sprintf(TypeOut,"Translation of %s succeeded.",CIFFile);
OutPrompt(TypeOut);
}
}
MenuDeselect(MenuFRCIF);
}
static char
get_cif_file_type(cfile)
/* Return the code for the structure name. Skip to the first DS command,
* and look at the following line.
*
* a Stanford: A Stanford symbol name follows a DS command as in (PadIn);
* b NCA: An NCA symbol name follows a DS command as in (PadIn);
* h IGS: A KIC or IGS symbol name follows a DS command as in 9 PadIn;
* k KIC: A KIC or IGS symbol name follows a DS command as in 9 PadIn;
* i Icarus: An Icarus symbol name follows a DS command as in (9 PadIn);
* q Squid: A Squid symbol name follows a DS command as in 9 /usr/joe/PadIn;
* s Sif: A Sif symbol name follows a DS command as in (Name: PadIn);
* n none of the above
*/
FILE *cfile;
{
int c;
if (cfile == NULL)
return ('n');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c != 'D') {
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
continue;
}
if ((c = getc(cfile)) == EOF)
return ('n');
if (c != 'S') {
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
continue;
}
/* found a DS command, skip to ; */
while (((c = getc(cfile)) != EOF) && (c != ';')) ;
if (c == EOF)
return ('n');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == '(') {
/* a comment line */
while ((c = getc(cfile)) != EOF)
if (isspace(c)) continue;
if (c == EOF)
return ('n');
if (c == '9')
/* Icarus */
return ('i');
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == ':')
/* Sif */
return ('s');
if (c == ';')
/* Stanford/NCA */
return ('a');
}
return ('n');
}
else if (c == '9') {
/* user extension line */
while ((c = getc(cfile)) != EOF) {
if (isspace(c)) continue;
if (c == '/')
/* Squid */
return ('q');
if (c == ';')
/* IGS/KIC */
return ('k');
}
return ('n');
}
else
return ('n');
}
}
return ('n');
}
kic-2.4c/src/convert/Makefile.in 0000644 0000764 0000764 00000002442 07525375241 016244 0 ustar stevew stevew #######################################################################
# src/convert/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
LIB_TARGET = ../convert.a
HFILES =
CFILES = convert.c convert1.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/convert
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/help/ 0000755 0000764 0000764 00000000000 12427446157 013447 5 ustar stevew stevew kic-2.4c/src/help/textdisp.c 0000644 0000764 0000764 00000023062 07525346710 015457 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
#include "prefix.h"
#include "hlpdefs.h"
#if __STDC__
#include
#else
#include
#endif
#include
#include
#ifdef WIN32
#include
#endif
static topic *curtop;
static bool quitflag;
#if __STDC__
static void putline(char*);
static int putstuff(toplink*,int);
#else
static void putline();
static int putstuff();
#endif
int hlp_width = 72;
bool
hlp_tdisplay(top)
topic *top;
{
wordlist *wl;
int i = 0;
char *xx;
curtop = top;
out_init();
out_printf("\n");
if (cp_out == stdout) {
/* in order for the cursor to display the right color,
* column 1 must have the default attribute */
fprintf(cp_out," ");
fflush(cp_out);
cprint(15,top->title);
out_printf("\n");
}
else
out_cprint("%s\n",top->title);
for (wl = top->text; wl; wl = wl->wl_next)
putline(wl->wl_word);
if (top->subtopics) {
xx = "Sub-Topics:";
if (cp_out == stdout) {
fprintf(cp_out," ");
fflush(cp_out);
cprint(9,xx);
out_printf("\n");
}
else
out_cprint("%s\n",xx);
i = putstuff(top->subtopics, 0);
out_printf("\n");
}
if (top->seealso) {
xx = "See Also:";
if (cp_out == stdout) {
fprintf(cp_out," ");
fflush(cp_out);
cprint(10,xx);
out_printf("\n");
}
else
out_cprint("%s\n",xx);
(void) putstuff(top->seealso, i);
out_printf("\n");
}
if (!top->subtopics && !top->seealso)
out_printf("\n");
return (true);
}
toplink *
hlp_thandle(parent)
topic **parent;
{
char buf[BSIZE], *s;
toplink *tl;
int num;
quitflag = false;
if (!curtop) {
*parent = NULL;
return (NULL);
}
for (;;) {
s = "Selection (h for help) ";
if (cp_out == stdout) {
/* in order for the cursor to display the right color,
* column 1 must have the default attribute */
fprintf(cp_out," ");
fflush(cp_out);
cprint(11,s);
}
else {
fprintf(cp_out,"%s ",s);
fflush(cp_out);
}
#if defined (SCED) || defined (KIC)
s = GetString(buf,BSIZE,cp_in,
(curtop->subtopics || curtop->seealso) ? "Selection? " : NULL);
#else
s = fgets(buf,BSIZE,cp_in);
#endif
if (!s) {
clearerr(stdin);
quitflag = true;
*parent = NULL;
return (NULL);
}
while (*s == ' ' || *s == '\t') s++;
switch (*s) {
char *xx;
case '?':
case 'h':
xx = "\nType the number of a sub-topic or see also, or one of:\n\
h or ? Print this message\n\
r [ >file ] Reprint the current topic [ to file ]\n\
p or CR Return to the previous topic\n\
q Quit help\n";
if (cp_out == stdout) {
cprint(14,xx);
fprintf(cp_out," \n");
}
else
fprintf(cp_out,"%s\n",xx);
continue;
case 'r':
{
char *ss;
FILE *tmp;
bool ttytmp;
if ((ss = strchr(s,'\n')) != NULL)
*ss = '\0';
if ((ss = strchr(s,'>')) == NULL) {
(void) hlp_tdisplay(curtop);
continue;
}
tmp = cp_out;
ss++;
if (*ss == '>') {
ss++;
cp_out = fopen(ss,"a");
}
else
cp_out = fopen(ss,"w");
if (cp_out) {
ttytmp = out_isatty;
out_isatty = isatty(fileno(cp_out));
(void) hlp_tdisplay(curtop);
out_isatty = ttytmp;
(void) fclose(cp_out);
}
else
perror(ss);
cp_out = tmp;
continue;
}
case 'q':
quitflag = true;
*parent = NULL;
return NULL;
case 'p':
case '\n':
case '\r':
*parent = curtop;
return NULL;
}
if (!isdigit(*s)) {
fprintf(cp_out,"%s\n","Invalid command");
continue;
}
num = atoi(s);
if (num <= 0) {
fprintf(cp_out,"%s\n","Bad choice");
continue;
}
for (tl = curtop->subtopics; tl; tl = tl->next)
if (--num == 0)
break;
if (num) {
for (tl = curtop->seealso; tl; tl = tl->next)
if (--num == 0)
break;
}
if (num) {
fprintf(cp_out,"%s\n","Bad choice");
continue;
}
*parent = curtop;
return tl;
}
}
/* ARGSUSED */
void
hlp_tkillwin(top)
topic *top;
{
if (curtop)
curtop = curtop->parent;
if (curtop && !quitflag)
(void) hlp_tdisplay(curtop);
return;
}
/* This has to rip out the font changes from the lines... */
static void
putline(s)
char *s;
{
char buf[BSIZE];
int i = 0;
while (*s) {
if (((*s == '\033') && s[1]) ||
((*s == '_') && (s[1] == '\b')))
s += 2;
else
buf[i++] = *s++;
}
buf[i] = '\0';
out_printf("%s\n", buf);
return;
}
/* Figure out the number of columns we can use. Assume an entry like
* nn) word -- add 5 characters to the width...
*/
static int
putstuff(tl, base)
toplink *tl;
int base;
{
int maxwidth = 0, ncols, nrows, nbuts = 0, i, j, k;
toplink *tt;
for (tt = tl; tt; tt = tt->next) {
if (strlen(tt->description) + 5 > maxwidth)
maxwidth = strlen(tt->description) + 5;
nbuts++;
}
ncols = hlp_width / maxwidth;
if (!ncols) {
err_printf("Help, button too big!!\n");
return (0);
}
if (ncols > nbuts)
ncols = nbuts;
maxwidth = hlp_width / ncols;
nrows = nbuts / ncols;
if (nrows * ncols < nbuts)
nrows++;
for (i = 0; i < nrows; i++) {
for (tt = tl, j = 0; j < i; j++, tt = tt->next)
;
for (j = 0; j < ncols; j++) {
if (tt)
out_printf("%2d) %-*s ", base + j*nrows + i + 1,
maxwidth - 5, tt->description);
for (k = 0; k < nrows; k++)
if (tt)
tt = tt->next;
}
out_printf("\n");
}
return (nbuts);
}
#define MAXLEN 4096
#if __STDC__
void
out_printf(char *fmt, ...)
{
va_list args;
char buf[MAXLEN];
va_start(args,fmt);
(void) vsprintf(buf, fmt, args);
va_end(args);
PutString(buf);
return;
}
void
err_printf(char *fmt, ...)
{
va_list args;
char buf[MAXLEN];
va_start(args,fmt);
(void) vsprintf(buf, fmt, args);
va_end(args);
PutErrorString(buf);
return;
}
void
out_cprint(char *fmt, ...)
{
va_list args;
char buf[MAXLEN];
va_start(args,fmt);
(void) vsprintf(buf, fmt, args);
va_end(args);
PutBoldString(buf);
return;
}
#else
void
out_printf(va_alist)
va_dcl
{
va_list args;
char *fmt;
char buf[MAXLEN];
va_start(args);
fmt = va_arg(args,char *);
#if __NDPC__
(void) vsprintf(buf, fmt, &args);
#else
(void) vsprintf(buf, fmt, args);
#endif
va_end(args);
PutString(buf);
return;
}
void
err_printf(va_alist)
va_dcl
{
va_list args;
char *fmt;
char buf[MAXLEN];
va_start(args);
fmt = va_arg(args,char *);
#if __NDPC__
(void) vsprintf(buf, fmt, &args);
#else
(void) vsprintf(buf, fmt, args);
#endif
va_end(args);
PutErrorString(buf);
return;
}
void
out_cprint(va_alist)
va_dcl
{
va_list args;
char *fmt;
char buf[MAXLEN];
va_start(args);
fmt = va_arg(args,char *);
#if __NDPC__
(void) vsprintf(buf, fmt, &args);
#else
(void) vsprintf(buf, fmt, args);
#endif
va_end(args);
PutBoldString(buf);
return;
}
#endif /* __STDC__ */
char *
copy(str)
char *str;
{
char *p;
/* SRW */
if (!str) return NULL;
p = TMALLOC(strlen(str) + 1);
(void) strcpy(p, str);
return(p);
}
/* Case insensitive prefix. */
bool
ciprefix(p, s)
register char *p, *s;
{
if (!p) return true;
if (!s) return false;
while (*p) {
if ((isupper(*p) ? tolower(*p) : *p) !=
(isupper(*s) ? tolower(*s) : *s))
return(false);
p++;
s++;
}
return (true);
}
void
wl_free(wlist)
wordlist *wlist;
{
wordlist *wl, *nw;
for (wl = wlist; wl; wl = nw) {
nw = wl->wl_next;
free(wl->wl_word);
free(wl);
}
return;
}
#ifdef MSDOS
char *
dostemp(s)
/* return full path to temp file */
char *s;
{
static char buf[128], *c, *getenv();
c = getenv("TMP");
if (c && !access(c,0)) {
strcpy(buf,c);
strcat(buf,"\\");
strcat(buf,s);
return buf;
}
return s;
}
#endif
kic-2.4c/src/help/help.c 0000644 0000764 0000764 00000003424 07525346710 014543 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
/*
* The main entry point for the KIC help system.
*/
#include "prefix.h"
#include "hlpdefs.h"
char *hlp_directory;
FILE *cp_in;
FILE *cp_out;
FILE *cp_err;
char *HELPPATH;
int out_isatty;
void
hlp_main(path, word)
char *path;
char *word;
{
topic *top;
HELPPATH = path;
out_isatty = false;
hlp_directory = path;
if (!(top = hlp_read(word))) {
if (word && *word)
err_printf("Error: No such topic: %s\n",word);
else
err_printf("Error: no top level topic\n");
}
hlp_provide(top);
hlp_free();
return;
}
#ifdef MSDOS
void
hlp_pathfix(buf)
char *buf;
{
char *s, *t;
int bcnt = 0, ecnt = 0;
s = t = buf;
while (*t != '\0') {
if (*t == '/' || *t == '\\') {
*s++ = '\\';
t++;
bcnt = 0;
ecnt = 0;
}
else if (*t == '.') {
*s++ = *t++;
ecnt = 1;
}
else if (!ecnt) {
if (bcnt++ < 8) *s++ = *t++;
else t++;
}
else {
if (ecnt++ < 4) *s++ = *t++;
else t++;
}
}
*s = *t;
}
#else
void
hlp_pathfix(buf)
char *buf;
{
return;
}
#endif
kic-2.4c/src/help/readhelp.c 0000644 0000764 0000764 00000017757 07525346710 015415 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
#include "prefix.h"
#include "hlpdefs.h"
#include
#define prefix(x,y) ciprefix(x,y)
struct sHlpEnt {
int offset;
char *keyword;
char *title;
struct sHlpEnt *next;
};
static struct sHlpEnt *HelpBase;
#if __STDC__
static void sortlist(toplink**);
static int sortcmp(toplink**,toplink**);
static void tlfree(toplink*);
static FILE *db_open(char*,struct sHlpEnt**);
static void read_db(FILE*);
static struct sHlpEnt *find_entry(char*);
static char *my_fgets(char*,int,FILE*);
#else
static void sortlist();
static int sortcmp();
static void tlfree();
static FILE *db_open();
static void read_db();
static struct sHlpEnt *find_entry();
static char *my_fgets();
#endif
static topic *alltopics = NULL;
#define HLP_KEYWORD "!!KEYWORD"
#define HLP_TITLE "!!TITLE"
#define HLP_TEXT "!!TEXT"
#define HLP_SEEALSO "!!SEEALSO"
#define HLP_SUBTOPICS "!!SUBTOPICS"
topic *
hlp_read(word)
char *word;
{
char buf[BSIZE], *s, *t;
int i, seealso, subtopics;
FILE *fp;
topic *top;
toplink *tl = NULL;
struct sHlpEnt *bb;
wordlist *wl = NULL;
if (!(fp = db_open(word,&bb))) {
err_printf("Error: no title for topic %s.\n", word);
return (NULL);
}
top = alloc(topic);
top->keyword = copy(word);
top->title = copy(bb->title);
top->subtopics = NULL;
top->seealso = NULL;
top->text = NULL;
top->maxcols = 0;
seealso = false;
subtopics = false;
while ((s = my_fgets(buf,BSIZE,fp)) != NULL) {
if (prefix(HLP_KEYWORD,s))
break;
if (prefix(HLP_SEEALSO,s)) {
seealso = true;
subtopics = false;
tl = NULL;
continue;
}
if (prefix(HLP_SUBTOPICS,s)) {
subtopics = true;
seealso = false;
tl = NULL;
continue;
}
if (seealso || subtopics) {
if (*s == '#' || *s == '*')
continue;
while (isspace(*s))
s++;
if (!*s)
continue;
t = s + strlen(s)-1;
while (*t <= ' ')
*t-- = '\0';
if (tl) {
tl->next = alloc(toplink);
tl = tl->next;
}
else
tl = alloc(toplink);
tl->keyword = copy(s);
tl->next = NULL;
bb = find_entry(s);
if (bb)
tl->description = copy(bb->title);
else
tl->description = copy("");
if (seealso && !top->seealso)
top->seealso = tl;
else if (subtopics && !top->subtopics)
top->subtopics = tl;
continue;
}
if ((s = strchr(buf,'\n')) != NULL)
*s = '\0';
if (wl) {
wl->wl_next = alloc(wordlist);
wl->wl_next->wl_prev = wl;
wl = wl->wl_next;
}
else {
wl = alloc(wordlist);
wl->wl_prev = NULL;
}
wl->wl_next = NULL;
wl->wl_word = copy(buf);
if (!top->text)
top->text = wl;
top->numlines++;
if ((i = strlen(buf)) > top->maxcols)
top->maxcols = i;
}
(void) fclose(fp);
sortlist(&top->seealso);
sortlist(&top->subtopics);
top->readlink = alltopics;
alltopics = top;
return (top);
}
static void
sortlist(tlp)
toplink **tlp;
{
toplink **vec, *tl;
int num, i;
for (num = 0,tl = *tlp; tl; tl = tl->next) num++;
if (!num) return;
vec = (toplink **) TMALLOC(sizeof (toplink *) * num);
for (tl = *tlp, i = 0; tl; tl = tl->next, i++)
vec[i] = tl;
(void) qsort((char *) vec, num, sizeof (toplink *),
#if __STDC__
(int(*)(const void*,const void*))sortcmp);
#else
sortcmp);
#endif
*tlp = vec[0];
for (i = 0; i < num - 1; i++)
vec[i]->next = vec[i + 1];
vec[i]->next = NULL;
free(vec);
return;
}
static int
sortcmp(tlp1, tlp2)
toplink **tlp1, **tlp2;
{
return (strcmp((*tlp1)->description, (*tlp2)->description));
}
void
hlp_free()
{
topic *top, *nt = NULL;
for (top = alltopics; top; top = nt) {
nt = top->readlink;
free(top->title);
free(top->keyword);
wl_free(top->text);
tlfree(top->subtopics);
tlfree(top->seealso);
free(top);
}
alltopics = NULL;
return;
}
static void
tlfree(tl)
toplink *tl;
{
toplink *nt = NULL;
while (tl) {
free(tl->description);
free(tl->keyword);
/* Don't free the button stuff... */
nt = tl->next;
free(tl);
tl = nt;
}
return;
}
static FILE *
db_open(word,pb)
char *word;
struct sHlpEnt **pb;
{
char buf[BSIZE];
FILE *fp;
struct sHlpEnt *bb;
(void) sprintf(buf,"%s/%s",HELPPATH,DBFILE);
hlp_pathfix(buf);
/* open in binary mode, so ftell/fseek work in DOS */
fp = fopen(buf,"rb");
if (!fp) {
perror(buf);
return (NULL);
}
if (!HelpBase)
read_db(fp);
if (!HelpBase)
return (NULL);
bb = find_entry(word);
if (bb) {
*pb = bb;
fseek(fp,bb->offset,0);
}
else {
fclose(fp);
fp = NULL;
}
return (fp);
}
static void
read_db(fp)
FILE *fp;
{
char buf[BSIZE], *s, *t, *kw = NULL, *ti = NULL;
struct sHlpEnt *bb = NULL;
int keyword = 0, title = 0;
while ((s = my_fgets(buf, BSIZE, fp)) != NULL) {
if (prefix(HLP_KEYWORD,buf)) {
keyword = true;
title = false;
kw = NULL;
continue;
}
if (prefix(HLP_TITLE,buf)) {
title = true;
keyword = false;
ti = NULL;
continue;
}
if (prefix(HLP_TEXT,buf)) {
if (ti && kw) {
if (HelpBase == NULL) {
HelpBase = alloc(sHlpEnt);
bb = HelpBase;
}
else {
bb->next = alloc(sHlpEnt);
bb = bb->next;
}
bb->next = NULL;
bb->keyword = kw;
bb->title = ti;
bb->offset = ftell(fp);
ti = NULL;
kw = NULL;
keyword = false;
title = false;
}
continue;
}
if (keyword || title) {
while (isspace(*s))
s++;
if (!*s)
continue;
t = s + strlen(s)-1;
while (*t <= ' ')
*t-- = '\0';
if (keyword)
kw = copy(s);
else
ti = copy(s);
}
}
}
static struct sHlpEnt *
find_entry(word)
char *word;
{
struct sHlpEnt *bb;
if (!word)
return (HelpBase);
for (bb = HelpBase; bb; bb = bb->next) {
if (!strcmp(word,bb->keyword))
return (bb);
}
return (NULL);
}
static char *
my_fgets(buf,size,fp)
char *buf;
int size;
FILE *fp;
{
char *s;
int i, c;
/* works with DOS or UNIX */
for (s = buf, i = size; i; s++, i--) {
c = getc(fp);
if (c == '\r')
c = getc(fp);
if (c == EOF) {
*s = '\0';
if (s == buf)
return (NULL);
return (buf);
}
*s = c;
if (c == '\n') {
*++s = '\0';
return (buf);
}
}
buf[size-1] = '\0';
return (buf);
}
kic-2.4c/src/help/Makefile.in 0000644 0000764 0000764 00000002453 07525375365 015525 0 ustar stevew stevew #######################################################################
# src/help/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
LIB_TARGET = ../help.a
HFILES =
CFILES = help.c provide.c readhelp.c textdisp.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/help
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/help/provide.c 0000644 0000764 0000764 00000005353 07525346710 015266 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
* faustus@cad.berkeley.edu, ucbvax!faustus
* Permission is granted to modify and re-distribute this code in any manner
* as long as this notice is preserved. All standard disclaimers apply.
*
*************************************************************************/
#include "prefix.h"
#include "hlpdefs.h"
#if __STDC__
static void killfamily(topic*);
#else
static void killfamily();
#endif
void
hlp_provide(top)
topic *top;
{
toplink *res;
topic *parent, *newtop, *pa;
if (top == NULL) return;
top->xposition = top->yposition = 0;
if (!hlp_tdisplay(top)) {
err_printf("Couldn't display text\n");
return;
}
for (;;) {
res = hlp_thandle(&parent);
if (!res && !parent) {
/* No more windows. */
killfamily(top);
return;
}
if (res) {
/* Create a new window... */
if (!(newtop = hlp_read(res->keyword))) {
err_printf("Internal error: bad link\n");
continue;
}
newtop->next = parent->children;
parent->children = newtop;
newtop->parent = parent;
newtop->xposition = parent->xposition + 50;
newtop->yposition = parent->yposition + 50;
if (!hlp_tdisplay(newtop)) {
fprintf(cp_err, "Couldn't display\n");
return;
}
}
else {
/* Blow this one and its descendants away. */
killfamily(parent);
if (parent->parent) {
if (parent->parent->children == parent)
parent->parent->children =
parent->next;
else {
for (pa = parent->parent->children;
pa->next; pa = pa->next)
if (pa->next == parent)
break;
if (!pa->next) {
err_printf("bah...\n");
}
pa->next = pa->next->next;
}
}
if (parent == top)
return;
}
}
}
/* Note that this doesn't actually free the data structures, just gets
* rid of the window.
*/
static void
killfamily(top)
topic *top;
{
topic *ch;
for (ch = top->children; ch; ch = ch->next)
killfamily(ch);
hlp_tkillwin(top);
top->children = NULL;
return;
}
kic-2.4c/src/kic/ 0000755 0000764 0000764 00000000000 12427446157 013265 5 ustar stevew stevew kic-2.4c/src/kic/point.c 0000644 0000764 0000764 00000065334 12427244452 014567 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Graphical and keyboard input.
*/
#include "prefix.h"
#include "kic.h"
#define DEBOUNCETIME 100
/* button1: basic point operation
* button2: pan operation
* button3: window operation
* button4: return coords, no operation
*/
/* Point() command characters */
#define ESC 27
#define BSP '\b'
#define DEL 127
#define NEWL 13
#define SPA 32
#define CTRL_A 1
#define CTRL_C 3
#define CTRL_E 5
#define CTRL_F 6
#define CTRL_G 7
#define CTRL_L 12
#define CTRL_N 14
#define CTRL_T 20
#define CTRL_U 21
#define CTRL_V 22
#define CTRL_W 23
#define CTRL_X 24
static int OldButton3; /* remember last button 3 */
static int OldButton3X,OldButton3Y;
#define Matching(string) !strcmp(Parameters.kpCommand,string)
/* we keep track of the time between pointing events to debounce the cursor */
static unsigned int LastPointTime = 0;
/* SRW ** disable screen modifying functions such as scaling, pan. */
int LockOut;
/* SRW ** return from Point() if esc entered */
int EscReturn;
#ifdef __STDC__
static void show_sq_info(void);
static int button_press(int,int,int);
static void new_fine_window(int,int,int,int);
static void type_coordinate(void);
static void where_am_i(int,int,int);
static int ctrl_at(int,int);
static int is_pcw(int,int);
#else
static void show_sq_info();
static int button_press();
static void new_fine_window();
static void type_coordinate();
static void where_am_i();
static int ctrl_at();
static int is_pcw();
#endif
extern char *VersionString;
void
Point()
{
/*
* When user has typed Condition, do Action.
*
* Condition
* shortest unique prefix of Menu[i]
* Action
* Return with command selected stored in Parameters.kpCommand.
*
* Condition
* ESC
* Action
* Forget remembered type in.
*
* Condition
* ctrl-a
* Action
* Execute abort routine.
*
* Condition
* point key or tablet stylus button Z
* Action
* If user is pointing at a layer in the layer table viewport,
* change the current layer.
* If user is pointing at a command menu selection, return with
* command selected stored as Parameters.kpCommand.
* If user is pointing inside a layout viewport--coarse or fine--
* return with Parameters.kpCommand[0] == EOS and cursor
* descriptor up-to-date.
*
* Condition
* ctrl-c or ctrl-e
* Action
* Prompt user for a coordinate.
* Return with Parameters.kpCommand[0] == EOS and cursor
* descriptor up-to-date.
*
* Condition
* ctrl-f or tablet stylus button 1
* Action
* Wait for user to point.
* Redisplay in fine viewport around where he pointed
* if fine positioning is enabled, or pan otherwise.
*
* Condition
* ctrl-g
* Action
* Change scale of magnifying glass, or otherwise window, using
* next two point actions.
*
* Condition
* ctrl-l
* Action
* Select current layer from keyboard
*
* Condition
* ctrl-n
* Action
* Save the present view context in a list.
*
* Condition
* ctrl-t or ctrl-v
* Action
* Toggle position of magnifying glass, bottom or right.
*
* Condition
* ctrl-w or tablet stylus button 2
* Action
* Wait for user to point.
* Show location, but perform no action.
*/
char *TypeIn;
MENU *Menu;
unsigned int newtime;
int NumCommand,Buttons,Int1,Int2,Int3;
int Layer;
int X,Y;
int Key;
extern char *MenuEXIT;
show_sq_info();
/*
* The best way to handle interrupts reliably is to
* initialize the service routines as frequently as
* possible. Therefore, . . .
*/
InitSignals();
Menu = GetCurrentMenu();
Parameters.kpCommand[NumCommand = 0] = EOS;
Parameters.kpPointLayerTable = False;
Parameters.kpPointCoarseWindow = False;
if (OldButton3) {
OldButton3 = False;
FBSetRubberBanding(0);
}
LastPointTime = FBTime();
loop {
loop {
FBPoint(&X,&Y,&Key,&Buttons);
if (Key != 0) {
/* convert to lower case */
if (isupper(Key)) Key = tolower(Key);
break;
}
if (FB.fButtons) {
if ((Buttons == FB.fButtonMask[0] Or
Buttons == FB.fButtonMask[1] Or
Buttons == FB.fButtonMask[2] Or
Buttons == FB.fButtonMask[3]) And
(X < FB.fMaxX And X > 0 And Y < FB.fMaxY And Y > 0))
break;
}
}
if (Xcheck()) {
/* debouncing is done in msdos graphis library, otherwise do it
* here
*/
newtime = FBTime();
if (newtime > LastPointTime &&
newtime - LastPointTime < DEBOUNCETIME)
continue;
LastPointTime = newtime;
}
switch (Key) {
case 0:
break;
case BSP:
case DEL:
if (NumCommand) NumCommand--;
Parameters.kpCommand[NumCommand] = EOS;
continue;
case ESC:
Parameters.kpCommand[NumCommand = 0] = EOS;
/* SRW ** so we know if esc was entered */
Parameters.kpCommand[1] = ESC;
if (EscReturn) return;
continue;
case NEWL:
Parameters.kpCommand[NumCommand = 0] = EOS;
if (ctrl_at(X,Y)) return;
continue;
case '!':
/* shell command */
if (LockOut) continue; /* ignore */
ShowPrompt("! ");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
ShowProcess(TypeIn);
Parameters.kpCommand[NumCommand = 0] = EOS;
continue;
case CTRL_A:
/* SRW ** abort gracefully */
strcpy(Parameters.kpCommand,MenuEXIT);
NumCommand = 0;
return;
case CTRL_C:
case CTRL_E:
type_coordinate();
Parameters.kpCommand[NumCommand = 0] = EOS;
return;
case CTRL_F:
if (LockOut) continue; /* ignore ^F */
Parameters.kpCommand[NumCommand = 0] = EOS;
SaveLastView();
/* SRW ** pan if coarse viewport only */
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY) {
if (!InBox(X,Y,View->kvCoarseViewport)) {
NotPointingAtLayout();
continue;
}
PToL(View->kvCoarseWindow,&X,&Y);
InitCoarseWindow(X,Y,(int)View->kvCoarseWindow->kaWidth);
InitFineWindow(X,Y);
RedisplayViewports();
}
else
FinePosition(X,Y,Key);
/*
* This is necessary for debouncing.
* It takes time to redisplay, so we set the time of the last
* pointing event when the redisplay is finished.
*/
LastPointTime = FBTime();
continue;
case CTRL_G:
if (LockOut) continue; /* ignore ^G */
Parameters.kpCommand[NumCommand = 0] = EOS;
if (Parameters.kpCellName[0] == EOS)
return;
loop {
ShowPrompt("Point to diagonal of area to be magnified.");
FBPoint(&X,&Y,&Key,&Buttons);
if (Key == ESC) goto skip;
if (FB.fButtons And Buttons == FB.fButtonMask[0]) {
if (InBox(X,Y,View->kvCoarseViewport))
PToL(View->kvCoarseWindow,&X,&Y);
elif (InBox(X,Y,View->kvFineViewport))
PToL(View->kvFineWindow,&X,&Y);
else {
NotPointingAtLayout();
continue;
}
OldButton3X = X;
OldButton3Y = Y;
FBSetRubberBanding('R');
break;
}
}
loop {
ShowPrompt("Point to second endpoint.");
FBPoint(&X,&Y,&Key,&Buttons);
if (Key == ESC) {
FBSetRubberBanding(0);
goto skip;
}
if (FB.fButtons And Buttons == FB.fButtonMask[0]) {
if (InBox(X,Y,View->kvCoarseViewport))
PToL(View->kvCoarseWindow,&X,&Y);
elif (InBox(X,Y,View->kvFineViewport))
PToL(View->kvFineWindow,&X,&Y);
else {
NotPointingAtLayout();
continue;
}
FBSetRubberBanding(0);
break;
}
}
new_fine_window(OldButton3X,OldButton3Y,X,Y);
skip:
ErasePrompt();
continue;
case CTRL_L:
ShowPrompt("Layer #?");
Layer = 1;
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
sscanf(TypeIn,"%d",&Layer);
PointLayerTable(LayerTableViewport.kaBottom,(Layer-1)*6+1);
Parameters.kpCommand[NumCommand = 0] = EOS;
ErasePrompt();
return;
case CTRL_N:
Parameters.kpCommand[NumCommand = 0] = EOS;
SaveViewOnStack();
continue;
case CTRL_U:
case CTRL_X:
NumCommand = 0;
Parameters.kpCommand[0] = EOS;
continue;
case CTRL_V:
sprintf(TypeOut,
"KIC-%s distrib. by Whiteley Research Inc. www.wrcad.com",
VersionString);
ShowPrompt(TypeOut);
continue;
case CTRL_T:
if (LockOut) continue; /* ignore */
Parameters.kpCommand[NumCommand = 0] = EOS;
View->kvFineViewportOnBottom ^= 1;
InitViewport();
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY)
continue;
SetPositioning();
ShowParameters();
RedisplayViewports();
continue;
case CTRL_W:
where_am_i(X,Y,Key);
Parameters.kpCommand[NumCommand = 0] = EOS;
continue;
case SPA:
where_am_i(X,Y,(char)0);
Parameters.kpCommand[NumCommand = 0] = EOS;
continue;
default:
Parameters.kpCommand[NumCommand++] = Key;
if (NumCommand > 80) NumCommand = 80;
Parameters.kpCommand[NumCommand] = EOS;
/*
* Test for shortest unique prefix, or prefix matching upper
* case part of menu. Stupid search is plenty fast.
*/
Int3 = -1;
Int2 = 0;
for (Int1 = 0; Menu[Int1].mEntry != NULL; Int1++) {
for (Int2 = 0; Int2 < NumCommand; Int2++) {
char c = Menu[Int1].mPrefix[Int2];
if (isupper(c)) c = tolower(c);
if (Parameters.kpCommand[Int2] != c) break;
}
if (Parameters.kpCommand[Int2] == EOS And Int2 > 0) {
if (!Menu[Int1].mPrefix[Int2]) {
/* found a match */
if (Int3 >= 0) {
/* oops, more than 1 match */
Int2 = -1;
break;
}
Int3 = Int1;
}
}
}
if (Int3 >= 0 && Int2 >= 0) {
strcpy(Parameters.kpCommand,Menu[Int3].mEntry);
return;
}
continue;
}
NumCommand = 0;
if (button_press(Buttons,X,Y))
return;
}
}
static void
show_sq_info()
{
struct ks *s, *ss;
int Row,Col,cnt;
/* put message in properties line, flushed right */
Row = FB.fNumRows - 1;
Col = FB.fNumColumns - 10;
OutlineText(Col,Row,FB.fNumColumns,Row,FILL,ERASE,0);
if (SelectQHead) {
for (cnt = 0, s = SelectQHead; s; s = s->ksSucc)
if (s->ksPointer->oInfo == SQ_OLDSEL ||
s->ksPointer->oInfo == SQ_NEWSEL) {
cnt++;
/* check for dups */
for (ss = s->ksSucc; ss; ss = ss->ksSucc) {
if (s->ksPointer == ss->ksPointer) {
cnt--;
break;
}
}
}
if (cnt) {
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col,"select:");
sprintf(TypeOut,"%d",cnt);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col + 7,TypeOut);
}
}
}
static int
button_press(Buttons,X,Y)
int Buttons;
int X,Y;
{
Parameters.kpCommand[0] = EOS;
if (Buttons == 0) {
/* shouldn't get here unless null from keyboard */
return (False);
}
if (Buttons == FB.fButtonMask[0]) {
if (ctrl_at(X,Y)) return (True);
return (False);
}
if (Buttons == FB.fButtonMask[1]) {
if (LockOut) { /* treat like button 0 */
Buttons = FB.fButtonMask[0];
if (ctrl_at(X,Y)) return (True);
return (False);
}
SaveLastView();
/* pan if coarse viewport only */
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY) {
if (!InBox(X,Y,View->kvCoarseViewport)) {
NotPointingAtLayout();
return (False);
}
PToL(View->kvCoarseWindow,&X,&Y);
InitCoarseWindow(X,Y,(int)View->kvCoarseWindow->kaWidth);
InitFineWindow(X,Y);
RedisplayViewports();
}
else
FinePosition(X,Y,(char)0);
LastPointTime = FBTime();
return (False);
}
if (Buttons == FB.fButtonMask[2]) {
where_am_i(X,Y,(char)0);
return (False);
}
if (Buttons == FB.fButtonMask[3]) {
if (Parameters.kpCellName[0] == EOS) return (False);
if (LockOut) { /* treat like button 0 */
Buttons = FB.fButtonMask[0];
if (ctrl_at(X,Y)) return (True);
return (False);
}
if (Not OldButton3) {
if (InBox(X,Y,View->kvCoarseViewport))
PToL(View->kvCoarseWindow,&X,&Y);
elif (InBox(X,Y,View->kvFineViewport))
PToL(View->kvFineWindow,&X,&Y);
else {
NotPointingAtLayout();
return (False);
}
OldButton3X = KicCursor.kcRawX;
OldButton3Y = KicCursor.kcRawY;
KicCursor.kcRawX = X;
KicCursor.kcRawY = Y;
FBSetRubberBanding('R');
KicCursor.kcRawX = OldButton3X;
KicCursor.kcRawY = OldButton3Y;
OldButton3X = X;
OldButton3Y = Y;
OldButton3 = True;
}
else {
if (InBox(X,Y,View->kvCoarseViewport))
PToL(View->kvCoarseWindow,&X,&Y);
elif (InBox(X,Y,View->kvFineViewport))
PToL(View->kvFineWindow,&X,&Y);
else {
NotPointingAtLayout();
return (False);
}
FBSetRubberBanding(0);
OldButton3 = False;
new_fine_window(OldButton3X,OldButton3Y,X,Y);
}
return (False);
}
if (Buttons == FB.fButtonMask[4]) {
return (False);
}
return (False);
}
int
PointLoop(LookedAhead)
/* Loop until UNDO, a "non-safe" command, point to coarse window, or
* ESC is entered. Return value used for dispatching in non-safe (i.e.,
* cell modifying) commands.
*/
int *LookedAhead;
{
extern char *MenuUNDO;
loop {
if (*LookedAhead == False) {
EscReturn = True;
Point();
EscReturn = False;
}
else
*LookedAhead = False;
if (Parameters.kpCommand[1] == ESC)
return (PL_ESC);
if (Parameters.kpCommand[0] != EOS) {
if (SafeCmds(LookedAhead))
continue;
if (Matching(MenuUNDO)) return (PL_UND);
*LookedAhead = True;
return (PL_CMD);
}
if (Parameters.kpPointLayerTable)
continue;
if (Parameters.kpPointCoarseWindow)
return (PL_PCW);
NotPointingAtLayout();
}
}
int
PointLoopCreate(LookedAhead)
/* Same as PointLoop(), but returns PL_PLT when the layer table is
* pointed to. This enables routines that are creating geometry to
* redraw with the correct layer during object creation.
*/
int *LookedAhead;
{
extern char *MenuUNDO;
loop {
if (*LookedAhead == False) {
EscReturn = True;
Point();
EscReturn = False;
}
else
*LookedAhead = False;
if (Parameters.kpCommand[1] == ESC)
return (PL_ESC);
if (Parameters.kpCommand[0] != EOS) {
if (SafeCmds(LookedAhead))
continue;
if (Matching(MenuUNDO)) return (PL_UND);
*LookedAhead = True;
return (PL_CMD);
}
if (Parameters.kpPointLayerTable)
return (PL_PLT);
if (Parameters.kpPointCoarseWindow)
return (PL_PCW);
NotPointingAtLayout();
}
}
int
PointLoopSafe(LookedAhead)
/* Loop until UNDO, any command, point to coarse window, or
* ESC is entered. Return value used for dispatching in safe
* (i.e. non cell modifying) commands.
*/
int *LookedAhead;
{
loop {
EscReturn = True;
Point();
EscReturn = False;
if (Parameters.kpCommand[1] == ESC)
return (PL_ESC);
if (Parameters.kpCommand[0] != EOS) {
*LookedAhead = True;
return (PL_CMD);
}
if (Parameters.kpPointLayerTable)
continue;
if (Parameters.kpPointCoarseWindow)
return (PL_PCW);
NotPointingAtLayout();
}
}
int
PointLoopLayer(LookedAhead)
/* Loop until any command, point to layer menu, or
* ESC is entered. Return value used for dispatching in
* layer selection commands.
*/
int *LookedAhead;
{
loop {
EscReturn = True;
Point();
EscReturn = False;
if (Parameters.kpCommand[1] == ESC)
return (PL_ESC);
if (Parameters.kpCommand[0] != EOS) {
*LookedAhead = True;
return (PL_CMD);
}
if (Parameters.kpPointLayerTable)
return (PL_PLT);
if (Parameters.kpPointCoarseWindow)
return (PL_PCW);
}
}
void
NotPointingAtLayout()
{
ShowPromptAndWait("You aren't pointing in the layout viewport.");
}
void
RedisplayKIC()
/* Redisplay what is on the screen. */
{
if (RepaintFILL())
return;
if (RepaintMore())
return;
FullRedisplay();
}
void
FullRedisplay()
/* This is called after a resizing, or after the screen has been
* seriously messed with. We reinititialize everything, as the
* parameters may have changed. RedrawPrompt should take care of
* anything on the prompt line, including a return from FBGetchar()
* in the DISPLAY mode. FBKbRepaint() redraws the editing input
* if there was any.
*/
{
FBBegin(FB.fDisplay);
InitViewport();
InitCoarseWindow(View->kvCoarseWindow->kaX,View->kvCoarseWindow->kaY,
(int)View->kvCoarseWindow->kaWidth);
SetCurrentAOI(View->kvCoarseWindow);
InitFineWindow(View->kvFineWindow->kaX,View->kvFineWindow->kaY);
InitVLT();
FBForeground(ERASE,0);
FBFlood();
ShowCommandMenu();
ShowLayerTable();
ShowParameters();
if (Parameters.kpCellName[0] != EOS) {
Redisplay(View->kvCoarseWindow);
if (Parameters.kpRedisplayControl == SPLITSCREEN)
XORfineViewport();
}
RedrawPrompt();
FBKbRepaint((1+FB.fLastCursorColumn)*FB.fFontWidth,
FB.fMaxY - FB.fFontHeight*(FB.fNumRows-2));
}
void
FinePosition(X,Y,Key)
int X,Y;
int Key;
{
int Buttons;
if (Parameters.kpCellName[0] == EOS)
return;
if (Not FB.fButtons Or Key != EOS) {
ShowPrompt("Point to center of area you want magnified.");
loop {
FBPoint(&X,&Y,&Key,&Buttons);
if (Key == EOS Or Key == NEWL)
break;
elif (Key == CTRL_C Or Key == CTRL_E) {
type_coordinate();
CoarseLToP(KicCursor.kcX,KicCursor.kcY,X,Y);
ClipVP(View->kvCoarseViewport,X,Y);
break;
}
}
}
if (InBox(X,Y,View->kvCoarseViewport))
PToL(View->kvCoarseWindow,&X,&Y);
elif (InBox(X,Y,View->kvFineViewport))
PToL(View->kvFineWindow,&X,&Y);
else {
NotPointingAtLayout();
return;
}
XORfineViewport();
InitFineWindow(X,Y);
XORfineViewport();
ShowFineViewport();
}
static void
new_fine_window(OldX,OldY,X,Y)
int OldX,OldY,X,Y;
{
int NewWindowWidth, Hei, Wid, Tmp, CenterX, CenterY;
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY) {
SaveLastView();
Wid = X - OldX;
Hei = Y - OldY;
if (Wid < 0) Wid = -Wid;
if (Hei < 0) Hei = -Hei;
Tmp = Hei*
(View->kvCoarseViewport->kaWidth/
View->kvCoarseViewport->kaHeight);
NewWindowWidth = max(Wid,Tmp);
if (NewWindowWidth <= 0)
NewWindowWidth = RESOLUTION;
Wid /= 2;
Hei /= 2;
InitCoarseWindow(min(X,OldX)+Wid,
min(Y,OldY)+Hei,NewWindowWidth);
InitFineWindow(min(X,OldX)+Wid,
min(Y,OldY)+Hei);
RedisplayViewports();
ShowParameters();
}
else {
if (X > OldX)
SwapInts(X,OldX);
if ((OldX - X) < 2) { /* two lambda minimum width */
ShowPrompt("Magnifying glass width too small.");
return;
}
SaveLastView();
if (Y > OldY)
SwapInts(Y,OldY);
CenterX = (OldX - X)/2 + X;
CenterY = (OldY - Y)/2 + Y;
View->kvFineWindow->kaWidth = OldX - X;
View->kvFineWindow->kaHeight =
View->kvFineWindow->kaWidth*
(View->kvFineViewport->kaHeight/
View->kvFineViewport->kaWidth);
XORfineViewport();
InitFineWindow(CenterX,CenterY);
XORfineViewport();
ShowFineViewport();
}
}
static void
type_coordinate()
{
char *TypeIn;
int i;
float x, y;
ShowPrompt("x y? ");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL) {
i = sscanf(TypeIn,"%f%f",&x,&y);
if (i >= 1) {
KicCursor.kcPredX = KicCursor.kcX;
KicCursor.kcX = (int)(RESOLUTION*x);
KicCursor.kcDX = KicCursor.kcX-KicCursor.kcPredX;
}
if (i == 2) {
KicCursor.kcPredY = KicCursor.kcY;
KicCursor.kcY = (int)(RESOLUTION*y);
KicCursor.kcDY = KicCursor.kcY-KicCursor.kcPredY;
}
if (i >= 1)
ShowParameters();
}
Parameters.kpPointCoarseWindow = True;
ErasePrompt();
}
static void
where_am_i(X,Y,Key)
int X,Y;
int Key;
{
int Buttons;
if (Not FB.fButtons Or Key != 0) {
ShowPrompt("Point to see where you are.");
loop {
FBPoint(&X,&Y,&Key,&Buttons);
if (Not FB.fButtons And Key == NEWL)
break;
if (FB.fButtons And Buttons == FB.fButtonMask[0] And
X < FB.fMaxX And X > 0 And Y < FB.fMaxY And Y > 0)
break;
}
}
if (is_pcw(X,Y))
return;
NotPointingAtLayout();
Parameters.kpCommand[0] = '\0';
}
static int
ctrl_at(X,Y)
int X,Y;
{
int i, Row, Column;
MENU *Menu;
if (is_pcw(X,Y)) {
Parameters.kpPointCoarseWindow = True;
return (True);
}
Menu = GetCurrentMenu();
Row = (FB.fMaxY-Y-3)/FB.fFontHeight+1;
Column = X/FB.fFontWidth+1;
if (InBox(Column,Row,&MenuViewport)) {
for (i = 0; ; i++)
if (Menu[i].mEntry == NULL) break;
if (Column > 5)
Row += MenuViewport.kaY;
if (i > Row - 1) {
strcpy(Parameters.kpCommand,Menu[Row-1].mEntry);
return (True);
}
return (False);
}
if (InBox(Column,Row,&LayerTableViewport)) {
Parameters.kpCommand[0] = '\0';
return (PointLayerTable(Row,Column));
}
return (False);
}
static int
is_pcw(X,Y)
int X,Y;
{
if (InBox(X,Y,View->kvCoarseViewport)) {
KicCursor.kcInFine = False;
KicCursor.kcPredX = KicCursor.kcX;
KicCursor.kcPredY = KicCursor.kcY;
KicCursor.kcX = X;
KicCursor.kcY = Y;
KicCursor.kcRawX = X;
KicCursor.kcRawY = Y;
PToL(View->kvCoarseWindow,&KicCursor.kcX,&KicCursor.kcY);
PToL(View->kvCoarseWindow,&KicCursor.kcRawX,&KicCursor.kcRawY);
ClipToGridPoint(&KicCursor.kcX,&KicCursor.kcY);
KicCursor.kcDX = KicCursor.kcX-KicCursor.kcPredX;
KicCursor.kcDY = KicCursor.kcY-KicCursor.kcPredY;
ShowParameters();
Parameters.kpCommand[0] = '\0';
return (True);
}
if (InBox(X,Y,View->kvFineViewport)) {
KicCursor.kcInFine = True;
KicCursor.kcPredX = KicCursor.kcX;
KicCursor.kcPredY = KicCursor.kcY;
KicCursor.kcX = X;
KicCursor.kcY = Y;
KicCursor.kcRawX = X;
KicCursor.kcRawY = Y;
PToL(View->kvFineWindow,&KicCursor.kcX,&KicCursor.kcY);
PToL(View->kvFineWindow,&KicCursor.kcRawX,&KicCursor.kcRawY);
ClipToGridPoint(&KicCursor.kcX,&KicCursor.kcY);
KicCursor.kcDX = KicCursor.kcX-KicCursor.kcPredX;
KicCursor.kcDY = KicCursor.kcY-KicCursor.kcPredY;
ShowParameters();
Parameters.kpCommand[0] = '\0';
return (True);
}
return (False);
}
kic-2.4c/src/kic/more.c 0000644 0000764 0000764 00000012051 12427444065 014366 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/*************************************************************************
*
* Routines for "More" text presentation.
*
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
static int MoreOn; /* Turns on "more" mode, set/reset in InitMore() */
static int DidInitMore; /* Set if successful initialize in "more" mode */
static char *MoreBuffer; /* page storage, malloc'ed */
static char *MoreLinePtr; /* pointer to next line in storage */
static int MoreCols; /* Number of colums to save */
static int MoreRows; /* Number of rows to show */
static int MoreAt; /* current row */
#ifdef __STDC__
static void init_more(void);
static int more_prompt(void);
static void fixtabs(char*,char*);
#else
static void init_more();
static int more_prompt();
static void fixtabs();
#endif
int
MoreLine(line)
/* Add a line to the buffer, show buffer if page is full */
char *line;
{
char *s, c;
if (!MoreOn) return (False);
if (!DidInitMore) init_more();
if (!DidInitMore) return (False); /* malloc failed */
/* line is terminated with return code, have to strip for DOS
* and UNIX
*/
s = strchr(line,(char)0xd);
if (s) *s = '\0';
s = strchr(line,(char)0xa);
if (s) *s = '\0';
s = line;
while (strlen(s) > MoreCols) {
c = *(s + MoreCols);
*(s + MoreCols) = '\0';
fixtabs(MoreLinePtr,s);
MoreLinePtr += MoreCols + 1;
MoreAt++;
if (MoreAt >= MoreRows) {
MorePageDisplay();
if (more_prompt()) return (True);
}
*(s + MoreCols) = c;
s += MoreCols;
if (!*s) return (False);
}
fixtabs(MoreLinePtr,s);
MoreLinePtr += MoreCols + 1;
MoreAt++;
if (MoreAt >= MoreRows) {
MorePageDisplay();
if (more_prompt()) return (True);
}
return (False);
}
void
EnableMore(On)
int On;
{
if (On)
MoreOn = True;
else {
MoreOn = False;
if (!DidInitMore) return;
DidInitMore = False;
free(MoreBuffer);
MoreBuffer = NULL;
}
}
int
RepaintMore()
/* redraw the screen following an expose event */
{
if (!MoreOn)
return (False);
FBBegin(FB.fDisplay);
InitViewport();
InitCoarseWindow(View->kvCoarseWindow->kaX,View->kvCoarseWindow->kaY,
(int)View->kvCoarseWindow->kaWidth);
InitFineWindow(View->kvFineWindow->kaX,View->kvFineWindow->kaY);
InitVLT();
FBForeground(ERASE,0);
FBFlood();
ShowCommandMenu();
ShowLayerTable();
RedrawPrompt();
FBKbRepaint((1+FB.fLastCursorColumn)*FB.fFontWidth,
FB.fMaxY - FB.fFontHeight*(FB.fNumRows-2));
(void)MorePageDisplay();
return (True);
}
int
MorePageDisplay()
/* returns False if nothing to print */
{
char *s;
int Y;
if (MoreLinePtr == MoreBuffer)
return (False);
EraseLargeCoarseViewport();
FBForeground(DISPLAY,ColorTable[MoreTextColor].Ent);
Y = View->kvLargeCoarseViewport->kaTop - FB.fFontHeight - 1;
for (s = MoreBuffer; s < MoreLinePtr; s += MoreCols + 1) {
FBText(PIXEL_COORDINATE,
(View->kvLargeCoarseViewport->kaLeft+7),Y,s);
Y -= FB.fFontHeight;
}
return (True);
}
static void
init_more()
{
int i;
extern int hlp_width;
MoreAt = 0;
MoreRows = (View->kvLargeCoarseViewport->kaTop -
View->kvLargeCoarseViewport->kaBottom)/FB.fFontHeight - 2;
MoreCols = (View->kvLargeCoarseViewport->kaRight -
View->kvLargeCoarseViewport->kaLeft - 8)/FB.fFontWidth;
if (MoreBuffer == NULL) {
MoreBuffer = malloc(MoreRows*(MoreCols+1));
if (MoreBuffer == NULL) {
ShowPrompt("Error, Out of memory!");
return;
}
}
MoreLinePtr = MoreBuffer;
for (i = 0; i < MoreRows; i++) {
*MoreLinePtr = '\0';
MoreLinePtr += MoreCols + 1;
}
MoreLinePtr = MoreBuffer;
DidInitMore = True;
hlp_width = MoreCols;
}
static int
more_prompt()
{
int i;
char *s, InChar;
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(PIXEL_COORDINATE,View->kvLargeCoarseViewport->kaLeft+7,
View->kvLargeCoarseViewport->kaBottom+1,
" --More--");
InChar = FBGetchar(ERASE);
(void)InChar;
MoreAt = 0;
s = MoreBuffer;
for (i = 0; i < MoreRows; i++) {
*s = '\0';
s += MoreCols + 1;
}
MoreLinePtr = MoreBuffer;
/* can't do this */
/*
if (InChar == ESCAPE || InChar == 'q')
return (True);
*/
return (False);
}
static void
fixtabs(dst,src)
char *src, *dst;
{
char *s, *t;
for (s = src, t = dst; *s; ) {
if (*s == '\t') {
while ((t+1-dst)%8) *t++ = ' ';
*t++ = ' ';
s++;
}
else {
*t++ = *s++;
}
}
*t = '\0';
}
kic-2.4c/src/kic/modify.c 0000644 0000764 0000764 00000045214 11132463564 014717 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Stretch command
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuSTRCH;
extern char *MenuUNDO;
extern char *MenuTBRL;
extern char *MenuTB;
extern char *MenuRL;
#ifdef __STDC__
static void do_stretch(int,int,int,int,struct ka*,int);
static struct p *get_nearest_vertex(struct p*,int,int);
static void change_nearest_vertex(struct p*,int,int,int,int,int);
static void change_rect_vertex(struct ka*,struct ka*,int,int,int,int);
static int set_ref_to_vertex(int*,int*);
#else
static void do_stretch();
static struct p *get_nearest_vertex();
static void change_nearest_vertex();
static void change_rect_vertex();
static int set_ref_to_vertex();
#endif
static int RCode;
void
Stretch(LookedAhead)
int *LookedAhead;
{
struct ka NBB,OBB;
int RefX = 0,RefY = 0,LastRefX,LastRefY,MapX = 0,MapY = 0;
int RefTmpX, RefTmpY;
int FirstTime = True;
int GotOne = False;
int Undo = False;
int Modified = 0;
int LastCode;
int Pt;
char Types[4];
MenuSelect(MenuSTRCH);
Types[0] = CDPOLYGON;
Types[1] = CDWIRE;
Types[2] = CDBOX;
Types[3] = '\0';
if (AreTypesInQ(Types))
GotOne = True;
loop {
top:
if (Not GotOne) {
ShowPrompt("Point at geometry to stretch.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime) goto quit;
if (Undo == False) {
MenuSelect(MenuUNDO);
SQRestore(True);
/* restored objects have Info = SQ_NEWSEL */
Modified--;
Undo = True;
NBB = OBB;
EraseBox(&OBB);
Redisplay(&OBB);
MenuDeselect(MenuUNDO);
break;
}
else {
/* should have only Info = SQ_NEW objects here */
do_stretch(RefX,RefY,MapX,MapY,&NBB,False);
Modified++;
EraseBox(&NBB);
Redisplay(&NBB);
Undo = False;
MenuDeselect(MenuUNDO);
continue;
}
case PL_PCW:
SelectTypes(Types);
if (Not AreTypesInQ(Types))
goto top;
SQComputeBB();
NBB = SelectQBB;
}
}
next:
ShowPrompt("Point to the reference vertex.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
if (Not GotOne)
SQDesel(Types);
/* newly selected objects deleted, restored objects
* have Info = SQ_NEW.
*/
else {
if (FirstTime) {
MenuDeselect(MenuUNDO);
goto quit;
}
if (Undo == False) {
SQRestore(True);
/* restored objects have Info = SQ_NEWSEL */
Modified--;
Undo = True;
}
else {
/* should have only Info = SQ_NEWSEL objects here */
do_stretch(RefX,RefY,MapX,MapY,&NBB,True);
Modified++;
Undo = False;
}
}
EraseBox(&NBB);
Redisplay(&NBB);
MenuDeselect(MenuUNDO);
goto top;
}
LastRefX = RefX;
LastRefY = RefY;
RefX = KicCursor.kcX;
RefY = KicCursor.kcY;
LastCode = RCode;
RCode = set_ref_to_vertex(&RefX,&RefY);
SetRelative(RefX,RefY,True);
ShowPrompt("Point to where it should stretch.");
RefTmpX = KicCursor.kcX;
RefTmpY = KicCursor.kcY;
KicCursor.kcX = RefX;
KicCursor.kcY = RefY;
FBSetRubberBanding('s');
KicCursor.kcX = RefTmpX;
KicCursor.kcY = RefTmpY;
Pt = PointLoop(LookedAhead);
FBSetRubberBanding(0);
switch (Pt) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
RefX = LastRefX;
RefY = LastRefY;
RCode = LastCode;
MenuDeselect(MenuUNDO);
goto next;
}
SQRestore(False);
/* should have only Info = SQ_OLDSEL objects here */
FirstTime = False;
SetRelative(0L,0L,False);
MapX = KicCursor.kcX;
MapY = KicCursor.kcY;
do_stretch(RefX,RefY,MapX,MapY,&NBB,GotOne);
EraseBox(&NBB);
Redisplay(&NBB);
OBB = NBB;
Modified++;
Undo = False;
}
quit:
SQRestore(False);
if (Not GotOne And AreTypesInQ(Types)) {
SQComputeBB();
SQDesel(Types);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
MenuDeselect(MenuUNDO);
MenuDeselect(MenuSTRCH);
}
void
SetStretchMode()
{
if (strcmp(Parameters.kpCommand,MenuTBRL) == 0) {
AlterMenuEntries(MenuTBRL,MenuTB);
MenuSelect(MenuTB);
Parameters.kpStretchType = STR_TB;
return;
}
if (strcmp(Parameters.kpCommand,MenuTB) == 0) {
AlterMenuEntries(MenuTB,MenuRL);
MenuSelect(MenuRL);
Parameters.kpStretchType = STR_RL;
return;
}
if (strcmp(Parameters.kpCommand,MenuRL) == 0) {
AlterMenuEntries(MenuRL,MenuTBRL);
MenuDeselect(MenuTBRL);
Parameters.kpStretchType = STR_TBRL;
return;
}
}
static void
do_stretch(RefX,RefY,MapX,MapY,NBB,SelectNew)
int RefX,RefY,MapX,MapY;
struct ka *NBB;
int SelectNew;
{
struct prpty *PrptyDesc;
struct ks *SQDesc;
struct ka OBB,BB;
struct o *Pointer;
struct p *Path;
int X,Y,DX,DY;
int Layer;
NBB->kaLeft = CDINFINITY;
NBB->kaRight = -CDINFINITY;
NBB->kaBottom = CDINFINITY;
NBB->kaTop = -CDINFINITY;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
Pointer = NULL;
if (SQDesc->ksPointer->oType == CDWIRE) {
CDWire(SQDesc->ksPointer,&Layer,&DX,&Path);
CDStatusInt = CDBB(Parameters.kpCellDesc,SQDesc->ksPointer,
&OBB.kaLeft,&OBB.kaBottom,&OBB.kaRight,&OBB.kaTop);
Path = CopyPath(Path);
change_nearest_vertex(Path,RefX,RefY,MapX,MapY,CDWIRE);
if (Not CDMakeWire(Parameters.kpCellDesc,Layer,DX,Path,
&Pointer)) MallocFailed();
}
elif (SQDesc->ksPointer->oType == CDPOLYGON) {
CDPolygon(SQDesc->ksPointer,&Layer,&Path);
CDStatusInt = CDBB(Parameters.kpCellDesc,SQDesc->ksPointer,
&OBB.kaLeft,&OBB.kaBottom,&OBB.kaRight,&OBB.kaTop);
Path = CopyPath(Path);
change_nearest_vertex(Path,RefX,RefY,MapX,MapY,CDPOLYGON);
if (Not CDMakePolygon(Parameters.kpCellDesc,Layer,Path,
&Pointer)) MallocFailed();
}
elif (SQDesc->ksPointer->oType == CDBOX) {
OBB.kaLeft = SQDesc->ksPointer->oLeft;
OBB.kaRight = SQDesc->ksPointer->oRight;
OBB.kaBottom = SQDesc->ksPointer->oBottom;
OBB.kaTop = SQDesc->ksPointer->oTop;
change_rect_vertex(&BB,&OBB,RefX,RefY,MapX,MapY);
X = (BB.kaLeft + BB.kaRight)/2;
Y = (BB.kaBottom + BB.kaTop)/2;
DX = BB.kaRight - BB.kaLeft;
if (DX < 0) DX = -DX;
DY = BB.kaTop - BB.kaBottom;
if (DY < 0) DY = -DY;
if (DX == 0 || DY == 0 ||
DX < LayerTable[
(int)SQDesc->ksPointer->oLayer].klMinDimensions ||
DY < LayerTable[
(int)SQDesc->ksPointer->oLayer].klMinDimensions) {
ShowPromptAndWait("Can't do it, width too small.");
CDBox(SQDesc->ksPointer,&Layer,&DX,&DY,&X,&Y);
}
if (Not CDMakeBox(Parameters.kpCellDesc,SQDesc->ksPointer->oLayer,DX,DY,X,Y,
&Pointer)) MallocFailed();
}
if (Pointer) {
if (SelectNew)
Pointer->oInfo = SQ_NEWSEL;
else
Pointer->oInfo = SQ_NEW;
SQInsert(Pointer);
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (OBB.kaLeft < BB.kaLeft) BB.kaLeft = OBB.kaLeft;
if (OBB.kaRight > BB.kaRight) BB.kaRight = OBB.kaRight;
if (OBB.kaBottom < BB.kaBottom) BB.kaBottom = OBB.kaBottom;
if (OBB.kaTop > BB.kaTop) BB.kaTop = OBB.kaTop;
if (BB.kaLeft < NBB->kaLeft) NBB->kaLeft = BB.kaLeft;
if (BB.kaRight > NBB->kaRight) NBB->kaRight = BB.kaRight;
if (BB.kaBottom < NBB->kaBottom) NBB->kaBottom = BB.kaBottom;
if (BB.kaTop > NBB->kaTop) NBB->kaTop = BB.kaTop;
CDProperty(Parameters.kpCellDesc,SQDesc->ksPointer,&PrptyDesc);
while (PrptyDesc) {
CDAddProperty(Parameters.kpCellDesc,Pointer,
PrptyDesc->prpty_Value,PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
SQDesc->ksPointer->oInfo = SQ_GONE;
}
}
void
ShowStretch(MapX,MapY,RefX,RefY)
/* Called from rubber banding routine. */
int RefX,RefY,MapX,MapY;
{
struct ks *SQDesc, *SQDesc1;
struct ka OBB, BB;
struct p *Path, *pp;
int Layer;
int Width;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo != SQ_OLDSEL &&
SQDesc->ksPointer->oInfo != SQ_NEWSEL) continue;
/* draw only once if in queue more than once */
for (SQDesc1 = SQDesc->ksSucc; SQDesc1; SQDesc1 = SQDesc1->ksSucc)
if (SQDesc1->ksPointer == SQDesc->ksPointer) break;
if (SQDesc1 != NULL) continue;
switch (SQDesc->ksPointer->oType) {
case CDWIRE:
CDWire(SQDesc->ksPointer,&Layer,&Width,&Path);
pp = get_nearest_vertex(Path,RefX,RefY);
if (Parameters.kpStretchType != STR_TB)
pp->pX += MapX - RefX;
if (Parameters.kpStretchType != STR_RL)
pp->pY += MapY - RefY;
ShowWire(ColorTable[HighlightingColor].Ent,Width,Path);
if (Parameters.kpStretchType != STR_TB)
pp->pX -= MapX - RefX;
if (Parameters.kpStretchType != STR_RL)
pp->pY -= MapY - RefY;
break;
case CDPOLYGON:
CDPolygon(SQDesc->ksPointer,&Layer,&Path);
pp = get_nearest_vertex(Path,RefX,RefY);
if (Parameters.kpStretchType != STR_TB)
pp->pX += MapX - RefX;
if (Parameters.kpStretchType != STR_RL)
pp->pY += MapY - RefY;
ShowPolygon(ColorTable[HighlightingColor].Ent,Path);
if (Parameters.kpStretchType != STR_TB)
pp->pX -= MapX - RefX;
if (Parameters.kpStretchType != STR_RL)
pp->pY -= MapY - RefY;
break;
case CDBOX:
OBB.kaLeft = SQDesc->ksPointer->oLeft;
OBB.kaRight = SQDesc->ksPointer->oRight;
OBB.kaBottom = SQDesc->ksPointer->oBottom;
OBB.kaTop = SQDesc->ksPointer->oTop;
change_rect_vertex(&BB,&OBB,RefX,RefY,MapX,MapY);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
break;
}
}
}
static struct p *
get_nearest_vertex(Path,X,Y)
/* return the path vertex nearest X,Y. */
struct p *Path;
int X,Y;
{
double dx,dy,d,mind;
struct p *p;
int i,indx = 0;
mind = 1e30;
for (p = Path,i = 0; p; p = p->pSucc,i++) {
dx = p->pX - X;
dy = p->pY - Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = i;
}
}
for (p = Path, i = 0; i < indx; p = p->pSucc,i++) ;
return p;
}
static void
change_nearest_vertex(Path,X,Y,NewX,NewY,Type)
/* Translate the path vertex nearest X,Y to NewX-X,NewY-Y. */
struct p *Path;
int X,Y,NewX,NewY;
int Type;
{
double dx,dy,d,mind;
struct p *p;
int i,indx = 0;
mind = 1e30;
for (p = Path,i = 0; p; p = p->pSucc,i++) {
dx = p->pX - X;
dy = p->pY - Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = i;
}
}
if (indx == 0 && Type == CDPOLYGON) {
for (p = Path; p && p->pSucc; p = p->pSucc) ;
if (Path->pX == p->pX And Path->pY == p->pY) {
if (Parameters.kpStretchType != STR_TB)
p->pX += NewX - X;
if (Parameters.kpStretchType != STR_RL)
p->pY += NewY - Y;
}
}
for (p = Path, i = 0; i < indx; p = p->pSucc,i++) ;
if (Parameters.kpStretchType != STR_TB)
p->pX += NewX - X;
if (Parameters.kpStretchType != STR_RL)
p->pY += NewY - Y;
}
static void
change_rect_vertex(NBB,OBB,X,Y,NewX,NewY)
/* set NBB to the new box */
struct ka *NBB,*OBB;
int X,Y,NewX,NewY;
{
int indx = 0, Code;
double d,dx,dy,mind;
Code = RCode;
if (Code == 0) {
mind = 1e30;
dx = OBB->kaLeft - X;
dy = OBB->kaBottom - Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 1;
}
dy = OBB->kaTop - Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 2;
}
dx = OBB->kaRight - X;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 3;
}
dy = OBB->kaBottom - Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 4;
}
Code = indx;
}
*NBB = *OBB;
switch (Code) {
case 1:
if (Parameters.kpStretchType != STR_TB)
NBB->kaLeft += NewX - X;
if (Parameters.kpStretchType != STR_RL)
NBB->kaBottom += NewY - Y;
return;
case 2:
if (Parameters.kpStretchType != STR_TB)
NBB->kaLeft += NewX - X;
if (Parameters.kpStretchType != STR_RL)
NBB->kaTop += NewY - Y;
return;
case 3:
if (Parameters.kpStretchType != STR_TB)
NBB->kaRight += NewX - X;
if (Parameters.kpStretchType != STR_RL)
NBB->kaTop += NewY - Y;
return;
case 4:
if (Parameters.kpStretchType != STR_TB)
NBB->kaRight += NewX - X;
if (Parameters.kpStretchType != STR_RL)
NBB->kaBottom += NewY - Y;
}
}
static int
set_ref_to_vertex(X,Y)
/* Return in pointers the vertex closest to the given coordinates.
* Checks rectangle vertices as well as polys and wires. If a
* rectangle vertex is closest, this function returns a code identifying
* the vertex (1 BL, 2 TL, 3 TR, 4 BR), otherwise 0 is returned.
*/
int *X,*Y;
{
struct ks *SQDesc;
struct o *Pointer = NULL;
struct p *p,*Path;
double dx,dy,d,mind;
int i,indx = 0;
mind = 1e30;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
if (SQDesc->ksPointer->oType == CDBOX) {
dx = SQDesc->ksPointer->oLeft - *X;
dy = SQDesc->ksPointer->oBottom - *Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 1;
Pointer = SQDesc->ksPointer;
}
dy = SQDesc->ksPointer->oTop - *Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 2;
Pointer = SQDesc->ksPointer;
}
dx = SQDesc->ksPointer->oRight - *X;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 3;
Pointer = SQDesc->ksPointer;
}
dy = SQDesc->ksPointer->oBottom - *Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = 4;
Pointer = SQDesc->ksPointer;
}
continue;
}
if (SQDesc->ksPointer->oType == CDWIRE)
Path = ((struct w *)SQDesc->ksPointer->oRep)->wPath;
else if (SQDesc->ksPointer->oType == CDPOLYGON)
Path = ((struct po *)SQDesc->ksPointer->oRep)->poPath;
else
continue;
for (p = Path,i = 0; p; p = p->pSucc,i++) {
dx = p->pX - *X;
dy = p->pY - *Y;
d = dx*dx + dy*dy;
if (d < mind) {
mind = d;
indx = i;
Pointer = SQDesc->ksPointer;
}
}
}
if (Pointer->oType == CDBOX) {
switch (indx) {
case 1:
*X = Pointer->oLeft;
*Y = Pointer->oBottom;
break;
case 2:
*X = Pointer->oLeft;
*Y = Pointer->oTop;
break;
case 3:
*X = Pointer->oRight;
*Y = Pointer->oTop;
break;
case 4:
*X = Pointer->oRight;
*Y = Pointer->oBottom;
}
return (indx);
}
if (Pointer->oType == CDWIRE)
Path = ((struct w *)Pointer->oRep)->wPath;
else
Path = ((struct po *)Pointer->oRep)->poPath;
for (p = Path, i = 0; i < indx; p = p->pSucc,i++) ;
*X = p->pX;
*Y = p->pY;
return (0);
}
kic-2.4c/src/kic/copy.c 0000644 0000764 0000764 00000047236 07525346713 014417 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Copy and move selection operators.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuCOPY;
extern char *MenuMOVE;
extern char *MenuUNDO;
#define MOVE 1
#define COPY 0
#ifdef __STDC__
static void show_move(struct ka*,struct ka*);
static int copy_ok(int,int);
static void do_copy(int,int,int,int,struct ka*,int);
static char fix_xform(int);
static void do_copy_call(int,int,int,int,struct o*,struct o**);
static void add_transform(struct o*,int*);
static void free_path(struct p*);
#else
static void show_move();
static int copy_ok();
static void do_copy();
static char fix_xform();
static void do_copy_call();
static void add_transform();
static void free_path();
#endif
void
Copy(LookedAhead)
int *LookedAhead;
{
struct ka BB;
int RefX,RefY,CopX = 0,CopY = 0;
int i;
int Undo = False;
int FirstTime = True;
int GotOne = False;
int Modified = 0;
MenuSelect(MenuCOPY);
if (SelectQHead != NULL)
GotOne = True;
top:
if (Not GotOne) {
ShowPrompt("Point to object to copy.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
case PL_UND:
goto quit;
case PL_PCW:
BB.kaLeft = BB.kaRight = KicCursor.kcRawX;
BB.kaBottom = BB.kaTop = KicCursor.kcRawY;
Selection(&BB);
if (SelectQHead == NULL)
goto top;
}
}
Next:
ShowPrompt("Point to the reference point.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (Not GotOne) {
SQComputeBB();
SQDesel((char*)NULL);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
goto top;
}
goto quit;
}
FBSetRubberBanding('m');
RefX = KicCursor.kcX;
RefY = KicCursor.kcY;
SetRelative(RefX,RefY,True);
ShowPrompt("Point to locations where the selected items will be copied.");
loop {
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
if (FirstTime) {
MenuDeselect(MenuUNDO);
FBSetRubberBanding(0);
goto Next;
}
if (Undo == False) {
SQRestore(True);
EraseBox(&BB);
Redisplay(&BB);
Modified--;
Undo = True;
}
else {
do_copy(RefX,RefY,CopX,CopY,&BB,COPY);
Redisplay(&BB);
Modified++;
Undo = False;
}
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
CopX = KicCursor.kcX;
CopY = KicCursor.kcY;
i = copy_ok(CopX-RefX,CopY-RefY);
if (i == -1) goto quit;
if (i == 0) continue;
SQRestore(False);
do_copy(RefX,RefY,CopX,CopY,&BB,COPY);
FirstTime = False;
Undo = False;
Modified++;
Redisplay(&BB);
continue;
}
}
quit:
FBSetRubberBanding(0);
SQRestore(False);
if (Not GotOne And AreTypesInQ((char*)NULL)) {
SQComputeBB();
SQDesel((char*)NULL);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
MenuDeselect(MenuUNDO);
MenuDeselect(MenuCOPY);
}
void
Move(LookedAhead)
int *LookedAhead;
{
struct ka OldBB,NewBB;
int LastRefX,LastRefY;
int RefX = 0,RefY = 0,MovX = 0,MovY = 0;
int FirstTime = True;
int GotOne = False;
int Modified = 0;
int Undo = False;
MenuSelect(MenuMOVE);
if (SelectQHead != NULL)
GotOne = True;
loop {
top:
if (Not GotOne) {
ShowPrompt("Point to object to move.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime) goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
SQRestore(True);
/* restored objects have Info = SQ_NEWSEL */
show_move(&NewBB,&OldBB);
Modified--;
Undo = True;
MenuDeselect(MenuUNDO);
break;
}
else {
/* should have only Info = SQ_NEW objects here */
do_copy(RefX,RefY,MovX,MovY,&NewBB,MOVE);
SQDesel((char*)NULL);
show_move(&OldBB,&NewBB);
Modified++;
Undo = False;
MenuDeselect(MenuUNDO);
continue;
}
case PL_PCW:
SelectTypes((char*)NULL);
if (Not AreTypesInQ((char*)NULL))
goto top;
}
}
next:
ShowPrompt("Point to the reference point.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
if (Not GotOne) {
SQComputeBB();
SQDesel((char*)NULL);
/* newly selected objects deleted, restored objects
* have Info = SQ_NEW.
*/
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
else {
if (FirstTime) {
MenuDeselect(MenuUNDO);
goto quit;
}
if (Undo == False) {
SQRestore(True);
/* restored objects have Info = SQ_NEWSEL */
show_move(&OldBB,&NewBB);
Modified--;
Undo = True;
}
else {
/* should have only Info = SQ_NEWSEL objects here */
do_copy(RefX,RefY,MovX,MovY,&NewBB,MOVE);
show_move(&OldBB,&NewBB);
Modified++;
Undo = False;
}
}
MenuDeselect(MenuUNDO);
goto top;
}
FBSetRubberBanding('m');
LastRefX = RefX;
LastRefY = RefY;
RefX = KicCursor.kcX;
RefY = KicCursor.kcY;
SetRelative(RefX,RefY,True);
ShowPrompt("Point to where the selected items will be moved.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
RefX = LastRefX;
RefY = LastRefY;
MenuDeselect(MenuUNDO);
FBSetRubberBanding(0);
goto next;
}
FBSetRubberBanding(0);
SQComputeBB();
OldBB = SelectQBB;
MovX = KicCursor.kcX;
MovY = KicCursor.kcY;
SetRelative(0L,0L,False);
SQRestore(False);
do_copy(RefX,RefY,MovX,MovY,&NewBB,MOVE);
FirstTime = False;
Modified++;
Undo = False;
if (Not GotOne)
SQDesel((char*)NULL);
show_move(&OldBB,&NewBB);
}
quit:
FBSetRubberBanding(0);
SetRelative(0L,0L,False);
SQRestore(False);
if (Not GotOne And AreTypesInQ((char*)NULL)) {
SQComputeBB();
SQDesel((char*)NULL);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
if (Modified)
Parameters.kpModified = True;
ErasePrompt();
MenuDeselect(MenuUNDO);
MenuDeselect(MenuMOVE);
}
void
CopyPathWithXForm(Path)
struct p **Path;
{
struct p *OldPair,*NewPair;
/*
* Copy Path with transform and return pointer to new path
*/
OldPair = *Path;
if ((NewPair = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
*Path = NewPair;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
TPoint(&NewPair->pX,&NewPair->pY);
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
while(OldPair != NULL) {
if ((NewPair->pSucc = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
NewPair = NewPair->pSucc;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
TPoint(&NewPair->pX,&NewPair->pY);
OldPair = OldPair->pSucc;
}
}
void
ShowMove(RefX,RefY,NewX,NewY)
int RefX,RefY,NewX,NewY;
{
struct ks *SQDesc;
struct p *Path;
struct ka BB;
int Layer;
int Width;
int TFold[9], TFnew[9];
TCurrent(TFold);
TPush();
TIdentity();
SetNewTransform(RefX,RefY,NewX,NewY);
TCurrent(TFnew);
TPop();
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo != SQ_OLDSEL &&
SQDesc->ksPointer->oInfo != SQ_NEWSEL) continue;
/* prevent drawing duplicate entries twice */
SQDesc->ksPointer->oInfo += 20;
switch (SQDesc->ksPointer->oType) {
case CDBOX:
case CDSYMBOLCALL:
case CDLABEL:
GetBB(SQDesc->ksPointer,&BB);
TLoadCurrent(TFnew);
TPoint(&BB.kaLeft,&BB.kaBottom);
TPoint(&BB.kaRight,&BB.kaTop);
TLoadCurrent(TFold);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
break;
case CDWIRE:
CDWire(SQDesc->ksPointer,&Layer,&Width,&Path);
TLoadCurrent(TFnew);
CopyPathWithXForm(&Path);
TLoadCurrent(TFold);
ShowWire(ColorTable[HighlightingColor].Ent,Width,Path);
free_path(Path);
break;
case CDPOLYGON:
CDPolygon(SQDesc->ksPointer,&Layer,&Path);
TLoadCurrent(TFnew);
CopyPathWithXForm(&Path);
TLoadCurrent(TFold);
ShowPath(ColorTable[HighlightingColor].Ent,Path,True);
free_path(Path);
break;
}
}
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc)
if (SQDesc->ksPointer->oInfo > 20)
SQDesc->ksPointer->oInfo -= 20;
}
static void
show_move(OBB,NBB)
struct ka *OBB,*NBB;
{
int L1,R1,B1,T1,L2,R2,B2,T2;
struct ka BB;
L1 = NBB->kaLeft;
R1 = NBB->kaRight;
B1 = NBB->kaBottom;
T1 = NBB->kaTop;
L2 = OBB->kaLeft;
R2 = OBB->kaRight;
B2 = OBB->kaBottom;
T2 = OBB->kaTop;
if (L1 > R1) SwapInts(L1,R1);
if (B1 > T1) SwapInts(B1,T1);
if (L2 > R2) SwapInts(L2,R2);
if (B2 > T2) SwapInts(B2,T2);
if (L1 > R2 Or L2 > R1 Or B1 > T2 Or B2 > T1) {
/*
* Old BB is not within the new BB
* So, redisplay twice.
*/
EraseBox(OBB);
Redisplay(OBB);
EraseBox(NBB);
Redisplay(NBB);
return;
}
/*
* Old BB intersects new BB
*/
BB.kaLeft = min(L1,L2);
BB.kaRight = max(R1,R2);
BB.kaBottom = min(B1,B2);
BB.kaTop = max(T1,T2);
EraseBox(&BB);
Redisplay(&BB);
}
static int
copy_ok(X,Y)
int X,Y;
{
char *TypeIn;
if (Not Parameters.kpMX And Not Parameters.kpMY And
Parameters.kpRotationAngle == 0 And
X == 0 And Y == 0 ) {
ShowPrompt(
"This will copy objects directly over themselves. Continue(N)?");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) return (-1);
if ((TypeIn[0] != 'Y' And TypeIn[0] != 'y'))
return (0);
}
return (1);
}
static void
do_copy(RefX,RefY,NewX,NewY,NewBB,MoveOrCopy)
int RefX,RefY,NewX,NewY;
struct ka *NewBB;
int MoveOrCopy;
{
struct prpty *PrptyDesc;
struct ks *SQDesc;
struct p *Path;
struct ka BB;
struct o *Pointer;
int Layer;
char Xform;
char *Label;
int X,Y,Length,Width;
BB.kaLeft = BB.kaRight = NewX;
BB.kaTop = BB.kaBottom = NewY;
NewBB->kaLeft = NewBB->kaRight = NewX;
NewBB->kaTop = NewBB->kaBottom = NewY;
TPush();
TIdentity();
SetNewTransform(RefX,RefY,NewX,NewY);
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
switch (SQDesc->ksPointer->oType) {
case CDBOX:
CDBox(SQDesc->ksPointer,&Layer,&Length,&Width,&X,&Y);
TPoint(&X,&Y);
if (Parameters.kpRotationAngle == 90 Or
Parameters.kpRotationAngle == 270) {
SwapInts(Width,Length);
}
if (Not CDMakeBox(Parameters.kpCellDesc,Layer,Length,Width,
X,Y,&Pointer)) MallocFailed();
break;
case CDLABEL:
CDLabel(SQDesc->ksPointer,&Layer,&Label,&X,&Y,&Xform);
TPoint(&X,&Y);
if (Not CDMakeLabel(Parameters.kpCellDesc,Layer,Label,
X,Y,fix_xform(Xform),&Pointer)) MallocFailed();
break;
case CDWIRE:
CDWire(SQDesc->ksPointer,&Layer,&Width,&Path);
CopyPathWithXForm(&Path);
if (Not CDMakeWire(Parameters.kpCellDesc,Layer,Width,Path,
&Pointer)) MallocFailed();
break;
case CDPOLYGON:
CDPolygon(SQDesc->ksPointer,&Layer,&Path);
CopyPathWithXForm(&Path);
if (Not CDMakePolygon(Parameters.kpCellDesc,Layer,Path,
&Pointer)) MallocFailed();
break;
case CDSYMBOLCALL:
do_copy_call(RefX,RefY,NewX,NewY,SQDesc->ksPointer,&Pointer);
break;
}
GetBB(Pointer,&BB);
if (MoveOrCopy == MOVE)
Pointer->oInfo = SQ_NEWSEL;
else
Pointer->oInfo = SQ_NEW;
SQInsert(Pointer);
if (BB.kaLeft < NewBB->kaLeft) NewBB->kaLeft = BB.kaLeft;
if (BB.kaRight > NewBB->kaRight) NewBB->kaRight = BB.kaRight;
if (BB.kaBottom < NewBB->kaBottom) NewBB->kaBottom = BB.kaBottom;
if (BB.kaTop > NewBB->kaTop) NewBB->kaTop = BB.kaTop;
if (MoveOrCopy == MOVE)
SQDesc->ksPointer->oInfo = SQ_GONE;
PrptyDesc = SQDesc->ksPointer->oPrptyList;
while (PrptyDesc) {
CDAddProperty(Parameters.kpCellDesc,Pointer,
PrptyDesc->prpty_Value,PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
TPop();
}
static char
fix_xform(Xform)
int Xform;
{
int TF[9];
char xf;
TPush();
TIdentity();
xf = Xform & 3;
if (xf != 0) {
if (xf == 1) TRotate(0L,1L);
elif (xf == 2) TRotate(-1L,0L);
elif (xf == 3) TRotate(0L,-1L);
}
if (Xform & 4) TMY();
if (Xform & 8) TMX();
if (Parameters.kpRotationAngle != 0) {
if (Parameters.kpRotationAngle == 180) TRotate(-1L,0L);
elif (Parameters.kpRotationAngle == 90) TRotate(0L,1L);
elif (Parameters.kpRotationAngle == 270) TRotate(0L,-1L);
}
if (Parameters.kpMX) TMX();
if (Parameters.kpMY) TMY();
TCurrent(TF);
Xform = SetXform(TF);
TPop();
return ((char)Xform);
}
static void
do_copy_call(RefX,RefY,NewX,NewY,OPointer,NPointer)
int RefX,RefY,NewX,NewY;
struct o *OPointer;
struct o **NPointer;
{
char *SymbolName;
char Type;
int NumX,NumY;
int X,Y;
int DX,DY;
int TF[9];
struct o *Pointer;
struct t *TGen;
CDCall(OPointer,&SymbolName,&NumX,&DX,&NumY,&DY);
/* only possible error is CDMALLOCFAILED */
if (Not CDBeginMakeCall(Parameters.kpCellDesc,SymbolName,
NumX,DX,NumY,DY,&Pointer))
MallocFailed();
TPush();
TIdentity();
CDInitTGen(OPointer,&TGen);
loop {
/* first determine transform of the placed cell */
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) break;
elif (Type == CDTRANSLATE) TTranslate(X,Y);
elif (Type == CDROTATE) TRotate(X,Y);
elif (Type == CDMIRRORY) TMY();
elif (Type == CDMIRRORX) TMX();
}
/* now add the previous transform to that of the move */
SetNewTransform(RefX,RefY,NewX,NewY);
TCurrent(TF);
add_transform(Pointer,TF);
if (Not CDEndMakeCall(Parameters.kpCellDesc,Pointer))
MallocFailed();
*NPointer = Pointer;
TPop();
}
void
SetNewTransform(RefX,RefY,NewX,NewY)
int RefX,RefY,NewX,NewY;
{
TTranslate(-RefX,-RefY);
if (Parameters.kpMX) TMX();
if (Parameters.kpMY) TMY();
if (Parameters.kpRotationAngle != 0) {
if (Parameters.kpRotationAngle == 90) TRotate(0L,1L);
elif (Parameters.kpRotationAngle == 180) TRotate(-1L,0L);
elif (Parameters.kpRotationAngle == 270) TRotate(0L,-1L);
}
TTranslate(NewX,NewY);
}
static void
add_transform(Pointer,TF)
struct o *Pointer;
int *TF;
{
int A,B,C,D,TX,TY;
int ret;
/*
* Take the transformation defined in TF and add
* it to the symbol call currently being created.
*
* | a c 0 |
* Transform = TM = | b d 0 |
* | TX TY 1 |
*
* A = TM[0][0] = TF[0];
* B = TM[1][0] = TF[3];
* C = TM[0][1] = TF[1];
* D = TM[1][1] = TF[4];
* TX = TM[2][0] = TF[6];
* TY = TM[2][1] = TF[7];
*/
A = TF[0]; B = TF[3]; C = TF[1]; D = TF[4];
TX = TF[6]; TY = TF[7];
if (A == 0 And B == 1 And C == 1 And D == 0) {
/* MX R 0 -1 T tx,ty */
ret = CDT(Pointer,CDMIRRORX,0L,0L);
ret &= CDT(Pointer,CDROTATE,0L,-1L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == 0 And B == -1 And C == -1 And D == 0) {
/* MX R 0 1 T tx,ty */
ret = CDT(Pointer,CDMIRRORX,0L,0L);
ret &= CDT(Pointer,CDROTATE,0L,1L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == 0 And B == 1 And C == -1 And D == 0) {
/* R 0 -1 T tx,ty */
ret = CDT(Pointer,CDROTATE,0L,-1L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == 0 And B == -1 And C == 1 And D == 0) {
/* R 0 1 T tx,ty */
ret = CDT(Pointer,CDROTATE,0L,1L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == 1 And B == 0 And C == 0 And D == 1) {
/* T tx,ty */
ret = CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == -1 And B == 0 And C == 0 And D == -1) {
/* R -1 0 T tx,ty */
ret = CDT(Pointer,CDROTATE,-1L,0L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
elif (A == -1 And B == 0 And C == 0 And D == 1) {
/* MX T tx,ty */
ret = CDT(Pointer,CDMIRRORX,0L,0L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
else {
/* MY T tx,ty */
ret = CDT(Pointer,CDMIRRORY,0L,0L);
ret &= CDT(Pointer,CDTRANSLATE,TX,TY);
}
if (Not ret)
MallocFailed();
}
static void
free_path(Path)
struct p *Path;
{
struct p *Next;
for (; Path; Path = Next) {
Next = Path->pSucc;
afree(Path,p);
}
}
kic-2.4c/src/kic/techfile.c 0000644 0000764 0000764 00000041406 10270227345 015207 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley, Ed Gould
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Here is the format.
*
* Path? (~user/KIC)
*
* LayerName? nd
* Color'sName? green
* RGB? 0 255 0
* Filled? y
* (Invisible)
* (Blink)
* MinDimensions? 2
* Symbolic? n
* (tran ...)
* (resis ...)
* (cap ...)
*
* ...
* () = Optional
*/
#include "prefix.h"
#include "kic.h"
/* used by InitParameters() routine in init.c */
int FineVPonBottom = True;
char InitScreenMode = FULLSCREEN;
#define curlayer LayerTable[layer]
#define Matching(string) (!strcmp(cp,string))
#ifdef __STDC__
static char *get_keyword(FILE*,char*);
static int get_int(char*);
static void get_color(char*,int);
#else
static char *get_keyword();
static int get_int();
static void get_color();
#endif
void
ReadTechFile()
{
int layer = 0;
int i,j;
int rgb[3];
int fp[8];
char c,*cp;
char str1[512];
char inbuf[512]; /* 512 character input buffer */
FILE *techfile;
double d;
/*
* Initialize for default values
*/
Parameters.kpGridDisplayed = True;
Parameters.kpGridOnTop = True;
Parameters.kpShowGridInLargeViewport = False;
Parameters.kpDisplayAllLabels = False;
Parameters.kpLabelAllInstances = False;
Parameters.kpGridLineStyle = 0xcc;
Parameters.kpHardcopyResolution = 150; /* 75,100,150,300 */
*Parameters.kpHardcopyFormat = POSTSC;
#ifdef MSDOS
Parameters.kpHardcopyDevice = "prn";
#else
Parameters.kpHardcopyDevice = "lpr";
#endif
Parameters.kpNumRoundFlashSides = 20;
Parameters.kpPixToLambdaSnapping = 1;
*Parameters.kpFontName = '\0';
Parameters.kpCursorShape = -1;
Parameters.kpFullScreenCursor = False;
Parameters.kpPointBeepVolume = 0;
/*
* In lambda * RESOLUTION units
*/
Parameters.kpGrid = RESOLUTION;
LayerTable[0].klAttributes = FILLED | VISIBLE;
LayerTable[0].klStyleID = 0;
/*
* CDInit must be invoked only once,
* else the layer table will be trashed
*/
if (CDInit())
MallocFailed();
/* exit on error */
if ((techfile = OpenTechFile()) == NULL)
fatal_error("Can not open startup file.");
while ((cp = get_keyword(techfile,inbuf)) != NULL) {
if (Matching("PATH")) {
for (i = 0; inbuf[i] != '(' && inbuf[i]; i++) ;
if (inbuf[i] == '\0') continue;
i++;
while (isspace(inbuf[i])) i++;
for (j = 0; (str1[j] = inbuf[i]) != ')' && inbuf[i]; i++,j++) ;
if (inbuf[i] == '\0') continue;
j--;
while (isspace(str1[j])) j--;
str1[j+1] = '\0';
CDPath(str1);
continue;
}
if (Matching("LAYERNAME") || Matching("LAYER")) {
if (++layer > CDNUMLAYERS)
fatal_error("There are too many layers in your tech file.");
curlayer.klTechnology =
curlayer.klMask[0] =
curlayer.klMask[1] =
curlayer.klMask[2] = ' ';
curlayer.klAttributes |= VISIBLE | ALT_VISIBLE;
for (i = 0; (c = inbuf[i]) != 0; i++) {
if ((c > 057 && c < 072) || (c > 0100 && c < 0133)
|| (c > 0140 && c < 0173))
break;
}
if (c == '\0') continue;
curlayer.klTechnology = c;
if (((c = inbuf[++i]) > 057 && c < 072) ||
(c > 0100 && c < 0133) || (c > 0140 && c < 0173)) {
curlayer.klMask[0] = c;
if (((c = inbuf[++i]) > 057 && c < 072) ||
(c > 0100 && c < 0133) || (c > 0140 && c < 0173)) {
curlayer.klMask[1] = c;
if (((c = inbuf[++i]) > 057 && c < 072) ||
(c > 0100 && c < 0133) || (c > 0140 && c < 0173)) {
curlayer.klMask[2] = c;
}
}
}
CDSetLayer(layer, curlayer.klTechnology,curlayer.klMask);
continue;
}
if (Matching("RGB")) {
rgb[0] = rgb[1] = rgb[2] = 0;
sscanf(inbuf,"%d %d %d",&rgb[0],&rgb[1],&rgb[2]);
curlayer.klR = max(min(rgb[0],255),0);
curlayer.klG = max(min(rgb[1],255),0);
curlayer.klB = max(min(rgb[2],255),0);
continue;
}
if (Matching("SYMBOLIC")) {
i = 0;
while (isspace(inbuf[i])) i++;
if (inbuf[i] == '\0') continue;
if (inbuf[i] == 'y' || inbuf[i] == 'Y')
curlayer.klAttributes |= SYMBOLIC;
continue;
}
if (Matching("FILLED")) {
i = 0;
while (isspace(inbuf[i])) i++;
if (inbuf[i] == '\0') continue;
if (inbuf[i] == 'y' || inbuf[i] == 'Y')
curlayer.klAttributes |= FILLED;
else if (inbuf[i] == 'n' || inbuf[i] == 'N')
curlayer.klAttributes &= ~FILLED;
else {
*str1 = '\0';
fp[0] = 0;
fp[1] = 0;
fp[2] = 0;
fp[3] = 0;
fp[4] = 0;
fp[5] = 0;
fp[6] = 0;
fp[7] = 0;
curlayer.klAttributes |= FILLED;
sscanf(inbuf+i, "%x %x %x %x %x %x %x %x %s",
fp,fp+1,fp+2,fp+3,fp+4,fp+5,fp+6,fp+7,str1);
curlayer.klStyle[0] = fp[0];
curlayer.klStyle[1] = fp[1];
curlayer.klStyle[2] = fp[2];
curlayer.klStyle[3] = fp[3];
curlayer.klStyle[4] = fp[4];
curlayer.klStyle[5] = fp[5];
curlayer.klStyle[6] = fp[6];
curlayer.klStyle[7] = fp[7];
if (*str1 == 'y' || *str1 == 'Y' ||
*str1 == 'o' || *str1 == 'O')
curlayer.klAttributes |= OUTLINED;
}
continue;
}
if (Matching("ALTFILLED")) {
i = 0;
while (isspace(inbuf[i])) i++;
if (inbuf[i] == '\0') continue;
if (inbuf[i] == 'y' || inbuf[i] == 'Y')
curlayer.klAttributes |= ALT_FILLED;
else if (inbuf[i] == 'n' || inbuf[i] == 'N')
curlayer.klAttributes &= ~ALT_FILLED;
else {
*str1 = '\0';
fp[0] = 0;
fp[1] = 0;
fp[2] = 0;
fp[3] = 0;
fp[4] = 0;
fp[5] = 0;
fp[6] = 0;
fp[7] = 0;
curlayer.klAttributes |= ALT_FILLED;
sscanf(inbuf+i, "%x %x %x %x %x %x %x %x %s",
fp,fp+1,fp+2,fp+3,fp+4,fp+5,fp+6,fp+7,str1);
curlayer.klAltStyle[0] = fp[0];
curlayer.klAltStyle[1] = fp[1];
curlayer.klAltStyle[2] = fp[2];
curlayer.klAltStyle[3] = fp[3];
curlayer.klAltStyle[4] = fp[4];
curlayer.klAltStyle[5] = fp[5];
curlayer.klAltStyle[6] = fp[6];
curlayer.klAltStyle[7] = fp[7];
if (*str1 == 'y' || *str1 == 'Y' ||
*str1 == 'o' || *str1 == 'O')
curlayer.klAttributes |= ALT_OUTLINED;
}
continue;
}
if (Matching("INVISIBLE")) {
curlayer.klAttributes &= ~VISIBLE;
continue;
}
if (Matching("ALTINVISIBLE")) {
curlayer.klAttributes &= ~ALT_VISIBLE;
continue;
}
if (Matching("BLINK")) {
curlayer.klAttributes &= BLINK;
continue;
}
if (Matching("MINDIMENSIONS")) {
double ww;
d = ww = 0;
i = sscanf(inbuf,"%lf %lf", &d, &ww);
if (i > 0) {
if (d < 0)
d = 0;
if (ww < d)
ww = d;
curlayer.klMinDimensions = d*RESOLUTION;
curlayer.klWireWidth = ww*RESOLUTION;
}
continue;
}
if (Matching("STREAMDATA")) {
i = j = 0;
sscanf(inbuf,"%d %d",&i,&j);
if (i < 0 || i > 255)
i = 0;
if (j < -1 || j > 255)
j = -1;
curlayer.klStreamNumber = i;
curlayer.klStreamDataType = j;
continue;
}
if (strncmp(cp,"RESIS",5) == 0) {
if (sscanf(inbuf,"%lf",&d) == 1 && d >= 0) {
curlayer.klElectrical = alloc(eparms);
curlayer.klElectrical->e_type = ERESIS;
*curlayer.klElectrical->e_parms = d;
}
continue;
}
if (strncmp(cp,"CAP",3) == 0) {
if (sscanf(inbuf,"%lf",&d) == 1 && d >= 0) {
curlayer.klElectrical = alloc(eparms);
curlayer.klElectrical->e_type = ECAP;
*curlayer.klElectrical->e_parms = d;
}
continue;
}
if (strncmp(cp,"TRAN",4) == 0) {
curlayer.klElectrical = alloc(eparms);
curlayer.klElectrical->e_type = ETRANS;
sscanf(inbuf,"%lf %lf %lf %lf %lf %lf",
curlayer.klElectrical->e_parms,
curlayer.klElectrical->e_parms+1,
curlayer.klElectrical->e_parms+2,
curlayer.klElectrical->e_parms+3,
curlayer.klElectrical->e_parms+4,
curlayer.klElectrical->e_parms+5);
continue;
}
if (Matching("GRIDSPACING")) {
if (sscanf(inbuf,"%lf",&d) == 1 && d*RESOLUTION > 0)
Parameters.kpGrid = d*RESOLUTION;
continue;
}
if (Matching("GRIDSTYLE")) {
Parameters.kpGridLineStyle = get_int(inbuf);
continue;
}
if (Matching("ROUNDFLASHSIDES")) {
Parameters.kpNumRoundFlashSides = get_int(inbuf);
continue;
}
if (Matching("SHOWGRID")) {
Parameters.kpShowGridInLargeViewport = True;
continue;
}
if (Matching("ALTSHOWGRID")) {
Parameters.kpHardcopyGrid = True;
continue;
}
if (Matching("ALTDEVICE")) {
i = 0;
while (isspace(inbuf[i])) i++;
Parameters.kpHardcopyDevice = malloc(strlen(inbuf) + 1);
strcpy(Parameters.kpHardcopyDevice,inbuf + i);
continue;
}
if (Matching("ALTRESOLUTION")) {
Parameters.kpHardcopyResolution = get_int(inbuf);
continue;
}
if (Matching("ALTFORMAT")) {
i = 0;
while (isspace(inbuf[i])) i++;
if (inbuf[i] == 'p' || inbuf[i] == 'P')
*Parameters.kpHardcopyFormat = POSTSC;
else if (inbuf[i] == 'h' || inbuf[i] == 'H')
*Parameters.kpHardcopyFormat = HPLASER;
continue;
}
if (Matching("GRIDONBOTTOM")) {
Parameters.kpGridOnTop = False;
continue;
}
if (Matching("DISPLAYALLTEXT")) {
Parameters.kpDisplayAllLabels = True;
continue;
}
if (Matching("LABELALLINSTANCES")) {
Parameters.kpLabelAllInstances = True;
continue;
}
if (Matching("HIGHLIGHTING")) {
rgb[0] = rgb[1] = rgb[2] = 0;
sscanf(inbuf,"%d %d %d",&rgb[0],&rgb[1],&rgb[2]);
ColorTable[HighlightingColor].R = min(max(rgb[0],0),255);
ColorTable[HighlightingColor].G = min(max(rgb[1],0),255);
ColorTable[HighlightingColor].B = min(max(rgb[2],0),255);
continue;
}
if (Matching("BACKGROUND")) {
rgb[0] = rgb[1] = rgb[2] = 0;
sscanf(inbuf,"%d %d %d",&rgb[0],&rgb[1],&rgb[2]);
ColorTable[0].R = min(max(rgb[0],0),255);
ColorTable[0].G = min(max(rgb[1],0),255);
ColorTable[0].B = min(max(rgb[2],0),255);
continue;
}
if (Matching("MENUTEXT")) {
get_color(inbuf,MenuTextColor);
continue;
}
if (Matching("MENUPROMPT")) {
get_color(inbuf,MenuPromptColor);
continue;
}
if (Matching("MORETEXT")) {
get_color(inbuf,MoreTextColor);
continue;
}
if (Matching("MENUHIGHLIGHTING")) {
get_color(inbuf,MenuHighlightingColor);
continue;
}
if (Matching("MENUSELECT")) {
get_color(inbuf,MenuSelectColor);
continue;
}
if (Matching("COARSEGRID")) {
get_color(inbuf,CoarseGridColor);
continue;
}
if (Matching("FINEGRID")) {
get_color(inbuf,FineGridColor);
continue;
}
if (Matching("INSTANCEBOX")) {
get_color(inbuf,InstanceBBColor);
continue;
}
if (Matching("INSTANCENAME")) {
get_color(inbuf,InstanceSizeColor);
continue;
}
if (Matching("INSTANCESIZE")) {
get_color(inbuf,InstanceNameColor);
continue;
}
if (Matching("COLOR'SNAME") || Matching("COLOR"))
/* color name is not used except by people */
continue;
if (Matching("LRC") || Matching("LRCRULES"))
/* don't use these anymore */
continue;
if (Matching("SPLITSCREEN")) {
InitScreenMode = SPLITSCREEN;
continue;
}
/* These were used in XKIC */
if (Matching("NO_OUTLINE")) {
/* obsolete, not used */
continue;
}
if (Matching("SNAPPING")) {
Parameters.kpPixToLambdaSnapping = get_int(inbuf);
continue;
}
if (Matching("FONTNAME")) {
char *ip = inbuf;
while (isspace(*ip)) ++ip;
strncpy(Parameters.kpFontName, ip, 80);
Parameters.kpFontName[80] = EOS;
continue;
}
if (Matching("CURSORSHAPE")) {
Parameters.kpCursorShape = get_int(inbuf);
continue;
}
if (Matching("FULLSCREENCURSOR")) {
Parameters.kpFullScreenCursor = True;
continue;
}
if (Matching("BEEPVOLUME")) {
Parameters.kpPointBeepVolume = get_int(inbuf);
continue;
}
if (Matching("FINEVIEWPORTONSIDE")) {
FineVPonBottom = False;
continue;
}
printf("Warning: unknown keyword \"%s\" in %s file\n",cp,TECHFILE);
}
NumLayerTable = layer;
fclose(techfile);
}
static char
*get_keyword(file,inbuf)
FILE *file;
char *inbuf;
{
char *cp;
int c;
static char keyword[40];
/* look for first key word */
while (((c = getc(file)) < 0101 || c > 0132) && (c < 0141 || c > 0172))
if (c == EOF) return (NULL);
/* scan to end of keyword and convert to upper case */
cp = keyword;
while (c != 040 && c != '\r' && c != '\t' && c != 077 && c != '\n' &&
c != EOF) {
if (c > 0140 && c < 0173) c -= 32;
*cp++ = c;
c = getc(file);
}
*cp = 0;
/* scan to end of line and put args in inbuf */
while (c != '\n' && c != EOF) {
if (c == '\t' || c == 077) c = 040;
*inbuf++ = c;
c = getc(file);
}
*inbuf = 0;
return (keyword);
}
static int
get_int(buf)
char *buf;
{
int i = 0;
sscanf(buf, "%d", &i);
if (i < 0)
i = 0;
return (i);
}
static void
get_color(buf,what)
char *buf;
int what;
{
int i, rgb[3];
rgb[0] = rgb[1] = rgb[2] = 0;
i = sscanf(buf,"%d %d %d",&rgb[0],&rgb[1],&rgb[2]);
if (i == 1) {
ColorTable[what].Ent = rgb[0];
}
else {
ColorTable[what].R = min(max(rgb[0],0),255);
ColorTable[what].G = min(max(rgb[1],0),255);
ColorTable[what].B = min(max(rgb[2],0),255);
}
}
kic-2.4c/src/kic/grid.c 0000644 0000764 0000764 00000022304 07525346713 014357 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Shows a grid in a layout viewport.
*/
#include "prefix.h"
#include "kic.h"
void
ShowGrid()
{
/*
* Show grid for Window within AOI.
* Window maps to Viewport.
*/
int YInL,XInL;
int XInP,YInP;
int Left,Top,Right,Bottom;
int Step;
if (!Parameters.kpGridDisplayed Or Parameters.kpGrid <= 0) {
ShowAxes();
return;
}
FBDefineLineStyle(1,Parameters.kpGridLineStyle);
/*
*
* The grid is computed relative to (0,0).
*
*/
Step = Parameters.kpGrid*5;
if (((Parameters.kpRedisplayControl == COARSEVIEWPORTONLY And
View->kvCoarseViewport == View->kvLargeCoarseViewport) Or
(Parameters.kpRedisplayControl == SPLITSCREEN And
Parameters.kpShowGridInLargeViewport)) And
Parameters.kpGrid*View->kvCoarseRatio
> Parameters.kpPointingThreshold And CurrentAOI.aInCoarse) {
Top = View->kvCoarseWindow->kaTop -
(View->kvCoarseWindow->kaTop % Step);
if (View->kvCoarseWindow->kaTop >= 0)
Top += Step;
Bottom = View->kvCoarseWindow->kaBottom;
Left = View->kvCoarseWindow->kaLeft -
(View->kvCoarseWindow->kaLeft % Step);
if (View->kvCoarseWindow->kaLeft < 0)
Left -= Step;
Right = View->kvCoarseWindow->kaRight;
if (Parameters.kpGridLineStyle == 0) {
/* point grid */
for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
YInP = .5+(YInL - View->kvCoarseWindow->kaBottom)*
View->kvCoarseRatio;
YInP += View->kvCoarseViewport->kaBottom;
if (YInP < CurrentAOI.aBC) break;
if (YInP > CurrentAOI.aTC) continue;
for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
XInP = .5+(XInL - View->kvCoarseWindow->kaLeft)*
View->kvCoarseRatio;
XInP += View->kvCoarseViewport->kaLeft;
if (XInP > CurrentAOI.aRC) break;
if (XInP < CurrentAOI.aLC) continue;
if ((Top-YInL) % Step == 0 || (XInL-Left) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBPixel(XInP,YInP);
}
}
}
else {
/* Horizontal grid lines */
for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
YInP = .5+(YInL - View->kvCoarseWindow->kaBottom)*
View->kvCoarseRatio;
YInP += View->kvCoarseViewport->kaBottom;
if (YInP < CurrentAOI.aBC) break;
if (YInP > CurrentAOI.aTC) continue;
if ((Top-YInL) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBLine(CurrentAOI.aLC,YInP,
CurrentAOI.aRC,YInP);
}
/* Vertical grid lines */
for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
XInP = .5+(XInL - View->kvCoarseWindow->kaLeft)*
View->kvCoarseRatio;
XInP += View->kvCoarseViewport->kaLeft;
if (XInP > CurrentAOI.aRC) break;
if (XInP < CurrentAOI.aLC) continue;
if ((XInL-Left) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBLine(XInP,CurrentAOI.aBC,
XInP,CurrentAOI.aTC);
}
}
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
Parameters.kpGrid*View->kvFineRatio
> Parameters.kpPointingThreshold And CurrentAOI.aInFine) {
Top = View->kvFineWindow->kaTop -
(View->kvFineWindow->kaTop % Step);
if (View->kvFineWindow->kaTop >= 0)
Top += Step;
Bottom = View->kvFineWindow->kaBottom;
Left = View->kvFineWindow->kaLeft -
(View->kvFineWindow->kaLeft % Step);
if (View->kvFineWindow->kaLeft < 0)
Left -= Step;
Right = View->kvFineWindow->kaRight;
if (Parameters.kpGridLineStyle == 0) {
/* point grid */
for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
YInP = .5+(YInL - View->kvFineWindow->kaBottom)*
View->kvFineRatio;
YInP += View->kvFineViewport->kaBottom;
if (YInP < CurrentAOI.aBF) break;
if (YInP > CurrentAOI.aTF) continue;
for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
XInP = .5+(XInL - View->kvFineWindow->kaLeft)*
View->kvFineRatio;
XInP += View->kvFineViewport->kaLeft;
if (XInP > CurrentAOI.aRF) break;
if (XInP < CurrentAOI.aLF) continue;
if ((Top-YInL) % Step == 0 || (XInL-Left) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBPixel(XInP,YInP);
}
}
}
else {
/* Horizontal grid lines */
for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
YInP = .5+(YInL - View->kvFineWindow->kaBottom)*
View->kvFineRatio;
YInP += View->kvFineViewport->kaBottom;
if (YInP < CurrentAOI.aBF) break;
if (YInP > CurrentAOI.aTF) continue;
if ((Top-YInL) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBLine(CurrentAOI.aLF,YInP,
CurrentAOI.aRF,YInP);
}
/* Vertical grid lines */
for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid){
XInP = .5+(XInL - View->kvFineWindow->kaLeft)*
View->kvFineRatio;
XInP += View->kvFineViewport->kaLeft;
if (XInP > CurrentAOI.aRF) break;
if (XInP < CurrentAOI.aLF) continue;
if ((XInL-Left) % Step == 0)
FBForeground(DISPLAY,ColorTable[CoarseGridColor].Ent);
else
FBForeground(DISPLAY,ColorTable[FineGridColor].Ent);
FBLine(XInP,CurrentAOI.aBF,
XInP,CurrentAOI.aTF);
}
}
}
FBSetLineStyle(0);
ShowAxes();
}
void
ShowAxes()
{
int XInP,YInP;
/*
* Display the axes if they are visible.
*/
if (Parameters.kpDoingHardcopy && !Parameters.kpGridDisplayed)
return;
FBForeground(DISPLAY,ColorTable[HighlightingColor].Ent);
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY) {
CoarseLToP(0,0,XInP,YInP);
/* x axis */
if (View->kvCoarseViewport->kaBottom <= YInP And
YInP <= View->kvCoarseViewport->kaTop)
FBLine(View->kvCoarseViewport->kaLeft,YInP,
View->kvCoarseViewport->kaRight,YInP);
/* y axis */
if (View->kvCoarseViewport->kaLeft <= XInP And
XInP <= View->kvCoarseViewport->kaRight)
FBLine(XInP,View->kvCoarseViewport->kaBottom,
XInP,View->kvCoarseViewport->kaTop);
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY) {
FineLToP(0,0,XInP,YInP);
/* x axis */
if (View->kvFineViewport->kaBottom <= YInP And
YInP <= View->kvFineViewport->kaTop)
FBLine(View->kvFineViewport->kaLeft,YInP,
View->kvFineViewport->kaRight,YInP);
/* y axis */
if (View->kvFineViewport->kaLeft <= XInP And
XInP <= View->kvFineViewport->kaRight)
FBLine(XInP,View->kvFineViewport->kaBottom,
XInP,View->kvFineViewport->kaTop);
}
}
kic-2.4c/src/kic/boxes.c 0000644 0000764 0000764 00000050714 07525346713 014560 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Box management.
*
* CIFToKIC--the CDTo routine in the CD package--transforms non-Manhattan
* boxes to polygons, so the direction vector parameter in the routines
* here are superfluous.
*
* KIC only knows about Manhattan boxes.
* To make a 45, the user must use a wire or polygon.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuBOXES;
extern char *MenuUNDO;
int MakingBoxes;
#define ka_copy(BB1,BB2) BB1.kaLeft = BB2->kaLeft; \
BB1.kaRight = BB2->kaRight; \
BB1.kaBottom = BB2->kaBottom; \
BB1.kaTop = BB2->kaTop; \
TPoint(&BB1.kaLeft,&BB1.kaBottom); \
TPoint(&BB1.kaRight,&BB1.kaTop); \
if (BB1.kaLeft > BB1.kaRight) \
SwapInts(BB1.kaLeft,BB1.kaRight); \
if (BB1.kaBottom > BB1.kaTop) \
SwapInts(BB1.kaBottom,BB1.kaTop);
int
InBox(X,Y,AOI)
int X,Y;
struct ka *AOI;
{
if (((AOI->kaLeft <= X And X <= AOI->kaRight) Or
(AOI->kaRight <= X And X <= AOI->kaLeft)) And
((AOI->kaBottom <= Y And Y <= AOI->kaTop) Or
(AOI->kaTop <= Y And Y <= AOI->kaBottom)))
return (True);
return (False);
}
void
ShowBox(Layer,boxBB)
int Layer;
struct ka *boxBB;
{
struct ka BB, BB1, BB2;
int ShowLeft;
int ShowBottom;
int ShowRight;
int ShowTop;
int PixWidth = 2;
if (Layer == ColorTable[HighlightingColor].Ent) {
ShowEmptyBox(Layer,boxBB);
return;
}
ka_copy(BB,boxBB);
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
CoarseLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
CoarseLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRC And BB1.kaRight >= CurrentAOI.aLC And
BB1.kaBottom <= CurrentAOI.aTC And BB1.kaTop >= CurrentAOI.aBC) {
ShowLeft = True;
ShowBottom = True;
ShowRight = True;
ShowTop = True;
if (LayerTable[Layer].klAttributes & FILLED) {
if (BB1.kaLeft < CurrentAOI.aLC) {
BB1.kaLeft = CurrentAOI.aLC;
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBC) {
BB1.kaBottom = CurrentAOI.aBC;
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRC) {
BB1.kaRight = CurrentAOI.aRC;
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTC) {
BB1.kaTop = CurrentAOI.aTC;
ShowTop = False;
}
if (LayerTable[Layer].klAttributes & COARSE_FILL) {
FBFilledBox(Layer,DISPLAY,
LayerTable[Layer].klStyleID,
BB1.kaLeft,BB1.kaBottom,BB1.kaRight,BB1.kaTop);
if (LayerTable[Layer].klAttributes & OUTLINED) {
if (ShowBottom)
FBLine(BB1.kaRight,BB1.kaBottom,
BB1.kaLeft,BB1.kaBottom);
if (ShowLeft)
FBLine(BB1.kaLeft,BB1.kaBottom,
BB1.kaLeft,BB1.kaTop);
if (ShowRight)
FBLine(BB1.kaRight,BB1.kaTop,
BB1.kaRight,BB1.kaBottom);
if (ShowTop)
FBLine(BB1.kaLeft,BB1.kaTop,
BB1.kaRight,BB1.kaTop);
}
}
else {
FBFilledBox(Layer,DISPLAY,0,
BB1.kaLeft,BB1.kaBottom,BB1.kaRight,BB1.kaTop);
}
}
else {
BB2.kaLeft = BB1.kaLeft + PixWidth;
BB2.kaBottom = BB1.kaBottom + PixWidth;
BB2.kaRight = BB1.kaRight - PixWidth;
BB2.kaTop = BB1.kaTop - PixWidth;
if (BB1.kaLeft < CurrentAOI.aLC) {
BB1.kaLeft = CurrentAOI.aLC;
if (BB2.kaLeft < CurrentAOI.aLC)
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBC) {
BB1.kaBottom = CurrentAOI.aBC;
if (BB2.kaBottom < CurrentAOI.aBC)
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRC) {
BB1.kaRight = CurrentAOI.aRC;
if (BB2.kaRight > CurrentAOI.aRC)
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTC) {
BB1.kaTop = CurrentAOI.aTC;
if (BB2.kaTop > CurrentAOI.aTC)
ShowTop = False;
}
if (ShowLeft) {
if (BB2.kaLeft > CurrentAOI.aRC)
BB2.kaLeft = CurrentAOI.aRC;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB1.kaBottom,BB2.kaLeft,BB1.kaTop);
}
if (ShowBottom) {
if (BB2.kaBottom > CurrentAOI.aTC)
BB2.kaBottom = CurrentAOI.aTC;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB1.kaBottom,BB1.kaRight,BB2.kaBottom);
}
if (ShowRight) {
if (BB2.kaRight < CurrentAOI.aLC)
BB2.kaRight = CurrentAOI.aLC;
FBFilledBox(Layer,DISPLAY,0,BB2.kaRight,
BB1.kaBottom,BB1.kaRight,BB1.kaTop);
}
if (ShowTop) {
if (BB2.kaTop < CurrentAOI.aBC)
BB2.kaTop = CurrentAOI.aBC;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB2.kaTop,BB1.kaRight,BB1.kaTop);
}
}
}
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
FineLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
FineLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRF And BB1.kaRight >= CurrentAOI.aLF And
BB1.kaBottom <= CurrentAOI.aTF And BB1.kaTop >= CurrentAOI.aBF) {
ShowLeft = True;
ShowBottom = True;
ShowRight = True;
ShowTop = True;
if (LayerTable[Layer].klAttributes & FILLED) {
if (BB1.kaLeft < CurrentAOI.aLF) {
BB1.kaLeft = CurrentAOI.aLF;
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBF) {
BB1.kaBottom = CurrentAOI.aBF;
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRF) {
BB1.kaRight = CurrentAOI.aRF;
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTF) {
BB1.kaTop = CurrentAOI.aTF;
ShowTop = False;
}
if (LayerTable[Layer].klAttributes & FINE_FILL) {
FBFilledBox(Layer,DISPLAY,
LayerTable[Layer].klStyleID,
BB1.kaLeft,BB1.kaBottom,BB1.kaRight,BB1.kaTop);
if (LayerTable[Layer].klAttributes & OUTLINED) {
if (ShowLeft)
FBLine(BB1.kaLeft,BB1.kaBottom,
BB1.kaLeft,BB1.kaTop);
if (ShowBottom)
FBLine(BB1.kaRight,BB1.kaBottom,
BB1.kaLeft,BB1.kaBottom);
if (ShowRight)
FBLine(BB1.kaRight,BB1.kaTop,
BB1.kaRight,BB1.kaBottom);
if (ShowTop)
FBLine(BB1.kaLeft,BB1.kaTop,
BB1.kaRight,BB1.kaTop);
}
}
else {
FBFilledBox(Layer,DISPLAY,0,
BB1.kaLeft,BB1.kaBottom,BB1.kaRight,BB1.kaTop);
}
}
else {
BB2.kaLeft = BB1.kaLeft + PixWidth;
BB2.kaBottom = BB1.kaBottom + PixWidth;
BB2.kaRight = BB1.kaRight - PixWidth;
BB2.kaTop = BB1.kaTop - PixWidth;
if (BB1.kaLeft < CurrentAOI.aLF) {
BB1.kaLeft = CurrentAOI.aLF;
if (BB2.kaLeft < CurrentAOI.aLF)
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBF) {
BB1.kaBottom = CurrentAOI.aBF;
if (BB2.kaBottom < CurrentAOI.aBF)
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRF) {
BB1.kaRight = CurrentAOI.aRF;
if (BB2.kaRight > CurrentAOI.aRF)
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTF) {
BB1.kaTop = CurrentAOI.aTF;
if (BB2.kaTop > CurrentAOI.aTF)
ShowTop = False;
}
if (ShowLeft) {
if (BB2.kaLeft > CurrentAOI.aRF)
BB2.kaLeft = CurrentAOI.aRF;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB1.kaBottom,BB2.kaLeft,BB1.kaTop);
}
if (ShowBottom) {
if (BB2.kaBottom > CurrentAOI.aTF)
BB2.kaBottom = CurrentAOI.aTF;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB1.kaBottom,BB1.kaRight,BB2.kaBottom);
}
if (ShowRight) {
if (BB2.kaRight < CurrentAOI.aLF)
BB2.kaRight = CurrentAOI.aLF;
FBFilledBox(Layer,DISPLAY,0,BB2.kaRight,
BB1.kaBottom,BB1.kaRight,BB1.kaTop);
}
if (ShowTop) {
if (BB2.kaTop < CurrentAOI.aBF)
BB2.kaTop = CurrentAOI.aBF;
FBFilledBox(Layer,DISPLAY,0,BB1.kaLeft,
BB2.kaTop,BB1.kaRight,BB1.kaTop);
}
}
}
}
}
void
ShowEmptyBox(Layer,boxBB)
/* show a thin line box, no fill */
int Layer;
struct ka *boxBB;
{
struct ka BB,BB1;
int ShowLeft = True;
int ShowBottom = True;
int ShowRight = True;
int ShowTop = True;
ka_copy(BB,boxBB);
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
CoarseLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
CoarseLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRC And BB1.kaRight >= CurrentAOI.aLC And
BB1.kaBottom <= CurrentAOI.aTC And BB1.kaTop >= CurrentAOI.aBC) {
if (BB1.kaLeft < CurrentAOI.aLC) {
BB1.kaLeft = CurrentAOI.aLC;
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBC) {
BB1.kaBottom = CurrentAOI.aBC;
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRC) {
BB1.kaRight = CurrentAOI.aRC;
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTC) {
BB1.kaTop = CurrentAOI.aTC;
ShowTop = False;
}
FBForeground(DISPLAY,Layer);
if (ShowTop)
FBLine(BB1.kaLeft,BB1.kaTop,
BB1.kaRight,BB1.kaTop);
if (ShowRight)
FBLine(BB1.kaRight,BB1.kaTop,
BB1.kaRight,BB1.kaBottom);
if (ShowBottom)
FBLine(BB1.kaRight,BB1.kaBottom,
BB1.kaLeft,BB1.kaBottom);
if (ShowLeft)
FBLine(BB1.kaLeft,BB1.kaBottom,
BB1.kaLeft,BB1.kaTop);
}
}
ShowLeft = True;
ShowBottom = True;
ShowRight = True;
ShowTop = True;
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
FineLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
FineLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRF And BB1.kaRight >= CurrentAOI.aLF And
BB1.kaBottom <= CurrentAOI.aTF And BB1.kaTop >= CurrentAOI.aBF) {
if (BB1.kaLeft < CurrentAOI.aLF) {
BB1.kaLeft = CurrentAOI.aLF;
ShowLeft = False;
}
if (BB1.kaBottom < CurrentAOI.aBF) {
BB1.kaBottom = CurrentAOI.aBF;
ShowBottom = False;
}
if (BB1.kaRight > CurrentAOI.aRF) {
BB1.kaRight = CurrentAOI.aRF;
ShowRight = False;
}
if (BB1.kaTop > CurrentAOI.aTF) {
BB1.kaTop = CurrentAOI.aTF;
ShowTop = False;
}
FBForeground(DISPLAY,Layer);
if (ShowTop)
FBLine(BB1.kaLeft,BB1.kaTop,
BB1.kaRight,BB1.kaTop);
if (ShowRight)
FBLine(BB1.kaRight,BB1.kaTop,
BB1.kaRight,BB1.kaBottom);
if (ShowBottom)
FBLine(BB1.kaRight,BB1.kaBottom,
BB1.kaLeft,BB1.kaBottom);
if (ShowLeft)
FBLine(BB1.kaLeft,BB1.kaBottom,
BB1.kaLeft,BB1.kaTop);
}
}
}
void
EraseBox(boxBB)
struct ka *boxBB;
{
struct ka BB,BB1;
SetCurrentAOI(boxBB);
ka_copy(BB,boxBB);
if (Parameters.kpRedisplayControl == SPLITSCREEN)
XORfineViewport();
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
CoarseLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
CoarseLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRC And BB1.kaRight >= CurrentAOI.aLC And
BB1.kaBottom <= CurrentAOI.aTC And BB1.kaTop >= CurrentAOI.aBC) {
if (BB1.kaLeft < CurrentAOI.aLC)
BB1.kaLeft = CurrentAOI.aLC;
if (BB1.kaBottom < CurrentAOI.aBC)
BB1.kaBottom = CurrentAOI.aBC;
if (BB1.kaRight > CurrentAOI.aRC)
BB1.kaRight = CurrentAOI.aRC;
if (BB1.kaTop > CurrentAOI.aTC)
BB1.kaTop = CurrentAOI.aTC;
FBFilledBox(0,ERASE,0,BB1.kaLeft,BB1.kaBottom,
BB1.kaRight,BB1.kaTop);
}
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
FineLToP(BB.kaLeft,BB.kaBottom,BB1.kaLeft,BB1.kaBottom);
FineLToP(BB.kaRight,BB.kaTop,BB1.kaRight,BB1.kaTop);
if (BB1.kaLeft <= CurrentAOI.aRF And BB1.kaRight >= CurrentAOI.aLF And
BB1.kaBottom <= CurrentAOI.aTF And BB1.kaTop >= CurrentAOI.aBF) {
if (BB1.kaLeft < CurrentAOI.aLF)
BB1.kaLeft = CurrentAOI.aLF;
if (BB1.kaBottom < CurrentAOI.aBF)
BB1.kaBottom = CurrentAOI.aBF;
if (BB1.kaRight > CurrentAOI.aRF)
BB1.kaRight = CurrentAOI.aRF;
if (BB1.kaTop > CurrentAOI.aTF)
BB1.kaTop = CurrentAOI.aTF;
FBFilledBox(0,ERASE,0,BB1.kaLeft,BB1.kaBottom,
BB1.kaRight,BB1.kaTop);
}
}
if (Parameters.kpRedisplayControl == SPLITSCREEN)
XORfineViewport();
}
void
Boxes(LookedAhead)
int *LookedAhead;
{
struct ka BB;
struct o *Pointer = NULL;
int Undo = False;
int FirstTime = True;
int Modified = 0;
int X = 0,Y = 0;
MakingBoxes = True;
MenuSelect(MenuBOXES);
top:
loop {
if (FirstTime)
ShowPrompt("Point to diagonal's endpoints.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime == True) goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
CDDelete(Parameters.kpCellDesc,Pointer);
Modified--;
Undo = True;
EraseBox(&BB);
}
else {
if (Not CDMakeBox(Parameters.kpCellDesc,
Parameters.kpLayer,
(BB.kaRight-BB.kaLeft),
(BB.kaTop-BB.kaBottom),
(BB.kaRight-BB.kaLeft)/2+BB.kaLeft,
(BB.kaTop-BB.kaBottom)/2+BB.kaBottom,
&Pointer)) MallocFailed();
Modified++;
Undo = False;
}
Redisplay(&BB);
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
X = KicCursor.kcX;
Y = KicCursor.kcY;
SetRelative(X,Y,True);
FBSetRubberBanding('r');
break;
}
loop {
if (FirstTime)
ShowPrompt("Point to second endpoint.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
FBSetRubberBanding(0);
goto top;
case PL_PCW:
BB.kaLeft = min(X,KicCursor.kcX);
BB.kaBottom = min(Y,KicCursor.kcY);
BB.kaRight = max(X,KicCursor.kcX);
BB.kaTop = max(Y,KicCursor.kcY);
if (BB.kaRight - BB.kaLeft <
LayerTable[Parameters.kpLayer].klMinDimensions ||
BB.kaRight - BB.kaLeft == 0 ||
BB.kaTop - BB.kaBottom <
LayerTable[Parameters.kpLayer].klMinDimensions ||
BB.kaTop - BB.kaBottom == 0) {
ShowPromptAndWait(
"Can't make box with side less than minimum dimension.");
continue;
}
FBSetRubberBanding(0);
SetRelative(0L,0L,False);
break;
}
break;
}
if (LayerTable[Parameters.kpLayer].klElectrical == NULL)
ErasePrompt();
if (Not CDMakeBox(Parameters.kpCellDesc,
Parameters.kpLayer,
(BB.kaRight-BB.kaLeft),
(BB.kaTop-BB.kaBottom),
(BB.kaRight-BB.kaLeft)/2+BB.kaLeft,
(BB.kaTop-BB.kaBottom)/2+BB.kaBottom,
&Pointer)) MallocFailed();
Modified++;;
FirstTime = False;
Undo = False;
/* make sure the new box is displayed */
CDReflect(Parameters.kpCellDesc);
Redisplay(&BB);
}
quit:
if (Modified)
Parameters.kpModified = True;
FBSetRubberBanding(0);
SetRelative(0L,0L,False);
ErasePrompt();
MakingBoxes = False;
MenuDeselect(MenuBOXES);
}
void
OversizeBox(BB,Delta)
struct ka *BB;
int Delta;
{
BB->kaTop += Delta;
BB->kaRight += Delta;
BB->kaBottom -= Delta;
BB->kaLeft -= Delta;
}
void
OutlineBox(AOI)
struct ka *AOI;
{
FBLine(AOI->kaLeft,AOI->kaTop,
AOI->kaRight,AOI->kaTop);
FBLine(AOI->kaRight,AOI->kaTop,
AOI->kaRight,AOI->kaBottom);
FBLine(AOI->kaRight,AOI->kaBottom,
AOI->kaLeft, AOI->kaBottom);
FBLine(AOI->kaLeft, AOI->kaBottom,
AOI->kaLeft, AOI->kaTop);
}
kic-2.4c/src/kic/xmfb 0000644 0000764 0000764 00000000000 07525356706 014135 0 ustar stevew stevew kic-2.4c/src/kic/hcopy.c 0000644 0000764 0000764 00000034705 12427255730 014557 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1994
*
*************************************************************************/
/*************************************************************************
*
* Hcopy command.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#include
#include
#define Matching(string) !strcmp(Parameters.kpCommand,string)
#ifdef __STDC__
static void display();
static int legend(int);
static int frame(int*);
#else
static void display();
static int legend();
static int frame();
#endif
extern char *MenuHCOPY;
extern char *MenuHELP;
extern char *MenuFILL;
extern char *MenuVISIB;
extern char *MenuGRID;
extern char *MenuRDRAW;
char *MenuRESOL = "resol";
char *MenuPRN = "prn ";
char *MenuGO = "go ";
char *MenuFRAME = "frame";
char *MenuHCTYP = "hctyp";
static int FrameOn;
static struct ka FrameBox;
void
Hcopy()
{
int Int1,dummy;
int didcopy = False;
int tmpgrid;
char *outname = NULL,*TypeIn;
char OldMenu;
char *tmpDsp;
struct { short attr; unsigned char pattrn[8];} Temp[CDNUMLAYERS+1];
#ifndef MSDOS
char pname[256];
char tf[32];
#endif
MenuSelect(MenuHCOPY);
Parameters.kpDoingHardcopy = True;
tmpgrid = Parameters.kpGridDisplayed;
Parameters.kpGridDisplayed = Parameters.kpHardcopyGrid;
for (Int1 = 1; Int1 <= NumLayerTable; Int1++) {
Temp[Int1].attr = LayerTable[Int1].klAttributes;
memcpy(Temp[Int1].pattrn,LayerTable[Int1].klStyle,8);
memcpy(LayerTable[Int1].klStyle,LayerTable[Int1].klAltStyle,8);
if (LayerTable[Int1].klAttributes & ALT_FILLED)
LayerTable[Int1].klAttributes |= FILLED;
else
LayerTable[Int1].klAttributes &= ~FILLED;
if (LayerTable[Int1].klAttributes & ALT_OUTLINED)
LayerTable[Int1].klAttributes |= OUTLINED;
else
LayerTable[Int1].klAttributes &= ~OUTLINED;
if (LayerTable[Int1].klAttributes & ALT_VISIBLE)
LayerTable[Int1].klAttributes |= VISIBLE;
else
LayerTable[Int1].klAttributes &= ~VISIBLE;
}
InitVLT();
RedisplayViewports();
ErasePrompt();
ShowLayerTable();
OldMenu = Parameters.kpMenu;
Parameters.kpMenu = AMBIGUITYMENU;
AmbiguityMenu[0].mEntry = MenuHELP;
AmbiguityMenu[1].mEntry = MenuFRAME;
AmbiguityMenu[2].mEntry = MenuGO;
AmbiguityMenu[3].mEntry = " ";
AmbiguityMenu[4].mEntry = MenuFILL;
AmbiguityMenu[5].mEntry = MenuVISIB;
AmbiguityMenu[6].mEntry = MenuGRID;
AmbiguityMenu[7].mEntry = MenuRDRAW;
AmbiguityMenu[8].mEntry = " ";
AmbiguityMenu[9].mEntry = MenuRESOL;
AmbiguityMenu[10].mEntry = MenuPRN;
AmbiguityMenu[11].mEntry = MenuHCTYP;
AmbiguityMenu[12].mEntry = NULL;
FixMenuPrefix(AmbiguityMenu);
ShowMenu(AmbiguityMenu);
loop {
switch (PointLoopSafe(&dummy)) {
case PL_ESC:
goto quit;
case PL_PCW:
continue;
case PL_CMD:
if (Matching(MenuHELP)) {Help(); continue;}
if (Matching(MenuFILL)) {Fill(&dummy); continue;}
if (Matching(MenuVISIB)) {Visib(&dummy); continue;}
if (Matching(MenuGRID)) {SetGrid(&dummy); continue;}
if (Matching(MenuRDRAW)) {Rdraw(); continue;}
if (Matching(MenuFRAME)) {
if (frame(&dummy))
goto quit;
continue;
}
if (Matching(MenuRESOL)) {
MenuSelect(MenuRESOL);
sprintf(TypeOut,
"Resolution is %d dpi. Enter new resolution (75 100 150 300): ",
Parameters.kpHardcopyResolution);
ShowPrompt(TypeOut);
for (;;) {
if ((TypeIn = FBEdit(NULL)) == NULL) break;
if (*TypeIn == '\0' || *TypeIn == '\n') break;
Int1 = atoi(TypeIn);
if (Int1 == 75 || Int1 == 100 ||
Int1 == 150 || Int1 == 300) {
Parameters.kpHardcopyResolution = Int1;
break;
}
ShowPrompt("Enter resolution (75 100 150 300): ");
}
MenuDeselect(MenuRESOL);
ErasePrompt();
continue;
}
if (Matching(MenuPRN)) {
MenuSelect(MenuPRN);
ShowPrompt("Enter file or device for output: ");
outname = FBEdit(Parameters.kpHardcopyDevice);
if (outname != NULL) {
Parameters.kpHardcopyDevice =
tmalloc(strlen(outname)+1);
strcpy(Parameters.kpHardcopyDevice,outname);
}
MenuDeselect(MenuPRN);
ErasePrompt();
continue;
}
if (Matching(MenuHCTYP)) {
MenuSelect(MenuHCTYP);
ShowPrompt("Enter h (HP laser) or p (postscript): ");
outname = FBEdit(Parameters.kpHardcopyFormat);
if (outname &&
(*outname == HPLASER || *outname == POSTSC))
*Parameters.kpHardcopyFormat = *outname;
MenuDeselect(MenuHCTYP);
ErasePrompt();
continue;
}
if (Matching(MenuGO)) {
MenuSelect(MenuGO);
break;
}
*Parameters.kpCommand = '\0';
continue;
}
break;
}
outname = Parameters.kpHardcopyDevice;
#ifdef MSDOS
Int1 = -1;
if (!strcasecmp(outname,"prn")) Int1 = 0;
else if (!strcasecmp(outname,"lpt1")) Int1 = 0;
else if (!strcasecmp(outname,"lpt2")) Int1 = 1;
else if (!strcasecmp(outname,"lpt3")) Int1 = 2;
if (Int1 >= 0) {
while (PrinterPortStatus(Int1)) {
putc('\007',stdout);
fflush(stdout);
ShowPrompt("Error: Printer is not accessible. MORE");
(void)FBGetchar(ERASE);
ShowPrompt("Hit any key to continue, ESC to abort: ");
if (FBGetchar(DISPLAY) == ESCAPE)
goto quit;
}
}
#else
*pname = '\0';
if (!strncmp(outname,"lpr",3)) {
strcpy(pname,outname);
strcpy(tf,"/tmp/hcXXXXXX");
outname = mktemp(tf);
}
#endif
SaveLastView();
FB.fInitialized = False;
FB.fInterface = 1;
tmpDsp = FB.fDisplay;
FBBegin(outname);
display();
FBEnd();
FB.fDisplay = tmpDsp;
FB.fInterface = 0;
didcopy = True;
quit:
Parameters.kpGridDisplayed = tmpgrid;
for (Int1 = 1; Int1 <= NumLayerTable; Int1++) {
memcpy(LayerTable[Int1].klAltStyle,LayerTable[Int1].klStyle,8);
memcpy(LayerTable[Int1].klStyle,Temp[Int1].pattrn,8);
if (LayerTable[Int1].klAttributes & FILLED)
Temp[Int1].attr |= ALT_FILLED;
else
Temp[Int1].attr &= ~ALT_FILLED;
if (LayerTable[Int1].klAttributes & OUTLINED)
Temp[Int1].attr |= ALT_OUTLINED;
else
Temp[Int1].attr &= ~ALT_OUTLINED;
if (LayerTable[Int1].klAttributes & VISIBLE)
Temp[Int1].attr |= ALT_VISIBLE;
else
Temp[Int1].attr &= ~ALT_VISIBLE;
LayerTable[Int1].klAttributes = Temp[Int1].attr;
}
Parameters.kpDoingHardcopy = False;
MenuDeselect(MenuGO);
MenuDeselect(MenuFRAME);
FrameOn = False;
Parameters.kpMenu = OldMenu;
if (didcopy) {
FB.fInitialized = True;
FBBegin(FB.fDisplay);
InitViewport();
InitVLT();
FBForeground(ERASE,0);
FBFlood();
RestoreLastView();
#ifndef MSDOS
/* send the output to the printer */
if (*pname) {
sprintf(TypeOut,"%s %s; unlink %s &",pname,outname,outname);
system(TypeOut);
}
#endif
}
else {
InitVLT();
RedisplayViewports();
}
ShowLayerTable();
ShowCommandMenu();
ErasePrompt();
MenuDeselect(MenuHCOPY);
}
static void
display()
{
int L,B,R,T;
int W,H,X,Y;
double RY,RX;
int Margin;
int Leg;
char OldControl;
OldControl = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
InitVLT();
Margin = (FB.fMaxX+1) * .25/8; /* 1/4 inch */
Leg = legend(1);
View->kvCoarseViewport->kaLeft = Margin;
View->kvCoarseViewport->kaBottom = Leg;
View->kvCoarseViewport->kaRight = FB.fMaxX - Margin;
View->kvCoarseViewport->kaTop = FB.fMaxY - Margin;
View->kvCoarseViewport->kaWidth =
View->kvCoarseViewport->kaRight - View->kvCoarseViewport->kaLeft;
View->kvCoarseViewport->kaHeight =
View->kvCoarseViewport->kaTop - View->kvCoarseViewport->kaBottom;
if (FrameOn) {
L = FrameBox.kaLeft;
R = FrameBox.kaRight;
B = FrameBox.kaBottom;
T = FrameBox.kaTop;
}
else {
if (Not CDBB(Parameters.kpCellDesc,(struct o *)NULL,&L,&B,&R,&T))
MallocFailed();
}
TPush();
TIdentity();
if ((R-L) > (T-B)) {
TRotate(0L,1L);
TPoint(&L,&B);
TPoint(&R,&T);
if (L > R) SwapInts(L,R);
if (B > T) SwapInts(T,B);
}
else TIdentity();
TPremultiply();
X = (L+R)/2;
Y = (B+T)/2;
RY = (double)(T - B)/View->kvCoarseViewport->kaHeight;
RX = (double)(R - L)/View->kvCoarseViewport->kaWidth;
if (RX > RY) {
W = R - L;
H = W*View->kvCoarseViewport->kaHeight/
View->kvCoarseViewport->kaWidth;
}
else {
H = T - B;
W = H*View->kvCoarseViewport->kaWidth/
View->kvCoarseViewport->kaHeight;
}
View->kvCoarseWindow->kaX = X;
View->kvCoarseWindow->kaY = Y;
View->kvCoarseWindow->kaLeft = X - W/2;
View->kvCoarseWindow->kaRight = X + W/2;
View->kvCoarseWindow->kaBottom = Y - H/2;
View->kvCoarseWindow->kaTop = Y + H/2;
View->kvCoarseWindow->kaWidth = W;
View->kvCoarseWindow->kaHeight = H;
View->kvCoarseRatio =
View->kvCoarseViewport->kaWidth/View->kvCoarseWindow->kaWidth;
Redisplay(View->kvCoarseWindow);
legend(0);
TPop();
Parameters.kpRedisplayControl = OldControl;
}
static int
legend(mode)
/* mode == 0: add the legend to the plot
* mode != 0: simply return the height of the legend
*/
int mode;
{
struct tm *t;
int xpos, ypos, xu, yu;
int entry_wd, xspace, entry_ht, yspace, ncols, nrows;
int cwidth, i, j;
int Layer;
int Margin;
int NumVisible;
char buf[120], buf1[80], *s, *strrchr();
char LayerName[8];
time_t secs;
FBSetTextClip(0,0,FB.fMaxX,FB.fMaxY);
LayerName[4] = '\0';
Margin = (FB.fMaxX + 1) * .65/8;
entry_ht = (FB.fMaxX + 1) * .25/8;
cwidth = FB.fFontWidth;
xspace = entry_ht >> 1;
entry_wd = entry_ht + (cwidth << 2);
yspace = entry_ht >> 2;
NumVisible = 0;
for (i = 1; i <= NumLayerTable; i++)
if (LayerTable[i].klAttributes & VISIBLE) NumVisible++;
ncols = (FB.fMaxX + xspace - (Margin << 1))/(entry_wd+xspace);
nrows = (NumVisible - 1)/ncols + 1;
ypos = nrows*(entry_ht + yspace) + Margin/2;
if (mode)
return (ypos + entry_ht + yspace);
time(&secs);
t = localtime(&secs);
sprintf(buf1,"%02d-%02d-%02d %02d:%02d",t->tm_mon+1,t->tm_mday,
t->tm_year,t->tm_hour,t->tm_min);
s = strrchr(Parameters.kpCellDesc->sName,DIRC);
if (s) s++;
else s = Parameters.kpCellDesc->sName;
sprintf(buf,"KIC-%s Cell: %s ",VersionString,s);
FBSetColor(ColorTable[HighlightingColor].Ent);
FBScaledText(buf1,FB.fMaxX - Margin - strlen(buf1)*cwidth,ypos,0,
Parameters.kpHardcopyTextScale);
FBScaledText(buf,Margin,ypos,0,Parameters.kpHardcopyTextScale);
Layer = 0;
ypos -= (entry_ht + yspace - 1);
for (i = 0; i < nrows; i++) {
for (j = 0; j < ncols; j++) {
Layer++;
while (!(LayerTable[Layer].klAttributes & VISIBLE)) {
Layer++;
if (Layer > NumLayerTable) return (0);
}
if (Layer > NumLayerTable) return (0);
FBForeground(DISPLAY,Layer);
xpos = Margin + j*(entry_wd+xspace);
xu = xpos + entry_ht;
yu = ypos + entry_ht;
if (!(LayerTable[Layer].klAttributes & FILLED) ||
(LayerTable[Layer].klAttributes & OUTLINED))
FBEmptyBox(Layer,DISPLAY,0,xpos,ypos,xu,yu);
if (LayerTable[Layer].klAttributes & FILLED)
FBFilledBox(Layer,DISPLAY,LayerTable[Layer].klStyleID,
xpos,ypos,xu,yu);
LayerName[0] = LayerTable[Layer].klTechnology;
LayerName[1] = LayerTable[Layer].klMask[0];
LayerName[2] = LayerTable[Layer].klMask[1];
LayerName[3] = LayerTable[Layer].klMask[2];
LayerName[4] = '\0';
xu += cwidth/3;
FBScaledText(LayerName,xu,ypos,0,Parameters.kpHardcopyTextScale);
}
ypos -= entry_ht+yspace;
}
return (0);
}
static int
frame(LookedAhead)
int *LookedAhead;
{
int X, Y, OldRawX = 0, OldRawY = 0;
*LookedAhead = False;
if (FrameOn) {
MenuDeselect(MenuFRAME);
FrameOn = False;
return (0);
}
MenuSelect(MenuFRAME);
FrameOn = True;
ShowPrompt("Point to endpoints of diagonal.");
switch (PointLoop(LookedAhead)) {
case PL_UND:
case PL_ESC:
case PL_CMD:
MenuDeselect(MenuFRAME);
FrameOn = False;
return (1);
case PL_PCW:
FBSetRubberBanding('R');
OldRawX = KicCursor.kcRawX;
OldRawY = KicCursor.kcRawY;
}
ShowPrompt("Point to second endpoint.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
case PL_UND:
FBSetRubberBanding(0);
MenuDeselect(MenuFRAME);
FrameOn = False;
return (1);
case PL_PCW:
FBSetRubberBanding(0);
X = KicCursor.kcRawX;
Y = KicCursor.kcRawY;
FrameBox.kaLeft = min(X,OldRawX);
FrameBox.kaRight = max(X,OldRawX);
FrameBox.kaBottom = min(Y,OldRawY);
FrameBox.kaTop = max(Y,OldRawY);
sprintf(TypeOut,"Frame entered: %d,%d %d,%d",
FrameBox.kaLeft/RESOLUTION,
FrameBox.kaBottom/RESOLUTION,
FrameBox.kaRight/RESOLUTION,
FrameBox.kaTop/RESOLUTION);
ShowPrompt(TypeOut);
break;
}
return (0);
}
kic-2.4c/src/kic/viewport.c 0000644 0000764 0000764 00000110620 12427445312 015300 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Management of PARAMETER, LAYER TABLE, and MENU viewports.
*
*/
#ifdef WIN32
#include
#endif
#include "prefix.h"
#include "kic.h"
#include "sline.h"
#ifndef vms
#ifndef MSDOS
#include
#endif
#endif
#ifndef WIN32
#include
#include
#endif
#ifdef __STDC__
static void set_active(MENU*);
static void display_entry(MENU*,int);
static void display_selected(MENU*,int);
#if !defined(WIN32) && !defined(MSDOS) && !defined(vms)
static FILE *propen(char*,char*);
static int prclose(FILE*);
#endif
#else
static void set_active();
static void display_entry();
static void display_selected();
#if !defined(WIN32) && !defined(MSDOS) && !defined(vms)
static FILE *propen();
static int prclose();
#endif
#endif
#if __NDPC__
extern void sleep();
#endif
/***********************************************************************
*
* Routines used to process cursor data.
*
*
***********************************************************************/
/* also see macros in coords.h */
void
PToL(Window,X,Y)
/* convert viewport to window coordinates */
struct ka *Window;
int *X, *Y;
{
if (Window == View->kvCoarseWindow) {
*X = .5+(*X - View->kvCoarseViewport->kaLeft)/
View->kvCoarseRatio;
*X += Window->kaLeft;
*Y = .5+(*Y - View->kvCoarseViewport->kaBottom)/
View->kvCoarseRatio;
*Y += Window->kaBottom;
}
elif (Window == View->kvFineWindow) {
*X = .5+(*X - View->kvFineViewport->kaLeft)/
View->kvFineRatio;
*X += Window->kaLeft;
*Y = .5+(*Y - View->kvFineViewport->kaBottom)/
View->kvFineRatio;
*Y += Window->kaBottom;
}
else {
*X = *Y = 0;
return;
}
}
void
ClipToGridPoint(x,y)
/* Clip to nearest window grid coordinate */
int *x,*y;
{
int j,k,l;
k = Parameters.kpGrid/Parameters.kpPixToLambdaSnapping;
j = (*x/Parameters.kpGrid)*Parameters.kpGrid;
if (*x >= 0) {
l = *x - j;
l = ((l + k/2)/k)*k;
*x = j + l;
}
else {
l = j - *x;
l = ((l + k/2)/k)*k;
*x = j - l;
}
j = (*y/Parameters.kpGrid)*Parameters.kpGrid;
if (*y >= 0) {
l = *y - j;
l = ((l + k/2)/k)*k;
*y = j + l;
}
else {
l = j - *y;
l = ((l + k/2)/k)*k;
*y = j - l;
}
}
/***********************************************************************
*
* Routines to dislay parameter data.
*
*
***********************************************************************/
static int RelX, RelY;
static int Rel;
void
ShowParameters()
{
int Row,Col;
Row = FB.fNumRows - 1;
OutlineText(1,Row,FB.fNumColumns,Row,FILL,ERASE,0);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
Col = 1;
if (!Rel) {
FBText(ROW_COLUMN,Row,Col,"x=");
sprintf(TypeOut,"%g",(double)KicCursor.kcX/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 2,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"y=");
sprintf(TypeOut,"%g",(double)KicCursor.kcY/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 2,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"dx=");
sprintf(TypeOut,"%g",(double)KicCursor.kcDX/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 3,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"dy=");
sprintf(TypeOut,"%g",(double)KicCursor.kcDY/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 3,TypeOut);
}
else {
FBText(ROW_COLUMN,Row,Col,"x=");
sprintf(TypeOut,"%g",(double)KicCursor.kcX/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 2,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"y=");
sprintf(TypeOut,"%g",(double)KicCursor.kcY/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 2,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"DX=");
sprintf(TypeOut,"%g",(double)(KicCursor.kcX-RelX)/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 3,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"DY=");
sprintf(TypeOut,"%g",(double)(KicCursor.kcY-RelY)/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 3,TypeOut);
}
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"width=");
sprintf(TypeOut,"%g",View->kvCoarseWindow->kaWidth/RESOLUTION);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 6,TypeOut);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Row,Col += strlen(TypeOut) + 1,"cell:");
if (FB.fNumColumns > 52) {
strncpy(TypeOut,Parameters.kpCellName,FB.fNumColumns-52);
TypeOut[FB.fNumColumns-52] = EOS;
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Row,Col += 5,TypeOut);
}
ShowElectrical();
FBTransfer();
}
void
SetRelative(X,Y,Flag)
int X,Y;
int Flag;
{
RelX = X;
RelY = Y;
Rel = Flag;
}
void
ShowElectrical()
/* Print some electrical characteristics when making boxes. Layers in the
* tech file can have the following entries:
*
* resis[tance]
*
* cap[acitance]
*
* tran[smission] \
*
*
* Each of the <...> is a number. Tran parameters are in microns.
* After each box is made (or the get coordinate button is pressed after the
* initial corner is located) the appropriate results are printed.
*/
{
struct eparms *ee;
char buf[128];
double Wid, Hei, o[4];
char c;
if (!MakingBoxes) return;
if (!Rel) return;
if ((ee = LayerTable[Parameters.kpLayer].klElectrical) == NULL) return;
Wid = fabs((double)(KicCursor.kcX - RelX)/RESOLUTION);
Hei = fabs((double)(KicCursor.kcY - RelY)/RESOLUTION);
switch (ee->e_type) {
case ERESIS:
if (Wid == 0 || Hei == 0) {
ErasePrompt();
break;
}
sprintf(buf," Resistance: %g (L to R), %g (B to T)",
*ee->e_parms*Wid/Hei,*ee->e_parms*Hei/Wid);
ShowPrompt(buf);
break;
case ECAP:
sprintf(buf," Capacitance: %g",*ee->e_parms*Wid*Hei);
ShowPrompt(buf);
break;
case ETRANS:
if (Wid == 0 || Hei == 0) {
ErasePrompt();
break;
}
if (Wid > Hei) {
ee->e_parms[6] = Hei;
ee->e_parms[7] = Wid;
c = 'X';
}
else {
ee->e_parms[6] = Wid;
ee->e_parms[7] = Hei;
c = 'Y';
}
sline((struct params*)ee->e_parms,(struct output*)o);
sprintf(buf," Along %c: L=%g C=%g Z=%g T=%g",
c,o[0],o[1],o[2],o[3]);
ShowPrompt(buf);
break;
}
}
/***********************************************************************
*
* Routines to manage layer table.
*
*
***********************************************************************/
void
ShowLayerTable()
{
int Row,Column,Layer,j;
char LayerName[5];
LayerName[4] = EOS;
OutlineText(1,FB.fNumRows,FB.fNumColumns,FB.fNumRows,FILL,ERASE,0);
for(j = 1; j <= Parameters.kpLayersPerMenuRow; ++j){
Layer = Parameters.kpVisibleLayerMenuRow *
Parameters.kpLayersPerMenuRow + j;
if(Layer <= NumLayerTable){
Row = FB.fNumRows;
Column = (j - 1) * 6 + 1;
FBForeground(DISPLAY,Layer);
LayerName[0] = LayerTable[Layer].klTechnology;
LayerName[1] = LayerTable[Layer].klMask[0];
LayerName[2] = LayerTable[Layer].klMask[1];
LayerName[3] = LayerTable[Layer].klMask[2];
FBText(ROW_COLUMN,Row,Column+2,LayerName);
if (LayerTable[Layer].klAttributes & VISIBLE)
LtBox(Column,Row,DISPLAY,Layer);
if (Layer == Parameters.kpLayer)
OutlineText(Column+2,Row,Column+5,Row,OUTLINE,DISPLAY,
ColorTable[HighlightingColor].Ent);
}
}
if (Parameters.kpNumLayerMenuRows > 1)
LtMore();
FBTransfer();
}
void
LtMore()
{
int Row,Col;
FBForeground(DISPLAY,ColorTable[MoreTextColor].Ent);
Row = FB.fNumRows;
Col = Parameters.kpLayersPerMenuRow * 6 + 3;
FBText(ROW_COLUMN,Row,Col,"MORE");
OutlineText(Col,Row,Col+3,Row,OUTLINE,DISPLAY,
ColorTable[MenuPromptColor].Ent);
}
void
LtBox(Left,Bottom,DisplayOrErase,Layer)
int Left,Bottom,Layer;
int DisplayOrErase;
{
/*
* Draw the layer designator for the layer table
*/
int Right, Top;
Bottom = FB.fMaxY + 1 - Bottom*FB.fFontHeight;
Top = Bottom + FB.fFontHeight - 1;
Left = (Left-1) * FB.fFontWidth;
Right = Left + 2*FB.fFontWidth;
Left += 2;
Right -= 2;
if (DisplayOrErase == ERASE) {
FBFilledBox(Layer,ERASE,0,Left,Bottom,Right,Top);
return;
}
if (!(LayerTable[Layer].klAttributes & FILLED) ||
(LayerTable[Layer].klAttributes & OUTLINED))
FBEmptyBox(Layer,DISPLAY,0,Left,Bottom,Right,Top);
if (LayerTable[Layer].klAttributes & FILLED)
FBFilledBox(Layer,DISPLAY,LayerTable[Layer].klStyleID,
Left,Bottom,Right,Top);
}
int
PointLayerTable(CharRow,CharColumn)
int CharRow, CharColumn;
{
int Row,Column,Layer,Lmin;
char LayerName[5];
LayerName[4] = EOS;
Column = (CharColumn - 1)/6 + 1;
if (Column == Parameters.kpLayersPerMenuRow+1){
Parameters.kpVisibleLayerMenuRow++;
if (Parameters.kpVisibleLayerMenuRow ==
Parameters.kpNumLayerMenuRows)
Parameters.kpVisibleLayerMenuRow = 0;
ShowLayerTable();
return False;
}
Layer = Parameters.kpVisibleLayerMenuRow *
Parameters.kpLayersPerMenuRow + Column;
if(Layer <= NumLayerTable And Column <= Parameters.kpLayersPerMenuRow){
Parameters.kpPointLayerTable = True;
LayerName[0] = LayerTable[Parameters.kpLayer].klTechnology;
LayerName[1] = LayerTable[Parameters.kpLayer].klMask[0];
LayerName[2] = LayerTable[Parameters.kpLayer].klMask[1];
LayerName[3] = LayerTable[Parameters.kpLayer].klMask[2];
Lmin = Parameters.kpVisibleLayerMenuRow *
Parameters.kpLayersPerMenuRow + 1;
Row = FB.fNumRows;
if (Parameters.kpLayer >= Lmin && Parameters.kpLayer <
Lmin + Parameters.kpLayersPerMenuRow) {
Column = ((Parameters.kpLayer-1) %
Parameters.kpLayersPerMenuRow) * 6;
OutlineText(Column+3,Row,Column+6,Row,OUTLINE,ERASE,0);
FBForeground(DISPLAY,Parameters.kpLayer);
FBText(ROW_COLUMN,Row,Column+3,LayerName);
}
Parameters.kpLayer = Layer;
Column = ((Parameters.kpLayer-1) %
Parameters.kpLayersPerMenuRow) * 6;
OutlineText(Column+3,CharRow,Column+6,CharRow,OUTLINE,DISPLAY,
ColorTable[HighlightingColor].Ent);
/*
* A user might have done a redisplay with this layer chosen to
* be invisible. If so, make this layer visible. If this
* wasn't done, he might create a geometry, but not see it.
* This would be very annoying!
*/
if(Not NoMakeVisible &&
!(LayerTable[Parameters.kpLayer].klAttributes & VISIBLE))
MakeLayerVisible(Parameters.kpLayer);
}
return True;
}
/***********************************************************************
*
* Routines to dislay and manipulate menus.
*
*
***********************************************************************/
extern char *MenuCNTXT;
extern char *MenuMX;
extern char *MenuMY;
extern char *MenuLAYER;
extern char *MenuEXPND;
extern char *MenuPEEK;
extern char *Menu0;
extern char *Menu90;
extern char *Menu180;
extern char *Menu270;
void
ShowCommandMenu()
{
if (Parameters.kpMenu == ATTRIBUTESMENU) {
ShowMenu(AttributeMenu);
return;
}
if (Parameters.kpMenu == BASICMENU) {
ShowMenu(BasicMenu);
return;
}
if (Parameters.kpMenu == DEBUGMENU) {
ShowMenu(DebugMenu);
return;
}
if (Parameters.kpMenu == PROPERTYMENU) {
ShowMenu(PropertyMenu);
return;
}
if (Parameters.kpMenu == AMBIGUITYMENU) {
ShowMenu(AmbiguityMenu);
return;
}
}
void
ShowMenu(Menu)
MENU *Menu;
{
int Int1;
/*
* Erase the entire menu viewport.
*/
OutlineText(MenuViewport.kaLeft,MenuViewport.kaBottom,
MenuViewport.kaRight,MenuViewport.kaTop,FILL,ERASE,0);
/*
* Display Menu Table
*/
set_active(Menu);
for (Int1 = 0; ; Int1++) {
if (Menu[Int1].mEntry == NULL) break;
if (Menu[Int1].mActive)
display_selected(Menu,Int1);
else
display_entry(Menu,Int1);
}
FBTransfer();
}
static void
set_active(Menu)
MENU *Menu;
{
int i;
i = GetMenuIndex(Menu,MenuCNTXT);
if (i >= 0) {
if (Parameters.kpShowContext)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,MenuMX);
if (i >= 0) {
if (Parameters.kpMX)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,MenuMY);
if (i >= 0) {
if (Parameters.kpMY)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,MenuLAYER);
if (i >= 0) {
if (Parameters.kpLayerSpecificSelection)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,MenuEXPND);
if (i >= 0) {
if (Parameters.kpExpandInstances)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,MenuPEEK);
if (i >= 0) {
if (Parameters.kpExpandFineViewportOnly)
Menu[i].mActive = True;
else
Menu[i].mActive = False;
}
i = GetMenuIndex(Menu,Menu0);
if (i >= 0)
Menu[i].mActive = False;
i = GetMenuIndex(Menu,Menu90);
if (i >= 0)
Menu[i].mActive = True;
i = GetMenuIndex(Menu,Menu180);
if (i >= 0)
Menu[i].mActive = True;
i = GetMenuIndex(Menu,Menu270);
if (i >= 0)
Menu[i].mActive = True;
}
int
GetMenuIndex(Menu,String)
MENU *Menu;
char *String;
{
int i = 0;
while (Menu[i].mEntry != NULL) {
if (!strcmp(Menu[i].mEntry,String)) return i;
i++;
}
return -1;
}
MENU *
GetCurrentMenu()
{
if (Parameters.kpMenu == AMBIGUITYMENU)
return AmbiguityMenu;
if (Parameters.kpMenu == ATTRIBUTESMENU)
return AttributeMenu;
if (Parameters.kpMenu == BASICMENU)
return BasicMenu;
if (Parameters.kpMenu == DEBUGMENU)
return DebugMenu;
if (Parameters.kpMenu == PROPERTYMENU)
return PropertyMenu;
return NULL;
}
void
AlterMenuEntries(Word1,Word2)
/* Change all the entries of Word1 in the menus to Word2. */
char *Word1,*Word2;
{
int i;
i = GetMenuIndex(AttributeMenu,Word1);
if (i >= 0) {
AttributeMenu[i].mEntry = Word2;
FixMenuPrefix(AttributeMenu);
if (Parameters.kpMenu == ATTRIBUTESMENU)
ShowMenu(AttributeMenu);
}
i = GetMenuIndex(BasicMenu,Word1);
if (i >= 0) {
BasicMenu[i].mEntry = Word2;
FixMenuPrefix(BasicMenu);
if (Parameters.kpMenu == BASICMENU)
ShowMenu(BasicMenu);
}
i = GetMenuIndex(DebugMenu,Word1);
if (i >= 0) {
DebugMenu[i].mEntry = Word2;
FixMenuPrefix(DebugMenu);
if (Parameters.kpMenu == DEBUGMENU)
ShowMenu(DebugMenu);
}
i = GetMenuIndex(PropertyMenu,Word1);
if (i >= 0) {
PropertyMenu[i].mEntry = Word2;
FixMenuPrefix(PropertyMenu);
if (Parameters.kpMenu == PROPERTYMENU)
ShowMenu(PropertyMenu);
}
}
void
MenuSelect(Selection)
char *Selection;
{
int Int1;
MENU *Menu;
if ((Menu = GetCurrentMenu()) == NULL) return;
Int1 = GetMenuIndex(Menu,Selection);
if (Int1 < 0) return;
Menu[Int1].mActive = True;
display_selected(Menu,Int1);
FBTransfer();
}
void
MenuDeselect(Selection)
char *Selection;
{
int Int1;
MENU *Menu;
if ((Menu = GetCurrentMenu()) == NULL) return;
Int1 = GetMenuIndex(Menu,Selection);
if (Int1 < 0) return;
Menu[Int1].mActive = False;
display_entry(Menu,Int1);
FBTransfer();
}
void
FixMenuPrefix(Menu)
MENU *Menu;
{
int i;
for (i = 0; Menu[i].mEntry; i++)
FixMenuEntryPrefix(Menu,i);
}
void
FixMenuEntryPrefix(Menu,Index)
/* Find a unique prefix for the menu entry and save it
* in the mPrefix field.
*/
MENU *Menu;
int Index;
{
int Count;
char m1[32], m2[32];
int j,k;
memset(Menu[Index].mPrefix,0,6);
Count = 1;
strcpy(m1,Menu[Index].mEntry);
for (j = 0; Menu[j].mEntry; j++) {
if (Index == j) continue;
strcpy(m2,Menu[j].mEntry);
if (!strcasecmp(m1,m2)) {
if (*Menu[Index].mEntry != ' ')
for (k = j; Menu[k].mEntry; k++) {
strcpy(Menu[k].mPrefix,Menu[k+1].mPrefix);
Menu[k].mEntry = Menu[k+1].mEntry;
Menu[k].mActive = Menu[k+1].mActive;
}
continue;
}
while (!strncasecmp(m1,m2,Count))
Count++;
}
if (Count > 5) Count = 5;
while (Count--)
Menu[Index].mPrefix[Count] = Menu[Index].mEntry[Count];
}
static void
display_entry(Menu,Index)
MENU *Menu;
int Index;
{
char MenuSelection[8],*prefix;
int i;
int Left;
strncpy(MenuSelection,Menu[Index].mEntry,MenuViewport.kaX);
MenuSelection[MenuViewport.kaX] = '\0';
prefix = Menu[Index].mPrefix;
Index += MenuViewport.kaTop;
Left = MenuViewport.kaLeft;
if (Index > MenuViewport.kaY) {
Left += 6;
Index -= MenuViewport.kaY;
}
/*
* Erase highlight box.
*/
OutlineText(Left,Index,Left+4,Index,FILL,ERASE,0);
/*
* Redisplay menu selection.
*/
i = strlen(prefix);
while (i--)
if (islower(MenuSelection[i]))
MenuSelection[i] = toupper(MenuSelection[i]);
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBText(ROW_COLUMN,Index,Left,MenuSelection);
}
static void
display_selected(Menu,Index)
MENU *Menu;
int Index;
{
char MenuSelection[8], *prefix, Fill;
int i;
int Left;
strncpy(MenuSelection,Menu[Index].mEntry,MenuViewport.kaX);
MenuSelection[MenuViewport.kaX] = '\0';
prefix = Menu[Index].mPrefix;
Index += MenuViewport.kaTop;
Left = MenuViewport.kaLeft;
if (Index > MenuViewport.kaY) {
Left += 6;
Index -= MenuViewport.kaY;
}
/*
* Erase Menu command
*/
OutlineText(Left,Index,Left+4,Index,FILL,ERASE,0);
if (FB.fNonDestructiveText)
Fill = FILL;
else
Fill = OUTLINE;
/*
* Display highlight box.
*/
OutlineText(Left,Index,Left+4,Index,Fill,DISPLAY,
ColorTable[MenuHighlightingColor].Ent);
/*
* Redisplay menu selection.
*/
i = strlen(prefix);
while (i--)
if (islower(MenuSelection[i]))
MenuSelection[i] = toupper(MenuSelection[i]);
FBForeground(DISPLAY,ColorTable[MenuSelectColor].Ent);
FBText(ROW_COLUMN,Index,Left,MenuSelection);
}
/***********************************************************************
*
* Routines to dislay message text.
*
*
***********************************************************************/
static char BackPrompt[200];
static char BackColor;
void
ShowPrompt(Prompt)
char *Prompt;
{
ShowPromptWithColor(Prompt,ColorTable[MenuPromptColor].Ent);
}
void
ShowPromptAndWait(cp)
char *cp;
{
putchar('\007');
fflush(stdout);
ShowPrompt(cp);
#ifdef WIN32
Sleep(2000);
#else
sleep(2);
#endif
}
void
ShowPromptWithColor(Prompt,Color)
char *Prompt;
int Color;
{
/*
* Implements a basic scroller in a prompt window.
* Displays MORE when window is full and continues when
* user hits and key.
*/
char *cp;
char buffer[200];
int Int1;
int Row;
Row = FB.fNumRows - 2;
ErasePrompt();
FBForeground(DISPLAY,Color);
BackColor = Color;
cp = Prompt;
Int1 = 0;
while (*cp != EOS) {
buffer[Int1++] = *cp++;
if (*cp == EOS) {
buffer[Int1++] = EOS;
strcpy(BackPrompt,buffer);
FBText(ROW_COLUMN,Row,1,buffer);
FBTransfer();
FB.fLastCursorColumn = strlen(buffer) + 1;
}
elif ((Int1 > FB.fNumColumns - 8) Or (Int1 > 190)) {
sprintf(&buffer[Int1]," MORE");
strcpy(BackPrompt,buffer);
FBText(ROW_COLUMN,Row,1,buffer);
FBTransfer();
FB.fLastCursorColumn = strlen(buffer);
(void)FBGetchar(ERASE);
ErasePrompt();
FBForeground(DISPLAY,Color);
Int1 = 0;
}
}
}
void
RedrawPrompt()
{
if (BackPrompt[0] == '\0') return;
FBForeground(DISPLAY,BackColor);
FBText(ROW_COLUMN,FB.fNumRows-2,1,BackPrompt);
FB.fLastCursorColumn = strlen(BackPrompt);
}
void
AppendToOldPrompt(c)
int c;
{
char s[4];
s[0] = ' ';
s[1] = s[0];
s[2] = (char)c;
s[3] = '\0';
strcat(BackPrompt,s);
}
void
ErasePrompt()
{
OutlineText(1,FB.fNumRows-2,FB.fNumColumns,
FB.fNumRows-2,FILL,ERASE,0);
FB.fLastCursorColumn = 1;
BackPrompt[0] = '\0';
FBTransfer();
}
void
OutlineText(Left,Bottom,Right,Top,Type,DisplayOrErase,Pixel)
int Left,Bottom,Right,Top,Pixel;
int Type,DisplayOrErase;
{
/*
* Outline the box defined by LeftColumn, BottomRow, RightColumn, and
* TopRow in the color associated with Pixel.
*/
Bottom = FB.fMaxY-Bottom*FB.fFontHeight;
Top = FB.fMaxY - (Top-1)*FB.fFontHeight;
if (Top > FB.fMaxY) Top = FB.fMaxY;
Left = (Left-1) * FB.fFontWidth;
Right = (Right * FB.fFontWidth) + 1;
if (Bottom < 0)
Bottom = 0;
else
Bottom++;
FBBox(Pixel,DisplayOrErase,Type,0,Left,Bottom,Right,Top);
}
/***********************************************************************
*
* Routines to dislay and erase viewports.
*
*
***********************************************************************/
void
EraseLargeCoarseViewport()
{
/*
* Why -1? Major grid points that are centered on the left or bottom
* edges of the viewport wouldn't be totally erased without -1.
*/
FBFilledBox(0,ERASE,0,View->kvLargeCoarseViewport->kaLeft-1,
View->kvLargeCoarseViewport->kaBottom-1,
View->kvLargeCoarseViewport->kaRight,
View->kvLargeCoarseViewport->kaTop);
}
void
RedisplayViewports()
{
EraseLargeCoarseViewport();
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY)
Redisplay(View->kvCoarseWindow);
else {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
Redisplay(View->kvCoarseWindow);
XORfineViewport();
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
Redisplay(View->kvFineWindow);
Parameters.kpRedisplayControl = SPLITSCREEN;
}
}
void
ShowFineViewport()
{
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY) {
EraseLargeCoarseViewport();
Redisplay(View->kvCoarseWindow);
}
else {
FBFilledBox(0,ERASE,0,View->kvFineViewport->kaLeft-1,
View->kvFineViewport->kaBottom-1,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop);
/* Redisplay in magnifying glass. */
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
Redisplay(View->kvFineWindow);
Parameters.kpRedisplayControl = SPLITSCREEN;
}
FBTransfer();
}
/***********************************************************************
*
* Routines to dislay and erase marked objects and points.
*
*
***********************************************************************/
/* for point marks */
struct mark {
int X;
int Y;
int Delta;
struct mark *next;
};
void
ShowCurrentObject(Pointer,DisplayOrErase)
struct o *Pointer;
int DisplayOrErase;
{
struct ka AOI;
/*
* Show the object with an X through the bounding box.
*/
CDBB(Parameters.kpCellDesc,Pointer,&AOI.kaLeft,&AOI.kaBottom,
&AOI.kaRight,&AOI.kaTop);
if (DisplayOrErase == DISPLAY) {
ShowLine(ColorTable[HighlightingColor].Ent,AOI.kaLeft,AOI.kaBottom,
AOI.kaRight,AOI.kaTop);
ShowLine(ColorTable[HighlightingColor].Ent,AOI.kaLeft,AOI.kaTop,
AOI.kaRight,AOI.kaBottom);
ShowManhattanLine(ColorTable[HighlightingColor].Ent,AOI.kaLeft,
AOI.kaBottom,AOI.kaRight,AOI.kaBottom);
ShowManhattanLine(ColorTable[HighlightingColor].Ent,AOI.kaRight,
AOI.kaBottom,AOI.kaRight,AOI.kaTop);
ShowManhattanLine(ColorTable[HighlightingColor].Ent,AOI.kaRight,
AOI.kaTop,AOI.kaLeft,AOI.kaTop);
ShowManhattanLine(ColorTable[HighlightingColor].Ent,AOI.kaLeft,
AOI.kaTop,AOI.kaLeft,AOI.kaBottom);
}
else {
EraseBox(&AOI);
Redisplay(&AOI);
}
FBTransfer();
}
void
ShowInstanceMarker(DisplayOrErase,Layer,Pointer)
int Layer;
int DisplayOrErase;
struct o *Pointer;
{
struct t *TGen;
char Type;
int DX,DY,X,Y;
if(Not Parameters.kpShowInstanceMarkers)
return;
/*Mark reference point of symbol call */
X = Y = 0;
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&DX,&DY);
if(TGen == NULL)
break;
elif(Type == CDTRANSLATE){
X = DX;
Y = DY;
}
}
ShowMarker(DisplayOrErase,Layer,X,Y,200);
}
void
ShowMarker(DisplayOrErase,Layer,X,Y,Delta)
int DisplayOrErase;
int Layer;
int X,Y;
int Delta; /* width of marker in RESOLUTION*Lambda */
{
struct ka BB;
/* SRW ** save markers for redraw after screen alteration */
static struct mark *mlist;
struct mark *mm, *mtmp;
/* SRW ** display stored marks */
if (!Delta && DisplayOrErase == DISPLAY) {
for (mm = mlist; mm; mm = mm->next) {
X = mm->X;
Y = mm->Y;
Delta = mm->Delta;
/* transform for PUSH */
TPoint(&X,&Y);
ShowLine(Layer,X-Delta,Y,X+Delta,Y);
ShowLine(Layer,X,Y-Delta,X,Y+Delta);
}
FBTransfer();
return;
}
/* SRW ** constant size on screen */
Delta /= RESOLUTION;
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY)
Delta *= View->kvCoarseWindow->kaHeight/100;
else
Delta *= View->kvFineWindow->kaHeight/50;
if (DisplayOrErase == DISPLAY) {
FBForeground(DISPLAY,Layer);
/* add marker to list */
mm = alloc(mark);
if (!mm) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
mm->X = X;
mm->Y = Y;
mm->Delta = Delta;
mm->next = mlist;
mlist = mm;
/* transform for PUSH */
TPoint(&X,&Y);
ShowLine(Layer,X-Delta,Y,X+Delta,Y);
ShowLine(Layer,X,Y-Delta,X,Y+Delta);
}
else {
/* remove from list */
for (mtmp = NULL,mm = mlist; mm; mtmp = mm,mm = mm->next) {
if (mm->X == X && mm->Y == Y) {
if (mm == mlist) mlist = mm->next;
else mtmp->next = mm->next;
afree(mm,mark);
break;
}
}
BB.kaLeft = X - Delta;
BB.kaRight = X + Delta;
BB.kaBottom = Y - Delta;
BB.kaTop = Y + Delta;
EraseBox(&BB);
Redisplay(&BB);
}
FBTransfer();
}
/***********************************************************************
*
* Etc.
*
*
***********************************************************************/
#ifdef WIN32
// Exec cmdline as a new sub-process
//
static HANDLE
msw_NewProcess(DWORD *pid, char *cmdline, int with_console, HANDLE hin,
HANDLE hout, HANDLE herr)
{
PROCESS_INFORMATION info;
DWORD flags = 0;
STARTUPINFO startup = { 0 };
startup.cb = sizeof(STARTUPINFO);
if (hin || hout || herr) {
startup.dwFlags = STARTF_USESTDHANDLES;
startup.hStdInput = hin ? hin : GetStdHandle(STD_INPUT_HANDLE);
startup.hStdOutput = hout ? hout : GetStdHandle(STD_OUTPUT_HANDLE);
startup.hStdError = herr ? herr : GetStdHandle(STD_ERROR_HANDLE);
}
if (with_console)
flags |= CREATE_NEW_CONSOLE;
if (!CreateProcess(0, cmdline, 0, 0, True, flags,
0, 0, &startup, &info))
return (0);
CloseHandle(info.hThread);
if (pid)
*pid = info.dwProcessId;
return (info.hProcess);
}
#endif
void
ShowProcess(cp)
char *cp;
{
#ifdef vms
FILE *list;
char *bp;
char *tmp;
char *cmd;
char buffer[80];
char tmpname[80];
char tf[32];
int i;
cmd = cp;
FBForeground(DISPLAY,ColorTable[MoreTextColor].Ent);
/* convert to upper case */
bp = cp;
while(*bp != NULL){
if(*bp >= 'a' And *bp <= 'z')
*bp -= 32;
++bp;
}
/* substitute tmp filename for "/OUTPUT=KIC" */
bp = cp;
strcpy(tf,"SYSXXXXXX");
tmp = mktemp(tf);
sprintf(tmpname,"%s.LIS",tmp);
tmp = tmpname;
while(*bp != NULL){
if(*bp == 'O' And *(bp+1) == 'U' And *(bp+2) == 'T'){
bp += 3;
/* scan ahead for '=' */
while(*bp != NULL And *bp != '=') ++bp;
if(*bp != NULL){
i = bp - cp + 1;
if(cp[i] == 'K' And cp[i+1] == 'I' And cp[i+2] == 'C'){
cp[i] = NULL;
bp = &cp[i + 3];
sprintf(buffer,"%s%s %s",cp,tmp,bp);
cmd = buffer;
}
}
break;
}
++bp;
}
system(cmd);
if((list = fopen(tmp,"r")) != NULL){
FBMore(View->kvFineViewport->kaLeft-1,
View->kvFineViewport->kaBottom-1,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop,list);
fclose(list);
sprintf(buffer,"DELETE %s;*",tmp);
system(buffer);
}
#endif
#ifdef MSDOS
FILE *list;
char buffer[80];
FBForeground(DISPLAY,ColorTable[MoreTextColor].Ent);
if (!cp || !strlen(cp)) {
cp = "command";
FBEnd();
(void)system(cp);
FB.fInitialized = False;
FBBegin(FB.fDisplay);
FullRedisplay();
ErasePrompt();
return;
}
sprintf(buffer,"%s > tmp__kic.__t",cp);
(void)system(buffer);
list = fopen("tmp__kic.__t","r");
if (list == NULL) {
ShowPrompt("Can't open process.");
return;
}
EnableMore(True);
while (fgets(TypeOut,200,list) != NULL) {
if (MoreLine(TypeOut))
goto quit;
}
if (MorePageDisplay()) {
ShowPrompt("Hit any key to continue.");
(void)FBGetchar(ERASE);
}
quit:
EnableMore(False);
fclose(list);
unlink("tmp__kic.__t");
#else
FBForeground(DISPLAY,ColorTable[MoreTextColor].Ent);
if (!cp || !strlen(cp)) {
#ifdef WIN32
char *shellpath = getenv("SHELL");
if (!shellpath)
shellpath = getenv("COMSPEC");
if (!shellpath)
shellpath = "/bin/sh";
msw_NewProcess(NULL, shellpath, True, 0, 0, 0);
#else
system("xterm &");
#endif
ErasePrompt();
return;
}
/* intercept 'cd' */
if (!strncmp(cp, "cd", 2)) {
char *dir = cp + 2;
if (!*dir || isspace(*dir)) {
while (isspace(*dir))
dir++;
if (!*dir) {
#ifndef WIN32
struct passwd *pw = getpwuid(getuid());
if (pw)
dir = pw->pw_dir;
else
#endif
dir = getenv("HOME");
if (!dir)
dir = "/";
}
if (!chdir(dir))
sprintf(TypeOut, "Current working directory now %s", dir);
else
sprintf(TypeOut, "Directory change to %s failed", dir);
ShowPrompt(TypeOut);
return;
}
}
#ifdef WIN32
{
FILE *list;
char buffer[256];
sprintf(buffer,"%s > tmp__kic.__t",cp);
(void)system(buffer);
list = fopen("tmp__kic.__t","r");
if (list == NULL) {
ShowPrompt("Can't open process.");
return;
}
EnableMore(True);
while (fgets(TypeOut,200,list) != NULL) {
if (MoreLine(TypeOut))
goto quit;
}
if (MorePageDisplay()) {
ShowPrompt("Hit any key to continue.");
(void)FBGetchar(ERASE);
}
quit:
EnableMore(False);
fclose(list);
unlink("tmp__kic.__t");
}
#else
{
FILE *list;
if ((list = propen(cp,"r")) == NULL) {
ShowPrompt("Can't open process.");
return;
}
EnableMore(True);
while (fgets(TypeOut,200,list) != NULL) {
strcat(TypeOut,"\n");
if (MoreLine(TypeOut))
goto quit;
}
if (MorePageDisplay()) {
ShowPrompt("Hit any key to continue.");
(void)FBGetchar(ERASE);
}
quit:
EnableMore(False);
prclose(list);
}
#endif
#endif
FullRedisplay();
ErasePrompt();
}
#if !defined(WIN32) && !defined(MSDOS) && !defined(vms)
#define tst(a,b) (*mode == 'r'? (b) : (a))
#define RDR 0
#define WTR 1
static int propen_pid[20];
static FILE *
propen(cmd,mode)
char *cmd;
char *mode;
{
int p[2];
int myside, hisside, pid;
if(pipe(p) < 0)
return(NULL);
myside = tst(p[WTR], p[RDR]);
hisside = tst(p[RDR], p[WTR]);
if((pid = fork()) == 0){
/* myside and hisside reverse roles in child */
close(myside);
if(dup2(hisside, tst(0, 1)) == -1)
exit(1);
close(hisside);
execl("/bin/sh", "sh", "-c", cmd, (char*)0);
_exit(1);
}
if(pid == -1)
return(NULL);
propen_pid[myside] = pid;
close(hisside);
return(fdopen(myside, mode));
}
static int
prclose(ptr)
FILE *ptr;
{
int f, r;
void (*hstat)(), (*istat)(), (*qstat)();
int status;
f = fileno(ptr);
fclose(ptr);
istat = signal(SIGINT, SIG_IGN);
#ifdef SIGQUIT
qstat = signal(SIGQUIT, SIG_IGN);
#endif
#ifdef SIGHUP
hstat = signal(SIGHUP, SIG_IGN);
#endif
while((r = wait((int *)&status)) != propen_pid[f] && r != -1)
;
if(r == -1)
status = -1;
signal(SIGINT, istat);
#ifdef SIGQUIT
signal(SIGQUIT, qstat);
#endif
#ifdef SIGHUP
signal(SIGHUP, hstat);
#endif
return(status);
}
#endif
#if __NDPC__
/* sleep() delays for i seconds
* MicroWay NDP-C clock() returns hundredths of a second
*/
void
sleep(i)
int i;
{
int t;
if (i <= 0) return;
t = clock();
while (100*i > clock() - t) ;
}
#endif
kic-2.4c/src/kic/attri.c 0000644 0000764 0000764 00000117606 07525346713 014567 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Layer attribute menu code.
*/
#include "prefix.h"
#include "kic.h"
extern int LockOut; /* SRW ** disables ^F, etc. in Point() */
int NoMakeVisible; /* SRW ** don't make invisible layers visible */
/* in PointLayerTable() */
#define Matching(string) !strcmp(Parameters.kpCommand,string)
static int DefaultFillPatterns[][8] = {
{0x89, 0x18, 0x24, 0xc2, 0x43, 0x24, 0x18, 0x91},
{0x88, 0x48, 0x24, 0x13, 0xc8, 0x24, 0x12, 0x11},
{0x42, 0x81, 0x3c, 0x42, 0x42, 0x3c, 0x81, 0x42},
{0x11, 0x0e, 0x02, 0x62, 0x91, 0x28, 0x48, 0x90},
{0x81, 0x42, 0x3c, 0x00, 0x24, 0x24, 0x42, 0x81},
{0x91, 0x52, 0x64, 0x08, 0x10, 0x26, 0x4a, 0x89},
{0x44, 0x28, 0x93, 0x82, 0x82, 0x93, 0x28, 0x44},
{0x81, 0x42, 0x24, 0x99, 0x42, 0x24, 0x42, 0x81},
{0x54, 0x94, 0x23, 0xc0, 0x03, 0xc4, 0x29, 0x2a},
{0x08, 0x08, 0x08, 0xcf, 0x40, 0x40, 0x78, 0x08},
{0x00, 0x00, 0x42, 0x00, 0x24, 0x00, 0x42, 0x00},
{0x11, 0x22, 0x40, 0x88, 0x11, 0x02, 0x44, 0x88},
{0x01, 0x9c, 0xa2, 0xaa, 0xa2, 0x9c, 0x40, 0x3e},
{0x01, 0x39, 0x27, 0x20, 0x20, 0x27, 0x39, 0x01},
{0x00, 0x55, 0x00, 0x82, 0x10, 0x82, 0x00, 0x55},
{0x00, 0x32, 0x14, 0x14, 0x15, 0x3e, 0x40, 0x00}
};
/* XKIC fill patterns
static int DefaultFillPatterns[][8] = {
{0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11},
{0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88},
{0x66, 0x11, 0x88, 0x66, 0x66, 0x11, 0x88, 0x66},
{0x66, 0x88, 0x11, 0x66, 0x66, 0x88, 0x11, 0x66},
{0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55},
{0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0},
{0x55, 0x00, 0x55, 0x00, 0x55, 0x00, 0x55, 0x00},
{0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA},
{0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC},
{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
{0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00},
{0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33},
{0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F},
{0xFE, 0x82, 0xBA, 0xAA, 0xA2, 0xBE, 0x80, 0xFF},
{0x02, 0x7A, 0x4A, 0x4A, 0x42, 0x42, 0x7E, 0x00},
{0x2C, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x2C},
{0x18, 0x24, 0x42, 0x81, 0x81, 0x42, 0x24, 0x18}
};
*/
#ifdef __STDC__
static void color(int*,int);
static int get_layer(int*);
static int point_color(int*,int);
static void alter_color(int,int,int);
static void show_choices(void);
static void show_pixel_map(void);
static void flip_pixel(void);
#else
static void color();
static int get_layer();
static int point_color();
static void alter_color();
static void show_choices();
static void show_pixel_map();
static void flip_pixel();
#endif
void
Attri(LookedAhead)
int *LookedAhead;
{
*LookedAhead = False;
Parameters.kpMenu = ATTRIBUTESMENU;
FixMenuPrefix(AttributeMenu);
ShowCommandMenu();
}
void
Updat()
{
extern char *MenuUPDAT;
MenuSelect(MenuUPDAT);
SaveTechFile();
MenuDeselect(MenuUPDAT);
}
void
DisplayLabels()
{
extern char *MenuLABLS;
if (Parameters.kpDisplayAllLabels) {
MenuDeselect(MenuLABLS);
ShowPrompt("Labels will not be shown in large windows.");
Parameters.kpDisplayAllLabels = False;
}
else {
MenuSelect(MenuLABLS);
ShowPrompt("Labels will always be displayed.");
Parameters.kpDisplayAllLabels = True;
}
}
void
LabelInstances()
{
extern char *MenuCNAMS;
if (Parameters.kpLabelAllInstances) {
MenuDeselect(MenuCNAMS);
ShowPrompt("Instances will not be labeled in large windows.");
Parameters.kpLabelAllInstances = False;
}
else {
MenuSelect(MenuCNAMS);
ShowPrompt("Instances will always be labeled.");
Parameters.kpLabelAllInstances = True;
}
}
void
Mark()
{
extern char *MenuMARK;
if (Parameters.kpShowInstanceMarkers) {
MenuDeselect(MenuMARK);
ShowPrompt("Instances will not be marked when selected.");
Parameters.kpShowInstanceMarkers = False;
}
else {
MenuSelect(MenuMARK);
ShowPrompt("Instances will always be marked when selected.");
Parameters.kpShowInstanceMarkers = True;
}
}
void
Sides()
{
char Buf[80];
int i;
char *TypeIn;
extern char *MenuSIDES;
MenuSelect(MenuSIDES);
loop {
sprintf(Buf,"Enter number of sides for a round flash (8 to 90, now %d).",
Parameters.kpNumRoundFlashSides);
ShowPrompt(Buf);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) break;
if (!strlen(TypeIn)) break;
if (sscanf(TypeIn,"%d",&i) != 1) continue;;
if (i > 7 And i < 91) {
Parameters.kpNumRoundFlashSides = i;
break;
}
}
sprintf(Buf,"Clip polygon vertices to grid points (%c)?",
Parameters.kpClipVerticesToGrid ? 'Y' : 'N');
ShowPrompt(Buf);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL) {
if (*TypeIn == 'y' Or *TypeIn == 'Y')
Parameters.kpClipVerticesToGrid = True;
elif (*TypeIn == 'n' Or *TypeIn == 'N')
Parameters.kpClipVerticesToGrid = False;
}
ErasePrompt();
MenuDeselect(MenuSIDES);
}
void
ShowRGB()
{
extern char *MenuRGB;
MenuSelect(MenuRGB);
sprintf(TypeOut,"<%d,%d,%d>",
LayerTable[Parameters.kpLayer].klR,
LayerTable[Parameters.kpLayer].klG,
LayerTable[Parameters.kpLayer].klB);
ShowPrompt(TypeOut);
MenuDeselect(MenuRGB);
}
void
SetColor(RGBpix,PlusOrMinus)
int RGBpix;
int PlusOrMinus;
{
alter_color(-1,RGBpix,PlusOrMinus);
}
char *MenuBGRND = "bgrnd";
char *MenuHLITE = "hlite";
char *MenuPRMPT = "prmpt";
char *MenuMTEXT = "mtext";
char *MenuMHLTE = "mhlte";
char *MenuMSEL = "msel";
char *MenuMORE = "more ";
char *MenuBBINS = "bbins";
char *MenuNMINS = "nmins";
char *MenuSZINS = "szins";
char *MenuCGRID = "cgrid";
char *MenuFGRID = "fgrid";
void
AttribColor(LookedAhead)
int *LookedAhead;
{
int i = 0, OldMenu;
extern char *MenuPLUSR,*MenuMINSR;
extern char *MenuPLUSG,*MenuMINSG;
extern char *MenuPLUSB,*MenuMINSB;
OldMenu = Parameters.kpMenu;
Parameters.kpMenu = AMBIGUITYMENU;
AmbiguityMenu[0].mEntry = MenuHLITE;
AmbiguityMenu[1].mEntry = MenuBGRND;
AmbiguityMenu[2].mEntry = " ";
AmbiguityMenu[3].mEntry = MenuPRMPT;
AmbiguityMenu[4].mEntry = MenuMTEXT;
AmbiguityMenu[5].mEntry = MenuMHLTE;
AmbiguityMenu[6].mEntry = MenuMSEL;
AmbiguityMenu[7].mEntry = MenuMORE;
AmbiguityMenu[8].mEntry = " ";
AmbiguityMenu[9].mEntry = MenuFGRID;
AmbiguityMenu[10].mEntry = MenuCGRID;
AmbiguityMenu[11].mEntry = " ";
AmbiguityMenu[12].mEntry = MenuBBINS;
AmbiguityMenu[13].mEntry = MenuNMINS;
AmbiguityMenu[14].mEntry = MenuSZINS;
AmbiguityMenu[15].mEntry = " ";
AmbiguityMenu[16].mEntry = MenuPLUSR;
AmbiguityMenu[17].mEntry = MenuMINSR;
AmbiguityMenu[18].mEntry = MenuPLUSG;
AmbiguityMenu[19].mEntry = MenuMINSG;
AmbiguityMenu[20].mEntry = MenuPLUSB;
AmbiguityMenu[21].mEntry = MenuMINSB;
AmbiguityMenu[22].mEntry = NULL;
FixMenuPrefix(AmbiguityMenu);
ShowMenu(AmbiguityMenu);
loop {
if (*LookedAhead == False)
i = PointLoopSafe(LookedAhead);
else
*LookedAhead = False;
switch (i) {
case PL_ESC:
goto quit;
case PL_PCW:
continue;
case PL_CMD:
if (Matching(MenuHLITE))
{color(LookedAhead,HighlightingColor); continue;}
if (Matching(MenuBGRND))
{color(LookedAhead,0); continue;}
if (Matching(MenuPRMPT))
{color(LookedAhead,MenuPromptColor); continue;}
if (Matching(MenuMTEXT))
{color(LookedAhead,MenuTextColor); continue;}
if (Matching(MenuMHLTE))
{color(LookedAhead,MenuHighlightingColor); continue;}
if (Matching(MenuMSEL))
{color(LookedAhead,MenuSelectColor); continue;}
if (Matching(MenuMORE))
{color(LookedAhead,MoreTextColor); continue;}
if (Matching(MenuFGRID))
{color(LookedAhead,FineGridColor); continue;}
if (Matching(MenuCGRID))
{color(LookedAhead,CoarseGridColor); continue;}
if (Matching(MenuBBINS))
{color(LookedAhead,InstanceBBColor); continue;}
if (Matching(MenuNMINS))
{color(LookedAhead,InstanceNameColor); continue;}
if (Matching(MenuSZINS))
{color(LookedAhead,InstanceSizeColor); continue;}
if (Matching(MenuMINSB))
{SetColor('b','-'); continue;}
if (Matching(MenuMINSG))
{SetColor('g','-'); continue;}
if (Matching(MenuMINSR))
{SetColor('r','-'); continue;}
if (Matching(MenuPLUSB))
{SetColor('b','+'); continue;}
if (Matching(MenuPLUSG))
{SetColor('g','+'); continue;}
if (Matching(MenuPLUSR))
{SetColor('r','+'); continue;}
continue;
}
Parameters.kpMenu = OldMenu;
break;
}
quit:
Parameters.kpMenu = OldMenu;
ShowCommandMenu();
}
static void
color(LookedAhead,which)
int *LookedAhead;
int which;
{
char *menu;
if (Parameters.kpMergeColors)
strcpy(TypeOut,"Point to color for ");
else
strcpy(TypeOut,"Set RGB for ");
switch (which) {
case 0:
MenuSelect(MenuBGRND);
ShowPrompt("Set RGB of background color.");
(void)point_color(LookedAhead,0);
ErasePrompt();
MenuDeselect(MenuBGRND);
return;
case HighlightingColor:
MenuSelect(MenuHLITE);
ShowPrompt("Set RGB of highlighting color.");
(void)point_color(LookedAhead,HighlightingColor);
ErasePrompt();
MenuDeselect(MenuHLITE);
return;
case MenuTextColor:
menu = MenuMTEXT;
strcat(TypeOut,"menu text.");
break;
case MenuHighlightingColor:
menu = MenuMHLTE;
strcat(TypeOut,"menu highlighting.");
break;
case MenuSelectColor:
menu = MenuMSEL;
strcat(TypeOut,"selected menu text.");
break;
case MoreTextColor:
menu = MenuMORE;
strcat(TypeOut,"\"more\" mode text.");
break;
case MenuPromptColor:
menu = MenuPRMPT;
strcat(TypeOut,"prompt message text.");
break;
case FineGridColor:
menu = MenuFGRID;
strcat(TypeOut,"fine grid lines.");
break;
case CoarseGridColor:
menu = MenuCGRID;
strcat(TypeOut,"coarse grid lines.");
break;
case InstanceBBColor:
menu = MenuBBINS;
strcat(TypeOut,"unexpanded instance bounding boxes.");
break;
case InstanceNameColor:
menu = MenuNMINS;
strcat(TypeOut,"unexpanded instance names.");
break;
case InstanceSizeColor:
menu = MenuSZINS;
strcat(TypeOut,"unexpanded instance sizes.");
break;
default:
return;
}
MenuSelect(menu);
ShowPrompt(TypeOut);
if (Parameters.kpMergeColors) {
if (get_layer(LookedAhead)) {
ColorTable[which].Ent = Parameters.kpLayer;
switch (which) {
case MenuTextColor:
case MenuHighlightingColor:
case MenuSelectColor:
ShowCommandMenu();
break;
case MoreTextColor:
ShowPrompt("New \"more\" color set.");
break;
case MenuPromptColor:
ShowPrompt("New prompt color set.");
break;
case FineGridColor:
case CoarseGridColor:
ShowPrompt(
"New grid color will be visible after redraw.");
break;
case InstanceBBColor:
case InstanceNameColor:
case InstanceSizeColor:
ShowPrompt(
"New instance color will be visible after redraw.");
break;
}
}
else {
ErasePrompt();
}
}
else {
(void)point_color(LookedAhead,which);
ErasePrompt();
}
MenuDeselect(menu);
}
void
SetGrid(LookedAhead)
int *LookedAhead;
{
char *TypeIn;
double d;
int OldParameter = Parameters.kpShowGridInLargeViewport;
int i;
extern char *MenuGRID;
MenuSelect(MenuGRID);
if (Parameters.kpDoingHardcopy) {
sprintf(TypeOut,"Show grid in hard copy? (%c) ",
Parameters.kpGridDisplayed ? 'y' : 'n');
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
if (*TypeIn == 'y' || *TypeIn == 'Y') {
Parameters.kpGridDisplayed = True;
Parameters.kpHardcopyGrid = True;
}
if (*TypeIn == 'n' || *TypeIn == 'N') {
Parameters.kpGridDisplayed = False;
Parameters.kpHardcopyGrid = False;
}
goto quit;
}
if (Parameters.kpMenu == ATTRIBUTESMENU) {
sprintf(TypeOut,"Hex code for grid line style, 0 for point grid (%x)?",
Parameters.kpGridLineStyle);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
if (sscanf(TypeIn,"%x",&i) == 1)
if (i >= 0 && i < 256)
Parameters.kpGridLineStyle = i;
sprintf(TypeOut,"Show grid above layout geometries (%c)?",
Parameters.kpGridOnTop ? 'Y' : 'N');
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
if (*TypeIn == 'n' Or *TypeIn == 'N')
Parameters.kpGridOnTop = False;
elif (*TypeIn == 'y' Or *TypeIn == 'Y')
Parameters.kpGridOnTop = True;
sprintf(TypeOut,"Show grid in coarse viewport of a split screen (%c)?",
Parameters.kpShowGridInLargeViewport ? 'Y' : 'N');
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
if (*TypeIn == 'n' Or *TypeIn == 'N')
Parameters.kpShowGridInLargeViewport = False;
elif (*TypeIn == 'y' Or *TypeIn == 'Y')
Parameters.kpShowGridInLargeViewport = True;
}
sprintf(TypeOut,
"Enter new grid interval (currently %g, CR to turn grid %s): ",
(double)Parameters.kpGrid/RESOLUTION,
Parameters.kpGridDisplayed ? "off" : "on" );
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL){
if (!strlen(TypeIn)) {
Parameters.kpGridDisplayed ^= 1;
ErasePrompt();
}
elif (sscanf(TypeIn,"%lg",&d) == 1 And d > 0) {
Parameters.kpGrid = RESOLUTION*d;
if (Parameters.kpGrid == 0)
Parameters.kpGrid = 1;
sprintf(TypeOut,"Grid/Snap point spacing now %g/%g.",
(double)Parameters.kpGrid/RESOLUTION,
(double)Parameters.kpGrid/
(Parameters.kpPixToLambdaSnapping*RESOLUTION));
ShowPrompt(TypeOut);
}
else
ErasePrompt();
}
quit:
if (Parameters.kpShowGridInLargeViewport Or OldParameter)
FullRedisplay();
else
ShowFineViewport();
ErasePrompt();
MenuDeselect(MenuGRID);
}
void
Visib(LookedAhead)
int *LookedAhead;
{
extern char *MenuVISIB;
MenuSelect(MenuVISIB);
ShowPrompt("Point at layers to toggle visibility.");
NoMakeVisible = True;
loop {
switch (PointLoopLayer(LookedAhead)) {
case PL_PLT:
if (LayerTable[Parameters.kpLayer].klAttributes & VISIBLE)
MakeLayerInvisible(Parameters.kpLayer);
else
MakeLayerVisible(Parameters.kpLayer);
break;
case PL_ESC:
case PL_CMD:
MenuDeselect(MenuVISIB);
NoMakeVisible = False;
ErasePrompt();
return;
}
}
}
void
MakeLayerVisible(Layer)
int Layer;
{
int Row,Column,Lmin;
if (Layer <= NumLayerTable) {
Lmin = Parameters.kpVisibleLayerMenuRow *
Parameters.kpLayersPerMenuRow + 1;
LayerTable[Layer].klAttributes |= VISIBLE;
if (Layer >= Lmin && Layer < Lmin + Parameters.kpLayersPerMenuRow) {
Row = FB.fNumRows;
Column = (Layer - 1 - (((Layer-1)/Parameters.kpLayersPerMenuRow) *
Parameters.kpLayersPerMenuRow)) * 6 + 1;
LtBox(Column,Row,DISPLAY,Layer);
}
}
}
void
MakeLayerInvisible(Layer)
int Layer;
{
int Row,Column,Lmin;
if (Layer <= NumLayerTable) {
Lmin = Parameters.kpVisibleLayerMenuRow *
Parameters.kpLayersPerMenuRow + 1;
LayerTable[Layer].klAttributes &= ~VISIBLE;
if (Layer >= Lmin && Layer < Lmin + Parameters.kpLayersPerMenuRow) {
Row = FB.fNumRows;
Column = (Layer - 1 - (((Layer-1)/Parameters.kpLayersPerMenuRow) *
Parameters.kpLayersPerMenuRow)) * 6 + 1;
LtBox(Column,Row,ERASE,Layer);
}
}
}
void
Blink(LookedAhead)
int *LookedAhead;
{
int Layer;
extern char *MenuBLINK;
MenuSelect(MenuBLINK);
if (! FB.fBlinkers) {
ShowPrompt("Sorry, blinking layers are not available.");
*LookedAhead = False;
MenuDeselect(MenuBLINK);
return;
}
ShowPrompt("Point to EACH layer you want to be blinking.");
for (Layer = 1; Layer <= NumLayerTable; Layer++) {
LayerTable[Layer].klAttributes &= ~BLINK;
FBBlink(Layer,0,0,0,0);
}
loop {
Point();
if (Parameters.kpPointLayerTable)
LayerTable[Parameters.kpLayer].klAttributes |= BLINK;
else {
*LookedAhead = True;
MenuDeselect(MenuBLINK);
return;
}
}
}
void
Dimen(LookedAhead)
int *LookedAhead;
{
char *TypeIn;
double d;
extern char *MenuDIMEN;
MenuSelect(MenuDIMEN);
ShowPrompt("Point to layer on which to define minimum feature size.");
Point();
if (Parameters.kpPointLayerTable) {
sprintf(TypeOut,"Minimum dimension? (currently %g): ",(double)
LayerTable[Parameters.kpLayer].klMinDimensions/RESOLUTION);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
*LookedAhead = False;
if (TypeIn != NULL && *TypeIn != '\0' && *TypeIn != '\n') {
if (sscanf(TypeIn,"%lg",&d) == 1 And d >= 0) {
LayerTable[Parameters.kpLayer].klMinDimensions =
d*RESOLUTION;
sprintf(TypeOut,
"Minimum dimension on selected layer set to %g.",d);
ShowPrompt(TypeOut);
if (LayerTable[Parameters.kpLayer].klWireWidth <
LayerTable[Parameters.kpLayer].klMinDimensions)
LayerTable[Parameters.kpLayer].klWireWidth =
LayerTable[Parameters.kpLayer].klMinDimensions;
}
else
ShowPrompt("Bad input, parameter not changed.");
}
else
ErasePrompt();
}
else {
*LookedAhead = True;
ErasePrompt();
}
MenuDeselect(MenuDIMEN);
return;
}
void
RemoveLayer(LookedAhead)
int *LookedAhead;
{
int i,Layer;
extern char *MenuRMOVE;
ShowPrompt("Point to the layers which you want removed.");
loop {
MenuSelect(MenuRMOVE);
if (get_layer(LookedAhead)) {
Layer = Parameters.kpLayer;
for (i = Layer; i < NumLayerTable; i++)
LayerTable[i] = LayerTable[i+1];
--NumLayerTable;
InitVLT();
ShowLayerTable();
}
else
if (Parameters.kpCommand[0] != '\0' Or
Parameters.kpCommand[1] == ESCAPE)
break;
}
MenuDeselect(MenuRMOVE);
ErasePrompt();
}
void
AddLayer()
{
int i,n = 0;
char c,*TypeIn;
extern char *MenuADLYR;
MenuSelect(MenuADLYR);
sprintf(TypeOut,"Enter new layer number (1 for bottom layer, %d for top).",
(NumLayerTable + 1));
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
sscanf(TypeIn,"%d",&n);
if (n <= 0 Or n > (NumLayerTable + 1)) {
ShowPrompt("Sorry, bad layer number.");
goto quit;
}
ShowPrompt("Enter layer name.");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL Or *TypeIn == '\0' Or *TypeIn == '\n') goto quit;
++NumLayerTable;
for (i = 1; i < n; ++i)
CDSetLayer(i,LayerTable[i].klTechnology,LayerTable[i].klMask);
for (i = NumLayerTable; i > n; i--) {
LayerTable[i] = LayerTable[i - 1];
CDSetLayer(i,LayerTable[i].klTechnology,LayerTable[i].klMask);
}
LayerTable[n].klTechnology = LayerTable[n].klMask[0] =
LayerTable[n].klMask[1] = LayerTable[n].klMask[2] = ' ';
LayerTable[n].klTechnology = *TypeIn++;
for (i = 0; i < 3; i++) {
if ((c = *TypeIn++) == '\0')
break;
else
LayerTable[n].klMask[i] = c;
}
LayerTable[n].klAttributes = VISIBLE | FILLED;
LayerTable[n].klStyleID = 0;
LayerTable[n].klMinDimensions = 0;
LayerTable[n].klWireWidth = 0;
LayerTable[n].klR = LayerTable[n].klG = LayerTable[n].klB = 127;
for (i = 0; i < 8; i++)
LayerTable[n].klStyle[i] = 0;
ShowPrompt("Is this layer symbolic (N)?");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL And (*TypeIn == 'y' Or *TypeIn == 'Y'))
LayerTable[n].klAttributes |= SYMBOLIC;
ShowPrompt("Enter RGB of this layer.");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL) {
int r, g, b;
int nn = sscanf(TypeIn,"%d %d %d",&r,&g,&b);
if (nn > 2)
LayerTable[n].klB = min(max(b,0),255);
if (nn > 1)
LayerTable[n].klG = min(max(g,0),255);
if (nn > 0)
LayerTable[n].klR = min(max(r,0),255);
}
InitVLT();
ShowLayerTable();
quit:
MenuDeselect(MenuADLYR);
ErasePrompt();
}
static int
get_layer(LookedAhead)
/* if successful, Parameters.kpLayer contains choice */
int *LookedAhead;
{
switch (PointLoopLayer(LookedAhead)) {
case PL_ESC:
case PL_CMD:
case PL_PCW:
break;
case PL_PLT:
return (True);
}
return (False);
}
static int
point_color(LookedAhead,Color)
/* Loop until UNDO, a non color setting command, point to coarse window, or
* ESC is entered.
*/
int *LookedAhead;
int Color;
{
extern char *MenuPLUSR,*MenuMINSR;
extern char *MenuPLUSG,*MenuMINSG;
extern char *MenuPLUSB,*MenuMINSB;
extern int EscReturn;
loop {
if (*LookedAhead == False) {
EscReturn = True;
Point();
EscReturn = False;
}
else
*LookedAhead = False;
if (Parameters.kpCommand[1] == ESCAPE)
return (PL_ESC);
if (Parameters.kpCommand[0] != EOS) {
if (Matching(MenuMINSB)) { alter_color(Color,'b','-'); continue; }
if (Matching(MenuMINSG)) { alter_color(Color,'g','-'); continue; }
if (Matching(MenuMINSR)) { alter_color(Color,'r','-'); continue; }
if (Matching(MenuPLUSB)) { alter_color(Color,'b','+'); continue; }
if (Matching(MenuPLUSG)) { alter_color(Color,'g','+'); continue; }
if (Matching(MenuPLUSR)) { alter_color(Color,'r','+'); continue; }
*LookedAhead = True;
return (PL_CMD);
}
if (Parameters.kpPointCoarseWindow)
return (PL_PCW);
}
}
static void
alter_color(Color,RGBpix,PlusOrMinus)
int Color;
int RGBpix;
int PlusOrMinus;
{
extern char *MenuPLUSR,*MenuMINSR;
extern char *MenuPLUSG,*MenuMINSG;
extern char *MenuPLUSB,*MenuMINSB;
char *menu;
short *which;
switch (RGBpix) {
case 'r':
case 'R':
if (PlusOrMinus == '+')
menu = MenuPLUSR;
else
menu = MenuMINSR;
if (Color >= 0)
which = &ColorTable[Color].R;
else
which = &LayerTable[Parameters.kpLayer].klR;
break;
case 'g':
case 'G':
if (PlusOrMinus == '+')
menu = MenuPLUSG;
else
menu = MenuMINSG;
if (Color >= 0)
which = &ColorTable[Color].G;
else
which = &LayerTable[Parameters.kpLayer].klG;
break;
case 'b':
case 'B':
if (PlusOrMinus == '+')
menu = MenuPLUSB;
else
menu = MenuMINSB;
if (Color >= 0)
which = &ColorTable[Color].B;
else
which = &LayerTable[Parameters.kpLayer].klB;
break;
default:
return;
}
MenuSelect(menu);
if (PlusOrMinus == '+') {
if (*which == FB.fMaxIntensity) *which = 0;
else if (((*which) += 10) > FB.fMaxIntensity)
*which = FB.fMaxIntensity;
}
else {
if (*which == 0) *which = FB.fMaxIntensity;
else if (((*which) -= 10) < 0) *which = 0;
}
if (Color >= 0) {
FBVLT(ColorTable[Color].Ent,ColorTable[Color].R,
ColorTable[Color].G,ColorTable[Color].B);
sprintf(TypeOut,"<%d,%d,%d>",ColorTable[Color].R,
ColorTable[Color].G,ColorTable[Color].B);
}
else {
FBVLT(Parameters.kpLayer,
LayerTable[Parameters.kpLayer].klR,
LayerTable[Parameters.kpLayer].klG,
LayerTable[Parameters.kpLayer].klB);
sprintf(TypeOut,"<%d,%d,%d>",
LayerTable[Parameters.kpLayer].klR,
LayerTable[Parameters.kpLayer].klG,
LayerTable[Parameters.kpLayer].klB);
}
ShowLayerTable();
ShowPrompt(TypeOut);
MenuDeselect(menu);
}
/*********************************************************************
*
* Fill pattern editing
*
* Pointing to the box in location 0 toggles pixels. Point at layer
* to load pixel editor (first box), starts with DefaultFillPattern[0].
*
*********************************************************************/
static struct {
int fi_rc; /* temporary redisplay control */
int fi_vc; /* temporary view control */
int fi_on; /* True if doing FILL command */
int fi_px[8]; /* edited pixel storage */
int fi_eboxbot; /* bottom of edit box */
int fi_spa; /* spacing of edit box big pixels */
int fi_del; /* width of edit box big pixel */
int fi_incr; /* spacing of pattern menu boxes */
int fi_sep; /* separation of pattern menu boxes */
} fi;
void
Fill(LookedAhead)
int *LookedAhead;
{
int i,j=0;
char *ol;
extern char *MenuFILL;
MenuSelect(MenuFILL);
*LookedAhead = False;
if (Not FB.fDefinableFillPatterns) {
ShowPrompt("Point at layers to switch between filled and outlined.");
loop {
switch (PointLoopLayer(LookedAhead)) {
case PL_ESC:
case PL_PCW:
case PL_CMD:
MenuDeselect(MenuFILL);
ErasePrompt();
return;
case PL_PLT:
LayerTable[Parameters.kpLayer].klAttributes ^= FILLED;
ShowLayerTable();
continue;
}
}
}
fi.fi_on = True;
fi.fi_rc = Parameters.kpRedisplayControl;
fi.fi_vc = View->kvControl;
View->kvControl = SPLITSCREEN;
SetPositioning();
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
LockOut = True;
/* compute spacing between fill pattern menu */
i = 10;
if (!View->kvFineViewportOnBottom) i = 6;
fi.fi_incr = View->kvFineWindow->kaWidth/i;
fi.fi_sep = fi.fi_incr >> 3;
for (i = 0; i < 8; i++)
fi.fi_px[i] = DefaultFillPatterns[0][i];
show_choices();
loop {
ShowPrompt(
"Point at layer to load fillpattern, or fillpattern to assign.");
loop {
switch (PointLoopLayer(LookedAhead)) {
case PL_PLT:
if (!(LayerTable[Parameters.kpLayer].klAttributes
& FILLED)) {
ShowPrompt(
"Empty fill, can't edit. Select another layer or fillpattern.");
continue;
}
for (i = 0; i < 8; i++)
if (LayerTable[Parameters.kpLayer].klStyle[i]) break;
if (i == 8) {
ShowPrompt(
"Solid fill, can't edit. Select another layer or fillpattern.");
continue;
}
ShowPrompt(
"Use edit box to change pixels, point at fillpattern to end editing.");
for (i = 0; i < 8; i++)
fi.fi_px[i] =
LayerTable[Parameters.kpLayer].klStyle[i];
show_pixel_map();
continue;
case PL_PCW:
if (InBox(KicCursor.kcRawX,KicCursor.kcRawY,
View->kvFineWindow)) {
j = 1 + (KicCursor.kcRawX -
View->kvFineWindow->kaLeft)/fi.fi_incr;
if (j > 1) break;
if (KicCursor.kcRawY < fi.fi_eboxbot) {
if (KicCursor.kcRawY >
(View->kvFineWindow->kaBottom +
fi.fi_eboxbot)/2)
j = 0;
break;
}
flip_pixel();
continue;
}
case PL_ESC:
case PL_CMD:
goto quit;
}
break;
}
ShowPrompt("Point at layer to have this fill pattern.");
switch (PointLoopLayer(LookedAhead)) {
case PL_ESC:
case PL_PCW:
case PL_CMD:
goto quit;
}
switch (j) {
case 0:
LayerTable[Parameters.kpLayer].klAttributes
&= ~(FILLED|OUTLINED);
break;
case 1:
LayerTable[Parameters.kpLayer].klAttributes |= FILLED;
LayerTable[Parameters.kpLayer].klAttributes &= ~OUTLINED;
for (i = 0; i < 8; i++)
LayerTable[Parameters.kpLayer].klStyle[i] = 0;
break;
case 2:
for (i = 0; i < 8; i++)
LayerTable[Parameters.kpLayer].klStyle[i] = fi.fi_px[i];
break;
default:
if (View->kvFineViewportOnBottom) {
if (KicCursor.kcRawY <
(View->kvFineWindow->kaTop +
View->kvFineWindow->kaBottom)/2)
j += 8;
}
else {
int delta =
(View->kvFineWindow->kaTop -
View->kvFineWindow->kaBottom)/4;
if (KicCursor.kcRawY <
View->kvFineWindow->kaTop - delta)
j += 4;
if (KicCursor.kcRawY <
View->kvFineWindow->kaTop - 2*delta)
j += 4;
if (KicCursor.kcRawY <
View->kvFineWindow->kaTop - 3*delta)
j += 4;
}
for (i = 0; i < 8; i++)
LayerTable[Parameters.kpLayer].klStyle[i] =
DefaultFillPatterns[j-3][i];
break;
}
if (j > 1) {
LayerTable[Parameters.kpLayer].klAttributes |= FILLED;
ShowPrompt("Outline fill pattern? [n]");
ol = FBEdit(NULL);
if (ol != NULL And (strchr(ol,'y') || strchr(ol,'Y')))
LayerTable[Parameters.kpLayer].klAttributes |= OUTLINED;
else
LayerTable[Parameters.kpLayer].klAttributes &= ~OUTLINED;
}
InitVLT();
MakeLayerInvisible(Parameters.kpLayer);
MakeLayerVisible(Parameters.kpLayer);
}
quit:
InitVLT();
MenuDeselect(MenuFILL);
ErasePrompt();
Parameters.kpRedisplayControl = fi.fi_rc;
View->kvControl = fi.fi_vc;
SetPositioning();
ShowLayerTable();
RedisplayViewports();
if (!strcmp(Parameters.kpCommand,MenuFILL)) {
Parameters.kpCommand[0] = EOS;
*LookedAhead = False;
}
LockOut = False;
fi.fi_on = False;
FBTransfer();
return;
}
static void
show_choices()
/* show fill pattern menu in magnifying glass */
{
int j,EboxW,tmpat,tmpst;
struct ka BOX;
EraseBox(View->kvFineWindow);
tmpat = LayerTable[1].klAttributes;
tmpst = LayerTable[1].klStyleID;
LayerTable[1].klAttributes = VISIBLE;
LayerTable[1].klStyleID = 0;
EboxW = fi.fi_incr - fi.fi_sep;
BOX.kaLeft = View->kvFineWindow->kaLeft;
BOX.kaRight = View->kvFineWindow->kaLeft + EboxW;
BOX.kaTop = View->kvFineWindow->kaTop - EboxW;
fi.fi_eboxbot= BOX.kaTop;
BOX.kaBottom = (View->kvFineWindow->kaBottom + BOX.kaTop)/2;
/* Filled = False */
ShowBox(1,&BOX);
/* Filled = True */
LayerTable[1].klAttributes |= FILLED;
BOX.kaTop = BOX.kaBottom;
BOX.kaBottom = View->kvFineWindow->kaBottom;
ShowBox(1,&BOX);
BOX.kaTop = View->kvFineWindow->kaTop;
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
LayerTable[1].klStyleID = 1;
LayerTable[1].klAttributes |=
(FINE_FILL | COARSE_FILL);
if (View->kvFineViewportOnBottom) {
BOX.kaBottom = (BOX.kaTop + BOX.kaBottom + fi.fi_sep)/2;
for (j = 0; j < 8; j++) {
if (j)
FBDefineFillPattern(1,DefaultFillPatterns[j]);
else
FBDefineFillPattern(1,fi.fi_px);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
BOX.kaTop = BOX.kaBottom - fi.fi_sep;
BOX.kaBottom = View->kvFineWindow->kaBottom;
BOX.kaLeft = View->kvFineWindow->kaLeft + fi.fi_incr;
BOX.kaRight = BOX.kaLeft + EboxW;
for (j = 8; j < 16; j++) {
FBDefineFillPattern(1,DefaultFillPatterns[j]);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
}
else {
BOX.kaBottom += 3*(BOX.kaTop - BOX.kaBottom)/4 + fi.fi_sep/2;
for (j = 0; j < 4; j++) {
if (j)
FBDefineFillPattern(1,DefaultFillPatterns[j]);
else
FBDefineFillPattern(1,fi.fi_px);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
BOX.kaTop = BOX.kaBottom - fi.fi_sep;
BOX.kaBottom -=
(View->kvFineWindow->kaTop - View->kvFineWindow->kaBottom)/4;
BOX.kaLeft = View->kvFineWindow->kaLeft + fi.fi_incr;
BOX.kaRight = BOX.kaLeft + EboxW;
for (j = 4; j < 8; j++) {
FBDefineFillPattern(1,DefaultFillPatterns[j]);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
BOX.kaTop = BOX.kaBottom - fi.fi_sep;
BOX.kaBottom -=
(View->kvFineWindow->kaTop - View->kvFineWindow->kaBottom)/4;
BOX.kaLeft = View->kvFineWindow->kaLeft + fi.fi_incr;
BOX.kaRight = BOX.kaLeft + EboxW;
for (j = 8; j < 12; j++) {
FBDefineFillPattern(1,DefaultFillPatterns[j]);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
BOX.kaTop = BOX.kaBottom - fi.fi_sep;
BOX.kaBottom = View->kvFineWindow->kaBottom;
BOX.kaLeft = View->kvFineWindow->kaLeft + fi.fi_incr;
BOX.kaRight = BOX.kaLeft + EboxW;
for (j = 12; j < 16; j++) {
FBDefineFillPattern(1,DefaultFillPatterns[j]);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
ShowBox(1,&BOX);
}
}
fi.fi_del = EboxW/8;
fi.fi_spa = EboxW/40;
show_pixel_map();
LayerTable[1].klAttributes = tmpat;
LayerTable[1].klStyleID = tmpst;
}
static void
show_pixel_map()
/* display the pixel unit cell map and fill preview box */
{
int i,j,tmpat,tmpst;
struct ka BOX, PBOX;
tmpat = LayerTable[1].klAttributes;
tmpst = LayerTable[1].klStyleID;
LayerTable[1].klAttributes = VISIBLE | FILLED;
LayerTable[1].klStyleID = 0;
BOX.kaLeft = View->kvFineWindow->kaLeft;
BOX.kaRight = View->kvFineWindow->kaLeft + fi.fi_incr - fi.fi_sep;
BOX.kaBottom = fi.fi_eboxbot;
BOX.kaTop = View->kvFineWindow->kaTop;
EraseBox(&BOX);
ShowEmptyBox(1,&BOX);
/* Pixel map */
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++) {
if (!(fi.fi_px[i] & (1 << j))) continue;
PBOX.kaLeft = View->kvFineWindow->kaLeft +
j*fi.fi_del + fi.fi_spa;
PBOX.kaRight = View->kvFineWindow->kaLeft +
(j+1)*fi.fi_del - fi.fi_spa;
PBOX.kaBottom = fi.fi_eboxbot + i*fi.fi_del + fi.fi_spa;
PBOX.kaTop = fi.fi_eboxbot + (i+1)*fi.fi_del - fi.fi_spa;
ShowBox(1,&PBOX);
}
LayerTable[1].klAttributes |=
(OUTLINED | FINE_FILL | COARSE_FILL);
LayerTable[1].klStyleID = 1;
FBDefineFillPattern(1,fi.fi_px);
BOX.kaLeft += fi.fi_incr;
BOX.kaRight += fi.fi_incr;
BOX.kaBottom = View->kvFineWindow->kaBottom;
EraseBox(&BOX);
ShowBox(1,&BOX);
FBTransfer();
LayerTable[1].klAttributes = tmpat;
LayerTable[1].klStyleID = tmpst;
}
static void
flip_pixel()
/* toggle pixels in the pixel map and redisplay preview */
{
int i,j,tmpat,tmpst;
struct ka BOX, PBOX;
j = (8*(KicCursor.kcRawX - View->kvFineWindow->kaLeft))/
(fi.fi_incr - fi.fi_sep);
i = (8*(KicCursor.kcRawY - fi.fi_eboxbot))/(fi.fi_incr - fi.fi_sep);
fi.fi_px[i] ^= (1 << j);
PBOX.kaLeft = View->kvFineWindow->kaLeft + j*fi.fi_del + fi.fi_spa;
PBOX.kaRight = View->kvFineWindow->kaLeft + (j+1)*fi.fi_del - fi.fi_spa;
PBOX.kaBottom = fi.fi_eboxbot + i*fi.fi_del + fi.fi_spa;
PBOX.kaTop = fi.fi_eboxbot + (i+1)*fi.fi_del - fi.fi_spa;
tmpat = LayerTable[1].klAttributes;
tmpst = LayerTable[1].klStyleID;
LayerTable[1].klAttributes = VISIBLE | FILLED;
LayerTable[1].klStyleID = 0;
if (fi.fi_px[i] & (1 << j)) {
SetCurrentAOI(View->kvFineWindow);
ShowBox(1,&PBOX);
}
else
EraseBox(&PBOX);
LayerTable[1].klAttributes |=
(OUTLINED | FINE_FILL | COARSE_FILL);
LayerTable[1].klStyleID = 1;
FBDefineFillPattern(1,fi.fi_px);
BOX.kaLeft = View->kvFineWindow->kaLeft + fi.fi_incr;
BOX.kaRight = View->kvFineWindow->kaLeft + 2*fi.fi_incr - fi.fi_sep;
BOX.kaBottom = View->kvFineWindow->kaBottom;
BOX.kaTop = View->kvFineWindow->kaTop;
EraseBox(&BOX);
ShowBox(1,&BOX);
FBTransfer();
LayerTable[1].klAttributes = tmpat;
LayerTable[1].klStyleID = tmpst;
}
int
RepaintFILL()
/* Repaint screen while in fill pattern editor. Does the complete
* job.
*/
{
int i;
if (!fi.fi_on)
return (False);
Parameters.kpRedisplayControl = fi.fi_rc;
View->kvControl = fi.fi_vc;
FullRedisplay();
View->kvControl = SPLITSCREEN;
SetPositioning();
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
/* compute spacing between fill pattern menu */
i = 10;
if (!View->kvFineViewportOnBottom) i = 6;
fi.fi_incr = View->kvFineWindow->kaWidth/i;
fi.fi_sep = fi.fi_incr >> 3;
show_choices();
return (True);
}
kic-2.4c/src/kic/wires.c 0000644 0000764 0000764 00000040137 07525346714 014570 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Wire management.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuWIRES;
extern char *MenuUNDO;
extern char *MenuWIDTH;
#ifdef __STDC__
static void allocate_wire(int,struct p*,int,struct ka*,struct o**,int);
static void record_wire(struct o*);
static void copy_path(struct p **);
#else
static void allocate_wire();
static void record_wire();
static void copy_path();
#endif
void
Wires(LookedAhead)
int *LookedAhead;
{
struct p *Path;
struct ka BB,OldBB;
struct o *Pointer = NULL,*OldPointer = NULL;
int Width;
int X,Y,FX = 0,FY = 0;
int NumVertices = 0;
int ExpectFirstPoint = True;
int Modified = 0;
int Undo = False;
MenuSelect(MenuWIRES);
Path = NULL;
loop {
Width = LayerTable[Parameters.kpLayer].klWireWidth;
sprintf(TypeOut,"Point to the reference points (current width %g).",
(double)Width/RESOLUTION);
ShowPrompt(TypeOut);
switch (PointLoopCreate(LookedAhead)) {
case PL_PLT:
if (NumVertices > 1) {
Path = CopyPath(Path);
CDDelete(Parameters.kpCellDesc,Pointer);
EraseBox(&BB);
Redisplay(&BB);
Width = LayerTable[Parameters.kpLayer].klWireWidth;
allocate_wire(Parameters.kpLayer,Path,Width,&BB,
&Pointer,SQ_INCMPLT);
ShowWire(Parameters.kpLayer,Width,Path);
}
continue;
case PL_UND:
MenuSelect(MenuUNDO);
if (NumVertices == 0) {
if (OldPointer == NULL) {
MenuDeselect(MenuUNDO);
goto quit;
}
if (Undo == False) {
OldPointer->oInfo = SQ_GONE;
Modified--;
Undo = True;
}
else {
OldPointer->oInfo = SQ_NEW;
Modified++;
Undo = False;
}
EraseBox(&OldBB);
Redisplay(&OldBB);
MenuDeselect(MenuUNDO);
continue;
}
if (NumVertices > 1)
RemoveLastPointInPath(&Path);
CDDelete(Parameters.kpCellDesc,Pointer);
EraseBox(&BB);
Redisplay(&BB);
if (NumVertices == 1) {
ExpectFirstPoint = True;
ShowMarker(ERASE,0,FX,FY,200);
}
else {
allocate_wire(Parameters.kpLayer,Path,Width,&BB,
&Pointer,SQ_INCMPLT);
ShowWire(Parameters.kpLayer,Width,Path);
LastPointInPath(&X,&Y,Path);
}
NumVertices--;
MenuDeselect(MenuUNDO);
continue;
case PL_ESC:
if (Not ExpectFirstPoint) {
CDDelete(Parameters.kpCellDesc,Pointer);
Pointer = NULL;
EraseBox(&BB);
Redisplay(&BB);
}
goto quit;
case PL_CMD:
if (Not ExpectFirstPoint) {
if (NumVertices == 1) {
CDDelete(Parameters.kpCellDesc,Pointer);
}
else {
Modified++;
record_wire(Pointer);
}
Pointer = NULL;
EraseBox(&BB);
Redisplay(&BB);
}
goto quit;
}
if (ExpectFirstPoint) {
NumVertices++;
ExpectFirstPoint = False;
FX = X = KicCursor.kcX;
FY = Y = KicCursor.kcY;
Path = AllocatePath(X,Y);
SetRelative(X,Y,True);
allocate_wire(Parameters.kpLayer,Path,Width,&BB,
&Pointer,SQ_INCMPLT);
ShowWire(Parameters.kpLayer,Width,Path);
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,X,Y,200);
continue;
}
if (KicCursor.kcX == X And KicCursor.kcY == Y) {
if (NumVertices == 1) {
/* click twice to exit */
CDDelete(Parameters.kpCellDesc,Pointer);
ShowMarker(ERASE,0,FX,FY,200);
Pointer = NULL;
EraseBox(&BB);
Redisplay(&BB);
goto quit;
}
else {
Pointer->oInfo = SQ_NEW;
record_wire(OldPointer);
OldPointer = Pointer;
Pointer = NULL;
OldBB = BB;
Modified++;
}
NumVertices = 0;
ExpectFirstPoint = True;
EraseBox(&BB);
Redisplay(&BB);
Undo = False;
}
else {
X = KicCursor.kcX;
Y = KicCursor.kcY;
AppendPointToPath(&X,&Y,&Path);
CDDelete(Parameters.kpCellDesc,Pointer);
allocate_wire(Parameters.kpLayer,Path,Width,&BB,
&Pointer,SQ_INCMPLT);
ShowMarker(ERASE,0,FX,FY,200);
ShowWire(Parameters.kpLayer,Width,Path);
NumVertices++;
}
}
quit:
record_wire(OldPointer);
record_wire(Pointer);
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
if (NumVertices == 1)
ShowMarker(ERASE,0,FX,FY,200);
MenuDeselect(MenuWIRES);
}
static void
allocate_wire(Layer,Path,Width,BB,Pointer,Info)
int Layer;
struct p *Path;
int Width;
struct ka *BB;
struct o **Pointer;
int Info;
{
if (Not CDMakeWire(Parameters.kpCellDesc,
Layer,Width,Path,Pointer)) MallocFailed();
(*Pointer)->oInfo = Info;
CDStatusInt = CDBB(Parameters.kpCellDesc,*Pointer,
&BB->kaLeft,&BB->kaBottom,&BB->kaRight,&BB->kaTop);
OversizeBox(BB,Width);
}
static void
record_wire(Pointer)
struct o *Pointer;
{
if (Pointer == NULL) return;
if (Pointer->oInfo == SQ_GONE)
CDDelete(Parameters.kpCellDesc,Pointer);
else
Pointer->oInfo = SQ_OLD;
}
void
ShowWire(Layer,Width,Path)
int Layer;
int Width;
struct p *Path;
{
struct p *Pair;
struct ka BB;
struct p PolyPath[4];
int C,D;
int Wc,Wf;
int PredX,X,PredY,Y;
int Width2;
double alpha;
char OldRD;
if (Width <= 0) {
ShowPath(Layer,Path,0);
return;
}
Wc = View->kvCoarseRatio*Width;
Wf = View->kvFineRatio*Width;
Width2 = Width >> 1;
Pair = Path;
PredX = Pair->pX;
PredY = Pair->pY;
Pair = Pair->pSucc;
while (Pair != NULL) {
BB.kaLeft = PredX-Width2;
BB.kaBottom = PredY-Width2;
BB.kaRight = PredX+Width2;
BB.kaTop = PredY+Width2;
ShowBox(Layer,&BB);
X = Pair->pX;
Y = Pair->pY;
if (IsManhattan(PredX,PredY,X,Y)) {
if (PredY == Y) {
/* Horizontal thick line */
BB.kaLeft = min(PredX,X);
BB.kaBottom = Y-Width2;
BB.kaRight = max(PredX,X);
BB.kaTop = Y+Width2;
}
else {
/* Vertical thick line */
BB.kaLeft = X-Width2;
BB.kaBottom = min(PredY,Y);
BB.kaRight = X+Width2;
BB.kaTop = max(PredY,Y);
}
ShowBox(Layer,&BB);
}
else {
/* Non-manhattan Wire */
alpha = -atan2((double)(PredY - Y),(double)(PredX - X));
C = (double)(Width2) * sin(alpha);
D = (double)(Width2) * cos(alpha);
PolyPath[0].pX = PredX + C;
PolyPath[0].pY = PredY + D;
PolyPath[0].pSucc = &PolyPath[1];
PolyPath[1].pX = X + C;
PolyPath[1].pY = Y + D;
PolyPath[1].pSucc = &PolyPath[2];
PolyPath[2].pX = X - C;
PolyPath[2].pY = Y - D;
PolyPath[2].pSucc = &PolyPath[3];
PolyPath[3].pX = PredX - C;
PolyPath[3].pY = PredY - D;
PolyPath[3].pSucc = NULL;
OldRD = Parameters.kpRedisplayControl;
if (OldRD != FINEVIEWPORTONLY) {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
if (Wc < 1 || Layer == ColorTable[HighlightingColor].Ent)
ShowPath(Layer,PolyPath,True);
else
ShowPolygon(Layer,PolyPath);
}
if (OldRD != COARSEVIEWPORTONLY) {
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
if (Wf < 1 || Layer == ColorTable[HighlightingColor].Ent)
ShowPath(Layer,PolyPath,True);
else
ShowPolygon(Layer,PolyPath);
}
Parameters.kpRedisplayControl = OldRD;
}
Pair = Pair->pSucc;
PredX = X;
PredY = Y;
}
BB.kaLeft = PredX-Width2;
BB.kaBottom = PredY-Width2;
BB.kaRight = PredX+Width2;
BB.kaTop = PredY+Width2;
ShowBox(Layer,&BB);
}
void
Width(LookedAhead)
int *LookedAhead;
{
char *TypeIn;
int Layer, Undo = False;
int Width, dummy;
double d;
struct ks *sq;
struct o *Pointer, *NewPointer;
struct p *Path;
MenuSelect(MenuWIDTH);
for (sq = SelectQHead; sq; sq = sq->ksSucc) {
Pointer = sq->ksPointer;
if (Pointer->oInfo == SQ_GONE)
continue;
if (Pointer->oLayer != Parameters.kpLayer &&
Parameters.kpLayerSpecificSelection)
continue;
if (Pointer->oType == CDWIRE)
break;
}
if (sq) {
/* There is a wire selected. */
sprintf(TypeOut,
"Enter new width for selected wires (default width %g): ",
(double)LayerTable[Parameters.kpLayer].klWireWidth/RESOLUTION);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (!TypeIn){
MenuDeselect(MenuWIDTH);
ErasePrompt();
return;
}
Width = LayerTable[Parameters.kpLayer].klWireWidth;
if (*TypeIn != '\0' && *TypeIn != '\n') {
if (sscanf(TypeIn,"%lg",&d) == 1 && d >= 0) {
Width = d*RESOLUTION;
}
}
again:
for (sq = SelectQHead; sq; sq = sq->ksSucc) {
Pointer = sq->ksPointer;
if (Pointer->oType != CDWIRE)
continue;
if (Pointer->oInfo == SQ_GONE)
continue;
if (Pointer->oLayer != Parameters.kpLayer &&
Parameters.kpLayerSpecificSelection)
continue;
CDWire(Pointer,&Layer,&dummy,&Path);
copy_path(&Path);
if (Not CDMakeWire(Parameters.kpCellDesc,Layer,Width,Path,
&NewPointer)) MallocFailed();
NewPointer->oInfo = SQ_NEWSEL;
SQInsert(NewPointer);
Pointer->oInfo = SQ_GONE;
}
SQComputeBB();
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
MenuDeselect(MenuWIDTH);
ErasePrompt();
top:
switch (PointLoop(LookedAhead)) {
case PL_UND:
if (!Undo) {
MenuSelect(MenuUNDO);
SQComputeBB();
/* put everything back... */
SQRestore(True);
for (sq = SelectQHead; sq; sq = sq->ksSucc) {
if (sq->ksPointer->oInfo == SQ_NEWSEL)
sq->ksPointer->oInfo = SQ_OLDSEL;
}
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
MenuDeselect(MenuUNDO);
Undo = True;
}
else {
Undo = False;
goto again;
}
case PL_ESC:
case PL_PCW:
goto top;
case PL_CMD:
SQRestore(False);
break;
}
return;
}
sprintf(TypeOut,"Wire width for current layer is %g, enter new width: ",
(double)LayerTable[Parameters.kpLayer].klWireWidth/RESOLUTION);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL && *TypeIn != '\0' && *TypeIn != '\n') {
if (sscanf(TypeIn,"%lg",&d) == 1 && d >= 0) {
Width = d*RESOLUTION;
if (Width < LayerTable[Parameters.kpLayer].klMinDimensions) {
sprintf(TypeOut,
"Can't, the minimum dimension on this layer is %g.",
(double)LayerTable[Parameters.kpLayer].klMinDimensions/
RESOLUTION);
ShowPromptAndWait(TypeOut);
}
else
LayerTable[Parameters.kpLayer].klWireWidth = Width;
}
else
ShowPromptAndWait("Bad value, width not changed.");
}
ErasePrompt();
MenuDeselect(MenuWIDTH);
}
static void
copy_path(Path)
struct p **Path;
{
struct p *OldPair,*NewPair;
/*
* Copy Path with transform and return pointer to new path
*/
OldPair = *Path;
if ((NewPair = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
*Path = NewPair;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
while(OldPair != NULL) {
if ((NewPair->pSucc = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
NewPair = NewPair->pSucc;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
}
}
void
RemoveLastPointInPath(Path)
struct p **Path;
{
struct p *OldPair;
struct p *NewPair;
OldPair = *Path;
if (OldPair == NULL Or OldPair->pSucc == NULL)
return;
if ((NewPair = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
*Path = NewPair;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
while (OldPair->pSucc != NULL) {
if ((NewPair->pSucc = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
NewPair = NewPair->pSucc;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
}
}
void
AppendPointToPath(X,Y,Path)
struct p **Path;
int *X,*Y;
{
struct p *OldPair;
struct p *NewPair;
if (Path == NULL || *Path == NULL)
return;
OldPair = *Path;
if ((NewPair = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
*Path = NewPair;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
while (OldPair != NULL) {
if ((NewPair->pSucc = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
NewPair = NewPair->pSucc;
NewPair->pX = OldPair->pX;
NewPair->pY = OldPair->pY;
NewPair->pSucc = NULL;
OldPair = OldPair->pSucc;
}
/* Append the new reference point */
if (Parameters.kp45s)
To45(NewPair->pX,NewPair->pY,X,Y);
if ((NewPair->pSucc = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
NewPair = NewPair->pSucc;
NewPair->pX = *X;
NewPair->pY = *Y;
NewPair->pSucc = NULL;
}
kic-2.4c/src/kic/change.c 0000644 0000764 0000764 00000013434 07525346713 014663 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Change layer selection operator.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuCHLYR;
extern char *MenuUNDO;
void
ChangeLayer(LookedAhead)
int *LookedAhead;
{
struct ks *SQDesc;
struct prpty *PrptyDesc;
struct p *Path;
char *Label;
char *cp;
int X,Y;
int Layer;
int NewLayer;
int NewInfo;
int Width;
int Length;
int Info;
int FirstTime = True;
int UndoTheChange = 0;
char Type,Xform;
cp = MenuCHLYR;
MenuSelect(cp);
if(SelectQHead == NULL){
ShowPrompt("You haven't selected anything to change.");
MenuDeselect(cp);
return;
}
*LookedAhead = False;
if(Not *LookedAhead){
ShowPrompt("Point to the new layer.");
loop{
Point();
if(Parameters.kpPointLayerTable)
break;
elif(Parameters.kpCommand[0] != EOS){
MenuDeselect(cp);
*LookedAhead = True;
return;
}
}
}
loop {
SQDesc = SelectQHead;
if(FirstTime)
FirstTime = False;
else{
Point();
if(strcmp(Parameters.kpCommand,MenuUNDO) != 0){
Parameters.kpModified = True;
*LookedAhead = True;
while(SQDesc != NULL){
SQDesc->ksPointer->oInfo = SQ_OLDSEL;
SQDesc = SQDesc->ksSucc;
}
return;
}
cp = MenuUNDO;
MenuSelect(cp);
UndoTheChange ^= 1;
*LookedAhead = False;
}
while(SQDesc != NULL){
CDType(SQDesc->ksPointer,&Type);
RemovePropertyList(SQDesc->ksPointer,&PrptyDesc);
Info = SQDesc->ksPointer->oInfo;
if(Type == CDLABEL){
CDLabel(SQDesc->ksPointer,&Layer,&Label,&X,&Y,&Xform);
SQDesc->ksPointer->oInfo = SQ_GONE;
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
if(UndoTheChange){
NewLayer = Info - 10;
NewInfo = SQ_OLDSEL;
}
else{
NewLayer = Parameters.kpLayer;
NewInfo = Layer + 10;
}
if(Not CDMakeLabel(Parameters.kpCellDesc,NewLayer,Label,
X,Y,Xform,&(SQDesc->ksPointer))) MallocFailed();
SQDesc->ksPointer->oInfo = NewInfo;
}
elif(Type == CDBOX){
CDBox(SQDesc->ksPointer,&Layer,&Length,&Width,&X,&Y);
SQDesc->ksPointer->oInfo = SQ_GONE;
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
if(UndoTheChange){
NewLayer = Info - 10;
NewInfo = SQ_OLDSEL;
}
else{
NewLayer = Parameters.kpLayer;
NewInfo = Layer + 10;
}
if(Not CDMakeBox(Parameters.kpCellDesc,NewLayer,Length,Width,
X,Y,&(SQDesc->ksPointer))) MallocFailed();
SQDesc->ksPointer->oInfo = NewInfo;
}
elif(Type == CDSYMBOLCALL)
ShowPrompt("Can't change the layers of an instance.");
elif(Type == CDWIRE){
CDWire(SQDesc->ksPointer,&Layer,&Width,&Path);
SQDesc->ksPointer->oInfo = SQ_GONE;
Path = CopyPath(Path);
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
if(UndoTheChange){
NewLayer = Info - 10;
NewInfo = SQ_OLDSEL;
}
else{
NewLayer = Parameters.kpLayer;
NewInfo = Layer + 10;
}
if(Not CDMakeWire(Parameters.kpCellDesc,NewLayer,Width,Path,
&(SQDesc->ksPointer))) MallocFailed();
SQDesc->ksPointer->oInfo = NewInfo;
}
elif(Type == CDPOLYGON){
CDPolygon(SQDesc->ksPointer,&Layer,&Path);
SQDesc->ksPointer->oInfo = SQ_GONE;
Path = CopyPath(Path);
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
if(UndoTheChange){
NewLayer = Info - 10;
NewInfo = SQ_OLDSEL;
}
else{
NewLayer = Parameters.kpLayer;
NewInfo = Layer + 10;
}
if(Not CDMakePolygon(Parameters.kpCellDesc,NewLayer,Path,
&(SQDesc->ksPointer))) MallocFailed();
SQDesc->ksPointer->oInfo = NewInfo;
}
RestorePropertyList(SQDesc->ksPointer,PrptyDesc);
SQDesc = SQDesc->ksSucc;
}
SQComputeBB();
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
MenuDeselect(cp);
}
}
kic-2.4c/src/kic/init.c 0000644 0000764 0000764 00000060335 07525346713 014403 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Initialize KIC.
*/
#include "prefix.h"
#include "kic.h"
struct kv *View;
struct ka MenuViewport;
struct ka ParameterViewport;
struct ka LayerTableViewport;
struct kp Parameters;
struct kl LayerTable[CDNUMLAYERS+1];
struct kc KicCursor;
struct a CurrentAOI;
struct cl ColorTable[12];
int NumLayerTable;
char TypeOut[200];
#ifdef __STDC__
static void init_ColorTable1(void);
static void init_ColorTable2(void);
static void match(int);
#else
static void init_ColorTable1();
static void init_ColorTable2();
static void match();
#endif
/* If the ratio of window to viewport width is less than this, use the
* stippled fill patterns. Otherwise, use a solid fill.
*/
/* I don't like this "feature"
#define STIPPLERATIO 100
*/
#define STIPPLERATIO 0x7fffffffL
void
Init()
{
/*
* Read in .KIC file and initialize CD package.
*/
init_ColorTable1();
ReadTechFile();
FBBegin(FB.fDisplay);
init_ColorTable2();
InitParameters();
InitSignals();
}
static void
init_ColorTable1()
{
ColorTable[0].Ent = -1;
ColorTable[0].R = 0;
ColorTable[0].G = 0;
ColorTable[0].B = 0;
ColorTable[HighlightingColor].Ent = -1;
ColorTable[HighlightingColor].R = 240;
ColorTable[HighlightingColor].G = 240;
ColorTable[HighlightingColor].B = 240;
ColorTable[MenuPromptColor].Ent = -1;
ColorTable[MenuPromptColor].R = 255;
ColorTable[MenuPromptColor].G = 235;
ColorTable[MenuPromptColor].B = 110;
ColorTable[MenuTextColor].Ent = -1;
ColorTable[MenuTextColor].R = 120;
ColorTable[MenuTextColor].G = 240;
ColorTable[MenuTextColor].B = 0;
ColorTable[MenuHighlightingColor].Ent = -1;
ColorTable[MenuHighlightingColor].R = 110;
ColorTable[MenuHighlightingColor].G = 160;
ColorTable[MenuHighlightingColor].B = 255;
ColorTable[MenuSelectColor].Ent = -1;
ColorTable[MenuSelectColor].R = 180;
ColorTable[MenuSelectColor].G = 250;
ColorTable[MenuSelectColor].B = 150;
ColorTable[MoreTextColor].Ent = -1;
ColorTable[MoreTextColor].R = 170;
ColorTable[MoreTextColor].G = 210;
ColorTable[MoreTextColor].B = 200;
ColorTable[InstanceBBColor].Ent = -1;
ColorTable[InstanceBBColor].R = 150;
ColorTable[InstanceBBColor].G = 225;
ColorTable[InstanceBBColor].B = 195;
ColorTable[InstanceNameColor].Ent = -1;
ColorTable[InstanceNameColor].R = 180;
ColorTable[InstanceNameColor].G = 60;
ColorTable[InstanceNameColor].B = 0;
ColorTable[InstanceSizeColor].Ent = -1;
ColorTable[InstanceSizeColor].R = 220;
ColorTable[InstanceSizeColor].G = 85;
ColorTable[InstanceSizeColor].B = 180;
ColorTable[CoarseGridColor].Ent = -1;
ColorTable[CoarseGridColor].R = 150;
ColorTable[CoarseGridColor].G = 170;
ColorTable[CoarseGridColor].B = 255;
ColorTable[FineGridColor].Ent = -1;
ColorTable[FineGridColor].R = 60;
ColorTable[FineGridColor].G = 20;
ColorTable[FineGridColor].B = 200;
}
static void
init_ColorTable2()
{
int i, ind = FB.fNumColors;
ColorTable[0].Ent = 0;
ColorTable[HighlightingColor].Ent = ind--;
if (!Parameters.kpMergeColors) {
if (ColorTable[MenuPromptColor].Ent >= 0) {
i = ColorTable[MenuPromptColor].Ent;
ColorTable[MenuPromptColor].R = LayerTable[i].klR;
ColorTable[MenuPromptColor].G = LayerTable[i].klG;
ColorTable[MenuPromptColor].B = LayerTable[i].klB;
}
ColorTable[MenuPromptColor].Ent = ind--;
if (ColorTable[MenuTextColor].Ent >= 0) {
i = ColorTable[MenuTextColor].Ent;
ColorTable[MenuTextColor].R = LayerTable[i].klR;
ColorTable[MenuTextColor].G = LayerTable[i].klG;
ColorTable[MenuTextColor].B = LayerTable[i].klB;
}
ColorTable[MenuTextColor].Ent = ind--;
if (ColorTable[MenuHighlightingColor].Ent >= 0) {
i = ColorTable[MenuHighlightingColor].Ent;
ColorTable[MenuHighlightingColor].R = LayerTable[i].klR;
ColorTable[MenuHighlightingColor].G = LayerTable[i].klG;
ColorTable[MenuHighlightingColor].B = LayerTable[i].klB;
}
ColorTable[MenuHighlightingColor].Ent = ind--;
if (ColorTable[MenuSelectColor].Ent >= 0) {
i = ColorTable[MenuSelectColor].Ent;
ColorTable[MenuSelectColor].R = LayerTable[i].klR;
ColorTable[MenuSelectColor].G = LayerTable[i].klG;
ColorTable[MenuSelectColor].B = LayerTable[i].klB;
}
ColorTable[MenuSelectColor].Ent = ind--;
if (ColorTable[MoreTextColor].Ent >= 0) {
i = ColorTable[MoreTextColor].Ent;
ColorTable[MoreTextColor].R = LayerTable[i].klR;
ColorTable[MoreTextColor].G = LayerTable[i].klG;
ColorTable[MoreTextColor].B = LayerTable[i].klB;
}
ColorTable[MoreTextColor].Ent = ind--;
if (ColorTable[InstanceBBColor].Ent >= 0) {
i = ColorTable[InstanceBBColor].Ent;
ColorTable[InstanceBBColor].R = LayerTable[i].klR;
ColorTable[InstanceBBColor].G = LayerTable[i].klG;
ColorTable[InstanceBBColor].B = LayerTable[i].klB;
}
ColorTable[InstanceBBColor].Ent = ind--;
if (ColorTable[InstanceNameColor].Ent >= 0) {
i = ColorTable[InstanceNameColor].Ent;
ColorTable[InstanceNameColor].R = LayerTable[i].klR;
ColorTable[InstanceNameColor].G = LayerTable[i].klG;
ColorTable[InstanceNameColor].B = LayerTable[i].klB;
}
ColorTable[InstanceNameColor].Ent = ind--;
if (ColorTable[InstanceSizeColor].Ent >= 0) {
i = ColorTable[InstanceSizeColor].Ent;
ColorTable[InstanceSizeColor].R = LayerTable[i].klR;
ColorTable[InstanceSizeColor].G = LayerTable[i].klG;
ColorTable[InstanceSizeColor].B = LayerTable[i].klB;
}
ColorTable[InstanceSizeColor].Ent = ind--;
if (ColorTable[CoarseGridColor].Ent >= 0) {
i = ColorTable[CoarseGridColor].Ent;
ColorTable[CoarseGridColor].R = LayerTable[i].klR;
ColorTable[CoarseGridColor].G = LayerTable[i].klG;
ColorTable[CoarseGridColor].B = LayerTable[i].klB;
}
ColorTable[CoarseGridColor].Ent = ind--;
if (ColorTable[FineGridColor].Ent >= 0) {
i = ColorTable[FineGridColor].Ent;
ColorTable[FineGridColor].R = LayerTable[i].klR;
ColorTable[FineGridColor].G = LayerTable[i].klG;
ColorTable[FineGridColor].B = LayerTable[i].klB;
}
ColorTable[FineGridColor].Ent = ind--;
}
else {
if (ColorTable[MenuPromptColor].Ent < 0)
match(MenuPromptColor);
if (ColorTable[MenuTextColor].Ent < 0)
match(MenuTextColor);
if (ColorTable[MenuHighlightingColor].Ent < 0)
match(MenuHighlightingColor);
if (ColorTable[MenuSelectColor].Ent < 0)
match(MenuSelectColor);
if (ColorTable[MoreTextColor].Ent < 0)
match(MoreTextColor);
if (ColorTable[InstanceBBColor].Ent < 0)
match(InstanceBBColor);
if (ColorTable[InstanceNameColor].Ent < 0)
match(InstanceNameColor);
if (ColorTable[InstanceSizeColor].Ent < 0)
match(InstanceSizeColor);
if (ColorTable[CoarseGridColor].Ent < 0)
match(CoarseGridColor);
if (ColorTable[FineGridColor].Ent < 0)
match(FineGridColor);
}
}
static void
match(what)
/* find the layer with the closest color match */
int what;
{
int Layer;
int dd, ddmax;
int m = 0;
int r, g, b;
ddmax = 3*255*255+1;
r = ColorTable[what].R;
g = ColorTable[what].G;
b = ColorTable[what].B;
for (Layer = 1; Layer <= NumLayerTable; Layer++) {
dd =
(r - LayerTable[Layer].klR)*(r - LayerTable[Layer].klR) +
(g - LayerTable[Layer].klG)*(g - LayerTable[Layer].klG) +
(b - LayerTable[Layer].klB)*(b - LayerTable[Layer].klB);
if (dd < ddmax) {
m = Layer;
ddmax = dd;
}
}
ColorTable[what].Ent = m;
}
void
InitVLT()
{
int Layer,styleID;
int TFine,TCoarse;
int fp[8];
FBSetCursorColor(ColorTable[HighlightingColor].Ent);
/*
* Background color is zero.
*/
FBVLT(0,ColorTable[0].R,ColorTable[0].G,ColorTable[0].B);
FBVLT(ColorTable[HighlightingColor].Ent,ColorTable[HighlightingColor].R,
ColorTable[HighlightingColor].G,ColorTable[HighlightingColor].B);
if (!Parameters.kpMergeColors) {
FBVLT(ColorTable[MenuPromptColor].Ent,
ColorTable[MenuPromptColor].R,
ColorTable[MenuPromptColor].G,
ColorTable[MenuPromptColor].B);
FBVLT(ColorTable[MenuTextColor].Ent,
ColorTable[MenuTextColor].R,
ColorTable[MenuTextColor].G,
ColorTable[MenuTextColor].B);
FBVLT(ColorTable[MenuHighlightingColor].Ent,
ColorTable[MenuHighlightingColor].R,
ColorTable[MenuHighlightingColor].G,
ColorTable[MenuHighlightingColor].B);
FBVLT(ColorTable[MenuSelectColor].Ent,
ColorTable[MenuSelectColor].R,
ColorTable[MenuSelectColor].G,
ColorTable[MenuSelectColor].B);
FBVLT(ColorTable[MoreTextColor].Ent,
ColorTable[MoreTextColor].R,
ColorTable[MoreTextColor].G,
ColorTable[MoreTextColor].B);
FBVLT(ColorTable[InstanceBBColor].Ent,
ColorTable[InstanceBBColor].R,
ColorTable[InstanceBBColor].G,
ColorTable[InstanceBBColor].B);
FBVLT(ColorTable[InstanceNameColor].Ent,
ColorTable[InstanceNameColor].R,
ColorTable[InstanceNameColor].G,
ColorTable[InstanceNameColor].B);
FBVLT(ColorTable[InstanceSizeColor].Ent,
ColorTable[InstanceSizeColor].R,
ColorTable[InstanceSizeColor].G,
ColorTable[InstanceSizeColor].B);
FBVLT(ColorTable[CoarseGridColor].Ent,
ColorTable[CoarseGridColor].R,
ColorTable[CoarseGridColor].G,
ColorTable[CoarseGridColor].B);
FBVLT(ColorTable[FineGridColor].Ent,
ColorTable[FineGridColor].R,
ColorTable[FineGridColor].G,
ColorTable[FineGridColor].B);
}
/*
* Layer colors.
*/
styleID = 1; /* 0 is solid */
for (Layer = 1; Layer <= NumLayerTable; Layer++) {
FBVLT(Layer,LayerTable[Layer].klR,LayerTable[Layer].klG,
LayerTable[Layer].klB);
if (LayerTable[Layer].klAttributes & BLINK)
FBBlink(Layer,1000,1000,1000,1);
if (!FB.fDefinableFillPatterns) {
LayerTable[Layer].klStyleID = 0;
continue;
}
if (!(LayerTable[Layer].klAttributes & FILLED)) {
LayerTable[Layer].klStyleID = 0;
continue;
}
if ((LayerTable[Layer].klAttributes & FILLED) And
LayerTable[Layer].klStyle[0] == 0 And
LayerTable[Layer].klStyle[1] == 0 And
LayerTable[Layer].klStyle[2] == 0 And
LayerTable[Layer].klStyle[3] == 0 And
LayerTable[Layer].klStyle[4] == 0 And
LayerTable[Layer].klStyle[5] == 0 And
LayerTable[Layer].klStyle[6] == 0 And
LayerTable[Layer].klStyle[7] == 0) {
LayerTable[Layer].klStyleID = 0;
continue;
}
FBForeground(DISPLAY,Layer);
LayerTable[Layer].klStyleID = styleID;
fp[0] = LayerTable[Layer].klStyle[0];
fp[1] = LayerTable[Layer].klStyle[1];
fp[2] = LayerTable[Layer].klStyle[2];
fp[3] = LayerTable[Layer].klStyle[3];
fp[4] = LayerTable[Layer].klStyle[4];
fp[5] = LayerTable[Layer].klStyle[5];
fp[6] = LayerTable[Layer].klStyle[6];
fp[7] = LayerTable[Layer].klStyle[7];
FBDefineFillPattern(styleID,fp);
styleID++;
}
TFine = TCoarse = False;
if (1/View->kvFineRatio < STIPPLERATIO)
TFine = True;
if (1/View->kvCoarseRatio < STIPPLERATIO)
TCoarse = True;
for (Layer = 1; Layer <= NumLayerTable; Layer++) {
if(TFine)
LayerTable[Layer].klAttributes |= FINE_FILL;
else
LayerTable[Layer].klAttributes &= ~FINE_FILL;
if(TCoarse)
LayerTable[Layer].klAttributes |= COARSE_FILL;
else
LayerTable[Layer].klAttributes &= ~COARSE_FILL;
}
}
void
InitParameters()
{
/* set in techfile.c */
extern int FineVPonBottom;
extern char InitScreenMode;
Parameters.kpCellName = malloc(80);
if (Parameters.kpCellName == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Parameters.kpTopName = malloc(80);
if (Parameters.kpTopName == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Parameters.kpCommand = malloc(80);
if (Parameters.kpCommand == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Parameters.kpTopDesc = NULL;
Parameters.kpCellDesc = NULL;
Parameters.kpShowContext = True;
Parameters.kpLayer = 1;
Parameters.kp45s = False;
Parameters.kpStretchType = STR_TBRL;
Parameters.kpEnableSelectQRedisplay = True;
Parameters.kpLayerSpecificSelection = False;
Parameters.kpClipVerticesToGrid = False;
Parameters.kpExpandInstances = False;
Parameters.kpShowInstanceMarkers = False;
Parameters.kpRotationAngle = 0;
Parameters.kpWindowStack = NULL;
Parameters.kpSelectTypes[0] = CDSYMBOLCALL;
Parameters.kpSelectTypes[1] = CDPOLYGON;
Parameters.kpSelectTypes[2] = CDROUNDFLASH;
Parameters.kpSelectTypes[3] = CDLABEL;
Parameters.kpSelectTypes[4] = CDWIRE;
Parameters.kpSelectTypes[5] = CDBOX;
Parameters.kpSelectTypes[6] = EOS;
Parameters.kpNumX = 1;
Parameters.kpNumY = 1;
Parameters.kpDX = 0;
Parameters.kpDY = 0;
/*
* The fine window has a FIXED width and height.
* What should it be?
* PointingThreshold is the minimum value of ViewportWidth/WindowWidth
* such that it is still comfortable to point with lambda precision.
* If PointingThreshold == 7 and FineViewportWidth ~ 467 pixels,
* FineWindowWidth ~ 60 lambda.
* Most people have prefered 6 or 7.
*/
Parameters.kpPointingThreshold = 6;
Parameters.kpShowBandwidth = False;
KicCursor.kcX = KicCursor.kcPredX = 0;
KicCursor.kcY = KicCursor.kcPredY = 0;
Parameters.kpModified = False;
View = alloc(kv);
View->kvFineWindow = alloc(ka);
View->kvFineViewport = alloc(ka);
View->kvLargeCoarseViewport = alloc(ka);
View->kvSmallCoarseViewport = alloc(ka);
View->kvCoarseWindow = alloc(ka);
View->kvFineViewportOnBottom = FineVPonBottom;
/* can start out in FULLSCREEN or SPLITSCREEN mode */
View->kvControl = InitScreenMode;
TInit();
TStore();
InitViewport();
DefaultWindows();
SQInit();
}
void
DefaultWindows()
{
int DefWidth;
View->kvCoarseViewport = View->kvLargeCoarseViewport;
if (View->kvControl == FULLSCREEN)
DefWidth = 100;
else
DefWidth = 1000;
InitCoarseWindow(0,0,DefWidth*RESOLUTION);
/* default fine window */
View->kvFineWindow->kaWidth = View->kvFineViewport->kaWidth/
Parameters.kpPointingThreshold*RESOLUTION;
View->kvFineWindow->kaHeight = View->kvFineWindow->kaWidth*
View->kvFineViewport->kaHeight/View->kvFineViewport->kaWidth;
SetPositioning();
SaveLastView();
}
void
InitCoarseWindow(X,Y,Width)
int X,Y,Width;
{
int diff;
int Layer;
double Wid2;
struct ka *Cw;
Wid2 = Width/2;
diff = (int)((Wid2*View->kvCoarseViewport->kaHeight)/
View->kvCoarseViewport->kaWidth);
Cw = View->kvCoarseWindow;
Cw->kaX = X;
Cw->kaY = Y;
Cw->kaLeft = Cw->kaX - Wid2;
Cw->kaRight = Cw->kaX + Wid2;
Cw->kaBottom = Cw->kaY - diff;
Cw->kaTop = Cw->kaY + diff;
Cw->kaWidth = Cw->kaRight - Cw->kaLeft;
Cw->kaHeight = Cw->kaTop - Cw->kaBottom;
View->kvCoarseRatio = View->kvCoarseViewport->kaWidth/
Cw->kaWidth;
if (1/View->kvCoarseRatio < STIPPLERATIO)
for (Layer = 1; Layer <= NumLayerTable; Layer++)
LayerTable[Layer].klAttributes |= COARSE_FILL;
else
for (Layer = 1; Layer <= NumLayerTable; Layer++)
LayerTable[Layer].klAttributes &= ~COARSE_FILL;
}
void
InitFineWindow(X,Y)
int X,Y;
{
/* Width and height are fixed. */
int diff;
int Layer;
double Wid2;
struct ka *Fw;
Wid2 = View->kvFineWindow->kaWidth/2;
diff = (int)((Wid2*View->kvFineViewport->kaHeight)/
View->kvFineViewport->kaWidth);
Fw = View->kvFineWindow;
Fw->kaX = X;
Fw->kaY = Y;
Fw->kaLeft = Fw->kaX - Wid2;
Fw->kaRight = Fw->kaX + Wid2;
Fw->kaBottom = Fw->kaY - diff;
Fw->kaTop = Fw->kaY + diff;
Fw->kaWidth = Fw->kaRight - Fw->kaLeft;
Fw->kaHeight = Fw->kaTop - Fw->kaBottom;
View->kvFineRatio = View->kvFineViewport->kaWidth/Fw->kaWidth;
if (1/View->kvFineRatio < STIPPLERATIO)
for(Layer = 1;Layer <= NumLayerTable;++Layer)
LayerTable[Layer].klAttributes |= FINE_FILL;
else
for(Layer = 1;Layer <= NumLayerTable;++Layer)
LayerTable[Layer].klAttributes &= ~FINE_FILL;
}
void
SetPositioning()
{
int X,Y,Width;
if (View->kvControl != FULLSCREEN And
View->kvCoarseRatio < Parameters.kpPointingThreshold) {
/*
* Split--enable fine positioning.
*/
Parameters.kpRedisplayControl = SPLITSCREEN;
View->kvCoarseViewport = View->kvSmallCoarseViewport;
}
else {
/*
* Don't split--don't enable fine positioning.
*/
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
View->kvCoarseViewport = View->kvLargeCoarseViewport;
}
Width = View->kvCoarseWindow->kaWidth;
X = View->kvCoarseWindow->kaX;
Y = View->kvCoarseWindow->kaY;
InitCoarseWindow(X,Y,Width);
/* it is enough to just check the width */
if (Width <= View->kvFineWindow->kaWidth) {
View->kvFineWindow->kaWidth = Width - Width/4;
View->kvFineWindow->kaHeight = View->kvFineWindow->kaWidth*
(View->kvFineViewport->kaHeight/View->kvFineWindow->kaWidth);
}
InitFineWindow(X,Y);
}
void
InitViewport()
{
struct ka *Vl, *Vs, *Vf;
extern int NumBasicMenu;
Parameters.kpLayersPerMenuRow = FB.fNumColumns/6;
Parameters.kpNumLayerMenuRows =
(NumLayerTable - 1)/Parameters.kpLayersPerMenuRow + 1;
if (Parameters.kpNumLayerMenuRows > 1) {
Parameters.kpLayersPerMenuRow--;
Parameters.kpNumLayerMenuRows =
(NumLayerTable - 1)/Parameters.kpLayersPerMenuRow + 1;
}
MenuViewport.kaLeft = 1;
MenuViewport.kaBottom = FB.fNumRows - 3;
MenuViewport.kaTop = 1;
if (NumBasicMenu < MenuViewport.kaBottom)
MenuViewport.kaRight = 5;
else
MenuViewport.kaRight = 11;
/* save column width and height in X,Y integer fields */
MenuViewport.kaX = 5;
MenuViewport.kaY = MenuViewport.kaBottom -
MenuViewport.kaTop + 1;
LayerTableViewport.kaLeft = 1;
LayerTableViewport.kaBottom = FB.fNumRows;
LayerTableViewport.kaRight = FB.fNumColumns;
LayerTableViewport.kaTop = FB.fNumRows;
ParameterViewport.kaLeft = 1;
ParameterViewport.kaBottom = FB.fNumRows - 1;
ParameterViewport.kaRight = FB.fNumColumns;
ParameterViewport.kaTop = FB.fNumRows - 1;
/*
* The COARSE viewport is LARGE if fine-positioning isn't enabled.
* If it is, the LARGE COARSE viewport is split into a SMALL COARSE
* viewport and the FINE viewport.
*/
if (View->kvFineViewportOnBottom) {
Vl = View->kvLargeCoarseViewport;
Vl->kaLeft = FB.fFontWidth*MenuViewport.kaRight + FB.fFontWidth/2;
Vl->kaBottom = FB.fFontHeight*4;
Vl->kaRight = FB.fMaxX;
Vl->kaTop = FB.fMaxY;
Vl->kaWidth = Vl->kaRight - Vl->kaLeft;
Vl->kaHeight = Vl->kaTop - Vl->kaBottom;
Vs = View->kvSmallCoarseViewport;
Vs->kaLeft = Vl->kaLeft;
Vs->kaBottom = Vl->kaBottom + ((Vl->kaTop - Vl->kaBottom)*5)/12;
Vs->kaRight = Vl->kaRight;
Vs->kaTop = Vl->kaTop;
Vs->kaWidth = Vs->kaRight - Vs->kaLeft;
Vs->kaHeight = Vs->kaTop - Vs->kaBottom;
Vf = View->kvFineViewport;
Vf->kaLeft = Vs->kaLeft;
Vf->kaBottom = Vl->kaBottom;
Vf->kaRight = Vs->kaRight;
Vf->kaTop = Vs->kaBottom - 1;
Vf->kaWidth = Vf->kaRight - Vf->kaLeft;
Vf->kaHeight = Vf->kaTop - Vf->kaBottom;
}
else {
Vl = View->kvLargeCoarseViewport;
Vl->kaLeft = FB.fFontWidth*MenuViewport.kaRight + FB.fFontWidth/2;
Vl->kaBottom = FB.fFontHeight*4;
Vl->kaRight = FB.fMaxX;
Vl->kaTop = FB.fMaxY;
Vl->kaWidth = Vl->kaRight - Vl->kaLeft;
Vl->kaHeight = Vl->kaTop - Vl->kaBottom;
Vs = View->kvSmallCoarseViewport;
Vs->kaLeft = Vl->kaLeft;
Vs->kaBottom = Vl->kaBottom;
Vs->kaRight = (FB.fMaxX - Vl->kaLeft)/2 + Vl->kaLeft;
Vs->kaTop = Vl->kaTop;
Vs->kaWidth = Vs->kaRight - Vs->kaLeft;
Vs->kaHeight = Vs->kaTop - Vs->kaBottom;
Vf = View->kvFineViewport;
Vf->kaLeft = Vs->kaRight + 1;
Vf->kaBottom = Vl->kaBottom;
Vf->kaRight = Vl->kaRight;
Vf->kaTop = Vs->kaTop;
Vf->kaWidth = Vf->kaRight - Vf->kaLeft;
Vf->kaHeight = Vf->kaTop - Vf->kaBottom;
}
/* Inform X of the size and position of the InputOnly window
* used to solicit pointer motion and window enter/leave events.
*/
FBResizeDrawingWindow(Vl->kaLeft,Vl->kaBottom,
Vl->kaRight,Vl->kaTop);
}
void
SetCurrentAOI(Window)
struct ka *Window;
{
CoarseLToP(Window->kaLeft,Window->kaBottom,CurrentAOI.aLC,CurrentAOI.aBC);
CoarseLToP(Window->kaRight,Window->kaTop,CurrentAOI.aRC,CurrentAOI.aTC);
if (CurrentAOI.aLC <= View->kvCoarseViewport->kaRight And
CurrentAOI.aRC >= View->kvCoarseViewport->kaLeft And
CurrentAOI.aBC <= View->kvCoarseViewport->kaTop And
CurrentAOI.aTC >= View->kvCoarseViewport->kaBottom) {
ClipVP(View->kvCoarseViewport,CurrentAOI.aLC,CurrentAOI.aBC);
ClipVP(View->kvCoarseViewport,CurrentAOI.aRC,CurrentAOI.aTC);
CurrentAOI.aInCoarse = True;
}
else
CurrentAOI.aInCoarse = False;
FineLToP(Window->kaLeft,Window->kaBottom,CurrentAOI.aLF,CurrentAOI.aBF);
FineLToP(Window->kaRight,Window->kaTop,CurrentAOI.aRF,CurrentAOI.aTF);
if (CurrentAOI.aLF <= View->kvFineViewport->kaRight And
CurrentAOI.aRF >= View->kvFineViewport->kaLeft And
CurrentAOI.aBF <= View->kvFineViewport->kaTop And
CurrentAOI.aTF >= View->kvFineViewport->kaBottom) {
ClipVP(View->kvFineViewport,CurrentAOI.aLF,CurrentAOI.aBF);
ClipVP(View->kvFineViewport,CurrentAOI.aRF,CurrentAOI.aTF);
CurrentAOI.aInFine = True;
}
else
CurrentAOI.aInFine = False;
}
kic-2.4c/src/kic/basic.c 0000644 0000764 0000764 00000030130 12427255671 014506 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* The KIC basic menu code.
*/
#include "prefix.h"
#include "kic.h"
#include
#define Matching(string) !strcmp(Parameters.kpCommand,string)
void
Basic(LookedAhead)
int *LookedAhead;
{
*LookedAhead = False;
Parameters.kpMenu = BASICMENU;
FixMenuPrefix(BasicMenu);
ShowCommandMenu();
}
void
Rdraw()
{
extern char *MenuRDRAW;
MenuSelect(MenuRDRAW);
FullRedisplay();
MenuDeselect(MenuRDRAW);
}
void
Undo()
{
extern char *MenuUNDO;
MenuSelect(MenuUNDO);
ShowPrompt("Sorry, but it's too late.");
MenuDeselect(MenuUNDO);
}
void
DoSet45()
{
extern char *Menu45S;
if (Parameters.kp45s) {
MenuDeselect(Menu45S);
Parameters.kp45s = False;
}
else {
MenuSelect(Menu45S);
Parameters.kp45s = True;
}
}
void
AbortKIC()
{
char *TypeIn;
extern char *MenuEXIT;
MenuSelect(MenuEXIT);
if (Parameters.kpModified) {
sprintf(TypeOut,"Cell %s has been modified. Save it? (y) ",
Parameters.kpCellName);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
if (*TypeIn != 'n' && *TypeIn != 'N') {
if (CDUpdate(Parameters.kpCellDesc,(char *)NULL)) {
Parameters.kpModified = False;
if (Not CDReflect(Parameters.kpCellDesc))
MallocFailed();
}
else {
/* shouldn't happen */
sprintf(TypeOut,"Can't save %s.",Parameters.kpCellName);
ShowPromptAndWait(TypeOut);
goto quit;
}
}
}
if (!CheckModified()) {
FBEnd();
exit(0);
}
quit:
MenuDeselect(MenuEXIT);
ErasePrompt();
}
void
ShowFull()
{
extern char *MenuVIEW;
MenuSelect(MenuVIEW);
SaveLastView();
CenterFullView();
RedisplayViewports();
ShowParameters();
MenuDeselect(MenuVIEW);
}
void
Snap()
{
char *TypeIn;
double d;
extern char *MenuSNAP;
MenuSelect(MenuSNAP);
ShowPrompt("Number of cursor snap points in grid interval?");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL And sscanf(TypeIn,"%le",&d) == 1) {
if (d > 10 Or d < 1) d = 1.0;
Parameters.kpPixToLambdaSnapping = d;
sprintf(TypeOut,"Snap point spacing set to %g",
(double)Parameters.kpGrid/
(Parameters.kpPixToLambdaSnapping*RESOLUTION));
ShowPrompt(TypeOut);
}
else
ErasePrompt();
MenuDeselect(MenuSNAP);
}
void
Edit(Ready,Center,Modified)
int Ready,Center,Modified;
{
extern char *MenuEDIT;
/*
* Ready == True if the name of the cell to be edited is
* already in Parameters.kpCellName.
* Center == True if the cell should be automatically centered.
* Pop does NOT want it to be--it wants it to be exactly where it was
* when it was pushed into.
*/
char *TypeIn,*CellName;
int CloseOldCell = False;
struct s *TempCellDesc = 0;
MenuSelect(MenuEDIT);
if (Parameters.kpModified And Parameters.kpCellName[0] != EOS){
ShowPrompt("You've modified this cell. Do you want to save it (y)?");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) {
ErasePrompt();
MenuDeselect(MenuEDIT);
return;
}
if (TypeIn[0] == 'n' Or TypeIn[0] == 'N') {
/* don't want to close old cell until after new one is opened */
TempCellDesc = Parameters.kpCellDesc;
CloseOldCell = True;
}
else
Save();
}
ClearContext();
if (Not Ready){
ShowPrompt("Cell?");
CellName = FBEdit(NULL);
if (CellName == NULL) {
ErasePrompt();
MenuDeselect(MenuEDIT);
return;
}
while (isspace(*CellName)) CellName++;
if (*CellName == '\0') {
/* get next cellname from argument list */
CellName = NextCellName();
if (CellName == NULL) {
if (Parameters.kpCellName == NULL
Or *Parameters.kpCellName == '\0')
CellName = DEFAULT_EDIT_FILE;
else
CellName = Parameters.kpCellName;
}
}
if (!strcmp(Parameters.kpCellName,CellName)) {
if (CloseOldCell) {
if (Not CDClose(TempCellDesc))
MallocFailed();
CloseOldCell = False;
}
}
else
strcpy(Parameters.kpCellName,CellName);
}
#ifdef WIN32
/* In Win32, use forward slashes internally for dir sep */
for (TypeIn = Parameters.kpCellName; *TypeIn; TypeIn++)
if (*TypeIn == '\\')
*TypeIn = '/';
#endif
/* strip off any path prefix */
if (FixCellName(Parameters.kpCellName)) {
ShowPromptAndWait("Warning: internal path overflow");
}
SQClear();
ShowParameters();
ShowPrompt("Building database. Please wait.");
if (Not CDOpen(Parameters.kpCellName,&Parameters.kpCellDesc,'w')) {
CDClose(Parameters.kpCellDesc);
Parameters.kpCellDesc = NULL;
DefaultWindows();
RedisplayViewports();
sprintf(TypeOut,"Can't edit cell %s. MORE",Parameters.kpCellName);
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
sprintf(TypeOut,"%s",CDStatusString);
ShowPrompt(TypeOut);
Parameters.kpCellName[0] = '\0';
}
else {
if (CloseOldCell)
if (Not CDClose(TempCellDesc))
MallocFailed();
strcpy(Parameters.kpTopName,Parameters.kpCellName);
Parameters.kpTopDesc = Parameters.kpCellDesc;
if (CDStatusInt == CDNEWSYMBOL)
DefaultWindows();
elif (Center)
CenterFullView();
/*
* CDUnmark is expensive and has two purposes!
* First, we make sure that all objects begin with a 0 info field.
* We will therefore see EVERYTHING in the symbol during redisplay.
* Secondly, the bounding boxes are recomputed and therefore
* propogated correctly through the hierarchy.
*/
CDUnmark(Parameters.kpCellDesc);
RedisplayViewports();
if (CDStatusInt == CDNEWSYMBOL)
ShowPrompt("New cell is ready to be edited.");
else
ShowPrompt("Cell is ready to be edited.");
Parameters.kpModified = Modified;
TitleWindow();
}
ShowParameters();
SaveLastView();
MenuDeselect(MenuEDIT);
}
void
TitleWindow()
{
static char Title[80];
sprintf(Title,"KIC-%s (%s)",VersionString,Parameters.kpCellName);
FBSetName(Title,"kic");
}
void
Save()
{
ShowPrompt("Saving cell. Please wait.");
if (CDUpdate(Parameters.kpCellDesc,(char *)NULL)) {
ShowPrompt("Current cell has been saved.");
Parameters.kpModified = False;
if (Not CDReflect(Parameters.kpCellDesc))
MallocFailed();
}
else
ShowPrompt("Can't save cell.");
}
void
WriteCell()
{
char *TypeIn,NewName[64];
extern char *MenuSAVE;
MenuSelect(MenuSAVE);
if (Parameters.kpCellName[0] == '\0') {
ShowPrompt("There isn't anything to save.");
MenuDeselect(MenuSAVE);
return;
}
ShowPrompt("Cell name?");
TypeIn = FBEdit(Parameters.kpCellName);
if (TypeIn == NULL Or *TypeIn == '\0' Or *TypeIn == '\n') {
MenuDeselect(MenuSAVE);
ErasePrompt();
return;
}
strcpy(NewName,TypeIn);
ShowPrompt("Writing cell. Please wait.");
if (strcmp(Parameters.kpCellName,NewName)) {
/* new name given */
TypeIn = Parameters.kpCellDesc->sName;
Parameters.kpCellDesc->sName = NewName;
if (Not CDUpdate(Parameters.kpCellDesc,NewName)) {
ShowPrompt("Can't save cell.");
MenuDeselect(MenuSAVE);
Parameters.kpCellDesc->sName = TypeIn;
return;
}
ShowPrompt("New cell has been saved.");
Parameters.kpCellDesc->sName = TypeIn;
UpdateParent(NewName);
}
else {
if (Not CDUpdate(Parameters.kpCellDesc,(char *)NULL)) {
ShowPrompt("Can't save cell.");
MenuDeselect(MenuSAVE);
return;
}
ShowPrompt("Current cell has been saved.");
Parameters.kpModified = False;
if (Not CDReflect(Parameters.kpCellDesc))
MallocFailed();
}
MenuDeselect(MenuSAVE);
}
void
Peek()
{
extern char *MenuEXPND;
extern char *MenuPEEK;
if (Parameters.kpRedisplayControl == COARSEVIEWPORTONLY)
ShowPrompt("Peek mode isn't required.");
elif (Parameters.kpExpandFineViewportOnly) {
MenuDeselect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = False;
ShowFineViewport();
}
else {
Parameters.kpExpandFineViewportOnly = True;
MenuSelect(MenuPEEK);
if (Parameters.kpExpandInstances) {
MenuDeselect(MenuEXPND);
Parameters.kpExpandInstances = False;
RedisplayViewports();
}
else
ShowFineViewport();
}
}
void
Expand()
{
extern char *MenuEXPND;
extern char *MenuPEEK;
if (Parameters.kpExpandInstances) {
MenuDeselect(MenuEXPND);
Parameters.kpExpandInstances = False;
}
else {
MenuSelect(MenuEXPND);
Parameters.kpExpandInstances = True;
MenuDeselect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = False;
}
RedisplayViewports();
}
void
CenterFullView()
{
int L,B,R,T;
int X,Y,Width,Height;
double Cratio,Vratio;
if (Not CDBB(Parameters.kpCellDesc,(struct o *)NULL,&L,&B,&R,&T))
MallocFailed();
/*
* Window cell automatically. How slick.
* Leave some white space around the perimeter.
* Check for a null (empty) cell.
*/
if (L == R Or B == T Or (L == CDINFINITY And B == CDINFINITY)){
DefaultWindows();
return;
}
Width = R - L;
Height = T - B;
X = L + Width/2;
Y = B + Height/2;
if (Width < 0) Width = -Width;
if (Height < 0) Height = -Height;
Vratio = View->kvCoarseViewport->kaWidth/View->kvCoarseViewport->kaHeight;
Cratio = (double) Width/Height;
if (Cratio > Vratio)
Width *= 1.1;
else
Width = 1.1*Height*Vratio;
InitCoarseWindow(X,Y,Width);
InitFineWindow(X,Y);
SetPositioning();
}
static void
newtok(p,t)
char **p, *t;
{
char *s = *p;
while (isspace(*s)) s++;
while (*s && !isspace(*s)) *t++ = *s++;
*t = '\0';
while (isspace(*s)) s++;
*p = s;
}
int
FixCellName(cname)
/* Strip off any path prefix and add to search path if not already
* there.
*/
char *cname;
{
char *c, *p;
char tok[81];
int i, len, ret = 0;
c = strrchr(cname,DIRC);
if (!c)
return (0);
*c = '\0';
p = PGetPath();
len = strlen(p);
while (*p) {
newtok(&p,tok);
#ifdef MSDOS
if (!strcasecmp(tok,cname))
#else
if (!strcmp(tok,cname))
#endif
goto done;
}
/* length of path string from cd/paths.c */
if (len + strlen(cname) + 1 < 512)
strcpy(p,cname);
else
ret = 1;
done:
for (i = 0, c++; *c; i++, c++)
cname[i] = *c;
cname[i] = '\0';
return (ret);
}
kic-2.4c/src/kic/lines.c 0000644 0000764 0000764 00000007321 07525346713 014546 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Line management.
*/
#include "prefix.h"
#include "kic.h"
void
ShowLine(Layer,X1,Y1,X2,Y2)
int Layer;
int X1,Y1,X2,Y2;
{
int X1P,Y1P,X2P,Y2P;
TPoint(&X1,&Y1);
TPoint(&X2,&Y2);
FBForeground(DISPLAY,Layer);
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
CoarseLToP(X1,Y1,X1P,Y1P);
CoarseLToP(X2,Y2,X2P,Y2P);
if (Not LineClip(&X1P,&Y1P,&X2P,&Y2P,CurrentAOI.aLC,
CurrentAOI.aBC,CurrentAOI.aRC,CurrentAOI.aTC)){
FBLine(X1P,Y1P,X2P,Y2P);
}
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
FineLToP(X1,Y1,X1P,Y1P);
FineLToP(X2,Y2,X2P,Y2P);
if (Not LineClip(&X1P,&Y1P,&X2P,&Y2P,CurrentAOI.aLF,
CurrentAOI.aBF,CurrentAOI.aRF,CurrentAOI.aTF)) {
FBLine(X1P,Y1P,X2P,Y2P);
}
}
}
void
ShowManhattanLine(Layer,X1,Y1,X2,Y2)
int Layer;
int X1,Y1,X2,Y2;
{
int X1P,Y1P,X2P,Y2P;
FBForeground(DISPLAY,Layer);
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
CoarseLToP(X1,Y1,X1P,Y1P);
CoarseLToP(X2,Y2,X2P,Y2P);
if (X1P == X2P) {
if (X1P < CurrentAOI.aLC Or X1P > CurrentAOI.aRC) return;
if (Y1P > Y2P) SwapInts(Y1P,Y2P);
if (Y1P > CurrentAOI.aTC Or Y2P < CurrentAOI.aBC) return;
if (Y1P < CurrentAOI.aBC) Y1P = CurrentAOI.aBC;
if (Y2P > CurrentAOI.aTC) Y2P = CurrentAOI.aTC;
}
elif (Y1P == Y2P) {
if (Y1P < CurrentAOI.aBC Or Y1P > CurrentAOI.aTC) return;
if (X1P > X2P) SwapInts(X1P,X2P);
if (X1P > CurrentAOI.aRC Or X2P < CurrentAOI.aLC) return;
if (X1P < CurrentAOI.aLC) X1P = CurrentAOI.aLC;
if (X2P > CurrentAOI.aRC) X2P = CurrentAOI.aRC;
}
else return;
FBLine(X1P,Y1P,X2P,Y2P);
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
FineLToP(X1,Y1,X1P,Y1P);
FineLToP(X2,Y2,X2P,Y2P);
if (X1P == X2P) {
if (X1P < CurrentAOI.aLF Or X1P > CurrentAOI.aRF) return;
if (Y1P > Y2P) SwapInts(Y1P,Y2P);
if (Y1P > CurrentAOI.aTF Or Y2P < CurrentAOI.aBF) return;
if (Y1P < CurrentAOI.aBF) Y1P = CurrentAOI.aBF;
if (Y2P > CurrentAOI.aTF) Y2P = CurrentAOI.aTF;
}
elif (Y1P == Y2P) {
if (Y1P < CurrentAOI.aBF Or Y1P > CurrentAOI.aTF) return;
if (X1P > X2P) SwapInts(X1P,X2P);
if (X1P > CurrentAOI.aRF Or X2P < CurrentAOI.aLF) return;
if (X1P < CurrentAOI.aLF) X1P = CurrentAOI.aLF;
if (X2P > CurrentAOI.aRF) X2P = CurrentAOI.aRF;
}
else return;
FBLine(X1P,Y1P,X2P,Y2P);
}
}
kic-2.4c/src/kic/polyclip.c 0000644 0000764 0000764 00000054041 07525346714 015271 0 ustar stevew stevew /*************************************************************************
Graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1994
Author: Stephen R. Whiteley
*************************************************************************/
#include "prefix.h"
#include "kic.h"
/* A new polygon clipping routine. Unlike the old routine, this one
* keeps track of severed polygons by means of a linked list.
* First call PolygonClip(), which will perform clipping and
* create a list of polygons. The polygons are then extracted with
* NewPolygon() until 0 is returned. A suitably large xy buffer
* must be supplied in the Poly structure passed to NewPolygon().
*/
/* Undefine DO_FLOAT below if there is no chance of integer overflow,
* avoiding floating point for efficiency.
*/
#define DO_FLOAT
/* We represent individual polygons with a circular doubly linked list */
struct pair {
int pa_x,pa_y;
struct pair *pa_next;
struct pair *pa_prev;
};
/* List of circularly linked polygons */
struct plist {
struct pair *pl_pair;
struct pair *pl_start;
};
static struct plist *Polybuf; /* head of polygon list */
static struct plist *Newpoly; /* free structure to allocate */
static struct plist *Polycurrent; /* current polygon to return */
static int Numpolys; /* size of poly storage */
static struct pair *Linkbuf; /* polygon point storage */
static struct pair *Newlink; /* free structure to allocate */
static int Numlinks; /* size of link storage */
#ifdef __STDC__
static void clip_right(int);
static void clip_left(int);
static void clip_bottom(int);
static void clip_top(int);
static void linkpolys(struct plist*,int);
static int polycmpX(const void*,const void*);
static int polycmpY(const void*,const void*);
static void newlink(void);
static void newpoly(void);
#else
static void clip_right();
static void clip_left();
static void clip_bottom();
static void clip_top();
static void linkpolys();
static int polycmpX();
static int polycmpY();
static void newlink();
static void newpoly();
#endif
void
PolygonClip(poly,left,bottom,right,top)
Poly *poly;
int left, bottom, right, top;
{
struct pair *pa;
int i, n;
int tmp;
if (left > right) {
tmp = left;
left = right;
right = tmp;
}
if (bottom > top) {
tmp = bottom;
bottom = top;
top = tmp;
}
if (Linkbuf == NULL)
newlink();
if (Polybuf == NULL)
newpoly();
Newlink = Linkbuf;
Newpoly = Polybuf;
n = (poly->nvertices << 1) - 2;
for (i = 0; i < n; i += 2) {
Newlink->pa_x = poly->xy[i];
Newlink->pa_y = poly->xy[i+1];
Newlink->pa_prev = Newlink-1;
Newlink->pa_next = Newlink+1;
newlink();
}
pa = Linkbuf;
if (pa->pa_x != poly->xy[i] || pa->pa_y != poly->xy[i+1]) {
Newlink->pa_x = poly->xy[i];
Newlink->pa_y = poly->xy[i+1];
Newlink->pa_prev = Newlink-1;
Newlink->pa_next = Newlink+1;
newlink();
}
Newlink--;
Newlink->pa_next = pa;
pa->pa_prev = Newlink;
Newlink++;
Newpoly->pl_pair = pa;
newpoly();
clip_left(left);
clip_bottom(bottom);
clip_right(right);
clip_top(top);
Polycurrent = Polybuf;
}
int
NewPolygon(p)
Poly *p;
{
int *xy;
int i;
struct pair *pp, *pa;
for (;;) {
xy = (int*)p->xy;
i = 1;
if (Polycurrent == Newpoly) {
Newlink = Linkbuf;
Newpoly = Polybuf;
Polycurrent = Newpoly;
return (0);
}
pp = pa = Polycurrent->pl_pair;
if (pp) {
*xy++ = pp->pa_x;
*xy++ = pp->pa_y;
for (pp = pp->pa_next; ; pp = pp->pa_next) {
i++;
*xy++ = pp->pa_x;
*xy++ = pp->pa_y;
if (pp == pa) break;
}
}
Polycurrent++;
if (i >= 4)
break;
}
p->nvertices = i;
return (1);
}
static void
clip_right(right)
int right;
{
struct pair *pa, *pp, *pfirst, *plast, *pnext;
struct plist *list, *end, *pointer;
int x, y, xnext, ynext;
end = Newpoly;
for (list = Polybuf; list < end; list++) {
pointer = Newpoly;
pa = list->pl_pair;
/*
* First, find a vertex outside of the clipping
* region.
*/
for (pp = pa;;) {
if (pp->pa_x > right)
break;
pp = pp->pa_next;
if (pp == pa) {
/* no clipping needed */
Newpoly->pl_pair = pa;
newpoly();
goto next;
}
}
/* start with an "outside" point */
for (pa = pp;;) {
x = pp->pa_x;
y = pp->pa_y;
pnext = pp->pa_next;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
if (xnext <= right && x > right) {
/* poly edge crosses bounding clip line */
#ifdef DO_FLOAT
y += (ynext - y)*(((double)(right - x))/(xnext - x));
#else
y += ((right-x)*(ynext-y))/(xnext-x);
#endif
x = right;
if (x != xnext || y != ynext) {
pfirst = Newlink;
pfirst->pa_x = x;
pfirst->pa_y = y;
pfirst->pa_prev = NULL;
newlink();
pp = pnext;
pfirst->pa_next = pp;
pp->pa_prev = pfirst;
}
else {
pp = pnext;
pfirst = pnext;
pfirst->pa_prev = NULL;
}
/* walk along inside points, find the last one */
for (;;) {
if (pp->pa_x > right) {
pnext = pp;
pp = pp->pa_prev;
break;
}
pp = pp->pa_next;
}
x = pp->pa_x;
y = pp->pa_y;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
#ifdef DO_FLOAT
y += (ynext - y)*(((double)(right - x))/(xnext - x));
#else
y += ((right-x)*(ynext-y))/(xnext-x);
#endif
x = right;
if (x != xnext || y != ynext) {
plast = Newlink;
plast->pa_x = x;
plast->pa_y = y;
pp->pa_next = plast;
plast->pa_prev = pp;
plast->pa_next = NULL;
newlink();
}
else {
plast = pp;
plast->pa_next = NULL;
}
if (pfirst->pa_next != plast) {
/* note that we are saving poly fragments */
Newpoly->pl_pair = pfirst;
Newpoly->pl_start = pfirst;
newpoly();
Newpoly->pl_pair = plast;
Newpoly->pl_start = pfirst;
newpoly();
}
}
pp = pnext;
if (pp == pa)
break;
}
if (pointer < Newpoly)
linkpolys(pointer,'Y');
next:
;
}
for (list = end, end = Polybuf; list < Newpoly; list++) {
if (list->pl_pair) {
end->pl_pair = list->pl_pair;
end->pl_start = NULL;
end++;
}
}
Newpoly = end;
}
static void
clip_left(left)
int left;
{
struct pair *pa, *pp, *pfirst, *plast, *pnext;
struct plist *list, *end, *pointer;
int x, y, xnext, ynext;
end = Newpoly;
for (list = Polybuf; list < end; list++) {
pointer = Newpoly;
pa = list->pl_pair;
/*
* First, find a vertex outside of the clipping
* region.
*/
for (pp = pa;;) {
if (pp->pa_x < left)
break;
pp = pp->pa_next;
if (pp == pa) {
/* no clipping needed */
Newpoly->pl_pair = pa;
newpoly();
goto next;
}
}
/* start with an "outside" point */
for (pa = pp;;) {
x = pp->pa_x;
y = pp->pa_y;
pnext = pp->pa_next;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
if (xnext >= left && x < left) {
/* poly edge crosses bounding clip line */
#ifdef DO_FLOAT
y += (ynext - y)*(((double)(left - x))/(xnext - x));
#else
y += ((left - x) * (ynext - y))/(xnext - x);
#endif
x = left;
if (x != xnext || y != ynext) {
pfirst = Newlink;
pfirst->pa_x = x;
pfirst->pa_y = y;
pfirst->pa_prev = NULL;
newlink();
pp = pnext;
pfirst->pa_next = pp;
pp->pa_prev = pfirst;
}
else {
pp = pnext;
pfirst = pnext;
pfirst->pa_prev = NULL;
}
/* walk along inside points, find the last one */
for (;;) {
if (pp->pa_x < left) {
pnext = pp;
pp = pp->pa_prev;
break;
}
pp = pp->pa_next;
}
x = pp->pa_x;
y = pp->pa_y;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
#ifdef DO_FLOAT
y += (ynext - y)*(((double)(left - x))/(xnext - x));
#else
y += ((left - x) * (ynext - y))/(xnext - x);
#endif
x = left;
if (x != xnext || y != ynext) {
plast = Newlink;
plast->pa_x = x;
plast->pa_y = y;
pp->pa_next = plast;
plast->pa_prev = pp;
plast->pa_next = NULL;
newlink();
}
else {
plast = pp;
plast->pa_next = NULL;
}
if (pfirst->pa_next != plast) {
/* note that we are saving poly fragments */
Newpoly->pl_pair = pfirst;
Newpoly->pl_start = pfirst;
newpoly();
Newpoly->pl_pair = plast;
Newpoly->pl_start = pfirst;
newpoly();
}
}
pp = pnext;
if (pp == pa)
break;
}
if (pointer < Newpoly)
linkpolys(pointer,'Y');
next:
;
}
for (list = end, end = Polybuf; list < Newpoly; list++) {
if (list->pl_pair) {
end->pl_pair = list->pl_pair;
end->pl_start = NULL;
end++;
}
}
Newpoly = end;
}
static void
clip_bottom(bottom)
int bottom;
{
struct pair *pa, *pp, *pfirst, *plast, *pnext;
struct plist *list, *end, *pointer;
int x, y, xnext, ynext;
end = Newpoly;
for (list = Polybuf; list < end; list++) {
pointer = Newpoly;
pa = list->pl_pair;
/*
* First, find a vertex outside of the clipping
* region.
*/
for (pp = pa;;) {
if (pp->pa_y < bottom)
break;
pp = pp->pa_next;
if (pp == pa) {
/* no clipping needed */
Newpoly->pl_pair = pa;
newpoly();
goto next;
}
}
/* start with an "outside" point */
for (pa = pp;;) {
x = pp->pa_x;
y = pp->pa_y;
pnext = pp->pa_next;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
if (ynext >= bottom && y < bottom) {
/* poly edge crosses bounding clip line */
#ifdef DO_FLOAT
x += (xnext - x)*(((double)(bottom - y))/(ynext - y));
#else
x += ((bottom - y) * (xnext - x))/(ynext - y);
#endif
y = bottom;
if (x != xnext || y != ynext) {
pfirst = Newlink;
pfirst->pa_x = x;
pfirst->pa_y = y;
pfirst->pa_prev = NULL;
newlink();
pp = pnext;
pfirst->pa_next = pp;
pp->pa_prev = pfirst;
}
else {
pp = pnext;
pfirst = pnext;
pfirst->pa_prev = NULL;
}
/* walk along inside points, find the last one */
for (;;) {
if (pp->pa_y < bottom) {
pnext = pp;
pp = pp->pa_prev;
break;
}
pp = pp->pa_next;
}
x = pp->pa_x;
y = pp->pa_y;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
#ifdef DO_FLOAT
x += (xnext - x)*(((double)(bottom - y))/(ynext - y));
#else
x += ((bottom - y) * (xnext - x))/(ynext - y);
#endif
y = bottom;
if (x != xnext || y != ynext) {
plast = Newlink;
plast->pa_x = x;
plast->pa_y = y;
pp->pa_next = plast;
plast->pa_prev = pp;
plast->pa_next = NULL;
newlink();
}
else {
plast = pp;
plast->pa_next = NULL;
}
if (pfirst->pa_next != plast) {
/* note that we are saving poly fragments */
Newpoly->pl_pair = pfirst;
Newpoly->pl_start = pfirst;
newpoly();
Newpoly->pl_pair = plast;
Newpoly->pl_start = pfirst;
newpoly();
}
}
pp = pnext;
if (pp == pa)
break;
}
if (pointer < Newpoly)
linkpolys(pointer,'X');
next:
;
}
for (list = end, end = Polybuf; list < Newpoly; list++) {
if (list->pl_pair) {
end->pl_pair = list->pl_pair;
end->pl_start = NULL;
end++;
}
}
Newpoly = end;
}
static void
clip_top(top)
int top;
{
struct pair *pa, *pp, *pfirst, *plast, *pnext;
struct plist *list, *end, *pointer;
int x, y, xnext, ynext;
end = Newpoly;
for (list = Polybuf; list < end; list++) {
pointer = Newpoly;
pa = list->pl_pair;
/*
* First, find a vertex outside of the clipping
* region.
*/
for (pp = pa;;) {
if (pp->pa_y > top)
break;
pp = pp->pa_next;
if (pp == pa) {
/* no clipping needed */
Newpoly->pl_pair = pa;
newpoly();
goto next;
}
}
/* start with an "outside" point */
for (pa = pp;;) {
x = pp->pa_x;
y = pp->pa_y;
pnext = pp->pa_next;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
if (ynext <= top && y > top) {
/* poly edge crosses bounding clip line */
#ifdef DO_FLOAT
x += (xnext - x)*(((double)(top - y))/(ynext - y));
#else
x += ((top - y) * (xnext - x))/(ynext - y);
#endif
y = top;
if (x != xnext || y != ynext) {
pfirst = Newlink;
pfirst->pa_x = x;
pfirst->pa_y = y;
pfirst->pa_prev = NULL;
newlink();
pp = pnext;
pfirst->pa_next = pp;
pp->pa_prev = pfirst;
}
else {
pp = pnext;
pfirst = pnext;
pfirst->pa_prev = NULL;
}
/* walk along inside points, find the last one */
for (;;) {
if (pp->pa_y > top) {
pnext = pp;
pp = pp->pa_prev;
break;
}
pp = pp->pa_next;
}
x = pp->pa_x;
y = pp->pa_y;
xnext = pnext->pa_x;
ynext = pnext->pa_y;
#ifdef DO_FLOAT
x += (xnext - x)*(((double)(top - y))/(ynext - y));
#else
x += ((top - y) * (xnext - x))/(ynext - y);
#endif
y = top;
if (x != xnext || y != ynext) {
plast = Newlink;
plast->pa_x = x;
plast->pa_y = y;
pp->pa_next = plast;
plast->pa_prev = pp;
plast->pa_next = NULL;
newlink();
}
else {
plast = pp;
plast->pa_next = NULL;
}
if (pfirst->pa_next != plast) {
/* note that we are saving poly fragments */
Newpoly->pl_pair = pfirst;
Newpoly->pl_start = pfirst;
newpoly();
Newpoly->pl_pair = plast;
Newpoly->pl_start = pfirst;
newpoly();
}
}
pp = pnext;
if (pp == pa)
break;
}
if (pointer < Newpoly)
linkpolys(pointer,'X');
next:
;
}
for (list = end, end = Polybuf; list < Newpoly; list++) {
if (list->pl_pair) {
end->pl_pair = list->pl_pair;
end->pl_start = NULL;
end++;
}
}
Newpoly = end;
}
static void
linkpolys(base,XorY)
struct plist *base;
int XorY;
{
struct plist tmp, *b, *bb;
if (XorY == 'X')
qsort(base,Newpoly-base,sizeof(struct plist),polycmpX);
else
qsort(base,Newpoly-base,sizeof(struct plist),polycmpY);
for (b = base; b < Newpoly; b += 2) {
/* link adjacent vertices */
if (b->pl_pair == b->pl_start) {
if ((b+1)->pl_pair == (b+1)->pl_start) {
tmp = *(b+1);
*(b+1) = *(b+2);
*(b+2) = tmp;
}
b->pl_pair->pa_prev = (b+1)->pl_pair;
(b+1)->pl_pair->pa_next = b->pl_pair;
(b+1)->pl_pair = NULL;
if (b->pl_start != (b+1)->pl_start) {
for (bb = b+2; bb < Newpoly; bb++) {
if (bb->pl_start == b->pl_start) {
bb->pl_start = (b+1)->pl_start;
break;
}
}
b->pl_pair = NULL;
}
}
else {
if ((b+1)->pl_pair != (b+1)->pl_start) {
tmp = *(b+1);
*(b+1) = *(b+2);
*(b+2) = tmp;
}
b->pl_pair->pa_next = (b+1)->pl_pair;
(b+1)->pl_pair->pa_prev = b->pl_pair;
(b+1)->pl_pair = NULL;
if (b->pl_start != (b+1)->pl_start) {
for (bb = b+2; bb < Newpoly; bb++) {
if (bb->pl_start == (b+1)->pl_start) {
bb->pl_start = b->pl_start;
break;
}
}
b->pl_pair = NULL;
}
}
}
}
static int
polycmpX(p1,p2)
#ifdef __STDC__
const void *p1, *p2;
#else
char *p1, *p2;
#endif
{
return (((struct plist *)p1)->pl_pair->pa_x -
((struct plist *)p2)->pl_pair->pa_x);
}
static int
polycmpY(p1,p2)
#ifdef __STDC__
const void *p1, *p2;
#else
char *p1, *p2;
#endif
{
return (((struct plist *)p1)->pl_pair->pa_y -
((struct plist *)p2)->pl_pair->pa_y);
}
/* The next two routines support dynamic memory. Structures are expanded
* as necessary but never freed.
*/
static void
newlink()
{
struct pair *oldbuf;
int i, num;
if (Linkbuf == NULL) {
Linkbuf = (struct pair *)malloc(400*sizeof(struct pair));
if (Linkbuf == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Newlink = Linkbuf;
Numlinks = 400;
return;
}
Newlink++;
num = Newlink - Linkbuf;
if (num > Numlinks) {
Numlinks = num + 200;
oldbuf = Linkbuf;
Linkbuf = (struct pair *)
realloc((char*)Linkbuf,Numlinks*sizeof(struct pair));
if (Linkbuf == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Newlink = Linkbuf + num;
for (i = 0; i < num; i++) {
(Linkbuf+i)->pa_next = ((Linkbuf+i)->pa_next - oldbuf) + Linkbuf;
(Linkbuf+i)->pa_prev = ((Linkbuf+i)->pa_prev - oldbuf) + Linkbuf;
}
num = Newpoly - Polybuf;
for (i = 0; i < num; i++) {
(Polybuf+i)->pl_pair = ((Polybuf+i)->pl_pair - oldbuf) + Linkbuf;
}
}
}
static void
newpoly()
{
int num;
if (Polybuf == NULL) {
Polybuf = (struct plist *)malloc(100*sizeof(struct plist));
if (Polybuf == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Newpoly = Polybuf;
Numpolys = 100;
return;
}
Newpoly++;
num = Newpoly - Polybuf;
if (num > Numpolys) {
Numpolys = num + 100;
Polybuf = (struct plist *)
realloc((char*)Polybuf,Numpolys*sizeof(struct plist));
if (Polybuf == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Newpoly = Polybuf + num;
}
}
kic-2.4c/src/kic/header 0000644 0000764 0000764 00000001651 07525346713 014443 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
kic-2.4c/src/kic/prpty.c 0000644 0000764 0000764 00000013173 07525346714 014615 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#ifdef vms
#define TEMPFILE "SYSXXXXXX"
#else
#ifdef MSDOS
#define TEMPFILE "ktXXXXXX"
#else
#define TEMPFILE "/tmp/kicXXXXXX"
#endif
#endif
#ifdef __STDC__
static void show_properties(void);
#else
static void show_properties();
#endif
void
Properties(LookedAhead)
int *LookedAhead;
{
*LookedAhead = False;
Parameters.kpMenu = PROPERTYMENU;
FixMenuPrefix(PropertyMenu);
ShowCommandMenu();
SQShow();
}
void
DoShowProperties()
{
extern char *MenuSHOW;
MenuSelect(MenuSHOW);
show_properties();
MenuDeselect(MenuSHOW);
}
void
AddProperty()
{
struct ks *SQDesc;
char *TypeIn;
int Value;
char String[256];
extern char *MenuADPRP;
MenuSelect(MenuADPRP);
if ((SQDesc = SelectQHead) != NULL) {
ShowPrompt("Property number? ");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
sscanf(TypeIn,"%d",&Value);
ShowPrompt("Property string? ");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) goto quit;
strcpy(String,TypeIn);
while (SQDesc != NULL) {
if (Not CDAddProperty(Parameters.kpCellDesc,
SQDesc->ksPointer,Value,String)) MallocFailed();
SQDesc = SQDesc->ksSucc;
}
Parameters.kpModified = True;
}
else {
ShowPrompt("You haven't selected anything.");
MenuDeselect(MenuADPRP);
return;
}
quit:
ErasePrompt();
MenuDeselect(MenuADPRP);
}
void
RemoveProperty()
{
struct ks *SQDesc;
char *TypeIn;
int Value;
extern char *MenuRMPRP;
MenuSelect(MenuRMPRP);
if ((SQDesc = SelectQHead) != NULL) {
ShowPrompt("Property number to be removed? ");
TypeIn = FBEdit(NULL);
if (TypeIn != NULL) {
sscanf(TypeIn,"%d",&Value);
while (SQDesc != NULL) {
if (Not CDRemoveProperty(Parameters.kpCellDesc,SQDesc->ksPointer,
Value)) MallocFailed();
SQDesc = SQDesc->ksSucc;
}
}
ErasePrompt();
}
else
ShowPrompt("You haven't selected anything.");
MenuDeselect(MenuRMPRP);
}
/*
* These routines may more appropriately belong in CD.
*/
void
RemovePropertyList(Pointer,PrptyDesc)
struct o *Pointer;
struct prpty **PrptyDesc;
{
if (Pointer == NULL)
*PrptyDesc = NULL;
else{
*PrptyDesc = Pointer->oPrptyList;
Pointer->oPrptyList = NULL;
}
}
void
RestorePropertyList(Pointer,PrptyDesc)
struct o *Pointer;
struct prpty *PrptyDesc;
{
if (Pointer != NULL)
Pointer->oPrptyList = PrptyDesc;
}
static void
show_properties()
{
struct prpty *PrptyDesc;
struct ks *SQDesc;
FILE *tmpfile;
char buf1[120];
char tbf[128];
char oldRedisplayControl;
char *tf;
if ((SQDesc = SelectQHead) == NULL) {
ShowPrompt("Nothing to show.");
return;
}
strcpy(tbf, TEMPFILE);
tf = mktemp(tbf);
if (!tf) {
ShowPrompt("Internal error: mktemp() failed.");
return;
}
#ifdef vms
sprintf(buf1,"%s.LIS", tf);
#else
strcpy(buf1, tf);
#endif
oldRedisplayControl = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
while (SQDesc != NULL) {
if ((tmpfile = fopen(buf1,"w")) == NULL) {
char *t = strrchr(buf1, '/');
if (t) {
t++;
strcpy(tbf, t);
strcpy(buf1, tbf);
tmpfile = fopen(buf1, "w");
}
if (!tmpfile) {
ShowPromptAndWait("Can't open temporary file.");
break;
}
}
ShowCurrentObject(SQDesc->ksPointer,DISPLAY);
CDProperty(Parameters.kpCellDesc,SQDesc->ksPointer,&PrptyDesc);
if (PrptyDesc == NULL)
fprintf(tmpfile,"Object has no properties.\n");
else{
while (PrptyDesc != NULL) {
fprintf(tmpfile,"%6d %s\n",PrptyDesc->prpty_Value,
PrptyDesc->prpty_String);
PrptyDesc = PrptyDesc->prpty_Succ;
}
}
fclose(tmpfile);
if ((tmpfile = fopen(buf1,"r")) == NULL) {
ShowPromptAndWait("Can't open temporary file.");
break;
}
FBForeground(DISPLAY,ColorTable[MenuTextColor].Ent);
FBMore(View->kvFineViewport->kaLeft-1,
View->kvFineViewport->kaBottom-1,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop,tmpfile);
fclose(tmpfile);
unlink(buf1);
ShowCurrentObject(SQDesc->ksPointer,ERASE);
SQDesc = SQDesc->ksSucc;
}
Parameters.kpRedisplayControl = oldRedisplayControl;
ShowFineViewport();
}
kic-2.4c/src/kic/polygns.c 0000644 0000764 0000764 00000060725 10261423016 015115 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Polygon management.
*/
#include "prefix.h"
#include "kic.h"
#include
extern char *MenuPOLYG;
extern char *MenuFLASH;
extern char *MenuDONUT;
extern char *MenuARC;
extern char *MenuUNDO;
#ifndef PI
#define PI 3.14159265358979323846
#endif
#define RADTODEG 57.29577951
#ifdef __STDC__
static void allocate_poly(int,struct p*,struct ka*,struct o**,int);
static void record_poly(struct o*);
static double compute_radius(int,int);
static void clip_message(void);
#else
static void allocate_poly();
static void record_poly();
static double compute_radius();
static void clip_message();
#endif
void
Polygons(LookedAhead)
int *LookedAhead;
{
struct p *Path = NULL;
struct ka BB,OldBB;
struct o *Pointer = NULL,*OldPointer = NULL;
int ExpectFirstPoint = True;
int NumVertices = 0;
int Modified = 0;
int Undo = False;
int X,Y,FirstX, FirstY;
char *errmsg = "Can't allow a degenerate polygon.";
MenuSelect(MenuPOLYG);
SetCurrentAOI(View->kvCoarseWindow);
loop {
ShowPrompt("Point to vertices.");
switch (PointLoopCreate(LookedAhead)) {
case PL_PLT:
if (NumVertices > 1) {
Path = CopyPath(Path);
CDDelete(Parameters.kpCellDesc,Pointer);
EraseBox(&BB);
Redisplay(&BB);
allocate_poly(Parameters.kpLayer,Path,&BB,
&Pointer,SQ_INCMPLT);
ShowPath(Parameters.kpLayer,Path,False);
}
continue;
case PL_UND:
MenuSelect(MenuUNDO);
if (NumVertices == 0) {
if (OldPointer == NULL) {
MenuDeselect(MenuUNDO);
goto quit;
}
if (Undo == False) {
OldPointer->oInfo = SQ_GONE;
Modified--;
Undo = True;
}
else {
OldPointer->oInfo = SQ_NEW;
Modified++;
Undo = False;
}
EraseBox(&OldBB);
Redisplay(&OldBB);
MenuDeselect(MenuUNDO);
continue;
}
if (NumVertices > 1)
RemoveLastPointInPath(&Path);
CDDelete(Parameters.kpCellDesc,Pointer);
EraseBox(&BB);
Redisplay(&BB);
if (NumVertices == 1) {
ExpectFirstPoint = True;
ShowMarker(ERASE,0,FirstX,FirstY,200);
}
else {
allocate_poly(Parameters.kpLayer,Path,&BB,&Pointer,SQ_INCMPLT);
LastPointInPath(&X,&Y,Path);
ShowPath(Parameters.kpLayer,Path,False);
}
NumVertices--;
MenuDeselect(MenuUNDO);
continue;
case PL_ESC:
if (Not ExpectFirstPoint) {
CDDelete(Parameters.kpCellDesc,Pointer);
Pointer = NULL;
EraseBox(&BB);
Redisplay(&BB);
}
goto quit;
case PL_CMD:
if (Not ExpectFirstPoint) {
if (NumVertices <= 2) {
CDDelete(Parameters.kpCellDesc,Pointer);
Pointer = NULL;
}
else {
AppendPointToPath(&FirstX,&FirstY,&Path);
CDDelete(Parameters.kpCellDesc,Pointer);
allocate_poly(Parameters.kpLayer,Path,&BB,&Pointer,0);
Modified++;
}
EraseBox(&BB);
Redisplay(&BB);
}
goto quit;
}
if (ExpectFirstPoint) {
NumVertices++;
ExpectFirstPoint = False;
FirstX = X = KicCursor.kcX;
FirstY = Y = KicCursor.kcY;
Path = AllocatePath(X,Y);
SetRelative(X,Y,True);
allocate_poly(Parameters.kpLayer,Path,&BB,&Pointer,SQ_INCMPLT);
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,X,Y,200);
continue;
}
if (KicCursor.kcX == X And KicCursor.kcY == Y) {
X = FirstX;
Y = FirstY;
}
else {
X = KicCursor.kcX;
Y = KicCursor.kcY;
}
AppendPointToPath(&X,&Y,&Path);
CDDelete(Parameters.kpCellDesc,Pointer);
allocate_poly(Parameters.kpLayer,Path,&BB,&Pointer,SQ_INCMPLT);
if (X == FirstX And Y == FirstY) {
if (NumVertices <= 2) {
CDDelete(Parameters.kpCellDesc,Pointer);
ShowMarker(ERASE,0,FirstX,FirstY,200);
ShowPromptAndWait(errmsg);
}
else {
Pointer->oInfo = SQ_NEW;
record_poly(OldPointer);
OldPointer = Pointer;
OldBB = BB;
Modified++;
}
Pointer = NULL;
NumVertices = 0;
ExpectFirstPoint = True;
EraseBox(&BB);
Redisplay(&BB);
Undo = False;
}
else {
ShowMarker(ERASE,0,FirstX,FirstY,200);
ShowPath(Parameters.kpLayer,Path,False);
NumVertices++;
}
}
quit:
record_poly(OldPointer);
record_poly(Pointer);
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
if (NumVertices == 1)
ShowMarker(ERASE,0,FirstX,FirstY,200);
MenuDeselect(MenuPOLYG);
}
void
Flash(LookedAhead)
int *LookedAhead;
{
struct ka BB;
struct p *Path, *NewPath;
struct o *Pointer, *OldPointer = NULL;
double Angle,Rad = 0.0,DPhi;
int CenX,CenY,PerX,PerY;
int i;
int Undo = False;
int Modified = 0;
MenuSelect(MenuFLASH);
SetCurrentAOI(View->kvCoarseWindow);
DPhi = 2*PI/Parameters.kpNumRoundFlashSides;
loop {
ShowPrompt("Point at center.");
switch (PointLoop(LookedAhead)) {
case PL_UND:
if (OldPointer == NULL)
goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
OldPointer->oInfo = SQ_GONE;
Modified--;
Undo = True;
}
else {
OldPointer->oInfo = SQ_NEW;
Modified++;
Undo = False;
}
EraseBox(&BB);
Redisplay(&BB);
MenuDeselect(MenuUNDO);
continue;
case PL_ESC:
case PL_CMD:
goto quit;
}
CenX = KicCursor.kcX;
CenY = KicCursor.kcY;
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,CenX,CenY,200);
SetRelative(CenX,CenY,True);
next:
ShowPrompt("Point at the perimeter.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
ShowMarker(ERASE,0,CenX,CenY,200);
goto quit;
case PL_UND:
ShowMarker(ERASE,0,CenX,CenY,200);
continue;
case PL_PCW:
PerX = KicCursor.kcX;
PerY = KicCursor.kcY;
Rad = compute_radius(CenX - PerX,CenY - PerY);
if (Rad < (double)
LayerTable[Parameters.kpLayer].klMinDimensions/
RESOLUTION) {
ShowPromptAndWait(
"Sorry. The radius is less than the minimum dimension.");
goto next;
}
}
clip_message();
ShowMarker(ERASE,0,CenX,CenY,200);
Angle = 0;
Path = NewPath = AllocatePath(CenX,CenY+(int)Rad);
for (i = 1; i < Parameters.kpNumRoundFlashSides; i++) {
Angle += DPhi;
NewPath = NewPath->pSucc = AllocatePath(
CenX + (int)(Rad*sin(Angle)),
CenY + (int)(Rad*cos(Angle)));
}
NewPath = NewPath->pSucc = AllocatePath(CenX,CenY+(int)Rad);
if (Parameters.kpClipVerticesToGrid)
for (NewPath = Path; NewPath; NewPath = NewPath->pSucc)
ClipToGridPoint(&NewPath->pX,&NewPath->pY);
if (Not CDMakePolygon(Parameters.kpCellDesc,Parameters.kpLayer,
Path,&Pointer)) MallocFailed();
Pointer->oInfo = SQ_NEW;
record_poly(OldPointer);
OldPointer = Pointer;
BB.kaLeft = CenX - Rad;
BB.kaRight = CenX + Rad;
BB.kaBottom = CenY - Rad;
BB.kaTop = CenY + Rad;
Modified++;
Undo = False;
EraseBox(&BB);
Redisplay(&BB);
}
quit:
record_poly(OldPointer);
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
MenuDeselect(MenuFLASH);
}
void
Doughnut(LookedAhead)
int *LookedAhead;
{
struct ka BB;
struct o *Pointer1,*Pointer2,*OldPointer1 = NULL,*OldPointer2 = NULL;
struct p *Path1, *Path2, *NewPath1, *NewPath2;
double Angle,DPhi,Rad1 = 0.0,Rad2 = 0.0;
int CenX = 0,CenY = 0;
int i,Sides;
int Modified = 0;
int Undo = False;
MenuSelect(MenuDONUT);
SetCurrentAOI(View->kvCoarseWindow);
OldPointer1 = NULL;
Sides = Parameters.kpNumRoundFlashSides;
Sides = ((Sides+1)/2);
DPhi = PI/Sides;
loop {
ShowPrompt("Point at center.");
switch (PointLoop(LookedAhead)) {
case PL_UND:
if (OldPointer1 == NULL)
goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
OldPointer1->oInfo = SQ_GONE;
OldPointer2->oInfo = SQ_GONE;
Modified--;
Undo = True;
}
else {
OldPointer1->oInfo = SQ_NEW;
OldPointer2->oInfo = SQ_NEW;
Modified++;
Undo = False;
}
EraseBox(&BB);
Redisplay(&BB);
MenuDeselect(MenuUNDO);
continue;
case PL_ESC:
case PL_CMD:
goto quit;
}
CenX = KicCursor.kcX;
CenY = KicCursor.kcY;
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,CenX,CenY,200);
SetRelative(CenX,CenY,True);
inner:
ShowPrompt("Point at inner radius.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
ShowMarker(ERASE,0,CenX,CenY,200);
continue;
case PL_PCW:
Rad1 = compute_radius(CenX-KicCursor.kcX,CenY-KicCursor.kcY);
if (Rad1 == 0) {
ShowPromptAndWait(
"Inner diameter is zero, use Flash to make a disk.");
goto inner;
}
if (Rad1 < (double)
LayerTable[Parameters.kpLayer].klMinDimensions/
(2*RESOLUTION)) {
ShowPromptAndWait(
"Inner diameter is less than the minimum dimension.");
goto inner;
}
}
outer:
ShowPrompt("Point at outer radius.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
goto inner;
case PL_PCW:
Rad2 = compute_radius(CenX-KicCursor.kcX,CenY-KicCursor.kcY);
if (Rad2 <= Rad1) {
ShowPromptAndWait("The width is zero or negative.");
goto outer;
}
if (Rad2 - Rad1 < (double)
LayerTable[Parameters.kpLayer].klMinDimensions/
RESOLUTION) {
ShowPromptAndWait(
"The width is less than the minimum dimension.");
goto outer;
}
}
clip_message();
ShowMarker(ERASE,ColorTable[HighlightingColor].Ent,CenX,CenY,200);
Angle = 0;
Path1 = NewPath1 = AllocatePath(CenX,CenY+(int)Rad1);
Path2 = NewPath2 = AllocatePath(CenX,CenY-(int)Rad2);
for (i = 1; i < Sides; i++) {
Angle += DPhi;
NewPath1 = NewPath1->pSucc = AllocatePath(
CenX + (int)(Rad1*sin(Angle)),
CenY + (int)(Rad1*cos(Angle)));
NewPath2 = NewPath2->pSucc = AllocatePath(
CenX + (int)(Rad2*sin(Angle)),
CenY - (int)(Rad2*cos(Angle)));
}
NewPath1 = NewPath1->pSucc = AllocatePath(CenX,CenY-(int)Rad1);
NewPath2 = NewPath2->pSucc = AllocatePath(CenX,CenY+(int)Rad2);
NewPath1->pSucc = Path2;
NewPath2->pSucc = AllocatePath(CenX,CenY+(int)Rad1);
if (Parameters.kpClipVerticesToGrid)
for (NewPath1 = Path1; NewPath1; NewPath1 = NewPath1->pSucc)
ClipToGridPoint(&NewPath1->pX,&NewPath1->pY);
if (Not CDMakePolygon(Parameters.kpCellDesc,Parameters.kpLayer,Path1,
&Pointer1)) MallocFailed();
Angle = 0;
Path1 = NewPath1 = AllocatePath(CenX,CenY+(int)Rad1);
Path2 = NewPath2 = AllocatePath(CenX,CenY-(int)Rad2);
for (i = 1; i < Sides; i++) {
Angle += DPhi;
NewPath1 = NewPath1->pSucc = AllocatePath(
CenX - (int)(Rad1*sin(Angle)),
CenY + (int)(Rad1*cos(Angle)));
NewPath2 = NewPath2->pSucc = AllocatePath(
CenX - (int)(Rad2*sin(Angle)),
CenY - (int)(Rad2*cos(Angle)));
}
NewPath1 = NewPath1->pSucc = AllocatePath(CenX,CenY-(int)Rad1);
NewPath2 = NewPath2->pSucc = AllocatePath(CenX,CenY+(int)Rad2);
NewPath1->pSucc = Path2;
NewPath2->pSucc = AllocatePath(CenX,CenY+(int)Rad1);
if (Parameters.kpClipVerticesToGrid)
for (NewPath1 = Path1; NewPath1; NewPath1 = NewPath1->pSucc)
ClipToGridPoint(&NewPath1->pX,&NewPath1->pY);
if (Not CDMakePolygon(Parameters.kpCellDesc,Parameters.kpLayer,Path1,
&Pointer2)) MallocFailed();
Pointer1->oInfo = SQ_NEW;
Pointer2->oInfo = SQ_NEW;
record_poly(OldPointer1);
record_poly(OldPointer2);
OldPointer1 = Pointer1;
OldPointer2 = Pointer2;
BB.kaLeft = CenX - Rad2;
BB.kaRight = CenX + Rad2;
BB.kaBottom = CenY - Rad2;
BB.kaTop = CenY + Rad2;
Modified++;
Undo = False;
EraseBox(&BB);
Redisplay(&BB);
}
quit:
ShowMarker(ERASE,0,CenX,CenY,200);
record_poly(OldPointer1);
record_poly(OldPointer2);
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
MenuDeselect(MenuDONUT);
}
void
Arcs(LookedAhead)
int *LookedAhead;
{
struct ka BB;
struct p *Path1,*Path2,*NewPath1,*NewPath2;
struct o *Pointer,*OldPointer = NULL;
double A1,A2,Rad1 = 0.0,Rad2 = 0.0;
double Angle1 = 0.0,Angle2 = 0.0,DPhi;
int CenX = 0, CenY = 0;
int i,Sides;
int Undo = False;
int Modified = 0;
MenuSelect(MenuARC);
SetCurrentAOI(View->kvCoarseWindow);
loop {
ShowPrompt("Point at center of arc.");
switch (PointLoop(LookedAhead)) {
case PL_UND:
if (OldPointer == NULL)
goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
OldPointer->oInfo = SQ_GONE;
Modified--;
Undo = True;
}
else {
OldPointer->oInfo = SQ_NEW;
Modified++;
Undo = False;
}
EraseBox(&BB);
Redisplay(&BB);
MenuDeselect(MenuUNDO);
continue;
case PL_ESC:
case PL_CMD:
goto quit;
}
CenX = KicCursor.kcX;
CenY = KicCursor.kcY;
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,CenX,CenY,200);
SetRelative(CenX,CenY,True);
inner:
ShowPrompt("Point at inner radius.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
ShowMarker(ERASE,0,CenX,CenY,200);
continue;
case PL_PCW:
Rad1 = compute_radius(CenX-KicCursor.kcX,CenY-KicCursor.kcY);
if (Rad1 < (double)
LayerTable[Parameters.kpLayer].klMinDimensions/
(2*RESOLUTION)) {
ShowPromptAndWait(
"Inner diameter is less than the minimum dimension.");
goto inner;
}
}
outer:
ShowPrompt("Point at outer radius.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
goto inner;
case PL_PCW:
Rad2 = compute_radius(CenX-KicCursor.kcX,CenY-KicCursor.kcY);
if (Rad2 - Rad1 < (double)
LayerTable[Parameters.kpLayer].klMinDimensions/
RESOLUTION) {
ShowPromptAndWait(
"The width is less than the minimum dimension.");
goto outer;
}
}
begin:
ShowPrompt("Point to beginning of arc in a clockwise path.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
goto outer;
case PL_PCW:
Angle2 = atan2((double)(KicCursor.kcY-CenY),
(double)(KicCursor.kcX-CenX));
}
ShowPrompt("Point to end of arc in a clockwise path.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
goto begin;
case PL_PCW:
Angle1 = atan2((double)(KicCursor.kcY-CenY),
(double)(KicCursor.kcX-CenX));
}
clip_message();
ShowMarker(ERASE,ColorTable[HighlightingColor].Ent,CenX,CenY,200);
if (Angle2 < Angle1) Angle2 += 2*PI;
Sides = ((Angle2 - Angle1)/(2*PI))*Parameters.kpNumRoundFlashSides;
if (Sides < 3) Sides = 3;
DPhi = (Angle2 - Angle1)/Sides;
A1 = Angle1;
A2 = Angle2;
Path1 = NewPath1 = AllocatePath(
CenX + (int)(Rad1*cos(Angle1)),
CenY + (int)(Rad1*sin(Angle1)));
Path2 = NewPath2 = AllocatePath(
CenX + (int)(Rad2*cos(Angle2)),
CenY + (int)(Rad2*sin(Angle2)));
for (i = 1; i < Sides; i++) {
A1 += DPhi;
A2 -= DPhi;
NewPath1 = NewPath1->pSucc = AllocatePath(
CenX + (int)(Rad1*cos(A1)),
CenY + (int)(Rad1*sin(A1)));
NewPath2 = NewPath2->pSucc = AllocatePath(
CenX + (int)(Rad2*cos(A2)),
CenY + (int)(Rad2*sin(A2)));
}
NewPath1 = NewPath1->pSucc = AllocatePath(
CenX + (int)(Rad1*cos(Angle2)),
CenY + (int)(Rad1*sin(Angle2)));
NewPath2 = NewPath2->pSucc = AllocatePath(
CenX + (int)(Rad2*cos(Angle1)),
CenY + (int)(Rad2*sin(Angle1)));
NewPath1->pSucc = Path2;
NewPath2->pSucc = AllocatePath(
CenX + (int)(Rad1*cos(Angle1)),
CenY + (int)(Rad1*sin(Angle1)));
if (Parameters.kpClipVerticesToGrid)
for (NewPath1 = Path1; NewPath1; NewPath1 = NewPath1->pSucc)
ClipToGridPoint(&NewPath1->pX,&NewPath1->pY);
if (Not CDMakePolygon(Parameters.kpCellDesc,Parameters.kpLayer,Path1,
&Pointer)) MallocFailed();
Pointer->oInfo = SQ_NEW;
record_poly(OldPointer);
OldPointer = Pointer;
BB.kaLeft = CenX - Rad2;
BB.kaRight = CenX + Rad2;
BB.kaBottom = CenY - Rad2;
BB.kaTop = CenY + Rad2;
Modified++;
Undo = False;
EraseBox(&BB);
Redisplay(&BB);
}
quit:
record_poly(OldPointer);
ShowMarker(ERASE,0,CenX,CenY,200);
if (Modified)
Parameters.kpModified = True;
SetRelative(0L,0L,False);
ErasePrompt();
MenuDeselect(MenuARC);
}
void
ShowPath(Layer,Path,Terminate)
int Layer;
struct p *Path;
int Terminate; /* If True, the path is closed */
{
struct p *Pair;
int firstX,firstY,X,Y,lastX,lastY;
Pair = Path;
firstX = lastX = Pair->pX;
firstY = lastY = Pair->pY;
Pair = Pair->pSucc;
while (Pair != NULL) {
X = Pair->pX;
Y = Pair->pY;
ShowLine(Layer,lastX,lastY,X,Y);
lastX = X;
lastY = Y;
Pair = Pair->pSucc;
}
if (Terminate)
ShowLine(Layer,firstX,firstY,lastX,lastY);
}
void
ShowPolygon(Layer,Path)
int Layer;
struct p *Path;
{
struct p *Pair;
int *PolygonBuffer;
int i,n,nfine,ncoarse,n2;
int X,Y;
for (n = 0,Pair = Path; Pair != NULL; n++,Pair = Pair->pSucc) ;
if (Layer == ColorTable[HighlightingColor].Ent Or
!(LayerTable[Layer].klAttributes & FILLED) Or
!FB.fFilledPolygons Or n < 3) {
ShowPath(Layer,Path,True);
return;
}
n2 = n << 1;
ncoarse = nfine = n;
PolygonBuffer = (int*) tmalloc(n2*4*sizeof(int));
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY And
CurrentAOI.aInCoarse) {
for (i = 0,Pair = Path; i < n2; i += 2,Pair = Pair->pSucc) {
X = Pair->pX;
Y = Pair->pY;
TPoint(&X,&Y);
CoarseLToP(X,Y,PolygonBuffer[i],PolygonBuffer[i+1]);
}
FBPolygonClip(PolygonBuffer,&ncoarse,(struct ka*)&CurrentAOI.aLC);
if (LayerTable[Layer].klAttributes & COARSE_FILL) {
FBPolygon(Layer,FILL,LayerTable[Layer].klStyleID,
PolygonBuffer,ncoarse);
if (LayerTable[Layer].klAttributes & OUTLINED)
ShowPath(Layer,Path,True);
}
else
FBPolygon(Layer,FILL,0,PolygonBuffer,ncoarse);
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY And
CurrentAOI.aInFine) {
for (i = 0,Pair = Path; i < n2; i += 2,Pair = Pair->pSucc) {
X = Pair->pX;
Y = Pair->pY;
TPoint(&X,&Y);
FineLToP(X,Y,PolygonBuffer[i],PolygonBuffer[i+1]);
}
FBPolygonClip(PolygonBuffer,&nfine,(struct ka*)&CurrentAOI.aLF);
if (LayerTable[Layer].klAttributes & FINE_FILL) {
FBPolygon(Layer,FILL,LayerTable[Layer].klStyleID,
PolygonBuffer,nfine);
if (LayerTable[Layer].klAttributes & OUTLINED)
ShowPath(Layer,Path,True);
}
else
FBPolygon(Layer,FILL,0,PolygonBuffer,nfine);
}
free(PolygonBuffer);
}
void
LastPointInPath(X,Y,Path)
int *X,*Y;
struct p *Path;
{
struct p *p;
for (p = Path; p && p->pSucc; p = p->pSucc) ;
if (p) {
*X = p->pX;
*Y = p->pY;
}
}
struct p *
AllocatePath(X,Y)
int X,Y;
{
struct p *Path;
if ((Path = alloc(p)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
Path->pX = X;
Path->pY = Y;
Path->pSucc = NULL;
return Path;
}
static void
allocate_poly(Layer,Path,BB,Pointer,Info)
int Layer;
struct p *Path;
struct ka *BB;
struct o **Pointer;
int Info;
{
CDBogusPoly = True;
if (Not CDMakePolygon(Parameters.kpCellDesc,
Layer,Path,Pointer)) MallocFailed();
CDBogusPoly = False;
(*Pointer)->oInfo = Info;
CDStatusInt = CDBB(Parameters.kpCellDesc,*Pointer,
&BB->kaLeft,&BB->kaBottom,&BB->kaRight,&BB->kaTop);
}
static void
record_poly(Pointer)
struct o *Pointer;
{
if (Pointer == NULL) return;
if (Pointer->oInfo == SQ_GONE)
CDDelete(Parameters.kpCellDesc,Pointer);
else
Pointer->oInfo = SQ_OLD;
}
static double
compute_radius(x,y)
int x,y;
{
return (int)sqrt(x*(double)x + y*(double)y);
}
static void
clip_message()
{
if (Parameters.kpClipVerticesToGrid)
ShowPrompt("Vertices will be clipped to the nearest grid point.");
}
kic-2.4c/src/kic/redispla.c 0000644 0000764 0000764 00000033104 07525346714 015236 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* The KIC redisplay code.
*/
#include "prefix.h"
#include "kic.h"
/* cells smaller than this are never expanded */
static int MinWidth;
#define ka_copy(BB1,BB2) BB1.kaLeft = BB2->kaLeft; \
BB1.kaRight = BB2->kaRight; \
BB1.kaBottom = BB2->kaBottom; \
BB1.kaTop = BB2->kaTop; \
TPoint(&BB1.kaLeft,&BB1.kaBottom); \
TPoint(&BB1.kaRight,&BB1.kaTop); \
if(BB.kaLeft > BB.kaRight) \
SwapInts(BB1.kaLeft,BB1.kaRight); \
if(BB.kaBottom > BB.kaTop) \
SwapInts(BB1.kaBottom,BB1.kaTop);
#ifdef __STDC__
static void redisplay_layer(struct s*,struct ka*,int,int,int,int);
#else
static void redisplay_layer();
#endif
void
Redisplay(AOI)
struct ka *AOI;
{
struct ka FineAOI;
int Layer,Expanding;
char Temp;
if (Parameters.kpRedisplayControl == SPLITSCREEN) {
SetCurrentAOI(View->kvCoarseWindow);
XORfineViewport();
}
SetCurrentAOI(AOI);
if (CurrentAOI.aInCoarse == 0 And CurrentAOI.aInFine == 0)
goto quit;
Parameters.kpNumGeometries = 0;
if (Parameters.kpShowBandwidth)
StartTiming();
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY) {
FineAOI.kaX = AOI->kaX;
FineAOI.kaY = AOI->kaY;
FineAOI.kaLeft = max(AOI->kaLeft,View->kvFineWindow->kaLeft);
FineAOI.kaRight = min(AOI->kaRight,View->kvFineWindow->kaRight);
FineAOI.kaTop = min(AOI->kaTop,View->kvFineWindow->kaTop);
FineAOI.kaBottom = max(AOI->kaBottom,View->kvFineWindow->kaBottom);
}
if (!Parameters.kpGridOnTop)
ShowGrid();
if (Parameters.kpCellDesc != NULL) {
for (Layer = 1; Layer <= NumLayerTable; ++Layer) {
if (!(LayerTable[Layer].klAttributes & VISIBLE)) continue;
if (Parameters.kpRedisplayControl != FINEVIEWPORTONLY) {
Temp = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
MinWidth = 4.0/View->kvCoarseRatio;
Expanding = Parameters.kpExpandInstances;
if (Parameters.kpShowContext &&
(Parameters.kpCellDesc != Parameters.kpTopDesc)) {
TPush();
TLoad();
Parameters.kpHierarchyLevel = 0;
redisplay_layer(Parameters.kpTopDesc,AOI,Layer,
True,Layer == NumLayerTable,True);
TPop();
if (Parameters.kpSIGINTERRUPT) {
RedisplayAfterInterrupt();
goto quit;
}
}
Parameters.kpHierarchyLevel = 0;
redisplay_layer(Parameters.kpCellDesc,AOI,Layer,
Expanding,Layer == NumLayerTable,False);
Parameters.kpRedisplayControl = Temp;
if (Parameters.kpSIGINTERRUPT) {
RedisplayAfterInterrupt();
goto quit;
}
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY) {
Temp = Parameters.kpRedisplayControl;
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
MinWidth = 4.0/View->kvFineRatio;
Expanding = Parameters.kpExpandInstances ||
Parameters.kpExpandFineViewportOnly;
if (Parameters.kpShowContext &&
(Parameters.kpCellDesc != Parameters.kpTopDesc)) {
TPush();
TLoad();
Parameters.kpHierarchyLevel = 0;
redisplay_layer(Parameters.kpTopDesc,&FineAOI,Layer,
True,Layer == NumLayerTable,True);
if (Parameters.kpSIGINTERRUPT) {
RedisplayAfterInterrupt();
goto quit;
}
TPop();
}
Parameters.kpHierarchyLevel = 0;
redisplay_layer(Parameters.kpCellDesc,&FineAOI,Layer,
Expanding,Layer == NumLayerTable,False);
Parameters.kpRedisplayControl = Temp;
if (Parameters.kpSIGINTERRUPT) {
RedisplayAfterInterrupt();
goto quit;
}
}
}
}
if (Parameters.kpGridOnTop)
ShowGrid();
else
ShowAxes();
/*
* Highlight selected objects.
*/
SQShow();
/* SRW ** show markers */
ShowMarker(DISPLAY,ColorTable[HighlightingColor].Ent,0L,0L,0);
if (Parameters.kpShowBandwidth) {
StopTiming();
ShowRatio("geometries",Parameters.kpNumGeometries,"seconds(real)",
ElapsedRealTime());
ShowRatio("geometries",Parameters.kpNumGeometries,"seconds(user)",
ElapsedUserTime());
ShowRatio("geometries",Parameters.kpNumGeometries,"seconds(system)",
ElapsedSystemTime());
}
quit:
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY) {
FBForeground(DISPLAY,ColorTable[HighlightingColor].Ent);
OutlineBox(View->kvFineViewport);
}
SetCurrentAOI(View->kvCoarseWindow);
if (Parameters.kpRedisplayControl == SPLITSCREEN)
XORfineViewport();
}
static void
redisplay_layer(CellDesc,AOI,Layer,Expand,ShowBB,Context)
/* if Expand, show subcells in expanded form.
* if ShowBB, if !Expand, show bounding box of subcells.
* if Context, don't show current cell or descendents.
*/
struct s *CellDesc;
struct ka *AOI;
int Layer,Expand,ShowBB,Context;
{
struct g *GenDesc;
struct o *Pointer;
struct p *Path;
struct ka BB;
struct ka MasterBB;
struct s *MasterDesc;
char Type,Xform;
char *MasterName;
char *Label;
int NumX,NumY;
int Int1,Int2;
int X,Y;
int Width;
int DX,DY;
++Parameters.kpHierarchyLevel;
if (Not CDInitGen(CellDesc,Layer,AOI->kaLeft,AOI->kaBottom,
AOI->kaRight,AOI->kaTop,&GenDesc)) MallocFailed();
loop {
/* Test for user interrupt */
if (Parameters.kpSIGINTERRUPT) return;
CDGen(CellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
/* Don't display if conditionally deleted. */
if (Pointer->oInfo == SQ_GONE) continue;
++Parameters.kpNumGeometries;
Type = Pointer->oType;
if (Type == CDBOX) {
CDStatusInt = CDBB(CellDesc,Pointer,&BB.kaLeft,
&BB.kaBottom,&BB.kaRight,&BB.kaTop);
ShowBox(Layer,&BB);
continue;
}
if (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
if (Pointer->oInfo == SQ_INCMPLT)
ShowPath(Layer,Path,False);
else
ShowWire(Layer,Width,Path);
continue;
}
if (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
if (Pointer->oInfo == SQ_INCMPLT)
ShowPath(Layer,Path,False);
else
ShowPolygon(Layer,Path);
continue;
}
if (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
ShowLabel(Layer,Label,X,Y,Xform,Parameters.kpDisplayAllLabels);
continue;
}
}
if (TFull()) {
--Parameters.kpHierarchyLevel;
return;
}
/*
* If we aren't expanding instances, we want to show symbolic
* layers on next lower hierarchy level only.
*/
if (!Expand And Parameters.kpHierarchyLevel != 1) {
--Parameters.kpHierarchyLevel;
return;
}
if (Expand || (LayerTable[Layer].klAttributes & SYMBOLIC)) {
if (Not CDInitGen(CellDesc,0,AOI->kaLeft,AOI->kaBottom,AOI->kaRight,
AOI->kaTop,&GenDesc)) MallocFailed();
loop {
/* Test for user interrupt */
if (Parameters.kpSIGINTERRUPT) break;
CDGen(CellDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
if (Pointer->oInfo == SQ_GONE)
continue;
if (Context && (CellDesc == Parameters.kpCellDesc))
continue;
CDStatusInt = CDBB(CellDesc,Pointer,&BB.kaLeft,&BB.kaBottom,
&BB.kaRight,&BB.kaTop);
if (BB.kaRight < BB.kaLeft) SwapInts(BB.kaLeft,BB.kaRight);
if (BB.kaTop < BB.kaBottom) SwapInts(BB.kaBottom,BB.kaTop);
X = BB.kaRight - BB.kaLeft;
Y = BB.kaTop - BB.kaBottom;
if (Y < X) X = Y;
if (X < MinWidth) {
/*
* Outline BB of Instance.
*/
if (ShowBB)
ShowEmptyBox(ColorTable[InstanceBBColor].Ent,&BB);
continue;
}
CDCall(Pointer,&MasterName,&NumX,&DX,&NumY,&DY);
if (OpenCell(MasterName,&MasterDesc)) break;
if (Not CDBB(MasterDesc,(struct o *)NULL,&MasterBB.kaLeft,
&MasterBB.kaBottom,&MasterBB.kaRight,&MasterBB.kaTop))
MallocFailed();
SetTransform(Pointer);
for (Int1 = NumY-1; Int1 >= 0; --Int1) {
for (Int2 = 0; Int2 < NumX; ++Int2 ) {
TPush();
TIdentity();
TTranslate(Int2*DX,Int1*DY);
TPremultiply();
/*
* Box test instance array element with AOI.
*/
ka_copy(BB,(&MasterBB));
if (Not (BB.kaLeft > AOI->kaRight Or
BB.kaRight < AOI->kaLeft Or
BB.kaBottom > AOI->kaTop Or
BB.kaTop < AOI->kaBottom))
redisplay_layer(MasterDesc,
AOI,Layer,Expand,ShowBB,Context);
TPop();
}
}
TPop();
}
}
if (!Expand && ShowBB) {
if (Not CDInitGen(CellDesc,0,AOI->kaLeft,AOI->kaBottom,AOI->kaRight,
AOI->kaTop,&GenDesc)) MallocFailed();
loop {
/* Test for user interrupt */
if (Parameters.kpSIGINTERRUPT) break;
CDGen(CellDesc,GenDesc,&Pointer);
if (Pointer == NULL)
break;
if (Pointer->oInfo == SQ_GONE)
continue;
if (Context && (CellDesc == Parameters.kpCellDesc))
continue;
/*
* Unexpanded form of an instance array is its BB with the
* name of its master shown in its center.
* If it is not 1 by 1, tell the user its dimensions.
* BB dimensions are shown also.
* CDBB will always return True if Pointer != NULL.
*/
CDStatusInt = CDBB(CellDesc,Pointer,&BB.kaLeft,&BB.kaBottom,
&BB.kaRight,&BB.kaTop);
if (BB.kaRight < BB.kaLeft) SwapInts(BB.kaLeft,BB.kaRight);
if (BB.kaTop < BB.kaBottom) SwapInts(BB.kaBottom,BB.kaTop);
/*
* Outline BB of Instance.
*/
ShowEmptyBox(ColorTable[InstanceBBColor].Ent,&BB);
CDCall(Pointer,&MasterName,&NumX,&DX,&NumY,&DY);
if (NumX != 1 Or NumY != 1)
sprintf(TypeOut,"%d/%d %s",NumX,NumY,MasterName);
else sprintf(TypeOut,"%s",MasterName);
ShowLabel(ColorTable[InstanceNameColor].Ent,TypeOut,BB.kaLeft,
BB.kaBottom + (BB.kaTop-BB.kaBottom)/2,0,
Parameters.kpLabelAllInstances);
sprintf(TypeOut,"%g/%g",(double)(BB.kaRight-BB.kaLeft)/RESOLUTION,
(double)(BB.kaTop-BB.kaBottom)/RESOLUTION);
ShowLabel(ColorTable[InstanceSizeColor].Ent,TypeOut,BB.kaLeft,
BB.kaBottom,0,Parameters.kpLabelAllInstances);
}
}
--Parameters.kpHierarchyLevel;
return;
}
void
RedisplayAfterInterrupt()
{
TInit();
ShowPrompt("Interrupted. Type Ctrl A to abort.");
InitSignals();
ShowCommandMenu();
ShowLayerTable();
ShowParameters();
}
int
TCheck()
{
if (TFull()) {
ShowPrompt("Cell hierarchy is too deep. MORE");
(void)FBGetchar(ERASE);
ShowPrompt("Probably you have a recursive hierarchy.");
TInit();
return True;
}
return False;
}
void
SetTransform(Pointer)
struct o *Pointer;
{
struct t *TGen;
int X,Y;
char Type;
TPush();
TIdentity();
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL)
break;
if (Type == CDROTATE)
TRotate(X,Y);
elif (Type == CDTRANSLATE)
TTranslate(X,Y);
elif (Type == CDMIRRORX)
TMX();
elif (Type == CDMIRRORY)
TMY();
}
TPremultiply();
}
kic-2.4c/src/kic/dir.c 0000644 0000764 0000764 00000016236 07525346713 014217 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/*************************************************************************
*
* Dir command.
* Show a directory listing of symbol files.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#if __NDPC__
#include
typedef int *DIR;
struct direct {
char d_name[20];
};
#if __STDC__
extern DIR *opendir(char *);
extern struct direct *readdir(DIR *);
extern void closedir(DIR *);
#else
extern DIR *opendir( );
extern struct direct *readdir( );
extern void closedir( );
#endif
#else
#ifdef HPUX
/* more foulness from HP */
typedef unsigned int ino_t;
#endif
#include
#include
#ifdef direct
#undef direct
#endif
#define direct dirent
#endif
extern char *MenuDIR;
struct list {
char *l_word;
struct list *l_next;
};
#ifdef __STDC__
static void format_lines(struct list*);
static void display_lines(struct list*);
static void list_free(struct list*);
static void list_sort(struct list*);
static int lcomp(const void*,const void*);
static int is_symfile(char*);
static struct list *symfiles(char*);
#else
static void format_lines();
static void display_lines();
static void list_free();
static void list_sort();
static int lcomp();
static int is_symfile();
static struct list *symfiles();
#endif
/* external */
extern int MoreLine();
extern void EnableMore();
extern char *CopyString();
extern char *tmalloc();
void
Dir()
{
char *path;
char *c,*s;
struct list *wl,*wx = NULL,*wx0 = NULL;
MenuSelect(MenuDIR);
path = PGetPath();
for (s = path;;) {
while (isspace(*s)) s++;
if (*s == '\0')
break;
c = TypeOut;
while (!isspace(*s) && *s != '\0')
*c++ = *s++;
*c = '\0';
/* TypeOut contains the directory path */
wl = symfiles(TypeOut);
list_sort(wl);
format_lines(wl);
if (wx0 == NULL)
wx = wx0 = alloc(list);
else {
wx->l_next = alloc(list);
wx = wx->l_next;
}
if (wx == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
strcat(TypeOut," :");
wx->l_word = CopyString(TypeOut);
wx->l_next = wl;
while (wx->l_next) wx = wx->l_next;
}
display_lines(wx0);
list_free(wx0);
FullRedisplay();
MenuDeselect(MenuDIR);
}
static void
format_lines(li)
/* combine the words into columns */
struct list *li;
{
struct list *wl;
int i,width,colw;
char *buf,*b;
if (li == NULL) return;
width = View->kvLargeCoarseViewport->kaWidth - 8;
width /= FB.fFontWidth;
buf = tmalloc(width+1);
colw = 0;
for (wl = li; wl; wl = wl->l_next) {
i = strlen(wl->l_word);
if (i > colw) colw = i;
}
colw += 2;
width /= colw;
b = buf;
i = 0;
for (wl = li; wl; wl = wl->l_next) {
sprintf(b,"%-*s",colw,wl->l_word);
b = buf + strlen(buf);
i++;
if (i == width) {
free(li->l_word);
li->l_word = CopyString(buf);
li = li->l_next;
b = buf;
i = 0;
}
}
if (i) {
free(li->l_word);
li->l_word = CopyString(buf);
}
if (li->l_next) list_free(li->l_next);
li->l_next = alloc(list);
li = li->l_next;
if (li == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
/* add a blank line */
li->l_word = CopyString(" ");
li->l_next = NULL;
free(buf);
}
static void
display_lines(wl)
/* print the list, using MORE mode */
struct list *wl;
{
EnableMore(True);
for (; wl; wl = wl->l_next)
if (MoreLine(wl->l_word)) break;
MorePageDisplay();
ShowPrompt("Hit any key to continue.");
EnableMore(False);
(void)FBGetchar(ERASE);
}
static void
list_free(wl)
struct list *wl;
{
struct list *nw;
for (; wl; wl = nw) {
nw = wl->l_next;
free(wl->l_word);
afree(wl,list);
}
return;
}
static void
list_sort(wl)
/* alphabetically sort the list */
struct list *wl;
{
int i = 0;
struct list *ww;
char **stuff;
for (i = 0, ww = wl; ww; i++, ww = ww->l_next) ;
if (i < 2)
return;
stuff = (char **) tmalloc(i * sizeof (char *));
for (i = 0, ww = wl; ww; i++, ww = ww->l_next)
stuff[i] = ww->l_word;
qsort((char *) stuff, i, sizeof (char *), lcomp);
for (i = 0, ww = wl; ww; i++, ww = ww->l_next)
ww->l_word = stuff[i];
free(stuff);
return;
}
static int
lcomp(s, t)
#ifdef __STDC__
const void *s;
const void *t;
#else
char **s, **t;
#endif
{
return (strcmp(*(char**)s,*(char**)t));
}
static int
is_symfile(buf)
/* return True if a symbol file */
char *buf;
{
if (buf[0] != '(') return (False);
if ((buf[1] != ' ') && (buf[1] != 'S')) return (False);
if ((buf[2] != 'S') && (buf[2] != 'y') && (buf[2] != 'V')) return (False);
if ((buf[3] != 'y') && (buf[3] != 'm') && (buf[3] != 'E')) return (False);
if ((buf[4] != 'm') && (buf[4] != 'b') && (buf[4] != 'R')) return (False);
if ((buf[5] != 'b') && (buf[5] != 'o') && (buf[5] != 'S')) return (False);
if ((buf[6] != 'o') && (buf[6] != 'l') && (buf[6] != 'I')) return (False);
return (True);
}
#ifdef MSDOS
#define DIR_TERM '\\'
#else
#define DIR_TERM '/'
#endif
static struct list *
symfiles(dir)
char *dir;
{
DIR *wdir;
struct direct *de;
struct list *wl = NULL, *wl0 = NULL;
char buf[256];
FILE *fp;
int i;
if (!(wdir = opendir(dir)))
return (NULL);
while ((de = readdir(wdir)) != (struct direct *)NULL) {
sprintf(buf,"%s%c%s",dir,DIR_TERM,de->d_name);
fp = fopen(buf,"r");
if (fp == NULL)
continue;
/* is it a symbol file? */
for (i = 0; i <7; i++)
buf[i] = getc(fp);
buf[i] = '\0';
fclose(fp);
if (!is_symfile(buf))
continue;
if (wl0 == NULL) {
wl = wl0 = alloc(list);
}
else {
wl->l_next = alloc(list);
wl = wl->l_next;
}
wl->l_word = CopyString(de->d_name);
wl->l_next = NULL;
}
closedir(wdir);
return (wl0);
}
#if __NDPC__
DIR *
opendir(dir)
char *dir;
{
struct find_t *d;
char buf[128];
strcpy(buf,dir);
if (*buf == '\\' && *(buf+1) == '\0')
strcat(buf,"*.*");
else
strcat(buf,"\\*.*");
d = (struct find_t *) malloc(sizeof(struct find_t));
if (d == NULL) return NULL;
if (findfirst(buf,d,0x1f)) {
free(d);
return (NULL);
}
return ((DIR *) d);
}
struct direct *
readdir(d)
DIR *d;
{
char *c;
static struct direct dd;
int i;
if (d == NULL) return NULL;
strcpy(dd.d_name,((struct find_t *)d)->name);
for (c = dd.d_name; *c; c++)
if (isupper(*c)) *c = tolower(*c);
if (findnext((struct find_t *)d))
return (NULL);
return (&dd);
}
void
closedir(d)
DIR *d;
{
if (d)
free(d);
}
#endif
kic-2.4c/src/kic/sline.c 0000644 0000764 0000764 00000003431 12427444526 014542 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/* Superconducting Microstripline Model */
#include "sline.h"
#include
#include
#define EP 8.85416e-6
#define MU 1.256637
#ifndef PI
#define PI 3.1415926
#endif
#define atanh(x) log(((x)+1)/(1-(x)))/2
#define MAX(x,y) (((x)>(y)) ? (x) : (y))
void
sline(struct params *tl, struct output *out)
{
double p, pp, eta, lnra, rb, rb0;
double cap, zz, gind, kappa, aa;
p = 1 + tl->lthick/tl->dthick;
p = 2*p*p - 1;
p += sqrt(p*p - 1);
pp = sqrt(p);
aa = (p+1)/(2*pp);
eta = aa * (1 + log(4/(p-1))) - 2*atanh(1/pp);
eta = pp * (PI*tl->lwidth/(2*tl->dthick) + eta);
rb0 = eta + aa * log(MAX(p,eta));
if (tl->lwidth/tl->dthick >= 5)
rb = rb0;
else {
rb = -sqrt((rb0-1)*(rb0-p));
rb += (p+1)* atanh(sqrt((rb0-p)/(rb0-1)));
rb -= 2*pp * atanh(sqrt((rb0-p)/p/(rb0-1)));
rb += rb0 + pp*(PI*tl->lwidth)/2/tl->dthick;
/*
if (tl->lwidth/tl->dthick < 1) help(3);
*/
}
lnra = -2*aa * atanh(1/pp);
lnra -= 1 + (PI*tl->lwidth)/2/tl->dthick + log((p-1)/4/p);
kappa = 2*tl->dthick * (log(2*rb) - lnra)/tl->lwidth/PI;
cap = kappa*tl->lwidth*EP*tl->dielcon / tl->dthick;
gind = tl->ldepth * (1/tanh(tl->lthick/tl->ldepth) +
2*pp/rb /sinh(tl->lthick/tl->ldepth));
gind += tl->gpdepth / tanh(tl->gpthick/tl->gpdepth);
gind = MU/tl->lwidth/kappa * (tl->dthick + gind);
zz = sqrt(gind / cap);
out->L = gind*tl->llength;
out->C = cap*tl->llength;
out->Z = zz;
out->T = sqrt(gind*cap)*tl->llength;
}
kic-2.4c/src/kic/delete.c 0000644 0000764 0000764 00000005352 07525346713 014700 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Delete selection operator.
*/
#include "prefix.h"
#include "kic.h"
#ifdef __STDC__
static void do_delete(int,struct ka*);
#else
static void do_delete();
#endif
extern char *MenuDELET;
extern char *MenuUNDO;
void
Del(LookedAhead)
int *LookedAhead;
{
struct ks *SQDesc;
int Info = SQ_GONE;
MenuSelect(MenuDELET);
if (SelectQHead == NULL) {
ShowPrompt("There are no selected objects to delete.");
MenuDeselect(MenuDELET);
return;
}
SQComputeBB();
/* take care of instance markers */
SelectQBB.kaRight += 600;
SelectQBB.kaLeft -= 600;
SelectQBB.kaTop += 600;
SelectQBB.kaBottom -= 600;
do_delete(SQ_GONE,&SelectQBB);
MenuDeselect(MenuDELET);
top:
switch (PointLoop(LookedAhead)) {
case PL_UND:
MenuSelect(MenuUNDO);
if (Info == SQ_GONE) Info = SQ_OLDSEL;
else Info = SQ_GONE;
do_delete(Info,&SelectQBB);
MenuDeselect(MenuUNDO);
case PL_ESC:
case PL_PCW:
goto top;
case PL_CMD:
break;
}
if (Info == SQ_GONE) {
struct ks *SQNext;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
SQDesc->ksPointer->oInfo = SQ_OLD;
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
afree(SQDesc,ks);
}
SelectQHead = NULL;
SelectQBB.kaLeft = SelectQBB.kaBottom =
SelectQBB.kaRight = SelectQBB.kaTop = 0;
Parameters.kpModified = True;
}
else
SQComputeBB();
}
static void
do_delete(Info,BB)
int Info;
struct ka *BB;
{
struct ks *SQDesc;
/*
* Change Info field and redisplay.
*/
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc)
SQDesc->ksPointer->oInfo = Info;
EraseBox(BB);
Redisplay(BB);
FBTransfer();
}
kic-2.4c/src/kic/erase.c 0000644 0000764 0000764 00000016153 07525346713 014536 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/*
* Erase operator.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuERASE;
extern char *MenuUNDO;
#ifdef __STDC__
static void do_erase(struct ks*,struct ka*);
static void sq_swap(void);
static void erase_poly(struct o*,struct ka*);
#else
static void do_erase();
static void sq_swap();
static void erase_poly();
#endif
void
Erase(LookedAhead)
int *LookedAhead;
{
struct ka BB, SBB;
struct ks *SList;
int Xfirst = 0,Yfirst = 0;
int Undo = False;
int Modified = 0;
int FirstTime = True;
char TTmp[8];
char Types[4];
MenuSelect(MenuERASE);
Types[0] = CDBOX;
Types[1] = CDPOLYGON;
Types[3] = '\0';
strcpy(TTmp,Parameters.kpSelectTypes);
strcpy(Parameters.kpSelectTypes,Types);
ShowPrompt("Point to diagonal of rectangle to erase.");
top:
loop {
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime)
goto quit;
sq_swap();
EraseBox(&SBB);
Redisplay(&SBB);
FBTransfer();
if (Undo) {
Undo = False;
Modified++;
}
else {
Undo = True;
Modified--;
}
continue;
case PL_PCW:
Xfirst = KicCursor.kcX;
Yfirst = KicCursor.kcY;
FBSetRubberBanding('r');
break;
}
loop {
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
FBSetRubberBanding(0);
goto top;
case PL_PCW:
if (KicCursor.kcX == Xfirst &&
KicCursor.kcY == Yfirst) continue;
FBSetRubberBanding(0);
break;
}
break;
}
BB.kaLeft = min(Xfirst,KicCursor.kcX);
BB.kaRight = max(Xfirst,KicCursor.kcX);
BB.kaBottom = min(Yfirst,KicCursor.kcY);
BB.kaTop = max(Yfirst,KicCursor.kcY);
SList = SelectItems(&BB,False);
if (SList == NULL) continue;
SLBB(SList,&SBB);
SQRestore(False);
do_erase(SList,&BB);
SLFree(SList);
EraseBox(&SBB);
Redisplay(&SBB);
FBTransfer();
Modified++;
Undo = False;
FirstTime = False;
}
quit:
FBSetRubberBanding(0);
strcpy(Parameters.kpSelectTypes,TTmp);
SQRestore(False);
MenuDeselect(MenuERASE);
ErasePrompt();
if (Modified)
Parameters.kpModified = True;
}
void
NewBox(L,B,R,T,Layer)
int L,B,R,T;
int Layer;
{
int X,Y,DX,DY;
struct o *Pointer;
X = (L+R)/2;
Y = (B+T)/2;
DX = R-L;
DY = T-B;
if (DX < 0) DX = -DX;
if (DY < 0) DY = -DY;
if (CDMakeBox(Parameters.kpCellDesc,Layer,DX,DY,
X,Y,&Pointer) == 0) MallocFailed();
Pointer->oInfo = SQ_NEW;
SQInsert(Pointer);
}
void
NewPoly(p,Layer)
Poly *p;
int Layer;
{
struct p *pp,*Path;
struct o *NewPointer = NULL;
int *xy;
int i,n;
xy = p->xy;
Path = pp = alloc(p);
pp->pX = *xy++;
pp->pY = *xy++;
n = p->nvertices - 1;
for (i = 0; i < n; i++) {
pp->pSucc = alloc(p);
pp = pp->pSucc;
pp->pX = *xy++;
pp->pY = *xy++;
}
pp->pSucc = NULL;
if (Not CDMakePolygon(Parameters.kpCellDesc,Layer,Path,&NewPointer))
MallocFailed();
if (NewPointer) {
NewPointer->oInfo = SQ_NEW;
SQInsert(NewPointer);
}
}
static void
do_erase(SList,BB)
struct ks *SList;
struct ka *BB;
{
struct ks *SQDesc;
char Type;
int X,Y,Length,Width;
int Layer;
struct ka BoxBB;
for (SQDesc = SList; SQDesc; SQDesc = SQDesc->ksSucc) {
Type = SQDesc->ksPointer->oType;
/* ignore selected objects */
if (SQDesc->ksPointer->oInfo == SQ_OLDSEL) continue;
if (Type == CDBOX) {
CDBox(SQDesc->ksPointer,&Layer,&Length,&Width,&X,&Y);
BoxBB.kaLeft = X - Length/2;
BoxBB.kaRight = X + Length/2;
BoxBB.kaTop = Y + Width/2;
BoxBB.kaBottom = Y - Width/2;
if (BoxBB.kaBottom >= BB->kaTop) continue;
if (BoxBB.kaTop <= BB->kaBottom) continue;
if (BoxBB.kaRight <= BB->kaLeft) continue;
if (BoxBB.kaLeft >= BB->kaRight) continue;
SQDesc->ksPointer->oInfo = SQ_GONE;
SQInsert(SQDesc->ksPointer);
Layer = SQDesc->ksPointer->oLayer;
if (BoxBB.kaTop > BB->kaTop) {
NewBox(BoxBB.kaLeft,BB->kaTop,
BoxBB.kaRight,BoxBB.kaTop,Layer);
BoxBB.kaTop = BB->kaTop;
}
if (BoxBB.kaBottom < BB->kaBottom) {
NewBox(BoxBB.kaLeft,BoxBB.kaBottom,
BoxBB.kaRight,BB->kaBottom,Layer);
BoxBB.kaBottom = BB->kaBottom;
}
if (BoxBB.kaLeft < BB->kaLeft) {
NewBox(BoxBB.kaLeft,BoxBB.kaBottom,
BB->kaLeft,BoxBB.kaTop,Layer);
}
if (BoxBB.kaRight > BB->kaRight) {
NewBox(BB->kaRight,BoxBB.kaBottom,
BoxBB.kaRight,BoxBB.kaTop,Layer);
}
continue;
}
if (Type == CDPOLYGON) {
erase_poly(SQDesc->ksPointer,BB);
continue;
}
}
}
static void
sq_swap()
{
struct ks *S;
for (S = SelectQHead; S != NULL; S = S->ksSucc) {
if (S->ksPointer->oInfo == SQ_GONE) {
S->ksPointer->oInfo = SQ_NEW;
continue;
}
if (S->ksPointer->oInfo == SQ_NEW)
S->ksPointer->oInfo = SQ_GONE;
}
}
static void
erase_poly(Pointer,NewBB)
struct o *Pointer;
struct ka *NewBB;
{
int i;
struct p *path, *pp;
struct ka BB;
Poly p1,p2;
int *xy;
path = ((struct po *)Pointer->oRep)->poPath;
for (i = 0, pp = path; pp; i++,pp = pp->pSucc) ;
p1.nvertices = i;
p1.xy = (int*) tmalloc(i*10*sizeof(int));
p2.xy = p1.xy + 2*i;
xy = p1.xy;
for (pp = path; pp; pp = pp->pSucc) {
*xy++ = pp->pX;
*xy++ = pp->pY;
}
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,&BB.kaLeft,
&BB.kaBottom,&BB.kaRight,&BB.kaTop);
Pointer->oInfo = SQ_GONE;
SQInsert(Pointer);
PolygonClip(&p1,BB.kaLeft,NewBB->kaTop,BB.kaRight,BB.kaTop);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
PolygonClip(&p1,BB.kaLeft,BB.kaBottom,BB.kaRight,NewBB->kaBottom);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
PolygonClip(&p1,BB.kaLeft,NewBB->kaBottom,
NewBB->kaLeft,NewBB->kaTop);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
PolygonClip(&p1,NewBB->kaRight,NewBB->kaBottom,
BB.kaRight,NewBB->kaTop);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
free(p1.xy);
}
kic-2.4c/src/kic/instance.c 0000644 0000764 0000764 00000032375 07525346713 015247 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* KIC instance menu.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuPLACE;
extern char *MenuLLREF;
extern char *MenuUNDO;
extern char *MenuARRAY;
extern char *MenuCRSYM;
#define Mtest(zap) if((zap) == 0) MallocFailed()
struct rd {
struct s *Desc;
char Name[82];
};
static struct rd CurInstance;
#ifdef __STDC__
static int locate_array(int*);
static struct o *make_array(int,int);
#else
static int locate_array();
static struct o *make_array();
#endif
void
Place(LookedAhead)
int *LookedAhead;
{
char *TypeIn;
MenuSelect(MenuPLACE);
sprintf(TypeOut,"Current master cell is %s. New master? ",
*CurInstance.Name == '\0' ? "unspecified" : CurInstance.Name);
ShowPrompt(TypeOut);
TypeIn = FBEdit(CurInstance.Name);
if (TypeIn == NULL) {
ErasePrompt();
MenuDeselect(MenuPLACE);
return;
}
else {
if (*TypeIn != '\0' && *TypeIn != '\n')
strcpy(CurInstance.Name,TypeIn);
if (*CurInstance.Name == '\0') {
MenuDeselect(MenuPLACE);
return;
}
}
/* strip off any path prefix */
if (FixCellName(CurInstance.Name)) {
ShowPromptAndWait("Warning: internal path overflow");
}
if (OpenCell(CurInstance.Name,&CurInstance.Desc)) {
ShowPrompt("Bad subcell name, not found or error.");
*CurInstance.Name = '\0';
MenuDeselect(MenuPLACE);
return;
}
ShowPrompt("Point to locations to place cell.");
if (locate_array(LookedAhead))
Parameters.kpModified = True;
ErasePrompt();
MenuDeselect(MenuPLACE);
}
static int
locate_array(LookedAhead)
int *LookedAhead;
{
struct o *Pointer = NULL;
struct ka BB;
int X = 0,Y = 0;
int Undo = False;
int modified = 0;
FBSetRubberBanding('p');
loop {
switch (PointLoop(LookedAhead)) {
case PL_CMD:
case PL_ESC:
goto quit;
case PL_UND:
*LookedAhead = False;
if (Pointer == NULL)
continue;
MenuSelect(MenuUNDO);
if (Undo == False) {
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
EraseBox(&BB);
CDDelete(Parameters.kpCellDesc,Pointer);
Redisplay(&BB);
modified--;
Undo = True;
}
else {
FBSetRubberBanding(0);
Pointer = make_array(X,Y);
FBSetRubberBanding('p');
modified++;
Undo = False;
}
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
X = KicCursor.kcX;
Y = KicCursor.kcY;
FBSetRubberBanding(0);
Pointer = make_array(X,Y);
FBSetRubberBanding('p');
modified++;
Undo = False;
continue;
}
}
quit:
FBSetRubberBanding(0);
return (modified);
}
void
Handle()
{
if (Parameters.kpSubrefLowerLeft) {
Parameters.kpSubrefLowerLeft = False;
MenuDeselect(MenuLLREF);
}
else {
Parameters.kpSubrefLowerLeft = True;
MenuSelect(MenuLLREF);
}
}
/* ARGSUSED */
void
ShowNewInstance(X,Y,RefX,RefY)
int X,Y,RefX,RefY;
{
struct ka BB, BB1;
int TFold[9];
int XX,YY;
int DX,DY;
int NumX,NumY,Int1,Int2;
TCurrent(TFold);
NumX = Parameters.kpNumX;
NumY = Parameters.kpNumY;
DX = Parameters.kpDX;
DY = Parameters.kpDY;
CDBB(CurInstance.Desc,(struct o *)NULL,&BB.kaLeft,
&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (Parameters.kpSubrefLowerLeft) {
XX = BB.kaLeft;
YY = BB.kaBottom;
}
else {
XX = 0;
YY = 0;
}
TPush();
TIdentity();
SetNewTransform(XX,YY,X,Y);
TPremultiply();
for (Int1 = NumY-1; Int1 >= 0; --Int1) {
for (Int2 = 0; Int2 < NumX; ++Int2 ){
TPush();
TIdentity();
TTranslate(Int2*DX,Int1*DY);
TPremultiply();
BB1.kaLeft = BB.kaLeft;
BB1.kaRight = BB.kaRight;
BB1.kaBottom = BB.kaBottom;
BB1.kaTop = BB.kaTop;
TPoint(&BB1.kaLeft,&BB1.kaBottom);
TPoint(&BB1.kaRight,&BB1.kaTop);
TLoadCurrent(TFold);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB1);
TPop();
}
}
TPop();
}
void
MakeInstance(LookedAhead,name)
int *LookedAhead;
char *name;
{
int NumX,NumY;
char buf[82];
struct s *stmp;
NumX = Parameters.kpNumX;
NumY = Parameters.kpNumY;
strcpy(buf,CurInstance.Name);
stmp = CurInstance.Desc;
Parameters.kpNumX = 1;
Parameters.kpNumY = 1;
strcpy(CurInstance.Name,name);
if (OpenCell(CurInstance.Name,&CurInstance.Desc)) {
ShowPrompt("Bad subcell name, not found or error.");
}
else {
if (locate_array(LookedAhead))
Parameters.kpModified = True;
}
Parameters.kpNumX = NumX;
Parameters.kpNumY = NumY;
strcpy(CurInstance.Name,buf);
CurInstance.Desc = stmp;
}
static struct o*
make_array(X,Y)
int X,Y;
{
struct o *Pointer;
struct ka BB;
int NumX,NumY;
int L,R,T,B;
double DX,DY;
/*
* Create instance array.
*/
NumX = Parameters.kpNumX;
NumY = Parameters.kpNumY;
DX = Parameters.kpDX;
DY = Parameters.kpDY;
CDBB(CurInstance.Desc,(struct o *)NULL,&L,&B,&R,&T);
if (Not CDBeginMakeCall(Parameters.kpCellDesc,CurInstance.Name,NumX,
R-L+DX*RESOLUTION,NumY,T-B+DY*RESOLUTION,&Pointer)) {
MallocFailed();
}
if (Parameters.kpSubrefLowerLeft) {
/* Translation so cell is always placed with lower left corner
* at reference point.
*/
Mtest(CDT(Pointer,CDTRANSLATE,-L,-B));
}
if (Parameters.kpMX) {
Mtest(CDT(Pointer,CDMIRRORX,0L,0L));
}
if (Parameters.kpMY) {
Mtest(CDT(Pointer,CDMIRRORY,0L,0L));
}
if (Parameters.kpRotationAngle == 90) {
Mtest(CDT(Pointer,CDROTATE,0L,1L));
}
elif (Parameters.kpRotationAngle == 180) {
Mtest(CDT(Pointer,CDROTATE,-1L,0L));
}
elif (Parameters.kpRotationAngle == 270) {
Mtest(CDT(Pointer,CDROTATE,0L,-1L));
}
if (X || Y)
Mtest(CDT(Pointer,CDTRANSLATE,X,Y));
Mtest(CDEndMakeCall(Parameters.kpCellDesc,Pointer));
/* CDBB will always return True if Pointer != NULL */
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
EraseBox(&BB);
Redisplay(&BB);
return (Pointer);
}
void
GetArraySpec()
{
char *TypeIn;
MenuSelect(MenuARRAY);
sprintf(TypeOut,"Number X? (currently %d): ",Parameters.kpNumX);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
sscanf(TypeIn,"%d",&Parameters.kpNumX);
if (Parameters.kpNumX < 1 Or Parameters.kpNumX > 1000) {
ShowPromptAndWait("Sorry, outside range 1 - 1000, set to 1.");
Parameters.kpNumX = 1;
}
sprintf(TypeOut,"Number Y? (currently %d): ",Parameters.kpNumY);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
sscanf(TypeIn,"%d",&Parameters.kpNumY);
if (Parameters.kpNumY < 1 Or Parameters.kpNumY > 1000) {
ShowPromptAndWait("Sorry, outside range 1 - 1000, set to 1.");
Parameters.kpNumY = 1;
}
if (Parameters.kpNumX > 1 Or Parameters.kpNumY > 1) {
sprintf(TypeOut,"X Spacing? (currently %g): ",Parameters.kpDX);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
sscanf(TypeIn,"%lg",&Parameters.kpDX);
sprintf(TypeOut,"Y Spacing? (currently %g): ",Parameters.kpDY);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn != NULL)
sscanf(TypeIn,"%lg",&Parameters.kpDY);
}
ErasePrompt();
MenuDeselect(MenuARRAY);
}
void
NewSymbol()
/*
* Create a new symbol from the contents of the selection queue.
*/
{
struct ks *SQDesc;
struct o *Pointer;
struct t *TGen;
struct p *Path;
FILE *FileDesc;
char *TypeIn;
char *Label;
char Type,Xform;
char *SymbolName;
int Layer, new;
int NumX,NumY;
int X,Y,DX,DY,Width,Length;
int Xo, Yo;
MenuSelect(MenuCRSYM);
if (SelectQHead == NULL) {
ShowPrompt("Objects must be selected first.");
MenuDeselect(MenuCRSYM);
return;
}
ShowPrompt("Name of new symbol? ");
if ((TypeIn = FBEdit(NULL)) == NULL Or *TypeIn == EOS) {
ErasePrompt();
MenuDeselect(MenuCRSYM);
return;
}
if ((FileDesc = POpen(TypeIn,"w",(char *)NULL,(char **)NULL)) == NULL) {
sprintf(TypeOut,"Can't create symbol %s.",TypeIn);
ShowPrompt(TypeOut);
MenuDeselect(MenuCRSYM);
return;
}
SQComputeBB();
/* The new cell origin will be the lower left corner */
Xo = SelectQBB.kaLeft;
Yo = SelectQBB.kaBottom;
fprintf(FileDesc,"(Symbol %s);\n",TypeIn);
fprintf(FileDesc,"9 %s;\n",TypeIn);
GenBeginSymbol(FileDesc,0,1L,1L);
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
Pointer = SQDesc->ksPointer;
if (Pointer->oType == CDSYMBOLCALL) {
CDCall(Pointer,&SymbolName,&NumX,&DX,&NumY,&DY);
/* add symbol name extension */
fprintf(FileDesc,"9 %s;\n",SymbolName);
/* forget about property list info */
/* add symbol array extension */
if (NumX != 1 Or NumY != 1)
fprintf(FileDesc,"1 Array %d %d %d %d;\n",NumX,DX,NumY,DY);
fprintf(FileDesc,"C 0");
CDInitTGen(Pointer,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL) {
fprintf(FileDesc,";\n");
break;
}
elif (Type == CDROTATE)
fprintf(FileDesc," R %d %d",X,Y);
elif (Type == CDTRANSLATE)
fprintf(FileDesc," T %d %d",X-Xo,Y-Yo);
elif (Type == CDMIRRORX)
fprintf(FileDesc," MX");
elif (Type == CDMIRRORY)
fprintf(FileDesc," MY");
}
}
}
new = True;
for (Layer = 1; Layer <= CDNUMLAYERS; ++Layer, new = True) {
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
Pointer = SQDesc->ksPointer;
if (Pointer->oLayer == Layer) {
if (new) {
GenLayer(FileDesc,CDLayer[Layer].lTechnology,
CDLayer[Layer].lMask);
new = False;
}
Type = Pointer->oType;
if (Type == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
GenWireOffset(FileDesc,Width,Path,Xo,Yo);
}
elif (Type == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
GenPolygonOffset(FileDesc,Path,Xo,Yo);
}
elif (Type == CDLABEL) {
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
fprintf(FileDesc,"94 %s %d %d %d",Label,
X-Xo,Y-Yo,Xform);
fprintf(FileDesc,";\n");
}
elif (Type == CDBOX) {
CDBox(Pointer,&Layer,&Length,&Width,&X,&Y);
GenBox(FileDesc,Length,Width,X-Xo,Y-Yo,1,0);
}
}
}
}
GenEndSymbol(FileDesc);
GenEnd(FileDesc);
fclose(FileDesc);
sprintf(TypeOut,"New symbol %s created and saved.",TypeIn);
MenuDeselect(MenuCRSYM);
ShowPrompt(TypeOut);
}
int
OpenCell(Master,MasterDesc)
char *Master;
struct s **MasterDesc;
{
if (Not CDOpen(Master,MasterDesc,'r')) {
if (CDStatusInt == CDPARSEFAILED) {
sprintf(TypeOut,"Can't display cell %s. MORE",Master);
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
ShowPrompt(CDStatusString);
}
if (CDStatusInt == CDMALLOCFAILED)
MallocFailed();
return (True);
}
if (CDStatusInt == CDNEWSYMBOL) {
sprintf(TypeOut,
"Can't display cell %s, because it doesn't seem to be around.",
Master);
ShowPrompt(TypeOut);
return (True);
}
return (False);
}
kic-2.4c/src/kic/labels.c 0000644 0000764 0000764 00000021566 07525346713 014705 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* KIC label management.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuLABEL;
extern char *MenuUNDO;
/* Label transform field:
* bits 0-1 : 0-no rotation, 1-90, 2-180, 3-270
* bit 2 : mirror y
* bit 3 : mirror x
*/
#ifdef __STDC__
static void redisplay_label(struct o*);
static void delete_label(struct o*);
static char get_current_xform(void);
#else
static void redisplay_label();
static void delete_label();
static char get_current_xform();
#endif
void
Label(LookedAhead)
int *LookedAhead;
{
struct o *Pointer;
char *c,*Label = NULL;
int NumLabelsMade = 0;
int X = 0,Y = 0;
MenuSelect(MenuLABEL);
ShowPrompt("Enter label: ");
Label = FBEdit(NULL);
if (Label == NULL Or *Label == '\0')
goto quit;
for (c = Label; *c; c++)
if (isspace(*c)) *c = '_';
loop {
ShowPrompt("Point to where you want the label.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (NumLabelsMade == 0)
goto quit;
MenuSelect(MenuUNDO);
delete_label(Pointer);
NumLabelsMade--;
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
X = KicCursor.kcX;
Y = KicCursor.kcY;
if (Not CDMakeLabel(Parameters.kpCellDesc,Parameters.kpLayer,
Label,X,Y,get_current_xform(),&Pointer)) MallocFailed();
redisplay_label(Pointer);
NumLabelsMade++;
}
}
quit:
if (NumLabelsMade > 0)
Parameters.kpModified = True;
MenuDeselect(MenuLABEL);
ErasePrompt();
}
void
BBLabel(Window,Pointer,BB)
/* Return the effective BB of the label as seen in Window. */
struct ka *Window;
struct o *Pointer;
struct ka *BB;
{
struct la *LDesc;
int Len,Hei;
char Xform;
LDesc = (struct la *)Pointer->oRep;
Xform = LDesc->laXform;
FBTextBB(LDesc->laLabel,&Len,&Hei);
if (Parameters.kpDoingHardcopy) {
Len *= Parameters.kpHardcopyTextScale;
Hei *= Parameters.kpHardcopyTextScale;
}
if (Window == View->kvCoarseWindow) {
Len /= View->kvCoarseRatio;
Hei /= View->kvCoarseRatio;
}
else {
Len /= View->kvFineRatio;
Hei /= View->kvFineRatio;
}
BB->kaLeft = LDesc->laX;
BB->kaBottom = LDesc->laY;
if (Xform & 1) {
if (Xform & 2) {
if (!(Xform & 4))
BB->kaBottom -= Len;
if (Xform & 8)
BB->kaLeft -= Hei;
}
else {
if (!(Xform & 8))
BB->kaLeft -= Hei;
if (Xform & 4)
BB->kaBottom -= Len;
}
BB->kaRight = BB->kaLeft + Hei;
BB->kaTop = BB->kaBottom + Len;
}
else {
if (Xform & 2) {
if (!(Xform & 8))
BB->kaLeft -= Len;
if (!(Xform & 4))
BB->kaBottom -= Hei;
}
else {
if (Xform & 8)
BB->kaLeft -= Len;
if (Xform & 4)
BB->kaBottom -= Hei;
}
BB->kaRight = BB->kaLeft + Len;
BB->kaTop = BB->kaBottom + Hei;
}
}
void
CDLabelBB(Pointer,L,B,R,T)
/* called from CD */
struct o *Pointer;
int *L,*B,*R,*T;
{
struct ka BB;
BBLabel(View->kvCoarseWindow,Pointer,&BB);
*L = BB.kaLeft;
*B = BB.kaBottom;
*R = BB.kaRight;
*T = BB.kaTop;
}
void
ShowLabel(Layer,Label,X,Y,Xform,Flag)
int Layer;
char *Label;
int X,Y;
int Xform;
int Flag; /* If Flag, label is always displayed */
{
int TF[9],XT,YT;
char *c;
TPoint(&X,&Y);
/* have to fix transform */
TPush();
TIdentity();
if (Xform & 4) TMY();
if (Xform & 8) TMX();
Xform &= 3;
if (Xform != 0) {
if (Xform == 1) TRotate(0L,1L);
elif (Xform == 2) TRotate(-1L,0L);
elif (Xform == 3) TRotate(0L,-1L);
}
TPremultiply();
TCurrent(TF);
Xform = SetXform(TF);
TPop();
strcpy(TypeOut,Label);
c = TypeOut;
while ((c = strchr(c,'_')) != NULL) *c = ' ';
FBForeground(DISPLAY,Layer);
FBSetFillPattern(0);
if ((Flag Or 1/View->kvCoarseRatio < HALFRESOLUTION) And
Parameters.kpRedisplayControl != FINEVIEWPORTONLY) {
CoarseLToP(X,Y,XT,YT);
FBSetTextClip(
View->kvCoarseViewport->kaLeft,
View->kvCoarseViewport->kaBottom,
View->kvCoarseViewport->kaRight,
View->kvCoarseViewport->kaTop);
if (Parameters.kpDoingHardcopy)
FBScaledText(TypeOut,XT,YT,Xform,
Parameters.kpHardcopyTextScale);
else
FBScaledText(TypeOut,XT,YT,Xform,1);
}
if (Parameters.kpRedisplayControl != COARSEVIEWPORTONLY) {
FineLToP(X,Y,XT,YT);
FBSetTextClip(
View->kvFineViewport->kaLeft,
View->kvFineViewport->kaBottom,
View->kvFineViewport->kaRight,
View->kvFineViewport->kaTop);
FBScaledText(TypeOut,XT,YT,Xform,1);
}
FBSetFillPattern(LayerTable[Layer].klStyleID);
FBSetTextClip(0,0,FB.fMaxX,FB.fMaxY);
}
char
SetXform(TF)
int *TF;
{
int A,B,C,D;
/*
* Take the transformation defined in TF and set
* the returned bit field accordingly.
*
* | a c 0 |
* Transform = TM = | b d 0 |
* | TX TY 1 |
*
* A = TM[0][0] = TF[0];
* B = TM[1][0] = TF[3];
* C = TM[0][1] = TF[1];
* D = TM[1][1] = TF[4];
* TX = TM[2][0] = TF[6];
* TY = TM[2][1] = TF[7];
*/
A = TF[0]; B = TF[3]; C = TF[1]; D = TF[4];
if (A == 0 && D == 0) {
if (B == 1 && C == 1) /* MX R 0 -1 */
return (11);
if (B == -1 && C == -1) /* MX R 0 1 */
return (9);
if (B == 1 && C == -1) /* R 0 -1 */
return (3);
if (B == -1 && C == 1) /* R 0 1 */
return (1);
}
if (B == 0 && C == 0) {
if (A == 1 && D == 1) /* translate only */
return (0);
if (A == -1 && D == -1) /* R -1 0 */
return (2);
if (A == -1 && D == 1) /* MX */
return (8);
}
/* MY */
return (4);
}
static void
redisplay_label(Pointer)
struct o *Pointer;
{
struct ka BB;
int OldRD;
if (Pointer->oType != CDLABEL) return;
OldRD = Parameters.kpRedisplayControl;
if (OldRD != FINEVIEWPORTONLY) {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
BBLabel(View->kvCoarseWindow,Pointer,&BB);
Redisplay(&BB);
}
if (OldRD != COARSEVIEWPORTONLY) {
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
BBLabel(View->kvFineWindow,Pointer,&BB);
Redisplay(&BB);
}
Parameters.kpRedisplayControl = OldRD;
}
static void
delete_label(Pointer)
struct o *Pointer;
{
struct ka BBC,BBF;
char OldRd;
if (Pointer->oType != CDLABEL) return;
OldRd = Parameters.kpRedisplayControl;
if (OldRd != FINEVIEWPORTONLY) {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
BBLabel(View->kvCoarseWindow,Pointer,&BBC);
TPoint(&BBC.kaLeft,&BBC.kaBottom);
TPoint(&BBC.kaRight,&BBC.kaTop);
EraseBox(&BBC);
}
if (OldRd != COARSEVIEWPORTONLY) {
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
BBLabel(View->kvFineWindow,Pointer,&BBF);
TPoint(&BBF.kaLeft,&BBF.kaBottom);
TPoint(&BBF.kaRight,&BBF.kaTop);
EraseBox(&BBF);
}
CDDelete(Parameters.kpCellDesc,Pointer);
if (OldRd != FINEVIEWPORTONLY) {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
Redisplay(&BBC);
}
if (OldRd != COARSEVIEWPORTONLY) {
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
Redisplay(&BBF);
}
Parameters.kpRedisplayControl = OldRd;
}
static char
get_current_xform()
{
char c;
c = (char)0;
c += Parameters.kpRotationAngle/90;
if (Parameters.kpMY) c |= 4;
if (Parameters.kpMX) c |= 8;
return (c);
}
kic-2.4c/src/kic/select.c 0000644 0000764 0000764 00000102512 11132464053 014674 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* The KIC selection code.
*
*
* The Selection code extensively uses the CD Info field. The following
* convention is used:
*
* Info = SQ_OLD (0) Object is unselected.
* *Info = SQ_OLDSEL (1) Object is selected and in SelectionQ.
* Info = SQ_GONE (2) Object is conditionally deleted and in SelectionQ.
* Info = SQ_NEW (3) Object is conditionally created and in SelectionQ.
* *Info = SQ_NEWSEL (4) Object is conditionally created and in SelectionQ.
* Info = SQ_INCMPLT (5) Object is being created.
*
* Info = 6-11 Reserved.
* *Info = 11-255 Object has conditionally new layer and is in
* SelectionQ. OldLayer = Info - 10.
*
* * means that SQShow will highlight these objects.
*
* Giles Billingsley
*/
#include "prefix.h"
#include "kic.h"
#ifdef __STDC__
static void redisplay_edges(struct ka*);
static struct ks *which_cell(struct ks*);
static void sq_set_NEW(struct o*);
static void sq_delete_dups(void);
static void sq_display_selected(struct o*);
static int is_point_in_poly(int,struct p*,int,int);
static int overlap_path(struct p*,struct ka*);
static int overlap_line(struct ka*,struct ka*);
static int cross_line(struct ka*,struct ka*);
#else
static void redisplay_edges();
static struct ks *which_cell();
static void sq_set_NEW();
static void sq_delete_dups();
static void sq_display_selected();
static int is_point_in_poly();
static int overlap_path();
static int overlap_line();
static int cross_line();
#endif
/***********************************************************************
*
* Current transform code.
*
***********************************************************************/
extern char *MenuMX;
extern char *MenuMY;
extern char *Menu0;
extern char *Menu90;
extern char *Menu180;
extern char *Menu270;
void
MX()
{
if (Parameters.kpMX) {
Parameters.kpMX = False;
MenuDeselect(MenuMX);
}
else {
Parameters.kpMX = True;
MenuSelect(MenuMX);
}
}
void
MY()
{
if (Parameters.kpMY) {
Parameters.kpMY = False;
MenuDeselect(MenuMY);
}
else {
Parameters.kpMY = True;
MenuSelect(MenuMY);
}
}
void
Rotat0()
{
Parameters.kpRotationAngle = 90;
AlterMenuEntries(Menu0,Menu90);
MenuSelect(Menu90);
}
void
Rotat90()
{
Parameters.kpRotationAngle = 180;
AlterMenuEntries(Menu90,Menu180);
MenuSelect(Menu180);
}
void
Rotat180()
{
Parameters.kpRotationAngle = 270;
AlterMenuEntries(Menu180,Menu270);
MenuSelect(Menu270);
}
void
Rotat270()
{
Parameters.kpRotationAngle = 0;
AlterMenuEntries(Menu270,Menu0);
MenuDeselect(Menu0);
}
/***********************************************************************
*
* Selection operator code.
*
***********************************************************************/
extern char *MenuAREA;
extern char *MenuDESEL;
extern char *MenuSELEC;
extern char *MenuLAYER;
extern char *MenuUNDO;
struct ka SelectQBB;
struct ks *SelectQHead;
#define UpdateBB(BB2,BB1) \
if (BB1.kaLeft < BB2.kaLeft) BB2.kaLeft = BB1.kaLeft; \
if (BB1.kaBottom < BB2.kaBottom) BB2.kaBottom = BB1.kaBottom; \
if (BB1.kaRight > BB2.kaRight) BB2.kaRight = BB1.kaRight; \
if (BB1.kaTop > BB2.kaTop) BB2.kaTop = BB1.kaTop;
void
Sel(LookedAhead)
int *LookedAhead;
{
struct ka AOI;
int FirstTime = True;
MenuSelect(MenuSELEC);
ShowPrompt("Point to select.");
loop {
switch (PointLoop(LookedAhead)) {
case PL_CMD:
case PL_ESC:
goto quit;
case PL_UND:
if (FirstTime == True) goto quit;
MenuSelect(MenuUNDO);
Selection(&AOI);
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
AOI.kaLeft = AOI.kaRight = KicCursor.kcRawX;
AOI.kaBottom = AOI.kaTop = KicCursor.kcRawY;
ErasePrompt();
Selection(&AOI);
FirstTime = False;
}
}
quit:
MenuDeselect(MenuSELEC);
ErasePrompt();
}
void
Area(LookedAhead)
int *LookedAhead;
{
struct ka AOI;
int OldRawX = 0,OldRawY = 0;
int FirstTime = True;
MenuSelect(MenuAREA);
top:
loop {
ShowPrompt("Point to endpoints of diagonal.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime == True) goto quit;
MenuSelect(MenuUNDO);
Selection(&AOI);
MenuDeselect(MenuUNDO);
goto top;
case PL_PCW:
FBSetRubberBanding('R');
OldRawX = KicCursor.kcRawX;
OldRawY = KicCursor.kcRawY;
}
ShowPrompt("Point to second endpoint.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
FBSetRubberBanding(0);
goto top;
case PL_PCW:
FBSetRubberBanding(0);
break;
}
AOI.kaLeft = min(OldRawX,KicCursor.kcRawX);
AOI.kaBottom = min(OldRawY,KicCursor.kcRawY);
AOI.kaRight = max(OldRawX,KicCursor.kcRawX);
AOI.kaTop = max(OldRawY,KicCursor.kcRawY);
Selection(&AOI);
FirstTime = False;
}
quit:
FBSetRubberBanding(0);
MenuDeselect(MenuAREA);
ErasePrompt();
}
void
Desel()
{
MenuSelect(MenuDESEL);
SQComputeBB();
if (SelectQHead != NULL) {
SQClear();
/* Take care of Instance markers */
OversizeBox(&SelectQBB,200);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
MenuDeselect(MenuDESEL);
}
int
Layer()
{
if (strcmp(Parameters.kpCommand,MenuLAYER) == 0) {
if (Parameters.kpLayerSpecificSelection) {
MenuDeselect(MenuLAYER);
Parameters.kpLayerSpecificSelection = False;
}
else{
MenuSelect(MenuLAYER);
Parameters.kpLayerSpecificSelection = True;
}
return (True);
}
return (False);
}
void
Selection(AOI)
/* Select items and link into SelectionQ, compute BB. */
struct ka *AOI;
{
struct ks *SList, *S;
struct ka BB,OldSelectQBB;
if (AOI->kaLeft == AOI->kaRight) {
/* Point selection. */
SList = SelectItems(AOI,True);
if (SList == NULL) return;
if (SList->ksPointer->oType == CDSYMBOLCALL) {
/* no geometry found, get one symbol */
S = which_cell(SList);
if (S) {
if (S->ksPointer->oInfo == SQ_OLDSEL) {
/* already selected, deselect and break */
S->ksPointer->oInfo = SQ_OLD;
ShowInstanceMarker(ERASE,0,S->ksPointer);
SQDelete(S->ksPointer);
GetBB(S->ksPointer,&BB);
redisplay_edges(&BB);
}
else {
/* add to select Q */
S->ksPointer->oInfo = SQ_OLDSEL;
SQInsert(S->ksPointer);
sq_display_selected(S->ksPointer);
}
}
SQComputeBB();
SLFree(SList);
return;
}
for (S = SList; S != NULL; S = S->ksSucc) {
/* keep only geometry */
if (S->ksPointer->oType == CDSYMBOLCALL) break;
if (S->ksPointer->oInfo == SQ_OLDSEL) {
/* already selected, deselect and break */
S->ksPointer->oInfo = SQ_OLD;
SQDelete(S->ksPointer);
GetBB(S->ksPointer,&BB);
EraseBox(&BB);
Redisplay(&BB);
FBTransfer();
break;
}
else {
/* add to select Q */
S->ksPointer->oInfo = SQ_OLDSEL;
SQInsert(S->ksPointer);
sq_display_selected(S->ksPointer);
}
}
SQComputeBB();
}
else {
/* Area select. */
SList = SelectItems(AOI,False);
if (SList == NULL) return;
SQComputeBB();
OldSelectQBB = SelectQBB;
for (S = SList; S != NULL; S = S->ksSucc) {
if (S->ksPointer->oType == CDSYMBOLCALL &&
!BBVisible(S->ksPointer)) continue;
if (S->ksPointer->oInfo == SQ_OLDSEL) {
/* already selected, deselect */
S->ksPointer->oInfo = SQ_OLD;
SQDelete(S->ksPointer);
}
else {
/* add to select Q */
S->ksPointer->oInfo = SQ_OLDSEL;
SQInsert(S->ksPointer);
}
}
SQComputeBB();
UpdateBB(SelectQBB,OldSelectQBB);
if (SelectQBB.kaLeft == CDINFINITY) return;
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
FBTransfer();
}
SLFree(SList);
}
struct ks *
SelectItems(AOI,PointSelect)
/* Return a list of visible objects in the neighborhood of AOI as returned
* from the generator. Only types in Parameters.kpSelectTypes are listed,
* all are listed if this is NULL. The flag PointSelect is set for
* a point selection.
*/
struct ka *AOI;
int PointSelect;
{
struct g *GenDesc;
struct o *Pointer;
struct ka BB;
struct ks *SPointer = NULL, *S = NULL;
struct p *Path;
int Width;
int Delta = 0,Layer,Layer1;
if (PointSelect) {
/* expand the point to finite size */
if (KicCursor.kcInFine == True)
Delta = 3.0/View->kvFineRatio;
else
Delta = 3.0/View->kvCoarseRatio;
OversizeBox(AOI,Delta);
}
if (Parameters.kpLayerSpecificSelection) {
Layer = Parameters.kpLayer;
Layer1 = Layer;
}
else {
Layer = 1;
Layer1 = NumLayerTable;
}
for ( ; Layer <= Layer1; Layer++) {
if (!(LayerTable[Layer].klAttributes & VISIBLE)) continue;
if (Not CDInitGen(Parameters.kpCellDesc,Layer,AOI->kaLeft,AOI->kaBottom,
AOI->kaRight,AOI->kaTop,&GenDesc)) MallocFailed();
loop {
CDGen(Parameters.kpCellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
if (Pointer->oInfo == SQ_GONE) continue;
if (Pointer->oInfo == SQ_INCMPLT) continue;
if (Parameters.kpSelectTypes &&
!strchr(Parameters.kpSelectTypes,Pointer->oType)) continue;
switch (Pointer->oType) {
case CDWIRE:
CDWire(Pointer,&Layer,&Width,&Path);
if (PointSelect) {
if (InPath(Delta+Width/2,Path,
AOI->kaLeft+Delta,AOI->kaBottom+Delta) == NULL)
continue;
}
else {
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,
&BB.kaRight,&BB.kaTop);
if (InBox(BB.kaLeft,BB.kaBottom,AOI) &&
InBox(BB.kaRight,BB.kaTop,AOI))
/* wire is entirely inside AOI, select it */
break;
if (!overlap_path(Path,AOI)) continue;
/* wire overlaps AOI, select it */
}
break;
case CDPOLYGON:
CDPolygon(Pointer,&Layer,&Path);
if (PointSelect) {
if (!is_point_in_poly(Delta,Path,
AOI->kaLeft+Delta,AOI->kaBottom+Delta))
continue;
}
else {
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,
&BB.kaRight,&BB.kaTop);
if (InBox(BB.kaLeft,BB.kaBottom,AOI) &&
InBox(BB.kaRight,BB.kaTop,AOI))
/* poly is entirely inside AOI, select it */
break;
if (!is_point_in_poly(0,Path,
AOI->kaLeft,AOI->kaBottom))
if (!overlap_path(Path,AOI)) continue;
/* If an AOI corner is in the poly, select it.
* This catches the case where the AOI is
* entirely in the poly.
* Otherwise select poly only if the poly
* boundary intersects the AOI.
*/
}
break;
case CDLABEL:
case CDBOX:
break;
default:
continue;
}
if (SPointer == NULL)
S = SPointer = alloc(ks);
else {
S->ksSucc = alloc(ks);
S = S->ksSucc;
}
if (S == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
S->ksPointer = Pointer;
S->ksSucc = NULL;
}
}
/* Now for the instances... */
if (Parameters.kpSelectTypes &&
!strchr(Parameters.kpSelectTypes,CDSYMBOLCALL)) {
if (PointSelect) OversizeBox(AOI,-Delta);
return SPointer;
}
if (Not CDInitGen(Parameters.kpCellDesc,0,AOI->kaLeft,AOI->kaBottom,
AOI->kaRight,AOI->kaTop,&GenDesc)) MallocFailed();
loop {
CDGen(Parameters.kpCellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
if (Pointer->oInfo == SQ_GONE) continue;
if (SPointer == NULL)
S = SPointer = alloc(ks);
else {
S->ksSucc = alloc(ks);
S = S->ksSucc;
}
if (S == NULL) {
MallocFailed();
CDStatusInt = CDMALLOCFAILED;
}
S->ksPointer = Pointer;
S->ksSucc = NULL;
}
if (PointSelect) OversizeBox(AOI,-Delta);
return (SPointer);
}
void
SLFree(SList)
/* Free a list as returned from SelectItems(). */
struct ks *SList;
{
struct ks *SQDesc,*SQNext;
for (SQDesc = SList; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
afree(SQDesc,ks);
}
}
void
SLBB(SList,BB)
/* Compute the BB of the objects in SList. */
struct ks *SList;
struct ka *BB;
{
struct ks *S;
struct ka NBB,OBB;
NBB.kaLeft = CDINFINITY;
NBB.kaBottom = CDINFINITY;
NBB.kaRight = -CDINFINITY;
NBB.kaTop = -CDINFINITY;
NBB.kaHeight = 0;
NBB.kaWidth = 0;
NBB.kaX = 0;
NBB.kaY = 0;
for (S = SList; S != NULL; S = S->ksSucc) {
GetBB(S->ksPointer,&OBB);
UpdateBB(NBB,OBB);
}
*BB = NBB;
}
void
GetBB(Pointer,BB)
struct o *Pointer;
struct ka *BB;
{
if (Pointer->oType == CDLABEL)
BBLabel(View->kvCoarseWindow,Pointer,BB);
else
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,&BB->kaLeft,
&BB->kaBottom,&BB->kaRight,&BB->kaTop);
}
int
BBVisible(Pointer)
struct o *Pointer;
{
struct ka BB;
/* will edges show in coarse window? */
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (BB.kaLeft <= View->kvCoarseWindow->kaLeft &&
BB.kaRight >= View->kvCoarseWindow->kaRight &&
BB.kaBottom <= View->kvCoarseWindow->kaBottom &&
BB.kaTop >= View->kvCoarseWindow->kaTop)
return (False);
return (True);
}
static void
redisplay_edges(BB)
/* redisplay the edges of BB */
struct ka *BB;
{
struct ka EdgeOfBB;
/* Left edge. */
EdgeOfBB.kaLeft = BB->kaLeft-300;
EdgeOfBB.kaRight = BB->kaLeft+300;
EdgeOfBB.kaTop = BB->kaTop+300;
EdgeOfBB.kaBottom = BB->kaBottom-300;
EraseBox(&EdgeOfBB);
Redisplay(&EdgeOfBB);
/* Right edge. */
EdgeOfBB.kaRight = BB->kaRight+300;
EdgeOfBB.kaLeft = BB->kaRight-300;
EdgeOfBB.kaTop = BB->kaTop+300;
EdgeOfBB.kaBottom = BB->kaBottom-300;
EraseBox(&EdgeOfBB);
Redisplay(&EdgeOfBB);
/* Bottom edge. */
EdgeOfBB.kaBottom = BB->kaBottom-300;
EdgeOfBB.kaTop = BB->kaBottom+300;
EdgeOfBB.kaRight = BB->kaRight;
EdgeOfBB.kaLeft = BB->kaLeft;
EraseBox(&EdgeOfBB);
Redisplay(&EdgeOfBB);
/* Top edge. */
EdgeOfBB.kaBottom = BB->kaTop-300;
EdgeOfBB.kaTop = BB->kaTop+300;
EdgeOfBB.kaRight = BB->kaRight;
EdgeOfBB.kaLeft = BB->kaLeft;
EraseBox(&EdgeOfBB);
Redisplay(&EdgeOfBB);
FBTransfer();
}
static struct ks *
which_cell(SList)
/* Resolve ambiguity (multiple instances selected) */
struct ks *SList;
{
struct ks *S,*Sret;
char *SymbolName;
struct ka BB;
double A,Area;
/* find the smallest cell */
SLBB(SList,&BB);
Area = BB.kaRight - BB.kaLeft;
Area *= BB.kaTop - BB.kaBottom;
Sret = SList;
for (S = SList; S != NULL; S = S->ksSucc) {
CDStatusInt = CDBB(Parameters.kpCellDesc,S->ksPointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
A = BB.kaRight - BB.kaLeft;
A *= BB.kaTop - BB.kaBottom;
if (A < Area) {
Sret = S;
Area = A;
}
}
if (!BBVisible(Sret->ksPointer)) return (NULL);
SymbolName = ((struct c *)Sret->ksPointer->oRep)->cMaster->mName;
sprintf(TypeOut,"You have selected an instance of %s.",SymbolName);
ShowPrompt(TypeOut);
return (Sret);
}
int
AreTypesInQ(Types)
/* Returns True if one of Types is in SelectionQ and is selected,
* or of anything selected is in the Q if Types is NULL.
*/
char *Types;
{
struct ks *SQDesc;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (Types == NULL || strchr(Types,SQDesc->ksPointer->oType))
if (SQDesc->ksPointer->oInfo == SQ_OLDSEL) return (True);
}
return (False);
}
void
SelectTypes(Types)
/* Perform a point select, selecting only Types, or anything if
* Types is NULL.
*/
char *Types;
{
struct ka BB;
char TTmp[8];
BB.kaLeft = BB.kaRight = KicCursor.kcRawX;
BB.kaBottom = BB.kaTop = KicCursor.kcRawY;
if (Types == NULL) {
Selection(&BB);
return;
}
strcpy(TTmp,Parameters.kpSelectTypes);
strncpy(Parameters.kpSelectTypes,Types,8);
Parameters.kpSelectTypes[7] = '\0';
Selection(&BB);
strcpy(Parameters.kpSelectTypes,TTmp);
}
void
SQInit()
{
SelectQHead = NULL;
}
void
SQClear()
/* Clear the SelectionQ. */
{
struct ks *SQDesc,*SQNext;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
SQDesc->ksPointer->oInfo = SQ_OLD;
afree(SQDesc,ks);
}
SelectQHead = NULL;
}
void
SQInsert(Pointer)
/* Insert Pointer into the SelectionQ (no checking for duplication). */
struct o *Pointer;
{
struct ks *SQDesc;
if ((SQDesc = alloc(ks)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
/* SelectQHead is most recent addition */
SQDesc->ksPointer = Pointer;
SQDesc->ksSucc = SelectQHead;
SelectQHead = SQDesc;
}
void
SQDelete(Pointer)
/* Delete Pointer from SelectionQ if it is there. */
struct o *Pointer;
{
struct ks *SQDesc,*SQPrev,*SQNext;
SQPrev = NULL;
for (SQDesc = SelectQHead; SQDesc; SQPrev = SQDesc,SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
if (SQDesc->ksPointer != Pointer) continue;
Pointer->oInfo = SQ_OLD;
if (SQPrev == NULL)
SelectQHead = SQNext;
else
SQPrev->ksSucc = SQNext;
afree(SQDesc,ks);
return;
}
}
void
SQComputeBB()
/* Compute the BB of the queued and selected objects. */
{
struct ks *SQDesc;
struct ka BB;
int Info;
SelectQBB.kaLeft = CDINFINITY;
SelectQBB.kaBottom = CDINFINITY;
SelectQBB.kaRight = -CDINFINITY;
SelectQBB.kaTop = -CDINFINITY;
for (SQDesc = SelectQHead; SQDesc != NULL; SQDesc = SQDesc->ksSucc) {
Info = SQDesc->ksPointer->oInfo;
if (Info == SQ_OLDSEL || Info == SQ_NEWSEL ||
(Info > 10 && Info <= 255)) {
GetBB(SQDesc->ksPointer,&BB);
UpdateBB(SelectQBB,BB);
}
}
}
/* Theory behind SQRestore() and SQDesel();
*
* In commands which modify objects such as Move, the original object(s)
* are conditionally deleted, and new objects are conditionally created.
* All objects are left in the SelectionQ for a time to allow Undo.
* For example, suppose the SelectionQ is empty, and the user points at
* an object.
*
* operation: SelectionQ:
* select OLD (Info = SQ_OLDSEL)
* move NEW (Info = SQ_NEW), OLD (Info = SQ_GONE)
* User now selects newly moved object (the complicated case):
* select NEW NEW (Info = SQ_OLDSEL), NEW (Info = SQ_OLDSEL),
* OLD (Info = SQ_GONE)
* Now undo undoes the selection
* Undo (SQDesel()) NEW (Info = SQ_NEW), OLD (Info = SQ_GONE)
* Next undo undoes the move, leaving original item selected (conditionally).
* Undo (SQRestore(1)) OLD (Info = SQ_NEWSEL)
* Next undo undoes the selection
* Undo (SQDesel()) OLD (Info = SQ_NEW)
* The next undo repeats the move, etc.
*
* SQRestore(0) unsets the conditionality of objects in the SelectionQ
* and should be called when things are "final," i.e., before function
* exit or next operation.
*/
void
SQRestore(Undo)
/* Restore the conditionally created objects in the SelectionQ
* and delete duplicates if Undo is False. Otherwise undo the
* last operation.
*/
/* If Undo is True:
* Previously deleted objects become conditionally selected:
* Info = SQ_GONE -> Info = SQ_NEWSEL.
* New objects are deleted from SelectionQ and database:
* Info = SQ_NEW deleted from queue and database.
* Info = SQ_NEWSEL deleted from queue and database.
* Else
* Conditionally deleted objects are really deleted:
* Info = SQ_GONE deleted from queue and database.
* New objects are now Old objects, selected or otherwise:
* Info = SQ_NEW -> Info = SQ_OLD, deleted from queue.
* Info = SQ_NEWSEL -> Info = SQ_OLDSEL.
*/
int Undo;
{
struct ks *SQDesc,*SQNext;
int Info;
struct o *Pointer;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
Pointer = SQDesc->ksPointer;
Info = Pointer->oInfo;
if (Info == SQ_GONE) {
if (Undo == True)
Pointer->oInfo = SQ_NEWSEL;
else {
SQDelete(Pointer);
CDDelete(Parameters.kpCellDesc,Pointer);
}
continue;
}
if (Info == SQ_NEW) {
SQDelete(Pointer);
if (Undo == True) {
Pointer->oInfo = SQ_GONE;
CDDelete(Parameters.kpCellDesc,Pointer);
}
else
Pointer->oInfo = SQ_OLD;
continue;
}
if (Info == SQ_NEWSEL) {
if (Undo == True) {
SQDelete(Pointer);
Pointer->oInfo = SQ_GONE;
CDDelete(Parameters.kpCellDesc,Pointer);
}
else
Pointer->oInfo = SQ_OLDSEL;
}
}
if (Undo == False)
sq_delete_dups();
}
void
SQDesel(Types)
/* Undo a selection operation. */
/* Info = SQ_OLDSEL deleted from queue, and duplicates set to Info = SQ_NEW.
* Info = SQ_NEWSEL -> Info = SQ_NEW.
* Ignores objects with type not listed in Types.
*/
char *Types;
{
struct ks *SQDesc, *SQNext;
struct o *Pointer;
int Info;
char Type;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
Type = SQDesc->ksPointer->oType;
if (Types And !strchr(Types,Type)) continue;
Info = SQDesc->ksPointer->oInfo;
/* Have to be careful here. If selected object is already
* in queue have to reset Info of second entry to SQ_NEW.
*/
if (Info == SQ_OLDSEL) {
Pointer = SQDesc->ksPointer;
Pointer->oInfo = SQ_OLD;
SQDelete(Pointer);
sq_set_NEW(Pointer);
continue;
}
if (Info == SQ_NEWSEL)
SQDesc->ksPointer->oInfo = SQ_NEW;
}
}
void
SQShow()
/* Show selected objects by highlighting their BBs. */
{
struct ks *SQDesc;
int Info;
if (Not Parameters.kpEnableSelectQRedisplay) return;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
Info = SQDesc->ksPointer->oInfo;
/* Test for user interrupt */
if (Parameters.kpSIGINTERRUPT) {
RedisplayAfterInterrupt();
return;
}
if (Info == SQ_OLDSEL || Info == SQ_NEWSEL ||
(Info > 10 && Info <= 255)) {
/* Show Selected Objects */
sq_display_selected(SQDesc->ksPointer);
}
}
}
static void
sq_set_NEW(Pointer)
/* If object is in queue, set Info to SQ_NEW. */
struct o *Pointer;
{
struct ks *SQDesc;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer == Pointer) {
SQDesc->ksPointer->oInfo = SQ_NEW;
return;
}
}
}
static void
sq_delete_dups()
/* Delete duplicate entries in selection queue. */
{
struct ks *SQDesc,*SQDesc1,*SQNext;
int Info;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQNext) {
SQNext = SQDesc->ksSucc;
Info = SQDesc->ksPointer->oInfo;
for (SQDesc1 = SQDesc->ksSucc; SQDesc1; SQDesc1 = SQDesc1->ksSucc)
if (SQDesc->ksPointer == SQDesc1->ksPointer) {
SQDelete(SQDesc->ksPointer);
/* SQDelete sets Info to SQ_OLD, have to undo this */
SQDesc1->ksPointer->oInfo = Info;
break;
}
}
}
static void
sq_display_selected(Pointer)
struct o *Pointer;
{
int Layer;
struct p *Path;
int Width;
char OldRD;
struct ka BB;
if (Pointer->oType == CDWIRE) {
CDWire(Pointer,&Layer,&Width,&Path);
ShowWire(ColorTable[HighlightingColor].Ent,Width,Path);
return;
}
if (Pointer->oType == CDSYMBOLCALL) {
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
ShowInstanceMarker(DISPLAY,ColorTable[HighlightingColor].Ent,
Pointer);
return;
}
if (Pointer->oType == CDLABEL) {
/* BB of labels must be special-cased. Can't use CDBB. */
OldRD = Parameters.kpRedisplayControl;
if (OldRD != FINEVIEWPORTONLY) {
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
BBLabel(View->kvCoarseWindow,Pointer,&BB);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
}
if (OldRD != COARSEVIEWPORTONLY) {
Parameters.kpRedisplayControl = FINEVIEWPORTONLY;
BBLabel(View->kvFineWindow,Pointer,&BB);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
}
Parameters.kpRedisplayControl = OldRD;
return;
}
if (Pointer->oType == CDPOLYGON) {
CDPolygon(Pointer,&Layer,&Path);
ShowPath(ColorTable[HighlightingColor].Ent,Path,True);
return;
}
if (Pointer->oType == CDBOX) {
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
ShowEmptyBox(ColorTable[HighlightingColor].Ent,&BB);
return;
}
}
int *
InPath(Delta,Path,X,Y)
/* Is (X,Y) on the path described by ?
* If yes, return a pointer to x,y that are exactly in path.
*/
int Delta;
int X,Y;
struct p *Path;
{
struct p *Pair;
struct ka BB;
double x1,x2,y1,y2,d0,d1,d2,d3,w;
static int xy[2];
if (Delta < 10) Delta = 10;
if (Path == NULL) return (NULL);
for (Pair = Path; Pair->pSucc != NULL; Pair = Pair->pSucc) {
if (Pair->pX < Pair->pSucc->pX) {
BB.kaLeft = Pair->pX;
BB.kaRight = Pair->pSucc->pX;
}
else {
BB.kaRight = Pair->pX;
BB.kaLeft = Pair->pSucc->pX;
}
if (Pair->pY < Pair->pSucc->pY) {
BB.kaBottom = Pair->pY;
BB.kaTop = Pair->pSucc->pY;
}
else {
BB.kaBottom = Pair->pSucc->pY;
BB.kaTop = Pair->pY;
}
OversizeBox(&BB,Delta);
if (!InBox(X,Y,&BB)) continue;
x1 = Pair->pX - Pair->pSucc->pX;
y1 = Pair->pY - Pair->pSucc->pY;
d0 = x1*x1 + y1*y1;
x1 = Pair->pX - X;
y1 = Pair->pY - Y;
d1 = x1*x1 + y1*y1;
x2 = Pair->pSucc->pX - X;
y2 = Pair->pSucc->pY - Y;
d2 = x2*x2 + y2*y2;
d3 = (d2 - d1)/(2*sqrt(d0));
w = (d1+d2)/2 - d0/4 - d3*d3;
if (w <= Delta*Delta) {
/* should be positive, fabs() just in case */
d1 = sqrt(fabs(d1-w)/d0);
xy[0] = Pair->pX + (Pair->pSucc->pX - Pair->pX)*d1;
xy[1] = Pair->pY + (Pair->pSucc->pY - Pair->pY)*d1;
return (xy);
}
}
return (NULL);
}
#ifndef PI
#define PI 3.14159265358979323846
#endif
static int
is_point_in_poly(Delta,Path,X,Y)
/* Return True if point is enclosed in polygon, or near a vertex.
* Algorithm is to sum angle differences to reference point around
* path. If the reference point is inside, the sum is 2*PI, otherwise
* the sum is zero.
*/
int Delta;
struct p *Path;
int X,Y;
{
struct p *p;
double Xp,Yp,R,Theta,ThetaLast = 0.0,Sum,zz;
Sum = 0;
for (p = Path; p != NULL; p = p->pSucc) {
Xp = p->pX - X;
Yp = p->pY - Y;
R = sqrt(Xp*Xp + Yp*Yp);
if (R <= Delta) return (True);
Theta = asin(Yp/R);
if (Xp >= 0) {
if (Yp < 0)
Theta = 2*PI + Theta;
}
else
Theta = PI - Theta;
if (p != Path) {
zz = (Theta - ThetaLast);
if (zz > PI) zz -= 2*PI;
if (zz < -PI) zz += 2*PI;
Sum += zz;
}
ThetaLast = Theta;
}
if (fabs(Sum) >= 1.99*PI) return (True);
return (False);
}
static int
overlap_path(Path,BB)
/* return True if the path intersects the BB */
struct p *Path;
struct ka *BB;
{
struct ka Line;
Line.kaLeft = Path->pX;
Line.kaBottom = Path->pY;
Path = Path->pSucc;
for (; Path != NULL; Path = Path->pSucc) {
Line.kaRight = Path->pX;
Line.kaTop = Path->pY;
if (overlap_line(&Line,BB)) return (True);
Line.kaLeft = Line.kaRight;
Line.kaBottom = Line.kaTop;
}
return (False);
}
static int
overlap_line(Line,BB)
/* return True if Line intersects BB */
struct ka *Line,*BB;
{
struct ka LBB;
LBB.kaLeft = BB->kaLeft;
LBB.kaRight = BB->kaLeft;
LBB.kaBottom = BB->kaBottom;
LBB.kaTop = BB->kaTop;
if (cross_line(Line,&LBB)) return (True);
LBB.kaRight = BB->kaRight;
LBB.kaBottom = BB->kaTop;
if (cross_line(Line,&LBB)) return (True);
LBB.kaLeft = BB->kaRight;
LBB.kaBottom = BB->kaBottom;
if (cross_line(Line,&LBB)) return (True);
LBB.kaLeft = BB->kaLeft;
LBB.kaTop = BB->kaBottom;
if (cross_line(Line,&LBB)) return (True);
return (False);
}
static int
cross_line(Line,BB)
/* return True if line segments stored as diagonal of BB, Line
* intersect. The line in BB is Manhattan.
*/
struct ka *Line,*BB;
{
struct ka LineBB,MBB;
int X,Y;
MBB = *BB;
if (MBB.kaTop < MBB.kaBottom)
SwapInts(MBB.kaTop,MBB.kaBottom);
if (MBB.kaRight < MBB.kaLeft)
SwapInts(MBB.kaRight,MBB.kaLeft);
LineBB = *Line;
if (LineBB.kaTop < LineBB.kaBottom)
SwapInts(LineBB.kaTop,LineBB.kaBottom);
if (LineBB.kaRight < LineBB.kaLeft)
SwapInts(LineBB.kaRight,LineBB.kaLeft);
/* return False if BB's don't overlap */
if (LineBB.kaLeft > MBB.kaRight ||
LineBB.kaRight < MBB.kaLeft ||
LineBB.kaBottom > MBB.kaTop ||
LineBB.kaTop < MBB.kaBottom)
return (False);
/* if Line is Manhattan, return True */
if (Line->kaLeft == Line->kaRight || Line->kaBottom == Line->kaTop)
return (True);
if (BB->kaBottom == BB->kaTop) {
X = (BB->kaBottom - Line->kaBottom)*
((double)(Line->kaRight - Line->kaLeft)/
(Line->kaTop - Line->kaBottom)) +
Line->kaLeft;
if (X < BB->kaLeft || X > BB->kaRight) return (False);
}
else {
Y = (BB->kaLeft - Line->kaLeft)*
((double)(Line->kaTop - Line->kaBottom)/
(Line->kaRight - Line->kaLeft))
+ Line->kaBottom;
if (Y < BB->kaBottom || Y > BB->kaTop) return (False);
}
return (True);
}
kic-2.4c/src/kic/45s.c 0000644 0000764 0000764 00000004402 07525346714 014045 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
void
To45(x1,y1,x2,y2)
/*
* Changes one end of a line to make it vertical,horizontal, or diagonal.
*
* To45(x1,y1,x2,y2)
*
* x1,y1 = coordinates of one end of line (fixed)
* x2,y2 = pointers to coordinates of other end of line (movable)
*
* New end point will have the same x or y coordinate as old point
*/
int x1,y1,*x2,*y2;
{
int d[4];
int c,i;
d[2] = x1 - *x2;
d[0] = y1 - *y2;
d[1] = (*y2-y1)-(*x2-x1);
d[3] = (*y2-y1)+(*x2-x1);
if (d[0]*d[1]*d[2]*d[3] == 0) return;
c = 0;
for (i = 1; i <= 3; i++)
if (abs(d[i]) < abs(d[c])) c = i;
switch (c) {
case 0:
*y2 = y1;
break;
case 2:
*x2 = x1;
break;
case 1:
if (d[1] > 0) {
if (x1 > *x2) *x2 = *x2 + d[1];
else *y2 = *y2 - d[1];
}
else{
if (x1 > *x2) *y2 = *y2 - d[1];
else *x2 = *x2 + d[1];
}
break;
case 3:
if (d[3] > 0) {
if (x1 > *x2) *y2 = *y2 - d[3];
else *x2 = *x2 - d[3];
}
else{
if (x1 > *x2) *x2 = *x2 - d[3];
else *y2 = *y2 - d[3];
}
break;
}
}
int
IsManhattan(X1,Y1,X2,Y2)
int X1,Y1,X2,Y2;
{
if (X1 == X2 Or Y1 == Y2)
return (True);
return (False);
}
kic-2.4c/src/kic/debug.c 0000644 0000764 0000764 00000003205 07525346713 014517 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
void
Debug(LookedAhead)
int *LookedAhead;
{
*LookedAhead = False;
Parameters.kpMenu = DEBUGMENU;
FixMenuPrefix(DebugMenu);
ShowCommandMenu();
}
void
DoBW()
{
extern char *MenuBW;
if(Parameters.kpShowBandwidth) {
MenuDeselect(MenuBW);
Parameters.kpShowBandwidth = False;
}
else {
MenuSelect(MenuBW);
Parameters.kpShowBandwidth = True;
}
}
void
DoAlloc()
{
extern char *MenuALLOC;
/*
* Show # of symbol descs CD has allocated.
*/
MenuSelect(MenuALLOC);
sprintf(TypeOut,"%d symbols allocated so far by CD package.",
CDDesc.dNumSymbolsAllocated);
ShowPrompt(TypeOut);
MenuDeselect(MenuALLOC);
}
kic-2.4c/src/kic/measure.c 0000644 0000764 0000764 00000005423 12427243727 015074 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Simple measurement package for KIC.
*/
#include "prefix.h"
#include "kic.h"
#ifdef MSDOS
#include
#include
#else
#include
#ifndef WIN32
#include
#include
#include
#endif
#endif
time_t Realti,Realtf,Userti,Usertf,Systemti,Systemtf;
#ifdef vms
struct tbuffer {
int proc_user_time;
int proc_system_time;
int child_user_time;
int child_system_time;
};
struct tbuffer buffer;
#else
#if !defined(MDOS) && !defined(WIN32)
struct tms buffer;
#endif
#endif
void
StartTiming()
{
time((time_t *)&Realti);
#if !defined(MDOS) && !defined(WIN32)
times(&buffer);
#ifdef vms
Userti = buffer.proc_user_time/60;
Systemti = buffer.proc_system_time/60;
#else
Userti = buffer.tms_utime/60;
Systemti = buffer.tms_stime/60;
#endif
#endif
}
void
StopTiming()
{
time((time_t *)&Realtf);
#if !defined(MDOS) && !defined(WIN32)
times(&buffer);
#ifdef vms
Usertf = buffer.proc_user_time/60;
Systemtf = buffer.proc_system_time/60;
#else
Usertf = buffer.tms_utime/60;
Systemtf = buffer.tms_stime/60;
#endif
#endif
}
int
ElapsedRealTime()
{
return ((int)(Realtf-Realti));
}
int
ElapsedUserTime()
{
return ((int)(Usertf-Userti));
}
int
ElapsedSystemTime()
{
return ((int)(Systemtf-Systemti));
}
void
ShowRatio(VariablesName,VariablesValue,PerUnitName,PerUnitValue)
char *VariablesName;
int VariablesValue;
char *PerUnitName;
int PerUnitValue;
{
if(PerUnitValue != 0){
sprintf(TypeOut,"%d %s; %d %s; %d %s/%s MORE",VariablesValue,
VariablesName,PerUnitValue,PerUnitName,VariablesValue/PerUnitValue,
VariablesName,PerUnitName);
}
else{
sprintf(TypeOut,"%d %s; %d %s MORE",VariablesValue,VariablesName,
PerUnitValue,PerUnitName);
}
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
ErasePrompt();
}
kic-2.4c/src/kic/flatten.c 0000644 0000764 0000764 00000016021 10261420665 015054 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* The KIC flatten code.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuFLATN;
extern char *MenuUNDO;
#ifdef __STDC__
static void flatten_cell(struct s*);
static int is_call_in_sq(void);
#else
static void flatten_cell();
static int is_call_in_sq();
#endif
void
Flatten(LookedAhead)
int *LookedAhead;
{
struct s *MasterDesc;
struct ks *SQDesc;
struct ka OldSelectQBB;
char *MasterName;
int NumX,NumY;
int Int1,Int2;
int Undo = False;
int Modified = 0;
int DX,DY;
if (Not is_call_in_sq()) {
ShowPrompt("You haven't selected an instance to flatten.");
return;
}
top:
MenuSelect(MenuFLATN);
SQComputeBB();
OldSelectQBB = SelectQBB;
for (SQDesc = SelectQHead; SQDesc != NULL; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oType != CDSYMBOLCALL) continue;
if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
CDCall(SQDesc->ksPointer,&MasterName,&NumX,&DX,&NumY,&DY);
if (OpenCell(MasterName,&MasterDesc)) continue;
SetTransform(SQDesc->ksPointer);
for (Int1 = NumY; Int1 >= 1; --Int1) {
for (Int2 = 1; Int2 <= NumX; ++Int2) {
TPush();
TIdentity();
TTranslate((Int2-1)*DX,(Int1-1)*DY);
TPremultiply();
flatten_cell(MasterDesc);
TPop();
}
}
TPop();
SQDesc->ksPointer->oInfo = SQ_GONE;
Modified++;
}
/* take care of instance markers */
OldSelectQBB.kaRight += 600;
OldSelectQBB.kaLeft -= 600;
OldSelectQBB.kaTop += 600;
OldSelectQBB.kaBottom -= 600;
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
MenuDeselect(MenuFLATN);
loop {
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
if (Undo == False) {
SQRestore(True);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
MenuDeselect(MenuUNDO);
Modified--;
Undo = True;
continue;
}
else {
Undo = False;
MenuDeselect(MenuUNDO);
goto top;
}
}
}
quit:
SQRestore(False);
if (Modified)
Parameters.kpModified = True;
}
static void
flatten_cell(CellDesc)
struct s *CellDesc;
{
struct g *GenDesc;
struct o *Pointer;
struct p *Path;
struct s *MasterDesc;
char Xform;
char *Label;
char *MasterName;
int Layer;
int Int1,Int2;
int NumX,NumY;
int Left,Bottom,Right,Top;
int X,Y,Lngth,Width;
int DX,DY;
/*
* Traverse calls first.
* So, if instances aren't expanded, top level geometry
* isn't obscured by the symbolic pictures of any instances.
*/
if (Not CDInitGen(CellDesc,0,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc)) MallocFailed();
loop {
CDGen(CellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
if (Pointer->oInfo == SQ_GONE) continue;
CDCall(Pointer,&MasterName,&NumX,&DX,&NumY,&DY);
if (TFull()) return;
if (OpenCell(MasterName,&MasterDesc)) return;
SetTransform(Pointer);
for (Int1 = NumY; Int1 >= 1; --Int1) {
for (Int2 = 1; Int2 <= NumX; ++Int2) {
TPush();
TIdentity();
TTranslate((Int2-1)*DX,(Int1-1)*DY);
TPremultiply();
flatten_cell(MasterDesc);
TPop();
}
}
TPop();
}
for (Layer = 1;Layer <= NumLayerTable;++Layer) {
if (Not CDInitGen(CellDesc,Layer,-CDINFINITY,-CDINFINITY,
CDINFINITY,CDINFINITY,&GenDesc)) MallocFailed();
loop {
CDGen(CellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
if (Pointer->oInfo == SQ_GONE) continue;
switch (Pointer->oType) {
case CDBOX:
CDBox(Pointer,&Layer,&Lngth,&Width,&X,&Y);
/*
* KLUDGE
* So that the length and widths are rotated, we have to
* convert to a ka box and transform the corner points.
*/
Left = Pointer->oLeft;
Bottom = Pointer->oBottom;
Right = Pointer->oRight;
Top = Pointer->oTop;
if (Right < Left)
SwapInts(Right,Left);
if (Top < Bottom)
SwapInts(Top,Bottom);
TPoint(&Left,&Bottom);
TPoint(&Right,&Top);
Lngth = Right - Left;
Width = Top - Bottom;
X = Left + (Lngth >> 1);
Y = Bottom + (Width >> 1);
if (Not CDMakeBox(Parameters.kpCellDesc,Layer,Lngth,Width,X,Y,
&Pointer)) MallocFailed();
break;
case CDLABEL:
CDLabel(Pointer,&Layer,&Label,&X,&Y,&Xform);
TPoint(&X,&Y);
if (Not CDMakeLabel(Parameters.kpCellDesc,Layer,Label,
X,Y,Xform,&Pointer)) MallocFailed();
break;
case CDWIRE:
CDWire(Pointer,&Layer,&Width,&Path);
CopyPathWithXForm(&Path);
if (Not CDMakeWire(Parameters.kpCellDesc,Layer,Width,Path,
&Pointer)) MallocFailed();
break;
case CDPOLYGON:
CDPolygon(Pointer,&Layer,&Path);
CopyPathWithXForm(&Path);
if (Not CDMakePolygon(Parameters.kpCellDesc,Layer,Path,
&Pointer)) MallocFailed();
break;
default:
continue;
}
SQInsert(Pointer);
Pointer->oInfo = SQ_NEW;
}
}
}
static int
is_call_in_sq()
{
struct ks *SQDesc;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oType == CDSYMBOLCALL)
return (True);
}
return (False);
}
kic-2.4c/src/kic/lineclip.c 0000644 0000764 0000764 00000006134 07525346713 015234 0 ustar stevew stevew /*************************************************************************
Graphics and miscellaneous library
Copyright (c) Stephen R. Whiteley 1994
Author: Unknown Hero from Ancient Berkeley History
*************************************************************************/
#include "prefix.h"
#include "kic.h"
/* Line clipping routines. */
#define CODELEFT 1
#define CODEBOTTOM 2
#define CODERIGHT 4
#define CODETOP 8
#define CODE(x,y,c) c = 0;\
if(x < l)\
c = CODELEFT;\
else if(x > r)\
c = CODERIGHT;\
if(y < b)\
c |= CODEBOTTOM;\
else if(y > t)\
c |= CODETOP;
void
Y_Intercept(x1,y1,x2,y2,e,yi)
int x1,y1,x2,y2; /* two points on line */
int e; /* vertical line of intercept */
int *yi; /* y coordinate of intercept */
{
/*
* Y_Intercept will return the value 'yi' where the the coordinate
* (e,yi) is the intersection of the vertical line x = e and the line
* determined by the coordinates (x1,y1) and (x2,y2).
*/
*yi = y1;
if (x1 == x2) return; /* vertical line */
*yi = y1 + ((e - x1) * (y2 - y1))/(x2 - x1);
}
void
X_Intercept(x1,y1,x2,y2,e,xi)
int x1,y1,x2,y2; /* two point on line */
int e; /* horizontal line of intercept */
int *xi; /* x coordinate of intercept */
{
/*
* X_Intercept will return the value 'xi' where the the coordinate
* (xi,e) is the intersection of the horizontal line y = e and the line
* determined by the coordinates (x1,y1) and (x2,y2).
*/
*xi = x1;
if (y1 == y2) return; /* horizontal line */
*xi = x1 + ((e - y1) * (x2 - x1))/(y2 - y1);
}
int
LineClip(pX1,pY1,pX2,pY2,l,b,r,t)
int *pX1,*pY1,*pX2,*pY2,l,b,r,t;
{
/*
* LineClip will clip a line to a rectangular area. The returned
* value is 'True' if the line is out of the AOI (therefore does not
* need to be displayed) and 'False' if the line is in the AOI.
*/
int x1 = *pX1;
int y1 = *pY1;
int x2 = *pX2;
int y2 = *pY2;
int x = 0,y = 0;
int c,c1,c2;
CODE(x1,y1,c1)
CODE(x2,y2,c2)
while (c1 != 0 || c2 != 0) {
if ((c1 & c2) != 0) return (True); /* Line is invisible. */
if ((c = c1) == 0) c = c2;
if (c & CODELEFT) {
y = y1+(y2-y1)*(l-x1)/(x2-x1);
x = l;
}
else if (c & CODERIGHT) {
y = y1+(y2-y1)*(r-x1)/(x2-x1);
x = r;
}
else if (c & CODEBOTTOM) {
x = x1+(x2-x1)*(b-y1)/(y2-y1);
y = b;
}
else if (c & CODETOP) {
x = x1+(x2-x1)*(t-y1)/(y2-y1);
y = t;
}
if (c == c1) {
x1 = x; y1 = y; CODE(x,y,c1)
}
else {
x2 = x; y2 = y; CODE(x,y,c2)
}
}
*pX1 = x1; *pY1 = y1;
*pX2 = x2; *pY2 = y2;
return (False); /* Line is at least partially visible. */
}
kic-2.4c/src/kic/logo.c 0000644 0000764 0000764 00000022103 07525346714 014370 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#define FONT_FILE "logofont.kic"
/* a WordPerfect font file */
struct cdat {
unsigned char *headr;
unsigned char *data;
int size;
};
struct s_rlist {
int xl, yl, xr, yu;
struct s_rlist *next;
};
#if __STDC__
static void fixname(char*);
static struct cdat *findchar(int,FILE*);
static void addchar(struct cdat*,int,int,int,FILE*);
static void coalesce(struct s_rlist**,int,int);
static void swaptest(void);
static void fixint(unsigned char*);
#else
static void fixname();
static struct cdat *findchar();
static void addchar();
static void coalesce();
static void swaptest();
static void fixint();
#endif
extern char *MenuLOGO;
extern char *MenuPLACE;
#if __NDPC__
#if __STDC__
static FILE *my_fopen(char*,char*);
#else
static FILE *my_fopen();
#endif
#define fopen my_fopen
#endif
void
Logo(LookedAhead)
int *LookedAhead;
{
FILE *fp,*kf;
struct cdat *c;
int i,x,x1,y1,psize;
char *s, buf[80];
char name[12];
swaptest();
MenuSelect(MenuLOGO);
fp = fopen(FONT_FILE,"rb");
if (fp == NULL) {
sprintf(TypeOut,"%s%c%s",PATH_TO_HELP,DIRC,FONT_FILE);
fp = fopen(TypeOut,"rb");
if (fp == NULL) {
ShowPrompt("Can't open font file.");
MenuDeselect(MenuLOGO);
return;
}
}
ShowPrompt("Enter text: ");
s = FBEdit(NULL);
if (s == NULL || !*s) {
ErasePrompt();
MenuDeselect(MenuLOGO);
fclose(fp);
return;
}
strncpy(buf,s,80);
buf[79] = '\0';
strncpy(name,s,8);
name[8] = '\0';
fixname(name);
i = 1;
s = strchr(name,'\0');
while (!access(name,0)) {
sprintf(s,".%d",i);
i++;
}
ShowPrompt("Enter pixel size: ");
s = FBEdit(NULL);
if (s == NULL || !*s) {
ErasePrompt();
MenuDeselect(MenuLOGO);
fclose(fp);
return;
}
psize = 100.0*atof(s);
kf = fopen(name,"w");
if (kf == NULL) {
ShowPrompt("Can't open output file.\n");
MenuDeselect(MenuLOGO);
fclose(fp);
return;
}
sprintf(TypeOut,"Symbol %s",name);
GenComment(kf,TypeOut);
fprintf(kf,"9 %s;\n",name);
GenBeginSymbol(kf,0,1,1);
GenLayer(kf,LayerTable[Parameters.kpLayer].klTechnology,
LayerTable[Parameters.kpLayer].klMask);
s = buf;
x = 0;
while (*s) {
c = findchar(*s,fp);
if (c == NULL) {
x += 20;
rewind(fp);
s++;
continue;
}
fixint(c->headr+6);
fixint(c->headr+8);
fixint(c->headr+10);
x1 = x + (*(short*)(c->headr+6));
y1 = (*(short*)(c->headr+8));
addchar(c,x1,y1,psize,kf);
x += (*(short*)(c->headr+10));
free(c->headr);
free(c);
rewind(fp);
s++;
}
GenEndSymbol(kf);
GenEnd(kf);
fclose(kf);
fclose(fp);
sprintf(TypeOut,"New symbol %s created, point to place.",name);
ShowPrompt(TypeOut);
MenuSelect(MenuPLACE);
MenuDeselect(MenuLOGO);
MakeInstance(LookedAhead,name);
MenuDeselect(MenuPLACE);
}
static void
addchar(cd,x0,y0,psize,kf)
struct cdat *cd;
int x0,y0,psize;
FILE *kf;
{
int i,j,k,bwidth,lines,x,y,xl = 0;
unsigned char c,*s;
int inbox;
struct s_rlist **rlist, *list = NULL;
if (cd == NULL) return;
bwidth = (*(short*) (cd->headr+10) + 7)/8;
lines = cd->size/bwidth;
s = cd->data;
rlist = (struct s_rlist**)tmalloc(lines*sizeof(struct s_rlist*));
y = y0*psize;
inbox = 0;
for (i = 0; i < lines; i++) {
rlist[i] = NULL;
x = x0*psize;
for (j = 0; j < bwidth; j++) {
c = *s++;
for (k = 0; k < 8; k++) {
if (c & 0x80) {
if (!inbox) {
xl = x;
inbox = 1;
}
}
else {
if (inbox) {
if (!rlist[i])
rlist[i] = list = alloc(s_rlist);
else {
list->next = alloc(s_rlist);
list = list->next;
}
list->xl = xl;
list->yl = y - psize;
list->xr = x;
list->yu = y;
list->next = NULL;
inbox = 0;
}
}
c <<= 1;
x += psize;
}
}
if (inbox) {
if (!rlist[i])
rlist[i] = list = alloc(s_rlist);
else {
list->next = alloc(s_rlist);
list = list->next;
}
list->xl = xl;
list->yl = y - psize;
list->xr = x;
list->yu = y;
list->next = NULL;
inbox = 0;
}
y -= psize;
}
coalesce(rlist,lines,psize);
for (i = 0; i < lines; i++) {
for (list = rlist[i]; list; list = rlist[i]) {
rlist[i] = list->next;
GenBox(kf,list->xr - list->xl,list->yu - list->yl,
list->xl + (list->xr - list->xl)/2,
list->yl + (list->yu - list->yl)/2,1,0);
free(list);
}
}
free(rlist);
}
static void
coalesce(rlist,lines,psize)
/* merge rectangles */
struct s_rlist **rlist;
int lines, psize;
{
int i;
struct s_rlist *listL, *listU, *listp;
for (i = 1; i < lines; i++) {
for (listL = rlist[i]; listL; listL = listL->next) {
listp = NULL;
for (listU = rlist[i-1]; listU;
listp = listU, listU = listU->next) {
if (listL->xl == listU->xl && listL->xr == listU->xr) {
listL->yu = listU->yu;
if (listp == NULL) {
rlist[i-1] = listU->next;
}
else {
listp->next = listU->next;
}
free(listU);
break;
}
}
}
}
}
static void
fixname(s)
char *s;
{
while (*s) {
if (!isalpha(*s) && !isdigit(*s))
*s = '_';
s++;
}
}
static struct cdat *
findchar(char_id,fp)
int char_id;
FILE *fp;
{
unsigned char buf[64],*s;
unsigned int c;
int size;
struct cdat *cd;
for (;;) {
if (feof(fp)) break;
c = getc(fp);
if (c != 0x1b) continue;
c = getc(fp);
if (c != '*') continue;
c = getc(fp);
if (c != 'c') continue;
c = getc(fp);
s = buf;
while (isdigit(c)) {
*s++ = c;
c = getc(fp);
}
*s = '\0';
if (char_id != atoi((char*)buf)) continue;
if (c != 'E') continue;
c = getc(fp);
if (c != 0x1b) continue;
c = getc(fp);
if (c != '(') continue;
c = getc(fp);
if (c != 's') continue;
c = getc(fp);
s = buf;
while (isdigit(c)) {
*s++ = c;
c = getc(fp);
}
*s = '\0';
if (c != 'W') continue;
size = atoi((char*)buf);
cd = (struct cdat*)tmalloc(sizeof(struct cdat));
cd->size = size - 16;
cd->headr = (unsigned char*)tmalloc(size);
fread(cd->headr,size,1,fp);
cd->data = cd->headr + 16;
return (cd);
}
return (NULL);
}
static int swap_bytes;
static void
swaptest()
{
union {unsigned short i; unsigned char c[2];} u;
u.i = 1;
if (u.c[0] == 1)
swap_bytes = True;
else
swap_bytes = False;
}
static void
fixint(i)
unsigned char *i;
{
unsigned char c;
if (swap_bytes) {
c = *i;
*i = *(i+1);
*(i+1) = c;
}
}
#if __NDPC__
#undef fopen
extern int _pmode;
static FILE*
my_fopen(what,how)
/* support for NDPC's silly pmode */
char *what, *how;
{
FILE *fp;
char *c, buf[8];
char *index();
strncpy(buf,how,8);
buf[7] = '\0';
if ((c = index(buf,'b')) != NULL) {
_pmode = 0x8000;
*c = '\0';
}
fp = fopen(what,buf);
_pmode = 0x4000;
return (fp);
}
#endif
kic-2.4c/src/kic/contexts.c 0000644 0000764 0000764 00000024304 07525346713 015303 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* KIC context code.
*/
#include "prefix.h"
#include "kic.h"
struct cc {
int ccX,ccY,ccWidth;
int ccModified;
struct kw *ccSaveWindow;
struct o *ccInst;
char *ccMaster;
int ccXform[9];
struct cc *ccNext;
struct cc *ccPrev;
};
static struct cc *Context;
static int WroteCell;
#ifdef __STDC__
static void edit_cell(int);
static int pop_context(void);
static void sq_first_call(struct o**);
static void select_call(void);
#else
static void edit_cell();
static int pop_context();
static void sq_first_call();
static void select_call();
#endif
void
Push(LookedAhead)
int *LookedAhead;
{
struct o *Pointer;
struct cc *New;
char Type;
char *MasterName;
int NumX,NumY;
int DX,DY;
extern char *MenuPUSH;
MenuSelect(MenuPUSH);
WroteCell = False;
loop {
/*
* Fetch first call desc in select Q if any.
* Its master is the cell we will push to.
* Otherwise, point to select an instance;
*/
sq_first_call(&Pointer);
if (Pointer != NULL) {
CDType(Pointer,&Type);
if (Type == CDSYMBOLCALL)
break;
}
ShowPrompt("Point to instance to push to ");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
case PL_UND:
ErasePrompt();
MenuDeselect(MenuPUSH);
return;
case PL_PCW:
select_call();
}
}
ErasePrompt();
CDCall(Pointer,&MasterName,&NumX,&DX,&NumY,&DY);
New = alloc(cc);
if (New == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
New->ccMaster = malloc(strlen(Parameters.kpCellName)+1);
if (New->ccMaster == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
strcpy(New->ccMaster,Parameters.kpCellName);
New->ccInst = Pointer;
New->ccX = View->kvCoarseWindow->kaX;
New->ccY = View->kvCoarseWindow->kaY;
New->ccModified = Parameters.kpModified;
New->ccWidth = View->kvCoarseWindow->kaWidth;
New->ccSaveWindow = Parameters.kpWindowStack;
New->ccNext = Context;
Context = New;
strcpy(Parameters.kpCellName,MasterName);
Parameters.kpModified = False;
Parameters.kpWindowStack = NULL;
/* find the inverse transform of the cell, used when displaying
* context */
TPush();
TLoad(); /* load the current inverse transform */
TCurrent(New->ccXform);
TInverse(); /* compute the inverse (actual transform) */
TLoadInverse(); /* load it */
SetTransform(Pointer);
TInverse(); /* compute the inverse */
TLoadInverse(); /* load it */
TStore(); /* save it for use in redisplay() */
TPop();
TPop();
edit_cell(False);
TitleWindow();
MenuDeselect(MenuPUSH);
}
void
ShowContext()
{
extern char *MenuCNTXT;
if (Parameters.kpShowContext) {
Parameters.kpShowContext = False;
MenuDeselect(MenuCNTXT);
}
else {
Parameters.kpShowContext = True;
MenuSelect(MenuCNTXT);
}
if (Parameters.kpCellDesc != Parameters.kpTopDesc)
FullRedisplay();
}
static void
edit_cell(Modified)
int Modified;
{
SQClear();
ShowPrompt("Building database. Please wait.");
if (Not CDOpen(Parameters.kpCellName,&Parameters.kpCellDesc,'w')) {
sprintf(TypeOut,"Can't edit cell %s. MORE",Parameters.kpCellName);
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
sprintf(TypeOut,"%s",CDStatusString);
ShowPrompt(TypeOut);
Parameters.kpCellName[0] = EOS;
}
else {
if (CDStatusInt == CDNEWSYMBOL) {
ShowPrompt("Internal error: cell not found");
return;
}
CenterFullView();
CDUnmark(Parameters.kpCellDesc);
RedisplayViewports();
ShowPrompt("Cell is ready to be edited.");
Parameters.kpModified = Modified;
}
ShowParameters();
}
void
UpdateParent(NewName)
char *NewName;
{
char *TypeIn,*MasterName,Type;
int NumX,NumY;
int X,Y,DX,DY;
struct s *CellDesc;
struct t *TGen;
struct o *Pointer;
if (Context == NULL)
return;
ShowPrompt("Update parent cell to call new cell name? (n) ");
TypeIn = FBEdit(NULL);
if (TypeIn And (*TypeIn == 'y' Or *TypeIn == 'Y')) {
/*Change the instance pushed from so its master is NewName.*/
if (Not CDOpen(Context->ccMaster,&CellDesc,'w')) {
sprintf(TypeOut,"Can't display %s. MORE",
Context->ccMaster);
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
ShowPrompt(CDStatusString);
return;
}
CDCall(Context->ccInst,&MasterName,&NumX,&DX,&NumY,&DY);
if (Not CDBeginMakeCall(
CellDesc,NewName,NumX,DX,NumY,DY,&Pointer)) {
if (CDStatusInt ==
CDPARSEFAILED Or CDStatusInt == CDNEWSYMBOL) {
sprintf(TypeOut,"Can't write cell %s. MORE",NewName);
ShowPrompt(TypeOut);
(void)FBGetchar(ERASE);
ShowPrompt(CDStatusString);
return;
}
elif (CDStatusInt == CDMALLOCFAILED)
MallocFailed();
}
CDInitTGen(Context->ccInst,&TGen);
loop {
CDTGen(&TGen,&Type,&X,&Y);
if (TGen == NULL)
break;
if (Not CDT(Pointer,Type,X,Y))
MallocFailed();
}
if (Not CDEndMakeCall(CellDesc,Pointer))
MallocFailed();
CDDelete(CellDesc,Context->ccInst);
WroteCell = True;
Context->ccModified = True;
Context->ccInst = Pointer;
}
}
void
Pop()
{
char *TypeIn;
extern char *MenuPOP;
MenuSelect(MenuPOP);
if (Context == NULL)
ShowPrompt("There isn't a context to pop to.");
else {
SQClear();
if (WroteCell) {
/*
* Restore cell to its old state, because we don't want
* a global change, but we want a change to the instance
* pushed from.
*/
if (Not CDClose(Parameters.kpCellDesc))
MallocFailed();
Parameters.kpModified = False;
}
elif (Parameters.kpModified) {
ShowPrompt("You've modified this cell. Do you want to save it (y)?");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) {
MenuDeselect(MenuPOP);
ErasePrompt();
return;
}
if (TypeIn[0] == 'n' Or TypeIn[0] == 'N') {
if (Not CDClose(Parameters.kpCellDesc))
MallocFailed();
}
else
Save();
}
edit_cell(pop_context());
}
TitleWindow();
MenuDeselect(MenuPOP);
}
static int
pop_context()
{
struct kw *Tmp;
struct cc *Old;
int Modified;
strcpy(Parameters.kpCellName,Context->ccMaster);
InitCoarseWindow(Context->ccX,Context->ccY,Context->ccWidth);
InitFineWindow(Context->ccX,Context->ccY);
for (Tmp = Parameters.kpWindowStack; Tmp;
Tmp = Parameters.kpWindowStack) {
Parameters.kpWindowStack = Tmp->kwNext;
afree(Tmp,kw);
}
Parameters.kpWindowStack = Context->ccSaveWindow;
free(Context->ccMaster);
TPush();
TLoadCurrent(Context->ccXform);
TStore();
TPop();
SetPositioning();
Parameters.kpModified = False;
Modified = Context->ccModified;
Old = Context;
Context = Context->ccNext;
afree(Old,cc);
return (Modified);
}
int
CheckModified()
/* called on exit */
{
struct s *SDesc;
struct cc *Cx = Context;
char *TypeIn;
while (Cx) {
if (Cx->ccModified) {
sprintf(TypeOut,"Cell %s has been modified. Save it? (y) ",
Cx->ccMaster);
ShowPrompt(TypeOut);
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) return (True);
if (*TypeIn != 'n' && *TypeIn != 'N') {
CDSymbol(Cx->ccMaster,&SDesc);
if (SDesc && CDUpdate(SDesc,(char *)NULL)) {
Cx->ccModified = False;
if (Not CDReflect(SDesc))
MallocFailed();
}
else {
/* shouldn't happen */
sprintf(TypeOut,"Can't save %s.",Cx->ccMaster);
ShowPromptAndWait(TypeOut);
return (True);
}
}
}
Cx = Cx->ccNext;
}
ClearContext();
return (False);
}
void
ClearContext()
/* called from Edit() */
{
while (Context) pop_context();
}
static void
sq_first_call(Pointer)
struct o **Pointer;
{
struct ks *SQDesc;
char Type;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
CDType(SQDesc->ksPointer,&Type);
if (Type == CDSYMBOLCALL) {
*Pointer = SQDesc->ksPointer;
return;
}
}
*Pointer = NULL;
}
static void
select_call()
{
struct ka BB;
char TTmp[8];
BB.kaLeft = BB.kaRight = KicCursor.kcRawX;
BB.kaBottom = BB.kaTop = KicCursor.kcRawY;
strcpy(TTmp,Parameters.kpSelectTypes);
Parameters.kpSelectTypes[0] = CDSYMBOLCALL;
Parameters.kpSelectTypes[1] = EOS;
Selection(&BB);
strcpy(Parameters.kpSelectTypes,TTmp);
}
kic-2.4c/src/kic/Makefile.in 0000644 0000764 0000764 00000003110 07525375503 015324 0 ustar stevew stevew #######################################################################
# src/kic/Makefile.in
#######################################################################
# $Id$
#######################################################################
VERSION = @VERSION@
DATE = @DATE@
CC = @CC@
CFLAGS = @CFLAGS@
DEPEND_PROG = @DEPEND_PROG@
RANLIB = @RANLIB@
FILTER = @FILTER@
LIB_TARGET = ../kic.a
HFILES =
CFILES = 45s.c attri.c basic.c boxes.c break.c change.c contexts.c copy.c \
debug.c delete.c dir.c erase.c flatten.c grid.c hcopy.c init.c instance.c \
labels.c lineclip.c lines.c logo.c measure.c modify.c more.c point.c \
polyclip.c polygns.c prpty.c redispla.c select.c sline.c techfile.c \
viewport.c wires.c xorbox.c zoom.c
ALLFILES = $(CFILES) $(HFILES) Makefile.in
COBJS = $(CFILES:.c=.o)
INCLUDE = -I../include
$(LIB_TARGET): $(COBJS)
ar r $(LIB_TARGET) $?
$(RANLIB) $(LIB_TARGET)
co: $(ALLFILES)
$(ALLFILES):
-@if [ ! -h $@ ]; then \
co $@; \
fi;
ci:
-@for aa in $(ALLFILES); do\
if [ ! -h $$aa ]; then \
rcsdiff $$aa > /dev/null 2>&1; \
if [ $$? = 1 ]; then \
rcs -l $$aa > /dev/null 2>&1; \
ci -r$(VERSION) $$aa; \
fi; \
fi \
done
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c $*.c
depend:
@echo depending in src/kic
@if [ x$(DEPEND_DONE) = x ]; then \
echo DEPEND_DONE = 1 >> Makefile; \
$(DEPEND_PROG) $(INCLUDE) $(CFILES) $(FILTER) >> Makefile; \
fi
clean:
-rm *.o $(LIB_TARGET)
distclean:
-rm *.o $(LIB_TARGET) Makefile
#######################################################################
kic-2.4c/src/kic/break.c 0000644 0000764 0000764 00000026226 07525346713 014525 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
/*
* Break selection operator.
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuBREAK;
extern char *MenuUNDO;
#ifdef __STDC__
static int do_break(int,int,int);
static int break_wire(int,int,struct o*,int);
static int break_poly(int,int,struct o*,int);
static struct p *isec_y(struct p*,struct p*,int);
static struct p *isec_x(struct p*,struct p*,int);
#else
static int do_break();
static int break_wire();
static int break_poly();
static struct p *isec_y();
static struct p *isec_x();
#endif
void
Break(LookedAhead)
int *LookedAhead;
{
int GotOne = False;
int Undo = False;
int FirstTime = True;
int Modified = 0;
struct ka OldSelectQBB;
int OldX = 0, OldY = 0;
char Types[4];
char pl;
MenuSelect(MenuBREAK);
Types[0] = CDBOX;
Types[1] = CDPOLYGON;
Types[2] = CDWIRE;
Types[3] = '\0';
if (AreTypesInQ(Types))
GotOne = True;
top:
if (Not GotOne) {
ShowPrompt("Point to object to break.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime) goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
SQRestore(True);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
Modified--;
Undo = True;
MenuDeselect(MenuUNDO);
break;
}
else {
(void) do_break(OldX,OldY,True);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
Modified++;
Undo = False;
MenuDeselect(MenuUNDO);
goto top;
}
case PL_PCW:
SelectTypes(Types);
if (Not AreTypesInQ(Types))
goto top;;
}
}
ShowPrompt("Point on the break line.");
next:
FBSetRubberBanding('l');
pl = PointLoop(LookedAhead);
FBSetRubberBanding(0);
switch (pl) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
MenuSelect(MenuUNDO);
if (Not GotOne) {
SQDesel(Types);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
MenuDeselect(MenuUNDO);
goto top;
}
if (FirstTime)
goto quit;
if (Undo == False) {
MenuSelect(MenuBREAK);
ShowPrompt("Point on the break line.");
SQRestore(True);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
Modified--;
Undo = True;
}
else {
(void) do_break(OldX,OldY,True);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
ErasePrompt();
MenuDeselect(MenuBREAK);
Modified++;
Undo = False;
}
MenuDeselect(MenuUNDO);
goto next;
case PL_PCW:
if (Not FirstTime And GotOne And Not Undo) goto next;
if (do_break(KicCursor.kcX,KicCursor.kcY,False)) {
SQRestore(False);
do_break(KicCursor.kcX,KicCursor.kcY,True);
OldX = KicCursor.kcX;
OldY = KicCursor.kcY;
OldSelectQBB = SelectQBB;
if (Not GotOne)
/* deselect anything left over */
SQDesel(Types);
EraseBox(&OldSelectQBB);
Redisplay(&OldSelectQBB);
FirstTime = False;
Modified++;
Undo = False;
if (Not GotOne)
goto top;
ErasePrompt();
MenuDeselect(MenuBREAK);
goto next;
}
}
quit:
SQRestore(False);
if (Not GotOne And AreTypesInQ(Types)) {
SQComputeBB();
SQDesel(Types);
EraseBox(&SelectQBB);
Redisplay(&SelectQBB);
}
if (Modified)
Parameters.kpModified = True;
ErasePrompt();
MenuDeselect(MenuUNDO);
MenuDeselect(MenuBREAK);
}
struct p *
CopyPath(path)
struct p *path;
{
struct p *pcopy,*pc = NULL,*pp = path;
if (path == NULL) return (NULL);
pcopy = pc = alloc(p);
pc->pX = pp->pX;
pc->pY = pp->pY;
pp = pp->pSucc;
while (pp) {
pc->pSucc = alloc(p);
pc = pc->pSucc;
pc->pX = pp->pX;
pc->pY = pp->pY;
pp = pp->pSucc;
}
pc->pSucc = NULL;
return (pcopy);
}
static int
do_break(RefX,RefY,Flag)
int RefX,RefY;
int Flag;
{
struct ks *SQDesc;
int X,Y,Length,Width,Right,Left,Top,Bottom;
int RotationAngle,Layer;
int DidBreak = False;
char Type;
/* If Flag is False, returns True if a break would be performed,
* but operation is not done.
*/
RotationAngle = Parameters.kpRotationAngle;
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
Type = SQDesc->ksPointer->oType;
if (Type == CDSYMBOLCALL) {
/* can't break symbols */
continue;
}
if (Type == CDLABEL) {
continue;
}
if (Type == CDBOX) {
CDBox(SQDesc->ksPointer,&Layer,&Length,&Width,&X,&Y);
Left = X - Length/2;
Right = X + Length/2;
Top = Y + Width/2;
Bottom = Y - Width/2;
if (RotationAngle == 0 Or RotationAngle == 180) {
if (RefX <= Left Or RefX >= Right)
continue;
if (Not Flag) return (True);
SQDesc->ksPointer->oInfo = SQ_GONE;
NewBox(Left,Bottom,RefX,Top,Layer);
NewBox(RefX,Bottom,Right,Top,Layer);
}
else {
if (RefY <= Bottom Or RefY >= Top)
continue;
if (Not Flag) return (True);
SQDesc->ksPointer->oInfo = SQ_GONE;
NewBox(Left,Bottom,Right,RefY,Layer);
NewBox(Left,RefY,Right,Top,Layer);
}
DidBreak = True;
}
if (Type == CDWIRE) {
DidBreak = break_wire(RefX,RefY,SQDesc->ksPointer,Flag);
continue;
}
if (Type == CDPOLYGON) {
DidBreak = break_poly(RefX,RefY,SQDesc->ksPointer,Flag);
continue;
}
}
return (DidBreak);
}
static int
break_wire(RefX,RefY,Pointer,Flag)
int RefX,RefY;
struct o *Pointer;
int Flag;
{
struct p *pp,*px,*pTemp,*pNew,*pInt;
struct o *NewPointer;
struct ka BB;
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,&BB.kaLeft,
&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (Parameters.kpRotationAngle == 0 Or
Parameters.kpRotationAngle == 180) {
if (RefX <= BB.kaLeft Or RefX >= BB.kaRight) return (False);
if (Not Flag) return (True);
px = CopyPath(((struct w *)Pointer->oRep)->wPath);
for (pNew = pp = px; pp And pp->pSucc; pp = pTemp) {
pTemp = pp->pSucc;
if ((pp->pX <= RefX And pp->pSucc->pX > RefX) Or
(pp->pX >= RefX And pp->pSucc->pX < RefX)) {
pp->pSucc = NULL;
pInt = isec_y(pp,pTemp,RefX);
if (pp->pX != pInt->pX Or pp->pY != pInt->pY) {
pp->pSucc = pInt;
pInt->pSucc = NULL;
pInt = CopyPath(pInt);
}
if (Not CDMakeWire(Parameters.kpCellDesc,Pointer->oLayer,
((struct w *)Pointer->oRep)->wWidth,pNew,&NewPointer))
MallocFailed();
NewPointer->oInfo = SQ_NEW;
SQInsert(NewPointer);
pInt->pSucc = pTemp;
pNew = pInt;
}
}
}
else {
if (RefY <= BB.kaBottom Or RefY >= BB.kaTop) return (False);
if (Not Flag) return (True);
px = CopyPath(((struct w *)Pointer->oRep)->wPath);
for (pNew = pp = px; pp And pp->pSucc; pp = pp->pSucc) {
pTemp = pp->pSucc;
if ((pp->pY <= RefY And pp->pSucc->pY > RefY) Or
(pp->pY >= RefY And pp->pSucc->pY < RefY)) {
pp->pSucc = NULL;
pInt = isec_x(pp,pTemp,RefY);
if (pp->pX != pInt->pX Or pp->pY != pInt->pY) {
pp->pSucc = pInt;
pInt->pSucc = NULL;
pInt = CopyPath(pInt);
}
if (Not CDMakeWire(Parameters.kpCellDesc,Pointer->oLayer,
((struct w *)Pointer->oRep)->wWidth,pNew,&NewPointer))
MallocFailed();
NewPointer->oInfo = SQ_NEW;
SQInsert(NewPointer);
pInt->pSucc = pTemp;
pNew = pInt;
}
}
}
if (Not CDMakeWire(Parameters.kpCellDesc,Pointer->oLayer,
((struct w *)Pointer->oRep)->wWidth,pNew,&NewPointer))
MallocFailed();
NewPointer->oInfo = SQ_NEW;
SQInsert(NewPointer);
Pointer->oInfo = SQ_GONE;
return (True);
}
static int
break_poly(RefX,RefY,Pointer,Flag)
int RefX,RefY;
struct o *Pointer;
int Flag;
{
int i;
struct p *path, *pp;
struct ka BB;
Poly p1,p2;
int *xy;
int L1,R1,B1,T1;
int L2,R2,B2,T2;
CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,&BB.kaLeft,
&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (Parameters.kpRotationAngle == 0 Or
Parameters.kpRotationAngle == 180) {
if (RefX <= BB.kaLeft Or RefX >= BB.kaRight)
return (False);
if (Not Flag)
return (True);
L1 = BB.kaLeft;
B1 = BB.kaBottom;
R1 = RefX;
T1 = BB.kaTop;
L2 = RefX;
B2 = BB.kaBottom;
R2 = BB.kaRight;
T2 = BB.kaTop;
}
else {
if (RefY <= BB.kaBottom Or RefY >= BB.kaTop)
return (False);
if (Not Flag)
return (True);
L1 = BB.kaLeft;
B1 = BB.kaBottom;
R1 = BB.kaRight;
T1 = RefY;
L2 = BB.kaLeft;
B2 = RefY;
R2 = BB.kaRight;
T2 = BB.kaTop;
}
path = ((struct po *)Pointer->oRep)->poPath;
for (i = 0, pp = path; pp; i++,pp = pp->pSucc) ;
p1.nvertices = i;
p1.xy = (int*) tmalloc(i*10*sizeof(int));
p2.xy = p1.xy + i*2;
xy = p1.xy;
for (pp = path; pp; pp = pp->pSucc) {
*xy++ = pp->pX;
*xy++ = pp->pY;
}
PolygonClip(&p1,L1,B1,R1,T1);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
PolygonClip(&p1,L2,B2,R2,T2);
while (NewPolygon(&p2))
NewPoly(&p2,Pointer->oLayer);
Pointer->oInfo = SQ_GONE;
free(p1.xy);
return (True);
}
static struct p *
isec_y(p1,p2,X)
struct p *p1,*p2;
int X;
{
struct p *pp;
pp = alloc(p);
pp->pX = X;
pp->pY = p1->pY + ((X - p1->pX)*(p2->pY - p1->pY))/(p2->pX - p1->pX);
return (pp);
}
static struct p *
isec_x(p1,p2,Y)
struct p *p1,*p2;
int Y;
{
struct p *pp;
pp = alloc(p);
pp->pX = p1->pX + ((Y - p1->pY)*(p2->pX - p1->pX))/(p2->pY - p1->pY);
pp->pY = Y;
return (pp);
}
kic-2.4c/src/kic/xorbox.c 0000644 0000764 0000764 00000025752 07525346714 014766 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************/
#include "prefix.h"
#include "kic.h"
#if __STDC__
static void do_xor(struct ks*,int);
static void xor_erase(struct ks*,struct ka*);
static void xor_new_box(struct ks**,int,int,int,int,int);
static void xor_restore(struct ks*);
static void xor_final(struct ks*);
#else
static void do_xor();
static void xor_erase();
static void xor_new_box();
static void xor_restore();
static void xor_final();
#endif
/* This file supports a command which adds boxes to the database
* such as to invert a region on a layer. Previously existing
* boxes of the same layer which intersect the added box are deleted,
* and become clear areas in the added box.
*/
extern char *MenuUNDO;
extern char *MenuXOR;
void
XORbox(LookedAhead)
int *LookedAhead;
{
struct ka BB;
struct o *Pointer = NULL;
struct ks *SList = NULL;
int Undo = False;
int FirstTime = True;
int Modified = 0;
int X = 0,Y = 0;
MenuSelect(MenuXOR);
if (SelectQHead != NULL)
Desel();
top:
loop {
if (FirstTime)
ShowPrompt("Point to diagonal's endpoints.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
if (FirstTime == True) goto quit;
MenuSelect(MenuUNDO);
if (Undo == False) {
xor_restore(SList);
SList = NULL;
Modified--;
Undo = True;
}
else {
if (Not CDMakeBox(Parameters.kpCellDesc,
Parameters.kpLayer,
(BB.kaRight-BB.kaLeft),
(BB.kaTop-BB.kaBottom),
(BB.kaRight-BB.kaLeft)/2+BB.kaLeft,
(BB.kaTop-BB.kaBottom)/2+BB.kaBottom,
&Pointer)) MallocFailed();
Modified++;
SList = alloc(ks);
SList->ksPointer = Pointer;
SList->ksSucc = NULL;
do_xor(SList,Parameters.kpLayer);
Undo = False;
}
EraseBox(&BB);
Redisplay(&BB);
MenuDeselect(MenuUNDO);
continue;
case PL_PCW:
X = KicCursor.kcX;
Y = KicCursor.kcY;
SetRelative(X,Y,True);
FBSetRubberBanding('r');
break;
}
loop {
if (FirstTime)
ShowPrompt("Point to second endpoint.");
switch (PointLoop(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_UND:
FBSetRubberBanding(0);
goto top;
case PL_PCW:
BB.kaLeft = min(X,KicCursor.kcX);
BB.kaBottom = min(Y,KicCursor.kcY);
BB.kaRight = max(X,KicCursor.kcX);
BB.kaTop = max(Y,KicCursor.kcY);
if (BB.kaRight - BB.kaLeft <
LayerTable[Parameters.kpLayer].klMinDimensions ||
BB.kaRight - BB.kaLeft == 0 ||
BB.kaTop - BB.kaBottom <
LayerTable[Parameters.kpLayer].klMinDimensions ||
BB.kaTop - BB.kaBottom == 0) {
ShowPromptAndWait(
"Can't make box with side less than minimum dimension.");
continue;
}
FBSetRubberBanding(0);
SetRelative(0L,0L,False);
break;
}
break;
}
ErasePrompt();
if (Not CDMakeBox(Parameters.kpCellDesc,
Parameters.kpLayer,
(BB.kaRight-BB.kaLeft),
(BB.kaTop-BB.kaBottom),
(BB.kaRight-BB.kaLeft)/2+BB.kaLeft,
(BB.kaTop-BB.kaBottom)/2+BB.kaBottom,
&Pointer)) MallocFailed();
Modified++;
xor_final(SList);
SList = alloc(ks);
SList->ksPointer = Pointer;
SList->ksSucc = NULL;
do_xor(SList,Parameters.kpLayer);
FirstTime = False;
Undo = False;
/* make sure the new box is displayed */
CDReflect(Parameters.kpCellDesc);
EraseBox(&BB);
Redisplay(&BB);
}
quit:
if (Modified)
Parameters.kpModified = True;
FBSetRubberBanding(0);
SetRelative(0L,0L,False);
ErasePrompt();
xor_final(SList);
MenuDeselect(MenuXOR);
}
static void
do_xor(SList,Layer)
struct ks *SList;
int Layer;
{
struct g *GenDesc;
struct o *Pointer;
struct ka BB, AOI;
struct ks *SQDesc;
(void)CDBB(Parameters.kpCellDesc,SList->ksPointer,&AOI.kaLeft,
&AOI.kaBottom,&AOI.kaRight,&AOI.kaTop);
/* conditionally delete overlapping boxes, store list in Select Q */
if (Not CDInitGen(Parameters.kpCellDesc,Layer,AOI.kaLeft,AOI.kaBottom,
AOI.kaRight,AOI.kaTop,&GenDesc)) MallocFailed();
loop {
CDGen(Parameters.kpCellDesc,GenDesc,&Pointer);
if (Pointer == NULL) break;
if (Pointer == SList->ksPointer) continue;
if (Pointer->oType == CDBOX) {
Pointer->oInfo = SQ_GONE;
SQInsert(Pointer);
continue;
}
}
/* cut the holes, SList has new rectangles created */
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo != SQ_GONE) continue;
if (SQDesc->ksPointer->oType != CDBOX) continue;
CDStatusInt = CDBB(Parameters.kpCellDesc,SQDesc->ksPointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
xor_erase(SList,&BB);
}
/* replace the part of the box outside of the AOI */
for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer->oInfo != SQ_GONE) continue;
if (SQDesc->ksPointer->oType != CDBOX) continue;
CDStatusInt = CDBB(Parameters.kpCellDesc,SQDesc->ksPointer,
&BB.kaLeft,&BB.kaBottom,&BB.kaRight,&BB.kaTop);
if (BB.kaTop > AOI.kaTop) {
xor_new_box(&SList,BB.kaLeft,AOI.kaTop,
BB.kaRight,BB.kaTop,Layer);
BB.kaTop = AOI.kaTop;
}
if (BB.kaBottom < AOI.kaBottom) {
xor_new_box(&SList,BB.kaLeft,BB.kaBottom,
BB.kaRight,AOI.kaBottom,Layer);
BB.kaBottom = AOI.kaBottom;
}
if (BB.kaLeft < AOI.kaLeft) {
xor_new_box(&SList,BB.kaLeft,BB.kaBottom,
AOI.kaLeft,BB.kaTop,Layer);
}
if (BB.kaRight > AOI.kaRight) {
xor_new_box(&SList,AOI.kaRight,BB.kaBottom,
BB.kaRight,BB.kaTop,Layer);
}
}
}
static void
xor_erase(SList,BB)
struct ks *SList;
struct ka *BB;
{
struct ks *SQDesc;
struct ka BoxBB;
int X,Y,Length,Width;
int Layer;
char Type;
for (SQDesc = SList; SQDesc; SQDesc = SQDesc->ksSucc) {
if (SQDesc->ksPointer == NULL) continue;
Type = SQDesc->ksPointer->oType;
if (Type == CDBOX) {
CDBox(SQDesc->ksPointer,&Layer,&Length,&Width,&X,&Y);
BoxBB.kaLeft = X - Length/2;
BoxBB.kaRight = X + Length/2;
BoxBB.kaTop = Y + Width/2;
BoxBB.kaBottom = Y - Width/2;
if (BoxBB.kaBottom >= BB->kaTop) continue;
if (BoxBB.kaTop <= BB->kaBottom) continue;
if (BoxBB.kaRight <= BB->kaLeft) continue;
if (BoxBB.kaLeft >= BB->kaRight) continue;
Layer = SQDesc->ksPointer->oLayer;
CDDelete(Parameters.kpCellDesc,SQDesc->ksPointer);
SQDesc->ksPointer = NULL;
if (BoxBB.kaTop > BB->kaTop) {
xor_new_box(&SQDesc,BoxBB.kaLeft,BB->kaTop,
BoxBB.kaRight,BoxBB.kaTop,Layer);
BoxBB.kaTop = BB->kaTop;
}
if (BoxBB.kaBottom < BB->kaBottom) {
xor_new_box(&SQDesc,BoxBB.kaLeft,BoxBB.kaBottom,
BoxBB.kaRight,BB->kaBottom,Layer);
BoxBB.kaBottom = BB->kaBottom;
}
if (BoxBB.kaLeft < BB->kaLeft) {
xor_new_box(&SQDesc,BoxBB.kaLeft,BoxBB.kaBottom,
BB->kaLeft,BoxBB.kaTop,Layer);
}
if (BoxBB.kaRight > BB->kaRight) {
xor_new_box(&SQDesc,BB->kaRight,BoxBB.kaBottom,
BoxBB.kaRight,BoxBB.kaTop,Layer);
}
}
}
}
static void
xor_new_box(SQD,L,B,R,T,Layer)
struct ks **SQD;
int L,B,R,T;
int Layer;
{
int X,Y,DX,DY;
struct o *Pointer;
struct ks *SQTmp;
X = (L+R)/2;
Y = (B+T)/2;
DX = R-L;
DY = T-B;
if (DX < 0) DX = -DX;
if (DY < 0) DY = -DY;
if (CDMakeBox(Parameters.kpCellDesc,Layer,DX,DY,
X,Y,&Pointer) == 0) MallocFailed();
Pointer->oInfo = SQ_OLD;
if ((*SQD)->ksPointer == NULL)
(*SQD)->ksPointer = Pointer;
else {
SQTmp = alloc(ks);
SQTmp->ksPointer = Pointer;
SQTmp->ksSucc = (*SQD)->ksSucc;
(*SQD)->ksSucc = SQTmp;
(*SQD) = SQTmp;
}
}
static void
xor_restore(SList)
struct ks *SList;
{
struct ks *SQTmp, *SQPrev;
while (SList) {
if (SList->ksPointer) {
CDDelete(Parameters.kpCellDesc,SList->ksPointer);
SList->ksPointer = NULL;
}
SQTmp = SList;
SList = SList->ksSucc;
afree(SQTmp,ks);
}
for (SList = SelectQHead; SList; SList = SQTmp) {
SQTmp = SList->ksSucc;
if (SList->ksPointer->oInfo == SQ_GONE) {
SList->ksPointer->oInfo = SQ_OLD;
SList->ksPointer = 0;
}
}
SQPrev = NULL;
for (SList = SelectQHead; SList; SList = SQTmp) {
SQTmp = SList->ksSucc;
if (!SList->ksPointer) {
if (SQPrev)
SQPrev->ksSucc = SQTmp;
else
SelectQHead = SQTmp;
afree(SList,ks);
continue;
}
SQPrev = SList;
}
}
static void
xor_final(SList)
struct ks *SList;
{
struct ks *SQTmp, *SQPrev;
while (SList) {
SQTmp = SList->ksSucc;
afree(SList,ks);
SList = SQTmp;
}
for (SList = SelectQHead; SList; SList = SList->ksSucc) {
struct ks *s;
for (s = SList->ksSucc; s; s = s->ksSucc) {
if (SList->ksPointer && SList->ksPointer == s->ksPointer)
s->ksPointer = NULL;
}
}
for (SList = SelectQHead; SList; SList = SList->ksSucc) {
if (SList->ksPointer && SList->ksPointer->oInfo == SQ_GONE) {
CDDelete(Parameters.kpCellDesc,SList->ksPointer);
SList->ksPointer = NULL;
}
}
SQPrev = NULL;
for (SList = SelectQHead; SList; SList = SQTmp) {
SQTmp = SList->ksSucc;
if (!SList->ksPointer) {
if (SQPrev)
SQPrev->ksSucc = SQTmp;
else
SelectQHead = SQTmp;
afree(SList,ks);
continue;
}
SQPrev = SList;
}
}
kic-2.4c/src/kic/zoom.c 0000644 0000764 0000764 00000032004 07525346713 014414 0 ustar stevew stevew /*************************************************************************
*
* Enhanced KIC layout editor - Stephen R. Whiteley, 1992
*
*************************************************************************
* Original header:
*
* Copyright -C- 1981 Kenneth H. Keller, Giles C. Billingsley
*
* KIC is a graphics editor that was developed by the integrated
* circuits group of the Electronics Research Laboratory and the
* Department of Electrical Engineering and Computer Sciences at
* the University of California, Berkeley, California. The program
* KIC is available free of charge to any interested party.
* The sale, resale, or use of this program for profit without the
* express written consent of the Department of Electrical Engineering
* and Computer Sciences, University of California, Berkeley, California,
* is forbidden.
*
*************************************************************************/
/*
* Zoom, pan, window, etc.
*
*/
#include "prefix.h"
#include "kic.h"
extern char *MenuPAN;
extern char *MenuZOOM;
extern char *MenuWINDO;
extern char *MenuLAST;
extern char *MenuEXPND;
extern char *MenuPEEK;
void
Pan(LookedAhead)
int *LookedAhead;
{
MenuSelect(MenuPAN);
ShowPrompt("Point to center of new window.");
loop {
switch (PointLoopSafe(LookedAhead)) {
case PL_ESC:
case PL_CMD:
MenuDeselect(MenuPAN);
ErasePrompt();
return;
case PL_PCW:
SaveLastView();
InitCoarseWindow(KicCursor.kcX,KicCursor.kcY,
(int)View->kvCoarseWindow->kaWidth);
InitFineWindow(KicCursor.kcX, KicCursor.kcY);
RedisplayViewports();
FBTransfer();
}
}
}
void
Zoom(LookedAhead)
int *LookedAhead;
{
char *TypeIn;
int NewWindowWidth;
int X,Y;
MenuSelect(MenuZOOM);
ShowPrompt("New window width? (RETURN toggles full screen display) ");
TypeIn = FBEdit(NULL);
if (TypeIn == NULL) { /* esc entered */
MenuDeselect(MenuZOOM);
ErasePrompt();
return;
}
SaveLastView();
if ((sscanf(TypeIn,"%d",&NewWindowWidth) < 1) Or NewWindowWidth <= 0) {
if (View->kvControl != FULLSCREEN) {
View->kvControl = FULLSCREEN;
Parameters.kpRedisplayControl = COARSEVIEWPORTONLY;
NewWindowWidth = View->kvFineWindow->kaWidth;
View->kvCoarseWindow->kaX = View->kvFineWindow->kaX;
View->kvCoarseWindow->kaY = View->kvFineWindow->kaY;
InitCoarseWindow(View->kvCoarseWindow->kaX,
View->kvCoarseWindow->kaY,NewWindowWidth);
SetPositioning();
}
else {
Parameters.kpRedisplayControl = SPLITSCREEN;
View->kvControl = SPLITSCREEN;
X = View->kvCoarseWindow->kaX;
Y = View->kvCoarseWindow->kaY;
NewWindowWidth = View->kvCoarseWindow->kaWidth;
SetPositioning();
CenterFullView();
if (NewWindowWidth > View->kvCoarseWindow->kaWidth)
NewWindowWidth = 3*View->kvCoarseWindow->kaWidth/4;
View->kvFineWindow->kaWidth = NewWindowWidth;
InitFineWindow(X,Y);
}
}
else {
NewWindowWidth *= RESOLUTION;
if (View->kvControl == FULLSCREEN)
InitCoarseWindow(View->kvCoarseWindow->kaX,
View->kvCoarseWindow->kaY,NewWindowWidth);
else
/* zoom from fine window position */
InitCoarseWindow(View->kvFineWindow->kaX,
View->kvFineWindow->kaY,NewWindowWidth);
SetPositioning();
}
ShowParameters();
RedisplayViewports();
MenuDeselect(MenuZOOM);
*LookedAhead = False;
ErasePrompt();
FBTransfer();
return;
}
void
Windo(LookedAhead)
int *LookedAhead;
{
int NewWindowWidth, Width, Height, Tmp;
MenuSelect(MenuWINDO);
loop {
ShowPrompt("Point to endpoints of diagonal.");
switch (PointLoopSafe(LookedAhead)) {
case PL_ESC:
case PL_CMD:
goto quit;
case PL_PCW:
break;
}
FBSetRubberBanding('R');
switch (PointLoopSafe(LookedAhead)) {
case PL_ESC:
case PL_CMD:
FBSetRubberBanding(0);
goto quit;
case PL_PCW:
FBSetRubberBanding(0);
break;
}
SaveLastView();
/*
* Coarse window height is smaller than its width.
* When user points to endpoints of diagonal to define new window,
* he expects to see everything in this window after redisplay.
* To make this happen, we have to EXPAND the width enough so that
* the height that InitCoarseWindow computes is equal to the height
* the user wants.
* The following lines compute the multiplier that expands the
* width by the right amount.
*/
Width = KicCursor.kcX - KicCursor.kcPredX;
Height = KicCursor.kcY - KicCursor.kcPredY;
if (Width < 0) Width = -Width;
if (Height < 0) Height = -Height;
Tmp = Height * View->kvCoarseViewport->kaWidth/
View->kvCoarseViewport->kaHeight;
NewWindowWidth = max(Width,Tmp);
Height /= 2;
Width /= 2;
if (NewWindowWidth <= 0) NewWindowWidth = RESOLUTION;
InitCoarseWindow( min(KicCursor.kcX,KicCursor.kcPredX)+Width,
min(KicCursor.kcY,KicCursor.kcPredY)+Height,NewWindowWidth);
InitFineWindow(min(KicCursor.kcX,KicCursor.kcPredX)+Width,
min(KicCursor.kcY,KicCursor.kcPredY)+Height);
SetPositioning();
ShowParameters();
RedisplayViewports();
FBTransfer();
}
quit:
MenuDeselect(MenuWINDO);
ErasePrompt();
}
/* The three routines that follow have been modified to keep
* track of the the display status of the last view (^T), and the fine
* viewport magnification. The last view is updated after every change
* of either window. Also, the saved window name is assigned a
* letter instead of prompting the user for a name.
*/
void
LastView()
{
int i;
struct kw Last;
struct kw *Tmp;
char oldMenu;
int EscWasReturned = 0;
Last.kwLastWindowX = View->kvCoarseWindow->kaX;
Last.kwLastWindowY = View->kvCoarseWindow->kaY;
Last.kwLastFineWindowX = View->kvFineWindow->kaX;
Last.kwLastFineWindowY = View->kvFineWindow->kaY;
Last.kwLastWindowWidth = View->kvCoarseWindow->kaWidth;
Last.kwLastFineWindowWidth = View->kvFineWindow->kaWidth;
Last.kwExpand = Parameters.kpExpandInstances;
Last.kwExpandFineOnly = Parameters.kpExpandFineViewportOnly;
(Last.kwName)[5] = View->kvFineViewportOnBottom;
(Last.kwName)[6] = View->kvControl;
i = 0;
for (Tmp = Parameters.kpWindowStack; Tmp; Tmp = Tmp->kwNext)
AmbiguityMenu[i++].mEntry = Tmp->kwName;
AmbiguityMenu[i].mEntry = NULL;
FixMenuPrefix(AmbiguityMenu);
if (i > 1) {
/* Show ambiguity menu. */
oldMenu = Parameters.kpMenu;
Parameters.kpMenu = AMBIGUITYMENU;
ShowMenu(AmbiguityMenu);
/* Which viewport is user interested in? */
ShowPrompt("Point to the name of the desired view.");
loop {
int dummy;
switch (PointLoopSafe(&dummy)) {
case PL_ESC:
EscWasReturned = 1;
break;
case PL_CMD:
break;
case PL_PCW:
ShowPrompt("You aren't pointing at the menu.");
continue;
}
break;
}
Parameters.kpMenu = oldMenu;
ShowCommandMenu();
if (EscWasReturned) goto quit;
/* find new view */
for (Tmp = Parameters.kpWindowStack; Tmp; Tmp = Tmp->kwNext)
if (strncmp(Tmp->kwName,Parameters.kpCommand,
MenuViewport.kaRight-MenuViewport.kaLeft+1) == 0){
break;
}
}
else
Tmp = Parameters.kpWindowStack;
/* The status of the fine window positioning is stored in
* the name field, as is full screen mode flag.
*/
View->kvFineViewportOnBottom = (Tmp->kwName)[5];
View->kvControl = (Tmp->kwName)[6];
InitViewport();
/* change to new viewport */
InitCoarseWindow(Tmp->kwLastWindowX,Tmp->kwLastWindowY,
Tmp->kwLastWindowWidth);
SetPositioning();
InitFineWindow(Tmp->kwLastFineWindowX,Tmp->kwLastFineWindowY);
if (Tmp->kwExpand) {
MenuSelect(MenuEXPND);
Parameters.kpExpandInstances = True;
}
else {
MenuDeselect(MenuEXPND);
Parameters.kpExpandInstances = False;
}
if (Tmp->kwExpandFineOnly) {
MenuSelect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = True;
}
else {
MenuDeselect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = False;
}
Parameters.kpWindowStack->kwLastWindowX = Last.kwLastWindowX;
Parameters.kpWindowStack->kwLastWindowY = Last.kwLastWindowY;
Parameters.kpWindowStack->kwLastFineWindowX = Last.kwLastFineWindowX;
Parameters.kpWindowStack->kwLastFineWindowY = Last.kwLastFineWindowY;
Parameters.kpWindowStack->kwLastWindowWidth = Last.kwLastWindowWidth;
Parameters.kpWindowStack->kwLastFineWindowWidth = Last.kwLastFineWindowWidth;
Parameters.kpWindowStack->kwExpand = Last.kwExpand;
Parameters.kpWindowStack->kwExpandFineOnly = Last.kwExpandFineOnly;
(Parameters.kpWindowStack->kwName)[5] = (Last.kwName)[5];
(Parameters.kpWindowStack->kwName)[6] = (Last.kwName)[6];
ShowParameters();
RedisplayViewports();
FBTransfer();
quit:
MenuDeselect(MenuLAST);
ErasePrompt();
}
void
RestoreLastView()
{
struct kw *Tmp;
Tmp = Parameters.kpWindowStack;
/* The status of the fine window positioning is stored in
* the name field, as is full screen mode flag.
*/
View->kvFineViewportOnBottom = (Tmp->kwName)[5];
View->kvControl = (Tmp->kwName)[6];
InitViewport();
/* change to new viewport */
InitCoarseWindow(Tmp->kwLastWindowX,Tmp->kwLastWindowY,
Tmp->kwLastWindowWidth);
SetPositioning();
InitFineWindow(Tmp->kwLastFineWindowX,Tmp->kwLastFineWindowY);
if (Tmp->kwExpand) {
MenuSelect(MenuEXPND);
Parameters.kpExpandInstances = True;
}
else {
MenuDeselect(MenuEXPND);
Parameters.kpExpandInstances = False;
}
if (Tmp->kwExpandFineOnly) {
MenuSelect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = True;
}
else {
MenuDeselect(MenuPEEK);
Parameters.kpExpandFineViewportOnly = False;
}
ShowParameters();
RedisplayViewports();
}
void
SaveLastView()
{
/*
* Parameters.kpWindowStack is always the last view.
*/
if (Parameters.kpWindowStack == NULL) {
if ((Parameters.kpWindowStack = alloc(kw)) == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
strcpy(Parameters.kpWindowStack->kwName,"prev");
Parameters.kpWindowStack->kwNext = NULL;
}
Parameters.kpWindowStack->kwLastWindowX = View->kvCoarseWindow->kaX;
Parameters.kpWindowStack->kwLastWindowY = View->kvCoarseWindow->kaY;
Parameters.kpWindowStack->kwLastFineWindowX = View->kvFineWindow->kaX;
Parameters.kpWindowStack->kwLastFineWindowY = View->kvFineWindow->kaY;
Parameters.kpWindowStack->kwLastWindowWidth =
View->kvCoarseWindow->kaWidth;
Parameters.kpWindowStack->kwLastFineWindowWidth =
View->kvFineWindow->kaWidth;
Parameters.kpWindowStack->kwExpand = Parameters.kpExpandInstances;
Parameters.kpWindowStack->kwExpandFineOnly =
Parameters.kpExpandFineViewportOnly;
(Parameters.kpWindowStack->kwName)[5] = View->kvFineViewportOnBottom;
(Parameters.kpWindowStack->kwName)[6] = View->kvControl;
}
void
SaveViewOnStack()
{
int i = 0;
char buf[32];
struct kw *New, *Tmp;
New = alloc(kw);
if (New == NULL) {
CDStatusInt = CDMALLOCFAILED;
MallocFailed();
}
New->kwLastWindowX = View->kvCoarseWindow->kaX;
New->kwLastWindowY = View->kvCoarseWindow->kaY;
New->kwLastFineWindowX = View->kvFineWindow->kaX;
New->kwLastFineWindowY = View->kvFineWindow->kaY;
New->kwLastWindowWidth = View->kvCoarseWindow->kaWidth;
New->kwLastFineWindowWidth = View->kvFineWindow->kaWidth;
New->kwExpand = Parameters.kpExpandInstances;
New->kwExpandFineOnly = Parameters.kpExpandFineViewportOnly;
(New->kwName)[5] = View->kvFineViewportOnBottom;
(New->kwName)[6] = View->kvControl;
if (Parameters.kpWindowStack == NULL)
SaveLastView();
New->kwNext = NULL;
for (Tmp = Parameters.kpWindowStack; Tmp->kwNext; i++,Tmp = Tmp->kwNext) ;
Tmp->kwNext = New;
sprintf(buf,"Current view assigned to: %c",'A'+i);
ShowPrompt(buf);
New->kwName[0] = 'a'+ i;
New->kwName[1] = '\0';
}
kic-2.4c/src/msw_package/ 0000755 0000764 0000764 00000000000 12427316655 014777 5 ustar stevew stevew kic-2.4c/src/msw_package/Makefile 0000644 0000764 0000764 00000000000 12427311414 016411 0 ustar stevew stevew kic-2.4c/config.sub 0000555 0000764 0000764 00000105124 12427243544 013707 0 ustar stevew stevew #! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2013-04-24'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# 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 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-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.
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
c54x)
basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | amd64-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-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
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aros)
basic_machine=i386-pc
os=-aros
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16 | cr16-*)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | 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*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
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
os=-msys
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
openrisc | openrisc-*)
basic_machine=or32-unknown
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tile*)
basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
z80-*-coff)
basic_machine=z80-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
;;
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
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
;;
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
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
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-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* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-nacl*)
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
;;
m68*-cisco)
os=-aout
;;
mep-*)
os=-elf
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-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
;;
-cnk*|-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
kic-2.4c/startup/ 0000755 0000764 0000764 00000000000 12427316655 013431 5 ustar stevew stevew kic-2.4c/startup/ltab.trw 0000644 0000764 0000764 00000000147 07525346715 015116 0 ustar stevew stevew 10
JUNC 1 0
TRIE 2 0
SIOA 3 0
WIRA 4 0
RESI 5 0
SIOB 6 0
WIRB 7 0
GOLD 8 0
TEXT 9 0
NOSI 10 0
kic-2.4c/startup/kic_tech.300 0000644 0000764 0000764 00000004136 07525346715 015435 0 ustar stevew stevew Path? ( . )
LayerName? SUBS
RGB? 0 5 200
Symbolic? n
Filled? n
AltFilled? n
MinDimensions 0
StreamData? 1 0
LayerName? HTS1
RGB? 10 190 15
Symbolic? n
Filled? 11 22 40 88 11 02 44 88 outline
AltFilled? 11 22 40 88 11 02 44 88 outline
MinDimensions 0
StreamData? 2 0
LayerName? CONT
RGB? 255 250 5
Symbolic? n
Filled? 00 00 10 00 00 00 00 00 outline
AltFilled? n
MinDimensions 0
StreamData? 3 0
LayerName? RESI
RGB? 255 170 227
Symbolic? n
Filled? 11 0e 02 62 91 28 48 90 outline
AltFilled? 88 44 22 11 88 44 22 11 outline
MinDimensions 0
StreamData? 4 0
LayerName? DIE0
RGB? 180 10 12
Symbolic? n
Filled? 10 10 10 10 10 10 10 10 outline
AltFilled? 11 11 11 11 11 11 11 11 outline
MinDimensions 0
StreamData? 5 0
LayerName? WIR0
RGB? 0 40 130
Symbolic? n
Filled? 01 02 04 08 10 20 40 80 outline
AltFilled? 01 02 04 08 10 20 40 80 outline
MinDimensions 0
StreamData? 6 0
LayerName? DIE1
RGB? 0 150 5
Symbolic? n
Filled? 00 00 10 00 00 00 00 00 outline
AltFilled? 00 00 00 ff 00 00 00 ff outline
MinDimensions 0
StreamData? 7 0
LayerName? WIR1
RGB? 250 2 250
Symbolic? n
Filled? 80 40 20 10 08 04 02 01 outline
AltFilled? 80 40 20 10 08 04 02 01 outline
MinDimensions 0
StreamData? 8 0
LayerName? text
RGB? 250 255 250
Symbolic? n
Filled? n
AltFilled? n
MinDimensions 0
StreamData? 9 0
LayerName? algn
RGB? 155 170 130
Symbolic? n
Filled? n
AltFilled? n
AltInvisible
MinDimensions 0
StreamData? 10 0
LayerName? nDRC
RGB? 200 0 165
Symbolic? n
Filled? n
AltFilled? n
AltInvisible
MinDimensions 0
StreamData? 11 0
LayerName? y0
RGB? 70 200 200
Symbolic? n
Filled? 81 42 24 99 42 24 42 81
AltFilled? n
AltInvisible
MinDimensions 0
StreamData? 12 0
LayerName? y1
RGB? 190 90 197
Symbolic? n
Filled? 01 02 04 08 10 20 40 80 outline
AltFilled? n
AltInvisible
MinDimensions 0
StreamData? 13 0
Highlighting 215 220 230
Background 0 0 0
MenuText 10
MenuSelect 11
MenuHighlighting 5
MenuPrompt 1
MoreText 10
FineGrid 5
CoarseGrid 6
InstanceBox 10
InstanceName 12
InstanceSize 5
GridSpacing 1
GridStyle 204
AltShowGrid
RoundFlashSides 40
AltDevice prn
AltResolution 300
AltFormat p
Snapping 2
FineViewportOnSide
FontName
BeepVolume 0
kic-2.4c/startup/kic_help.txt 0000644 0000764 0000764 00000136574 10270230541 015747 0 ustar stevew stevew !!KEYWORD
help
!!TITLE
help
!!TEXT
KIC is distributed by Whiteley Research Inc., www.wrcad.com.
Welcome to the KIC help system. Point to the commands for a
description of their function. Exit the help system by hitting
ESCAPE.
!!SUBTOPICS
commands
techfile
electric
keyboard
pointer
scrn
utilities
!!KEYWORD
a45s
!!TITLE
45s
!!TEXT
When on, wire and polygon vertices are constrained to form
angles of multiples of 45 degrees.
!!KEYWORD
adlyr
!!TITLE
adlyr
!!TEXT
Add a layer to the layer menu.
!!SEEALSO
rmove
!!KEYWORD
adprp
!!TITLE
adprp
!!TEXT
Add a property to the selected objects. A property consists
of a value and a string, and is stored in the symbol file.
Properties are not used within KIC, but may be needed for
future interfaces.
!!SEEALSO
rmprp
show
!!KEYWORD
alloc
!!TITLE
alloc
!!TEXT
Print the number of objects in the current cell.
!!KEYWORD
arc
!!TITLE
arc
!!TEXT
Create an arc. The sides command can be used to reset the
number of segments used.
!!SEEALSO
sides
!!KEYWORD
area
!!TITLE
area
!!TEXT
Set area select mode. Selected objects overlap the rectangle
defined by two successive point operations.
!!SEEALSO
selec
layer
!!KEYWORD
array
!!TITLE
array
!!TEXT
The user is prompted for parameters for cell array creation.
!!SEEALSO
place
!!KEYWORD
attri
!!TITLE
attri
!!TEXT
Change to the Attrubutes Menu. The Attributes menu contains
commands for modifying the presentation format of KIC.
!!KEYWORD
bang
!!TITLE
!
!!TEXT
Text following ! is processed by an operating system shell.
This can only be used for simple commands, which do not
require interactivity. However, if no text follows "!",
KIC places the user in an interactive subshell. In DOS,
type "exit" to return to KIC.
!!KEYWORD
basic
!!TITLE
basic
!!TEXT
Change to the Basic Menu. The Basic Menu contains commands
for creating geometries and editing new cells.
!!KEYWORD
blink
!!TITLE
blink
!!TEXT
Set layer to blink (not implemented).
!!KEYWORD
boxes
!!TITLE
boxes
!!TEXT
Create rectangles on the currently selected layer. Point
to the diagonal corners of the rectangle. The first corner
is marked during rectangle creation. If electrical parameters
are specified in the technology file for the current layer,
a readout of an electrical parameter (capacitance, resistance,
or transmission line parameters) is provided for the newly
created rectangle. Using pointer device button 4 will provide
the readout, without actually creating the rectangle.
!!SEEALSO
button4
electric
!!KEYWORD
break
!!TITLE
break
!!TEXT
Divide geometries along a horizontal or vertical line. If
the current rotation is 0 or 180, the line is vertical,
otherwise it is horizontal.
!!SEEALSO
rotate
!!KEYWORD
button1
!!TITLE
button1
!!TEXT
This button is used for point operations. The Enter key
simulates a button 1 event, at the current pointer location.
!!KEYWORD
button2
!!TITLE
button2
!!TEXT
This button performs a pan operation in full screen mode, or
sets the fine viewport center in split screen mode. In DOS,
ctrl-ENTER simulates a button 2 event.
!!KEYWORD
button3
!!TITLE
button3
!!TEXT
This button, used twice, performs a window operation in full
screen mode, or defines a new fine window in split screen mode.
If the DOS keyboard pointer is in use, alt-ENTER simulates a
button 3 event.
!!KEYWORD
button4
!!TITLE
button4
!!TEXT
This button performs no operation, but updates the coordinate
parameters as displayed on-screen. The space bar simulates
a button 4 event, as does the Delete key under DOS. Most
common pointing devices have only three buttons, in which
case the button 4 function is available only from the keyboard.
!!SEEALSO
spacebar
!!KEYWORD
bw
!!TITLE
bw
!!TEXT
Show the number of features drawn per second.
!!KEYWORD
chlyr
!!TITLE
chlyr
!!TEXT
Change the layer of the selected geometries. The user is
prompted for the new layer.
!!SEEALSO
selec
area
!!KEYWORD
ciftokic
!!TITLE
ciftokic
!!TEXT
Usage: ciftokic [options] [cif_file]
options:
-Lmicprl Microns per lambda (default 1.0).
-prefix (cif dialect) where prefix =
k Generated from KIC
a Stanford: A Stanford symbol name follows a DS command as
in (PadIn);
b NCA: An NCA symbol name follows a DS command as in
(PadIn);
h IGS: A KIC or IGS symbol name follows a DS command
as in 9 PadIn;
i Icarus: An Icarus symbol name follows a DS command as
in (9 PadIn);
q Squid: A Squid symbol name follows a DS command as in
9 /usr/joe/PadIn;
s Sif: A Sif symbol name follows a DS command as in
(Name: PadIn);
n none of the above\n");
Will prompt for cif input file name if not specified, hit
return for help.
!!KEYWORD
cnams
!!TITLE
cnams
!!TEXT
When on, display the names of unexpanded cells.
!!KEYWORD
cntxt
!!TITLE
cntxt
!!TEXT
With this switch on, the context is displayed during a subedit.
The context is the surrounding geometry in cells other than the
cell being edited.
!!SEEALSO
push
pop
!!KEYWORD
cnvrt
!!TITLE
cnvrt
!!TEXT
KIC has built-in translators for Calma GDSII and CIF formats.
This command brings up a submenu containing commands which
perform the translations. A file "convert.log" is created
in the current directory, which contains a record of messages
emitted during the conversion.
!!SUBTOPICS
frcif
frgds
tocif
togds
!!KEYWORD
color
!!TITLE
color
!!TEXT
The color command presents a submenu allowing the user to
change the colors of various screen objects. If KIC is
running on systems with more than 32 colors available, the
screen colors are separate from the layer colors. Other-
wise the screen colors are mapped into the layer colors.
The objects that are presented in the menu are the high-
lighting and background colors, the menu text, selcted text,
and highlighting colors, the prompt line color, the colors
used for the "more" text, the grid colors, and the colors
used to display unexpanded instances. These colors are set
either with the +r, etc. buttons, or by pointing to the
layer table in the merged color mode.
!!SEEALSO
plusretc
!!KEYWORD
commands
!!TITLE
Menu Commands
!!TEXT
KIC has two main menus. The Basic menu contains commands
for creating geometries and otherwise modifying cells.
The Attributes menu contains commands which modify the
display. In addition, the Properties menu allows property
strings and values to be associated with objects (not used
by KIC presently), and the Debug menu has commands for
displaying some internal parameters. Some commands provide
temporary submenus.
Commands are executed by pointing at the menu, or by typing
the command prefix shown in upper case (input is case
insensitive). Commands can be exited by selecting another
command in most cases, or by hitting the ESCAPE key. Some
commands are switches which remain in effect until selected
again.
!!SUBTOPICS
a45s
adlyr
adprp
alloc
arc
area
array
attri
basic
blink
boxes
break
bw
chlyr
cnams
cntxt
cnvrt
color
copy
crsym
cursr
debug
delet
desel
dimen
dir
donut
edit
erase
expnd
fill
flash
flatn
font
grid
hcopy
help
label
labls
last
layer
llref
logo
mark
mirror
move
pan
peek
place
plusretc
polyg
pop
prpty
push
quit
rdraw
rgb
rmove
rmprp
rotate
save
selec
show
sides
snap
strch
tbrl
undo
updat
view
visib
width
windo
wires
xor
zoom
!!KEYWORD
copy
!!TITLE
copy
!!TEXT
Copy an object. If objects are previously selected, the group
will be copied to new locations. If no objects have been
selected, the user is asked to point to an object to copy.
Responding to the prompts, the user first points to a ref-
erence point, then to a destination. The copy is produced
such that the reference point falls on the destination point.
The orientation of the copied object is altered according to
the current transformation. Multiple copies are made by
simply pointing to additional destinations.
!!SEEALSO
move
rotate
mirror
!!KEYWORD
crsym
!!TITLE
crsym
!!TEXT
Create a new symbol file from the currently selected objects.
The user is prompted for a name for the new file.
!!SEEALSO
selec
area
flatn
!!KEYWORD
ctrla
!!TITLE
ctrl-a
!!TEXT
Entering ^A has the same effect as the exit command.
!!SEEALSO
quit
!!KEYWORD
ctrle
!!TITLE
ctrl-e
!!TEXT
Pressing ^E prompts the user for a coordinate pair, which
is then used in a point operation. ^C has the same effect
as ^E.
!!KEYWORD
ctrlf
!!TITLE
ctrl-f
!!TEXT
After hitting ^F, the user can point once to pan in full screen
mode, or define the center of the fine window in split screen
mode.
!!SEEALSO
pan
button2
!!KEYWORD
ctrlg
!!TITLE
ctrl-g
!!TEXT
After hitting ^G, the user points twice to define a new window
in full screen mode, or a new fine window if in split screen
mode.
!!SEEALSO
windo
button3
!!KEYWORD
ctrll
!!TITLE
ctrl-l
!!TEXT
After hitting ^L, the user is prompted for a number, which
corresponds to a layer. The current layer is set to that
layer.
!!SEEALSO
fkeys
!!KEYWORD
ctrln
!!TITLE
ctrl-n
!!TEXT
A view can be saved at any time by hitting ^N. The view is
assigned a letter, which may be recalled with the Last command.
!!SEEALSO
last
!!KEYWORD
ctrlt
!!TITLE
ctrl-t
!!TEXT
^T toggles whether the fine viewport is on the bottom or to
the right in split screen mode.
!!SEEALSO
zoom
!!KEYWORD
ctrlv
!!TITLE
ctrl-v
!!TEXT
Print the KIC version number on the message line.
!!KEYWORD
cursr
!!TITLE
cursr
!!TEXT
Under the X window system, a variety of cursors are available.
This command produces a menu from which to choose. Point to
the desired cursor, then press ENTER.
!!SEEALSO
xwindows
!!KEYWORD
debug
!!TITLE
debug
!!TEXT
Change to the Debug Menu. The Debug Menu has commands for
viewing some internal parameters.
!!KEYWORD
delet
!!TITLE
delet
!!TEXT
Delete the selected objects (can be undone).
!!KEYWORD
desel
!!TITLE
desel
!!TEXT
Deselect the currently selected objects.
!!SEEALSO
selec
!!KEYWORD
dimen
!!TITLE
dimen
!!TEXT
Set the minimum dimension of a layer.
!!KEYWORD
dir
!!TITLE
dir
!!TEXT
Display a listing of symbol files found along the KIC path.
!!KEYWORD
donut
!!TITLE
donut
!!TEXT
Create a 360 degree arc with a hole. The number of segments
used can be altered with the sides command.
!!SEEALSO
sides
!!KEYWORD
edit
!!TITLE
edit
!!TEXT
Load a cell for editing.
!!KEYWORD
electric
!!TITLE
Electrical Parameters
!!TEXT
KIC provides the facility for generating a readout of elec-
trical parameters while creating rectangles. One must supply
the appropriate information to the desired layers in the
technology file. There are three possibilities: resistance,
capacitance, or microstripline parameters. The microstripline
parameters assume that propagation is along the longer
dimension of the rectangle. The resistance readout provides
information for both orientations. The microstripline model
assumes that the underlying area contains ground plane, with a
specified dielectric thickness, i.e., no account is taken of
the "real" geometry.
!!SEEALSO
boxes
techfile
!!KEYWORD
enter
!!TITLE
Enter
!!TEXT
Pressing Enter (or Return on some keyboards) initiates a point
operation at the current pointer location, with the same effect
as pressing mouse button 1.
!!SEEALSO
button1
!!KEYWORD
erase
!!TITLE
erase
!!TEXT
Rectanglar regions of polygons and boxes can be erased with
this command. The user points twice to define the diagonal
of the region to be erased. If in layer mode, only the
current layer is erased, otherwise all layers are erased.
Selected objects are not erased.
!!SEEALSO
layer
selec
!!KEYWORD
escape
!!TITLE
Esc
!!TEXT
The ESCAPE key flushes the keyboard buffer, and terminates
most commands.
!!KEYWORD
expnd
!!TITLE
expnd
!!TEXT
When on, subcells are shown in expanded (all features visible)
form. Otherwise, only the bounding box is shown.
!!SEEALSO
peek
!!KEYWORD
fill
!!TITLE
fill
!!TEXT
Edit the fill patterns assigned to the layers. The left
column of the display contains solid and empty patterns,
and the editing window. Second to left is a preview of
the pattern in the editing window. The remaining columns
contain sample fill patterns. Following the prompt, one
loads a fill pattern by pointing to either a stippled layer
in the layer menu, or one of the sample fillpattern fields.
Once loaded, the pattern can be edited by pointing at pixel
locations in the editing window. This toggles the pixels
on and off. When finished, point to the preview panel,
then to the desired layer in the layer menu. Empty or
solid fill patterns can not be loaded from layers. An
empty or solid fill can be assigned to a layer by first
pointing at the appropriate location in the left column,
then to the desired layer. Point to the fill command menu
entry to end the session.
!!SEEALSO
updat
!!KEYWORD
fkeys
!!TITLE
function keys
!!TEXT
Under DOS, pressing the function keys F1-F12 selects one of the
12 displayed layers in the layer table. If there are more than
12 layers defined, then a "more" button will exist in the layer
menu. Pointing at the more button will cycle through the layer
table, showing 12 layers at a time.
!!KEYWORD
flash
!!TITLE
flash
!!TEXT
Create a disk object. The number of sides can be altered with
the sides command.
!!SEEALSO
sides
!!KEYWORD
flatn
!!TITLE
flatn
!!TEXT
Smash the chosen subcells (and sub-subcells they contain)
into the parent cell. The hierarchy is flattened.
!!KEYWORD
font
!!TITLE
font
!!TEXT
Under X windows, the user has a choice of fonts. The same font is
used for all text in KIC. This command displays a list of
available fonts. Select a font by pointing at the list, then hit
^D (control-d).
In the native-Windows version, this command can be used to change
the size of the font. The user is prompted for a character cell
size, in a form like "7x13".
In either case, the updat command will save the new font in the
technology file, using the FontName keyword. Note that under
Windows, the FontName is in the form "WxH", for example "8x15",
whereas under UNIX the FontName is the name of an X font.
!!SEEALSO
updat
xwindows
!!KEYWORD
frame
!!TITLE
frame
!!TEXT
This sets the view produced in the hardcopy, which
otherwise defaults to the full cell. Point at the
diagonal endpoints of the region to be plotted.
This region will appear in the plot. Point at the
command button again to turn this feature off, and
plot the full cell. The plot is actually generated
with the "go" command.
!!KEYWORD
frcif
!!TITLE
frcif
!!TEXT
This command creates a family of KIC symbol files from a CIF
database file. The user is prompted for the name of the CIF
file. Care should be taken to avoid overwriting existing
files during conversion, as there is no checking. The user
is reminded of this by a message. The converter has built-in
intelligence to determine the style of CIF to be converted,
which is one of
KIC: symbol name follows a DS command as in 9 PadIn;
IGS: symbol name follows a DS command as in 9 PadIn;
Stanford: symbol name follows a DS command as in (PadIn);
NCA: symbol name follows a DS command as in (PadIn);
Icarus: symbol name follows a DS command as in (9 PadIn);
Sif: symbol name follows a DS command as in (Name: PadIn);
none: No symbol names.
If no symbol name can be found, symbol files are named
"symbolN" where N is the number of the symbol as known to CIF.
Layers which are integers are mapped into the current layer
table, if the table entry corresponding to the number has been
defined. Otherwise, the line is left as is, e.g., "L 64;"
would appear as "L 64;" in the KIC files (which would have to
be altered later). Similarly, layer names which are not found
in the layer table remain unchanged.
!!SEEALSO
ciftokic
!!KEYWORD
frgds
!!TITLE
frgds
!!TEXT
Using this command, a GDSII (Stream) file can be expanded into
KIC files. The file and symbol names are altered to be
compatible with DOS in DOS versions of KIC, and an alias file
"dos__str.als" is created in the current directory if it
doesn't exit, and is added to if it does. This file
provides the mapping between the original and new symbol names,
and is only created if a name required alteration. The user
is prompted for the name of the Stream file. The converter
creates KIC files, one for each symbol found in the Stream
file. Care should be taken to avoid overwriting existing
files during conversion, as there is no checking for name
collisions. The layer mapping is taken from the technology
file. If the datatype obtained from the dotkic file is -1, the
datatype given in the input is not comparison tested. In this
case, only the layer number is significant. Otherwise, the
datatype must match the specified datatype for the layer.
The valid stream layer numbers and data types are 0-255.
!!SEEALSO
techfile
strtokic
!!KEYWORD
go
!!TITLE
go
!!TEXT
Actually generate the hardcopy plot.
!!KEYWORD
grid
!!TITLE
grid
!!TEXT
Modify the grid. If in the Attributes menu, the color and
pattern can be modified, in addition to the spacing. Hit
ENTER to toggle the grid on and off.
!!SEEALSO
snap
!!KEYWORD
hcopy
!!TITLE
hcopy
!!TEXT
This command brings up a submenu for generation of hard
copy plots. At present, the HP Laserjet PCL format and
PostScript are supported. To improve visibility of the
plots, the layer fill patterns are set separately and may
differ from those normally displayed. These alternate
fill patterns, grid display, and layer visibility choices
are in effect only when the hcopy command is active. The
fill command in the submenu works identically to the normal
fill command, however the alternate fill patterns are used.
The grid command allows modification of the grid style
displayed in the plot. Layers can be made invisible
(or visible) only during plotting with the visib command.
These choices can be saved (in the technology file) with
the updat command in the attriubutes menu. The prn command
allows a choice of output device driver or file names.
The resol command can provide different print resolutions.
Higher resolution gives better print quality but requires
more time to produce. Also, higher resolution causes
the fill patterns to become finer, which may make layer
differentiation more difficult. The hctype command is used
to determine the plot format, currently 'h' for HP PCL or
'p' for PostScript. Ordinarily, the full cell is plotted,
notwithstanding what is displayed on the screen. The
frame command allows a portion of the cell to be plotted.
The plot is actually generated with the go command.
Rotated/mirrored text is not supported in PCL.
!!SUBTOPICS
frame
go
hctyp
prn
resol
!!SEEALSO
fill
visib
techfile
!!KEYWORD
hctyp
!!TITLE
hctyp
!!TEXT
Set the format of the hardcopy output. Currently, this can
be either 'h' for HP LaserJet PCL, or 'p' for PostScript.
!!KEYWORD
helpprog
!!TITLE
help
!!TEXT
This is a stand-alone version of the KIC help utility.
Invocation is
help [keyword]
where keyword is the name of an internal item.
Without an argument, entry is to the top level. The help
database is stored in the startup directory as
"kic_help.txt". This is a text file, which can be edited
with any text editor. KIC doesn't care if this is in DOS
or UNIX text format. The file is a collection of records,
as below. Each data item is keyed by one of the following
keywords, which must occupy a single line starting in the
first column: !!KEYWORD, !!TITLE, !!TEXT, !!SUBTOPICS, and
!!SEEALSO.
!!KEYWORD
word
!!TITLE
A Title for Word
!!TEXT
This is the text that describes the entry. The next two
fields (!!SUBTOPICS and !!SEEALSO) are optional. They are
lists of other keywords.
!!SUBTOPICS
subword
subword2
!!SEEALSO
anotherword
!!KEYWORD
kbrd
!!TITLE
Keyboard Pointer
!!TEXT
If a Microsoft compatible mouse or digitizing pad is not
available, the keyboard can be used as a pointer. The
marker is moved with the arrow keys. Holding down the
control key provides fine translation, and coarse trans-
lation is available by holding down the alt key, along
with the desired arrow key. See the button entries for
the keyboard keys used to simulate the various button
presses.
!!SEEALSO
button1
button2
button3
button4
!!KEYWORD
keyboard
!!TITLE
Keyboard Commands
!!TEXT
Menu commands can be entered from the keyboard by typing
the prefix upper cased in the menu entries. Escape, ^X,
and ^U clear the keyboard buffer. In addition, there are
a few control character commands as listed below. Input
is case insensitive.
!!SUBTOPICS
bang
ctrla
ctrle
ctrlf
ctrlg
ctrll
ctrln
ctrlt
ctrlv
enter
escape
fkeys
spacebar
!!KEYWORD
kictocif
!!TITLE
kictocif
!!TEXT
Usage: kictocif [options] [root_kic_cell]
options (case insensitive):
-Ocifname CIF file name to create.
-S Convert symbolic layers only.
-D Convert detail layers only.
-Pc c = Program prefix (a Stanford, b NCA, h IGS,
i Icarus, k KIC, q Squid, s SIF).
-Text Use layers in tech.ext.
-Lmicprl Microns per lambda (default 1.0).
Will prompt for root kic cell if not specified, hit
return for help.
!!KEYWORD
kictostr
!!TITLE
kictostr
!!TEXT
Usage: kictostr [options] [root_kic_cell]
options (case insensitive):
-C Convert only cells found in current directory.
-Zname Stream library name (default "KICTOSTREAM").
-Ostrname Stream file name to create. (default is root
kic cell name with .str extension)
-S Convert symbolic layers only.
-D Convert detail layers only.
-Xfilename Use filename as layer table reference ("ltab")
file, default is to use layers from the technology
file (StreamData lines).
-Text Use layers in tech.ext.
-N Parse layer names for stream layers, KIC layers
must be named "NNDD" (num datatype). Supersedes
-X, -T.
-Lmicprl Microns per lambda (default 1.0).
-Mupermic Database units per micron (default 100.0).
Will prompt for kic cell name to convert if not supplied,
hit return for help.
If the datatype obtained from the technology or ltab file is
outside of 0-255, the written datatype is 0. The valid stream
layer numbers and data types are 0-255. In DOS versions, the
file "dos__str.als" is used to map DOS cell names to stream
names. This file is created by the stream to KIC converters.
!!KEYWORD
label
!!TITLE
label
!!TEXT
Create a text label. The text will be rotated or mirrored
according to the current transform.
!!SEEALSO
rotate
mirror
!!KEYWORD
labls
!!TITLE
labls
!!TEXT
When on, labels will be displayed in the coarse viewport in
split screen mode. Otherwise, they will be displayed only
in the fine viewport.
!!KEYWORD
last
!!TITLE
last
!!TEXT
Display the last view, or show a selection menu of views
saved with the ^N command.
!!SEEALSO
ctrln
!!KEYWORD
layer
!!TITLE
layer
!!TEXT
When on, the selections will be layer specific. Otherwise,
any object pointed to or within the selection area will be
selected. When on, only objects on the current layer will be
selected. Instances are selected during a layer specific
point select if there is no other qualifying geometry.
!!KEYWORD
llref
!!TITLE
llref
!!TEXT
When this switch is on, cells are placed such that the lower
left corner of the bounding box is used as the reference,
i.e., the cell is rotated or mirrored around this point
according to the current transform, and placed so this point
corresponds to where the user pointed. Otherwise, the origin
of the subcell is used as the reference.
!!KEYWORD
logo
!!TITLE
logo
!!TEXT
The logo command allows the creation of physical text subcells
for labelling, corporate identification, etc. The text is
placed on the current layer in a cell which is named for the
first 8 characters in the string, with a .N extension if
necessary for uniqueness, with N being an integer. After the
cell is created, it can be placed with a point operation.
The size of the text is controlled by the pixel size, which is
given in microns. For the default font supplied, the character
height is about 50 times the pixel size.
!!KEYWORD
mark
!!TITLE
mark
!!TEXT
When on, instances will be marked (obsolete).
!!KEYWORD
mirror
!!TITLE
MX,MY
!!TEXT
Add mirroring about X or Y to the current transform. This
will affect moved or copied objects, and newly placed
instances.
!!SEEALSO
rotate
!!KEYWORD
move
!!TITLE
move
!!TEXT
Move an object. If objects are previously selected, the group
will be moved. If no object has been selected, the user is
requested to point to an object to move. Responding to the
prompts, the user points to a reference point, then to a
destination point. The object is moved such that the
reference point falls on the destination point. The orien-
tation is altered according to the current transformation.
!!SEEALSO
copy
rotate
mirror
!!KEYWORD
pan
!!TITLE
pan
!!TEXT
When on, point to new locations for the center of view in the
coarse window, (or the window in full screen mode).
!!KEYWORD
peek
!!TITLE
peek
!!TEXT
When on, instances will be expanded in the fine viewport
but not the coarse viewport in split screen mode.
!!SEEALSO
expnd
!!KEYWORD
place
!!TITLE
place
!!TEXT
When this switch is on, a basic point operation will cause
an instance or array of the current master cell to be placed
in the cell currently being edited. If the llref toggle is
on, the lower left corner of the subcell or array is used as
the reference, otherwise the subcell or array origin is
used. The rotation and mirroring are set by the current
transform buttons. When place is turned on, the user is
given the opportunity to specify or change the current master
cell.
!!SEEALSO
array
llref
mirror
rotate
!!KEYWORD
plusretc
!!TITLE
+r, etc
!!TEXT
The currently selected layer color is modified with these
buttons. These are also used by the commands in the color
submenu to set colors of screen attributes.
!!KEYWORD
pointer
!!TITLE
Pointing Device
!!TEXT
Under DOS, KIC can be set up to operate with a Microsoft
compatible mouse, a Summagraphics compatible digitizing pad,
or with a keyboard driven pointer. The selection is made in
the file mfb.rc which is in the directory kic/startup. If
the disk is other than drive C, the SRWDRV environment
variable designates the appropriate drive. See the comments
in mfb.rc for information on changing the pointing device.
Under UNIX, the mfb.rc file is not used, and the pointing
device is that in use on the X-windows server.
!!SUBTOPICS
button1
button2
button3
button4
kbrd
!!KEYWORD
polyg
!!TITLE
polyg
!!TEXT
Create polygons. Point at the last vertex twice, or to the
first vertex to complete the polygon.
!!KEYWORD
pop
!!TITLE
pop
!!TEXT
Pop the editing context back to the parent cell.
!!SEEALSO
push
!!KEYWORD
prn
!!TITLE
prn
!!TEXT
Set the name of the printer device or file for hardcopies.
In DOS, the name can be that of a port driver (prn, lpt1,
etc). If not so recognized, the name will be taken as a
file to which the output is directed. Under UNIX, if the
first three characters are "lpr", a process is opened and
the output is fed to the standard input of the process.
Otherwise, a file is opened for output.
!!KEYWORD
prpty
!!TITLE
prpty
!!TEXT
Change to the Properties Menu.
!!KEYWORD
push
!!TITLE
push
!!TEXT
Push the selected subcell for editing. If no subcell has
been selected, the user is asked to point at one. The
pushed-to cell is displayed in true orientation, with or
without the surrounding context shown as set with the
CNTXT button.
!!SEEALSO
pop
cntxt
!!KEYWORD
quit
!!TITLE
quit
!!TEXT
Exit KIC. The user will be prompted for instructions if there
are cells which have not been saved.
!!KEYWORD
rdraw
!!TITLE
rdraw
!!TEXT
Redisplay the screen.
!!KEYWORD
resol
!!TITLE
resol
!!TEXT
The interface supports resolutions of 75, 100, 150, and
300 dpi. The default is 150 dpi. The resolution can be
changed with this command.
!!KEYWORD
rgb
!!TITLE
rgb
!!TEXT
Display the RGB value of the currently selected layer.
!!SEEALSO
plusretc
!!KEYWORD
rmove
!!TITLE
rmove
!!TEXT
Remove a layer from the layer menu.
!!SEEALSO
adlyr
!!KEYWORD
rmprp
!!TITLE
rmprp
!!TEXT
Remove a property from the selected objects.
!!KEYWORD
rotate
!!TITLE
0 90 180 270
!!TEXT
During a move, copy, or instance placement, a transformation
is performed as specified by the current rotation setting.
The rotation setting also governs the orientation of the break
command.
!!SEEALSO
mirror
break
!!KEYWORD
save
!!TITLE
save
!!TEXT
Save the cell currently being edited. The user is given the
option of saving the cell under a new name. If a new name is
given, the user is prompted whether to change references in
the parent cell (if it exists) to the new name.
!!KEYWORD
scale
!!TITLE
scale
!!TEXT
Usage: scale [-a numer] [-b denom] [-t ext] [root_kic_file]
options:
-a numer Numerator of scale factor, positive
integer >= 1 (default 1).
-b denom Denominator of scale factor, positive
integer >= 1 (default 1).
-t ext Use tech.ext for layer definitions.
Will prompt for root kic file if not given. The program
multiplies all coordinates in the root cell and subcells by
numer/denom, and writes over the original cells. If you want
to preserve the original cells, they have to be copied to
another name or directory. BE CAREFUL, EXPERIMENTING WITH THIS
PROGRAM CAN CLOBBER YOUR WORK.
!!KEYWORD
scrn
!!TITLE
Screen Partitioning
!!TEXT
KIC has two viewing modes, full screen and split screen, the
default being full screen. The mode can be changed with the
zoom command. In full screen mode, one view occupies the
entire viewing area. In split screen mode, there are two
viewports, a coarse view and a fine view. The fine view is
a magnification of a portion of the coarse view. The ^N
command saves the view, and the Last command can be invoked
inside of most commands, so that the view can be altered
during geometry creation. This facilitates wiring large
cells. The positioning of the fine viewport within the
coarse viewport can be changed with the pointing device
using buttons 2 and 3.
!!SEEALSO
ctrln
last
zoom
button2
button3
!!KEYWORD
selec
!!TITLE
selec
!!TEXT
When on, objects pointed to will be selected, as indicated
by highlighting. Several commands operate on selected
objects. A message on the parameter line indicates the
number of objects currently selected.
!!SEEALSO
layer
area
!!KEYWORD
show
!!TITLE
show
!!TEXT
Show the properties of the selected objects.
!!KEYWORD
sides
!!TITLE
sides
!!TEXT
Set the number of sides assumed for rounded geometries.
!!KEYWORD
snap
!!TITLE
snap
!!TEXT
Set the spacing of the snap lines. Setting to 1 will
correspond to grid lines, setting to 2 will snap on and
midway between grid lines, etc.
!!SEEALSO
grid
!!KEYWORD
spacebar
!!TITLE
spacebar
!!TEXT
Pressing the space bar updates the screen parameter information
in the same way as a point operation, however no actual action
is taken. This is usful for measuring distances. This is the
same effect as mouse button 4, which exists on some pointing
devices. ^W has a similar effect, however the user is asked
to point first.
!!SEEALSO
button4
!!KEYWORD
strch
!!TITLE
strch
!!TEXT
The stretch command operates on polygons, wires, and
rectangles. It enables moving of polygon and wire vertices,
and rectangle corners. The movement is constrained by the
current setting of the TBRL button.
If no geometry has been selected, the user is asked to point
to an object to stretch. Once an object is selected, the
user is then prompted to point at a vertex, and the closest
one to where the user points is active. The user then points
to the new location, and the vertex is then moved. This move
is constrained by the TBRL setting. If the setting is "TBRL",
there is no constraint. If the setting is "TB", then only the
Y part of the translation is performed, and likewise if the
setting is "RL" only the X translation occurs.
If there are several objects selected, then the vertex closest
to where the user points is taken as the reference vertex.
This vertex is translated to the new location. In each of the
other objects, the same transformation is applied to the
vertex closest to the reference vertex. Thus, a group of
wires, for example, can all be extended at once.
!!SEEALSO
tbrl
!!KEYWORD
strmtext
!!TITLE
strmtext
!!TEXT
Usage: strmtotext [-id] [-n2345678] [ streamfile [textfile] ]
options:
-id Prints the version of the program and copyright
information.
-n Indicates a non-standard Stream file is to be
read, that is, one structure beginning with
BGBSTR and ending with ENDSTR.
1-8 Indicate the number of Stream records per line
in the output text. (Default is one per line).
streamfile A Calma Stream file (3.0) input to this program.
(Standard input default).
textfile The name of the file to receive the program's
output. (Standard output default).
!!KEYWORD
strtokic
!!TITLE
strtokic
!!TEXT
Usage: strtokic [options] [streamfile]
options (case insensitive):
-P Convert manhattan polygons to boxes, four-sided
manhattan polygons are always converted.
-E Print errors in file "strtokic.err",
default is to screen (stderr).
-Csname sname = Root structure name to convert.
Default, convert all structures in file.
-Rfilename filename = Name of root cell (default "Root").
The root cell contains global library informa-
tion, and can usually be ignored.
-Xfilename Use filename as layer table reference ("ltab")
file, default is to use layers from the
technology file (StreamData lines).
-Text Use layers from tech.ext.
-N Use stream layer numbers for layer names. Will
reference layers as "L NNDD" where N is the layer
number and D is the data type, both as two char-
acter fields. Supersedes -X, -T.
-Lmicprl Microns per lambda (default 1.0).
Will prompt for stream file name to convert if not supplied,
hit return for help.
Search path for technology file: . , .../kic/startup.
If the datatype obtained from the technology or ltab file is -1,
the datatype given in the input is not comparison tested. In
this case, only the layer number is significant. Otherwise,
the datatype must match the specified datatype for the layer.
The valid stream layer numbers and data types are 0-255. In
DOS versions, cell names are mapped to DOS compatible file
names. This mapping as added to the file "dos__str.als",
which is created if it doesn't exist.
!!KEYWORD
tbrl
!!TITLE
tbrl
!!TEXT
This is a three way toggle used by the strch command. When on,
i.e. reading "tb" or "rl", the stretch operation is constrained
to the Y or X direction, respectively. This is useful when
only the length or width of an object is to be changed, and
the magnification is large.
!!SEEALSO
strch
!!KEYWORD
techfile
!!TITLE
Technology File
!!TEXT
The technology file tells KIC all it knows about the layers
and display attributes. The name of the file is "kic_tech",
and an extension .xxx can be added to the name, so that if KIC
is started with the -t xxx option, the technology file with
the extension will be used. For example, kic -t trw would try
to read kic_tech.trw.
If no technology file is found in the current directory, a
system-wide directory is searched. This location can be set
with the KIC_LIB_DIR environment variable. The default
technology file has been provided by your system administrator.
A personalized version can be generated with the updat
command.
The technology file consists of a path specification, followed
by several layer specifications, followed by the display
attribute specifiers.
The path consists of the characters "Path?" followed by space,
followed by a space separated list of directories (format
appropriate for the operating system) enclosed in parens.
Aside from the path, the file is read without case
sensitivity.
The layer specification consists of a list of keywords in the
order and format illustrated in the example below. The layer
name consists of four alphanumeric characters or fewer.
The color RGB is three numbers (RGB) each from 0-255.
Following "Filled?" one can have "y" (solid fill), "n" (empty
fill, thick outline), or eight bytes of hex code defining a
fill pattern, followed by an optional "y" or "outline", which
if present indicates that the pattern is outlined. Examples:
filled? y
filled? cc aa cc aa cc aa cc aa outline
The syntax is identical for "AltFilled", which sets the pattern
for hardcopies.
The number following "MinDimensions?" is the minimum feature
size in microns. A second number is the default wire width,
which defaults to the minimum dimension.
If the "Invisible" keyword is given, the layer is invisible by
default. Similarly, "AltInvisible" will hide the layer in
hardcopies.
If the "Symbolic?" keyword is followed by "y", the
geometry is shown even when the cell is not expanded. Normal
layers should follow "Symbolic?" with "n".
The two numbers following "StreamData" are the Stream layer
number and data type used when converting to GDSII.
The keywords "Tran", "Resis", and "Cap" signify electrial
parameter specifications, only one of which can be used per
layer.
The display mode keywords are all optional. GridSpacing is in
microns. The following keywords indicate an attribute color:
MenuPrompt, MenuText, MenuHighlighting, MenuSelect,
MoreText, CoarseGrid, FineGrid, InstanceBox, InstanceName,
InstanceSize.
The last three set the colors used in unexpanded instances.
Each is followed by either one or three integers. If KIC is
running on a system with less than 32 possible colors, the
attribute colors and layer colors are merged, such that the
attributes are mapped to specific layers for color reference.
In this mode, KIC will generate a technology file with a single
integer following the above parameters, which is the layer
number for color reference. Otherwise, three numbers are
produced, which are the RGB values in the range 0-255.
In addition, Highlighting and Background are followed by RGB
values in either case.
In merged mode, reading an RGB technology file will produce KIC
internal layer references based on the best color match. In
non-merged mode, reading in a single integer technology file
will load the independent color buffer with the corresponding
layer's color.
RoundFlashSides is followed by the number of segments used to
approximate rounded geometries. Highlighting and Background
are followed by RGB values for the colors. If ShowGrid is
present the grid wil be shown, otherwise it is invisible by
default. If GridOnBottom is given, the grid will be below
geometries, otherwise it is shown above. If DisplayAllText
is given, labels will be shown in the coarse viewport in
split screen mode, otherwise labels are displayed only in
the fine viewport. Similarly, if LabelAllInstances is
present, instances will be labeled in the coarse viewport
in split screen mode. AltShowGrid controls grid display in
hardcopies. AltDevice gives the printer device name for hard
copies, AltResolution gives the resolution, and AltFormat
gives the format code for the plot data.
The following is an example. Text enclosed in square brackets
is optional. Other text is required.
Path? (. \library\stuff mydir\layouts)
LayerName? gndc
[Color'sName? green]
RGB? 0 255 0
[Symbolic? n]
[Filled? y] default n
[AltFilled cc aa cc aa cc aa cc aa y] default n
[Invisible]
[AltInvisible]
[Blink]
[MinDimensions? 2] default 0
[StreamData 21 0]
[tran ...]
[resis ...]
[cap ...]
...
defaults
[ Gridspacing 2.5 2.0
Highlighting 255 255 255 255 255 255
Background 0 0 100 0 0 0
merged format:
MenuPrompt 2 closest match
MenuText 3 to colors as
MenuHighlighting 4 listed below
MenuSelect 8
MoreText 9
CoarseGrid 6
FineGrid 7
InstanceBox 1
InstanceName 1
InstanceSize 1
OR
independent format:
MenuPrompt 100 150 0 255 235 110
MenuText 0 250 0 120 240 0
MenuHighlighting 250 0 0 110 160 255
MenuSelect 125 250 125 180 250 150
MoreText 170 210 200 170 210 200
CoarseGrid 90 150 0 150 170 255
FineGrid 140 150 80 60 20 200
InstanceBox 250 250 250 150 225 195
InstanceName 250 0 0 180 60 0
InstanceSize 0 0 250 220 85 180
RoundFlashSides 32 20
ShowGrid 0
AltShowGrid 0
AltDevice lpt2 prn
AltResolution 100 150
GridOnBottom 0
DisplayAllText 0
LabelAllInstances ] 0
The electrical parameters have the following formats:
resis[tance]
cap[acitance]
tran[smission]
Each of the <...> is a floating point number. Tran parameters
are in microns. A superconducting model is employed.
!!SEEALSO
updat
!!KEYWORD
tocif
!!TITLE
tocif
!!TEXT
With this command, the current editing cell and its descednents
are written to a CIF file. The user is prompted for the name
of the file for CIF output. The resulting CIF file can be used
to port designs created in KIC to other systems.
!!SEEALSO
kictocif
!!KEYWORD
togds
!!TITLE
togds
!!TEXT
This command creates a GDSII (Stream) file of the current
editing cell and its descendents. The name of the file for
the GDSII output is requested from the user. The resulting
file can be used to export designs created with KIC to other
systems, as the GDSII format is an industry standard. In
DOS versions, if the file "dos__str.als" is found in the
current directory, the DOS cell names are mapped to Stream
cell names through the table in this file. This file is
ordinarily created by the Stream to KIC converters. The
layer mapping is taken from the technology file. If the
datatype obtained from the technology or ltab file is
outside of 0-255, the written datatype is 0. The valid stream
layer numbers and data types are 0-255.
!!SEEALSO
techfile
kictostr
!!KEYWORD
undo
!!TITLE
undo
!!TEXT
The undo command reverses the last operation of most commands
which create, delete, or modify geometry.
!!KEYWORD
updat
!!TITLE
updat
!!TEXT
Write an updated technology file in the current directory.
This file provides setup information to KIC.
!!SEEALSO
techfile
!!KEYWORD
utilities
!!TITLE
Utilities
!!TEXT
There are several utility programs supplied with KIC.
These are:
ciftokic CIF to KIC converter
kictocif KIC to CIF converter
strtokic Stream to KIC converter
kictostr KIC to stream converter
strmtext Stream to text program
scale Cell scaling program
help help database editor/browser
Stream format is also referred to as Calma GDSII.
!!SUBTOPICS
ciftokic
helpprog
kictocif
kictostr
scale
strmtext
strtokic
!!KEYWORD
view
!!TITLE
view
!!TEXT
Display a centered full view of the current cell.
!!KEYWORD
visib
!!TITLE
visib
!!TEXT
Set the visibility of the layers.
!!KEYWORD
width
!!TITLE
width
!!TEXT
This function has two modes. If there are wires selected,
on the current layer with the layer button active, or any
wires with the layer button inactive, KIC prompts for a
new wire width for the selected wires. If the layer button
is active, only wires on the current layer have their
widths changed, otherwise selected wires from all layers
have their widths altered. No checking is performed for
minimum width violations in this mode. The other mode sets
the default wire width for the current layer, and this is
constrained to be greater or equal to the minimum width.
This mode is entered if there are no applicable wires
selected when the width button is chosen. Wires
subsequently created on the present layer will have the new
width.
!!SEEALSO
wires
layer
!!KEYWORD
windo
!!TITLE
windo
!!TEXT
Point to the diagonal corners of a new window. In split screen
mode, this command operates with the coarse window.
!!SEEALSO
ctrlg
button3
!!KEYWORD
wires
!!TITLE
wires
!!TEXT
Create wires. Point to the same location twice to end a wire.
!!KEYWORD
xor
!!TITLE
xor
!!TEXT
This mode facilitates inverting the polarity of layers. The
operation is similar to the boxes command, however all prev-
iously existing boxes on the same layer which overlap the
created box become holes in the new box. Structures other
than boxes are covered. No checking is done for minimum
feature size of the newly created geometry.
!!SEEALSO
boxes
!!KEYWORD
xwindows
!!TITLE
X Windows
!!TEXT
This version of KIC supports X Windows. However, transformed
text display is not available under X windows. The X version
provides selectable fonts and cursors.
!!SEEALSO
cursr
font
!!KEYWORD
zoom
!!TITLE
zoom
!!TEXT
Enter a new width for the window, or the coarse window if in
split screen mode, or hit Enter to toggle between full and
split screen modes.
kic-2.4c/startup/README 0000644 0000764 0000764 00000001600 07525346715 014311 0 ustar stevew stevew Files in KIC startup directory
kic_help.txt .................. Help Database
kic_tech .................. default technology (copy of kic_tech.scm)
kic_tech.110 .................. TRW process 110 technology file
kic_tech.220 .................. TRW process 220 technology file
kic_tech.300 .................. TRW process 300 technology file
kic_tech.hyp .................. Hypres Nb technology file
kic_tech.scm .................. Mosis scalable CMOS technology file
logofont.kic .................. Font file for "logo" command
ltab .................. Layer table file (obsolete, still
can be used by stand-alone stream
converters)
ltab.trw
ltab.hyp
NOTE: if the supplied logofont.kic is not 54539 bytes, it has been
corrupted. This file is a renamed HP laserjet font file (.hpf
file) for WordPerfect 5.1.
kic-2.4c/startup/kic_tech.220 0000644 0000764 0000764 00000003400 07525346715 015427 0 ustar stevew stevew Path? ( . )
LayerName? JUNC
RGB? 250 250 0
Symbolic? n
Filled? 00 55 00 82 10 82 00 55 outline
AltFilled? c3 c6 6c 38 38 6c c6 c3 outline
MinDimensions 5
StreamData? 1 0
LayerName? TRIE
RGB? 0 255 0
Symbolic? n
Filled? y
AltFilled? 00 55 00 82 10 82 00 55 outline
MinDimensions 4
StreamData? 2 0
LayerName? SIOA
RGB? 255 170 130
Symbolic? n
Filled? y
AltFilled? y
MinDimensions 3
StreamData? 3 0
LayerName? WIRA
RGB? 0 170 220
Symbolic? n
Filled? 11 22 44 88 11 22 44 88 outline
AltFilled? 10 20 40 80 01 02 04 08 outline
MinDimensions 4
StreamData? 4 0
LayerName? RESI
RGB? 230 40 0
Symbolic? n
Filled? 89 18 24 c2 43 24 18 91 outline
AltFilled? 66 00 00 00 66 00 00 00 outline
MinDimensions 4
StreamData? 5 0
LayerName? SIOB
RGB? 255 140 35
Symbolic? n
Filled? 81 42 3c 00 24 24 42 81 outline
AltFilled? 81 42 3c 00 24 24 42 81 outline
MinDimensions 3
StreamData? 6 0
LayerName? WIRB
RGB? 190 90 197
Symbolic? n
Filled? 88 44 22 11 88 44 22 11 outline
AltFilled? 80 40 20 10 08 04 02 01 outline
MinDimensions 4
StreamData? 7 0
LayerName? GOLD
RGB? 255 170 227
Symbolic? n
Filled? n
AltFilled? n
MinDimensions 4
StreamData? 8 0
LayerName? TEXT
RGB? 255 255 255
Symbolic? y
Filled? n
AltFilled? n
MinDimensions 0
StreamData? 9 0
LayerName? NOSI
RGB? 255 255 255
Symbolic? y
Filled? n
AltFilled? n
AltInvisible
MinDimensions 0
StreamData? 10 0
Highlighting 215 220 230
Background 0 0 0
MenuText 255 255 255
MenuSelect 255 255 255
MenuHighlighting 230 40 0
MenuPrompt 250 250 0
MoreText 255 255 255
FineGrid 230 40 0
CoarseGrid 255 140 35
InstanceBox 255 170 227
InstanceName 230 40 0
InstanceSize 190 90 197
GridSpacing 1
GridStyle 204
AltShowGrid
DisplayAllText
RoundFlashSides 40
AltDevice prn
AltResolution 150
AltFormat p
Snapping 2
FineViewportOnSide
FontName
BeepVolume 0
kic-2.4c/startup/logofont.kic 0000644 0000764 0000764 00000152413 07525346715 015761 0 ustar stevew stevew )s246W @ H Q [ T, g Bits Charter (C) Copyright Bitstream Inc, 1987. All rights reserved. Reproduction, adaptation or distribution of copies of this font is prohibited, except as allowed under the copyright laws.*c33E(s118W 3 3 d > > > > > > > > > > > > > > *c34E(s82W 5 dxxxxxxxx0000000*c35E(s346W 5 . 7 <