*** empty log message ***

DEVEL_2_0_BRANCH-1
Oliver Rauch 2000-11-10 06:47:25 +00:00
rodzic 86e64140b7
commit 1c07f937d7
58 zmienionych plików z 17042 dodań i 0 usunięć

59
Makefile.in 100644
Wyświetl plik

@ -0,0 +1,59 @@
SHELL = /bin/sh
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = .
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
sanedatadir = @datadir@/sane
MKDIR = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
@SET_MAKE@
SUBDIRS = lib sanei src doc
all: all-recursive
install: install-recursive
uninstall: uninstall-recursive
clean: clean-recursive
distclean: clean distclean-recursive
rm -f *~ include/*~ include/sane/*~ *.log *.bak libtool
rm -f include/sane/config.h Makefile config.cache config.status
rm -f intl/Makefile
depend: depend-recursive
all-recursive install-recursive uninstall-recursive clean-recursive distclean-recursive \
depend-recursive:
for subdir in $(SUBDIRS); do \
target=`echo $@ | sed s/-recursive//`; \
echo making $$target in $$subdir; \
(cd $$subdir && $(MAKE) $$target) \
|| case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
.PHONY: all clean depend \
all-recursive install-recursive clean-recursive depend-recursive

1062
aclocal.m4 vendored 100644

Plik diff jest za duży Load Diff

883
config.guess vendored 100755
Wyświetl plik

@ -0,0 +1,883 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
# The master version of this file is at the FSF in /home/gd/gnu/lib.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit system type (host/target name).
#
# Only a few systems have been added to this list; please add others
# (but try to keep the structure clean).
#
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 8/24/94.)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
cat <<EOF >dummy.s
.globl main
.ent main
main:
.frame \$30,0,\$26,0
.prologue 0
.long 0x47e03d80 # implver $0
lda \$2,259
.long 0x47e20c21 # amask $2,$1
srl \$1,8,\$2
sll \$2,2,\$2
sll \$0,3,\$0
addl \$1,\$0,\$0
addl \$2,\$0,\$0
ret \$31,(\$26),1
.end main
EOF
${CC-cc} dummy.s -o dummy 2>/dev/null
if test "$?" = 0 ; then
./dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
;;
15)
UNAME_MACHINE="alphaev5"
;;
14)
UNAME_MACHINE="alphaev56"
;;
10)
UNAME_MACHINE="alphapca56"
;;
16)
UNAME_MACHINE="alphaev6"
;;
esac
fi
rm -f dummy.s dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-cbm-sysv4
exit 0;;
amiga:NetBSD:*:*)
echo m68k-cbm-netbsd${UNAME_RELEASE}
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc64:OpenBSD:*:*)
echo mips64el-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hkmips:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
arm32:NetBSD:*:*)
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
SR2?01:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit 0 ;;
NILE:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
i86pc:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit 0 ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit 0 ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
atari*:NetBSD:*:*)
echo m68k-atari-netbsd${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3*:NetBSD:*:*)
echo m68k-sun-netbsd${UNAME_RELEASE}
exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:NetBSD:*:*)
echo m68k-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
2020:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
sed 's/^ //' << EOF >dummy.c
int main (argc, argv) int argc; char **argv; {
#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-cc} dummy.c -o dummy \
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit 0 ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit 0 ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit 0 ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else echo i586-dg-dgux${UNAME_RELEASE}
fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit 0 ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit 0 ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit 0 ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit 0 ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit 0 ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i?86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
sed 's/^ //' << EOF >dummy.c
#include <sys/systemcfg.h>
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
*:AIX:*:4)
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=4.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit 0 ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit 0 ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit 0 ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit 0 ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit 0 ;;
9000/[3478]??:HP-UX:*:*)
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
9000/8?? ) HP_ARCH=hppa1.0 ;;
esac
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
sed 's/^ //' << EOF >dummy.c
#include <unistd.h>
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-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit 0 ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit 0 ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
i?86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit 0 ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit 0 ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
exit 0 ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F300:UNIX_System_V:*:*)
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
F301:UNIX_System_V:*:*)
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
exit 0 ;;
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
i?86:BSD/386:*:* | *:BSD/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
*:NetBSD:*:*)
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
i*:CYGWIN*:*)
echo i386-pc-cygwin32
exit 0 ;;
i*:MINGW*:*)
echo i386-pc-mingw32
exit 0 ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin32
exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us.
ld_help_string=`ld --help 2>&1`
ld_supported_emulations=`echo $ld_help_string \
| sed -ne '/supported emulations:/!d
s/[ ][ ]*/ /g
s/.*supported emulations: *//
s/ .*//
p'`
case "$ld_supported_emulations" in
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
esac
if test "${UNAME_MACHINE}" = "alpha" ; then
sed 's/^ //' <<EOF >dummy.s
.globl main
.ent main
main:
.frame \$30,0,\$26,0
.prologue 0
.long 0x47e03d80 # implver $0
lda \$2,259
.long 0x47e20c21 # amask $2,$1
srl \$1,8,\$2
sll \$2,2,\$2
sll \$0,3,\$0
addl \$1,\$0,\$0
addl \$2,\$0,\$0
ret \$31,(\$26),1
.end main
EOF
LIBC=""
${CC-cc} dummy.s -o dummy 2>/dev/null
if test "$?" = 0 ; then
./dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
;;
15)
UNAME_MACHINE="alphaev5"
;;
14)
UNAME_MACHINE="alphaev56"
;;
10)
UNAME_MACHINE="alphapca56"
;;
16)
UNAME_MACHINE="alphaev6"
;;
esac
objdump --private-headers dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
LIBC="libc1"
fi
fi
rm -f dummy.s dummy
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >dummy.c <<EOF
main(argc, argv)
int argc;
char *argv[];
{
#ifdef __MIPSEB__
printf ("%s-unknown-linux-gnu\n", argv[1]);
#endif
#ifdef __MIPSEL__
printf ("%sel-unknown-linux-gnu\n", argv[1]);
#endif
return 0;
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
else
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
# If ld does not provide *any* "supported emulations:"
# that means it is gnuoldld.
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
case "${UNAME_MACHINE}" in
i?86)
VENDOR=pc;
;;
*)
VENDOR=unknown;
;;
esac
# Determine whether the default compiler is a.out or elf
cat >dummy.c <<EOF
#include <features.h>
main(argc, argv)
int argc;
char *argv[];
{
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
# else
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
# endif
# else
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
# endif
#else
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
#endif
return 0;
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
i?86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
i?86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
pc:*:*:*)
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
paragon:*:*:*)
echo i860-intel-osf1
exit 0 ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit 0 ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
m68*:LynxOS:2.*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i?86:LynxOS:2.*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit 0 ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit 0 ;;
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit 0 ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
news*:NEWS-OS:*:6*)
echo mips-sony-newsos6
exit 0 ;;
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
cat >dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
#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 <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
printf ("%s-next-nextstep%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)
printf ("vax-dec-bsd\n"); exit (0);
#else
printf ("vax-dec-ultrix\n"); exit (0);
#endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit 0 ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
c34*)
echo c34-convex-bsd
exit 0 ;;
c38*)
echo c38-convex-bsd
exit 0 ;;
c4*)
echo c4-convex-bsd
exit 0 ;;
esac
fi
#echo '(Unable to guess system type)' 1>&2
exit 1

958
config.sub vendored 100755
Wyświetl plik

@ -0,0 +1,958 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
if [ x$1 = x ]
then
echo Configuration name missing. 1>&2
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
echo "or $0 ALIAS" 1>&2
echo where ALIAS is a recognized configuration type. 1>&2
exit 1
fi
# First pass through any local machine types.
case $1 in
*local*)
echo $1
exit 0
;;
*)
;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
linux-gnu*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple)
os=
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco5)
os=sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
| arme[lb] | pyramid | mn10200 | mn10300 \
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
| mipstx39 | mipstx39el \
| sparc | sparclet | sparclite | sparc64 | v850)
basic_machine=$basic_machine-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i[3456]86)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
| xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
| sparc64-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mipstx39-* | mipstx39el-* \
| f301-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-cbm
;;
amigaos | amigados)
basic_machine=m68k-cbm
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | ymp)
basic_machine=ymp-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[ctj]90-cray)
basic_machine=c90-cray
os=-unicos
;;
crds | unos)
basic_machine=m68k-crds
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i[3456]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i[3456]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i[3456]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i[3456]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
miniframe)
basic_machine=m68000-convergent
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
np1)
basic_machine=np1-gould
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5)
basic_machine=i586-intel
;;
pentiumpro | p6)
basic_machine=i686-intel
;;
pentium-* | p5-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
k5)
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
basic_machine=i586-amd
;;
nexen)
# We don't have specific support for Nexgen yet, so just call it a Pentium
basic_machine=i586-nexgen
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=rs6000-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
mips)
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sparc)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
os=-nextstep2
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
# For sys5.3 apollo
-sys5.3)
os=-sysv3
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-xenix)
os=-xenix
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
*-acorn)
os=-riscix1.2
;;
arm*-semi)
os=-aout
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-ibm)
os=-aix
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f301-fujitsu)
os=-uxpv
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-aix*)
vendor=ibm
;;
-hpux*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os

109
doc/Makefile.in 100644
Wyświetl plik

@ -0,0 +1,109 @@
SHELL = /bin/sh
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
configdir = ${sysconfdir}/sane.d
sanedatadir = ${datadir}/sane
docdir=$(prefix)/doc/sane-@VERSION@
MKDIR = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
LN_S = @LN_S@
@SET_MAKE@
SECT1 = xscanimage.1 xcam.1
MANPAGES = $(SECT1)
DOCS = sane.ps sane.dvi
LATEX = TEXINPUTS=$(srcdir):$$TEXINPUTS latex
DLH = TEXINPUTS=$(srcdir):$$TEXINPUTS dlh
MAN2HTML= nroff -man |\
man2html -compress -title $${page} -cgiurl '$$title.$$section.html'|\
sed 's,<BODY>,<BODY BGCOLOR=\#FFFFFF TEXT=\#000000><H1 ALIGN=CENTER><IMG SRC="../sane.png" HEIGHT=117 WIDTH=346></H1>,'
all: $(MANPAGES)
%.1 %.5: %.man
sed -e 's|@DATADIR@|$(datadir)|g' \
-e 's|@CONFIGDIR@|$(configdir)|g' \
-e 's|@LIBDIR@|$(libdir)|g' \
-e 's|@BINDIR@|$(bindir)|g' \
-e 's|@SBINDIR@|$(sbindir)|g' $^ >$@
install: $(MANPAGES)
$(MKDIR) $(mandir)/man1 $(mandir)/man5
@for page in $(SECT1); do \
echo installing $${page} in $(mandir)/man1/$${page}...; \
$(INSTALL_DATA) $${page} $(mandir)/man1/$${page} || exit 1; \
done
install-docs: ps
$(MKDIR) $(docdir)
@for doc in $(DOCS); do \
echo installing $${doc} in $(docdir)/$${doc}...; \
$(INSTALL_DATA) $${doc} $(docdir)/$${doc} || exit 1; \
done
docs: ps html
sane.ind:
touch sane.ind
$(LATEX) $(srcdir)/sane
makeindex sane.idx
ps: sane.ind
-rm -f figs; $(LN_S) $(srcdir)/figs .
$(LATEX) $(srcdir)/sane
$(LATEX) $(srcdir)/sane
dvips sane.dvi -o sane.ps
html: sane.ind sane-backends-html html-man
$(DLH) $(srcdir)/sane.tex
sane-backends-html:
cd $(top_srcdir)/backend \
&& emacs -batch --load $(top_srcdir)/tools/sane-desc.el \
-f sane-desc-doit
html-man: $(MANPAGES)
@for page in $(MANPAGES); do \
echo "translating $${page} to $${page}.html..."; \
cat $${page} | $(MAN2HTML) > $${page}.html; \
done
sane.tex: sane.ind
clean:
rm -f *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky *.blg *.idx *.cb
rm -f *.ilg
distclean: clean
rm -f $(MANPAGES)
rm -f Makefile *~
rm -f *.lot *.lof *.ind
rm -f sane.dvi sane.ps
rm -f sane/*.html sane/*.gif
-rmdir sane
depend:
.PHONY: all install depend clean ps html htmlman sane-backends-html

BIN
doc/sane.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 10 KiB

1869
doc/sane.tex 100644

Plik diff jest za duży Load Diff

24
doc/xcam.man 100644
Wyświetl plik

@ -0,0 +1,24 @@
.TH xcam 1 "24 Jun 2000"
.IX xcam
.SH NAME
xcam - a graphical camera frontend for SANE
.SH SYNOPSIS
.B xcam
.SH DESCRIPTION
Should be straightforward to use. Just be sure to use a very recent
version of GTK.
.SH FILES
.TP
.I $HOME/.sane/xcam/devicename.rc
For each device, there is one rc-file that holds the saved settings
for that particular device. Normally, this file should not be
manipulated directly. Instead, the user should use the
.B xcam
interface to select appropriate values and then save the device
settings using the "Preferences->Save as default settings" menubar entry.
.SH "SEE ALSO"
xscanimage(1), scanimage(1), sane\-dll(5) and the backend manpages
.SH AUTHOR
David Mosberger-Tang

135
doc/xscanimage.man 100644
Wyświetl plik

@ -0,0 +1,135 @@
.TH xscanimage 1 "11 Aug 2000"
.IX xscanimage
.SH NAME
xscanimage - scan an image
.SH SYNOPSIS
.B xscanimage
.RB [ --display
.IR d ]
.RB [ --no-xshm ]
.RB [ --sync ]
.IR n ]
.RI [ devicename ]
.SH DESCRIPTION
.B xscanimage
provides a graphical user-interface to control an image
acquisition device such as a flatbed scanner or a camera. It allows
previewing and scanning invidual images and can be invoked either
directly from the command-line or through The GIMP image manipulation
program. In the former case,
.B xscanimage
acts as a stand-alone program that saves acquired images in a suitable
PNM format (PBM for black-and-white images, PGM for grayscale images,
and PPM for color images). In the latter case, the images are
directly passed to The GIMP for further processing.
.B xscanimage
accesses image acquisition devices through the SANE (Scanner Access
Now Easy) interface. The list of available devices depends on
installed hardware and configuration. When invoked without an
explicit devicename argument,
.B xscanimage
presents a dialog listing all known and available devices. To access
an available device that is not known to the system, the devicename
must be specified explicitly. The format of devicename is
backendname:devicefile (eg umax:/dev/sga).
.SH RUNNING UNDER THE GIMP
To run
.B xscanimage
under the
.BR gimp (1),
simply copy it to one of the
.BR gimp (1)
plug-ins directories. If you want to conserve disk-space, you can
create a symlink instead. For example, for gimp-1.0.x the command
.PP
ln -s @BINDIR@/xscanimage ~/.gimp/plug-ins/
.PP
and for gimp-1.1.x the command
.PP
ln -s @BINDIR@/xscanimage ~/.gimp-1.1/plug-ins/
.PP
adds a symlink for the
.B xscanimage
binary to the user's plug-ins directory. After creating this symlink,
.B xscanimage
will be queried by
.BR gimp (1)
the next time it's invoked. From then on,
.B xscanimage
can be invoked through "Xtns->Acquire Image->Device dialog..." menu entry.
You'll also find that the "Xtns->Acquire Image" menu contains short-cuts
to the SANE devices that were available at the time the
.B xscanimage
was queried. For example, the first PNM pseudo-device is typically
available as the short-cut "Xtns->Acquire Image->pnm:0".
Note that
.BR gimp (1)
caches these short-cuts in ~/.gimp/pluginrc. Thus, when the list of
available devices changes (e.g., a new scanner is installed), then it
is typically desirable to rebuild this cache. To do this, you can
either
.BR touch (1)
the
.B xscanimage
binary (e.g., "touch @BINDIR@/xscanimage") or delete the plug-ins cache
(e.g., "rm ~/.gimp/plug-ins"). Either way, invoking
.BR gimp (1)
afterwards will cause the pluginrc to be rebuilt.
.SH OPTIONS
.PP
The
.B --display
flag selects the X11 display used to present the graphical user-interface
(see
.BR X (1)
for details).
.PP
The
.B --no-xshm
flag requests not to use shared memory images. Shared memory images
usually enhance performance but cause problems with some buggy X11
servers. Unless your X11 server dies when running this program, there
is no need or advantage to specify this flag.
.PP
The
.B --sync
flag requests a synchronous connection with the X11 server. This is for
debugging purposes only.
.SH FILES
.TP
.I $HOME/.sane/xscanimage/xscanimage.rc
This files holds the user preferences. Normally, this file should not
be manipulated directly. Instead, the user should customize the
program through the "Preferences" dialog.
.TP
.I $HOME/.sane/xscanimage/devicename.rc
For each device, there is one rc-file that holds the saved settings
for that particular device. Normally, this file should not be
manipulated directly. Instead, the user should use the
.B xscanimage
interface to select appropriate values and then save the device
settings using the "Preferences->Save Device Settings" menubar entry.
.TP
.I $HOME/.sane/preview-devicename.ppm
After acquiring a preview,
.B xscanimage
normally saves the preview image in this device-specific file. Thus,
next time the program is started up, the program can present the old
preview image. This feature can be turned off through the
"Preferences->Preview Options..." dialog.
.TP
.I @DATADIR@/sane-style.rc
This system-wide file controls the aspects of the user-interface such
as colors and fonts. It is a GTK style file and provides fine control
over the visual aspects of the user-interface.
.TP
.I $HOME/.sane/sane-style.rc
This file serves the same purpose as the system-wide style file. If
present, it takes precedence over the system wide style file.
.SH "SEE ALSO"
gimp(1), scanimage(1), sane-scsi(5), sane\-dll(5), sane\-net(5),
sane\-"backendname"(5)
.SH AUTHOR
Tristan Tarrant, Andreas Beck, and David Mosberger

129
include/getopt.h 100644
Wyświetl plik

@ -0,0 +1,129 @@
/* Declarations for getopt.
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#if defined (__STDC__) && __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */

