libspectre-0.2.12/ 0000755 0001750 0001750 00000000000 14356636335 010747 5 0000000 0000000 libspectre-0.2.12/config.guess 0000755 0001750 0001750 00000140304 14126654676 013214 0000000 0000000 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2021 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2021-06-03'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
#
# Please send patches to .
# The "shellcheck disable" line above the timestamp inhibits complaints
# about features and limitations of the classic Bourne shell that were
# superseded or lifted in POSIX. However, this script identifies a wide
# variety of pre-POSIX systems that do not have POSIX shells at all, and
# even some reasonably current systems (Solaris 10 as case-in-point) still
# have a pre-POSIX /bin/sh.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2021 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
# Just in case it came from the environment.
GUESS=
# 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.
tmp=
# shellcheck disable=SC2172
trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
set_cc_for_build() {
# prevent multiple calls if $tmp is already set
test "$tmp" && return 0
: "${TMPDIR=/tmp}"
# shellcheck disable=SC2039,SC3028
{ 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" 2>/dev/null) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c"
for driver in cc gcc c89 c99 ; do
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD=$driver
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
}
# 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 ; 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/*)
LIBC=unknown
set_cc_for_build
cat <<-EOF > "$dummy.c"
#include
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#elif defined(__GLIBC__)
LIBC=gnu
#else
#include
/* First heuristic to detect musl libc. */
#ifdef __DEFINED_va_list
LIBC=musl
#endif
#endif
EOF
cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
eval "$cc_set_libc"
# Second heuristic to detect musl libc.
if [ "$LIBC" = unknown ] &&
command -v ldd >/dev/null &&
ldd --version 2>&1 | grep -q ^musl; then
LIBC=musl
fi
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
if [ "$LIBC" = unknown ]; then
LIBC=gnu
fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
/usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
echo unknown)`
case $UNAME_MACHINE_ARCH in
aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
machine=${arch}${endian}-unknown
;;
*) machine=$UNAME_MACHINE_ARCH-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
case $UNAME_MACHINE_ARCH in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# Determine ABI tags.
case $UNAME_MACHINE_ARCH in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case $UNAME_VERSION in
Debian*)
release='-gnu'
;;
*)
release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
GUESS=$machine-${os}${release}${abi-}
;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
;;
*:SecBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
;;
*:MidnightBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
;;
*:ekkoBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
;;
*:SolidBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
;;
*:OS108:*:*)
GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
;;
macppc:MirBSD:*:*)
GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
;;
*:MirBSD:*:*)
GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
;;
*:Sortix:*:*)
GUESS=$UNAME_MACHINE-unknown-sortix
;;
*:Twizzler:*:*)
GUESS=$UNAME_MACHINE-unknown-twizzler
;;
*:Redox:*:*)
GUESS=$UNAME_MACHINE-unknown-redox
;;
mips:OSF1:*.*)
GUESS=mips-dec-osf1
;;
alpha:OSF1:*:*)
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
trap '' 0
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.
OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
;;
Amiga*:UNIX_System_V:4.0:*)
GUESS=m68k-unknown-sysv4
;;
*:[Aa]miga[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-unknown-amigaos
;;
*:[Mm]orph[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-unknown-morphos
;;
*:OS/390:*:*)
GUESS=i370-ibm-openedition
;;
*:z/VM:*:*)
GUESS=s390-ibm-zvmoe
;;
*:OS400:*:*)
GUESS=powerpc-ibm-os400
;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
GUESS=arm-acorn-riscix$UNAME_RELEASE
;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
GUESS=arm-unknown-riscos
;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
GUESS=hppa1.1-hitachi-hiuxmpp
;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
case `(/bin/universe) 2>/dev/null` in
att) GUESS=pyramid-pyramid-sysv3 ;;
*) GUESS=pyramid-pyramid-bsd ;;
esac
;;
NILE*:*:*:dcosx)
GUESS=pyramid-pyramid-svr4
;;
DRS?6000:unix:4.0:6*)
GUESS=sparc-icl-nx6
;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) GUESS=sparc-icl-nx7 ;;
esac
;;
s390x:SunOS:*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
;;
sun4H:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-hal-solaris2$SUN_REL
;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-sun-solaris2$SUN_REL
;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
GUESS=i386-pc-auroraux$UNAME_RELEASE
;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
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 test "$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
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
;;
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.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=sparc-sun-solaris3$SUN_REL
;;
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'.
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
GUESS=sparc-sun-sunos$SUN_REL
;;
sun3*:SunOS:*:*)
GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
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)
GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
sun4)
GUESS=sparc-sun-sunos$UNAME_RELEASE
;;
esac
;;
aushp:SunOS:*:*)
GUESS=sparc-auspex-sunos$UNAME_RELEASE
;;
# 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:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
GUESS=m68k-atari-mint$UNAME_RELEASE
;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
GUESS=m68k-milan-mint$UNAME_RELEASE
;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
GUESS=m68k-hades-mint$UNAME_RELEASE
;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
GUESS=m68k-unknown-mint$UNAME_RELEASE
;;
m68k:machten:*:*)
GUESS=m68k-apple-machten$UNAME_RELEASE
;;
powerpc:machten:*:*)
GUESS=powerpc-apple-machten$UNAME_RELEASE
;;
RISC*:Mach:*:*)
GUESS=mips-dec-mach_bsd4.3
;;
RISC*:ULTRIX:*:*)
GUESS=mips-dec-ultrix$UNAME_RELEASE
;;
VAX*:ULTRIX*:*:*)
GUESS=vax-dec-ultrix$UNAME_RELEASE
;;
2020:CLIX:*:* | 2430:CLIX:*:*)
GUESS=clipper-intergraph-clix$UNAME_RELEASE
;;
mips:*:*:UMIPS | mips:*:*:RISCos)
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; }
GUESS=mips-mips-riscos$UNAME_RELEASE
;;
Motorola:PowerMAX_OS:*:*)
GUESS=powerpc-motorola-powermax
;;
Motorola:*:4.3:PL8-*)
GUESS=powerpc-harris-powermax
;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
GUESS=powerpc-harris-powermax
;;
Night_Hawk:Power_UNIX:*:*)
GUESS=powerpc-harris-powerunix
;;
m88k:CX/UX:7*:*)
GUESS=m88k-harris-cxux7
;;
m88k:*:4*:R4*)
GUESS=m88k-motorola-sysv4
;;
m88k:*:3*:R3*)
GUESS=m88k-motorola-sysv3
;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
test "$TARGET_BINARY_INTERFACE"x = x
then
GUESS=m88k-dg-dgux$UNAME_RELEASE
else
GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
fi
else
GUESS=i586-dg-dgux$UNAME_RELEASE
fi
;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
GUESS=m88k-dolphin-sysv3
;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
GUESS=m88k-motorola-sysv3
;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
GUESS=m88k-tektronix-sysv3
;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
GUESS=m68k-tektronix-bsd
;;
*:IRIX*:*:*)
IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
GUESS=mips-sgi-irix$IRIX_REL
;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
GUESS=i386-ibm-aix
;;
ia64:AIX:*:*)
if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
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
GUESS=$SYSTEM_NAME
else
GUESS=rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
GUESS=rs6000-ibm-aix3.2.4
else
GUESS=rs6000-ibm-aix3.2
fi
;;
*: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 test -x /usr/bin/lslpp ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
GUESS=$IBM_ARCH-ibm-aix$IBM_REV
;;
*:AIX:*:*)
GUESS=rs6000-ibm-aix
;;
ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
GUESS=romp-ibm-bsd4.4
;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
GUESS=rs6000-bull-bosx
;;
DPX/2?00:B.O.S.:*:*)
GUESS=m68k-bull-sysv3
;;
9000/[34]??:4.3bsd:1.*:*)
GUESS=m68k-hp-bsd
;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
GUESS=m68k-hp-bsd4.4
;;
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 test -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 test "$HP_ARCH" = ""; then
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 test "$HP_ARCH" = hppa2.0w
then
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
GUESS=$HP_ARCH-hp-hpux$HPUX_REV
;;
ia64:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
GUESS=ia64-hp-hpux$HPUX_REV
;;
3050*:HI-UX:*:*)
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; }
GUESS=unknown-hitachi-hiuxwe2
;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
GUESS=hppa1.1-hp-bsd
;;
9000/8??:4.3bsd:*:*)
GUESS=hppa1.0-hp-bsd
;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
GUESS=hppa1.0-hp-mpeix
;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
GUESS=hppa1.1-hp-osf
;;
hp8??:OSF1:*:*)
GUESS=hppa1.0-hp-osf
;;
i*86:OSF1:*:*)
if test -x /usr/sbin/sysversion ; then
GUESS=$UNAME_MACHINE-unknown-osf1mk
else
GUESS=$UNAME_MACHINE-unknown-osf1
fi
;;
parisc*:Lites*:*:*)
GUESS=hppa1.1-hp-lites
;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
GUESS=c1-convex-bsd
;;
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*:*)
GUESS=c34-convex-bsd
;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
GUESS=c38-convex-bsd
;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
GUESS=c4-convex-bsd
;;
CRAY*Y-MP:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=ymp-cray-unicos$CRAY_REL
;;
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:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=t90-cray-unicos$CRAY_REL
;;
CRAY*T3E:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=alphaev5-cray-unicosmk$CRAY_REL
;;
CRAY*SV1:*:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=sv1-cray-unicos$CRAY_REL
;;
*:UNICOS/mp:*:*)
CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
GUESS=craynv-cray-unicosmp$CRAY_REL
;;
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/ /_/'`
GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
;;
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/ /_/'`
GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
;;
sparc*:BSD/OS:*:*)
GUESS=sparc-unknown-bsdi$UNAME_RELEASE
;;
*:BSD/OS:*:*)
GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
;;
arm:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
set_cc_for_build
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
else
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
fi
;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
case $UNAME_PROCESSOR in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
;;
i*:CYGWIN*:*)
GUESS=$UNAME_MACHINE-pc-cygwin
;;
*:MINGW64*:*)
GUESS=$UNAME_MACHINE-pc-mingw64
;;
*:MINGW*:*)
GUESS=$UNAME_MACHINE-pc-mingw32
;;
*:MSYS*:*)
GUESS=$UNAME_MACHINE-pc-msys
;;
i*:PW*:*)
GUESS=$UNAME_MACHINE-pc-pw32
;;
*:Interix*:*)
case $UNAME_MACHINE in
x86)
GUESS=i586-pc-interix$UNAME_RELEASE
;;
authenticamd | genuineintel | EM64T)
GUESS=x86_64-unknown-interix$UNAME_RELEASE
;;
IA64)
GUESS=ia64-unknown-interix$UNAME_RELEASE
;;
esac ;;
i*:UWIN*:*)
GUESS=$UNAME_MACHINE-pc-uwin
;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
GUESS=x86_64-pc-cygwin
;;
prep*:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=powerpcle-unknown-solaris2$SUN_REL
;;
*:GNU:*:*)
# the GNU system
GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
;;
*:Minix:*:*)
GUESS=$UNAME_MACHINE-unknown-minix
;;
aarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` 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
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arm*:Linux:*:*)
set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
else
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
fi
fi
;;
avr32*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
cris:Linux:*:*)
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
;;
crisv32:Linux:*:*)
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
;;
e2k:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
frv:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
hexagon:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
i*86:Linux:*:*)
GUESS=$UNAME_MACHINE-pc-linux-$LIBC
;;
ia64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m32r*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m68*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
mips:Linux:*:* | mips64:Linux:*:*)
set_cc_for_build
IS_GLIBC=0
test x"${LIBC}" = xgnu && IS_GLIBC=1
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
#undef mips
#undef mipsel
#undef mips64
#undef mips64el
#if ${IS_GLIBC} && defined(_ABI64)
LIBCABI=gnuabi64
#else
#if ${IS_GLIBC} && defined(_ABIN32)
LIBCABI=gnuabin32
#else
LIBCABI=${LIBC}
#endif
#endif
#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
CPU=mipsisa64r6
#else
#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
CPU=mipsisa32r6
#else
#if defined(__mips64)
CPU=mips64
#else
CPU=mips
#endif
#endif
#endif
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
MIPS_ENDIAN=el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
MIPS_ENDIAN=
#else
MIPS_ENDIAN=
#endif
#endif
EOF
cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
eval "$cc_set_vars"
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
openrisc*:Linux:*:*)
GUESS=or1k-unknown-linux-$LIBC
;;
or32:Linux:*:* | or1k*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
padre:Linux:*:*)
GUESS=sparc-unknown-linux-$LIBC
;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
GUESS=hppa64-unknown-linux-$LIBC
;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
*) GUESS=hppa-unknown-linux-$LIBC ;;
esac
;;
ppc64:Linux:*:*)
GUESS=powerpc64-unknown-linux-$LIBC
;;
ppc:Linux:*:*)
GUESS=powerpc-unknown-linux-$LIBC
;;
ppc64le:Linux:*:*)
GUESS=powerpc64le-unknown-linux-$LIBC
;;
ppcle:Linux:*:*)
GUESS=powerpcle-unknown-linux-$LIBC
;;
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
s390:Linux:*:* | s390x:Linux:*:*)
GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
;;
sh64*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sh*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sparc:Linux:*:* | sparc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
tile*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
vax:Linux:*:*)
GUESS=$UNAME_MACHINE-dec-linux-$LIBC
;;
x86_64:Linux:*:*)
set_cc_for_build
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_X32 >/dev/null
then
LIBCABI=${LIBC}x32
fi
fi
GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
;;
xtensa*:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
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.
GUESS=i386-sequent-sysv4
;;
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.
GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
GUESS=$UNAME_MACHINE-pc-os2-emx
;;
i*86:XTS-300:*:STOP)
GUESS=$UNAME_MACHINE-unknown-stop
;;
i*86:atheos:*:*)
GUESS=$UNAME_MACHINE-unknown-atheos
;;
i*86:syllable:*:*)
GUESS=$UNAME_MACHINE-pc-syllable
;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
GUESS=i386-unknown-lynxos$UNAME_RELEASE
;;
i*86:*DOS:*:*)
GUESS=$UNAME_MACHINE-pc-msdosdjgpp
;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
else
GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
fi
;;
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
GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
;;
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
GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
else
GUESS=$UNAME_MACHINE-pc-sysv32
fi
;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
GUESS=i586-pc-msdosdjgpp
;;
Intel:Mach:3*:*)
GUESS=i386-pc-mach3
;;
paragon:*:*:*)
GUESS=i860-intel-osf1
;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
fi
;;
mini*:CTIX:SYS*5:*)
# "miniframe"
GUESS=m68010-convergent-sysv
;;
mc68k:UNIX:SYSTEM5:3.51m)
GUESS=m68k-convergent-sysv
;;
M680?0:D-NIX:5.3:*)
GUESS=m68k-diab-dnix
;;
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*:*)
GUESS=m68k-unknown-lynxos$UNAME_RELEASE
;;
mc68030:UNIX_System_V:4.*:*)
GUESS=m68k-atari-sysv4
;;
TSUNAMI:LynxOS:2.*:*)
GUESS=sparc-unknown-lynxos$UNAME_RELEASE
;;
rs6000:LynxOS:2.*:*)
GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
;;
SM[BE]S:UNIX_SV:*:*)
GUESS=mips-dde-sysv$UNAME_RELEASE
;;
RM*:ReliantUNIX-*:*:*)
GUESS=mips-sni-sysv4
;;
RM*:SINIX-*:*:*)
GUESS=mips-sni-sysv4
;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
GUESS=$UNAME_MACHINE-sni-sysv4
else
GUESS=ns32k-sni-sysv
fi
;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
GUESS=i586-unisys-sysv4
;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
GUESS=hppa1.1-stratus-sysv4
;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
GUESS=i860-stratus-sysv4
;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
GUESS=$UNAME_MACHINE-stratus-vos
;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
GUESS=hppa1.1-stratus-vos
;;
mc68*:A/UX:*:*)
GUESS=m68k-apple-aux$UNAME_RELEASE
;;
news*:NEWS-OS:6*:*)
GUESS=mips-sony-newsos6
;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if test -d /usr/nec; then
GUESS=mips-nec-sysv$UNAME_RELEASE
else
GUESS=mips-unknown-sysv$UNAME_RELEASE
fi
;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
GUESS=powerpc-be-beos
;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
GUESS=powerpc-apple-beos
;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
GUESS=i586-pc-beos
;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
GUESS=i586-pc-haiku
;;
x86_64:Haiku:*:*)
GUESS=x86_64-unknown-haiku
;;
SX-4:SUPER-UX:*:*)
GUESS=sx4-nec-superux$UNAME_RELEASE
;;
SX-5:SUPER-UX:*:*)
GUESS=sx5-nec-superux$UNAME_RELEASE
;;
SX-6:SUPER-UX:*:*)
GUESS=sx6-nec-superux$UNAME_RELEASE
;;
SX-7:SUPER-UX:*:*)
GUESS=sx7-nec-superux$UNAME_RELEASE
;;
SX-8:SUPER-UX:*:*)
GUESS=sx8-nec-superux$UNAME_RELEASE
;;
SX-8R:SUPER-UX:*:*)
GUESS=sx8r-nec-superux$UNAME_RELEASE
;;
SX-ACE:SUPER-UX:*:*)
GUESS=sxace-nec-superux$UNAME_RELEASE
;;
Power*:Rhapsody:*:*)
GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
;;
*:Rhapsody:*:*)
GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
;;
arm64:Darwin:*:*)
GUESS=aarch64-apple-darwin$UNAME_RELEASE
;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
if command -v xcode-select > /dev/null 2> /dev/null && \
! xcode-select --print-path > /dev/null 2> /dev/null ; then
# Avoid executing cc if there is no toolchain installed as
# cc will be a stub that puts up a graphical alert
# prompting the user to install developer tools.
CC_FOR_BUILD=no_compiler_found
else
set_cc_for_build
fi
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_PPC >/dev/null
then
UNAME_PROCESSOR=powerpc
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# uname -m returns i386 or x86_64
UNAME_PROCESSOR=$UNAME_MACHINE
fi
GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
;;
*:QNX:*:4*)
GUESS=i386-pc-qnx
;;
NEO-*:NONSTOP_KERNEL:*:*)
GUESS=neo-tandem-nsk$UNAME_RELEASE
;;
NSE-*:NONSTOP_KERNEL:*:*)
GUESS=nse-tandem-nsk$UNAME_RELEASE
;;
NSR-*:NONSTOP_KERNEL:*:*)
GUESS=nsr-tandem-nsk$UNAME_RELEASE
;;
NSV-*:NONSTOP_KERNEL:*:*)
GUESS=nsv-tandem-nsk$UNAME_RELEASE
;;
NSX-*:NONSTOP_KERNEL:*:*)
GUESS=nsx-tandem-nsk$UNAME_RELEASE
;;
*:NonStop-UX:*:*)
GUESS=mips-compaq-nonstopux
;;
BS2000:POSIX*:*:*)
GUESS=bs2000-siemens-sysv
;;
DS/*:UNIX_System_V:*:*)
GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
;;
*: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
elif test "x${cputype-}" != x; then
UNAME_MACHINE=$cputype
fi
GUESS=$UNAME_MACHINE-unknown-plan9
;;
*:TOPS-10:*:*)
GUESS=pdp10-unknown-tops10
;;
*:TENEX:*:*)
GUESS=pdp10-unknown-tenex
;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
GUESS=pdp10-dec-tops20
;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
GUESS=pdp10-xkl-tops20
;;
*:TOPS-20:*:*)
GUESS=pdp10-unknown-tops20
;;
*:ITS:*:*)
GUESS=pdp10-unknown-its
;;
SEI:*:*:SEIUX)
GUESS=mips-sei-seiux$UNAME_RELEASE
;;
*:DragonFly:*:*)
DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case $UNAME_MACHINE in
A*) GUESS=alpha-dec-vms ;;
I*) GUESS=ia64-dec-vms ;;
V*) GUESS=vax-dec-vms ;;
esac ;;
*:XENIX:*:SysV)
GUESS=i386-pc-xenix
;;
i*86:skyos:*:*)
SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
;;
i*86:rdos:*:*)
GUESS=$UNAME_MACHINE-pc-rdos
;;
*:AROS:*:*)
GUESS=$UNAME_MACHINE-unknown-aros
;;
x86_64:VMkernel:*:*)
GUESS=$UNAME_MACHINE-unknown-esx
;;
amd64:Isilon\ OneFS:*:*)
GUESS=x86_64-unknown-onefs
;;
*:Unleashed:*:*)
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
;;
esac
# Do we have a guess based on uname results?
if test "x$GUESS" != x; then
echo "$GUESS"
exit
fi
# No uname command or uname output not recognized.
set_cc_for_build
cat > "$dummy.c" <
#include
#endif
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
#include
#if defined(_SIZE_T_) || defined(SIGLOST)
#include
#endif
#endif
#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 (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
#if defined(_SIZE_T_) || defined(SIGLOST)
struct utsname un;
uname (&un);
printf ("vax-dec-ultrix%s\n", un.release); exit (0);
#else
printf ("vax-dec-ultrix\n"); exit (0);
#endif
#endif
#endif
#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
#if defined(_SIZE_T_) || defined(SIGLOST)
struct utsname *un;
uname (&un);
printf ("mips-dec-ultrix%s\n", un.release); exit (0);
#else
printf ("mips-dec-ultrix\n"); exit (0);
#endif
#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; }
echo "$0: unable to guess system type" >&2
case $UNAME_MACHINE:$UNAME_SYSTEM in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <&2 <&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
fi
exit 1
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
libspectre-0.2.12/libspectre/ 0000755 0001750 0001750 00000000000 14356636335 013103 5 0000000 0000000 libspectre-0.2.12/libspectre/spectre-utils.h 0000644 0001750 0001750 00000012143 14155760600 015766 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_UTILS_H
#define SPECTRE_UTILS_H
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
SPECTRE_BEGIN_DECLS
/* Checks. Based on dbus-internals */
void _spectre_warn (const char *format,
...);
void _spectre_warn_check_failed (const char *format,
...);
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define _SPECTRE_FUNCTION_NAME __func__
#elif defined(__GNUC__) || defined(_MSC_VER)
#define _SPECTRE_FUNCTION_NAME __FUNCTION__
#else
#define _SPECTRE_FUNCTION_NAME "unknown function"
#endif
/* Define SPECTRE_VA_COPY() to do the right thing for copying va_list variables.
* config.h may have already defined SPECTRE_VA_COPY as va_copy or __va_copy.
*/
#if !defined (SPECTRE_VA_COPY)
# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
# define SPECTRE_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
# elif defined (SPECTRE_VA_COPY_AS_ARRAY)
# define SPECTRE_VA_COPY(ap1, ap2) memcpy ((ap1), (ap2), sizeof (va_list))
# else /* va_list is a pointer */
# define SPECTRE_VA_COPY(ap1, ap2) ((ap1) = (ap2))
# endif /* va_list is a pointer */
#endif /* !SPECTRE_VA_COPY */
/*
* (code from GLib)
*
* The _SPECTRE_LIKELY and _SPECTRE_UNLIKELY macros let the programmer give hints to
* the compiler about the expected result of an expression. Some compilers
* can use this information for optimizations.
*
* The _SPECTRE_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
* putting assignments in the macro arg
*/
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#define _SPECTRE_BOOLEAN_EXPR(expr) \
__extension__ ({ \
int _spectre_boolean_var_; \
if (expr) \
_spectre_boolean_var_ = 1; \
else \
_spectre_boolean_var_ = 0; \
_spectre_boolean_var_; \
})
#define _SPECTRE_LIKELY(expr) (__builtin_expect (_SPECTRE_BOOLEAN_EXPR(expr), 1))
#define _SPECTRE_UNLIKELY(expr) (__builtin_expect (_SPECTRE_BOOLEAN_EXPR(expr), 0))
#else
#define _SPECTRE_LIKELY(expr) (expr)
#define _SPECTRE_UNLIKELY(expr) (expr)
#endif
#ifdef SPECTRE_DISABLE_ASSERT
#define _spectre_assert(condition)
#else
void _spectre_real_assert (int condition,
const char *condition_text,
const char *file,
int line,
const char *func);
#define _spectre_assert(condition) \
_spectre_real_assert ((condition) != 0, #condition, __FILE__, __LINE__, _SPECTRE_FUNCTION_NAME)
#endif /* SPECTRE_DISABLE_ASSERT */
#ifdef SPECTRE_DISABLE_CHECKS
#define _spectre_return_if_fail(condition)
#define _spectre_return_val_if_fail(condition, val)
#else /* SPECTRE_DISABLE_CHECKS */
#define _spectre_return_if_fail(condition) do { \
_spectre_assert ((*(const char*)_SPECTRE_FUNCTION_NAME) != '_'); \
if (!(condition)) { \
_spectre_warn_check_failed ("%s: assertion `%s' failed (%s:%d)\n", \
_SPECTRE_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
return; \
} } while (0)
#define _spectre_return_val_if_fail(condition, val) do { \
_spectre_assert ((*(const char*)_SPECTRE_FUNCTION_NAME) != '_'); \
if (!(condition)) { \
_spectre_warn_check_failed ("%s: assertion `%s' failed (%s:%d)\n", \
_SPECTRE_FUNCTION_NAME, #condition, __FILE__, __LINE__); \
return (val); \
} } while (0)
#endif /* SPECTRE_DISABLE_CHECKS */
/* String handling helpers */
char *_spectre_strdup_printf (const char *format,
...);
char *_spectre_strdup (const char *str);
int _spectre_strncasecmp (const char *s1,
const char *s2,
size_t n);
int _spectre_strcasecmp (const char *s1,
const char *s2);
double _spectre_strtod (const char *nptr,
char **endptr);
SPECTRE_END_DECLS
#endif /* SPECTRE_UTILS_H */
libspectre-0.2.12/libspectre/spectre-device.h 0000644 0001750 0001750 00000003234 14155760600 016066 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_DEVICE_H
#define SPECTRE_DEVICE_H
#include
#include
#include
#include "ps.h"
SPECTRE_BEGIN_DECLS
typedef struct SpectreDevice SpectreDevice;
SpectreDevice *spectre_device_new (struct document *doc);
SpectreStatus spectre_device_render (SpectreDevice *device,
unsigned int page,
SpectreRenderContext *rc,
int x,
int y,
int width,
int height,
unsigned char **page_data,
int *row_length);
void spectre_device_free (SpectreDevice *device);
SPECTRE_END_DECLS
#endif /* SPECTRE_DEVICE_H */
libspectre-0.2.12/libspectre/ps.c 0000644 0001750 0001750 00000222324 14155760473 013614 0000000 0000000 /*
* ps.c -- Postscript scanning and copying routines.
* Copyright (C) 1992 Timothy O. Theisen
* Copyright (C) 2004 Jose E. Marchesi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU gv; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA
*
* Author: Tim Theisen Systems Programmer
* Internet: tim@cs.wisc.edu Department of Computer Sciences
* UUCP: uwvax!tim University of Wisconsin-Madison
* Phone: (608)262-0438 1210 West Dayton Street
* FAX: (608)262-9777 Madison, WI 53706
*
* Changes submitted by Maurizio Loreti distributed on the public
* domain:
*
* - Code for handle bzip2 compressed files.
*/
/*
* Added the ps_io_*() routines, rewrote readline(), modified
* pscopyuntil() and pscopydoc() and eliminated pscopy().
* The modifications mainly aim at
* - elimination of the (line length <= 255) constraint since
* there are just too many documents ignoring this requirement.
* - acceptance of '\r' as line terminator as suggested by
* Martin Buck (martin-2.buck@student.uni-ulm.de).
* Johannes Plass, 04/96 (plass@thep.physik.uni-mainz.de)
*
*/
/*
* > Believe it or not--even Adobe doesn't know how to produce correct
* > PS-files. Their Acrobat Reader sometimes starts including other files
* > with %%BeginFile instead of %%BeginFile: and even more often ends them
* > with just %%EOF instead of %%EndFile.
* > Martin Buck, martin-2.buck@student.uni-ulm.de
*
* Therefore we use Martin's ACROREAD_WORKAROUND (thanks for the patch, Martin).
* ###jp### 04/96
*
*/
/* modified by Russell Lang, rjl@aladdin.com to use with GSview
* 1995-01-11
* supports DOS EPS files (binary header)
*/
#define USE_ACROREAD_WORKAROUND
#include
#include
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
#include
#include "spectre-utils.h"
#include "ps.h"
#ifdef BSD4_2
#define memset(a,b,c) bzero(a,c)
#endif
#define BEGINMESSAGE(txt)
#define ENDMESSAGE(txt)
#define INFMESSAGE(txt)
#define IMESSAGE(it)
#define INFIMESSAGE(txt,it)
#define FMESSAGE(ft)
#define INFFMESSAGE(txt,ft)
#define SMESSAGE(st)
#define INFSMESSAGE(txt,st)
#define IIMESSAGE(it1,it2)
#define INFIIMESSAGE(txt,it1,it2)
#define PS_malloc(sss) malloc ((size_t)(sss) )
#define PS_calloc(ccc,sss) calloc ((size_t)(ccc),(size_t)(sss) )
#define PS_realloc(ppp,sss) realloc ((void*) (ppp),(size_t)(sss) )
#define PS_free(ppp) free ((void*) (ppp) )
#define PS_cfree(ppp) cfree ((void*) (ppp) )
#define PS_XtMalloc(sss) malloc ((size_t)(sss) )
#define PS_XtRealloc(ppp,sss) realloc ((void*) (ppp),(size_t)(sss) )
#define PS_XtFree(ppp) free ((void*) (ppp) )
/* We use this helper function for providing proper */
/* case and colon :-) insensitive DSC matching */
static int dsc_strncmp(char *s1, char *s2, size_t n)
{
char *tmp;
if (_spectre_strncasecmp(s1, s2, n) == 0)
return 0;
if (s2[n-1] == ':'){
tmp = (char *) PS_malloc(n*sizeof(char));
strncpy(tmp, s2, (n-1));
tmp[n-1]=' ';
if (_spectre_strncasecmp(s1, tmp, n) == 0){
PS_free(tmp);
return 0;
}
PS_free(tmp);
}
return 1;
}
/* length calculates string length at compile time */
/* can only be used with character constants */
#define length(a) (sizeof((a))-1)
#define iscomment(a, b) (dsc_strncmp((a), (b), length((b))) == 0)
#define DSCcomment(a) ((a)[0] == '%' && (a)[1] == '%')
/* list of standard paper sizes from Adobe's PPD. */
static const struct documentmedia papersizes[] = {
{"BBox", 0, 0},
{"Letter", 612, 792},
{"LetterSmall", 612, 792},
{"Legal", 612, 1008},
{"Statement", 396, 612},
{"Tabloid", 792, 1224},
{"Ledger", 1224, 792},
{"Executive", 540, 720},
{"A0", 2384, 3370},
{"A1", 1684, 2384},
{"A2", 1191, 1684},
{"A3", 842, 1191},
{"A4", 595, 842},
{"A4Small", 595, 842},
{"A5", 420, 595},
{"B4", 729, 1032},
{"B5", 516, 729},
{"Folio", 612, 936},
{"Quarto", 610, 780},
{"10x14", 720, 1008},
{ NULL, 0, 0}
};
#if NeedFunctionPrototypes
# define PT(aaa) aaa
#else
# define PT(aaa) ()
#endif
typedef enum {
False = 0,
True
} Boolean;
/*--------------------------------------------------*/
/* Declarations for ps_io_*() routines. */
typedef struct FileDataStruct_ *FileData;
typedef struct FileDataStruct_ {
FILE *file; /* file */
int filepos; /* file position corresponding to the start of the line */
char *buf; /* buffer */
int buf_size; /* size of buffer */
int buf_end; /* last char in buffer given as offset to buf */
int line_begin; /* start of the line given as offset to buf */
int line_end; /* end of the line given as offset to buf */
int line_len; /* length of line, i.e. (line_end-line_begin) */
char line_termchar; /* char exchanged for a '\0' at end of line */
int status; /* 0 = okay, 1 = failed */
} FileDataStruct;
static FileData ps_io_init PT((FILE *));
static void ps_io_exit PT((FileData));
static void ps_io_rewind PT((FileData));
static char *ps_io_fgetchars PT((FileData, int));
static int ps_io_fseek PT((FileData, int));
static int ps_io_ftell PT((FileData));
static char *readline PT((FileData, long, char **, long *, unsigned int *));
static char *readlineuntil PT((FileData, long, char **, long *, unsigned int *, char));
static char *gettextline PT((char *));
static char *ps_gettext PT((char *,char **));
static int blank PT((char *));
static char *pscopyuntil PT((FileData,FILE *,long,long,char *));
/* DOS EPS header reading */
static unsigned long ps_read_doseps PT((FileData, DOSEPS *));
static PS_DWORD reorder_dword PT((PS_DWORD));
static PS_WORD reorder_word PT((PS_WORD));
static char *skipped_line = "% ps_io_fgetchars: skipped line";
static char *empty_string = "";
static Boolean scan_boundingbox(int *bb, const char *line)
{
char fllx[21], flly[21], furx[21], fury[21];
if (sscanf (line, "%d %d %d %d",
&bb[LLX], &bb[LLY], &bb[URX], &bb[URY]) == 4)
return True;
if (sscanf (line, "%20s %20s %20s %20s",
fllx, flly, furx, fury) == 4) {
float ffllx, fflly, ffurx, ffury;
ffllx = _spectre_strtod (fllx, NULL);
fflly = _spectre_strtod (flly, NULL);
ffurx = _spectre_strtod (furx, NULL);
ffury = _spectre_strtod (fury, NULL);
bb[LLX] = ffllx;
bb[LLY] = fflly;
bb[URX] = ffurx;
bb[URY] = ffury;
if (bb[LLX] > ffllx)
bb[LLX]--;
if (bb[LLY] > fflly)
bb[LLY]--;
if (bb[URX] < ffurx)
bb[URX]++;
if (bb[URY] < ffury)
bb[URY]++;
return True;
}
return False;
}
/*--------------------------------------------------*/
/*
* psscan -- scan the PostScript file for document structuring comments.
*
* This scanner is designed to retrieve the information necessary for
* the ghostview previewer. It will scan files that conform to any
* version (1.0, 2.0, 2.1, or 3.0) of the document structuring conventions.
* It does not really care which version of comments the file contains.
* (The comments are largely upward compatible.) It will scan a number
* of non-conforming documents. (You could have part of the document
* conform to V2.0 and the rest conform to V3.0. It would be similar
* to the DC-2 1/2+, it would look funny but it can still fly.)
*
* This routine returns a pointer to the document structure.
* The structure contains the information relevant to previewing.
* These include EPSF flag (to tell if the file is a encapsulated figure),
* Page Media (for the Page Size), Bounding Box (to minimize backing
* pixmap size or determine window size for encapsulated PostScript),
* Orientation of Paper (for default transformation matrix), and
* Page Order. The title and CreationDate are also retrieved to
* help identify the document.
*
* The following comments are examined:
*
* Header section:
* Must start with %!PS-Adobe-. Version numbers ignored.
*
* %!PS-Adobe-* [EPSF*] (changed EPSF-* to EPSF* to do XFig a favor ...###jp###)
* %%BoundingBox: |(atend)
* %%CreationDate:
* %%Creator:
* %%Orientation: Portrait|Landscape|(atend)
* %%Pages: []|(atend)
* %%PageOrder: Ascend|Descend|Special|(atend)
* %%Title:
* %%DocumentMedia:
* %%DocumentPaperSizes:
* %%EndComments
*
* Note: Either the 3.0 or 2.0 syntax for %%Pages is accepted.
* Also either the 2.0 %%DocumentPaperSizes or the 3.0
* %%DocumentMedia comments are accepted as well.
*
* The header section ends either explicitly with %%EndComments or
* implicitly with any line that does not begin with %X where X is
* a not whitespace character.
*
* If the file is encapsulated PostScript the optional Preview section
* is next:
*
* %%BeginPreview
* %%EndPreview
*
* This section explicitly begins and ends with the above comments.
*
* Next the Defaults section for version 3 page defaults:
*
* %%BeginDefaults
* %%PageBoundingBox:
* %%PageOrientation: Portrait|Landscape
* %%PageMedia:
* %%EndDefaults
*
* This section explicitly begins and ends with the above comments.
*
* The prolog section either explicitly starts with %%BeginProlog or
* implicitly with any nonblank line.
*
* %%BeginProlog
* %%EndProlog
*
* The Prolog should end with %%EndProlog, however the proglog implicitly
* ends when %%BeginSetup, %%Page, %%Trailer or %%EOF are encountered.
*
* The Setup section is where the version 2 page defaults are found.
* This section either explicitly begins with %%BeginSetup or implicitly
* with any nonblank line after the Prolog.
*
* %%BeginSetup
* %%PageBoundingBox:
* %%PageOrientation: Portrait|Landscape
* %%PaperSize:
* %%EndSetup
*
* The Setup should end with %%EndSetup, however the setup implicitly
* ends when %%Page, %%Trailer or %%EOF are encountered.
*
* Next each page starts explicitly with %%Page and ends implicitly with
* %%Page or %%Trailer or %%EOF. The following comments are recognized:
*
* %%Page:
* %%PageBoundingBox: |(atend)
* %%PageOrientation: Portrait|Landscape
* %%PageMedia:
* %%PaperSize:
*
* The trailer section start explicitly with %%Trailer and end with %%EOF.
* The following comment are examined with the proper (atend) notation
* was used in the header:
*
* %%Trailer
* %%BoundingBox: |(atend)
* %%Orientation: Portrait|Landscape|(atend)
* %%Pages: []|(atend)
* %%PageOrder: Ascend|Descend|Special|(atend)
* %%EOF
*
*
* + A DC-3 received severe damage to one of its wings. The wing was a total
* loss. There was no replacement readily available, so the mechanic
* installed a wing from a DC-2.
*/
/*-----------------------------------------------------------*/
#define CHECK_MALLOCED(aaa)
/*###########################################################*/
/* psscan */
/*###########################################################*/
struct document *
psscan(FILE *file, const char *filename, int scanstyle)
{
struct document *doc;
int bb_set = NONE;
int pages_set = NONE;
int page_order_set = NONE;
int orientation_set = NONE;
int page_bb_set = NONE;
int page_media_set = NONE;
int preread; /* flag which tells the readline isn't needed */
unsigned int i;
unsigned int maxpages = 0;
unsigned int nextpage = 1; /* Next expected page */
unsigned int thispage;
int ignore = 0; /* whether to ignore page ordinals */
char *label;
char *line;
/* 255 characters + 1 newline + 1 NULL */
char text[PSLINELENGTH]; /* Temporary storage for text */
long position; /* Position of the current line */
long beginsection; /* Position of the beginning of the section */
unsigned int line_len; /* Length of the current line */
unsigned int section_len = 0; /* Place to accumulate the section length */
char *next_char; /* 1st char after text returned by ps_gettext() */
char *cp;
ConstMedia dmp;
long enddoseps; /* zero of not DOS EPS, otherwise position of end of ps section */
DOSEPS doseps;
FileData fd;
int respect_eof; /* Derived from the scanstyle argument.
If set to 0 EOF comments will be ignored,
if set to 1 they will be taken seriously.
Purpose; Out there are many documents which
include other DSC conforming documents without
without enclosing them by 'BeginDocument' and
'EndDocument' comments. This may cause fake EOF
comments to appear in the body of a page.
Similarly, if respect_eof is set to false
'Trailer' comments are ignored except of the
last one found in the document.
*/
int ignore_dsc; /* Derived from scanstyle.
If set the document structure will be ignored.
*/
BEGINMESSAGE(psscan)
respect_eof = (scanstyle & SCANSTYLE_IGNORE_EOF) ? 0 : 1;
ignore_dsc = (scanstyle & SCANSTYLE_IGNORE_DSC) ? 1 : 0;
if (ignore_dsc) {
INFMESSAGE(ignoring DSC)
ENDMESSAGE(psscan)
return(NULL);
}
fd = ps_io_init(file);
/* rjl: check for DOS EPS files and almost DSC files that start with ^D */
enddoseps = ps_read_doseps (fd, &doseps);
if (!readline(fd, enddoseps, &line, &position, &line_len)) {
fprintf(stderr, "Warning: empty file.\n");
ENDMESSAGE(psscan)
ps_io_exit(fd);
return(NULL);
}
/* HP printer job language data follows. Some printer drivers add pjl
* commands to switch a pjl printer to postscript mode. If no PS header
* follows, this seems to be a real pjl file. */
if(iscomment(line, "\033%-12345X@PJL")) {
/* read until first DSC comment */
readlineuntil(fd, enddoseps, &line, &position, &line_len, '%');
if(line[0] != '%') {
fprintf(stderr, "psscan error: input files seems to be a PJL file.\n");
ENDMESSAGE(psscan)
ps_io_exit(fd);
return (NULL);
}
}
// Initialize text so that all the strcmp we do after sscanf don't
// end up reading uninitialized memory if the sscanf fails
text[0] = '\0';
/* Header comments */
/* Header should start with "%!PS-Adobe-", but some programms omit
* parts of this or add a ^D at the beginning. */
if ((iscomment(line,"%!PS") || iscomment(line, "\004%!PS"))) {
INFMESSAGE(found "PS-Adobe-" comment)
doc = (struct document *) PS_calloc(1, sizeof(struct document));
CHECK_MALLOCED(doc);
/* ignore possible leading ^D */
if (*line == '\004') {
position++;
line_len--;
}
doc->ref_count = 1;
doc->filename = _spectre_strdup (filename);
doc->beginheader = position;
section_len = line_len;
text[0] = '\0';
sscanf(line, "%%!%256s %*s", text);
doc->format = _spectre_strdup (text);
text[0] = '\0';
sscanf(line, "%*s %256s", text);
doc->epsf = iscomment(text, "EPSF");
} else {
/* There are postscript documents that do not have
%PS at the beginning, usually unstructured. We should GS decide
For instance, the tech reports at this university:
http://svrc.it.uq.edu.au/Bibliography/svrc-tr.html?94-45
add ugly PostScript before the actual document.
GS and gv is
able to display them correctly as unstructured PS.
In a way, this makes sense, a program PostScript does not need
the !PS at the beginning.
*/
doc = (struct document *) PS_calloc(1, sizeof(struct document));
CHECK_MALLOCED(doc);
doc->ref_count = 1;
doc->filename = _spectre_strdup (filename);
doc->default_page_orientation = NONE;
doc->orientation = NONE;
}
if (enddoseps) { /* rjl: add doseps header */
doc->doseps = (DOSEPS *) malloc(sizeof(DOSEPS));
*(doc->doseps) = doseps;
}
preread = 0;
while (preread || readline(fd, enddoseps, &line, &position, &line_len)) {
if (!preread) section_len += line_len;
preread = 0;
if (line[0] != '%' ||
iscomment(line+1, "%EndComments") ||
line[1] == ' ' || line[1] == '\t' || line[1] == '\n' ||
!isprint(line[1])) {
break;
} else if (line[1] != '%') {
/* Do nothing */
} else if (doc->title == NULL && iscomment(line+2, "Title:")) {
doc->title = gettextline(line+length("%%Title:"));
} else if (doc->date == NULL && iscomment(line+2, "CreationDate:")) {
doc->date = gettextline(line+length("%%CreationDate:"));
} else if (doc->languagelevel == NULL && iscomment(line+2, "LanguageLevel:")) {
doc->languagelevel = gettextline(line+length("%%LanguageLevel:"));
} else if(doc->creator == NULL && iscomment(line + 2, "Creator:")) {
doc->creator = gettextline(line + length("%%Creator:"));
} else if(doc->fortext == NULL && iscomment(line + 2, "For:")) {
doc->fortext = gettextline(line + length("%%For:"));
} else if (bb_set == NONE && iscomment(line+2, "BoundingBox:")) {
sscanf(line+length("%%BoundingBox:"), "%256s", text);
if (strcmp(text, "(atend)") == 0) {
bb_set = ATEND;
} else {
if (scan_boundingbox(doc->boundingbox,
line + length("%%BoundingBox:")))
bb_set = 1;
}
} else if (orientation_set == NONE &&
iscomment(line+2, "Orientation:")) {
sscanf(line+length("%%Orientation:"), "%256s", text);
if (strcmp(text, "(atend)") == 0 || strcmp(text, "atend") == 0) {
orientation_set = ATEND;
} else if (strcmp(text, "Portrait") == 0) {
doc->orientation = PORTRAIT;
orientation_set = 1;
} else if (strcmp(text, "Landscape") == 0) {
doc->orientation = LANDSCAPE;
orientation_set = 1;
} else if (strcmp(text, "Seascape") == 0) {
doc->orientation = SEASCAPE;
orientation_set = 1;
} else if (strcmp(text, "UpsideDown") == 0) {
doc->orientation = UPSIDEDOWN;
orientation_set = 1;
}
} else if (page_order_set == NONE && iscomment(line+2, "PageOrder:")) {
sscanf(line+length("%%PageOrder:"), "%256s", text);
if (strcmp(text, "(atend)") == 0 || strcmp(text, "atend") == 0) {
page_order_set = ATEND;
} else if (strcmp(text, "Ascend") == 0) {
doc->pageorder = ASCEND;
page_order_set = 1;
} else if (strcmp(text, "Descend") == 0) {
doc->pageorder = DESCEND;
page_order_set = 1;
} else if (strcmp(text, "Special") == 0) {
doc->pageorder = SPECIAL;
page_order_set = 1;
}
} else if (pages_set == NONE && iscomment(line+2, "Pages:")) {
sscanf(line+length("%%Pages:"), "%256s", text);
if (strcmp(text, "(atend)") == 0 || strcmp(text, "atend") == 0) {
pages_set = ATEND;
} else {
int page_order;
switch (sscanf(line+length("%%Pages:"), "%u %d",
&maxpages, &page_order)) {
case 2:
if (page_order_set == NONE) {
if (page_order == -1) {
doc->pageorder = DESCEND;
} else if (page_order == 0) {
doc->pageorder = SPECIAL;
} else if (page_order == 1) {
doc->pageorder = ASCEND;
}
}
// fall-through
case 1:
if (maxpages > 0) {
PS_free(doc->pages);
doc->pages = (struct page *) PS_calloc(maxpages,
sizeof(struct page));
if (!doc->pages)
maxpages = 0;
CHECK_MALLOCED(doc->pages);
}
}
}
} else if (doc->nummedia == NONE &&
iscomment(line+2, "DocumentMedia:")) {
char w[21], h[21];
PS_free(doc->media);
doc->media = (Media) PS_calloc(1, sizeof (MediaStruct));
CHECK_MALLOCED(doc->media);
doc->media[0].name = ps_gettext(line+length("%%DocumentMedia:"),
&next_char);
if (doc->media[0].name != NULL) {
if (sscanf(next_char, "%20s %20s", w, h) == 2) {
doc->media[0].width = _spectre_strtod (w, NULL) + 0.5;
doc->media[0].height = _spectre_strtod (h, NULL) + 0.5;
}
if (doc->media[0].width != 0 && doc->media[0].height != 0) {
doc->nummedia = 1;
} else {
PS_free(doc->media[0].name);
doc->media[0].name = NULL;
}
}
preread=1;
while (readline(fd, enddoseps, &line, &position, &line_len) &&
DSCcomment(line) && iscomment(line+2, "+")) {
section_len += line_len;
doc->media = (Media)
PS_realloc(doc->media,
(doc->nummedia+1)*
sizeof (MediaStruct));
CHECK_MALLOCED(doc->media);
memset (doc->media + doc->nummedia, 0, sizeof (MediaStruct));
doc->media[doc->nummedia].name = ps_gettext(line+length("%%+"),
&next_char);
if (doc->media[doc->nummedia].name != NULL) {
if (sscanf(next_char, "%20s %20s", w, h) == 2) {
doc->media[doc->nummedia].width = _spectre_strtod (w, NULL) + 0.5;
doc->media[doc->nummedia].height = _spectre_strtod (h, NULL) + 0.5;
}
if (doc->media[doc->nummedia].width != 0 && doc->media[doc->nummedia].height != 0) {
doc->nummedia++;
} else {
PS_free(doc->media[doc->nummedia].name);
doc->media[doc->nummedia].name = NULL;
}
}
}
section_len += line_len;
if (doc->nummedia != 0) doc->default_page_media = doc->media;
} else if (doc->nummedia == NONE &&
iscomment(line+2, "DocumentPaperSizes:")) {
PS_free(doc->media);
doc->media = (Media) PS_calloc(1, sizeof (MediaStruct));
CHECK_MALLOCED(doc->media);
doc->media[0].name = ps_gettext(line+length("%%DocumentPaperSizes:"),
&next_char);
if (doc->media[0].name != NULL) {
for (i=0; papersizes[i].name; i++) {
dmp = (Media)&papersizes[i];
/* Note: Paper size comment uses down cased paper size
* name. Case insensitive compares are only used for
* PaperSize comments.
*/
if (_spectre_strcasecmp(doc->media[0].name, dmp->name) == 0) {
PS_free(doc->media[0].name);
doc->media[0].name = (char *)PS_malloc(strlen(dmp->name)+1);
CHECK_MALLOCED(doc->media[0].name);
strcpy(doc->media[0].name, dmp->name);
doc->media[0].width = dmp->width;
doc->media[0].height = dmp->height;
break;
}
}
if (doc->media[0].width != 0 && doc->media[0].height != 0) {
doc->nummedia = 1;
} else {
PS_free(doc->media[0].name);
doc->media[0].name = NULL;
}
}
while ((cp = ps_gettext(next_char, &next_char))) {
doc->media = (Media)
PS_realloc(doc->media,
(doc->nummedia+1)*
sizeof (MediaStruct));
CHECK_MALLOCED(doc->media);
memset (doc->media + doc->nummedia, 0, sizeof (MediaStruct));
doc->media[doc->nummedia].name = cp;
for (i=0; papersizes[i].name; i++) {
dmp = (Media)&papersizes[i];
/* Note: Paper size comment uses down cased paper size
* name. Case insensitive compares are only used for
* PaperSize comments.
*/
if (_spectre_strcasecmp(doc->media[doc->nummedia].name,
dmp->name) == 0) {
PS_free(doc->media[doc->nummedia].name);
doc->media[doc->nummedia].name =
(char *)PS_malloc(strlen(dmp->name)+1);
CHECK_MALLOCED(doc->media[doc->nummedia].name);
strcpy(doc->media[doc->nummedia].name, dmp->name);
doc->media[doc->nummedia].width = dmp->width;
doc->media[doc->nummedia].height = dmp->height;
break;
}
}
if (doc->media[doc->nummedia].width != 0 && doc->media[doc->nummedia].height != 0) {
doc->nummedia++;
} else {
PS_free(doc->media[doc->nummedia].name);
doc->media[doc->nummedia].name = NULL;
}
}
preread=1;
while (readline(fd, enddoseps, &line, &position, &line_len) &&
DSCcomment(line) && iscomment(line+2, "+")) {
section_len += line_len;
next_char = line + length("%%+");
while ((cp = ps_gettext(next_char, &next_char))) {
doc->media = (Media)
PS_realloc(doc->media,
(doc->nummedia+1)*
sizeof (MediaStruct));
CHECK_MALLOCED(doc->media);
memset (doc->media + doc->nummedia, 0, sizeof (MediaStruct));
doc->media[doc->nummedia].name = cp;
for (i=0; papersizes[i].name; i++) {
dmp = (Media)&papersizes[i];
/* Note: Paper size comment uses down cased paper size
* name. Case insensitive compares are only used for
* PaperSize comments.
*/
if (_spectre_strcasecmp(doc->media[doc->nummedia].name,
dmp->name) == 0) {
doc->media[doc->nummedia].width = dmp->width;
doc->media[doc->nummedia].height = dmp->height;
break;
}
}
if (doc->media[doc->nummedia].width != 0 && doc->media[doc->nummedia].height != 0) {
doc->nummedia++;
} else {
PS_free(doc->media[doc->nummedia].name);
doc->media[doc->nummedia].name = NULL;
}
}
}
section_len += line_len;
if (doc->nummedia != 0) doc->default_page_media = doc->media;
}
}
if (DSCcomment(line) && iscomment(line+2, "EndComments")) {
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
}
doc->endheader = position;
doc->lenheader = section_len - line_len;
/* Optional Preview comments for encapsulated PostScript files */
beginsection = position;
section_len = line_len;
while (blank(line) && readline(fd, enddoseps, &line, &position, &line_len)) {
section_len += line_len;
}
if (doc->epsf && DSCcomment(line) && iscomment(line+2, "BeginPreview")) {
doc->beginpreview = beginsection;
beginsection = 0;
while (readline(fd, enddoseps, &line, &position, &line_len) &&
!(DSCcomment(line) && iscomment(line+2, "EndPreview"))) {
section_len += line_len;
}
section_len += line_len;
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
doc->endpreview = position;
doc->lenpreview = section_len - line_len;
}
/* Page Defaults for Version 3.0 files */
if (beginsection == 0) {
beginsection = position;
section_len = line_len;
}
while (blank(line) && readline(fd, enddoseps, &line, &position, &line_len)) {
section_len += line_len;
}
if (DSCcomment(line) && iscomment(line+2, "BeginDefaults")) {
doc->begindefaults = beginsection;
beginsection = 0;
while (readline(fd, enddoseps, &line, &position, &line_len) &&
!(DSCcomment(line) && iscomment(line+2, "EndDefaults"))) {
section_len += line_len;
if (!DSCcomment(line)) {
/* Do nothing */
} else if (doc->default_page_orientation == NONE &&
iscomment(line+2, "PageOrientation:")) {
sscanf(line+length("%%PageOrientation:"), "%256s", text);
if (strcmp(text, "Portrait") == 0) {
doc->default_page_orientation = PORTRAIT;
} else if (strcmp(text, "Landscape") == 0) {
doc->default_page_orientation = LANDSCAPE;
} else if (strcmp(text, "Seascape") == 0) {
doc->default_page_orientation = SEASCAPE;
} else if (strcmp(text, "UpsideDown") == 0) {
doc->default_page_orientation = UPSIDEDOWN;
}
} else if (page_media_set == NONE &&
iscomment(line+2, "PageMedia:")) {
cp = ps_gettext(line+length("%%PageMedia:"), NULL);
if (cp) {
for (dmp = doc->media, i=0; inummedia; i++, dmp++) {
if (strcmp(cp, dmp->name) == 0) {
doc->default_page_media = dmp;
page_media_set = 1;
break;
}
}
PS_free(cp);
}
} else if (page_bb_set == NONE &&
iscomment(line+2, "PageBoundingBox:")) {
if (scan_boundingbox(doc->default_page_boundingbox,
line+length("%%PageBoundingBox:")))
page_bb_set = 1;
}
}
section_len += line_len;
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
doc->enddefaults = position;
doc->lendefaults = section_len - line_len;
}
/* Document Prolog */
if (beginsection == 0) {
beginsection = position;
section_len = line_len;
}
while (blank(line) && readline(fd, enddoseps, &line, &position, &line_len)) {
section_len += line_len;
}
if (!(DSCcomment(line) &&
(iscomment(line+2, "BeginSetup") ||
iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
iscomment(line+2, "EOF")))) {
doc->beginprolog = beginsection;
beginsection = 0;
preread = 1;
while ((preread ||
readline(fd, enddoseps, &line, &position, &line_len)) &&
!(DSCcomment(line) &&
(iscomment(line+2, "EndProlog") ||
iscomment(line+2, "BeginSetup") ||
iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
iscomment(line+2, "EOF")))) {
if (iscomment(line, "%!PS")) {
/* Embedded document in Prolog, typically font resources.
* Skip until end of resource or Prolog
*/
while (readline(fd, enddoseps, &line, &position, &line_len) &&
!(DSCcomment(line) &&
(iscomment(line+2, "EndProlog") ||
iscomment(line+2, "BeginSetup") ||
iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
iscomment(line+2, "EOF")))) {
section_len += line_len;
}
}
if (!preread) section_len += line_len;
preread = 0;
}
section_len += line_len;
if (DSCcomment(line) && iscomment(line+2, "EndProlog")) {
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
}
doc->endprolog = position;
doc->lenprolog = section_len - line_len;
}
/* Document Setup, Page Defaults found here for Version 2 files */
if (beginsection == 0) {
beginsection = position;
section_len = line_len;
}
while (blank(line) && readline(fd, enddoseps, &line, &position, &line_len)) {
section_len += line_len;
}
if (!(DSCcomment(line) &&
(iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
(respect_eof && iscomment(line+2, "EOF"))))) {
doc->beginsetup = beginsection;
beginsection = 0;
preread = 1;
while ((preread ||
readline(fd, enddoseps, &line, &position, &line_len)) &&
!(DSCcomment(line) &&
(iscomment(line+2, "EndSetup") ||
iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
(respect_eof && iscomment(line+2, "EOF"))))) {
if (!preread) section_len += line_len;
preread = 0;
if (!DSCcomment(line)) {
/* Do nothing */
} else if (doc->default_page_orientation == NONE &&
iscomment(line+2, "PageOrientation:")) {
sscanf(line+length("%%PageOrientation:"), "%256s", text);
if (strcmp(text, "Portrait") == 0) {
doc->default_page_orientation = PORTRAIT;
} else if (strcmp(text, "Landscape") == 0) {
doc->default_page_orientation = LANDSCAPE;
} else if (strcmp(text, "Seascape") == 0) {
doc->default_page_orientation = SEASCAPE;
} else if (strcmp(text, "UpsideDown") == 0) {
doc->default_page_orientation = UPSIDEDOWN;
}
} else if (page_media_set == NONE &&
iscomment(line+2, "PaperSize:")) {
cp = ps_gettext(line+length("%%PaperSize:"), NULL);
for (dmp = doc->media, i=0; inummedia; i++, dmp++) {
/* Note: Paper size comment uses down cased paper size
* name. Case insensitive compares are only used for
* PaperSize comments.
*/
if (cp && _spectre_strcasecmp(cp, dmp->name) == 0) {
doc->default_page_media = dmp;
page_media_set = 1;
break;
}
}
PS_free(cp);
} else if (page_bb_set == NONE &&
iscomment(line+2, "PageBoundingBox:")) {
if (scan_boundingbox(doc->default_page_boundingbox,
line+length("%%PageBoundingBox:")))
page_bb_set = 1;
}
}
section_len += line_len;
if (DSCcomment(line) && iscomment(line+2, "EndSetup")) {
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
}
doc->endsetup = position;
doc->lensetup = section_len - line_len;
}
/* BEGIN Mozilla fix. Some documents generated by mozilla
have resources between %%EndProlog and the first
page and there isn't any setup section. So instead
of including such resources in the first page,
we add them here as an implicit setup section
*/
else if (doc->endprolog != position) {
doc->beginsetup = beginsection;
doc->endsetup = position;
doc->lensetup = section_len - line_len;
beginsection = 0;
}
/* END Mozilla fix */
/* BEGIN Windows NT fix ###jp###
Mark Pfeifer (pfeiferm%ppddev@comet.cmis.abbott.com) told me
about problems when viewing Windows NT 3.51 generated postscript
files with gv. He found that the relevant postscript files
show important postscript code after the '%%EndSetup' and before
the first page comment '%%Page: x y'.
*/
if (doc->beginsetup) {
while (!(DSCcomment(line) &&
(iscomment(line+2, "EndSetup") ||
(iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
(respect_eof && iscomment(line+2, "EOF"))))) &&
(readline(fd, enddoseps, &line, &position, &line_len))) {
section_len += line_len;
doc->lensetup = section_len - line_len;
doc->endsetup = position;
}
}
/* END Windows NT fix ###jp##*/
/* Individual Pages */
if (beginsection == 0) {
beginsection = position;
section_len = line_len;
}
while (blank(line) && readline(fd, enddoseps, &line, &position, &line_len)) {
section_len += line_len;
}
if (maxpages == 0) {
maxpages = 1;
PS_free(doc->pages);
doc->pages = (struct page *) PS_calloc(maxpages, sizeof(struct page));
CHECK_MALLOCED(doc->pages);
}
newpage:
while (DSCcomment(line) && iscomment(line+2, "Page:")) {
label = ps_gettext(line+length("%%Page:"), &next_char);
if (sscanf(next_char, "%u", &thispage) != 1) thispage = 0;
if (nextpage == 1) {
ignore = thispage != 1;
}
if (!ignore && thispage != nextpage) {
PS_free(label);
doc->numpages--;
goto continuepage;
}
nextpage++;
if (doc->numpages == maxpages) {
maxpages++;
doc->pages = (struct page *)
PS_realloc(doc->pages, maxpages*sizeof (struct page));
CHECK_MALLOCED(doc->pages);
}
memset(&(doc->pages[doc->numpages]), 0, sizeof(struct page));
page_bb_set = NONE;
doc->pages[doc->numpages].label = label;
if (beginsection) {
doc->pages[doc->numpages].begin = beginsection;
beginsection = 0;
} else {
doc->pages[doc->numpages].begin = position;
section_len = line_len;
}
continuepage:
while (readline(fd, enddoseps, &line, &position, &line_len) &&
!(DSCcomment(line) &&
(iscomment(line+2, "Page:") ||
iscomment(line+2, "Trailer") ||
(respect_eof && iscomment(line+2, "EOF"))))) {
section_len += line_len;
if (!DSCcomment(line)) {
/* Do nothing */
} else if (doc->pages[doc->numpages].orientation == NONE &&
iscomment(line+2, "PageOrientation:")) {
const int res = sscanf(line+length("%%PageOrientation:"), "%256s", text);
if (res != EOF) {
if (strcmp(text, "Portrait") == 0) {
doc->pages[doc->numpages].orientation = PORTRAIT;
} else if (strcmp(text, "Landscape") == 0) {
doc->pages[doc->numpages].orientation = LANDSCAPE;
} else if (strcmp(text, "Seascape") == 0) {
doc->pages[doc->numpages].orientation = SEASCAPE;
} else if (strcmp(text, "UpsideDown") == 0) {
doc->pages[doc->numpages].orientation = UPSIDEDOWN;
}
}
} else if (doc->pages[doc->numpages].media == NULL &&
iscomment(line+2, "PageMedia:")) {
cp = ps_gettext(line+length("%%PageMedia:"), NULL);
for (dmp = doc->media, i=0; inummedia; i++, dmp++) {
if (cp && strcmp(cp, dmp->name) == 0) {
doc->pages[doc->numpages].media = dmp;
break;
}
}
PS_free(cp);
} else if (doc->pages[doc->numpages].media == NULL &&
iscomment(line+2, "PaperSize:")) {
cp = ps_gettext(line+length("%%PaperSize:"), NULL);
for (dmp = doc->media, i=0; inummedia; i++, dmp++) {
/* Note: Paper size comment uses down cased paper size
* name. Case insensitive compares are only used for
* PaperSize comments.
*/
if (cp && _spectre_strcasecmp(cp, dmp->name) == 0) {
doc->pages[doc->numpages].media = dmp;
break;
}
}
PS_free(cp);
} else if ((page_bb_set == NONE || page_bb_set == ATEND) &&
iscomment(line+2, "PageBoundingBox:")) {
const int res = sscanf(line+length("%%PageBoundingBox:"), "%256s", text);
if ((res != EOF) && (strcmp(text, "(atend)") == 0 || strcmp(text, "atend") == 0)) {
page_bb_set = ATEND;
} else {
if (scan_boundingbox(doc->pages[doc->numpages].boundingbox,
line+length("%%PageBoundingBox:")))
if(page_bb_set == NONE)
page_bb_set = 1;
}
}
}
section_len += line_len;
doc->pages[doc->numpages].end = position;
doc->pages[doc->numpages].len = section_len - line_len;
doc->numpages++;
}
/* Document Trailer */
if (beginsection) {
doc->begintrailer = beginsection;
beginsection = 0;
} else {
doc->begintrailer = position;
section_len = line_len;
}
preread = 1;
while ((preread ||
readline(fd, enddoseps, &line, &position, &line_len)) &&
!(respect_eof && DSCcomment(line) && iscomment(line+2, "EOF"))) {
if (!preread) section_len += line_len;
preread = 0;
if (!DSCcomment(line)) {
/* Do nothing */
} else if (iscomment(line+2, "Page:")) {
PS_free(ps_gettext(line+length("%%Page:"), &next_char));
if (sscanf(next_char, "%u", &thispage) != 1) thispage = 0;
if (!ignore && thispage == nextpage) {
if (doc->numpages > 0) {
doc->pages[doc->numpages-1].end = position;
doc->pages[doc->numpages-1].len += section_len - line_len;
} else {
if (doc->endsetup) {
doc->endsetup = position;
doc->endsetup += section_len - line_len;
} else if (doc->endprolog) {
doc->endprolog = position;
doc->endprolog += section_len - line_len;
}
}
goto newpage;
}
} else if (!respect_eof && iscomment(line+2, "Trailer")) {
/* What we thought was the start of the trailer was really */
/* the trailer of an EPS on the page. */
/* Set the end of the page to this trailer and keep scanning. */
if (doc->numpages > 0) {
doc->pages[ doc->numpages-1 ].end = position;
doc->pages[ doc->numpages-1 ].len += section_len - line_len;
}
doc->begintrailer = position;
section_len = line_len;
} else if (bb_set == ATEND && iscomment(line+2, "BoundingBox:")) {
scan_boundingbox(doc->boundingbox, line + length("%%BoundingBox:"));
} else if (orientation_set == ATEND &&
iscomment(line+2, "Orientation:")) {
sscanf(line+length("%%Orientation:"), "%256s", text);
if (strcmp(text, "Portrait") == 0) {
doc->orientation = PORTRAIT;
} else if (strcmp(text, "Landscape") == 0) {
doc->orientation = LANDSCAPE;
} else if (strcmp(text, "Seascape") == 0) {
doc->orientation = SEASCAPE;
} else if (strcmp(text, "UpsideDown") == 0) {
doc->orientation = UPSIDEDOWN;
}
} else if (page_order_set == ATEND && iscomment(line+2, "PageOrder:")) {
sscanf(line+length("%%PageOrder:"), "%256s", text);
if (strcmp(text, "Ascend") == 0) {
doc->pageorder = ASCEND;
} else if (strcmp(text, "Descend") == 0) {
doc->pageorder = DESCEND;
} else if (strcmp(text, "Special") == 0) {
doc->pageorder = SPECIAL;
}
} else if (pages_set == ATEND && iscomment(line+2, "Pages:")) {
int page_order;
if (sscanf(line+length("%%Pages:"), "%*u %d", &page_order) == 1) {
if (page_order_set == NONE) {
if (page_order == -1) doc->pageorder = DESCEND;
else if (page_order == 0) doc->pageorder = SPECIAL;
else if (page_order == 1) doc->pageorder = ASCEND;
}
}
}
}
section_len += line_len;
if (DSCcomment(line) && iscomment(line+2, "EOF")) {
readline(fd, enddoseps, &line, &position, &line_len);
section_len += line_len;
} else if (doc->doseps) {
/* No EOF, make sure endtrailer <= ps_end */
long ps_end = doc->doseps->ps_begin + doc->doseps->ps_length;
if (position > ps_end) {
position = ps_end;
section_len = position - doc->begintrailer;
line_len = 0;
}
}
doc->endtrailer = position;
doc->lentrailer = section_len - line_len;
#if 0
section_len = line_len;
preread = 1;
while (preread ||
readline(fd, enddoseps, &line, &position, &line_len)) {
if (!preread) section_len += line_len;
preread = 0;
if (DSCcomment(line) && iscomment(line+2, "Page:")) {
PS_free(ps_gettext(line+length("%%Page:"), &next_char));
if (sscanf(next_char, "%d", &thispage) != 1) thispage = 0;
if (!ignore && thispage == nextpage) {
if (doc->numpages > 0) {
doc->pages[doc->numpages-1].end = position;
doc->pages[doc->numpages-1].len += doc->lentrailer +
section_len - line_len;
} else {
if (doc->endsetup) {
doc->endsetup = position;
doc->endsetup += doc->lentrailer +
section_len - line_len;
} else if (doc->endprolog) {
doc->endprolog = position;
doc->endprolog += doc->lentrailer +
section_len - line_len;
}
}
goto newpage;
}
}
}
#endif
ENDMESSAGE(psscan)
ps_io_exit(fd);
return doc;
}
/*###########################################################*/
/*
* psfree -- free dynamic storage associated with document structure.
*/
/*###########################################################*/
static void
psfree(struct document *doc)
{
unsigned int i;
BEGINMESSAGE(psfree)
if (doc) {
for (i=0; inumpages; i++) {
if (doc->pages[i].label) PS_free(doc->pages[i].label);
}
for (i=0; inummedia; i++) {
if (doc->media[i].name) PS_free(doc->media[i].name);
}
if (doc->format) PS_free(doc->format);
if (doc->filename) PS_free(doc->filename);
if (doc->creator) PS_free(doc->creator);
if (doc->fortext) PS_free(doc->fortext);
if (doc->title) PS_free(doc->title);
if (doc->date) PS_free(doc->date);
if (doc->pages) PS_free(doc->pages);
if (doc->media) PS_free(doc->media);
if (doc->languagelevel) PS_free(doc->languagelevel);
if (doc->doseps) free(doc->doseps); /* rjl: */
PS_free(doc);
}
ENDMESSAGE(psfree)
}
void
psdocdestroy (struct document *doc)
{
if (!doc)
return;
_spectre_assert (doc->ref_count > 0);
doc->ref_count--;
if (doc->ref_count)
return;
psfree (doc);
}
struct document *
psdocreference (struct document *doc)
{
if (!doc)
return NULL;
_spectre_assert (doc->ref_count > 0);
doc->ref_count++;
return doc;
}
/*----------------------------------------------------------*/
/*
* gettextline -- skip over white space and return the rest of the line.
* If the text begins with '(' return the text string
* using ps_gettext().
*/
/*----------------------------------------------------------*/
static char *
gettextline(line)
char *line;
{
char *cp;
BEGINMESSAGE(gettextline)
while (*line && (*line == ' ' || *line == '\t')) line++;
if (*line == '(') {
ENDMESSAGE(gettextline)
return ps_gettext(line, NULL);
} else {
if (strlen(line) == 0) {ENDMESSAGE(gettextline) return NULL;}
cp = (char *) PS_malloc(strlen(line));
CHECK_MALLOCED(cp);
strncpy(cp, line, strlen(line)-1);
cp[strlen(line)-1] = '\0';
ENDMESSAGE(gettextline)
return cp;
}
}
/*----------------------------------------------------------*/
/*
* ps_gettext -- return the next text string on the line.
* return NULL if nothing is present.
*/
/*----------------------------------------------------------*/
static char *
ps_gettext(line, next_char)
char *line;
char **next_char;
{
char text[PSLINELENGTH]; /* Temporary storage for text */
char *cp;
int quoted=0;
BEGINMESSAGE(ps_gettext)
while (*line && (*line == ' ' || *line == '\t')) line++;
cp = text;
if (*line == '(') {
int level = 0;
quoted=1;
line++;
while (*line && !(*line == ')' && level == 0 )) {
if (cp - text >= PSLINELENGTH - 1)
break;
if (*line == '\\') {
if (*(line+1) == 'n') {
*cp++ = '\n';
line += 2;
} else if (*(line+1) == 'r') {
*cp++ = '\r';
line += 2;
} else if (*(line+1) == 't') {
*cp++ = '\t';
line += 2;
} else if (*(line+1) == 'b') {
*cp++ = '\b';
line += 2;
} else if (*(line+1) == 'f') {
*cp++ = '\f';
line += 2;
} else if (*(line+1) == '\\') {
*cp++ = '\\';
line += 2;
} else if (*(line+1) == '(') {
*cp++ = '(';
line += 2;
} else if (*(line+1) == ')') {
*cp++ = ')';
line += 2;
} else if (*(line+1) >= '0' && *(line+1) <= '9') {
if (*(line+2) >= '0' && *(line+2) <= '9') {
if (*(line+3) >= '0' && *(line+3) <= '9') {
*cp++ = ((*(line+1) - '0')*8 + *(line+2) - '0')*8 +
*(line+3) - '0';
line += 4;
} else {
*cp++ = (*(line+1) - '0')*8 + *(line+2) - '0';
line += 3;
}
} else {
*cp++ = *(line+1) - '0';
line += 2;
}
} else {
line++;
*cp++ = *line++;
}
} else if (*line == '(') {
level++;
*cp++ = *line++;
} else if (*line == ')') {
level--;
*cp++ = *line++;
} else {
*cp++ = *line++;
}
}
/* Delete trailing ')' */
if (*line == ')')
{
line++;
}
} else {
while (*line && !(*line == ' ' || *line == '\t' || *line == '\n')) {
if (cp - text >= PSLINELENGTH - 2)
break;
*cp++ = *line++;
}
}
*cp = '\0';
if (next_char) *next_char = line;
if (!quoted && strlen(text) == 0) {ENDMESSAGE(ps_gettext) return NULL;}
cp = (char *) PS_malloc(strlen(text)+1);
CHECK_MALLOCED(cp);
strcpy(cp, text);
ENDMESSAGE(ps_gettext)
return cp;
}
/*----------------------------------------------------------*/
/* ps_io_init */
/*----------------------------------------------------------*/
#define FD_FILE (fd->file)
#define FD_FILEPOS (fd->filepos)
#define FD_LINE_BEGIN (fd->line_begin)
#define FD_LINE_END (fd->line_end)
#define FD_LINE_LEN (fd->line_len)
#define FD_LINE_TERMCHAR (fd->line_termchar)
#define FD_BUF (fd->buf)
#define FD_BUF_END (fd->buf_end)
#define FD_BUF_SIZE (fd->buf_size)
#define FD_STATUS (fd->status)
#define FD_STATUS_OKAY 0
#define FD_STATUS_BUFTOOLARGE 1
#define FD_STATUS_NOMORECHARS 2
#define LINE_CHUNK_SIZE 4096
#define MAX_PS_IO_FGETCHARS_BUF_SIZE 57344
#define BREAK_PS_IO_FGETCHARS_BUF_SIZE 49152
static FileData ps_io_init(file)
FILE *file;
{
FileData fd;
size_t size = sizeof(FileDataStruct);
BEGINMESSAGE(ps_io_init)
fd = (FileData) PS_XtMalloc(size);
memset((void*) fd ,0,(size_t)size);
rewind(file);
FD_FILE = file;
FD_FILEPOS = ftell(file);
FD_BUF_SIZE = (2*LINE_CHUNK_SIZE)+1;
FD_BUF = PS_XtMalloc(FD_BUF_SIZE);
FD_BUF[0] = '\0';
ENDMESSAGE(ps_io_init)
return(fd);
}
/*----------------------------------------------------------*/
/* ps_io_rewind */
/*----------------------------------------------------------*/
static void
ps_io_rewind(fd)
FileData fd;
{
rewind(FD_FILE);
FD_FILEPOS = ftell(FD_FILE);
FD_BUF[0] = '\0';
FD_BUF_END = 0;
FD_BUF_SIZE = 0;
FD_LINE_BEGIN = 0;
FD_LINE_END = 0;
FD_LINE_LEN = 0;
FD_LINE_TERMCHAR = '\0';
FD_STATUS = FD_STATUS_OKAY;
}
/*----------------------------------------------------------*/
/* ps_io_exit */
/*----------------------------------------------------------*/
static void
ps_io_exit(fd)
FileData fd;
{
BEGINMESSAGE(ps_io_exit)
PS_XtFree(FD_BUF);
PS_XtFree(fd);
ENDMESSAGE(ps_io_exit)
}
/*----------------------------------------------------------*/
/* ps_io_fseek */
/*----------------------------------------------------------*/
static int
ps_io_fseek(fd,offset)
FileData fd;
int offset;
{
int status;
BEGINMESSAGE(ps_io_fseek)
status=fseek(FD_FILE,(long)offset,SEEK_SET);
FD_BUF_END = FD_LINE_BEGIN = FD_LINE_END = FD_LINE_LEN = 0;
FD_FILEPOS = offset;
FD_STATUS = FD_STATUS_OKAY;
ENDMESSAGE(ps_io_fseek)
return(status);
}
/*----------------------------------------------------------*/
/* ps_io_ftell */
/*----------------------------------------------------------*/
static int
ps_io_ftell(fd)
FileData fd;
{
BEGINMESSAGE(ps_io_ftell)
IMESSAGE(FD_FILEPOS)
ENDMESSAGE(ps_io_ftell)
return(FD_FILEPOS);
}
/*----------------------------------------------------------*/
/* ps_io_fgetchars */
/*----------------------------------------------------------*/
#ifdef USE_MEMMOVE_CODE
static void ps_memmove (d, s, l)
char *d;
const char *s;
unsigned l;
{
if (s < d) for (s += l, d += l; l; --l) *--d = *--s;
else if (s != d) for (; l; --l) *d++ = *s++;
}
#else
# define ps_memmove memmove
#endif
static char * ps_io_fgetchars(fd,num)
FileData fd;
int num;
{
char *eol=NULL,*tmp;
size_t size_of_char = sizeof(char);
BEGINMESSAGE(ps_io_fgetchars)
if (FD_STATUS != FD_STATUS_OKAY) {
INFMESSAGE(aborting since status not okay)
ENDMESSAGE(ps_io_fgetchars)
return(NULL);
}
FD_BUF[FD_LINE_END] = FD_LINE_TERMCHAR; /* restoring char previously exchanged against '\0' */
FD_LINE_BEGIN = FD_LINE_END;
#if 0
{
int fp = (int)(ftell(FD_FILE));
if (num<0) { INFMESSAGE(reading line) }
else { INFMESSAGE(reading specified num of chars) }
IIMESSAGE(FD_BUF_SIZE,FD_BUF_END)
IIMESSAGE(FD_LINE_BEGIN,FD_LINE_END)
INFIMESSAGE(unparsed:,FD_BUF_END-FD_LINE_END)
IMESSAGE(fp)
IIMESSAGE(FD_FILEPOS,fp-(FD_BUF_END-FD_LINE_END))
}
#endif /* 0 */
do {
if (num<0) { /* reading whole line */
if (FD_BUF_END-FD_LINE_END) {
/* strpbrk is faster but fails on lines with embedded NULLs
eol = strpbrk(FD_BUF+FD_LINE_END,"\n\r");
*/
tmp = FD_BUF + FD_BUF_END;
eol = FD_BUF + FD_LINE_END;
while (eol < tmp && *eol != '\n' && *eol != '\r') eol++;
if (eol >= tmp) eol = NULL;
if (eol) {
if (*eol=='\r' && *(eol+1)=='\n') eol += 2;
else eol++;
break;
}
}
} else { /* reading specified num of chars */
if (FD_BUF_END >= FD_LINE_BEGIN+num) {
eol = FD_BUF+FD_LINE_BEGIN+num;
break;
}
}
INFMESSAGE(no end of line yet)
if (FD_BUF_END - FD_LINE_BEGIN > BREAK_PS_IO_FGETCHARS_BUF_SIZE) {
INFMESSAGE(breaking line artificially)
eol = FD_BUF + FD_BUF_END - 1;
break;
}
while (FD_BUF_SIZE < FD_BUF_END+LINE_CHUNK_SIZE+1) {
if (FD_BUF_SIZE > MAX_PS_IO_FGETCHARS_BUF_SIZE) {
/* we should never get here, since the line is broken
artificially after BREAK_PS_IO_FGETCHARS_BUF_SIZE bytes. */
INFMESSAGE(buffer became to large)
ENDMESSAGE(ps_io_fgetchars)
fprintf(stderr, "gv: ps_io_fgetchars: Fatal Error: buffer became too large.\n");
exit(-1);
}
if (FD_LINE_BEGIN) {
INFMESSAGE(moving line to begin of buffer)
ps_memmove((void*)FD_BUF,(void*)(FD_BUF+FD_LINE_BEGIN),
((size_t)(FD_BUF_END-FD_LINE_BEGIN+1))*size_of_char);
FD_BUF_END -= FD_LINE_BEGIN;
FD_LINE_BEGIN = 0;
} else {
INFMESSAGE(enlarging buffer)
/*
FD_BUF_SIZE = FD_BUF_END+LINE_CHUNK_SIZE+1;
*/
FD_BUF_SIZE = FD_BUF_SIZE+LINE_CHUNK_SIZE+1;
IMESSAGE(FD_BUF_SIZE)
FD_BUF = PS_XtRealloc(FD_BUF,FD_BUF_SIZE);
}
}
FD_LINE_END = FD_BUF_END;
/* read() seems to fail sometimes (? ? ?) so we always use fread ###jp###,07/31/96*/
FD_BUF_END += fread(FD_BUF+FD_BUF_END,size_of_char,LINE_CHUNK_SIZE,FD_FILE);
FD_BUF[FD_BUF_END] = '\0';
if (FD_BUF_END-FD_LINE_END == 0) {
INFMESSAGE(failed to read more chars)
ENDMESSAGE(ps_io_fgetchars)
FD_STATUS = FD_STATUS_NOMORECHARS;
return(NULL);
}
}
while (1);
FD_LINE_END = eol - FD_BUF;
FD_LINE_LEN = FD_LINE_END - FD_LINE_BEGIN;
FD_LINE_TERMCHAR = FD_BUF[FD_LINE_END];
FD_BUF[FD_LINE_END] = '\0';
#ifdef USE_FTELL_FOR_FILEPOS
if (FD_LINE_END==FD_BUF_END) {
INFMESSAGE(### using ftell to get FD_FILEPOS)
/*
For VMS we cannot assume that the record is FD_LINE_LEN bytes long
on the disk. For stream_lf and stream_cr that is true, but not for
other formats, since VAXC/DECC converts the formatting into a single \n.
eg. variable format files have a 2-byte length and padding to an even
number of characters. So, we use ftell for each record.
This still will not work if we need to fseek to a \n or \r inside a
variable record (ftell always returns the start of the record in this
case).
(Tim Adye, adye@v2.rl.ac.uk)
*/
FD_FILEPOS = ftell(FD_FILE);
} else
#endif /* USE_FTELL_FOR_FILEPOS */
FD_FILEPOS += FD_LINE_LEN;
#if 0
SMESSAGE(FD_BUF+FD_LINE_BEGIN)
IIMESSAGE(FD_LINE_BEGIN,FD_LINE_END)
IIMESSAGE(FD_BUF_END,FD_LINE_LEN)
#endif
ENDMESSAGE(ps_io_fgetchars)
return(FD_BUF+FD_LINE_BEGIN);
}
/*----------------------------------------------------------*/
/*
readline()
Read the next line in the postscript file.
Automatically skip over data (as indicated by
%%BeginBinary/%%EndBinary or %%BeginData/%%EndData
comments.)
Also, skip over included documents (as indicated by
%%BeginDocument/%%EndDocument comments.)
*/
/*----------------------------------------------------------*/
static char * readline (fd, enddoseps, lineP, positionP, line_lenP)
FileData fd;
long enddoseps;
char **lineP;
long *positionP;
unsigned int *line_lenP;
{
unsigned int nbytes=0;
int skipped=0;
int nesting_level=0;
char *line;
BEGINMESSAGE(readline)
if (positionP) *positionP = FD_FILEPOS;
if (positionP && enddoseps) {
if (*positionP >= enddoseps)
return NULL; /* don't read any more, we have reached end of dos eps section */
}
line = ps_io_fgetchars(fd,-1);
if (!line) {
INFMESSAGE(could not get line)
*line_lenP = 0;
*lineP = empty_string;
ENDMESSAGE(readline)
return(NULL);
}
*line_lenP = FD_LINE_LEN;
#define IS_COMMENT(comment) \
(DSCcomment(line) && iscomment(line+2,(comment)))
#define IS_BEGIN(comment) \
(iscomment(line+7,(comment)))
#define IS_END(comment) \
(iscomment(line+5,(comment)))
#define SKIP_WHILE(cond) \
while (readline(fd, enddoseps, &line, NULL, &nbytes) && (cond)) *line_lenP += nbytes; \
skipped=1;
#define SKIP_UNTIL_1(comment) { \
INFMESSAGE(skipping until comment) \
SKIP_WHILE((!IS_COMMENT(comment))) \
INFMESSAGE(completed skipping until comment) \
}
#define SKIP_UNTIL_2(comment1,comment2) { \
INFMESSAGE(skipping until comment1 or comment2)\
SKIP_WHILE((!IS_COMMENT(comment1) && !IS_COMMENT(comment2)))\
INFMESSAGE(completed skipping until comment1 or comment2)\
}
#if 0
if ((scanstyle&SCANSTYLE_MISSING_BEGINDOCUMENT) &&
(line[0] == '%') &&
(*line_lenP > 11) &&
(iscomment(line,"%!PS-Adobe-") || iscomment(line + 1,"%!PS-Adobe-"))) {
char *c=line+11;
while (*c && !isspace(*c)) c++;
if (isspace(*c)) while (*c && isspace(*c)) c++;
/* don't skip EPSF files */
printf("line in question: %s\n",line);
if (strncmp(c,"EPSF",4)) {
printf("skipping starts here: %s\n",line);
SKIP_UNTIL_1("EOF")
*line_lenP += nbytes;
readline(fd, enddoseps, &line, NULL, &nbytes);
printf("skipping ends here: %s\n",line);
}
}
else
#endif
if (!IS_COMMENT("Begin")) {} /* Do nothing */
else if IS_BEGIN("Document:") { /* Skip the EPS without handling its content */
nesting_level=1;
line = ps_io_fgetchars(fd,-1);
if (line) *line_lenP += FD_LINE_LEN;
while (line) {
if (IS_COMMENT("Begin") && IS_BEGIN("Document:"))
nesting_level++;
else if (IS_COMMENT("End") && IS_END("Document"))
nesting_level--;
if (nesting_level == 0) break;
line = ps_io_fgetchars(fd,-1);
if (line) *line_lenP += FD_LINE_LEN;
}
}
else if IS_BEGIN("Feature:") SKIP_UNTIL_1("EndFeature")
#ifdef USE_ACROREAD_WORKAROUND
else if IS_BEGIN("File") SKIP_UNTIL_2("EndFile","EOF")
#else
else if IS_BEGIN("File") SKIP_UNTIL_1("EndFile")
#endif
else if IS_BEGIN("Font") SKIP_UNTIL_1("EndFont")
else if IS_BEGIN("ProcSet") SKIP_UNTIL_1("EndProcSet")
else if IS_BEGIN("Resource") SKIP_UNTIL_1("EndResource")
else if IS_BEGIN("Data:") {
int num;
char text[101];
INFMESSAGE(encountered "BeginData:")
if (FD_LINE_LEN > 100) FD_BUF[100] = '\0';
text[0] = '\0';
if (sscanf(line+length("%%BeginData:"), "%d %*s %100s", &num, text) >= 1) {
if (strcmp(text, "Lines") == 0) {
INFIMESSAGE(number of lines to skip:,num)
while (num) {
line = ps_io_fgetchars(fd,-1);
if (line) *line_lenP += FD_LINE_LEN;
num--;
}
} else {
int read_chunk_size = LINE_CHUNK_SIZE;
INFIMESSAGE(number of chars to skip:,num)
while (num>0) {
if (num <= LINE_CHUNK_SIZE) read_chunk_size=num;
line = ps_io_fgetchars(fd,read_chunk_size);
if (line) *line_lenP += FD_LINE_LEN;
num -= read_chunk_size;
}
}
}
SKIP_UNTIL_1("EndData")
}
else if IS_BEGIN("Binary:") {
int num;
INFMESSAGE(encountered "BeginBinary:")
if (sscanf(line+length("%%BeginBinary:"), "%d", &num) == 1) {
int read_chunk_size = LINE_CHUNK_SIZE;
INFIMESSAGE(number of chars to skip:,num)
while (num>0) {
if (num <= LINE_CHUNK_SIZE) read_chunk_size=num;
line = ps_io_fgetchars(fd,read_chunk_size);
if (line) *line_lenP += FD_LINE_LEN;
num -= read_chunk_size;
}
SKIP_UNTIL_1("EndBinary")
}
}
if (skipped) {
INFMESSAGE(skipped lines)
*line_lenP += nbytes;
*lineP = skipped_line;
} else {
*lineP = FD_BUF+FD_LINE_BEGIN;
}
ENDMESSAGE(readline)
return(FD_BUF+FD_LINE_BEGIN);
}
/*----------------------------------------------------------*/
/*
readlineuntil()
Read the next line in the postscript file until char is found
Similar to readline, but it doesn't skip lines.
*/
/*----------------------------------------------------------*/
static char * readlineuntil (FileData fd, long enddoseps, char **lineP, long *positionP, unsigned int *line_lenP, char charP)
{
char *line;
if (positionP) *positionP = FD_FILEPOS;
do {
line = ps_io_fgetchars(fd,-1);
if (!line) {
INFMESSAGE(could not get line)
*line_lenP = 0;
*lineP = empty_string;
ENDMESSAGE(readline)
return(NULL);
}
if (positionP) *positionP = FD_FILEPOS;
*line_lenP = FD_LINE_LEN;
*lineP = FD_BUF+FD_LINE_BEGIN;
} while (line[0] != charP);
return(FD_BUF+FD_LINE_BEGIN);
}
/*###########################################################*/
/*
* pscopyuntil -- copy lines of Postscript from a section of one file
* to another file until a particular comment is reached.
* Automatically switch to binary copying whenever
* %%BeginBinary/%%EndBinary or %%BeginData/%%EndData
* comments are encountered.
*/
/*###########################################################*/
char *
pscopyuntil(fd, to, begin, end, comment)
FileData fd;
FILE *to;
long begin; /* set negative to avoid initial seek */
long end;
char *comment;
{
char *line;
int comment_length;
BEGINMESSAGE(pscopyuntil)
if (comment) {
INFSMESSAGE(will copy until,comment)
comment_length = strlen(comment);
}
else {
INFMESSAGE(will copy until specified file position)
comment_length = 0;
}
if (begin >= 0) ps_io_fseek(fd, begin);
while (ps_io_ftell(fd) < end) {
line = ps_io_fgetchars(fd,-1);
if (!line) break;
if (comment && strncmp(line, comment, comment_length) == 0) {
char *cp = (char *) PS_malloc(strlen(line)+1);
INFSMESSAGE(encountered specified,comment)
CHECK_MALLOCED(cp);
strcpy(cp, line);
ENDMESSAGE(pscopyuntil)
return cp;
}
fputs(line, to);
if (!IS_COMMENT("Begin")) {} /* Do nothing */
else if IS_BEGIN("Data:") {
int num;
char text[101];
INFMESSAGE(encountered "BeginData:")
if (FD_LINE_LEN > 100) FD_BUF[100] = '\0';
text[0] = '\0';
if (sscanf(line+length("%%BeginData:"), "%d %*s %100s", &num, text) >= 1) {
if (strcmp(text, "Lines") == 0) {
INFIMESSAGE(number of lines:,num)
while (num) {
line = ps_io_fgetchars(fd,-1);
if (line) fputs(line,to);
num--;
}
} else {
int read_chunk_size = LINE_CHUNK_SIZE;
INFIMESSAGE(number of chars:,num)
while (num>0) {
if (num <= LINE_CHUNK_SIZE) read_chunk_size=num;
line = ps_io_fgetchars(fd,read_chunk_size);
if (line) fwrite(line,sizeof(char),FD_LINE_LEN, to);
num -= read_chunk_size;
}
}
}
}
else if IS_BEGIN("Binary:") {
int num;
INFMESSAGE(encountered "BeginBinary:")
if (sscanf(line+length("%%BeginBinary:"), "%d", &num) == 1) {
int read_chunk_size = LINE_CHUNK_SIZE;
INFIMESSAGE(number of chars:,num)
while (num>0) {
if (num <= LINE_CHUNK_SIZE) read_chunk_size=num;
line = ps_io_fgetchars(fd,read_chunk_size);
if (line) fwrite(line, sizeof (char),FD_LINE_LEN, to);
num -= read_chunk_size;
}
}
}
}
ENDMESSAGE(pscopyuntil)
return NULL;
}
/*----------------------------------------------------------*/
/* blank */
/* Check whether the line contains nothing but white space. */
/*----------------------------------------------------------*/
static int blank(line)
char *line;
{
char *cp = line;
BEGINMESSAGE(blank)
while (*cp == ' ' || *cp == '\t') cp++;
ENDMESSAGE(blank)
return *cp == '\n' || *cp== '\r' || (*cp == '%' && (line[0] != '%' || line[1] != '%'));
}
void
pscopy (FILE *from, FILE *to, Document d, long begin, long end)
{
FileData fd;
fd = ps_io_init(from);
pscopyuntil(fd, to, begin, end, NULL);
ps_io_exit(fd);
}
void
pscopyheaders (FILE *from, FILE *to, Document d)
{
char *comment;
Boolean pages_written = False;
int here;
FileData fd;
fd = ps_io_init(from);
here = d->beginheader;
while ((comment=pscopyuntil(fd,to,here,d->endheader,"%%Pages:"))) {
SMESSAGE(comment)
here = ps_io_ftell(fd);
if (pages_written) {
PS_free(comment);
continue;
}
fputs("%%Pages: (atend)\n", to);
pages_written = True;
PS_free(comment);
}
if (!pages_written && !d->epsf)
fputs("%%Pages: (atend)\n", to);
pscopyuntil(fd, to, d->beginpreview, d->endpreview,NULL);
pscopyuntil(fd, to, d->begindefaults, d->enddefaults,NULL);
pscopyuntil(fd, to, d->beginprolog, d->endprolog,NULL);
pscopyuntil(fd, to, d->beginsetup, d->endsetup,NULL);
ps_io_exit(fd);
}
void
pscopypage (FILE *from, FILE *to, Document d, unsigned int page, unsigned int n_page)
{
FileData fd;
char *comment;
fd = ps_io_init(from);
comment = pscopyuntil(fd,to,d->pages[page].begin,d->pages[page].end, "%%Page:");
fprintf(to, "%%%%Page: %s %d\n",d->pages[page].label, n_page);
PS_free(comment);
pscopyuntil(fd, to, -1, d->pages[page].end,NULL);
ps_io_exit(fd);
}
void
pscopytrailer (FILE *from, FILE *to, Document d, unsigned int n_pages)
{
FileData fd;
Boolean pages_written = False;
char *comment;
int here;
fd = ps_io_init(from);
here = d->begintrailer;
if (!d->epsf) {
pscopyuntil(fd, to, here, here + strlen ("%%Trailer") + 1, NULL);
here = ps_io_ftell(fd);
fprintf(to, "%%%%Pages: %d\n",n_pages);
}
while ((comment = pscopyuntil(fd, to, here, d->endtrailer, "%%Pages:"))) {
here = ps_io_ftell(fd);
if (pages_written) {
PS_free(comment);
continue;
}
pages_written = True;
PS_free(comment);
}
ps_io_exit(fd);
}
/*##########################################################*/
/* pscopydoc */
/* Copy the headers, marked pages, and trailer to fp */
/*##########################################################*/
void
pscopydoc(dest_file,src_filename,d,pagelist)
FILE *dest_file;
char *src_filename;
Document d;
char *pagelist;
{
FILE *src_file;
char text[PSLINELENGTH];
char *comment;
Boolean pages_written = False;
Boolean pages_atend = False;
int pages;
int page = 1;
unsigned int i, j;
int here;
FileData fd;
BEGINMESSAGE(pscopydoc)
INFSMESSAGE(copying from file, src_filename)
src_file = fopen(src_filename, "rb");
fd = ps_io_init(src_file);
i=0;
pages=0;
while (pagelist[i]) { if (pagelist[i]=='*') pages++; i++; }
INFIMESSAGE(number of pages to be copied,pages)
here = d->beginheader;
while ((comment=pscopyuntil(fd,dest_file,here,d->endheader,"%%Pages:"))) {
SMESSAGE(comment)
here = ps_io_ftell(fd);
if (pages_written || pages_atend) {
PS_free(comment);
continue;
}
sscanf(comment+length("%%Pages:"), "%256s", text);
if (strcmp(text, "(atend)") == 0) {
fputs(comment, dest_file);
pages_atend = True;
} else {
switch (sscanf(comment+length("%%Pages:"), "%*d %u", &i)) {
case 1:
fprintf(dest_file, "%%%%Pages: %d %d\n", pages, i);
break;
default:
fprintf(dest_file, "%%%%Pages: %d\n", pages);
break;
}
pages_written = True;
}
PS_free(comment);
}
pscopyuntil(fd, dest_file, d->beginpreview, d->endpreview,NULL);
pscopyuntil(fd, dest_file, d->begindefaults, d->enddefaults,NULL);
pscopyuntil(fd, dest_file, d->beginprolog, d->endprolog,NULL);
pscopyuntil(fd, dest_file, d->beginsetup, d->endsetup,NULL);
for (i = 0; i < d->numpages; i++) {
if (d->pageorder == DESCEND) j = (d->numpages - 1) - i;
else j = i;
if (pagelist[j]=='*') {
comment = pscopyuntil(fd,dest_file,d->pages[i].begin,d->pages[i].end, "%%Page:");
fprintf(dest_file, "%%%%Page: %s %d\n",d->pages[i].label, page++);
PS_free(comment);
pscopyuntil(fd, dest_file, -1, d->pages[i].end,NULL);
}
}
here = d->begintrailer;
while ((comment = pscopyuntil(fd, dest_file, here, d->endtrailer, "%%Pages:"))) {
here = ps_io_ftell(fd);
if (pages_written) {
PS_free(comment);
continue;
}
switch (sscanf(comment+length("%%Pages:"), "%*d %u", &i)) {
case 1:
fprintf(dest_file, "%%%%Pages: %d %d\n", pages, i);
break;
default:
fprintf(dest_file, "%%%%Pages: %d\n", pages);
break;
}
pages_written = True;
PS_free(comment);
}
fclose(src_file);
ps_io_exit(fd);
ENDMESSAGE(pscopydoc)
}
#undef length
/* rjl: routines to handle reading DOS EPS files */
static unsigned long dsc_arch = 0x00000001;
/* change byte order if architecture is big-endian */
static PS_DWORD
reorder_dword(val)
PS_DWORD val;
{
if (*((char *)(&dsc_arch)))
return val; /* little endian machine */
else
return ((val&0xff) << 24) | ((val&0xff00) << 8)
| ((val&0xff0000L) >> 8) | ((val>>24)&0xff);
}
/* change byte order if architecture is big-endian */
static PS_WORD
reorder_word(PS_WORD val)
{
if (*((char *)(&dsc_arch)))
return val; /* little endian machine */
else
return (PS_WORD) ((PS_WORD)(val&0xff) << 8) | (PS_WORD)((val&0xff00) >> 8);
}
static void
ps_read_doseps_dword(FileData fd, PS_DWORD *dword)
{
const size_t read = fread(dword, 4, 1, FD_FILE);
if (read == 4) {
*dword = (unsigned long)reorder_dword(*dword);
} else {
*dword = 0;
}
}
static void
ps_read_doseps_word(FileData fd, PS_WORD *word)
{
const size_t read = fread(word, 2, 1, FD_FILE);
if (read == 2) {
*word = (unsigned short)reorder_word(*word);
} else {
*word = 0;
}
}
/* DOS EPS header reading */
static unsigned long
ps_read_doseps(fd,doseps)
FileData fd;
DOSEPS *doseps;
{
const size_t read = fread(doseps->id, 1, 4, FD_FILE);
if (! ((read == 4) && (doseps->id[0]==0xc5) && (doseps->id[1]==0xd0)
&& (doseps->id[2]==0xd3) && (doseps->id[3]==0xc6)) ) {
/* id is "EPSF" with bit 7 set */
ps_io_rewind(fd);
return 0; /* OK */
}
ps_read_doseps_dword(fd, &doseps->ps_begin); /* PS offset */
ps_read_doseps_dword(fd, &doseps->ps_length); /* PS length */
ps_read_doseps_dword(fd, &doseps->mf_begin); /* Metafile offset */
ps_read_doseps_dword(fd, &doseps->mf_length); /* Metafile length */
ps_read_doseps_dword(fd, &doseps->tiff_begin); /* TIFF offset */
ps_read_doseps_dword(fd, &doseps->tiff_length); /* TIFF length */
ps_read_doseps_word(fd, &doseps->checksum);
ps_io_fseek(fd, doseps->ps_begin); /* seek to PS section */
return doseps->ps_begin + doseps->ps_length;
}
int
psgetpagebbox (const struct document *doc, int page, int *urx, int *ury, int *llx, int *lly)
{
int new_llx = 0;
int new_lly = 0;
int new_urx = 0;
int new_ury = 0;
if ((page >= 0) &&
(doc->pages) &&
(doc->pages[page].boundingbox[URX] >
doc->pages[page].boundingbox[LLX]) &&
(doc->pages[page].boundingbox[URY] >
doc->pages[page].boundingbox[LLY])) {
/* use page bbox */
new_llx = doc->pages[page].boundingbox[LLX];
new_lly = doc->pages[page].boundingbox[LLY];
new_urx = doc->pages[page].boundingbox[URX];
new_ury = doc->pages[page].boundingbox[URY];
} else if ((doc->boundingbox[URX] > doc->boundingbox[LLX]) &&
(doc->boundingbox[URY] > doc->boundingbox[LLY])) {
/* use doc bbox */
new_llx = doc->boundingbox[LLX];
new_lly = doc->boundingbox[LLY];
new_urx = doc->boundingbox[URX];
new_ury = doc->boundingbox[URY];
}
*llx = new_llx;
*lly = new_lly;
*urx = new_urx;
*ury = new_ury;
return (new_llx != 0 || new_lly != 0 || new_urx != 0 || new_ury != 0);
}
/* From Evince */
#define DEFAULT_PAGE_SIZE 1
void
psgetpagebox (const struct document *doc, int page, int *urx, int *ury, int *llx, int *lly)
{
int new_llx = 0;
int new_lly = 0;
int new_urx = 0;
int new_ury = 0;
int new_pagesize = -1;
if (new_pagesize == -1) {
new_pagesize = DEFAULT_PAGE_SIZE;
if (doc) {
/* If we have a document:
* We use -- the page size (if specified)
* or the doc. size (if specified)
* or the page bbox (if specified)
* or the bounding box
*/
if ((page >= 0) && (doc->numpages > (unsigned int)page) &&
(doc->pages) && (doc->pages[page].media)) {
new_pagesize = doc->pages[page].media - doc->media;
} else if (doc->default_page_media != NULL) {
new_pagesize = doc->default_page_media - doc->media;
} else if ((page >= 0) &&
(doc->numpages > (unsigned int)page) &&
(doc->pages) &&
(doc->pages[page].boundingbox[URX] >
doc->pages[page].boundingbox[LLX]) &&
(doc->pages[page].boundingbox[URY] >
doc->pages[page].boundingbox[LLY])) {
new_pagesize = -1;
} else if ((doc->boundingbox[URX] > doc->boundingbox[LLX]) &&
(doc->boundingbox[URY] > doc->boundingbox[LLY])) {
new_pagesize = -1;
}
}
}
/* Compute bounding box */
if (doc && (doc->epsf || new_pagesize == -1)) { /* epsf or bbox */
psgetpagebbox (doc, page, &new_urx, &new_ury, &new_llx, &new_lly);
} else {
if (new_pagesize < 0)
new_pagesize = DEFAULT_PAGE_SIZE;
new_llx = new_lly = 0;
if (doc && doc->media &&
((unsigned int)new_pagesize < doc->nummedia)) {
new_urx = doc->media[new_pagesize].width;
new_ury = doc->media[new_pagesize].height;
} else {
new_urx = papersizes[new_pagesize].width;
new_ury = papersizes[new_pagesize].height;
}
}
if (new_urx <= new_llx)
new_urx = papersizes[12].width;
if (new_ury <= new_lly)
new_ury = papersizes[12].height;
*urx = new_urx;
*ury = new_ury;
*llx = new_llx;
*lly = new_lly;
}
libspectre-0.2.12/libspectre/spectre-macros.h 0000644 0001750 0001750 00000003026 14155760600 016112 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_MACROS_H
#define SPECTRE_MACROS_H
#ifdef __cplusplus
# define SPECTRE_BEGIN_DECLS extern "C" {
# define SPECTRE_END_DECLS }
#else
# define SPECTRE_BEGIN_DECLS
# define SPECTRE_END_DECLS
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef NULL
# ifdef __cplusplus
# define NULL (0L)
# else /* !__cplusplus */
# define NULL ((void*) 0)
# endif /* !__cplusplus */
#endif
#if defined(_WIN32)
# define SPECTRE_PUBLIC __declspec(dllexport)
#elif defined(__GNUC__)
# define SPECTRE_PUBLIC __attribute__((visibility("default"))) extern
#else
# define SPECTRE_PUBLIC
#endif
#endif /* SPECTRE_MACROS_H */
libspectre-0.2.12/libspectre/spectre-document.h 0000644 0001750 0001750 00000020335 14155760600 016446 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_DOCUMENT_H
#define SPECTRE_DOCUMENT_H
#include
#include
#include
#include
SPECTRE_BEGIN_DECLS
/*! This is the object that represents a PostScript document. */
typedef struct SpectreDocument SpectreDocument;
/*! Creates a document */
SPECTRE_PUBLIC
SpectreDocument *spectre_document_new (void);
/*! Loads a the given file into the document. This function can fail
@param document the document where the file will be loaded
@param filename the file to loa
@see spectre_document_status
*/
SPECTRE_PUBLIC
void spectre_document_load (SpectreDocument *document,
const char *filename);
/*! Returns the document status
@param document the document whose status will be returned
*/
SPECTRE_PUBLIC
SpectreStatus spectre_document_status (SpectreDocument *document);
/*! Frees the document
@param document the document that will be freed
*/
SPECTRE_PUBLIC
void spectre_document_free (SpectreDocument *document);
/*! Returns the number of pages of the document. This function can fail
@param document the document whose pages number will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
unsigned int spectre_document_get_n_pages (SpectreDocument *document);
/*! Returns the orientation of the document. This function can fail
@param document the document whose orientation will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
SpectreOrientation spectre_document_get_orientation (SpectreDocument *document);
/*! Returns the title of the document. It returns a null const char * if
the document specifies no title. This function can fail
@param document the document whose title will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
const char *spectre_document_get_title (SpectreDocument *document);
/*! Returns the creator of the document. It returns a null const char * if
the document specifies no creator. This function can fail
@param document the document whose creator will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
const char *spectre_document_get_creator (SpectreDocument *document);
/*! Returns the for of the document. It returns a null const char * if
the document specifies no for. This function can fail
@param document the document whose for will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
const char *spectre_document_get_for (SpectreDocument *document);
/*! Returns the creation date of the document. The date is copied verbatim from
the document, so no format can be assumed on it. It returns a null const char * if
the document specifies no creation date. This function can fail
@param document the document whose creation date will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
const char *spectre_document_get_creation_date (SpectreDocument *document);
/*! Returns the format of the document. This function can fail
@param document the document whose format will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
const char *spectre_document_get_format (SpectreDocument *document);
/*! Returns if the document is a Encapsulated PostScript file. This function can fail
@param document the document to query
@see spectre_document_status
*/
SPECTRE_PUBLIC
int spectre_document_is_eps (SpectreDocument *document);
/*! Returns the PostScript language level of the document. It returns 0 if no
language level was defined on the file. This function can fail
@param document the document whose language level will be returned
@see spectre_document_status
*/
SPECTRE_PUBLIC
unsigned int spectre_document_get_language_level (SpectreDocument *document);
/*! Returns a page of the document. This function can fail
@param document the document whose page will be returned
@param page_index the page index to get. First page has index 0.
@see spectre_document_status
*/
SPECTRE_PUBLIC
SpectrePage *spectre_document_get_page (SpectreDocument *document,
unsigned int page_index);
/*! Returns a page of the document referenced by label. This function can fail
@param document the document whose page will be returned
@param label the label of the page to get.
@see spectre_document_status
*/
SPECTRE_PUBLIC
SpectrePage *spectre_document_get_page_by_label (SpectreDocument *document,
const char *label);
/*! Convenient function for rendering documents with no pages, tipically eps.
When used with multi-page documents the first page will be rendered.
@param document the document to render
@rc the rendering context specifying how the document has to be rendered
@width the page width will be returned here, or NULL
@height the page height will be returned here, or NULL
@page_data a pointer that will point to the image data
@row_length the length of an image row will be returned here
@see spectre_document_render_full
*/
SPECTRE_PUBLIC
void spectre_document_render_full (SpectreDocument *document,
SpectreRenderContext *rc,
unsigned char **page_data,
int *row_length);
/*! Convenient function for rendering documents with no pages, tipically eps.
Document will be rendered with the default options, use spectre_document_render_full
if you want to change any of them.
When used with multi-page documents the first page will be rendered.
@param document the document to render
@width the page width will be returned here, or NULL
@height the page height will be returned here, or NULL
@page_data a pointer that will point to the image data
@row_length the length of an image row will be returned here
@see spectre_document_render_full
*/
SPECTRE_PUBLIC
void spectre_document_render (SpectreDocument *document,
unsigned char **page_data,
int *row_length);
/* Convenient function for getting the page size of documents with no pages, tipically eps.
When used with multi-page documents the size of the first page will be returned.
@param document the document whose page will be returned
@width the page width will be returned here, or NULL
@height the page height will be returned here, or NULL
*/
SPECTRE_PUBLIC
void spectre_document_get_page_size (SpectreDocument *document,
int *width,
int *height);
/*! Save document as filename. This function can fail
@param document the document that will be saved
@param filename the path where document will be saved
@see spectre_document_status
*/
SPECTRE_PUBLIC
void spectre_document_save (SpectreDocument *document,
const char *filename);
/* Save document as a pdf document. This function can fail
@param document the document that will be saved
@param filename the path where document will be saved as pdf
@see spectre_document_status
*/
SPECTRE_PUBLIC
void spectre_document_save_to_pdf (SpectreDocument *document,
const char *filename);
SPECTRE_END_DECLS
#endif /* SPECTRE_DOCUMENT_H */
libspectre-0.2.12/libspectre/spectre-version.h.in 0000644 0001750 0001750 00000002526 13360215166 016723 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_VERSION_H
#define SPECTRE_VERSION_H
#include
SPECTRE_BEGIN_DECLS
#define SPECTRE_MAJOR_VERSION @SPECTRE_MAJOR_VERSION@
#define SPECTRE_MINOR_VERSION @SPECTRE_MINOR_VERSION@
#define SPECTRE_MICRO_VERSION @SPECTRE_MICRO_VERSION@
#define SPECTRE_VERSION_STRING "@SPECTRE_VERSION@"
#define SPECTRE_VERSION ((@SPECTRE_MAJOR_VERSION@ << 16) | (@SPECTRE_MINOR_VERSION@ << 8) | (@SPECTRE_MICRO_VERSION@))
SPECTRE_END_DECLS
#endif /* SPECTRE_VERSION_H */
libspectre-0.2.12/libspectre/spectre.h 0000644 0001750 0001750 00000002226 14155760600 014631 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_H
#define SPECTRE_H
#include
#include
#include
#include
#include
#include
#endif /* SPECTRE_H */
libspectre-0.2.12/libspectre/spectre-page.c 0000644 0001750 0001750 00000010747 14155760600 015545 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include "spectre-page.h"
#include "spectre-device.h"
#include "spectre-private.h"
#include "spectre-utils.h"
struct SpectrePage
{
struct document *doc;
SpectreStatus status;
unsigned int index;
int width;
int height;
};
SpectrePage *
_spectre_page_new (unsigned int page_index,
struct document *doc)
{
SpectrePage *page;
page = calloc (1, sizeof (SpectrePage));
if (!page)
return NULL;
page->index = page_index;
page->width = -1;
page->height = -1;
page->doc = psdocreference (doc);
return page;
}
void
spectre_page_free (SpectrePage *page)
{
if (!page)
return;
if (page->doc) {
psdocdestroy (page->doc);
page->doc = NULL;
}
free (page);
}
SpectreStatus
spectre_page_status (SpectrePage *page)
{
_spectre_return_val_if_fail (page != NULL, SPECTRE_STATUS_INVALID_PAGE);
return page->status;
}
unsigned int
spectre_page_get_index (SpectrePage *page)
{
_spectre_return_val_if_fail (page != NULL, 0);
return page->index;
}
const char *
spectre_page_get_label (SpectrePage *page)
{
_spectre_return_val_if_fail (page != NULL, NULL);
return page->doc->numpages > 0 ? page->doc->pages[page->index].label : NULL;
}
SpectreOrientation
spectre_page_get_orientation (SpectrePage *page)
{
int page_orientation = NONE;
_spectre_return_val_if_fail (page != NULL, SPECTRE_ORIENTATION_PORTRAIT);
if (page->doc->numpages > 0) {
page_orientation = page->doc->pages[page->index].orientation != NONE ?
page->doc->pages[page->index].orientation :
page->doc->default_page_orientation;
}
if (page_orientation == NONE)
page_orientation = page->doc->orientation;
switch (page_orientation) {
default:
case PORTRAIT:
return SPECTRE_ORIENTATION_PORTRAIT;
case LANDSCAPE:
return SPECTRE_ORIENTATION_LANDSCAPE;
case SEASCAPE:
return SPECTRE_ORIENTATION_REVERSE_LANDSCAPE;
case UPSIDEDOWN:
return SPECTRE_ORIENTATION_REVERSE_PORTRAIT;
}
}
void
spectre_page_get_size (SpectrePage *page,
int *width,
int *height)
{
_spectre_return_if_fail (page != NULL);
if (page->width == -1 || page->height == -1) {
int urx, ury, llx, lly;
psgetpagebox (page->doc, page->index,
&urx, &ury, &llx, &lly);
page->width = urx - llx;
page->height = ury - lly;
}
if (width)
*width = page->width;
if (height)
*height = page->height;
}
void
spectre_page_render (SpectrePage *page,
SpectreRenderContext *rc,
unsigned char **page_data,
int *row_length)
{
SpectreDevice *device;
int width, height;
_spectre_return_if_fail (page != NULL);
_spectre_return_if_fail (rc != NULL);
spectre_page_get_size (page, &width, &height);
device = spectre_device_new (page->doc);
page->status = spectre_device_render (device, page->index, rc,
0, 0, width, height,
page_data, row_length);
spectre_device_free (device);
}
void
spectre_page_render_slice (SpectrePage *page,
SpectreRenderContext *rc,
int x,
int y,
int width,
int height,
unsigned char **page_data,
int *row_length)
{
SpectreDevice *device;
int page_height;
_spectre_return_if_fail (page != NULL);
_spectre_return_if_fail (rc != NULL);
spectre_page_get_size (page, NULL, &page_height);
device = spectre_device_new (page->doc);
page->status = spectre_device_render (device, page->index, rc,
x, page_height - (y + height),
width, height,
page_data, row_length);
spectre_device_free (device);
}
libspectre-0.2.12/libspectre/ps.h 0000644 0001750 0001750 00000013751 14155760473 013623 0000000 0000000 /*
* ps.h -- Include file for PostScript routines.
* Copyright (C) 1992 Timothy O. Theisen
* Copyright (C) 2004 Jose E. Marchesi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU gv; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA
*
* Author: Tim Theisen Systems Programmer
* Internet: tim@cs.wisc.edu Department of Computer Sciences
* UUCP: uwvax!tim University of Wisconsin-Madison
* Phone: (608)262-0438 1210 West Dayton Street
* FAX: (608)262-9777 Madison, WI 53706
*/
#ifndef PS_H
#define PS_H
#include
#include
SPECTRE_BEGIN_DECLS
#ifndef NeedFunctionPrototypes
#if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
#define NeedFunctionPrototypes 1
#else
#define NeedFunctionPrototypes 0
#endif /* __STDC__ */
#endif /* NeedFunctionPrototypes */
/* Constants used to index into the bounding box array. */
#define LLX 0
#define LLY 1
#define URX 2
#define URY 3
/* Constants used to store keywords that are scanned. */
/* NONE is not a keyword, it tells when a field was not set */
/*
enum {ATEND = -1, NONE = 0, PORTRAIT, LANDSCAPE, ASCEND, DESCEND, SPECIAL};
*/
#define ATEND (-1)
#define NONE 0
#define PORTRAIT 1
#define LANDSCAPE 2
#define SEASCAPE 3
#define UPSIDEDOWN 4
#define ASCEND 5
#define DESCEND 6
#define SPECIAL 7
#define AUTOMATIC 8
#define PSLINELENGTH 257 /* 255 characters + 1 newline + 1 NULL */
/* rjl: DOS binary EPS header */
#define PS_DWORD unsigned long/* must be 32 bits unsigned */
#define PS_WORD unsigned short/* must be 16 bits unsigned */
typedef struct tagDOSEPS {
unsigned char id[4];
PS_DWORD ps_begin;
PS_DWORD ps_length;
PS_DWORD mf_begin;
PS_DWORD mf_length;
PS_DWORD tiff_begin;
PS_DWORD tiff_length;
PS_WORD checksum;
} DOSEPS;
/*##############################################
media
##############################################*/
typedef struct documentmedia {
char *name;
int width;
int height;
} MediaStruct, *Media;
typedef const struct documentmedia *ConstMedia;
typedef struct document {
unsigned int ref_count;
#ifdef GV_CODE
int structured; /* toc will be useful */
int labels_useful; /* page labels are distinguishable, hence useful */
#endif
char *format; /* Postscript format */
char *filename; /* Document filename */
int epsf; /* Encapsulated PostScript flag. */
char *title; /* Title of document. */
char *date; /* Creation date. */
char *creator; /* Program that created the file */
char *fortext;
char *languagelevel;
int pageorder; /* ASCEND, DESCEND, SPECIAL */
long beginheader, endheader; /* offsets into file */
unsigned int lenheader;
long beginpreview, endpreview;
unsigned int lenpreview;
long begindefaults, enddefaults;
unsigned int lendefaults;
long beginprolog, endprolog;
unsigned int lenprolog;
long beginsetup, endsetup;
unsigned int lensetup;
long begintrailer, endtrailer;
unsigned int lentrailer;
int boundingbox[4];
int default_page_boundingbox[4];
int orientation; /* PORTRAIT, LANDSCAPE */
int default_page_orientation; /* PORTRAIT, LANDSCAPE */
unsigned int nummedia;
struct documentmedia *media;
ConstMedia default_page_media;
DOSEPS *doseps;
unsigned int numpages;
struct page *pages;
} *Document;
struct page {
char *label;
int boundingbox[4];
const struct documentmedia *media;
int orientation; /* PORTRAIT, LANDSCAPE */
long begin, end; /* offsets into file */
unsigned int len;
};
/* scans a PostScript file and return a pointer to the document
structure. Returns NULL if file does not Conform to commenting
conventions . */
#define SCANSTYLE_NORMAL 0
#define SCANSTYLE_IGNORE_EOF (1<<0)
#define SCANSTYLE_IGNORE_DSC (1<<1)
Document psscan (
#if NeedFunctionPrototypes
FILE *,
const char *,
int /* scanstyle */
#endif
);
void psdocdestroy (
#if NeedFunctionPrototypes
struct document *
#endif
);
Document psdocreference (
#if NeedFunctionPrototypes
struct document *
#endif
);
extern void pscopydoc (
#if NeedFunctionPrototypes
FILE *,
char *,
Document,
char *
#endif
);
int psgetpagebbox (
#if NeedFunctionPrototypes
const struct document *,
int,
int *,
int *,
int *,
int *
#endif
);
void psgetpagebox (
#if NeedFunctionPrototypes
const struct document *,
int,
int *,
int *,
int *,
int *
#endif
);
void pscopy (
#if NeedFunctionPrototypes
FILE *,
FILE *,
Document,
long,
long
#endif
);
void pscopyheaders (
#if NeedFunctionPrototypes
FILE *,
FILE *,
Document
#endif
);
void pscopypage (
#if NeedFunctionPrototypes
FILE *,
FILE *,
Document,
unsigned int,
unsigned int
#endif
);
void pscopytrailer (
#if NeedFunctionPrototypes
FILE *,
FILE *,
Document,
unsigned int
#endif
);
SPECTRE_END_DECLS
#endif /* PS_H */
libspectre-0.2.12/libspectre/spectre-render-context.h 0000644 0001750 0001750 00000014621 14155760600 017572 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2; or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful;
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not; write to the Free Software
* Foundation; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_RENDER_CONTEXT_H
#define SPECTRE_RENDER_CONTEXT_H
#include
SPECTRE_BEGIN_DECLS
/*! This object defines how a page will be rendered */
typedef struct SpectreRenderContext SpectreRenderContext;
/*! Creates a rendering context */
SPECTRE_PUBLIC
SpectreRenderContext *spectre_render_context_new (void);
/*! Frees a rendering context
@param rc The rendering context to free
*/
SPECTRE_PUBLIC
void spectre_render_context_free (SpectreRenderContext *rc);
/*! Sets the scale. The default is 1
@param rc The rendering context to modify
@param x_scale The scale factor for the X dimension to use when rendering. 2 is twice as big
@param y_scale The scale factor for the Y dimension to use when rendering. 2 is twice as big
*/
SPECTRE_PUBLIC
void spectre_render_context_set_scale (SpectreRenderContext *rc,
double x_scale,
double y_scale);
/*! Gets the scale
@param rc The rendering context to query
@param x_scale The scale factor for the X dimension will be stored here, or NULL
@param y_scale The scale factor for the Y dimension will be stored here, or NULL
*/
SPECTRE_PUBLIC
void spectre_render_context_get_scale (SpectreRenderContext *rc,
double *x_scale,
double *y_scale);
/*! Sets the rotation. The default is 0
@param rc The rendering context to modify
@param rotation The rotation to use when rendering. Usually 0, 90, 180 or 270
*/
SPECTRE_PUBLIC
void spectre_render_context_set_rotation (SpectreRenderContext *rc,
unsigned int rotation);
/*! Gets the rotation
@param rc The rendering context to query
*/
SPECTRE_PUBLIC
unsigned int spectre_render_context_get_rotation (SpectreRenderContext *rc);
/*! Sets the resolution. The default is 72 for both directions
@param rc The rendering context to modify
@param x_dpi the horizontal resolution to set
@param y_dpi the vertical resolution to set
*/
SPECTRE_PUBLIC
void spectre_render_context_set_resolution (SpectreRenderContext *rc,
double x_dpi,
double y_dpi);
/*! Gets the resolution
@param rc The rendering context to query
@param x_dpi the horizontal resolution will be stored here, or NULL
@param y_dpi the vertical resolution will be stored here, or NULL
*/
SPECTRE_PUBLIC
void spectre_render_context_get_resolution (SpectreRenderContext *rc,
double *x_dpi,
double *y_dpi);
/*! Sets the page size in pixels. Rotation shouldn't be considered,
the page size will be automatically adjusted when rendering according
to the rotation selected. Note that the page size doesn't affect the
scale. If no page size is given the page bounding box will be used,
or the rectangle given when using spectre_page_render_slice
@param rc The rendering context to modify
@param width the width of the page
@param height the height of the page
*/
SPECTRE_PUBLIC
void spectre_render_context_set_page_size (SpectreRenderContext *rc,
int width,
int height);
/*! Gets the page size in pixels
@param rc The rendering context to query
@param width the width of the page will be stored here, or NULL
@param height the height of the page will be stored here, or NULL
*/
SPECTRE_PUBLIC
void spectre_render_context_get_page_size (SpectreRenderContext *rc,
int *width,
int *height);
/*! Sets whether to use the platform fonts when rendering or not. The default is TRUE
@param rc The rendering context to modify
@param use_platform_fonts should platform fonts be used when rendering?
*/
SPECTRE_PUBLIC
void spectre_render_context_set_use_platform_fonts (SpectreRenderContext *rc,
int use_platform_fonts);
/*! Gets whether to use the platform fonts when rendering or not
@param rc The rendering context to query
*/
SPECTRE_PUBLIC
int spectre_render_context_get_use_platform_fonts (SpectreRenderContext *rc);
/*! Sets the antialias options for graphics and texts. The default is 4 for graphics and 2 for text
@param rc The rendering context to modify
@param graphics_bits The number of antialias bits to use for graphics.
Typically 4 for antialias and 1 for no antialias
@param text_bits The number of antialias bits to use for text.
Typically 2 for antialias and 1 for no antialias
*/
SPECTRE_PUBLIC
void spectre_render_context_set_antialias_bits (SpectreRenderContext *rc,
int graphics_bits,
int text_bits);
/*! Gets the antialias options for graphics and texts
@param rc The rendering context to query
@param graphics_bits The number of antialias bits to use for graphics will be stored here
@param text_bits The number of antialias bits to use for text will be stored here
*/
SPECTRE_PUBLIC
void spectre_render_context_get_antialias_bits (SpectreRenderContext *rc,
int *graphics_bits,
int *text_bits);
SPECTRE_END_DECLS
#endif /* SPECTRE_PAGE_H */
libspectre-0.2.12/libspectre/spectre-gs.h 0000644 0001750 0001750 00000004613 14201706315 015235 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_GS_H
#define SPECTRE_GS_H
#include
#include "ps.h"
#include
SPECTRE_BEGIN_DECLS
typedef enum {
CLEANUP_DELETE_INSTANCE = 1 << 0,
CLEANUP_EXIT = 1 << 1
} SpectreGSCleanupFlag;
typedef struct SpectreGS SpectreGS;
SpectreGS *spectre_gs_new (void);
int spectre_gs_create_instance (SpectreGS *gs,
void *caller_handle);
int spectre_gs_register_callout (SpectreGS *gs,
gs_callout callout, void *caller_handle);
int spectre_gs_run (SpectreGS *gs,
int n_args,
char **args);
int spectre_gs_process (SpectreGS *gs,
const char *filename,
int x,
int y,
long begin,
long end);
int spectre_gs_send_string (SpectreGS *gs,
const char *str);
int spectre_gs_send_page (SpectreGS *gs,
struct document *doc,
unsigned int page_index,
int x,
int y);
void spectre_gs_cleanup (SpectreGS *gs,
SpectreGSCleanupFlag flag);
void spectre_gs_free (SpectreGS *gs);
long spectre_gs_get_version (void);
SPECTRE_END_DECLS
#endif /* SPECTRE_GS_H */
libspectre-0.2.12/libspectre/spectre-exporter.c 0000644 0001750 0001750 00000005156 14155760600 016477 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include "spectre-exporter.h"
#include "spectre-private.h"
#include "spectre-utils.h"
SpectreExporter *
spectre_exporter_new (SpectreDocument *document,
SpectreExporterFormat format)
{
struct document *doc;
_spectre_return_val_if_fail (document != NULL, NULL);
doc = _spectre_document_get_doc (document);
switch (format) {
case SPECTRE_EXPORTER_FORMAT_PS:
return _spectre_exporter_ps_new (doc);
case SPECTRE_EXPORTER_FORMAT_PDF:
return _spectre_exporter_pdf_new (doc);
}
return NULL;
}
void
spectre_exporter_free (SpectreExporter *exporter)
{
if (!exporter)
return;
if (exporter->doc) {
psdocdestroy (exporter->doc);
exporter->doc = NULL;
}
if (exporter->gs) {
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
}
if (exporter->from) {
fclose (exporter->from);
exporter->from = NULL;
}
if (exporter->to) {
fclose (exporter->to);
exporter->to = NULL;
}
free (exporter);
}
SpectreStatus
spectre_exporter_begin (SpectreExporter *exporter,
const char *filename)
{
_spectre_return_val_if_fail (exporter != NULL, SPECTRE_STATUS_EXPORTER_ERROR);
_spectre_return_val_if_fail (filename != NULL, SPECTRE_STATUS_EXPORTER_ERROR);
if (exporter->begin)
return exporter->begin (exporter, filename);
return SPECTRE_STATUS_SUCCESS;
}
SpectreStatus
spectre_exporter_do_page (SpectreExporter *exporter,
unsigned int page_index)
{
_spectre_return_val_if_fail (exporter != NULL, SPECTRE_STATUS_EXPORTER_ERROR);
return exporter->do_page (exporter, page_index);
}
SpectreStatus
spectre_exporter_end (SpectreExporter *exporter)
{
_spectre_return_val_if_fail (exporter != NULL, SPECTRE_STATUS_EXPORTER_ERROR);
if (exporter->end)
return exporter->end (exporter);
return SPECTRE_STATUS_SUCCESS;
}
libspectre-0.2.12/libspectre/spectre-private.h 0000644 0001750 0001750 00000005047 14155760600 016305 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_PRIVATE_H
#define SPECTRE_PRIVATE_H
#include "spectre-macros.h"
#include "spectre-status.h"
#include "spectre-document.h"
#include "spectre-page.h"
#include "spectre-exporter.h"
#include "spectre-gs.h"
#include "ps.h"
SPECTRE_BEGIN_DECLS
struct SpectreRenderContext {
double x_scale;
double y_scale;
SpectreOrientation orientation;
double x_dpi;
double y_dpi;
int width;
int height;
int text_alpha_bits;
int graphic_alpha_bits;
int use_platform_fonts;
};
struct SpectreExporter {
struct document *doc;
/* PDF specific */
SpectreGS *gs;
/* PS specific */
FILE *from;
FILE *to;
int n_pages;
SpectreStatus (* begin) (SpectreExporter *exporter,
const char *filename);
SpectreStatus (* do_page) (SpectreExporter *exporter,
unsigned int page_index);
SpectreStatus (* end) (SpectreExporter *exporter);
};
SpectrePage *_spectre_page_new (unsigned int page_index,
struct document *doc);
struct document *_spectre_document_get_doc (SpectreDocument *document);
SpectreExporter *_spectre_exporter_ps_new (struct document *doc);
SpectreExporter *_spectre_exporter_pdf_new (struct document *doc);
/*! Loads the given open file into the document. This function can fail
@param document the document where the file will be loaded
@param file the file to load
@see spectre_document_status
*/
SPECTRE_PUBLIC
void spectre_document_load_from_stream (SpectreDocument *document,
FILE *file);
SPECTRE_END_DECLS
#endif /* SPECTRE_PRIVATE_H */
libspectre-0.2.12/libspectre/spectre-status.h 0000644 0001750 0001750 00000004735 14155760600 016161 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_STATUS_H
#define SPECTRE_STATUS_H
#include
SPECTRE_BEGIN_DECLS
/*! Defines the error status of a Spectre object */
typedef enum _SpectreStatus {
SPECTRE_STATUS_SUCCESS /*! No error */ = 0,
SPECTRE_STATUS_NO_MEMORY /*! There has been a problem
allocating memory */,
SPECTRE_STATUS_LOAD_ERROR /*! There has been a problem
loading the postcript file */,
SPECTRE_STATUS_DOCUMENT_NOT_LOADED /*! A function that needs the
document to be loaded has been
called and the document has not
been loaded or there was an
error when loading it */,
SPECTRE_STATUS_INVALID_PAGE /*! The request page number
is not in the document page
range */,
SPECTRE_STATUS_RENDER_ERROR /*! There has been a problem
rendering the page */,
SPECTRE_STATUS_EXPORTER_ERROR /*! There has been a problem
exporting the document */,
SPECTRE_STATUS_SAVE_ERROR /*! There has been a problem
saving the document */
} SpectreStatus;
/*! Gets a textual description of the given status
@param status the status whose textual description will be returned
*/
SPECTRE_PUBLIC
const char *spectre_status_to_string (SpectreStatus status);
SPECTRE_END_DECLS
#endif /* SPECTRE_STATUS_H */
libspectre-0.2.12/libspectre/spectre-exporter-ps.c 0000644 0001750 0001750 00000004547 14155760600 017122 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include "spectre-private.h"
static SpectreStatus
spectre_exporter_ps_begin (SpectreExporter *exporter,
const char *filename)
{
exporter->from = fopen (exporter->doc->filename, "rb");
if (!exporter->from)
return SPECTRE_STATUS_EXPORTER_ERROR;
exporter->to = fopen (filename, "wb");
if (!exporter->to) {
fclose (exporter->from);
exporter->from = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
pscopyheaders (exporter->from, exporter->to, exporter->doc);
return SPECTRE_STATUS_SUCCESS;
}
static SpectreStatus
spectre_exporter_ps_do_page (SpectreExporter *exporter,
unsigned int page_index)
{
if (exporter->doc->numpages <= 0)
return SPECTRE_STATUS_SUCCESS;
pscopypage (exporter->from, exporter->to, exporter->doc,
page_index, exporter->n_pages++);
return SPECTRE_STATUS_SUCCESS;
}
static SpectreStatus
spectre_exporter_ps_end (SpectreExporter *exporter)
{
pscopytrailer (exporter->from, exporter->to, exporter->doc,
exporter->n_pages);
fclose (exporter->from);
exporter->from = NULL;
fclose (exporter->to);
exporter->to = NULL;
return SPECTRE_STATUS_SUCCESS;
}
SpectreExporter *
_spectre_exporter_ps_new (struct document *doc)
{
SpectreExporter *exporter;
exporter = calloc (1, sizeof (SpectreExporter));
if (!exporter)
return NULL;
exporter->doc = psdocreference (doc);
exporter->begin = spectre_exporter_ps_begin;
exporter->do_page = spectre_exporter_ps_do_page;
exporter->end = spectre_exporter_ps_end;
return exporter;
}
libspectre-0.2.12/libspectre/Makefile.am 0000644 0001750 0001750 00000002042 13362566151 015047 0000000 0000000 EXTRA_DIST=spectre-version.h.in
lib_LTLIBRARIES = libspectre.la
libspectreincludedir = $(includedir)/libspectre
libspectreinclude_HEADERS = \
spectre.h \
spectre-macros.h \
spectre-status.h \
spectre-document.h \
spectre-render-context.h \
spectre-page.h \
spectre-exporter.h \
spectre-version.h
gv_sources = \
ps.h \
ps.c
libspectre_la_SOURCES = \
spectre.h \
spectre-private.h \
spectre-macros.h \
spectre-status.h \
spectre-status.c \
spectre-document.h \
spectre-document.c \
spectre-gs.h \
spectre-gs.c \
spectre-render-context.h \
spectre-render-context.c \
spectre-device.h \
spectre-device.c \
spectre-page.h \
spectre-page.c \
spectre-exporter.h \
spectre-exporter.c \
spectre-exporter-pdf.c \
spectre-exporter-ps.c \
spectre-utils.h \
spectre-utils.c \
$(gv_sources)
libspectre_la_CPPFLAGS = \
$(SPECTRE_CFLAGS)
libspectre_la_CFLAGS = \
$(VISIBILITY_CFLAGS)
libspectre_la_LIBADD = $(LIB_GS)
libspectre_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined
libspectre-0.2.12/libspectre/spectre-version.h 0000644 0001750 0001750 00000002311 14356526210 016307 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_VERSION_H
#define SPECTRE_VERSION_H
#include
SPECTRE_BEGIN_DECLS
#define SPECTRE_MAJOR_VERSION 0
#define SPECTRE_MINOR_VERSION 2
#define SPECTRE_MICRO_VERSION 12
#define SPECTRE_VERSION_STRING "0.2.12"
#define SPECTRE_VERSION ((0 << 16) | (2 << 8) | (12))
SPECTRE_END_DECLS
#endif /* SPECTRE_VERSION_H */
libspectre-0.2.12/libspectre/spectre-document.c 0000644 0001750 0001750 00000027152 14275374755 016464 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
/* For stat */
#include
#include
#include
#include "spectre-document.h"
#include "spectre-private.h"
#include "spectre-exporter.h"
#include "spectre-utils.h"
struct SpectreDocument
{
struct document *doc;
SpectreStatus status;
int structured;
};
SpectreDocument *
spectre_document_new (void)
{
SpectreDocument *doc;
doc = calloc (1, sizeof (SpectreDocument));
return doc;
}
static void
document_load (SpectreDocument *document,
const char *filename,
FILE *file)
{
_spectre_return_if_fail (document != NULL);
if (document->doc && strcmp (filename, document->doc->filename) == 0) {
document->status = SPECTRE_STATUS_SUCCESS;
return;
}
if (document->doc) {
psdocdestroy (document->doc);
document->doc = NULL;
}
if (!file) {
document->status = SPECTRE_STATUS_LOAD_ERROR;
return;
}
document->doc = psscan (file, filename, SCANSTYLE_NORMAL);
if (!document->doc) {
document->status = SPECTRE_STATUS_LOAD_ERROR;
return;
}
if (document->doc->numpages == 0 && document->doc->lenprolog == 0) {
document->status = SPECTRE_STATUS_LOAD_ERROR;
psdocdestroy (document->doc);
document->doc = NULL;
return;
} else if (document->doc->numpages == 0 && !document->doc->format) {
/* Make sure it's a valid PS document */
unsigned char *data = NULL;
int row_length;
spectre_document_render (document, &data, &row_length);
free (data);
if (spectre_document_status (document)) {
document->status = SPECTRE_STATUS_LOAD_ERROR;
psdocdestroy (document->doc);
document->doc = NULL;
return;
}
}
document->structured = ((!document->doc->epsf && document->doc->numpages > 0) ||
(document->doc->epsf && document->doc->numpages > 1));
if (document->status != SPECTRE_STATUS_SUCCESS)
document->status = SPECTRE_STATUS_SUCCESS;
}
void
spectre_document_load (SpectreDocument *document,
const char *filename)
{
FILE *file;
_spectre_return_if_fail (filename != NULL);
file = fopen (filename, "rb");
if (!file) {
document->status = SPECTRE_STATUS_LOAD_ERROR;
return;
}
document_load (document, filename, file);
fclose (file);
}
void
spectre_document_load_from_stream (SpectreDocument *document,
FILE *file)
{
document_load (document, "stream", file);
}
void
spectre_document_free (SpectreDocument *document)
{
if (!document)
return;
if (document->doc) {
psdocdestroy (document->doc);
document->doc = NULL;
}
free (document);
}
SpectreStatus
spectre_document_status (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, SPECTRE_STATUS_DOCUMENT_NOT_LOADED);
return document->status;
}
unsigned int
spectre_document_get_n_pages (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, 0);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return 0;
}
return document->structured ? document->doc->numpages : 1;
}
SpectreOrientation
spectre_document_get_orientation (SpectreDocument *document)
{
int doc_orientation;
_spectre_return_val_if_fail (document != NULL, SPECTRE_ORIENTATION_PORTRAIT);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return SPECTRE_ORIENTATION_PORTRAIT;
}
doc_orientation = document->doc->orientation != NONE ?
document->doc->orientation : document->doc->default_page_orientation;
switch (doc_orientation) {
default:
case PORTRAIT:
return SPECTRE_ORIENTATION_PORTRAIT;
case LANDSCAPE:
return SPECTRE_ORIENTATION_LANDSCAPE;
case SEASCAPE:
return SPECTRE_ORIENTATION_REVERSE_LANDSCAPE;
case UPSIDEDOWN:
return SPECTRE_ORIENTATION_REVERSE_PORTRAIT;
}
}
const char *
spectre_document_get_title (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
return document->doc->title;
}
const char *
spectre_document_get_creator (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
return document->doc->creator;
}
const char *
spectre_document_get_for (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
return document->doc->fortext;
}
const char *
spectre_document_get_creation_date (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
return document->doc->date;
}
const char *
spectre_document_get_format (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
return document->doc->format;
}
int
spectre_document_is_eps (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, FALSE);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return FALSE;
}
return document->doc->epsf;
}
unsigned int
spectre_document_get_language_level (SpectreDocument *document)
{
_spectre_return_val_if_fail (document != NULL, 0);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return 0;
}
return document->doc->languagelevel ? atoi (document->doc->languagelevel) : 0;
}
SpectrePage *
spectre_document_get_page (SpectreDocument *document,
unsigned int page_index)
{
SpectrePage *page;
unsigned int index;
_spectre_return_val_if_fail (document != NULL, NULL);
index = (document->doc->pageorder == DESCEND) ?
(document->doc->numpages - 1) - page_index :
page_index;
if (index >= spectre_document_get_n_pages (document)) {
document->status = SPECTRE_STATUS_INVALID_PAGE;
return NULL;
}
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
page = _spectre_page_new (index, document->doc);
if (!page) {
document->status = SPECTRE_STATUS_NO_MEMORY;
return NULL;
}
if (document->status != SPECTRE_STATUS_SUCCESS)
document->status = SPECTRE_STATUS_SUCCESS;
return page;
}
SpectrePage *
spectre_document_get_page_by_label (SpectreDocument *document,
const char *label)
{
unsigned int i;
int page_index = -1;
_spectre_return_val_if_fail (document != NULL, NULL);
if (!label) {
document->status = SPECTRE_STATUS_INVALID_PAGE;
return NULL;
}
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return NULL;
}
for (i = 0; i < document->doc->numpages; i++) {
if (strcmp (document->doc->pages[i].label, label) == 0) {
page_index = i;
break;
}
}
if (page_index == -1) {
document->status = SPECTRE_STATUS_INVALID_PAGE;
return NULL;
}
return spectre_document_get_page (document, page_index);
}
void
spectre_document_render_full (SpectreDocument *document,
SpectreRenderContext *rc,
unsigned char **page_data,
int *row_length)
{
SpectrePage *page;
_spectre_return_if_fail (document != NULL);
_spectre_return_if_fail (rc != NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return;
}
page = spectre_document_get_page (document, 0);
if (!page || document->status != SPECTRE_STATUS_SUCCESS) {
spectre_page_free (page);
return;
}
spectre_page_render (page, rc, page_data, row_length);
document->status = spectre_page_status (page);
spectre_page_free (page);
}
void
spectre_document_render (SpectreDocument *document,
unsigned char **page_data,
int *row_length)
{
SpectreRenderContext *rc;
_spectre_return_if_fail (document != NULL);
rc = spectre_render_context_new ();
spectre_document_render_full (document, rc, page_data, row_length);
spectre_render_context_free (rc);
}
void
spectre_document_get_page_size (SpectreDocument *document,
int *width,
int *height)
{
SpectrePage *page;
int w, h;
_spectre_return_if_fail (document != NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return;
}
page = spectre_document_get_page (document, 0);
if (!page || document->status != SPECTRE_STATUS_SUCCESS) {
spectre_page_free (page);
return;
}
spectre_page_get_size (page, &w, &h);
if (width)
*width = w;
if (height)
*height = h;
spectre_page_free (page);
}
void
spectre_document_save (SpectreDocument *document,
const char *filename)
{
struct stat stat_buf;
FILE *from;
FILE *to;
_spectre_return_if_fail (document != NULL);
_spectre_return_if_fail (filename != NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return;
}
if (stat (document->doc->filename, &stat_buf) != 0) {
document->status = SPECTRE_STATUS_SAVE_ERROR;
return;
}
from = fopen (document->doc->filename, "rb");
if (!from) {
document->status = SPECTRE_STATUS_SAVE_ERROR;
return;
}
to = fopen (filename, "wb");
if (!to) {
document->status = SPECTRE_STATUS_SAVE_ERROR;
fclose (from);
return;
}
pscopy (from, to, document->doc, 0, stat_buf.st_size - 1);
fclose (from);
fclose (to);
document->status = SPECTRE_STATUS_SUCCESS;
}
void
spectre_document_save_to_pdf (SpectreDocument *document,
const char *filename)
{
SpectreExporter *exporter;
SpectreStatus status;
unsigned int i;
_spectre_return_if_fail (document != NULL);
_spectre_return_if_fail (filename != NULL);
if (!document->doc) {
document->status = SPECTRE_STATUS_DOCUMENT_NOT_LOADED;
return;
}
exporter = spectre_exporter_new (document, SPECTRE_EXPORTER_FORMAT_PDF);
if (!exporter) {
document->status = SPECTRE_STATUS_NO_MEMORY;
return;
}
status = spectre_exporter_begin (exporter, filename);
if (status) {
document->status = status == SPECTRE_STATUS_NO_MEMORY ?
SPECTRE_STATUS_NO_MEMORY : SPECTRE_STATUS_SAVE_ERROR;
spectre_exporter_free (exporter);
return;
}
for (i = 0; i < spectre_document_get_n_pages (document); i++) {
status = spectre_exporter_do_page (exporter, i);
if (status)
break;
}
if (status) {
document->status = status == SPECTRE_STATUS_NO_MEMORY ?
SPECTRE_STATUS_NO_MEMORY : SPECTRE_STATUS_SAVE_ERROR;
spectre_exporter_free (exporter);
return;
}
status = spectre_exporter_end (exporter);
spectre_exporter_free (exporter);
if (status) {
document->status = status == SPECTRE_STATUS_NO_MEMORY ?
SPECTRE_STATUS_NO_MEMORY : SPECTRE_STATUS_SAVE_ERROR;
} else {
document->status = SPECTRE_STATUS_SUCCESS;
}
}
struct document *
_spectre_document_get_doc (SpectreDocument *document)
{
return document->doc;
}
libspectre-0.2.12/libspectre/spectre-gs.c 0000644 0001750 0001750 00000015625 14201706315 015235 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include "spectre-gs.h"
#include "spectre-utils.h"
/* ghostscript stuff */
#include
#define BUFFER_SIZE 32768
struct SpectreGS {
void *ghostscript_instance;
};
static int
critic_error_code (int code)
{
if (code >= 0)
return FALSE;
if (code <= -100) {
switch (code) {
case gs_error_Fatal:
fprintf (stderr, "(libspectre) ghostscript reports: fatal internal error %d", code);
return TRUE;
break;
case gs_error_ExecStackUnderflow:
fprintf (stderr, "(libspectre) ghostscript reports: stack overflow %d", code);
return TRUE;
break;
/* no error or not important */
default:
return FALSE;
}
} else {
const char *errors[] = { "", ERROR_NAMES };
int x = (-1) * code;
if (x < (int) (sizeof (errors) / sizeof (const char*))) {
fprintf (stderr, "(libspectre) ghostscript reports: %s %d\n", errors[x], code);
}
return TRUE;
}
}
static int
spectre_gs_stdout (void *handler, const char *out, int len)
{
return len;
}
int
spectre_gs_process (SpectreGS *gs,
const char *filename,
int x,
int y,
long begin,
long end)
{
FILE *fd;
int error;
static char buf[BUFFER_SIZE];
unsigned int read;
int exit_code;
size_t left = end - begin;
void *ghostscript_instance = gs->ghostscript_instance;
fd = fopen (filename, "rb");
if (!fd) {
return FALSE;
}
fseek (fd, begin, SEEK_SET);
error = gsapi_run_string_begin (ghostscript_instance, 0, &exit_code);
if (critic_error_code (error)) {
fclose (fd);
return FALSE;
}
if (x != 0 || y != 0) {
char *set;
set = _spectre_strdup_printf ("%d %d translate\n", -x, -y);
error = gsapi_run_string_continue (ghostscript_instance, set, strlen (set),
0, &exit_code);
error = error == gs_error_NeedInput ? 0 : error;
free (set);
if (error != gs_error_NeedInput && critic_error_code (error)) {
fclose (fd);
return FALSE;
}
}
while (left > 0 && !critic_error_code (error)) {
size_t to_read = BUFFER_SIZE;
if (left < to_read)
to_read = left;
read = fread (buf, sizeof (char), to_read, fd);
error = gsapi_run_string_continue (ghostscript_instance,
buf, read, 0, &exit_code);
error = error == gs_error_NeedInput ? 0 : error;
left -= read;
}
fclose (fd);
if (critic_error_code (error))
return FALSE;
error = gsapi_run_string_end (ghostscript_instance, 0, &exit_code);
if (critic_error_code (error))
return FALSE;
return TRUE;
}
SpectreGS *
spectre_gs_new (void)
{
SpectreGS *gs;
gs = calloc (1, sizeof (SpectreGS));
return gs;
}
int
spectre_gs_create_instance (SpectreGS *gs,
void *caller_handle)
{
int error;
error = gsapi_new_instance (&gs->ghostscript_instance, caller_handle);
if (!critic_error_code (error)) {
gsapi_set_stdio (gs->ghostscript_instance,
NULL,
spectre_gs_stdout,
NULL);
return TRUE;
}
return FALSE;
}
int
spectre_gs_register_callout (SpectreGS *gs,
gs_callout callout,void *caller_handle)
{
int error;
error = gsapi_register_callout(gs->ghostscript_instance, callout, caller_handle);
return !critic_error_code (error);
}
int
spectre_gs_run (SpectreGS *gs,
int n_args,
char **args)
{
int error;
error = gsapi_init_with_args (gs->ghostscript_instance, n_args, args);
return !critic_error_code (error);
}
int
spectre_gs_send_string (SpectreGS *gs,
const char *str)
{
int error;
int exit_code;
error = gsapi_run_string_with_length (gs->ghostscript_instance,
str, strlen (str), 0, &exit_code);
return !critic_error_code (error);
}
int
spectre_gs_send_page (SpectreGS *gs,
struct document *doc,
unsigned int page_index,
int x,
int y)
{
int xoffset = 0, yoffset = 0;
int page_urx, page_ury, page_llx, page_lly;
int bbox_urx, bbox_ury, bbox_llx, bbox_lly;
int doc_xoffset = 0, doc_yoffset = 0;
int page_xoffset = 0, page_yoffset = 0;
if (psgetpagebbox (doc, page_index, &bbox_urx, &bbox_ury, &bbox_llx, &bbox_lly)) {
psgetpagebox (doc, page_index,
&page_urx, &page_ury,
&page_llx, &page_lly);
if ((bbox_urx - bbox_llx) == (page_urx - page_llx) ||
(bbox_ury - bbox_lly) == (page_ury - page_lly)) {
/* BoundingBox */
xoffset = page_llx;
yoffset = page_lly;
}
}
if (doc->numpages > 0) {
page_xoffset = xoffset + x;
page_yoffset = yoffset + y;
} else {
doc_xoffset = xoffset + x;
doc_yoffset = yoffset + y;
}
if (!spectre_gs_process (gs,
doc->filename,
doc_xoffset,
doc_yoffset,
doc->beginprolog,
doc->endprolog))
return FALSE;
if (!spectre_gs_process (gs,
doc->filename,
0, 0,
doc->beginsetup,
doc->endsetup))
return FALSE;
if (doc->numpages > 0) {
if (doc->pageorder == SPECIAL) {
unsigned int i;
/* Pages cannot be re-ordered */
for (i = 0; i < page_index; i++) {
if (!spectre_gs_process (gs,
doc->filename,
page_xoffset,
page_yoffset,
doc->pages[i].begin,
doc->pages[i].end))
return FALSE;
}
}
if (!spectre_gs_process (gs,
doc->filename,
page_xoffset,
page_yoffset,
doc->pages[page_index].begin,
doc->pages[page_index].end))
return FALSE;
}
if (!spectre_gs_process (gs,
doc->filename,
0, 0,
doc->begintrailer,
doc->endtrailer))
return FALSE;
return TRUE;
}
void
spectre_gs_cleanup (SpectreGS *gs,
SpectreGSCleanupFlag flag)
{
if (gs->ghostscript_instance == NULL)
return;
if (flag & CLEANUP_EXIT)
gsapi_exit (gs->ghostscript_instance);
if (flag & CLEANUP_DELETE_INSTANCE)
gsapi_delete_instance (gs->ghostscript_instance);
gs->ghostscript_instance = NULL;
}
void
spectre_gs_free (SpectreGS *gs)
{
if (!gs)
return;
spectre_gs_cleanup (gs,
CLEANUP_DELETE_INSTANCE |
CLEANUP_EXIT);
free (gs);
}
long
spectre_gs_get_version (void)
{
gsapi_revision_t gsrev;
if (gsapi_revision (&gsrev, sizeof(gsrev)) != 0)
return 0;
return gsrev.revision;
}
libspectre-0.2.12/libspectre/spectre-utils.c 0000644 0001750 0001750 00000020016 14155760600 015757 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include "spectre-utils.h"
#ifdef HAVE_SYS_TYPES_H
#include
#endif
#ifdef HAVE_UNISTD_H
#include
#endif
#ifdef WIN32
#include
#endif
static unsigned long
_spectre_get_pid (void)
{
#if defined(HAVE_SYS_TYPES_H) && defined(HAVE_UNISTD_H)
return getpid ();
#elif defined(WIN32)
return GetCurrentProcessId ();
#endif
}
static int warn_initted = FALSE;
static int fatal_warnings = FALSE;
static int fatal_warnings_on_check_failed = FALSE;
static void
init_warnings (void)
{
const char *s;
if (warn_initted)
return;
warn_initted = TRUE;
s = getenv ("SPECTRE_FATAL_WARNINGS");
if (!s || !(*s))
return;
if (*s == '0') {
fatal_warnings = FALSE;
fatal_warnings_on_check_failed = FALSE;
} else if (*s == '1') {
fatal_warnings = TRUE;
fatal_warnings_on_check_failed = TRUE;
} else {
fprintf (stderr,
"SPECTRE_FATAL_WARNINGS should be set to 0 or 1 if set, not '%s'",
s);
}
}
/**
* Prints a warning message to stderr. Can optionally be made to exit
* fatally by setting SPECTRE_FATAL_WARNINGS, but this is rarely
* used. This function should be considered pretty much equivalent to
* fprintf(stderr). _spectre_warn_check_failed() on the other hand is
* suitable for use when a programming mistake has been made.
*/
void
_spectre_warn (const char *format,
...)
{
va_list args;
if (!warn_initted)
init_warnings ();
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
if (fatal_warnings) {
fflush (stderr);
abort ();
}
}
/**
* Prints a "critical" warning to stderr when an assertion fails;
* differs from _spectre_warn primarily in that it prefixes the pid and
* defaults to fatal. This should be used only when a programming
* error has been detected. (NOT for unavoidable errors that an app
* might handle. Calling this means "there is a bug"
*/
void
_spectre_warn_check_failed (const char *format,
...)
{
va_list args;
if (!warn_initted)
init_warnings ();
fprintf (stderr, "process %lu: ", _spectre_get_pid ());
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
if (fatal_warnings_on_check_failed) {
fflush (stderr);
abort ();
}
}
#ifndef SPECTRE_DISABLE_ASSERT
void
_spectre_real_assert (int condition,
const char *condition_text,
const char *file,
int line,
const char *func)
{
if (_SPECTRE_UNLIKELY (!condition)) {
_spectre_warn ("%lu: assertion failed \"%s\" file \"%s\" line %d function %s\n",
_spectre_get_pid (), condition_text, file, line, func);
abort ();
}
}
#endif /* SPECTRE_DISABLE_ASSERT */
static char *
spectre_strdup_vprintf (const char *format,
va_list args)
{
char *string = NULL;
int len;
#if defined(HAVE_VASPRINTF)
len = vasprintf (&string, format, args);
if (len < 0)
string = NULL;
#else /* !HAVE_VASPRINTF */
va_list args_copy;
int n;
char c;
SPECTRE_VA_COPY (args_copy, args);
#if HAVE__VSCPRINTF
n = _vscprintf (format, args);
#else
n = vsnprintf (&c, 1, format, args);
#endif
string = malloc ((n + 1) * sizeof (char));
if (string) {
len = vsprintf (string, format, args_copy);
if (len < 0) {
free (string);
string = NULL;
}
}
va_end (args_copy);
#endif
return string;
}
char *
_spectre_strdup_printf (const char *format, ...)
{
char *buffer;
va_list args;
va_start (args, format);
buffer = spectre_strdup_vprintf (format, args);
va_end (args);
return buffer;
}
char *
_spectre_strdup (const char *str)
{
size_t len;
char *copy;
if (!str)
return NULL;
len = strlen (str) + 1;
copy = malloc (len);
if (!copy)
return NULL;
memcpy (copy, str, len);
return copy;
}
#define TOLOWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
int
_spectre_strncasecmp (const char *s1,
const char *s2,
size_t n)
{
int c1, c2;
while (n && *s1 && *s2) {
n -= 1;
c1 = (int)(unsigned char) TOLOWER (*s1);
c2 = (int)(unsigned char) TOLOWER (*s2);
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
return (n) ? (((int) (unsigned char) *s1) - ((int) (unsigned char) *s2)) : 0;
}
int
_spectre_strcasecmp (const char *s1,
const char *s2)
{
int c1, c2;
while (*s1 && *s2) {
c1 = (int)(unsigned char) TOLOWER (*s1);
c2 = (int)(unsigned char) TOLOWER (*s2);
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
return (((int)(unsigned char) *s1) - ((int)(unsigned char) *s2));
}
#define ascii_isspace(c) \
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#define ascii_isdigit(c) \
(c >= '0' && c <= '9')
/* This function behaves like the standard strtod() function
* does in the C locale. It does this without actually changing
* the current locale, since that would not be thread-safe.
* A limitation of the implementation is that this function
* will still accept localized versions of infinities and NANs.
*/
double
_spectre_strtod (const char *nptr,
char **endptr)
{
char *fail_pos;
double val;
struct lconv *locale_data;
const char *decimal_point;
int decimal_point_len;
const char *p, *decimal_point_pos;
const char *end = NULL; /* Silence gcc */
int strtod_errno;
fail_pos = NULL;
locale_data = localeconv ();
decimal_point = locale_data->decimal_point;
decimal_point_len = strlen (decimal_point);
decimal_point_pos = NULL;
end = NULL;
if (decimal_point[0] != '.' || decimal_point[1] != 0) {
p = nptr;
/* Skip leading space */
while (ascii_isspace (*p))
p++;
/* Skip leading optional sign */
if (*p == '+' || *p == '-')
p++;
if (ascii_isdigit (*p) || *p == '.') {
while (ascii_isdigit (*p))
p++;
if (*p == '.')
decimal_point_pos = p++;
while (ascii_isdigit (*p))
p++;
if (*p == 'e' || *p == 'E')
p++;
if (*p == '+' || *p == '-')
p++;
while (ascii_isdigit (*p))
p++;
end = p;
}
/* For the other cases, we need not convert the decimal point */
}
if (decimal_point_pos) {
char *copy, *c;
/* We need to convert the '.' to the locale specific decimal point */
copy = (char *) malloc (end - nptr + 1 + decimal_point_len);
c = copy;
memcpy (c, nptr, decimal_point_pos - nptr);
c += decimal_point_pos - nptr;
memcpy (c, decimal_point, decimal_point_len);
c += decimal_point_len;
memcpy (c, decimal_point_pos + 1, end - (decimal_point_pos + 1));
c += end - (decimal_point_pos + 1);
*c = 0;
errno = 0;
val = strtod (copy, &fail_pos);
strtod_errno = errno;
if (fail_pos) {
if (fail_pos - copy > decimal_point_pos - nptr)
fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
else
fail_pos = (char *)nptr + (fail_pos - copy);
}
free (copy);
} else if (end) {
char *copy;
copy = (char *) malloc (end - (char *)nptr + 1);
memcpy (copy, nptr, end - nptr);
*(copy + (end - (char *)nptr)) = 0;
errno = 0;
val = strtod (copy, &fail_pos);
strtod_errno = errno;
if (fail_pos) {
fail_pos = (char *)nptr + (fail_pos - copy);
}
free (copy);
} else {
errno = 0;
val = strtod (nptr, &fail_pos);
strtod_errno = errno;
}
if (endptr)
*endptr = fail_pos;
errno = strtod_errno;
return val;
}
libspectre-0.2.12/libspectre/spectre-status.c 0000644 0001750 0001750 00000002751 14155760600 016150 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "spectre-status.h"
const char *
spectre_status_to_string (SpectreStatus status)
{
switch (status) {
case SPECTRE_STATUS_SUCCESS:
return "success";
case SPECTRE_STATUS_NO_MEMORY:
return "out of memory";
case SPECTRE_STATUS_LOAD_ERROR:
return "error loading document";
case SPECTRE_STATUS_DOCUMENT_NOT_LOADED:
return "document is not loaded";
case SPECTRE_STATUS_INVALID_PAGE:
return "page is invalid";
case SPECTRE_STATUS_RENDER_ERROR:
return "render error";
case SPECTRE_STATUS_EXPORTER_ERROR:
return "exporter error";
case SPECTRE_STATUS_SAVE_ERROR:
return "save error";
}
return "unknown error status";
}
libspectre-0.2.12/libspectre/spectre-page.h 0000644 0001750 0001750 00000011551 14155760600 015544 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_PAGE_H
#define SPECTRE_PAGE_H
#include
#include
#include
SPECTRE_BEGIN_DECLS
typedef enum {
SPECTRE_ORIENTATION_PORTRAIT /*! Vertical orientation */,
SPECTRE_ORIENTATION_REVERSE_LANDSCAPE /*! Inverse horizontal orientation,
also known as Seascape */,
SPECTRE_ORIENTATION_REVERSE_PORTRAIT /*! Inverse vertical orientation */,
SPECTRE_ORIENTATION_LANDSCAPE /*! Horizontal orientation */
} SpectreOrientation;
/*! This is the object that represents a page of a PostScript document.
They can not be created directly and can only be obtained from
::spectre_document_get_page */
typedef struct SpectrePage SpectrePage;
/*! Returns the status of the given page
@param page The page whose status will be returned
*/
SPECTRE_PUBLIC
SpectreStatus spectre_page_status (SpectrePage *page);
/*! Frees the memory of the given page
@param page The page whose memory will be freed
*/
SPECTRE_PUBLIC
void spectre_page_free (SpectrePage *page);
/*! Returns the index of the page inside the document. First page has index 0
@param page The page whose index will be returned
*/
SPECTRE_PUBLIC
unsigned int spectre_page_get_index (SpectrePage *page);
/*! Returns the label of the page inside the document.
@param page The page whose label will be returned
*/
SPECTRE_PUBLIC
const char *spectre_page_get_label (SpectrePage *page);
/*! Returns the orientation of the page
@param page The page whose orientation will be returned
*/
SPECTRE_PUBLIC
SpectreOrientation spectre_page_get_orientation (SpectrePage *page);
/*! Returns the size of the page. It always returns the page size according to
the page bounding box without taking into account the page orientation.
@param page The page whose size will be returned
@param width The page width will be returned here, or NULL
@param height The page height will be returned here, or NULL
@see spectre_page_get_orientation
*/
SPECTRE_PUBLIC
void spectre_page_get_size (SpectrePage *page,
int *width,
int *height);
/*! Renders the page to RGB32 format. This function can fail
@param page The page to renderer
@param rc The rendering context specifying how the page has to be rendered
@param page_data A pointer that will point to the image data
if the call succeeds
@param row_length The length of an image row will be returned here. It can
happen that row_length is different than width * 4
@see spectre_page_status
*/
SPECTRE_PUBLIC
void spectre_page_render (SpectrePage *page,
SpectreRenderContext *rc,
unsigned char **page_data,
int *row_length);
/* ! Renders a rectangle of the page to RGB32 format. This function can fail
@param page The page to renderer
@param rc The rendering context specifying how the page has to be rendered
@param x The X coordinate of the top left corner of the rectangle
@param y The Y coordinate to the top left corner of the rectangle
@param width The width of the rectangle
@param height The height of the rectangle
@param page_data A pointer that will point to the image data
if the call succeeds
@param row_length The length of an image row will be returned here. It can
happen that row_length is different than width * 4
@see spectre_page_status
*/
SPECTRE_PUBLIC
void spectre_page_render_slice (SpectrePage *page,
SpectreRenderContext *rc,
int x,
int y,
int width,
int height,
unsigned char **page_data,
int *row_length);
SPECTRE_END_DECLS
#endif /* SPECTRE_PAGE_H */
libspectre-0.2.12/libspectre/spectre-device.c 0000644 0001750 0001750 00000027560 14201706315 016064 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include "spectre-device.h"
#include "spectre-gs.h"
#include "spectre-utils.h"
#include "spectre-private.h"
/* ghostscript stuff */
#include
struct SpectreDevice {
struct document *doc;
int width, height;
int row_length; /*! Size of a horizontal row (y-line) in the image buffer */
unsigned char *gs_image; /*! Image buffer we received from Ghostscript library */
unsigned char *user_image;
int page_called;
};
static int
spectre_open (void *handle, void *device)
{
return 0;
}
static int
spectre_preclose (void *handle, void *device)
{
return 0;
}
static int
spectre_close (void *handle, void *device)
{
return 0;
}
static int
spectre_presize (void *handle, void *device, int width, int height,
int raster, unsigned int format)
{
SpectreDevice *sd;
if (!handle)
return 0;
sd = (SpectreDevice *)handle;
sd->width = width;
sd->height = height;
sd->row_length = raster;
sd->gs_image = NULL;
free(sd->user_image);
sd->user_image = malloc (sd->row_length * sd->height);
return 0;
}
static int
spectre_size (void *handle, void *device, int width, int height, int raster,
unsigned int format, unsigned char *pimage)
{
SpectreDevice *sd;
if (!handle)
return 0;
sd = (SpectreDevice *)handle;
sd->gs_image = pimage;
return 0;
}
static int
spectre_sync (void *handle, void *device)
{
return 0;
}
static int
spectre_page (void *handle, void *device, int copies, int flush)
{
SpectreDevice *sd;
if (!handle)
return 0;
sd = (SpectreDevice *)handle;
sd->page_called = TRUE;
memcpy (sd->user_image, sd->gs_image, sd->row_length * sd->height);
return 0;
}
static int
spectre_update (void *handle, void *device, int x, int y, int w, int h)
{
SpectreDevice *sd;
int i;
if (!handle)
return 0;
sd = (SpectreDevice *)handle;
if (!sd->gs_image || sd->page_called || !sd->user_image)
return 0;
for (i = y; i < y + h; ++i) {
memcpy (sd->user_image + sd->row_length * i + x * 4,
sd->gs_image + sd->row_length * i + x * 4, w * 4);
}
return 0;
}
static display_callback spectre_device = {
sizeof (display_callback),
DISPLAY_VERSION_MAJOR,
DISPLAY_VERSION_MINOR,
spectre_open,
spectre_preclose,
spectre_close,
spectre_presize,
spectre_size,
spectre_sync,
spectre_page,
spectre_update
};
SpectreDevice *
spectre_device_new (struct document *doc)
{
SpectreDevice *device;
device = calloc (1, sizeof (SpectreDevice));
if (!device)
return NULL;
device->doc = psdocreference (doc);
return device;
}
#define PIXEL_SIZE 4
#define ROW_ALIGN 32
static void
swap_pixels (unsigned char *data,
size_t pixel_a_start,
size_t pixel_b_start)
{
unsigned char value;
size_t i;
for (i = 0; i < PIXEL_SIZE; i++) {
value = data[pixel_a_start + i];
data[pixel_a_start + i] = data[pixel_b_start + i];
data[pixel_b_start + i] = value;
}
}
static void
copy_pixel (unsigned char *dest,
unsigned char *src,
size_t dest_pixel_start,
size_t src_pixel_start)
{
memcpy (dest + dest_pixel_start, src + src_pixel_start, PIXEL_SIZE);
}
static void
rotate_image_to_orientation (unsigned char **page_data,
int *row_length,
int width,
int height,
SpectreOrientation orientation)
{
int i, j;
size_t stride, padding;
unsigned char *user_image;
switch (orientation) {
default:
case SPECTRE_ORIENTATION_PORTRAIT:
break;
case SPECTRE_ORIENTATION_REVERSE_PORTRAIT:
for (j = 0; j < height / 2; ++j) {
for (i = 0; i < width; ++i) {
swap_pixels (*page_data,
*row_length * j + PIXEL_SIZE * i,
*row_length * (height - 1 - j) + PIXEL_SIZE * (width - 1 - i));
}
}
if (height % 2 == 1) {
for (i = 0; i < width / 2; ++i) {
swap_pixels (*page_data,
*row_length * (height / 2) + PIXEL_SIZE * i,
*row_length * (height - 1 - height / 2) + PIXEL_SIZE * (width - 1 - i));
}
}
break;
case SPECTRE_ORIENTATION_LANDSCAPE:
case SPECTRE_ORIENTATION_REVERSE_LANDSCAPE:
if (height % ROW_ALIGN > 0) {
padding = (ROW_ALIGN - height % ROW_ALIGN) * PIXEL_SIZE;
stride = height * PIXEL_SIZE + padding;
user_image = malloc (width * stride);
for (j = 0; j < width; ++j)
memset (user_image + j * stride + stride - padding, 0, padding);
} else {
stride = height * PIXEL_SIZE;
user_image = malloc (width * stride);
}
if (orientation == SPECTRE_ORIENTATION_LANDSCAPE) {
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i) {
copy_pixel (user_image,
*page_data,
stride * i + PIXEL_SIZE * (height - 1 - j),
*row_length * j + PIXEL_SIZE * i);
}
}
} else {
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i) {
copy_pixel (user_image,
*page_data,
stride * (width - 1 - i) + PIXEL_SIZE * j,
*row_length * j + PIXEL_SIZE * i);
}
}
}
free (*page_data);
*page_data = user_image;
*row_length = stride;
break;
}
}
static int spectre_callout_handler(void *instance, void *callout_handle, const char *device_name, int id, int size, void *data)
{
/* On entry, callout_handle == the value of state passed in
* to gsapi_register_callout. */
/* We are only interested in callouts from the display device. */
if (device_name == NULL || strcmp(device_name, "display"))
return -1;
if (id == DISPLAY_CALLOUT_GET_CALLBACK)
{
/* Fill in the supplied block with the details of our callback
* handler, and the handle to use. In this instance, the handle
* is the pointer to our test structure. */
gs_display_get_callback_t *cb = (gs_display_get_callback_t *)data;
cb->callback = &spectre_device;
cb->caller_handle = callout_handle;
return 0;
}
return -1;
}
SpectreStatus
spectre_device_render (SpectreDevice *device,
unsigned int page,
SpectreRenderContext *rc,
int x,
int y,
int width,
int height,
unsigned char **page_data,
int *row_length)
{
SpectreGS *gs;
char **args;
int n_args = 12;
int arg = 0;
int success;
char *text_alpha, *graph_alpha;
char *size = NULL;
char *resolution, *set;
char *dsp_format;
char *width_points = NULL;
char *height_points = NULL;
gs = spectre_gs_new ();
if (!gs)
return SPECTRE_STATUS_NO_MEMORY;
if (!spectre_gs_create_instance (gs, device)) {
spectre_gs_cleanup (gs, CLEANUP_DELETE_INSTANCE);
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}
if (!spectre_gs_register_callout(gs, spectre_callout_handler, device)) {
spectre_gs_cleanup (gs, CLEANUP_DELETE_INSTANCE);
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}
width = (int) ((width * rc->x_scale) + 0.5);
height = (int) ((height * rc->y_scale) + 0.5);
if (rc->use_platform_fonts == FALSE)
n_args++;
if (rc->width != -1 && rc->height != -1)
n_args += 3;
args = calloc (sizeof (char *), n_args);
args[arg++] = "libspectre"; /* This value doesn't really matter */
args[arg++] = "-dMaxBitmap=10000000";
args[arg++] = "-dSAFER";
args[arg++] = "-dNOPAUSE";
args[arg++] = "-dNOPAGEPROMPT";
args[arg++] = "-P-";
args[arg++] = "-sDEVICE=display";
args[arg++] = text_alpha = _spectre_strdup_printf ("-dTextAlphaBits=%d",
rc->text_alpha_bits);
args[arg++] = graph_alpha = _spectre_strdup_printf ("-dGraphicsAlphaBits=%d",
rc->graphic_alpha_bits);
args[arg++] = size =_spectre_strdup_printf ("-g%dx%d", width, height);
args[arg++] = resolution = _spectre_strdup_printf ("-r%fx%f",
rc->x_scale * rc->x_dpi,
rc->y_scale * rc->y_dpi);
args[arg++] = dsp_format = _spectre_strdup_printf ("-dDisplayFormat=%d",
DISPLAY_COLORS_RGB |
DISPLAY_DEPTH_8 |
DISPLAY_ROW_ALIGN_DEFAULT |
#ifdef WORDS_BIGENDIAN
DISPLAY_UNUSED_FIRST |
DISPLAY_BIGENDIAN |
#else
DISPLAY_UNUSED_LAST |
DISPLAY_LITTLEENDIAN |
#endif
DISPLAY_TOPFIRST);
if (rc->use_platform_fonts == FALSE)
args[arg++] = "-dNOPLATFONTS";
if (rc->width != -1 && rc->height != -1) {
args[arg++] = width_points = _spectre_strdup_printf ("-dDEVICEWIDTHPOINTS=%d",
rc->width);
args[arg++] = height_points = _spectre_strdup_printf ("-dDEVICEHEIGHTPOINTS=%d",
rc->height);
args[arg++] = "-dFIXEDMEDIA";
}
success = spectre_gs_run (gs, n_args, args);
free (text_alpha);
free (graph_alpha);
free (size);
free (width_points);
free (height_points);
free (resolution);
free (dsp_format);
free (args);
if (!success) {
free (device->user_image);
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}
set = _spectre_strdup_printf ("<< /Orientation %d >> setpagedevice .locksafe",
SPECTRE_ORIENTATION_PORTRAIT);
if (!spectre_gs_send_string (gs, set)) {
free (set);
free (device->user_image);
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}
free (set);
if (!spectre_gs_send_page (gs, device->doc, page, x, y)) {
free (device->user_image);
spectre_gs_free (gs);
return SPECTRE_STATUS_RENDER_ERROR;
}
*page_data = device->user_image;
*row_length = device->row_length;
rotate_image_to_orientation (page_data, row_length, width, height, rc->orientation);
spectre_gs_free (gs);
return SPECTRE_STATUS_SUCCESS;
}
void
spectre_device_free (SpectreDevice *device)
{
if (!device)
return;
if (device->doc) {
psdocdestroy (device->doc);
device->doc = NULL;
}
free (device);
}
libspectre-0.2.12/libspectre/spectre-exporter-pdf.c 0000644 0001750 0001750 00000007375 14356525407 017262 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007, 2023 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include "spectre-private.h"
#include "spectre-utils.h"
static SpectreStatus
spectre_exporter_pdf_begin (SpectreExporter *exporter,
const char *filename)
{
static const int kArgs = 9;
char *args[kArgs];
int arg = 0;
char *output_file;
struct document *doc = exporter->doc;
exporter->gs = spectre_gs_new ();
if (!spectre_gs_create_instance (exporter->gs, NULL)) {
spectre_gs_cleanup (exporter->gs, CLEANUP_DELETE_INSTANCE);
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
args[arg++] = "libspectre"; /* This value doesn't really matter */
args[arg++] = "-dMaxBitmap=10000000";
args[arg++] = "-dBATCH";
args[arg++] = "-dNOPAUSE";
args[arg++] = "-dSAFER";
args[arg++] = "-P-";
args[arg++] = "-sDEVICE=pdfwrite";
args[arg++] = output_file = _spectre_strdup_printf ("-sOutputFile=%s",
filename);
args[arg++] = "-c";
assert(kArgs == arg);
if (!spectre_gs_run (exporter->gs, kArgs, args)) {
free (output_file);
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
free (output_file);
if (!spectre_gs_process (exporter->gs,
doc->filename,
0, 0,
doc->beginprolog,
doc->endprolog)) {
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
if (!spectre_gs_process (exporter->gs,
doc->filename,
0, 0,
doc->beginsetup,
doc->endsetup)) {
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
return SPECTRE_STATUS_SUCCESS;
}
static SpectreStatus
spectre_exporter_pdf_do_page (SpectreExporter *exporter,
unsigned int page_index)
{
struct document *doc = exporter->doc;
if (!exporter->gs)
return SPECTRE_STATUS_EXPORTER_ERROR;
if (!spectre_gs_process (exporter->gs,
doc->filename,
0, 0,
doc->pages[page_index].begin,
doc->pages[page_index].end)) {
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return SPECTRE_STATUS_EXPORTER_ERROR;
}
return SPECTRE_STATUS_SUCCESS;
}
static SpectreStatus
spectre_exporter_pdf_end (SpectreExporter *exporter)
{
int ret;
struct document *doc = exporter->doc;
if (!exporter->gs)
return SPECTRE_STATUS_EXPORTER_ERROR;
ret = spectre_gs_process (exporter->gs,
doc->filename,
0, 0,
doc->begintrailer,
doc->endtrailer);
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
return ret ? SPECTRE_STATUS_SUCCESS : SPECTRE_STATUS_EXPORTER_ERROR;
}
SpectreExporter *
_spectre_exporter_pdf_new (struct document *doc)
{
SpectreExporter *exporter;
exporter = calloc (1, sizeof (SpectreExporter));
if (!exporter)
return NULL;
exporter->doc = psdocreference (doc);
exporter->begin = spectre_exporter_pdf_begin;
exporter->do_page = spectre_exporter_pdf_do_page;
exporter->end = spectre_exporter_pdf_end;
return exporter;
}
libspectre-0.2.12/libspectre/Makefile.in 0000644 0001750 0001750 00000115246 14356526206 015074 0000000 0000000 # Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = libspectre
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(libspectreinclude_HEADERS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = spectre-version.h
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(libdir)" \
"$(DESTDIR)$(libspectreincludedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libspectre_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__objects_1 = libspectre_la-ps.lo
am_libspectre_la_OBJECTS = libspectre_la-spectre-status.lo \
libspectre_la-spectre-document.lo libspectre_la-spectre-gs.lo \
libspectre_la-spectre-render-context.lo \
libspectre_la-spectre-device.lo libspectre_la-spectre-page.lo \
libspectre_la-spectre-exporter.lo \
libspectre_la-spectre-exporter-pdf.lo \
libspectre_la-spectre-exporter-ps.lo \
libspectre_la-spectre-utils.lo $(am__objects_1)
libspectre_la_OBJECTS = $(am_libspectre_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libspectre_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libspectre_la_CFLAGS) \
$(CFLAGS) $(libspectre_la_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/libspectre_la-ps.Plo \
./$(DEPDIR)/libspectre_la-spectre-device.Plo \
./$(DEPDIR)/libspectre_la-spectre-document.Plo \
./$(DEPDIR)/libspectre_la-spectre-exporter-pdf.Plo \
./$(DEPDIR)/libspectre_la-spectre-exporter-ps.Plo \
./$(DEPDIR)/libspectre_la-spectre-exporter.Plo \
./$(DEPDIR)/libspectre_la-spectre-gs.Plo \
./$(DEPDIR)/libspectre_la-spectre-page.Plo \
./$(DEPDIR)/libspectre_la-spectre-render-context.Plo \
./$(DEPDIR)/libspectre_la-spectre-status.Plo \
./$(DEPDIR)/libspectre_la-spectre-utils.Plo
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libspectre_la_SOURCES)
DIST_SOURCES = $(libspectre_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
HEADERS = $(libspectreinclude_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/spectre-version.h.in \
$(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_LIBS = @CAIRO_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_GS = @LIB_GS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@
LT_REVISION = @LT_REVISION@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPECTRE_CFLAGS = @SPECTRE_CFLAGS@
SPECTRE_MAJOR_VERSION = @SPECTRE_MAJOR_VERSION@
SPECTRE_MICRO_VERSION = @SPECTRE_MICRO_VERSION@
SPECTRE_MINOR_VERSION = @SPECTRE_MINOR_VERSION@
SPECTRE_VERSION = @SPECTRE_VERSION@
STRIP = @STRIP@
VERSION = @VERSION@
VERSION_INFO = @VERSION_INFO@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = spectre-version.h.in
lib_LTLIBRARIES = libspectre.la
libspectreincludedir = $(includedir)/libspectre
libspectreinclude_HEADERS = \
spectre.h \
spectre-macros.h \
spectre-status.h \
spectre-document.h \
spectre-render-context.h \
spectre-page.h \
spectre-exporter.h \
spectre-version.h
gv_sources = \
ps.h \
ps.c
libspectre_la_SOURCES = \
spectre.h \
spectre-private.h \
spectre-macros.h \
spectre-status.h \
spectre-status.c \
spectre-document.h \
spectre-document.c \
spectre-gs.h \
spectre-gs.c \
spectre-render-context.h \
spectre-render-context.c \
spectre-device.h \
spectre-device.c \
spectre-page.h \
spectre-page.c \
spectre-exporter.h \
spectre-exporter.c \
spectre-exporter-pdf.c \
spectre-exporter-ps.c \
spectre-utils.h \
spectre-utils.c \
$(gv_sources)
libspectre_la_CPPFLAGS = \
$(SPECTRE_CFLAGS)
libspectre_la_CFLAGS = \
$(VISIBILITY_CFLAGS)
libspectre_la_LIBADD = $(LIB_GS)
libspectre_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libspectre/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign libspectre/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
spectre-version.h: $(top_builddir)/config.status $(srcdir)/spectre-version.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libspectre.la: $(libspectre_la_OBJECTS) $(libspectre_la_DEPENDENCIES) $(EXTRA_libspectre_la_DEPENDENCIES)
$(AM_V_CCLD)$(libspectre_la_LINK) -rpath $(libdir) $(libspectre_la_OBJECTS) $(libspectre_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-ps.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-device.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-document.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-exporter-pdf.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-exporter-ps.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-exporter.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-gs.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-page.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-render-context.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-status.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libspectre_la-spectre-utils.Plo@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libspectre_la-spectre-status.lo: spectre-status.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-status.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-status.Tpo -c -o libspectre_la-spectre-status.lo `test -f 'spectre-status.c' || echo '$(srcdir)/'`spectre-status.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-status.Tpo $(DEPDIR)/libspectre_la-spectre-status.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-status.c' object='libspectre_la-spectre-status.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-status.lo `test -f 'spectre-status.c' || echo '$(srcdir)/'`spectre-status.c
libspectre_la-spectre-document.lo: spectre-document.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-document.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-document.Tpo -c -o libspectre_la-spectre-document.lo `test -f 'spectre-document.c' || echo '$(srcdir)/'`spectre-document.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-document.Tpo $(DEPDIR)/libspectre_la-spectre-document.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-document.c' object='libspectre_la-spectre-document.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-document.lo `test -f 'spectre-document.c' || echo '$(srcdir)/'`spectre-document.c
libspectre_la-spectre-gs.lo: spectre-gs.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-gs.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-gs.Tpo -c -o libspectre_la-spectre-gs.lo `test -f 'spectre-gs.c' || echo '$(srcdir)/'`spectre-gs.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-gs.Tpo $(DEPDIR)/libspectre_la-spectre-gs.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-gs.c' object='libspectre_la-spectre-gs.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-gs.lo `test -f 'spectre-gs.c' || echo '$(srcdir)/'`spectre-gs.c
libspectre_la-spectre-render-context.lo: spectre-render-context.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-render-context.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-render-context.Tpo -c -o libspectre_la-spectre-render-context.lo `test -f 'spectre-render-context.c' || echo '$(srcdir)/'`spectre-render-context.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-render-context.Tpo $(DEPDIR)/libspectre_la-spectre-render-context.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-render-context.c' object='libspectre_la-spectre-render-context.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-render-context.lo `test -f 'spectre-render-context.c' || echo '$(srcdir)/'`spectre-render-context.c
libspectre_la-spectre-device.lo: spectre-device.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-device.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-device.Tpo -c -o libspectre_la-spectre-device.lo `test -f 'spectre-device.c' || echo '$(srcdir)/'`spectre-device.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-device.Tpo $(DEPDIR)/libspectre_la-spectre-device.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-device.c' object='libspectre_la-spectre-device.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-device.lo `test -f 'spectre-device.c' || echo '$(srcdir)/'`spectre-device.c
libspectre_la-spectre-page.lo: spectre-page.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-page.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-page.Tpo -c -o libspectre_la-spectre-page.lo `test -f 'spectre-page.c' || echo '$(srcdir)/'`spectre-page.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-page.Tpo $(DEPDIR)/libspectre_la-spectre-page.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-page.c' object='libspectre_la-spectre-page.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-page.lo `test -f 'spectre-page.c' || echo '$(srcdir)/'`spectre-page.c
libspectre_la-spectre-exporter.lo: spectre-exporter.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-exporter.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-exporter.Tpo -c -o libspectre_la-spectre-exporter.lo `test -f 'spectre-exporter.c' || echo '$(srcdir)/'`spectre-exporter.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-exporter.Tpo $(DEPDIR)/libspectre_la-spectre-exporter.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-exporter.c' object='libspectre_la-spectre-exporter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-exporter.lo `test -f 'spectre-exporter.c' || echo '$(srcdir)/'`spectre-exporter.c
libspectre_la-spectre-exporter-pdf.lo: spectre-exporter-pdf.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-exporter-pdf.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-exporter-pdf.Tpo -c -o libspectre_la-spectre-exporter-pdf.lo `test -f 'spectre-exporter-pdf.c' || echo '$(srcdir)/'`spectre-exporter-pdf.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-exporter-pdf.Tpo $(DEPDIR)/libspectre_la-spectre-exporter-pdf.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-exporter-pdf.c' object='libspectre_la-spectre-exporter-pdf.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-exporter-pdf.lo `test -f 'spectre-exporter-pdf.c' || echo '$(srcdir)/'`spectre-exporter-pdf.c
libspectre_la-spectre-exporter-ps.lo: spectre-exporter-ps.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-exporter-ps.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-exporter-ps.Tpo -c -o libspectre_la-spectre-exporter-ps.lo `test -f 'spectre-exporter-ps.c' || echo '$(srcdir)/'`spectre-exporter-ps.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-exporter-ps.Tpo $(DEPDIR)/libspectre_la-spectre-exporter-ps.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-exporter-ps.c' object='libspectre_la-spectre-exporter-ps.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-exporter-ps.lo `test -f 'spectre-exporter-ps.c' || echo '$(srcdir)/'`spectre-exporter-ps.c
libspectre_la-spectre-utils.lo: spectre-utils.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-spectre-utils.lo -MD -MP -MF $(DEPDIR)/libspectre_la-spectre-utils.Tpo -c -o libspectre_la-spectre-utils.lo `test -f 'spectre-utils.c' || echo '$(srcdir)/'`spectre-utils.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-spectre-utils.Tpo $(DEPDIR)/libspectre_la-spectre-utils.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='spectre-utils.c' object='libspectre_la-spectre-utils.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-spectre-utils.lo `test -f 'spectre-utils.c' || echo '$(srcdir)/'`spectre-utils.c
libspectre_la-ps.lo: ps.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -MT libspectre_la-ps.lo -MD -MP -MF $(DEPDIR)/libspectre_la-ps.Tpo -c -o libspectre_la-ps.lo `test -f 'ps.c' || echo '$(srcdir)/'`ps.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libspectre_la-ps.Tpo $(DEPDIR)/libspectre_la-ps.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ps.c' object='libspectre_la-ps.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libspectre_la_CPPFLAGS) $(CPPFLAGS) $(libspectre_la_CFLAGS) $(CFLAGS) -c -o libspectre_la-ps.lo `test -f 'ps.c' || echo '$(srcdir)/'`ps.c
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-libspectreincludeHEADERS: $(libspectreinclude_HEADERS)
@$(NORMAL_INSTALL)
@list='$(libspectreinclude_HEADERS)'; test -n "$(libspectreincludedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(libspectreincludedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libspectreincludedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libspectreincludedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(libspectreincludedir)" || exit $$?; \
done
uninstall-libspectreincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(libspectreinclude_HEADERS)'; test -n "$(libspectreincludedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(libspectreincludedir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libspectreincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/libspectre_la-ps.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-device.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-document.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter-pdf.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter-ps.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-gs.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-page.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-render-context.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-status.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-utils.Plo
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-libspectreincludeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-libLTLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libspectre_la-ps.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-device.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-document.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter-pdf.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter-ps.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-exporter.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-gs.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-page.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-render-context.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-status.Plo
-rm -f ./$(DEPDIR)/libspectre_la-spectre-utils.Plo
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-libLTLIBRARIES \
uninstall-libspectreincludeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-libLTLIBRARIES \
install-libspectreincludeHEADERS install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
uninstall-libspectreincludeHEADERS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
libspectre-0.2.12/libspectre/spectre-exporter.h 0000644 0001750 0001750 00000003456 14155760600 016505 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SPECTRE_EXPORTER_H
#define SPECTRE_EXPORTER_H
#include
#include
#include
SPECTRE_BEGIN_DECLS
typedef enum {
SPECTRE_EXPORTER_FORMAT_PS,
SPECTRE_EXPORTER_FORMAT_PDF
} SpectreExporterFormat;
typedef struct SpectreExporter SpectreExporter;
SPECTRE_PUBLIC
SpectreExporter *spectre_exporter_new (SpectreDocument *document,
SpectreExporterFormat format);
SPECTRE_PUBLIC
void spectre_exporter_free (SpectreExporter *exporter);
SPECTRE_PUBLIC
SpectreStatus spectre_exporter_begin (SpectreExporter *exporter,
const char *filename);
SPECTRE_PUBLIC
SpectreStatus spectre_exporter_do_page (SpectreExporter *exporter,
unsigned int page_index);
SPECTRE_PUBLIC
SpectreStatus spectre_exporter_end (SpectreExporter *exporter);
SPECTRE_END_DECLS
#endif /* SPECTRE_EXPORTER_H */
libspectre-0.2.12/libspectre/spectre-render-context.c 0000644 0001750 0001750 00000011502 14155760600 017560 0000000 0000000 /* This file is part of Libspectre.
*
* Copyright (C) 2007 Albert Astals Cid
* Copyright (C) 2007 Carlos Garcia Campos
*
* Libspectre is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2; or (at your option)
* any later version.
*
* Libspectre is distributed in the hope that it will be useful;
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not; write to the Free Software
* Foundation; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include "spectre-render-context.h"
#include "spectre-page.h"
#include "spectre-private.h"
#include "spectre-utils.h"
SpectreRenderContext *
spectre_render_context_new (void)
{
SpectreRenderContext *rc;
rc = malloc (sizeof (SpectreRenderContext));
if (!rc)
return NULL;
rc->x_scale = 1.0;
rc->y_scale = 1.0;
rc->orientation = 0;
rc->x_dpi = 72.0;
rc->y_dpi = 72.0;
rc->width = -1;
rc->height = -1;
rc->text_alpha_bits = 4;
rc->graphic_alpha_bits = 2;
rc->use_platform_fonts = TRUE;
return rc;
}
void
spectre_render_context_free (SpectreRenderContext *rc)
{
if (!rc)
return;
free (rc);
}
void
spectre_render_context_set_scale (SpectreRenderContext *rc,
double x_scale,
double y_scale)
{
_spectre_return_if_fail (rc != NULL);
rc->x_scale = x_scale;
rc->y_scale = y_scale;
}
void
spectre_render_context_get_scale (SpectreRenderContext *rc,
double *x_scale,
double *y_scale)
{
_spectre_return_if_fail (rc != NULL);
if (x_scale)
*x_scale = rc->x_scale;
if (y_scale)
*y_scale = rc->y_scale;
}
void
spectre_render_context_set_rotation (SpectreRenderContext *rc,
unsigned int rotation)
{
_spectre_return_if_fail (rc != NULL);
rotation %= 360;
if (rotation < 90)
rc->orientation = SPECTRE_ORIENTATION_PORTRAIT;
else if (rotation >= 90 && rotation < 180)
rc->orientation = SPECTRE_ORIENTATION_LANDSCAPE;
else if (rotation >= 180 && rotation < 270)
rc->orientation = SPECTRE_ORIENTATION_REVERSE_PORTRAIT;
else if (rotation >= 270 && rotation < 360)
rc->orientation = SPECTRE_ORIENTATION_REVERSE_LANDSCAPE;
}
unsigned int
spectre_render_context_get_rotation (SpectreRenderContext *rc)
{
_spectre_return_val_if_fail (rc != NULL, 0);
switch (rc->orientation) {
default:
case SPECTRE_ORIENTATION_PORTRAIT:
return 0;
case SPECTRE_ORIENTATION_LANDSCAPE:
return 90;
case SPECTRE_ORIENTATION_REVERSE_PORTRAIT:
return 180;
case SPECTRE_ORIENTATION_REVERSE_LANDSCAPE:
return 270;
}
return 0;
}
void
spectre_render_context_set_resolution (SpectreRenderContext *rc,
double x_dpi,
double y_dpi)
{
_spectre_return_if_fail (rc != NULL);
rc->x_dpi = x_dpi;
rc->y_dpi = y_dpi;
}
void
spectre_render_context_get_resolution (SpectreRenderContext *rc,
double *x_dpi,
double *y_dpi)
{
_spectre_return_if_fail (rc != NULL);
if (x_dpi)
*x_dpi = rc->x_dpi;
if (y_dpi)
*y_dpi = rc->y_dpi;
}
void
spectre_render_context_set_page_size (SpectreRenderContext *rc,
int width,
int height)
{
_spectre_return_if_fail (rc != NULL);
rc->width = width;
rc->height = height;
}
void
spectre_render_context_get_page_size (SpectreRenderContext *rc,
int *width,
int *height)
{
_spectre_return_if_fail (rc != NULL);
if (width)
*width = rc->width;
if (height)
*height = rc->height;
}
void
spectre_render_context_set_use_platform_fonts (SpectreRenderContext *rc,
int use_platform_fonts)
{
_spectre_return_if_fail (rc != NULL);
rc->use_platform_fonts = use_platform_fonts;
}
int
spectre_render_context_get_use_platform_fonts (SpectreRenderContext *rc)
{
_spectre_return_val_if_fail (rc != NULL, FALSE);
return rc->use_platform_fonts;
}
void
spectre_render_context_set_antialias_bits (SpectreRenderContext *rc,
int graphics_bits,
int text_bits)
{
_spectre_return_if_fail (rc != NULL);
rc->graphic_alpha_bits = graphics_bits;
rc->text_alpha_bits = text_bits;
}
void
spectre_render_context_get_antialias_bits (SpectreRenderContext *rc,
int *graphics_bits,
int *text_bits)
{
_spectre_return_if_fail (rc != NULL);
if (graphics_bits)
*graphics_bits = rc->graphic_alpha_bits;
if (text_bits)
*text_bits = rc->text_alpha_bits;
}
libspectre-0.2.12/configure.ac 0000644 0001750 0001750 00000022566 14356526146 013166 0000000 0000000 AC_PREREQ(2.59)
m4_define([spectre_major_version], [0])
m4_define([spectre_minor_version], [2])
m4_define([spectre_micro_version], [12])
m4_define([spectre_version],
[spectre_major_version.spectre_minor_version.spectre_micro_version])
AC_INIT(libspectre, [spectre_version])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([1.7])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AM_MAINTAINER_MODE
# libtool versioning
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#
## increment if the interface has additions, changes, removals.
LT_CURRENT=2
## increment any time the source changes; set to
## 0 if you increment CURRENT
LT_REVISION=12
## increment if any interfaces have been added; set to 0
## if any interfaces have been changed or removed. removal has
## precedence over adding, so set to 0 if both happened.
LT_AGE=1
VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE"
AC_SUBST(VERSION_INFO)
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
AC_SUBST(LT_CURRENT_MINUS_AGE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
SPECTRE_MAJOR_VERSION=spectre_major_version
SPECTRE_MINOR_VERSION=spectre_minor_version
SPECTRE_MICRO_VERSION=spectre_micro_version
SPECTRE_VERSION=spectre_major_version.spectre_minor_version.spectre_micro_version
AC_SUBST(SPECTRE_MAJOR_VERSION)
AC_SUBST(SPECTRE_MINOR_VERSION)
AC_SUBST(SPECTRE_MICRO_VERSION)
AC_SUBST(SPECTRE_VERSION)
AC_PROG_LIBTOOL
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_CC_STDC
AC_STDC_HEADERS
AC_C_BIGENDIAN
AC_CHECK_FUNC(vasprintf, [ AC_DEFINE(HAVE_VASPRINTF, 1, [Define if the 'vasprintf' function is available.]) ])
AC_CHECK_FUNC(_vscprintf, [ AC_DEFINE(HAVE__VSCPRINTF, 1, [Define if the '_vscprintf' function is available.]) ])
LIBGS_REQUIRED="9.53.0"
AC_CHECK_LIB(gs, gsapi_new_instance, have_libgs=yes, have_libgs=no)
if test "x$have_libgs" = "xyes"; then
LIB_GS="-lgs"
save_LIBS=$LIBS
LIBS="$LIBS -lgs"
AC_LANG_PUSH(C)
AC_MSG_CHECKING([for libgs >= $LIBGS_REQUIRED])
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
#include
]],
[[
gsapi_revision_t gsrev;
if (gsapi_revision (&gsrev, sizeof (gsrev)) != 0)
return 1;
if (gsrev.revision < `echo "$LIBGS_REQUIRED" | sed -e 's/\.//g'`)
return 1;
]])],
[have_libgs=yes],
[have_libgs=no],
[have_libgs=yes]
)
AC_MSG_RESULT($have_libgs)
AC_LANG_POP(C)
LIBS=$save_LIBS
if test "x$have_libgs" = "xno"; then
AC_MSG_ERROR([You need libgs >= $LIBGS_REQUIRED in order to compile libspectre])
fi
else
AC_MSG_ERROR([You need libgs in order to compile libspectre])
fi
AC_SUBST(LIB_GS)
AC_ARG_ENABLE(asserts,
AS_HELP_STRING([--enable-asserts],[include assertion checks]),
enable_asserts=$enableval,
enable_asserts=$USE_MAINTAINER_MODE)
if test x$enable_asserts = xno; then
AC_DEFINE(SPECTRE_DISABLE_ASSERT,[1],[Disable assertion checking])
fi
AC_ARG_ENABLE(checks,
AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),
enable_checks=$enableval,
enable_checks=yes)
if test x$enable_checks = xno; then
AC_DEFINE(SPECTRE_DISABLE_CHECKS,[1],[Disable public API sanity checking])
fi
dnl Test
AC_ARG_ENABLE(test,
[AC_HELP_STRING([--enable-test], [Compile tests])],enable_test="$enableval",enable_test=yes)
if test "x$enable_test" = "xyes"; then
PKG_CHECK_MODULES(CAIRO, cairo cairo-png, enable_test=yes,enable_test=no)
if test "x$enable_test" != "xyes"; then
AC_MSG_WARN("Tests disabled since required cairo library was not found")
fi
fi
AM_CONDITIONAL(ENABLE_TEST, test x$enable_test = xyes)
dnl ===========================================================================
dnl check compiler flags (From cairo)
AC_DEFUN([SPECTRE_CC_TRY_FLAG], [
AC_MSG_CHECKING([whether $CC supports $1])
spectre_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_COMPILE_IFELSE([ ], [spectre_cc_flag=yes], [spectre_cc_flag=no])
CFLAGS="$spectre_save_CFLAGS"
if test "x$spectre_cc_flag" = "xyes"; then
ifelse([$2], , :, [$2])
else
ifelse([$3], , :, [$3])
fi
AC_MSG_RESULT([$spectre_cc_flag])
])
dnl Use lots of warning flags with with gcc and compatible compilers
dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked. So there's no need to do anything
dnl else. If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)
MAYBE_WARN="-Wall -Wextra \
-Wsign-compare -Werror-implicit-function-declaration \
-Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
-Wpacked -Wswitch-enum \
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
-Wdeclaration-after-statement \
-Wno-missing-field-initializers -Wno-unused-parameter \
-Wno-attributes -Wno-long-long -Winline"
AC_ARG_ENABLE(iso-c,
AC_HELP_STRING([--enable-iso-c], [Try to warn if code is not ISO C ]),,[enable_iso_c=no])
if test "x$enable_iso_c" != "xno"; then
MAYBE_WARN="$MAYBE_WARN -ansi -pedantic"
fi
# invalidate cached value if MAYBE_WARN has changed
if test "x$spectre_cv_warn_maybe" != "x$MAYBE_WARN"; then
unset spectre_cv_warn_cflags
fi
AC_CACHE_CHECK([for supported warning flags], spectre_cv_warn_cflags, [
echo
WARN_CFLAGS=""
# Some warning options are not supported by all versions of
# gcc, so test all desired options against the current
# compiler.
#
# Note that there are some order dependencies
# here. Specifically, an option that disables a warning will
# have no net effect if a later option then enables that
# warnings, (perhaps implicitly). So we put some grouped
# options (-Wall and -Wextra) up front and the -Wno options
# last.
for W in $MAYBE_WARN; do
SPECTRE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
done
spectre_cv_warn_cflags=$WARN_CFLAGS
spectre_cv_warn_maybe=$MAYBE_WARN
AC_MSG_CHECKING([which warning flags were supported])])
WARN_CFLAGS="$spectre_cv_warn_cflags"
SPECTRE_CFLAGS="$SPECTRE_CFLAGS $WARN_CFLAGS"
AC_SUBST(SPECTRE_CFLAGS)
dnl **********************************
dnl *** va_copy checks (from GLib) ***
dnl **********************************
dnl we currently check for all three va_copy possibilities, so we get
dnl all results in config.log for bug reports.
AC_CACHE_CHECK([for an implementation of va_copy()],spectre_cv_va_copy,[
AC_LINK_IFELSE([#include
#include
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() {
f (0, 42);
return 0;
}],
[spectre_cv_va_copy=yes],
[spectre_cv_va_copy=no])
])
AC_CACHE_CHECK([for an implementation of __va_copy()],spectre_cv___va_copy,[
AC_LINK_IFELSE([#include
#include
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
__va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() {
f (0, 42);
return 0;
}],
[spectre_cv___va_copy=yes],
[spectre_cv___va_copy=no])
])
if test "x$spectre_cv_va_copy" = "xyes"; then
spectre_va_copy_func=va_copy
else if test "x$spectre_cv___va_copy" = "xyes"; then
spectre_va_copy_func=__va_copy
fi
fi
if test -n "$spectre_va_copy_func"; then
AC_DEFINE_UNQUOTED(SPECTRE_VA_COPY,$spectre_va_copy_func,[A 'va_copy' style function])
fi
AC_LANG_PUSH(C)
AC_CACHE_CHECK([whether va_lists can be copied by value],
spectre_cv_va_val_copy,
[AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
#include
#include
]],
[[
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
args2 = args1;
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() {
f (0, 42);
return 0;
}
]])],
[spectre_cv_va_val_copy=yes],
[spectre_cv_va_val_copy=no],
[spectre_cv_va_val_copy=yes])
])
AC_LANG_POP(C)
if test "x$spectre_cv_va_val_copy" = "xno"; then
AC_DEFINE(SPECTRE_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
fi
dnl Check for -fvisibility=hidden to determine if we can do GNU-style
dnl visibility attributes for symbol export control
dnl
VISIBILITY_CFLAGS=""
case "$host" in
*-*-mingw*)
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([SPECTRE_PUBLIC], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
[defines how to decorate public symbols while building])
CFLAGS="${CFLAGS} -fvisibility=hidden"
;;
*)
dnl on other compilers, check if we can do -fvisibility=hidden
SAVED_CFLAGS="${CFLAGS}"
CFLAGS="-fvisibility=hidden"
AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
AC_TRY_COMPILE([], [return 0],
AC_MSG_RESULT(yes)
enable_fvisibility_hidden=yes,
AC_MSG_RESULT(no)
enable_fvisibility_hidden=no)
CFLAGS="${SAVED_CFLAGS}"
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([SPECTRE_PUBLIC], [__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building])
VISIBILITY_CFLAGS="-fvisibility=hidden"
],
[AC_DEFINE([SPECTRE_PUBLIC],[extern])])
;;
esac
AC_SUBST([VISIBILITY_CFLAGS])
AC_OUTPUT([
Makefile
Doxyfile
libspectre/Makefile
libspectre/spectre-version.h
test/Makefile
libspectre.pc
])
libspectre-0.2.12/ChangeLog 0000644 0001750 0001750 00000240661 14356636335 012452 0000000 0000000 commit 44ba3f8291e5640045d501f130f8a4521fc407b3
Author: Albert Astals Cid
Date: Sun Jan 8 22:53:43 2023 +0100
libspectre 0.2.12
NEWS | 7 +++++++
configure.ac | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
commit cc3f0f9260912b7bd238838830d0f7ddd30a8881
Author: Albert Astals Cid
Date: Sun Jan 8 12:34:50 2023 +0100
Fix exporting to pdf
setpdfwrite has not done anything for a while according to
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=9699aea5cf6491106a2ad1be260d9eb2e85903c3
libspectre/spectre-exporter-pdf.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
commit 7ec4f0110698d7e43309e4c7aa821303f3698b9b
Author: Albert Astals Cid
Date: Fri Nov 4 00:09:15 2022 +0100
release: 0.2.11
NEWS | 7 +++++++
configure.ac | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
commit 0205c12924a63f326e0b6f11153aba4eebdcd551
Author: Albert Astals Cid
Date: Fri Nov 4 00:06:18 2022 +0100
CI: Fix ubuntu:21.04 CI
.gitlab-ci.yml | 3 +++
1 file changed, 3 insertions(+)
commit 66dc111212930fa7f936ea3ed69a566febef5f4c
Author: Marek Kasik
Date: Fri Mar 25 15:18:00 2022 +0100
Avoid possible crash when loading a document
Check for result of openning of a file in spectre_document_load()
and don't proceed if there was an error.
libspectre/spectre-document.c | 4 ++++
1 file changed, 4 insertions(+)
commit 8d0515492504f5e4cf3dd9ddf3e89360f0a67e91
Author: Albert Astals Cid
Date: Sat Feb 12 11:37:35 2022 +0100
release: 0.2.10
NEWS | 11 +++++++++++
configure.ac | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
commit 66299f05ed419b5b6ee5495f8ee5e8d670bfd1c4
Author: Albert Astals Cid
Date: Fri Sep 25 01:47:29 2020 +0200
Use the new api to pass the callbacks
Needs ghostscript >= 9.53
.gitlab-ci.yml | 6 +++---
configure.ac | 4 ++--
libspectre/spectre-device.c | 47 +++++++++++++++++++++++++++------------------
libspectre/spectre-gs.c | 20 ++++---------------
libspectre/spectre-gs.h | 6 ++++--
5 files changed, 41 insertions(+), 42 deletions(-)
commit 4d34d6cfe9bd8fc7b8355a39502374d9d6426ed0
Author: Marek Kasik
Date: Mon Nov 29 16:27:57 2021 +0100
Set alignment for rendering to default
Previous aligning to 32 bytes rendered EPS in wrong way (not always but often).
Setting default alignment which aligns to size of pointer fixes this issue.
The commit which set it to the 32 was talking about alignment of 4 bytes so I guess
that there were bits interchanged with bytes.
Fixes #44
libspectre/spectre-device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 6928e8933e8b6c98c0590985866cc12e7321f491
Author: Albert Astals Cid
Date: Sat Dec 26 12:21:22 2020 +0100
Free the previous user_image in case spectre_presize is called multiple times
libspectre/spectre-device.c | 1 +
1 file changed, 1 insertion(+)
commit 155777e316aa1bbc0f3be9ed7a6e7a9b76b58968
Author: Randy
Date: Thu May 14 08:52:41 2020 +0200
remove version suffix from ghostscript directory
test/ossfuzz.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
commit 5e1a10e97c29c06756e65a97c7f9e23117eb3646
Author: Albert Astals Cid
Date: Wed May 6 22:07:40 2020 +0200
release: 0.2.9
NEWS | 17 +++++++++++++++++
configure.ac | 4 ++--
2 files changed, 19 insertions(+), 2 deletions(-)
commit 8d026495dc62fd4a1f41c95c1eea22589e2b623e
Author: Albert Astals Cid
Date: Sun Apr 26 19:18:04 2020 +0200
Move spectre_document_load_from_stream to spectre-private.h for now
Not ready for the prime time
libspectre/spectre-document.h | 9 ---------
libspectre/spectre-private.h | 9 +++++++++
test/spectre_read_fuzzer.c | 1 +
3 files changed, 10 insertions(+), 9 deletions(-)
commit 3639f1fe932d8374dd482de4e01457afe3e43a34
Author: Albert Astals Cid
Date: Mon Apr 13 15:51:08 2020 +0200
Make sure we don't read uninitialized memory from text
oss-fuzz/21670
libspectre/ps.c | 4 ++++
1 file changed, 4 insertions(+)
commit 465a5c66e5e1ea04a8f70105b1db4ef8051c0428
Author: Albert Astals Cid
Date: Fri Apr 10 19:26:21 2020 +0200
Initialize varibles if reading fails
This way we don't do uninitizlied memory uses later on
oss-fuzz/21638
libspectre/ps.c | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
commit af1cb4cb719dcb94314bbefc78b59ac426b8fed2
Author: Albert Astals Cid
Date: Wed Apr 8 23:52:43 2020 +0200
Fix uninitialized memory read on malformed documents
libspectre/ps.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
commit 48735999ca27fca8f154aa15c078c4576ab64ae5
Author: Albert Astals Cid
Date: Wed Apr 8 23:52:43 2020 +0200
Fix uninitialized memory read on malformed documents
libspectre/ps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
commit dd7168828cf07971adc8c24bab0f3b6e3d28e0c9
Author: Albert Astals Cid
Date: Wed Apr 8 23:09:45 2020 +0200
Fix crash on malformed files
libspectre/ps.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
commit f56ba915e3f125130f131cca8a89580e1990c0e2
Author: Albert Astals Cid
Date: Sat Mar 28 18:59:50 2020 +0100
Fix memory leak
oss-fuzz/21240
libspectre/ps.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
commit c37b6b33d0558fa84936cb7b7f40694282f9c05a
Author: Albert Astals Cid
Date: Sat Mar 28 19:02:54 2020 +0100
CI: use debian testing while unstable is broken
.gitlab-ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 945d39259c0ca1dfd6c594a9d3ed971152313190
Author: Randy
Date: Tue Mar 10 23:48:10 2020 +0100
fix memory leak in ps.c:650
libspectre/ps.c | 1 +
1 file changed, 1 insertion(+)
commit a6329a26cbc8a920cf56531a762bfbf62b3ddc9d
Author: Randy
Date: Tue Mar 10 21:34:26 2020 +0000
Refactor spectre_document_load_from_data() -> _stream()
libspectre/spectre-document.c | 47 ++++++++++---------------------------------
libspectre/spectre-document.h | 16 +++++++--------
test/spectre_read_fuzzer.c | 17 ++++++++++++++--
3 files changed, 33 insertions(+), 47 deletions(-)
commit 567f72a04dcc5e883e708bd2a3a149e818c1c12f
Author: Randy
Date: Sat Mar 7 10:49:20 2020 +0100
fix memory leak in ps.c:603
libspectre/ps.c | 1 +
1 file changed, 1 insertion(+)
commit ebc0c1ef2e36cb50267689cc44338a17d2895725
Author: Randy
Date: Sat Mar 7 10:11:03 2020 +0100
fix NULL-dereference in psscan.c:934
libspectre/ps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 3bff18aa496ff00b9ddd127c83241a4399850ef0
Author: Randy
Date: Tue Mar 3 08:33:22 2020 +0000
fix NULL-dereference in psscan()
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20986
libspectre/ps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 79741b6e1b8abdcb7366d4f35d9bfa041854bfab
Author: Randy
Date: Mon Mar 2 20:58:40 2020 +0000
Fix memory leak
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20283
libspectre/ps.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
commit 836217c48d2b499f9dda2dcc848cf1dc85a4b18a
Author: Randy
Date: Sat Feb 29 10:47:54 2020 +0100
ossfuzz: integrate into build, add entrypoint
test/Makefile.am | 16 +++++++++++++++-
test/README | 9 +++++++++
test/fuzz_main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+), 1 deletion(-)
commit 920c30cf1d4353b28266fc91f88b2ae72e0f5e4f
Author: Randy
Date: Sat Feb 29 10:55:27 2020 +0000
Add spectre_document_load_from_data(), update fuzz target
libspectre/spectre-document.c | 53 +++++++++++++++++++++++++++++++++++++------
libspectre/spectre-document.h | 13 +++++++++++
test/spectre_read_fuzzer.c | 14 +++---------
3 files changed, 62 insertions(+), 18 deletions(-)
commit ca205d084434915127e64a9d54eafd05cdee872b
Author: Randy
Date: Wed Feb 19 14:33:03 2020 +0100
ossfuzz: fix coverage build
test/ossfuzz.sh | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
commit 7ae80bff9ee04793a1c0d59e538da7802f81a43d
Author: Randy
Date: Tue Feb 18 21:33:37 2020 +0000
Refactor code so that psscan() can accept a FILE*, this will enable parsing from fmemopen()'d buffers. I figured this should be merged separately before spectre_document_load_from_data() is added.
libspectre/ps.c | 11 +----------
libspectre/ps.h | 1 +
libspectre/spectre-document.c | 14 +++++++++++++-
test/parser-test.c | 2 +-
4 files changed, 16 insertions(+), 12 deletions(-)
commit bdc1caaeb22832a0dc1f7420a497cd2382d5edd6
Author: Randy
Date: Thu Feb 13 16:43:36 2020 +0100
ossfuzz: add dictionary, update build script
test/ossfuzz.sh | 7 +++++--
test/postscript.dict | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 2 deletions(-)
commit cc41bfe79d2ab2f72a3a11ae1db946f7575e891a
Author: Albert Astals Cid
Date: Sun Jan 5 22:35:10 2020 +0100
Revert "ossfuzz: keep shared libraries after install"
This reverts commit 9b1e58286c7c72baaba55f07bfb42db03240fecf.
test/ossfuzz.sh | 1 +
1 file changed, 1 insertion(+)
commit 9b1e58286c7c72baaba55f07bfb42db03240fecf
Author: Randy
Date: Wed Jan 1 23:15:59 2020 +0100
ossfuzz: keep shared libraries after install
test/ossfuzz.sh | 1 -
1 file changed, 1 deletion(-)
commit 1a367871cbe7dab1a70be0779ba1b0306e41e760
Author: Randy
Date: Sun Dec 8 20:04:20 2019 +0100
fix leak in spectre_device_render()
libspectre/spectre-device.c | 3 +++
1 file changed, 3 insertions(+)
commit ceeeec8ee480c9cce066c0921665ef647bd5c135
Author: Randy
Date: Tue Nov 26 16:07:07 2019 +0100
update ossfuzz.sh
test/ossfuzz.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit a75690875044349b24c521db87db8065da294d16
Author: Randy
Date: Tue Nov 26 15:48:53 2019 +0100
update fuzz target
test/spectre_read_fuzzer.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
test/spectre_read_fuzzer.cc | 46 ------------------------------------------
2 files changed, 49 insertions(+), 46 deletions(-)
commit de4eaa73e94516ba6c8ddda364cf2f59b4eb28ca
Author: Randy
Date: Sun Nov 24 11:42:17 2019 +0100
fix indentation
test/spectre_read_fuzzer.cc | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
commit fc996641b011adbf21e4205a32ac02f6543f5fd4
Author: Randy
Date: Wed Nov 20 12:36:56 2019 +0100
add build script, fuzz target
test/ossfuzz.sh | 20 ++++++++++++++++++++
test/spectre_read_fuzzer.cc | 46 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
commit 90000c9d5c1d0928e02da0a799bb81676589e073
Author: Christian Persch
Date: Sat Oct 20 00:17:47 2018 +0200
spectre-gs: Remove support for old ghostscript
Now that we require a recent ghostscript, we can remove
the support for older versions.
libspectre/spectre-device.c | 9 +++------
libspectre/spectre-gs.c | 21 +++++----------------
2 files changed, 8 insertions(+), 22 deletions(-)
commit 75e154f89565af475ef4c9c9a01a805eadb9405e
Author: Christian Persch
Date: Sat Oct 20 00:17:47 2018 +0200
spectre-gs: Enforce minimum ghostscript version
Ghostscript versions before 9.24 had a critical vulnerability
allowing to escape -dSAFER; refuse to do anything if the version
is less than 9.24.
https://gitlab.freedesktop.org/libspectre/libspectre/issues/25
configure.ac | 2 +-
libspectre/spectre-gs.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
commit 48696f7e724923564dd6c8908afdb7c9d4893f02
Author: Albert Astals Cid
Date: Fri Oct 19 18:03:51 2018 +0200
Make clang happy
ps.c:1875:9: warning: promoted type 'int' of K&R function parameter is not compatible with the parameter type 'char' declared in a previous prototype [-Wknr-promoted-parameter]
char charP;
^
ps.c:197:88: note: previous declaration is here
static char *readlineuntil PT((FileData, long, char **, long *, unsigned int *, char));
^
ps.c:2212:13: warning: promoted type 'int' of K&R function parameter is not compatible with the parameter type 'unsigned short' declared in a previous prototype [-Wknr-promoted-parameter]
PS_WORD val;
^
ps.c:206:48: note: previous declaration is here
static PS_WORD reorder_word PT((PS_WORD));
libspectre/ps.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
commit 92a478f926ded10dc15726e31998d041d6ff7794
Author: Christian Persch
Date: Fri Oct 19 21:07:36 2018 +0200
Hide internal symbols
Use hidden visibility by default and make only the public API
symbols visible.
https://gitlab.freedesktop.org/libspectre/libspectre/issues/30
configure.ac | 33 +++++++++++++++++++++++++++++++++
libspectre/Makefile.am | 3 +++
libspectre/spectre-document.h | 20 ++++++++++++++++++++
libspectre/spectre-exporter.h | 6 +++++-
libspectre/spectre-macros.h | 8 ++++++++
libspectre/spectre-page.h | 8 ++++++++
libspectre/spectre-render-context.h | 14 ++++++++++++++
libspectre/spectre-status.h | 1 +
test/Makefile.am | 12 ++++++++++--
9 files changed, 102 insertions(+), 3 deletions(-)
commit 17c72f0560bf079cbd0e6df5dd3445cb8f05660a
Author: Albert Astals Cid
Date: Fri Oct 19 17:41:01 2018 +0200
Make gcc happy about switch fallthrough
libspectre/ps.c | 1 +
1 file changed, 1 insertion(+)
commit 818ff44e1e1e665efeeccc2a58c6453949368638
Author: Albert Astals Cid
Date: Sat Oct 13 00:39:28 2018 +0200
Fix crash with malformed document
Closes issue #14
libspectre/ps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit f4f8cb65e01e62c86354a6697307f9549136a66e
Author: Albert Astals Cid
Date: Sat Oct 13 00:08:49 2018 +0200
Add basic CI
.gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
commit f88d2c259242936bbc3c74bf43107626c0f5ad61
Author: Caolán McNamara
Date: Fri Jan 13 09:56:14 2017 +0000
state what lib is printing the error
and where it originally came from
so its clear where
"undefined -21" came from in cases like
https://bugzilla.gnome.org/show_bug.cgi?id=678500
https://bugs.freedesktop.org/show_bug.cgi?id=99395
libspectre/spectre-gs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
commit 1cdaa3fa1da8e0b3b1d2df8cfa5027d2a7b24418
Author: Carlos Garcia Campos
Date: Sat Jul 2 10:07:09 2016 +0200
release: 0.2.8
NEWS | 16 ++++++++++++++++
configure.ac | 4 ++--
2 files changed, 18 insertions(+), 2 deletions(-)
commit 974f3ef9dd389448fbe81c4a4f19d679d4d30374
Author: Carlos Garcia Campos
Date: Sat Jul 2 10:06:13 2016 +0200
build: Fix make distcheck
Makefile.am | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
commit 38bb113d18ac0e7872dfac311295c8f42e9a260f
Author: Marek Kasik
Date: Wed Jan 7 18:35:16 2015 +0100
Rotate documents correctly with newer libgs versions
Rotate result of rendering given by ghostscript when libgs >= 9.08.
https://bugs.freedesktop.org/show_bug.cgi?id=76450
libspectre/spectre-device.c | 108 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 106 insertions(+), 2 deletions(-)
commit 316168c4dc24932a832a66a915be01a22906bacd
Author: Carlos Garcia Campos
Date: Thu Jun 23 17:40:35 2016 +0200
spectre-gs: Add a method to get the libgs version
libspectre/spectre-gs.c | 11 +++++++++++
libspectre/spectre-gs.h | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
commit 34a52f30400aab1c21c69c31122d496751d7d99e
Author: Carlos Garcia Campos
Date: Sat Apr 2 11:15:38 2016 +0200
Fix the build with Ghostscript >= 9.18
libspectre/spectre-gs.c | 11 +++++++++++
1 file changed, 11 insertions(+)
commit ebbff50f9a32725e6533130e235ebabbb1cd6e84
Author: Carlos Garcia Campos
Date: Wed Sep 3 17:20:33 2014 +0200
Revert "Rotate documents correctly"
This reverts commit c0b7b178d455f00b21e6317376ab49324bddb340.
libspectre/spectre-device.c | 58 +++++++++++++---------------------
libspectre/spectre-exporter-pdf.c | 4 ---
libspectre/spectre-gs.c | 65 ++++++---------------------------------
libspectre/spectre-gs.h | 6 +---
4 files changed, 31 insertions(+), 102 deletions(-)
commit c0b7b178d455f00b21e6317376ab49324bddb340
Author: Marek Kasik
Date: Mon Jun 9 13:26:53 2014 +0200
Rotate documents correctly
Set correct size of rendered images when a rotation
is requested. Use "rotate" command to rotate documents
instead of setting of "Orientation". Adjust offsets
accordingly. Don't execute "setpagedevice" when rendering
to "display" device.
https://bugs.freedesktop.org/show_bug.cgi?id=76450
libspectre/spectre-device.c | 58 +++++++++++++++++++++-------------
libspectre/spectre-exporter-pdf.c | 4 +++
libspectre/spectre-gs.c | 65 +++++++++++++++++++++++++++++++++------
libspectre/spectre-gs.h | 6 +++-
4 files changed, 102 insertions(+), 31 deletions(-)
commit 3e104448c4f532802dfaf30a42618bc09be99159
Author: Carlos Garcia Campos
Date: Sat Nov 3 10:54:36 2012 +0100
build: Use CPPFLAGS instead of CFLAGS for compiling flags
https://bugs.freedesktop.org/show_bug.cgi?id=56481
libspectre/Makefile.am | 5 +----
test/Makefile.am | 10 ++++------
2 files changed, 5 insertions(+), 10 deletions(-)
commit 6f6a8c2f9d921185a1403be27ec013d9f48a8cbf
Author: Carlos Garcia Campos
Date: Sat Nov 3 10:45:01 2012 +0100
ps: Fix comparison between signed and unsigned compile warning
https://bugs.freedesktop.org/show_bug.cgi?id=56476
libspectre/ps.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
commit e02ef42c0725935fce74415cc48fa5f50ec6d023
Author: Carlos Garcia Campos
Date: Wed Aug 8 17:21:55 2012 +0200
Update for release 0.2.7
NEWS | 10 ++++++++++
configure.ac | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
commit b2d0de2665baead41e86f40fb51260e9a94c2210
Author: Carlos Garcia Campos
Date: Wed Aug 8 16:43:57 2012 +0200
build: Don't use global INCLUDES var in makefiles
libspectre/Makefile.am | 12 ++++++------
test/Makefile.am | 19 +++++++++++++------
2 files changed, 19 insertions(+), 12 deletions(-)
commit 8ffd9185f81cb8337cece4c8e3672d0e6a97e935
Author: Marek Kasik
Date: Wed Nov 24 15:54:14 2010 +0100
Allocate at least 1 page in doc->pages
Allocate at least 1 page if there are no %%Pages: or %%Page: comments
in the PS file (#31512).
libspectre/ps.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
commit 7500e4d1ae85ecf9f61b1446e07ebb887118757c
Author: Carlos Garcia Campos
Date: Sat Oct 30 15:55:18 2010 +0200
Fix a crash with documents containing an invalid %%Pages: comment
When failed to allocate memory for pages because of invalid %%Pages:
comment, set maxpages to 0 to ignore the comment. Problem spotted
by Marek Kasik. Fixes bug #30867.
libspectre/ps.c | 2 ++
1 file changed, 2 insertions(+)
commit 213dfcef5ee9e44f0f9e9026222beb0e69a4257d
Author: Carlos Garcia Campos
Date: Thu Jun 10 13:20:21 2010 +0200
Update for release 0.2.6
NEWS | 19 +++++++++++++++++++
configure.ac | 4 ++--
2 files changed, 21 insertions(+), 2 deletions(-)
commit b389eb07cf793fec3a7c7cd4c75a2752a72f51ad
Author: Carlos Garcia Campos
Date: Tue Jun 1 14:39:54 2010 +0200
Fix rendering of files with doseps header and EOF comment missing
Fixes bug #27830.
libspectre/ps.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
commit 64405a78fdce7e028d91bdc68ab497d4c8a53bf0
Author: Carlos Garcia Campos
Date: Tue Jun 1 11:35:34 2010 +0200
Add --enable-iso-c configure option disabled by default
It uses, if available, -ansic and -pedantic flags. See bug #27735
configure.ac | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
commit 8e28de56006377184aa2ac2220afd82c9a2431d1
Author: Carlos Garcia Campos
Date: Tue Jun 1 11:09:57 2010 +0200
Remove unneeded #include
See bug #27734.
libspectre/spectre-device.c | 1 -
1 file changed, 1 deletion(-)
commit 4bcf3ff07f962712f71b2dc6dbd5f7e8f95e566a
Author: Carlos Garcia Campos
Date: Tue Jun 1 11:01:29 2010 +0200
Make Ghostscript not look first in the current directory for library files
libspectre/spectre-device.c | 3 ++-
libspectre/spectre-exporter-pdf.c | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
commit ee8c5a19138f33dd4c40da4e3def16eba48eccc1
Author: Carlos Garcia Campos
Date: Sun Apr 18 19:01:01 2010 +0200
Update for release 0.2.5
NEWS | 16 ++++++++++++++++
configure.ac | 4 ++--
2 files changed, 18 insertions(+), 2 deletions(-)
commit 233babb7bf516aac10b853785b8d22c7d6fa777e
Author: Carlos Garcia Campos
Date: Sun Apr 18 18:28:34 2010 +0200
Use %I64x format for DisplayHandle on Windows 64 bits
libspectre/spectre-device.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
commit ce55aa1110f3b933943a92ecd0a948d017cdb492
Author: Carlos Garcia Campos
Date: Tue Apr 6 17:24:59 2010 +0200
Fix a crash in pdf exporter when rendering fails
libspectre/spectre-exporter-pdf.c | 6 ++++++
1 file changed, 6 insertions(+)
commit 35aa9dfac2631de24a40d95d1469acb52f379249
Author: Carlos Garcia Campos
Date: Sun Mar 28 13:18:38 2010 +0200
Use the correct format string for DisplayHandle arg depending on the platform
libspectre/spectre-device.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
commit 75a268029e803a34ce93b7094809ee15be0a9c08
Author: Carlos Garcia Campos
Date: Sun Feb 21 20:49:15 2010 +0100
Update for release 0.2.4
NEWS | 15 +++++++++++++++
configure.ac | 4 ++--
2 files changed, 17 insertions(+), 2 deletions(-)
commit 6dc6c41ba977e8bee0fd71f3db4c3c92287ee71f
Author: Carlos Garcia Campos
Date: Sun Feb 21 17:49:05 2010 +0100
Fix compile warning
libspectre/spectre-render-context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 51c6a92e7bf7261a19eb1d9e776ce11957c213c4
Author: Carlos Garcia Campos
Date: Sun Feb 21 17:46:17 2010 +0100
Use AM_SILENT_RULES when available
autogen.sh | 10 +++++-----
configure.ac | 2 ++
2 files changed, 7 insertions(+), 5 deletions(-)
commit 8a720825f6ee77d6945833c59609f6a9141dad19
Author: Carlos Garcia Campos
Date: Sun Feb 21 17:24:54 2010 +0100
Use spectre_gs_process() instead of spectre_gs_send_page() in pdf exporter
When rendering with the display device we use a new gs instance for
every page and we have to process prolog, setup and trailer for every
page. PDF exporter is different, we use a single gs instance created in
exporter_pdf_begin() and destroyed in exporter_pdf_end(). Now we use
spectre_gs_process() to send prolog and setup in begin() and trailer in
end() so that we just send the page contents in do_page().
Fixes bug #26592.
libspectre/spectre-exporter-pdf.c | 43 ++++++++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 3 deletions(-)
commit 18a4e6d9746614227b404df4399471d2a2858f1f
Author: Carlos Garcia Campos
Date: Sun Feb 21 17:22:07 2010 +0100
Make spectre_gs_process() public so that it can be used by exporters
It's public in the internal private API
libspectre/spectre-gs.c | 2 +-
libspectre/spectre-gs.h | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
commit d25e37b5e52d83af50924a548da6f10983960735
Author: Carlos Garcia Campos
Date: Sun Feb 21 13:22:18 2010 +0100
Ignore page order parameter of %%Pages if there's a %%PageOrder comment
It caused problems in documents where there's a %%PageOrder after the
%%Pages comment. See evince bug https://bugzilla.gnome.org/show_bug.cgi?id=585436
libspectre/ps.c | 3 ---
1 file changed, 3 deletions(-)
commit b039f45f826e4516b8717d0bcfbee692fab4d385
Author: Hib Eris