fondu-060102/0042755000076500007650000000000010356332477011143 5ustar gwwgwwfondu-060102/MacFiles.h0100644000076500007650000000310610303427300012750 0ustar gwwgww/* I can't find the mac "Files.h" include file under Darwin, so... */ /* Nor the CoreServices/CoreServices.h file that is supposed to replace it */ #define noErr 0 #define eofErr (-39) #define fnfErr (-43) #define dupFNErr (-48) #define fsRdPerm 1 #define fsWrPerm 2 #define smSystemScript (-1) #define kFSCatInfoNodeID 16 typedef unsigned char Str255[256]; typedef unsigned char Str63[64]; typedef struct { /* gcc misaligns this */ short vRefNum; int dirID; Str63 name; } FSSpec; typedef struct { unsigned char hidden[80]; } FSRef; typedef struct { int fdType; int fdCreator; unsigned short fdFlags; short Point_x, Point_y; short fdFldr; int pad; /* Just in case I've screwed up the alignment */ } FInfo; typedef struct FSCatalogInfo { unsigned short nodeFlags; short volume; unsigned int parentDirID; unsigned int nodeID; int padding[50]; /* There's a bunch more junk that I don't care about */ } FSCatalogInfo; short FSpOpenRF(const FSSpec *spec,char permission,short *refNum); void FSpCreateResFile(const FSSpec *spec,int creator,int type,short script); short FSRead(short refNum,long *cnt,char *buf); short FSWrite(short refNum,long *cnt,char *buf); short FSClose(short refNum ); short FSpGetFInfo(const FSSpec *spec,FInfo *fndrInfo); short SetEOF(short refNum,int eofpos); short FSMakeFSSpec(short volume, int dirid,unsigned char *,FSSpec *spec); short FSPathMakeRef(const unsigned char *path,FSRef *ref,int *isDir); short FSGetCatalogInfo(FSRef *ref,int whichinfo,FSCatalogInfo *info,void *null2,FSSpec *spec,void *null3); fondu-060102/LICENSE0100644000076500007650000000276310303427303012134 0ustar gwwgwwPfaEdit is copyright (C) 2000,2001,2002,2003 by George Williams Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The configure script is subject to the GNU public license. See the file COPYING. fondu-060102/VERSION0100664000076500007650000000000710356333026012174 0ustar gwwgww060102 fondu-060102/Makefile.in0100644000076500007650000000363410356332436013204 0ustar gwwgww# @configure_input@ wilprefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ CC = @CC@ srcdir = @srcdir@ VPATH = @srcdir@ HOST= @HOST@ DARWIN_CORE = $(if $(findstring apple-darwin,$(HOST)),/System/Library/Frameworks/CoreServices.framework/CoreServices,) WFLAGS = -Wmissing-prototypes -Wunused -Wimplicit -Wreturn-type -Wparentheses -pedantic CFLAGS = -g $(WFLAGS) FONDUOBJS = fondu.o readnfnt.o fondups.o UFONDOBJS = ufond.o ufondbdf.o ufondpfb.o ufondttf.o crctab.o DFONT2RESOBJS = dfont2res.o crctab.o SHOWOBJS = showfond.o TOBINOBJS = tomacbinary.o crctab.o FROMBINOBJS = frommacbinary.o LUMPEROBJS = lumper.o SETFONDNAMEOBJS = setfondname.o all: fondu ufond showfond dfont2res tobin frombin lumper setfondname fondu: $(FONDUOBJS) $(CC) $(CFLAGS) -o fondu $(FONDUOBJS) -lm $(DARWIN_CORE) ufond: $(UFONDOBJS) $(CC) $(CFLAGS) -o ufond $(UFONDOBJS) showfond: $(SHOWOBJS) $(CC) $(CFLAGS) -o showfond $(SHOWOBJS) $(DARWIN_CORE) dfont2res: $(DFONT2RESOBJS) $(CC) $(CFLAGS) -o dfont2res $(DFONT2RESOBJS) tobin: $(TOBINOBJS) $(CC) $(CFLAGS) -o tobin $(TOBINOBJS) $(DARWIN_CORE) frombin: $(FROMBINOBJS) $(CC) $(CFLAGS) -o frombin $(FROMBINOBJS) $(DARWIN_CORE) lumper: $(LUMPEROBJS) $(CC) $(CFLAGS) -o lumper $(LUMPEROBJS) setfondname: $(SETFONDNAMEOBJS) $(CC) $(CFLAGS) -o setfondname $(SETFONDNAMEOBJS) clean: -rm -f *.o fondu ufond showfond dfont2res tobin frombin lumper setfondname distclean: clean -rm Makefile install: all mkdir -p $(DESTDIR)$(bindir) cp fondu ufond showfond dfont2res tobin frombin lumper setfondname $(DESTDIR)$(bindir) VERSION:=$(shell date +"%y%d%m") DISTNAME=fondu-$(VERSION) DISTFILES=$(wildcard *.c *.1 *.h) README Makefile.in configure.in configure \ LICENSE install-sh config.sub config.guess dist: mkdir $(DISTNAME) ln $(DISTFILES) $(DISTNAME)/ tar cfz $(DISTNAME).tar.gz $(DISTNAME) rm -fr $(DISTNAME) Makefile: Makefile.in chmod +w $@ ./config.status chmod -w $@ fondu-060102/configure0100755000076500007650000027316710356332454013060 0ustar gwwgww#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="fondu.c" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os VPATH HOST LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` export HOST=$host ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then we branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. cat >confdef2opt.sed <<\_ACEOF t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote d : quote s,[ `~#$^&*(){}\\|;'"<>?],\\&,g s,\[,\\&,g s,\],\\&,g s,\$,$$,g p _ACEOF # We use echo to avoid assuming a particular line-breaking character. # The extra dot is to prevent the shell from consuming trailing # line-breaks from the sub-command output. A line-break within # single-quotes doesn't work because, if this script is created in a # platform that uses two characters for line-breaks (e.g., DOS), tr # would break. ac_LF_and_DOT=`echo; echo .` DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` rm -f confdef2opt.sed ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@VPATH@,$VPATH,;t t s,@HOST@,$HOST,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi chmod -w Makefile fondu-060102/config.guess0100755000076500007650000011315010303427330013440 0ustar gwwgww#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. timestamp='2001-09-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c ; for c in cc gcc c89 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; if test $? = 0 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # Netbsd (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # Determine the machine/vendor (is the vendor relevant). case "${UNAME_MACHINE}" in amiga) machine=m68k-unknown ;; arm32) machine=arm-unknown ;; atari*) machine=m68k-atari ;; sun3*) machine=m68k-sun ;; mac68k) machine=m68k-apple ;; macppc) machine=powerpc-apple ;; hp3[0-9][05]) machine=m68k-hp ;; ibmrt|romp-ibm) machine=romp-ibm ;; *) machine=${UNAME_MACHINE}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE}" in i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; 2-1307) UNAME_MACHINE="alphaev68" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; arc64:OpenBSD:*:*) echo mips64el-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hkmips:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; sparc*:NetBSD:*) echo `uname -p`-unknown-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) case "${HPUX_REV}" in 11.[0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; esac ;; esac fi ;; esac if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; hppa*:OpenBSD:*:*) echo hppa-unknown-openbsd exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 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/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in big) echo mips-unknown-linux-gnu && exit 0 ;; little) echo mipsel-unknown-linux-gnu && exit 0 ;; esac ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. ld_supported_targets=`cd /; ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build cat >$dummy.c < #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 printf ("%s-pc-linux-gnu\n", argv[1]); # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif # else printf ("%s-pc-linux-gnulibc1\n", argv[1]); # endif #else printf ("%s-pc-linux-gnuaout\n", argv[1]); #endif return 0; } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) if test "${UNAME_MACHINE}" = "x86pc"; then UNAME_MACHINE=pc fi echo `uname -p`-${UNAME_MACHINE}-nto-qnx exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[KW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos 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 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: fondu-060102/README0100644000076500007650000000164610303427331012007 0ustar gwwgwwBUILDING FONDU Just type: $ configure $ make # make install RUNNING FONDU fondu mac-font-files Will convert a series of mac font files (copied over to unix in binhex or macbinary formats) into their equivalent unix font files. ufond unix-font-files Will convert a series of unix font files into the equivalent mac font file(s) If several of the unix fonts have the same font family, then they will all be placed in one mac FOND (family). showfond mac-font-files Will show some information about various mac font resources. tobin files Will take a list of files and convert them into macbinary format frombin files Will take a list of files and convert them from macbinary format (on non-max platforms each output file may be split into three files .data For the data fork .rcsc For the resource fork .info For random info on the font fondu-060102/frommacbinary.c0100644000076500007650000002044310303430002014105 0ustar gwwgww/* Copyright (C) 2002-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #if __Mac # include /* -I/Developer/Headers/FlatCarbon/ */ #endif /* A MacBinary file */ /* http://www.lazerware.com/formats/macbinary.html */ /* begins with a 128 byte header */ /* (which specifies lengths for data/resource forks) */ /* (and contains mac type/creator data) */ /* (and other stuff) */ /* (and finally a crc checksum) /* is followed by the data section (padded to a mult of 128 bytes) */ /* is followed by the resource section (padded to a mult of 128 bytes) */ /* Crc code taken from: */ /* http://www.ctan.org/tex-archive/tools/macutils/crc/ */ /* MacBinary files use the same CRC that binhex does (in the MacBinary header) */ extern unsigned long binhex_crc(unsigned char *buffer,int size); /* frombin filenames */ static void Usage(char *prog) { fprintf( stderr, "Usage: %s [-usage] [-help] [-version] filenames\n" ); fprintf( stderr, " -usage\t\tPrints this message\n" ); fprintf( stderr, " -help\t\tPrints this message\n" ); fprintf( stderr, " -version\t\tPrints the version of the program\n" ); fprintf( stderr, "Takes a list of macbinary filenames and extracts the contents\n" ); fprintf( stderr, " on the mac it creates the obvious file.\n" ); fprintf( stderr, " on non-mac systems it will create up to three files for each input file\n"); fprintf( stderr, " *.info contains some mac specific data\n" ); fprintf( stderr, " *.data contains the data fork (if present)\n" ); fprintf( stderr, " *.rsrc contains the resource fork (if present)\n" ); exit( 1 ); } static void ProcessFile(char *filename) { FILE *binfile; unsigned char header[128]; char name[80]; int dlen, rlen; int i,ch; binfile = fopen(filename,"r"); if ( binfile==NULL ) { fprintf( stderr, "Cannot open %s\n", filename); return; } fread(header,1,sizeof(header),binfile); if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 || header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 ) { fprintf( stderr, "%s does not look like a macbinary file\n", filename ); fclose(binfile); return; } strncpy(name,(char *) header+2,header[1]); name[header[1]] = '\0'; dlen = ((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); rlen = ((header[0x57]<<24)|(header[0x58]<<16)|(header[0x59]<<8)|header[0x5a]); fprintf( stderr, " %s => %s, dfork len=%d rfork len=%d\n", filename, name, dlen, rlen ); #ifndef __Mac { FILE *datafile, *resfile, *infofile; if ( dlen>0 ) { fseek(binfile,128,SEEK_SET); strcpy(name+header[1],".data"); datafile = fopen(name,"w"); if ( datafile==NULL ) fprintf( stderr, "Cannot open output file: %s\n", name ); else { for ( i=0; i0 ) { fseek(binfile,128 + ((dlen+127)&~127),SEEK_SET); strcpy(name+header[1],".rsrc"); resfile = fopen(name,"w"); if ( resfile==NULL ) fprintf( stderr, "Cannot open output file: %s\n", name ); else { for ( i=0; i0 || rlen>0 ) { fseek(binfile,128,SEEK_SET); name[header[1]]='\0'; datafile = fopen(name,"w"); if ( datafile==NULL ) fprintf( stderr, "Cannot open output file: %s\n", name ); else { for ( i=0; i0 ) { fseek(binfile,128 + ((dlen+127)&~127),SEEK_SET); strcpy(name+header[1],"/rsrc"); resfile = fopen(name,"w"); if ( resfile==NULL ) fprintf( stderr, "Cannot open output file: %s\n", name ); else { for ( i=0; ifdType = (header[65]<<24)|(header[66]<<16)|(header[67]<<8)|header[68]; ((FInfo *) (info.finderInfo))->fdCreator = (header[69]<<24)|(header[70]<<16)|(header[71]<<8)|header[72]; FSSetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info); } } } } } #else /* __Mac */ { FILE *file; FSRef ref; FSSpec spec; int creator, type; long len; short macfile; unsigned char *buf; file = fopen( name,"w"); if ( file==NULL ) fprintf(stderr, "Cannot open output file: %s\n", name ); else { /* First the data fork */ fseek(binfile,128,SEEK_SET); for ( i=0; i0 ; i+= len ) { if ( i+len>rlen ) len = rlen-i; FSWrite(macfile,&len,buf); } FSClose(macfile); free(buf); } } } } #endif fclose(binfile); } int main( int argc, char **argv) { int i; for ( i=1; i. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dsp16xx \ | fr30 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | m32r | m68000 | m68k | m88k | mcore \ | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el | mips64vr4300 \ | mips64vr4300el | mips64vr5000 | mips64vr5000el \ | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ | mipsisa32 \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | s390 | s390x \ | sh | sh[34] | sh[34]eb | shbe | shle \ | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ | stormy16 | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 \ | we32k \ | x86 | xscale \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alphapca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armv*-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cray2-* | cydra-* \ | d10v-* | d30v-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | m32r-* \ | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | s390-* | s390x-* \ | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [cjt]90) basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=t3e-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb) basic_machine=sh-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: fondu-060102/configure.in0100644000076500007650000000031310356332436013437 0ustar gwwgwwdnl Process this file with autoconf to produce a configure script. AC_INIT(fondu.c) AC_PROG_CC AC_CANONICAL_HOST export HOST=$host AC_SUBST(VPATH) AC_SUBST(HOST) AC_OUTPUT(Makefile) chmod -w Makefile fondu-060102/crctab.c0100644000076500007650000000560710303430002012517 0ustar gwwgww/* GWW: taken from http://www.ctan.org/tex-archive/tools/macutils/crc/ */ /* This is the output (slightly modified) of makecrc for the binhex case */ extern unsigned long binhex_crc(unsigned char *buffer,int size); static const unsigned long binhex_crcinit = 0; static unsigned short crctab[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, }; static unsigned long binhex_updcrc(icrc, icp, icnt) unsigned long icrc; unsigned char *icp; int icnt; { #define M1 0xff #define M2 0xff00 register unsigned long crc = icrc; register unsigned char *cp = icp; register int cnt = icnt; while(cnt--) { crc=((crc<<8)&M2)^crctab[((crc>>8)&0xff)^*cp++]; } return(crc); } unsigned long binhex_crc(unsigned char *buffer,int size) { return ( binhex_updcrc(binhex_crcinit,buffer,size)); } fondu-060102/dfont2res.10100644000076500007650000000112710303427401013107 0ustar gwwgww.TH DFONT2RES 1 "23 October 2002" .SH NAME dfont2res \- convert Macintosh dfont font file format to Macintosh resource fork format .SH SYNOPSIS .B dfont2res .B dfontfile .SH DESCRIPTION The program .B dfont2res converts a font from the new data fork resource file (.dfont) format (as used under MacOS X) to the older resource fork format. .SH AUTHOR George Williams (gww@silcom.com). .LP Manual page by Ziying Sherwin (sherwin@nlm.nih.gov) and R.P.C Rodgers (rodgers@nlm.nih.gov), Lister Hill National Center for Biomedical Communications, U.S. National Library of Medicine. .\" end of manual page fondu-060102/dfont2res.c0100644000076500007650000001550610303430002013166 0ustar gwwgww/* Copyright (C) 2002 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include "ufond.h" static void Usage(char *prog) { fprintf(stderr, "Usage: %s mac-dfont {mac-dfonts}\n", prog ); fprintf(stderr, "\tTakes a list of mac-dfont files and generates corresponding resource\n" ); fprintf(stderr, "\tfork files (in a macbinary wrapper)\n" ); exit(0); } /* A MacBinary file */ /* http://www.lazerware.com/formats/macbinary.html */ /* begins with a 128 byte header */ /* (which specifies lengths for data/resource forks) */ /* (and contains mac type/creator data) */ /* (and other stuff) */ /* (and finally a crc checksum) /* is followed by the data section (padded to a mult of 128 bytes) */ /* is followed by the resource section (padded to a mult of 128 bytes) */ /* Crc code taken from: */ /* http://www.ctan.org/tex-archive/tools/macutils/crc/ */ /* MacBinary files use the same CRC that binhex does (in the MacBinary header) */ extern unsigned long binhex_crc(unsigned char *buffer,int size); static void DumpMacBinaryHeader(FILE *res,struct macbinaryheader *mb) { uint8 header[128], *hpt; char buffer[256], *pt, *dpt; uint32 len; time_t now; int i,crc; if ( mb->macfilename==NULL ) { char *pt = strrchr(mb->binfilename,'/'); if ( pt==NULL ) pt = mb->binfilename; else ++pt; strcpy(buffer,pt); dpt = strrchr(buffer,'.'); if ( dpt==NULL ) { buffer[0] = '_'; strcpy(buffer+1,pt); } else *dpt = '\0'; mb->macfilename = buffer; buffer[63] = '\0'; } memset(header,'\0',sizeof(header)); hpt = header; *hpt++ = '\0'; /* version number */ /* Mac Filename */ pt = mb->macfilename; *hpt++ = strlen( pt ); while ( *pt ) *hpt++ = *pt++; while ( hpttype>>24; *hpt++ = mb->type>>16; *hpt++ = mb->type>>8; *hpt++ = mb->type; /* Mac Creator */ *hpt++ = mb->creator>>24; *hpt++ = mb->creator>>16; *hpt++ = mb->creator>>8; *hpt++ = mb->creator; *hpt++ = '\0'; /* No finder flags set */ *hpt++ = '\0'; /* (byte 74) MBZ */ *hpt++ = '\0'; *hpt++ = '\0'; /* Vert Position in folder */ *hpt++ = '\0'; *hpt++ = '\0'; /* Hor Position in folder */ *hpt++ = '\0'; *hpt++ = '\0'; /* window or folder id??? */ *hpt++ = '\0'; /* protected bit ??? */ *hpt++ = '\0'; /* (byte 82) MBZ */ /* Data fork length */ *hpt++ = '\0'; *hpt++ = '\0'; *hpt++ = '\0'; *hpt++ = '\0'; /* Resource fork length */ fseek(res,0,SEEK_END); len = ftell(res)-sizeof(header); *hpt++ = len>>24; *hpt++ = len>>16; *hpt++ = len>>8; *hpt++ = len; /* Pad resource fork to be a multiple of 128 bytes */ while ( (len&127)!=0 ) { putc('\0',res); ++len; } /* Creation time, (seconds from 1/1/1904) */ time(&now); /* convert from 1970 based time to 1904 based time */ now += (1970-1904)*365L*24*60*60; for ( i=1904; i<1970; i+=4 ) now += 24*60*60; /* Ignore any leap seconds */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; /* Modification time, (seconds from 1/1/1904) */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; *hpt++ = '\0'; *hpt++ = '\0'; /* Get Info comment length */ *hpt++ = 0; /* More finder flags */ /* MacBinary 3 */ memcpy(header+102,"mBIN",4); header[106] = 0; /* Script. I assume 0 is latin */ header[107] = 0; /* extended finder flags */ /* End of MacBinary 3 */ header[122] = 130; /* MacBinary version 3, written in (129 is MB2) */ header[123] = 129; /* MacBinary Version 2, needed to read */ crc = binhex_crc(header,124); header[124] = crc>>8; header[125] = crc; fseek(res,0,SEEK_SET); fwrite(header,1,sizeof(header),res); } static void CopyFile(FILE *out, FILE *in, char *filename) { struct macbinaryheader header; char buffer[1024], *pt; unsigned char ubuf[16]; int len, map_pos; memset(buffer,0,128); fwrite(buffer,1,128,out); /* Fake Mac binary header */ /* Copy the file */ while ( (len=fread(buffer,1,1024,in))>0 ) fwrite(buffer,1,len,out); /* dfonts have a slightly different map header than do resource forks */ /* make the header appropriate for a fork */ rewind(in); fread(ubuf,1,16,in); map_pos = 128 + ((ubuf[4]<<24)|(ubuf[5]<<16)|(ubuf[6]<<8)|ubuf[7]); fseek(out,map_pos,SEEK_SET); fwrite(buffer,1,16,out); /* And now the macbinary header */ pt = strrchr(filename,'/'); if ( pt==NULL ) strcpy(buffer,filename); else strcpy(buffer,pt+1); pt = strstr(buffer,".dfont"); if ( pt==NULL ) pt = strrchr(buffer,'.'); if ( pt!=NULL ) *pt = '\0'; header.type = CHR('F','F','I','L'); header.creator = CHR('D','M','O','V'); header.macfilename = buffer; DumpMacBinaryHeader(out,&header); } int main( int argc, char **argv) { int i; FILE *in, *out; char buffer[1024], *pt; if ( argc==1 ) Usage(argv[0]); for ( i=1; i #include #include #include #include #include #include #include #include "macfonts.h" int tolatin1 = false; static int force = false, inquire = false, doafm = false, trackps = false, show=false; int getushort(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); if ( ch2==EOF ) return( EOF ); return( (ch1<<8)|ch2 ); } long getlong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 ); } static int _cleanfilename(char *filename) { char *pt, *npt; int ch, exists, ch2; for ( ch = *(pt=npt=filename); ch!='\0'; ch = *++pt ) { if ( ch>'!' && ch!='*' && ch!='?' && ch!='/' && ch!='\\' && ch!='[' && ch<0x7f ) *npt++ = ch; } *npt = '\0'; if ( force && !inquire ) return( true ); exists = access(filename,F_OK)==0; forever { if ( exists ) fprintf( stderr, "%s exists, do you want to overwrite it? (n) ", filename ); else if ( inquire ) fprintf( stderr, "Write %s? (y) ", filename ); else return( true ); ch = getchar(); if ( ch=='q' || ch=='Q' ) exit(0); if ( ch=='a' || ch=='A' ) { force = true; inquire = false; return( true ); } if ( ch=='y' || ch=='Y' || ch=='n' || ch=='N' || ch==EOF || ch=='\n' ) { if ( ch=='\n' || ch==EOF ) ch = exists ? 'n' : 'y'; else while ( (ch2=getchar())!='\n' && ch2!=EOF ); return( ch=='y' || ch=='Y' ); } else if ( ch=='=' ) { for ( pt=filename; (ch=getchar())!=EOF && ch!='\n'; ) *pt++ = ch; return( true ); } else { fprintf( stderr, "Please answer with 'y'(es), 'n'(o), 'q'(uit), 'a'(ll), or '=new-filename'.\n" ); } } } int cleanfilename(char *filename) { int ret = _cleanfilename(filename); if ( ret && show ) fprintf( stderr, "Creating %s\n", filename ); return( ret ); } static void mytmpname(char *temp) { static int upos; /* build up a temporary filename that doesn't match anything else */ forever { sprintf( temp, "fondu%04X-%d", getpid(), ++upos ); if ( access(temp,F_OK)==-1 ) return; } } /* The mac has rules about what the filename should be for a postscript*/ /* font. If you deviate from those rules the font will not be found */ /* The font name must begin with a capital letter */ /* The filename is designed by modifying the font name */ /* After the initial capital there can be at most 4 lower case letters (or digits) */ /* in the filename, any additional lc letters (or digits) in the fontname are ignored */ /* Every subsequent capital will be followed by at most 2 lc letters */ /* special characters ("-$", etc.) are removed entirely */ /* So Times-Bold => TimesBol, HelveticaDemiBold => HelveDemBol */ static char *FileNameFromPSFontName(char *fontname) { char *filename = strdup(fontname); char *pt, *spt, *lcpt; for ( pt = filename, spt = fontname; *spt /*&& ptfontname==NULL ) { char *pt = strrchr(filename,'.'); char *ept = strrchr(filename,'/'); if ( pt!=NULL && pt>ept ) *pt = '\0'; fprintf( stderr, "Failed to find file %s when searching for a postscript resource\n", filename ); } free(filename); } static FILE *CreateAfmFile(FILE *f,FOND *fond,int style, char *fontname,char *familyname, PSFONT *psfont, char *origfilename) { char namebuf[300]; int i; FILE *afm; memset(psfont,0,sizeof(PSFONT)); if ( !(style&4) && fond->psnames[(style&3)|((style&~7)>>1)]!=NULL ) { /* postscript name table doesn't include underline styles */ char *fn = fond->psnames[(style&3)|((style&~7)>>1)]; strcpy(familyname,fond->family); strcpy(fontname,fn); ProcessNestedPS( fn, origfilename, psfont ); if ( psfont->familyname!=NULL ) strcpy(familyname,psfont->familyname); /* Different in URW fonts */ } else { if ( fond->family!=NULL ) strcpy(familyname,fond->family); else if ( fond->fondname!=NULL ) strcpy(familyname,fond->fondname); else strcpy(familyname,"Nameless"); strcpy(fontname,familyname); for ( i=0; styles[i]!=NULL ; ++i ) if ( style&(1<hadvance*1000/em) ); fprintf( afm, "N %s ; B %d %d %d %d ;", bb->glyphname, (int) floor(bb->left*1000/em), (int) floor(bb->bottom*1000/em), (int) ceil(bb->right*1000/em), (int) ceil(bb->top*1000/em) ); if ( strcmp(bb->glyphname,"fi")==0 ) fprintf( afm, " L f i ;" ); else if ( strcmp(bb->glyphname,"fl")==0 ) fprintf( afm, " L f l ;" ); else if ( strcmp(bb->glyphname,"ff")==0 ) fprintf( afm, " L f f ;" ); putc('\n',afm); } static void MakeAfmFiles(FOND *fond,FILE *f, int isfixed,char *origfilename) { long start = ftell(f); int ii,i,j,k,l,dups; FILE *afm; time_t now; char fontname[256], familyname[256]; char buffer[32]; PSFONT psfont; for ( ii=0; ii<48; ++ii ) { int style = ((ii&3)|((ii&~3)<<1)); for ( i=fond->stylekerncnt-1; i>=0; --i ) if ( fond->stylekerns[i].style==style ) break; if ( i==-1 && fond->psnames[ii]==NULL ) continue; afm = CreateAfmFile(f,fond,style, fontname,familyname,&psfont,origfilename); if ( afm==NULL ) continue; fprintf( afm, "StartFontMetrics 2.0\n" ); if ( psfont.fontname==NULL ) fprintf( afm, "Comment Caveat: This does not contain all the information generally found in an AFM file\n" ); fprintf( afm, "Comment Generated by Fondu from a mac FOND resource\n" ); time(&now); fprintf( afm, "Comment Creation Date: %s", ctime(&now) ); fprintf( afm, "FontName %s\n", fontname ); fprintf( afm, "FamilyName %s\n", familyname ); fprintf( afm, "IsFixedPitch %s\n", isfixed?"true":"false"); if ( psfont.fontname!=NULL ) { if ( psfont.fullname ) fprintf( afm, "FullName %s\n", psfont.fullname ); if ( psfont.weight ) fprintf( afm, "Weight %s\n", psfont.weight ); if ( psfont.notice ) fprintf( afm, "Notice (%s)\n", psfont.notice ); if ( psfont.version ) fprintf( afm, "Version (%s)\n", psfont.version ); fprintf( afm, "ItalicAngle %g\n", psfont.italicangle ); fprintf( afm, "EncodingScheme %s\n", psfont.isadobestd ? "AdobeStandardEncoding" : "FontSpecific" ); fprintf( afm, "FontBBox %g %g %g %g\n", psfont.fbb[0], psfont.fbb[1], psfont.fbb[2], psfont.fbb[3] ); if ( psfont.xh!=0 ) fprintf( afm, "XHeight %d\n", psfont.xh ); if ( psfont.ch!=0 ) fprintf( afm, "CapHeight %d\n", psfont.ch ); if ( psfont.as!=0 ) fprintf( afm, "Ascender %d\n", psfont.as ); if ( psfont.ds!=0 ) fprintf( afm, "Descender %d\n", psfont.ds ); dups = 0; for ( k=0; k<256; ++k ) { if ( strcmp(psfont.glyphs[psfont.encoding[k]].glyphname,".notdef")==0 && psfont.glyphs[0].isref ) continue; for ( l=psfont.glyphcnt-1; l>=0; --l ) if ( strcmp(psfont.glyphs[psfont.encoding[k]].glyphname,psfont.glyphs[l].glyphname)==0 ) break; if ( l==-1 ) continue; else if ( !psfont.glyphs[l].isref ) psfont.glyphs[l].isref = true; else ++dups; } fprintf( afm, "StartCharMetrics %d\n", psfont.glyphcnt+dups ); psfont.glyphs[0].isref = false; for ( k=0; k<256; ++k ) { if ( strcmp(psfont.glyphs[psfont.encoding[k]].glyphname,".notdef")==0 && psfont.glyphs[0].isref ) continue; for ( l=psfont.glyphcnt-1; l>=0; --l ) if ( strcmp(psfont.glyphs[psfont.encoding[k]].glyphname,psfont.glyphs[l].glyphname)==0 ) break; if ( l==-1 ) continue; AfmBB(afm,&psfont.glyphs[l],k,psfont.em); psfont.glyphs[l].isref = true; } for ( l=0; lstylewidthcnt-1; j>=0; --j ) if ( style==fond->stylewidths[j].style ) break; if ( j!=-1 ) { fprintf( afm, "StartCharMetrics %d\n", fond->last-fond->first+1 ); for ( k=fond->first; k<=fond->last; ++k ) { const char *name; if ( k<=256 && macnames[k]!=NULL ) name = macnames[k]; else { sprintf( buffer, "char%04x", k ); name = buffer; } fprintf( afm, "C %d ; WX %d ; N %s ;\n", /* No bounding box info */ k>=256?-1:k, (fond->stylewidths[j].widthtab[k-fond->first]*1000 + (1<<11))>>12, name ); } } else fprintf( afm, "StartCharMetrics 0\n" ); } fprintf( afm, "EndCharMetrics\n" ); if ( i!=-1 ) { /* kerning data are from the fond. so they are in mac encoding */ /* the pfb's encoding is irrelevant in this section */ fprintf( afm, "StartKernData\nStartKernPairs %d\n", fond->stylekerns[i].kernpairs ); for ( k=0; kstylekerns[i].kernpairs; ++k ) { const char *name1, *name2; struct kerns *kp = &fond->stylekerns[i].kerns[k]; if ( 1 /* kp->ch1<=256 */ ) name1 = macnames[kp->ch1]; else { sprintf( buffer, "char%04x", kp->ch1 ); name1 = buffer; } if ( name1==NULL ) name1 = ".notdef"; if ( 1 /* kp->ch2<=256 */ ) name2 = macnames[kp->ch2]; else { sprintf( fontname, "char%04x", kp->ch2 ); name2 = fontname; } if ( name2==NULL ) name2 = ".notdef"; fprintf( afm, "KPX %s %s %d\n", name1, name2, (kp->offset*1000+(1<<11))>>12 ); } fprintf( afm, "EndKernPairs\nEndKernData\n"); } fprintf( afm, "EndFontMetrics\n" ); fclose( afm ); } fseek(f,start,SEEK_SET); } /* There's probably only one fond in the file, but there could be more so be */ /* prepared... */ /* I want the fond: */ /* to get the fractional widths for the SWIDTH entry on bdf */ /* to get the font name */ /* to get the font association tables */ /* to get the style flags */ /* http://developer.apple.com/techpubs/mac/Text/Text-269.html */ static FOND *BuildFondList(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list,char *origfilename) { long here, start = ftell(f); long offset; int rname = -1; char name[300]; int ch1, ch2; int i, j, k, cnt, isfixed; FOND *head=NULL, *cur; long widoff, kernoff, styleoff; fseek(f,rlistpos,SEEK_SET); for ( i=0; inext = head; head = cur; if ( rname!=-1 ) { fseek(f,name_list+rname,SEEK_SET); ch1 = getc(f); fread(name,1,ch1,f); name[ch1] = '\0'; cur->fondname = strdup(name); } offset += 4; fseek(f,offset,SEEK_SET); isfixed = getushort(f)&0x8000?1:0; /* family id = */ getushort(f); cur->first = getushort(f); cur->last = getushort(f); /* on a 1 point font... */ /* ascent = */ getushort(f); /* descent = */ (short) getushort(f); /* leading = */ getushort(f); /* widmax = */ getushort(f); if ( (widoff = getlong(f))!=0 ) widoff += offset; if ( (kernoff = getlong(f))!=0 ) kernoff += offset; if ( (styleoff = getlong(f))!=0 ) styleoff += offset; for ( j=0; j<9; ++j ) getushort(f); /* internal & undefined, for international scripts = */ getlong(f); /* version = */ getushort(f); cur->assoc_cnt = getushort(f)+1; cur->assoc = calloc(cur->assoc_cnt,sizeof(struct assoc)); for ( j=0; jassoc_cnt; ++j ) { cur->assoc[j].size = getushort(f); cur->assoc[j].style = getushort(f); cur->assoc[j].id = getushort(f); } if ( widoff!=0 ) { fseek(f,widoff,SEEK_SET); cnt = getushort(f)+1; cur->stylewidthcnt = cnt; cur->stylewidths = calloc(cnt,sizeof(struct stylewidths)); for ( j=0; jstylewidths[j].style = getushort(f); cur->stylewidths[j].widthtab = malloc((cur->last-cur->first+3)*sizeof(short)); for ( k=cur->first; k<=cur->last+2; ++k ) cur->stylewidths[j].widthtab[k] = getushort(f); } } if ( kernoff!=0 ) { fseek(f,kernoff,SEEK_SET); cnt = getushort(f)+1; cur->stylekerncnt = cnt; cur->stylekerns = calloc(cnt,sizeof(struct stylekerns)); for ( j=0; jstylekerns[j].style = getushort(f); cur->stylekerns[j].kernpairs = getushort(f); cur->stylekerns[j].kerns = malloc(cur->stylekerns[j].kernpairs*sizeof(struct kerns)); for ( k=0; kstylekerns[j].kernpairs; ++k ) { cur->stylekerns[j].kerns[k].ch1 = getc(f); cur->stylekerns[j].kerns[k].ch2 = getc(f); cur->stylekerns[j].kerns[k].offset = getushort(f); } } } if ( styleoff!=0 ) { unsigned char stringoffsets[48]; int strcnt, strlen, format; char **strings, *pt; fseek(f,styleoff,SEEK_SET); /* class = */ getushort(f); /* glyph encoding offset = */ getlong(f); /* reserved = */ getlong(f); for ( j=0; j<48; ++j ) stringoffsets[j] = getc(f); strcnt = getushort(f); strings = malloc(strcnt*sizeof(char *)); for ( j=0; j=0; --k ) if ( stringoffsets[j]==stringoffsets[k] ) break; if ( k!=-1 || stringoffsets[j]==0 ) continue; /* this style doesn't exist */ format = stringoffsets[j]-1; strlen = strings[0][0]; if ( format!=0 && format!=-1 ) for ( k=0; kpsnames[j] = malloc(strlen+1); strcpy(pt,strings[ 0 ]+1); pt += strings[ 0 ][0]; if ( format!=0 && format!=-1 ) for ( k=0; kfamily = strdup(strings[0]); for ( j=0; j>8)&0xff,pfb); putc((len>>16)&0xff,pfb); putc(len>>24,pfb); fseek(pfb,hold,SEEK_SET); if ( ch1==5 ) /* end of font mark */ break; putc(0x80,pfb); putc(ch1,pfb); lenpos = ftell(pfb); putc(0,pfb); putc(0,pfb); putc(0,pfb); putc(0,pfb); type = ch1; len = rlen; } if ( rlen>max ) { free(buffer); max = rlen; if ( max<0x800 ) max = 0x800; buffer=malloc(max); if ( buffer==NULL ) { fprintf( stderr, "Out of memory\n" ); exit( 1 ); } } fread(buffer,1,rlen,f); if ( type==1 ) { int j; char *pt; for ( j=0; j>8)&0xff,pfb); putc((len>>16)&0xff,pfb); putc(len>>24,pfb); if ( psfont!=NULL ) { rewind(pfb); ParsePfb(pfb,psfont); } fclose(pfb); if ( psfont==NULL ) { if ( cleanfilename(newname)) { if ( rename(name,newname)==-1 ) { fprintf( stderr, "Could not create %s\n", newname); unlink(name); } } else unlink(name); } fseek(f,here,SEEK_SET); } static int ttfnamefixup(FILE *ttf,char *buffer) { int version, isotf=false; int i,num, nameoffset, stringoffset; int fullval, famval, fullstr, famstr, fulllen, famlen, val, tag; int plat, spec, lang, name, len, off, ch; char *pt; rewind(ttf); if ( (version=getlong(ttf))==CHR('O','T','T','O')) isotf = true; else if ( version!=0x10000 && version!=CHR('t','r','u','e')) return(false); /* Not going to mess with ttc collections, or whatever else this might be */ num = getushort(ttf); /* srange = */ getushort(ttf); /* esel = */ getushort(ttf); /* rshift = */ getushort(ttf); for ( i=0; ifullval ) { fullval = val; fullstr = off; fulllen = len; if ( val==2 || val==3 ) break; } else if ( name==1 && val>famval ) { famval = val; famstr = off; famlen = len; } } if ( fullval==0 ) { if ( famval==0 ) return( false ); fullstr = famstr; fulllen = famlen; } fseek(ttf,stringoffset+fullstr,SEEK_SET); pt = buffer; if ( val==3 ) { for ( i=0; i'!' && ch!='*' && ch!='?' && ch!='/' && ch!='\\' && ch<0x7f ) *pt++ = ch; } } else { for ( i=0; i'!' && ch!='*' && ch!='?' && ch!='/' && ch!='\\' && ch<0x7f ) *pt++ = ch; } } strcpy(pt,isotf?".otf":".ttf"); return( true ); } static void ttfnameset(FILE *ttf,char *curname,char *patheticattempt) { char buffer[1024]; if ( !ttfnamefixup(ttf,buffer)) strcpy(buffer,patheticattempt); if ( !cleanfilename(buffer)) unlink(curname); else if ( rename(curname, buffer)==-1 ) { fprintf( stderr, "Could not create %s\n", buffer ); unlink(curname); } } static void SearchTtfResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds) { long here, start = ftell(f); long roff; int rname = -1; char name[300], newname[300]; int ch1, ch2; static int ucnt; int len, i, rlen, ilen; /* I think (hope) the sfnt resource is just a copy of the ttf file */ char *buffer=NULL; int max = 0; FILE *ttf; fseek(f,rlistpos,SEEK_SET); for ( i=0; i16*1024 ) ilen = 16*1024; if ( ilen>max ) { free(buffer); max = ilen; if ( max<0x800 ) max = 0x800; buffer=malloc(max); } for ( len=0; len0 ) { len = dlen > 8192 ? 8192 : dlen; len = fread(buffer,1,dlen > 8192 ? 8192 : dlen,binary); if ( len==0 ) break; fwrite(buffer,1,len,out); dlen -= len; } fclose(out); free(buffer); return( true ); } static int IsResourceFork(FILE *f, long offset,char *filename, PSFONT *psfont) { /* If it is a good resource fork then the first 16 bytes are repeated */ /* at the location specified in bytes 4-7 */ /* We include an offset because if we are looking at a mac binary file */ /* the resource fork will actually start somewhere in the middle of the */ /* file, not at the beginning */ unsigned char buffer[16], buffer2[16]; long rdata_pos, map_pos, type_list, name_list, rpos; long rdata_len, map_len; unsigned long tag; int i, cnt, subcnt; FOND *fondlist=NULL, *fl; fseek(f,offset,SEEK_SET); if ( fread(buffer,1,16,f)!=16 ) return( false ); rdata_pos = offset + ((buffer[0]<<24)|(buffer[1]<<16)|(buffer[2]<<8)|buffer[3]); map_pos = offset + ((buffer[4]<<24)|(buffer[5]<<16)|(buffer[6]<<8)|buffer[7]); rdata_len = ((buffer[8]<<24)|(buffer[9]<<16)|(buffer[10]<<8)|buffer[11]); map_len = ((buffer[12]<<24)|(buffer[13]<<16)|(buffer[14]<<8)|buffer[15]); if ( rdata_pos+rdata_len!=map_pos ) return( false ); fseek(f,map_pos,SEEK_SET); buffer2[15] = buffer[15]+1; /* make it be different */ if ( fread(buffer2,1,16,f)!=16 ) return( false ); /* Apple's data fork resources appear to have a bunch of zeroes here instead */ /* of a copy of the first 16 bytes */ for ( i=0; i<16; ++i ) if ( buffer2[i]!=0 ) break; if ( i!=16 ) { for ( i=0; i<16; ++i ) if ( buffer[i]!=buffer2[i] ) return( false ); } getlong(f); /* skip the handle to the next resource map */ getushort(f); /* skip the file resource number */ getushort(f); /* skip the attributes */ type_list = map_pos + getushort(f); name_list = map_pos + getushort(f); if ( psfont==NULL ) { fseek(f,type_list,SEEK_SET); cnt = getushort(f)+1; for ( i=0; inext ) for ( i=0; i<48; ++i ) if ( fl->psnames[i]!=NULL ) ProcessNestedPS( fl->psnames[i],filename, NULL ); } } fseek(f,type_list,SEEK_SET); cnt = getushort(f)+1; for ( i=0; i>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff );*/ subcnt = getushort(f)+1; rpos = type_list+getushort(f); if ( tag==CHR('P','O','S','T')) /* No FOND */ SearchPostscriptResources(f,rpos,subcnt,rdata_pos,name_list,psfont); else if ( psfont!=NULL ) /* No Op */; else if ( tag==CHR('F','O','N','T')) SearchNFNTResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('N','F','N','T')) SearchNFNTResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('s','f','n','t')) SearchTtfResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('F','O','N','D')) /* already parsed */; else /* Ignored */; } return( true ); } #ifndef OldMacintosh /* OS/X and linux with appropriate drivers */ static int HasResourceFork(char *filename,PSFONT *psfont) { char *respath = malloc(strlen(filename)+strlen("/rsrc")+1); FILE *temp; int ret=false; strcpy(respath,filename); strcat(respath,"/rsrc"); temp = fopen(respath,"r"); free(respath); if ( temp!=NULL ) { ret = IsResourceFork(temp,0,filename,psfont); fclose(temp); } return( ret ); } #else /* OS/9 and before, these calls depreciated in X.4 */ static int HasResourceFork(char *filename,PSFONT *psfont) { /* If we're on a mac, we can try to see if we've got a real resource fork */ FSRef ref; FSSpec spec; short res; long cnt, ret; FILE *temp; char *buf; if ( FSPathMakeRef( (unsigned char *) filename,&ref,NULL)!=noErr ) return( 0 ); if ( FSGetCatalogInfo(&ref,0,NULL,NULL,&spec,NULL)!=noErr ) return( 0 ); if ( FSpOpenRF(&spec,fsRdPerm,&res)!=noErr ) return( 0 ); temp = tmpfile(); buf = malloc(8192); while ( 1 ) { cnt = 8192; ret = FSRead(res,&cnt,buf); if ( cnt!=0 ) fwrite(buf,1,cnt,temp); if ( ret==eofErr ) break; if ( ret!=noErr ) break; } free(buf); FSClose(res); rewind(temp); ret = IsResourceFork(temp,0,filename,psfont); fclose(temp); return( ret ); } #endif static int IsResourceInBinary(FILE *f,char *filename, PSFONT *psfont) { unsigned char header[128], first[8]; unsigned long offset, dlen, rlen; if ( fread(header,1,128,f)!=128 ) return( false ); if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 || header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 ) return( false ); dlen = ((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); rlen = ((header[0x57]<<24)|(header[0x58]<<16)|(header[0x59]<<8)|header[0x5a]); /* Look for a bare truetype font in a binhex/macbinary wrapper */ if ( dlen!=0 && rlen<=dlen) { int pos = ftell(f); fread(first,1,4,f); first[5] = '\0'; if ( strcmp((char *) first,"OTTO")==0 || strcmp((char *) first,"true")==0 || strcmp((char *) first,"ttcf")==0 || (first[0]==0 && first[1]==1 && first[2]==0 && first[3]==0)) { int len = header[1]; header[2+len] = '\0'; return( MightBeTrueType(f,pos,dlen,(char *) header+2)); } } /* 128 bytes for header, then the dlen is padded to a 128 byte boundary */ offset = 128 + ((dlen+127)&~127); return( IsResourceFork(f,offset,filename,psfont)); } static int lastch=0, repeat = 0; static void outchr(FILE *binary, int ch) { int i; if ( repeat ) { if ( ch==0 ) { /* no repeat, output a literal 0x90 (the repeat flag) */ lastch=0x90; putc(lastch,binary); } else { for ( i=1; i>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); val = cnt = 0; } } if ( cnt!=0 ) { if ( cnt==1 ) outchr(binary,val<<2); else if ( cnt==2 ) { val<<=4; outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } else if ( cnt==3 ) { val<<=6; outchr(binary,(val>>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } } rewind(binary); ch = getc(binary); /* Name length */ /* skip name */ for ( i=0, pt=wrappedfilename; i8 || strlen(dpt)>4 ) { char exten[8]; strncpy(exten,dpt,7); exten[4] = '\0'; /* it includes the dot */ if ( dpt-spt>6 ) dpt = spt+6; *dpt++ = '~'; *dpt++ = '1'; strcpy(dpt,exten); } return( IsResourceInFile(buffer,NULL)); } int main(int argc, char **argv) { int i, ret = 0; for ( i=1; i #include #include #include #include #include "psfont.h" #include "macfonts.h" #include #include struct fontparse { FontDict *fd, *mainfd; /* always in font data */ unsigned int infi:1; unsigned int inchars:1; unsigned int inprivate:1; unsigned int insubs:1; unsigned int inmetrics: 1; unsigned int inmetrics2: 1; unsigned int inbb: 1; unsigned int inencoding: 1; unsigned int multiline: 1; unsigned int incidsysteminfo: 1; unsigned int inblendfi:1; unsigned int inblendprivate:1; unsigned int skipping_mbf: 1; unsigned int inblend: 1; unsigned int iscid: 1; unsigned int iscff: 1; unsigned int useshexstrings: 1; unsigned int doneencoding: 1; unsigned int ignore: 1; int instring; int fdindex; char **pending_parse; unsigned int alreadycomplained: 1; char *vbuf, *vmax, *vpt; int depth; }; static char *copyn(const char *str,long n) { char *ret; if ( str==NULL ) return( NULL ); ret = malloc(n+1); memcpy(ret,str,n); ret[n]='\0'; return( ret ); } static char *PSDictHasEntry(struct psdict *dict, char *key) { int i; if ( dict==NULL ) return( NULL ); for ( i=0; inext; ++i ) if ( strcmp(dict->keys[i],key)==0 ) return( dict->values[i] ); return( NULL ); } static int PSDictRemoveEntry(struct psdict *dict, char *key) { int i; if ( dict==NULL ) return( false ); for ( i=0; inext; ++i ) if ( strcmp(dict->keys[i],key)==0 ) break; if ( i==dict->next ) return( false ); free( dict->keys[i]); free( dict->values[i] ); --dict->next; while ( inext ) { dict->keys[i] = dict->keys[i+1]; dict->values[i] = dict->values[i+1]; ++i; } return( true ); } static void copyenc(char *encoding[256],char *std[256]) { int i; for ( i=0; i<256; ++i ) encoding[i] = strdup(std[i]); } char *AdobeStandardEncoding[] = { /* 0000 */ ".notdef", /* 0001 */ ".notdef", /* 0002 */ ".notdef", /* 0003 */ ".notdef", /* 0004 */ ".notdef", /* 0005 */ ".notdef", /* 0006 */ ".notdef", /* 0007 */ ".notdef", /* 0008 */ ".notdef", /* 0009 */ ".notdef", /* 000a */ ".notdef", /* 000b */ ".notdef", /* 000c */ ".notdef", /* 000d */ ".notdef", /* 000e */ ".notdef", /* 000f */ ".notdef", /* 0010 */ ".notdef", /* 0011 */ ".notdef", /* 0012 */ ".notdef", /* 0013 */ ".notdef", /* 0014 */ ".notdef", /* 0015 */ ".notdef", /* 0016 */ ".notdef", /* 0017 */ ".notdef", /* 0018 */ ".notdef", /* 0019 */ ".notdef", /* 001a */ ".notdef", /* 001b */ ".notdef", /* 001c */ ".notdef", /* 001d */ ".notdef", /* 001e */ ".notdef", /* 001f */ ".notdef", /* 0020 */ "space", /* 0021 */ "exclam", /* 0022 */ "quotedbl", /* 0023 */ "numbersign", /* 0024 */ "dollar", /* 0025 */ "percent", /* 0026 */ "ampersand", /* 0027 */ "quoteright", /* 0028 */ "parenleft", /* 0029 */ "parenright", /* 002a */ "asterisk", /* 002b */ "plus", /* 002c */ "comma", /* 002d */ "hyphen", /* 002e */ "period", /* 002f */ "slash", /* 0030 */ "zero", /* 0031 */ "one", /* 0032 */ "two", /* 0033 */ "three", /* 0034 */ "four", /* 0035 */ "five", /* 0036 */ "six", /* 0037 */ "seven", /* 0038 */ "eight", /* 0039 */ "nine", /* 003a */ "colon", /* 003b */ "semicolon", /* 003c */ "less", /* 003d */ "equal", /* 003e */ "greater", /* 003f */ "question", /* 0040 */ "at", /* 0041 */ "A", /* 0042 */ "B", /* 0043 */ "C", /* 0044 */ "D", /* 0045 */ "E", /* 0046 */ "F", /* 0047 */ "G", /* 0048 */ "H", /* 0049 */ "I", /* 004a */ "J", /* 004b */ "K", /* 004c */ "L", /* 004d */ "M", /* 004e */ "N", /* 004f */ "O", /* 0050 */ "P", /* 0051 */ "Q", /* 0052 */ "R", /* 0053 */ "S", /* 0054 */ "T", /* 0055 */ "U", /* 0056 */ "V", /* 0057 */ "W", /* 0058 */ "X", /* 0059 */ "Y", /* 005a */ "Z", /* 005b */ "bracketleft", /* 005c */ "backslash", /* 005d */ "bracketright", /* 005e */ "asciicircum", /* 005f */ "underscore", /* 0060 */ "quoteleft", /* 0061 */ "a", /* 0062 */ "b", /* 0063 */ "c", /* 0064 */ "d", /* 0065 */ "e", /* 0066 */ "f", /* 0067 */ "g", /* 0068 */ "h", /* 0069 */ "i", /* 006a */ "j", /* 006b */ "k", /* 006c */ "l", /* 006d */ "m", /* 006e */ "n", /* 006f */ "o", /* 0070 */ "p", /* 0071 */ "q", /* 0072 */ "r", /* 0073 */ "s", /* 0074 */ "t", /* 0075 */ "u", /* 0076 */ "v", /* 0077 */ "w", /* 0078 */ "x", /* 0079 */ "y", /* 007a */ "z", /* 007b */ "braceleft", /* 007c */ "bar", /* 007d */ "braceright", /* 007e */ "asciitilde", /* 007f */ ".notdef", /* 0080 */ ".notdef", /* 0081 */ ".notdef", /* 0082 */ ".notdef", /* 0083 */ ".notdef", /* 0084 */ ".notdef", /* 0085 */ ".notdef", /* 0086 */ ".notdef", /* 0087 */ ".notdef", /* 0088 */ ".notdef", /* 0089 */ ".notdef", /* 008a */ ".notdef", /* 008b */ ".notdef", /* 008c */ ".notdef", /* 008d */ ".notdef", /* 008e */ ".notdef", /* 008f */ ".notdef", /* 0090 */ ".notdef", /* 0091 */ ".notdef", /* 0092 */ ".notdef", /* 0093 */ ".notdef", /* 0094 */ ".notdef", /* 0095 */ ".notdef", /* 0096 */ ".notdef", /* 0097 */ ".notdef", /* 0098 */ ".notdef", /* 0099 */ ".notdef", /* 009a */ ".notdef", /* 009b */ ".notdef", /* 009c */ ".notdef", /* 009d */ ".notdef", /* 009e */ ".notdef", /* 009f */ ".notdef", /* 00a0 */ ".notdef", /* 00a1 */ "exclamdown", /* 00a2 */ "cent", /* 00a3 */ "sterling", /* 00a4 */ "fraction", /* 00a5 */ "yen", /* 00a6 */ "florin", /* 00a7 */ "section", /* 00a8 */ "currency", /* 00a9 */ "quotesingle", /* 00aa */ "quotedblleft", /* 00ab */ "guillemotleft", /* 00ac */ "guilsinglleft", /* 00ad */ "guilsinglright", /* 00ae */ "fi", /* 00af */ "fl", /* 00b0 */ ".notdef", /* 00b1 */ "endash", /* 00b2 */ "dagger", /* 00b3 */ "daggerdbl", /* 00b4 */ "periodcentered", /* 00b5 */ ".notdef", /* 00b6 */ "paragraph", /* 00b7 */ "bullet", /* 00b8 */ "quotesinglbase", /* 00b9 */ "quotedblbase", /* 00ba */ "quotedblright", /* 00bb */ "guillemotright", /* 00bc */ "ellipsis", /* 00bd */ "perthousand", /* 00be */ ".notdef", /* 00bf */ "questiondown", /* 00c0 */ ".notdef", /* 00c1 */ "grave", /* 00c2 */ "acute", /* 00c3 */ "circumflex", /* 00c4 */ "tilde", /* 00c5 */ "macron", /* 00c6 */ "breve", /* 00c7 */ "dotaccent", /* 00c8 */ "dieresis", /* 00c9 */ ".notdef", /* 00ca */ "ring", /* 00cb */ "cedilla", /* 00cc */ ".notdef", /* 00cd */ "hungarumlaut", /* 00ce */ "ogonek", /* 00cf */ "caron", /* 00d0 */ "emdash", /* 00d1 */ ".notdef", /* 00d2 */ ".notdef", /* 00d3 */ ".notdef", /* 00d4 */ ".notdef", /* 00d5 */ ".notdef", /* 00d6 */ ".notdef", /* 00d7 */ ".notdef", /* 00d8 */ ".notdef", /* 00d9 */ ".notdef", /* 00da */ ".notdef", /* 00db */ ".notdef", /* 00dc */ ".notdef", /* 00dd */ ".notdef", /* 00de */ ".notdef", /* 00df */ ".notdef", /* 00e0 */ ".notdef", /* 00e1 */ "AE", /* 00e2 */ ".notdef", /* 00e3 */ "ordfeminine", /* 00e4 */ ".notdef", /* 00e5 */ ".notdef", /* 00e6 */ ".notdef", /* 00e7 */ ".notdef", /* 00e8 */ "Lslash", /* 00e9 */ "Oslash", /* 00ea */ "OE", /* 00eb */ "ordmasculine", /* 00ec */ ".notdef", /* 00ed */ ".notdef", /* 00ee */ ".notdef", /* 00ef */ ".notdef", /* 00f0 */ ".notdef", /* 00f1 */ "ae", /* 00f2 */ ".notdef", /* 00f3 */ ".notdef", /* 00f4 */ ".notdef", /* 00f5 */ "dotlessi", /* 00f6 */ ".notdef", /* 00f7 */ ".notdef", /* 00f8 */ "lslash", /* 00f9 */ "oslash", /* 00fa */ "oe", /* 00fb */ "germandbls", /* 00fc */ ".notdef", /* 00fd */ ".notdef", /* 00fe */ ".notdef", /* 00ff */ ".notdef" }; static void setStdEnc(char *encoding[256]) { copyenc(encoding,AdobeStandardEncoding); } static void setLatin1Enc(char *encoding[256]) { static char *latin1enc[] = { /* 0000 */ ".notdef", /* 0001 */ ".notdef", /* 0002 */ ".notdef", /* 0003 */ ".notdef", /* 0004 */ ".notdef", /* 0005 */ ".notdef", /* 0006 */ ".notdef", /* 0007 */ ".notdef", /* 0008 */ ".notdef", /* 0009 */ ".notdef", /* 000a */ ".notdef", /* 000b */ ".notdef", /* 000c */ ".notdef", /* 000d */ ".notdef", /* 000e */ ".notdef", /* 000f */ ".notdef", /* 0010 */ ".notdef", /* 0011 */ ".notdef", /* 0012 */ ".notdef", /* 0013 */ ".notdef", /* 0014 */ ".notdef", /* 0015 */ ".notdef", /* 0016 */ ".notdef", /* 0017 */ ".notdef", /* 0018 */ ".notdef", /* 0019 */ ".notdef", /* 001a */ ".notdef", /* 001b */ ".notdef", /* 001c */ ".notdef", /* 001d */ ".notdef", /* 001e */ ".notdef", /* 001f */ ".notdef", /* 0020 */ "space", /* 0021 */ "exclam", /* 0022 */ "quotedbl", /* 0023 */ "numbersign", /* 0024 */ "dollar", /* 0025 */ "percent", /* 0026 */ "ampersand", /* 0027 */ "quoteright", /* 0028 */ "parenleft", /* 0029 */ "parenright", /* 002a */ "asterisk", /* 002b */ "plus", /* 002c */ "comma", /* 002d */ "hyphen", /* 002e */ "period", /* 002f */ "slash", /* 0030 */ "zero", /* 0031 */ "one", /* 0032 */ "two", /* 0033 */ "three", /* 0034 */ "four", /* 0035 */ "five", /* 0036 */ "six", /* 0037 */ "seven", /* 0038 */ "eight", /* 0039 */ "nine", /* 003a */ "colon", /* 003b */ "semicolon", /* 003c */ "less", /* 003d */ "equal", /* 003e */ "greater", /* 003f */ "question", /* 0040 */ "at", /* 0041 */ "A", /* 0042 */ "B", /* 0043 */ "C", /* 0044 */ "D", /* 0045 */ "E", /* 0046 */ "F", /* 0047 */ "G", /* 0048 */ "H", /* 0049 */ "I", /* 004a */ "J", /* 004b */ "K", /* 004c */ "L", /* 004d */ "M", /* 004e */ "N", /* 004f */ "O", /* 0050 */ "P", /* 0051 */ "Q", /* 0052 */ "R", /* 0053 */ "S", /* 0054 */ "T", /* 0055 */ "U", /* 0056 */ "V", /* 0057 */ "W", /* 0058 */ "X", /* 0059 */ "Y", /* 005a */ "Z", /* 005b */ "bracketleft", /* 005c */ "backslash", /* 005d */ "bracketright", /* 005e */ "asciicircum", /* 005f */ "underscore", /* 0060 */ "grave", /* 0061 */ "a", /* 0062 */ "b", /* 0063 */ "c", /* 0064 */ "d", /* 0065 */ "e", /* 0066 */ "f", /* 0067 */ "g", /* 0068 */ "h", /* 0069 */ "i", /* 006a */ "j", /* 006b */ "k", /* 006c */ "l", /* 006d */ "m", /* 006e */ "n", /* 006f */ "o", /* 0070 */ "p", /* 0071 */ "q", /* 0072 */ "r", /* 0073 */ "s", /* 0074 */ "t", /* 0075 */ "u", /* 0076 */ "v", /* 0077 */ "w", /* 0078 */ "x", /* 0079 */ "y", /* 007a */ "z", /* 007b */ "braceleft", /* 007c */ "bar", /* 007d */ "braceright", /* 007e */ "asciitilde", /* 007f */ ".notdef", /* 0080 */ ".notdef", /* 0081 */ ".notdef", /* 0082 */ ".notdef", /* 0083 */ ".notdef", /* 0084 */ ".notdef", /* 0085 */ ".notdef", /* 0086 */ ".notdef", /* 0087 */ ".notdef", /* 0088 */ ".notdef", /* 0089 */ ".notdef", /* 008a */ ".notdef", /* 008b */ ".notdef", /* 008c */ ".notdef", /* 008d */ ".notdef", /* 008e */ ".notdef", /* 008f */ ".notdef", /* 0090 */ "dotlessi", /* Um, Adobe's Latin1 has some extra chars */ /* 0091 */ "grave", /* 0092 */ "accute", /* This is a duplicate... */ /* 0093 */ "circumflex", /* 0094 */ "tilde", /* 0095 */ "macron", /* 0096 */ "breve", /* 0097 */ "dotaccent", /* 0098 */ "dieresis", /* 0099 */ ".notdef", /* 009a */ "ring", /* 009b */ "cedilla", /* 009c */ ".notdef", /* 009d */ "hungarumlaut", /* 009e */ "ogonek", /* 009f */ "caron", /* 00a0 */ "space", /* 00a1 */ "exclamdown", /* 00a2 */ "cent", /* 00a3 */ "sterling", /* 00a4 */ "currency", /* 00a5 */ "yen", /* 00a6 */ "brokenbar", /* 00a7 */ "section", /* 00a8 */ "dieresis", /* 00a9 */ "copyright", /* 00aa */ "ordfeminine", /* 00ab */ "guillemotleft", /* 00ac */ "logicalnot", /* 00ad */ "hyphen", /* 00ae */ "registered", /* 00af */ "macron", /* 00b0 */ "degree", /* 00b1 */ "plusminus", /* 00b2 */ "twosuperior", /* 00b3 */ "threesuperior", /* 00b4 */ "acute", /* 00b5 */ "mu", /* 00b6 */ "paragraph", /* 00b7 */ "periodcentered", /* 00b8 */ "cedilla", /* 00b9 */ "onesuperior", /* 00ba */ "ordmasculine", /* 00bb */ "guillemotright", /* 00bc */ "onequarter", /* 00bd */ "onehalf", /* 00be */ "threequarters", /* 00bf */ "questiondown", /* 00c0 */ "Agrave", /* 00c1 */ "Aacute", /* 00c2 */ "Acircumflex", /* 00c3 */ "Atilde", /* 00c4 */ "Adieresis", /* 00c5 */ "Aring", /* 00c6 */ "AE", /* 00c7 */ "Ccedilla", /* 00c8 */ "Egrave", /* 00c9 */ "Eacute", /* 00ca */ "Ecircumflex", /* 00cb */ "Edieresis", /* 00cc */ "Igrave", /* 00cd */ "Iacute", /* 00ce */ "Icircumflex", /* 00cf */ "Idieresis", /* 00d0 */ "Eth", /* 00d1 */ "Ntilde", /* 00d2 */ "Ograve", /* 00d3 */ "Oacute", /* 00d4 */ "Ocircumflex", /* 00d5 */ "Otilde", /* 00d6 */ "Odieresis", /* 00d7 */ "multiply", /* 00d8 */ "Oslash", /* 00d9 */ "Ugrave", /* 00da */ "Uacute", /* 00db */ "Ucircumflex", /* 00dc */ "Udieresis", /* 00dd */ "Yacute", /* 00de */ "Thorn", /* 00df */ "germandbls", /* 00e0 */ "agrave", /* 00e1 */ "aacute", /* 00e2 */ "acircumflex", /* 00e3 */ "atilde", /* 00e4 */ "adieresis", /* 00e5 */ "aring", /* 00e6 */ "ae", /* 00e7 */ "ccedilla", /* 00e8 */ "egrave", /* 00e9 */ "eacute", /* 00ea */ "ecircumflex", /* 00eb */ "edieresis", /* 00ec */ "igrave", /* 00ed */ "iacute", /* 00ee */ "icircumflex", /* 00ef */ "idieresis", /* 00f0 */ "eth", /* 00f1 */ "ntilde", /* 00f2 */ "ograve", /* 00f3 */ "oacute", /* 00f4 */ "ocircumflex", /* 00f5 */ "otilde", /* 00f6 */ "odieresis", /* 00f7 */ "divide", /* 00f8 */ "oslash", /* 00f9 */ "ugrave", /* 00fa */ "uacute", /* 00fb */ "ucircumflex", /* 00fc */ "udieresis", /* 00fd */ "yacute", /* 00fe */ "thorn", /* 00ff */ "ydieresis" }; copyenc(encoding,latin1enc); } char *AdobeExpertEncoding[] = { /* 0000 */ ".notdef", /* 0001 */ ".notdef", /* 0002 */ ".notdef", /* 0003 */ ".notdef", /* 0004 */ ".notdef", /* 0005 */ ".notdef", /* 0006 */ ".notdef", /* 0007 */ ".notdef", /* 0008 */ ".notdef", /* 0009 */ ".notdef", /* 000a */ ".notdef", /* 000b */ ".notdef", /* 000c */ ".notdef", /* 000d */ ".notdef", /* 000e */ ".notdef", /* 000f */ ".notdef", /* 0010 */ ".notdef", /* 0011 */ ".notdef", /* 0012 */ ".notdef", /* 0013 */ ".notdef", /* 0014 */ ".notdef", /* 0015 */ ".notdef", /* 0016 */ ".notdef", /* 0017 */ ".notdef", /* 0018 */ ".notdef", /* 0019 */ ".notdef", /* 001a */ ".notdef", /* 001b */ ".notdef", /* 001c */ ".notdef", /* 001d */ ".notdef", /* 001e */ ".notdef", /* 001f */ ".notdef", /* 0020 */ "space", /* 0021 */ "exclamsmall", /* 0022 */ "Hungarumlautsmal", /* 0023 */ ".notdef", /* 0024 */ "dollaroldstyle", /* 0025 */ "dollarsuperior", /* 0026 */ "ampersandsmall", /* 0027 */ "Acutesmall", /* 0028 */ "parenleftsuperior", /* 0029 */ "parenrightsuperior", /* 002a */ "twodotenleader", /* 002b */ "onedotenleader", /* 002c */ "comma", /* 002d */ "hyphen", /* 002e */ "period", /* 002f */ "fraction", /* 0030 */ "zerooldstyle", /* 0031 */ "oneoldstyle", /* 0032 */ "twooldstyle", /* 0033 */ "threeoldstyle", /* 0034 */ "fouroldstyle", /* 0035 */ "fiveoldstyle", /* 0036 */ "sixoldstyle", /* 0037 */ "sevenoldstyle", /* 0038 */ "eightoldstyle", /* 0039 */ "nineoldstyle", /* 003a */ "colon", /* 003b */ "semicolon", /* 003c */ "commasuperior", /* 003d */ "threequartersemdash", /* 003e */ "periodsuperior", /* 003f */ "questionsmall", /* 0040 */ ".notdef", /* 0041 */ "asuperior", /* 0042 */ "bsuperior", /* 0043 */ "centsuperior", /* 0044 */ "dsuperior", /* 0045 */ "esuperior", /* 0046 */ ".notdef", /* 0047 */ ".notdef", /* 0048 */ ".notdef", /* 0049 */ "isuperior", /* 004a */ ".notdef", /* 004b */ ".notdef", /* 004c */ "lsuperior", /* 004d */ "msuperior", /* 004e */ "nsuperior", /* 004f */ "osuperior", /* 0050 */ ".notdef", /* 0051 */ ".notdef", /* 0052 */ "rsuperior", /* 0053 */ "ssuperior", /* 0054 */ "tsuperior", /* 0055 */ ".notdef", /* 0056 */ "ff", /* 0057 */ "fi", /* 0058 */ "fl", /* 0059 */ "ffi", /* 005a */ "ffl", /* 005b */ "parenleftinferior", /* 005c */ ".notdef", /* 005d */ "parenrightinferior", /* 005e */ "Circumflexsmall", /* 005f */ "hyphensuperior", /* 0060 */ "Gravesmall", /* 0061 */ "Asmall", /* 0062 */ "Bsmall", /* 0063 */ "Csmall", /* 0064 */ "Dsmall", /* 0065 */ "Esmall", /* 0066 */ "Fsmall", /* 0067 */ "Gsmall", /* 0068 */ "Hsmall", /* 0069 */ "Ismall", /* 006a */ "Jsmall", /* 006b */ "Ksmall", /* 006c */ "Lsmall", /* 006d */ "Msmall", /* 006e */ "Nsmall", /* 006f */ "Osmall", /* 0070 */ "Psmall", /* 0071 */ "Qsmall", /* 0072 */ "Rsmall", /* 0073 */ "Ssmall", /* 0074 */ "Tsmall", /* 0075 */ "Usmall", /* 0076 */ "Vsmall", /* 0077 */ "Wsmall", /* 0078 */ "Xsmall", /* 0079 */ "Ysmall", /* 007a */ "Zsmall", /* 007b */ "colonmonetary", /* 007c */ "onefitted", /* 007d */ "rupiah", /* 007e */ "Tildesmall", /* 007f */ ".notdef", /* 0080 */ ".notdef", /* 0081 */ ".notdef", /* 0082 */ ".notdef", /* 0083 */ ".notdef", /* 0084 */ ".notdef", /* 0085 */ ".notdef", /* 0086 */ ".notdef", /* 0087 */ ".notdef", /* 0088 */ ".notdef", /* 0089 */ ".notdef", /* 008a */ ".notdef", /* 008b */ ".notdef", /* 008c */ ".notdef", /* 008d */ ".notdef", /* 008e */ ".notdef", /* 008f */ ".notdef", /* 0090 */ ".notdef", /* 0091 */ ".notdef", /* 0092 */ ".notdef", /* 0093 */ ".notdef", /* 0094 */ ".notdef", /* 0095 */ ".notdef", /* 0096 */ ".notdef", /* 0097 */ ".notdef", /* 0098 */ ".notdef", /* 0099 */ ".notdef", /* 009a */ ".notdef", /* 009b */ ".notdef", /* 009c */ ".notdef", /* 009d */ ".notdef", /* 009e */ ".notdef", /* 009f */ ".notdef", /* 00a0 */ ".notdef", /* 00a1 */ "exclamdownsmall", /* 00a2 */ "centoldstyle", /* 00a3 */ "Lslashsmall", /* 00a4 */ ".notdef", /* 00a5 */ ".notdef", /* 00a6 */ "Scaronsmall", /* 00a7 */ "Zcaronsmall", /* 00a8 */ "Dieresissmall", /* 00a9 */ "Brevesmall", /* 00aa */ "Caronsmall", /* 00ab */ ".notdef", /* 00ac */ "Dotaccentsmall", /* 00ad */ ".notdef", /* 00ae */ ".notdef", /* 00af */ "Macronsmall", /* 00b0 */ ".notdef", /* 00b1 */ ".notdef", /* 00b2 */ "figuredash", /* 00b3 */ "hypheninferior", /* 00b4 */ ".notdef", /* 00b5 */ ".notdef", /* 00b6 */ "Ogoneksmall", /* 00b7 */ "Ringsmall", /* 00b8 */ "Cedillasmall", /* 00b9 */ ".notdef", /* 00ba */ ".notdef", /* 00bb */ ".notdef", /* 00bc */ "onequarter", /* 00bd */ "onehalf", /* 00be */ "threequarters", /* 00bf */ "questiondownsmall", /* 00c0 */ "oneeighth", /* 00c1 */ "threeeighths", /* 00c2 */ "fiveeighths", /* 00c3 */ "seveneighths", /* 00c4 */ "onethird", /* 00c5 */ "twothirds", /* 00c6 */ ".notdef", /* 00c7 */ ".notdef", /* 00c8 */ "zerosuperior", /* 00c9 */ "onesuperior", /* 00ca */ "twosuperior", /* 00cb */ "threesuperior", /* 00cc */ "foursuperior", /* 00cd */ "fivesuperior", /* 00ce */ "sixsuperior", /* 00cf */ "sevensuperior", /* 00d0 */ "eightsuperior", /* 00d1 */ "ninesuperior", /* 00d2 */ "zeroinferior", /* 00d3 */ "oneinferior", /* 00d4 */ "twoinferior", /* 00d5 */ "threeinferior", /* 00d6 */ "fourinferior", /* 00d7 */ "fiveinferior", /* 00d8 */ "sixinferior", /* 00d9 */ "seveninferior", /* 00da */ "eightinferior", /* 00db */ "nineinferior", /* 00dc */ "centinferior", /* 00dd */ "dollarinferior", /* 00de */ "periodinferior", /* 00df */ "commainferior", /* 00e0 */ "Agravesmall", /* 00e1 */ "Aacutesmall", /* 00e2 */ "Acircumflexsmall", /* 00e3 */ "Atildesmall", /* 00e4 */ "Adieresissmall", /* 00e5 */ "Aringsmall", /* 00e6 */ "AEsmall", /* 00e7 */ "Ccedillasmall", /* 00e8 */ "Egravesmall", /* 00e9 */ "Eacutesmall", /* 00ea */ "Ecircumflexsmall", /* 00eb */ "Edieresissmall", /* 00ec */ "Igravesmall", /* 00ed */ "Iacutesmall", /* 00ee */ "Icircumflexsmall", /* 00ef */ "Idieresissmall", /* 00f0 */ "Ethsmall", /* 00f1 */ "Ntildesmall", /* 00f2 */ "Ogravesmall", /* 00f3 */ "Oacutesmall", /* 00f4 */ "Ocircumflexsmall", /* 00f5 */ "Otildesmall", /* 00f6 */ "Odieresissmall", /* 00f7 */ "OEsmall", /* 00f8 */ "Oslashsmall", /* 00f9 */ "Ugravesmall", /* 00fa */ "Uacutesmall", /* 00fb */ "Ucircumflexsmall", /* 00fc */ "Udieresissmall", /* 00fd */ "Yacutesmall", /* 00fe */ "Thornsmall", /* 00ff */ "Ydieresissmall" }; static struct fontdict *MakeEmptyFont(void) { struct fontdict *ret; ret = calloc(1,sizeof(struct fontdict)); ret->fontinfo = calloc(1,sizeof(struct fontinfo)); ret->chars = calloc(1,sizeof(struct pschars)); ret->private = calloc(1,sizeof(struct private)); ret->private->subrs = calloc(1,sizeof(struct pschars)); ret->private->private = calloc(1,sizeof(struct psdict)); ret->private->leniv = 4; ret->fontinfo->fstype = -1; return( ret ); } static struct fontdict *PSMakeEmptyFont(void) { struct fontdict *ret; ret = calloc(1,sizeof(struct fontdict)); ret->fontinfo = calloc(1,sizeof(struct fontinfo)); ret->chars = calloc(1,sizeof(struct pschars)); ret->private = calloc(1,sizeof(struct private)); ret->private->subrs = calloc(1,sizeof(struct pschars)); ret->private->private = calloc(1,sizeof(struct psdict)); ret->private->leniv = 4; ret->charprocs = calloc(1,sizeof(struct charprocs)); ret->fontinfo->fstype = -1; return( ret ); } static char *myfgets(char *str, int len, FILE *file) { char *pt, *end; int ch=0; for ( pt = str, end = str+len-1; pt0); ++end ) { if ( *end=='\\' && (end[1]=='(' || end[1]==')')) ++end; else if ( *end=='(' ) ++parencnt; else if ( *end==')' ) --parencnt; } if ( end>start ) { if ( ret==NULL ) ret = malloc(end-start+1); else ret = realloc(ret,len+end-start); strncpy(ret+len-1,start,end-start); len += end-start; ret[len-1] = '\0'; } if ( *end!='\0' ) break; if ( myfgets(buffer,sizeof(buffer),in)==NULL ) return( ret ); start = buffer; } return( ret ); } static char *gettoken(char *start) { char *end, *ret; while ( *start!='\0' && *start!='/' ) ++start; if ( *start=='/' ) ++start; for ( end = start; *end!='\0' && !isspace(*end) && *end!='[' && *end!='/' && *end!='{' && *end!='(' ; ++end ); ret = malloc(end-start+1); if ( end>start ) strncpy(ret,start,end-start); ret[end-start] = '\0'; return( ret ); } static int getbool(char *start) { while ( isspace(*start) ) ++start; if ( *start=='T' || *start=='t' ) return( 1 ); return( 0 ); } static void fillintarray(int *array,char *start,int maxentries) { int i; char *end; while ( *start!='\0' && *start!='[' && *start!='{' ) ++start; if ( *start=='[' || *start=='{' ) ++start; for ( i=0; i=2 ) { /* Some of Luc Devroye's fonts have a "div" in the FontMatrix */ array[i-2] /= array[i-1]; i -= 2; end = start+3; } else return; if ( start==end ) return; start = end; while ( isspace(*start) ) ++start; } } static void InitDict(struct psdict *dict,char *line) { while ( *line!='/' && *line!='\0' ) ++line; while ( !isspace(*line) && *line!='\0' ) ++line; dict->cnt += strtol(line,NULL,10); if ( dict->next>0 ) { int i; /* Shouldn't happen, but did in a bad file */ dict->keys = realloc(dict->keys,dict->cnt*sizeof(char *)); dict->values = realloc(dict->values,dict->cnt*sizeof(char *)); for ( i=dict->next; icnt; ++i ) { dict->keys[i] = NULL; dict->values[i] = NULL; } } else { dict->keys = calloc(dict->cnt,sizeof(char *)); dict->values = calloc(dict->cnt,sizeof(char *)); } } static void InitChars(struct pschars *chars,char *line) { while ( *line!='/' && *line!='\0' ) ++line; while ( !isspace(*line) && *line!='\0' ) ++line; chars->cnt = strtol(line,NULL,10); if ( chars->cnt>0 ) { chars->keys = calloc(chars->cnt,sizeof(char *)); chars->values = calloc(chars->cnt,sizeof(char *)); chars->lens = calloc(chars->cnt,sizeof(int)); } } static void InitCharProcs(struct charprocs *cp, char *line) { while ( *line!='/' && *line!='\0' ) ++line; while ( !isspace(*line) && *line!='\0' ) ++line; cp->cnt = strtol(line,NULL,10); if ( cp->cnt>0 ) { cp->keys = calloc(cp->cnt,sizeof(char *)); cp->values = NULL; } } static int mycmp(char *str,char *within, char *end ) { while ( withininstring && fp->depth==0 && (strncmp(line,"def",3)==0 || strncmp(line,"|-",2)==0 || strncmp(line,"ND",2)==0)) { while ( 1 ) { while ( fp->vpt>fp->vbuf+1 && isspace(fp->vpt[-1]) ) --fp->vpt; if ( fp->vpt>fp->vbuf+8 && strncmp(fp->vpt-8,"noaccess",8)==0 ) fp->vpt -= 8; else if ( fp->vpt>fp->vbuf+8 && strncmp(fp->vpt-8,"readonly",8)==0 ) fp->vpt -= 8; else if ( fp->vpt>fp->vbuf+4 && strncmp(fp->vpt-4,"bind",4)==0 ) fp->vpt -= 4; else break; } /* In some URW fonts (Nimbus Sans L, n019003l) we get a complex */ /* expression rather than just an array. This is ok. The expression */ /* converts itself into an array. We could just truncate to the */ /* default array, but I don't see any reason to do so */ if ( fp->pending_parse!=NULL ) { *fp->pending_parse = copyn(fp->vbuf,fp->vpt-fp->vbuf); fp->pending_parse = NULL; } else { dict->values[dict->next] = copyn(fp->vbuf,fp->vpt-fp->vbuf); ++dict->next; } fp->vpt = fp->vbuf; fp->multiline = false; return; } if ( fp->vpt>=fp->vmax ) { int len = fp->vmax-fp->vbuf+1000, off=fp->vpt-fp->vbuf; fp->vbuf = realloc(fp->vbuf,len); fp->vpt = fp->vbuf+off; fp->vmax = fp->vbuf+len; } if ( fp->instring ) { if ( *line==')' ) --fp->instring; } else if ( incomment ) { /* Do Nothing */; } else if ( *line=='(' ) ++fp->instring; else if ( *line=='%' ) incomment = true; else if ( *line=='[' || *line=='{' ) ++fp->depth; else if ( *line=='}' || *line==']' ) --fp->depth; *fp->vpt++ = *line++; } } static void AddValue(struct fontparse *fp, struct psdict *dict, char *line, char *endtok) { char *pt; if ( dict!=NULL ) { if ( dict->next>=dict->cnt ) { dict->cnt += 10; dict->keys = realloc(dict->keys,dict->cnt*sizeof(char *)); dict->values = realloc(dict->values,dict->cnt*sizeof(char *)); } dict->keys[dict->next] = copyn(line+1,endtok-(line+1)); } pt = line+strlen(line)-1; while ( isspace(*endtok)) ++endtok; while ( pt>endtok && isspace(*pt)) --pt; ++pt; if ( strncmp(pt-3,"def",3)==0 ) pt -= 3; else if ( strncmp(pt-2,"|-",2)==0 || strncmp(pt-2,"ND",2)==0 ) pt -= 2; else { fp->multiline = true; ContinueValue(fp,dict,endtok); return; } forever { while ( pt-1>endtok && isspace(pt[-1])) --pt; if ( pt-8>endtok && strncmp(pt-8,"noaccess",8)==0 ) pt -= 8; else if ( pt-8>endtok && strncmp(pt-8,"readonly",8)==0 ) pt -= 8; else if ( pt-4>endtok && strncmp(pt-4,"bind",4)==0 ) pt -= 4; else break; } if ( dict!=NULL ) { dict->values[dict->next] = copyn(endtok,pt-endtok); ++dict->next; } else { *fp->pending_parse = copyn(endtok,pt-endtok); fp->pending_parse = NULL; } } static int hex(int ch1, int ch2) { if ( ch1>='0' && ch1<='9' ) ch1 -= '0'; else if ( ch1>='a' ) ch1 -= 'a'-10; else ch1 -= 'A'-10; if ( ch2>='0' && ch2<='9' ) ch2 -= '0'; else if ( ch2>='a' ) ch2 -= 'a'-10; else ch2 -= 'A'-10; return( (ch1<<4)|ch2 ); } unsigned short r; #define c1 52845 #define c2 22719 static void initcode(void) { r = 55665; } static int decode(unsigned char cypher) { unsigned char plain = ( cypher ^ (r>>8)); r = (cypher + r) * c1 + c2; return( plain ); } static void dumpzeros(FILE *out, unsigned char *zeros, int zcnt) { while ( --zcnt >= 0 ) fputc(*zeros++,out); } static void decodestr(unsigned char *str, int len) { unsigned short r = 4330; unsigned char plain, cypher; while ( len-->0 ) { cypher = *str; plain = ( cypher ^ (r>>8)); r = (cypher + r) * c1 + c2; *str++ = plain; } } static void findstring(struct fontparse *fp,struct pschars *subrs,int index,char *nametok,char *str) { char buffer[1024], *bpt, *bs, *end = buffer+sizeof(buffer)-1; int val; while ( isspace(*str)) ++str; if ( *str=='(' ) { ++str; bpt = buffer; while ( *str!=')' ) { if ( *str!='\\' ) val = *str++; else { if ( isdigit( *++str )) { val = *str++-'0'; if ( isdigit( *str )) { val = (val<<3) | (*str++-'0'); if ( isdigit( *str )) val = (val<<3) | (*str++-'0'); } } else val = *str++; } if ( bptfd->private->leniv; subrs->lens[index] = bpt-bs; subrs->keys[index] = strdup(nametok); subrs->values[index] = malloc(bpt-bs); memcpy(subrs->values[index],bs,bpt-bs); if ( index>=subrs->next ) subrs->next = index+1; } } static char *rmbinary(char *line) { char *pt; for ( pt=line; *pt; ++pt ) { if (( *pt<' ' || *pt>=0x7f ) && *pt!='\n' ) { if ( strlen(pt)>5 ) { pt[0] = '.'; pt[1] = '.'; pt[2] = '.'; pt[3] = '\n'; pt[4] = '\0'; } else { pt[0] = '\n'; pt[1] = '\0'; } break; } } return( line ); } static void parseline(struct fontparse *fp,char *line,FILE *in) { char buffer[200], *pt, *endtok; while ( *line==' ' || *line=='\t' ) ++line; if ( line[0]=='%' && !fp->multiline ) return; if ( fp->inencoding && strncmp(line,"dup",3)==0 ) { /* Metamorphasis has multiple entries on a line */ while ( strncmp(line,"dup",3)==0 ) { char *end; int pos = strtol(line+3,&end,10); line = end; while ( isspace( *line )) ++line; if ( *line=='/' ) ++line; for ( pt = buffer; !isspace(*line); *pt++ = *line++ ); *pt = '\0'; if ( pos>=0 && pos<256 ) fp->fd->encoding[pos] = strdup(buffer); while ( isspace(*line)) ++line; if ( strncmp(line,"put",3)==0 ) line+=3; while ( isspace(*line)) ++line; } return; } else if ( fp->inencoding && strstr(line,"for")!=NULL && strstr(line,"/.notdef")!=NULL ) { /* the T1 spec I've got doesn't allow for this, but I've seen it anyway*/ /* 0 1 255 {1 index exch /.notdef put} for */ /* 0 1 31 { 1 index exch /.notdef put } bind for */ int i; for ( i=0; i<256; ++i ) if ( fp->fd->encoding[i]==NULL ) fp->fd->encoding[i] = strdup(".notdef"); return; } else if ( fp->inencoding && strstr(line,"Encoding")!=NULL && strstr(line,"put")!=NULL ) { /* Saw a type 3 font with lines like "Encoding 1 /_a0 put" */ char *end; int pos; while ( isspace(*line)) ++line; if ( strncmp(line,"Encoding ",9)==0 ) { line+=9; pos = strtol(line,&end,10); line = end; while ( isspace(*line)) ++line; if ( *line=='/' ) { ++line; for ( pt = buffer; !isspace(*line); *pt++ = *line++ ); *pt = '\0'; if ( pos>=0 && pos<256 ) fp->fd->encoding[pos] = strdup(buffer); } } return; } else if ( fp->insubs ) { struct pschars *subrs = fp->fd->private->subrs; while ( isspace(*line)) ++line; if ( strncmp(line,"dup ",4)==0 ) { int i; char *ept; for ( line += 4; *line==' '; ++line ); i = strtol(line,&ept,10); if ( fp->ignore ) /* Do Nothing */; else if ( icnt ) { findstring(fp,subrs,i,NULL,ept); } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Index too big (must be <%d) |%s", subrs->cnt, rmbinary(line)); fp->alreadycomplained = true; } } else if ( strncmp(line, "readonly put", 12)==0 || strncmp(line, "ND", 2)==0 || strncmp(line, "|-", 2)==0 ) { fp->insubs = false; fp->ignore = false; } else if ( *line=='\n' || *line=='\0' ) { /* Ignore blank lines */; } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Didn't understand |%s", rmbinary(line) ); fp->alreadycomplained = true; } } else if ( fp->inchars ) { struct pschars *chars = fp->fd->chars; while ( isspace(*line)) ++line; if ( strncmp(line,"end",3)==0 ) fp->ignore = fp->inchars = false; else if ( *line!='\n' || *line=='\0' ) /* Ignore it */; else if ( *line!='/' || !(isalpha(line[1]) || line[1]=='.')) { fprintf( stderr, "No name for CharStrings dictionary |%s", rmbinary(line) ); fp->alreadycomplained = true; } else if ( fp->ignore ) { /* Do Nothing */; } else if ( chars->next>=chars->cnt ) fprintf( stderr, "Too many entries in CharStrings dictionary |%s", rmbinary(line) ); else { int i = chars->next; char *namestrt = ++line; while ( isalnum(*line) || *line=='.' ) ++line; *line = '\0'; findstring(fp,chars,i,namestrt,line+1); } } fp->inencoding = 0; while ( isspace(*line)) ++line; endtok = NULL; if ( *line=='/' ) for ( endtok=line+1; !isspace(*endtok) && *endtok!='(' && *endtok!='{' && *endtok!='[' && *endtok!='\0'; ++endtok ); if ( strstr(line,"/shareddict")!=NULL && strstr(line,"where")!=NULL ) { fp->infi = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->inprivate = fp->inblendprivate = fp->inblendfi = false; fp->skipping_mbf = true; return; } if ( mycmp("Encoding",line+1,endtok)==0 && !fp->doneencoding ) { if ( strstr(endtok,"StandardEncoding")!=NULL ) { setStdEnc(fp->fd->encoding); fp->fd->isadobestd = true; } else if ( strstr(endtok,"ISOLatin1Encoding")!=NULL ) { setLatin1Enc(fp->fd->encoding); } else { fp->inencoding = 1; } fp->infi = fp->inprivate = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->doneencoding = true; } else if ( mycmp("BoundingBoxes",line+1,endtok)==0 ) { fp->infi = fp->inprivate = fp->inencoding = fp->inmetrics = fp->inmetrics2 = false; fp->inbb = true; } else if ( mycmp("Metrics",line+1,endtok)==0 ) { fp->infi = fp->inprivate = fp->inbb = fp->inencoding = fp->inmetrics2 = false; fp->inmetrics = true; fp->fd->metrics = calloc(1,sizeof(struct psdict)); fp->fd->metrics->cnt = strtol(endtok,NULL,10); fp->fd->metrics->keys = malloc(fp->fd->metrics->cnt*sizeof(char *)); fp->fd->metrics->values = malloc(fp->fd->metrics->cnt*sizeof(char *)); } else if ( strstr(line,"/Private")!=NULL && strstr(line,"/Blend")!=NULL ) { fp->infi = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->inprivate = fp->inblendprivate = fp->inblendfi = false; fp->inblendprivate = 1; fp->fd->blendprivate = calloc(1,sizeof(struct psdict)); InitDict(fp->fd->blendprivate,line); return; } else if ( strstr(line,"/FontInfo")!=NULL && strstr(line,"/Blend")!=NULL ) { fp->infi = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->inprivate = fp->inblendprivate = fp->inblendfi = false; fp->inblendfi = 1; fp->fd->blendfontinfo = calloc(1,sizeof(struct psdict)); InitDict(fp->fd->blendfontinfo,line); return; } else if ( fp->infi ) { if ( fp->multiline ) { ContinueValue(fp,NULL,line); return; } if ( endtok==NULL && strncmp(line,"end", 3)==0 ) { fp->infi=0; return; } else if ( endtok==NULL ) return; if ( mycmp("version",line+1,endtok)==0 ) fp->fd->fontinfo->version = getstring(endtok,in); else if ( mycmp("Notice",line+1,endtok)==0 ) { if ( fp->fd->fontinfo->notice!=NULL ) free(fp->fd->fontinfo->notice); fp->fd->fontinfo->notice = getstring(endtok,in); } else if ( mycmp("Copyright",line+1,endtok)==0 ) { /* cff spec allows for copyright and notice */ if ( fp->fd->fontinfo->notice!=NULL ) free(fp->fd->fontinfo->notice); fp->fd->fontinfo->notice = getstring(endtok,in); } else if ( mycmp("FullName",line+1,endtok)==0 ) { if ( fp->fd->fontinfo->fullname==NULL ) fp->fd->fontinfo->fullname = getstring(endtok,in); else getstring(endtok,in); } else if ( mycmp("FamilyName",line+1,endtok)==0 ) fp->fd->fontinfo->familyname = getstring(endtok,in); else if ( mycmp("Weight",line+1,endtok)==0 ) fp->fd->fontinfo->weight = getstring(endtok,in); else if ( mycmp("ItalicAngle",line+1,endtok)==0 ) fp->fd->fontinfo->italicangle = strtod(endtok,NULL); else if ( mycmp("UnderlinePosition",line+1,endtok)==0 ) fp->fd->fontinfo->underlineposition = strtod(endtok,NULL); else if ( mycmp("UnderlineThickness",line+1,endtok)==0 ) fp->fd->fontinfo->underlinethickness = strtod(endtok,NULL); else if ( mycmp("isFixedPitch",line+1,endtok)==0 ) fp->fd->fontinfo->isfixedpitch = getbool(endtok); else if ( mycmp("em",line+1,endtok)==0 ) fp->fd->fontinfo->em = strtol(endtok,NULL,10); else if ( mycmp("ascent",line+1,endtok)==0 ) fp->fd->fontinfo->ascent = strtol(endtok,NULL,10); else if ( mycmp("descent",line+1,endtok)==0 ) fp->fd->fontinfo->descent = strtol(endtok,NULL,10); else if ( mycmp("FSType",line+1,endtok)==0 ) fp->fd->fontinfo->fstype = strtol(endtok,NULL,10); else if ( mycmp("BlendDesignPositions",line+1,endtok)==0 ) { fp->pending_parse = &fp->fd->fontinfo->blenddesignpositions; AddValue(fp,NULL,line,endtok); } else if ( mycmp("BlendDesignMap",line+1,endtok)==0 ) { fp->pending_parse = &fp->fd->fontinfo->blenddesignmap; AddValue(fp,NULL,line,endtok); } else if ( mycmp("BlendAxisTypes",line+1,endtok)==0 ) { fp->pending_parse = &fp->fd->fontinfo->blendaxistypes; AddValue(fp,NULL,line,endtok); } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Didn't understand |%s", rmbinary(line) ); fp->alreadycomplained = true; } } else if ( fp->inblend ) { if ( endtok==NULL ) { if ( *line!='/' && strstr(line,"end")!=NULL ) fp->inblend = false; return; } /* Ignore anything in the blend dict defn */ } else if ( fp->inblendprivate || fp->inblendfi ) { struct psdict *subdict = fp->inblendfi ? fp->fd->blendfontinfo : fp->fd->blendprivate; if ( fp->multiline ) { ContinueValue(fp,subdict,line); return; } else if ( endtok==NULL ) { if ( *line!='/' && strstr(line,"end")!=NULL ) { fp->inblendprivate = fp->inblendfi = false; fp->inprivate = true; } return; } else AddValue(fp,subdict,line,endtok); } else if ( fp->inprivate ) { if ( strstr(line,"/CharStrings")!=NULL && strstr(line,"dict")!=NULL ) { if ( fp->fd->chars->next==0 ) { InitChars(fp->fd->chars,line); fp->ignore = false; } else { fp->ignore = true; fprintf( stderr, "Ignoring duplicate /CharStrings entry\n" ); } fp->inchars = 1; fp->insubs = 0; return; } else if ( strstr(line,"/Subrs")!=NULL ) { if ( fp->fd->private->subrs->next>0 ) { fp->ignore = true; fprintf( stderr, "Ignoring duplicate /Subrs entry\n" ); } else { InitChars(fp->fd->private->subrs,line); fp->ignore = false; } fp->insubs = 1; fp->inchars = 0; return; } else if ( fp->multiline ) { ContinueValue(fp,fp->fd->private->private,line); return; } if ( endtok==NULL ) { char *pt = line; if ( *pt!='/' ) while ( (pt=strstr(pt,"end"))!=NULL ) { if ( fp->inchars ) fp->inchars = false; else fp->inprivate = false; pt += 3; } return; } if ( mycmp("ND",line+1,endtok)==0 || mycmp("|-",line+1,endtok)==0 || mycmp("NP",line+1,endtok)==0 || mycmp("|",line+1,endtok)==0 || mycmp("RD",line+1,endtok)==0 || mycmp("-|",line+1,endtok)==0 || mycmp("password",line+1,endtok)==0 || mycmp("MinFeature",line+1,endtok)==0 ) /* These conveigh no information, but are required */; else if ( mycmp("UniqueID",line+1,endtok)==0 ) { if ( fp->fd->uniqueid==0 ) fp->fd->uniqueid = strtol(endtok,NULL,10); } else { if ( mycmp("lenIV",line+1,endtok)==0 ) fp->fd->private->leniv = strtol(endtok,NULL,10); /* We need this value */ AddValue(fp,fp->fd->private->private,line,endtok); } } else if ( fp->incidsysteminfo ) { if ( endtok==NULL && strncmp(line,"end", 3)==0 ) { fp->incidsysteminfo=0; return; } else if ( endtok==NULL ) return; if ( mycmp("Registry",line+1,endtok)==0 ) fp->fd->registry = getstring(endtok,in); else if ( mycmp("Ordering",line+1,endtok)==0 ) fp->fd->ordering = getstring(endtok,in); else if ( mycmp("Supplement",line+1,endtok)==0 ) /* cff spec allows for copyright and notice */ fp->fd->supplement = strtol(endtok,NULL,0); } else { if ( strstr(line,"/Private")!=NULL && strstr(line,"dict")!=NULL ) { fp->infi = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->inprivate = fp->inblendprivate = fp->inblendfi = false; if ( strstr(line,"/Blend")!=NULL ) { fp->inblendprivate = 1; fp->fd->blendprivate = calloc(1,sizeof(struct psdict)); InitDict(fp->fd->blendprivate,line); } else { fp->inprivate = 1; InitDict(fp->fd->private->private,line); } return; } else if ( strstr(line,"/FontInfo")!=NULL && strstr(line,"dict")!=NULL ) { fp->inprivate = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->infi = fp->inblendprivate = fp->inblendfi = false; if ( strstr(line,"/Blend")!=NULL ) { fp->inblendfi = 1; fp->fd->blendfontinfo = calloc(1,sizeof(struct psdict)); InitDict(fp->fd->blendfontinfo,line); } else { fp->infi = 1; } return; } else if ( strstr(line,"/Blend")!=NULL && strstr(line,"dict")!=NULL ) { fp->inprivate = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->infi = fp->inblendprivate = fp->inblendfi = false; fp->inblend = true; return; } else if ( strstr(line,"/CharStrings")!=NULL && strstr(line,"dict")!=NULL ) { if ( fp->fd->chars->next==0 ) { InitChars(fp->fd->chars,line); fp->ignore = false; } else { fp->ignore = true; fprintf( stderr, "Ignoring duplicate /CharStrings entry\n" ); } fp->inchars = 1; fp->insubs = 0; fp->infi = fp->inprivate = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->inblendprivate = fp->inblendfi = false; return; } else if ( mycmp("/CharProcs",line,endtok)==0 ) { InitCharProcs(fp->fd->charprocs,line); fp->infi = fp->inprivate = fp->inbb = fp->inmetrics = fp->inmetrics2 = false; fp->insubs = 0; return; } else if ( strstr(line,"/CIDSystemInfo")!=NULL ) { fp->incidsysteminfo = 1; return; } else if ( fp->inmetrics ) { if ( endtok!=NULL ) AddValue(fp,fp->fd->metrics,line,endtok); return; } else if ( fp->inbb ) { /* Ignore it */; return; } if ( fp->multiline ) { ContinueValue(fp,NULL,line); return; } if ( endtok==NULL ) { if ( fp->skipping_mbf ) ; else if ( fp->fdindex!=-1 && strstr(line,"end")!=NULL ) { if ( ++fp->fdindex>=fp->mainfd->fdcnt ) fp->fd = fp->mainfd; else fp->fd = fp->mainfd->fds[fp->fdindex]; } return; } if ( mycmp("FontName",line+1,endtok)==0 ) { if ( fp->fd->fontname==NULL ) fp->fd->fontname = gettoken(endtok); else gettoken(endtok); /* skip it */ } else if ( mycmp("PaintType",line+1,endtok)==0 ) fp->fd->painttype = strtol(endtok,NULL,10); else if ( mycmp("FontType",line+1,endtok)==0 ) fp->fd->fonttype = strtol(endtok,NULL,10); else if ( mycmp("FontMatrix",line+1,endtok)==0 ) { if ( fp->fd->fontmatrix[0]==0 ) filldoublearray(fp->fd->fontmatrix,endtok,6); else { double temp[6]; filldoublearray(temp,endtok,6); } } else if ( mycmp("LanguageLevel",line+1,endtok)==0 ) fp->fd->languagelevel = strtol(endtok,NULL,10); else if ( mycmp("WMode",line+1,endtok)==0 ) fp->fd->wmode = strtol(endtok,NULL,10); else if ( mycmp("FontBBox",line+1,endtok)==0 ) filldoublearray(fp->fd->fontbb,endtok,4); else if ( mycmp("UniqueID",line+1,endtok)==0 ) { if ( fp->fd->uniqueid==0 ) fp->fd->uniqueid = strtol(endtok,NULL,10); } else if ( mycmp("UniqueId",line+1,endtok)==0 ) { fprintf(stderr,"This font contains a \"UniqueId\" variable, but the correct name for it is\n\t\"UniqueID\" (postscript is case concious)\n" ); if ( fp->fd->uniqueid==0 ) fp->fd->uniqueid = strtol(endtok,NULL,10); } else if ( mycmp("XUID",line+1,endtok)==0 ) { if ( fp->fd->xuid[0]==0 ) fillintarray(fp->fd->xuid,endtok,20); } else if ( mycmp("StrokeWidth",line+1,endtok)==0 ) fp->fd->strokewidth = strtod(endtok,NULL); else if ( mycmp("WeightVector",line+1,endtok)==0 ) { fp->pending_parse = &fp->fd->weightvector; AddValue(fp,NULL,line,endtok); } else if ( mycmp("$Blend",line+1,endtok)==0 ) { fp->pending_parse = &fp->fd->blendfunc; AddValue(fp,NULL,line,endtok); } else if ( strstr( line,"/NormalizeDesignVector" )!=NULL ) { fp->pending_parse = &fp->fd->ndv; AddValue(fp,NULL,line,endtok); } else if ( strstr( line,"/ConvertDesignVector" )!=NULL ) { fp->pending_parse = &fp->fd->cdv; AddValue(fp,NULL,line,endtok); } else if ( mycmp("BuildChar",line+1,endtok)==0 ) /* Do Nothing */; else if ( mycmp("BuildGlyph",line+1,endtok)==0 ) /* Do Nothing */; else if ( mycmp("CIDFontName",line+1,endtok)==0 ) fp->fd->cidfontname = gettoken(endtok); else if ( mycmp("CIDFontVersion",line+1,endtok)==0 ) { fp->fd->cidversion = strtod(endtok,NULL); #if 0 if ( fp->fd->fontinfo->version==NULL ) { char temp[40]; sprintf(temp,"%f", fp->fd->cidversion); fp->fd->fontinfo->version = strdup(temp); } #endif } else if ( mycmp("CIDFontType",line+1,endtok)==0 ) fp->fd->cidfonttype = strtol(endtok,NULL,10); else if ( mycmp("UIDBase",line+1,endtok)==0 ) fp->fd->uniqueid = strtol(endtok,NULL,10); else if ( mycmp("CIDMapOffset",line+1,endtok)==0 ) fp->fd->mapoffset = strtol(endtok,NULL,10); else if ( mycmp("FDBytes",line+1,endtok)==0 ) fp->fd->fdbytes = strtol(endtok,NULL,10); else if ( mycmp("GDBytes",line+1,endtok)==0 ) fp->fd->gdbytes = strtol(endtok,NULL,10); else if ( mycmp("CIDCount",line+1,endtok)==0 ) fp->fd->cidcnt = strtol(endtok,NULL,10); else if ( mycmp("FDArray",line+1,endtok)==0 ) { int i; fp->mainfd = fp->fd; fp->fd->fdcnt = strtol(endtok,NULL,10); fp->fd->fds = calloc(fp->fd->fdcnt,sizeof(struct fontdict *)); for ( i=0; ifd->fdcnt; ++i ) fp->fd->fds[i] = MakeEmptyFont(); fp->fdindex = 0; fp->fd = fp->fd->fds[0]; } else if ( mycmp("FontSetInit",line+1,endtok)==0 ) { fp->iscff = true; fp->iscid = false; } else if ( mycmp("CIDInit",line+1,endtok)==0 ) { fp->iscid = true; fp->iscff = false; } else if ( fp->skipping_mbf ) { /* Skip over the makeblendedfont defn in a multimaster font */ /* Do Nothing */ } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Didn't understand |%s", rmbinary(line) ); fp->alreadycomplained = true; } } } static void addinfo(struct fontparse *fp,char *line,char *tok,char *binstart,int binlen,FILE *in) { char *pt; decodestr((unsigned char *) binstart,binlen); binstart += fp->fd->private->leniv; binlen -= fp->fd->private->leniv; retry: if ( fp->insubs ) { struct pschars *chars = /*fp->insubs ?*/ fp->fd->private->subrs /*: fp->fd->private->othersubrs*/; while ( isspace(*line)) ++line; if ( strncmp(line,"dup ",4)==0 ) { int i = strtol(line+4,NULL,10); if ( fp->ignore ) /* Do Nothing */; else if ( icnt ) { if ( chars->values[i]!=NULL ) fprintf( stderr, "Duplicate definition of subroutine %d\n", i ); chars->lens[i] = binlen; chars->values[i] = malloc(binlen); memcpy(chars->values[i],binstart,binlen); if ( i>=chars->next ) chars->next = i+1; } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Index too big (must be <%d) |%s", chars->cnt, rmbinary(line)); fp->alreadycomplained = true; } } else if ( !fp->alreadycomplained ) { fprintf( stderr, "Didn't understand |%s", rmbinary(line) ); fp->alreadycomplained = true; } } else if ( fp->inchars ) { struct pschars *chars = fp->fd->chars; if ( *tok=='\0' ) fprintf( stderr, "No name for CharStrings dictionary |%s", rmbinary(line) ); else if ( fp->ignore ) /* Do Nothing */; else if ( chars->next>=chars->cnt ) fprintf( stderr, "Too many entries in CharStrings dictionary |%s", rmbinary(line) ); else { int i = chars->next; chars->lens[i] = binlen; chars->keys[i] = strdup(tok); chars->values[i] = malloc(binlen); memcpy(chars->values[i],binstart,binlen); ++chars->next; } } else if ( !fp->alreadycomplained ) { /* Special hacks for known badly formatted fonts */ if ( strstr(line,"/CharStrings")!=NULL ) { for ( pt=line; *pt!='/'; ++pt ); pt = strchr(pt+1,'/'); if ( pt!=NULL ) *pt = '\0'; parseline(fp,line,in); if ( pt!=NULL ) { *pt = '/'; line = pt; goto retry; } return; } else if ( strstr(line,"/Subrs")!=NULL ) { pt = strstr(line,"dup"); if ( pt!=NULL ) *pt = '\0'; parseline(fp,line,in); if ( pt!=NULL ) { *pt = 'd'; line = pt; goto retry; } return; } fprintf( stderr, "Shouldn't be in addinfo |%s", rmbinary(line) ); fp->alreadycomplained = true; } } /* In the book the token which starts a character description is always RD but*/ /* it's just the name of a subroutine which is defined in the private diction*/ /* and it could be anything. in one case it was "-|" (hyphen bar) so we can't*/ /* just look for RD we must be a bit smarter and figure out what the token is*/ /* (oh. I see now. it's allowed to be either one "RD" or "-|", but nothing else*/ /* right) */ /* It's defined as {string currentfile exch readstring pop} so look for that */ /* Except that in gsf files we've also got "/-!{string currentfile exch readhexstring pop} readonly def" */ /* NOTE: readhexstring!!! */ /* And in files generated by GNU fontutils */ static int glorpline(struct fontparse *fp, FILE *temp, char *rdtok) { static char *buffer=NULL, *end; char *pt, *binstart; int binlen; int ch; int innum, val=0, inbinary, cnt=0, inr, wasspace, nownum, nowr, nowspace, sptok; char *rdline = "{string currentfile exch readstring pop}", *rpt; char *rdline2 = "{string currentfile exch readhexstring pop}"; char *tokpt = NULL, *rdpt; char temptok[255]; int intok, first; int wasminus=false, isminus, nibble, firstnibble, inhex; int willbehex = false; ch = getc(temp); if ( ch==EOF ) return( 0 ); ungetc(ch,temp); if ( buffer==NULL ) { buffer = malloc(3000); end = buffer+3000; } innum = inr = 0; wasspace = 0; inbinary = 0; rpt = NULL; rdpt = NULL; inhex = 0; pt = buffer; binstart=NULL; binlen = 0; intok=0; sptok=0; first=1; temptok[0] = '\0'; while ( (ch=getc(temp))!=EOF ) { if ( pt>=end ) { char *old = buffer; int len = (end-buffer)+2000; buffer = realloc(buffer,len); end = buffer+len; pt = buffer+(pt-old); if ( binstart!=NULL ) binstart = buffer+(binstart-old); } *pt++ = ch; isminus = ch=='-' && wasspace; nownum = nowspace = nowr = 0; if ( rpt!=NULL && ch!=*rpt && ch=='h' && rpt-rdline>25 && rpt-rdline<30 && rdline2[rpt-rdline]=='h' ) { rpt = rdline2 + (rpt-rdline); willbehex = true; } if ( inbinary ) { if ( --cnt==0 ) inbinary = 0; } else if ( inhex ) { if ( isxdigit(ch)) { int h; if ( isdigit(ch)) h = ch-'0'; else if ( ch>='a' && ch<='f' ) h = ch-'a'+10; else h = ch-'A'+10; if ( firstnibble ) { nibble = h; --pt; } else { pt[-1] = (nibble<<4)|h; if ( --cnt==0 ) inbinary = inhex = 0; } firstnibble = !firstnibble; } else { --pt; /* skip everything not hex */ } } else if ( ch=='/' ) { intok = 1; tokpt = temptok; } else if ( intok && !isspace(ch) && ch!='{' && ch!='[' ) { *tokpt++ = ch; } else if ( (intok||sptok) && (ch=='{' || ch=='[')) { *tokpt = '\0'; rpt = rdline+1; intok = sptok = 0; } else if ( intok ) { *tokpt = '\0'; intok = 0; sptok = 1; } else if ( sptok && isspace(ch)) { nowspace = 1; if ( ch=='\n' || ch=='\r' ) break; } else if ( sptok && !isdigit(ch)) sptok = 0; else if ( rpt!=NULL && ch==*rpt ) { if ( *++rpt=='\0' ) { /* it matched the character definition string so this is the */ /* token we want to search for */ strcpy(rdtok,temptok); fp->useshexstrings = willbehex; rpt = NULL; } } else if ( rpt!=NULL && ch==' ' ) { /* Extra spaces are ok */ } else if ( rpt!=NULL ) { rpt = NULL; willbehex = false; } else if ( isdigit(ch)) { sptok = 0; nownum = 1; if ( innum ) val = 10*val + ch-'0'; else val = ch-'0'; } else if ( isspace(ch)) { nowspace = 1; if ( ch=='\n' || ch=='\r' ) break; } else if ( wasspace && ch==*rdtok ) { nowr = 1; fp->useshexstrings = willbehex; rdpt = rdtok+1; } else if ( wasspace && ch=='-' ) { /* fonts produced by type1fix seem to define both "RD" and "-|" which confused me. so just respond to either */ nowr = 1; fp->useshexstrings = false; rdpt = "|"; } else if ( wasspace && ch=='R' ) { /* fonts produced by type1fix seem to define both "RD" and "-|" which confused me. so just respond to either */ nowr = 1; fp->useshexstrings = false; rdpt = "D"; } else if ( inr && ch==*rdpt ) { if ( *++rdpt =='\0' ) { ch = getc(temp); *pt++ = ch; if ( isspace(ch) && val!=0 ) { inhex = fp->useshexstrings; inbinary = !fp->useshexstrings; firstnibble = true; cnt = val; binstart = pt; binlen = val; } } else nowr = 1; } else if ( wasminus && ch=='!' ) { ch = getc(temp); *pt++ = ch; if ( isspace(ch) && val!=0 ) { inhex = 1; cnt = val; binstart = pt; binlen = val; firstnibble = true; } } innum = nownum; wasspace = nowspace; inr = nowr; wasminus = isminus; first = 0; } *pt = '\0'; if ( binstart==NULL ) { parseline(fp,buffer,temp); } else { addinfo(fp,buffer,temptok,binstart,binlen,temp); } return( 1 ); } static int nrandombytes[4]; #define EODMARKLEN 16 #define bgetc(extra,in) (*(extra)=='\0' ? getc(in) : (unsigned char ) *(extra)++ ) static void decrypteexec(FILE *in,FILE *temp, int hassectionheads,char *extra) { int ch1, ch2, ch3, ch4, binary; int zcnt; unsigned char zeros[EODMARKLEN+6+1]; int sect_len; if ( extra==(void *) 5 ) extra = ""; while ( (ch1=bgetc(extra,in))!=EOF && isspace(ch1)); if ( ch1==0200 && hassectionheads ) { /* skip the 6 byte section header in pfb files that follows eexec */ ch1 = bgetc(extra,in); sect_len = bgetc(extra,in); sect_len |= bgetc(extra,in)<<8; sect_len |= bgetc(extra,in)<<16; sect_len |= bgetc(extra,in)<<24; sect_len -= 3; ch1 = bgetc(extra,in); } ch2 = bgetc(extra,in); ch3 = bgetc(extra,in); ch4 = bgetc(extra,in); binary = 0; if ( ch1<'0' || (ch1>'9' && ch1<'A') || ( ch1>'F' && ch1<'a') || (ch1>'f') || ch2<'0' || (ch2>'9' && ch2<'A') || (ch2>'F' && ch2<'a') || (ch2>'f') || ch3<'0' || (ch3>'9' && ch3<'A') || (ch3>'F' && ch3<'a') || (ch3>'f') || ch4<'0' || (ch4>'9' && ch4<'A') || (ch4>'F' && ch4<'a') || (ch4>'f') ) binary = 1; if ( ch1==EOF || ch2==EOF || ch3==EOF || ch4==EOF ) { return; } initcode(); if ( binary ) { nrandombytes[0] = decode(ch1); nrandombytes[1] = decode(ch2); nrandombytes[2] = decode(ch3); nrandombytes[3] = decode(ch4); zcnt = 0; while (( ch1=bgetc(extra,in))!=EOF ) { --sect_len; if ( hassectionheads ) { if ( sect_len==0 && ch1==0200 ) { ch1 = bgetc(extra,in); sect_len = bgetc(extra,in); sect_len |= bgetc(extra,in)<<8; sect_len |= bgetc(extra,in)<<16; sect_len |= bgetc(extra,in)<<24; sect_len += 1; if ( ch1=='\1' ) break; } else { dumpzeros(temp,zeros,zcnt); zcnt = 0; putc(decode(ch1),temp); } } else { if ( ch1=='0' ) ++zcnt; else {dumpzeros(temp,zeros,zcnt); zcnt = 0; } if ( zcnt>EODMARKLEN ) break; if ( zcnt==0 ) putc(decode(ch1),temp); else zeros[zcnt-1] = decode(ch1); } } } else { nrandombytes[0] = decode(hex(ch1,ch2)); nrandombytes[1] = decode(hex(ch3,ch4)); ch1 = bgetc(extra,in); ch2 = bgetc(extra,in); ch3 = bgetc(extra,in); ch4 = bgetc(extra,in); nrandombytes[2] = decode(hex(ch1,ch2)); nrandombytes[3] = decode(hex(ch3,ch4)); zcnt = 0; while (( ch1=bgetc(extra,in))!=EOF ) { while ( ch1!=EOF && isspace(ch1)) ch1 = bgetc(extra,in); while ( (ch2=bgetc(extra,in))!=EOF && isspace(ch2)); if ( ch1=='0' && ch2=='0' ) ++zcnt; else { dumpzeros(temp,zeros,zcnt); zcnt = 0;} if ( zcnt>EODMARKLEN ) break; if ( zcnt==0 ) putc(decode(hex(ch1,ch2)),temp); else zeros[zcnt-1] = decode(hex(ch1,ch2)); } } while (( ch1=bgetc(extra,in))=='0' || isspace(ch1) ); if ( ch1!=EOF ) ungetc(ch1,in); } static void decryptagain(struct fontparse *fp,FILE *temp,char *rdtok) { while ( glorpline(fp,temp,rdtok)); } static void parsetype3(struct fontparse *fp,FILE *in) { /*PSFontInterpretPS(in,fp->fd->charprocs);*/ } static unsigned char *readt1str(FILE *temp,int offset,int len,int leniv) { int i; unsigned char *str, *pt; unsigned short r = 4330; unsigned char plain, cypher; /* The CID spec doesn't mention this, but the type 1 strings are all */ /* eexec encrupted (with the nested encryption). Remember leniv varies */ /* from fd to fd (potentially) */ /* I'm told (by Ian Kemmish) that leniv==-1 => no eexec encryption */ fseek(temp,offset,SEEK_SET); if ( leniv<0 ) { str = pt = malloc(len+1); for (; i>8)); r = (cypher + r) * c1 + c2; } str = pt = malloc(len-leniv+1); for (; i>8)); r = (cypher + r) * c1 + c2; *pt++ = plain; } } *pt = '\0'; return( str ); } static void figurecids(struct fontparse *fp,FILE *temp) { struct fontdict *fd = fp->mainfd; int i,j,k,val; int *offsets; int cidcnt = fd->cidcnt; int leniv; /* Some cid formats don't have any of these */ fd->cidstrs = malloc(cidcnt*sizeof(unsigned char *)); fd->cidlens = malloc(cidcnt*sizeof(short)); fd->cidfds = malloc((cidcnt+1)*sizeof(short)); offsets = malloc((cidcnt+1)*sizeof(int)); fseek(temp,fd->mapoffset,SEEK_SET); for ( i=0; i<=fd->cidcnt; ++i ) { for ( j=val=0; jfdbytes; ++j ) val = (val<<8) + getc(temp); fd->cidfds[i] = val; for ( j=val=0; jgdbytes; ++j ) val = (val<<8) + getc(temp); offsets[i] = val; if ( i!=0 ) fd->cidlens[i-1] = offsets[i]-offsets[i-1]; } for ( i=0; icidcnt; ++i ) { if ( fd->cidlens[i]== 0 ) fd->cidstrs[i] = NULL; else { fd->cidstrs[i] = readt1str(temp,offsets[i],fd->cidlens[i], fd->fds[fd->cidfds[i]]->private->leniv); fd->cidlens[i] -= fd->fds[fd->cidfds[i]]->private->leniv; } } free(offsets); for ( k=0; kfdcnt; ++k ) { struct private *private = fd->fds[k]->private; char *ssubroff = PSDictHasEntry(private->private,"SubrMapOffset"); char *ssdbytes = PSDictHasEntry(private->private,"SDBytes"); char *ssubrcnt = PSDictHasEntry(private->private,"SubrCount"); int subroff, sdbytes, subrcnt; if ( ssubroff!=NULL && ssdbytes!=NULL && ssubrcnt!=NULL && (subroff=strtol(ssubroff,NULL,10))>=0 && (sdbytes=strtol(ssdbytes,NULL,10))>0 && (subrcnt=strtol(ssubrcnt,NULL,10))>0 ) { private->subrs->cnt = subrcnt; private->subrs->values = calloc(subrcnt,sizeof(char *)); private->subrs->lens = calloc(subrcnt,sizeof(int)); leniv = private->leniv; offsets = malloc((subrcnt+1)*sizeof(int)); fseek(temp,subroff,SEEK_SET); for ( i=0; i<=subrcnt; ++i ) { for ( j=val=0; jsubrs->lens[i-1] = offsets[i]-offsets[i-1]; } for ( i=0; isubrs->values[i] = readt1str(temp,offsets[i], private->subrs->lens[i],leniv); } private->subrs->next = i; free(offsets); } PSDictRemoveEntry(private->private,"SubrMapOffset"); PSDictRemoveEntry(private->private,"SDBytes"); PSDictRemoveEntry(private->private,"SubrCount"); } } static void dodata( struct fontparse *fp, FILE *in, FILE *temp) { int binary, cnt, len; int ch, ch2; char *pt; char fontsetname[256]; while ( (ch=getc(in))!='(' && ch!='/' && ch!=EOF ); if ( ch=='/' ) { /* There appears to be no provision for a hex encoding here */ /* Why can't they use the same format for routines with the same name? */ binary = true; for ( pt=fontsetname; (ch=getc(in))!=' ' && ch!=EOF; ) if ( pt0 ) { ch = getc(in); putc(ch,temp); --cnt; } } else { while ( cnt>0 ) { /* Hex data are allowed to contain whitespace */ while ( isspace(ch=getc(in)) ); while ( isspace(ch2=getc(in)) ); ch = hex(ch,ch2); putc(ch,temp); --cnt; } if ( (ch=getc(in))!='>' ) ungetc(ch,in); } rewind(temp); if ( fp->iscid ) figurecids(fp,temp); else { /*fp->fd->sf = _CFFParse(temp,len,fontsetname);*/ fp->fd->wascff = true; } } static void doubledecrypt(struct fontparse *fp,FILE *in, FILE *temp) { char buffer[256]; int first, hassectionheads; char rdtok[20]; int saw_blend = false; strcpy(rdtok,"RD"); first = 1; hassectionheads = 0; while ( myfgets(buffer,sizeof(buffer),in)!=NULL ) { if ( strstr(buffer, "Blend")!=NULL ) saw_blend = true; if ( first && buffer[0]=='\200' ) { hassectionheads = 1; fp->fd->wasbinary = true; parseline(fp,buffer+6,in); } else if ( strstr(buffer,"CharProcs")!=NULL && strstr(buffer,"begin")!=NULL ) { parsetype3(fp,in); return; } else if ( !fp->iscid ) { if ( saw_blend ) parseline(fp,buffer,in); /* But if it's a multi master font, don't do the special private hack */ else if ( strstr(buffer,"/CharStrings")!=NULL && strstr(buffer,"begin")!=NULL ) { /* gsf files are not eexec encoded, but the charstrings are encoded*/ InitChars(fp->fd->chars,buffer); fp->inchars = 1; decryptagain(fp,in,rdtok); return; } else if ( strstr(buffer,"/Subrs")!=NULL && strstr(buffer,"array")!=NULL ) { /* Same case as above */ InitChars(fp->fd->private->subrs,buffer); fp->insubs = 1; decryptagain(fp,in,rdtok); return; } else if ( strstr(buffer,"/Private")!=NULL && strstr(buffer,"dict")!=NULL ) { /* files produced by GNU fontutils have some of the same issues */ fp->inprivate = 1; fp->infi = false; decryptagain(fp,in,rdtok); return; } else parseline(fp,buffer,in); } else parseline(fp,buffer,in); first = 0; if ( strstr(buffer,"%%BeginData: ")!=NULL ) break; if ( strstr(buffer,"currentfile")!=NULL && strstr(buffer, "eexec")!=NULL ) { fp->skipping_mbf = false; break; } } if ( strstr(buffer,"%%BeginData: ")!=NULL ) { /* used by both CID fonts and CFF fonts (and chameleons, whatever they are) */ dodata(fp,in,temp); } else { decrypteexec(in,temp,hassectionheads,strstr(buffer, "eexec")+5); rewind(temp); decryptagain(fp,temp,rdtok); while ( myfgets(buffer,sizeof(buffer),in)!=NULL ) { if ( buffer[0]!='\200' || !hassectionheads ) parseline(fp,buffer,in); } } } static FontDict *_ReadPSFont(FILE *in) { FILE *temp; struct fontparse fp; char *oldloc; temp = tmpfile(); if ( temp==NULL ) { fprintf( stderr, "Cannot open a temporary file\n" ); fclose(in); return(NULL); } oldloc = setlocale(LC_NUMERIC,"C"); memset(&fp,'\0',sizeof(fp)); fp.fd = fp.mainfd = PSMakeEmptyFont(); fp.fdindex = -1; doubledecrypt(&fp,in,temp); free(fp.vbuf); setlocale(LC_NUMERIC,oldloc); fclose(temp); return( fp.fd ); } static void PSCharsFree(struct pschars *chrs) { int i; if ( chrs==NULL ) return; for ( i=0; inext; ++i ) { if ( chrs->keys!=NULL ) free(chrs->keys[i]); free(chrs->values[i]); } free(chrs->lens); free(chrs->keys); free(chrs->values); free(chrs); } static void PSDictFree(struct psdict *dict) { int i; if ( dict==NULL ) return; for ( i=0; inext; ++i ) { if ( dict->keys!=NULL ) free(dict->keys[i]); free(dict->values[i]); } free(dict->keys); free(dict->values); free(dict); } static void PrivateFree(struct private *prv) { PSCharsFree(prv->subrs); #if 1 PSDictFree(prv->private); #else PSCharsFree(prv->othersubrs); free(prv->minfeature); free(prv->nd); free(prv->np); free(prv->rd); #endif free(prv); } static void FontInfoFree(struct fontinfo *fi) { free(fi->familyname); free(fi->fullname); free(fi->notice); free(fi->weight); free(fi->version); free(fi->blenddesignpositions); free(fi->blenddesignmap); free(fi->blendaxistypes); free(fi); } static void PSFontFree(FontDict *fd) { int i; if ( fd->encoding!=NULL ) for ( i=0; i<256; ++i ) free( fd->encoding[i]); free(fd->fontname); free(fd->cidfontname); free(fd->registry); free(fd->ordering); FontInfoFree(fd->fontinfo); PSCharsFree(fd->chars); PrivateFree(fd->private); if ( fd->charprocs!=NULL ) { for ( i=0; icharprocs->cnt; ++i ) free(fd->charprocs->keys[i]); free(fd->charprocs->keys); free(fd->charprocs->values); free(fd->charprocs); } if ( fd->cidstrs!=NULL ) { for ( i=0; icidcnt; ++i ) free( fd->cidstrs[i]); free(fd->cidstrs); } free(fd->cidlens); free(fd->cidfds); if ( fd->fds!=NULL ) { for ( i=0; ifdcnt; ++i ) PSFontFree(fd->fds[i]); free(fd->fds); } free(fd->blendfunc); free(fd->weightvector); free(fd->cdv); free(fd->ndv); PSDictFree(fd->blendprivate); PSDictFree(fd->blendfontinfo); free(fd); } static struct bbglyph *FindAdobeGlyph(PSFONT *psfont,int adobe_enc) { char *search_name; struct pschars *chars = psfont->temp; int i; if ( adobe_enc>=256 || adobe_enc<0 ) return( &psfont->glyphs[0] ); /* Return .notdef */ search_name = AdobeStandardEncoding[adobe_enc]; for ( i=0; icnt; ++i ) { if ( strcmp(search_name,chars->keys[i])==0 ) { if ( psfont->glyphs[i].isref ) return( NULL ); return( &psfont->glyphs[i] ); } } for ( i=0; icnt; ++i ) { if ( strcmp(".notdef",chars->keys[i])==0 ) return( &psfont->glyphs[i] ); } return( &psfont->glyphs[0] ); /* Return something. font doesn't even have notdef */ } static void FindBB(PSFONT *psfont, struct bbglyph *bb, unsigned char *type1, int len, struct pschars *subrs, char *name ) { double stack[50]; int sp=0, v; /* Type1 stack is about 25 long, Type2 stack is 48 */ double transient[32]; struct { double x,y; } current; double dx, dy, dx2, dy2, dx3, dy3; /* subroutines may be nested to a depth of 10 */ struct substate { unsigned char *type1; int len; int subnum; } pcstack[11]; int pcsp=0; double pops[30]; int popsp=0; int base, polarity; struct pschars *s; int first = true; int lsidebearing; struct bbglyph *bb1, *bb2; int offx, offy; current.x = current.y = 0; while ( len>0 ) { if ( sp>48 ) { fprintf( stderr, "Stack got too big in %s\n", name ); sp = 48; } base = 0; --len; if ( (v = *type1++)>=32 ) { if ( v<=246) { stack[sp++] = v - 139; } else if ( v<=250 ) { stack[sp++] = (v-247)*256 + *type1++ + 108; --len; } else if ( v<=254 ) { stack[sp++] = -(v-251)*256 - *type1++ - 108; --len; } else { int val = (*type1<<24) | (type1[1]<<16) | (type1[2]<<8) | type1[3]; stack[sp++] = val; type1 += 4; len -= 4; } } else if ( v==28 ) { stack[sp++] = (short) ((type1[0]<<8) | type1[1]); type1 += 2; len -= 2; /* In the Dict tables of CFF, a 5byte fixed value is prefixed by a */ /* 29 code. In Type2 strings the prefix is 255. */ } else if ( v==12 ) { v = *type1++; --len; switch ( v ) { case 0: /* dotsection */ sp = 0; break; case 1: /* vstem3 */ /* specifies three v hints zones at once */ if ( sp<6 ) fprintf(stderr, "Stack underflow on vstem3 in %s\n", name ); /* according to the standard, if there is a vstem3 there can't */ /* be any vstems, so there can't be any confusion about hint order */ /* so we don't need to worry about unblended stuff */ sp = 0; break; case 2: /* hstem3 */ /* specifies three h hints zones at once */ if ( sp<6 ) fprintf(stderr, "Stack underflow on hstem3 in %s\n", name ); sp = 0; break; case 6: /* seac */ /* build accented characters */ seac: if ( sp<5 ) fprintf(stderr, "Stack underflow on seac in %s\n", name ); /* stack[0] must be the lsidebearing of the accent. I'm not sure why */ bb1 = FindAdobeGlyph(psfont,stack[3]); bb2 = FindAdobeGlyph(psfont,stack[4]); offx = stack[1] - (stack[0]-lsidebearing); offy = stack[2]; if ( bb1==NULL || bb2==NULL ) bb->isref = true; else { bb->top = bb1->top > bb2->top+offy ? bb1->top : bb2->top+offy; bb->bottom = bb1->bottom < bb2->bottom+offy ? bb1->bottom : bb2->bottom+offy; bb->right = bb1->right > bb2->right+offx ? bb1->right : bb2->right+offx; bb->left = bb1->left < bb2->left+offx ? bb1->left : bb2->left+offx; } sp = 0; break; case 7: /* sbw */ /* generalized width/sidebearing command */ if ( sp<4 ) fprintf(stderr, "Stack underflow on sbw in %s\n", name ); lsidebearing = stack[0]; /* stack[1] is lsidebearing y (only for vertical writing styles, CJK) */ bb->hadvance = stack[2]; /* stack[3] is height (for vertical writing styles, CJK) */ sp = 0; break; case 5: case 9: case 14: case 26: if ( sp<1 ) fprintf(stderr, "Stack underflow on unary operator in %s\n", name ); switch ( v ) { case 5: stack[sp-1] = (stack[sp-1]==0); break; /* not */ case 9: if ( stack[sp-1]<0 ) stack[sp-1]= -stack[sp-1]; break; /* abs */ case 14: stack[sp-1] = -stack[sp-1]; break; /* neg */ case 26: stack[sp-1] = sqrt(stack[sp-1]); break; /* sqrt */ } break; case 3: case 4: case 10: case 11: case 12: case 15: case 24: if ( sp<2 ) fprintf(stderr, "Stack underflow on binary operator in %s\n", name ); else switch ( v ) { case 3: /* and */ stack[sp-2] = (stack[sp-1]!=0 && stack[sp-2]!=0); break; case 4: /* and */ stack[sp-2] = (stack[sp-1]!=0 || stack[sp-2]!=0); break; case 10: /* add */ stack[sp-2] += stack[sp-1]; break; case 11: /* sub */ stack[sp-2] -= stack[sp-1]; break; case 12: /* div */ stack[sp-2] /= stack[sp-1]; break; case 24: /* mul */ stack[sp-2] *= stack[sp-1]; break; case 15: /* eq */ stack[sp-2] = (stack[sp-1]==stack[sp-2]); break; } --sp; break; case 22: /* ifelse */ if ( sp<4 ) fprintf(stderr, "Stack underflow on ifelse in %s\n", name ); else { if ( stack[sp-2]>stack[sp-1] ) stack[sp-4] = stack[sp-3]; sp -= 3; } break; case 23: /* random */ /* This function returns something (0,1]. It's not clear to me*/ /* if rand includes 0 and RAND_MAX or not, but this approach */ /* should work no matter what */ do { stack[sp] = (rand()/(RAND_MAX-1)); } while ( stack[sp]==0 || stack[sp]>1 ); ++sp; break; case 16: /* callothersubr */ /* stack[sp-1] is the number of the thing to call in the othersubr array */ /* stack[sp-2] is the number of args to grab off our stack and put on the */ /* double postscript stack */ if ( sp<2 || sp < 2+stack[sp-2] ) { fprintf(stderr, "Stack underflow on callothersubr in %s\n", name ); sp = 0; } else { int tot = stack[sp-2], k; popsp = 0; for ( k=sp-3; k>=sp-2-tot; --k ) pops[popsp++] = stack[k]; /* othersubrs 0-3 must be interpretted. 0-2 are Flex, 3 is Hint Replacement */ /* othersubrs 12,13 are for counter hints. We don't need to */ /* do anything to ignore them */ /* Subroutines 14-18 are multiple master blenders. We need */ /* to pay attention to them too */ switch ( (int) stack[sp-1] ) { case 3: { /* when we weren't capabable of hint replacement we */ /* punted by putting 3 on the stack (T1 spec page 70) */ /* subroutine 3 is a noop */ pops[popsp-1] = 3; } break; case 1: { /* Flex */ } break; case 2: { /* No op */; } break; case 0: break; } sp = k+1; } break; case 20: /* put */ if ( sp<2 ) fprintf(stderr, "Too few items on stack for put in %s\n", name ); else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) fprintf(stderr,"Reference to transient memory out of bounds in put in %s\n", name ); else { transient[(int)stack[sp-1]] = stack[sp-2]; sp -= 2; } break; case 21: /* get */ if ( sp<1 ) fprintf(stderr, "Too few items on stack for get in %s\n", name ); else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) fprintf(stderr,"Reference to transient memory out of bounds in put in %s\n", name ); else stack[sp-1] = transient[(int)stack[sp-1]]; break; case 17: /* pop */ /* pops something from the postscript stack and pushes it on ours */ /* used to get a return value from an othersubr call */ /* Bleah. Adobe wants the pops to return the arguments if we */ /* don't understand the call. What use is the subroutine then?*/ if ( popsp<=0 ) fprintf(stderr, "Pop stack underflow on pop in %s\n", name ); else stack[sp++] = pops[--popsp]; break; case 18: /* drop */ if ( sp>0 ) --sp; break; case 27: /* dup */ if ( sp>=1 ) { stack[sp] = stack[sp-1]; ++sp; } break; case 28: /* exch */ if ( sp>=2 ) { double temp = stack[sp-1]; stack[sp-1] = stack[sp-2]; stack[sp-2] = temp; } break; case 29: /* index */ if ( sp>=1 ) { int index = stack[--sp]; if ( index<0 || sp=2 ) { int j = stack[sp-1], N=stack[sp-2]; if ( N>sp || j>=N || j<0 || N<0 ) fprintf( stderr, "roll out of range in %s\n", name ); else if ( j==0 || N==0 ) /* No op */; else { double *temp = malloc(N*sizeof(double)); int i; for ( i=0; ibb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; } sp = 0; break; case 34: /* hflex */ case 35: /* flex */ case 36: /* hflex1 */ case 37: /* flex1 */ sp = 0; break; default: fprintf( stderr, "Uninterpreted opcode 12,%d in %s\n", v, name ); break; } } else switch ( v ) { case 1: /* hstem */ case 18: /* hstemhm */ base = 0; if ( sp&1 ) { bb->hadvance = stack[0]; base=1; } if ( sp-base<2 ) fprintf(stderr, "Stack underflow on hstem in %s\n", name ); /* stack[0] is absolute y for start of horizontal hint */ /* (actually relative to the y specified as lsidebearing y in sbw*/ /* stack[1] is relative y for height of hint zone */ sp = 0; break; case 19: /* hintmask */ case 20: /* cntrmask */ /* If there's anything on the stack treat it as a vstem hint */ base = 0; case 3: /* vstem */ case 23: /* vstemhm */ break; case 14: /* endchar */ /* endchar is allowed to terminate processing even within a subroutine */ pcsp = 0; if ( sp==4 ) { /* In Type2 strings endchar has a depreciated function of doing */ /* a seac (which doesn't exist at all). Except enchar takes */ /* 4 args and seac takes 5. Bleah */ stack[4] = stack[3]; stack[3] = stack[2]; stack[2] = stack[1]; stack[1] = stack[0]; stack[0] = 0; sp = 5; goto seac; } /* the docs say that endchar must be the last command in a char */ /* (or the last command in a subroutine which is the last in the */ /* char) So in theory if there's anything left we should complain*/ /* In practice though, the EuroFont has a return statement after */ /* the endchar in a subroutine. So we won't try to catch that err*/ /* and just stop. */ /* Adobe says it's not an error, but I can't understand their */ /* logic */ goto done; break; case 13: /* hsbw (set left sidebearing and width) */ if ( sp<2 ) fprintf(stderr, "Stack underflow on hsbw in %s\n", name ); lsidebearing = stack[0]; current.x = stack[0]; /* sets the current point too */ bb->hadvance = stack[1]; sp = 0; break; case 9: /* closepath */ sp = 0; break; case 21: /* rmoveto */ case 22: /* hmoveto */ case 4: /* vmoveto */ case 5: /* rlineto */ case 6: /* hlineto */ case 7: /* vlineto */ polarity = 0; base = 0; while ( basetop = bb->bottom = current.y; bb->left = bb->right = current.x; first = false; } else { if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; } } sp = 0; break; case 25: /* rlinecurve */ base = 0; while ( sp>base+6 ) { current.x += stack[base++]; current.y += stack[base++]; if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; } case 24: /* rcurveline */ case 8: /* rrcurveto */ case 31: /* hvcurveto */ case 30: /* vhcurveto */ case 27: /* hhcurveto */ case 26: /* vvcurveto */ polarity = 0; while ( sp>base+2 ) { dx = dy = dx2 = dy2 = dx3 = dy3 = 0; if ( v==8 || v==25 || v==24 ) { if ( sp<6+base ) { fprintf(stderr, "Stack underflow on rrcurveto in %s\n", name ); base = sp; } else { dx = stack[base++]; dy = stack[base++]; dx2 = stack[base++]; dy2 = stack[base++]; dx3 = stack[base++]; dy3 = stack[base++]; } } else if ( v==27 ) { /* hhcurveto */ if ( sp<4+base ) { fprintf(stderr, "Stack underflow on hhcurveto in %s\n", name ); base = sp; } else { if ( (sp-base)&1 ) dy = stack[base++]; dx = stack[base++]; dx2 = stack[base++]; dy2 = stack[base++]; dx3 = stack[base++]; } } else if ( v==26 ) { /* vvcurveto */ if ( sp<4+base ) { fprintf(stderr, "Stack underflow on hhcurveto in %s\n", name ); base = sp; } else { if ( (sp-base)&1 ) dx = stack[base++]; dy = stack[base++]; dx2 = stack[base++]; dy2 = stack[base++]; dy3 = stack[base++]; } } else if ( (v==31 && !(polarity&1)) || (v==30 && (polarity&1)) ) { if ( sp<4+base ) { fprintf(stderr, "Stack underflow on hvcurveto in %s\n", name ); base = sp; } else { dx = stack[base++]; dx2 = stack[base++]; dy2 = stack[base++]; dy3 = stack[base++]; if ( sp==base+1 ) dx3 = stack[base++]; } } else /*if ( (v==30 && !(polarity&1)) || (v==31 && (polarity&1)) )*/ { if ( sp<4+base ) { fprintf(stderr, "Stack underflow on vhcurveto in %s\n", name ); base = sp; } else { dy = stack[base++]; dx2 = stack[base++]; dy2 = stack[base++]; dx3 = stack[base++]; if ( sp==base+1 ) dy3 = stack[base++]; } } ++polarity; current.x += dx; current.y += dy; if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; current.x += dx2; current.y += dy2; if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; current.x += dx3; current.y += dy3; if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; } if ( v==24 ) { current.x += stack[base++]; current.y += stack[base++]; if ( current.y>bb->top ) bb->top = current.y; if ( current.ybottom ) bb->bottom = current.y; if ( current.x>bb->right ) bb->right = current.x; if ( current.xleft ) bb->left = current.x; } sp = 0; break; case 29: /* callgsubr */ case 10: /* callsubr */ /* stack[sp-1] contains the number of the subroutine to call */ if ( sp<1 ) { fprintf(stderr, "Stack underflow on callsubr in %s\n", name ); break; } else if ( pcsp>10 ) { fprintf( stderr, "Too many subroutine calls in %s\n", name ); break; } s=subrs; if ( s==NULL || stack[sp-1]>=s->cnt || stack[sp-1]<0 || s->values[(int) stack[sp-1]]==NULL ) fprintf(stderr,"Subroutine number out of bounds in %s\n", name ); else { pcstack[pcsp].type1 = type1; pcstack[pcsp].len = len; pcstack[pcsp].subnum = stack[sp-1]; ++pcsp; type1 = s->values[(int) stack[sp-1]]; len = s->lens[(int) stack[sp-1]]; } if ( --sp<0 ) sp = 0; break; case 11: /* return */ /* return from a subr outine */ if ( pcsp<1 ) fprintf(stderr, "return when not in subroutine in %s\n", name ); else { --pcsp; type1 = pcstack[pcsp].type1; len = pcstack[pcsp].len; } break; default: fprintf( stderr, "Uninterpreted opcode %d in %s\n", v, name ); break; } } done: if ( pcsp!=0 ) fprintf(stderr, "end of subroutine reached with no return in %s\n", name ); } void ParsePfb(FILE *pfb,PSFONT *psfont) { FontDict *fd = _ReadPSFont(pfb); char *pt; int i,j, anyrefs, attempts; memset(psfont,0,sizeof(PSFONT)); if ( fd==NULL || fd->fontname==NULL ) return; psfont->glyphcnt = fd->chars->next; psfont->glyphs = calloc(psfont->glyphcnt,sizeof(struct bbglyph)); psfont->temp = fd->chars; for ( i=0; i<256; ++i ) { for ( j=fd->chars->next-1; j>=0; --j ) if ( strcmp(fd->encoding[i],fd->chars->keys[j])==0 ) break; if ( j==-1 ) for ( j=fd->chars->next-1; j>0; --j ) if ( strcmp(".notdef",fd->chars->keys[j])==0 ) break; psfont->encoding[i] = j; } psfont->fontname = strdup(fd->fontname); if ( fd->fontinfo!=NULL ) { psfont->familyname = strdup(fd->fontinfo->familyname); psfont->fullname = strdup(fd->fontinfo->fullname); psfont->weight = strdup(fd->fontinfo->weight); psfont->notice = strdup(fd->fontinfo->notice); psfont->version = strdup(fd->fontinfo->version); psfont->italicangle = fd->fontinfo->italicangle; } else { psfont->familyname = strdup(fd->fontname); if ( (pt = strchr(psfont->familyname,'-'))!=NULL ) *pt = '\0'; psfont->fullname = strdup(fd->fontname); psfont->weight = strdup("Regular"); } psfont->isadobestd = fd->isadobestd; psfont->em = 1000; if ( fd->fontmatrix[0]!=0 ) psfont->em = 1.0/fd->fontmatrix[0]; memcpy(psfont->fbb,fd->fontbb,sizeof(psfont->fbb)); anyrefs = true; for ( i=0; iglyphcnt; ++i ) psfont->glyphs[i].isref = true; attempts = 0; while ( anyrefs && attemptsglyphcnt ) { anyrefs = false; for ( i=0; iglyphcnt; ++i ) if ( psfont->glyphs[i].isref ) { psfont->glyphs[i].isref = false; FindBB(psfont,&psfont->glyphs[i],fd->chars->values[i],fd->chars->lens[i], fd->private->subrs, fd->chars->keys[i]); if ( psfont->glyphs[i].isref ) anyrefs = true; else psfont->glyphs[i].glyphname = strdup(fd->chars->keys[i]); } ++attempts; } for ( i=0; iglyphcnt; ++i ) if ( !psfont->glyphs[i].isref ) { if ( strcmp(psfont->glyphs[i].glyphname,"X")==0 ) psfont->ch = psfont->glyphs[i].top; else if ( strcmp(psfont->glyphs[i].glyphname,"x")==0 ) psfont->xh = psfont->glyphs[i].top; else if ( strcmp(psfont->glyphs[i].glyphname,"l")==0 ) psfont->as = psfont->glyphs[i].top; else if ( strcmp(psfont->glyphs[i].glyphname,"p")==0 ) psfont->ds = psfont->glyphs[i].bottom; } for ( i=0; iglyphcnt; ++i ) if ( psfont->glyphs[i].isref ) { -- psfont->glyphcnt; memcpy(&psfont->glyphs[i],&psfont->glyphs[i+1],(psfont->glyphcnt-i)*sizeof(struct bbglyph)); } PSFontFree(fd); } fondu-060102/frombin.10100644000076500007650000000113210303427445012641 0ustar gwwgww.TH FROMBIN 1 "21 December 2002" .SH NAME frombin \- convert macbinary files into normal files .SH SYNOPSIS .B frombin .BR macbinaryfile ... .SH DESCRIPTION The program .B frombin reads a series of macbinary files and unwraps them. On the mac it will produce a file similar to the original one. On non-macs it will create (up to) three files, one for the data fork (called .data), one for the resource fork (called .rsrc) and one containing random information in a human readable format (called .info). .SH AUTHOR George Williams (gww@silcom.com). .\" end of manual page fondu-060102/setfondname.c0100644000076500007650000002436710303430002013570 0ustar gwwgww/* Copyright (C) 2001-2004 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "macfonts.h" #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4)) #define true 1 #define false 0 int getushort(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); if ( ch2==EOF ) return( EOF ); return( (ch1<<8)|ch2 ); } long getlong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 ); } static void putshort(int val, FILE *f) { putc(val>>8,f); putc(val&0xff,f); } static void dousage(void) { fprintf( stderr, "Usage: setfondname -name=newname font.dfont\n" ); exit(1); } static char *newname; static void NewName(char *name) { if ( name[1]=='-' ) ++name; if ( strcmp(name,"-usage")==0 ) dousage(); else if ( strncmp(name,"-name=",6)==0 ) newname = strdup(name+6); else dousage(); } static void ClearNames(void) { newname = NULL; } /* There's probably only one fond in the file, but there could be more so be */ /* prepared... */ /* http://developer.apple.com/techpubs/mac/Text/Text-269.html */ static void CheckFondList(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list) { long start = ftell(f); int i; fseek(f,rlistpos,SEEK_SET); for ( i=0; i33 || header[63]!=0 || header[2+header[1]]!=0 ) return( false ); offset = 128+((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); return( IsResourceFork(f,offset)); } static int lastch=0, repeat = 0; static void outchr(FILE *binary, int ch) { int i; if ( repeat ) { if ( ch==0 ) { /* no repeat, output a literal 0x90 (the repeat flag) */ lastch=0x90; putc(lastch,binary); } else { for ( i=1; i>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); val = cnt = 0; } } if ( cnt!=0 ) { if ( cnt==1 ) outchr(binary,val<<2); else if ( cnt==2 ) { val<<=4; outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } else if ( cnt==3 ) { val<<=6; outchr(binary,(val>>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } } rewind(binary); ch = getc(binary); /* Name length */ /* skip name */ for ( i=0; i8 || strlen(dpt)>4 ) { char exten[8]; strncpy(exten,dpt,7); exten[4] = '\0'; /* it includes the dot */ if ( dpt-spt>6 ) dpt = spt+6; *dpt++ = '~'; *dpt++ = '1'; strcpy(dpt,exten); } return( IsResourceInFile(buffer)); } int main(int argc, char **argv) { int i, ret = 0; if ( argc==1 ) dousage(); for ( i=1; i #include #include #include typedef unsigned int uint32; typedef int int32; typedef unsigned short uint16; typedef short int16; typedef unsigned char uint8; typedef signed char int8; #define true 1 #define false 0 /* resource file format: Start of file: long Offset to start of resource data (always 0x100) long Offset to start of resource map long Length of resource data (map_offset-data_offset) long Length of resource map pad with 0s to 0x100 Resource data for each resource long length of this resource byte*n resource data end Resource map (repeat the initial 16 bytes for normal resource files, or 16 bytes of 0 for dfonts) long 0 short 0 short 0 short Offset from start of map to start of resource types (28?) short Offset from start of map to start of resource names Resource Types short Number of different types-1 for each type: long tag short number of resources of this type-1 short offset to resource list end Resource lists for each resource of the given type: short resource id short offset to name in resource name list (0xffff for none) byte flags byte*3 offset from start of resource data section to this resource's data long 0 end Resource names for each named resource byte name length byte*n name end */ struct resource_types { uint32 tag; struct resource *res; struct resource_types *next; uint32 pos, resloc; int cnt; }; struct resource { uint16 id, new_id; int flags; FILE *srcf; uint32 src_off; /* Length is in the first long at this offset, data follow */ char *name; /* Resource name */ struct resource *next; uint32 name_off; uint32 merged_off; uint32 nameptloc; }; static struct resource_types *global_types; static int do_fond_fixup = false; /* only set if there's a resource id conflict */ static int only_fonts = true; /* Copy every resource in first file, but only font resources in subsequent ones */ #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4)) #define true 1 #define false 0 static int getushort(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); if ( ch2==EOF ) return( EOF ); return( (ch1<<8)|ch2 ); } static long getlong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 ); } static void putshort(int val, FILE *f) { putc(val>>8,f); putc(val&0xff,f); } static void putlong(long val, FILE *f) { putc((val>>24)&0xff,f); putc((val>>16)&0xff,f); putc((val>>8)&0xff,f); putc(val&0xff,f); } /* This routine is called after all resources have been written */ static void DumpResourceMap(FILE *res,struct resource_types *rtypes) { uint32 rfork_base = 0; uint32 resource_base = rfork_base+0x100; uint32 rend, rtypesstart, mend, namestart; struct resource_types *cur; struct resource *rcur; int i,j; fseek(res,0,SEEK_END); rend = ftell(res); for ( i=0; i<16; ++i ) /* 16 bytes of zeroes for a dfont */ putc(0,res); putlong(0,res); /* Some mac specific thing I don't understand */ putshort(0,res); /* another */ putshort(0,res); /* another */ putshort(4+ftell(res)-rend,res); /* Offset to resource types */ putshort(0,res); /* Don't know where the names go yet */ rtypesstart = ftell(res); for ( i=0, cur=rtypes; cur!=NULL; cur = cur->next, ++i ); putshort(i-1,res); /* Count of different types */ for ( cur=rtypes; cur!=NULL; cur = cur->next ) { putlong(cur->tag,res); /* Resource type */ putshort(0,res); /* Number of resources of this type */ putshort(0,res); /* Offset to the resource list */ } /* Now the resource lists... */ for ( cur=rtypes; cur!=NULL; cur = cur->next ) { cur->pos = ftell(res); for ( rcur=cur->res; rcur!=NULL; rcur=rcur->next ) { putshort(rcur->new_id,res); rcur->nameptloc = ftell(res); putshort(0xffff,res); /* assume no name at first */ putc(rcur->flags,res); /* resource flags */ /* three byte resource offset */ putc( ((rcur->merged_off-resource_base)>>16)&0xff, res ); putc( ((rcur->merged_off-resource_base)>>8)&0xff, res ); putc( ((rcur->merged_off-resource_base)&0xff), res ); putlong(0,res); } } namestart = ftell(res); /* Now the names, if any */ for ( cur=rtypes; cur!=NULL; cur = cur->next ) { for ( rcur=cur->res; rcur!=NULL; rcur=rcur->next ) { if ( rcur->name!=NULL ) { rcur->name_off = ftell(res); putc(strlen(rcur->name),res); /* Length */ fwrite(rcur->name,1,strlen(rcur->name),res); } } } mend = ftell(res); /* Repeat the rtypes list now we know where they go */ fseek(res,rtypesstart+2,SEEK_SET); /* skip over the count */ for ( cur=rtypes; cur!=NULL; cur = cur->next ) { putlong(cur->tag,res); /* Resource type */ for ( j=0, rcur=cur->res; rcur!=NULL; rcur=rcur->next, ++j ); putshort(j-1,res); /* Number of resources of this type */ putshort(cur->pos-rtypesstart,res); } /* And go back and fixup any name pointers */ for ( cur=rtypes; cur!=NULL; cur = cur->next ) { for ( rcur=cur->res; rcur!=NULL; rcur=rcur->next ) { if ( rcur->name!=NULL ) { fseek(res,rcur->nameptloc,SEEK_SET); putshort(rcur->name_off-namestart,res); } } } fseek(res,rend,SEEK_SET); /* Fixup duplicate header (and offset to the name list) */ for ( i=0; i<16; ++i ) putc(0,res); putlong(0,res); /* Some mac specific thing I don't understand */ putshort(0,res); /* another */ putshort(0,res); /* another */ putshort(4+ftell(res)-rend,res); /* Offset to resource types */ putshort(namestart-rend,res); /* name section */ fseek(res,rfork_base,SEEK_SET); /* Fixup main resource header */ putlong(0x100,res); /* start of resource data */ putlong(rend-rfork_base,res); /* start of resource map */ putlong(rend-rfork_base-0x100,res); /* length of resource data */ putlong(mend-rend,res); /* length of map section */ } static void DumpResource(FILE *to,struct resource *rcur) { uint32 len; int ch; rcur->merged_off = ftell(to); fseek(rcur->srcf,rcur->src_off,SEEK_SET); len = getlong(rcur->srcf); if ( len==EOF ) { fprintf( stderr, "Bad resource length at offset %d\n", rcur->src_off ); exit(1); } putlong(len,to); while ( len>0 ) { ch = getc(rcur->srcf); putc(ch,to); --len; } } static int FindNewId(uint32 tag,FILE *origf,int id) { struct resource_types *cur; struct resource *res; for ( cur= global_types; cur!=NULL; cur=cur->next ) { if ( cur->tag==tag ) { for ( res=cur->res; res!=NULL; res=res->next ) { if ( res->id==id && res->srcf==origf ) return( res->new_id ); } return( id ); } } return( id ); } static void DumpFond(FILE *to,struct resource *rcur) { int i, assoc_cnt, size, style, id, newid; /* first dump the resource, then doctor it */ DumpResource(to,rcur); fseek(to,rcur->merged_off+4+2*26,SEEK_SET); assoc_cnt = getushort(to)+1; for ( i=0; isrcf,id); else newid = FindNewId(CHR('N','F','N','T'),rcur->srcf,id); if ( newid!=id ) { fseek(to,-2,SEEK_CUR); putshort(newid,to); fseek(to,0,SEEK_CUR); /* Have to do a seek to prepare for reading */ } } fseek(to,0,SEEK_END); } static void ResCopy(FILE *to) { /* Copy everything from the global resource set to the result file */ struct resource_types *cur; struct resource *rcur; int fixupfond; for ( cur=global_types; cur!=NULL; cur=cur->next ) { fixupfond = do_fond_fixup && cur->tag==CHR('F','O','N','D'); for ( rcur = cur->res; rcur!=NULL; rcur=rcur->next ) if ( fixupfond ) DumpFond(to,rcur); else DumpResource(to,rcur); } } static int ResIdUsed(int id,struct resource *list1, struct resource *list2) { while ( list1!=NULL ) { if ( id == list1->new_id ) return( true ); list1=list1->next; } while ( list2!=NULL ) { if ( id == list2->new_id ) return( true ); list2=list2->next; } return( false ); } static void MergeResLists(struct resource_types *into, struct resource_types *from) { struct resource *res, *rtest, *rnext, *p; for ( res = from->res; res!=NULL; res = rnext ) { rnext = res->next; while ( ResIdUsed(res->new_id,into->res,rnext)) res->new_id = (res->new_id+1)&0xffff; if ( res->new_id!=res->id ) { if ( into->tag==CHR('s','f','n','t') || into->tag==CHR('N','F','N','T')) do_fond_fixup = true; fprintf( stderr, "Warning: Renumbering resource '%c%c%c%c' %d -> %d\n", (into->tag>>24), ((into->tag>>16)&0xff), ((into->tag>>8)&0xff), (into->tag&0xff), res->id, res->new_id ); } for ( rtest=into->res, p=NULL; rtest!=NULL; p=rtest, rtest=rtest->next ) { if ( rtest->new_id>res->new_id ) break; } if ( p==NULL ) { res->next = into->res; into->res = res; } else { res->next = p->next; p->next = res; } } free(from); } static void MergeToGlobalResources(struct resource_types *head) { struct resource_types *test, *p, *hnext; if ( global_types==NULL ) { global_types = head; return; } while ( head!=NULL ) { hnext = head->next; if ( only_fonts && (head->tag!=CHR('s','f','n','t') && head->tag!=CHR('N','F','N','T') && head->tag!=CHR('F','O','N','D')) ) { /* Copy everything in the first file, but only font resources in */ /* subsequent ones */ head = hnext; continue; } for ( test=global_types; test!=NULL; test=test->next ) { if ( test->tag==head->tag ) { MergeResLists(test,head); break; } } if ( test==NULL ) { /* I don't know if they are supposed to be ordered, but why not */ for ( test=global_types, p=NULL; test!=NULL; p=test, test=test->next ) { if ( test->tag>head->tag ) break; } if ( p==NULL ) { head->next = global_types; global_types = head; } else { head->next = p->next; p->next = head; } } head = hnext; } } static int IsResourceFork(FILE *f, long offset) { /* If it is a good resource fork then the first 16 bytes are repeated */ /* at the location specified in bytes 4-7 */ /* Sigh. Unless it's a dfont */ /* We include an offset because if we are looking at a mac binary file */ /* the resource fork will actually start somewhere in the middle of the */ /* file, not at the beginning */ unsigned char buffer[16], buffer2[16]; long rdata_pos, map_pos, type_list, name_list; int i, cnt; int ch1, ch2; int namepos; struct resource_types *head=NULL, *last=NULL, *cur; fseek(f,offset,SEEK_SET); if ( fread(buffer,1,16,f)!=16 ) return( false ); rdata_pos = offset + ((buffer[0]<<24)|(buffer[1]<<16)|(buffer[2]<<8)|buffer[3]); map_pos = offset + ((buffer[4]<<24)|(buffer[5]<<16)|(buffer[6]<<8)|buffer[7]); fseek(f,map_pos,SEEK_SET); buffer2[15] = buffer[15]+1; /* make it be different */ if ( fread(buffer2,1,16,f)!=16 ) return( false ); /* Apple's data fork resources appear to have a bunch of zeroes here instead */ /* of a copy of the first 16 bytes */ for ( i=0; i<16; ++i ) if ( buffer2[i]!=0 ) break; if ( i!=16 ) for ( i=0; i<16; ++i ) if ( buffer[i]!=buffer2[i] ) return( false ); getlong(f); /* skip the handle to the next resource map */ getushort(f); /* skip the file resource number */ getushort(f); /* skip the attributes */ type_list = map_pos + getushort(f); name_list = map_pos + getushort(f); fseek(f,type_list,SEEK_SET); cnt = getushort(f)+1; for ( i=0; itag = getlong(f); cur->cnt = getushort(f)+1; cur->pos = type_list+getushort(f); if ( last==NULL ) head = cur; else last->next = cur; last = cur; } for ( cur = head; cur!=NULL; cur=cur->next ) { struct resource *rlast=NULL, *rcur; fseek(f,cur->pos,SEEK_SET); for ( i=0; icnt; ++i ) { rcur = calloc(1,sizeof(struct resource)); rcur->new_id = rcur->id = getushort(f); namepos = getushort(f); if ( namepos==0xffff ) rcur->name_off = 0; else rcur->name_off = name_list + namepos; rcur->flags = getc(f); ch1 = getc(f); ch2=getc(f); rcur->src_off = rdata_pos + ((ch1<<16)|(ch2<<8)|getc(f)); rcur->srcf = f; /* must be zero */ getlong(f); if ( rlast==NULL ) cur->res = rcur; else rlast->next = rcur; rlast = rcur; } } for ( cur = head; cur!=NULL; cur=cur->next ) { struct resource *rcur; for ( rcur=cur->res; rcur!=NULL; rcur=rcur->next ) { if ( rcur->name_off!=0 ) { fseek(f,rcur->name_off,SEEK_SET); ch1 = getc(f); if ( ch1!=EOF ) { rcur->name = malloc(ch1+1); fread(rcur->name,1,ch1,f); rcur->name[ch1] = '\0'; } } } } MergeToGlobalResources(head); return( true ); } static int HasResourceFork(char *filename) { /* If we're on a mac, we can try to see if we've got a real resource fork */ /* linux has an HFS+ driver (or whatever) too, so we might as well always */ /* do this check */ char *respath = malloc(strlen(filename)+strlen("/rsrc")+1); FILE *temp; int ret = false; strcpy(respath,filename); strcat(respath,"/rsrc"); temp = fopen(respath,"r"); free(respath); if ( temp!=NULL ) ret = IsResourceFork(temp,0); return( ret ); } static int IsResourceInBinary(FILE *f) { unsigned char header[128]; unsigned long offset; if ( fread(header,1,128,f)!=128 ) return( false ); if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 || header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 ) return( false ); offset = 128+((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); return( IsResourceFork(f,offset)); } static int lastch=0, repeat = 0; static void outchr(FILE *binary, int ch) { int i; if ( repeat ) { if ( ch==0 ) { /* no repeat, output a literal 0x90 (the repeat flag) */ lastch=0x90; putc(lastch,binary); } else { for ( i=1; i>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); val = cnt = 0; } } if ( cnt!=0 ) { if ( cnt==1 ) outchr(binary,val<<2); else if ( cnt==2 ) { val<<=4; outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } else if ( cnt==3 ) { val<<=6; outchr(binary,(val>>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } } rewind(binary); ch = getc(binary); /* Name length */ /* skip name */ for ( i=0; i8 || strlen(dpt)>4 ) { char exten[8]; strncpy(exten,dpt,7); exten[4] = '\0'; /* it includes the dot */ if ( dpt-spt>6 ) dpt = spt+6; *dpt++ = '~'; *dpt++ = '1'; strcpy(dpt,exten); } return( IsResourceInFile(buffer)); } static void CopyFile( FILE *to, FILE *from ) { int ch; rewind(from); while ( (ch=getc(from))!=EOF ) putc(ch,to); } static void DumpResourceMaps(char *filename) { FILE *restemp = tmpfile(), *real; int i; char *pt, *dot, *new; /* Initial resource header, we'll fix it up later, for now just 0x100 bytes*/ for ( i=0; i<0x100; ++i ) putc('\0',restemp); /* The dump out the resource data */ ResCopy(restemp); /* Then the resource map (which fixes the initial header too) */ DumpResourceMap(restemp,global_types); pt = strrchr(filename,'/'); if ( pt==NULL ) pt=filename; dot = strrchr(pt,'.'); if ( dot==NULL ) dot = pt+strlen(pt); new = malloc(strlen(pt)+strlen(".dfont")+2); strcpy(new,pt); strcpy(new+(dot-pt),".dfont"); real = fopen(new,"w"); if ( real==NULL ) { fprintf( stderr, "Can't open %s for output\n", new); exit(1); } CopyFile(real,restemp); fclose(restemp); fclose(real); } int main(int argc, char **argv) { int i; if ( argc<3 ) { fprintf(stderr, "Usage: %s base.dfont additional.dfont ...\n\t merges any additional resource files into base.\n", argv[0]); exit(1); } for ( i=1; i scalable */ /* style>>8 is the bit depth (0=>1, 1=>2, 2=>4, 3=>8) */ /* search order for ID is sfnt, NFNT, FONT */ int stylewidthcnt; struct stylewidths { short style; short *widthtab; /* 4.12 fixed number with the width specified as a fraction of an em */ } *stylewidths; int stylekerncnt; struct stylekerns { short style; int kernpairs; struct kerns { unsigned char ch1, ch2; short offset; /* 4.12 */ } *kerns; } *stylekerns; char *psnames[48]; char *family; struct fond *next; } FOND; typedef struct PSFONT { char *fontname, *familyname, *weight, *fullname, *notice, *version; double italicangle; double em; double fbb[4]; int as, ds, ch, xh; int isadobestd; int glyphcnt; struct bbglyph { char *glyphname; int top, bottom, left, right; int hadvance; int isref; } *glyphs; short encoding[256]; /* glyph ids */ void *temp; } PSFONT; extern int tolatin1; extern const char *macnames[]; extern const char *styles[]; extern int getushort(FILE *f); extern long getlong(FILE *f); extern int cleanfilename(char *filename); extern void SearchNFNTResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds); extern void ParsePfb(FILE *pfb,PSFONT *psfont); fondu-060102/psfont.h0100644000076500007650000001645010303427502012610 0ustar gwwgww/* Copyright (C) 2000-2004 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _PSFONT_H_ #define _PSFONT_H_ /* pfb section headers. There seem to be three and a half of them. the first is a the start of the file and is 6 bytes long "\200\001x\005\000\000", the second is right after the newline after eexec and is 6 bytes "\200\002I\224\000\000", the third is right before the zeros (after the encoded data) and is "\200\001\024\002\000\000" the last is at the end of file and is only two bytes "\200\003" I think that the \200 byte indicates a header, the next byte is 1 for ascii, 2 for binary and 3 for eof, then next 4 bytes are the length (not present for eof headers) with the first byte the least significant. */ struct charprocs { int cnt, next; char **keys; void **values; }; struct psdict { int cnt, next; char **keys; char **values; }; struct pschars { int cnt, next; char **keys; unsigned char **values; int *lens; int bias; /* for type2 strings */ }; struct fontinfo { char *familyname; char *fullname; char *notice; char *weight; char *version; double italicangle; unsigned int isfixedpitch:1; double underlineposition; double underlinethickness; int em, ascent, descent; /* Generated by Fontographer (and us) */ int fstype; /* 2=>no embedding, 4=>print, 8=>edit */ /* Multiple master */ char *blenddesignpositions; char *blenddesignmap; char *blendaxistypes; }; struct private { struct psdict *private; struct pschars *subrs; /* (optional, required if othersubrs is present) */ /* 0-2 part of Flex, 3 hint replacement, 4 and up for charstrings */ int leniv; /* (optional) must be 4 for old interpreters (number of rand chars at start of charstrings entries) */ #if 0 int bluefuzz; /* (optional) (expand bluezones by this much, def=1) */ double bluescale; /* (optional) if the current pointsize in pixels is less than this value then do overshoot hinting */ int blueshift; /* (optional) */ double bluevalues[14]; /* <=7 pairs of integers, first less than second, (may be empty) */ /* first pair is baseline overshoots, other pairs above baseline */ double expansionfactor; /* (optional) only for languagegroup==1 (CJK) */ double familyblues[14]; /* (optional) bluevalues for family, can override local entry at small pointsizes */ double familyotherblues[10];/* (optional) otherblues for family */ unsigned int forcebold:1; /* (optional) */ int languagegroup; /* (optional) (0=>latin, greek, cyril, etc.), (1=>CJK)*/ int leniv; /* (optional) must be 4 for old interpreters (number of rand chars at start of charstrings entries) */ char *minfeature; /* obsolete, required must be {16 16} */ char *nd; /* "noaccess def" (may also be named "|-") */ char *np; /* "noaccess put" (may also be named "|") */ double otherblues[10]; /* (optional) descender blue zones */ struct pschars *othersubrs; /* (optional) shouldn't contain user defined subs */ int password; /* obsolete, required must be 5839 */ char *rd; /* "{string currentfile exch readstring pop}" (may also be named "-|") */ unsigned int rndstemup:1; /* (optional) obsolete, false if languagegroud==1 */ double stdhw[1]; /* (optional) dominant horizontal stem width */ double stdvw[1]; /* (optional) dominant vert */ double stemsnaph[12]; /* (optional) common h stem widths (at most 12, includes stdhw, sorted by increasing size) */ double stemsnapv[12]; /* (optional) common v stem widths*/ struct pschars *subrs; /* (optional, required if othersubrs is present) */ /* 0-2 part of Flex, 3 hint replacement, 4 and up for charstrings */ int uniqueid; /* (optional) seems same as fontdict entry. why's it here too? what of XUID? */ /* CID entries */ int subrmapoffset; /* Offset to the start of this font's subr strings map */ int sdbytes; /* bytes in each pointer in the map */ int subrcnt; /* number of subroutines, number of pointers-1 in the map */ #endif }; typedef struct fontdict { int fonttype; double fontmatrix[6]; char *fontname; /* (optional) */ struct fontinfo *fontinfo; int languagelevel; /* (optional) */ int wmode; /* (optional) chooses between alternate metric sets */ /* non-type0 entries */ int isadobestd; char *encoding[256]; double fontbb[4]; int uniqueid; /* (optional) open range between 4,000,000 and 4,999,999 */ int xuid[20]; /* (optional) */ /* Type1 specific values */ int painttype; /* 0 (filled) 2 (stroked) */ double strokewidth; /* (optional) only if painttype==2 */ struct psdict *metrics; /* (optional) */ struct psdict *metrics2; /* (optional) */ struct pschars *chars; struct charprocs *charprocs; struct private *private; unsigned int wasbinary: 1; unsigned int wascff: 1; /* CID stuff */ int fdcnt; /* For the underlying dictionaries */ struct fontdict **fds; char *cidfontname; int cidfonttype; double cidversion; char *registry; char *ordering; int supplement; int mapoffset; int fdbytes; int gdbytes; int cidcnt; unsigned char **cidstrs; short *cidlens; short *cidfds; /* CFF stuff */ struct splinefont *sf; /* MM stuff */ char *blendfunc; char *weightvector; char *cdv; char *ndv; struct psdict *blendprivate; struct psdict *blendfontinfo; } FontDict; struct cidbytes { int fdbytes, gdbytes, cidcnt; int cidmapoffset; int fdcnt; struct fddata { int leniv; int subrmapoff, sdbytes, subrcnt; int flexmax; unsigned int iscjk:1; struct pschars *subrs; } *fds; int *fdind; int errors; }; struct fd2data { int defwid, nomwid; /* For Type2 charstrings */ struct pschars *subrs; FILE *private; /* Subroutines get stored in the private file immediately after the private dict */ int eodictmark, fillindictmark; int privatelen; }; extern char *AdobeStandardEncoding[256]; #endif fondu-060102/readnfnt.c0100644000076500007650000004411010303430002013052 0ustar gwwgww/* Copyright (C) 2001-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "macfonts.h" const char *macnames[] = { NULL, "Eth", "eth", "Lslash", "lslash", "Scaron", "scaron", "Yacute", "yacute", NULL, NULL, "Thorn", "thorn", NULL, "Zcaron", "zcaron", NULL, NULL, NULL, NULL, NULL, "onehalf", "onequarter", "onesuperior", "threequarters", "threesuperior", "twosuperior", "brokenbar", "minus", "multiply", NULL, NULL, "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", NULL, "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", NULL}; static unsigned char mac2iso[] = { 0, 208, 240, 0, 0, 0, 0, 221, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 0, 196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 251, 252, 0, 176, 162, 163, 167, 0, 182, 223, 174, 169, 0, 180, 168, 0, 198, 216, 0, 177, 0, 0, 165, 181, 0, 0, 0, 0, 0, 170, 186, 0, 230, 248, 191, 161, 172, 0, 0, 0, 0, 171, 187, 0, 32, 192, 195, 213, 0, 0, 0, 0, 0, 0, 0, 0, 247, 0, 255, 0, 0, 164, 0, 0, 0, 0, 0, 183, 0, 0, 0, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212, 0, 210, 218, 219, 217, 0, 0, 0, 175, 0, 0, 0, 184, 0, 0, 0 }; static unsigned char iso2mac[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 193, 162, 163, 219, 180, 0, 164, 172, 169, 187, 199, 194, 0, 168, 248, 161, 177, 0, 0, 171, 181, 166, 225, 252, 0, 188, 200, 0, 0, 0, 192, 203, 231, 229, 204, 128, 129, 174, 130, 233, 131, 230, 232, 237, 234, 235, 236, 1, 132, 241, 238, 239, 205, 133, 0, 175, 244, 242, 243, 134, 0, 0, 167, 136, 135, 137, 139, 138, 140, 190, 141, 143, 142, 144, 145, 147, 146, 148, 149, 2, 150, 152, 151, 153, 155, 154, 214, 191, 157, 156, 158, 159, 0, 0, 216 }; const char *styles[]= { "Bold", "Italic", "Underline", "Outline", "Shadow", "Condensed", "Extended", NULL }; struct MacFontRec { short fontType; short firstChar; short lastChar; short widthMax; short kernMax; /* bb learing */ short Descent; /* maximum negative distance below baseline*/ short fRectWidth; /* bounding box width */ short fRectHeight; /* bounding box height */ unsigned short *offsetWidths;/* offset to start of offset/width table */ /* 0xffff => undefined, else high byte is offset in locTable, */ /* low byte is width */ short ascent; short descent; short leading; short rowWords; /* shorts per row */ unsigned short *fontImage; /* rowWords*fRectHeight */ /* Images for all characters plus one extra for undefined */ unsigned short *locs; /* lastchar-firstchar+3 words */ /* Horizontal offset to start of n'th character. Note: applies */ /* to each row. Missing characters have same loc as following */ }; typedef struct rect { short left,width, height,bottom; } Rect; static void LoadNFNT(FILE *f,struct MacFontRec *font, long offset) { long here = ftell(f); long baseow; long ow; int i; offset += 4; /* skip over the length */ fseek(f,offset,SEEK_SET); memset(font,'\0',sizeof(struct MacFontRec)); font->fontType = getushort(f); font->firstChar = getushort(f); font->lastChar = getushort(f); font->widthMax = getushort(f); font->kernMax = (short) getushort(f); font->Descent = (short) getushort(f); font->fRectWidth = getushort(f); font->fRectHeight = getushort(f); baseow = ftell(f); ow = getushort(f); font->ascent = getushort(f); font->descent = getushort(f); if ( font->Descent>=0 ) { ow |= (font->Descent<<16); font->Descent = -font->descent; /* Possibly overkill, but should be safe */ } font->leading = getushort(f); font->rowWords = getushort(f); if ( font->rowWords!=0 ) { font->fontImage = NULL; if ( font->rowWords!=0 ) font->fontImage = calloc(font->rowWords*font->fRectHeight,sizeof(short)); font->locs = calloc(font->lastChar-font->firstChar+3,sizeof(short)); font->offsetWidths = calloc(font->lastChar-font->firstChar+3,sizeof(short)); for ( i=0; irowWords*font->fRectHeight; ++i ) font->fontImage[i] = getushort(f); for ( i=0; ilastChar-font->firstChar+3; ++i ) font->locs[i] = getushort(f); fseek(f,baseow+2*ow,SEEK_SET); for ( i=0; ilastChar-font->firstChar+3; ++i ) font->offsetWidths[i] = getushort(f); } fseek(f,here,SEEK_SET); } static int FontHasChar(struct MacFontRec *font, int ch ) { if ( chfirstChar || ch>font->lastChar || ch==0 || ch=='\t' || ch=='\r' ) return( false ); return ( font->offsetWidths[ch-font->firstChar]!=0xffff ); } static int GetFontCount(struct MacFontRec *font) { int cnt=0, i; for ( i=font->firstChar; i<=font->lastChar; ++i ) { if ( FontHasChar(font,i) ) ++cnt; } return( cnt ); } static int GetFontAvgWidth(struct MacFontRec *font) { int cnt=0, i, wid=0,ch; /* Only average those characters in the encoding */ for ( i=font->firstChar; i<=font->lastChar; ++i ) { if ( tolatin1 ) { if ( i<256 && mac2iso[i]!=0 ) ch = mac2iso[i]; else continue; } else ch = i; if ( FontHasChar(font,ch) ) { ++cnt; wid += (font->offsetWidths[ch-font->firstChar]&0xff); } } return( cnt>0?wid*10/cnt:0 ); } static int AnyBitsSet(unsigned short *pt, int bits, int bite ) { int i; for ( i=bits; i>4]&(1<<(15-(i&15))) ) return( true ); return( false ); } static int GetCharBBox(struct MacFontRec *font, int ch, Rect *bbox ) { unsigned short *widths = font->offsetWidths; unsigned short *locs = font->locs; unsigned short *rows = font->fontImage; int i; int ow; ch -= font->firstChar; ow = widths[ch]; bbox->left = (ow>>8)+font->kernMax; bbox->width = locs[ch+1]-locs[ch]; bbox->height = font->fRectHeight; bbox->bottom = -font->descent; for ( i=0; ifRectHeight; ++i ) if ( AnyBitsSet(rows+i*font->rowWords,locs[ch],locs[ch+1]) ) break; bbox->height -= i; for ( i=0; iheight; ++i ) if ( AnyBitsSet(rows+(font->fRectHeight-i-1)*font->rowWords,locs[ch],locs[ch+1]) ) break; bbox->bottom += i; bbox->height -= i; if ( bbox->height<0 ) bbox->height = 0; return( ow&0xff ); /* Width */ } static void WriteRow(FILE *bdf,unsigned short *test, int bits, int bite ) { int i; int cnt=0x8, nibble=0; char buffer[80], *pt=buffer; for ( i=bits; i>4]&(1<<(15-(i&15))) ) nibble |= cnt; if ( (cnt>>=1)==0 ) { if ( nibble>=10 ) *pt++ = 'A'+nibble-10; else *pt++ = '0'+nibble; cnt=0x8; nibble=0; } } if ( cnt!=0x8 ) { if ( nibble>=10 ) *pt++ = 'A'+nibble-10; else *pt++ = '0'+nibble; } if ( (pt-buffer)&1 ) *pt++ = '0'; /* pad out to a byte */ *pt++ = '\n'; *pt = '\0'; fputs(buffer,bdf); } static void WriteBitmap(FILE *bdf, struct MacFontRec *font, int ch, Rect *rct ) { unsigned short *locs = font->locs; unsigned short *rows = font->fontImage; int i; int bits, bite; int rowf, rowe; ch -= font->firstChar; bits = locs[ch]; bite = locs[ch+1]; rowf = font->fRectHeight - (rct->height+font->descent+rct->bottom); rowe = font->fRectHeight-(rct->bottom+font->descent); for ( i=rowf; irowWords,bits,bite); } static void WriteChar(FILE *bdf,struct MacFontRec *font,int enc, int index, int size, FOND *mine, struct assoc *ass) { Rect rct; int width; short *widths = NULL; if ( mine!=NULL && ass!=NULL ) { int i; /* I'm ignoring the glyph width table in the nfnt, and just looking at*/ /* the family table in the fond */ for ( i=0; istylewidthcnt; ++i ) if ( mine->stylewidths[i].style == ass->style ) { widths = mine->stylewidths[i].widthtab; break; } } if ( index==0 ) fprintf(bdf,"STARTCHAR .notdef\n"); else if ( index<256 && macnames[index]!=NULL ) fprintf(bdf,"STARTCHAR %s\n", macnames[index]); else fprintf(bdf,"STARTCHAR char%04x\n", index ); width = GetCharBBox(font,index,&rct); fprintf(bdf,"ENCODING %d\n", enc ); fprintf(bdf,"SWIDTH %ld 0\n", widths==NULL?width*1000L/size:((widths[index]*1000L+(1<<11))>>12) ); fprintf(bdf,"DWIDTH %d 0\n", width ); fprintf(bdf,"BBX %d %d %d %d\n", rct.width, rct.height, rct.left, rct.bottom ); fprintf(bdf,"BITMAP\n" ); WriteBitmap(bdf,font,index,&rct); fprintf(bdf,"ENDCHAR\n" ); } static void DumpNFNT2BDF(FILE *bdf,struct MacFontRec *font, char *resname, FOND *mine, struct assoc *ass) { int cnt, avg; int style = ass!=NULL ? ass->style : 0; int size = ass!=NULL ? ass->size : font->fRectHeight; int i; int dpi = 75; if ( size==17 || size==33 ) dpi = 100; cnt = GetFontCount(font); avg = GetFontAvgWidth(font); fprintf(bdf,"STARTFONT 2.1\n"); fprintf(bdf, "FONT -Fondu-%s-%s-%s-%s--%d-%d0-%d-%d-%s-%d-%s-1\n", (mine!=NULL && mine->fondname!=NULL)?mine->fondname:resname, (style&sf_bold)?"Bold":"Medium", (style&sf_italic)?"I":"R", (style&sf_condense)?"Condensed":(style&sf_extend)?"Extended":"Normal", size, (size*72+dpi/2)/dpi, dpi, dpi, (font->fontType&0xf000)==0xb000?"M":"P", avg, tolatin1?"ISO8859":"MacRoman" ); fprintf(bdf, "SIZE %d %d %d\n", (size*72+dpi/2)/dpi, dpi, dpi ); fprintf(bdf, "FONTBOUNDINGBOX %d %d %d %d\n", font->fRectWidth, font->fRectHeight, font->kernMax, -font->descent ); fprintf(bdf, "COMMENT Created by Fondu from a mac NFNT/FONT resource\n" ); fprintf(bdf, "STARTPROPERTIES 17\n" ); fprintf(bdf, "FOUNDRY \"Fondu\"\n" ); fprintf(bdf, "FAMILY_NAME \"%s\"\n", mine!=NULL && mine->fondname!=NULL?mine->fondname:resname ); fprintf(bdf, "WEIGHT_NAME \"%s\"\n", (style&sf_bold)?"Bold":"Medium" ); fprintf(bdf, "SLANT \"%s\"\n", (style&sf_italic)?"I":"R" ); fprintf(bdf, "SETWIDTH_NAME \"%s\"\n", (style&sf_condense)?"Condensed":(style&sf_extend)?"Extended":"Normal" ); fprintf(bdf, "ADD_STYLE_NAME \"\"\n" ); fprintf(bdf, "PIXEL_SIZE %d\n", size ); fprintf(bdf, "POINT_SIZE %d0\n", (size*72+dpi/2)/dpi ); fprintf(bdf, "RESOLUTION_X %d\n", dpi ); fprintf(bdf, "RESOLUTION_Y %d\n", dpi ); fprintf(bdf, "SPACING \"%s\"\n", (font->fontType&0xf000)==0xb000?"M":"P"); fprintf(bdf, "AVERAGE_WIDTH %d\n", avg ); fprintf(bdf, "CHARSET_REGISTRY \"%s\"\n",tolatin1?"ISO8859":"MacRoman" ); fprintf(bdf, "CHARSET_ENCODING \"1\"\n" ); fprintf(bdf, "FONT_ASCENT %d\n", font->ascent ); fprintf(bdf, "FONT_DESCENT %d\n", font->descent ); fprintf(bdf, "FACE_NAME \"" ); if ( *resname!='\0' ) { fprintf(bdf, "%s\"\n", resname ); } else if ( mine!=NULL && mine->fondname!=NULL ) { fprintf(bdf, "%s", mine->fondname ); if ( ass!=NULL ) { for ( i=0; styles[i]!=NULL; ++i ) if ( ass->style&(1<firstChar; i<=font->lastChar; ++i ) if ( (i>=256 || mac2iso[i]==0) && FontHasChar(font,i) ) WriteChar(bdf,font,-1,i,size,mine,ass); } else { for ( i=font->firstChar; i<=font->lastChar; ++i ) if ( FontHasChar(font,i) ) WriteChar(bdf,font,i,i,size,mine,ass); } fprintf(bdf, "ENDFONT\n" ); } void SearchNFNTResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds) { long here, start = ftell(f); long roff; int rname = -1; char resname[256], name[300]; int ch1, ch2; static int ucnt; int i,j; int res_id; FILE *bdf; FOND *mine; struct assoc *ass; struct MacFontRec font; fseek(f,rlistpos,SEEK_SET); for ( i=0; inext ) { int i; for ( i=0; iassoc_cnt; ++i ) if ( res_id==mine->assoc[i].id && mine->assoc[i].size!=0 ) { ass = &mine->assoc[i]; break; } if ( ass!=NULL ) break; } resname[0] = '\0'; if ( rname!=-1 ) { fseek(f,name_list+rname,SEEK_SET); ch1 = getc(f); fread(resname,1,ch1,f); resname[ch1] = '\0'; sprintf( name, "%s-%d.bdf", resname, ass!=NULL?ass->size:font.fRectHeight ); } else if ( ass!=NULL ) { if ( mine->fondname==NULL ) sprintf( name, "Untitled%d-%d.bdf", ++ucnt, ass->size ); else { strcpy( name, mine->fondname ); for ( j=0; styles[j]!=NULL; ++j ) if ( ass->style&(1<size ); } } else sprintf(name,"Untitled%d-%d.bdf", ++ucnt, font.fRectHeight ); fseek(f,here,SEEK_SET); if ( !cleanfilename(name)) /* Do Nothing */; else if ( (font.fontType&0xc)!=0 ) fprintf( stderr, "The bitmap font %s a depth greater than 1 and is ignored\n", name ); else { bdf = fopen( name,"w+" ); if ( bdf==NULL ) fprintf( stderr, "Can't open %s for output\n", name ); else DumpNFNT2BDF(bdf,&font,resname,mine,ass); } free( font.offsetWidths ); free( font.fontImage ); free( font.locs ); } fseek(f,start,SEEK_SET); } fondu-060102/res2data.c0100644000076500007650000000742410322556431013005 0ustar gwwgww/* Copyright (C) 2002-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #ifdef __Mac #include static int ToResourceFork(char *filename) { /* If we're on a mac, we can try to see if we've got a real resource fork */ #ifndef OldMacintosh char *buf, *pt, *respath; FILE *res, *temp; int cnt; respath = malloc(strlen(filename)+strlen("/rsrc")+1); strcpy(respath,filename); strcat(respath,"/rsrc"); res = fopen(respath,"r"); free(respath); buf = malloc(strlen(filename)+strlen(".res")+20); pt = strrchr(filename,'/'); if ( pt==NULL ) pt=filename-1; strcpy(buf,pt+1); strcat(buf,".res"); temp = fopen(buf,"w"); if ( temp==NULL ) { fprintf( stderr, "Failed to open %s for output\n", buf); return( -1 ); } buf = malloc(8192); while ( 1 ) { cnt = 8192; cnt = fread(buf,1,cnt,temp); if ( cnt>0 ) fwrite(buf,1,cnt,temp); if ( cnt<=0 ) break; } free(buf); fclose(res); fclose(temp); return( 1 ); #else FSRef ref; FSSpec spec; short res; int cnt, ret; FILE *temp; char *buf, *pt; if ( FSPathMakeRef( (unsigned char *) filename,&ref,NULL)!=noErr ) return( 0 ); if ( FSGetCatalogInfo(&ref,0,NULL,NULL,&spec,NULL)!=noErr ) return( 0 ); if ( FSpOpenRF(&spec,fsRdPerm,&res)!=noErr ) return( 0 ); buf = malloc(strlen(filename)+strlen(".res")+20); pt = strrchr(filename,'/'); if ( pt==NULL ) pt=filename-1; strcpy(buf,pt+1); strcat(buf,".res"); temp = fopen(buf,"w"); if ( temp==NULL ) { fprintf( stderr, "Failed to open %s for output\n", buf); return( -1 ); } buf = malloc(8192); while ( 1 ) { cnt = 8192; ret = FSRead(res,&cnt,buf); if ( cnt!=0 ) fwrite(buf,1,cnt,temp); if ( ret==eofErr ) break; if ( ret!=noErr ) break; } free(buf); FSClose(res); fclose(temp); return( 1 ); #endif } static void Usage(char *prog) { fprintf( stderr, " Usage: %s files\n Copies the resource forks of the specified files into data forks.\n", prog ); exit( 1 ); } int main(int argc, char **argv) { int i; if ( argc<=1 ) Usage(argv[0]); for ( i=1; i #include #include #include #include #if __Mac # include /* -I/Developer/Headers/FlatCarbon/ */ #endif /* A MacBinary file */ /* http://www.lazerware.com/formats/macbinary.html */ /* begins with a 128 byte header */ /* (which specifies lengths for data/resource forks) */ /* (and contains mac type/creator data) */ /* (and other stuff) */ /* (and finally a crc checksum) /* is followed by the data section (padded to a mult of 128 bytes) */ /* is followed by the resource section (padded to a mult of 128 bytes) */ /* Crc code taken from: */ /* http://www.ctan.org/tex-archive/tools/macutils/crc/ */ /* MacBinary files use the same CRC that binhex does (in the MacBinary header) */ extern unsigned long binhex_crc(unsigned char *buffer,int size); /* the resource fork may be opened (on Mac OS/X) by /rsrc */ /* tobin [-res rfilename] filename {[-res filename] rfilename} */ /* tobin filename -res rfilename */ /* tobin -res rfilename */ static void Usage(char *prog) { fprintf( stderr, "Usage: %s {[-res filename] [-create creat] [-type type] [filename]}\n" ); fprintf( stderr, " -res filename\tProvides the name of a file whose data fork is to\n" ); fprintf( stderr, "\t\t\tplaced in a resource fork\n" ); fprintf( stderr, " -create creat\tProvides a four character creator (if omitted on the\n" ); fprintf( stderr, "\t\t\tmac this will be read from the datafile.\n" ); fprintf( stderr, " -type type\tProvides a four character type (if omitted on the\n" ); fprintf( stderr, "\t\t\tmac this will be read from the datafile.\n" ); fprintf( stderr, "Takes a list of filenames and perhaps a list of resource forks\n" ); fprintf( stderr, "and puts the result into a list of macbinary files.\n" ); fprintf( stderr, "On the mac, if no resource fork file is specified and the datafork\n" ); fprintf( stderr, "file contains a resource fork, then it will be used as the resource\n" ); fprintf( stderr, "fork.\n" ); fprintf( stderr, "If no data filename is specified then the resource file will be\n" ); fprintf( stderr, "placed in the macbinary file without a data fork.\n" ); fprintf( stderr, "The output filename will be the name of the data fork file with .bin\n" ); fprintf( stderr, "appended, or if there is no data fork file, then the resource fork file\n" ); fprintf( stderr, "with .bin appended.\n" ); exit( 1 ); } static FILE *ResForkOfDataFile(char *dataname) { #ifndef OldMacintosh /* OS/X and linux with appropriate drivers */ char *respath = malloc(strlen(dataname)+strlen("/rsrc")+1); FILE *temp; strcpy(respath,dataname); strcat(respath,"/rsrc"); temp = fopen(respath,"r"); free(respath); return( temp ); #elif __Mac /* At 10.4 Mac starts warning that FSSpec is depreciated */ /* copy the resource fork of dataname (if any) into the data fork of a temp file */ FSRef ref; FSSpec spec; short res, err; long cnt; FILE *temp; unsigned char *buf; if ( dataname==NULL ) return( NULL ); if ( FSPathMakeRef( (unsigned char *) dataname,&ref,NULL)!=noErr ) return( NULL ); if ( FSGetCatalogInfo(&ref,0,NULL,NULL,&spec,NULL)!=noErr ) return( NULL ); if ( FSpOpenRF(&spec,fsRdPerm,&res)!=noErr ) return( NULL ); temp = tmpfile(); buf = malloc(8192); while ( 1 ) { cnt = 8192; err = FSRead(res,&cnt,buf); if ( cnt>0 ) fwrite(buf,1,cnt,temp); if ( err==eofErr ) break; if ( err!=noErr ) break; } free(buf); FSClose(res); rewind(temp); return( temp ); #else return( NULL ); #endif } static void FindTypeCreater(char *dataname,char **create,char **type) { #if __Mac && !defined(OldMacintosh) static char cbuf[5], tbuf[5]; FSRef ref; FSCatalogInfo info; if ( FSPathMakeRef( (unsigned char *) dataname,&ref,NULL)!=noErr ) return; if ( FSGetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info,NULL,NULL,NULL)!=noErr ) return; if ( *type==NULL ) { tbuf[0] = ((FInfo *) (info.finderInfo))->fdType>>24; tbuf[1] = ((FInfo *) (info.finderInfo))->fdType>>16; tbuf[2] = ((FInfo *) (info.finderInfo))->fdType>>8; tbuf[3] = ((FInfo *) (info.finderInfo))->fdType; tbuf[4] = '\0'; *type = tbuf; } if ( *create==NULL ) { cbuf[0] = ((FInfo *) (info.finderInfo))->fdCreator>>24; cbuf[1] = ((FInfo *) (info.finderInfo))->fdCreator>>16; cbuf[2] = ((FInfo *) (info.finderInfo))->fdCreator>>8; cbuf[3] = ((FInfo *) (info.finderInfo))->fdCreator; cbuf[4] = '\0'; *create = cbuf; } #elif defined(OldMacintosh) static char cbuf[5], tbuf[5]; FSRef ref; FSSpec spec; FInfo info; if ( dataname==NULL ) return; if ( FSPathMakeRef( (unsigned char *) dataname,&ref,NULL)!=noErr ) return; if ( FSGetCatalogInfo(&ref,0,NULL,NULL,&spec,NULL)!=noErr ) return; if ( FSpGetFInfo(&spec,&info)!=noErr ) return; if ( *type==NULL ) { tbuf[0] = info.fdType>>24; tbuf[1] = info.fdType>>16; tbuf[2] = info.fdType>>8; tbuf[3] = info.fdType; tbuf[4] = '\0'; *type = tbuf; } if ( *create==NULL ) { cbuf[0] = info.fdCreator>>24; cbuf[1] = info.fdCreator>>16; cbuf[2] = info.fdCreator>>8; cbuf[3] = info.fdCreator; cbuf[4] = '\0'; *create = cbuf; } #else static char tbuf[5]; int len = strlen(dataname); if ( *type==NULL ) { if (( len>4 && strcmp(dataname+len-4,".txt")==0 ) || ( len>4 && strcmp(dataname+len-4,".TXT")==0 ) || ( len>5 && strcmp(dataname+len-5,".text")==0 ) || ( len>5 && strcmp(dataname+len-5,".TEXT")==0 )) { strcpy(tbuf,"TEXT"); *type = tbuf; } } #endif } static void Dump(char *dataname, char *resname, char *create, char *type) { FILE *datafile=NULL, *resfile=NULL, *outfile; char *outname; unsigned char header[128], *hpt; char *pt, *ept; time_t now; unsigned long dlen, rlen; int i,crc, ch; if ( dataname==NULL && resname==NULL ) return; if ( dataname!=NULL ) { datafile = fopen(dataname,"r"); if ( datafile==NULL ) { fprintf(stderr,"Can't open %s for reading\n", dataname ); exit(1); } FindTypeCreater(dataname,&create,&type); } if ( resname!=NULL ) { resfile = fopen(resname,"r"); if ( resfile==NULL ) { fprintf(stderr,"Can't open %s for reading\n", resname ); exit(1); } } else resfile = ResForkOfDataFile(dataname); if ( dataname!=NULL ) { outname = malloc(strlen(dataname)+30); strcpy(outname,dataname); strcat(outname,".bin"); } else { outname = malloc(strlen(resname)+30); strcpy(outname,resname); strcat(outname,".bin"); } outfile = fopen(outname,"w"); if ( outfile==NULL ) { fprintf( stderr, "Cannot open %s for writing\n", outname); free(outname); if ( datafile ) fclose(datafile); if ( resfile ) fclose(resfile); } memset(header,'\0',sizeof(header)); hpt = header; *hpt++ = '\0'; /* version number */ /* Mac Filename */ pt = dataname?dataname:resname; ept = strrchr(pt,'/'); if ( ept!=NULL ) pt = ept+1; ept = pt+strlen(pt); if ( ept-pt>63 ) ept=pt+63; *hpt++ = ept-pt; while ( pt>24; *hpt++ = dlen>>16; *hpt++ = dlen>>8; *hpt++ = dlen; /* Resource fork length */ *hpt++ = rlen>>24; *hpt++ = rlen>>16; *hpt++ = rlen>>8; *hpt++ = rlen; /* Creation time, (seconds from 1/1/1904) */ time(&now); /* convert from 1970 based time to 1904 based time */ now += (1970-1904)*365L*24*60*60; for ( i=1904; i<1970; i+=4 ) now += 24*60*60; /* Ignore any leap seconds */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; /* Modification time, (seconds from 1/1/1904) */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; *hpt++ = '\0'; *hpt++ = '\0'; /* Get Info comment length */ *hpt++ = 0; /* More finder flags */ /* MacBinary 3 */ memcpy(header+102,"mBIN",4); header[106] = 0; /* Script. I assume 0 is latin */ header[107] = 0; /* extended finder flags */ /* End of MacBinary 3 */ header[122] = 130; /* MacBinary version 3, written in (129 is MB2) */ header[123] = 129; /* MacBinary Version 2, needed to read */ crc = binhex_crc(header,124); header[124] = crc>>8; header[125] = crc; fwrite(header,1,sizeof(header),outfile); if ( datafile ) { while ( (ch=getc(datafile))!=EOF ) putc(ch,outfile); while ( (dlen&127)!=0 ) { putc('\0',outfile); ++dlen; } fclose(datafile); } if ( resfile ) { while ( (ch=getc(resfile))!=EOF ) putc(ch,outfile); while ( (rlen&127)!=0 ) { putc('\0',outfile); ++rlen; } fclose(resfile); } } int main( int argc, char **argv) { int i; char *datafork=NULL, *resfork=NULL; char *create=NULL, *type=NULL; /* these are sticky */ for ( i=1; i=argc ) { fprintf( stderr, "%s must be followed by a filename\n", argv[i] ); exit( 1 ); } if ( strlen(argv[i+1])!=4 ) { fprintf( stderr, "the argument of %s must be four characters, but %s is not.\n", argv[i], argv[i+1] ); exit( 0 ); } else create = argv[++i]; } else if ( strcmp(pt,"type")==0 || strcmp(pt,"t")==0 ) { if ( i+1>=argc ) { fprintf( stderr, "%s must be followed by a filename\n", argv[i] ); exit( 1 ); } if ( strlen(argv[i+1])!=4 ) { fprintf( stderr, "the argument of %s must be four characters, but %s is not.\n", argv[i], argv[i+1] ); exit( 0 ); } else type = argv[++i]; } else if ( strcmp(pt,"res")==0 || strcmp(pt,"rsrc")==0 || strcmp(pt,"resource")==0 || strcmp(pt,"r")==0 ) { if ( i+1>=argc ) { fprintf( stderr, "%s must be followed by a filename\n", argv[i] ); exit( 1 ); } if ( resfork!=NULL ) { Dump(datafork,resfork,create,type); datafork = NULL; resfork = argv[++i]; } else if ( datafork!=NULL ) { Dump(datafork,argv[++i],create,type); datafork = NULL; } else resfork = argv[++i]; } else { fprintf( stderr, "Unrecognized argument %s\n", argv[i]); Usage(argv[0]); } } else { if ( datafork!=NULL ) { Dump(datafork,resfork,create,type); datafork = argv[i]; resfork = NULL; } else if ( resfork!=NULL ) { Dump(argv[i],resfork,create,type); resfork = NULL; } else datafork = argv[i]; } } if ( datafork!=NULL || resfork!=NULL ) Dump(datafork,resfork,create,type); return( 0 ); } fondu-060102/showfond.10100644000076500007650000000107010303427515013033 0ustar gwwgww.TH SHOWFOND 1 "23 October 2002" .SH NAME showfond \- display information about Macintosh font resources .SH SYNOPSIS .B showfond .BR macfile ... .SH DESCRIPTION The program .B showfond dumps information about Macintosh font resources (FOND, NFNT, sfnt) found in the file(s) specified on the command line. .SH AUTHOR George Williams (gww@silcom.com). .LP Manual page by Ziying Sherwin (sherwin@nlm.nih.gov) and R.P.C Rodgers (rodgers@nlm.nih.gov), Lister Hill National Center for Biomedical Communications, U.S. National Library of Medicine. .\" end of manual page fondu-060102/showfond.c0100644000076500007650000006425010303430002013107 0ustar gwwgww/* Copyright (C) 2001-2004 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "macfonts.h" #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4)) #define true 1 #define false 0 int getushort(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); if ( ch2==EOF ) return( EOF ); return( (ch1<<8)|ch2 ); } long getlong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 ); } /* There's probably only one fond in the file, but there could be more so be */ /* prepared... */ /* I want the fond: */ /* to get the fractional widths for the SWIDTH entry on bdf */ /* to get the font name */ /* to get the font association tables */ /* to get the style flags */ /* http://developer.apple.com/techpubs/mac/Text/Text-269.html */ static FOND *BuildFondList(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list) { long here, start = ftell(f); long offset, end; int rname = -1; char name[300]; int ch1, ch2; int i, j, k, l, ch, rlen, cnt; FOND *head=NULL, *cur; long widoff, kernoff, styleoff, bboff, offsetstart, glyphenc; fseek(f,rlistpos,SEEK_SET); for ( i=0; ifondname = strdup(name); printf( "\nFOND %s\n", name ); } else printf( "\nFOND nameless\n" ); offset += 4; fseek(f,offset-4,SEEK_SET); printf( "Resource len=%d\n", rlen = getlong(f)); printf( "flags = %x\n", getushort(f)); /* 1 => mbz */ /* 2 => has a glyph width table */ /* 1<<12 => ignore global FractEnable */ /* 1<<13 => more on the above */ /* 1<<14 => don't use fractional width table */ /* 1<<15 => fixed width */ printf( "famid = %d\n", getushort(f)); cur->first = getushort(f); cur->last = getushort(f); printf( "first=%d, last=%d\n", cur->first, cur->last ); /* on a 1 point font... */ printf( "ascent = %g\n", getushort(f)/(double) (1<<12)); printf( "descent = %g\n", (short) getushort(f)/(double) (1<<12)); printf( "leading = %g\n", getushort(f)/(double) (1<<12)); printf( "widmax = %g\n", getushort(f)/(double) (1<<12) ); if ( (widoff = getlong(f))!=0 ) widoff += offset; if ( (kernoff = getlong(f))!=0 ) kernoff += offset; if ( (styleoff = getlong(f))!=0 ) styleoff += offset; printf( "width table offset = %d\n", widoff==0?0:widoff-offset); printf( "kern table offset = %d\n", kernoff==0?0:kernoff-offset); printf( "style table offset = %d\n", styleoff==0?0:styleoff-offset); printf( "extra width values:\n" ); printf( " plain: %d\n", getushort(f)); printf( " bold: %d\n", getushort(f)); printf( " italic: %d\n", getushort(f)); printf( " underline: %d\n", getushort(f)); printf( " outline: %d\n", getushort(f)); printf( " shadow: %d\n", getushort(f)); printf( " condensed: %d\n", getushort(f)); printf( " extended: %d\n", getushort(f)); printf( " not used: %d\n", getushort(f)); /* internal & undefined, for international scripts = */ getlong(f); printf( "version=%d\n", getushort(f)); /* not the font version, but the format of the FOND */ cur->assoc_cnt = getushort(f)+1; printf( "Association cnt=%d\n", cur->assoc_cnt ); cur->assoc = calloc(cur->assoc_cnt,sizeof(struct assoc)); for ( j=0; jassoc_cnt; ++j ) { cur->assoc[j].size = getushort(f); cur->assoc[j].style = getushort(f); cur->assoc[j].id = getushort(f); printf( " size=%d style=%x id=%d\n", cur->assoc[j].size, cur->assoc[j].style, cur->assoc[j].id ); } end = offset+rlen; offsetstart = ftell(f); bboff = 0; if ( widoff!=0 || kernoff!=0 || styleoff!=0 ) { /* if any of these three tables exists there will be an offset table */ int test; printf( "Offset table cnt=%d\n", cnt=getushort(f)+1 ); for ( j=0; jstylewidthcnt = cnt; cur->stylewidths = calloc(cnt,sizeof(struct stylewidths)); for ( j=0; jstylewidths[j].style = getushort(f); cur->stylewidths[j].widthtab = malloc((cur->last-cur->first+3)*sizeof(short)); printf( " Style=%x\n", cur->stylewidths[j].style); for ( k=cur->first; k<=cur->last+2; ++k ) cur->stylewidths[j].widthtab[k] = getushort(f); } if ( cnt>0 ) { printf( "Widths for style %x%s\n", cur->stylewidths[0].style, (cnt>1?" (I'm not printing out the others)":"") ); for ( k=cur->first; k<=cur->last; ++k ) printf( "Width %d (%c): %g\n", k, k>=32&&k<127?k:k>=160?k:' ', cur->stylewidths[0].widthtab[k]/(double)(1<<12)); } } if ( kernoff!=0 ) { fseek(f,kernoff,SEEK_SET); printf( "Style kern entries: %d\n", cnt = getushort(f)+1); cur->stylekerncnt = cnt; cur->stylekerns = calloc(cnt,sizeof(struct stylekerns)); for ( j=0; jstylekerns[j].style = getushort(f); cur->stylekerns[j].kernpairs = getushort(f); cur->stylekerns[j].kerns = malloc(cur->stylekerns[j].kernpairs*sizeof(struct kerns)); printf( " Style=%x kernpairs=%d\n", cur->stylekerns[j].style,cur->stylekerns[j].kernpairs); for ( k=0; kstylekerns[j].kernpairs; ++k ) { cur->stylekerns[j].kerns[k].ch1 = getc(f); cur->stylekerns[j].kerns[k].ch2 = getc(f); cur->stylekerns[j].kerns[k].offset = getushort(f); } } } if ( styleoff!=0 ) { int class; fseek(f,styleoff,SEEK_SET); printf( "PS Font Class Flags: %x\n", class = getushort(f)); /* How to create a bold (italic, condensed) font when we don't have one */ if ( class&1 ) printf( " 0x1 Font name needs coordinating\n" ); if ( class&2 ) printf( " 0x2 Needs MacVector reencoding\n" ); if ( class&4 ) printf( " 0x4 Can be outlined with PaintType==2\n" ); if ( class&8 ) printf( " 0x8 Do not embolded by smear & white out\n" ); if ( class&0x10 ) printf( " 0x10 Do not embolded by smearing\n" ); if ( class&0x20 ) printf( " 0x20 Embolden by increasing size\n" ); if ( class&0x40 ) printf( " 0x40 Do not oblique font to italicize\n" ); if ( class&0x80 ) printf( " 0x80 No auto-condense\n" ); if ( class&0x100 ) printf( " 0x100 No auto-expand\n" ); if ( class&0x200 ) printf( " 0x200 Needs some other encoding scheme\n" ); printf( " Glyph encoding offset: %d\n", glyphenc = getlong(f)); /* offset from start of table */ /* reserved = */ getlong(f); /* 48 (byte) indeces into the name table */ printf( "Plain index is: %d\n", getc(f)); printf( "Bold index is: %d\n", getc(f)); printf( "Italic index is: %d\n", getc(f)); for ( j=3; j<48; ++j ) getc(f); printf( " String count: %d\n", cnt = getushort(f)); /* basename length = */ k = getc(f); printf( " BaseFontName: \"" ); for ( j=0; j undefined, else high byte is offset in locTable, */ /* low byte is width */ short ascent; short descent; short leading; short rowWords; /* shorts per row */ unsigned short *fontImage; /* rowWords*fRectHeight */ /* Images for all characters plus one extra for undefined */ unsigned short *locs; /* lastchar-firstchar+3 words */ /* Horizontal offset to start of n'th character. Note: applies */ /* to each row. Missing characters have same loc as following */ }; static void LoadNFNT(FILE *f,struct MacFontRec *font, long offset) { long here = ftell(f); long baseow; long ow; int i; fseek(f,offset,SEEK_SET); printf( "NFNT length = %d\n", getlong(f)); memset(font,'\0',sizeof(struct MacFontRec)); font->fontType = getushort(f); font->firstChar = getushort(f); font->lastChar = getushort(f); font->widthMax = getushort(f); font->kernMax = (short) getushort(f); font->Descent = (short) getushort(f); font->fRectWidth = getushort(f); font->fRectHeight = getushort(f); baseow = ftell(f); ow = getushort(f); font->ascent = getushort(f); font->descent = getushort(f); if ( font->Descent>=0 ) { ow |= (font->Descent<<16); font->Descent = -font->descent; /* Possibly overkill, but should be safe */ } font->leading = getushort(f); font->rowWords = getushort(f); font->fontImage = calloc(font->rowWords*font->fRectHeight,sizeof(short)); font->locs = calloc(font->lastChar-font->firstChar+3,sizeof(short)); font->offsetWidths = calloc(font->lastChar-font->firstChar+3,sizeof(short)); for ( i=0; irowWords*font->fRectHeight; ++i ) font->fontImage[i] = getushort(f); for ( i=0; ilastChar-font->firstChar+3; ++i ) font->locs[i] = getushort(f); fseek(f,baseow+2*ow,SEEK_SET); for ( i=0; ilastChar-font->firstChar+3; ++i ) font->offsetWidths[i] = getushort(f); fseek(f,here,SEEK_SET); } void SearchNFNTResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds) { long here, start = ftell(f); long roff; int rname = -1; char resname[256], name[300]; int ch1, ch2; int i; int res_id; FOND *mine; struct assoc *ass; struct MacFontRec font; fseek(f,rlistpos,SEEK_SET); for ( i=0; inext ) { for ( i=0; iassoc_cnt; ++i ) if ( res_id==mine->assoc[i].id ) { ass = &mine->assoc[i]; break; } if ( ass!=NULL ) break; } resname[0] = '\0'; if ( rname!=-1 ) { fseek(f,name_list+rname,SEEK_SET); ch1 = getc(f); fread(resname,1,ch1,f); resname[ch1] = '\0'; sprintf( name, "%s-%d.bdf", resname, ass!=NULL?ass->size:font.fRectHeight ); fseek(f,here,SEEK_SET); } printf( "NFNT %d", res_id ); if ( resname[0]!='\0' ) printf( " %s", resname ); if ( ass!=NULL ) printf( "in %s size=%d\n", mine->fondname, ass->size ); else printf( "\n" ); printf( " type=%x first=%x, last=%x widMax=%d kMax=%d, ndescent=%d\n rWidth=%d rHeight=%d rWords=%d\n", (unsigned short) font.fontType, font.firstChar, font.lastChar, font.widthMax, font.kernMax, font.Descent, font.fRectWidth, font.fRectHeight, font.rowWords ); } fseek(f,start,SEEK_SET); } static void SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds) { long here = ftell(f); int rname = -1, tmp; int ch1, ch2; int i; /* I don't pretend to understand the rational behind the format of a */ /* postscript font. It appears to be split up into chunks where the */ /* maximum chunk size is 0x800 */ fseek(f,rlistpos,SEEK_SET); for ( i=0; ifullval ) { fullval = val; fullstr = off; fulllen = len; if ( val==2 || val==3 ) break; } else if ( name==1 && val>famval ) { famval = val; famstr = off; famlen = len; } } if ( fullval==0 ) { if ( famval==0 ) return( false ); fullstr = famstr; fulllen = famlen; } fseek(ttf,stringoffset+fullstr,SEEK_SET); pt = buffer; if ( val==3 ) { for ( i=0; i'!' && ch!='*' && ch!='?' && ch!='/' && ch!='\\' && ch<0x7f ) *pt++ = ch; } } else { for ( i=0; i'!' && ch!='*' && ch!='?' && ch!='/' && ch!='\\' && ch<0x7f ) *pt++ = ch; } } *pt = '\0'; /* strcpy(pt,isotf?".otf":".ttf"); */ return( true ); } static void SearchTtfResources(FILE *f,long rlistpos,int subcnt,long rdata_pos, long name_list, FOND *fonds) { long start = ftell(f), here; long roff; int rname = -1; int ch1, ch2; int i; char buffer[200]; fseek(f,rlistpos,SEEK_SET); for ( i=0; i>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff ); subcnt = getushort(f)+1; rpos = type_list+getushort(f); if ( tag==CHR('P','O','S','T')) /* No FOND */ SearchPostscriptResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('F','O','N','T')) /* No FOND */ ; else if ( tag==CHR('N','F','N','T')) /* Has FOND */ SearchNFNTResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('s','f','n','t')) /* Has FOND */ SearchTtfResources(f,rpos,subcnt,rdata_pos,name_list,fondlist); else if ( tag==CHR('F','O','N','D')) ; } return( true ); } static int HasResourceFork(char *filename) { /* If we're on a mac, we can try to see if we've got a real resource fork */ /* linux has an HFS+ driver (or whatever) too, so we might as well always */ /* do this check */ char *respath = malloc(strlen(filename)+strlen("/rsrc")+1); FILE *temp; int ret = false; strcpy(respath,filename); strcat(respath,"/rsrc"); temp = fopen(respath,"r"); free(respath); if ( temp!=NULL ) { ret = IsResourceFork(temp,0); fclose(temp); } return( ret ); } static int IsResourceInBinary(FILE *f) { unsigned char header[128]; unsigned long offset; if ( fread(header,1,128,f)!=128 ) return( false ); if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 || header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 ) return( false ); offset = 128+((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]); return( IsResourceFork(f,offset)); } static int lastch=0, repeat = 0; static void outchr(FILE *binary, int ch) { int i; if ( repeat ) { if ( ch==0 ) { /* no repeat, output a literal 0x90 (the repeat flag) */ lastch=0x90; putc(lastch,binary); } else { for ( i=1; i>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); val = cnt = 0; } } if ( cnt!=0 ) { if ( cnt==1 ) outchr(binary,val<<2); else if ( cnt==2 ) { val<<=4; outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } else if ( cnt==3 ) { val<<=6; outchr(binary,(val>>16)&0xff); outchr(binary,(val>>8)&0xff); outchr(binary,val&0xff); } } rewind(binary); ch = getc(binary); /* Name length */ /* skip name */ for ( i=0; i8 || strlen(dpt)>4 ) { char exten[8]; strncpy(exten,dpt,7); exten[4] = '\0'; /* it includes the dot */ if ( dpt-spt>6 ) dpt = spt+6; *dpt++ = '~'; *dpt++ = '1'; strcpy(dpt,exten); } return( IsResourceInFile(buffer)); } int main(int argc, char **argv) { int i, ret = 0; for ( i=1; i #include #include #include #include #include #include "ufond.h" /* Process bdf files to turn them into NFNT resources */ struct bdffont { char **header; char ***chars; int charmax; char *fontname; int size; Face *face; }; int BDFGetNames(Face *face) { /* Get the font and family names by reading the fontfile */ FILE *bdf = fopen( face->filename, "r" ); char buffer[512]; char *pt; if ( bdf==NULL ) { fprintf( stderr, "Can't open %s for reading\n", face->filename ); return(false); } if ( fgets(buffer,sizeof(buffer),bdf)==NULL || strncmp(buffer,"STARTFONT ",10)!=0 ) { fprintf( stderr, "Hmm, %s doesn't look like a bdf font", face->filename ); fclose(bdf); return( false ); } buffer[0]='\0'; while ( fgets(buffer,sizeof(buffer),bdf)!=NULL ) { if ( strncmp(buffer,"CHARS ",6)==0 ) /* No more meta info */ break; if ( strncmp(buffer,"FAMILY_NAME \"",13)==0 ) { pt = strchr(buffer+13,'"'); if ( pt!=NULL ) { *pt = '\0'; face->family = strdup(buffer+13); } } else if ( strncmp(buffer,"PIXEL_SIZE ",11)==0 ) { face->size = strtol(buffer+11,NULL,10); /* It is tempting to use the bounding box value rather than the size */ /* that way we don't have to do any clipping, but it gives the wrong */ /* result. */ } else if ( strncmp(buffer,"FONTBOUNDINGBOX ",16)==0 ) { int w,h,lb,ds; if ( sscanf(buffer, "FONTBOUNDINGBOX %d %d %d %d", &w, &h, &lb, &ds)==4 ) { face->xmin = lb; face->ymin = ds; face->xmax = lb+w; face->ymax = ds+h; } } else if ( strncmp(buffer,"FONT_ASCENT ",12)==0 ) { face->ascent = strtol(buffer+12,NULL,10); } else if ( strncmp(buffer,"FONT_DESCENT ",13)==0 ) { face->descent = strtol(buffer+13,NULL,10); } else if ( strncmp(buffer,"SLANT \"",7)==0 ) { if ( buffer[7]=='I' || buffer[7]=='O' ) face->style |= sf_italic; } else if ( strncmp(buffer,"WEIGHT_NAME \"",13)==0 ) { if ( strstr(buffer+13,"Bold")!=NULL || strstr(buffer+13,"BOLD")!=NULL || strstr(buffer+13,"Gras")!=NULL || strstr(buffer+13,"Fett")!=NULL || strstr(buffer+13,"Black")!=NULL || strstr(buffer+13,"Heavy")!=NULL ) face->style |= sf_bold; } else if ( strncmp(buffer,"SETWIDTH_NAME \"",15)==0 ) { if ( strstr(buffer+15,"Condense")!=NULL ) face->style |= sf_condense; else if ( strstr(buffer+15,"Extend")!=NULL || strstr(buffer+15,"Expand")!=NULL ) face->style |= sf_extend; } else if ( strncmp(buffer,"SPACING \"",9)==0 ) { if ( buffer[9]=='M' ) face->fixed = true; } } fclose(bdf); if ( face->size==0 ) face->size = face->ascent+face->descent; if ( face->family==NULL || face->size==0 ) { fprintf( stderr, "Hmm, %s does not contain all the needed meta data\n", face->filename ); return( false ); } if ( face->ascent==0 ) { if ( face->descent!=0 ) face->ascent = face->size-face->descent; else face->ascent = (8*face->size+5)/10; } if ( face->descent == 0 ) face->descent = face->size-face->ascent; return( true ); } static void FreeBdfFont(struct bdffont *font) { char **l; int i; if ( font!=NULL ) { for ( i=0; icharmax; ++i ) if ( font->chars[i]!=NULL ) { l = font->chars[i]; while ( *l ) free( *l++ ); free(font->chars[i]); } free(font->chars); l = font->header; while ( *l ) free( *l++ ); free( font->header ); if ( font->fontname ) free( font->fontname ); free( font ); } } #define MAX_WIDTH 200 static char **SlurpChar(FILE *bdffile,char *buffer, int size, char *terminator, int *val) { static char **list=NULL; static int tot=0; int i=0, j, enc= -1; char **ret; for (;;) { if ( i>=tot ) { if ( list==NULL ) list = malloc((tot=60)*sizeof(char *)); else list = realloc(list,(tot*=2)*sizeof(char *)); for ( j=i; jfilename,"r"); struct bdffont *bdffont; char buffer[MAX_WIDTH+1]; char **chr; int i, enc, last_enc= -1; if ( bdffile==NULL ) { fprintf( stderr, "Can't open %s\n", face->filename ); return( NULL ); } bdffont = calloc(1,sizeof(*bdffont)); bdffont->face = face; fgets(buffer,sizeof(buffer),bdffile); bdffont->header = SlurpChar(bdffile,buffer, sizeof(buffer), "ENDPROPERTIES", &enc); fgets(buffer,sizeof(buffer),bdffile); fgets(buffer,sizeof(buffer),bdffile); while ( strcmp(buffer,"ENDFONT\n")!=0 ) { chr = SlurpChar(bdffile,buffer, sizeof(buffer), "ENDCHAR", &enc); if ( enc!=-1 ) { if ( enc>=bdffont->charmax ) { int new = enc+256; if ( bdffont->charmax==0 ) bdffont->chars = malloc(new*sizeof(char **)); else bdffont->chars = realloc(bdffont->chars,new*sizeof(char **)); for ( i=bdffont->charmax; ichars[i] = NULL; bdffont->charmax = new; } bdffont->chars[enc] = chr; last_enc = enc; } if ( fgets(buffer,sizeof(buffer),bdffile)==NULL ) break; } return( bdffont ); } static void ParseBdfHeader(struct macfont *macfont, struct bdffont *bdf) { int h=10,w=10,lb=0,ds=0, i; for ( i=0; bdf->header[i]!=NULL; ++i ) if ( sscanf(bdf->header[i], "FONTBOUNDINGBOX %d %d %d %d", &w, &h, &lb, &ds)==4 ) break; macfont->fRectWidth = w; macfont->fRectHeight = macfont->face->size; macfont->ascent = macfont->face->ascent; macfont->descent = macfont->face->descent; macfont->nDescent = -macfont->face->descent; macfont->leading = 0; macfont->kernMax = lb; macfont->firstChar = 0; macfont->lastChar = 0xff; macfont->fontType = macfont->face->fixed?0xb000:0x9000; } static int ParseCharWidths(struct macfont *macfont,int ch,char **chlist,int loc) { int pwidth=0, swidth=0, gwidth=0, lb=0; int i; for ( i=0 ; chlist[i]!=NULL; ++i ) { if ( strncmp(chlist[i],"SWIDTH", 6)==0 ) sscanf(chlist[i],"SWIDTH %d", &swidth ); else if ( strncmp(chlist[i],"DWIDTH", 6)==0 ) sscanf(chlist[i],"DWIDTH %d", &pwidth ); else if ( strncmp(chlist[i],"BBX", 3)==0 ) sscanf(chlist[i],"BBX %d %*d %d", &gwidth, &lb ); } macfont->widths[ch] = pwidth; macfont->lbearings[ch] = lb; macfont->face->metrics[ch] = (((long) swidth<<12)+500)/1000; macfont->locs[ch] = loc; return( loc + gwidth ); } static void ProcessLBearings(struct macfont *macfont) { int i, lb=256, wmax=0; for ( i=0; i<255; ++i ) { if ( macfont->widths[i]!=0xffff && macfont->lbearings[i]lbearings[i]; if ( macfont->widths[i]!=0xffff && macfont->widths[i]>wmax ) wmax = macfont->widths[i]; } macfont->kernMax = lb; macfont->widmax = wmax; for ( i=0; i<255; ++i ) { if ( macfont->widths[i]!=0xffff ) macfont->widths[i] |= (macfont->lbearings[i]-lb)<<8; } /* These seem to be magic, don't know why */ macfont->widths[0] = 0; macfont->widths['\t'] = 6; macfont->widths['\r'] = 0; } static void ParseRow(struct macfont *macfont,int ch,int row, char *hexbits) { int loc = macfont->locs[ch], bits=macfont->locs[ch+1]-loc; unsigned short word; if ( row>=macfont->fRectHeight || row<0 ) return; while ( *hexbits!='\0' && bits>0 ) { if ( isdigit(*hexbits)) word = (*hexbits-'0')<<12; else if ( *hexbits>='a' && *hexbits<='f' ) word = (*hexbits-'a'+10)<<12; else if ( *hexbits>='A' && *hexbits<='F' ) word = (*hexbits-'A'+10)<<12; else word = 0; ++hexbits; if ( isdigit(*hexbits)) word |= (*hexbits-'0')<<8; else if ( *hexbits>='a' && *hexbits<='f' ) word |= (*hexbits-'a'+10)<<8; else if ( *hexbits>='A' && *hexbits<='F' ) word |= (*hexbits-'A'+10)<<8; else --hexbits; ++hexbits; if ( isdigit(*hexbits)) word |= (*hexbits-'0')<<4; else if ( *hexbits>='a' && *hexbits<='f' ) word |= (*hexbits-'a'+10)<<4; else if ( *hexbits>='A' && *hexbits<='F' ) word |= (*hexbits-'A'+10)<<4; else --hexbits; ++hexbits; if ( isdigit(*hexbits)) word |= (*hexbits-'0'); else if ( *hexbits>='a' && *hexbits<='f' ) word |= (*hexbits-'a'+10); else if ( *hexbits>='A' && *hexbits<='F' ) word |= (*hexbits-'A'+10); else --hexbits; ++hexbits; if ( (loc&15)==0 ) macfont->rows[row][loc>>4] = word; else { macfont->rows[row][loc>>4] |= (word>>(loc&15)); if ( bits-(16-(loc&15))<=0 ) break; macfont->rows[row][(loc>>4)+1] = (word<<(16-(loc&15))); } loc += 16; bits -= 16; } } static void ParseBitmap(struct macfont *macfont,int ch,char **chlist) { int height, descent, ascent,off,i, base; for ( base=0 ; chlist[base]!=NULL; ++base ) { if ( strncmp(chlist[base],"BBX",3)==0 ) sscanf(chlist[base],"BBX %*d %d %*d %d", &height, &descent ); else if ( strncmp(chlist[base],"BITMAP",6)==0 ) break; } if ( chlist[base]!=NULL ) { ascent = height+descent; off = macfont->ascent-ascent; for ( i=0; ilocs[ch], lw = (loc>>4), lb= (1<<(15-(loc&15))); int i; for ( i=0; ifRectHeight; ++i ) macfont->rows[i][lw] |= lb; } static struct macfont *CvtBdfToNfnt(struct bdffont *bdf,Face *face) { struct macfont *macfont; int i, loc, ch; if ( bdf==NULL ) return( NULL ); macfont = calloc(sizeof(struct macfont),sizeof(char)); macfont->face = face; macfont->widths = calloc(258,sizeof(short)); macfont->lbearings = calloc(258,sizeof(short)); macfont->locs = calloc(258,sizeof(short)); ParseBdfHeader(macfont,bdf); macfont->rows = malloc(macfont->fRectHeight*sizeof(char *)); loc = 0; for ( i=0; i<256; ++i ) { ch = i; if ( chcharmax && bdf->chars[ch]!=NULL ) loc = ParseCharWidths(macfont,i,bdf->chars[ch],loc); else { macfont->widths[i] = -1; macfont->locs[i] = loc; } } macfont->locs[i] = loc; /* Char for unused letters */ macfont->widths[i]=3; macfont->face->metrics[i]=(3<<12)/macfont->fRectHeight; macfont->lbearings[i]=1; macfont->locs[i+1] = ++loc; /* one beyond, gives size to last character */ macfont->widths[i+1]=-1; macfont->rowWords = (loc+15)/16; for ( i=0; ifRectHeight; ++i ) macfont->rows[i] = calloc(macfont->rowWords,sizeof(short)); for ( i=0; i<256; ++i ) { ch = i; if ( chcharmax && bdf->chars[ch]!=NULL ) ParseBitmap(macfont,i,bdf->chars[ch]); } DummyUpFakeBitmap(macfont,i); ProcessLBearings(macfont); return( macfont ); } static struct macfont *ProcessBdfFile(Face *face) { struct bdffont *bdf = SlurpFont(face); struct macfont *macfont = CvtBdfToNfnt(bdf,face); FreeBdfFont(bdf); return( macfont ); } static void FreeMacFont(struct macfont *macfont) { int i; for ( i=0; ifRectHeight; ++i ) free(macfont->rows[i]); free(macfont->rows); free(macfont->lbearings); free(macfont->widths); free(macfont->locs); free(macfont); } static long DumpMacFont(FILE *resfile, struct macfont *macfont) { int size, i,j; long here; size = 13*sizeof(short) + macfont->fRectHeight*macfont->rowWords*sizeof(short) + 258*sizeof(short) + 258*sizeof(short); macfont->owTLoc = (size- 258*sizeof(short)- (8*sizeof(short)))/ /* Offset to owTLoc itself*/ sizeof(short); here = ftell(resfile); putlong(0,resfile); /* Resources start with a size field */ putshort(macfont->fontType,resfile); putshort(macfont->firstChar,resfile); putshort(macfont->lastChar,resfile); putshort(macfont->widmax,resfile); putshort(macfont->kernMax,resfile); putshort(macfont->nDescent,resfile); putshort(macfont->fRectWidth,resfile); putshort(macfont->fRectHeight,resfile); putshort(macfont->owTLoc,resfile); putshort(macfont->ascent,resfile); putshort(macfont->descent,resfile); putshort(macfont->leading,resfile); putshort(macfont->rowWords,resfile); for ( i=0; ifRectHeight; ++i ) { for ( j=0; jrowWords; ++j ) putshort( macfont->rows[i][j],resfile ); } for ( i=0; i<258; ++i ) putshort(macfont->locs[i],resfile); for ( i=0; i<258; ++i ) putshort(macfont->widths[i],resfile); if ( size!=ftell(resfile)-here-4 ) printf( "IE: expected %d found %d\n", size, ftell(resfile)-here-4 ); size = ftell(resfile)-here-4; fseek(resfile,here,SEEK_SET); putlong(size,resfile); fseek(resfile,0,SEEK_END); return( here ); } long BDFToResource(FILE *res,Face *face) { struct macfont *macfont = ProcessBdfFile(face); long ret; if ( macfont==NULL ) return( 0 ); ret = DumpMacFont(res, macfont); FreeMacFont(macfont); return( ret ); } fondu-060102/ufond.10100644000076500007650000000370410303427533012325 0ustar gwwgww.ds Ps P\s-2OST\s+2S\s-2CRIPT\s+2 .TH UFOND 1 "23 October 2002" .SH NAME ufond \- convert UNIX font files into Macintosh format .SH SYNOPSIS .B ufond .RB [ \-dfont ] .RB [ \-macbin ] .RB [ \-res ] .RB [ \-script .IR name ] .BR fontfile ... .SH DESCRIPTION The program .B ufond takes UNIX font files, wraps them in a Macintosh resource fork, creates a family for them, and then wraps that in a macbinary or binhex file. .LP The program reads one or more font files, specified at the end of the command line, using any of the following formats: .TP Glyph Bitmap Distribution (.bdf) .TP TrueType (.ttf) .TP OpenType (.otf) .TP \*(Ps Binary format (.pfb) .LP All fonts with the same font family name will be placed in the same FOND. The program associates the name of a \*(Ps font with a bitmap font, as well as handling bold, italic, and other variants properly. .LP The generated Macintosh files will be in one of three formats: .TP MacBinary (default) .TP dfont (data fork resource file format, used by MacOS X) .TP bare resource fork (you have to know how to transform this into a real resource fork) .LP The program normally assumes that your fonts are in the roman script system. If this is not true you may specify a script directly. The program knows the names of a few scripts (greek, cyrillic, hebrew, arabic) which may be entered directly; otherwise you must know the Macintosh script number. .\" more information about Macintosh scripts is important here .SH OPTIONS .TP .B \-dfont Generate Macintosh files in dfont format. .TP .B \-macbin Generate Macintosh files in MacBinary format. .TP .B \-res Generate Macintosh files in resource format. .TP .BI \-script " name" Specify the Macintosh script number. .SH AUTHOR George Williams (gww@silcom.com). .LP Manual page by Ziying Sherwin (sherwin@nlm.nih.gov) and R.P.C Rodgers (rodgers@nlm.nih.gov), Lister Hill National Center for Biomedical Communications, U.S. National Library of Medicine. .\" end of manual page fondu-060102/ufond.c0100644000076500007650000007206410303430002012375 0ustar gwwgww/* Copyright (C) 2001-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include "ufond.h" /* ufond [-bin] [-res] [-dfont] [-macbin] [-script num] filelist */ /* The basic idea is the following: */ /* We collect all the files we are supposed to deal with */ /* we parse each file far enough to get: */ /* a fontname */ /* (for bdf) a size */ /* (for ttf) the mac encoding so we can order the hmtx properly */ /* (for bdf,ttf) the metrics */ /* We strip off things like Italic, Bold, Oblique, Condensed, "-" to get a family name */ /* We collect all files into families */ /* We generate one FOND for each family and put the bdf and ttf into it */ /* We generate one seperate resource file for each ps font in the family */ /* If we do not have a plain style then make a seperate FOND for each style */ /* and pretend each is plain */ /* If we have a PS font style with no matching bdf (ie. no metrics) then */ /* complain (but make an entry for it in the fond anyway?) */ int getushort(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); if ( ch2==EOF ) return( EOF ); return( (ch1<<8)|ch2 ); } long getlong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 ); } void putshort(int val, FILE *f) { putc(val>>8,f); putc(val&0xff,f); } void putlong(long val, FILE *f) { putc((val>>24)&0xff,f); putc((val>>16)&0xff,f); putc((val>>8)&0xff,f); putc(val&0xff,f); } enum output_format { of_dfont, of_macbin, of_res } output_format = of_macbin; static int script = 0; /* Roman */ static uint16 HashToId(char *fontname) { int low = 128, high = 0x4000; uint32 hash = 0; if ( script!=0 ) { low = 0x4000+(script-1)*0x200; high = low + 0x200; } while ( *fontname ) { int temp = (hash>>28)&0xf; hash = (hash<<4) | temp; hash ^= *fontname++-' '; } hash %= (high-low); hash += low; return( hash ); } static void Usage(char *prog) { fprintf( stderr, "Usage: %s [-dfont] [-macbin] [-res] [-script name] fontfile {fontfiles}\n", prog ); fprintf( stderr, " -dfont\t\tPuts the output into a Mac OS/X dfont file.\n" ); fprintf( stderr, " -macbin\tPuts the output into a resource fork inside a mac binary file.\n" ); fprintf( stderr, " -res\tPuts the output into a data file containing a resource fork\n\t\t(you have to figure out how to get it into a real resource fork)" ); fprintf( stderr, " -script [name|code]\tThe name should be the name of a mac script\n\t\tlike Roman or Cyrillic (not all names are recognized)\n\t\tthe code can be a number representing a script\n" ); fprintf( stderr, "A list of bdf/ttf files all with the same family name will be merged into\n" ); fprintf( stderr, "one FOND and all stored in one output files. Any pfb files will be refered\n" ); fprintf( stderr, "to in the FOND but will live in a seperate file.\n" ); exit( 1 ); } static Face *ParseArgs(int argc, char **argv) { Face *head = NULL, *last=NULL, *cur; int i, bad, val; char *pt, *end; for ( i=1; i= argc ) bad=true; else if ( strcasecmp(argv[i],"roman")==0 ) script = 0; else if ( strcasecmp(argv[i],"japanese")==0 ) script = 1; else if ( strcasecmp(argv[i],"traditionalchinese")==0 || strcasecmp(argv[i],"tradchinese")==0 || strcasecmp(argv[i],"big5")==0 || strcasecmp(argv[i],"taiwan")==0 ) script = 2; else if ( strcasecmp(argv[i],"simplifiedchinese")==0 || strcasecmp(argv[i],"simpchinese")==0 ) script = 25; else if ( strcasecmp(argv[i],"korean")==0 ) script = 3; else if ( strcasecmp(argv[i],"arabic")==0 ) script = 4; else if ( strcasecmp(argv[i],"hebrew")==0 ) script = 5; else if ( strcasecmp(argv[i],"greek")==0 ) script = 6; else if ( strcasecmp(argv[i],"cyrillic")==0 || strcasecmp(argv[i],"russian")==0 ) script = 7; else if ( (val = strtol(argv[i],&end,10), *end!='\0') || val<0 || val>128 ) bad = true; else script = val; if ( bad ) { fprintf( stderr, "The script argument must be followed by a script name or number\n(Roman=0, Japanese=1, Big5=2, Korean=3, Arabic=4, Hebrew=5, Greek=6, Cyrillic=7)\n" ); exit(1); } } else Usage(argv[0]); } else { cur = calloc(1,sizeof(Face)); cur->filename = argv[i]; pt = strrchr(argv[i],'.'); cur->type = -1; bad = 0; if ( pt==NULL ) /* do nothing */; else if ( strcasecmp(pt,".bdf")==0 ) { cur->type = ft_bdf; bad = !BDFGetNames(cur); } else if ( strcasecmp(pt,".ttf")==0 || strcasecmp(pt,".otf")==0 ) { cur->type = ft_ttf; bad = !TTFGetNames(cur); } else if ( strcasecmp(pt,".pfb")==0 ) { cur->type = ft_ps; bad = !PSGetNames(cur); } /* I'm not going to support .pfa files, doing the conversion is */ /* a pain, and I've already written something that does it. */ if ( cur->type==-1 ) { fprintf( stderr, "Unknown file type for %s\n Must be one of .bdf, .pfb, .ttf or .otf\n", argv[i] ); Usage( argv[0] ); } else if ( bad ) Usage( argv[0] ); if ( head==NULL ) head = cur; else last->next = cur; last = cur; } } if ( head==NULL ) { fprintf( stderr, "No files\n" ); Usage(argv[0]); } return( head ); } static Family *SortByFamily(Face *faces) { Family *head=NULL, *last=NULL, *cur; Face *next; int index; int i,cnt,one; for ( ; faces!=NULL ; faces = next ) { next = faces->next; /* mac styles may be numbers < 96. Postscript styles <48 */ /* But we still might get two bitmaps with the same style>=48 so */ /* merge them into one FOND if they match */ if ( faces->style<48 ) for ( cur=head; cur!=NULL && strcmp(cur->familyname,faces->family)!=0; cur = cur->next ); else for ( cur=head; cur!=NULL && strcmp(cur->familyname,faces->fontname)!=0; cur = cur->next ); if ( cur==NULL ) { cur = calloc(1,sizeof(Family)); if ( head==NULL ) head = cur; else last->next = cur; last = cur; cur->familyname = faces->style<48 ? faces->family : faces->fontname; } if ( faces->type!=ft_ps ) cur->fixed = faces->fixed; index = faces->style; if ( index>=96 ) { index = 0; fprintf( stderr, "%s has a style which doesn't fit in a normal FOND, so we're\ngiving it its own FOND where it can pretend to be plain\n", faces->filename ); } if ( faces->type==ft_bdf ) { faces->next = cur->faces[index]; cur->faces[index] = faces; } else if ( faces->type==ft_ttf ) { if ( cur->ttffaces[index]!=NULL ) fprintf( stderr, "Attempt to add two scalable fonts for the same style in a FOND\n%s and %s\n", faces->filename, cur->ttffaces[index]->filename ); cur->ttffaces[index] = faces; faces->next = NULL; } else { index = faces->psstyle; if ( index>=48 ) { index = 0; fprintf( stderr, "%s has a style which doesn't fit in a normal FOND, so we're\ngiving it its own FOND where it can pretend to be plain\n", faces->filename ); } if ( cur->psfaces[index]!=NULL ) fprintf( stderr, "Attempt to add two postscript fonts for the same style in a FOND\n%s and %s\n", faces->filename, cur->psfaces[index]->filename ); cur->psfaces[index] = faces; faces->next = NULL; } } for ( cur=head; cur!=NULL; cur=cur->next ) { for ( i=0; i<48; ++i ) { /* ps style is different from mac style, hence the complexity */ if ( cur->psfaces[i]!=NULL && cur->faces[cur->psfaces[i]->style]==NULL ) { fprintf( stderr, "A postscript font was found without a bitmap font of the same style\n %s\n", cur->psfaces[i]->filename ); exit( 1 ); } } for ( i=cnt=0; i<96; ++i ) if ( cur->faces[i]!=NULL || cur->ttffaces[i]!=NULL ) { one = i; ++cnt; } if ( one!=0 && cnt==1 ) { fprintf( stderr, "%s does not have a corresponding plain style font.\nWe will claim it is plain when we build the FOND\n", cur->faces[one]!=NULL ? cur->faces[one]->filename: cur->ttffaces[one]->filename ); cur->faces[0] = cur->faces[one]; cur->ttffaces[0] = cur->ttffaces[one]; cur->psfaces[0] = cur->psfaces[one]; cur->faces[one] = cur->ttffaces[one] = cur->psfaces[one] = NULL; cur->familyname = cur->faces[one]!=NULL ? cur->faces[one]->fontname: cur->ttffaces[one]->fontname; } else if ( cur->faces[0]==NULL && cur->ttffaces[0]==NULL ) { fprintf( stderr, "The family, %s, does not have a plain style. That would lead to\nconfusion, so I'm giving up.\n", cur->familyname ); exit( 1 ); } cur->id = HashToId(cur->familyname); } return( head ); } static void putpsstring(FILE *res,char *fontname) { putc(strlen(fontname),res); if ( *fontname ) { if ( islower(*fontname)) putc(toupper(*fontname),res); else putc(*fontname,res); for ( ++fontname; *fontname; ++fontname ) putc(*fontname,res); } } static uint32 FamilyToFOND(FILE *res,Family *fam) { uint32 rlenpos = ftell(res), widoffpos, widoffloc, kernloc, styleloc, glyphloc, end; int i,j,cnt, scnt, strcnt, pscnt, maxw, size; Face *face, *test; int exact, badmatch; /* Fonds are generally marked system heap and sometimes purgeable (resource flags) */ /* Use a ttf font if we've got it (metrics more accurate), else the */ /* biggest bitmap */ face = fam->ttffaces[0]; if ( face==NULL ) { face = fam->faces[0]; for ( test = face; test!=NULL; test=test->next ) if ( test->size > face->size ) face = test; } maxw = 0; for ( i=0; i<256; ++i ) if ( face->metrics[i]>maxw ) maxw = face->metrics[i]; putlong(0,res); /* Fill in length later */ putshort(fam->fixed?0x9000:0x1000,res); putshort(fam->id,res); putshort(0,res); /* First character */ putshort(255,res); /* Last character */ putshort((short) ((face->ascent*(1<<12))/(face->ascent+face->descent)),res); putshort(-(short) ((face->descent*(1<<12))/(face->ascent+face->descent)),res); putshort((short) ((face->linegap*(1<<12))/(face->ascent+face->descent)),res); putshort((short) maxw,res); widoffpos = ftell(res); putlong(0,res); /* Fill in width offset later */ putlong(0,res); /* Fill in kern offset later */ putlong(0,res); /* Fill in style offset later */ for ( i=0; i<9; ++i ) putshort(0,res); /* Extra width values */ putlong(0,res); /* Script for international */ putshort(2,res); /* FOND version */ /* Font association table */ for ( i=cnt=scnt=0; i<96; ++i ) { for ( face = fam->faces[i]; face!=NULL; face = face->next ) ++cnt; if ( fam->ttffaces[i] ) ++cnt; if ( fam->faces[i]!=NULL || fam->ttffaces[i]!=NULL ) ++scnt; } putshort(cnt-1,res); /* Number of faces */ /* This list is ordered by size and then by style */ for ( i=cnt=0; i<96; ++i ) if ( fam->ttffaces[i]!=NULL ) { putshort(0,res); /* it's scaleable */ putshort(i,res); /* style */ fam->ttffaces[i]->id = fam->id + cnt++; putshort(fam->ttffaces[i]->id,res); } for ( i=0; i<96; ++i ) /* I depend on this ordering */ for ( face=fam->faces[i]; face!=NULL; face=face->next ) face->id = fam->id + cnt++; for ( size=1; size<256; ++size ) { for ( i=0; i<96; ++i ) { for ( face=fam->faces[i]; face!=NULL; face=face->next ) if ( face->size==size ) { putshort(face->size,res); putshort(i,res); /* style */ putshort(face->id,res); /* make up a unique ID */ } } } /* offset table */ putshort(1-1,res); /* One table */ putlong(6,res); /* Offset from start of otab to next byte */ /* bounding box table */ putshort(scnt-1,res); /* One bounding box per style */ for ( i=0; i<96; ++i ) if ( fam->faces[i]!=NULL || fam->ttffaces[i]!=NULL ) { /* Use a ttf font if we've got it (metrics more accurate), else the */ /* biggest bitmap */ face = fam->ttffaces[i]; if ( face==NULL ) { face = fam->faces[i]; for ( test = face; test!=NULL; test=test->next ) if ( test->size > face->size ) face = test; } putshort(i,res); /* style */ putshort(face->xmin,res); putshort(face->ymin,res); putshort(face->xmax,res); putshort(face->ymax,res); } widoffloc = ftell(res); putshort(scnt-1,res); /* One set of width metrics per style */ for ( i=0; i<96; ++i ) if ( fam->faces[i]!=NULL || fam->ttffaces[i]!=NULL ) { face = fam->ttffaces[i]; if ( face==NULL ) { face = fam->faces[i]; for ( test = face; test!=NULL; test=test->next ) if ( test->size > face->size ) face = test; } putshort(i,res); /* style */ for ( j=0; j<256; ++j ) putshort(face->metrics[j],res); putshort(1<<12,res); /* Seem to be two extra glyphs. default is one */ putshort(1<<12,res); /* 1 em is default size */ } kernloc = 0; exact = badmatch = false; for ( i=pscnt=0; i<48; ++i ) if ( fam->psfaces[i]!=NULL ) { ++pscnt; if ( strcmp(fam->familyname,fam->psfaces[i]->fontname)==0 ) exact = true; if ( strncmp(fam->psfaces[i]->fontname,fam->familyname,strlen(fam->familyname))!=0 ) badmatch = true; } styleloc = 0; if ( pscnt!=0 ) { char *family = badmatch ? "" : fam->familyname; int fontclass; if ( badmatch ) exact = false; styleloc = ftell(res); fontclass = 0x1; if ( fam->psfaces[psf_outline]==NULL ) fontclass |= 4; if ( fam->psfaces[psf_bold]!=NULL ) fontclass |= 0x18; if ( fam->psfaces[psf_italic]!=NULL ) fontclass |= 0x40; if ( fam->psfaces[psf_condense]!=NULL ) fontclass |= 0x80; if ( fam->psfaces[psf_extend]!=NULL ) fontclass |= 0x100; putshort(fontclass,res); /* fontClass */ putlong(0,res); /* Offset to glyph encoding table (which we don't use) */ putlong(0,res); /* Reserved, MBZ */ strcnt = 1/* Family Name */ + pscnt-exact /* count of format strings */ + pscnt-exact /* count of additional strings */; /* indeces to format strings */ for ( i=0,pscnt=2; i<48; ++i ) if ( fam->psfaces[i]==NULL || strcmp(family,fam->psfaces[i]->fontname)==0) putc(1,res); else putc(pscnt++,res); putshort(strcnt,res); /* strcnt strings */ putpsstring(res,family); /* Now the format strings */ for ( i=0; i<48; ++i ) if ( fam->psfaces[i]!=NULL ) { if ( strcmp(family,fam->psfaces[i]->fontname)!=0 ) { putc(1,res); /* Familyname with the following */ putc(pscnt++,res); } } /* Now the additional names */ for ( i=0; i<48; ++i ) if ( fam->psfaces[i]!=NULL ) { if ( strcmp(family,fam->psfaces[i]->fontname)!=0 ) putpsstring(res,fam->psfaces[i]->fontname+strlen(family)); } /* Greg: record offset for glyph encoding table */ /* We assume that the bitmap and postscript fonts are encoded similarly */ /* and so a null vector will do. */ glyphloc = ftell( res ); putshort(0, res); /* Greg: an empty Glyph encoding table */ } end = ftell(res); fseek(res,widoffpos,SEEK_SET); putlong(widoffloc-rlenpos-4,res); /* Fill in width offset */ putlong(kernloc!=0?kernloc-rlenpos-4:0,res); /* Fill in kern offset */ putlong(styleloc!=0?styleloc-rlenpos-4:0,res); /* Fill in style offset */ /* Greg: go back and add the glyph encoding table offset */ if (styleloc && glyphloc) { fseek(res, styleloc + 2, SEEK_SET); putlong(glyphloc-styleloc, res); } fseek(res,rlenpos,SEEK_SET); putlong(end-rlenpos-4,res); /* resource length */ fseek(res,end,SEEK_SET); return(rlenpos); } /* I presume this routine is called after all resources have been written */ static void DumpResourceMap(FILE *res,struct resourcetype *rtypes) { uint32 rfork_base = output_format!=of_macbin?0:128; /* space for mac binary header */ uint32 resource_base = rfork_base+0x100; uint32 rend, rtypesstart, mend, namestart; int i,j; fseek(res,0,SEEK_END); rend = ftell(res); if ( output_format!=of_dfont ) { /* Duplicate resource header */ putlong(0x100,res); /* start of resource data */ putlong(rend-rfork_base,res); /* start of resource map */ putlong(rend-rfork_base-0x100,res); /* length of resource data */ putlong(0,res); /* don't know the length of the map section yet */ } else { for ( i=0; i<16; ++i ) /* 16 bytes of zeroes */ putc(0,res); } putlong(0,res); /* Some mac specific thing I don't understand */ putshort(0,res); /* another */ putshort(0,res); /* another */ putshort(4+ftell(res)-rend,res); /* Offset to resource types */ putshort(0,res); /* Don't know where the names go yet */ rtypesstart = ftell(res); for ( i=0; rtypes[i].tag!=0; ++i ); putshort(i-1,res); /* Count of different types */ for ( i=0; rtypes[i].tag!=0; ++i ) { putlong(rtypes[i].tag,res); /* Resource type */ putshort(0,res); /* Number of resources of this type */ putshort(0,res); /* Offset to the resource list */ } /* Now the resource lists... */ for ( i=0; rtypes[i].tag!=0; ++i ) { rtypes[i].resloc = ftell(res); for ( j=0; rtypes[i].res[j].pos!=0; ++j ) { putshort(rtypes[i].res[j].id,res); rtypes[i].res[j].nameptloc = ftell(res); putshort(0xffff,res); /* assume no name at first */ putc(rtypes[i].res[j].flags,res); /* resource flags */ /* three byte resource offset */ putc( ((rtypes[i].res[j].pos-resource_base)>>16)&0xff, res ); putc( ((rtypes[i].res[j].pos-resource_base)>>8)&0xff, res ); putc( ((rtypes[i].res[j].pos-resource_base)&0xff), res ); putlong(0,res); } } namestart = ftell(res); /* Now the names, if any */ for ( i=0; rtypes[i].tag!=0; ++i ) { for ( j=0; rtypes[i].res[j].pos!=0; ++j ) { if ( rtypes[i].res[j].name!=NULL ) { rtypes[i].res[j].nameloc = ftell(res); putc(strlen(rtypes[i].res[j].name),res); /* Length */ fwrite(rtypes[i].res[j].name,1,strlen(rtypes[i].res[j].name),res); } } } mend = ftell(res); /* Repeat the rtypes list now we know where they go */ fseek(res,rtypesstart+2,SEEK_SET); /* skip over the count */ for ( i=0; rtypes[i].tag!=0; ++i ) { putlong(rtypes[i].tag,res); /* Resource type */ for ( j=0; rtypes[i].res[j].pos!=0; ++j ); putshort(j-1,res); /* Number of resources of this type */ putshort(rtypes[i].resloc-rtypesstart,res); } /* And go back and fixup any name pointers */ for ( i=0; rtypes[i].tag!=0; ++i ) { for ( j=0; rtypes[i].res[j].pos!=0; ++j ) { if ( rtypes[i].res[j].name!=NULL ) { fseek(res,rtypes[i].res[j].nameptloc,SEEK_SET); putshort(rtypes[i].res[j].nameloc-namestart,res); } } } fseek(res,rend,SEEK_SET); /* Fixup duplicate header (and offset to the name list) */ if ( output_format!=of_dfont ) { putlong(0x100,res); /* start of resource data */ putlong(rend-rfork_base,res); /* start of resource map */ putlong(rend-rfork_base-0x100,res); /* length of resource data */ putlong(mend-rend,res); /* length of map section */ } else { for ( i=0; i<16; ++i ) putc(0,res); } putlong(0,res); /* Some mac specific thing I don't understand */ putshort(0,res); /* another */ putshort(0,res); /* another */ putshort(4+ftell(res)-rend,res); /* Offset to resource types */ putshort(namestart-rend,res); /* name section */ fseek(res,rfork_base,SEEK_SET); /* Fixup main resource header */ putlong(0x100,res); /* start of resource data */ putlong(rend-rfork_base,res); /* start of resource map */ putlong(rend-rfork_base-0x100,res); /* length of resource data */ putlong(mend-rend,res); /* length of map section */ } /* A MacBinary file */ /* http://www.lazerware.com/formats/macbinary.html */ /* begins with a 128 byte header */ /* (which specifies lengths for data/resource forks) */ /* (and contains mac type/creator data) */ /* (and other stuff) */ /* (and finally a crc checksum) /* is followed by the data section (padded to a mult of 128 bytes) */ /* is followed by the resource section (padded to a mult of 128 bytes) */ /* Crc code taken from: */ /* http://www.ctan.org/tex-archive/tools/macutils/crc/ */ /* MacBinary files use the same CRC that binhex does (in the MacBinary header) */ extern unsigned long binhex_crc(unsigned char *buffer,int size); static void DumpMacBinaryHeader(FILE *res,struct macbinaryheader *mb) { uint8 header[128], *hpt; char buffer[256], *pt, *dpt; uint32 len; time_t now; int i,crc; if ( mb->macfilename==NULL ) { char *pt = strrchr(mb->binfilename,'/'); if ( pt==NULL ) pt = mb->binfilename; else ++pt; strcpy(buffer,pt); dpt = strrchr(buffer,'.'); if ( dpt==NULL ) { buffer[0] = '_'; strcpy(buffer+1,pt); } else *dpt = '\0'; mb->macfilename = buffer; buffer[63] = '\0'; } memset(header,'\0',sizeof(header)); hpt = header; *hpt++ = '\0'; /* version number */ /* Mac Filename */ pt = mb->macfilename; *hpt++ = strlen( pt ); while ( *pt ) *hpt++ = *pt++; while ( hpttype>>24; *hpt++ = mb->type>>16; *hpt++ = mb->type>>8; *hpt++ = mb->type; /* Mac Creator */ *hpt++ = mb->creator>>24; *hpt++ = mb->creator>>16; *hpt++ = mb->creator>>8; *hpt++ = mb->creator; *hpt++ = '\0'; /* No finder flags set */ *hpt++ = '\0'; /* (byte 74) MBZ */ *hpt++ = '\0'; *hpt++ = '\0'; /* Vert Position in folder */ *hpt++ = '\0'; *hpt++ = '\0'; /* Hor Position in folder */ *hpt++ = '\0'; *hpt++ = '\0'; /* window or folder id??? */ *hpt++ = '\0'; /* protected bit ??? */ *hpt++ = '\0'; /* (byte 82) MBZ */ /* Data fork length */ *hpt++ = '\0'; *hpt++ = '\0'; *hpt++ = '\0'; *hpt++ = '\0'; /* Resource fork length */ fseek(res,0,SEEK_END); len = ftell(res)-sizeof(header); *hpt++ = len>>24; *hpt++ = len>>16; *hpt++ = len>>8; *hpt++ = len; /* Pad resource fork to be a multiple of 128 bytes */ while ( (len&127)!=0 ) { putc('\0',res); ++len; } /* Creation time, (seconds from 1/1/1904) */ time(&now); /* convert from 1970 based time to 1904 based time */ now += (1970-1904)*365L*24*60*60; for ( i=1904; i<1970; i+=4 ) now += 24*60*60; /* Ignore any leap seconds */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; /* Modification time, (seconds from 1/1/1904) */ *hpt++ = now>>24; *hpt++ = now>>16; *hpt++ = now>>8; *hpt++ = now; *hpt++ = '\0'; *hpt++ = '\0'; /* Get Info comment length */ *hpt++ = 0; /* More finder flags */ /* MacBinary 3 */ memcpy(header+102,"mBIN",4); header[106] = 0; /* Script. I assume 0 is latin */ header[107] = 0; /* extended finder flags */ /* End of MacBinary 3 */ header[122] = 130; /* MacBinary version 3, written in (129 is MB2) */ header[123] = 129; /* MacBinary Version 2, needed to read */ crc = binhex_crc(header,124); header[124] = crc>>8; header[125] = crc; fseek(res,0,SEEK_SET); fwrite(header,1,sizeof(header),res); } static void WriteDummyHeaders(FILE *res) { /* Leave space for the mac binary header (128bytes) and the mac resource */ /* file header (256 bytes) */ int i; if ( output_format == of_macbin ) { for ( i=0; i<128; ++i ) putc(0,res); } for ( i=0; i<256; ++i ) putc(0,res); } static int DumpPostscriptFont(Face *face) { FILE *res; int ret = 1; struct resourcetype resources[2]; struct macbinaryheader header; char buffer[63], *pt, *spt, *lcpt=NULL; char filename[63], *fpt; fpt = filename; for ( pt = buffer, spt = face->fontname; *spt && ptfontname?spt+5:spt+3); } else if ( islower(*spt) && sptpsfaces[i]!=NULL ) if ( !DumpPostscriptFont(fam->psfaces[i]) ) fprintf( stderr, "Failed to write resource file for PostScript %s\n", face->fontname ); for ( i=ncnt=tcnt=0; i<96; ++i ) { for ( face=fam->faces[i]; face!=NULL; face=face->next ) ++ncnt; if ( fam->ttffaces[i]!=NULL ) ++tcnt; } if ( ncnt==0 && tcnt==0 ) return; strcpy(filename,fam->familyname); strcat(filename,".fam"); strcat(filename,output_format==of_dfont?".dfont": output_format==of_macbin?".bin": ".rsrc"); res = fopen(filename,"w"); if ( res==NULL ) { fprintf( stderr, "Failed to open output file %s\n", filename ); return; } WriteDummyHeaders(res); memset( resources, 0, sizeof(resources)); memset( fonds, 0, sizeof(fonds)); npos = tpos = fpos = 0; if ( ncnt!=0 ) { resources[0].tag = CHR('N','F','N','T'); resources[0].res = calloc(ncnt+1,sizeof(struct resource)); for ( i=ncnt=tcnt=0; i<96; ++i ) { for ( face=fam->faces[i]; face!=NULL; face=face->next ) { resources[0].res[ncnt].pos = BDFToResource(res,face); resources[0].res[ncnt].flags = 0x00; /* NFNTs generally have flags of 0 */ resources[0].res[ncnt].id = fam->id+ncnt; ++ncnt; } } tpos = fpos = 1; } if ( tcnt!=0 ) { resources[tpos].tag = CHR('s','f','n','t'); resources[tpos].res = calloc(tcnt+1,sizeof(struct resource)); for ( i=tcnt=0; i<96; ++i ) { if ( fam->ttffaces[i]!=NULL ) { resources[tpos].res[tcnt].pos = TTFToResource(res,fam->ttffaces[i]); resources[tpos].res[tcnt].flags = 0x00; /* sfnts generally have resource flags 0x20 */ resources[tpos].res[tcnt].id = fam->id+tcnt; ++tcnt; } } ++fpos; } resources[fpos].tag = CHR('F','O','N','D'); resources[fpos].res = fonds; fonds[0].pos = FamilyToFOND(res,fam); fonds[0].flags = 0x00; /* I've seen FONDs with resource flags 0, 0x20, 0x60 */ fonds[0].id = fam->id; fonds[0].name = fam->familyname; DumpResourceMap(res,resources); if ( output_format==of_macbin ) { header.macfilename = NULL; header.binfilename = filename; /* Fontographer uses the old suitcase format for both bitmaps and ttf */ header.type = CHR('F','F','I','L'); header.creator = CHR('D','M','O','V'); DumpMacBinaryHeader(res,&header); } ret = !ferror(res); if ( fclose(res)==-1 || ret == 0 ) fprintf( stderr, "Failed to write resource file for family %s\n", fam->familyname ); } int main( int argc, char **argv) { Family *families; families = SortByFamily(ParseArgs(argc, argv)); for ( ; families!=NULL; families=families->next ) DumpFamily(families); return( 0 ); } fondu-060102/ufond.h0100644000076500007650000001036510303427544012417 0ustar gwwgww/* Copyright (C) 2001-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include /* for NULL */ #include /* for free */ #include #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4)) #define true 1 #define false 0 #define forever for (;;) #if INT_MAX==2147483647 typedef int int32; typedef unsigned int uint32; #else typedef long int32; typedef unsigned long uint32; #endif /* I don't know of any systems where the following are not true */ typedef short int16; typedef unsigned short uint16; typedef signed char int8; typedef unsigned char uint8; enum style_flags { sf_bold = 1, sf_italic = 2, sf_underline = 4, sf_outline = 8, sf_shadow = 0x10, sf_condense = 0x20, sf_extend = 0x40 }; enum psstyle_flags { psf_bold = 1, psf_italic = 2, psf_outline = 4, psf_shadow = 0x8, psf_condense = 0x10, psf_extend = 0x20 }; typedef struct face { char *filename; enum face_type { ft_bdf, ft_ps, ft_ttf } type; /* ttf will include otf */ char *fontname; char *family; int16 style; int16 psstyle; int size; int fixed; short metrics[256]; /* Not computed until NFNT resource dumped, TTF knows once names are read, PS never knows */ int id; /* NFNT, sfnt resource ID */ int ascent, descent, linegap; struct face *next; int xmin, ymin, xmax, ymax; /* Bounding box for a 1em font (fixed 4.12 format) */ } Face; typedef struct family { char *familyname; int id; /* FOND resource ID */ int fixed; int ascent, descent, linegap, maxwidth; Face *faces[96]; Face *ttffaces[96]; Face *psfaces[48]; struct family *next; } Family; struct resource { uint32 pos; uint8 flags; uint16 id; char *name; uint32 nameloc; uint32 nameptloc; }; struct resourcetype { uint32 tag; struct resource *res; uint32 resloc; }; struct macbinaryheader { char *macfilename; char *binfilename; /* if macfilename is null and this is set we will figure out macfilename by removing .bin */ uint32 type; uint32 creator; }; struct macfont { short fRectWidth; short fRectHeight; short ascent; short descent; short nDescent; short leading; short kernMax; short firstChar; short lastChar; short fontType; short rowWords; short owTLoc; uint16 widmax; Face *face; unsigned short *widths; short *lbearings; unsigned short *locs; unsigned short **rows; unsigned short *idealwidths; /* For the fond */ }; extern int getushort(FILE *f); extern long getlong(FILE *f); extern void putshort(int val, FILE *f); extern void putlong(long val, FILE *f); /* Postscript */ extern int PSGetNames(Face *face); extern struct resource *PSToResources(FILE *res,Face *face); /* TrueType */ extern int TTFGetNames(Face *face); extern long TTFToResource(FILE *res,Face *face); /* bdf */ extern int BDFGetNames(Face *face); extern long BDFToResource(FILE *res,Face *face); fondu-060102/ufondpfb.c0100644000076500007650000001326310303430002013061 0ustar gwwgww/* Copyright (C) 2001-2003 by George Williams */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include "ufond.h" /* Process postscript files to make them useable on the mac */ /* this involves almost no work, because all the hard stuff is done on the bitmap */ static long getpfblong(FILE *f) { int ch1 = getc(f); int ch2 = getc(f); int ch3 = getc(f); int ch4 = getc(f); if ( ch4==EOF ) return( EOF ); return( ch4|(ch3<<8)|(ch2<<16)|(ch1<<24) ); } int PSGetNames(Face *face) { /* Get the font and family names by reading the fontfile */ FILE *pf = fopen( face->filename, "r" ); char buffer[512]; int ch; char *pt, *npt; if ( pf==NULL ) { fprintf( stderr, "Can't open %s for reading\n", face->filename ); return(false); } ch = getc(pf); if ( ch==0x80 ) { /* skip over the pfb header */ getc(pf); getc(pf); getc(pf); getc(pf); getc(pf); } else { ungetc(ch,pf); fprintf( stderr, "Hmm, %s doesn't look like a pfb font,\nif it's a pfa just convert it to pfb and try again.\n", face->filename ); fclose(pf); return( false ); } buffer[0]='\0'; fgets(buffer,sizeof(buffer),pf); if ( buffer[0]!='%' || buffer[1]!='!' ) { fprintf( stderr, "%s does not look like a postscript font\n", face->fontname); fclose(pf); return( false ); } while ( fgets(buffer,sizeof(buffer),pf)!=NULL ) { if ( (pt=strstr(buffer,"/FamilyName"))!=NULL ) { pt += strlen("/FamilyName"); while ( *pt==' ' ) ++pt; if ( *pt=='(' ) ++pt; /* don't deal with the full complexities of strings, just look for*/ /* the final ) and assume we've got normal chars, no nested parens*/ for ( npt=pt; *npt!=')' && *npt!='\0'; ++npt ); *npt = '\0'; face->family = strdup(pt); if ( face->fontname!=NULL ) break; } else if ( (pt=strstr(buffer,"/FontName"))!=NULL ) { pt += strlen("/FontName"); while ( *pt==' ' ) ++pt; if ( *pt=='/' ) ++pt; for ( npt=pt; *npt!=' ' && *npt!='\0'; ++npt ); *npt = '\0'; face->fontname = strdup(pt); if ( face->family!=NULL ) break; } } fclose(pf); if ( face->fontname==NULL && face->family!=NULL ) face->fontname = strdup(face->family); if ( face->fontname!=NULL ) { if ( strstr(face->fontname,"Bold")!=NULL ) { face->style |= sf_bold; face->psstyle |= psf_bold; } if ( strstr(face->fontname,"Italic")!=NULL || strstr(face->fontname,"Oblique")!=NULL ) { face->style |= sf_italic; face->psstyle |= psf_italic; } if ( strstr(face->fontname,"Outline")!=NULL ) { face->style |= sf_outline; face->psstyle |= psf_outline; } if ( strstr(face->fontname,"Shadow")!=NULL ) { face->style |= sf_shadow; face->psstyle |= psf_shadow; } if ( strstr(face->fontname,"Condense")!=NULL ) { face->style |= sf_condense; face->psstyle |= psf_condense; } if ( strstr(face->fontname,"Extend")!=NULL ) { face->style |= sf_extend; face->psstyle |= psf_extend; } } return( face->fontname!=NULL ); } struct resource *PSToResources(FILE *res,Face *face) { /* split the font up into as many small resources as we need and return */ /* an array pointing to the start of each */ struct stat statb; int cnt, type, len, i; struct resource *resstarts; FILE *pf; stat(face->filename,&statb); cnt = 3*(statb.st_size+0x800)/(0x800-2)+1; /* should be (usually) a vast over estimate */ resstarts = calloc(cnt+1,sizeof(struct resource)); pf = fopen(face->filename,"r"); cnt = 0; forever { if ( getc(pf)!=0x80 ) { fprintf( stderr, "Missing pfb section head in %s\n", face->fontname ); fclose(pf); return( NULL ); } type = getc(pf); if ( type==3 ) { resstarts[cnt].id = 501+cnt; /* 501 appears to be magic */ resstarts[cnt++].pos = ftell(res); putlong(2,res); /* length */ putc(5,res); /* eof mark */ putc(0,res); break; } len = getpfblong(pf); while ( len>0 ) { int ilen = len; if ( ilen>0x800-2 ) ilen = 0x800-2; len -= ilen; resstarts[cnt].id = 501+cnt; resstarts[cnt++].pos = ftell(res); putlong(ilen+2,res); /* length */ putc(type,res); /* section type mark */ putc(0,res); for ( i=0; i #include #include #include #include #include "ufond.h" /* When there are bitmaps in a ttf file, we should create dummy NFNT entries */ /* for them, each 26 bytes long which is all the fields up to rowWords. */ /* rowWords should be 0, and there should be nothing after it. firstChar is 0*/ /* and lastChar is 0xff. OffsetWidths is 0. others appear to be as expected */ struct ttfinfo { long cmap_start; long head_start; long hhea_start; long hmtx_start; long maxp_start; long name_start; long post_start; int max_glyph; int glyphs[256]; /* Glyph ids of the first 256 encoding entries */ int emsize; int macstyle; int longmtx; int isfixed; short metrics[256]; char *fontname, *familyname; }; static char *ReadUnicode(FILE *ttf,long pos, int len) { /* len is in bytes, not unicode-chars */ char *str = malloc(len/2+1), *pt = str; int ch; long here = ftell(ttf); fseek(ttf,pos,SEEK_SET); while ( len>0 ) { ch = getushort(ttf); if ( ch>=' ' && ch<127 ) *pt++ = ch; len -= 2; } *pt = '\0'; fseek(ttf,here,SEEK_SET); return( str ); } static char *Read1Byte(FILE *ttf,long pos, int len) { char *str = malloc(len+1), *pt = str; int ch; long here = ftell(ttf); fseek(ttf,pos,SEEK_SET); while ( len>0 ) { ch = getc(ttf); if ( ch>=' ' && ch<127 ) *pt++ = ch; --len; } *pt = '\0'; fseek(ttf,here,SEEK_SET); return( str ); } int TTFGetNames(Face *face) { /* Get a bunch of info including the font and family names */ FILE *ttf = fopen( face->filename, "r" ); int ch1, ch2, ch3, ch4; struct ttfinfo info; int i, cnt, tag; int platform, specific, offset, format, len, lang, name, stroff; long strbase; char *str; if ( ttf==NULL ) { fprintf( stderr, "Can't open %s for reading\n", face->filename ); return(false); } ch1 = getc(ttf); ch2 = getc(ttf); ch3 = getc(ttf); ch4 = getc(ttf); if (!(( ch1==0 && ch2==1 && ch3==0 && ch4==0 ) || (ch1=='O' && ch2=='T' && ch3=='T' && ch4=='O') || (ch1=='t' && ch2=='r' && ch3=='u' && ch4=='e')) ) { fprintf( stderr, "Hmm, %s doesn't look like a true or open type font.\n", face->filename ); fclose(ttf); return( false ); } memset(&info,0,sizeof(info)); cnt = getushort(ttf); /* searchRange = */ getushort(ttf); /* entrySelector = */ getushort(ttf); /* rangeshift = */ getushort(ttf); for ( i=0; i>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff ); #endif switch ( tag ) { case CHR('c','m','a','p'): info.cmap_start = offset; break; case CHR('b','h','e','d'): case CHR('h','e','a','d'): info.head_start = offset; break; case CHR('h','h','e','a'): info.hhea_start = offset; break; case CHR('h','m','t','x'): info.hmtx_start = offset; break; case CHR('m','a','x','p'): info.maxp_start = offset; break; case CHR('n','a','m','e'): info.name_start = offset; break; case CHR('p','o','s','t'): info.post_start = offset; break; } } if ( info.cmap_start==0 || info.head_start==0 || info.hhea_start==0 || info.hmtx_start==0 || info.maxp_start==0 || info.name_start==0 ) { fprintf( stderr, "Hmm, %s is missing some required tables. I can't deal with it.\n", face->filename ); fclose(ttf); return( false ); } if ( info.post_start ) { fseek(ttf,info.post_start+12,SEEK_SET); info.isfixed = getlong(ttf); } fseek(ttf,info.maxp_start+4,SEEK_SET); info.max_glyph = getushort(ttf); fseek(ttf,info.head_start+18,SEEK_SET); info.emsize = getushort(ttf); fseek(ttf,info.head_start+36,SEEK_SET); face->xmin = getushort(ttf); face->ymin = getushort(ttf); face->xmax = getushort(ttf); face->ymax = getushort(ttf); info.macstyle = getushort(ttf); fseek(ttf,info.hhea_start+4,SEEK_SET); face->ascent = getushort(ttf); face->descent = -getushort(ttf); face->linegap = getushort(ttf); fseek(ttf,info.hhea_start+34,SEEK_SET); info.longmtx = getushort(ttf); if ( face->ascent+face->descent!=info.emsize ) { face->ascent = .8*info.emsize; face->descent = info.emsize-face->ascent; } /* We need to get an encoding vector so we'll know what glyphs go to */ /* what encodings. We need this so we can read in the metrics info */ /* we need that so we can fill in the width table of the FOND */ fseek(ttf,info.cmap_start+2,SEEK_SET); cnt = getushort(ttf); for ( i=0; ifilename ); fclose(ttf); return( false ); } /*language = */ getushort(ttf); for ( i=0; i<256; ++i ) info.glyphs[i] = getc(ttf); for ( i=0; i<256; ++i ) { int k = info.glyphs[i]; if ( k>=info.longmtx ) k = info.longmtx-1; fseek(ttf,info.hmtx_start+k*4,SEEK_SET); info.metrics[i] = getushort(ttf); } fseek(ttf,info.name_start+2,SEEK_SET); cnt = getushort(ttf); strbase = getushort(ttf)+info.name_start; for ( i=0; ifilename ); return( false ); } face->fontname = info.fontname; face->family = info.familyname; face->style = info.macstyle; face->size = 0; face->fixed = info.isfixed; for ( i=0; i<256; ++i ) face->metrics[i] = (info.metrics[i]<<12)/info.emsize; return( true ); } long TTFToResource(FILE *res,Face *face) { /* Just put the ttf(otf) file into a resource */ struct stat statb; int ch; FILE *ttf; long here = ftell(res); stat(face->filename,&statb); putlong(statb.st_size,res); ttf = fopen(face->filename,"r"); while ( (ch=getc(ttf))!=EOF ) putc(ch,res); fclose(ttf); return( here ); } fondu-060102/fondu-patch0100664000076500007650000000467210356073740013277 0ustar gwwgwwOnly in fondu-051010/: config.guess Only in fondu-051010/: config.sub Only in fondu-051010/: configure diff -ur fondu/configure.in fondu-051010/configure.in --- fondu/configure.in 2002-12-22 03:41:45.000000000 +0100 +++ fondu-051010/configure.in 2006-01-02 00:52:55.000000000 +0100 @@ -3,12 +3,9 @@ AC_INIT(fondu.c) AC_PROG_CC AC_CANONICAL_HOST +export HOST=$host -case "$host" in -*-apple-darwin*) - cp Makefile.Mac Makefile - exit 0 - ;; -esac +AC_SUBST(VPATH) +AC_SUBST(HOST) AC_OUTPUT(Makefile) diff -ur fondu/Makefile.in fondu-051010/Makefile.in --- fondu/Makefile.in 2004-05-27 15:59:02.000000000 +0200 +++ fondu-051010/Makefile.in 2006-01-02 01:37:58.000000000 +0100 @@ -1,8 +1,14 @@ -prefix = @prefix@ +wilprefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ CC = @CC@ +srcdir = @srcdir@ +VPATH = @srcdir@ +HOST= @HOST@ + + +DARWIN_CORE = $(if $(findstring apple-darwin,$(HOST)),/System/Library/Frameworks/CoreServices.framework/CoreServices,,) WFLAGS = -Wmissing-prototypes -Wunused -Wimplicit -Wreturn-type -Wparentheses -pedantic CFLAGS = -g $(WFLAGS) @@ -18,22 +24,23 @@ all: fondu ufond showfond dfont2res tobin frombin lumper setfondname fondu: $(FONDUOBJS) - $(CC) $(CFLAGS) -o fondu $(FONDUOBJS) -lm + $(CC) $(CFLAGS) -o fondu $(FONDUOBJS) -lm $(DARWIN_CORE) + ufond: $(UFONDOBJS) $(CC) $(CFLAGS) -o ufond $(UFONDOBJS) showfond: $(SHOWOBJS) - $(CC) $(CFLAGS) -o showfond $(SHOWOBJS) + $(CC) $(CFLAGS) -o showfond $(SHOWOBJS) $(DARWIN_CORE) dfont2res: $(DFONT2RESOBJS) $(CC) $(CFLAGS) -o dfont2res $(DFONT2RESOBJS) tobin: $(TOBINOBJS) - $(CC) $(CFLAGS) -o tobin $(TOBINOBJS) + $(CC) $(CFLAGS) -o tobin $(TOBINOBJS) $(DARWIN_CORE) frombin: $(FROMBINOBJS) - $(CC) $(CFLAGS) -o frombin $(FROMBINOBJS) + $(CC) $(CFLAGS) -o frombin $(FROMBINOBJS) $(DARWIN_CORE) lumper: $(LUMPEROBJS) $(CC) $(CFLAGS) -o lumper $(LUMPEROBJS) @@ -48,4 +55,17 @@ -rm Makefile install: all - cp fondu ufond showfond dfont2res tobin frombin lumper setfondname $(bindir) + mkdir -p $(DESTDIR)$(bindir) + cp fondu ufond showfond dfont2res tobin frombin lumper setfondname $(DESTDIR)$(bindir) + +VERSION=051010 +DISTNAME=fondu-$(VERSION) +DISTFILES=$(wildcard *.c *.1 *.h) README Makefile.in configure.in configure \ + LICENSE install-sh config.sub config.guess + + +dist: + mkdir $(DISTNAME) + ln $(DISTFILES) $(DISTNAME)/ + tar cfz $(DISTNAME).tar.gz $(DISTNAME) + rm -fr $(DISTNAME) Only in fondu: Makefile.Mac Only in fondu: Makefile.unix