47
include/lalloca.h 100644
Wyświetl plik

@ -0,0 +1,47 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 The Free Software Foundation
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This file implements a dynamic linking based SANE meta backend. It
allows managing an arbitrary number of SANE backends by using
dynamic linking to load backends on demand. */
#ifndef lalloca_h
#define lalloca_h
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
# if __STDC__
void *alloca ();
# else
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#endif /* lalloca_h */

Wyświetl plik

@ -0,0 +1,342 @@
#ifndef SANE_CONFIG_H
#define SANE_CONFIG_H
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
#undef _ALL_SOURCE
#endif
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to empty if the keyword does not work. */
#undef const
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define if on MINIX. */
#undef _MINIX
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define if the system does not provide POSIX.1 features except
with this defined. */
#undef _POSIX_1_SOURCE
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define to `unsigned char' if <sys/types.h> doesn't define. */
#undef u_char
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
#undef u_int
/* Define to `unsigned long' if <sys/types.h> doesn't define. */
#undef u_long
/* Define to `long' if <sys/types.h> doesn't define. */
#undef ssize_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
/* Define scsireq_t as `struct scsireq' if necessary. */
#undef scsireq_t
/* Define to the return type of signal handlers. */
#undef RETSIGTYPE
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if NLS is requested. */
#undef ENABLE_NLS
/* Define as 1 if you have catgets and don't want to use GNU gettext. */
#undef HAVE_CATGETS
/* Define as 1 if you have gettext and don't want to use GNU gettext. */
#undef HAVE_GETTEXT
/* Define if your locale.h file contains LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define to the name of the distribution. */
#undef PACKAGE
/* The concatenation of the strings PACKAGE, "-", and VERSION. */
#undef PACKAGE_VERSION
/* Define to the version of the distribution. */
#undef VERSION
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT
/* Define if you have the __argz_next function. */
#undef HAVE___ARGZ_NEXT
/* Define if you have the __argz_stringify function. */
#undef HAVE___ARGZ_STRINGIFY
/* Define if you have the dcgettext function. */
#undef HAVE_DCGETTEXT
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the atexit function. */
#undef HAVE_ATEXIT
/* Define if you have the ioperm function. */
#undef HAVE_IOPERM
/* Define if you have the mkdir function. */
#undef HAVE_MKDIR
/* Define if you have the munmap function. */
#undef HAVE_MUNMAP
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
/* Define if you have the scsireq_enter function. */
#undef HAVE_SCSIREQ_ENTER
/* Define if you have the sigprocmask function. */
#undef HAVE_SIGPROCMASK
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the stpcpy function. */
#undef HAVE_STPCPY
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strncasecmp function. */
#undef HAVE_STRNCASECMP
/* Define if you have the strndup function. */
#undef HAVE_STRNDUP
/* Define if you have the strftime function. */
#undef HAVE_STRFTIME
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the strsep function. */
#undef HAVE_STRSEP
/* Define if you have the strtod function. */
#undef HAVE_STRTOD
/* Define if you have the valloc function. */
#undef HAVE_VALLOC
/* Define if you have the snprintf function. */
#undef HAVE_SNPRINTF
/* Ignore HAVE_USLEEP under Apollo Domain because the usleep()
implementation in the Sys5.3 environment is broken. */
#ifndef apollo
/* Define if you have the usleep function. */
# undef HAVE_USLEEP
#endif
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <libc.h> header file. */
#undef HAVE_LIBC_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <sys/io.h> header file. */
#undef HAVE_SYS_IO_H
/* Define if you have the <asm/io.h> header file. */
#undef HAVE_ASM_IO_H
/* Define if you have the <scsi.h> header file. */
#undef HAVE_SCSI_H
/* Define if you have the <scsi/sg.h> header file. */
#undef HAVE_SCSI_SG_H
/* Define if you have the "/usr/src/linux/include/scsi/sg.h" header file. */
#undef HAVE__USR_SRC_LINUX_INCLUDE_SCSI_SG_H
/* Define if you have the <sys/dsreq.h> header file. */
#undef HAVE_SYS_DSREQ_H
/* Define if you have the <sys/scsi.h> header file. */
#undef HAVE_SYS_SCSI_H
/* Define if you have the <sys/scsi/targets/scgio.h> header file. */
#undef HAVE_SYS_SCSI_TARGETS_SCGIO_H
/* Define if you have the <sys/scsi/sgdefs.h> header file. */
#undef HAVE_SYS_SCSI_SGDEFS_H
/* Define if you have the <sys/scsicmd.h> header file. */
#undef HAVE_SYS_SCSICMD_H
/* Define if you have the <sys/scsiio.h> header file. */
#undef HAVE_SYS_SCSIIO_H
/* Define if you have the <sys/scanio.h> header file. */
#undef HAVE_SYS_SCANIO_H
/* Define if you have the <apollo/scsi.h> header file. */
#undef HAVE_APOLLO_SCSI_H
/* Define if you have the <bsd/dev/scsireg.h> header file. */
#undef HAVE_BSD_DEV_SCSIREG_H
/* Define if you have the <io/cam/cam.h> header file. */
#undef HAVE_IO_CAM_CAM_H
/* Define if you have the <camlib.h> header file. */
#undef HAVE_CAMLIB_H
/* Define if you have the <gscdds.h> header file. */
#undef HAVE_GSCDDS_H
/* Define if you have the <os2.h> header file. */
#undef HAVE_OS2_H
/* Define if you have EMX's sys/hw.h headers. */
#undef HAVE_SYS_HW_H
/* Define if you have sys/types.h. OS/2 wants them before select.h, etc. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <values.h> header file. */
#undef HAVE_VALUES_H
/* Define if you have the i library (-li). */
#undef HAVE_LIBI
/* Define if you have the intl library (-lintl). */
#undef HAVE_LIBINTL
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Define if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the dlopen function. */
#undef HAVE_DLOPEN
/* Define if you have the <dl.h> header file. */
#undef HAVE_DL_H
/* Define if you have the shl_load function. */
#undef HAVE_SHL_LOAD
/* Define if you have the GIMP header files and library. */
#undef HAVE_LIBGIMP_GIMP_H
/* Define if you have the GIMPfeatures header file. */
#undef HAVE_LIBGIMP_GIMPFEATURES_H
/* Define if you have libjpeg. */
#undef HAVE_LIBJPEG
/* Define if you have libz. */
#undef HAVE_LIBZ
/* Define if you have libpng. */
#undef HAVE_LIBPNG
/* Define if you have libtiff. */
#undef HAVE_LIBTIFF
#ifndef HAVE_STRNCASECMP
/* OS/2 needs this */
# define strncasecmp(a, b, c) strnicmp(a, b, c)
#endif
#if defined (__sun) && defined (__GNUC__)
# define _POSIX_SOURCE
# define __EXTENSIONS__
#endif
#endif /* SANE_CONFIG_H */

Wyświetl plik

@ -0,0 +1,42 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1996 David Mosberger-Tang and Andreas Beck
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This file declares SANE internal routines that are provided to
simplify backend implementation. */
#ifndef sanei_h
#define sanei_h
#include <sane/sane.h>
/* A few convenience macros: */
#define STRINGIFY1(x) #x
#define STRINGIFY(x) STRINGIFY1(x)
#define PASTE1(x,y) x##y
#define PASTE(x,y) PASTE1(x,y)
#define NELEMS(a) ((int)(sizeof (a) / sizeof (a[0])))
extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt,
void * value, SANE_Word * info);
extern int sanei_save_values (int fd, SANE_Handle device);
extern int sanei_load_values (int fd, SANE_Handle device);
#endif /* sanei_h */

Wyświetl plik

@ -0,0 +1,106 @@
#include <sane/sanei_debug.h>
#ifdef HAVE_SYS_HW_H
/* OS/2 i/o-port access compatibility macros: */
# define inb(p) _inp8 (p)
# define outb(v,p) _outp8 ((p),(v))
# define ioperm(b,l,o) _portaccess ((b),(b)+(l)-1)
# define HAVE_IOPERM 1
#endif
#ifndef HAVE_OS2_H
#ifndef O_NONBLOCK
# ifdef O_NDELAY
# define O_NONBLOCK O_NDELAY
# else
# define O_NONBLOCK FNDELAY /* last resort */
# endif
#endif
#endif /* HAVE_OS2_H */
#ifdef HAVE_SIGPROCMASK
# define SIGACTION sigaction
#else
/* Just enough backwards compatibility that we get by in the backends
without making handstands. */
# ifdef sigset_t
# undef sigset_t
# endif
# ifdef sigemptyset
# undef sigemptyset
# endif
# ifdef sigfillset
# undef sigfillset
# endif
# ifdef sigaddset
# undef sigaddset
# endif
# ifdef sigdelset
# undef sigdelset
# endif
# ifdef sigprocmask
# undef sigprocmask
# endif
# ifdef SIG_BLOCK
# undef SIG_BLOCK
# endif
# ifdef SIG_UNBLOCK
# undef SIG_UNBLOCK
# endif
# ifdef SIG_SETMASK
# undef SIG_SETMASK
# endif
# define sigset_t int
# define sigemptyset(set) do { *(set) = 0; } while (0)
# define sigfillset(set) do { *(set) = ~0; } while (0)
# define sigaddset(set,signal) do { *(set) |= sigmask (signal); } while (0)
# define sigdelset(set,signal) do { *(set) &= ~sigmask (signal); } while (0)
# define sigaction(sig,new,old) sigvec (sig,new,old)
/* Note: it's not safe to just declare our own "struct sigaction" since
some systems (e.g., some versions of OpenStep) declare that structure,
but do not implement sigprocmask(). Hard to believe, aint it? */
# define SIGACTION sigvec
# define SIG_BLOCK 1
# define SIG_UNBLOCK 2
# define SIG_SETMASK 3
#endif /* !HAVE_SIGPROCMASK */
/* Declare the entry points: */
extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback);
extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool);
extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *);
extern const SANE_Option_Descriptor *
ENTRY(get_option_descriptor) (SANE_Handle, SANE_Int);
extern SANE_Status ENTRY(control_option) (SANE_Handle, SANE_Int, SANE_Action,
void *, SANE_Word *);
extern SANE_Status ENTRY(get_parameters) (SANE_Handle, SANE_Parameters *);
extern SANE_Status ENTRY(start) (SANE_Handle);
extern SANE_Status ENTRY(read) (SANE_Handle, SANE_Byte *, SANE_Int,
SANE_Int *);
extern SANE_Status ENTRY(set_io_mode) (SANE_Handle, SANE_Bool);
extern SANE_Status ENTRY(get_select_fd) (SANE_Handle, SANE_Int *);
extern void ENTRY(cancel) (SANE_Handle);
extern void ENTRY(close) (SANE_Handle);
extern void ENTRY(exit) (void);
#ifndef STUBS
/* Now redirect sane_* calls to backend's functions: */
#define sane_init(a,b) ENTRY(init) (a,b)
#define sane_get_devices(a,b) ENTRY(get_devices) (a,b)
#define sane_open(a,b) ENTRY(open) (a,b)
#define sane_get_option_descriptor(a,b) ENTRY(get_option_descriptor) (a,b)
#define sane_control_option(a,b,c,d,e) ENTRY(control_option) (a,b,c,d,e)
#define sane_get_parameters(a,b) ENTRY(get_parameters) (a,b)
#define sane_start(a) ENTRY(start) (a)
#define sane_read(a,b,c,d) ENTRY(read) (a,b,c,d)
#define sane_set_io_mode(a,b) ENTRY(set_io_mode) (a,b)
#define sane_get_select_fd(a,b) ENTRY(get_select_fd) (a,b)
#define sane_cancel(a) ENTRY(cancel) (a)
#define sane_close(a) ENTRY(close) (a)
#define sane_exit(a) ENTRY(exit) (a)
#endif /* STUBS */

Wyświetl plik

@ -0,0 +1,26 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1996 David Mosberger-Tang and Andreas Beck
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This file declares SANE application interface. See the SANE
standard for a detailed explanation of the interface. */
#ifndef sanei_codec_ascii_h
#define sanei_codec_ascii_h
extern void sanei_codec_ascii_init (Wire *w);
#endif /* sanei_codec_ascii_h */

Wyświetl plik

@ -0,0 +1,26 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1996 David Mosberger-Tang and Andreas Beck
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This file declares SANE application interface. See the SANE
standard for a detailed explanation of the interface. */
#ifndef sanei_codec_bin_h
#define sanei_codec_bin_h
extern void sanei_codec_bin_init (Wire *w);
#endif /* sanei_codec_bin_h */

Wyświetl plik

@ -0,0 +1,93 @@
#ifndef _SANEI_DEBUG_H
#define _SANEI_DEBUG_H
#include <sane/sanei.h>
/* this header file defines:
*
* DBG_INIT() - should be called before any other debug function
* DBG(level, fmt, ...) - prints a message at debug level `level' or higher
* using a printf-like function
* IF_DBG(x) - expands to x if debug support is enabled at
* compile-time, if NDEBUG is defined at compile-time
* this macro expands to nothing
*
* ENTRY(name) - expands to sane_BACKEND_NAME_name
*
* before you include sanei_debug.h, you'll have to define
*
* BACKEND_NAME - the name of your backend without double-quotes
* STUBS - if this is defined, nothing will happen
* DEBUG_DECLARE_ONLY - generate prototypes instead of functions
* DEBUG_NOT_STATIC - doesn't generate static functions
*
*/
#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
#ifdef NDEBUG
extern void sanei_debug_ndebug (int level, const char *msg, ...);
# define DBG_LEVEL (0)
# define DBG_INIT()
# define DBG sanei_debug_ndebug
# define IF_DBG(x)
#else /* !NDEBUG */
# define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
# if defined(BACKEND_NAME) && !defined(STUBS)
# ifdef DEBUG_DECLARE_ONLY
extern int DBG_LEVEL;
# else /* !DEBUG_DECLARE_ONLY */
int DBG_LEVEL = 0;
# endif /* DEBUG_DECLARE_ONLY */
# endif /* BACKEND_NAME && !STUBS */
# define DBG_INIT() \
sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
# define DBG_LOCAL PASTE(DBG_LEVEL,_call)
# ifndef STUBS
# ifdef DEBUG_DECLARE_ONLY
extern void DBG_LOCAL (int level, const char *msg, ...);
# else /* !DEBUG_DECLARE_ONLY */
# include <stdarg.h>
extern void sanei_debug_msg
(int level, int max_level, const char *be, const char *fmt, va_list ap);
# ifndef DEBUG_NOT_STATIC
static
# endif /* !DEBUG_NOT_STATIC */
void
DBG_LOCAL (int level, const char *msg, ...)
{
va_list ap;
va_start (ap, msg);
sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap);
va_end (ap);
}
# endif /* DEBUG_NOT_STATIC */
# endif /* !STUBS */
# define DBG DBG_LOCAL
extern void sanei_init_debug (const char * backend, int * debug_level_var);
# define IF_DBG(x) x
#endif /* NDEBUG */
#endif /* _SANEI_DEBUG_H */

Wyświetl plik

@ -0,0 +1,55 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1998 Christian Bucher
Copyright (C) 1998 Kling & Hautzinger GmbH
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#ifndef sanei_pio_h
#define sanei_pio_h
#include <sys/types.h>
#include <sane/sane.h>
extern SANE_Status sanei_pio_open (const char * dev, int * fd);
extern void sanei_pio_close (int fd);
extern int sanei_pio_read (int fd, u_char * buf, int n);
extern int sanei_pio_write (int fd, const u_char * buf, int n);
#endif /* sanei_pio_h */

Wyświetl plik

@ -0,0 +1,50 @@
#ifdef HAVE_SIGPROCMASK
# define SIGACTION sigaction
#else
/* Just enough backwards compatibility that we get by in the backends
without making handstands. */
# ifdef sigset_t
# undef sigset_t
# endif
# ifdef sigemptyset
# undef sigemptyset
# endif
# ifdef sigfillset
# undef sigfillset
# endif
# ifdef sigaddset
# undef sigaddset
# endif
# ifdef sigdelset
# undef sigdelset
# endif
# ifdef sigprocmask
# undef sigprocmask
# endif
# ifdef SIG_BLOCK
# undef SIG_BLOCK
# endif
# ifdef SIG_UNBLOCK
# undef SIG_UNBLOCK
# endif
# ifdef SIG_SETMASK
# undef SIG_SETMASK
# endif
# define sigset_t int
# define sigemptyset(set) do { *(set) = 0; } while (0)
# define sigfillset(set) do { *(set) = ~0; } while (0)
# define sigaddset(set,signal) do { *(set) |= sigmask (signal); } while (0)
# define sigdelset(set,signal) do { *(set) &= ~sigmask (signal); } while (0)
# define sigaction(sig,new,old) sigvec (sig,new,old)
/* Note: it's not safe to just declare our own "struct sigaction" since
some systems (e.g., some versions of OpenStep) declare that structure,
but do not implement sigprocmask(). Hard to believe, aint it? */
# define SIGACTION sigvec
# define SIG_BLOCK 1
# define SIG_UNBLOCK 2
# define SIG_SETMASK 3
#endif /* !HAVE_SIGPROCMASK */

Wyświetl plik

@ -0,0 +1,33 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 2000 Yuri Dario
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This file declares a _proposed_ internal SANE interface. It was
proposed 2000-02-19 by Yuri Dario to wrap UNIX functions fork(),
kill(), waitpid() and wait(), which are missing on OS/2.
*/
#ifndef sanei_thread_h
#define sanei_thread_h
extern int sanei_thread_begin( void (*start)(void *arg),
void *arg_list);
extern int sanei_thread_kill( int pid, int sig);
extern int sanei_thread_waitpid( int pid, int *stat_loc, int options);
extern int sanei_thread_wait( int *stat_loc);
#endif /* sanei_thread_h */

Wyświetl plik

@ -0,0 +1,104 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Support routines to translate internal datatypes into a wire-format
(used for RPCs and to save/restore options). */
#ifndef sanei_wire_h
#define sanei_wire_h
#include <sys/types.h>
typedef enum
{
WIRE_ENCODE = 0,
WIRE_DECODE,
WIRE_FREE
}
WireDirection;
struct Wire;
typedef void (*WireCodecFunc) (struct Wire *w, void *val_ptr);
typedef ssize_t (*WireReadFunc) (int fd, void * buf, size_t len);
typedef ssize_t (*WireWriteFunc) (int fd, const void * buf, size_t len);
typedef struct Wire
{
int version; /* protocol version in use */
WireDirection direction;
int status;
struct
{
WireCodecFunc w_byte;
WireCodecFunc w_char;
WireCodecFunc w_word;
WireCodecFunc w_string;
}
codec;
struct
{
size_t size;
char *curr;
char *start;
char *end;
}
buffer;
struct
{
int fd;
WireReadFunc read;
WireWriteFunc write;
}
io;
}
Wire;
extern void sanei_w_init (Wire *w, void (*codec_init)(Wire *));
extern void sanei_w_space (Wire *w, size_t howmuch);
extern void sanei_w_void (Wire *w);
extern void sanei_w_byte (Wire *w, SANE_Byte *v);
extern void sanei_w_char (Wire *w, SANE_Char *v);
extern void sanei_w_word (Wire *w, SANE_Word *v);
extern void sanei_w_string (Wire *w, SANE_String *v);
extern void sanei_w_status (Wire *w, SANE_Status *v);
extern void sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v);
extern void sanei_w_value_type (Wire *w, SANE_Value_Type *v);
extern void sanei_w_unit (Wire *w, SANE_Unit *v);
extern void sanei_w_action (Wire *w, SANE_Action *v);
extern void sanei_w_frame (Wire *w, SANE_Frame *v);
extern void sanei_w_range (Wire *w, SANE_Range *v);
extern void sanei_w_range_ptr (Wire *w, SANE_Range **v);
extern void sanei_w_device (Wire *w, SANE_Device *v);
extern void sanei_w_device_ptr (Wire *w, SANE_Device **v);
extern void sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v);
extern void sanei_w_option_descriptor_ptr (Wire *w,
SANE_Option_Descriptor **v);
extern void sanei_w_parameters (Wire *w, SANE_Parameters *v);
extern void sanei_w_array (Wire *w, SANE_Word *len, void **v,
WireCodecFunc w_element, size_t element_size);
extern void sanei_w_set_dir (Wire *w, WireDirection dir);
extern void sanei_w_call (Wire *w, SANE_Word proc_num,
WireCodecFunc w_arg, void *arg,
WireCodecFunc w_reply, void *reply);
extern void sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply);
extern void sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply);
#endif /* sanei_wire_h */

Wyświetl plik

@ -0,0 +1 @@
timestamp

250
install-sh 100755
Wyświetl plik

@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

77
lib/Makefile.in 100644
Wyświetl plik

@ -0,0 +1,77 @@
SHELL = /bin/sh
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
configdir = ${sysconfdir}/sane.d
sanedatadir = ${datadir}/sane
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
INCLUDES = -I. -I$(srcdir) \
-I$(top_builddir)/include/sane -I$(top_srcdir)/include
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
DEFS = @DEFS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
@SET_MAKE@
LIBLIB_OBJS = alloca.o getopt.o getopt1.o strndup.o \
strdup.o strsep.o snprintf.o usleep.o
LIBLIB_LTOBJS = alloca.lo getopt.lo getopt1.lo strndup.lo \
strdup.lo strsep.lo snprintf.lo usleep.lo
TARGETS = $(LIBLIB_OBJS)
TARGETS = liblib.a
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
$(COMPILE) $<
@test -f $@ || $(COMPILE) $<
all: $(TARGETS)
liblib.a: $(LIBLIB_OBJS)
ar r $@ $(LIBLIB_OBJS)
install: all
uninstall:
check:
depend:
makedepend -I. -I../include *.c
clean:
rm -f *.out *.o *.lo *~ *.a *.bak $(TESTPROGRAMS)
rm -rf .libs
distclean: clean
rm -f Makefile
.PHONY: all install check depend clean distclean

493
lib/alloca.c 100644
Wyświetl plik

@ -0,0 +1,493 @@
/* alloca.c -- allocate automatically reclaimed memory
(Mostly) portable public-domain implementation -- D A Gwyn
This implementation of the PWB library alloca function,
which is used to allocate space off the run-time stack so
that it is automatically reclaimed upon procedure exit,
was inspired by discussions with J. Q. Johnson of Cornell.
J.Otto Tennant <jot@cray.com> contributed the Cray support.
There are some preprocessor constants that can
be defined when compiling for your specific system, for
improved efficiency; however, the defaults should be okay.
The general concept of this implementation is to keep
track of all alloca-allocated blocks, and reclaim any
that are found to be deeper in the stack than the current
invocation. This heuristic does not reclaim storage as
soon as it becomes invalid, but it will do so eventually.
As a special case, alloca(0) reclaims storage without
allocating any. It is a good idea to use alloca(0) in
your main control loop, etc. to force garbage collection. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef HAVE_ALLOCA
#ifdef emacs
#include "blockinput.h"
#endif
/* If compiling with GCC 2, this file's not needed. */
#if !defined (__GNUC__) || __GNUC__ < 2
/* If someone has defined alloca as a macro,
there must be some other way alloca is supposed to work. */
#ifndef alloca
#ifdef emacs
#ifdef static
/* actually, only want this if static is defined as ""
-- this is for usg, in which emacs must undefine static
in order to make unexec workable
*/
#ifndef STACK_DIRECTION
you
lose
-- must know STACK_DIRECTION at compile-time
#endif /* STACK_DIRECTION undefined */
#endif /* static */
#endif /* emacs */
/* If your stack is a linked list of frames, you have to
provide an "address metric" ADDRESS_FUNCTION macro. */
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
long i00afunc ();
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
#else
#define ADDRESS_FUNCTION(arg) &(arg)
#endif
#if __STDC__
typedef void *pointer;
#else
typedef char *pointer;
#endif
#define NULL 0
/* Different portions of Emacs need to call different versions of
malloc. The Emacs executable needs alloca to call xmalloc, because
ordinary malloc isn't protected from input signals. On the other
hand, the utilities in lib-src need alloca to call malloc; some of
them are very simple, and don't have an xmalloc routine.
Non-Emacs programs expect this to call xmalloc.
Callers below should use malloc. */
extern pointer malloc ();
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#ifndef STACK_DIRECTION
#define STACK_DIRECTION 0 /* Direction unknown. */
#endif
#if STACK_DIRECTION != 0
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
#else /* STACK_DIRECTION == 0; need run-time code. */
static int stack_dir; /* 1 or -1 once known. */
#define STACK_DIR stack_dir
static void
find_stack_direction ()
{
static char *addr = NULL; /* Address of first `dummy', once known. */
auto char dummy; /* To get stack address. */
if (addr == NULL)
{ /* Initial entry. */
addr = ADDRESS_FUNCTION (dummy);
find_stack_direction (); /* Recurse once. */
}
else
{
/* Second entry. */
if (ADDRESS_FUNCTION (dummy) > addr)
stack_dir = 1; /* Stack grew upward. */
else
stack_dir = -1; /* Stack grew downward. */
}
}
#endif /* STACK_DIRECTION == 0 */
/* An "alloca header" is used to:
(a) chain together all alloca'ed blocks;
(b) keep track of stack depth.
It is very important that sizeof(header) agree with malloc
alignment chunk size. The following default should work okay. */
#ifndef ALIGN_SIZE
#define ALIGN_SIZE sizeof(double)
#endif
typedef union hdr
{
char align[ALIGN_SIZE]; /* To force sizeof(header). */
struct
{
union hdr *next; /* For chaining headers. */
char *deep; /* For stack depth measure. */
} h;
} header;
static header *last_alloca_header = NULL; /* -> last alloca header. */
/* Return a pointer to at least SIZE bytes of storage,
which will be automatically reclaimed upon exit from
the procedure that called alloca. Originally, this space
was supposed to be taken from the current stack frame of the
caller, but that method cannot be made to work for some
implementations of C, for example under Gould's UTX/32. */
pointer
alloca (size)
unsigned size;
{
auto char probe; /* Probes stack depth: */
register char *depth = ADDRESS_FUNCTION (probe);
#if STACK_DIRECTION == 0
if (STACK_DIR == 0) /* Unknown growth direction. */
find_stack_direction ();
#endif
/* Reclaim garbage, defined as all alloca'd storage that
was allocated from deeper in the stack than currently. */
{
register header *hp; /* Traverses linked list. */
#ifdef emacs
BLOCK_INPUT;
#endif
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
{
register header *np = hp->h.next;
free ((pointer) hp); /* Collect garbage. */
hp = np; /* -> next header. */
}
else
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
#ifdef emacs
UNBLOCK_INPUT;
#endif
}
if (size == 0)
return NULL; /* No allocation required. */
/* Allocate combined header + user data storage. */
{
register pointer new = malloc (sizeof (header) + size);
/* Address of header. */
((header *) new)->h.next = last_alloca_header;
((header *) new)->h.deep = depth;
last_alloca_header = (header *) new;
/* User storage begins just after header. */
return (pointer) ((char *) new + sizeof (header));
}
}
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
#ifdef DEBUG_I00AFUNC
#include <stdio.h>
#endif
#ifndef CRAY_STACK
#define CRAY_STACK
#ifndef CRAY2
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
struct stack_control_header
{
long shgrow:32; /* Number of times stack has grown. */
long shaseg:32; /* Size of increments to stack. */
long shhwm:32; /* High water mark of stack. */
long shsize:32; /* Current size of stack (all segments). */
};
/* The stack segment linkage control information occurs at
the high-address end of a stack segment. (The stack
grows from low addresses to high addresses.) The initial
part of the stack segment linkage control information is
0200 (octal) words. This provides for register storage
for the routine which overflows the stack. */
struct stack_segment_linkage
{
long ss[0200]; /* 0200 overflow words. */
long sssize:32; /* Number of words in this segment. */
long ssbase:32; /* Offset to stack base. */
long:32;
long sspseg:32; /* Offset to linkage control of previous
segment of stack. */
long:32;
long sstcpt:32; /* Pointer to task common address block. */
long sscsnm; /* Private control structure number for
microtasking. */
long ssusr1; /* Reserved for user. */
long ssusr2; /* Reserved for user. */
long sstpid; /* Process ID for pid based multi-tasking. */
long ssgvup; /* Pointer to multitasking thread giveup. */
long sscray[7]; /* Reserved for Cray Research. */
long ssa0;
long ssa1;
long ssa2;
long ssa3;
long ssa4;
long ssa5;
long ssa6;
long ssa7;
long sss0;
long sss1;
long sss2;
long sss3;
long sss4;
long sss5;
long sss6;
long sss7;
};
#else /* CRAY2 */
/* The following structure defines the vector of words
returned by the STKSTAT library routine. */
struct stk_stat
{
long now; /* Current total stack size. */
long maxc; /* Amount of contiguous space which would
be required to satisfy the maximum
stack demand to date. */
long high_water; /* Stack high-water mark. */
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
long hits; /* Number of internal buffer hits. */
long extends; /* Number of block extensions. */
long stko_mallocs; /* Block allocations by $STKOFEN. */
long underflows; /* Number of stack underflow calls ($STKRETN). */
long stko_free; /* Number of deallocations by $STKRETN. */
long stkm_free; /* Number of deallocations by $STKMRET. */
long segments; /* Current number of stack segments. */
long maxs; /* Maximum number of stack segments so far. */
long pad_size; /* Stack pad size. */
long current_address; /* Current stack segment address. */
long current_size; /* Current stack segment size. This
number is actually corrupted by STKSTAT to
include the fifteen word trailer area. */
long initial_address; /* Address of initial segment. */
long initial_size; /* Size of initial segment. */
};
/* The following structure describes the data structure which trails
any stack segment. I think that the description in 'asdef' is
out of date. I only describe the parts that I am sure about. */
struct stk_trailer
{
long this_address; /* Address of this block. */
long this_size; /* Size of this block (does not include
this trailer). */
long unknown2;
long unknown3;
long link; /* Address of trailer block of previous
segment. */
long unknown5;
long unknown6;
long unknown7;
long unknown8;
long unknown9;
long unknown10;
long unknown11;
long unknown12;
long unknown13;
long unknown14;
};
#endif /* CRAY2 */
#endif /* not CRAY_STACK */
#ifdef CRAY2
/* Determine a "stack measure" for an arbitrary ADDRESS.
I doubt that "lint" will like this much. */
static long
i00afunc (long *address)
{
struct stk_stat status;
struct stk_trailer *trailer;
long *block, size;
long result = 0;
/* We want to iterate through all of the segments. The first
step is to get the stack status structure. We could do this
more quickly and more directly, perhaps, by referencing the
$LM00 common block, but I know that this works. */
STKSTAT (&status);
/* Set up the iteration. */
trailer = (struct stk_trailer *) (status.current_address
+ status.current_size
- 15);
/* There must be at least one stack segment. Therefore it is
a fatal error if "trailer" is null. */
if (trailer == 0)
abort ();
/* Discard segments that do not contain our argument address. */
while (trailer != 0)
{
block = (long *) trailer->this_address;
size = trailer->this_size;
if (block == 0 || size == 0)
abort ();
trailer = (struct stk_trailer *) trailer->link;
if ((block <= address) && (address < (block + size)))
break;
}
/* Set the result to the offset in this segment and add the sizes
of all predecessor segments. */
result = address - block;
if (trailer == 0)
{
return result;
}
do
{
if (trailer->this_size <= 0)
abort ();
result += trailer->this_size;
trailer = (struct stk_trailer *) trailer->link;
}
while (trailer != 0);
/* We are done. Note that if you present a bogus address (one
not in any segment), you will get a different number back, formed
from subtracting the address of the first block. This is probably
not what you want. */
return (result);
}
#else /* not CRAY2 */
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
Determine the number of the cell within the stack,
given the address of the cell. The purpose of this
routine is to linearize, in some sense, stack addresses
for alloca. */
static long
i00afunc (long address)
{
long stkl = 0;
long size, pseg, this_segment, stack;
long result = 0;
struct stack_segment_linkage *ssptr;
/* Register B67 contains the address of the end of the
current stack segment. If you (as a subprogram) store
your registers on the stack and find that you are past
the contents of B67, you have overflowed the segment.
B67 also points to the stack segment linkage control
area, which is what we are really interested in. */
stkl = CRAY_STACKSEG_END ();
ssptr = (struct stack_segment_linkage *) stkl;
/* If one subtracts 'size' from the end of the segment,
one has the address of the first word of the segment.
If this is not the first segment, 'pseg' will be
nonzero. */
pseg = ssptr->sspseg;
size = ssptr->sssize;
this_segment = stkl - size;
/* It is possible that calling this routine itself caused
a stack overflow. Discard stack segments which do not
contain the target address. */
while (!(this_segment <= address && address <= stkl))
{
#ifdef DEBUG_I00AFUNC
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
#endif
if (pseg == 0)
break;
stkl = stkl - pseg;
ssptr = (struct stack_segment_linkage *) stkl;
size = ssptr->sssize;
pseg = ssptr->sspseg;
this_segment = stkl - size;
}
result = address - this_segment;
/* If you subtract pseg from the current end of the stack,
you get the address of the previous stack segment's end.
This seems a little convoluted to me, but I'll bet you save
a cycle somewhere. */
while (pseg != 0)
{
#ifdef DEBUG_I00AFUNC
fprintf (stderr, "%011o %011o\n", pseg, size);
#endif
stkl = stkl - pseg;
ssptr = (struct stack_segment_linkage *) stkl;
size = ssptr->sssize;
pseg = ssptr->sspseg;
result += size;
}
return (result);
}
#endif /* not CRAY2 */
#endif /* CRAY */
#endif /* no alloca */
#endif /* not GCC version 2 */
#endif /* !HAVE_ALLOCA */

831
lib/getopt.c 100644
Wyświetl plik

@ -0,0 +1,831 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 1996
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
#if defined (_LIBC) || defined (HAVE_UNISTD_H)
#include <unistd.h>
#endif
#endif /* GNU C library. */
#ifdef VMS
#include <unixlib.h>
#if HAVE_STRING_H - 0
#include <string.h>
#endif
#endif
#ifdef WIN32
/* It's not Unix, really. See? Capital letters. */
#include <windows.h>
#define getpid() GetCurrentProcessId()
#endif
#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# define _(msgid) gettext (msgid)
#else
# define _(msgid) (msgid)
#endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
#include "getopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = NULL;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* XXX 1003.2 says this must be 1 before any call. */
int optind = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
#define my_index strchr
#else
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
static char *
my_index (str, chr)
const char *str;
int chr;
{
while (*str)
{
if (*str == chr)
return (char *) str;
str++;
}
return 0;
}
/* If using GCC, we can safely declare strlen this way.
If not using GCC, it is ok not to declare it. */
#ifdef __GNUC__
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
#if !defined (__STDC__) || !__STDC__
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int strlen (const char *);
#endif /* not __STDC__ */
#endif /* __GNUC__ */
#endif /* not __GNU_LIBRARY__ */
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first of them;
`last_nonopt' is the index after the last of them. */
static int first_nonopt;
static int last_nonopt;
/* Bash 2.0 gives us an environment variable containing flags
indicating ARGV elements that should not be considered arguments. */
static const char *nonoption_flags;
static int nonoption_flags_len;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
#if defined (__STDC__) && __STDC__
static void exchange (char **);
#endif
static void
exchange (argv)
char **argv;
{
int bottom = first_nonopt;
int middle = last_nonopt;
int top = optind;
char *tem;
/* Exchange the shorter segment with the far end of the longer segment.
That puts the shorter segment into the right place.
It leaves the longer segment in the right place overall,
but it consists of two parts that need to be swapped next. */
while (top > middle && middle > bottom)
{
if (top - middle > middle - bottom)
{
/* Bottom segment is the short one. */
int len = middle - bottom;
register int i;
/* Swap it with the top part of the top segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
argv[bottom + i] = argv[top - (middle - bottom) + i];
argv[top - (middle - bottom) + i] = tem;
}
/* Exclude the moved bottom segment from further swapping. */
top -= len;
}
else
{
/* Top segment is the short one. */
int len = top - middle;
register int i;
/* Swap it with the bottom part of the bottom segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
argv[bottom + i] = argv[middle + i];
argv[middle + i] = tem;
}
/* Exclude the moved top segment from further swapping. */
bottom += len;
}
}
/* Update records for the slots the non-options now occupy. */
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Initialize the internal data when the first call is made. */
#if defined (__STDC__) && __STDC__
static const char *_getopt_initialize (const char *);
#endif
static const char *
_getopt_initialize (optstring)
const char *optstring;
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
posixly_correct = getenv ("POSIXLY_CORRECT");
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (posixly_correct != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
if (posixly_correct == NULL)
{
/* Bash 2.0 puts a special variable in the environment for each
command it runs, specifying which ARGV elements are the results of
file name wildcard expansion and therefore should not be
considered as options. */
char var[100];
sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ());
nonoption_flags = getenv (var);
if (nonoption_flags == NULL)
nonoption_flags_len = 0;
else
nonoption_flags_len = strlen (nonoption_flags);
}
return optstring;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
It is only valid when a long-named option has been found by the most
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
optarg = NULL;
if (optind == 0)
{
optstring = _getopt_initialize (optstring);
optind = 1; /* Don't scan ARGV[0], the program name. */
}
/* Test whether ARGV[optind] points to a non-option argument.
Either it does not have option syntax, or there is an environment flag
from the shell indicating it is not an option. */
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
|| (optind < nonoption_flags_len \
&& nonoption_flags[optind] == '1'))
if (nextchar == NULL || *nextchar == '\0')
{
/* Advance to the next ARGV-element. */
/* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
moved back by the user (who may also have changed the arguments). */
if (last_nonopt > optind)
last_nonopt = optind;
if (first_nonopt > optind)
first_nonopt = optind;
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
exchange them so that the options come first. */
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (last_nonopt != optind)
first_nonopt = optind;
/* Skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc && NONOPTION_P)
optind++;
last_nonopt = optind;
}
/* The special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
if (optind != argc && !strcmp (argv[optind], "--"))
{
optind++;
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (first_nonopt == last_nonopt)
first_nonopt = optind;
last_nonopt = argc;
optind = argc;
}
/* If we have done all the ARGV-elements, stop the scan
and back over any non-options that we skipped and permuted. */
if (optind == argc)
{
/* Set the next-arg-index to point at the non-options
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if (NONOPTION_P)
{
if (ordering == REQUIRE_ORDER)
return EOF;
optarg = argv[optind++];
return 1;
}
/* We have found another option-ARGV-element.
Skip the initial punctuation. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
/* Decode the current option-ARGV-element. */
/* Check whether the ARGV-element is a long option.
If long_only and the ARGV-element has the form "-f", where f is
a valid short option, don't consider it an abbreviated form of
a long option that starts with f. Otherwise there would be no
way to give the -f short option.
On the other hand, if there's a long option "fubar" and
the ARGV-element is "-fu", do consider that an abbreviation of
the long option, just like "--fu", and not "-f" with arg "u".
This distinction seems to be the most useful approach. */
if (longopts != NULL
&& (argv[optind][1] == '-'
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
{
char *nameend;
const struct option *p;
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
int indfound;
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
#ifdef lint /* Suppress `used before initialized' warning. */
indfound = 0;
#endif
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
if (nameend - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
indfound = option_index;
exact = 1;
break;
}
else if (pfound == NULL)
{
/* First nonexact match found. */
pfound = p;
indfound = option_index;
}
else
/* Second or later nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
optopt = 0;
return '?';
}
if (pfound != NULL)
{
option_index = indfound;
optind++;
if (*nameend)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = nameend + 1;
else
{
if (opterr)
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
_("%s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
nextchar += strlen (nextchar);
optopt = pfound->val;
return '?';
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
optopt = pfound->val;
return optstring[0] == ':' ? ':' : '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
optind++;
optopt = 0;
return '?';
}
}
/* Look at and handle the next short option-character. */
{
char c = *nextchar++;
char *temp = my_index (optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0')
++optind;
if (temp == NULL || c == ':')
{
if (opterr)
{
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
fprintf (stderr, _("%s: illegal option -- %c\n"),
argv[0], c);
else
fprintf (stderr, _("%s: invalid option -- %c\n"),
argv[0], c);
}
optopt = c;
return '?';
}
if (temp[1] == ':')
{
if (temp[2] == ':')
{
/* This is an option that accepts an argument optionally. */
if (*nextchar != '\0')
{
optarg = nextchar;
optind++;
}
else
optarg = NULL;
nextchar = NULL;
}
else
{
/* This is an option that requires an argument. */
if (*nextchar != '\0')
{
optarg = nextchar;
/* If we end this ARGV-element by taking the rest as an arg,
we must advance to the next element now. */
optind++;
}
else if (optind == argc)
{
if (opterr)
{
/* 1003.2 specifies the format of this message. */
fprintf (stderr,
_("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
if (optstring[0] == ':')
c = ':';
else
c = '?';
}
else
/* We already incremented `optind' once;
increment it again when taking next ARGV-elt as argument. */
optarg = argv[optind++];
nextchar = NULL;
}
}
return c;
}
}
int
getopt (argc, argv, optstring)
int argc;
char *const *argv;
const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
break;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

180
lib/getopt1.c 100644
Wyświetl plik

@ -0,0 +1,180 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "getopt.h"
#if !defined (__STDC__) || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#else
char *getenv ();
#endif
#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == EOF)
break;
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */

532
lib/snprintf.c 100644
Wyświetl plik

@ -0,0 +1,532 @@
#include <config.h>
#ifndef HAVE_SNPRINTF
/***************************************************************************
* LPRng - An Extended Print Spooler System
*
* Copyright 1988-1997, Patrick Powell, San Diego, CA
* papowell@sdsu.edu
* See below for conditions of use.
*
***************************************************************************
* MODULE: snprintf.c
* PURPOSE: LPRng version of printf - absolutely bombproof (hopefully!)
**************************************************************************/
#if 0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you are thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own.
6. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
7. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
#include "lp.h"
#endif
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#define HAVE_STDARGS /* let's hope that works everywhere (mj) */
#define VA_LOCAL_DECL va_list ap;
#define VA_START(f) va_start(ap, f)
#define VA_SHIFT(v,t) ; /* no-op for ANSI */
#define VA_END va_end(ap)
/**** ENDINCLUDE ****/
static char *const _id = "$Id$";
/*
* dopr(): poor man's version of doprintf
*/
static char * plp_Errormsg ( int err );
static void dopr( char *buffer, const char *format, va_list args );
static void fmtstr( char *value, int ljust, int len, int zpad, int precision );
static void fmtnum( long value, int base, int dosign,
int ljust, int len, int zpad, int precision );
static void fmtdouble( int fmt, double value,
int ljust, int len, int zpad, int precision );
static void dostr( char * );
static char *output;
static void dopr_outch( int c );
static char *end;
int visible_control = 1;
/**************************************************************
* Original:
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
* A bombproof version of doprnt (dopr) included.
* Sigh. This sort of thing is always nasty do deal with. Note that
* the version here does not include floating point...
*
* plp_snprintf() is used instead of sprintf() as it does limit checks
* for string length. This covers a nasty loophole.
*
* The other functions are there to prevent NULL pointers from
* causing nast effects.
**************************************************************/
int vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
str[0] = 0;
end = str+count-1;
dopr( str, fmt, args );
if( count>0 ){
end[0] = 0;
}
return(strlen(str));
}
/* VARARGS3 */
#ifdef HAVE_STDARGS
int snprintf (char *str,size_t count,const char *fmt,...)
#else
int snprintf (va_alist) va_dcl
#endif
{
#ifndef HAVE_STDARGS
char *str;
size_t count;
char *fmt;
#endif
VA_LOCAL_DECL
VA_START (fmt);
VA_SHIFT (str, char *);
VA_SHIFT (count, size_t );
VA_SHIFT (fmt, char *);
(void) vsnprintf ( str, count, fmt, ap);
VA_END;
return( strlen( str ) );
}
static void dopr( char *buffer, const char *format, va_list args )
{
int ch;
long value;
int longflag = 0;
char *strvalue;
int ljust;
int len;
int zpad;
int precision;
int set_precision;
double dval;
int err = errno;
output = buffer;
while( (ch = *format++) ){
switch( ch ){
case '%':
ljust = len = zpad = 0;
precision = -1; set_precision = 0;
nextch:
ch = *format++;
switch( ch ){
case 0:
dostr( "**end of format**" );
return;
case '-': ljust = 1; goto nextch;
case '.': set_precision = 1; precision = 0; goto nextch;
case '*': len = va_arg( args, int ); goto nextch;
case '0': /* set zero padding if len not set */
if(len==0 && set_precision == 0 ) zpad = '0';
case '1': case '2': case '3':
case '4': case '5': case '6':
case '7': case '8': case '9':
if( set_precision ){
precision = precision*10 + ch - '0';
} else {
len = len*10 + ch - '0';
}
goto nextch;
case 'l': longflag = 1; goto nextch;
case 'u': case 'U':
/*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
if( longflag ){
value = va_arg( args, long );
} else {
value = va_arg( args, int );
}
fmtnum( value, 10,0, ljust, len, zpad, precision ); break;
case 'o': case 'O':
/*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
if( longflag ){
value = va_arg( args, long );
} else {
value = va_arg( args, int );
}
fmtnum( value, 8,0, ljust, len, zpad, precision ); break;
case 'd': case 'D':
if( longflag ){
value = va_arg( args, long );
} else {
value = va_arg( args, int );
}
fmtnum( value, 10,1, ljust, len, zpad, precision ); break;
case 'x':
if( longflag ){
value = va_arg( args, long );
} else {
value = va_arg( args, int );
}
fmtnum( value, 16,0, ljust, len, zpad, precision ); break;
case 'X':
if( longflag ){
value = va_arg( args, long );
} else {
value = va_arg( args, int );
}
fmtnum( value,-16,0, ljust, len, zpad, precision ); break;
case 's':
strvalue = va_arg( args, char *);
fmtstr( strvalue,ljust,len, zpad, precision );
break;
case 'c':
ch = va_arg( args, int );
{ char b[2];
int vsb = visible_control;
b[0] = ch;
b[1] = 0;
visible_control = 0;
fmtstr( b,ljust,len, zpad, precision );
visible_control = vsb;
}
break;
case 'f': case 'g':
dval = va_arg( args, double );
fmtdouble( ch, dval,ljust,len, zpad, precision ); break;
case 'm':
fmtstr( plp_Errormsg(err),ljust,len, zpad, precision ); break;
case '%': dopr_outch( ch ); continue;
default:
dostr( "???????" );
}
longflag = 0;
break;
default:
dopr_outch( ch );
break;
}
}
*output = 0;
}
/*
* Format '%[-]len[.precision]s'
* - = left justify (ljust)
* len = minimum length
* precision = numbers of chars in string to use
*/
static void
fmtstr( char *value, int ljust, int len, int zpad, int precision )
{
int padlen, strlen, i, c; /* amount to pad */
if( value == 0 ){
value = "<NULL>";
}
if( precision > 0 ){
strlen = precision;
} else {
/* cheap strlen so you do not have library call */
for( strlen = 0; (c=value[strlen]); ++ strlen ){
if( visible_control && iscntrl( c ) && !isspace( c ) ){
++strlen;
}
}
}
padlen = len - strlen;
if( padlen < 0 ) padlen = 0;
if( ljust ) padlen = -padlen;
while( padlen > 0 ) {
dopr_outch( ' ' );
--padlen;
}
/* output characters */
for( i = 0; (c = value[i]); ++i ){
if( visible_control && iscntrl( c ) && !isspace( c ) ){
dopr_outch('^');
c = ('@' | (c & 0x1F));
}
dopr_outch(c);
}
while( padlen < 0 ) {
dopr_outch( ' ' );
++padlen;
}
}
static void
fmtnum( long value, int base, int dosign, int ljust,
int len, int zpad, int precision )
{
int signvalue = 0;
unsigned long uvalue;
char convert[20];
int place = 0;
int padlen = 0; /* amount to pad */
int caps = 0;
/* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
value, base, dosign, ljust, len, zpad )); */
uvalue = value;
if( dosign ){
if( value < 0 ) {
signvalue = '-';
uvalue = -value;
}
}
if( base < 0 ){
caps = 1;
base = -base;
}
do{
convert[place++] =
(caps? "0123456789ABCDEF":"0123456789abcdef")
[uvalue % (unsigned)base ];
uvalue = (uvalue / (unsigned)base );
}while(uvalue);
convert[place] = 0;
padlen = len - place;
if( padlen < 0 ) padlen = 0;
if( ljust ) padlen = -padlen;
/* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
convert,place,signvalue,padlen)); */
if( zpad && padlen > 0 ){
if( signvalue ){
dopr_outch( signvalue );
--padlen;
signvalue = 0;
}
while( padlen > 0 ){
dopr_outch( zpad );
--padlen;
}
}
while( padlen > 0 ) {
dopr_outch( ' ' );
--padlen;
}
if( signvalue ) dopr_outch( signvalue );
while( place > 0 ) dopr_outch( convert[--place] );
while( padlen < 0 ){
dopr_outch( ' ' );
++padlen;
}
}
static void
fmtdouble( int fmt, double value, int ljust, int len, int zpad, int precision )
{
char convert[128];
char fmtstr[128];
int l;
if( len == 0 ) len = 10;
if( len > sizeof(convert) - 10 ){
len = sizeof(convert) - 10;
}
if( precision > sizeof(convert) - 10 ){
precision = sizeof(convert) - 10;
}
if( precision > len ) precision = len;
strcpy( fmtstr, "%" );
if( ljust ) strcat(fmtstr, "-" );
if( len ){
sprintf( fmtstr+strlen(fmtstr), "%d", len );
}
if( precision > 0 ){
sprintf( fmtstr+strlen(fmtstr), ".%d", precision );
}
l = strlen( fmtstr );
fmtstr[l] = fmt;
fmtstr[l+1] = 0;
sprintf( convert, fmtstr, value );
dostr( convert );
}
static void dostr( char *str )
{
while(*str) dopr_outch(*str++);
}
static void dopr_outch( int c )
{
if( end == 0 || output < end ){
*output++ = c;
}
}
/****************************************************************************
* static char *plp_errormsg( int err )
* returns a printable form of the
* errormessage corresponding to the valie of err.
* This is the poor man's version of sperror(), not available on all systems
* Patrick Powell Tue Apr 11 08:05:05 PDT 1995
****************************************************************************/
/****************************************************************************/
#if !defined(HAVE_STRERROR)
# if defined(HAVE_SYS_NERR)
# if !defined(HAVE_SYS_NERR_DEF)
extern int sys_nerr;
# endif
# define num_errors (sys_nerr)
# else
# define num_errors (-1) /* always use "errno=%d" */
# endif
# if defined(HAVE_SYS_ERRLIST)
# if !defined(HAVE_SYS_ERRLIST_DEF)
extern const char *const sys_errlist[];
# endif
# else
# undef num_errors
# define num_errors (-1) /* always use "errno=%d" */
# endif
#endif
static char * plp_Errormsg ( int err )
{
char *cp;
#if defined(HAVE_STRERROR)
cp = (void *)strerror(err);
#else
# if defined(HAVE_SYS_ERRLIST)
if (err >= 0 && err < num_errors) {
cp = (void *)sys_errlist[err];
} else
# endif
{
static char msgbuf[32]; /* holds "errno=%d". */
/* SAFE use of sprintf */
(void) sprintf (msgbuf, "errno=%d", err);
cp = msgbuf;
}
#endif
return (cp);
}
#if defined(TEST)
#include <stdio.h>
int main( void )
{
char buffer[128];
char *t;
char *test1 = "01234";
errno = 1;
plp_snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "%s = '%s'\n", t, buffer );
plp_snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "%s = '%s'\n", t, buffer );
return(0);
}
#endif
#endif /* HAVE_SNPRINTF */

38
lib/strdup.c 100644
Wyświetl plik

@ -0,0 +1,38 @@
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#ifndef HAVE_STRDUP
char *
strdup (const char * s)
{
char *clone;
size_t size;
size = strlen (s) + 1;
clone = malloc (size);
memcpy (clone, s, size);
return clone;
}
#endif /* !HAVE_STRDUP */

39
lib/strndup.c 100644
Wyświetl plik

@ -0,0 +1,39 @@
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#ifndef HAVE_STRNDUP
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
char *
strndup (const char * s, size_t n)
{
char *clone;
clone = malloc (n + 1);
strncpy (clone, s, n);
clone[n] = '\0';
return clone;
}
#endif /* !HAVE_STRNDUP */

49
lib/strsep.c 100644
Wyświetl plik

@ -0,0 +1,49 @@
/* Copyright (C) 1992, 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#include <string.h>
#ifndef HAVE_STRSEP
char *
strsep (char **stringp, const char *delim)
{
char *begin, *end;
begin = *stringp;
if (! begin || *begin == '\0')
return NULL;
/* Find the end of the token. */
end = strpbrk (begin, delim);
if (end)
{
/* Terminate the token and set *STRINGP past NUL character. */
*end++ = '\0';
*stringp = end;
}
else
/* No more delimiters; this is the last token. */
*stringp = NULL;
return begin;
}
#endif /* !HAVE_STRSEP */

60
lib/usleep.c 100644
Wyświetl plik

@ -0,0 +1,60 @@
/* Copyright (C) 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <config.h>
#ifndef HAVE_USLEEP
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef apollo
# include <apollo/base.h>
# include <apollo/time.h>
static time_$clock_t DomainTime100mS =
{
0, 100000/4
};
static status_$t DomainStatus;
#endif
/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
unsigned int
usleep (unsigned int useconds)
{
#ifdef apollo
/* The usleep function does not work under the SYS5.3 environment.
Use the Domain/OS time_$wait call instead. */
time_$wait (time_$relative, DomainTime100mS, &DomainStatus);
#else
struct timeval delay;
delay.tv_sec = 0;
delay.tv_usec = useconds;
select (0, 0, 0, 0, &delay);
return 0;
#endif
}
#endif /* !HAVE_USLEEP */

36
mkinstalldirs 100755
Wyświetl plik

@ -0,0 +1,36 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1994-03-25
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
fi
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

11
sane-frontend.NEWS 100644
Wyświetl plik

@ -0,0 +1,11 @@
The SANE-Package has been split into two packages:
SANE (backends) and SANE-FRONTENDS.
This is an early version of SANE-FRONTENDS.
If you experience any problems please write
to the sane mailing list or contact:
Oliver Rauch <Oliver.Rauch@Wolfsburg.DE>

21
sane.INSTALL 100644
Wyświetl plik

@ -0,0 +1,21 @@
How to configure, build, and install SANE-FRONTENDS.
Quick install:
==============
./configure
make
make install
- If you get an error message that libsane-dll.so.1 or libsane-so.1 is not found, you have to
tell your system where the SANE-libraries are installed.
- On some systems the library directory "/usr/local/lib" is not searched by the
systems dynamic library loader. If SANE is installed in "/usr/local/..."
you have to tell your systems dynamic library loader to search in "/usr/local/lib".
For linux: add the path "/usr/local/lib" to /etc/ld.so.conf and call ldconfig (as root).
- For sane-1.0.1 you have to add a line with the path to the SANE libraries
(normally /usr/local/lib/sane) to /etc/ld.so.conf and call ldconfig (as root).
For sane-1.0.2 (and later versions) the path to the SANE libs MUST NOT be listed
in /etc/ld.so.conf

4
sane.PROBLEMS 100644
Wyświetl plik

@ -0,0 +1,4 @@
- xscanimage/xcam crashes X server on Linux/Alpha
Older versions of the TGA X server (such as version 3.1.2) are known
to fail when creating shared images of certain sizes. This can be
avoided by invoking xscanimage and xcam with option --no-shm.

76
sanei/Makefile.in 100644
Wyświetl plik

@ -0,0 +1,76 @@
SHELL = /bin/sh
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
configdir = ${sysconfdir}/sane.d
sanedatadir = ${datadir}/sane
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
DEFS = @DEFS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
MCOMP = --mode=compile
MLINK = --mode=link
@SET_MAKE@
LIBSANEI_OBJS = sanei_init_debug.o \
sanei_wire.o sanei_codec_ascii.o sanei_codec_bin.o \
sanei_save_values.o sanei_load_values.o
LIBSANEI_LTOBJS = sanei_init_debug.lo \
sanei_wire.lo sanei_codec_ascii.lo sanei_codec_bin.lo \
sanei_save_values.lo sanei_load_values.lo
TARGETS = libsanei.a
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
$(COMPILE) $<
@test -f $@ || $(COMPILE) $<
all: $(TARGETS)
libsanei.a: $(LIBSANEI_OBJS)
ar r $@ $(LIBSANEI_OBJS)
install:
depend:
makedepend -I. -I../include *.c
clean:
rm -f *.out *.o *.lo *~ *.a *.bak $(OBJS)
rm -rf .libs
distclean: clean
rm -f Makefile
.PHONY: all install check depend clean distclean

Wyświetl plik

@ -0,0 +1,345 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#include "sane/config.h"
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sane/sane.h>
#include "../include/sane/sanei_wire.h"
#include "../include/sane/sanei_codec_ascii.h"
static const char *hexdigit = "0123456789abcdef";
static void
skip_ws (Wire *w)
{
while (1)
{
sanei_w_space (w, 1);
if (w->status != 0)
return;
if (!isspace (*w->buffer.curr))
return;
++w->buffer.curr;
}
}
static unsigned
get_digit (Wire *w)
{
unsigned digit;
sanei_w_space (w, 1);
digit = tolower(*w->buffer.curr++) - '0';
if (digit > 9)
digit -= 'a' - ('9' + 1);
if (digit > 0xf)
{
w->status = EINVAL;
return 0;
}
return digit;
}
static SANE_Byte
get_byte (Wire *w)
{
return get_digit (w) << 4 | get_digit (w);
}
static void
ascii_w_byte (Wire *w, void *v)
{
SANE_Byte *b = v;
switch (w->direction)
{
case WIRE_ENCODE:
sanei_w_space (w, 3);
*w->buffer.curr++ = hexdigit[(*b >> 4) & 0x0f];
*w->buffer.curr++ = hexdigit[(*b >> 0) & 0x0f];
*w->buffer.curr++ = '\n';
break;
case WIRE_DECODE:
skip_ws (w);
*b = get_byte (w);
break;
case WIRE_FREE:
break;
}
}
static void
ascii_w_char (Wire *w, void *v)
{
SANE_Char *c = v;
switch (w->direction)
{
case WIRE_ENCODE:
sanei_w_space (w, 5);
*w->buffer.curr++ = '\'';
if (*c == '\'' || *c == '\\')
*w->buffer.curr++ = '\\';
*w->buffer.curr++ = *c;
*w->buffer.curr++ = '\'';
*w->buffer.curr++ = '\n';
break;
case WIRE_DECODE:
sanei_w_space (w, 4);
if (*w->buffer.curr++ != '\'')
{
w->status = EINVAL;
return;
}
*c = *w->buffer.curr++;
if (*c == '\\')
{
sanei_w_space (w, 2);
*c = *w->buffer.curr++;
}
if (*w->buffer.curr++ != '\'')
{
w->status = EINVAL;
return;
}
break;
case WIRE_FREE:
break;
}
}
static void
ascii_w_string (Wire *w, void *v)
{
size_t len, alloced_len;
SANE_String *s = v;
char * str, ch;
int done;
switch (w->direction)
{
case WIRE_ENCODE:
if (*s)
{
sanei_w_space (w, 1);
*w->buffer.curr++ = '"';
str = *s;
while ((ch = *str++))
{
sanei_w_space (w, 2);
if (ch == '"' || ch == '\\')
*w->buffer.curr++ = '\\';
*w->buffer.curr++ = ch;
}
*w->buffer.curr++ = '"';
}
else
{
sanei_w_space (w, 5);
*w->buffer.curr++ = '(';
*w->buffer.curr++ = 'n';
*w->buffer.curr++ = 'i';
*w->buffer.curr++ = 'l';
*w->buffer.curr++ = ')';
}
sanei_w_space (w, 1);
*w->buffer.curr++ = '\n';
break;
case WIRE_DECODE:
skip_ws (w);
sanei_w_space (w, 1);
ch = *w->buffer.curr++;
if (ch == '"')
{
alloced_len = len = 0;
str = 0;
done = 0;
do
{
sanei_w_space (w, 1);
if (w->status != 0)
return;
ch = *w->buffer.curr++;
if (ch == '"')
done = 1;
if (ch == '\\')
{
sanei_w_space (w, 1);
ch = *w->buffer.curr++;
}
if (len >= alloced_len)
{
alloced_len += 1024;
if (!str)
str = malloc (alloced_len);
else
str = realloc (str, alloced_len);
if (str == 0)
{
/* Malloc failed, so return an error. */
w->status = ENOMEM;
return;
}
}
str[len++] = ch;
}
while (!done);
str[len - 1] = '\0';
*s = realloc (str, len);
if (*s == 0)
{
/* Malloc failed, so return an error. */
w->status = ENOMEM;
return;
}
}
else if (ch == '(')
{
sanei_w_space (w, 4);
if ( *w->buffer.curr++ != 'n'
|| *w->buffer.curr++ != 'i'
|| *w->buffer.curr++ != 'l'
|| *w->buffer.curr++ != ')')
{
w->status = EINVAL;
return;
}
*s = 0;
}
else
{
w->status = EINVAL;
return;
}
break;
case WIRE_FREE:
if (*s)
free (*s);
break;
}
}
static void
ascii_w_word (Wire *w, void *v)
{
SANE_Word val, *word = v;
int i, is_negative = 0;
char buf[16];
switch (w->direction)
{
case WIRE_ENCODE:
val = *word;
i = sizeof (buf) - 1;
if (val < 0)
{
is_negative = 1;
val = -val;
}
do
{
buf[i--] = '0' + (val % 10);
val /= 10;
}
while (val);
if (is_negative)
buf[i--] = '-';
sanei_w_space (w, sizeof (buf) - i);
memcpy (w->buffer.curr, buf + i + 1, sizeof (buf) - i - 1);
w->buffer.curr += sizeof (buf) - i - 1;
*w->buffer.curr++ = '\n';
break;
case WIRE_DECODE:
skip_ws (w);
val = 0;
sanei_w_space (w, 1);
if (*w->buffer.curr == '-')
{
is_negative = 1;
++w->buffer.curr;
}
while (1)
{
sanei_w_space (w, 1);
if (w->status != 0)
return;
if (!isdigit (*w->buffer.curr))
break;
val = 10*val + (*w->buffer.curr++ - '0');
}
*word = is_negative ? -val : val;
break;
case WIRE_FREE:
break;
}
}
void
sanei_codec_ascii_init (Wire *w)
{
w->codec.w_byte = ascii_w_byte;
w->codec.w_char = ascii_w_char;
w->codec.w_word = ascii_w_word;
w->codec.w_string = ascii_w_string;
}

Wyświetl plik

@ -0,0 +1,128 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#include "sane/config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sane/sane.h>
#include "../include/sane/sanei_wire.h"
#include "../include/sane/sanei_codec_bin.h"
static void
bin_w_byte (Wire *w, void *v)
{
SANE_Byte *b = v;
sanei_w_space (w, 1);
switch (w->direction)
{
case WIRE_ENCODE:
*w->buffer.curr++ = *b;
break;
case WIRE_DECODE:
*b = *w->buffer.curr++;
break;
case WIRE_FREE:
break;
}
}
static void
bin_w_string (Wire *w, void *v)
{
SANE_Word len;
SANE_String *s = v;
if (w->direction == WIRE_ENCODE)
{
len = 0;
if (*s)
len = strlen (*s) + 1;
}
sanei_w_array (w, &len, v, w->codec.w_byte, 1);
if (!len && w->direction == WIRE_DECODE)
*s = 0;
}
static void
bin_w_word (Wire *w, void *v)
{
SANE_Word val, *word = v;
sanei_w_space (w, 4);
switch (w->direction)
{
case WIRE_ENCODE:
val = *word;
/* store in bigendian byte-order: */
w->buffer.curr[0] = (val >> 24) & 0xff;
w->buffer.curr[1] = (val >> 16) & 0xff;
w->buffer.curr[2] = (val >> 8) & 0xff;
w->buffer.curr[3] = (val >> 0) & 0xff;
w->buffer.curr += 4;
break;
case WIRE_DECODE:
val = ( ((w->buffer.curr[0] & 0xff) << 24)
| ((w->buffer.curr[1] & 0xff) << 16)
| ((w->buffer.curr[2] & 0xff) << 8)
| ((w->buffer.curr[3] & 0xff) << 0));
*word = val;
w->buffer.curr += 4;
break;
case WIRE_FREE:
break;
}
}
void
sanei_codec_bin_init (Wire *w)
{
w->codec.w_byte = bin_w_byte;
w->codec.w_char = bin_w_byte;
w->codec.w_word = bin_w_word;
w->codec.w_string = bin_w_string;
}

Wyświetl plik

@ -0,0 +1,133 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1996, 1997 David Mosberger-Tang and Andreas Beck
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#include "sane/config.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <stdarg.h>
#include <sys/syslog.h>
#ifdef HAVE_OS2_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <sys/stat.h>
#ifdef HAVE_OS2_H
# define INCL_DOS
# include <os2.h>
#endif
#define BACKEND_NAME sanei_debug
#include "../include/sane/sanei_debug.h"
void
sanei_init_debug (const char * backend, int * var)
{
char ch, buf[256] = "SANE_DEBUG_";
const char * val;
unsigned int i;
*var = 0;
for (i = 11; (ch = backend[i - 11]) != 0; ++i)
{
if (i >= sizeof (buf) - 1)
break;
buf[i] = toupper(ch);
}
buf[i] = '\0';
val = getenv (buf);
if (!val)
return;
*var = atoi (val);
DBG (0, "Setting debug level of %s to %d.\n", backend, *var);
}
void
sanei_debug_msg
(int level, int max_level, const char *be, const char *fmt, va_list ap)
{
char *msg;
if (max_level >= level)
{
if ( 1 == isfdtype(fileno(stderr), S_IFSOCK) )
{
msg = (char *)malloc (sizeof(char) * (strlen(be) + strlen(fmt) + 4));
if (msg == NULL)
{
syslog (LOG_DEBUG, "[sanei_debug] malloc() failed\n");
vsyslog (LOG_DEBUG, fmt, ap);
}
else
{
sprintf (msg, "[%s] %s", be, fmt);
vsyslog(LOG_DEBUG, msg, ap);
free (msg);
}
}
else
{
fprintf (stderr, "[%s] ", be);
vfprintf (stderr, fmt, ap);
}
}
}
#ifdef NDEBUG
void
sanei_debug_ndebug (int level, const char *fmt, ...)
{
/* this function is never called */
}
#endif

Wyświetl plik

@ -0,0 +1,198 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
This file implements a routine to restore option values saved to a
file (using sanei_save_values()). This is a bit tricky since
setting an option may change the availability of other options.
The problem is that we don't know the order of the set-value calls
that resulted in the saved set of option values. One solution
might be to simply keep setting all option values until we no
longer get any changes to the option value set. However, that has
the potential for live-lock. Instead, we keep track of what
options caused a SANE_INFO_RELOAD_OPTIONS. For such options, their
value is set exactly once. This guarantees convergence after a
bounded (and usually small) number of iterations. The resulting
value set is guaranteed to be the desired (saved) one as long as
setting an option that affects availability of other options does
not "lose" its value by setting another option. I don't think any
sane backend would do this and since this is SANE, we just proved
that this algorithm works perfectly. */
#ifdef _AIX
# include <lalloca.h> /* MUST come first for AIX! */
#endif
#include "sane/config.h"
#include <lalloca.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_LIBC_H
# include <libc.h> /* NeXTStep/OpenStep */
#endif
#include <sane/sane.h>
#include "../include/sane/sanei_wire.h"
#include "../include/sane/sanei_codec_ascii.h"
#define BITS_PER_LONG (8*sizeof (u_long))
#define SET(set, bit) \
((set)[(bit)/BITS_PER_LONG] |= (1UL << (bit)%BITS_PER_LONG))
#define IS_SET(set, bit) \
(((set)[(bit)/BITS_PER_LONG] & (1UL << (bit)%BITS_PER_LONG)) != 0)
int
sanei_load_values (int fd, SANE_Handle device)
{
const SANE_Option_Descriptor *opt;
SANE_Word *word_array;
SANE_String name, str;
u_long *caused_reload;
SANE_Int num_options;
SANE_Status status;
int i, keep_going;
SANE_Word word;
SANE_Int info;
off_t offset;
size_t size;
char *buf;
Wire w;
offset = lseek (fd, 0, SEEK_CUR);
w.io.fd = fd;
w.io.read = read;
w.io.write = write;
sanei_w_init (&w, sanei_codec_ascii_init);
sanei_w_set_dir (&w, WIRE_DECODE);
keep_going = 0;
sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_options, 0);
size = (num_options + BITS_PER_LONG - 1) / BITS_PER_LONG * sizeof (long);
caused_reload = alloca (size);
memset (caused_reload, 0, size);
while (1)
{
sanei_w_space (&w, 3);
if (!w.status)
sanei_w_string (&w, &name);
if (w.status)
{
if (keep_going)
{
lseek (fd, offset, SEEK_SET);
sanei_w_set_dir (&w, WIRE_DECODE);
keep_going = 0;
continue;
}
return 0;
}
status = SANE_STATUS_GOOD;
info = 0;
for (i = 1; (opt = sane_get_option_descriptor (device, i)); ++i)
{
if (!opt->name || strcmp (opt->name, name) != 0)
continue;
if (IS_SET(caused_reload, i))
continue;
switch (opt->type)
{
case SANE_TYPE_BOOL:
case SANE_TYPE_INT:
case SANE_TYPE_FIXED:
if (opt->size == sizeof (SANE_Word))
{
sanei_w_word (&w, &word);
status = sane_control_option (device, i,
SANE_ACTION_SET_VALUE,
&word, &info);
}
else
{
SANE_Int len;
sanei_w_array (&w, &len, (void **) &word_array,
(WireCodecFunc) sanei_w_word,
sizeof (SANE_Word));
status = sane_control_option (device, i,
SANE_ACTION_SET_VALUE,
word_array, &info);
w.direction = WIRE_FREE;
sanei_w_array (&w, &len, (void **) &word_array,
(WireCodecFunc) sanei_w_word,
sizeof (SANE_Word));
w.direction = WIRE_DECODE;
}
break;
case SANE_TYPE_STRING:
sanei_w_string (&w, &str);
buf = malloc (opt->size);
strncpy (buf, str, opt->size);
buf[opt->size - 1] = '\0';
sanei_w_free (&w, (WireCodecFunc) sanei_w_string, &str);
status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
buf, &info);
break;
case SANE_TYPE_BUTTON:
case SANE_TYPE_GROUP:
break;
}
break;
}
sanei_w_free (&w, (WireCodecFunc) sanei_w_string, &name);
if (status == SANE_STATUS_GOOD && (info & SANE_INFO_RELOAD_OPTIONS))
{
SET (caused_reload, i);
keep_going = 1;
}
}
return 0;
}

Wyświetl plik

@ -0,0 +1,160 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#include "sane/config.h"
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_LIBC_H
# include <libc.h> /* NeXTStep/OpenStep */
#endif
#include <sane/sane.h>
#include "../include/sane/sanei_wire.h"
#include "../include/sane/sanei_codec_ascii.h"
int
sanei_save_values (int fd, SANE_Handle device)
{
const SANE_Option_Descriptor *opt;
size_t word_array_size = 0;
SANE_Word *word_array = 0;
size_t str_size = 0;
SANE_String str = 0;
SANE_Word word;
Wire w;
int i;
w.io.fd = fd;
w.io.read = read;
w.io.write = write;
sanei_w_init (&w, sanei_codec_ascii_init);
sanei_w_set_dir (&w, WIRE_ENCODE);
for (i = 0; (opt = sane_get_option_descriptor (device, i)); ++i)
{
if ((opt->cap & (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT))
!= (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT)
|| !opt->name)
/* if we can't query AND set the option, don't bother saving it */
continue;
switch (opt->type)
{
case SANE_TYPE_BOOL:
case SANE_TYPE_INT:
case SANE_TYPE_FIXED:
if (opt->size == sizeof (SANE_Word))
{
if (sane_control_option (device, i, SANE_ACTION_GET_VALUE,
&word, 0)
!= SANE_STATUS_GOOD)
continue;
sanei_w_string (&w, (SANE_String *) &opt->name);
sanei_w_word (&w, &word);
}
else
{
SANE_Int len = opt->size / sizeof (SANE_Word);
if (opt->size > word_array_size)
{
word_array_size =
((opt->size + 32*sizeof (SANE_Word))
& ~(32*sizeof (SANE_Word) - 1));
if (word_array)
word_array = realloc (word_array, word_array_size);
else
word_array = malloc (word_array_size);
if (word_array == 0)
{
/* Malloc failed, so return an error. */
w.status = ENOMEM;
return 1;
}
}
if (sane_control_option (device, i, SANE_ACTION_GET_VALUE,
word_array, 0)
!= SANE_STATUS_GOOD)
continue;
sanei_w_string (&w, (SANE_String *) &opt->name);
sanei_w_array (&w, &len, (void **) &word_array,
(WireCodecFunc) sanei_w_word, sizeof (SANE_Word));
}
break;
case SANE_TYPE_STRING:
if (opt->size > str_size)
{
str_size = (opt->size + 1024) & ~1023;
if (str)
str = realloc (str, str_size);
else
str = malloc (str_size);
if (str == 0)
{
/* Malloc failed, so return an error. */
w.status = ENOMEM;
return 1;
}
}
if (sane_control_option (device, i, SANE_ACTION_GET_VALUE, str, 0)
!= SANE_STATUS_GOOD)
continue;
sanei_w_string (&w, (SANE_String *) &opt->name);
sanei_w_string (&w, &str);
break;
case SANE_TYPE_BUTTON:
case SANE_TYPE_GROUP:
break;
}
}
sanei_w_set_dir (&w, WIRE_DECODE);
if (word_array)
free (word_array);
if (str)
free (str);
return 0;
}

Wyświetl plik

@ -0,0 +1,108 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 2000 Yuri Dario
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
*/
#include "sane/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_OS2_H
#define INCL_DOSPROCESS
#include <os2.h>
#endif
#include "../include/sane/sanei_thread.h"
/*
* starts a new thread or process
* parameters:
* start address of reader function
* arg_list pointer to scanner data structure
*
*/
int
sanei_thread_begin( void (*start)(void *arg),
void *arg_list)
{
#ifdef HAVE_OS2_H
return _beginthread( start, NULL, 64*1024, arg_list);
#else
return fork();
#endif
}
int
sanei_thread_kill( int pid, int sig)
{
#ifdef HAVE_OS2_H
return DosKillThread( pid);
#else
return kill( pid, sig);
#endif
}
int
sanei_thread_waitpid( int pid, int *stat_loc, int options)
{
#ifdef HAVE_OS2_H
return pid; /* DosWaitThread( (TID*) &pid, DCWW_WAIT);*/
#else
return waitpid( pid, stat_loc, options);
#endif
}
int
sanei_thread_wait( int *stat_loc)
{
#ifdef HAVE_OS2_H
*stat_loc = 0;
return -1; /* return error because I don't know child pid */
#else
return wait( stat_loc);
#endif
}

441
sanei/sanei_wire.c 100644
Wyświetl plik

@ -0,0 +1,441 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice. */
#include "sane/config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sane/sane.h>
#include "../include/sane/sanei_wire.h"
void
sanei_w_space (Wire *w, size_t howmuch)
{
size_t nbytes, left_over;
int fd = w->io.fd;
ssize_t nread, nwritten;
if (w->buffer.curr + howmuch > w->buffer.end)
{
switch (w->direction)
{
case WIRE_ENCODE:
nbytes = w->buffer.curr - w->buffer.start;
w->buffer.curr = w->buffer.start;
while (nbytes > 0)
{
nwritten = (*w->io.write) (fd, w->buffer.curr, nbytes);
if (nwritten < 0)
{
w->status = errno;
return;
}
w->buffer.curr += nwritten;
nbytes -= nwritten;
}
w->buffer.curr = w->buffer.start;
w->buffer.end = w->buffer.start + w->buffer.size;
break;
case WIRE_DECODE:
left_over = w->buffer.end - w->buffer.curr;
if (left_over)
memcpy (w->buffer.start, w->buffer.curr, left_over);
w->buffer.curr = w->buffer.start;
w->buffer.end = w->buffer.start + left_over;
do {
nread = (*w->io.read) (fd, w->buffer.end,
w->buffer.size - left_over);
if (nread <= 0)
{
if (nread == 0)
errno = EINVAL;
w->status = errno;
return;
}
left_over += nread;
w->buffer.end += nread;
} while (left_over < howmuch);
break;
case WIRE_FREE:
break;
}
}
}
void
sanei_w_void (Wire *w)
{
}
void
sanei_w_array (Wire *w, SANE_Word *len_ptr, void **v, WireCodecFunc w_element,
size_t element_size)
{
SANE_Word len;
char *val;
int i;
if (w->direction == WIRE_FREE)
{
free (*v);
return;
}
if (w->direction == WIRE_ENCODE)
len = *len_ptr;
sanei_w_word (w, &len);
if (w->direction == WIRE_DECODE)
{
*len_ptr = len;
if (len)
{
*v = malloc (len * element_size);
if (*v == 0)
{
/* Malloc failed, so return an error. */
w->status = ENOMEM;
return;
}
}
else
*v = 0;
}
val = *v;
for (i = 0; i < len; ++i)
{
(*w_element) (w, val);
val += element_size;
}
}
void
sanei_w_ptr (Wire *w, void **v, WireCodecFunc w_value, size_t value_size)
{
SANE_Word is_null;
if (w->direction == WIRE_FREE)
{
if (*v)
free (*v);
return;
}
if (w->direction == WIRE_ENCODE)
is_null = (*v == 0);
sanei_w_word (w, &is_null);
if (!is_null)
{
if (w->direction == WIRE_DECODE)
{
*v = malloc (value_size);
if (*v == 0)
{
/* Malloc failed, so return an error. */
w->status = ENOMEM;
return;
}
}
(*w_value) (w, *v);
}
else if (w->direction == WIRE_DECODE)
*v = 0;
}
void
sanei_w_byte (Wire *w, SANE_Byte *v)
{
(*w->codec.w_byte) (w, v);
}
void
sanei_w_char (Wire *w, SANE_Char *v)
{
(*w->codec.w_char) (w, v);
}
void
sanei_w_word (Wire *w, SANE_Word *v)
{
(*w->codec.w_word) (w, v);
}
void
sanei_w_string (Wire *w, SANE_String *v)
{
(*w->codec.w_string) (w, v);
}
void
sanei_w_status (Wire *w, SANE_Status *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_bool (Wire *w, SANE_Bool *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_value_type (Wire *w, SANE_Value_Type *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_unit (Wire *w, SANE_Unit *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_action (Wire *w, SANE_Action *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_frame (Wire *w, SANE_Frame *v)
{
SANE_Word word = *v;
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
*v = word;
}
void
sanei_w_range (Wire *w, SANE_Range *v)
{
sanei_w_word (w, &v->min);
sanei_w_word (w, &v->max);
sanei_w_word (w, &v->quant);
}
void
sanei_w_device (Wire *w, SANE_Device *v)
{
sanei_w_string (w, (SANE_String *) &v->name);
sanei_w_string (w, (SANE_String *) &v->vendor);
sanei_w_string (w, (SANE_String *) &v->model);
sanei_w_string (w, (SANE_String *) &v->type);
}
void
sanei_w_device_ptr (Wire *w, SANE_Device **v)
{
sanei_w_ptr (w, (void **) v,
(WireCodecFunc) sanei_w_device, sizeof (**v));
}
void
sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v)
{
SANE_Word len;
sanei_w_string (w, (SANE_String *) &v->name);
sanei_w_string (w, (SANE_String *) &v->title);
sanei_w_string (w, (SANE_String *) &v->desc);
sanei_w_value_type (w, &v->type);
sanei_w_unit (w, &v->unit);
sanei_w_word (w, &v->size);
sanei_w_word (w, &v->cap);
sanei_w_constraint_type (w, &v->constraint_type);
switch (v->constraint_type)
{
case SANE_CONSTRAINT_NONE:
break;
case SANE_CONSTRAINT_RANGE:
sanei_w_ptr (w, (void **) &v->constraint.range,
(WireCodecFunc) sanei_w_range, sizeof (SANE_Range));
break;
case SANE_CONSTRAINT_WORD_LIST:
if (w->direction == WIRE_ENCODE)
len = v->constraint.word_list[0] + 1;
sanei_w_array (w, &len, (void **) &v->constraint.word_list,
w->codec.w_word, sizeof(SANE_Word));
break;
case SANE_CONSTRAINT_STRING_LIST:
if (w->direction == WIRE_ENCODE)
{
for (len = 0; v->constraint.string_list[len]; ++len);
++len; /* send NULL string, too */
}
sanei_w_array (w, &len, (void **) &v->constraint.string_list,
w->codec.w_string, sizeof(SANE_String));
break;
}
}
void
sanei_w_option_descriptor_ptr (Wire *w, SANE_Option_Descriptor **v)
{
sanei_w_ptr (w, (void **) v,
(WireCodecFunc) sanei_w_option_descriptor, sizeof (**v));
}
void
sanei_w_parameters (Wire *w, SANE_Parameters *v)
{
sanei_w_frame (w, &v->format);
sanei_w_bool (w, &v->last_frame);
sanei_w_word (w, &v->bytes_per_line);
sanei_w_word (w, &v->pixels_per_line);
sanei_w_word (w, &v->lines);
sanei_w_word (w, &v->depth);
}
static void
flush (Wire *w)
{
if (w->direction == WIRE_ENCODE)
sanei_w_space (w, w->buffer.size + 1);
else if (w->direction == WIRE_DECODE)
w->buffer.curr = w->buffer.end = w->buffer.start;
}
void
sanei_w_set_dir (Wire *w, WireDirection dir)
{
flush (w);
w->direction = dir;
flush (w);
}
void
sanei_w_call (Wire *w,
SANE_Word procnum,
WireCodecFunc w_arg, void *arg,
WireCodecFunc w_reply, void *reply)
{
w->status = 0;
sanei_w_set_dir (w, WIRE_ENCODE);
sanei_w_word (w, &procnum);
(*w_arg) (w, arg);
if (w->status == 0)
{
sanei_w_set_dir (w, WIRE_DECODE);
(*w_reply) (w, reply);
}
}
void
sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply)
{
w->status = 0;
sanei_w_set_dir (w, WIRE_ENCODE);
(*w_reply) (w, reply);
flush (w);
}
void
sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply)
{
WireDirection saved_dir = w->direction;
w->direction = WIRE_FREE;
(*w_reply) (w, reply);
w->direction = saved_dir;
}
void
sanei_w_init (Wire *w, void (*codec_init_func)(Wire *))
{
w->status = 0;
w->direction = WIRE_ENCODE;
w->buffer.size = 8192;
w->buffer.start = malloc (w->buffer.size);
if (w->buffer.start == 0)
/* Malloc failed, so return an error. */
w->status = ENOMEM;
w->buffer.curr = w->buffer.start;
w->buffer.end = w->buffer.start + w->buffer.size;
if (codec_init_func != 0)
(*codec_init_func) (w);
}

89
src/Makefile.in 100644
Wyświetl plik

@ -0,0 +1,89 @@
SHELL = /bin/sh
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
sane_prefix = @SANE_PREFIX@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
configdir = ${sysconfdir}/sane.d
sanedatadir = ${datadir}/sane
MKDIR = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include \
@INCLUDES@ @GTK_CFLAGS@
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
SANE_LIBS = @SANE_LIBS@
GTK_LIBS = @GTK_LIBS@
GIMP_LIBS = @GIMP_LIBS@
XSCAN = @XSCAN@
BINPROGS = @BINPROGS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@
@SET_MAKE@
PROGRAMS = $(BINPROGS)
LIBLIB = ../lib/liblib.a
LIBSANEI = ../sanei/libsanei.a
SCAN_OBJS = stiff.o
XSCAN_OBJS = xscanimage.o progress.o preview.o preferences.o gtkglue.o
XCAM_OBJS = xcam.o preferences.o gtkglue.o
.c.o:
$(COMPILE) $<
all: $(PROGRAMS)
install: $(PROGRAMS)
$(MKDIR) $(bindir) $(datadir)
@for program in $(BINPROGS); do \
$(INSTALL_PROGRAM) $${program} \
$(bindir)/$${program}; \
done
$(INSTALL_DATA) $(srcdir)/sane-style.rc $(datadir)/sane-style.rc
xscanimage: $(XSCAN_OBJS) $(LIBSANEI) $(LIBLIB)
$(LINK) $(XSCAN_OBJS) $(LIBSANEI) \
$(LIBLIB) $(GIMP_LIBS) $(GTK_LIBS) $(LIBS) $(SANE_LIBS)
xcam: $(XCAM_OBJS) $(LIBSANEI) $(LIBLIB)
$(LINK) $(XCAM_OBJS) $(LIBSANEI) \
$(LIBLIB) $(GTK_LIBS) $(LIBS) $(SANE_LIBS)
clean:
rm -f *.o *~ .*~ *.bak
rm -rf .libs
distclean: clean
rm -f Makefile $(PROGRAMS)
depend:
makedepend $(INCLUDES) *.c
.PHONY: all install depend clean distclean

1399
src/gtkglue.c 100644

Plik diff jest za duży Load Diff

119
src/gtkglue.h 100644
Wyświetl plik

@ -0,0 +1,119 @@
#ifndef gtkglue_h
#define gtkglue_h
#include <sys/types.h>
#include <gtk/gtk.h>
#include <sane/config.h>
#include <sane/sane.h>
struct GSGDialog;
typedef void (*GSGCallback) (struct GSGDialog *dialog, void *arg);
typedef enum
{
GSG_TL_X, /* top-left x */
GSG_TL_Y, /* top-left y */
GSG_BR_X, /* bottom-right x */
GSG_BR_Y /* bottom-right y */
}
GSGCornerCoordinates;
typedef struct
{
/* The option number of the well-known options. Each of these may
be -1 in case the backend doesn't define the respective option. */
int preview;
int dpi;
int coord[4];
}
GSGWellKnownOptions;
typedef struct
{
gchar *label;
struct GSGDialogElement *elem;
gint index;
}
GSGMenuItem;
typedef struct GSGDialogElement
{
struct GSGDialog *dialog; /* wasteful, but is there a better solution? */
GtkWidget *automatic; /* auto button for options that support this */
GtkWidget *widget;
GtkObject *data;
int menu_size; /* # of items in menu (if any) */
GSGMenuItem *menu;
}
GSGDialogElement;
typedef struct GSGDialog
{
GtkWidget *window;
GtkWidget *main_hbox;
GtkWidget *advanced_vbox;
GtkTooltips *tooltips;
GdkColor tooltips_fg;
GdkColor tooltips_bg;
SANE_Handle *dev;
const char *dev_name;
GSGWellKnownOptions well_known;
int num_elements;
GSGDialogElement *element;
gint idle_id;
u_int rebuild : 1;
u_int advanced : 1;
/* This callback gets invoked whenever the backend notifies us
that the option descriptors have changed. */
GSGCallback option_reload_callback;
void *option_reload_arg;
/* This callback gets invoked whenever the backend notifies us
that the parameters have changed. */
GSGCallback param_change_callback;
void *param_change_arg;
}
GSGDialog;
extern int gsg_message_dialog_active;
/* Construct the path and return it in filename_ret (this buffer must
be at least max_len bytes long). The path is constructed as
follows:
~/.sane/${PROG_NAME}/${PREFIX}${DEV_NAME}${POSTFIX}
If PROG_NAME is NULL, an empty string is used and the leading slash
is removed. On success, 0 is returned, on error a negative number and
ERRNO is set to the appropriate value. */
extern int gsg_make_path (size_t max_len, char *filename_ret,
const char *prog_name,
const char *prefix, const char *dev_name,
const char *postfix);
extern void gsg_message (gchar *title, gchar * message);
extern void gsg_error (gchar * error_message);
extern void gsg_warning (gchar * warning_message);
extern int gsg_get_filename (const char *label, const char *default_name,
size_t max_len, char *filename);
extern GSGDialog *gsg_create_dialog (GtkWidget *window,
const char *device_name,
GSGCallback option_reload_callback,
void *option_reload_arg,
GSGCallback param_callback,
void *param_arg);
extern void gsg_sync (GSGDialog *dialog);
extern void gsg_refresh_dialog (GSGDialog *dialog);
extern void gsg_update_scan_window (GSGDialog *dialog);
extern void gsg_set_advanced (GSGDialog *dialog, int advanced);
extern void gsg_set_tooltips (GSGDialog *dialog, int enable);
extern void gsg_set_sensitivity (GSGDialog *dialog, int sensitive);
extern void gsg_destroy_dialog (GSGDialog * dialog);
#define gsg_dialog_get_device(dialog) ((dialog)->dev)
#endif /* gtkglue_h */

181
src/preferences.c 100644
Wyświetl plik

@ -0,0 +1,181 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <preferences.h>
#include <sane/sane.h>
#include "../include/sane/sanei.h"
#include "../include/sane/sanei_wire.h"
#include "../include/sane/sanei_codec_ascii.h"
#define POFFSET(field) ((char *) &((Preferences *) 0)->field - (char *) 0)
#define PFIELD(p,offset,type) (*((type *)(((char *)(p)) + (offset))))
Preferences preferences =
{
0, /* no preferred device (must be 0 or malloced!) */
0, /* no default filename */
0, /* advanced user */
1, /* tooltips enabled */
10.0, /* length unit */
1, /* preserve_preview */
0, /* preview_own_cmap */
1.0 /* preview_gamma */
};
static void w_string (Wire *w, Preferences *p, long offset);
static void w_double (Wire *w, Preferences *p, long offset);
static void w_int (Wire *w, Preferences *p, long offset);
static struct
{
SANE_String name;
void (*codec) (Wire *w, Preferences *p, long offset);
long offset;
}
desc[] =
{
{"device", w_string, POFFSET(device)},
{"filename", w_string, POFFSET(filename)},
{"advanced", w_int, POFFSET(advanced)},
{"tool-tips", w_int, POFFSET(tooltips_enabled)},
{"length-unit", w_double, POFFSET(length_unit)},
{"preserve-preview", w_int, POFFSET(preserve_preview)},
{"preview-own-cmap", w_int, POFFSET(preview_own_cmap)},
{"preview-gamma", w_double, POFFSET(preview_gamma)},
};
static void
w_string (Wire *w, Preferences *p, long offset)
{
SANE_String string;
if (w->direction == WIRE_ENCODE)
string = PFIELD (p, offset, char *);
sanei_w_string (w, &string);
if (w->direction == WIRE_DECODE)
{
if (w->status == 0)
{
const char **field;
field = &PFIELD (p, offset, const char *);
if (*field)
free ((char *) *field);
*field = string ? strdup (string) : 0;
}
sanei_w_free (w, (WireCodecFunc) sanei_w_string, &string);
}
}
static void
w_double (Wire *w, Preferences *p, long offset)
{
SANE_Word word;
if (w->direction == WIRE_ENCODE)
word = SANE_FIX (PFIELD (p, offset, double));
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
{
if (w->status == 0)
PFIELD (p, offset, double) = SANE_UNFIX (word);
sanei_w_free (w, (WireCodecFunc) sanei_w_word, &word);
}
}
static void
w_int (Wire *w, Preferences *p, long offset)
{
SANE_Word word;
if (w->direction == WIRE_ENCODE)
word = PFIELD (p, offset, int);
sanei_w_word (w, &word);
if (w->direction == WIRE_DECODE)
{
if (w->status == 0)
PFIELD (p, offset, int) = word;
sanei_w_free (w, (WireCodecFunc) sanei_w_word, &word);
}
}
void
preferences_save (int fd)
{
Wire w;
int i;
w.io.fd = fd;
w.io.read = read;
w.io.write = write;
sanei_w_init (&w, sanei_codec_ascii_init);
sanei_w_set_dir (&w, WIRE_ENCODE);
for (i = 0; i < NELEMS (desc); ++i)
{
sanei_w_string (&w, &desc[i].name);
(*desc[i].codec) (&w, &preferences, desc[i].offset);
}
sanei_w_set_dir (&w, WIRE_DECODE); /* flush it out */
}
void
preferences_restore (int fd)
{
SANE_String name;
Wire w;
int i;
w.io.fd = fd;
w.io.read = read;
w.io.write = write;
sanei_w_init (&w, sanei_codec_ascii_init);
sanei_w_set_dir (&w, WIRE_DECODE);
while (1)
{
sanei_w_space (&w, 3);
if (w.status)
return;
sanei_w_string (&w, &name);
if (w.status || !name)
return;
for (i = 0; i < NELEMS (desc); ++i)
{
if (strcmp (name, desc[i].name) == 0)
{
(*desc[i].codec) (&w, &preferences, desc[i].offset);
break;
}
}
}
}

24
src/preferences.h 100644
Wyświetl plik

@ -0,0 +1,24 @@
#ifndef preferences_h
#define preferences_h
#include <sane/sane.h>
typedef struct
{
const char *device; /* name of preferred device (or NULL) */
const char *filename; /* default filename */
int advanced; /* advanced user? */
int tooltips_enabled; /* should tooltips be disabled? */
double length_unit; /* 1.0==mm, 10.0==cm, 25.4==inches, etc. */
int preserve_preview; /* save/restore preview image(s)? */
int preview_own_cmap; /* install colormap for preview */
double preview_gamma; /* gamma value for previews */
}
Preferences;
extern Preferences preferences;
extern void preferences_save (int fd);
extern void preferences_restore (int fd);
#endif /* preferences_h */

1349
src/preview.c 100644

Plik diff jest za duży Load Diff

86
src/preview.h 100644
Wyświetl plik

@ -0,0 +1,86 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
This file is part of the SANE package.
SANE 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.
SANE 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 sane; see the file COPYING. If not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef preview_h
#define preview_h
#include <sys/types.h>
#include <sane/config.h>
#include <sane/sane.h>
typedef struct
{
GSGDialog *dialog; /* the dialog for this preview */
SANE_Value_Type surface_type;
SANE_Unit surface_unit;
float surface[4]; /* the corners of the scan surface (device coords) */
float aspect; /* the aspect ratio of the scan surface */
int saved_dpi_valid;
SANE_Word saved_dpi;
int saved_coord_valid[4];
SANE_Word saved_coord[4];
/* desired/user-selected preview-window size: */
int preview_width;
int preview_height;
u_char *preview_row;
int scanning;
time_t image_last_time_updated;
gint input_tag;
SANE_Parameters params;
int image_offset;
int image_x;
int image_y;
int image_width;
int image_height;
u_char *image_data; /* 3 * image_width * image_height bytes */
GdkGC *gc;
int selection_drag;
struct
{
int active;
int coord[4];
}
selection, previous_selection;
GtkWidget *top; /* top-level widget */
GtkWidget *hruler;
GtkWidget *vruler;
GtkWidget *viewport;
GtkWidget *window; /* the preview window */
GtkWidget *cancel; /* the cancel button */
}
Preview;
/* Create a new preview based on the info in DIALOG. */
extern Preview *preview_new (GSGDialog *dialog);
/* Some of the parameters may have changed---update the preview. */
extern void preview_update (Preview *p);
/* Acquire a preview image and display it. */
extern void preview_scan (Preview *p);
/* Destroy a preview. */
extern void preview_destroy (Preview *p);
#endif /* preview_h */

90
src/progress.c 100644
Wyświetl plik

@ -0,0 +1,90 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Hacked (C) 1996 Tristan Tarrant
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "progress.h"
static const int progress_x = 5;
static const int progress_y = 5;
void
progress_cancel (GtkWidget * widget, gpointer data)
{
Progress_t *p = (Progress_t *) data;
(*p->callback) ();
}
Progress_t *
progress_new (char *title, char *text,
GtkSignalFunc callback, gpointer callback_data)
{
GtkWidget *button, *label;
GtkBox *vbox, *hbox;
Progress_t *p;
p = (Progress_t *) malloc (sizeof (Progress_t));
p->callback = callback;
p->shell = gtk_dialog_new ();
gtk_widget_set_uposition (p->shell, progress_x, progress_y);
gtk_window_set_title (GTK_WINDOW (p->shell), title);
vbox = GTK_BOX (GTK_DIALOG (p->shell)->vbox);
hbox = GTK_BOX (GTK_DIALOG (p->shell)->action_area);
gtk_container_border_width (GTK_CONTAINER (vbox), 7);
label = gtk_label_new (text);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
p->pbar = gtk_progress_bar_new ();
gtk_widget_set_usize (p->pbar, 200, 20);
gtk_box_pack_start (vbox, p->pbar, TRUE, TRUE, 0);
button = gtk_toggle_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) progress_cancel, p);
gtk_box_pack_start (hbox, button, TRUE, TRUE, 0);
gtk_widget_show (label);
gtk_widget_show (p->pbar);
gtk_widget_show (button);
gtk_widget_show (GTK_WIDGET (p->shell));
return p;
}
void
progress_free (Progress_t * p)
{
if (p)
{
gtk_widget_destroy (p->shell);
free (p);
}
}
void
progress_update (Progress_t * p, gfloat newval)
{
if (p)
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), newval);
}

34
src/progress.h 100644
Wyświetl plik

@ -0,0 +1,34 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef progress_h
#define progress_h
typedef struct Progress_t
{
GtkSignalFunc callback;
gpointer callback_data;
GtkWidget *shell;
GtkWidget *pbar;
}
Progress_t;
extern Progress_t *progress_new (char *, char *, GtkSignalFunc, void *);
extern void progress_free (Progress_t *);
extern void progress_update (Progress_t *, gfloat);
#endif /* progress_h */

21
src/sane-style.rc 100644
Wyświetl plik

@ -0,0 +1,21 @@
# style <name> [= <name>]
# {
# <option>
# }
#
# widget <widget_set> style <style_name>
# widget_class <widget_class_set> style <style_name>
# accelerator <widget_name> <accelerator>
style "progressbar"
{
bg[PRELIGHT] = { 22500, 53280, 22500 } # green
}
style "curve"
{
fg[NORMAL] = { 58000, 0, 0 } # red
}
widget "*GtkCurve" style "curve"
widget "*GtkProgressBar" style "progressbar"

484
src/stiff.c 100644
Wyświetl plik

@ -0,0 +1,484 @@
/* Create SANE/tiff headers TIFF interfacing routines for SANE
Copyright (C) 2000 Peter Kirchgessner
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef _AIX
# include <lalloca.h> /* MUST come first for AIX! */
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sane/config.h>
#include <sane/sane.h>
typedef struct {
int tag, typ, nvals, val;
} IFD_ENTRY;
typedef struct {
int maxtags;
int ntags;
IFD_ENTRY *ifde;
} IFD;
#define IFDE_TYP_BYTE (1)
#define IFDE_TYP_ASCII (2)
#define IFDE_TYP_SHORT (3)
#define IFDE_TYP_LONG (4)
#define IFDE_TYP_RATIONAL (5)
static IFD *
create_ifd (void)
{ IFD *ifd;
int maxtags = 10;
ifd = (IFD *)malloc (sizeof (IFD));
if (ifd == NULL) return NULL;
ifd->ifde = (IFD_ENTRY *)malloc (maxtags * sizeof (IFD_ENTRY));
if (ifd->ifde == NULL)
{
free (ifd);
return NULL;
}
ifd->ntags = 0;
ifd->maxtags = maxtags;
return ifd;
}
static void
free_ifd (IFD *ifd)
{
if (ifd == NULL) return;
if (ifd->ifde != NULL)
{
free (ifd->ifde);
ifd->ifde = NULL;
}
free (ifd);
ifd = NULL;
}
static void
add_ifd_entry (IFD *ifd, int tag, int typ, int nvals, int val)
{ IFD_ENTRY *ifde;
int add_entries = 10;
if (ifd == NULL) return;
if (ifd->ntags == ifd->maxtags)
{
ifde = (IFD_ENTRY *)realloc (ifd->ifde,
(ifd->maxtags+add_entries)*sizeof (IFD_ENTRY));
if (ifde == NULL) return;
ifd->ifde = ifde;
ifd->maxtags += add_entries;
}
ifde = &(ifd->ifde[ifd->ntags]);
ifde->tag = tag;
ifde->typ = typ;
ifde->nvals = nvals;
ifde->val = val;
(ifd->ntags)++;
}
static void
write_i2 (FILE *fptr, int val, int motorola)
{
if (motorola)
{
putc ((val >> 8) & 0xff, fptr);
putc (val & 0xff, fptr);
}
else
{
putc (val & 0xff, fptr);
putc ((val >> 8) & 0xff, fptr);
}
}
static void
write_i4 (FILE *fptr, int val, int motorola)
{
if (motorola)
{
putc ((val >> 24) & 0xff, fptr);
putc ((val >> 16) & 0xff, fptr);
putc ((val >> 8) & 0xff, fptr);
putc (val & 0xff, fptr);
}
else
{
putc (val & 0xff, fptr);
putc ((val >> 8) & 0xff, fptr);
putc ((val >> 16) & 0xff, fptr);
putc ((val >> 24) & 0xff, fptr);
}
}
static void
write_ifd (FILE *fptr, IFD *ifd, int motorola)
{int k;
IFD_ENTRY *ifde;
if (!ifd) return;
if (motorola) putc ('M', fptr), putc ('M', fptr);
else putc ('I', fptr), putc ('I', fptr);
write_i2 (fptr, 42, motorola); /* Magic */
write_i4 (fptr, 8, motorola); /* Offset to first IFD */
write_i2 (fptr, ifd->ntags, motorola);
for (k = 0; k < ifd->ntags; k++)
{
ifde = &(ifd->ifde[k]);
write_i2 (fptr, ifde->tag, motorola);
write_i2 (fptr, ifde->typ, motorola);
write_i4 (fptr, ifde->nvals, motorola);
if ((ifde->typ == IFDE_TYP_SHORT) && (ifde->nvals == 1))
{
write_i2 (fptr, ifde->val, motorola);
write_i2 (fptr, 0, motorola);
}
else
{
write_i4 (fptr, ifde->val, motorola);
}
}
write_i4 (fptr, 0, motorola); /* End of IFD chain */
}
static void
write_tiff_bw_header (FILE *fptr, int width, int height, int resolution)
{IFD *ifd;
int header_size = 8, ifd_size;
int strip_offset, data_offset, data_size;
int strip_bytecount;
int ntags;
int motorola;
ifd = create_ifd ();
strip_bytecount = ((width+7)/8) * height;
/* the following values must be known in advance */
ntags = 11;
data_size = 0;
if (resolution > 0)
{
ntags += 3;
data_size += 2*4 + 2*4;
}
ifd_size = 2 + ntags*12 + 4;
data_offset = header_size + ifd_size;
strip_offset = data_offset + data_size;
/* New subfile type */
add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0);
/* image width */
add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, width);
/* image length */
add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, height);
/* bits per sample */
add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 1, 1);
/* compression (uncompressed) */
add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1);
/* photometric interpretation */
add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 0);
/* strip offset */
add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset);
/* orientation */
add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1);
/* samples per pixel */
add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 1);
/* rows per strip */
add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height);
/* strip bytecount */
add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount);
if (resolution > 0)
{
/* x resolution */
add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
/* y resolution */
add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
}
if (resolution > 0)
{
/* resolution unit (dpi) */
add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2);
}
/* I prefer motorola format. Its human readable. */
motorola = 1;
write_ifd (fptr, ifd, motorola);
/* Write x/y resolution */
if (resolution > 0)
{
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
}
free_ifd (ifd);
}
static void
write_tiff_grey_header (FILE *fptr, int width, int height, int depth,
int resolution)
{IFD *ifd;
int header_size = 8, ifd_size;
int strip_offset, data_offset, data_size;
int strip_bytecount;
int ntags;
int motorola, bps, maxsamplevalue;
ifd = create_ifd ();
bps = (depth <= 8) ? 1 : 2; /* Bytes per sample */
maxsamplevalue = (depth <= 8) ? 255 : 65535;
strip_bytecount = width * height * bps;
/* the following values must be known in advance */
ntags = 13;
data_size = 0;
if (resolution > 0)
{
ntags += 3;
data_size += 2*4 + 2*4;
}
ifd_size = 2 + ntags*12 + 4;
data_offset = header_size + ifd_size;
strip_offset = data_offset + data_size;
/* New subfile type */
add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0);
/* image width */
add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, width);
/* image length */
add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, height);
/* bits per sample */
add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 1, 8);
/* compression (uncompressed) */
add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1);
/* photometric interpretation */
add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 1);
/* strip offset */
add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset);
/* orientation */
add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1);
/* samples per pixel */
add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 1);
/* rows per strip */
add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height);
/* strip bytecount */
add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount);
/* min sample value */
add_ifd_entry (ifd, 280, IFDE_TYP_SHORT, 1, 0);
/* max sample value */
add_ifd_entry (ifd, 281, IFDE_TYP_SHORT, 1, maxsamplevalue);
if (resolution > 0)
{
/* x resolution */
add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
/* y resolution */
add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
}
if (resolution > 0)
{
/* resolution unit (dpi) */
add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2);
}
/* I prefer motorola format. Its human readable. But for 16 bit, */
/* the image format is defined by SANE to be the native byte order */
if (bps == 1)
{
motorola = 1;
}
else
{int check = 1;
motorola = ((*((char *)&check)) == 0);
}
write_ifd (fptr, ifd, motorola);
/* Write x/y resolution */
if (resolution > 0)
{
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
}
free_ifd (ifd);
}
static void
write_tiff_color_header (FILE *fptr, int width, int height, int depth,
int resolution)
{IFD *ifd;
int header_size = 8, ifd_size;
int strip_offset, data_offset, data_size;
int strip_bytecount;
int ntags;
int motorola, bps, maxsamplevalue;
ifd = create_ifd ();
bps = (depth <= 8) ? 1 : 2; /* Bytes per sample */
maxsamplevalue = (depth <= 8) ? 255 : 65535;
strip_bytecount = width * height * 3 * bps;
/* the following values must be known in advance */
ntags = 13;
data_size = 3*2 + 3*2;
if (resolution > 0)
{
ntags += 3;
data_size += 2*4 + 2*4;
}
ifd_size = 2 + ntags*12 + 4;
data_offset = header_size + ifd_size;
strip_offset = data_offset + data_size;
/* New subfile type */
add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0);
/* image width */
add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, width);
/* image length */
add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT,
1, height);
/* bits per sample */
add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 1, depth);
/* compression (uncompressed) */
add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1);
/* photometric interpretation */
add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 2);
/* strip offset */
add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset);
/* orientation */
add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1);
/* samples per pixel */
add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 3);
/* rows per strip */
add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height);
/* strip bytecount */
add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount);
/* min sample value */
add_ifd_entry (ifd, 280, IFDE_TYP_SHORT, 3, data_offset);
data_offset += 3*2;
/* max sample value */
add_ifd_entry (ifd, 281, IFDE_TYP_SHORT, 3, data_offset);
data_offset += 3*2;
if (resolution > 0)
{
/* x resolution */
add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
/* y resolution */
add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset);
data_offset += 2*4;
}
if (resolution > 0)
{
/* resolution unit (dpi) */
add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2);
}
/* I prefer motorola format. Its human readable. But for 16 bit, */
/* the image format is defined by SANE to be the native byte order */
if (bps == 1)
{
motorola = 1;
}
else
{int check = 1;
motorola = ((*((char *)&check)) == 0);
}
write_ifd (fptr, ifd, motorola);
/* Write min sample value values */
write_i2 (fptr, 0, motorola);
write_i2 (fptr, 0, motorola);
write_i2 (fptr, 0, motorola);
/* Write max sample value values */
write_i2 (fptr, maxsamplevalue, motorola);
write_i2 (fptr, maxsamplevalue, motorola);
write_i2 (fptr, maxsamplevalue, motorola);
/* Write x/y resolution */
if (resolution > 0)
{
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
write_i4 (fptr, resolution, motorola);
write_i4 (fptr, 1, motorola);
}
free_ifd (ifd);
}
void
sanei_write_tiff_header (SANE_Frame format, int width, int height, int depth,
int resolution)
{
#ifdef __EMX__ /* OS2 - write in binary mode. */
_fsetmode(stdout, "b");
#endif
switch (format)
{
case SANE_FRAME_RED:
case SANE_FRAME_GREEN:
case SANE_FRAME_BLUE:
case SANE_FRAME_RGB:
write_tiff_color_header (stdout, width, height, depth, resolution);
break;
default:
if (depth == 1)
write_tiff_bw_header (stdout, width, height, resolution);
else
write_tiff_grey_header (stdout, width, height, depth, resolution);
break;
}
}

20
src/stiff.h 100644
Wyświetl plik

@ -0,0 +1,20 @@
/* Create SANE/tiff headers TIFF interfacing routines for SANE
Copyright (C) 2000 Peter Kirchgessner
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
void
sanei_write_tiff_header (SANE_Frame format, int width, int height, int depth,
int resolution);

1039
src/xcam.c 100644

Plik diff jest za duży Load Diff

1744
src/xscanimage.c 100644

Plik diff jest za duży Load Diff