diff --git a/cde/Makefile b/cde/Makefile index 536bf227e..e04387a18 100644 --- a/cde/Makefile +++ b/cde/Makefile @@ -1,5 +1,5 @@ # $TOG: Makefile /main/15 1999/10/12 09:33:30 mgreess $ - RELEASE = Release 2.3.0 + RELEASE = Release 2.3.0a PRODUCT = CDE SHELL = /bin/sh RM = rm -f @@ -7,7 +7,6 @@ MAKE = make NMAKE = nmake WORLDOPTS = -WIN32WORLDOPTS = -i TOP = . CURRENT_DIR = . CONFIGSRC = $(TOP)/config @@ -146,7 +145,7 @@ $(IMAKESRC)/Makefile.proto: imake.bootstrap: cd $(IMAKESRC) && $(MAKE) -f Makefile.proto bootstrapdepend cd $(IMAKESRC) && $(MAKE) $(FLAGS) bootstrap - cd $(IMAKESRC) && $(MAKE) -f Makefile.proto all + cd $(IMAKESRC) && $(MAKE) -f Makefile.proto all -@if [ -f xmakefile ]; then set -x; \ $(RM) xmakefile.bak; $(MV) xmakefile xmakefile.bak; \ else exit 0; fi @@ -161,30 +160,6 @@ Makefile:: xmakefile: Imakefile $(IMAKE_CMD) -s xmakefile -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) -World.Win32: - @echo : - @echo Building $(RELEASE) of $(PRODUCT). - @echo : - @echo : - cd $(IMAKESRC) - $(NMAKE) -f Makefile.ini clean.Win32 - $(NMAKE) -f Makefile.ini imake.exe - cd ..\.. - -if exist xmakefile.bak del xmakefile.bak - -if exist xmakefile ren xmakefile xmakefile.bak - $(IMAKE:/=\) -s xmakefile -I$(IRULESRC) $(IMAKE_DEFINES) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) - $(NMAKE_CMD) $(MFLAGS) VerifyOS - $(NMAKE_CMD) $(MFLAGS) Makefiles - $(NMAKE_CMD) $(MFLAGS) clean - $(NMAKE_CMD) $(MFLAGS) includes - $(NMAKE_CMD) $(MFLAGS) depend - $(NMAKE_CMD) $(MFLAGS) $(WIN32WORLDOPTS) - @echo : - @echo : - @echo Full build of $(RELEASE) of $(PRODUCT) complete. - @echo : - - # don't allow any default rules in this Makefile .SUFFIXES: diff --git a/cde/admin/IntegTools/dbTools/installCDE.src b/cde/admin/IntegTools/dbTools/installCDE.src index 0b0c84b31..024a6d6f6 100755 --- a/cde/admin/IntegTools/dbTools/installCDE.src +++ b/cde/admin/IntegTools/dbTools/installCDE.src @@ -50,8 +50,6 @@ unset FIGNORE LOGFILE="installCDE.$$.log" -REVISION="$(echo "$Revision: /main/20 $" | awk '{print $2}')" - Log() { /bin/echo "$1" | tee -a $LOGFILE @@ -66,19 +64,19 @@ MakeTarball() Log "Creating tarball..." DIRNAME=build.$DATE - mkdir -p $TARBALL_LOCATION/$DIRNAME - cd / - echo $DATE >$LOGFILES_LOCATION/.build.$DATE - chown bin $LOGFILES_LOCATION/.build.$DATE + mkdir -p "$TARBALL_LOCATION/$DIRNAME" + cd / || exit 1 + echo "$DATE" >"$LOGFILES_LOCATION/.build.$DATE" + chown bin "$LOGFILES_LOCATION/.build.$DATE" if [ "$COMPRESS_TARBALL" = "yes" ]; then - tar -cf - $INSTALL_LOCATION/STAR \ - 2>$TARBALL_LOCATION/$DIRNAME/extract.err | - compress -c >$TARBALL_LOCATION/$DIRNAME/dttar.Z + tar -cf - "$INSTALL_LOCATION/STAR" \ + 2>"$TARBALL_LOCATION/$DIRNAME/extract.err" | + compress -c >"$TARBALL_LOCATION/$DIRNAME/dttar.Z" else - tar -cf $TARBALL_LOCATION/$DIRNAME/dt.tar \ - $INSTALL_LOCATION/STAR \ - 2>$TARBALL_LOCATION/$DIRNAME/extract.err 2>&1 + tar -cf "$TARBALL_LOCATION/$DIRNAME/dt.tar" \ + "$INSTALL_LOCATION/STAR" \ + 2>"$TARBALL_LOCATION/$DIRNAME/extract.err" 2>&1 fi if [ "$ACTUAL_INSTALLATION_LOC" = "" ]; then @@ -86,31 +84,30 @@ MakeTarball() else actualInstallDir=$ACTUAL_INSTALLATION_LOC fi - let size=$(du -s $actualInstallDir | awk '{print $1}')*512 + let size=$(du -s "$actualInstallDir" | awk '{print $1}')*512 HASH load installation fileset *after* tarball generated LoadFileSet "" "CDE-INSTALL" HASH create config dir destPost=$TARBALL_LOCATION/$DIRNAME/config - mkdir $destPost + mkdir "$destPost" HASH copy config and platform config scripts src=$INSTALL_LOCATION/install/$PLATFORM_SCRIPT_DIR - cp $src/config/STAR.cfg $destPost + cp "$src/config/STAR.cfg" "$destPost" HASH copy this script and install.dt platform overrides - cp $src/install.dto $TARBALL_LOCATION/$DIRNAME/install.dto - cp $src/install.cde $TARBALL_LOCATION/$DIRNAME/install.cde - chmod 755 $TARBALL_LOCATION/$DIRNAME/install.cde + cp "$src/install.dto" "$TARBALL_LOCATION/$DIRNAME/install.dto" + cp "$src/install.cde" "$TARBALL_LOCATION/$DIRNAME/install.cde" + chmod 755 "$TARBALL_LOCATION/$DIRNAME/install.cde" - cd / + cd / || exit 1 Log "done." - cat >$TARBALL_LOCATION/$DIRNAME/dt.pkg <"$TARBALL_LOCATION/$DIRNAME/dt.pkg" <$TARBALL_LOCATION/$DIRNAME/build.status <"$TARBALL_LOCATION/$DIRNAME/build.status" < FIN - chmod g+w $TARBALL_LOCATION/$DIRNAME/build.status + chmod g+w "$TARBALL_LOCATION/$DIRNAME/build.status" } DoFilesetScript() @@ -142,22 +139,22 @@ DoFilesetScript() ScriptName=$2 # use long config file name (configFoo) fi - if [ $CDECONFIGDIR = "CONFIG" ]; then + if [ "$CDECONFIGDIR" = "CONFIG" ]; then typeset -u ScriptName fi test_string=${DATABASE_FILES#*$FilesetName} if (( ${#DATABASE_FILES} > ${#test_string} )) then - if [ -x $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName ] + if [ -x "$POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName" ] then Log "Executing $PLATFORM specific $FilesetName customize script" - KORNSHELL $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName -e 2>&1 | \ + KORNSHELL "$POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName" -e 2>&1 | \ tee -a $LOGFILE - elif [ -x $POST_INSTALL_DIR/$ScriptName ] + elif [ -x "$POST_INSTALL_DIR/$ScriptName" ] then Log "Executing $FilesetName customize script" - KORNSHELL $POST_INSTALL_DIR/$ScriptName -e 2>&1 | tee -a $LOGFILE + KORNSHELL "$POST_INSTALL_DIR/$ScriptName" -e 2>&1 | tee -a $LOGFILE fi fi } @@ -176,16 +173,16 @@ CreatePackingList() { Log " " Log "Creating packing list." - touch $INSTALL_LOCATION/Packing_list - for i in `echo $DATABASE_FILES` + touch "$INSTALL_LOCATION/Packing_list" + for i in $DATABASE_FILES do Log " for $i" - KORNSHELL $TOOL_DIR/udbToAny.ksh -toDB -ReleaseStream $PLATFORM $DATABASE_DIR/${i}.udb > /tmp/${i}.db - if [ -r /tmp/${i}.db ] + KORNSHELL "$TOOL_DIR/udbToAny.ksh" -toDB -ReleaseStream "$PLATFORM" "$DATABASE_DIR/${i}.udb" > "/tmp/${i}.db" + if [ -r "/tmp/${i}.db" ] then - for file in `fgrep install_target /tmp/${i}.db | cut -sf 2 -d \: ` + grep -F install_target "/tmp/${i}.db" | cut -sf 2 -d '\: ' < file | while IFS= read -r line do - echo "$file" >>$INSTALL_LOCATION/Packing_list + echo "$line" >>"$INSTALL_LOCATION/Packing_list" done fi done @@ -198,23 +195,23 @@ CleanDaemons() for i in inetd rpc.ttdbserver rpc.cmsd do - if [ "$PLATFORM" = "aix" -a $i = "inetd" ] + if [ "$PLATFORM" = "aix" ] && [ $i = "inetd" ] then - lssrc -s inetd >/dev/null 2>&1 - if [ $? = "0" ] + if ! lssrc -s inetd >/dev/null 2>&1 then stopsrc -s inetd >>$LOGFILE 2>&1 fi - elif [ "$PLATFORM" = "openbsd" -o "$PLATFORM" = "freebsd" -o "$PLATFORM" = "netbsd" -o "$PLATFORM" = "linux" ] + elif [ "$PLATFORM" = "openbsd" ] || [ "$PLATFORM" = "freebsd" ] || \ + [ "$PLATFORM" = "netbsd" ] || [ "$PLATFORM" = "linux" ] then - ps axo pid,comm | grep $i > /tmp/tmppsout + pgrep pid,comm > /tmp/tmppsout if [ -s /tmp/tmppsout ] then awk '{print "kill " $1}' /tmp/tmppsout | /bin/sh -f sleep 2 fi else - ps -ef | grep $i | grep -v grep >/tmp/tmppsout + pgrep -v pgrep >/tmp/tmppsout if [ -s /tmp/tmppsout ] then awk '{print "kill " $2}' /tmp/tmppsout | /bin/sh -f @@ -229,8 +226,8 @@ RestartInetd() { HASH now restart inetd - OLDPWD=`pwd` - cd / + OLDPWD=$(pwd) + cd / || exit 1 if [ "$PLATFORM" = "sun" ] then /usr/sbin/svcadm refresh svc:/network/inetd:default @@ -238,7 +235,7 @@ RestartInetd() elif [ "$PLATFORM" = "aix" ] then startsrc -s inetd >>$LOGFILE 2>&1 - elif [ "$PLATFORM" = "openbsd" -o "$PLATFORM" = "netbsd" ] + elif [ "$PLATFORM" = "openbsd" ] || [ "$PLATFORM" = "netbsd" ] then /etc/rc.d/inetd start >/dev/null elif [ "$PLATFORM" = "freebsd" ] @@ -254,7 +251,7 @@ RestartInetd() /etc/inetd #endif fi - cd $OLDPWD + cd "$OLDPWD" || exit 1 } CheckForActualLocations() @@ -275,21 +272,21 @@ XCOMM if [ "$CLEANING" = "yes" ] then Log "Removing $INSTALL_LOCATION contents... " - if [ -d $INSTALL_LOCATION ] + if [ -d "$INSTALL_LOCATION" ] then - rm -rf $INSTALL_LOCATION/STAR + rm -rf "${INSTALL_LOCATION:?}/"STAR if [ "$LeaveLinks" = "yes" ] then - if [ ! -L $INSTALL_LOCATION ] + if [ ! -L "$INSTALL_LOCATION" ] then - rm -rf $INSTALL_LOCATION + rm -rf "$INSTALL_LOCATION" fi else - if [ -L $INSTALL_LOCATION ] + if [ -L "$INSTALL_LOCATION" ] then - rm -f $INSTALL_LOCATION + rm -f "$INSTALL_LOCATION" else - rm -rf $INSTALL_LOCATION + rm -rf "$INSTALL_LOCATION" fi fi fi @@ -304,22 +301,22 @@ XCOMM HASH first create the actual directory - if not there HASH - if [ ! -d $ACTUAL_INSTALLATION_LOC ] + if [ ! -d "$ACTUAL_INSTALLATION_LOC" ] then - mkdir -p $ACTUAL_INSTALLATION_LOC - if [ ! -d $ACTUAL_INSTALLATION_LOC ] + mkdir -p "$ACTUAL_INSTALLATION_LOC" + if [ ! -d "$ACTUAL_INSTALLATION_LOC" ] then Log "cannot create $ACTUAL_INSTALLATION_LOC directory" exit 1 fi fi - ln -s $ACTUAL_INSTALLATION_LOC $INSTALL_LOCATION + ln -s "$ACTUAL_INSTALLATION_LOC" "$INSTALL_LOCATION" else - if [ ! -d $INSTALL_LOCATION -a ! -L $INSTALL_LOCATION ]; + if [ ! -d "$INSTALL_LOCATION" ] && [ ! -L "$INSTALL_LOCATION" ]; then - mkdir -p $INSTALL_LOCATION + mkdir -p "$INSTALL_LOCATION" fi fi fi @@ -334,21 +331,21 @@ XCOMM if [ "$CLEANING_ETC" = "yes" ] then Log "Removing $CONFIGURE_LOCATION contents... " - if [ -d $CONFIGURE_LOCATION ] + if [ -d "$CONFIGURE_LOCATION" ] then - rm -rf $CONFIGURE_LOCATION/STAR + rm -rf "${CONFIGURE_LOCATION:?}/"STAR if [ "$LeaveLinks" = "yes" ] then - if [ ! -L $CONFIGURE_LOCATION ] + if [ ! -L "$CONFIGURE_LOCATION" ] then - rm -rf $CONFIGURE_LOCATION + rm -rf "$CONFIGURE_LOCATION" fi else - if [ -L $CONFIGURE_LOCATION ] + if [ -L "$CONFIGURE_LOCATION" ] then - rm -f $CONFIGURE_LOCATION + rm -f "$CONFIGURE_LOCATION" else - rm -rf $CONFIGURE_LOCATION + rm -rf "$CONFIGURE_LOCATION" fi fi fi @@ -356,43 +353,43 @@ XCOMM if [ "$ACTUAL_CONFIGURATION_LOC" != "" ] then - if [ ! -d $ACTUAL_CONFIGURATION_LOC ] + if [ ! -d "$ACTUAL_CONFIGURATION_LOC" ] then - mkdir -p $ACTUAL_CONFIGURATION_LOC - if [ ! -d $ACTUAL_CONFIGURATION_LOC ] + mkdir -p "$ACTUAL_CONFIGURATION_LOC" + if [ ! -d "$ACTUAL_CONFIGURATION_LOC" ] then Log "cannot create $ACTUAL_CONFIGURATION_LOC directory" exit 1 fi fi - ln -s $ACTUAL_CONFIGURATION_LOC $CONFIGURE_LOCATION + ln -s "$ACTUAL_CONFIGURATION_LOC" "$CONFIGURE_LOCATION" else - if [ ! -d $CONFIGURE_LOCATION -a ! -L $CONFIGURE_LOCATION ]; + if [ ! -d "$CONFIGURE_LOCATION" ] && [ ! -L "$CONFIGURE_LOCATION" ]; then - mkdir -p $CONFIGURE_LOCATION + mkdir -p "$CONFIGURE_LOCATION" fi fi if [ "$CLEANING" = "yes" ] then Log "Removing $LOGFILES_LOCATION contents... " - if [ -d $LOGFILES_LOCATION ] + if [ -d "$LOGFILES_LOCATION" ] then - rm -rf $LOGFILES_LOCATION/STAR + rm -rf "${LOGFILES_LOCATION:?}/"STAR if [ "$LeaveLinks" = "yes" ] then - if [ ! -L $LOGFILES_LOCATION ] + if [ ! -L "$LOGFILES_LOCATION" ] then - rm -rf $LOGFILES_LOCATION + rm -rf "$LOGFILES_LOCATION" fi else - if [ -L $LOGFILES_LOCATION ] + if [ -L "$LOGFILES_LOCATION" ] then - rm -f $LOGFILES_LOCATION + rm -f "$LOGFILES_LOCATION" else - rm -rf $LOGFILES_LOCATION + rm -rf "$LOGFILES_LOCATION" fi fi fi @@ -400,22 +397,22 @@ XCOMM if [ "$ACTUAL_VAR_LOC" != "" ] then - if [ ! -d $ACTUAL_VAR_LOC ] + if [ ! -d "$ACTUAL_VAR_LOC" ] then - mkdir -p $ACTUAL_VAR_LOC - if [ ! -d $ACTUAL_VAR_LOC ] + mkdir -p "$ACTUAL_VAR_LOC" + if [ ! -d "$ACTUAL_VAR_LOC" ] then Log "cannot create $ACTUAL_VAR_LOC directory" exit 1 fi fi - ln -s $ACTUAL_VAR_LOC $LOGFILES_LOCATION + ln -s "$ACTUAL_VAR_LOC" "$LOGFILES_LOCATION" else - if [ ! -d $LOGFILES_LOCATION -a ! -L $LOGFILES_LOCATION ]; + if [ ! -d "$LOGFILES_LOCATION" ] && [ ! -L "$LOGFILES_LOCATION" ]; then - mkdir -p $LOGFILES_LOCATION + mkdir -p "$LOGFILES_LOCATION" fi fi @@ -424,7 +421,7 @@ XCOMM USAGE() { -echo -e "Usage: $(basename $0) {-s |-z } [options]" +echo -e "Usage: $(basename "$0") {-s |-z } [options]" echo -e "" echo -e "\t-s \t\t\tthe top of the build tree" echo -e "\t-z \t\tthe desktop install package" @@ -491,28 +488,28 @@ LoadFileSet() fi XCOMM don't bother if the fileset doesn't exist - if [ ! -e $DATABASE_DIR/${2}.udb ] + if [ ! -e "$DATABASE_DIR/${2}.udb" ] then return fi Log " $num installing database $2" Log " - creating ${2}.lst file" - KORNSHELL $TOOL_DIR/udbToAny.ksh -toLst -ReleaseStream $PLATFORM \ - $DATABASE_DIR/${2}.udb > /tmp/${2}.lst + KORNSHELL "$TOOL_DIR/udbToAny.ksh" -toLst -ReleaseStream "$PLATFORM" \ + "$DATABASE_DIR/${2}.udb" > "/tmp/${2}.lst" Log " - installing ... " - KORNSHELL $TOOL_DIR/mkProd -D $DESTINATION_DIR -S $BUILD_TREE /tmp/${2}.lst \ - 2>/tmp/${2}.err 1>/tmp/${2}.good + KORNSHELL "$TOOL_DIR/mkProd" -D "$DESTINATION_DIR" -S "$BUILD_TREE" "/tmp/${2}.lst" \ + 2>"/tmp/${2}.err" 1>"/tmp/${2}.good" Log " done." Log " - checking for errors ..." - rm -f /tmp/${2}.missing + rm -f "/tmp/${2}.missing" awk '{if ($1 == "ERROR:") print " " $4}' \ - /tmp/${2}.err >> /tmp/${2}.missing - if [ -s /tmp/${2}.missing ] + "/tmp/${2}.err" >> "/tmp/${2}.missing" + if [ -s "/tmp/${2}.missing" ] then Log " - missing files:" - cat /tmp/${2}.missing | tee -a $LOGFILE + "/tmp/${2}.missing" >> "$LOGFILE" fi } ORIGINAL_COMMAND_LINE="$*" @@ -526,27 +523,27 @@ PLATFORM_SCRIPT_DIR="" XCOMM XCOMM Set system XCOMM - if [ $BUILDSYSTEM = "AIX" ]; + if [ "$BUILDSYSTEM" = "AIX" ]; then PLATFORM=aix PLATFORM_SCRIPT_DIR=ibm - elif [ $BUILDSYSTEM = "SunOS" ]; + elif [ "$BUILDSYSTEM" = "SunOS" ]; then PLATFORM=sun PLATFORM_SCRIPT_DIR=sun - elif [ $BUILDSYSTEM = "Linux" ]; + elif [ "$BUILDSYSTEM" = "Linux" ]; then PLATFORM="linux" PLATFORM_SCRIPT_DIR="linux" - elif [ $BUILDSYSTEM = "FreeBSD" ]; + elif [ "$BUILDSYSTEM" = "FreeBSD" ]; then PLATFORM="freebsd" PLATFORM_SCRIPT_DIR="freebsd" - elif [ $BUILDSYSTEM = "OpenBSD" ]; + elif [ "$BUILDSYSTEM" = "OpenBSD" ]; then PLATFORM="openbsd" PLATFORM_SCRIPT_DIR="openbsd" - elif [ $BUILDSYSTEM = "NetBSD" ]; + elif [ "$BUILDSYSTEM" = "NetBSD" ]; then PLATFORM="netbsd" PLATFORM_SCRIPT_DIR="netbsd" @@ -557,9 +554,9 @@ XCOMM if [ "$PLATFORM" = "aix" ]; then - USER=`/bin/whoami` + USER=$(/bin/whoami) else - USER=`/usr/bin/whoami` + USER=$(/usr/bin/whoami) fi if [ "$USER" != "root" ]; @@ -590,7 +587,6 @@ XCOMM RUN_SCRIPTS_ONLY="no" DATABASE_FILES="" BUILD_TREE="" - TAR_DIR="" LeaveLinks="no" REMOVE_LINKS="no" CLEAN_DAEMONS="yes" @@ -782,30 +778,29 @@ XCOMM echo "" - if [ -z "$BUILD_TREE" -a -z "$TAR_TREE" ] + if [ -z "$BUILD_TREE" ] && [ -z "$TAR_TREE" ] then USAGE exit 1 fi - if [ "$BUILD_TREE" != "" -a ! -d "$BUILD_TREE" ] + if [ "$BUILD_TREE" != "" ] && [ ! -d "$BUILD_TREE" ] then Log "Build tree does not exist." exit 1 fi - if [ "$TAR_TREE" != "" -a ! -d "$TAR_TREE" ] + if [ "$TAR_TREE" != "" ] && [ ! -d "$TAR_TREE" ] then Log "Tar tree does not exist." exit 1 fi - if [ "$DESTINATION_DIR" != "" -a ! -d "$DESTINATION_DIR" ] + if [ "$DESTINATION_DIR" != "" ] && [ ! -d "$DESTINATION_DIR" ] then Log "Creating $DESTINATION_DIR" - mkdir $DESTINATION_DIR - if [ $? -ne 0 ] + if ! mkdir "$DESTINATION_DIR" then Log "mkdir $DESTINATION_DIR failed" exit 1 @@ -823,11 +818,11 @@ XCOMM if [ $TARBALL = "yes" ]; then - set -- `/bin/date` + set -- "$(/bin/date)" DATE=$2_$3_$4_$6 fi - if [ -z "$BUILD_TREE" -a ${0##STAR/} = INSTALL.CDE ]; then + if [ -z "$BUILD_TREE" ] && [ "${0##STAR/}" = INSTALL.CDE ]; then typeset -u CDEPACKAGE typeset -u CDETARFILE typeset -u CDETARFILEZ @@ -919,7 +914,7 @@ XCOMM [ -z "$CONFIGURE_LOCATION" ] && CONFIGURE_LOCATION=CDE_CONFIGURATION_TOP [ -z "$LOGFILES_LOCATION" ] && LOGFILES_LOCATION=CDE_LOGFILES_TOP - if [ -L $INSTALL_LOCATION -a "$CONFIGURE_ONLY" != "yes" ] + if [ -L $INSTALL_LOCATION ] && [ "$CONFIGURE_ONLY" != "yes" ] then touch $INSTALL_LOCATION/foo >/dev/null 2>/dev/null if [ ! -f $INSTALL_LOCATION/foo ] @@ -937,7 +932,7 @@ XCOMM if [ -d $INSTALL_LOCATION ] then - if [ -x $INSTALL_LOCATION/bin -a ! -d $INSTALL_LOCATION/bin ] + if [ -x $INSTALL_LOCATION/bin ] && [ ! -d $INSTALL_LOCATION/bin ] then rm -f $INSTALL_LOCATION/bin fi @@ -978,22 +973,22 @@ XCOMM then Log "Load the Desktop from $BUILD_TREE" - cd $STARTING_DIR + cd "$STARTING_DIR" || exit 1 let j=1 - for i in `echo $DATABASE_FILES` + for i in $DATABASE_FILES do LoadFileSet "$j" "$i" let j=j+1 done else Log "Load the Desktop from $TAR_TREE" - compressed=$(awk '/COMPRESSED: /{print $2}' $TAR_TREE/$CDEPACKAGE) + compressed=$(awk '/COMPRESSED: /{print $2}' "$TAR_TREE/$CDEPACKAGE") if [ "$compressed" = "yes" ]; then - uncompress <$TAR_TREE/$CDETARFILEZ | tar xvf - $INSTALL_LOCATION + uncompress <"$TAR_TREE/$CDETARFILEZ" | tar xvf - $INSTALL_LOCATION else - tar -xvf $TAR_TREE/$CDETARFILE $INSTALL_LOCATION + tar -xvf "$TAR_TREE/$CDETARFILE" $INSTALL_LOCATION fi - DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/$CDEPACKAGE) + DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' "$TAR_TREE/$CDEPACKAGE") fi Log " " @@ -1009,7 +1004,7 @@ XCOMM MakeTarball fi - cd $STARTING_DIR + cd "$STARTING_DIR" || exit 1 if [ "$RUN_SCRIPTS" = "yes" ] then diff --git a/cde/admin/IntegTools/dbTools/linksLast b/cde/admin/IntegTools/dbTools/linksLast index d79e6bdd3..e01927c74 100755 --- a/cde/admin/IntegTools/dbTools/linksLast +++ b/cde/admin/IntegTools/dbTools/linksLast @@ -8,9 +8,9 @@ USAGE="Usage: $0 file.lst" case $# in - 0) echo $USAGE;; + 0) echo "$USAGE";; 1);; - *) echo $USAGE;; + *) echo "$USAGE";; esac awk ' @@ -20,4 +20,4 @@ END { if ( i > 0 ) for ( i in links) print links[i]; } -' $@ +' "$@" diff --git a/cde/admin/IntegTools/dbTools/uncomment b/cde/admin/IntegTools/dbTools/uncomment index 699120c40..4ca80e922 100755 --- a/cde/admin/IntegTools/dbTools/uncomment +++ b/cde/admin/IntegTools/dbTools/uncomment @@ -5,5 +5,5 @@ # and coalesce multiple blanks/tabs into a single blank # -cat $@ | egrep -v '^[ ]*#|^[ ]*$' | sed 's/[ ][ ]*/ /g'|\ +cat "$@" | grep -E -v '^[ ]*#|^[ ]*$' | sed 's/[ ][ ]*/ /g'|\ sed 's/ $//' diff --git a/cde/admin/IntegTools/post_install/build_udb_list b/cde/admin/IntegTools/post_install/build_udb_list index 35d6b83da..6af5c7164 100755 --- a/cde/admin/IntegTools/post_install/build_udb_list +++ b/cde/admin/IntegTools/post_install/build_udb_list @@ -1,4 +1,4 @@ #!/bin/ksh awk '{if ($1 == "install_target" && $3 != "") print $3}' \ - $2/databases/$1.udb >$1.list + "$2/databases/$1.udb" >"$1.list" diff --git a/cde/admin/IntegTools/post_install/configDemos.src b/cde/admin/IntegTools/post_install/configDemos.src index 7c183bf96..b0c700642 100755 --- a/cde/admin/IntegTools/post_install/configDemos.src +++ b/cde/admin/IntegTools/post_install/configDemos.src @@ -19,19 +19,19 @@ XCOMM # XCOMM ############################################ RemoveDemoFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -45,8 +45,8 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link while read SRC @@ -61,17 +61,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-DEMOS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configFonts.src b/cde/admin/IntegTools/post_install/configFonts.src index 0419454b8..7a8d7ee3b 100755 --- a/cde/admin/IntegTools/post_install/configFonts.src +++ b/cde/admin/IntegTools/post_install/configFonts.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveFontFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,18 +57,15 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-FONTS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configHelp.src b/cde/admin/IntegTools/post_install/configHelp.src index fb417a3a0..5cca6674d 100755 --- a/cde/admin/IntegTools/post_install/configHelp.src +++ b/cde/admin/IntegTools/post_install/configHelp.src @@ -13,19 +13,19 @@ XCOMM ####### RemoveHelpFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -39,11 +39,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -55,21 +55,18 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-HELP-C retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP XCOMM XCOMM set up symlinks that point into the $CDE_TOP tree XCOMM - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configHelpPrg.src b/cde/admin/IntegTools/post_install/configHelpPrg.src index bdfb3ca76..dbf416d5c 100755 --- a/cde/admin/IntegTools/post_install/configHelpPrg.src +++ b/cde/admin/IntegTools/post_install/configHelpPrg.src @@ -13,19 +13,19 @@ XCOMM ####### RemoveHelpFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -39,11 +39,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF1 @@ -55,17 +55,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-HELP retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configHelpRun.src b/cde/admin/IntegTools/post_install/configHelpRun.src index efc1de312..b53a4b510 100755 --- a/cde/admin/IntegTools/post_install/configHelpRun.src +++ b/cde/admin/IntegTools/post_install/configHelpRun.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveHelpRunFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-HELP-RUN retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configIcons.src b/cde/admin/IntegTools/post_install/configIcons.src index b3015909a..311b3ec3c 100755 --- a/cde/admin/IntegTools/post_install/configIcons.src +++ b/cde/admin/IntegTools/post_install/configIcons.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveIconFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-ICONS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configInc.src b/cde/admin/IntegTools/post_install/configInc.src index 5fcc63753..58175c4e6 100755 --- a/cde/admin/IntegTools/post_install/configInc.src +++ b/cde/admin/IntegTools/post_install/configInc.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveIncludeFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-INC retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configMan.src b/cde/admin/IntegTools/post_install/configMan.src index dd7be23ba..ed5bb0157 100755 --- a/cde/admin/IntegTools/post_install/configMan.src +++ b/cde/admin/IntegTools/post_install/configMan.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveManFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-DEMOS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configManDev.src b/cde/admin/IntegTools/post_install/configManDev.src index 985ba1d8d..0ccfea5a3 100755 --- a/cde/admin/IntegTools/post_install/configManDev.src +++ b/cde/admin/IntegTools/post_install/configManDev.src @@ -15,30 +15,30 @@ XCOMM ############################################ RemoveManDevFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - if [ -L $SRC -a -d $SRC ] + if [ -L "$SRC" ] && [ -d "$SRC" ] then - results=`ls $SRC` + results=$(find -name "$SRC") if [ ! -s "$SRC" ] then - rm -f $SRC + rm -f "$SRC" else continue fi else - rm -f $SRC + rm -f "$SRC" fi dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -52,11 +52,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -68,17 +68,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-MAN-DEV retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configMsgCat.src b/cde/admin/IntegTools/post_install/configMsgCat.src index e760148dc..96411103f 100755 --- a/cde/admin/IntegTools/post_install/configMsgCat.src +++ b/cde/admin/IntegTools/post_install/configMsgCat.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemoveMsgCatFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-MSG-C retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configPrg.src b/cde/admin/IntegTools/post_install/configPrg.src index 0cfb146cd..3877e43ed 100755 --- a/cde/admin/IntegTools/post_install/configPrg.src +++ b/cde/admin/IntegTools/post_install/configPrg.src @@ -15,19 +15,19 @@ XCOMM ############################################ RemovePrgFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -41,11 +41,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -57,17 +57,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ########################################################################## XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-PRG retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/configShlibs.src b/cde/admin/IntegTools/post_install/configShlibs.src index a03143845..db4676617 100755 --- a/cde/admin/IntegTools/post_install/configShlibs.src +++ b/cde/admin/IntegTools/post_install/configShlibs.src @@ -14,19 +14,19 @@ XCOMM ####### XCOMM ############################################ RemoveShlibFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -40,11 +40,11 @@ VerifyInstalledFiles() { echo "Status mode owner group filename" echo "-----------------------------------------" -XCOMM exists correct correct correct /usr/dt/foo1 -XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 +XCOMM exists correct correct correct /usr/dt/foo1 +XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "verify.func" done <<-EOF @@ -56,17 +56,14 @@ XCOMM exists the link is correct /usr/dt/link XCOMM ######################################################################### XCOMM -XCOMM Main Body +XCOMM Main Body XCOMM XCOMM ######################################################################### -PRODUCT=CDE -FILESET=CDE-SHLIBS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "deconfigure" ] then diff --git a/cde/admin/IntegTools/post_install/linux/configMin.src b/cde/admin/IntegTools/post_install/linux/configMin.src index cda5678be..d67a9d882 100755 --- a/cde/admin/IntegTools/post_install/linux/configMin.src +++ b/cde/admin/IntegTools/post_install/linux/configMin.src @@ -7,9 +7,6 @@ XCOMM @(#) $TOG: configMin.src /main/1 1998/03/11 16:18:12 mgreess $ XCOMM ####### #define HASH # -PRODUCT=CDE -FILESET=CDE-MIN -DO_CONFIGURATION="" retval=0 FixEtcServices() @@ -72,19 +69,19 @@ TMPFILE=/tmp/services RemoveMinFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -102,7 +99,7 @@ XCOMM exists correct correct correct /usr/dt/foo1 XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "../verify.func" done <<-EOF @@ -118,7 +115,7 @@ XCOMM Main Body XCOMM XCOMM ############################################################### - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "configure" ] then diff --git a/cde/admin/IntegTools/post_install/linux/configRun.src b/cde/admin/IntegTools/post_install/linux/configRun.src index 02b64e8ca..64d7bf077 100755 --- a/cde/admin/IntegTools/post_install/linux/configRun.src +++ b/cde/admin/IntegTools/post_install/linux/configRun.src @@ -9,9 +9,6 @@ XCOMM ####### #define HASH # #define STAR * -PRODUCT=CDE -FILESET=CDE-RUN -DO_CONFIGURATION="" retval=0 CreateAppConfigDirectory() @@ -21,41 +18,42 @@ CreateAppConfigDirectory() HASH all of its subdirectories HASH - cd $DT_CONFIG_TOP - if [ ! -d $APPCONFIG ] + cd "$DT_CONFIG_TOP" || exit + if [ ! -d "$APPCONFIG" ] then - mkdir $APPCONFIG + mkdir "$APPCONFIG" fi - cd $APPCONFIG + cd "$APPCONFIG" || exit for i in $APPCONFIG_DIRS do - if [ ! -d $i ] + ( + if [ ! -d "$i" ] then - mkdir $i + mkdir "$i" fi - cd $i + cd "$i" || exit HASH HASH for each locale HASH for j in $DT_TOP/$APPCONFIG/$i/STAR do - if [ ! -d `basename $j` ] + if [ ! -d "$(basename "$j")" ] then - mkdir `basename $j` + mkdir "$(basename "$j")" fi done - cd .. + ) done } doDttermTerminfo() { - if [ -f $DT_TOP/config/dtterm.ti ] + if [ -f "$DT_TOP/config/dtterm.ti" ] then - tic $DT_TOP/config/dtterm.ti + tic "$DT_TOP/config/dtterm.ti" if [ -f /usr/share/lib/terminfo/d/dtterm ] then chown bin /usr/share/lib/terminfo/d/dtterm @@ -69,7 +67,7 @@ doDttermTerminfo() chmod 644 /usr/share/terminfo/d/dtterm fi fi - if [ ! -f /usr/share/lib/terminfo/d/dtterm -a ! -f /usr/share/terminfo/d/dtterm ] + if [ ! -f /usr/share/lib/terminfo/d/dtterm ] && [ ! -f /usr/share/terminfo/d/dtterm ] then echo "Unable to compile $DT_TOP/config/dtterm.ti" fi @@ -80,19 +78,19 @@ doDttermTerminfo() RemoveRunFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -122,7 +120,7 @@ XCOMM exists the link is correct /usr/dt/link PrintUsage() { - echo "Usage:" $0 "[OPERATION]" + echo "Usage:" "$0" "[OPERATION]" echo "" echo "Operations:" echo " -e configure" @@ -140,22 +138,16 @@ XCOMM Main Body XCOMM XCOMM ########################################################################## -PRODUCT=CDE -FILESET=CDE-RUN - DT_TOP=CDE_INSTALLATION_TOP DT_CONFIG_TOP=CDE_CONFIGURATION_TOP DT_TEMP_TOP=CDE_LOGFILES_TOP -ROOT=/ retval=0 APPCONFIG=appconfig APPCONFIG_DIRS="appmanager help icons types" -PRINTERS="" -DEFAULT_PRINTER="DtPrint" - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "usage" ] then @@ -175,12 +167,12 @@ DEFAULT_PRINTER="DtPrint" mkdir -p $DT_TEMP_TOP/$APPCONFIG/appmanager fi - cd $DT_TEMP_TOP + cd "$DT_TEMP_TOP" || exit mv $APPCONFIG/appmanager .hidden-appmanager - chmod -R 755 * + chmod -R 755 -- * chmod 755 .hidden-appmanager - chown -R bin * - chgrp -R bin * + chown -R bin -- * + chgrp -R bin -- * mv .hidden-appmanager $APPCONFIG/appmanager chmod 755 . chown bin . @@ -209,14 +201,14 @@ DEFAULT_PRINTER="DtPrint" HASH Configure Xsession.d HASH - cd $DT_CONFIG_TOP/config + cd $DT_CONFIG_TOP/config || exit if [ ! -d Xsession.d ] then mkdir Xsession.d fi - cd $DT_CONFIG_TOP - chmod -R 755 * + cd $DT_CONFIG_TOP || exit + chmod -R 755 -- * doDttermTerminfo diff --git a/cde/admin/IntegTools/post_install/linux/configShlibs.src b/cde/admin/IntegTools/post_install/linux/configShlibs.src index cf7ab5879..a03d5b218 100755 --- a/cde/admin/IntegTools/post_install/linux/configShlibs.src +++ b/cde/admin/IntegTools/post_install/linux/configShlibs.src @@ -6,19 +6,19 @@ XCOMM $TOG: configShlibs.src /main/1 1998/03/11 16:18:33 mgreess $ XCOMM ############################################ RemoveShlibFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -36,7 +36,7 @@ XCOMM exists correct correct correct /usr/dt/foo1 XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "../verify.func" done <<-EOF @@ -54,14 +54,14 @@ XCOMM XCOMM creates links in the install tree libtt.so -> libtt.so.1 XCOMM - cd CDE_INSTALLATION_TOP/lib + cd CDE_INSTALLATION_TOP/lib || exit - for lib in `/bin/ls *.so.*` + for lib in $(/bin/ls lib*.so.*) do - link=`echo $lib | cut -d. -f1,2` + link=$(echo "$lib" | cut -d. -f1,2) - rm -f $link - ln -s $lib $link + rm -f "$link" + ln -s "$lib" "$link" done @@ -73,11 +73,8 @@ XCOMM Main Body XCOMM XCOMM ######################################################################### -PRODUCT=CDE -FILESET=CDE-SHLIBS retval=0 CDE_TOP=CDE_INSTALLATION_TOP -CDE_CONF_TOP=CDE_CONFIGURATION_TOP HandleOption $* diff --git a/cde/admin/IntegTools/post_install/linux/configTT.src b/cde/admin/IntegTools/post_install/linux/configTT.src index a1a9f64f2..4f1ee2f2c 100755 --- a/cde/admin/IntegTools/post_install/linux/configTT.src +++ b/cde/admin/IntegTools/post_install/linux/configTT.src @@ -11,26 +11,23 @@ XCOMM XCOMM ####### #define HASH # -PRODUCT=CDE -FILESET=CDE-TT -DO_CONFIGURATION="" retval=0 RemoveTTFiles() { - while read SRC + while read -r SRC do if [ "$SRC" != "" ] then - rm -f $SRC + rm -f "$SRC" dirname=${SRC%/STAR} - if [ -d $dirname ] + if [ -d "$dirname" ] then - cd $dirname + cd "$dirname" || exit while [ "$dirname" != "$CDE_TOP" ] do cd .. - rmdir ${dirname##STAR/} >/dev/null 2>/dev/null + rmdir "${dirname##STAR/}" >/dev/null 2>/dev/null dirname=${dirname%/STAR} done fi @@ -48,7 +45,7 @@ XCOMM exists correct correct correct /usr/dt/foo1 XCOMM MISSING WRONG WRONG WRONG /usr/dt/foo2 XCOMM exists the link is correct /usr/dt/link - while read SRC + while read -r SRC do #include "../verify.func" done <<-EOF @@ -64,7 +61,7 @@ XCOMM Main Body XCOMM XCOMM ###################################################################### - HandleOption $* + HandleOption "$*" if [ "$OPERATION" = "configure" ] then diff --git a/cde/admin/IntegTools/post_install/size.func b/cde/admin/IntegTools/post_install/size.func deleted file mode 100644 index 608a6e8d5..000000000 --- a/cde/admin/IntegTools/post_install/size.func +++ /dev/null @@ -1,14 +0,0 @@ - if [ "$SRC" != "" ] - then - set -A tokens $SRC - if [ "${tokens[3]}" = "file" ] - then - if [ -f ${tokens[0]} ] - then - filesize=`ls -l ${tokens[0]} | awk '{print $5}'` - echo "$filesize\t\t\c" - echo "${tokens[0]}" - let total=total+filesize - fi - fi - fi diff --git a/cde/admin/IntegTools/post_install/verify.func b/cde/admin/IntegTools/post_install/verify.func index 886d472e4..ad25ff44b 100644 --- a/cde/admin/IntegTools/post_install/verify.func +++ b/cde/admin/IntegTools/post_install/verify.func @@ -1,9 +1,9 @@ if [ "$SRC" != "" ] then - set -A tokens $SRC + set -A tokens "$SRC" if [ "${tokens[3]}" = "file" ] then - if [ -f ${tokens[0]} ] + if [ -f "${tokens[0]}" ] then printf "exists " else @@ -13,7 +13,7 @@ fi elif [ "${tokens[3]}" = "sym_link" ] then - if [ -L ${tokens[0]} ] + if [ -L "${tokens[0]}" ] then printf "exists " else @@ -26,9 +26,9 @@ if [ "${tokens[3]}" = "file" ] then touch /tmp/config-test - chmod ${tokens[1]} /tmp/config-test - tmpperms=`ls -l /tmp/config-test | awk '{print $1}'` - realperms=`ls -l ${tokens[0]} | awk '{print $1}'` + chmod "${tokens[1]}" /tmp/config-test + tmpperms=$(ls -l /tmp/config-test | awk '{print $1}') + realperms=$(ls -l "${tokens[0]}" | awk '{print $1}') if [ "$tmpperms" = "$realperms" ] then @@ -37,7 +37,7 @@ printf " WRONG " fi - owner=`ls -l ${tokens[0]} | awk '{print $3}'` + owner=$(ls -l "${tokens[0]}" | awk '{print $3}') if [ "$owner" = "${tokens[4]}" ] then @@ -46,7 +46,7 @@ printf " WRONG " fi - group=`ls -l ${tokens[0]} | awk '{print $4}'` + group=$(ls -l "${tokens[0]}" | awk '{print $4}') if [ "$group" = "${tokens[5]}" ] then @@ -56,7 +56,7 @@ fi elif [ "${tokens[3]}" = "sym_link" ] then - linkto=`ls -l ${tokens[0]} | awk '{print $11}'` + linkto=$(ls -l "${tokens[0]}" | awk '{print $11}') if [ "${tokens[2]}" = "$linkto" ] then printf " the link is correct " diff --git a/cde/config/cf/Amoeba.cf b/cde/config/cf/Amoeba.cf deleted file mode 100644 index 3a20c2ad8..000000000 --- a/cde/config/cf/Amoeba.cf +++ /dev/null @@ -1,430 +0,0 @@ -XCOMM platform: $XConsortium: Amoeba.cf /main/12 1996/09/28 16:04:48 rws $ -XCOMM platform: $XFree86: xc/config/cf/Amoeba.cf,v 3.6 1995/01/28 15:40:08 dawes Exp $ - -/* The presence of this configuration file in the X distribution - * does not imply full support for the system it describes. - * Additional patches from The XFree86 Project, Inc. will be required to - * compile the X distribution on Amoeba. According to them, these patches - * will also be made available at the regular Amoeba ftp site - * ftp.am.cs.vu.nl. - */ - -/* - * Configuration file for Amoeba 5.2 - */ - -#ifndef OSName -#define OSName Amoeba 5.2 -#endif -XCOMM operating system: OSName -#ifndef OSMajorVersion -#define OSMajorVersion 5 -#endif -#ifndef OSMinorVersion -#define OSMinorVersion 2 -#endif -#ifndef OSTeenyVersion -#define OSTeenyVersion 0 -#endif -#ifndef OSVendor -#define OSVendor Vrije Universiteit -#endif - -#define AmoebaArchitecture YES - -/* Configuration defaults */ -#ifndef AmoebaTop -#define AmoebaTop __AM_TOP__ -#endif -#ifndef AmoebaBin -#define AmoebaBin $(ATOP)/bin.sun4 -#endif -#ifndef AmoebaConf -#define AmoebaConf __AM_CONF__ -#endif - -#define HasNdbm YES -#define NeedSdbm YES -#define HasShm NO -#define HasSecureRPC NO -#define SetTtyGroup NO -#define HasPutenv YES -#define HasSockets NO -#define HasStreams NO - -#if defined(Sun3Architecture) || defined(SparcArchitecture) -#define XsunAmoebaServer YES -#define XsunAmoebaMonoServer YES -#endif - -#define BuildFonts NO -#define BuildFontServer NO -#define BuildPexExt NO -#define BuildXIE NO - -#define YaccCmd byacc -#define TermcapLibrary /* in libajax */ -#define LexLib /* not needed */ - -#define PexCCOptions DefaultCCOptions -#define ServerOSDefines XFree86ServerOSDefines - -#define UsrLibDir $(DESTDIR)/profile/module/x11/lib -#define LibDir $(DESTDIR)/profile/module/x11/lib -#define ManDirectoryRoot $(DESTDIR)/profile/module/x11/man -#define BinDir $(DESTDIR)/profile/module/x11/bin -#define IncRoot $(DESTDIR)/profile/module/x11/include -#define FontDir $(DESTDIR)/profile/module/x11/fonts/$(ARCH) -#define DefaultRGBDatabase $(DESTDIR)/profile/module/x11/lib/rgb/$(ARCH)/rgb - -#define ManSuffix 1 -#define ManPath ManDirectoryRoot -#define XmanLocalSearchPath ManDirectoryRoot - -#define DefaultUserPath :/bin:$(BINDIR) -#define DefaultSystemPath /bin:$(BINDIR): - -#define StandardIncludes -I$(ATOP)/src/h \ - -I$(ATOP)/src/h/posix \ - -I$(ATOP)/src/h/posix/machdep/$(ARCH) \ - -I$(ATOP)/src/h/machdep/arch/$(ARCH) \ - -I$(ATOP)/src/h/toolset/$(TOOLSET) - -#define Malloc0ReturnsNull YES -#define ServerInstallFlags -s 32 -#define FontDefines -DFONT_SNF -#define ConnectionFlags -DAMTCPCONN -DAMRPCCONN -#define ServerXdmcpDefines /* no -DXDMCP */ -#define UseRgbTxt YES -#define NdbmDefines -DSDBM -DNDBM -I$(XINCLUDESRC) -#define DBMLibrary /* $(LIBSRC)/sdbm/libsdbm.a */ - -#if defined(i386Architecture) -#ifndef AckToolset -#define AckToolset YES -#define ExtraFPLoadFlags -fp -#endif -#define XF86MonoServer YES -#endif - -#if defined(Sun3Architecture) -#ifndef AckToolset -#define AckToolset YES -#endif -#endif - -#if AckToolset -#define CcCmd ack -#define ServerCcCmd ack -#define LdCmd ack -#define AckArchOption -mam_$(ARCH) -#define DefaultCCOptions AckArchOption -#define LibraryCCOptions AckArchOption -#define LdCombineFlags -Rled-r -c.out -#define ArCmd aal clrv -#define RanlibCmd /bin/true -#define AsCmd AmoebaConf/$(ARCH).$(TOOLSET)/toolset/do_as AckArchOption -#define AsIncl -I$(ATOP)/src/h/machdep/arch/$(ARCH) -#define AsmDefines -DACK_ASSEMBLER -#define LdPreLib /**/ -#define LdPostLib /**/ -#endif - -#if defined(SparcArchitecture) -#define AllocateLocalDefines -DINCLUDE_ALLOCA_H - -#define CcCmd cc -#define ServerCcCmd cc -#define LdCmd AmoebaConf/$(ARCH).$(TOOLSET)/toolset/do_gld -#define DefaultCCOptions -sun4 -#define LibraryCCOptions -sun4 -#define AmoebaCompilerDefs -Usun -#define ServerExtraDefines AllocateLocalDefines -#define LdPostLib /**/ -#endif - -#ifndef AmoebaCompilerDefs -#define AmoebaCompilerDefs /**/ -#endif - -#define CommonAmoebaDefines -DAMOEBA -D$(ARCH) AmoebaCompilerDefs -#define StandardDefines CommonAmoebaDefines -#define StandardCppDefines StandardDefines - -#ifndef ExtraFPLoadFlags -#define ExtraFPLoadFlags -#endif -#define MathLibrary $(ALIB)/math/libmath.a -#define OSLibraries $(ALIB)/ajax/libajax.a \ - $(ALIB)/amoeba/libamoeba.a \ - MathLibrary \ - ExtraFPLoadFlags -#define ServerExtraSysLibs $(CBRT) OSLibraries -#define ExtraLoadFlags OSLibraries - -ATOP = AmoebaTop -ALIB = AmoebaConf/$(ARCH).$(TOOLSET)/lib -#if AckToolset -/* The ACK toolset already links in the appropriate head.o by default */ -HEAD = -#else -HEAD = $(ALIB)/head/head.o -#endif - -ABIN = AmoebaBin -AINSTALL = /bin/sh $(CONFIGSRC)/util/aminstall.sh $(ABIN) -AINSTALLFLAGS = -TOB = /bin/sh $(CONFIGSRC)/util/aminstall.sh $(ABIN) -MKXDIRHIER = /bin/sh $(CONFIGSRC)/util/ammkdirhier.sh $(ABIN) - -/* Make wizardy: */ -COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c -LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) - -#if defined(i386Architecture) -ARCH = i80386 -TOOLSET = ack -ALDFLAGS = /* -mam_i80386 now in CCopts */ -.c -Rcv-s32 - -#include -#endif - -#if defined(Sun3Architecture) -ARCH = mc68000 -TOOLSET = ack -ALDFLAGS = -.c -Rcv-s32 -#endif - -#if defined(SparcArchitecture) -ARCH = sparc -TOOLSET = sun -SPARCLIBDIR = AmoebaBin/gnu/sparc -ALDFLAGS = -mam_sparc -n -Ttext 40000 -Bstatic -e start -L$(SPARCLIBDIR) -#endif - -#define BootstrapCFlags -DAMOEBA -DCROSS_$(ARCH) -DCROSS_COMPILE - -/* - * The rest of this files consists of rules to allow cross-compilation - * and installation of binaries and data files from the Unix host to - * the Amoeba file system. - */ - -/* #ifdef CROSS_COMPILING */ -#define CrossCompiling YES - -#define HostLinkRule(target, flags, src, libs) cc -o target src - -#define LinkRule(program,options,objects,libraries) \ -$(LD) $(ALDFLAGS) $(HEAD) -o program options objects libraries $(EXTRA_LOAD_FLAGS) - -/* ComplexHostProgramTarget - Compile a program such that we can run - * it on this host, i.e., don't use the default cross compiler. - */ -#ifndef ComplexHostProgramTarget -#define ComplexHostProgramTarget(program) @@\ - CC=cc @@\ - STD_INCLUDES= @@\ - CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) @@\ -EXTRA_LOAD_FLAGS= @@\ - PROGRAM = program @@\ - @@\ -AllTarget(program) @@\ - @@\ -program: $(OBJS) $(DEPLIBS) @@\ - RemoveTargetProgram($@) @@\ - HostLinkRule($@,$(_NOOP_),$(OBJS),$(DEPLIBS) $(LOCAL_LIBRARIES)) @@\ - @@\ -DependTarget() @@\ - @@\ -LintTarget() @@\ - @@\ -clean:: @@\ - RemoveFile(ProgramTargetName(program)) -#endif /* ComplexHostProgramTarget */ - -#ifndef SimpleHostProgramTarget -#define SimpleHostProgramTarget(program) @@\ - OBJS = program.o @@\ - SRCS = program.c @@\ - @@\ -ComplexHostProgramTarget(program) -#endif /* SimpleHostProgramTarget */ - - -#ifndef Concat -#if (__STDC__ && !defined(UnixCpp)) || defined(AnsiCpp) -#define Concat(a,b)a##b -#else -#define Concat(a,b)a/**/b -#endif -#endif - -/* - * LintLibReferences - variables for lint libraries - */ -#ifndef LintLibReferences -#define LintLibReferences(varname,libname,libsource) @@\ -Concat(LINT,varname) = Concat(libsource/llib-,libname.ln) -#endif - -/* - * UnsharedLibReferences - variables for unshared libraries - */ -#ifndef UnsharedLibReferences -#define UnsharedLibReferences(varname,libname,libsource) @@\ -Concat3(DEP,varname,LIB) = Concat($(BUILDLIBDIR)/lib,libname.a) @@\ - Concat(varname,LIB) = Concat($(BUILDLIBDIR)/lib,libname.a) @@\ -LintLibReferences(varname,libname,libsource) -#endif - -#ifndef InstallLibrary -#define InstallLibrary(libname,dest) @@\ -install:: Concat(lib,libname.a) @@\ - @echo '** TODO: Install Library ' Concat(lib,libname.a) -#endif /* InstallLibrary */ - -#ifndef MergeIntoInstalledLibrary -#define MergeIntoInstalledLibrary(tolib,fromlib) @@\ -install:: fromlib @@\ - @echo '** TODO: merge ' fromlib into tolib -#endif /* MergeIntoInstalledLibrary */ - -#ifndef InstallLibraryAlias -#define InstallLibraryAlias(libname,alias,dest) @@\ -install:: @@\ - @echo '** TODO: Install lib alias ' libname alias dest -#endif /* InstallLibraryAlias */ - -#ifndef InstallLintLibrary -#define InstallLintLibrary(libname,dest) @@\ -install.ln:: Concat(llib-l,libname.ln) @@\ - @echo '** TODO: Install lintlib ' Concat(llib-l,libname.ln) -#endif /* InstallLintLibrary */ - -#ifndef InstallManPageLong -#define InstallManPageLong(file,destdir,dest) @@\ -install.man:: file.man @@\ - @echo '** TODO: Install man page ' file.man -#endif /* InstallManPageLong */ - -#ifndef InstallGenManPageLong -#define InstallGenManPageLong(file,destdir,dest,suffix) @@\ -install.man:: file.man @@\ - @echo '** TODO: Install man page ' file.man -#endif /* InstallGenManPageLong */ - -#ifndef InstallManPageAliases -#define InstallManPageAliases(file,destdir,aliases) @@\ -install.man:: @@\ - @(TMP=/tmp/tmp.$$$$; \ @@\ - $(RM) $${TMP}; \ @@\ - echo .so `basename destdir`/file.$(MANSUFFIX) > $${TMP}; \ @@\ - for i in aliases; do (set -x; \ @@\ - $(TOB) $${TMP} $(DESTDIR)destdir/$$i.$(MANSUFFIX)); \ @@\ - done; \ @@\ - $(RM) $${TMP}) -#endif /* InstallManPageAliases */ - -#ifndef InstallGenManPageAliases -#define InstallGenManPageAliases(file,destdir,suffix,aliases) @@\ -install.man:: @@\ - @(TMP=/tmp/tmp.$$$$; \ @@\ - $(RM) $${TMP}; \ @@\ - echo .so `basename destdir`/file.suffix > $${TMP}; \ @@\ - for i in aliases; do (set -x; \ @@\ - $(TOB) $${TMP} $(DESTDIR)destdir/$$i.suffix); \ @@\ - done; \ @@\ - $(RM) $${TMP}) -#endif /* InstallGenManPageAliases */ - -#ifndef InstallNamedNonExec -#define InstallNamedNonExec(srcname,dstname,dest) @@\ -install:: srcname @@\ - $(MKXDIRHIER) $(DESTDIR)dest @@\ - $(TOB) srcname $(DESTDIR)dest/dstname -#endif /* InstallNamedNonExec */ - -#ifndef InstallNonExecFile -#define InstallNonExecFile(file,dest) @@\ -install:: file @@\ - $(MKXDIRHIER) dest @@\ - $(TOB) file dest/file -#endif /* InstallNonExecFile */ - -#ifndef InstallNonExec -#define InstallNonExec(file,dest) @@\ -install:: file @@\ - $(TOB) file dest/file -#endif /* InstallNonExec */ - -#ifndef InstallProgramWithFlags -#define InstallProgramWithFlags(program,dest,flags) @@\ -install:: program @@\ - $(MKXDIRHIER) dest/program @@\ - $(AINSTALL) $(AINSTALLFLAGS) program dest/program/pd.$(ARCH) -#endif /* InstallProgramWithFlags */ - -#ifndef InstallScript -#define InstallScript(program,dest) @@\ -install:: program.script @@\ - $(TOB) program.script dest/program -#endif /* InstallScript */ - -#ifndef InstallNamedScript -#define InstallNamedScript(srcname,dstname,dest) @@\ -install:: srcname @@\ - $(TOB) srcname dest/dstname -#endif /* InstallNamedScript */ - -#ifndef InstallNamedProg -#define InstallNamedProg(srcname,dstname,dest) @@\ -install:: srcname @@\ - $(MKXDIRHIER) $(DESTDIR)dest/dstname @@\ - $(AINSTALL) $(AINSTALLFLAGS) srcname $(DESTDIR)dest/dstname/pd.$(ARCH) -#endif /* InstallNamedProg */ - -#ifndef InstallMultipleDestFlags -#define InstallMultipleDestFlags(step,list,dest,flags) @@\ -step:: list @@\ - $(MKXDIRHIER) $(DESTDIR)dest @@\ - @case '${MFLAGS}' in *[i]*) set +e;; esac; \ @@\ - for i in list; do \ @@\ - (set -x; $(TOB) $$i dest/$$i); \ @@\ - done -#endif /* InstallMultipleDestFlags */ - -#ifndef InstallMultipleProg -#define InstallMultipleProg(list,dest) @@\ -install:: list @@\ - @case '${MFLAGS}' in *[i]*) set +e;; esac; \ @@\ - for i in list; do \ @@\ - (set -x; \ @@\ - $(MKXDIRHIER) $(DESTDIR)dest/$$i; \ @@\ - $(AINSTALL) $(AINSTALLFLAGS) $$i dest/$$i/pd.$(ARCH));\ @@\ - done -#endif /* InstallMultipleProg */ - -#ifndef InstallAppDefaults -#if InstallAppDefFiles -#define InstallAppDefaults(class) @@\ -install:: class.ad @@\ - $(MKXDIRHIER) $(XAPPLOADDIR) @@\ - $(TOB) class.ad $(DESTDIR)$(XAPPLOADDIR)/class -#else -#define InstallAppDefaults(class) -#endif /* InstallAppDefFiles */ -#endif /* InstallAppDefaults */ - -#ifndef InstallAppDefaultsLong -#if InstallAppDefFiles -#define InstallAppDefaultsLong(file,class) @@\ -install:: file.ad @@\ - $(MKXDIRHIER) $(DESTDIR)$(XAPPLOADDIR) @@\ - $(TOB) file.ad $(DESTDIR)$(XAPPLOADDIR)/class -#else -#define InstallAppDefaultsLong(file,class) -#endif /* InstallAppDefFiles */ -#endif /* InstallAppDefaultsLong */ - -/* #endif CROSS_COMPILE */ diff --git a/cde/config/cf/Imake.cf b/cde/config/cf/Imake.cf index 4aa0814b0..2891dae8e 100644 --- a/cde/config/cf/Imake.cf +++ b/cde/config/cf/Imake.cf @@ -197,29 +197,6 @@ XCOMM $TOG: Imake.cf /main/30 1998/04/28 13:55:25 barstow $ # endif #endif /* __FreeBSD__ */ -#ifdef AMOEBA - /* Should be before the 'sun' entry because we may be cross-compiling */ -# define MacroIncludeFile -# define MacroFile Amoeba.cf -# if defined(i80386) || defined(__i80386__) -# undef i80386 -# define i386Architecture -# else -# if defined(mc68000) || defined(__mc68000__) -# undef mc68000 -# define Sun3Architecture -# define SunArchitecture -# else -# if defined(sparc) || defined(__sparc__) -# undef sparc -# define SparcArchitecture -# define SunArchitecture -# endif -# endif -# undef sun -# endif -#endif /* AMOEBA */ - #ifdef sun # define MacroIncludeFile # define MacroFile sun.cf @@ -469,12 +446,6 @@ XCOMM $TOG: Imake.cf /main/30 1998/04/28 13:55:25 barstow $ # undef SVR4 #endif /* Oki */ -#ifdef WIN32 -# define MacroIncludeFile -# define MacroFile Win32.cf -# define Win32Architecture -#endif /* WIN32 */ - #ifdef linux # define MacroIncludeFile # define MacroFile linux.cf diff --git a/cde/config/cf/Imakefile b/cde/config/cf/Imakefile index 8872406fd..fc976fc49 100644 --- a/cde/config/cf/Imakefile +++ b/cde/config/cf/Imakefile @@ -15,7 +15,6 @@ site.def RULEFILES = \ Imake.rules \ Motif.rules \ -Win32.rules \ X11.rules \ bsdLib.rules \ cde.rules \ @@ -55,13 +54,11 @@ xf86.tmpl CFFILES = \ Imake.cf \ -Amoeba.cf \ DGUX.cf \ FreeBSD.cf \ Mips.cf \ NetBSD.cf \ Oki.cf \ -Win32.cf \ bsd.cf \ convex.cf \ cray.cf \ diff --git a/cde/config/cf/Win32.cf b/cde/config/cf/Win32.cf deleted file mode 100644 index 065e026c0..000000000 --- a/cde/config/cf/Win32.cf +++ /dev/null @@ -1,133 +0,0 @@ -XCOMM platform: $TOG: Win32.cf /main/57 1997/12/04 11:03:33 kaleb $ - -#ifndef OSName -#define OSName DefaultOSName -#endif -#ifndef OSMajorVersion -#define OSMajorVersion DefaultOSMajorVersion -#endif -#ifndef OSMinorVersion -#define OSMinorVersion DefaultOSMinorVersion -#endif -#ifndef OSTeenyVersion -#define OSTeenyVersion DefaultOSTeenyVersion -#endif -XCOMM operating system: OSName OSMajorVersion./**/OSMinorVersion - -#ifndef CompilerMajorVersion -/* 0 == NT 3.1 Win32 SDK, 2 == MSVC++ 2, 4 == MSVC 4 */ -#define CompilerMajorVersion 4 -#endif - -#define BootstrapCFlags -DWIN32 -#ifdef _M_IX86 -#define CpuDefines -D_X86_ -#endif -/* brain-damaged windows headers will not compile with -Za */ -#define StandardDefines -DWIN32 -DWIN32_LEAN_AND_MEAN -D_DLL -D_MT -D__STDC__ CpuDefines -#if CompilerMajorVersion < 4 -#define DefaultCCOptions -nologo -batch -G4 -W2 -#else -#define DefaultCCOptions -nologo -G4 -W2 -#endif -#if CompilerMajorVersion < 4 -#define DebuggableCDebugFlags -Zi -#else -#define DebuggableCDebugFlags -Zi -Od -#endif -#define ThreadedX YES -#define HasThreadSafeAPI NO -#define CpCmd copy -#define LnCmd copy -#define MvCmd ren -#define RmCmd del -#ifndef RmTreeCmd -XCOMM choices here include: -XCOMM o `del /q /s` and live with pressing the "any" key -XCOMM o `deltree, copied from MS-DOS 5 -XCOMM o `rm -rfx` from the SDK Subscription (MSTOOLS in your Path) -XCOMM o `rm -rf` from the GNU file utilities -XCOMM We're using the GNU file utilities -#define RmTreeCmd rm -rf -#endif -#define CcCmd cl -#define HasCplusplus YES -#define CplusplusCmd cl -#if CompilerMajorVersion < 4 -#define PreProcessCmd CcCmd -nologo -batch -EP -#define CppCmd CcCmd -nologo -batch -E -#else -#define PreProcessCmd CcCmd -nologo -EP -#define CppCmd CcCmd -nologo -E -#endif -#define PatheticCpp YES -#define ConstructMFLAGS YES -#if (CompilerMajorVersion == 0) -#define ArCmdBase lib32 -#else -#define ArCmdBase lib -#endif -#define ArCmd ArCmdBase -#define CplusplusCmd cl -#define MkdirHierCmd $(CONFIGSRC:/=\)\util\mkdirhier -#define InstallCmd copy -#define InstPgmFlags /**/ -#define InstBinFlags /**/ -#define InstUidFlags /**/ -#define InstLibFlags /**/ -#define InstIncFlags /**/ -#define InstManFlags /**/ -#define InstDatFlags /**/ -#define InstallFlags /**/ -#if (CompilerMajorVersion == 0) -#define ExtraLibraries crtdll.lib kernel32.lib wsock32.lib -#elif (CompilerMajorVersion < 4) -#define ExtraLibraries msvcrt.lib kernel32.lib wsock32.lib -#else -#define ExtraLibraries msvcrt.lib kernel32.lib wsock32.lib -link -nodefaultlib:libc -#endif -#define MakeCmd nmake -nologo -#if (CompilerMajorVersion == 0) -#define LdCmd link32 -#else -#define LdCmd link -#endif -#define MathLibrary -#define HasSymLinks NO -#define HasVarDirectory NO -#define HasPutenv YES -#define Osuf obj -#ifndef CCsuf -#define CCsuf cxx -#endif -#define BuildServer NO -#define ConnectionFlags -DTCPCONN - -/* override as necessary in site.def/host.def */ -#ifndef StdIncDir -#define StdIncDir C:/MSDEVSTD/INCLUDE -#endif -#define LdPreLib /**/ -#define LdPostLib /**/ -#ifndef UseInstalled -#define ImakeCmd $(IMAKESRC:/=\)\imake -#define DependCmd $(DEPENDSRC:/=\)\makedepend -#endif -#define DependFlags -D_WIN32 -#define FilesToClean *.bak *.obj *.lib make.log -#define ShLibDir $(BINDIR) - -#define XFileSearchPathBase Concat4($(LIBDIR)/;L/;T/;N;C,;S:$(LIBDIR)/;l/;T/;N;C,;S:$(LIBDIR)/;T/;N;C,;S:$(LIBDIR)/;L/;T/;N;S:$(LIBDIR)/;l/;T/;N;S:$(LIBDIR)/;T/;N;S) - -#define XawI18nDefines -DHAS_WCHAR_H -#define UseRgbTxt YES -#define HasCbrt NO -#define HasFfs NO -#define HasXdmAuth NO - -/* the following components haven't been ported yet */ -#define BuildLBX NO -#define BuildXprint NO -#define XprtServer NO - -#include diff --git a/cde/config/cf/Win32.rules b/cde/config/cf/Win32.rules deleted file mode 100644 index 93b91ed5f..000000000 --- a/cde/config/cf/Win32.rules +++ /dev/null @@ -1,525 +0,0 @@ -XCOMM platform: $TOG: Win32.rules /main/51 1997/12/02 14:48:29 kaleb $ - -#define HasSharedLibraries YES -#define NeedLibInsideFlag YES -#define SharedLibXaw NO -#define SharedLibXmu NO -#define SharedLibXt NO -#define SharedDataSeparation NO -#define SharedCodeDef /**/ -#define SharedLibraryDef /**/ -#define ShLibIncludeFile -#define SharedLibraryLoadFlags -dll -#define PositionIndependentCFlags /**/ - -.c.obj: - $(CC) -c $*.c @<< - $(CFLAGS) -<< - -#if HasCplusplus -.CCsuf.obj: - $(CXX) -c $*.CCsuf @<< - $(CFLAGS) -<< -#endif - -#define ProgramTargetName(target) target.exe - -#define RunProgram(progvar,options) $(progvar:/=\) options - -#define RemoveFile(file) if exist file $(RM) file - -#define RemoveFiles(files) @$(MAKE) $(MFLAGS) -f << @@\ -.SUFFIXES: @@\ - @@\ -all: files @@\ - !for %%i in ( Avoid.Error $$** ) do if exist %%i $(RM) %%i @@\ - @@\ -Avoid.Error files: @@\ -<< - -#define MakeDir(dir) -$(MKDIRHIER) dir - -#define ObjectCompile(options) RemoveFile($@) @@\ - $(CC) -c $*.c @<< @@\ - $(CFLAGS) options @@\ -<< - -#define LibObjCompile(dir,options) RemoveFiles($@ dir\$@) @@\ - $(CC) -c $*.c @<< @@\ - $(CCOPTIONS) $(ALLDEFINES) options @@\ -<< @@\ - $(MV) $@ dir\$@ - -#define BuildIncludesTop(srclist,dstsubdir,dstupdir) @@\ -includes:: srclist @@\ - MakeDir($(BUILDINCDIR:/=\)) @@\ - @$(MAKE) $(MFLAGS) -f << @@\ -.SUFFIXES: @@\ - @@\ -all: srclist @@\ - cd $(BUILDINCDIR:/=\) @@\ - !RemoveFile($$**) @@\ - !$(LN) $(BUILDINCTOP:/=\)\$(CURRENT_DIR:/=\)\$$** . @@\ - @@\ -Avoid.Error srclist: @@\ -<< - -#define BuildIncludes(srclist,dstsubdir,dstupdir) @@\ -XVARdef0 = $(BUILDINCDIR)/dstsubdir @@\ -XVARdef1 = $(BUILDINCTOP)/dstupdir/$(CURRENT_DIR) @@\ - @@\ -includes:: srclist @@\ - MakeDir($(XVARuse0:/=\)) @@\ - @$(MAKE) -A $(MFLAGS) -f << @@\ -.SUFFIXES: @@\ - @@\ -all: srclist @@\ - cd $(XVARuse0:/=\) @@\ - !RemoveFile($$**) @@\ - !$(LN) $(XVARuse1:/=\)\$$** . @@\ - @@\ -Avoid.Error srclist: @@\ -<< - -#define LinkFileList(step,list,dir,sub) @@\ -XVARdef0 = dir @@\ -XVARdef1 = sub @@\ -XVARdef2 = list @@\ - @@\ -step:: $(XVARuse2:/=\) @@\ - cd $(XVARuse0:/=\) @@\ - !RemoveFile($**) @@\ - !$(LN) $(XVARuse1:/=\)\\$** . - -#define LinkRule(program,options,objects,libraries) \ -$(CCLINK) Concat(-Fe,program) options objects libraries $(EXTRA_LOAD_FLAGS) - -#define NormalProgramTarget(program,objects,deplibs,locallibs,syslibs) @@\ -XVARdef0 = objects @@\ - @@\ -ProgramTargetName(program): $(XVARuse0:.o=.obj) deplibs @@\ - RemoveTargetProgram($@) @@\ - LinkRule($@,$(LDOPTIONS),$(XVARuse0:.o=.obj),locallibs $(LDLIBS) syslibs) @@\ - @@\ -clean:: @@\ - RemoveFile(ProgramTargetName(program)) - -#define ProgramTargetHelper(program,srcs,objs,deplib,locallib,syslib) @@\ -ProgramTargetName(program): $(objs:.o=.obj) $(deplib) @@\ - RemoveTargetProgram($@) @@\ - LinkRule($@,$(LDOPTIONS),$(objs:.o=.obj),locallib $(LDLIBS) syslib) @@\ - @@\ -InstallProgram(program,$(BINDIR)) @@\ -InstallManPage(program,$(MANDIR)) - -#define ComplexProgramTarget(program) @@\ -PROGRAM = ProgramTargetName(program) @@\ - @@\ -AllTarget(ProgramTargetName(program)) @@\ - @@\ -ProgramTargetHelper(program,SRCS,OBJS,DEPLIBS,$(LOCAL_LIBRARIES),NullParameter) @@\ - @@\ -DependTarget() @@\ -LintTarget() @@\ - @@\ -clean:: @@\ - RemoveFile($(PROGRAM)) - -#define ComplexProgramTarget_1(program,locallib,syslib) @@\ -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) @@\ -SRCS = $(SRCS1) $(SRCS2) $(SRCS3) @@\ -PROGRAM1 = ProgramTargetName(program) @@\ - @@\ -AllTarget($(PROGRAM1) $(PROGRAM2) $(PROGRAM3)) @@\ - @@\ -ProgramTargetHelper(program,SRCS1,OBJS1,DEPLIBS1,locallib,syslib) @@\ - @@\ -DependTarget() @@\ -LintTarget() @@\ - @@\ -clean:: @@\ - for %%i in ($(PROGRAMS)) do $(RM) ProgramTargetName(%%i) - -#define ComplexProgramTarget_2(program,locallib,syslib) @@\ -PROGRAM2 = ProgramTargetName(program) @@\ - @@\ -ProgramTargetHelper(program,SRCS2,OBJS2,DEPLIBS2,locallib,syslib) - -#define ComplexProgramTarget_3(program,locallib,syslib) @@\ -PROGRAM3 = ProgramTargetName(program) @@\ - @@\ -ProgramTargetHelper(program,SRCS3,OBJS3,DEPLIBS3,locallib,syslib) - -#define MoveToBakFile(file) -@if exist file $(MV) file file.bak - -#define RMoveToBakFile(file) -RemoveFile(file.bak) @@\ - -@if exist file $(MV) file file.bak - -#define InstallMultipleDestFlags(step,list,dest,flags) @@\ -XVARdef0 = $(DESTDIR)dest @@\ - @@\ -step:: list @@\ - MakeDir($(XVARuse0:/=\)) @@\ - !$(INSTALL) $(INSTALLFLAGS) flags $** $(XVARuse0:/=\) - -#define CleanTarget() @@\ -clean:: @@\ - RemoveFiles(FilesToClean ExtraFilesToClean) - -#define LibraryTargetName(libname)libname.lib - -#define LibraryTargetNameSuffix(libname,suffix)Concat(libname,suffix.lib) - -#define MakeLibrary(libname,objlist) $(AR) @<< @@\ --out:libname objlist @@\ -<< - -#define LinkSourceFile(src,dir) @@\ -XVARdef0 = dir/src @@\ - @@\ -src: $(XVARuse0:/=\) @@\ - RemoveFile($@) @@\ - $(LN) $? $@ @@\ - @@\ -includes:: src @@\ - @@\ -depends:: src @@\ - @@\ -clean:: @@\ - RemoveFile(src) - -#define LinkFile(tofile,fromfile) @@\ -XVARdef0 = fromfile @@\ -tofile:: $(XVARuse0:/=\) @@\ - RemoveFile($@) @@\ - $(LN) $? $@ @@\ - @@\ -includes:: tofile @@\ - @@\ -depend:: tofile @@\ - @@\ -clean:: @@\ - RemoveFile(tofile) - - -#define NormalLibraryTarget(libname,objlist) @@\ -AllTarget(LibraryTargetName(libname)) @@\ - @@\ -XVARdef0 = objlist @@\ - @@\ -LibraryTargetName(libname): $(XVARuse0:.o=.obj) $(EXTRALIBRARYDEPS) @@\ - RemoveFile($@) @@\ - MakeLibrary($@,$(XVARuse0:.o=.obj)) @@\ - LinkBuildLibrary($@) - -#define NormalLibraryTarget2(libname,objlist1,objlist2) @@\ -NormalLibraryTarget(libname,objlist1 objlist2) - -#define NormalLibraryTarget3(libname,objlist1,objlist2,objlist3) @@\ -NormalLibraryTarget(libname,objlist1 objlist2 objlist3) - -#define NormalDepLibraryTarget(libname,deplist,objlist) @@\ -AllTarget(LibraryTargetName(libname)) @@\ - @@\ -XVARdef0 = deplist @@\ -XVARdef1 = objlist @@\ -XVARdef2 = $(XVARuse1:/=\) @@\ - @@\ -LibraryTargetName(libname): $(XVARuse0:/=\) $(EXTRALIBRARYDEPS) @@\ - RemoveFile($@) @@\ - MakeLibrary($@,$(XVARuse2:.o=.obj)) @@\ - LinkBuildLibrary($@) - -#define ProfiledLibraryTarget(libname,objlist) @@\ -AllTarget(LibraryTargetNameSuffix(libname,_p)) @@\ - @@\ -XVARdef0 = objlist @@\ - @@\ -LibraryTargetNameSuffix(libname,_p): $(XVARuse0:.o=.obj) $(EXTRALIBRARYDEPS) @@\ - RemoveFile($@) @@\ - cd profiled @@\ - MakeLibrary(..\$@,$(XVARuse0:.o=.obj)) @@\ - cd .. - -#define DebuggedLibraryTarget(libname,objlist) @@\ -AllTarget(LibraryTargetNameSuffix(libname,_d)) @@\ - @@\ -XVARdef0 = objlist @@\ - @@\ -LibraryTargetNameSuffix(libname,_d): $(XVARuse0:.o=.obj) $(EXTRALIBRARYDEPS) @@\ - RemoveFile($@) @@\ - cd debugger @@\ - MakeLibrary(..\$@,$(XVARuse0:.o=.obj)) @@\ - cd .. - -#ifndef UseInstalled -#define ImakeDependency(target) @@\ -target:: ProgramTargetName($(IMAKE)) @@\ - @@\ -ProgramTargetName($(IMAKE)): @@\ - < $@ @@\ - @@\ -clean:: @@\ - RemoveFile(DONE) - -#define CppScriptTarget(dst,src,defs,deplist) @@\ -dst:: @@\ - @echo sorry, unable to make $@ - -#define CppFileTarget(dst,src,defs,deplist) @@\ -XFAKEVAR = X @@\ -dst:: src deplist @@\ - RemoveFile($@) @@\ - $(PREPROCESSCMD) -I. <$@ @@\ - XCOMM define $(XFAKEVAR)COMM XCOMM @@\ - XCOMM include @@\ -<< @@\ - defs @@\ -<< @@\ - @@\ -clean:: @@\ - RemoveFiles(dst) - -#define InstallNamedTarget(step,srcname,flags,dest,dstname) @@\ -XVARdef0 = $(DESTDIR)dest @@\ - @@\ -step:: srcname @@\ - MakeDir($(XVARuse0:/=\)) @@\ - $(INSTALL) $(INSTALLFLAGS) flags srcname $(XVARuse0:/=\)\\dstname - -#define InstallNamedTargetNoClobber(step,srcname,flags,dest,dstname) @@\ -XVARdef0 = $(DESTDIR)dest @@\ - @@\ -step:: srcname @@\ - MakeDir($(XVARuse0:/=\)) @@\ - @if exist $(XVARuse0:/=\)\\dstname echo Not overwriting existing $(XVARuse0:/=\)\\dstname @@\ - if not exist $(XVARuse0:/=\)\\dstname $(INSTALL) $(INSTALLFLAGS) flags srcname $(XVARuse0:/=\)\\dstname - - -#define InstallLibrary(libname,dest) @@\ -InstallTarget(install,LibraryTargetName(libname),$(INSTLIBFLAGS),dest) - -#define InstallScript(program,dest) /**/ - -#define InstallNamedProg(srcname,dstname,dest) @@\ -install:: srcname @@\ - @echo sorry, unable to install srcname - -#define InstallSharedLibrary(libname,rev,dest) @@\ -InstallTarget(install,LibraryTargetName(libname),$(INSTLIBFLAGS),$(USRLIBDIR)) @@\ -InstallTarget(install,libname.dll,$(INSTLIBFLAGS),dest) - -#define InstallSharedLibraryData(libname,rev,dest) - -#define MakeDLL(libname,solist) $(LD) @<< @@\ -$(SHLIBLDFLAGS) -out:libname.dll libname.exp solist @@\ -<< - -#define SharedLibraryTarget(libname,rev,solist,down,up) @@\ -AllTarget(libname.dll) @@\ - @@\ -CppFileTarget(libname.def,libname-def.cpp,-DLIBRARY_VERSION=rev,$(ICONFIGFILES)) @@\ - @@\ -XVARdef0 = solist @@\ - @@\ -LibraryTargetName(libname): $(XVARuse0:.o=.obj) libname.def $(EXTRALIBRARYDEPS) @@\ - RemoveFile($@) @@\ - MakeLibrary($@,-def:libname.def $(XVARuse0:.o=.obj)) @@\ - LinkBuildLibrary($@) @@\ - @@\ -libname.dll: LibraryTargetName(libname) $(EXTRALIBRARYDEPS) @@\ - RemoveFile(libname.dll) @@\ - MakeDLL(libname,$(XVARuse0:.o=.obj) $(REQUIREDLIBS) $(EXTRA_LIBRARIES)) @@\ - LinkBuildDLL(libname.dll) @@\ - @@\ -clean:: @@\ - RemoveFile(LibraryTargetName(libname)) @@\ - RemoveFile(libname.dll) - -#define SharedLibraryDataTarget(libname,rev,salist) - -#define ObjectCplusplusCompile(options) RemoveFile($@) @@\ - $(CXX) -c $*.CCsuf @<< @@\ - $(CFLAGS) options @@\ -<< - -#define CplusplusLinkRule LinkRule - -#define CplusplusProgramTargetHelper ProgramTargetHelper - -#ifndef ComplexCplusplusProgramTarget -#define ComplexCplusplusProgramTarget(program) @@\ - PROGRAM = ProgramTargetName(program) @@\ - @@\ -AllTarget(ProgramTargetName(program)) @@\ - @@\ -CplusplusProgramTargetHelper(program,SRCS,OBJS,DEPLIBS,$(LOCAL_LIBRARIES),NullParameter) @@\ - @@\ -DependTarget() @@\ -LintTarget() @@\ - @@\ -clean:: @@\ - RemoveFile(ProgramTargetName(program)) -#endif /* ComplexCplusplusProgramTarget */ - -#ifndef UseInstalled -# define LinkBuildDLL(binary) MakeDir($(BUILDBINDIR:/=\)) @@\ - RemoveFile(Concat($(BUILDBINDIR:/=\)\,binary)) @@\ - cd $(BUILDBINDIR:/=\) && $(LN) Concat($(BUILDBINTOP:/=\)\$(CURRENT_DIR:/=\)\,binary) . - -# ifdef LinkBuildBinary -# undef LinkBuildBinary -# endif -# define LinkBuildBinary(binary) @@\ -all:: $(BUILDBINDIR)\ProgramTargetName(binary) ProgramTargetName(binary) @@\ - @@\ -$(BUILDBINDIR)\ProgramTargetName(binary): ProgramTargetName(binary) @@\ - MakeDir($(BUILDBINDIR:/=\)) @@\ - RemoveFile($(BUILDBINDIR:/=\)\ProgramTargetName(binary))) @@\ - cd $(BUILDBINDIR:/=\) && $(LN) $(BUILDBINTOP:/=\)\$(CURRENT_DIR:/=\)\ProgramTargetName(binary) . - -# ifdef LinkBuildLibrary -# undef LinkBuildLibrary -# endif -# define LinkBuildLibrary(lib) MakeDir($(BUILDLIBDIR:/=\)) @@\ - RemoveFile(Concat($(BUILDLIBDIR:/=\)\,lib)) @@\ - cd $(BUILDLIBDIR:/=\) && $(LN) Concat($(BUILDLIBTOP:/=\)\$(CURRENT_DIR:/=\)\,lib) . - -#endif - -#ifndef ProjectUnsharedLibReferences -#define ProjectUnsharedLibReferences(varname,libname,libsource,buildlibdir) @@\ -Concat3(DEP,varname,LIB) = _UseCat($(USRLIBDIR)/lib,buildlibdir/,libname.lib) @@\ -Concat(varname,LIB) = $(Concat3(DEP,varname,LIB)) @@\ -LintLibReferences(varname,libname,libsource) -#endif - - -/* - * ServerTargetWithFlags - generate rules to compile, link, and relink a server - */ -#ifndef ServerTargetWithFlags -#define ServerTargetWithFlags(server,subdirs,objects,libs,syslibs,flags) @@\ -XVARdef0 = objects @@\ - @@\ -AllTarget(ProgramTargetName(server)) @@\ -ProgramTargetName(server): subdirs $(XVARuse0:.o=.obj) libs @@\ - MoveToBakFile($@) @@\ - LinkRule($@,$(LDOPTIONS),$(XVARuse0:.o=.obj),libs $(LDLIBS) syslibs) @@\ - @@\ -Concat(load,server): @@\ - MoveToBakFile(ProgramTargetName(server)) @@\ - LinkRule(ProgramTargetName(server),$(LDOPTIONS),$(XVARuse0:.o=.obj),libs $(LDLIBS) syslibs) @@\ - @@\ -loadX:: Concat(load,server) @@\ - @@\ -ProofProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\ -ProofLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\ - @@\ -InstallProgramWithFlags(server,$(BINDIR),flags) @@\ - @@\ -clean:: @@\ - RemoveFile(ProgramTargetName(server)) -#endif /* ServerTargetWithFlags */ diff --git a/cde/config/imake/Makefile.ini b/cde/config/imake/Makefile.ini index e57026c3f..aed7800e0 100644 --- a/cde/config/imake/Makefile.ini +++ b/cde/config/imake/Makefile.ini @@ -50,16 +50,3 @@ clean: $(RM) -r Makefile.proto Makefile Makefile.dep bootstrap .depend depend: - -imake.exe:: - @echo making imake with BOOTSTRAPCFLAGS=-DWIN32 - -imake.exe:: imake.obj - cl -nologo imake.obj libc.lib kernel32.lib - -imake.obj: imake.c - cl -nologo -W2 -D__STDC__ -c -DWIN32 $(CFLAGS) imake.c - -clean.Win32: - if exist imake.exe del imake.exe - if exist imake.obj del imake.obj diff --git a/cde/config/imake/imake.c b/cde/config/imake/imake.c index 3444c045f..6ca76d34c 100644 --- a/cde/config/imake/imake.c +++ b/cde/config/imake/imake.c @@ -161,9 +161,6 @@ in this Software without prior written authorization from The Open Group. #include #include #include "Xosdefs.h" -#ifdef WIN32 -# include "Xw32defs.h" -#endif #ifndef X_NOT_POSIX # ifndef _POSIX_SOURCE # define _POSIX_SOURCE @@ -172,9 +169,7 @@ in this Software without prior written authorization from The Open Group. #include #include #ifdef X_NOT_POSIX -# ifndef WIN32 -# include -# endif +# include #else # include #endif @@ -203,15 +198,10 @@ typedef int waitType; # define waitSig(w) ((w) & 0xff) typedef int waitType; # else /* SYSV */ -# ifdef WIN32 -# include -typedef int waitType; -# else # include # define waitCode(w) ((w).w_T.w_Retcode) # define waitSig(w) ((w).w_T.w_Termsig) typedef union wait waitType; -# endif # endif # ifndef WIFSIGNALED # define WIFSIGNALED(w) waitSig(w) @@ -233,11 +223,7 @@ extern char *getenv(); #ifdef X_NOT_STDC_ENV extern int errno; #endif -#ifndef WIN32 #include -#else -#include -#endif #ifndef SYS_NMLN # ifdef _SYS_NMLN # define SYS_NMLN _SYS_NMLN @@ -316,13 +302,7 @@ static char *cpp = NULL; static char *tmpMakefile = "/tmp/Imf.XXXXXX"; static char *tmpImakefile = "/tmp/IIf.XXXXXX"; -static char *make_argv[ ARGUMENTS ] = { -#ifdef WIN32 - "nmake" -#else - "make" -#endif -}; +static char *make_argv[ ARGUMENTS ] = {"make"}; static int make_argindex; static int cpp_argindex; @@ -727,15 +707,6 @@ doit(FILE *outfd, const char *cmd, char **argv) /* * Fork and exec the command. */ -#ifdef WIN32 - if (outfd) - dup2(fileno(outfd), 1); - status = _spawnvp(_P_WAIT, cmd, argv); - if (status < 0) - LogFatal("Cannot spawn %s.", cmd); - if (status > 0) - LogFatal("Exit code %d.", status); -#else pid = fork(); if (pid < 0) LogFatal("Cannot fork."); @@ -756,11 +727,8 @@ doit(FILE *outfd, const char *cmd, char **argv) execvp(cmd, argv); LogFatal("Cannot exec %s.", cmd); } -#endif } -#ifndef WIN32 - #if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \ defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV)) static void @@ -828,13 +796,12 @@ parse_utsname(struct utsname *name, const char *fmt, char *result, const char *m int ret = sscanf(buf, fmt + arg + 1, result); (void) ret; } -#endif /* Trim leading 0's and periods from version names. The 0's cause the number to be interpreted as octal numbers. Some version strings have the potential for different numbers of .'s in them. */ - + #if (defined(DEFAULT_OS_MAJOR_REV) || defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV)) static const char * trim_version(const char *p) @@ -1240,7 +1207,6 @@ get_gcc_incdir(FILE *inFile) static boolean define_os_defaults(FILE *inFile) { -#ifndef WIN32 #if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \ defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV)) struct utsname name; @@ -1287,22 +1253,6 @@ define_os_defaults(FILE *inFile) #if defined (sun) && defined(SVR4) get_sun_compiler_versions (inFile); #endif -#else /* WIN32 */ - OSVERSIONINFO osvi; - static char* os_names[] = { "Win32s", "Windows 95", "Windows NT" }; - - memset(&osvi, 0, sizeof(OSVERSIONINFO)); - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - GetVersionEx (&osvi); - - fprintf (inFile, "#define DefaultOSName Microsoft %s\n", - os_names[osvi.dwPlatformId]); - - fprintf(inFile, "#define DefaultOSMajorVersion %d\n", osvi.dwMajorVersion); - fprintf(inFile, "#define DefaultOSMinorVersion %d\n", osvi.dwMinorVersion); - fprintf(inFile, "#define DefaultOSTeenyVersion %d\n", - osvi.dwBuildNumber & 0xFFFF); -#endif /* WIN32 */ return FALSE; } @@ -1539,9 +1489,6 @@ ReadLine(FILE *tmpfd, const char *tmpfname) char *p1, *p2; if (! initialized) { -#ifdef WIN32 - FILE *fp = tmpfd; -#endif int total_red; struct stat st; @@ -1558,12 +1505,8 @@ ReadLine(FILE *tmpfd, const char *tmpfname) end = buf + total_red; *end = '\0'; fseek(tmpfd, 0, 0); -#if defined(SYSV) || defined(WIN32) +#if defined(SYSV) tmpfd = freopen(tmpfname, "w+", tmpfd); -#ifdef WIN32 - if (! tmpfd) /* if failed try again */ - tmpfd = freopen(tmpfname, "w+", fp); -#endif if (! tmpfd) LogFatal("cannot reopen %s.", tmpfname); #else /* !SYSV */ @@ -1587,10 +1530,6 @@ ReadLine(FILE *tmpfd, const char *tmpfname) break; } else if (*p1 == '\n') { /* real EOL */ -#ifdef WIN32 - if (p1 > pline && p1[-1] == '\r') - p1[-1] = '\0'; -#endif *p1++ = '\0'; break; } @@ -1653,9 +1592,6 @@ KludgeOutputLine(char **pline) if (quotechar) { if (quotechar == '\\' || (*p == quotechar && -# ifdef WIN32 - quotechar != ')' && -# endif p[-1] != '\\')) quotechar = '\0'; continue; diff --git a/cde/config/imake/imakemdep.h b/cde/config/imake/imakemdep.h index bad190de0..07892e865 100644 --- a/cde/config/imake/imakemdep.h +++ b/cde/config/imake/imakemdep.h @@ -99,10 +99,10 @@ in this Software without prior written authorization from The Open Group. #ifdef Mips # if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43) # define imake_ccflags "-DBSD43" -# else +# else # define imake_ccflags "-DSYSV" # endif -#endif +#endif #ifdef is68k #define imake_ccflags "-Dluna -Duniosb" @@ -132,14 +132,6 @@ in this Software without prior written authorization from The Open Group. #define imake_ccflags "-fn -tm c1" #endif -#ifdef WIN32 -#if _MSC_VER < 1000 -#define imake_ccflags "-nologo -batch -D__STDC__" -#else -#define imake_ccflags "-nologo -D__STDC__" -#endif -#endif - #ifdef __sxg__ #define imake_ccflags "-DSYSV -DUSG -DNOSTDHDRS" #endif @@ -207,14 +199,9 @@ in this Software without prior written authorization from The Open Group. * all colons). One way to tell if you need this is to see whether or not * your Makefiles have no tabs in them and lots of @@ strings. */ -#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || defined(__llvm__) || (defined(AMOEBA) && defined(CROSS_COMPILE)) +#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(__llvm__) #define FIXUP_CPP_WHITESPACE #endif -#ifdef WIN32 -#define REMOVE_CPP_LEADSPACE -#define INLINE_SYNTAX -#define MAGIC_MAKE_VARS -#endif /* * Step 4: USE_CC_E, DEFAULT_CC, DEFAULT_CPP @@ -225,10 +212,6 @@ in this Software without prior written authorization from The Open Group. #ifdef hpux #define USE_CC_E #endif -#ifdef WIN32 -#define USE_CC_E -#define DEFAULT_CC "cl" -#endif #if defined(_IBMR2) && !defined(DEFAULT_CPP) #define DEFAULT_CPP "/usr/ccs/lib/cpp" #endif @@ -475,14 +458,6 @@ char *cpp_argv[ARGUMENTS] = { "-DSVR4", #endif #endif -#ifdef WIN32 - "-DWIN32", - "-nologo", -#if _MSC_VER < 1000 - "-batch", -#endif - "-D__STDC__", -#endif #ifdef NCR "-DNCR", /* NCR */ #endif @@ -490,40 +465,6 @@ char *cpp_argv[ARGUMENTS] = { "-traditional", "-D__linux__", #endif -#ifdef __sxg__ - "-D__sxg__", -#endif -#ifdef nec_ews_svr2 - "-Dnec_ews_svr2", -#endif -#ifdef AMOEBA - "-DAMOEBA", -# ifdef CROSS_COMPILE - "-DCROSS_COMPILE", -# ifdef CROSS_i80386 - "-DCROSS_i80386", -# endif -# ifdef CROSS_sparc - "-DCROSS_sparc", -# endif -# ifdef CROSS_mc68000 - "-DCROSS_mc68000", -# endif -# else -# ifdef i80386 - "-Di80386", -# endif -# ifdef sparc - "-Dsparc", -# endif -# ifdef mc68000 - "-Dmc68000", -# endif -# endif -#endif -#if defined(__sgi) && defined(__ANSI_CPP__) - "-cckr", -#endif #ifdef __minix_vmd "-Dminix", #endif diff --git a/cde/config/makedepend/main.c b/cde/config/makedepend/main.c index 22e5da170..6b4d462d1 100644 --- a/cde/config/makedepend/main.c +++ b/cde/config/makedepend/main.c @@ -134,7 +134,7 @@ catch (sig) fatalerr ("got signal %d\n", sig); } -#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) +#if defined(USG) || (defined(i386) && defined(SYSV)) #define USGISH #endif @@ -661,15 +661,8 @@ redirect(line, makefile) fatalerr("cannot open \"%s\"\n", makefile); snprintf(backup, BUFSIZ, "%s.bak", makefile); unlink(backup); -#ifdef WIN32 - fclose(fdin); -#endif if (rename(makefile, backup) < 0) fatalerr("cannot rename %s to %s\n", makefile, backup); -#ifdef WIN32 - if ((fdin = fopen(backup, "r")) == NULL) - fatalerr("cannot open \"%s\"\n", backup); -#endif if ((fdout = freopen(makefile, "w", stdout)) == NULL) fatalerr("cannot open \"%s\"\n", backup); len = strlen(line); diff --git a/cde/config/util/Imakefile b/cde/config/util/Imakefile index a82e20fff..d39c7bc6b 100644 --- a/cde/config/util/Imakefile +++ b/cde/config/util/Imakefile @@ -7,18 +7,10 @@ MDEP_PROG = makedepend EXPORTLISTGEN = exportlistgen #endif -#ifdef Win32Architecture -CMKDIRHIER = mkdirhier.exe -#endif - PROGRAMS = xmkmf $(MDEP_PROG) mergelib ProgramTargetName(makestrs) $(EXPORTLISTGEN) $(CMKDIRHIER) DEPLIBS = DEPEND_DEFINES = $(DEPENDDEFINES) -#ifndef Win32Architecture - EXTRA_LIBRARIES = -#endif - XCOMM Some compilers generate fatal errors if an -L directory does XCOMM not exist. Since BUILDLIBDIR may not exist yet suppress its use. LDPRELIB = @@ -45,10 +37,6 @@ SimpleProgramTarget(lndir) #endif #endif -#ifdef Win32Architecture -SimpleProgramTarget(mkdirhier) -#endif - NormalProgramTarget(makestrs,makestrs.o,,,) InstallNamedProg(xmkmf,xmkmf,$(BINDIR)) diff --git a/cde/config/util/aminstall.sh b/cde/config/util/aminstall.sh deleted file mode 100644 index 6a8def3f3..000000000 --- a/cde/config/util/aminstall.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# $XConsortium: aminstall.sh,v 1.1 94/03/29 15:54:08 gildea Exp $ -# aminstall - transfer cross-compiled files to system running Amoeba. -# Usage: aminstall binary-directory [-s stksz] unix-source amoeba-dest - -# -# Default soap mask for files -# -SPMASK=0xFF:2:2 -export SPMASK -PROG=$0 -USAGE="Usage: $PROG binary-directory unix-source amoeba-dest" - -# -# Argument check -# -case $# in -3|5) ;; -*) echo $USAGE >&2 - exit 1 - ;; -esac - -bindir=$1 -stksz= -case $2 in --s) if [ $# -ne 5 ] - then - echo $USAGE >&2 - exit 1 - fi - stksz="-s $3" - shift - shift - ;; -esac - -unxfile=$2 -dest=$3 - -# -# Change /public .... into /super (just for installation) -# -stripped=`echo $dest | sed 's:^/public::'` -if [ X$dest != X$stripped ]; then - dest=/super$stripped -fi - -# -# If the file already exists, then delete it -# -INFO=`$bindir/std_info $dest 2>&1` -case $INFO in -*"not found"*) ;; -*failed*) ;; -*bytes*) $bindir/del -f $dest - ;; -/??????) echo $PROG: cannot install over directory 1>&2 - exit - ;; -*) $bindir/del -d $dest - ;; -esac - -# -# Transfer the file to Amoeba -# -$bindir/../bin.scripts/ainstall $stksz $unxfile $dest > /dev/null 2>&1 -if [ $? -ne 0 ] -then - echo "This is not binary - using tob" - $bindir/tob $unxfile $dest -fi - diff --git a/cde/copyright b/cde/copyright index f13fa4df7..3dd323137 100644 --- a/cde/copyright +++ b/cde/copyright @@ -1,7 +1,7 @@ - Common Desktop Environment Version 2.3.0 (stable) + Common Desktop Environment Version 2.3.0a (devel) (c) Copyright 1993-2012 The Open Group (c) Copyright 2012-2018 CDE Project contributors, see CONTRIBUTORS for details diff --git a/cde/databases/CDE-LOC.src b/cde/databases/CDE-LOC.src index 86b8dbd24..5a4123982 100644 --- a/cde/databases/CDE-LOC.src +++ b/cde/databases/CDE-LOC.src @@ -303,6 +303,11 @@ programs/localized/%_LANG_%/app-defaults/Dtbuilder install_target = /usr/dt/app-defaults/%_LANG_%/Dtbuilder } XCOMM +programs/localized/%_LANG_%/app-defaults/Dtudcfonted +{ default + install_target = /usr/dt/app-defaults/%_LANG_%/Dtudcfonted +} +XCOMM XCOMM >>----------------------------- XCOMM appmanager XCOMM <<----------------------------- diff --git a/cde/databases/CDE-MAN.udb b/cde/databases/CDE-MAN.udb index 5d57f027d..c38a5546b 100644 --- a/cde/databases/CDE-MAN.udb +++ b/cde/databases/CDE-MAN.udb @@ -423,6 +423,22 @@ doc/C/man/man1/dttypes.1 install_target = /usr/dt/share/man/man1/dttypes.1 } # +doc/C/man/man1/dtudcexch.1 +{ uxp + install_target = /usr/dt/share/catman/C/cde_man/cat1/dtudcexch.1 +} +{ default + install_target = /usr/dt/share/man/man1/dtudcexch.1 +} +# +doc/C/man/man1/dtudcfonted.1 +{ uxp + install_target = /usr/dt/share/catman/C/cde_man/cat1/dtudcfonted.1 +} +{ default + install_target = /usr/dt/share/man/man1/dtudcfonted.1 +} +# doc/C/man/man1/dtwm.1 { default install_target = /usr/dt/share/man/man1/dtwm.1 diff --git a/cde/databases/CDE-MSG-LOC.src b/cde/databases/CDE-MSG-LOC.src index 4a5b0e3f2..3cd369464 100644 --- a/cde/databases/CDE-MSG-LOC.src +++ b/cde/databases/CDE-MSG-LOC.src @@ -306,6 +306,16 @@ programs/localized/%_LANG_%/msg/dtconfig.cat install_target = /usr/dt/lib/nls/msg/%_LANG_%/dtconfig.cat } XCOMM +programs/localized/%_LANG_%/msg/dtudcexch.cat +{ default + install_target = /usr/dt/lib/nls/msg/%_LANG_%/dtudcexch.cat +} +XCOMM +programs/localized/%_LANG_%/msg/dtudcfonted.cat +{ default + install_target = /usr/dt/lib/nls/msg/%_LANG_%/dtudcfonted.cat +} +XCOMM programs/localized/%_LANG_%/msg/dtpdm.cat { default install_target = /usr/dt/lib/nls/msg/%_LANG_%/dtpdm.cat diff --git a/cde/databases/CDE-RUN.udb b/cde/databases/CDE-RUN.udb index 39ea2bff6..49013224c 100644 --- a/cde/databases/CDE-RUN.udb +++ b/cde/databases/CDE-RUN.udb @@ -1670,6 +1670,76 @@ programs/dtcalc/dtcalc mode = 0555 } # +programs/dtudcfonted/dtudcfonted +{ default + install_target = /usr/dt/bin/dtudcfonted + mode = 0555 +} +# +programs/localized/C/app-defaults/Dtudcfonted +{ default + install_target = /usr/dt/app-defaults/C/Dtudcfonted +} +# +programs/dtudcexch/dtudcexch +{ default + install_target = /usr/dt/bin/dtudcexch + mode = 0555 +} +# +programs/dtudcfonted/dtaddcpf/dtaddcpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtaddcpf + mode = 0555 +} +# +programs/dtudcfonted/dtbdftocpf/dtbdftocpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtbdftocpf + mode = 0555 +} +# +programs/dtudcfonted/dtcpftobdf/dtcpftobdf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtcpftobdf + mode = 0555 +} +# +programs/dtudcfonted/dtcpftogpf/dtcpftogpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtcpftogpf + mode = 0555 +} +# +programs/dtudcfonted/dtcpgpf/dtcpgpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtcpgpf + mode = 0555 +} +# +programs/dtudcfonted/dtgpftobdf/dtgpftobdf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtgpftobdf + mode = 0555 +} +# +programs/dtudcfonted/dtgpftocpf/dtgpftocpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtgpftocpf + mode = 0555 +} +# +programs/dtudcfonted/dtlsgpf/dtlsgpf +{ default + install_target = /usr/dt/lib/dtudcfonted/dtlsgpf + mode = 0555 +} +# +programs/dtudcfonted/libfal/fonts.list +{ default + install_target = /usr/dt/config/C/fonts.list +} +# programs/dtterm/dtterm { default install_target = /usr/dt/bin/dtterm diff --git a/cde/doc/common/help/HELPEnt.sgm b/cde/doc/common/help/HELPEnt.sgm index 0b20916d8..a4a38af12 100644 --- a/cde/doc/common/help/HELPEnt.sgm +++ b/cde/doc/common/help/HELPEnt.sgm @@ -1,5 +1,5 @@ -Common Desktop Environment 2.3.0, +Common Desktop Environment 2.3.0a, © Copyright 1993-2012 The Open Group © Copyright 2012-2018 CDE Project contributors, see CONTRIBUTORS for details diff --git a/cde/lib/DtHelp/il/ilall.c b/cde/lib/DtHelp/il/ilall.c deleted file mode 100644 index c9b89e94e..000000000 --- a/cde/lib/DtHelp/il/ilall.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ilall.c /main/3 1995/10/23 15:41:33 rswiston $ */ - - THIS FILE NO LONGER USED - ld -o IS NOW DONE INSTEAD, IN /ilc/Makefile . diff --git a/cde/lib/DtHelp/il/ilcompg3g4.h b/cde/lib/DtHelp/il/ilcompg3g4.h deleted file mode 100644 index 8d254d9e9..000000000 --- a/cde/lib/DtHelp/il/ilcompg3g4.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ilcompg3g4.h /main/3 1995/10/23 15:42:24 rswiston $ */ - - NO LONGER USED - REPLACED BY ilcompg3g4.c - - diff --git a/cde/lib/DtHelp/il/ilcompressg3.c b/cde/lib/DtHelp/il/ilcompressg3.c deleted file mode 100644 index dd664a92e..000000000 --- a/cde/lib/DtHelp/il/ilcompressg3.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ilcompressg3.c /main/3 1995/10/23 15:43:14 rswiston $ */ - - NO LONGER USED - REPLACED BY ilcompg3g4.c - diff --git a/cde/lib/DtHelp/il/ilcompressg4.c b/cde/lib/DtHelp/il/ilcompressg4.c deleted file mode 100644 index e7ecbcf30..000000000 --- a/cde/lib/DtHelp/il/ilcompressg4.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ilcompressg4.c /main/3 1995/10/23 15:43:21 rswiston $ */ - - NO LONGER USED - REPLACED BY ilcompg3g4.c - - diff --git a/cde/lib/DtHelp/il/iljpeg.c b/cde/lib/DtHelp/il/iljpeg.c deleted file mode 100644 index 9d0b27e72..000000000 --- a/cde/lib/DtHelp/il/iljpeg.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpeg.c /main/3 1995/10/23 15:49:57 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegcodec.c b/cde/lib/DtHelp/il/iljpegcodec.c deleted file mode 100644 index 76ce92bfe..000000000 --- a/cde/lib/DtHelp/il/iljpegcodec.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegcodec.c /main/3 1995/10/23 15:50:11 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegcsize.h b/cde/lib/DtHelp/il/iljpegcsize.h deleted file mode 100644 index 2d0c7f820..000000000 --- a/cde/lib/DtHelp/il/iljpegcsize.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegcsize.h /main/3 1995/10/23 15:50:25 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegdct.h b/cde/lib/DtHelp/il/iljpegdct.h deleted file mode 100644 index 68482032e..000000000 --- a/cde/lib/DtHelp/il/iljpegdct.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegdct.h /main/3 1995/10/23 15:50:38 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegfwft0.c b/cde/lib/DtHelp/il/iljpegfwft0.c deleted file mode 100644 index 318fb8798..000000000 --- a/cde/lib/DtHelp/il/iljpegfwft0.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegfwft0.c /main/3 1995/10/23 15:50:54 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegglobals.h b/cde/lib/DtHelp/il/iljpegglobals.h deleted file mode 100644 index c202d7dfa..000000000 --- a/cde/lib/DtHelp/il/iljpegglobals.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegglobals.h /main/3 1995/10/23 15:51:08 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpeghuffman.c b/cde/lib/DtHelp/il/iljpeghuffman.c deleted file mode 100644 index d1441c3ea..000000000 --- a/cde/lib/DtHelp/il/iljpeghuffman.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpeghuffman.c /main/3 1995/10/23 15:51:22 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegio.c b/cde/lib/DtHelp/il/iljpegio.c deleted file mode 100644 index c91dfc2d0..000000000 --- a/cde/lib/DtHelp/il/iljpegio.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegio.c /main/3 1995/10/23 15:51:36 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegisodct.c b/cde/lib/DtHelp/il/iljpegisodct.c deleted file mode 100644 index 97f98913c..000000000 --- a/cde/lib/DtHelp/il/iljpegisodct.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegisodct.c /main/3 1995/10/23 15:51:47 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegmarker.c b/cde/lib/DtHelp/il/iljpegmarker.c deleted file mode 100644 index 3aa8241b5..000000000 --- a/cde/lib/DtHelp/il/iljpegmarker.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegmarker.c /main/3 1995/10/23 15:51:59 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegmarker.h b/cde/lib/DtHelp/il/iljpegmarker.h deleted file mode 100644 index 7300a9326..000000000 --- a/cde/lib/DtHelp/il/iljpegmarker.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegmarker.h /main/3 1995/10/23 15:52:12 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegparam.h b/cde/lib/DtHelp/il/iljpegparam.h deleted file mode 100644 index d03e94421..000000000 --- a/cde/lib/DtHelp/il/iljpegparam.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegparam.h /main/3 1995/10/23 15:52:25 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegprototypes.h b/cde/lib/DtHelp/il/iljpegprototypes.h deleted file mode 100644 index 3cd51fc4a..000000000 --- a/cde/lib/DtHelp/il/iljpegprototypes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegprototypes.h /main/3 1995/10/23 15:52:40 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegstream.c b/cde/lib/DtHelp/il/iljpegstream.c deleted file mode 100644 index ab07e5c50..000000000 --- a/cde/lib/DtHelp/il/iljpegstream.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegstream.c /main/3 1995/10/23 15:52:53 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegstream.h b/cde/lib/DtHelp/il/iljpegstream.h deleted file mode 100644 index 41b8cf2e6..000000000 --- a/cde/lib/DtHelp/il/iljpegstream.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegstream.h /main/3 1995/10/23 15:53:06 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegsystem.h b/cde/lib/DtHelp/il/iljpegsystem.h deleted file mode 100644 index 9ac8397ea..000000000 --- a/cde/lib/DtHelp/il/iljpegsystem.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegsystem.h /main/3 1995/10/23 15:53:18 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegtables.h b/cde/lib/DtHelp/il/iljpegtables.h deleted file mode 100644 index 942915971..000000000 --- a/cde/lib/DtHelp/il/iljpegtables.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegtables.h /main/3 1995/10/23 15:53:35 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtHelp/il/iljpegtransform.c b/cde/lib/DtHelp/il/iljpegtransform.c deleted file mode 100644 index fff417e4a..000000000 --- a/cde/lib/DtHelp/il/iljpegtransform.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: iljpegtransform.c /main/3 1995/10/23 15:53:48 rswiston $ */ - - NO LONGER USED. All elements named "iljpeg?*" are no longer used. - Replaced by new JPEG code "iljpg?*". - diff --git a/cde/lib/DtSvc/DtUtil1/Dt.h b/cde/lib/DtSvc/DtUtil1/Dt.h index 710021212..3122efa76 100644 --- a/cde/lib/DtSvc/DtUtil1/Dt.h +++ b/cde/lib/DtSvc/DtUtil1/Dt.h @@ -58,7 +58,7 @@ extern "C" { DtREVISION * 100 + \ DtUPDATE_LEVEL) -#define DtVERSION_STRING "CDE Version 2.3.0" +#define DtVERSION_STRING "CDE Version 2.3.0a" /* diff --git a/cde/lib/DtSvc/DtUtil1/DtsMM.c b/cde/lib/DtSvc/DtUtil1/DtsMM.c index 99965b0eb..6892a1809 100644 --- a/cde/lib/DtSvc/DtUtil1/DtsMM.c +++ b/cde/lib/DtSvc/DtUtil1/DtsMM.c @@ -549,7 +549,7 @@ _DtDtsMMCacheName(int override) results = malloc(strlen(_DTDTSMMTEMPDIR)+ strlen(_DTDTSMMTEMPFILE)+ strlen(dsp)+3); - sprintf(results, "%s/%s%s\0", + sprintf(results, "%s/%s%s", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE, dsp); diff --git a/cde/lib/tt/bin/ttauth/process.c b/cde/lib/tt/bin/ttauth/process.c index 626428c12..cffe65c25 100644 --- a/cde/lib/tt/bin/ttauth/process.c +++ b/cde/lib/tt/bin/ttauth/process.c @@ -680,11 +680,7 @@ auth_finalize(void) ProgramName, temp_name); } else { (void) unlink (ttauth_filename); -#ifdef WIN32 - if (rename(temp_name, ttauth_filename) == -1) -#else if (link (temp_name, ttauth_filename) == -1) -#endif { fprintf (stderr, "%s: unable to link authority file %s, use %s\n", diff --git a/cde/lib/tt/bin/ttauth/ttauth.man b/cde/lib/tt/bin/ttauth/ttauth.man index 3503f5173..ad3452bd4 100644 --- a/cde/lib/tt/bin/ttauth/ttauth.man +++ b/cde/lib/tt/bin/ttauth/ttauth.man @@ -18,7 +18,7 @@ .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. -.TH TTAUTH 1 "Release 2.3.0" "CDE" +.TH TTAUTH 1 "Release 2.3.0a" "CDE" .SH NAME ttauth \- ToolTalk authority file utility .SH SYNOPSIS diff --git a/cde/lib/tt/lib/mp/mp_auth_functions.C b/cde/lib/tt/lib/mp/mp_auth_functions.C index 5ddd9af9a..e8c28eed2 100644 --- a/cde/lib/tt/lib/mp/mp_auth_functions.C +++ b/cde/lib/tt/lib/mp/mp_auth_functions.C @@ -68,12 +68,9 @@ extern char *getenv(); #ifndef X_NOT_POSIX #include #else -#ifndef WIN32 extern unsigned sleep (); -#else #define link rename #endif -#endif static int read_short(FILE *, unsigned short *); static int read_string(FILE *, char **); @@ -97,12 +94,6 @@ _tt_AuthFileName () static char *buf; static int bsize; int size; -#ifdef WIN32 -#ifndef PATH_MAX -#define PATH_MAX 512 -#endif - char dir[PATH_MAX]; -#endif if (name = getenv ("TTAUTHORITY")) return (name); @@ -111,24 +102,6 @@ _tt_AuthFileName () if (!name) { -#ifdef WIN32 - char *ptr1; - char *ptr2; - int len1 = 0, len2 = 0; - - if ((ptr1 = getenv("HOMEDRIVE")) && (ptr2 = getenv("HOMEDIR"))) { - len1 = strlen (ptr1); - len2 = strlen (ptr2); - } else if (ptr2 = getenv("USERNAME")) { - len1 = strlen (ptr1 = "/users/"); - len2 = strlen (ptr2); - } - if ((len1 + len2 + 1) < PATH_MAX) { - sprintf (dir, "%s%s", ptr1, (ptr2) ? ptr2 : ""); - name = dir; - } - if (!name) -#endif return (NULL); } @@ -226,24 +199,18 @@ _tt_LockAuthFile(char *file_name, int retries, int timeout, long dead) void _tt_UnlockAuthFile(char *file_name) { -#ifndef WIN32 char creat_name[1025]; -#endif char link_name[1025]; if ((int) strlen (file_name) > 1022) return; -#ifndef WIN32 strcpy (creat_name, file_name); strcat (creat_name, "-c"); -#endif strcpy (link_name, file_name); strcat (link_name, "-l"); -#ifndef WIN32 unlink (creat_name); -#endif unlink (link_name); } diff --git a/cde/lib/tt/tooltalk.tmpl b/cde/lib/tt/tooltalk.tmpl index 5f65f1469..b23edbbce 100644 --- a/cde/lib/tt/tooltalk.tmpl +++ b/cde/lib/tt/tooltalk.tmpl @@ -6,7 +6,7 @@ /* TT_VERSION defines the version string which is imbedded in all the */ /* binaries and shipped libraries. */ -TT_VERSION = "CDE Version 2.3.0" +TT_VERSION = "CDE Version 2.3.0a" TT_VERSION_DEFINE = -DTT_VERSION_STRING=\"$(TT_VERSION)\" diff --git a/cde/programs/Imakefile b/cde/programs/Imakefile index fd6abf08b..72f2224d8 100644 --- a/cde/programs/Imakefile +++ b/cde/programs/Imakefile @@ -17,9 +17,6 @@ DTINFODIR = dtinfo DTINFODIR = dtinfo #endif -XCOMM JET 4/2/2018 - disabling dtudcfonted and dtudcexch. They are -XCOMM very broken in terms of coverity and compiler warnings. Also, -XCOMM who uses them? And for what? SUBDIRS = dthelp dsdm dtmail dtpad dtfile dtwm dtlogin \ dtsession dthello dtstyle dtexec dtdbcache dticon dtterm \ @@ -27,7 +24,7 @@ SUBDIRS = dthelp dsdm dtmail dtpad dtfile dtwm dtlogin \ dtscreen dtksh dtcm dtsearchpath \ dtappbuilder dtappintegrate dtprintegrate dtconfig \ dtcreate dtprintinfo fontaliases dtdspmsg ttsnoop \ - dtimsstart dtdocbook dtpdm dtsr \ + dtudcfonted dtudcexch dtimsstart dtdocbook dtpdm dtsr \ dtpdmd $(DTINFODIR) $(EXTRADIRS) LINTSUBDIRS = dthelp dsdm dtmail dtpad dtfile dtwm dtlogin \ @@ -35,7 +32,7 @@ LINTSUBDIRS = dthelp dsdm dtmail dtpad dtfile dtwm dtlogin \ dtcalc dtaction dtcreate \ dtscreen dtksh dtcm dtsearchpath \ dtappbuilder dtappintegrate dtprintegrate dtprintinfo dtdspmsg \ - dtimsstart dtdocbook dtpdm dtsr \ + dtudcfonted dtudcexch dtimsstart dtdocbook dtpdm dtsr \ dtpdmd $(DTINFODIR) $(EXTRADIRS) MakeSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtappintegrate/dtappintegrate.src b/cde/programs/dtappintegrate/dtappintegrate.src index 3ae02e5e3..62ee9f9a1 100755 --- a/cde/programs/dtappintegrate/dtappintegrate.src +++ b/cde/programs/dtappintegrate/dtappintegrate.src @@ -47,7 +47,7 @@ XCOMM # XCOMM ------------------------------------------------------------------# function ShowSyntax { - echo "Usage: $SCRIPT_NAME -s [-t ] [-l ] [-u]" | tee -a $LOGFILE + echo "Usage: $SCRIPT_NAME -s [-t ] [-l ] [-u]" | tee -a "$LOGFILE" return 0 } XCOMM ------------------------------------------------------------------# @@ -66,15 +66,15 @@ XCOMM ------------------------------------------------------------------# function GetAbsolutePath { if [ "/" = "$1" ]; then - echo $2 - elif [ -L $1 ]; then - GetAbsolutePath `ls -l $1 | awk '{print $NF}'` $2 + echo "$2" + elif [ -L "$1" ]; then + GetAbsolutePath "$(find . -name "$1" | awk '{print $NF}')" "$2" else { - if [ "." = "$1" -o ".." = "$1" ]; then - GetAbsolutePath / /`basename $1`$2 + if [ "." = "$1" ] || [ ".." = "$1" ]; then + GetAbsolutePath / /"$(basename "$1")""$2" else - GetAbsolutePath `dirname $1` /`basename $1`$2 + GetAbsolutePath "$(dirname "$1")" /"$(basename "$1")""$2" fi } fi @@ -116,7 +116,7 @@ function GetRelativePath for (i = 2 + s; i <= b; i++) { printf("%s%s", B[i], (i < b) ? "/":"\n"); } - }' $2 $1 + }' "$2" "$1" } XCOMM ------------------------------------------------------------------# XCOMM LinkCfgs # @@ -136,46 +136,52 @@ function LinkCfgs typeset pattern="" files="" shift;shift;shift - if [[ -L $source || -L $(dirname $source) ]] then - spath=$(GetAbsolutePath $source) + if [[ -L $source || -L $(dirname "$source") ]] + then + spath=$(GetAbsolutePath "$source") else spath=$source fi - if [[ -L $target || -L $(dirname $target) ]] then - tpath=$(GetAbsolutePath $target) + if [[ -L $target || -L $(dirname "$target") ]] + then + tpath=$(GetAbsolutePath "$target") else tpath=$target fi rpath="" for pattern in "$@" do - if [[ $pattern = "(*)" ]] then - files=$(ls -d $source/COMMENT_STAR 2>/dev/null) + if [[ $pattern = "(*)" ]] + then + files=$(ls -d "$source"/COMMENT_STAR 2>/dev/null) else - files=$(ls -d $source/$pattern 2>/dev/null) + files=$(ls -d "$source"/"$pattern" 2>/dev/null) fi - if [[ $? = 0 ]] then - count=$(echo $files | wc -w) + if $files + then + count=$(echo "$files" | wc -w) for cfgfile in $files do - basecfg=$(basename $cfgfile) - if [[ $torf = TRUE ]] then - if [[ $rpath = "" ]] then - rpath=$(GetRelativePath $spath $tpath) + basecfg=$(basename "$cfgfile") + if [[ $torf = TRUE ]] + then + if [[ $rpath = "" ]] + then + rpath=$(GetRelativePath "$spath" "$tpath") fi - rm -f $tpath/$basecfg - echo "ln -sf $rpath/$basecfg $tpath/$basecfg" >> $LOGFILE - ln -sf $rpath/$basecfg $tpath/$basecfg >> $LOGFILE 2>&1 + rm -f "$tpath"/"$basecfg" + echo "ln -sf $rpath/$basecfg $tpath/$basecfg" >> "$LOGFILE" + ln -sf "$rpath/$basecfg" "$tpath/$basecfg" >> "$LOGFILE" 2>&1 else - rm $tpath/$basecfg >/dev/null 2>&1 - if [[ $? = 0 ]] then - echo "rm $tpath/$basecfg" >> $LOGFILE + if rm "$tpath"/"$basecfg" >/dev/null 2>&1 + then + echo "rm $tpath/$basecfg" >> "$LOGFILE" fi fi done fi done - return $count + return "$count" } XCOMM ------------------------------------------------------------------# @@ -195,12 +201,12 @@ XCOMM # XCOMM ------------------------------------------------------------------# function IntegrateUnintegrate { - typeset torf=$1 srcs="" trgs="" fpats="" langs="" tpath="" spath="" rpath="" k="" languages="" lang="" - typeset cfgs="" srcabs="" trgabs="" + typeset torf=$1 srcs="" trgs="" fpats="" tpath="" spath="" rpath="" languages="" lang="" + typeset srcabs="" trgabs="" integer i=0 icons=0 types=1 help=2 appmgr=3 - srcabs=$(GetAbsolutePath $APP_ROOT) - trgabs=$(GetAbsolutePath $APP_TARGET) + srcabs=$(GetAbsolutePath "$APP_ROOT") + trgabs=$(GetAbsolutePath "$APP_TARGET") srcs[0]=$srcabs$ICONS$APP_LANG srcs[1]=$srcabs$TYPES$APP_LANG @@ -220,32 +226,36 @@ function IntegrateUnintegrate rc=1 while (( i < 4 )) do - if [[ $APP_LANG = "" ]] then - languages=$(ls -d ${srcs[i]}/COMMENT_STAR 2>/dev/null) - if [[ $? = 0 ]] then + if [[ $APP_LANG = "" ]] + then + if languages=$(ls -d "${srcs[i]}"/COMMENT_STAR 2>/dev/null) + then for lang in $languages do - baselang=$(basename $lang) - if [[ -d $lang ]] then - if [[ $torf = TRUE ]] then - if [[ ! -d ${trgs[i]}/$baselang ]] then - mkdir -p ${trgs[i]}/$baselang + baselang=$(basename "$lang") + if [[ -d $lang ]] + then + if [[ $torf = TRUE ]] + then + if [[ ! -d ${trgs[i]}/$baselang ]] + then + mkdir -p "${trgs[i]}"/"$baselang" fi fi - LinkCfgs ${srcs[i]}/$baselang ${trgs[i]}/$baselang $torf ${fpats[i]} - if [[ $? != 0 ]] then + if ! LinkCfgs "${srcs[i]}/$baselang" "${trgs[i]}/$baselang" "$torf" "${fpats[i]}" + then rc=0 fi fi done fi else - LinkCfgs ${srcs[i]} ${trgs[i]} $torf ${fpats[i]} - if [[ $? != 0 ]] then + if ! LinkCfgs "${srcs[i]}" "${trgs[i]}" "$torf" "${fpats[i]}" + then rc=0 fi fi - i=i+1 + i=$((i+1)) done return $rc } @@ -261,10 +271,10 @@ XCOMM ------------------------------------------------------------------# function ExitOut { typeset retcode=$1 - echo "<<<<<<< END OF APPLICATION INTEGRATION >>>>>>>" >> $LOGFILE + echo "<<<<<<< END OF APPLICATION INTEGRATION >>>>>>>" >> "$LOGFILE" echo "See $LOGFILE file for more information" - exit $retcode + exit "$retcode" } XCOMM ----<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>----- XCOMM ----<<<<<<<<<<<.-------------------------.>>>>>>>>>>>----- @@ -278,7 +288,6 @@ XCOMM Initialize variables XCOMM ------------------------------------------------------------------- sFLAG=0 tFLAG=0 -lFLAG=0 uFLAG=0 TYPES=/types @@ -287,16 +296,15 @@ ICONS=/icons HELP=/help APPCONFIG=/dt/appconfig CONFIG_TOP=CDE_CONFIGURATION_TOP -DT=`basename $CONFIG_TOP` +DT=$(basename $CONFIG_TOP) APP_TARGET=${CONFIG_TOP%/$DT}$APPCONFIG -PIXMAP_FILES=*.pm -BITMAP_FILES=*.bm -HELPVOLUME_FILES_OLD=*.hv -HELPVOLUME_FILES_NEW=*.sdl -HELPFAMILY_FILES=*.hf -ACTIONDB_FILES=*.dt -FRONTPANEL_FILES=*.fp +PIXMAP_FILES="*.pm" +BITMAP_FILES="*.bm" +HELPVOLUME_FILES_OLD="*.hv" +HELPVOLUME_FILES_NEW="*.sdl" +HELPFAMILY_FILES="*.hf" +ACTIONDB_FILES="*.dt" APPMAN_FILES="(*)" ID=$(id) @@ -314,7 +322,8 @@ XCOMM ------------------------------------------------------------------- ID=${ID##*uid=} ID=${ID#*\(} ID=${ID%%\)*} -if [[ $ID != root ]] then +if [[ $ID != root ]] + then echo "Error: Must be root user to run $0!" >&2 exit 3 fi @@ -322,23 +331,24 @@ fi XCOMM ------------------------------------------------------------------- XCOMM Put prolog into log file. XCOMM ------------------------------------------------------------------- -echo "<<<<<<< START OF APPLICATION INTEGRATION >>>>>>>" > $LOGFILE +echo "<<<<<<< START OF APPLICATION INTEGRATION >>>>>>>" > "$LOGFILE" XCOMM ------------------------------------------------------------------- XCOMM Put the date of application integration into the log file. XCOMM ------------------------------------------------------------------- -echo $(date) >> $LOGFILE +date >> "$LOGFILE" XCOMM ------------------------------------------------------------------- XCOMM Put the command line into the log file. XCOMM ------------------------------------------------------------------- -echo "$SCRIPT_NAME $*" >> $LOGFILE +echo "$SCRIPT_NAME $*" >> "$LOGFILE" XCOMM ------------------------------------------------------------------- XCOMM Check if there are no command line arguments. XCOMM If none, then display the command syntax. XCOMM ------------------------------------------------------------------- -if [[ $# = 0 ]] then +if [[ $# = 0 ]] + then ShowSyntax ExitOut 0 fi @@ -353,8 +363,7 @@ do APP_ROOT="$OPTARG";; t) tFLAG=1 APP_TARGET="$OPTARG";; - l) lFLAG=1 - APP_LANG="$OPTARG";; + l) APP_LANG="$OPTARG";; u) uFLAG=1;; ?) echo " " ShowSyntax @@ -365,42 +374,50 @@ done XCOMM ------------------------------------------------------------------- XCOMM Check if application's root was specified and is valid. XCOMM ------------------------------------------------------------------- -if [[ $sFLAG = 0 ]] then +if [[ $sFLAG = 0 ]] + then echo "Error: Did not specify -s option!" >&2 ExitOut 4 else - if [[ ! -d $APP_ROOT ]] then + if [[ ! -d $APP_ROOT ]] + then APP_PATH=$APP_ROOT echo "Error: $APP_PATH is not a directory!" >&2 ExitOut 4 fi - if [[ ! -r $APP_ROOT ]] || [[ ! -x $APP_ROOT ]] then + if [[ ! -r $APP_ROOT ]] || [[ ! -x $APP_ROOT ]] + then APP_PATH=$APP_ROOT echo "Error: Can not read $APP_PATH directory!" >&2 ExitOut 4 fi fi -if [[ ${APP_ROOT%%/COMMENT_STAR} != "" ]] then +if [[ ${APP_ROOT%%/COMMENT_STAR} != "" ]] + then APP_ROOT=$(pwd)/$APP_ROOT fi XCOMM ------------------------------------------------------------------- XCOMM If target is specified, do some sanity checks on this path. XCOMM ------------------------------------------------------------------- -if [[ $tFLAG = 1 ]] then - if [[ ! -d $APP_TARGET ]] then +if [[ $tFLAG = 1 ]] + then + if [[ ! -d $APP_TARGET ]] + then APP_PATH=$APP_TARGET echo "Error: $APP_PATH is not a directory!" >&2 ExitOut 4 fi - if [[ ! -r $APP_TARGET ]] || [[ ! -x $APP_TARGET ]] then + if [[ ! -r $APP_TARGET ]] || [[ ! -x $APP_TARGET ]] + then APP_PATH=$APP_TARGET echo "Error: Can not read $APP_PATH directory!" >&2 ExitOut 4 fi - if [[ ${APP_TARGET%%/COMMENT_STAR} != "" ]] then + if [[ ${APP_TARGET%%/COMMENT_STAR} != "" ]] + then APP_TARGET=$(pwd)/$APP_TARGET fi fi @@ -410,16 +427,18 @@ XCOMM Set up variables. XCOMM ------------------------------------------------------------------- APP_ROOT=$APP_ROOT$APPCONFIG -if [[ $APP_LANG != "" ]] then +if [[ $APP_LANG != "" ]] + then APP_LANG=/$APP_LANG fi XCOMM ------------------------------------------------------------------- XCOMM Unintegrate the application by un-doing the integration steps. XCOMM ------------------------------------------------------------------- -if [[ $uFLAG = 1 ]] then - IntegrateUnintegrate FALSE - if [[ $? = 0 ]] then +if [[ $uFLAG = 1 ]] + then + if IntegrateUnintegrate FALSE + then echo "Unintegration Complete" else echo "No files to unintegrate" @@ -432,16 +451,17 @@ XCOMM See if these directories exist. If they don't, then create them. XCOMM ------------------------------------------------------------------- for i in $APP_TARGET$ICONS$APP_LANG $APP_TARGET$TYPES$APP_LANG $APP_TARGET$APPMANAGER$APP_LANG $APP_TARGET$HELP$APP_LANG do - if [[ ! -d $i ]] then - mkdir -p $i + if [[ ! -d $i ]] + then + mkdir -p "$i" fi done XCOMM ------------------------------------------------------------------- XCOMM Determine which awk to use. XCOMM ------------------------------------------------------------------- -$(type nawk > /dev/null 2>&1) -if [[ $? != 0 ]] then +if ! type nawk > /dev/null 2>&1 + then AWK="awk" else AWK="nawk" @@ -450,8 +470,8 @@ fi XCOMM ------------------------------------------------------------------- XCOMM Integrate the application. XCOMM ------------------------------------------------------------------- -IntegrateUnintegrate TRUE -if [[ $? = 0 ]] then +if IntegrateUnintegrate TRUE + then echo "Integration Complete" else echo "No files to integrate" diff --git a/cde/programs/dtdocbook/Imakefile b/cde/programs/dtdocbook/Imakefile index 8c46ff2ff..2e039ad89 100644 --- a/cde/programs/dtdocbook/Imakefile +++ b/cde/programs/dtdocbook/Imakefile @@ -3,11 +3,7 @@ XCOMM $XConsortium: Imakefile /main/6 1996/10/24 00:10:08 cde-hp $ #define IHaveSubdirs #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' -#if !UseNSGMLS -SGMLSDIR = sgmls -#endif - -SUBDIRS = doc2sdl lib tcl instant $(SGMLSDIR) xlate_locale +SUBDIRS = doc2sdl lib instant xlate_locale MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtdocbook/doc2sdl/docbook.tcl b/cde/programs/dtdocbook/doc2sdl/docbook.tcl index 08b422827..17a0d08b8 100755 --- a/cde/programs/dtdocbook/doc2sdl/docbook.tcl +++ b/cde/programs/dtdocbook/doc2sdl/docbook.tcl @@ -123,24 +123,6 @@ if {[info commands OutputString] == ""} { } -# set up a default string compare routine so everything works even -# if run outside of instant(1); it won't really be i18n safe, but -# it'll give us a dictionary sort -if {[info commands CompareI18NStrings] == ""} { - proc CompareI18NStrings {string1 string2} { - set string1 [string toupper $string1] - set string2 [string toupper $string2] - if {$string1 > $string2} { - return 1 - } else if {$string1 < $string2} { - return -1 - } else { - return 0 - } - } -} - - # emit a string to the output stream proc Emit {string} { OutputString $string @@ -1624,10 +1606,14 @@ proc EndPart {} { # check that all the glossed terms have been defined foreach name [array names currentGlossArray] { - if {[lindex $currentGlossArray($name) 1] != "defined"} { - set glossString [lindex $currentGlossArray($name) 2] - UserError "No glossary definition for \"$glossString\"" no - } + if {[info exists currentGlossArray($name)]} { + if {[lindex $currentGlossArray($name) 1] != "defined"} { + set glossString [lindex $currentGlossArray($name) 2] + UserError "No glossary definition for \"$glossString\"" no + } + } else { + puts stderr "EndPart: currentGlossArray: index does not exist: '$name'" + } } # delete this glossary array @@ -2195,6 +2181,7 @@ proc SortAndEmitGlossary {popForm} { set names [array names currentGlossArray] foreach name $names { + # puts stderr "JET0: name: $name" upvar 0 currentGlossArray($name) glossEntryList # skip this array entry if we've already emitted it; mark as @@ -2213,9 +2200,15 @@ proc SortAndEmitGlossary {popForm} { append sortArray($sortAs) $content } - set names [lsort -command CompareI18NStrings [array names sortArray]] - foreach name $names { - Emit $sortArray($name) + set idxnames [lsort -dictionary [array names sortArray]] + + foreach name $idxnames { + # puts stderr "JET1: name: $name" + if {[info exists sortArray($name)]} { + Emit $sortArray($name) + } else { + puts stderr "SortAndEmitGlossary: sortArray index does not exist: '$name'" + } } if {[string toupper $popForm] == "POPFORM"} { @@ -2473,32 +2466,36 @@ proc WriteIndex {} { set file [open "${baseName}.idx" w] - # sort the index using our special I18N safe sort function that - # gives us a dictionary (case insensitive) sort - set names [lsort -command CompareI18NStrings [array names indexArray]] + # sort the index - if {[set length [llength $names]]} { + set idxnames [lsort -dictionary [array names indexArray]] + + if {[set length [llength $idxnames]]} { set oldLevel 0 puts $file "" - foreach name $names { - set thisEntry $indexArray($name) - switch [lindex $thisEntry 0] { - 1 { switch $oldLevel { - 1 { puts $file "" } - 2 { puts $file "\n" } - 3 { puts $file "\n\n" } + foreach name $idxnames { + if {[info exists indexArray($name)]} { + set thisEntry $indexArray($name) + switch [lindex $thisEntry 0] { + 1 { switch $oldLevel { + 1 { puts $file "" } + 2 { puts $file "\n" } + 3 { puts $file "\n\n" } } - } - 2 { switch $oldLevel { - 2 { puts $file "" } - 3 { puts $file "\n" } + } + 2 { switch $oldLevel { + 2 { puts $file "" } + 3 { puts $file "\n" } } - } - 3 { if {$oldLevel == 3} { puts $file "" } } - } - puts -nonewline $file "" - puts -nonewline $file [lindex $thisEntry 3] - set oldLevel [lindex $thisEntry 0] + } + 3 { if {$oldLevel == 3} { puts $file "" } } + } + puts -nonewline $file "" + puts -nonewline $file [lindex $thisEntry 3] + set oldLevel [lindex $thisEntry 0] + } else { + puts stderr "WriteIndex: index does not exist: '$name'" + } } switch $oldLevel { @@ -2547,10 +2544,10 @@ proc FootnoteRef {idref} { # add an element to the current SNB - try to reuse an entry if # possible -proc AddToSNB {type data} { +proc AddToSNB {stype data} { global currentSNB nextId - set index "$type::$data" + set index "${stype}::${data}" if {[info exists currentSNB($index)]} { set snbId $currentSNB($index) diff --git a/cde/programs/dtdocbook/instant/Imakefile b/cde/programs/dtdocbook/instant/Imakefile index 9330fd4df..0969f10b6 100644 --- a/cde/programs/dtdocbook/instant/Imakefile +++ b/cde/programs/dtdocbook/instant/Imakefile @@ -2,10 +2,22 @@ XCOMM $XConsortium: Imakefile /main/6 1996/11/29 11:06:09 rswiston $ XLATESRC = $(DTSVCSRC)/DtUtil2 -INCLUDES = -I../lib/tptregexp -I../tcl -I$(XLATESRC) +TCLINC = +TCLLIB = + +#if defined(LinuxArchitecture) +TCLINC = -I/usr/include/tcl +TCLLIB = -ltcl +#elif defined(FreeBSDArchitecture) || defined(OpenBSDArchitecture) +TCLINC = -I/usr/local/include/tcl8.6 +TCLLIB = -ltcl86 +#endif + +INCLUDES = -I../lib/tptregexp -I$(XLATESRC) $(TCLINC) DEPLIBS = $(DEPDTSVCLIB) LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \ --L../lib/tptregexp -ltptregexp ../tcl/libtcl.a + -L../lib/tptregexp -ltptregexp $(TCLLIB) + #if defined(SunArchitecture) EXTRA_LIBRARIES = -lsocket -lnsl -lgen -lm #else diff --git a/cde/programs/dtdocbook/instant/general.h b/cde/programs/dtdocbook/instant/general.h index c2f360e83..413e9aabb 100644 --- a/cde/programs/dtdocbook/instant/general.h +++ b/cde/programs/dtdocbook/instant/general.h @@ -324,9 +324,3 @@ void PrintElemTree(Element_t *); void PrintStats(Element_t *); void PrintIDList(); -/* ----- other declarations ----- */ - -#ifdef ultrix -#define strdup(s) strcpy((char *)malloc(strlen(s)+1), s) -#endif - diff --git a/cde/programs/dtdocbook/instant/main.c b/cde/programs/dtdocbook/instant/main.c index 09554a490..7dfe91c60 100644 --- a/cde/programs/dtdocbook/instant/main.c +++ b/cde/programs/dtdocbook/instant/main.c @@ -111,19 +111,15 @@ extern void Browse(); static int TclPrintLocation(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]); + const char *argv[]); static int DefaultOutputString(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]); -static int CompareI18NStrings(ClientData clientData, - Tcl_Interp *interp, - int argc, - char *argv[]); + const char *argv[]); static int TclReadLocaleStrings(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]); + const char *argv[]); char *GetOutFileBaseName(); char * @@ -208,17 +204,6 @@ main( 0, 0); - /* Add a function to the interpreter to compare to strings. Our - * comparison will unmung any i18n characters (see - * {Un}EscapeI18NChars()) and uppercase the strings before - * comparison to insure we get a dictionary sort. We also use the - * nl_strcmp() function to get proper i18n collation */ - Tcl_CreateCommand(interpreter, - "CompareI18NStrings", - CompareI18NStrings, - 0, - 0); - /* Add a function to read a localized set of data from a file. * We'll make sure the munging takes place so we can parse it * in Tcl and any strings we get will output properly when @@ -356,12 +341,11 @@ static char *UnEscapeI18NChars( static int DefaultOutputString(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]) + const char *argv[]) { -#define LOCAL_BUFFER_LENGTH 128 - char *string, *pString, *pArgv; - char localBuffer[LOCAL_BUFFER_LENGTH]; - int retCode, stringLength; + char *string = NULL, *pString = NULL; + const char *pArgv = NULL; + int retCode = 0, stringLength = 0; if (argc < 2) { Tcl_SetResult(interpreter, "Missing string to output", TCL_VOLATILE); @@ -375,14 +359,10 @@ static int DefaultOutputString(ClientData clientData, /* leave room for worst case expansion plus quotes plus null */ pArgv = argv[1]; - stringLength = (2 * strlen(pArgv)) + 3; + stringLength = (3 * strlen(pArgv)) + 3; - /* try to use automatic buffer; use malloc if string is too large */ - if (stringLength <= LOCAL_BUFFER_LENGTH) { - string = localBuffer; - } else { - string = malloc(stringLength); - } + string = Tcl_Alloc(stringLength); + memset(string, 0, stringLength); pString = string; @@ -390,109 +370,69 @@ static int DefaultOutputString(ClientData clientData, * any characters that will throw Tcl for a loop */ *pString++ = '"'; while (*pArgv) { - switch (*pArgv) { - case '{': - case '}': - case '"': - case '\'': - case '[': - case ']': - case '$': - case '\\': - *pString++ = '\\'; - } - *pString++ = *pArgv++; + if (*pArgv & 0x80) + { + /* 8-bit data - need to encode since modern Tcl expects + * any "binary" (8-bit) data in strings to be proper UTF-8 + * encoded. We aren't doing that (yet), so convert any + * detected 8b characters into a \xNN format. + * + * This code should be unnecessary when we switch to UTF8. + */ + char fmt[16]; + snprintf(fmt, 16, "%02x", (int)*pArgv & 0xff); +#if 0 + fprintf(stderr, "JET: converted 0x%02x to '%s'\n", + *pArgv, fmt); +#endif + /* copy the 4 bytes into the string */ + *pString++ = '\\'; + *pString++ = 'x'; + *pString++ = fmt[0]; + *pString++ = fmt[1]; + pArgv++; + } + else + { + switch (*pArgv) { + case '{': + case '}': + case '"': + case '\'': + case '[': + case ']': + case '$': + case '\\': + *pString++ = '\\'; + } + *pString++ = *pArgv++; + } } *pString++ = '"'; *pString++ = 0; /* put the string to the output */ - retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, 0); - - /* free the string if we're not using the automatic buffer */ - if (string != localBuffer) { - free(string); + retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, + (char *)NULL); +#if 0 + /* JET*/ + if (retCode != TCL_OK) + { + fprintf(stderr, "JET: retCode = %d, LEN = %d STRING = '%s'\n", + retCode, strlen(string), string); + fprintf(stderr, "\tstring[1] = 0x%02x\n", string[1]); } +#endif + Tcl_Free(string); /* and ripple up any error code we got from the "puts" */ return retCode; } - -static int CompareI18NStrings(ClientData clientData, - Tcl_Interp *interp, - int argc, - char *argv[]) -{ - int ret_val, len; - char *ret_string, *cp; - - if (argc < 3) { - Tcl_SetResult(interpreter, - "Missing string(s) to compare", - TCL_VOLATILE); - return TCL_ERROR; - } - - if (argc > 3) { - Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE); - return TCL_ERROR; - } - - /* unmung the two strings (see {Un}EscapeI18NChars()) */ - UnEscapeI18NChars(argv[1]); - UnEscapeI18NChars(argv[2]); - - /* upper case the strings to insure a dictionary sort */ - cp = argv[1]; - while (*cp) { - if ((len = mblen(cp, MB_CUR_MAX)) == 1) { - if (isalpha(*cp)) { - *cp = toupper(*cp); - } - cp++; - } else { - if (len > 0) - cp += len; - else - break; /* JET - we should be done here... */ - } - } - cp = argv[2]; - while (*cp) { - if ((len = mblen(cp, MB_CUR_MAX)) == 1) { - if (isalpha(*cp)) { - *cp = toupper(*cp); - } - cp++; - } else { - if (len > 0) - cp += len; - else - break; /* JET - we should be done here... */ - } - } - - /* compare the strings using an I18N safe sort */ - ret_val = strcoll(argv[1], argv[2]); - if (ret_val > 0) { - ret_string = "1"; - } else if (ret_val < 0) { - ret_string = "-1"; - } else { - ret_string = "0"; - } - - Tcl_SetResult(interpreter, ret_string, TCL_VOLATILE); - - return TCL_OK; -} - - static int TclPrintLocation(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]) + const char *argv[]) { if (argc > 1) { Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE); @@ -917,27 +857,27 @@ EscapeI18NChars( static char * -ReadLocaleStrings(char *file_name, int *ret_code) { -int fd; -char *pBuf; -char *i18nBuf; -off_t size; -struct stat stat_buf; +ReadLocaleStrings(const char *file_name, int *ret_code) { + int fd; + char *pBuf; + char *i18nBuf; + off_t size; + struct stat stat_buf; fd = open(file_name, O_RDONLY); if (fd == -1) { *ret_code = 1; - return ""; + return NULL; } fstat(fd, &stat_buf); size = stat_buf.st_size; - pBuf = malloc(size+1); - pBuf[size] = 0; + pBuf = Tcl_Alloc(size+1); + memset(pBuf, 0, size+1); if (read(fd, pBuf, size) != size) { *ret_code = 2; - return ""; + return NULL; } i18nBuf = EscapeI18NChars(pBuf); @@ -952,10 +892,10 @@ struct stat stat_buf; static int TclReadLocaleStrings(ClientData clientData, Tcl_Interp *interp, int argc, - char *argv[]) { -char *pBuf; -int ret_code; -char errorBuf[512]; + const char *argv[]) { + char *pBuf; + int ret_code; + char errorBuf[512]; if (argc > 2) { Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE); diff --git a/cde/programs/dtdocbook/instant/translate.c b/cde/programs/dtdocbook/instant/translate.c index 987c459db..70e68bd90 100644 --- a/cde/programs/dtdocbook/instant/translate.c +++ b/cde/programs/dtdocbook/instant/translate.c @@ -207,7 +207,7 @@ ExpandVariables( if (*ip == VDELIM && *(ip+1) == L_CURLY && *(ip+2) != '_') { ip++; ip++; /* point at variable name */ - len + 2; + len += 2; vp = vbuf; /* Look for matching (closing) curly. (watch for nesting) * We store the variable content in a tmp buffer, so we don't @@ -294,9 +294,16 @@ CallInterpreter( ) { int result; - char line[20]; int recursive; +#if 0 + if (ib) + { + fprintf(stderr, "JET: %s: IB = '%s'\n", __FUNCTION__, + ib); + } +#endif + /* save the value of this "e" to be used by Tcl_PrintLocation in * the case of a user error */ diff --git a/cde/programs/dtdocbook/instant/util.c b/cde/programs/dtdocbook/instant/util.c index fa726e0f7..f4b081e2c 100644 --- a/cde/programs/dtdocbook/instant/util.c +++ b/cde/programs/dtdocbook/instant/util.c @@ -525,7 +525,7 @@ OutputString( int track_pos ) { - char c, *sdata, *cp; + char c = 0, *sdata, *cp; static int char_pos; /* remembers our character position */ static int interp_pos; /* like char_pos but when output is to interp */ int *ppos; /* points to appropriate line position var */ @@ -678,8 +678,8 @@ static int CheckOutputBuffer( */ int FFlush(FILE *stream) { -if (stream) return fflush(stream); -return 0; + if (stream) return fflush(stream); + return 0; } @@ -722,8 +722,8 @@ int Putc( if (result != TCL_OK) { fprintf(stderr, "interpreter error \"%s\" at line %d executing:\n", - interpreter->result, - interpreter->errorLine); + Tcl_GetStringResult(interpreter), + Tcl_GetErrorLine(interpreter)); fprintf(stderr, "\"%s\"\n", commandBuf); return EOF; } @@ -787,8 +787,8 @@ int FPuts( if (result != TCL_OK) { fprintf(stderr, "interpreter error \"%s\" at line %d executing:\n", - interpreter->result, - interpreter->errorLine); + Tcl_GetStringResult(interpreter), + Tcl_GetErrorLine(interpreter)); fprintf(stderr, "\"%s\"\n", pBuff); if (pBuff != commandBuf) free(pBuff); return EOF; diff --git a/cde/programs/dtdocbook/sgmls/ChangeLog b/cde/programs/dtdocbook/sgmls/ChangeLog deleted file mode 100644 index b002c5bd4..000000000 --- a/cde/programs/dtdocbook/sgmls/ChangeLog +++ /dev/null @@ -1,1817 +0,0 @@ -Mon Feb 22 09:59:16 1993 James Clark (jjc at jclark) - - * Version 1.1 released. - - * md1.c (fixdatt): New function. - (mdnadl): For attlist #notation that occurs after an entity with - the specified notation has been declared, call fixdatt rather - that giving an error. - * sgmlfnsm.h: Declare fixdatt. - * md2.c (storedatt): Remove call to adlval. - (mdextid): Precede calls to storedatt with call to adlval. - * msg.h: Change message 218. - - * sgmls.c (read_line): Cast UINT_MAX to unsigned. - - * Makefile.bcc: Add optimization flags for Borland C++ 3.1. - - * stklen.c: Increase to 14k. - -Sat Feb 6 19:29:01 1993 James Clark (jjc at jclark) - - * etype.h (EMM): New etdmin flag. - * md1.c (mdelem): Set EMM flag if minus was explicitly specified - for end tag minimization. - (etdadl): Give an error if there's a CONREF element and the EMM - flag was set, instead of checking OMITTAG and the EMO flag. - (mdelem): Likewise for declared content of EMPTY. - -Wed Feb 3 11:08:02 1993 James Clark (jjc at jclark) - - * unix.cfg: Add LIMITS_H_MISSING define. - * configure: Handle LIMITS_H_MISSING. - * std.h: Don't include is LIMITS_H_MISSING is defined. - In this case guess UINT_MAX, based on sizeof(unsigned int). - -Mon Feb 1 21:49:52 1993 James Clark (jjc at jclark) - - * sgmls.c (read_line): Don't allow buffer length to exceed - UINT_MAX. - (E_LINELENGTH): New error. - * std.h: Include - -Sun Jan 31 23:58:55 1993 James Clark (jjc at jclark) - - * pars1.c (destack): Don't give error message if conrefsw is set. - -Sat Jan 30 21:36:36 1993 James Clark (jjc at jclark) - - * lineout.c (process_document): Add argument that says whether - document is subdocument. Don't output appinfo if document is - subdocument. - * appl.h: Change declaration. - * main.c (main): Change caller. - -Fri Jan 15 04:30:17 1993 James Clark (jjc at jclark) - - * Makefile: Add formatted man pages to distribution. Include - rules to build them. - - * sgmls.c (RECHAR): Delete definition. - - * appl.h: Delete comma after last enumerator. - -Mon Jan 11 09:51:43 1993 James Clark (jjc at jclark) - - * sgmldecl.c (sdnames): Size of temp buffer should be - REFNAMELEN+1. - -Sun Jan 10 22:37:20 1993 James Clark (jjc at jclark) - - * rast.c (do_file): Add default case to switch. - -Fri Jan 8 09:57:07 1993 James Clark (jjc at jclark) - - * synrf.c: Delete NONSGML. Add POSTLINK. - * synxtrn.h: Corresponding changes. - -Thu Jan 7 20:00:07 1993 James Clark (jjc at jclark) - - * rast.c (do_file): Free attributes when skipping subdocument. - - * sgmls.c (sgmls_free): Free entity.u.external.filenames. - - * latin1.c, ebcdic.h (SHIFTNON, UNSHIFTNON): Use simpler - definitions. - -Wed Jan 6 17:36:50 1993 James Clark (jjc at jclark) - - * pcbrf.c (et0a): Change action for spcr to DAS_. - - * pars2.c (parse): In case ERX_ catch references to entities that - are not allowed in replaceable character data. - (parselit): Delete case PIE_. In case DEF_ don't catch references - to external data entities. - - * md1.c (mdelem): Test for length of rank stem and rank suffix was - off by 2. - - * pars2.c (parsemd): For case NUM, use NU not NUM for lexical class. - - * md1.c (mdattdef): Uncomment check for ID attribute with default - value. - -Sun Jan 3 20:30:34 1993 James Clark (jjc at jclark) - - * sgmldecl.h: Delete declaration of appinfo[]. - - * sgmldecl.c (sdnames): Return if keyword unrecognized. - - * synxtrn.h: Delete KDTD. Renumber K*. - * synrf.c: Delete "DTD". - - * sgmldecl.c: Move definition of REFLITLEN to... - * entity.h: - * md2.c (mdextid): Length of minimum literal must not exceed - REFLITLEN. - -Sat Jan 2 17:03:11 1993 James Clark (jjc at jclark) - - * pars1.c (checkdtd): Check for undefined short reference maps if - -u flag is used. - - * md2.c (mdsrmdef): Don't free the map on error if it was - previously used in a USEMAP declaration. - -Fri Jan 1 19:37:38 1993 James Clark (jjc at jclark) - - * entgen.c (sysidgen): Return 0 if no non-empty filenames were found. - -Thu Dec 31 02:52:38 1992 James Clark (jjc at jclark) - - * pars2.c (charrefn): Split last part off into... - (datachar): New function. - (charrefa): Split part off into... - (setcurchar): New function. - (parse): In case NON_, call datachar(). - * sgmlfnsm.h: Declare new functions. - - * sgmls.h: Use separate length for pi. - * sgmls.c (sgmls_next): Handle this. - * rast.c (output_processing_instruction): Add length argument. - (do_file): Change caller. - * sgmlsasp.c (output_pi): Add length argument. - (do_file): Change caller. - - * pars2.c (parse): In case NSC_, give an error. - * pcbrf.c (pcblitc, pcbmds, pcblitv): Use SYS_ action for NSC. - (pcbmsi): Get rid of NS4 state. Handle NSC like NON. - * pars2.c (charrefn): Only potentially confusing characters need - to be prefixed with DELNONCH. - * msg.h: Change message 4 so as not to say `in markup'. - * pars2.c (parse): When handling SYS_, if non-SGML character was - DELNONCH skip another character. - -Wed Dec 30 11:00:15 1992 James Clark (jjc at jclark) - - * lextoke.h: Add SP class for SPACE. SEP is now just SEPCHAR. - * pcbrf.c (pcbval): Change accordingly. Don't allow RS, RE or SEPCHAR - during tokenization. - * lextaba.c (lextoke): Change code for space to SP. - * pars2.c (parseseq): Test that it's not a space in addition to - testing that its code is not SEP. - * sgmldecl.c (sdnaming): Check that class is SP or SEP. - - * sgmlmsg.c: Define HDREE string. - (printit): Use HDREE string when the current character is EOS. - - * pars2.c (charrefa): Rewrite. If reading from an internal entity, - need to copy the entity before changing it. - * source.h (struct source): Add copied member. - (COPIEDSW): New macro. - * sgml2.c (entopen): Initialize COPIEDSW. - (entget): If internal entity was copied, free copy before popping - SCB stack. - - * entity.h (SHIFTNON, UNSHIFTNON): Move definitions to latin1.h - * ebcdic.h (SHIFTNON, UNSHIFTNON): Provide appropriate - definitions. - - * appl.h: Move DELNONCH, DELCDATA, DELSDATA to latin1.h and ebcdic.h. - * ebcdic.c: Use these. - * entity.h (struct switches): Remove delnonch, delcdata and - delsdata members. - * main.c (swinit): Don't initialize delnonch. - * sgmlio.c (ioinit): Don't save swp->delnonch. - (ioread): Use DELNONCH constant. - * sgmlmsg.c (swdelcdata, swdelsdata, swdelnonch): Deleted. - (msginit): Don't initialize these. - (printit): Use DELNONCH constant. Can now use switch statement. - (transparm): Use constants for delimiters. - * sgmldecl.c (sdinit): Use DEL* constants. - * sgmldecl.c (sdnaming): Use DELNONCH constant. - * pars2.c (tokdata): Likewise. - (parselit): Likewise. - * sgml1.c (sgmlset): Don't initialize nonchbuf. Don't change - lexical codes for sw.delnonch. - * sgmlxtrn.c (nonchbuf): Initialize first character. - * lextaba.c (lexcnm, lexcon, lexlms): Make code for DELNONCH be - NSC. - * synxtrn.h (struct lexcode): Delete lmnsc member. - * lexrf.c (lex): Change initialization accordingly. - * lexcode.h: Move definition of NSC to lextaba.c. - - * Get rid of BADCHAR hack by having entity escape magic characters - with delnonch just as happens in internal entities. - * sgmldecl.c (sdinit): Don't make BADCHAR a magic character. - * pars2.c (parse): When handling NON_ don't check if character is - BADCHAR. When handling NSC_, give an error if at file level. - * latin.h, ebcdic.h (BADCHAR): Deleted. - * ebcdic.c: Don't use BADCHAR. - * sgmlio.c (ioinit): Don't make BADCHAR bad. Remember - swp->delnonch in delnonch. - (iocont): Count a bad character as 2 characters. - (ioread): Prefix bad character with delnonch. Make sure there's - always room for two characters plus end of buffer. - * source.h (struct source): Add nextchar member. - (NEXTC): New macro. - * sgml2.c (scbset): Update NEXTC. - * sgmlaux.h (struct location): Add nextchar member. - * sgml1.c (get_location): Update nextchar. - * sgmlmsg.c (IS_MAGIC): Deleted. - (printit): Print the real next character if curchar is delnonch. - * sgmlio.c (isbad): Rename to ismagic. - * msg.h: Delete message 152. - - * appl.h (ADDNONCH): Move to entity.h. - * entity.h (struct switches): Delete addnonch member. - (UNSHIFTNON, SHIFTNON): New macro. - * main.c (swinit): Don't initialize addnonch. - * lineout.c (print_string): Use UNSHIFTNON. - * sgmlmsg.c (transparm): Likewise. - * sgmldecl.c (sdnaming): Likewise. - * pars2.c (shiftnon): Deleted. - * sgmlfnsm.h: Delete prototype. - * pars2.c (parse, charrefn): Use SHIFTNON macro instead of - shiftnon function. - * action.h (NSC_): New action. - * pars2.c (parse): Handle NSC_. - * pcbrf.c: Undo change of Jun 10, except to pcbmsi. - For parse modes which use NON_ action, handle NSC class by using - NSC_ action and transforming state as for NON class. - -Tue Dec 15 10:31:43 1992 James Clark (jjc at jclark) - - * lineout.c (process_document); Don't define subdoc if suppsw is set. - - * Makefile (OBJS3): Add getopt.o. - - * sgmlio.c (ioclose): Don't call closefile if fp is 0. - -Thu Dec 3 09:46:41 1992 James Clark (jjc at jclark) - - * md1.c (mdattdef): Check that normalized length of CDATA default - value does not exceed LITLEN. - - * entity.h (struct switches): Add die member. - * main.c (die): New function. - (swinit): Initialize die. - * sgmlmsg.c (msginit): Initialize die. - (msgprint): Call die for EXITERR errors. - - * main.c (OPTIONS): Rename to options. Rewrite as an array of - char so as to avoid duplication. - -Tue Dec 1 07:19:47 1992 James Clark (jjc at jclark) - - * Makefile.bcc: rast needs getopt.obj. - -Mon Nov 30 15:52:03 1992 James Clark (jjc at jclark) - - * sgmldecl.c (charset_map, capset_map, sdfeatures): Fully bracket - initializer. - * sgml1.c (sgmltab): Likewise. - * sgmlxtrn.c (dctab, deftab, dvtab, enttab, exttab, extettab, - funtab, mstab, pubcltab): Likewise. - -Thu Nov 26 11:44:40 1992 James Clark (jjc at jclark) - - * md2.c (mdentity): Check for duplicate definition and earlier - usage of default entity after parsing complete definition. - -Fri Nov 20 05:19:07 1992 James Clark (jjc at jclark) - - * sgmlsasp.c: Delete definitions of RECHAR and RSCHAR. Use - definitions from config.h. - - * rast.c (output_char): Use definitions of RECHAR, RSCHAR and - TABCHAR from config.h. - - * lexrf.c (lex): Use GENRECHAR rather than '\b' for genre field. - - * sgmldecl.h (CANON_NONSGML, CANON_DATACHAR): Move definitions - into ascii.h and ebcdic.h. - * genlex.c (main): Characters that aren't special in some way need - to be treated as NONSGML or DATACHAR depending on whether they are - the number of a shunned character. - -Thu Nov 19 06:32:37 1992 James Clark (jjc at jclark) - - * ecbdic.h: Use a better formal public identifier. - - * cms.cfg (DEFAULT_PATH, PATH_FILE_SEP, SYSID_FILE_SEP, - MIN_DAT_SUBS_FROM, MIN_DAT_SUBS_TO): Fix definitions. - - * ebcdic.c: Include ebcdic.h and use character definitions that it - provides. - -Tue Nov 17 05:46:34 1992 James Clark (jjc at jclark) - - * cms.cfg: New file. - * ebcdic.h: New file. - * Makefile.cms: New file. - * genlex.c: New file. - * ebcdic.c: New file. - * Makefile (lextabe.c, genlex): New targets. - * Makefile: Add new files to distribution. - - * lexrf.c: Separate out character set dependent parts into... - * lextaba.c: New file. - * lexcode.h: New file. Move definitions needed by lextaba.c and - lexrf.c here. - * sgmldecl.c (asciicharset): Move definition into lextaba.c. - Move definitions of UNKNOWN etc constants into sgmldecl.h. - * sgmldecl.h: Declare asciicharset. - - * entity.h: Separate character set dependent parts into... - * latin1.h: New file. - * *.cfg: Include latin1.h. - - * lexrf.c (lex): Rewrite short reference delimiter strings that use - RS, RE or TAB so as to use RSCHAR, RECHAR and TABCHAR definitions. - - * lexrf.c (lextran): Don't use character constants. - - * lexrf.c (lextran): Fix entry for character number 172. - -Mon Nov 16 12:39:41 1992 James Clark (jjc at jclark) - - * arc*.c: Rename to *.c. - * mod*.c: Rename to *.c. - * Makefile, Makefile.vms, Makefile.bcc: Corresponding changes. - - * msg.h: Make message 58 a warning. Rewrite message. - -Sun Nov 15 11:41:04 1992 James Clark (jjc at jclark) - - * main.c (munge_program_name): Use isupper() and tolower(). - - * main.c (main): Don't allow -a option. - -Sat Nov 14 10:34:47 1992 James Clark (jjc at jclark) - - * lineout.c (attribute_type_string): Don't distinguish ID and - IDREF attributes from tokenized attributes. - * sgmls.h (sgmls_attribute_type): Delete SGMLS_ATTR_ID and - SGMLS_ATTR_IDREF. - * sgmls.c (parse_attribute, sgmls_free_attribute): Don't handle ID - and IDREF attribute types. - * sgmlsasp.c (output_attribute): Don't handle SGMLS_ATTR_ID and - SGMLS_ATTR_IDREF. - * rast.c (output_attribute): Likewise. - - * main.c (store_sgmldecl): Handle possibility that SIGTERM is not - defined. - -Thu Nov 5 11:01:35 1992 James Clark (jjc at jclark) - - * msg.h: In message 3, change `NAMELEN' to `NAMELEN or LITLEN'. - - * modmd1.c (mdattdef): Handle CDR action when parsing default - value. - -Thu Oct 29 17:19:13 1992 James Clark (jjc at jclark) - - * lineout.c (output_conforming): Only generate output if !suppsw. - -Wed Oct 28 10:29:28 1992 James Clark (jjc at jclark) - - * rast.c (main): Add -o option to specify output file. Avoid use of - temporary file when -o specified. - (usage): New function. - -Sun Oct 25 10:30:18 1992 James Clark (jjc at jclark) - - * modmd1.c (adlfree): New function. - (mdadl, mdnadl, mdattdef): Fix some leaks. - * sgmlfnsm.h: Declare adlfree. - - * main.c (OPTIONS): Correct definitions that apply when - CANT_REDIRECT_STDERR is defined. - - * Makefile (dist): Fix up the compilation options in - the Makefile. - -Sat Oct 24 14:02:35 1992 James Clark (jjc at jclark) - - * entity.h: Define STDINNAME. - * main.c (main): Don't require an argument. - (make_docent): Treat no arguments as equivalent to `-'. - * entgen.c (entgen): Don't search for `-'. - * modsgml2.c (filepend): Pass buffer as argument to - iopend(). - * sgmlaux.h (iopend): Fix declaration. - * sgmlio.c (openfile, closefile, isreg): New functions. - (ioopen): Use openfile. Initialize pendbuf. - (ioclose): Use closefile. - (iopend, iocont): Handle unseekable files. - (ioread): Return the contents of pendbuf if pendbuf is - non-NULL. Handle the case where fgetpos fails. - Use openfile and closefile. - * unix.cfg, dos.cfg: Add HAVE_SYS_STAT_H configuration option. - * configure: Handle HAVE_SYS_STAT_H. - -Fri Oct 23 11:38:06 1992 James Clark (jjc at jclark) - - * Makefile.bcc: Handle rast. - - * Makefile (install): Rewrite. - - * sgmls/sgmls.c (unescape1, parse_data): Cast value of escape - sequence. - - * lineout.h (CONFORMING_CODE): New output command. - * lineout.c (output_conforming): New function. - * appl.h: Declare it. - * main.c (main): Call output_conforming() if appropriate. - * sgmls.h: New event SGMLS_EVENT_CONFORMING. - * sgmls.c (sgmls_next): Handle CONFORMING_CODE. - * sgmlsasp.c (do_file): Handle SGMLS_EVENT_CONFORMING. - - * CHANGES: Rename to - * NEWS. - * Makefile: Change definition of MISC accordingly. - - * rast.c: New file. - * rast.man: New file. - * Makefile: Handle rast. - (install.man): Rewrite. - - * main.c (print_caps): Deleted. - (make_argv): Use -c rather than -z. Always pass -c to - subprocesses. - (main): Delete -c option. Rename -z to -c. - (OPTIONS, usage): Change accordingly. - (capsw): Deleted. - -Wed Oct 21 20:13:02 1992 James Clark (jjc at jclark) - - * modpars2.c (attval): Decrement already tokenized value before - comparing it to a FIXED value. - -Tue Oct 20 16:45:34 1992 James Clark (jjc at jclark) - - * modsgml2.c (filepend): Don't suspend the file if it's already - suspended. - -Sun Oct 18 15:24:13 1992 James Clark (jjc at jclark) - - * sgmls.pl: Handle f, p, s commands. Fix handling of S, E, and N - commands. - (esc, esc_data): Don't handle \s. Ignore \012. - -Sat Oct 17 12:48:56 1992 James Clark (jjc at jclark) - - * sgmls.c (parse_data): Translate \n into '\015'. - (unescape_file): New function. - (sgmls_next, parse_location): Use unescape_file. - * sgmlsasp.c (output_data_char): New function. - (output_data, output_pi): Use output_data_char. - - * sgmls.c (parse_data): Don't support \s. - (unescape1): Likewise. - - * lineout.c (print_string): Don't strip RSs. - - * sgmls.c (add_attribute): New function. - (sgmls_next): Use add_attribute. - - * lineout.c (process_subdoc): Handle the possibility that `id' is - 0. - * appl.h (E_SUBDOC): Declare it. - * main.c (errlist): Add error message for E_SUBDOC. - * modsgml2.c (entopen): Handle the possibility that etx.x is 0 for - external entities. - * modmd1.c (mddtds): If entgen fails, behave as if there was no - external DTD. - * modmd2.c (mdentity): Don't give up if entgen fails. - * msg.h: New message 149, 229. Make errors 147 and 148 warnings. - - * entgen.c (field): Fix typo in handling of field 'D' for subdocs. - -Fri Oct 16 09:55:40 1992 James Clark (jjc at jclark) - - * sgmls.h (struct sgmls_event): Delete `subdoc' from union. - (struct sgmls_external_entity): Add pubid and sysid members. - * sgmls.c (parse_filenames): Deleted. - (parse_external_entity, parse_subdoc_entity): Don't call - parse_filenames. - (parse_notation): Don't parse pubid and sysid. - (define_external_entity): Fill in pubid, sysid and filenames - fields from stored values in sp. - (define_notation): Fill in pubid and sysid fields from stored - values in sp. - (sgmls_next): Handle SYSID_CODE, PUBID_CODE and FILE_CODE. - For {START,END}_SUBDOC_CODE look up the subdoc entity. - (sgmls_free): Free the pubid, sysid and files members of sp. - Free the pubid and sysid fields of external entities. - (struct sgmls): Add files, nfiles, sysid and pubid members. - (sgmls_create): Initialize them. - -Thu Oct 15 10:53:33 1992 James Clark (jjc at jclark) - - * adl.h (struct ne): Add nepubid and nesysid members. - (NEPUBID, NESYSID): New macros. - (NEDCNPUBID, NEDCNSYSID, NEDCNDEFINED): New macros. - * msg.h: Deleted message 149. - * entity.h (struct dcncb): Delete dcnid member. Add sysid and - pubid members. - * modmd2.c (mdentity): Fill in nepubid and nesysid. - (mdnot): Don't call entgen. Fill in sysid, pubid and defined - members of dcb. - * entgen.c (nentgen): Deleted. - (entgen): Don't call nentgen. - (field): When checking for Y substitution storage class must be <= - * lineout.h (PUBID_CODE, SYSID_CODE, FILE_CODE): New codes. - * lineout.c (process_document): Output a definition for a - subdocument entity before processing it. - (print_id): Rewrite. - (output_external_entity, output_subdoc): Add two additional - arguments. Change printing of external identifiers. - (output_notation): Delete `id' argument. Add two additional - arguments. Change printing of external identifiers. - (define_external_entity, handle_single_token): Change callers. - (print_filename): Don't use \s. - * modpars2.c (aenttst): Use NEDCNDEFINED rather than NEDCNID. - * modsgml2.c (entopen): Likewise. - * modpars1.c (checkdtd): Use `defined' member of dcncb in place of - `dcnid'. - * traceset.c (tracedcn): Don't use `dcnid' member. - - * modsgml1.c (sgmlend): Merge loops. Divide maxsubcap values by - cappoints values. - * main.c (write_caps): Use RACT format. - (get_subcaps): Read new format. - -Wed Oct 14 09:54:19 1992 James Clark (jjc at jclark) - - * modmd2.c (mdentity): Free pne after errors 147 or 148. - - * modmd2.c (mdnot): Free ntx on error. - -Mon Sep 28 13:05:35 1992 James Clark (jjc at jclark) - - * Version 1.0 released. - -Fri Sep 25 11:17:34 1992 James Clark (jjc at jclark) - - * Makefile.vms: New file. - - * modpars1.c (parsepro): Set rc for STE_ case. - - * modmd2.c (mdentity): For the default entity copy the system and - public identifiers. - - * modmd2.c (mdentity): Free pne if estore != ESN. - -Thu Sep 24 13:39:01 1992 James Clark (jjc at jclark) - - * source.h (struct entity): Add dflt member. - * modsgml2.c (usedef): Set ecb->dflt. - * modmd2.c (mdentity): Check whether earlier existing definition - of entity was defaulted. If so, give a warning and remove this - definition. - * msg.h: New message 228. - -Wed Sep 23 12:14:44 1992 James Clark (jjc at jclark) - - * modpars2.c (attval): Don't pass attribute value as argument to - error 67. - * msg.h: Don't use attribute value in error message. - -Fri Sep 11 15:32:30 1992 James Clark (jjc at jclark) - - * sgmlio.c (ioread): Set f->fp to 0 after closing it if there is - no next file. - (iopend): Don't call fclose if f->fp is 0. - -Mon Aug 31 11:06:57 1992 James Clark (jjc at jclark) - - * Makefile (config.h): Don't use `export'. - -Fri Aug 21 15:12:48 1992 James Clark (jjc at jclark) - - * modsgml2.c (entopen): For ESX and ESC return ENTDATA even if - entity is empty. - * lineout.c (print_data): If n == 0, don't ignore it if it's sdata. - -Tue Aug 18 11:30:38 1992 James Clark (jjc at jclark) - - * modsgml2.c (entref): Use error 35 if it's a parameter entity. - -Mon Aug 17 12:53:48 1992 James Clark (jjc at jclark) - - * source.h (union etext): Delete etd member. - - * Makefile: Include sgml-mode.el. - -Thu Aug 13 15:04:47 1992 James Clark (jjc at jclark) - - * sgmldecl.c (sdcsdesc): Give a warning for an unknown designating - escape sequence. - (sgmlwrsd): Use the system character set as the document character - set. - (DUMMY_CHARSET): Deleted. - * msg.h: New message 227. - - * test: Put out and err files in separate directories. - - * main.c (main): Ignore -a. - (usage): Don't mention -a. - (swinit): Set swambig to 1. - (build_subargv): Don't pass -a. - -Wed Aug 12 22:02:24 1992 James Clark (jjc at jclark) - - * action.h (STE_): New action. - * arcpcbrf.c (es7a): Change action for nms and tagc from PEP_ to STE_. - * modpars1.c (parsepro): Handle STE_. - * modsgml1.c (sgmlnext): Start the document element for DCE_ or MSS_. - -Thu Aug 6 16:42:37 1992 James Clark (jjc at jclark) - - * modpars2.c (parseval): If a number token is terminated by a name - character, give error 17. - -Wed Jul 29 01:49:20 1992 James Clark (jjc at jclark) - - * modpars1.c (startdtd): Allocate an extra character for nmbuf. - * modmd2.c (mdentity): Check that length of parameter entity name - does not exceed NAMELEN - 1. Pass NAMELEN to parsemd when - parsing parameter entity name. - - * msg.h: New message 225. - * modserv.c (sandwich): Move to... - * modmd2.c (sandwich): Return 0 if the result is too long. - * modmd2.c (mdentity): Give an error if the result was too long - after adding bracketing delimiters. - - * msg.h: New message 224. - * modmd1.c (mdattdef): It is an error if the value returned by - vallen exceeds LITLEN. - * modpars2.c (attval): Likewise. - - * sgmls.c (unescape1): If s does not contain a backslash, return - the length of s. - -Tue Jul 28 18:35:54 1992 James Clark (jjc at jclark) - - * action.h (PENR): New action. - * modpars2.c (parsemd): Handle PENR. - * arcpcbrf.c (pr21a): Change actions for ee, com, pero from PCI_ - to PENR. - (sp21, tk21): After ee, state is TK1. - - * modpars2.c (parsegrp, parsengrp): Detect duplicates. - - * modpars1.c (parsepro): Handle EE_. - -Thu Jul 23 12:50:34 1992 James Clark (jjc at jclark) - - * modmd1.c (mdattdef): If anmtgrp returns an error and adlim < - GRPCNT, report that ATTCNT not GRPCNT was exceeded. - -Mon Jun 29 00:46:09 1992 James Clark (jjc at jclark) - - * sgmldecl.c (systemcharset): New charset. - (charset_map): By default assume the system character set is ISO - Latin-1. - (nlextoke, nlextran): New variables. - (setnonsgml): Rename to... - (setlexical): Handle characters made significant by NAMING - section. Use nlextoke and nlextran to munge lexical tables. - (sgmldecl): Call setlexical. - (sdpubsyntax): Delete call to setnonsgml(). - (sdshunchar): Delete calls to setnonsgml(). - (sdnaming): Redo parsing of naming classes. - (sgmlwrsd): Generate NAMING section from lextoke and lextran. - Use system character set as syntax reference character set. - - * msg.h: Remove trailing period from message 218. - -Sun Jun 28 15:59:25 1992 James Clark (jjc at jclark) - - * modpars2.c (tokdata): Insert missing parentheses around - `parmlen -= 2'. - -Sat Jun 20 10:09:39 1992 James Clark (jjc at jclark) - - * Makefile (depend): Use sed { command. - - * Makefile: Pass PREFIX to configure. - * configure: Edit DEFAULT_PATH using PREFIX. - -Mon Jun 15 19:41:55 1992 James Clark (jjc at jclark) - - * configure: More elaborate test for HAVE_EXTENDED_PRINTF. - -Fri Jun 12 13:20:49 1992 James Clark (jjc at jclark) - - * context.c (testend): Set andoptsw to 1 after ending a group. - -Wed Jun 10 16:49:50 1992 James Clark (jjc at jclark) - - * arcpcbrf.c (pcbconm): New state NS0. - (et0, da0, da1): After NSC state changes to NS0. - (pcbmsrc): New state NS0. - (et30, da30): After NSC state changes to NS0. - (pcbmsc): New state NS2. - (et32, da32): After NSC state changes to NS2. - (pcbmsi): New state NS4. - (et34, me34, me35, es34, md34): After NSC state changes to NS4. - - * lineout.c (print_string): Don't recognize character preceded by - DELNONCH as DELCDATA or DELSDATA. - -Tue Jun 9 21:17:15 1992 James Clark (jjc at jclark) - - * modpars1.c (parsepro): Call setdtype() when EOD_ encountered. - Don't call setdtype() or checkdtd() if we gave an error message - for the EOD_. - -Sun Jun 7 09:57:32 1992 James Clark (jjc at jclark) - - * configure: When determining void_ret, use a typedef in order to - catch compilers that can't handle this typedef. - - * replace.c (hash): Cast enumeration type to int. - * sgmls.c (error): Likewise. - * sgmldecl.h: Use #define rather than enum to define *CAP and Q* - constants. - * sgmlmsg.c: Likewise for HDR*. - -Fri May 22 13:31:58 1992 James Clark (jjc at jclark) - - * sgmldecl.c (bufsalloc, bufsrealloc): Allocate entbuf here. - * modpars1.c (commbufs): Don't allocate entbuf here. - -Wed May 20 11:55:42 1992 James Clark (jjc at jclark) - - * Makefile (config.h): Depends on configure and unix.cfg. - - * configure: Pipe yes into man. - - * arclexrf.c: Don't include stdio.h. Use 0 instead of NULL. - - * unixproc.c: Include standard header files before std.h. - - * std.h: Reorder definitions so that all standard headers are - included before conditional definitions of SEEK_SET etc. - -Mon May 18 15:38:35 1992 James Clark (jjc at jclark) - - * modpars2.c (charrefn): Return DAF_ instead of DAS_. - -Mon May 18 08:37:23 1992 James Clark (jjc at jclark) - - * configure: Catch signals when testing for extended printf. - -Sun May 17 09:49:14 1992 James Clark (jjc at jclark) - - * modmd1.c (mdadl, mdelem): Don't dereference nmgrp[0] if it is NULL. - - * replace.c (parse_error): Declare as NO_RETURN. - - * context.c (copypos): Cast unsigned char to int in comparison. - * modmd1.c (mdelem): Likewise. - * modmd2.c (storedatt): Likewise. - * modpars2.c (parsenm): Likewise. - (s2valnm): Likewise. - * sgmlxtrn.[ch]: Make Tstart an int. - * context.c: Don't cast Tstart to int. - * modpars2.c (shiftnon): Cast unsigned char to unsigned in modulus - expression. - * context.c (HITSET, HITOFF): Cast `n' to unsigned in shift - expression. - - * arclexrf.c: Avoid use within comments of character sequences - that will be interpreted as trigraphs. - - * std.h: Don't include getopt.h. - * configure: Don't handle HAVE_GETOPT_H. - * *.cfg: Delete HAVE_GETOPT_H. - * getopt.c, main.c, sgmlsasp.c: Include getopt.h. - * getopt.h: Don't use prototypes. - - * msgcat.h: Don't use prototypes. - -Sat May 16 12:15:43 1992 James Clark (jjc at jclark) - - * entgen.c (nentgen): Treat empty system/public identifiers as - missing. - -Fri May 15 23:51:10 1992 James Clark (jjc at jclark) - - * std.h: Declare errno in case doesn't. - -Tue May 12 18:58:54 1992 James Clark (jjc at jclark) - - * *.cfg (HAVE_GETOPT_H): New define. - * configure: Handle HAVE_GETOPT_H. - * std.h: Include getopt.h. - * getopt.c, main.c, sgmlsasp.c: Don't include getopt.h. - - * configure: Fixes for Ultrix. - - * entgen.c (entgen): Cast f->fpisysis to char * in argument to - strchr. - - * sgmlsasp.c (error): Define as NO_RETURN. - -Mon May 11 08:54:06 1992 James Clark (jjc at jclark) - - * Version 0.8 released. - - * Makefile.bcc (OBJS1): Add exclude.obj. - -Sat May 9 10:26:16 1992 James Clark (jjc at jclark) - - * dos.cfg: Add CANT_REDIRECT_STDERR. - * main.c: Add -f option if CANT_REDIRECT_STDERR is defined. - - * adl.h (NEDCNADL): Change dcnadl to adl. - - * entity.h (struct dcncb): Add entsw member. - * modmd1.c (mdnadl): Check that an entity with this notation has - not already been declared. - * modmd2.c (mdextid): Set the entsw field of the notation. - * msg.h: New message 218. - - * msg.h: Improve message 192. - - * msg.h: Improve message 78. - - * modpars1.c (checkdtd): Check for undefined notations even if - sw.undef not specified. - * msg.h: Change type of 192 to 'W'. - - * modmd2.c (mdextid): Separate copying of attribute list into - storedatt. Call this also if there was no data attribute - specification list but this notation does have an attribute list. - (storedatt): New function. Don't increase ds.attgcnt. - * modpars2.c (parseatt): Separate initialization of ad into - initatt. No need to copy al: this is done in storedatt. - (initatt): New function. - * sgmlfnsm.h: Declare storedatt and initatt. - -Fri May 8 13:00:56 1992 James Clark (jjc at jclark) - - * sgmldecl.c: Use ISO 8879:1986 instead of ISO 8879-1986. - Also recognize the latter but give an error message. - (sdfixcolon): Rename to sdfixstandard. - * msg.h: Change message 163 accordingly. - - * modpars2.c (adlval): Don't dereference newetd if it's NULL. - - * entgen.c (entgen): Initialize sysidsrch. Don't always call - sysidgen() if there's a system identifier. - (field): Use %E for escape sequence. %S gives system identifier. - -Wed May 6 21:40:25 1992 James Clark (jjc at jclark) - - * sgmldecl.c (sdtranschar): Cast arguments to ltous to long. - - * msgcat.c: Conditionalize use of prototypes on USE_PROTOTYPES not - __STDC__. - -Tue May 5 00:24:39 1992 James Clark (jjc at jclark) - - * lineout.c (process_subdoc): Only call get_subcaps() if - subprocess exited successfully. - - * msg.h: New message 217. - * exclude.c (excktok): Use message 217 instead of 41. Second - parameter is current gi not gi that does excluding. - - * modpars1.c (iopend): Save offset into line. Don't seek to - middle of line. - (iocont): Seek to beginning of line, then skip to middle of line - using saved offset. - (struct iofcb): Delete penderr and sverrno. New pendoff member. - - * modpars1.c (parsecon): An RE that would be ignored can force a - start tag. - -Mon May 4 23:26:21 1992 James Clark (jjc at jclark) - - * unix.cfg (FPOS_MISSING): New define. - * configure: Handle FPOS_MISSING. - * std.h: Provide fpos_t, fgetpos, fsetpos if FPOS_MISSING. - * sgmlio.c (iopend, iocont, ioread): Use fsetpos/fgetpos rather - than fseek/ftell. Use penderr to indicate that iopend() failed. - (struct iofcb): Make off an fpos_t. Add penderr member. - -Sun May 3 09:41:05 1992 James Clark (jjc at jclark) - - * sgmlmsg.c (printit): Don't rely on return value of fprintf. - -Wed Apr 29 00:03:42 1992 James Clark (jjc at jclark) - - * modpars1.c (destack): Undo Apr 26 change. - * exclude.c: New file. - * msg.h: New message 216. - * Makefile: Add exclude.c. - * modpars1.c (stack): Call exclude(). - * sgmlfnsm.h: Declare exclude(). - * modpars1.c (stag): Don't give errors here for invalid exclusions. - - * ambig.c (listambig): Clear marks afterwards. - - * synxtrn.h: Don't use an enum for the key indices. - -Tue Apr 28 09:22:43 1992 James Clark (jjc at jclark) - - * vms.cfg: New file. - * Makefile (MISC): Include vms.cfg. - - * portproc.c (run_process): Free the right thing. - - * Makefile (OBJS2): Add getopt.o. - - * modsgml1.c (sgmltab): Undo change of April 13. When pending RE - is followed by another RE that is ignored, output the first RE - immediately. - -Sun Apr 26 11:36:49 1992 James Clark (jjc at jclark) - - * modpars1.c (destack): When element ends without required element, - check whether required element has been excluded. - -Tue Apr 21 12:39:42 1992 James Clark (jjc at jclark) - - * entity.h (struct switches): Add swundef member. - * main.c (swinit): Initialize swundef. - (OPTIONS): Add u. - (main): Support -u. - (usage): Mention -u. - * modpars1.c (checkdtd): New function. - (parsepro): Call checkdtd. - * msg.h: New messages 142 and 190. - -Mon Apr 20 15:09:40 1992 James Clark (jjc at jclark) - - * modmd1.c (mdadl): Only call etdadl if the element has already - been defined. - (etdadl): No need to check that p->etdmod is non-NULL. - -Thu Apr 16 12:56:15 1992 James Clark (jjc at jclark) - - * main.c (main): Implement -i. - (swinit): Initialize includes. - * entity.h (struct switches): New includes member. - * modpars1.c (pentname, doincludes): New functions. - (startdtd): Call doincludes. - (endprolog): Call doincludes if there was no DTD. - * msg.h: New message 138. - -Wed Apr 15 15:58:53 1992 James Clark (jjc at jclark) - - * traceset.c (tracemap): Deleted. - * trace.h (TRACEMAP): Deleted. - * modserv.c (mapsrch): Don't use TRACEMAP. - * modsgml2.c (ptrsrch): Likewise. - - * trace.h, traceset.c *.cfg: Include tracing is TRACE is defined, - rather than if FINAL is not defined. - * entity.h: Include trace and ptrace in struct switched only if - TRACE is defined. - * main.c (main, swinit, build_subargv): Support -x and -y only if - TRACE is defined. - (xrealloc): New function. - * appl.h: Declare xrealloc. - - * traceset.c (tracemod): Calculate size of pg correctly. - -Tue Apr 14 13:47:21 1992 James Clark (jjc at jclark) - - * action.h: Get rid ETGP_. Renumber accordingly. - * modsgml1.c (sgmltab): Get rid of column for ETGP_. - - * modpars2.c (parseseq): Rewrite. - - * modpars2.c (s2valnm): Cosmetic changes. - - * modpars2.c (parsetkn): Rewrite. Don't store length ahead of - name. - (parseatt): Don't call dellen. - (mdattdef): Likewise. - (charrefn): Number doesn't have length byte. - * modmd1.c (mdelem): ranksuff doesn't have length byte. - * modserv.c (dellen): Deleted. - * sgmlfnsm.h (dellen): Delete declaration. - * sgmldecl.c: Numbers no longer have length bytes. - - * modpars2.c (parse): Use NAMELEN rather than 8 when parsing - number in numeric character reference. - -Mon Apr 13 23:21:45 1992 James Clark (jjc at jclark) - - * modsgml1.c (sgmltab): Add two new states to handle the case - where the pending RE has been followed by an RE that was ignored. - -Wed Apr 8 10:59:48 1992 James Clark (jjc at jclark) - - * modsgml1.c (sgmltab): In state NR1, hold on to REF_ as in state - DA1. - - * Makefile (install, install.man): New targets. - - * modsgml1.c (sgmlact): When popping the pcbsgml stack, change the - state of the new top of stack pcb as if there had been a - processing instruction or markup declaration. - -Tue Apr 7 13:55:17 1992 James Clark (jjc at jclark) - - * configure: New file. - * Makefile: Add configure to distribution. - (config.h): Build using configure. - * unix.cfg: Some minor cleanup to work better with configure. - Move things that can't be auto-configured to top. - -Sun Apr 5 20:53:42 1992 James Clark (jjc at jclark) - - * main.c (main): Call MAIN_HOOK if it's defined. - - * Makefile: Add thinkc.cfg to MISC. - - * getopt.c: Include getopt.h. - - * sgmlio.c (nextstr): Make declaration a prototype. - -Wed Apr 1 09:30:33 1992 James Clark (jjc at jclark) - - * main.c (usage): Mention -p. - -Sun Mar 29 15:47:44 1992 James Clark (jjc at jclark) - - * sgmldecl.c (sgmldecl): Use separate buffer to parse closing >. - Return non-zero if there was some appinfo. - (sdappinfo): Don't save appinfo. Delete appinfo array. - (sgmlappinfo): Deleted. - (sgmlwrsd): Always write out APPINFO NONE. - * sgmlmain.g (sgmlappinfo): Delete declaration. - * sgmlfnsm.h (sgmldecl): Change return type to int. - * action.h (APP_): New action. - * modpars1.c (parsepro): Return APP_ after parsing SGML - declaration if there was some appinfo. - * sgmlmain.h (SGMLAPP): New event. - (ADATA, ADATALEN): New macros. - * modsgml1.c (sgmlnext): Return SGMLAPP for APP_. - * lineout.h: Define APPINFO_CODE. - * lineout.c (process_document): Handle SGMLAPP. - (output_appinfo): New function. - * sgmls.c (sgmls_next): Handle APPINFO_CODE. - * sgmls.h (sgmls_event_type): Add SGMLS_EVENT_APPINFO. - (sgmls_event): Add appinfo field to union. - * sgmlsasp.c (do_file): Ignore SGMLS_APPINFO. - -Fri Mar 27 11:18:06 1992 James Clark (jjc at jclark) - - * Version 0.7 released. - - * modsgml2.c (scbset): Check that es >= 0. - - * sgmldecl.c (sgmlappinfo): New function. - * sgmlmain.h: Declare it. - - * lineout.c (output_internal_entity): Distinguish CDATA and SDATA - entities with a keyword rather than with \|. - * sgmls.c (parse_internal_entity): Grok this. - Rename E_ENTITYTYPE to E_BADEXTERNAL. - Change error message for E_BADINTERNAL. - (unescape): Split off part into - (unescape1): New function. - * sgmls.pl: Grok new I format. - - * sgmlio.c (nifopen): New function. - (FOPENR): Define as nifopen if HAVE_O_NOINHERIT is defined. - * dos.cfg: Define HAVE_NO_INHERIT. - - * stklen.c: New file. - * Makefile.bcc: Compile stklen.c. - * Makefile: Include stklen.c in distribution. - - * main.c (main): New -p option. - - * modpars1.c (parsepro): Give an error for R/CDATA marked section - in the DTD subset. - * msg.h: Use message 135 for this. - - * modpars1.c (common): Rename to commbufs. Change callers. - * sgmlfnsm.h: Change declaration. - - * sgmlsasp.c (main): New -n option. - (fold_general_names): New variable. - * sgmlsasp.h (fold_general_names): Declare it. - * replace.c (scan_name): Fold name to upper case only if - fold_general_names is non-zero. - -Thu Mar 26 12:39:24 1992 James Clark (jjc at jclark) - - * modpars1.c (setdtype): Don't give message about the document - type element's not being declared if we already gave an error - message about there not being a doctype declaration. - (parsepro): In onlypro mode, call setdtype. - -Wed Mar 25 11:13:18 1992 James Clark (jjc at jclark) - - * sgmldecl.c (sdquantity): Eliminate unnecessary inner - redeclaration of i. - - * sgmldecl.c (sdnaming): Eliminate unnecessary assignment to i. - - * sgmls.c (parse_data): Eliminate unnecessary assignment to start. - - * main.c (make_argv): Eliminate unnecessary increment of i. - - * entgen.c (entgen): Eliminate unnecessary assignment to buf. - - * modpars2.c (antvget): Make advn local to block in which it is - used. Eliminate unnecessary assignment. - - * modpars2.c (alperm): Eliminate unnecessary assignment to alperm. - - * modpars1.c (parsecon): Eliminate unnecessary assignment to pcb. - - * context.c (newtoken): Make Psave and rc local to block in which - it is used. Eliminate unnecessary assignments. - - * Cast some arguments of xrealloc, memcpy, MEMZERO to UNIV. - - * tools.c (VP): New macro. - * sgmlsasp.h (VP): New macro. - * appl.h (appl_error): - * main.c (fatal): - * replace.c (parse_error): - * sgmlmsg.c (xfprintf): Use VP for prototypes of varargs functions. - -Mon Mar 23 13:57:55 1992 James Clark (jjc at jclark) - - * sgmlxtrn.c (savedpos): New variable. - * sgmlxtrn.h: Declare it. - * modpars1.c (endprolog): Separate allocation of struct mpos's - into... - (newmpos): New function. - (endprolog): Allocate savedpos. - * context.c (context): If there's an applicable inclusion, save - the current position in savedpos. Don't return RCPEX unless the - element is valid in this model only as an inclusion; in this case, - restore the saved position. - -Sun Mar 22 10:34:54 1992 James Clark (jjc at jclark) - - * entity.h (struct switches): Add onlypro member. - * main.c (swinit): Initialize onlypro. - * modpars1.c (parsepro): If onlypro switch is set, don't give an - error for EOD after DTD subset is finished, and also return EOD at - end of prolog. - -Sat Mar 21 19:27:59 1992 James Clark (jjc at jclark) - - * etype.h (TXOPT, TXREP, TXOREP): New ttype flags to support dump.c. - * modpars2.c (parsemod, parsegcm): Set TX* flags when occurrence - indicator is specified explicitly. - - * modmd2.c (mdentity): Build the entity text for ESS and ESE - types. Handle ESS and ESE like other internal entity types. - (tagtext, entfix): Deleted. - * sgmlxtrn.c (tagtext, entfix): Delete declarations. - * modpars1.c (shortref): Don't handle ENTEGI, ENTSGI. Delete - stagrc variable. - * modpars2.c (parse): Likewise. Delete stagrc variable. - * modsgml2.c (entopen): Handle ESS and ESE normally. - * traceset.c (traceecb): Likewise. - * source.h (ENTEGI, ENTSGI): Deleted. - (ENTDATA, ENTPI): Renumber. - -Mon Feb 24 16:12:59 1992 James Clark (jjc at jclark) - - * context.c (testend): Insert brackets around && within || to keep - gcc 2 quiet. - - * traceset.c: Add some casts to keep gcc 2's -Wformat happy. - -Fri Feb 21 12:21:05 1992 James Clark (jjc at jclark) - - * lineout.c (process_subdoc): Forget the current filename after - processing subdoc. - - * main.c (build_subargv): Pass on -l. - -Thu Feb 20 11:48:06 1992 James Clark (jjc at jclark) - - * action.h (MSP_): New action. - * arcpcbrf.c (md7a): Change action for MSO from LAF_ to MSP_. - * modpars1.c (parsepro): Handle MSP_. For MSS_ return DCE_. - * modsgml1.c (sgmlnext): Change handling of MSS_ in the prolog. - - * modserv.c (hout): Use a struct hash **. Had bug when removing - first element in chain. - -Tue Feb 18 11:11:35 1992 James Clark (jjc at jclark) - - * sgmlxtrn.c: Don't declare array sizes unnecessarily. Insert - newlines in license. - - * msg.h: Give errors about unsupported features a `U' type code. - * sgmlsmsg.c: Use a different header for `U' type messages. - -Fri Feb 14 11:41:51 1992 James Clark (jjc at jclark) - - * sgmls.c (parse_data): Don't use strchr. - - * replace.c (hash): Change hashing function. Do modulus in hash(). - Make return type int. Change callers. - - * sgmls.h, sgmls.c, sgmlsasp.c: Redo error handling so as not to use - setjmp. - * std.h: Don't include . - - * source.h (ENTHASH): - * etype.h (ETDHASH): - * adl.h (IDHASH): Bump up values. - - * modserv.c (hash): Use better hashing function. - - * modserv.c (idget): Deleted. - * sgmlfnsm.h: Delete declaration. - - * momd11.c (mdelem, mdadl): - * modmd2.c (mdsrmuse): Don't allocate nmgrp - * modmd1.c (mdnadl, mdelem): Don't allocate nnmgrp. - * modpars2.c (parsemod): Don't allocate gbuf. - * modmd2.c (mdelem): Don't allocate nmbuf - * modmd2.c (mdextid): Don't allocate sysibuf, pubibuf. - * sgmldecl.c (bufsalloc, bufsrealloc): Handle only scbs and tbuf. - * modpars1.c (parsepro): Call startdtd() before mddtds. - (startdtd): New function. Allocate nmgrp, nnmgrp, gbuf, nmbuf, - pubibuf, sysibuf. - (common): New function. Allocate al, lbuf, entbuf. - (endprolog): Free buffers allocated in startdtd(). Call common() - if it hasn't already been called. - -Thu Feb 13 10:42:26 1992 James Clark (jjc at jclark) - - * modsgml2.c (entref): Handle the case where the entity has been - used in a shortref mapping declaration, but has not been defined. - - * Redo tracing code. - - * traceset.c (traceecb): Return if p is NULL. - * modsgml2.c (entfind): Call traceecb even if p is NULL. - - * sgmlincl.h: Always include trace.h. - - * traceset.c (estype1, estype2): Make them local static variables - in traceecb. - * trace.h (estype1, estype2): Declarations deleted. - - * sgmlxtrn.[ch] (pifldlen): Deleted. - * modmd2.c (pubfield): Additional argument that gets length of - field. - (parsefpi): Change callers. Don't use pifldlen. - - * modpars2.c (antvget): Pass pointer which receives value. - (parseatt): Pass pointer to antvget() to receive value. - * sgmlxtrn.[ch]: Delete antvptr. - - * sgmlxtrn.[ch] (pvalptr): Deleted. - * modpars2.c (parseval): Don't set pvalptr. - (attval): - * modmd1.c (mdattdef): - * modmd2.c (tagtext): Use last argument passed to parseval - instead of pvalptr. - -Tue Feb 11 13:23:03 1992 James Clark (jjc at jclark) - - * modpars1.c (endprolog): tag::tpos needs to be GRPLVL+2 long. - - * entity.h (MAXNAMELEN): Move into sgmldecl.c. - - * modmd1.c (mdelem): Use lbuf for rank suffix. Use tbuf for - comgibuf. - - * modmd2.c (mdsrmuse): Store short reference name in lbuf. - Simplify accordingly. - - * modmd2.c (mdentity): Use external nmbuf instead of ename. - Allocate nmbuf if necessary. Only needs to be NAMELEN+2 bytes - long. - * sgmlxtrn.[ch]: Declare nmbuf. - * modpars1.c (endprolog): Free nmbuf. - - * modmd2.c (mdentity): Get rid of pname. - - * modsgml2.c (usedef): - * modmd2.c (mdentity, mdnot): - * modmd1.c (mddtds): - * entgen.c (nentgen, field): Don't include length byte in fpinm. - * modmd2.c (mdextid): - * modmd2.c (field): Don't include length byte in fpinedcn. - - * ambig.c (ambig, ambigfree): Don't allocate memory all in one chunk. - - * modmd2.c (mdsrmuse): Point subdcl to somewhere that won't get - overwritten. - - * sgmldecl.c (newkey): Make size of names REFNAMELEN+1, - (sdnames): Don't allow name to be specified as parameter literal. - Install names at end. - (sdxsyntax): Don't install names. - (sgmlwrsd): Output new names as names not literals. - * synxtrn.h (key): - * arcsynrf.c (key): Make size of names REFNAMELEN+1. - * sgmldecl.c (REFNAMELEN): Move to entity.h. - - * sgmldecl.c (bufsrealloc): Handle the possibility that NAMELEN >= - LITLEN. - - * namelen.h: Deleted. - * entity.h: Define MAXNAMELEN explicitly. Don't include namelen.h. - - * sgmls.c, sgmls.h, sgmlsasp.c, sgmlsasp.h, replace.c, replace.h: - Avoid depending on any upper limit to NAMELEN. - -Mon Feb 10 11:07:24 1992 James Clark (jjc at jclark) - - * lineout.c (define_entity): Have single argument including length - and EOS. - (handle_single_token): Change accordingly. - (handle_token_list): Temporarily make the token look like a name. - - * sgmlxtrn.[ch] (entbuf): Change to a pointer. - * sgmldecl.c (bufsalloc, bufsrealloc): Allocate entbuf. - - * sgmlxtrn.[ch] (dtype): Change to a pointer. - * modmd1.c (mddtds): Dynamically allocate dtype. - * modpars1.c (setdtype): If dtype is NULL, point it to indefetd. - - * modmd1.c (mdelem): Use nnmgrp for holding exception name group - lists. Allocate nnmgrp if necessary. - * modpars2.c (parsegrp): Additional tbuf argument. Use this as - name buffer rather than local array. - * modparse2.c (parsengrp): Similarily. - * Change callers. - - * modmd2.c (mdsrmdef): Avoid use of sname buffer. Free srhptr when - cleaning up. - - * modpars2.c (parsegcm): Use tbuf instead of local array. - - * modserv.c (savenm): New function. - * adl.h (struct ad): Make adname a pointer. - * modmd1.c (mdadl, mdnadl, anmtgrp): Don't parse names directly - into adname. Parse into a buffer and then save with savenm. - - * entity.h (struct hash, struct dcncb): - * adl.h (struct id): - * etype.h (struct etd): - * source.h (struct entity, struct srh): - * modserv.c (hin): - - * sgmlaux.h (struct error): Make subdcl a pointer. - * modsgml2.c (mderr, errorinit): Corresponding changes. - * sgmlmsg.c (printit): Pass empty string if e->subdcl is NULL. - - * sgmlmain.h (struct rcbtag): Make curgi a pointer. - * modsgml1.c (sgmlnext): Corresponding changes. - - * entity.h (struct fpi): Make fpinm a pointer. Delete fpinml. - * modmd2.c (mdextid): Don't copy ename. - * modsgml2.c (usedef): Likewise. - * entgen.c (field): Don't use fpinml. - - * entity.h (struct fpi): Make fpinedcn a pointer. - * modmd2.c (mdextid): - * entgen.c (field): Corresponding changes. - - * lineout.c (process_document): Fix so that it compiles if - !SUPPORT_SUBDOC. - - * sgmls.c: Don't include setjmp.h. - - * sgmlmsg.c: Avoid use of printf("%*s"). - -Sun Feb 9 13:18:10 1992 James Clark (jjc at jclark) - - * ambig.c (struct contoken): Change type of size to UNCH. - - * sgmldecl.c (sdquantity): If specified quantity limit is too big - use biggest allowed. - - * modmd1.c (mdadl, mdelem, mdsrmuse): Make nmgrp external - variable. Allocate if necessary. - (mdnadl): Rename nmgrp to nnmgrp. Make it an external variable. - Allocate if necessary. - * sgmlxtrn.c (nmgrp, nnmgrp): New variables. - * entity.h (MAXGRPCNT): Move into sgmldecl.c. - * modpars1.c (endprolog): Free nmgrp, nnmgrp, gbuf. - * sgmldecl.h (GRPCNT): Get it from sd. - * context.h: New file. - * traceset.c, context.c: Move common macros into context.h. - * Makefile: Include context.h in HDRS. - * etype.h (struct mpos): Make h a unsigned long *. - (HITCLEAR): New macro. - * context.c (ANYHIT, HITSET, HITON, HITOFF): New macros. - Fix operations on H to use these macros. - (offbit, allhit): Change long to unsigned long *. - (anyhit): New function. - * traceset.c (tracehits): New function. - (tracegi, traceend): Use tracehits. - * modpars1.c (stack): Use HITCLEAR to clear hit bits. - (endprolog): Allocate space for hit bits. Set grplongs. - * sgmlxtrn.c (grplongs): New variable. - - * modpars1.c (endprolog): New function. - (parsepro): Call endprolog. - * ambig.c (ambigfree): New function. - * modpars1.c (stack): Move allocation of tags and scbsgml into - endprolog. - - * ambig.c: Dynamically allocate struct contoken's. - (struct contoken): Use pointers rather than arrays for first and - last. - (newcontoken, freecontoken): New functions. - (andgroup): Dynamically allocate nullablefirst. - (MAXSTATES): Use GRPGTCNT rather than MAXGRPGTCNT. - * entity.h (MAXGRPGTCNT): Move to sgmldecl.c. - * ambig.c (listmerge): Use mergebuf. - (follow): Make it an UNCH **. - (ambig): Allocate follow and mergebuf if necessary. - * sgmlxtrn.[ch] (gbuf): Make it a pointer. - * modpars2.c (parsemod): Allocate gbuf if necessary. - - * etype.h (struct tag): Make tpos a pointer. - * modpars1.c (stack): Allocate tpos members. - * entity.h (MAXGRPLVL): Move to sgmldecl.c. Increase to MAXGRPGTCNT. - - * context.c (TOKENHIT): Don't use intermediate variable. - -Fri Feb 7 09:14:02 1992 James Clark (jjc at jclark) - - * Version 0.6 released. - -Thu Feb 6 10:16:57 1992 James Clark (jjc at jclark) - - * Add casts so that it compiles with `typedef char *UNIV;'. - - * action.h (GTR_): New action. - * modpars1.c (parsecon): Handle GTR_. - * arcpcbrf.c (sp0a): Change action for EOB from GET_ to GTR_. - - * modpars1.c (parsepro): Increment sgmlsw in MDC_ and PIS_ actions. - - * Remove unnecessary #undefs. - - * Use (UNCH *)0 instead of NULL. - - * Delete multiple pass support. - - * process.c: Rename to ... - * unixproc.c: New file. - * dosproc.c, portproc.c: New files. - - * sgmldecl.c (sdcolon): Don't give an error for 8879:1986. - -Wed Feb 5 10:59:21 1992 James Clark (jjc at jclark) - - * modserv.c (rmalloc): Change return type to UNIV. - -Mon Feb 3 13:27:29 1992 James Clark (jjc at jclark) - - * arcpcbrf.c (et32a): Change action for msc from DAS_ to LAS_. - - * lextoke.h: - * modsgml1.c (sgmlset): - * modpars2.c (s2valnm): - * arcpcbrf.c (pcbval): Remove DEL class. - * modmd1.c (mdattdef): - * modpars2.c (parseatt): - * sgmlmsg.c (parms): - * modsgml2.c (pcbtab): - * synxtrn.h: - * arcpcbrf.c (pcblitt): Use new pcb for tokenized attributes. - * modpars2.c (parselit): Handle DEF_ differently for tokenized - attributes. - * modpars2.c (tokdata): New function. - * sgmlfnsm.h: Declare it. - -Sun Feb 2 17:49:47 1992 James Clark (jjc at jclark) - - * lineout.c (print_string): Fix bug in DELNONCH handling. - -Fri Jan 31 17:51:15 1992 James Clark (jjc at jclark) - - * entgen.c (nsysidgen): Deleted. - (nentgen): New function. - (entgen): Use nentgen for notation identifiers. - (genext, ext): Omit entries for notations. - (field): Change calculation for accessing genext. - * sgmls.h (struct sgmls_notation): Delete id field. Add sysid and - pubid fields. - * sgmls.c (parse_notation): Support new N syntax. - -Thu Jan 30 13:28:33 1992 James Clark (jjc at jclark) - - * entgen.c: Include sgmlaux.h after unistd.h. - - * modmd2.c (mdextid): Increase ds.attdef by sum of normalized - lengths of explicitly specified data attributes. - - * entity.h (struct switches): New nopen member. - * modsgml2.c (entopen): Use nopen to check that maximum allowed - number of open subdocument entities is not exceeded. - * main.c (main): Support -o. - (swinit): Initialize nopen. - (build_subargv): Pass on incremented -o option. - -Wed Jan 29 12:53:39 1992 James Clark (jjc at jclark) - - * unix.cfg, entgen.c (DEFAULT_PATH): Don't use %L. - - * replace.c (load_replacement_file): Split off allocation into... - (make_replacement_table): New function. - (define_replacement): Ignore duplicates. - * replace.h: Change declarations. - * sgmlsasp.c (main): Use this to support multiple replacement - files. - -Mon Jan 27 16:35:03 1992 James Clark (jjc at jclark) - - * context.c (newtoken): Fix computation of nextand. - -Sun Jan 26 23:11:23 1992 James Clark (jjc at jclark) - - * main.c: Cleanup temporary files on exit or signal. - - * main.c: Pass -z option to subdoc processes. Read capacity usage - after process completes. Write capacity usage to file if specified - by -z option. - * modsgml1.c (sgmlsubcap): New function. - (sgmlend): Take account of subdocument capacity usage. - - * sgmldecl.c: Remove support for passing SGML declarations through - the environment. - * main.c, lineout.c: Remove support for outputting environment. - * sgmls.c, sgmls.h: Delete support for V command. - - * main.c: Write SGML declaration to temporary file. Pass this as - first file to subdoc processes. - * sgmldecl.c (sgmlwrsd): New function. - - * Rename RESOLVE_SUBDOC to SUPPORT_SUBDOC. - * lineout.c: Always resolve subdoc references. - * sgmldecl.c: Initialize SUBDOC to NO if !SUBDOC_SUPPORT. - * main.c, appl.h (subdocsw): Deleted. - - * lineout.c: Resolve subdocuments even if suppsw. - - * momd1.c (anmtgrp): Make adn a UNS *. - * sgmlfns.h: Change declaration. - * adl.h (struct ad): Make adnum a UNS. - * adl.h (struct ad): Make adlen a UNS. - - * entity.h (struct fpi): Use UNS rather than UNCH for lengths. - - * Use MAXNAMELEN rather than NAMELEN for size of arrays. - * namelen.h: New file. - * Use MAXGRPCNT rather than GRPCNT for size of arrays. - * etype.h (struct tag): Use MAXGRPLVL instead of GRPLVL for size - of tpos array. - * entity.h: Remove definitions of ENTCASE, NAMECASE, and most - quantity limits. - * sgmldecl.h: Redefine thse to pick up values specified in SGML - declaration. - * entity.h (MAXGRPCNT, MAXGRPLVL, MAXGRPGTCNT, MAXNAMELEN): New - definitions. - * modpars1.c (parsecon): - * modpars2.c (parseatt): Don't pass tbuflim. - * sgmldecl.c: Implement parsing of non-public syntax sections. - - * modserv.c (ntoa): Use sprintf. - * sgmlxtrn.[ch] (ntoabuf): Deleted. - - * sgmldecl.c: Remove extended reference syntax. - -Sun Jan 19 13:38:24 1992 James Clark (jjc at jclark) - - * modpars1.c (parsepro): Don't take tbuf as an argument. - Change callers and declaration. - * sgmldecl.c (sgmldecl): Don't take tbuf as an argument. Change - callers and declaration. - - * modmd2.c (mdextid): - * entity.h (struct fpi): Use pointers for fpisysis and fpipubis. - No need for fpipubsw and fpisyssw. - * entgen.c (field, entgen): Corresponding changes. - * sgmlxtrn.h (sysibuf, pubibuf): Declare. - * sgmlxtrn.[ch] (sysibuf, pubibuf): Define. - * modmd2.c (mdexitid): Initialize these if necessary. - - * entgen.c (field, entgen, mindatcpy): Avoid using static buffer - in field. - - * sgmlmsg.c (elttrace): Avoid using buffer. Change HDRELT string - accordingly. - - * sgmlxtrn.c: Change big arrays into pointers. - * sgmlxtrn.h: Change declarations accordingly. - * sgmldecl.c (sdinit, bufsalloc, bufsrealloc): New functions. - * modpars1.c (stack): Allocate scbsgml and tags if necessary. - - * sgmlaux.h: Include sgmldecl.h. - * sgmlincl.h: Don't include sgmldecl.h. - * entgen.c (field, entgen): Use ENTCASE and NAMECASE to determine - folding of names. - -Fri Jan 17 18:30:07 1992 James Clark (jjc at jclark) - - * msg.h: Avoid dependencies on reference quantity set. - -Thu Jan 16 10:12:17 1992 James Clark (jjc at jclark) - - * Rename strlsave to savestr. - - * modpars2.c (parselit, parseval, adlval, vallen, attval, parseatt): - * modserv.c (replace, strlsave, sandwich): - * sgmldecl.h (struct sgmldecl): - * sgmldecl.c (sdversion, sdappinfo, sdfixcolon, sdpubcapacity, - sdpubsyntax, sdcharset): - * lineout.c (define_entity, handle_token_list, - handle_single_token): - * modsgml1.c (sgmlnext): - * modsgml2.c (entopen): - * modmd2.c (mdsrmdef, parsefpi, tagtext, entfix, mdextid): - * entity.h (struct fpi): - * entgen.c (entgen, field): - * adl.h (struct ad): - * modserv.c (dellen): - * modmd1.c (mdattdef): Change representation of literals not to - have initial length byte. Change representation of token list or - CDATA attributes (but not single token attributes) not to have - initial length byte. - -Mon Jan 13 10:38:18 1992 James Clark (jjc at jclark) - - * sgmlxtrn.h (gbuf): Make size GRPGTCNT+3. - * modpars2.c (parsemod): Don't count outermost model in - gbuf[0].tu.tnum. - * modmd1.c (mdelem): Change calculation of size of cmod and of - modcnt accordingly. - * ambig.c (MAXSTATES): Change to GRPGTCNT+2. - - * Version 0.5 released. - - * modmd1.c (mdelem): Outermost group doesn't count towards modcnt. - -Sun Jan 5 10:51:05 1992 James Clark (jjc at jclark) - - * ambig.c: New file. - * etype.h (struct etd): Add mark field. - * modpars2.c (parsemod): Possibly call ambig(). - * entity.h (struct switches): Add swambig member. - * main.c (main, usage, build_subargv): Handle -a option. - (swinit): Initialize swambig. - -Wed Dec 11 14:01:06 1991 James Clark (jjc at jclark) - - * modmd1.c (mdadl): Don't call etdadl() if alperm is 0. - - * context.c, modpars1.c: Move definitions of RC* into ... - * etype.h - - * context.c (newtoken): Make sure Tstart is unhit. - -Thu Dec 5 10:30:16 1991 James Clark (jjc at jclark) - - * process.c (run_process): Use vfork() if available. Call buildenv - before forking and then cleanup in parent. Use _exit() if execvp - fails. - * unix.cfg: Add HAVE_VFORK and HAVE_VFORK_H. - - * std.h: Delete definition of isascii. - -Tue Nov 19 08:42:41 1991 James Clark (jjc at jclark) - - * lineout.c (print_data): Don't split up data. - (data_count): Rename to have_data. - - * context.c (context): Handle the case where there's a hit in a - plus group, but the current element has ended. - -Thu Nov 7 09:38:14 1991 James Clark (jjc at jclark) - - * source.h, sgmlaux.h, sgmlmain.h, modsgml1.c, lineout.c: Use - unsigned long to hold line number. - -Wed Nov 6 11:28:50 1991 James Clark (jjc at jclark) - - * std.h: Add declaration of strerror. - * sgmlmsg.c: Delete declaration of strerror. - - * msg.h: Improve message 134. Delete messages 135 and 137. - -Tue Nov 5 10:13:54 1991 James Clark (jjc at jclark) - - * arcpcbrf.c (et0a): Change action for sep (TAB) from NOP_ to DAS_. - -Mon Nov 4 15:28:40 1991 James Clark (jjc at jclark) - - * sgmls.h: Rename to lineout.h. - -Sat Nov 2 09:06:09 1991 James Clark (jjc at jclark) - - * msg.h: In message 133, s/comment/markup declaration/. - - * arcpcbrf.c (et7a): Use EE_ rather than EOF_ on EE. - * modpars1.c (parsepro): Give an error message on EOD_. - * msg.h: Use message 127 for this. - - * modpars2.c (charrefa): Decrement RCNT if the character is RS. - - * modpars1.c (parsepro): Give an error if the DTE_ is not at level - 0, and do not terminate the DTD. - * msg.h: Use message 143 for this. - - * msg.h: Delete message 143. - -Fri Nov 1 08:58:26 1991 James Clark (jjc at jclark) - - * modmd2.c (mdsruse): Use message number 142 when an associated - element type is specified and the declaration is not in the DTD. - Use message 28 if an associated element type is not specified and - the declaration is in the DTD. Use message 126 if something other - than an associated element or MDC is specified and the declaration - is not in the DTD. - - * msg.h: Delete message 138. This error is caught in parsefpi(). - - * msg.h: Delete message 140. Not used anywhere. - - * modpars2.c (parsegcm): When GRPGTCNT is exceeded use message - number 114. - - * msg.h: Don't abbreviate attribute as att in messages 72 and 151. - - * msg.h: s/not declared minimizable/not minimizable/ - - * modmd2.c (mdsrmdef): Give an error if concrete syntax does not - support short references. - * msg.h: New message 198. - - * modpars2.c (adlval): If SHORTTAG is NO and OMITTAG is NO, do not - allow an unimpliable attribute value specification to be omitted. - * msg.h: New message 197. - - * msg.h: Improve message number 84. - - * modpars2.c (parseatt): If SHORTTAG is NO, do not allow an - undelimited attribute value (ie an attribute value specification - that is not an attribute value literal). - * msg.h: New message 196. - - * modpars2.c (parseatt): If SHORTTAG is NO, do not allow - attribute name to be omitted. - * msg.h: New message 195. - - * modpars2.c (parseatt): No need to have prototype definition. - - * modpars1.c (parsetag): If SHORTTAG is NO, do not allow - unclosed tag or null start tag. - * msg.h: New messages 193 and 194. - -Thu Oct 31 10:51:54 1991 James Clark (jjc at jclark) - - * sgmldecl.c (noemptytag): New function. - (sdimply, sdfeatures): Call noemptytag() if the SHORTTAG feature - is NO. - - * sgmldecl.c (sdimply): Store value of SHORTTAG environment - variable in sd.shorttag. - - * modmd1.c (mdattdef): Declared value of data attribute cannot be - ID. - * msg.h: Use message 144 for this. - - * msg.h: Delete message 144. - - * modpars1.c (parsecon): Handle DCE_ action by switching to - pcbconm and repeating current character. Move code that was - target of goto. - - * Makefile: Add ChangeLog to the list of files to go in the - distribution. - - * unix.cfg: Mention that defining HAVE_CAT requires use of - /usr/xpg2bin/cc on a Sun. - - * modpars1.c (destack): Don't give an error when a required tag - was not specified if conrefsw is set. - (parsecon): Clear conrefsw only after calling destack(). - - * sgmldecl.c (envcharset): Skip any white space before digits - after doing sscanf. - - * main.c (subdocsw): Initialize to 1. - - * Started using ChangeLog at version 0.3. diff --git a/cde/programs/dtdocbook/sgmls/INSTALL b/cde/programs/dtdocbook/sgmls/INSTALL deleted file mode 100644 index 7c3d7504d..000000000 --- a/cde/programs/dtdocbook/sgmls/INSTALL +++ /dev/null @@ -1,56 +0,0 @@ -This file describes how to install sgmls. - -UNIX ----- - -Look at the Makefile and edit it if necessary. - -Do `make config.h'. This runs a shell script that generates an -appropriate config.h file from unix.cfg. If this works, have a look -at config.h and make sure it's correct. (In particular you might want -to change the definition of DEFAULT_PATH.) If this doesn't work, copy -unix.cfg to config.h, and then edit config.h yourself; please also -tell me what went wrong. - -Do `make'. - -If you like, do `make test' to run some tests. - -Do `make install' to install the binaries. - -If you like, do `make install.man' to install the man pages. - -MS-DOS with Borland C++ 2.0 ---------------------------- - -Rename makefile to makefile.ux and then rename makefile.bcc to -makefile. - -Copy dos.cfg to config.h. - -Look at config.h and makefile and edit them if you want. - -Do `make -S'. - -Copy sgmls.exe and sgmlsasp.exe to a directory that's on your path. - -VAX/VMS -------- - -Copy vms.cfg to config.h. - -Look at Makefile.vms and config.h and edit them if you want. - -Use the script in Makefile.vms to build sgmls and sgmlsasp. - -VM/CMS ------- - -[This configuration is untested.] - -Copy cms.cfg to config.h. - -Use Makefile.cms to build sgmls and sgmlsasp. - -James Clark -jjc@jclark.com diff --git a/cde/programs/dtdocbook/sgmls/Imakefile b/cde/programs/dtdocbook/sgmls/Imakefile deleted file mode 100644 index a73e9608c..000000000 --- a/cde/programs/dtdocbook/sgmls/Imakefile +++ /dev/null @@ -1,45 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/3 1996/07/17 12:21:51 rws $ - -#ifdef IBMArchitecture -EXTRA_DEFINES = -Dvfork=fork -#endif - -PROG1=sgmls -SRCS1=lexrf.c pcbrf.c synrf.c context.c md1.c md2.c pars1.c pars2.c serv.c \ - sgml1.c sgml2.c sgmlmsg.c sgmlxtrn.c traceset.c entgen.c sgmlio.c \ - xfprintf.c main.c unixproc.c sgmldecl.c version.c strerror.c getopt.c \ - msgcat.c lineout.c ambig.c exclude.c lextaba.c - -OBJS1=lexrf.o pcbrf.o synrf.o context.o md1.o md2.o pars1.o pars2.o serv.o \ - sgml1.o sgml2.o sgmlmsg.o sgmlxtrn.o traceset.o entgen.o sgmlio.o \ - xfprintf.o main.o unixproc.o sgmldecl.o version.o strerror.o getopt.o \ - msgcat.o lineout.o ambig.o exclude.o lextaba.o - -PROG2=sgmlsasp -OBJS2=sgmlsasp.o replace.o sgmls.o strerror.o getopt.o -SRCS2a=sgmlsasp.c replace.c sgmls.c -SRCS2=$(SRCS2a) strerror.c getopt.c - -PROG3=rast -SRCS3a=rast.c -SRCS3=$(SRCS3a) sgmls.c strerror.c -OBJS3=rast.o sgmls.o strerror.o getopt.o - -XCOMM Not build for now... -PROG4=genlex -SRCS4a=genlex.c ebcdic.c -SRCS4=$(SRCS4a) lextaba.c lexrf.c -OBJS4=genlex.o ebcdic.o lextaba.o lexrf.o - -XCOMM SRCS=$(SRCS1) $(SRCS2a) $(SRCS3a) $(SRCS4a) lextabe.c - -HDRS=action.h adl.h entity.h error.h etype.h sgmldecl.h keyword.h lextoke.h \ - msg.h sgmlaux.h sgmlfnsm.h sgmlincl.h sgmlmain.h lineout.h sgmlxtrn.h \ - source.h synxtrn.h tools.h trace.h context.h getopt.h msgcat.h std.h \ - appl.h sgmls.h sgmlsasp.h replace.h lexcode.h latin1.h ebcdic.h - -PROGRAMS = $(PROG1) $(PROG2) $(PROG3) - -ComplexProgramTarget_1(sgmls,,) -ComplexProgramTarget_2(sgmlsasp,,) -ComplexProgramTarget_3(rast,,) diff --git a/cde/programs/dtdocbook/sgmls/LICENSE b/cde/programs/dtdocbook/sgmls/LICENSE deleted file mode 100644 index 576ca35b4..000000000 --- a/cde/programs/dtdocbook/sgmls/LICENSE +++ /dev/null @@ -1,43 +0,0 @@ - LICENSE AND DISCLAIMER OF WARRANTIES - - Standard Generalized Markup Language Users' Group (SGMLUG) - SGML Parser Materials - - 1. License - -SGMLUG hereby grants to any user: (1) an irrevocable royalty-free, -worldwide, non-exclusive license to use, execute, reproduce, display, -perform and distribute copies of, and to prepare derivative works -based upon these materials; and (2) the right to authorize others to -do any of the foregoing. - - 2. Disclaimer of Warranties - -(a) The SGML Parser Materials are provided "as is" to any USER. USER -assumes responsibility for determining the suitability of the SGML -Parser Materials for its use and for results obtained. SGMLUG makes -no warranty that any errors have been eliminated from the SGML Parser -Materials or that they can be eliminated by USER. SGMLUG shall not -provide any support maintenance or other aid to USER or its licensees -with respect to SGML Parser Materials. SGMLUG shall not be -responsible for losses of any kind resulting from use of the SGML -Parser Materials including (without limitation) any liability for -business expense, machine downtime, or damages caused to USER or third -parties by any deficiency, defect, error, or malfunction. - -(b) SGMLUG DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, ARISING OUT -OF OR RELATING TO THE SGML PARSER MATERIALS OR ANY USE THEREOF, -INCLUDING (WITHOUT LIMITATION) ANY WARRANTY WHATSOEVER AS TO THE -FITNESS FOR A PARTICULAR USE OR THE MERCHANTABILITY OF THE SGML PARSER -MATERIALS. - -(c) In no event shall SGMLUG be liable to USER or third parties -licensed by USER for any indirect, special, incidental, or -consequential damages (including lost profits). -(d) SGMLUG has no knowledge of any conditions that would impair its right -to license the SGML Parser Materials. Notwithstanding the foregoing, -SGMLUG does not make any warranties or representations that the -SGML Parser Materials are free of claims by third parties of patent, -copyright infringement or the like, nor does SGMLUG assume any -liability in respect of any such infringement of rights of third -parties due to USER's operation under this license. diff --git a/cde/programs/dtdocbook/sgmls/NEWS b/cde/programs/dtdocbook/sgmls/NEWS deleted file mode 100644 index 711ba8dc4..000000000 --- a/cde/programs/dtdocbook/sgmls/NEWS +++ /dev/null @@ -1,104 +0,0 @@ -This file describes recent user-visible changes in sgmls. Bug fixes -are not described. See the man pages for more details. - -Version 1.1 -=========== - -The rast filter converts the output of sgmls to RAST format. See -rast.man. - -There have been some changes to the output format: system and public -identifiers for external entities and notations are specified using -the new `s' and `p' commands; the filenames for external entities are -specified using the new `f' command rather than being arguments to the -`E' and `S' commands; the `\s' escape sequence is no longer generated; -an `S' command is generated for an entity mentioned in a `{' command; -RS characters are no longer stripped and are represented by `\012'. - -The -c option now takes an argument giving the name of the file to -which the report of capacity calculations should be written. The -report is in RACT format. - -sgmls can now handle non-seekable devices (such as pipes). If no -filenames are specified on the command line, sgmls will read the -document entity from standard input. A filename of `-' can also be -used to refer to standard input. - -The output format no longer distinguishes attributes whose declared -value is ID, IDREF or IDREFS and uses the TOKEN keyword for these. -(The ESIS does not distinguish these attributes.) - -The -a option is no longer allowed. - -Version 1.0 -=========== - -Eight bit characters can be made name characters. - -Ambiguous content models are always detected. The -a option is ignored. - -Version 0.8 -=========== - -On Unix systems, the configure script can automatically generate -config.h from unix.cfg. - -An APPINFO parameter in the SGML declaration other than NONE is output -as a `#' command. - -sgmls has a -iNAME option which defines a parameter entity NAME with -replacement text "INCLUDE". - -sgmls has a -u option that warns about undefined elements. - -In SGML_PATH, the public text designating sequence (escape sequence) -is now accessed with %E rather than %S. %S now gives the system -identifier. When a system identifier is supplied, SGML_PATH will be -used to generate a filename only if SGML_PATH uses %S and the system -identifier does not contain (semi-)colons. - -An accordance with Amendment 1 to ISO 8879:1986, in the SGML -declaration `ISO 8879:1986' rather than `ISO 8879-1986' is required. - -With MS-DOS, errors can be redirected to a file using the -f option. - -Version 0.7 -=========== - -More quantity limits can be changed. In particular, GRPCNT, GRPLVL -and GRPGTCNT can be increased up to 253; NAMELEN can be increased to -239. Names are now dynamically allocated (that is, the amount of -memory used to store a name depends on the actual length of the name -rather than on value specified for NAMELEN.) - -sgmlasp supports a -n option which disables upper-case substitution -for names in replacement files. - -sgmls has a -p option which makes it parse only the prolog. - -The format of the I command has been changed: CDATA and SDATA entities -are distinguished using a keyword rather than by surrounding SDATA -entities with \|s. - -Version 0.6 -=========== - -A concrete syntax can now be specified explicitly in the SGML -declaration, and various parts of the reference concrete syntax can be -changed, including some quantity limits. - -The treatment of notation identifiers and the syntax of the N output -command have been changed. - -SUBDOC support works with MS-DOS. - -The -n option has been removed; references to subdocument entities are -always resolved. - -It is no longer possible to change the implied SGML declaration using -environment variables. You must use an explicit SGML declaration -instead. - -The V output command has been removed. - -sgmlsasp supports multiple replacement files. diff --git a/cde/programs/dtdocbook/sgmls/README b/cde/programs/dtdocbook/sgmls/README deleted file mode 100644 index 0e9fc5808..000000000 --- a/cde/programs/dtdocbook/sgmls/README +++ /dev/null @@ -1,38 +0,0 @@ -/* $XConsortium: README /main/2 1996/07/15 14:10:45 drk $ */ -This is sgmls, an SGML parser derived from the ARCSGML parser -materials which were written by Charles F. Goldfarb. (These are -available for anonymous ftp from ftp.ifi.uio.no [128.240.88.1] in the -directory SIGhyper/SGMLUG/distrib.) - -The version number is given in the file version.c. - -The file INSTALL contains installation instructions. - -The file NEWS describes recent user-visible changes. - -The file sgmls.man contains a Unix manual page; sgmls.txt is the -formatted version of this. - -The file sgml-mode.el contains a very simple SGML mode for GNU Emacs. - -The files sgmls.c and sgmls.h contain a small library for parsing the -output of sgmls. This is used by sgmlsasp, which translates the -output of sgmls using an ASP replacement file, and by rast, which -translates the output of sgmls to the format of a RAST result. The -files sgmlsasp.man and rast.man contain Unix manual pages for sgmlsasp -and rast; sgmlsasp.txt and rast.txt are the formatted versions of -these. - -The file LICENSE contains the license which applies to arcsgml and -accordingly to those parts of sgmls derived from arcsgml. See also -the copyright notice at the beginning of sgmlxtrn.c. The parts that -were written by me are in the public domain (any files that were -written entirely by me contain a comment to that effect.) The file -sgml-mode.el is covered by the GNU GPL. - -Please report any bugs to me. When reporting bugs, please include the -version number, details of your machine, OS and compiler, and a -complete self-contained file that will allow me to reproduce the bug. - -James Clark -jjc@jclark.com diff --git a/cde/programs/dtdocbook/sgmls/TODO b/cde/programs/dtdocbook/sgmls/TODO deleted file mode 100644 index 8a3a8e854..000000000 --- a/cde/programs/dtdocbook/sgmls/TODO +++ /dev/null @@ -1,78 +0,0 @@ -Warn about mixed content models where #PCDATA can't occur everywhere. - -Perhaps there should be a configuration option saying what a control -character is for the purpose of SHUNCHAR CONTROLS. - -Should the current character that is printed in error messages be -taken from be taken from the file entity or the current entity? - -Refine SYS_ action. If we distinguish DELNONCH in lexmark, lexgrp, -lexsd, we can have separate action that ignores the following -character as well. - -Should RSs in CDATA/SDATA entities be ignored as specified in 322:1-2? -Similarily, do the rules on REs in 322:3-11 apply to CDATA/SDATA -entities? (I don't think they count as being `in content'.) - -What should the entity manager do when it encounters code 13 in an -input file? (Currently it treats it as an RE.) - -Document when invalid exclusions are detected. - -Option not to perform capacity checking. - -Give a warning if the recommendation of 422:1-3 is contravened. - -Should an empty CDATA/RCDATA marked section be allowed in the document -type declaration subset? - -Include example of use of SGML_PATH in documentation. - -Try to detect the situation in 310:8-10 (but see 282:1-2). - -Resize hash tables if they become too full. - -Say something in the man page about message catalogues. - -Consider whether support for SHORTREF NONE requires further changes -(other than disallowing short reference mapping declaration). - -Fake /dev/fd/N and /dev/stdin for systems that don't provide it. - -Improve the effficiency of the entity manager by not closing and -reopening files. If we run out of FILEs choose the stream with the -fewest bytes remaining to be read, and read the rest of it into -memory. Each entity level will have its own read buffer. - -Support multi-line error messages: automatically indent after -newline. (We could output to a temporary file first, then copy to -stderr replacing newlines by newline+indent). - -Option that says to output out of context things. - -Divide up formal public identifier errors. Give these errors their -own type code. - -Consider whether, when OMITTAG is NO, we need to change interpretation -of an empty start-tag (7.4.1.1). - -Possibly turn errors 70 and 136 into warnings. - -Make things work with NORMSEP > 2. Would need to keep track of number -of CDATA and SDATA entities in CDATA attributes. - -Handle `SCOPE INSTANCE'. - -In entgen.c, truncate filenames for OSs that don't do this themselves. - -Provide an option that specifies that maximum number of errors; when -this limit is exceeded sgmls would exit. - -Document non-portable assumptions in the code. - -Option to write out SGML declaration. In this case make it write out -APPINFO parameter. - -Allow there to be catalogs mapping public ids to filenames. -Environment variable SGML_CATALOG containing list of filenames of -catalogs. diff --git a/cde/programs/dtdocbook/sgmls/action.h b/cde/programs/dtdocbook/sgmls/action.h deleted file mode 100644 index 1e6ea3765..000000000 --- a/cde/programs/dtdocbook/sgmls/action.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: action.h /main/3 1996/06/19 17:14:03 drk $ */ -/* ACTION.H: Symbols for all PCB action codes. */ -/* CONACT.H: Symbols for content parse action names (end with '_'). - There must be no conflict with PARSEACT.H, which - uses 0 through 19, or SGMLACT.H, which uses 20 through 32 - (except that 31 - 32 can be defined here because they are - used only by PARSEPRO and do not conflict with SGML.C). -*/ -#define CIR_ 31 /* Invalid character(s) ignored in MDS; restarting parse. */ -#define DTD_ 32 /* Process DOCTYPE declaration. */ -#define DTE_ 33 /* End of DOCTYPE declaration. */ -#define PEP_ 34 /* TEMP: Previous character ended prolog. */ -#define DAS_ 35 /* Current character begins data. */ -#define FCE_ 36 /* Process free character (SR12-18, 21-30). */ -#define DCE_ 37 /* Data character in element text; change PCB. */ -#define LAS_ 38 /* Start lookahead buffer with current character. */ -#define LAM_ 39 /* Move character to lookahead buffer. */ -#define LAF_ 40 /* Flush the lookahead buffer; REPEATCC. */ -#define NED_ 41 /* Process null end-tag delimiter. */ -#define NET_ 42 /* Process null end-tag. */ -#define NST_ 43 /* Process null start-tag. */ -#define NLF_ 44 /* Flush lookahead buffer except for trailing NET or SR. */ -#define ETC_ 45 /* End-tag in CDATA or RCDATA; treat as data if invalid. */ -#define SRMIN 46 /* Dummy for SHORT REFERENCES: srn = SRn - SRMIN. */ -#define SR1_ 47 /* TAB */ -#define SR2_ 48 /* RE */ -#define SR3_ 49 /* RS */ -#define SR4_ 50 /* Leading blanks */ -#define SR5_ 51 /* Null record */ -#define DAR_ 52 /* Flush data buffer after repeating current character. */ -#define SR7_ 53 /* Trailing blanks */ -#define SR8_ 54 /* Space */ -#define SR9_ 55 /* Two or more blanks */ -#define SR10 56 /* Quotation mark (first data character) */ -#define SR11 57 /* Number sign */ -#define SR12 58 /* FCE CHARACTERS start here */ -/* _ 59 */ -#define BSQ_ 60 /* Blank sequence begun; find its end. */ -/* 61 In use by PARSEACT.H */ -/* 62 In use by PARSEACT.H */ -/* 63 In use by PARSEACT.H */ -/* 64 In use by PARSEACT.H */ -#define SR19 65 /* Hyphen */ -#define SR20 66 /* Two hyphens */ -#define SR25 71 /* Left bracket */ -#define SR26 72 /* Right bracket */ -#define RBR_ 73 /* Two right brackets. */ -#define GTR_ 74 /* EOB with pending data character */ -#define MSP_ 75 /* Marked section start in prolog outside DTD */ -#define APP_ 76 /* APPINFO (other than NONE) */ -#define STE_ 77 /* Start tag ended prolog */ - -/* GRPACT.H: Symbols for group tokenization action names (all alpha). - There must be no conflict with PARSEACT.H, which - uses 0 - 19. -*/ -#define AND 20 /* AND connector found. */ -#define DTAG 21 /* Data tag token group occurred (treat as #CHARS). */ -#define GRPE 22 /* Group ended. */ -#define GRP_ 23 /* Group started. */ -#define NAS_ 24 /* Name started in content model or name group. */ -#define NMT_ 25 /* Name or name token started in name token group. */ -#define OPT 26 /* OPT occurrence indicator for previous token. */ -#define OR 27 /* OR connector found. */ -#define OREP 28 /* OREP occurrence indicator for previous token. */ -#define REP 29 /* REP occurrence indicator for previous token. */ -#define RNS_ 30 /* Reserved name started (#PCDATA). */ -#define SEQ 31 /* SEQ connector found. */ -/* LITACT.H: Symbols for content parse action names (end with '_'). - There must be no conflict with PARSEACT.H, which - uses 0 through 19. -*/ -#define MLA_ 20 /* Move character to look-aside data buffer. */ -#define LPR_ 21 /* Move previous character to data buffer. */ -#define RSM_ 22 /* Process record start and move it to data buffer. */ -#define FUN_ 23 /* Replace function character with a space. */ -#define LP2_ 24 /* Move previous two characters to data buffer. */ -#define MLE_ 25 /* Minimum literal error: invalid character ignored. */ -#define RPR_ 26 /* Remove previous character from data buffer; terminate. */ -#define TER_ 27 /* Terminate the parse. */ -/* MDACT.H: Symbols for markup declaration parse action names (all alpha). - There must be no conflict with PARSEACT.H, which - uses 0 - 19. -*/ -#define CDR 20 /* CD[1] (MINUS) occurred previously. */ -#define EMD 21 /* End of markup declaration. */ -#define GRPS 22 /* Group started. */ -#define LIT 23 /* Literal started: character data. */ -#define LITE 24 /* Literal started: character data; LITA is delimiter. */ -#define MGRP 25 /* Minus exception group (MINUS,GRPO). */ -#define NAS 26 /* Name started. */ -#define NMT 27 /* Name token started. */ -#define NUM 28 /* Number or number token started. */ -#define PEN 29 /* Parameter entity name being defined (PERO found). */ -#define PGRP 30 /* Plus exception group (PLUS,GRPO). */ -#define RNS 31 /* Reserved name started. */ -#define MDS 32 /* Markup declaration subset start. */ -#define PENR 33 /* REPEATCC; PERO found. */ -/* PARSEACT.H: Symbols for common parse action names (end with '_'). - There must be no conflict with other action name - files, which use numbers greater than 19. -*/ -#define CRA_ 1 /* Character reference: alphabetic. */ -#define CRN_ 2 /* Character reference: numeric; non-char refs o.k.. */ -#define NON_ 3 /* Single byte of non-character data found. */ -#define EOF_ 4 /* Error: illegal entity end; resume old input; return. */ -#define ER_ 5 /* Entity reference; start new input source; continue. */ -#define GET_ 6 /* EOB, EOS, or EE: resume old input source; continue. */ -#define INV_ 7 /* Error: invalid char terminated markup; repeat char. */ -#define LEN_ 8 /* Error: length limit exceeded; end markup; repeat char. */ -#define NOP_ 9 /* No action necessary. */ -#define PCI_ 10 /* Previous character was invalid. */ -#define PER_ 11 /* Parameter reference; start new input source; continue. */ -#define RC2_ 12 /* Back up two characters. */ -#define RCC_ 13 /* Repeat current character. */ -#define RCR_ 14 /* Repeat current character and return to caller. */ -#define EE_ 15 /* EOS or EE: resume old input source; return to caller. */ -#define RS_ 16 /* Record start: ccnt=0; ++rcnt. */ -#define ERX_ 17 /* Entity reference; start new input source; return. */ -#define SYS_ 18 /* Error allowed: SYSCHAR in input stream; replace it. */ -#define EOD_ 19 /* End of document. */ -/* Number way out of order to avoid recompilation. */ -#define NSC_ 58 /* Handle DELNONCH/DELXNONCH when NON_ is allowed */ -#define PEX_ 61 /* Parameter entity ref; start new input source; return. */ -#define DEF_ 62 /* Data entity found. */ -#define PIE_ 63 /* PI entity found (needed in markup). */ -#define LNR_ 64 /* LEN_ error with extra REPEATCC. */ -/* SGMLACT.H: Symbols for content parse action names (end with '_') - that are returned to SGML.C for processing. - There must be no conflict with PARSEACT.H, which - uses 0 through 19, or CONACT.H, which uses 34 and above. - (Note: 31 is also used in CONACT.H, but no conflict - is created because they are tested only in PARSEPRO.C, which - completes before SGML.C starts to examine those codes. - Also, when EOD_ is returned from PARSECON, it is changed - to LOP_.) -*/ -#define CON_ 20 /* Normal content action (one of the following). */ -#define DAF_ 21 /* Data found. */ -#define ETG_ 22 /* Process end-tag. */ -#define MD_ 23 /* Process markup declaration (NAMESTRT found). */ -#define MDC_ 24 /* Process markup declaration comment (CD found). */ -#define MSS_ 25 /* Process marked section start. */ -#define MSE_ 26 /* Process marked section end. */ -#define PIS_ 27 /* Processing instruction (string). */ -#define REF_ 28 /* Record end found. */ -#define STG_ 29 /* Process start-tag. */ -#define RSR_ 30 /* Return RS to effect SGML state transition. */ -#define LOP_ 31 /* Loop for new content without returning anything. */ -/* TAGACT.H: Symbols for tag parse action names (all alpha). - There must be no conflict with PARSEACT.H, which - uses 0 - 19. -*/ -#define AVD 20 /* Delimited attribute value started: normal delimiter. */ -#define AVU 21 /* Undelimited value started. */ -#define ETIC 22 /* Tag closed with ETI. */ -#define NVS 23 /* Name of attribute or value started. */ -#define NASV 24 /* Saved NAS was actually an NTV. */ -#define NTV 25 /* Name token value started; get name and full value. */ -#define TAGC 26 /* Tag closed normally. */ -#define TAGO 27 /* Tag closed implicitly by TAGO character. */ -#define AVDA 28 /* Delimited attribute value started: alternative delim. */ -#define DSC 29 /* Closed by DSC character. */ -/* VALACT.H: Symbols for attribute value tokenization action names (all alpha). -*/ -#define NOPA 0 /* No action necessary. */ -#define INVA 1 /* Invalid character; terminate parse. */ -#define LENA 2 /* Length limit of token exceeded; terminate parse. */ -#define NASA 3 /* Name started. */ -#define NMTA 4 /* Name token started. */ -#define NUMA 5 /* Number or number token started. */ - -/* SGML declaration parsing actions. */ - -#define ESGD 20 /* End of SGML declaration. */ -#define LIT1 21 /* Literal started. */ -#define LIT2 22 /* Literal started with LITA delimiter. */ -#define NUM1 23 /* Number started. */ -#define NAS1 24 /* Name started. */ -#define ISIG 25 /* Insignificant character occurred. */ diff --git a/cde/programs/dtdocbook/sgmls/adl.h b/cde/programs/dtdocbook/sgmls/adl.h deleted file mode 100644 index af4fa3d38..000000000 --- a/cde/programs/dtdocbook/sgmls/adl.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: adl.h /main/3 1996/06/19 17:14:09 drk $ */ -/* ADL.H: Definitions for attribute descriptor list processing. -*/ -/* N/C/SDATA external entity types for nxetype member of ne structure. */ -#define ESNCDATA 1 /* External character data entity. */ -#define ESNNDATA 2 /* Non-SGML data entity. */ -#define ESNSDATA 3 /* External specific character data entity. */ -#define ESNSUB 4 /* SGML subdocument entity. */ - -/* N/C/SDATA control block for AENTITY attributes and NDATA returns.*/ -struct ne { /* N/C/SDATA entity control block. */ - UNIV neid; /* Files for NDATA entity. */ - UNCH *nepubid; /* Public identifier if specified. */ - UNCH *nesysid; /* System identifier if specified. */ - PDCB nedcn; /* Data content notation control block. */ - struct ad *neal; /* Data attribute list (NULL if none). */ - UNCH *neename; /* Ptr to entity name (length and EOS). */ - UNCH nextype; /* Entity type: NDATA SDATA CDATA SUBDOC. */ -}; -#define NESZ (sizeof(struct ne)) -typedef struct ne *PNE; -/* NDATA entity control block fields. */ -#define NEID(p) (((PNE)p)->neid) /* File ID of NDATA entity. */ -#define NESYSID(p) (((PNE)p)->nesysid) /* System ID of NDATA entity. */ -#define NEPUBID(p) (((PNE)p)->nepubid) /* Public ID of NDATA entity. */ -#define NEDCN(p) (((PNE)p)->nedcn->ename) /* Data content notation name. */ -#define NEDCNSYSID(p) (((PNE)p)->nedcn->sysid) /* Notation system ID.*/ -#define NEDCNPUBID(p) (((PNE)p)->nedcn->pubid) /* Notation public ID.*/ -#define NEDCNDEFINED(p) (((PNE)p)->nedcn->defined) /* Notation defined? */ -#define NEDCNADL(p) (((PNE)p)->nedcn->adl) /* Data content notation attlist.*/ -#define NEENAME(p) (((PNE)p)->neename) /* Entity name pointer. */ -#define NEXTYPE(p) (((PNE)p)->nextype) /* External entity type. */ -#define NEAL(p) (((PNE)p)->neal) /* Data attributes (if any). */ -#define NEDCNMARK(p) DCNMARK(((PNE)p)->nedcn) - -/* Attribute descriptor list entry. */ -struct ad { - UNCH *adname; /* Attribute name with length and EOS. */ - UNCH adflags; /* Attribute flags. */ - UNCH adtype; /* Value type. */ - UNS adnum; /* Group size or member pos in grp. */ - UNS adlen; /* Length of default or value (for capacity). */ - UNCH *addef; /* Default value (NULL if REQUIRED or IMPLIED). */ - union { - PNE n; /* AENTITY: NDATA control block. */ - PDCB x; /* ANOTEGRP: DCN control block. */ - } addata; /* Special data associated with some attributes.*/ -}; -#define ADSZ (sizeof(struct ad)) /* Size of an ad structure. */ - -/* Attribute flags for entire list adflags: ADLF. */ -#define ADLREQ 0x80 /* Attribute list: 1=REQUIRED att defined. */ -#define ADLNOTE 0x40 /* Attribute list: 1=NOTATION att defined. */ -#define ADLCONR 0x20 /* Attribute list: 1=CONREF att defined. */ - -/* Attribute flags for list member adflags: ADFLAGS(n). */ -#define AREQ 0x80 /* Attribute: 0=null; 1=required. */ -#define ACURRENT 0x40 /* Attribute: 0=normal; 1=current. */ -#define AFIXED 0x20 /* Attribute: 0=normal; 1=must equal default. */ -#define AGROUP 0x10 /* Attribute: 0=single; 1=group of ad's. */ -#define ACONREF 0x08 /* Attribute: 0=normal; 1=att is CONREF. */ -#define AINVALID 0x04 /* Attribute: 1=value is invalid; 0=o.k. */ -#define AERROR 0x02 /* Attribute: 1=error was specified; 0=o.k. */ -#define ASPEC 0x01 /* Attribute: 1=value was specified; 0=default. */ - -/* Attribute types for adtype. */ -#define ANMTGRP 0x00 /* Attribute: Name token group or member. */ -#define ANOTEGRP 0x01 /* Attribute: Notation (name group). */ -#define ACHARS 0x02 /* Attribute: Character string. */ -#define AENTITY 0x03 /* Attribute: Data entity (name). */ -#define AID 0x04 /* Attribute: ID value (name). */ -#define AIDREF 0x05 /* Attribute: ID reference value (name). */ -#define ANAME 0x06 /* Attribute: Name. */ -#define ANMTOKE 0x07 /* Attribute: Name token. */ -#define ANUMBER 0x08 /* Attribute: Number. */ -#define ANUTOKE 0x09 /* Attribute: Number token. */ -#define ATKNLIST 0x0A /* Attribute: >= means value is a token list. */ -#define AENTITYS 0x0A /* Attribute: Data entities (name list). */ -#define AIDREFS 0x0B /* Attribute: ID reference value (name list). */ -#define ANAMES 0x0C /* Attribute: Name list. */ -#define ANMTOKES 0x0D /* Attribute: Name token list. */ -#define ANUMBERS 0x0E /* Attribute: Number list. */ -#define ANUTOKES 0x0F /* Attribute: Number token list. */ - -/* Field definitions for entries in an attribute list. - The first argument to all of these is the list address. -*/ -/* Attribute list: flags. */ -#define ADLF(a) ((a)[0].adflags) -/* Attribute list: number of list members. */ -#define ADN(a) ((a)[0].adtype) -/* Attribute list: number of attributes. */ -#define AN(a) ((a)[0].adnum) -/* Nth attribute in list: name. */ -#define ADNAME(a, n) (((a)[n].adname+1)) -/* Nth att in list: number of val)ues. */ -#define ADNUM(a, n) ((a)[n].adnum) -/* Nth attribute in list: flags. */ -#define ADFLAGS(a, n) ((a)[n].adflags) -/* Nth attribute in list: type. */ -#define ADTYPE(a, n) ((a)[n].adtype) -/* Nth attribute in list: len of def or val.*/ -#define ADLEN(a, n) ((a)[n].adlen) -/* Nth attribute in list: def or value. */ -#define ADVAL(a, n) ((a)[n].addef) -/* Nth attribute in list: special data. */ -#define ADDATA(a, n) ((a)[n].addata) -/* Nth att: token at Pth pos in value. */ -#define ADTOKEN(a, n, p)(((a)[n].addef+(p))) - -#define IDHASH 101 /* Size of ID hash table. Must be prime. */ -struct id { /* ID attribute control block. */ - struct id *idnext; /* Next ID in chain. */ - UNCH *idname; /* ID name with length prefix and EOS. */ - UNCH iddefed; /* Non-zero if it has been defined. */ - struct fwdref *idrl; /* Chain of forward references to this ID. */ -}; -#define IDSZ sizeof(struct id) -typedef struct id *PID; /* Ptr to ID attribute control block. */ diff --git a/cde/programs/dtdocbook/sgmls/ambig.c b/cde/programs/dtdocbook/sgmls/ambig.c deleted file mode 100644 index e41bb1f1c..000000000 --- a/cde/programs/dtdocbook/sgmls/ambig.c +++ /dev/null @@ -1,461 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ambig.c /main/3 1996/06/19 17:14:13 drk $ */ -/* ambig.c - - Content model ambiguity checking. - - Written by James Clark (jjc@jclark.com). -*/ -/* -This uses the construction in pp8-9 of [1], extended to deal with AND -groups. - -Note that it is not correct for the purposes of ambiguity analysis to -handle AND groups by turning them into an OR group of SEQ groups -(consider (a&b?)). - -We build an automaton for the entire content model by adding the -following case for AND: - -nullable(v) := nullable(left child) and nullable(right child) -if nullable(right child) then - for each x in last(left child) do - follow(v,x) = follow(left child,x) U first(right child); -if nullable(left child) then - for each x in last(right child) do - follow(v,x) = follow(right child,x) U first(left child); -first(v) := first(left child) U first(right child); -last(v) := first(left child) U first(right child); - -We also build an automaton for each AND group by building automata for -each of the members of the AND group using the above procedure and -then combine the members using: - -for each x in last(left child) do - follow(v,x) = follow(left child,x) U first(right child); -for each x in last(right child) do - follow(v,x) = follow(right child,x) U first(left child); -first(v) := first(left child) U first(right child); - -The content model is ambiguous just in case one of these automata is -non-deterministic. (Note that when checking determinism we need to -check the `first' set as well as all the `follow' sets.) - -Why is this correct? Consider a primitive token in a member of an AND -group. There are two worst cases for ambiguity: firstly, when none of -the other members of AND group have been matched; secondly, when just -the nullable members remain to be matched. The first case is not -affected by context of the AND group (unless the first case is -identical to the second case.) - -Note that inclusions are not relevant for the purposes of determining -the ambiguity of content models. Otherwise the case in clause -11.2.5.1: - - An element that can satisfy an element in the content model is - considered to do so, even if the element is also an inclusion. - -could never arise. - -[1] Anne Brueggemann-Klein, Regular Expressions into Finite Automata, -Universitaet Freiburg, Institut fur Informatik, 33 July 1991. -*/ - -#include "sgmlincl.h" - -/* Sets of states are represented by 0-terminated, ordered lists of -indexes in gbuf. */ - -#define MAXSTATES (GRPGTCNT+2) -#define listcat(x, y) strcat((char *)(x), (char *)(y)) -#define listcpy(x, y) strcpy((char *)(x), (char *)(y)) - -/* Information about a content token. */ - -struct contoken { - UNCH size; - UNCH nullable; - UNCH *first; - UNCH *last; -}; - -static VOID contoken P((int, int, struct contoken *)); -static VOID andgroup P((int, int, struct contoken *)); -static VOID orgroup P((int, int, struct contoken *)); -static VOID seqgroup P((int, int, struct contoken *)); -static VOID andambig P((int)); -static int listambig P((UNCH *)); -static VOID listmerge P((UNCH *, UNCH *)); -static struct contoken *newcontoken P((void)); -static VOID freecontoken P((struct contoken *)); - - -/* Dynamically allocated vector of follow sets. */ - -static UNCH **follow; -static UNCH *mergebuf; /* for use by listmerge */ - -/* Set to non-zero if the content model is ambiguous. */ - -static int ambigsw; - -/* Check the current content model (in gbuf) for ambiguity. */ - -VOID ambig() -{ - struct contoken *s; - int i; - - if (!follow) { - /* We can't allocate everything in one chunk, because that would - overflow a 16-bit unsigned if GRPGTCNT was 253. */ - UNCH *ptr; - follow = (UNCH **)rmalloc(MAXSTATES*sizeof(UNCH *)); - follow[0] = 0; - ptr = (UNCH *)rmalloc((MAXSTATES - 1)*MAXSTATES); - for (i = 1; i < MAXSTATES; i++) { - follow[i] = ptr; - ptr += MAXSTATES; - } - mergebuf = (UNCH *)rmalloc(MAXSTATES); - } - - for (i = 1; i < MAXSTATES; i++) - follow[i][0] = 0; - - ambigsw = 0; - - s = newcontoken(); - contoken(1, 1, s); - - ambigsw = ambigsw || listambig(s->first); - - freecontoken(s); - - for (i = 1; !ambigsw && i < MAXSTATES; i++) - if (listambig(follow[i])) - ambigsw = 1; - - if (ambigsw) - mderr(137, (UNCH *)0, (UNCH *)0); -} - -/* Free memory used for ambiguity checking. */ - -VOID ambigfree() -{ - if (follow) { - frem((UNIV)follow[1]); - frem((UNIV)follow); - frem((UNIV)mergebuf); - follow = 0; - } -} - -/* Determine whether a list of primitive content tokens (each -represented by its index in gbuf) is ambiguous. */ - -static -int listambig(list) -UNCH *list; -{ - UNCH *p; - int chars = 0; - int rc = 0; - - for (p = list; *p; p++) { - if ((gbuf[*p].ttype & TTMASK) == TTETD) { - struct etd *e = gbuf[*p].tu.thetd; - if (e->mark) { - rc = 1; - break; - } - e->mark = 1; - } - else { - assert((gbuf[*p].ttype & TTMASK) == TTCHARS); - if (chars) { - rc = 1; - break; - } - chars = 1; - } - } - - for (p = list; *p; p++) - if ((gbuf[*p].ttype & TTMASK) == TTETD) - gbuf[*p].tu.thetd->mark = 0; - - return rc; -} - - -/* Analyze a content token. The `checkand' argument is needed to ensure -that the algorithm is not exponential in the AND-group nesting depth. -*/ - -static -VOID contoken(m, checkand, res) -int m; /* Index of content token in gbuf */ -int checkand; /* Non-zero if AND groups should be checked */ -struct contoken *res; /* Result */ -{ - UNCH flags = gbuf[m].ttype; - switch (flags & TTMASK) { - case TTCHARS: - case TTETD: - res->first[0] = m; - res->first[1] = 0; - res->last[0] = m; - res->last[1] = 0; - res->size = 1; - res->nullable = 0; - break; - case TTAND: - if (checkand) - andambig(m); - andgroup(m, checkand, res); - break; - case TTOR: - orgroup(m, checkand, res); - break; - case TTSEQ: - seqgroup(m, checkand, res); - break; - default: - abort(); - } - if (flags & TREP) { - UNCH *p; - for (p = res->last; *p; p++) - listmerge(follow[*p], res->first); - } - if (flags & TOPT) - res->nullable = 1; -} - -/* Check an AND group for ambiguity. */ - -static -VOID andambig(m) -int m; -{ - int i, tnum; - int lim; - struct contoken *curr; - struct contoken *next; - - tnum = gbuf[m].tu.tnum; - assert(tnum > 0); - curr = newcontoken(); - next = newcontoken(); - contoken(m + 1, 0, curr); - i = m + 1 + curr->size; - curr->size += 1; - for (--tnum; tnum > 0; --tnum) { - UNCH *p; - contoken(i, 0, next); - curr->size += next->size; - i += next->size; - for (p = curr->last; *p; p++) - listcat(follow[*p], next->first); - for (p = next->last; *p; p++) - listmerge(follow[*p], curr->first); - listcat(curr->first, next->first); - listcat(curr->last, next->last); - } - lim = m + curr->size; - for (i = m + 1; i < lim; i++) { - if (listambig(follow[i])) - ambigsw = 1; - follow[i][0] = 0; - } - freecontoken(curr); - freecontoken(next); -} - -/* Handle an AND group. */ - -static -VOID andgroup(m, checkand, res) -int m; -int checkand; -struct contoken *res; -{ - int i, tnum; - /* union of the first sets of nullable members of the group */ - UNCH *nullablefirst; - struct contoken *next; - - tnum = gbuf[m].tu.tnum; - assert(tnum > 0); - contoken(m + 1, checkand, res); - nullablefirst = (UNCH *)rmalloc(MAXSTATES); - if (res->nullable) - listcpy(nullablefirst, res->first); - else - nullablefirst[0] = 0; - i = m + 1 + res->size; - res->size += 1; - next = newcontoken(); - for (--tnum; tnum > 0; --tnum) { - UNCH *p; - contoken(i, checkand, next); - res->size += next->size; - i += next->size; - if (next->nullable) - for (p = res->last; *p; p++) - listcat(follow[*p], next->first); - for (p = next->last; *p; p++) - listmerge(follow[*p], nullablefirst); - listcat(res->first, next->first); - if (next->nullable) - listcat(nullablefirst, next->first); - listcat(res->last, next->last); - res->nullable &= next->nullable; - } - frem((UNIV)nullablefirst); - freecontoken(next); -} - -/* Handle a SEQ group. */ - -static -VOID seqgroup(m, checkand, res) -int m; -int checkand; -struct contoken *res; -{ - int i, tnum; - struct contoken *next; - - tnum = gbuf[m].tu.tnum; - assert(tnum > 0); - contoken(m + 1, checkand, res); - i = m + 1 + res->size; - res->size += 1; - next = newcontoken(); - for (--tnum; tnum > 0; --tnum) { - UNCH *p; - contoken(i, checkand, next); - res->size += next->size; - i += next->size; - for (p = res->last; *p; p++) - listcat(follow[*p], next->first); - if (res->nullable) - listcat(res->first, next->first); - if (next->nullable) - listcat(res->last, next->last); - else - listcpy(res->last, next->last); - res->nullable &= next->nullable; - } - freecontoken(next); -} - -/* Handle an OR group. */ - -static -VOID orgroup(m, checkand, res) -int m; -int checkand; -struct contoken *res; -{ - int i, tnum; - struct contoken *next; - - tnum = gbuf[m].tu.tnum; - assert(tnum > 0); - contoken(m + 1, checkand, res); - i = m + 1 + res->size; - res->size += 1; - next = newcontoken(); - for (--tnum; tnum > 0; --tnum) { - contoken(i, checkand, next); - res->size += next->size; - i += next->size; - listcat(res->first, next->first); - listcat(res->last, next->last); - res->nullable |= next->nullable; - } - freecontoken(next); -} - - -/* Merge the second ordered list into the first. */ - -static -VOID listmerge(p, b) -UNCH *p, *b; -{ - UNCH *a = mergebuf; - - strcpy((char *)a, (char *)p); - - for (;;) { - if (*a) { - if (*b) { - if (*a < *b) - *p++ = *a++; - else if (*a > *b) - *p++ = *b++; - else - a++; - } - else - *p++ = *a++; - } - else if (*b) - *p++ = *b++; - else - break; - } - *p = '\0'; -} - -static -struct contoken *newcontoken() -{ - struct contoken *p = (struct contoken *)rmalloc(sizeof(struct contoken) - + MAXSTATES*2); - p->first = (UNCH *)(p + 1); - p->last = p->first + MAXSTATES; - return p; -} - -static -VOID freecontoken(p) -struct contoken *p; -{ - frem((UNIV)p); -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/appl.h b/cde/programs/dtdocbook/sgmls/appl.h deleted file mode 100644 index ddd349c1e..000000000 --- a/cde/programs/dtdocbook/sgmls/appl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: appl.h /main/3 1996/06/19 17:14:17 drk $ */ -/* appl.h */ - -enum { - E_NOMEM = 1, - E_DOC, - E_EXEC, - E_FORK, - E_WAIT, - E_SIGNAL, - E_OPEN, - E_CAPBOTCH, - E_SUBDOC -}; - -VOID process_document P((int)); -VOID output_conforming P((void)); - -UNIV xmalloc P((UNS)); -UNIV xrealloc P((UNIV, UNS)); -VOID appl_error VP((int, ...)); - -#ifdef SUPPORT_SUBDOC -int run_process P((char **)); -char **make_argv P((UNIV)); -VOID get_subcaps P((void)); -#endif - -#ifdef SUPPORT_SUBDOC -extern int suberr; -#endif - -extern int suppsw; -extern int locsw; diff --git a/cde/programs/dtdocbook/sgmls/cms.cfg b/cde/programs/dtdocbook/sgmls/cms.cfg deleted file mode 100644 index aad15028a..000000000 --- a/cde/programs/dtdocbook/sgmls/cms.cfg +++ /dev/null @@ -1,146 +0,0 @@ -/* cms.cfg: Configuration file for sgmls on VM/CMS. */ -/* Contributed by C. M. Sperberg-McQueen . */ - -/* A list of filename templates to use for searching for external -entities. -The filenames are separated by the character specified in PATH_FILE_SEP. -See sgmls.man for details. */ -#define DEFAULT_PATH "%N.%X:%N.%C" -/* The character that separates the filenames templates. */ -#define PATH_FILE_SEP ';' -/* The character that separates filenames in a system identifier. -Usually the same as PATH_FILE_SEP. */ -#define SYSID_FILE_SEP ';' -/* The environment variable that contains the list of fileid patterns. */ -#define PATH_ENV_VAR "SGML_PATH" - -/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a -name or system identifier into a legal filename. A character in -MIN_DAT_SUBS_FROM will be transformed into the character in the -corresponding position in MIN_DAT_SUBS_TO. If there is no such -position, then the character is removed. */ -/* This says that spaces and the characters :'(),./=? should be deleted. */ -#define MIN_DAT_SUBS_FROM " :\'(),./=?" -#define MIN_DAT_SUBS_TO "" - -/* Define this to allow tracing. */ -/* #define TRACE 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C, so you might not want -to define it if you are porting to a new system. Otherwise I suggest -you leave it defined. */ -/* OK, I'll drop it for now. -MSM */ -#define SUPPORT_SUBDOC 0 - -/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports -X/Open extensions; if they do, then, for example, - - printf("%2$s%1$s", "bar", "foo") - -should print `foobar'. */ - -/* #define HAVE_EXTENDED_PRINTF 1 */ - -/* Define HAVE_CAT if your system provides the X/Open message -catalogue functions catopen() and catgets(), and you want to use them. -An implementations of these functions is included and will be used if -you don't define this. On SunOS 4.1.1, if you do define this you -should set CC=/usr/xpg2bin/cc in the makefile. */ - -/* #define HAVE_CAT 1 */ - -#ifdef __STDC__ -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 -#endif - -/* Can't use without prototypes. */ -#ifndef USE_PROTOTYPES -#define VARARGS 1 -#endif - -/* If your compiler defines __STDC__ but doesn't provide , -you must define VARARGS yourself here. */ -/* #define VARARGS 1 */ - -/* Define this if you do not have strerror(). */ -/* Manual says we do, linker says it don't like it. -msm */ -/* #define STRERROR_MISSING 1 */ - -/* Define this unless the character testing functions in ctype.h -are defined for all values representable as an unsigned char. You do -not need to define this if your system is ANSI C conformant. You -should define for old Unix systems. */ -/* #define USE_ISASCII 1 */ - -/* Define this if your system provides the BSD style string operations -rather than ANSI C ones (eg bcopy() rather than memcpy(), and index() -rather than strchr()). */ -/* #define BSD_STRINGS 1 */ - -/* Define this if you have getopt(). */ -/* #define HAVE_GETOPT 1 */ - -/* Define this if you have access(). */ -#define HAVE_ACCESS 1 - -/* Define this if you have . */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define this if you have waitpid(). */ -/* #define HAVE_WAITPID 1 */ - -/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */ -/* #define POSIX 1 */ - -/* Define this if you have the vfork() system call. */ -/* #define HAVE_VFORK 1 */ - -/* Define this if you have . */ -/* #define HAVE_VFORK_H 1 */ - -/* Define this if you don't have */ -/* #define STDLIB_H_MISSING 1 */ - -/* Define this if you don't have */ -/* #define STDDEF_H_MISSING 1 */ - -/* Define this if you don't have remove(); unlink() will be used instead. */ -/* #define REMOVE_MISSING 1 */ - -/* Define this if you don't have raise(); kill() will be used instead. */ -/* #define RAISE_MISSING 1 */ - -/* Define this if you don't have fsetpos() and fgetpos(). */ -/* Hmm. Waterloo C manual includes them but says "reserved -for future use." -msm */ -/* #define FPOS_MISSING 1 */ - -/* Universal pointer type. */ -/* If your compiler doesn't fully support void *, change `void' to `char'. */ -typedef void *UNIV; - -/* If your compiler doesn't support void as a function return type, -change `void' to `int'. */ -typedef void VOID; - -/* If you don't have an ANSI C conformant , define -CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed. -The on some versions of System Release V 3.2 is not ANSI C -conformant: the value of CHAR_MIN is 0 even though the `char' type is -signed. */ - -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* VM/CMS uses EBCDIC. */ -#include "ebcdic.h" diff --git a/cde/programs/dtdocbook/sgmls/config.h b/cde/programs/dtdocbook/sgmls/config.h deleted file mode 100644 index 7e5a517e8..000000000 --- a/cde/programs/dtdocbook/sgmls/config.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: config.h /main/4 1996/06/19 17:14:22 drk $ */ -/* unix.cfg: Configuration file for sgmls on Unix. */ - -/* A list of filename templates to use for searching for external entities. -The filenames are separated by the character specified in PATH_FILE_SEP. -See sgmls.man for details. */ -#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D" -/* The character that separates the filenames templates. */ -#define PATH_FILE_SEP ':' -/* The character that separates filenames in a system identifier. -Usually the same as PATH_FILE_SEP. */ -#define SYSID_FILE_SEP ':' -/* The environment variable that contains the list of filename templates. */ -#define PATH_ENV_VAR "SGML_PATH" - -/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a name -or system identifier into a legal filename. A character in -MIN_DAT_SUBS_FROM will be transformed into the character in the -corresponding position in MIN_DAT_SUBS_TO. If there is no such -position, then the character is removed. */ -/* This says that spaces should be transformed to underscores, and -slashes to percents. */ -#define MIN_DAT_SUBS_FROM " /" -#define MIN_DAT_SUBS_TO "_%" - -/* Define this to allow tracing. */ -/* #define TRACE 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C, so you might not want -to define it if you are porting to a new system. Otherwise I suggest -you leave it defined. */ -#define SUPPORT_SUBDOC 1 - -/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports -X/Open extensions; if they do, then, for example, - - printf("%2$s%1$s", "bar", "foo") - -should print `foobar'. */ - -#define HAVE_EXTENDED_PRINTF 1 - -/* Define HAVE_CAT if your system provides the X/Open message -catalogue functions catopen() and catgets(), and you want to use them. -An implementations of these functions is included and will be used if -you don't define this. On SunOS 4.1.1, if you do define this you -should set CC=/usr/xpg2bin/cc in the makefile. */ - -#define HAVE_CAT 1 - -#ifdef __STDC__ -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 -#endif - -/* Can't use without prototypes. */ -#ifndef USE_PROTOTYPES -#define VARARGS 1 -#endif - -/* If your compiler defines __STDC__ but doesn't provide , -you must define VARARGS yourself here. */ -/* #define VARARGS 1 */ - -/* Define this if you do not have strerror(). */ -/* #define STRERROR_MISSING 1 */ - -/* Define this unless the character testing functions in ctype.h -are defined for all values representable as an unsigned char. You do -not need to define this if your system is ANSI C conformant. You -should define for old Unix systems. */ -/* #define USE_ISASCII 1 */ - -/* Define this if your system provides the BSD style string operations -rather than ANSI C ones (eg bcopy() rather than memcpy(), and index() -rather than strchr()). */ -/* #define BSD_STRINGS 1 */ - -/* Define this if you have getopt(). */ -#define HAVE_GETOPT 1 - -/* Define this if you have access(). */ -#define HAVE_ACCESS 1 - -/* Define this if you have . */ -#define HAVE_UNISTD_H 1 - -/* Define this if you have . */ -#define HAVE_SYS_STAT_H 1 - -/* Define this if you have waitpid(). */ -#define HAVE_WAITPID 1 - -/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */ -#define POSIX 1 - -/* Define this if you have the vfork() system call. */ -#define HAVE_VFORK 1 - -/* Define this if you have . */ -/* #define HAVE_VFORK_H 1 */ - -/* Define this if you don't have */ -/* #define STDLIB_H_MISSING 1 */ - -/* Define this if you don't have */ -/* #define STDDEF_H_MISSING 1 */ - -/* Define this if you don't have */ -/* #define LIMITS_H_MISSING 1 */ - -/* Define this if you don't have remove(); unlink() will be used instead. */ -/* #define REMOVE_MISSING 1 */ - -/* Define this if you don't have raise(); kill() will be used instead. */ -/* #define RAISE_MISSING 1 */ - -/* Define this if you don't have fsetpos() and fgetpos(). */ -/* #define FPOS_MISSING 1 */ - -/* Universal pointer type. */ -/* If your compiler doesn't fully support void *, change `void' to `char'. */ -typedef void *UNIV; - -/* If your compiler doesn't support void as a function return type, -change `void' to `int'. */ -typedef void VOID; - -/* If you don't have an ANSI C conformant , define -CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed. -The on some versions of System Release V 3.2 is not ANSI C -conformant: the value of CHAR_MIN is 0 even though the `char' type is -signed. */ - -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* Assume the system character set is ISO Latin-1. */ -#include "latin1.h" diff --git a/cde/programs/dtdocbook/sgmls/configure b/cde/programs/dtdocbook/sgmls/configure deleted file mode 100755 index 7fd196837..000000000 --- a/cde/programs/dtdocbook/sgmls/configure +++ /dev/null @@ -1,617 +0,0 @@ -#!/bin/sh -# Generate config.h from unix.cfg. - -trap 'rm -f doit doit.c doit.o doit.log config.out; exit 1' 1 2 3 15 - -on= -off= -CC=${CC-cc} - -# Normally we use VARARGS if __STDC__ is not defined. -# Test whether this assumption is wrong. - -cat >doit.c <<\EOF -#ifdef __STDC__ -#include -int foo(char *s,...) -{ - va_list ap; - - va_start(ap, s); - va_end(ap); - return 0; -} -#else -int foo = 0; -#endif -EOF - -$CC $CFLAGS -c doit.c >/dev/null 2>&1 -if test $? -ne 0 -then - on="$on VARARGS" -fi - -cat >doit.c <<\EOF -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - off="$off STDDEF_H_MISSING" -else - on="$on STDDEF_H_MISSING" -fi - -cat >doit.c <<\EOF -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - off="$off STDLIB_H_MISSING" -else - on="$on STDLIB_H_MISSING" -fi - -cat >doit.c <<\EOF -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - off="$off LIMITS_H_MISSING" -else - on="$on LIMITS_H_MISSING" -fi - -cat >doit.c <<\EOF -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - on="$on HAVE_VFORK_H" -else - off="$off HAVE_VFORK_H" -fi - -cat >doit.c <<\EOF -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - on="$on HAVE_UNISTD_H" -else - off="$off HAVE_UNISTD_H" -fi - -cat >doit.c <<\EOF -#include -#include -int foo = 0; -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - on="$on HAVE_SYS_STAT_H" -else - off="$off HAVE_SYS_STAT_H" -fi - -cat >doit.c <<\EOF -/* Exit normally unless we need to use isascii. */ - -#include -#include - -static int whoops() -{ - _exit(1); -} - -main() -{ - int c; -#ifdef isascii -#ifdef SIGSEGV - signal(SIGSEGV, whoops); -#endif -#ifdef SIGBUS - signal(SIGBUS, whoops); -#endif -#ifdef SIGIOT - signal(SIGIOT, whoops); -#endif - - for (c = 128; c < 256; c++) { - if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' - || c == '6' || c == '7' || c == '8' || c == '9') { - if (!isdigit(c) || isalpha(c) || iscntrl(c) || isspace(c) || ispunct(c)) - exit(1); - } - else if (isdigit(c)) - exit(1); - else if (isalpha(c)) { - if (iscntrl(c) || isspace(c) || ispunct(c) - || (islower(c) && toupper(c) != c && !isupper(toupper(c))) - || (isupper(c) && tolower(c) != c && !islower(tolower(c)))) - exit(1); - } - else if (islower(c) || isupper(c)) - exit(1); - else if (iscntrl(c)) { - if (ispunct(c)) - exit(1); - } - } -#endif /* isascii */ - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - # This tries to find the symbol that looks like the array - # used by , and sees if its length appears to be 128 - # rather than 256. - if test 1 = `(nm -n doit 2>/dev/null) | awk ' -BEGIN { - weight["0"] = 0; - weight["1"] = 1; - weight["2"] = 2; - weight["3"] = 3; - weight["4"] = 4; - weight["5"] = 5; - weight["6"] = 6; - weight["7"] = 7; - weight["8"] = 8; - weight["9"] = 9; - weight["a"] = weight["A"] = 10; - weight["b"] = weight["B"] = 11; - weight["c"] = weight["C"] = 12; - weight["d"] = weight["D"] = 13; - weight["e"] = weight["E"] = 14; - weight["f"] = weight["F"] = 15; -} - -/^[0-9a-zA-Z]* D .*ctype/ && ctype_nr == 0 { - ctype_nr = NR; - addr = 0; - len = length($1); - for (i = 1; i <= len; i++) - addr = addr*16 + weight[substr($1, i, 1)]; -} - -/^[0-9a-zA-Z]* D / && NR == ctype_nr + 1 { - next_addr = 0; - len = length($1); - for (i = 1; i <= len; i++) - next_addr = next_addr*16 + weight[substr($1, i, 1)]; -} - -END { - size = next_addr - addr; - if (size >= 128 && size < 256) - print "1"; - else - print "0"; -}'` - then - on="$on USE_ISASCII" - else - if ((yes | man 3 ctype) 2>/dev/null) \ - | sed -e 's/.//g' -e 's/ *$//' -e '/de-$/N' \ - -e 's/-\n//g' -e '/defined$/N' -e '/only$/N' \ - -e '/where$/N' -e '/isascii$/N' -e '/is$/N' \ - -e 's/\n/ /g' -e 's/ */ /g' \ - | grep "defined only where isascii is true" >/dev/null - then - on="$on USE_ISASCII" - else - off="$off USE_ISASCII" - fi - fi -else - on="$on USE_ISASCII" -fi - -cat >doit.c <<\EOF -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - remove("foo"); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - off="$off REMOVE_MISSING" -else - on="$on REMOVE_MISSING" -fi - -cat >doit.c <<\EOF -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - getopt(argc, argv, "v"); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_GETOPT" -else - off="$off HAVE_GETOPT" -fi - -cat >doit.c <<\EOF -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - access("foo", 4); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_ACCESS" -else - off="$off HAVE_ACCESS" -fi - -cat >doit.c <<\EOF -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - vfork(); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_VFORK" -else - off="$off HAVE_VFORK" -fi - -cat >doit.c <<\EOF -main(argc, argv) -int argc; -char **argv; -{ - - if (argc == 0) { - int status; - waitpid(-1, &status, 0); - } - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_WAITPID" -else - off="$off HAVE_WAITPID" -fi - -cat >doit.c <<\EOF -#include -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - strerror(0); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - off="$off STRERROR_MISSING" -else - on="$on STRERROR_MISSING" -fi - -cat >doit.c <<\EOF -#include -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - bcopy((char *)0, (char *)0, 0); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - # Only use BSD_STRINGS if ANSI string functions don't work. - cat >doit.c <<\EOF -#include -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - memcpy((char *)0, (char *)0, 0); - exit(0); -} -EOF - - if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null - then - off="$off BSD_STRINGS" - else - on="$on BSD_STRINGS" - fi -else - off="$off BSD_STRINGS" -fi - -cat >doit.c <<\EOF -#include -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) - raise(SIGINT); - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - off="$off RAISE_MISSING" -else - on="$on RAISE_MISSING" -fi - -cat >doit.c <<\EOF -#include -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) { - fpos_t pos; - fsetpos(stdin, &pos); - fgetpos(stdin, &pos); - } - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - off="$off FPOS_MISSING" -else - on="$on FPOS_MISSING" -fi - -cat >doit.c <<\EOF -#include -#include -#include - -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) { - pid_t pid; - int status; - long n = sysconf(_SC_OPEN_MAX); - pid = waitpid(-1, &status, 0); - WIFSTOPPED(status); - WIFSIGNALED(status); - WIFEXITED(status); - WEXITSTATUS(status); - WTERMSIG(status); - WSTOPSIG(status); - } - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on POSIX" -else - off="$off POSIX" -fi - -cat >doit.c <<\EOF -#include -#include - -static int whoops() -{ - _exit(1); -} - -main() -{ - char buf[30]; -#ifdef SIGSEGV - signal(SIGSEGV, whoops); -#endif -#ifdef SIGBUS - signal(SIGBUS, whoops); -#endif -#ifdef SIGIOT - signal(SIGIOT, whoops); -#endif - sprintf(buf, "%2$s%2$s%1$s%1$s", "bar", "foo"); - exit(!!strcmp(buf, "foofoobarbar")); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_EXTENDED_PRINTF" -else - off="$off HAVE_EXTENDED_PRINTF" -fi - -cat >doit.c <<\EOF -#include - -main(argc, argv) -int argc; -char **argv; -{ - if (argc == 0) { - nl_catd d = catopen("foo", 0); - catgets(d, 1, 1, "default"); - catclose(d); - } - exit(0); -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - on="$on HAVE_CAT" -else - off="$off HAVE_CAT" -fi - -cat >doit.c <<\EOF -#include - -char c = UCHAR_MAX; - -main(argc, argv) -int argc; -char **argv; -{ -#if CHAR_MIN < 0 - exit(!(c < 0)); -#else - exit(!(c > 0)); -#endif -} -EOF - -if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null -then - char_signed= -else - cat >doit.c <<\EOF -main() -{ - int i; - - for (i = 0; i < 512; i++) { - char c = (char)i; - if (c < 0) - exit(1); - } - exit(0); -} -EOF - - if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null - then - char_signed=0 - else - char_signed=1 - fi -fi - -cat >doit.c <<\EOF - -typedef void VOID; - -extern VOID bar(); - -VOID foo() -{ -} -EOF - -if $CC $CFLAGS -c doit.c >/dev/null 2>&1 -then - void_ret=void -else - void_ret=int -fi - - -cat >doit.c <<\EOF - -void *foo() -{ - static char *buf; - return buf; -} -EOF - -if $CC $CFLAGS -c doit.c >doit.log 2>&1 -then - if test -s doit.log - then - void_star="char \*" - else - void_star="void \*" - fi - -else - void_star="char \*" -fi - -edit= - -rm -f doit.c doit doit.log doit.o - -for var in $on -do - edit="$edit -e 's;^/\\* *\\(#define $var [^/]*\\) *\\*/;\\1;'" -done -for var in $off -do - edit="$edit -e 's;^#define $var [^/]*;/* & */;'" -done - -if test -n "$char_signed" -then - edit="$edit -e 's;^/\\* *\\(#define CHAR_SIGNED $char_signed\\) *\\*/;\\1;'" -fi - -edit="$edit -e 's/^typedef .*VOID;/typedef $void_ret VOID;/'" -edit="$edit -e 's/^typedef .*UNIV;/typedef ${void_star}UNIV;/'" - -if test "X$(PREFIX)" != "X/usr/local" -then - edit="$edit -e '/DEFAULT_PATH/s;/usr/local;$PREFIX;g'" -fi - -eval sed $edit unix.cfg ">config.out" - -mv config.out config.h - -exit 0 diff --git a/cde/programs/dtdocbook/sgmls/context.c b/cde/programs/dtdocbook/sgmls/context.c deleted file mode 100644 index 9a955a7ef..000000000 --- a/cde/programs/dtdocbook/sgmls/context.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: context.c /main/3 1996/06/19 17:14:26 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -#include "context.h" - -#define GI (tags[ts].tetd->etdgi+1) /* GI of current element. */ -#define NEWGI (newetd->etdgi+1) /* GI of new tag. */ -#define STATUS (*statuspt) /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ -#define PEX (-1) /* GI is a plus exception and not a minus. */ - -#define ANYHIT(h) (grplongs == 1 ? ((h)[0] != 0) : anyhit(h)) -#define HITSET(h, n) (h[(unsigned)(n-1)>>LONGPOW] \ - |= (1L<<((n-1)&(LONGBITS-1)))) -#define HITON(h, n) (h[(unsigned)(n-1)>>LONGPOW] & (1L<<((n-1)&(LONGBITS-1)))) - -#define HITOFF(h, n) (!(HITON(h, n))) - -#define TOKENHIT HITON(H,T) - -static -VOID copypos(to, from) -struct mpos *to, *from; -{ - int i; - for (i = 0; i <= (int)from[0].t; i++) { - to[i].g = from[i].g; - to[i].t = from[i].t; - memcpy(to[i].h, from[i].h, grplongs*sizeof(unsigned long)); - } -} - -/* CONTEXT: Determine whether a GI is valid in the present structural context. - Returns RCHIT if valid, RCEND if element has ended, RCREQ if a - different element is required, and RCMISS if it is totally invalid. - On entry, pos points to the model token to be tested against the GI. - TO DO: Save allowed GIs for an error message on an RCMISS. - Support a "query" mode (what is allowed now?) by working - with a copy of pos. -*/ -int context(gi, mod, pos, statuspt, mexts) -struct etd *gi; /* ETD of new GI. */ -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ -int mexts; /* >0=stack level of minus grp; -1=plus; 0=none.*/ -{ - UNCH toccsv, gtypesv; /* Save token's TOCC and GTYPE in case grp ends.*/ - - if (mexts == -1) { - if (STATUS == RCEND) - return RCPEX; - copypos(savedpos, pos); - } - Tstart = T; /* Save starting token for AND group testing. */ - while (STATUS!=RCMISS && STATUS!=RCEND) { - TRACEGI("CONTEXT", gi, mod, pos, Tstart); - while (TTYPE==TTOR || TTYPE==TTSEQ || TTYPE==TTAND) { - pos[P+1].g = M++; pos[++P].t = 1; HITCLEAR(H); - Tstart = T; /* Save starting token for AND group testing. */ - TRACEGI("OPENGRP", gi, mod, pos, Tstart); - } - STATUS = (UNCH)tokenreq(gi, mod, pos); - TRACEGI("STATUS", gi, mod, pos, Tstart); - if (gi==TOKEN.tu.thetd) { /* Hit in model. */ - STATUS = (UNCH)RCHIT; - gtypesv = GTYPE; toccsv = TOCC; - newtoken(mod, pos, statuspt); - return(mexts<=0 ? RCHIT : (gtypesv==TTOR || BITON(toccsv, TOPT)) - ? RCMEX : RCHITMEX); - } - if (STATUS==RCREQ) { - if (mexts == -1) - break; - STATUS = RCHIT; - nextetd = TOKEN.tu.thetd; - newtoken(mod, pos, statuspt); - return(RCREQ); - } - /* else if (STATUS==RCNREQ) */ - if (mexts>0) return(RCMEX); - newtoken(mod, pos, statuspt); - } - if (mexts == -1) { - copypos(pos, savedpos); - return STATUS = RCPEX; - } - return((int)STATUS); -} -/* ECONTEXT: Determine whether the current element can be ended, or whether - non-optional tokens remain at the current level or higher. - Returns 1 if element can be ended, or 0 if tokens remain. - On entry, STATUS==RCEND if there are no tokens left; if not, - pos points to the next model token to be tested. - TO DO: Support a "query" mode (what is required now?) by working - with a copy of pos. -*/ -int econtext(mod, pos, statuspt) -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ -{ - unsigned next; /* Position in AND group of next testable token.*/ - - Tstart = T; - TRACEEND("ECONT", mod, pos, 0, 0, Tstart); - if (P<=1) {nextetd = 0; return(TOKENHIT || BITON(TOCC, TOPT));} - nextetd = TTYPE == TTETD ? TOKEN.tu.thetd : 0; - while (STATUS!=RCMISS && STATUS!=RCEND) { - STATUS = (UNCH)testend(mod, pos, 0, 0); - TRACEEND("ECONTEND", mod, pos, 0, 0, Tstart); - nextetd = P<=1 || TTYPE != TTETD ? 0 : TOKEN.tu.thetd; - if (STATUS==RCEND) return(1); - if (P<=1) return(TOKENHIT || BITON(TOCC, TOPT)); - if (STATUS==RCMISS) { - if (BITON(TOCC, TOPT)) nextetd = 0; - return(0); - } - if (!tokenopt(mod, pos)) return(0); - - STATUS = RCNREQ; - if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */ - else T = (UNCH)(((next = (UNS)offbit(H, (int)T, GNUM))!=0) ? - next : offbit(H, 0, GNUM)); - - M = G + grpsz(&GHDR, (int)T-1) + 1; - TRACEEND("ECONTNEW", mod, pos, 0, 0, Tstart); - } - if (STATUS==RCMISS) { - if (BITON(TOCC, TOPT)) nextetd = 0; - return(0); - } - return(1); /* STATUS==RCEND */ -} -/* NEWTOKEN: Find the next token to test. Set STATUS to indicate results: - RCEND if element has ended (no more tokens to test); - RCREQ if required new token was found; - RCNREQ if non-required new token was found; - RCHIT if a hit token was repeated (now non-required); - and RCMISS if a new token can't be found because current token - (which was not hit) was neither unconditionally required nor - optional. -*/ -VOID newtoken(mod, pos, statuspt) -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -UNCH *statuspt; /* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ*/ -{ - unsigned nextand = 0; /* Position in AND group of next testable token.*/ - int currhit = (STATUS==RCHIT); /* 1=current GI hit; 0=not. */ - - /* If the GI was a hit, turn on the hit bit and set the status to - assume that the token to be tested against the next GI will - be non-required. If the current token is repeatable, exit so - it will stand as the next token to test. - */ - if (STATUS==RCHIT) { - HITSET(H, T); - STATUS = RCNREQ; - if (BITON(TOCC, TREP)) return; - } - /* At this point, we must determine the next token to test: - either against the next GI, if this one was a hit, or - against the same GI if conditions permit a retry. - To find the next token, we must first end the current group, - if possible, and any we can that contain it. - If the outermost group was a hit and is repeatable, or - if the element has ended, we exit now. - If it hasn't ended, or was optional and ended with a miss, - we can retry the GI against the next token. - */ - if ((STATUS = (UNCH)testend(mod, pos, 1, 1))!=RCNREQ) return; - - /* At this point, the "current token" is either the original one, - or the token for the highest level unhit group that it ended. - We will retry a missed GI, by testing it against the next - token, if the current token: - 1. Is optional; - 2. Was hit (i.e., because it is repeatable and was hit by a - previous GI or because it is a hit group that just ended); - 3. Is in an AND or OR group and is not the last testable token. - - It will be the next sequential one (unhit one, in an AND group); - if there are none left, use the first unhit token in the group. - In either case, set M to correspond to the new T. - */ - retest: - TRACEEND("RETEST", mod, pos, (int)nextand, 1, Tstart); - if (GTYPE==TTAND) { - nextand = offbit(H, (int)T, GNUM); - if (!nextand) - nextand = offbit(H, 0, GNUM); - } - if ( BITON(TOCC, TOPT) - || TOKENHIT - || GTYPE==TTOR /* T!=GNUM or group would have ended. */ - || nextand ) { - if (GTYPE!=TTAND) ++T; /* T!=GNUM or group would have ended. */ - else T = nextand; - M = G + grpsz(&GHDR, (int)T-1) + 1; - if (GTYPE==TTAND) { - /* If AND group wrapped, it can end if all non-optionals were - hit. */ - if (T==Tstart && !currhit) { - UNCH Psave = P; - int rc = testend(mod, pos, 0, 1); - if (Psave!=P) {if ((STATUS = (UNCH)rc)==RCNREQ) goto retest;} - else STATUS = RCMISS; - } - - /* We only test unhit tokens, so we must use an unhit token - as Tstart (which is used to detect when the AND group has - wrapped). */ - else if (HITON(H,Tstart)) Tstart = T; - } - } - else STATUS = RCMISS; - TRACEEND("NEWTOKEN", mod, pos, (int)nextand, 1, Tstart); -} -/* TESTEND: End the current group, if possible, and any that it is nested in. - The current token will either be a group header, or some token - that could not end its group. Return 1 if the (possibly new) - current token is repeatable; 0 if it is not. -*/ -int testend(mod, pos, andoptsw, newtknsw) -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -int andoptsw; /* 1=test optional AND members; 0=ignore. */ -int newtknsw; /* 1=new token test; 0=end element test. */ -{ - int rc = 0; /* Return code: RCNREQ RCHIT RCMISS RCEND */ - - while (!rc) { - TRACEEND("TRACEEND", mod, pos, rc, andoptsw, Tstart); - /* TESTMISS: - If we've hit no tokens yet in the current group, and - the current token is the last unhit one in the group we can test, - we will end the group (it may never really have started!) - because we might be able to try the token that follows it. - In any group, a token is the last testable unhit token if it - is the last sequential one, as the GI was already tested against - the preceding unhit tokens. In addition, - in a SEQ group, it is the last testable unhit token if it isn't - optional, because we can't skip past it to the following ones. - If we end the group, before popping the level, set M to G, as this - level`s group header will be the next level's current token. - */ - if (!ANYHIT(H) && (T==GNUM - || (GTYPE==TTSEQ && BITOFF(TOCC, TOPT)))) { - M = G; --P; Tstart = T; - if (P<=1) { - if (BITON(TOCC, TOPT) || TOKENHIT) rc = RCEND; - else rc = RCMISS; - } - continue; - } - /* TESTHIT: - See if we've hit all the non-optional tokens in the group. - If so, pop to the previous level and set the group's hit bit. - If we were called from NEWTOKEN we are trying to find the token - to test against the next start-tag, so if the group is repeatable, - process it again. (If not, we were called from ECONTEXT and - are testing whether the element can be ended.) - Otherwise, if we are at the first level, the element is over. - */ - if ((GTYPE==TTOR && TOKENHIT) - || (GTYPE==TTSEQ && T==(UNCH)GNUM - && (TOKENHIT || BITON(TOCC, TOPT))) - || (GTYPE==TTAND && allhit(&GHDR, H, 0, andoptsw))) { - M = G; - --P; - HITSET(H, T); - Tstart = T; - if (newtknsw && BITON(TOCC, TREP)) rc = RCHIT; - else if (P<=1) rc = RCEND; - /* If we are looking for a new token to test against the next - start-tag, then we need to consider optional and members - in this group, even if we didn't need to consider them - in the group that we just ended because that group had - wrapped. */ - else if (newtknsw) andoptsw = 1; - /* Else loop to test new outer group. */ - } - else rc = RCNREQ; /* No group ended this time, so return. */ - } - TRACEEND("ENDFOUND", mod, pos, rc, andoptsw, Tstart); - return(rc); -} -/* TOKENOPT: Return 1 if current token is contextually optional; - otherwise, return 0. -*/ -int tokenopt(mod, pos) -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -{ - TRACEEND("TOKENOPT", mod, pos, 0, 0, Tstart); - return (BITON(TOCC, TOPT) /* Inherently optional. */ - || TOKENHIT /* Was hit (handles "plus" suffix case). */ - || (!ANYHIT(H) && groupopt(mod, pos))); - /* In optional group with no hits. */ -} -/* GROUPOPT: Temporarily makes the current group be the current token so that - TOKENOPT() can be applied to it. Returns the value returned - by TOKENOPT. -*/ -int groupopt(mod, pos) -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -{ - UNCH saveM; /* Save M when testing if group is not required.*/ - int rc; /* 1=contextually optional; 0=not. */ - - if (P==1) return(BITON(GOCC, TOPT) || TOKENHIT); - saveM = M; M = G; --P; - rc = tokenopt(mod, pos); - ++P; G = M; M = saveM; - return(rc); -} -/* TOKENREQ: Returns RCREQ if the current token is "contextually required". - That is, it is not contextually optional and - 1) it is a member of a "seq" group that is either required - or has at least 1 hit token. - 2) it is a member of an "and" group in which all other - tokens were hit. - Optional tokens are not counted - if GI is ETDCDATA, as we are looking for an - omitted start-tag. Otherwise, they are counted, - as the GI might match one of them. - Returns RCNREQ if the current token is "not required". -*/ -int tokenreq(gi, mod, pos) -struct etd *gi; /* ETD of new GI. */ -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -{ - TRACEGI("TOKENREQ", gi, mod, pos, Tstart); - return( tokenopt(mod, pos) ? RCNREQ - : ( GTYPE==TTSEQ && (ANYHIT(H) || groupreq(gi, mod, pos)==RCREQ) -#if 0 - || (GTYPE==TTAND && allhit(&GHDR, H, T, \*gi!=ETDCDATA*\ 1)) -#endif - ) - ? RCREQ : RCNREQ ); -} -/* GROUPREQ: Temporarily makes the current group be the current token so that - TOKENREQ() can be applied to it. Returns the value returned - by TOKENREQ. -*/ -int groupreq(gi, mod, pos) -struct etd *gi; /* ETD of new GI. */ -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -{ - UNCH saveM; /* Save M when testing if group is not required.*/ - int rc; /* Return code: RCREQ RCNREQ */ - - if (P==1) return(BITOFF(GOCC, TOPT) ? RCREQ : RCNREQ); - saveM = M; M = G; --P; - rc = tokenreq(gi, mod, pos); - ++P; G = M; M = saveM; - return(rc); -} -/* GRPSZ: Returns the number of tokens spanned by a group in the model (M), - from the group's start (G) to a specified index within the group (T). - M = 0, plus 1 for each token in the group, plus the size of - any subgroups (gotten by calling GRPSZ recursively). On entry, - M must be equal to G at the current level. -*/ -int grpsz(g, t) -struct thdr *g; /* mod[G]: Ptr to group in the model. */ -int t; /* T: Index of last token in the group. */ -{ - struct thdr *p = g; /* Ptr to current token in the model. */ - int m = 0; /* Size of group (including nested groups). */ - int i = 0; /* Number of group members (loop counter). */ - UNS type; /* Token type (without TOREP bits). */ - - while (++i<=t) { - ++p; ++m; - type = GET(p->ttype, TTMASK); - if (type==TTOR || type==TTSEQ || type==TTAND) { - m += grpsz(p, p->tu.tnum); - p = g+m; - } - } - return(m); -} -/* ALLHIT: Returns 1 if all hit bits for the specified group are turned on, - (other than those that correspond to optional tokens if "opt" is - 0) and the "but" bit (all bits if "but" bit is zero). Otherwise, - returns 0. GRPSZ is used to skip past subgroup tokens. -*/ -int allhit(p, hits, but, opt) -struct thdr *p; /* mod[G]: Ptr to group in the model. */ -unsigned long *hits; /* H: Hit bits to be tested. */ -int but; /* Index of bit to ignore; 0=test all. */ -int opt; /* 1=optional tokens must be hit; 0=ignore. */ -{ - int b = 0; /* Index of bit being tested in hits. */ - int e = p->tu.tnum; /* Ending index (number of bits to test). */ - unsigned type; /* Token type (without TOREP bits). */ - - while (++p, ++b<=e) { - if (HITOFF(hits,b) && (opt || BITOFF(p->ttype,TOPT)) && b!=but) - return 0; - if ((type = GET(p->ttype,TTMASK))==TTOR || type==TTSEQ || type==TTAND) - p += grpsz(p, p->tu.tnum); - } - return 1; -} -/* OFFBIT: Returns the index of the first unset bit after (i.e., not including) - the caller's "first" bit. If all bits through the - specified last bit are on, it returns 0. -*/ -int offbit(bits, first, last) -unsigned long *bits; /* Bits to be tested. */ -int first; /* Index of first bit to be tested in bits. */ -int last; /* Index of last bit to be tested in bits. */ -{ - while (++first <= last) - if (HITOFF(bits, first)) - return first; - return 0; -} - -/* ANYHIT: Return 1 if any bit is set. */ - -int anyhit(bits) -unsigned long *bits; -{ - int i; - for (i = 0; i < grplongs; i++) - if (bits[i] != 0) - return 1; - return 0; -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/context.h b/cde/programs/dtdocbook/sgmls/context.h deleted file mode 100644 index 12ac929e6..000000000 --- a/cde/programs/dtdocbook/sgmls/context.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: context.h /main/3 1996/06/19 17:14:30 drk $ */ -/* context.h */ - -#define M pos[0].g /* Index of current token in model. */ -#ifdef P -#undef P -#endif -#define P pos[0].t /* Index of current group in pos. */ -#define G pos[P].g /* Index of current group in model. */ -#define T pos[P].t /* Index of current token in its group. */ -#define H pos[P].h /* Pointer to hit bits for current group. */ -#define GHDR mod[G] /* Current group header. */ -#define TOKEN mod[M] /* Current token. */ -#define TTYPE (GET(TOKEN.ttype, TTMASK)) /* Token type of current token. */ -#define TOCC (GET(TOKEN.ttype, TOREP)) /* Occurrence for current token. */ -#define GTYPE (GET(GHDR.ttype, TTMASK)) /* Token type of current group. */ -#define GOCC (GET(GHDR.ttype, TOREP)) /* Occurrence for current group. */ -#define GNUM GHDR.tu.tnum /* Number of tokens in current grp. */ diff --git a/cde/programs/dtdocbook/sgmls/dos.cfg b/cde/programs/dtdocbook/sgmls/dos.cfg deleted file mode 100644 index 0d824d628..000000000 --- a/cde/programs/dtdocbook/sgmls/dos.cfg +++ /dev/null @@ -1,95 +0,0 @@ -/* dos.cfg: Configuration file for sgmls on MS-DOS. */ - -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 - -/* Define this if you do not have strerror(). */ -/* Borland C++ has strerror(), but it adds a newline to the end of the -message, so don't use it. */ -#define STRERROR_MISSING 1 - -/* Define this if you have getopt(). */ -/* #define HAVE_GETOPT 1 */ - -#ifndef HAVE_GETOPT -/* #define OPTION_CHAR '/' */ -/* Use MS-DOS (undocumented) system call to get switch character. */ -#define SWITCHAR 1 -#define REORDER_ARGS 1 -/* #define CASE_INSENSITIVE_OPTIONS 1 */ -#endif - -/* A list of filename templates to use for searching for external entities. -See sgmls.man for details. */ -#define DEFAULT_PATH "C:\\SGML\\%N.%X;%N.%X;%N.%D" -/* The character that separates the filenames templates. */ -#define PATH_FILE_SEP ';' -/* The character that separates filenames in a system identifier. -Usually the same as PATH_FILE_SEP. */ -#define SYSID_FILE_SEP ';' -/* The environment variable that contains the list of filename templates. */ -#define PATH_ENV_VAR "SGML_PATH" - -/* Define this if open() understands the O_NOINHERIT flag. This tells -DOS that subprocesses should not inherit the file descriptor. */ -#define HAVE_O_NOINHERIT 1 - -/* When turning a minimum literal into a filename, each character in -MIN_DAT_SUBS_FROM will be replaced by the character at the -corresponding position in MIN_DATA_SUBS_TO. If there is no such -character, then the character will be stripped. */ - -#define MIN_DAT_SUBS_FROM " +,./:=?" -#define MIN_DAT_SUBS_TO "" - -/* Define this if you have access(). */ -#define HAVE_ACCESS 1 - -/* Define this if you have . */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define this if you have a Unix-style . */ -#define HAVE_SYS_STAT_H 1 - -/* Define this to strip an extension off the program name in argv[0], - before using it in error messsages. */ -#define PROG_STRIP_EXTENSION 1 - -/* Define this to fold the program name in argv[0] to lower case, - before using it in error messsages. */ -#define PROG_FOLD 1 - -/* Before using argv[0] in error messages, strip off everything up to and -including the last character in prog that occurs in PROG_PREFIX. */ -#define PROG_PREFIX "\\/:" - -/* Define this to allow tracing. */ -/* #define TRACE 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C. */ -#define SUPPORT_SUBDOC 1 - -/* Define this if your shell does not allow you conveniently to -redirect errors to a file. Then sgmls will provide an option (-f) -that does this. */ -#define CANT_REDIRECT_STDERR 1 - -typedef void *UNIV; /* Universal (i.e., undefined) pointer type. */ -typedef void VOID; /* void as a function return type */ - -/* If you don't have , define CHAR_SIGNED as 1 or 0 -according to whether the `char' type is signed. */ -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* Assume the system character set is ISO Latin-1. */ -#include "latin1.h" diff --git a/cde/programs/dtdocbook/sgmls/dosproc.c b/cde/programs/dtdocbook/sgmls/dosproc.c deleted file mode 100644 index d84c8988a..000000000 --- a/cde/programs/dtdocbook/sgmls/dosproc.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: dosproc.c /main/3 1996/06/19 17:14:34 drk $ */ -/* dosproc.c - - - MS-DOS implementation of run_process(). - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifdef SUPPORT_SUBDOC - -#include "std.h" -#include "entity.h" -#include "appl.h" - -#include - -int run_process(argv) -char **argv; -{ - int ret; - fflush(stdout); - fflush(stderr); - ret = spawnvp(P_WAIT, argv[0], argv); - if (ret < 0) - appl_error(E_EXEC, argv[0], strerror(errno)); - return ret; -} - -#endif /* SUPPORT_SUBDOC */ - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/ebcdic.c b/cde/programs/dtdocbook/sgmls/ebcdic.c deleted file mode 100644 index cb6339a10..000000000 --- a/cde/programs/dtdocbook/sgmls/ebcdic.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ebcdic.c /main/3 1996/06/19 17:14:38 drk $ */ -/* ASCII to EBCDIC (ISO 8859-1 to IBM CP 37v2) table. */ -/* Contributed by C. M. Sperberg-McQueen . */ - -/* The mapping must be 1 to 1. The positions of *CHAR and *CH in the table -must not be changed, although the values in ebcdic.h can be. */ - -#include "ebcdic.h" - -unsigned char charset[] = { - 0, 1, 2, 3, 55, 45, 46, 47, - GENRECHAR, TABCHAR, RSCHAR, 11, 12, RECHAR, 14, 15, - 16, 17, 18, 19, 60, 61, 50, 38, - 24, 25, EOFCHAR, 39, EOBCHAR, DELCDATA, DELSDATA, DELNONCH, - SPCCHAR, 90, 127, 123, 91, 108, 80, 125, - 77, 93, 92, 78, 107, 96, 75, 97, -240, 241, 242, 243, 244, 245, 246, 247, -248, 249, 122, 94, 76, 126, 110, 111, -124, 193, 194, 195, 196, 197, 198, 199, -200, 201, 209, 210, 211, 212, 213, 214, -215, 216, 217, 226, 227, 228, 229, 230, -231, 232, 233, 173, 224, 189, 176, 109, -121, 129, 130, 131, 132, 133, 134, 135, -136, 137, 145, 146, 147, 148, 149, 150, -151, 152, 153, 162, 163, 164, 165, 166, -167, 168, 169, 192, 79, 208, 161, 7, - 4, 6, 8, 9, 10, 20, 21, 23, - 26, 27, 32, 33, 34, 35, 36, 40, - 41, 42, 43, 44, 48, 49, 51, 52, - 53, 54, 56, 57, 58, 59, 62, 255, - 65, 170, 74, 177, 159, 178, 106, 181, -187, 180, 154, 138, 95, 202, 175, 188, -144, 143, 234, 250, 190, 160, 182, 179, -157, 218, 155, 139, 183, 184, 185, 171, -100, 101, 98, 102, 99, 103, 158, 104, -116, 113, 114, 115, 120, 117, 118, 119, -172, 105, 237, 238, 235, 239, 236, 191, -128, 253, 254, 251, 252, 186, 174, 89, - 68, 69, 66, 70, 67, 71, 156, 72, - 84, 81, 82, 83, 88, 85, 86, 87, -140, 73, 205, 206, 203, 207, 204, 225, -112, 221, 222, 219, 220, 141, 142, 223, -}; diff --git a/cde/programs/dtdocbook/sgmls/ebcdic.h b/cde/programs/dtdocbook/sgmls/ebcdic.h deleted file mode 100644 index ce51f3f7e..000000000 --- a/cde/programs/dtdocbook/sgmls/ebcdic.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ebcdic.h /main/3 1996/06/19 17:14:42 drk $ */ -/* SGML Character Use: EBCDIC -*/ - -#define EOFCHAR '\077' /* FUNCTION: EE (entity end: files). */ -#define EOBCHAR '\034' /* NONCHAR: EOB (file entity: end of buffer. */ -#define RSCHAR '\045' /* FUNCTION: RS (record start). */ -#define RECHAR '\015' /* FUNCTION: RE (record end). */ -#define TABCHAR '\005' /* FUNCTION: TAB (horizontal tab). */ -#define SPCCHAR '\100' /* FUNCTION: SPACE (horizontal space). */ -#define GENRECHAR '\026' /* NONCHAR: Generated RE. */ -#define DELCDATA '\035' /* NONCHAR: Delimiter for CDATA entity in - attribute value. */ -#define DELSDATA '\036' /* NONCHAR: Delimiter for SDATA entity in - attribute value. */ -#define DELNONCH '\037' /* NONCHAR: non-SGML character prefix. */ - -/* This should work for EBCDIC. See comment in latin1.h. */ -#define SHIFTNON(ch) ((UNCH)(ch) | 0200) -#define UNSHIFTNON(ch) ((UNCH)(ch) & ~0200) - -/* See comment in latin1.h. */ -#define CANON_NONSGML 255 - -/* See comment in latin1.h. */ -#define CANON_DATACHAR 254 - -/* Components for a formal public identifier for the whole of the -system character set. Protect with ifndef so that it can be overriden -in config.h. */ - -/* Use a private escape sequence. */ -#ifndef SYSTEM_CHARSET_DESIGNATING_SEQUENCE -#define SYSTEM_CHARSET_DESIGNATING_SEQUENCE "ESC 2/5 2/15 3/0" -#endif -#ifndef SYSTEM_CHARSET_OWNER -#define SYSTEM_CHARSET_OWNER "-//IBM" -#endif -#ifndef SYSTEM_CHARSET_DESCRIPTION -#define SYSTEM_CHARSET_DESCRIPTION "Code Page 1047" -#endif diff --git a/cde/programs/dtdocbook/sgmls/entgen.c b/cde/programs/dtdocbook/sgmls/entgen.c deleted file mode 100644 index f32d92893..000000000 --- a/cde/programs/dtdocbook/sgmls/entgen.c +++ /dev/null @@ -1,428 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: entgen.c /main/3 1996/06/19 17:14:46 drk $ */ -/* entgen.c - - - Implement entgen() which generates a list of filenames from a struct fpi. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifdef HAVE_ACCESS - -#ifdef HAVE_UNISTD_H -#include /* For R_OK. */ -#endif /* HAVE_UNISTD_H */ - -#ifndef R_OK -#define R_OK 4 -#endif /* not R_OK */ - -#endif /* HAVE_ACCESS */ - -#include "sgmlaux.h" - -/* Environment variable that contains path. */ -#ifndef PATH_ENV_VAR -#define PATH_ENV_VAR "SGML_PATH" -#endif -/* Default search path. See field() for interpretation of %*. */ -#ifndef DEFAULT_PATH -#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D" -#endif - -#ifndef PATH_FILE_SEP -#define PATH_FILE_SEP ':' -#endif - -#ifndef SYSID_FILE_SEP -#define SYSID_FILE_SEP ':' -#endif - -/* This says: change space to underscore, slash to percent. */ - -#ifndef MIN_DAT_SUBS_FROM -#define MIN_DAT_SUBS_FROM " /" -#endif -#ifndef MIN_DAT_SUBS_TO -#define MIN_DAT_SUBS_TO "_%" -#endif - -static int field P((struct fpi *, int, char *)); -static int mindatcpy P((char *, char *, int, int)); -static int testopen P((char *)); -static UNIV sysidgen P((char *)); - -static char *path = 0; - -/* Non-zero if searching should be performed when a system identifier -is specified. */ -static int sysidsrch = 0; - -#define EMPTY_VERSION "default" - -static char *classes[] = { - "capacity", - "charset", - "notation", - "syntax", - "document", - "dtd", - "elements", - "entities", - "lpd", - "nonsgml", - "shortref", - "subdoc", - "text" - }; - -/* This is mainly for compatibility with arcsgml. */ - -static char *genext[] = { - "nsd", /* Non-SGML data entity. */ - "gml", /* GML document or text entity. */ - "spe", /* System parameter entity. */ - "dtd", /* Document type definition. */ - "lpd", /* Link process definition. */ - "pns", /* Public non-SGML data entity. */ - "pge", /* Public general entity. */ - "ppe", /* Public parameter entity. */ - "pdt", /* Public document type definition. */ - "plp", /* Public link process definition. */ - "vns", /* Display version non-SGML data entity. */ - "vge", /* Display version general entity. */ - "vpe", /* Display version parameter entity. */ - "vdt", /* Display version document type definition.*/ - "vlp", /* Display version link process definition.*/ -}; - -static char *ext[] = { - "sgml", /* SGML subdocument */ - "data", /* Data */ - "text", /* General text */ - "parm", /* Parameter entity */ - "dtd", /* Document type definition */ - "lpd", /* Link process definition */ -}; - -/* Like memcpy, but substitute, fold to lower case (if fold is -non-zero) and null terminate. This is used both for minimum data and -for names. If p is NULL, do nothing. Return len. */ - -static int mindatcpy(p, q, len, fold) -char *p, *q; -int len; -int fold; -{ - static char subsfrom[] = MIN_DAT_SUBS_FROM; - static char substo[] = MIN_DAT_SUBS_TO; - int n; - - if (!p) - return len; - for (n = len; --n >= 0; q++) { - char *r = strchr(subsfrom, *q); - if (!r) { - if (fold && ISASCII(*q) && isupper((UNCH)*q)) - *p++ = tolower((UNCH)*q); - else - *p++ = *q; - } - else { - int i = r - subsfrom; - if (i < sizeof(substo) - 1) - *p++ = substo[i]; - } - } - *p = '\0'; - return len; -} - - -/* Return length of field. Copy into buf if non-NULL. */ - -static int field(f, c, buf) -struct fpi *f; -int c; -char *buf; -{ - int n; - - switch (c) { - case '%': - if (buf) { - buf[0] = '%'; - buf[1] = '\0'; - } - return 1; - case 'N': /* the entity, document or dcn name */ - return mindatcpy(buf, (char *)f->fpinm, ustrlen(f->fpinm), - (f->fpistore != 1 && f->fpistore != 2 && f->fpistore != 3 - ? NAMECASE - : ENTCASE)); - case 'D': /* dcn name */ - if (f->fpistore != 1) /* not a external data entity */ - return -1; - if (f->fpinedcn == 0) /* it's a SUBDOC */ - return -1; - return mindatcpy(buf, (char *)f->fpinedcn, ustrlen(f->fpinedcn), - NAMECASE); - case 'X': - /* This is for compatibility with arcsgml */ - if (f->fpistore < 1 || f->fpistore > 5) - return -1; - n = (f->fpipubis != 0)*(f->fpiversw > 0 ? 2 : 1)*5+f->fpistore - 1; - if (buf) - strcpy(buf, genext[n]); - return strlen(genext[n]); - case 'Y': /* tYpe */ - n = f->fpistore; - if (n < 1 || n > 5) - return -1; - if (n == 1 && f->fpinedcn == 0) /* it's a SUBDOC */ - n = 0; - if (buf) - strcpy(buf, ext[n]); - return strlen(ext[n]); - case 'P': /* public identifier */ - if (!f->fpipubis) - return -1; - return mindatcpy(buf, (char *)f->fpipubis, ustrlen(f->fpipubis), 0); - case 'S': /* system identifier */ - if (!f->fpisysis) - return -1; - else { - UNCH *p; - n = 0; - for (p = f->fpisysis; *p; p++) - if (*p != RSCHAR) { - if (buf) - buf[n] = *p == RECHAR ? '\n' : *p; - n++; - } - return n; - } - } - /* Other fields need a formal public identifier. */ - /* return -1 if the formal public identifier was invalid or missing. */ - if (f->fpiversw < 0 || !f->fpipubis) - return -1; - - switch (c) { - case 'A': /* Is it available? */ - return f->fpitt == '+' ? 0 : -1; - case 'I': /* Is it ISO? */ - return f->fpiot == '!' ? 0 : -1; - case 'R': /* Is it registered? */ - return f->fpiot == '+' ? 0 : -1; - case 'U': /* Is it unregistered? */ - return f->fpiot == '-' ? 0 : -1; - case 'L': /* public text language */ - if (f->fpic == FPICHARS) - return -1; - /* it's entered in all upper case letters */ - return mindatcpy(buf, (char *)f->fpipubis + f->fpil, f->fpill, 1); - case 'O': /* owner identifier */ - return mindatcpy(buf, (char *)f->fpipubis + f->fpio, f->fpiol, 0); - case 'C': /* public text class */ - n = f->fpic - 1; - if (n < 0 || n >= sizeof(classes)/sizeof(classes[0])) - return -1; - if (buf) - strcpy(buf, classes[n]); - return strlen(classes[n]); - case 'T': /* text description */ - return mindatcpy(buf, (char *)f->fpipubis + f->fpit, f->fpitl, 0); - case 'V': - if (f->fpic < FPICMINV) /* class doesn't have version */ - return -1; - if (f->fpiversw > 0) /* no version */ - return -1; - if (f->fpivl == 0) { /* empty version: */ - /* use device-independent version*/ - if (buf) - strcpy(buf, EMPTY_VERSION); - return strlen(EMPTY_VERSION); - } - return mindatcpy(buf, (char *)f->fpipubis + f->fpiv, f->fpivl, 0); - case 'E': /* public text designating (escape) sequence */ - if (f->fpic != FPICHARS) - return -1; - return mindatcpy(buf, (char *)f->fpipubis + f->fpil, f->fpill, 0); - default: - break; - } - return -1; -} - -static int testopen(pathname) -char *pathname; -{ -#ifdef HAVE_ACCESS - return access(pathname, R_OK) >= 0; -#else /* not HAVE_ACCESS */ - FILE *fp; - fp = fopen(pathname, "r"); - if (!fp) - return 0; - fclose(fp); - return 1; -#endif /* not HAVE_ACCESS */ -} - -/* Return a pointer to an dynamically-allocated buffer that contains - the names of the files containing this entity, with each filename - terminated by a '\0', and with the list of filenames terminated by - another '\0'. */ - -UNIV entgen(f) -struct fpi *f; -{ - char *file; - - assert(f->fpistore != 6); /* Musn't call entgen for a notation. */ - if (!path) { - char *p; - char c; - path = getenv(PATH_ENV_VAR); - if (!path) - path = DEFAULT_PATH; - p = path; - - /* Only search for system identifiers if path uses %S. */ - while ((c = *p++) != '\0') - if (c == '%') { - if (*p == 'S') { - sysidsrch = 1; - break; - } - if (*p != '\0' && *p != PATH_FILE_SEP) - p++; - } - } - if (f->fpisysis - && (!sysidsrch - || strchr((char *)f->fpisysis, SYSID_FILE_SEP) - || strcmp((char *)f->fpisysis, STDINNAME) == 0)) - return sysidgen((char *)f->fpisysis); - - file = path; - - for (;;) { - char *p; - int len = 0; - char *fileend = strchr(file, PATH_FILE_SEP); - if (!fileend) - fileend = strchr(file, '\0'); - - /* Check that all substitutions are non-null, and calculate - the resulting total length of the filename. */ - for (p = file; p < fileend; p++) - if (*p == '%') { - int n; - /* Set len to -1 if a substitution is invalid. */ - if (++p >= fileend) { - len = -1; - break; - } - n = field(f, *p, (char *)0); - if (n < 0) { - len = -1; - break; - } - len += n; - } - else - len++; - - if (len > 0) { - /* We've got a valid non-empty filename. */ - char *s; - char *buf; - - s = buf = (char *)rmalloc(len + 2); - for (p = file; p < fileend; p++) - if (*p == '%') - s += field(f, *++p, s); - else - *s++ = *p; - *s++ = '\0'; - if (testopen(buf)) { - /* Terminate the array of filenames. */ - *s++ = '\0'; - return buf; - } - free((UNIV)buf); - } - if (*fileend == '\0') - break; - file = ++fileend; - } - return 0; -} - -/* Handle a system identifier without searching. */ - -static -UNIV sysidgen(s) -char *s; -{ - char *buf, *p; - - buf = (char *)rmalloc(strlen(s) + 2); - - for (p = buf; *s; s++) { - if (*s == SYSID_FILE_SEP) { - if (p > buf && p[-1] != '\0') - *p++ = '\0'; - } - else if (*s == RECHAR) - *p++ = '\n'; - else if (*s != RSCHAR) - *p++ = *s; - } - /* Terminate this filename. */ - if (p > buf && p[-1] != '\0') - *p++ = '\0'; - if (p == buf) { - /* No filenames. */ - frem((UNIV)buf); - return 0; - } - /* Terminate the list. */ - *p++ = '\0'; - return buf; -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/entity.h b/cde/programs/dtdocbook/sgmls/entity.h deleted file mode 100644 index cf6d26b2f..000000000 --- a/cde/programs/dtdocbook/sgmls/entity.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: entity.h /main/3 1996/06/19 17:14:51 drk $ */ -/* Struct dcncb: attribute list added to support data attributes. */ -#ifndef ENTITY_H /* Don't include this file more than once. */ -#define ENTITY_H -/* ENTITY.H: Definitions and control block templates for entity management. -*/ -#include "tools.h" /* Definitions for type declarations, etc. */ -#include "msgcat.h" - -#define STDINNAME "-" /* File name that refers to standard input. */ - -#define EOS '\0' /* NONCHAR: EE (entity end: strings). */ - -#define AVALCASE 2 /* 2=untranslated string of name characters. */ - -#define REFNAMELEN 8 /* reference quantity set NAMELEN */ -#define REFLITLEN 240 /* reference quantity set LITLEN */ - -/* Minimization status of returned tags. -*/ -#define MINNONE 0 /* Minimization: tag not minimized. */ -#define MINNULL 1 /* Minimization: tag was null. */ -#define MINNET 2 /* Minimization: end-tag was NET delimiter. */ -#define MINDATA 3 /* Minimization: end-tag was data tag. */ -#define MINSTAG 4 /* Minimization: tag implied by start-tag. */ -#define MINETAG 5 /* Minimization: end-tag implied by end-tag. */ - -/* Formal public identifier public text classes. -*/ -#define FPICAP 1 -#define FPICHARS 2 -#define FPINOT 3 -#define FPISYN 4 -#define FPICMINV 5 /* Minimum fpic value for versionable text. */ -#define FPIDOC 5 -#define FPIDTD 6 -#define FPIELEM 7 -#define FPIENT 8 -#define FPILPD 9 -#define FPINON 10 -#define FPISHORT 11 -#define FPISUB 12 -#define FPITEXT 13 -struct fpi { /* Formal public identifier. */ - UNCH fpiot; /* Owner type: + or - or ! (for ISO). */ - UNS fpiol; /* Length of owner identifier. */ - UNS fpio; /* Offset in pubis of owner identifier (no EOS).*/ - int fpic; /* Public text class. */ - UNCH fpitt; /* Text type: - or + (for available). */ - UNS fpitl; /* Length of text identifier. */ - UNS fpit; /* Offset in pubis of text identifier (no EOS). */ - UNS fpill; /* Language/designating sequence length. */ - UNS fpil; /* Offset in pubis of language. */ - UNS fpivl; /* Length of display version . */ - UNS fpiv; /* Offset in pubis of display version (no EOS). */ - int fpiversw; /* 1=use best ver; 0=use stated ver; -1=error. */ - UNCH *fpinm; /* Entity/DCN name (EOS, no length). */ - UNCH fpistore; /* 1=NDATA 2=general 3=parm 4=DTD 5=LPD 6=DCN. */ - /* Name of the entity's DCN. Valid only when fpistore == 1. - NULL if it's a SUBDOC. */ - UNCH *fpinedcn; - UNCH *fpipubis; /* Public ID string (EOS). */ - UNCH *fpisysis; /* System ID string (EOS). */ -}; -#define FPISZ sizeof(struct fpi) -typedef struct fpi *PFPI; /* Ptr to FPI control block. */ - -/* General control blocks. -*/ -#define NONONCH 1 /* Character references to non-chars invalid. */ -#define OKNONCH 0 /* Character references to non-chars allowed. */ -struct parse { /* Parse control block. */ - char *pname; /* Parse name; content, tag, etc. */ - UNCH *plex; /* Lexical analysis table. */ - UNCH **ptab; /* State and action table. */ - UNS state; /* State. */ - UNS input; /* Input. */ - UNS action; /* Action. */ - UNS newstate; /* Next state. */ -}; -struct restate { - UNS sstate; /* State. */ - UNS sinput; /* Input. */ - UNS saction; /* Action. */ - UNS snext; /* Next state. */ -}; -struct map { - UNCH *mapnm; /* Name followed by EOS. */ - int mapdata; /* Data associated with that name. */ -}; -struct hash { /* Dummy structure for function arguments. */ - struct hash *enext; /* Next entry in chain. */ - UNCH *ename; /* Entry name with size and EOS. */ -}; -typedef struct hash *PHASH; /* Ptr to hash table entry. */ -typedef struct hash **THASH; /* Ptr to hash table. */ - -struct fwdref { /* A forward id reference. */ - struct fwdref *next; /* Pt to next reference in chain. */ - UNIV msg; /* Ptr to saved error messsage. */ -}; -#define FWDREFSZ sizeof(struct fwdref) - -struct dcncb { /* Data content notation control block. */ - struct dcncb *enext; /* Next DCN in chain. */ - UNCH *ename; /* Notation name followed by EOS. */ - UNCH mark; /* For use by application. */ - UNCH entsw; /* Entity defined with this notation? */ - UNCH defined; /* Has this notation been defined. */ - UNCH *sysid; /* System identifier of notation. */ - UNCH *pubid; /* Public identifier of notation. */ - struct ad *adl; /* Data attribute list (NULL if none). */ -}; -#define DCBSZ sizeof(struct dcncb) -#define DCNMARK(p) ((p)->mark ? 1 : ((p)->mark = 1, 0)) - -typedef struct dcncb *PDCB; /* Ptr to DCN control block. */ - -/* Number of capacities in a capacity set. */ - -#define NCAPACITY 17 - -struct sgmlcap { - char **name; - UNCH *points; - long *number; - long *limit; -}; - -struct sgmlstat { /* Document statistics. */ - UNS dcncnt; /* Number of data content notations defined. */ - UNS pmexgcnt; /* Number of plus or minus exception groups. */ - UNS etdcnt; /* Number of element types declared. */ - UNS etdercnt; /* Number of element types defined by default. */ - UNS pmexcnt; /* Number of plus/minus exception grp members. */ - UNS modcnt; /* Number of content model tokens defined. */ - UNS attcnt; /* Number of attributes defined. */ - UNS attdef; /* Characters of attribute defaults defined. */ - UNS attgcnt; /* Number of att value grp members (incl dcn). */ - UNS idcnt; /* Number of ID attributes specified. */ - UNS idrcnt; /* Number of ID references specified. */ - UNS ecbcnt; /* Number of entities declared. */ - UNS ecbtext; /* Characters of entity text defined. */ - UNS srcnt; /* Number of short reference tables defined. */ - UNS dcntext; /* Characters of notation identifiers defined. */ -}; -struct switches { /* Parser control switches (1=non-standard). */ - int swdupent; /* 1=msg if duplicate ENTITY def attempted;0=no.*/ - int swcommnt; /* 1=return comment declarations as data; 0=no. */ - int swrefmsg; /* 1=msg if undeclared ref is defaulted; 0=no. */ - UNS swbufsz; /* Size of source file buffer for READ(). */ - int swenttr; /* 1=trace entity stack in error messages; 0=no.*/ - int sweltr; /* 1=trace element stack in error messages; 0=no. */ - int swambig; /* 1=check content model ambiguity */ - int swundef; /* 1=warn about undefined elements and notations. */ - char *prog; /* Program name for error messages. */ -#ifdef TRACE - char *trace; /* What to trace in the body. */ - char *ptrace; /* What to trace in the prolog. */ -#endif /* TRACE */ - nl_catd catd; /* Message catalog descriptor. */ - long nopen; /* Number of open document entities */ - int onlypro; /* Parse only the prolog. */ - char **includes; /* List of parameter entities to be defined - as "INCLUDE"; NULL terminated.*/ - VOID (*die) P((void)); /* Function to call on fatal error. */ -}; -struct markup { /* Delimiter strings for text processor. */ - UNCH *cro; /* LEXCON markup string: CRO */ - UNCH *dso; /* LEXCON markup string: DSO */ - UNCH *ero; /* LEXCON markup string: ERO */ - UNCH *etag; /* LEXMARK markup string: end-tag */ - UNCH *lit; /* LEXMARK markup string: LIT */ - UNCH *lita; /* LEXMARK markup string: LITA */ - UNCH *mdc; /* LEXCON markup string: MDC */ - UNCH *mdo; /* LEXCON markup string: MDO */ - UNCH *mse; /* LEXCON markup string: mse */ - UNCH *mss; /* LEXCON markup string: mss */ - UNCH *mssc; /* LEXCON markup string: mss CDATA */ - UNCH *mssr; /* LEXCON markup string: mss RCDATA */ - UNCH *pic; /* LEXCON markup string: PIC */ - UNCH *pio; /* LEXCON markup string: PIO */ - UNCH *refc; /* LEXGRP markup string: REFC */ - UNCH *stag; /* LEXMARK markup string: start-tag */ - UNCH *tagc; /* LEXMARK markup string: TAGC */ - UNCH *vi; /* LEXMARK markup string: VI */ - int lennet; /* LEXMARK markup string length: null end-tag. */ - int lennst; /* LEXMARK markup string length: null start-tag.*/ -}; -#endif /* ndef ENTITY_H */ diff --git a/cde/programs/dtdocbook/sgmls/error.h b/cde/programs/dtdocbook/sgmls/error.h deleted file mode 100644 index e7d06a1f6..000000000 --- a/cde/programs/dtdocbook/sgmls/error.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: error.h /main/3 1996/06/19 17:14:57 drk $ */ -/* ERROR.H: Symbols for SGML error codes (start with 'E_'). - Numbers 46 - 56 are generated by ERROR.C. - Later numbers are coded directly. -*/ -/* SGMLERR.C: General errors and syntax errors. -*/ -#define E_CONTEXT 1 /* W GI not allowed at this point in structure. */ -#define E_MDNAME 2 /* E Invalid markup declaration name. */ -/*efine E_LEN 3 E Syntax error: length exceeded. */ -#define E_SYS 4 /* W Illegal system character. */ -#define E_ETAG 5 /* E End-tag does not match any open start-tag. */ -#define E_STAGMAX 6 /* E Maximum number of open elements exceeded. */ -/* E_ALLNULL 7 W Start- and end-tag omitted with null content. */ -#define E_EOF 8 /* E/W Illegal entity end in markup or delimited text. */ -/* fine E_INV 9 E Markup error: invalid character. */ -#define E_CHARS 10 /* W Data found in content that doesn't allow it. */ -/* fine E_NOETDE 11 E End-tag GI not defined by element declaration. */ -#define E_BADNM 12 /* E Name is not syntactically valid. */ -#define E_BADATT 13 /* E Attribute was not defined by element declaration. */ -#define E_VALINV 14 /* W Att value/declaration conflict: invalid char. */ -#define E_VALLEN 15 /* W Att value/declaration conflict: token too long. */ -#define E_VALCNT 16 /* W Att value/declaration conflict: too many tokens. */ -#define E_VALTYPE 17 /* W Att value/declaration conflict: wrong token type.*/ -#define E_VALGRP 18 /* W Att value/declaration conflict: token not in grp.*/ -#define E_VALREQ 19 /* W Att value/declaration conflict: req unspecified. */ -/* E_EMIN 20 W End-tag implied by end-tag; not minimizable. */ -/* E_SMIN 21 W Omitted start-tag was not minimizable. */ -#define E_POSSATT 22 /* E Possible att found but not defined; used as data.*/ -/* Late additions numbered out of order to avoid recompilation. */ -/*efine E_ENTSYNC 37 E Entity and group nesting levels out of sync. */ -#define E_BADVAL 25 /* W Att value omitted (null); default used. */ -/* E_ECONTXT 30 W Element ended prematurely (some content omitted).*/ -/* E_EMINST 39 W End-tag implied by start-tag; not minimizable. */ -/* E_MEXTAG 40 W *** In Use *** */ -#define E_MEXERR 41 /* W Attempt to exclude contextually required element.*/ -#define E_DOCTYPE 42 /* W No document type defined; *DOCTYPE assumed. */ -/* E_NOETDS 43 E Start-tag GI not defined by element declaration. */ -#define E_RESTART 44 /* E Invalid chars ignored; trying to restart parse. */ - -/* MDERROR.C: Errors in markup declarations. -*/ -/*efine E_DUP 23 E Duplicate specification. */ -/*efine E_KEY 24 E Incorrect keyword for parameter. */ -/*efine E_MSE 26 E MSE occurred with no corresponding MS. */ -/*efine E_MSS 27 E MSS exceeded maximum nesting level. */ -/*efine E_NUM 28 E Incorrect number of parameters. */ -#define E_TYPE 29 /* E Incorrect parameter type. */ -/* Late additions numbered out of order to avoid recompilation. */ -/*efine E_VAL 38 W Incorrect parameter value. */ - -/* RESERROR.C: Errors in resource routines. -*/ -/* Unused I End of primary source entity. */ -/* fine E_FILBUF 31 E Could not read next buffer. */ -/* fine E_ERFILE 32 E Could not open file. */ -/* fine E_MALLOC 33 T Could not obtain required main storage. */ -/* fine E_ERMAX 34 E Maximum number of open entities exceeded. */ -/* fine E_ERNAME 35 E Referenced entity undeclared. */ -/* fine E_ERLOOP 36 E Entity referenced within itself: ref ignored. */ -/* Late additions numbered out of order to avoid recompilation. */ -/* E_ERDEF 45 E Referenced entity undeclared; SYSTEM assumed. */ diff --git a/cde/programs/dtdocbook/sgmls/etype.h b/cde/programs/dtdocbook/sgmls/etype.h deleted file mode 100644 index f9a967a74..000000000 --- a/cde/programs/dtdocbook/sgmls/etype.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: etype.h /main/3 1996/06/19 17:15:01 drk $ */ -/* ETYPE.H: Definitions for element type and group processing. -*/ -#define MCHARS 0x80 /* Model: contains #CHARS. */ -#define MGI 0x40 /* Model: contains GI names. */ -#define MPHRASE 0x20 /* Model: first token is #CHARS. */ -#define MKEYWORD 0x1F /* Model: defined with single keyword. */ -#define MNONE 0x10 /* Model: contains no GIs or #CHARS. */ -#define MANY 0x08 /* Model: contains any GIs or #CHARS. */ -#define MRCDATA 0x04 /* Model: contains RCDATA. */ -#define MCDATA 0x02 /* Model: contains CDATA. */ - -#define TOREP (TOPT+TREP) /* 11000000 Optional and repeatable. */ -#define TOPT 0x80 /* Token: 1=optional; 0=required. */ -#define TREP 0x40 /* Token: 1=repeatable; 0=not. */ -#define TXOREP (TXOPT+TXREP) /* * explicitly specified */ -#define TXOPT 0x20 /* ? explicitly specified */ -#define TXREP 0x10 /* + explicitly specified */ -#define TTMASK 0x0F /* 00001111 Mask for testing token type. */ -#define TTETD 4 /* 00000100 Token is an ETD. */ -#define TTAND 3 /* 00000011 Token is an AND group. */ -#define TTSEQ 2 /* 00000010 Token is a sequence group. */ -#define TTOR 1 /* 00000001 Token is an OR group. */ -#define TTCHARS 0 /* 00000000 Token is #CHARS. */ - -struct thdr { /* Token header or model header. */ - UNCH ttype; /* Token type attributes or model content. */ - union { - int tnum; /* Group token: tokens in group. - Model header: content tokens at any level. */ - struct etd *thetd; /* GI token: ptr to etd. */ - } tu; -}; -#define THSZ (sizeof(struct thdr)) - -#define ETDHASH 211 /* Size of element hash table. Must be prime. */ -#define SMO 0x40 /* ETDMIN: Start-tag O minimization. */ -#define EMO 0x04 /* ETDMIN: End-tag O minimization. */ -#define EMM 0x02 /* ETDMIN: End-tag minimization explicitly - specified to be minus */ -#define ETDDCL 0x80 /* ETDMIN: Element was declared. */ -#define ETDUSED 0x20 /* ETDMIN: Element used in another declaration. */ -#define ETDOCC 0x10 /* ETDMIN: Element occurred in document. */ - -struct etd { /* Element type definition. */ - struct etd *etdnext; /* Next element type definition in hash chain. */ - UNCH *etdgi; /* GI preceded by its length, followed by EOS. */ - UNCH etdmin; /* Flag bits: minimization. */ - UNCH mark; /* Mark bit: for ambiguity checking */ - struct thdr *etdmod; /* Content model. */ - struct etd **etdmex; /* Minus exceptions. */ - struct etd **etdpex; /* Plus exceptions. */ - struct ad *adl; /* Attribute descriptor list. */ - struct entity **etdsrm; /* Short reference map. */ -}; -#define ETDSZ (sizeof(struct etd)) -typedef struct etd *PETD; -extern struct etd dumetd[]; - -/* Number of bits in a long must be >= 1<etdmod; - - if ((mod->ttype & MKEYWORD) == 0 && exmark(1)) { - int excl; - - excktok(mod + 1, 0, &excl); - exmark(0); - } -} - -/* Set the mark field of all current exclusions to val. Return 1 if -there are some current exclusions. */ - -static -int exmark(val) -int val; -{ - int i; - int gotone = 0; - - for (i = ts; i > 0; --i) { - struct etd **p = tags[i].tetd->etdmex; - if (p) { - for (; *p; p++) - (*p)->mark = val; - gotone = 1; - } - } - return gotone; -} - -/* Check exclusions for this token. Return size of token. */ - -static -int excktok(t, orgrp, excl) -struct thdr *t; -int orgrp; /* 1 if token is member of or group */ -int *excl; /* Set to 1 if token is excluded. */ -{ - int size; - struct thdr *tem; - int tnum; - int optional = 0; - int hadopt, hadreq; - - *excl = 0; - - switch (t->ttype & TTMASK) { - case TTETD: - if (t->tu.thetd->mark) { - if (orgrp || (t->ttype & TOPT)) - *excl = 1; - else - sgmlerr(217, &pcbstag, t->tu.thetd->etdgi + 1, - tags[ts].tetd->etdgi + 1); - } - /* fall through */ - case TTCHARS: - size = 1; - break; - case TTOR: - case TTAND: - case TTSEQ: - tem = t + 1; - hadopt = 0; - hadreq = 0; - for (tnum = t->tu.tnum; tnum > 0; --tnum) { - int ex; - int n = excktok(tem, (t->ttype & TTMASK) == TTOR, &ex); - if (!ex) { - if (tem->ttype & TOPT) - hadopt = 1; - else - hadreq = 1; - } - tem += n; - } - size = tem - t; - if ((t->ttype & TTMASK) == TTOR) - optional = hadreq ? hadopt : 1; - else - optional = !hadreq; - break; - default: - abort(); - } - - /* Was required, but exclusions have made it optional. - eg */ - - if (optional && !(t->ttype & TOPT)) - sgmlerr(216, &pcbstag, tags[ts].tetd->etdgi + 1, (UNCH *)0); - - return size; -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/genlex.c b/cde/programs/dtdocbook/sgmls/genlex.c deleted file mode 100644 index 7e9362079..000000000 --- a/cde/programs/dtdocbook/sgmls/genlex.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: genlex.c /main/3 1996/06/19 17:15:09 drk $ */ -/* genlex: Generate lexical tables for non-ASCII charsets. */ - -#include "config.h" -#include "std.h" -#include "tools.h" - -#define CANON_ASCII_NONSGML 255 /* Canonical non-SGML character in ASCII. */ -#define CANON_ASCII_DATACHAR 254 /* Canonical DATACHAR in ASCII. */ - -extern unsigned char charset[]; -extern UNCH *lextabs[]; -extern UNCH lextran[]; - -static char *lextabnames[] = { - "lexcnm", "lexcon", "lexgrp", "lexlms", "lexmark", "lexsd", "lextoke" -}; - -static VOID print_tab(s, t) - char *s; - UNCH *t; -{ - int i; - printf("UNCH %s[] = {\n", s); - for (i = 0; i < 256; i++) - printf("%2d,%c", t[i], (i + 1) % 16 == 0 ? '\n' : ' '); - fputs("};\n\n", stdout); -} - -int main(argc, argv) - int argc; - char **argv; -{ - int i; - UNCH tab[256]; - char special[256]; - /* Shunned character numbers in the reference concrete syntax. */ - static UNCH refshun[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 255 - }; - char shunned[256]; - char *program_name; - - program_name = strrchr(argv[0], '/'); - if (program_name) - program_name++; - else - program_name = argv[0]; - - /* Check that the mapping is 1-1. */ - for (i = 0; i < 256; i++) - tab[i] = 0; - for (i = 0; i < 256; i++) - tab[charset[i]] = 1; - for (i = 0; i < 256; i++) - if (!tab[i]) { - fprintf(stderr, "%s: bad mapping: no character mapped to %d\n", - program_name, i); - exit(EXIT_FAILURE); - } - - /* Compute special. */ - for (i = 0; i < 256; i++) - special[i] = 0; - for (i = 0; lextabs[i]; i++) { - int j; - for (j = 0; j < 256; j++) - if (lextabs[i][j] != lextabs[i][CANON_ASCII_NONSGML] - && lextabs[i][j] != lextabs[i][CANON_ASCII_DATACHAR]) - special[charset[j]] = 1; - } - - /* Compute shunned. */ - for (i = 0; i < 256; i++) - shunned[i] = 0; - for (i = 0; i < sizeof(refshun); i++) - shunned[refshun[i]] = 1; - - printf("/* This file was automatically generated by %s. Do not edit. */\n\n", - program_name); - fputs("#include \"config.h\"\n#include \"entity.h\"\n#include \"sgmldecl.h\"\n\n", - stdout); - - /* Generate each of the lexical tables. */ - for (i = 0; lextabs[i]; i++) { - int j; - for (j = 0; j < 256; j++) - tab[charset[j]] = lextabs[i][j]; - - for (j = 0; j < 256; j++) - if (!special[j]) { - if (shunned[j]) - tab[j] = lextabs[i][CANON_ASCII_NONSGML]; - else - tab[j] = lextabs[i][CANON_ASCII_DATACHAR]; - } - print_tab(lextabnames[i], tab); - } - - /* Generate lextran. */ - for (i = 0; i < 256; i++) - tab[charset[i]] = charset[lextran[i]]; - print_tab("lextran", tab); - - /* Generate asciicharset. */ - fputs("int asciicharset[] = {\n", stdout); - for (i = 0; i < 128; i++) - printf("%3d,%c", charset[i], (i + 1) % 16 == 0 ? '\n' : ' '); - for (i = 128; i < 256; i++) - printf("UNUSED,%c", (i + 1) % 8 == 0 ? '\n' : ' '); - fputs("};\n", stdout); - - exit(EXIT_SUCCESS); -} diff --git a/cde/programs/dtdocbook/sgmls/getopt.c b/cde/programs/dtdocbook/sgmls/getopt.c deleted file mode 100644 index 6d70d33b4..000000000 --- a/cde/programs/dtdocbook/sgmls/getopt.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: getopt.c /main/3 1996/06/19 17:15:14 drk $ */ -/* getopt.c - - getopt() for those systems that don't have it. - - Derived from comp.sources.unix/volume3/att_getopt. - Modified by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifndef HAVE_GETOPT - -#include "std.h" -#include "getopt.h" - -#ifdef SWITCHAR -#include -#endif - -int opterr = 1; -int optind = 1; -int optopt; -char *optarg; - -#ifndef OPTION_CHAR -#define OPTION_CHAR '-' -#endif - -int getopt(argc, argv, opts) -int argc; -char **argv; -char *opts; -{ -#ifdef SWITCHAR - union REGS regs; - static char switchar = '\0'; -#endif - static int sp = 1; - int c; - char *cp; - char *message; -#ifdef SWITCHAR - if (switchar == '\0') { - regs.x.ax = 0x3700; - intdos(®s, ®s); - if (!regs.x.cflag) - switchar = regs.h.dl; - else - switchar = '/'; - } -#endif - if (sp == 1) { - if (optind >= argc) - return EOF; - if (( -#ifdef SWITCHAR - argv[optind][0] != switchar && -#endif - argv[optind][0] != OPTION_CHAR) || argv[optind][1] == '\0') { -#ifdef REORDER_ARGS - int i; - for (i = optind; i < argc; i++) - if (( -#ifdef SWITCHAR - argv[i][0] == switchar || -#endif - argv[i][0] == OPTION_CHAR) && argv[i][1] != '\0') - break; - if (i < argc) { - c = argv[i][1]; -#ifdef CASE_INSENSITIVE_OPTIONS - if (isupper(c)) - c = tolower(c); -#endif - if (c != ':' && c != OPTION_CHAR && (cp = strchr(opts, c)) != NULL - && cp[1] == ':' && argv[i][2] == 0 && i < argc - 1) { - int j; - char *temp1 = argv[i]; - char *temp2 = argv[i+1]; - for (j = i - 1; j >= optind; j--) - argv[j+2] = argv[j]; - argv[optind] = temp1; - argv[optind+1] = temp2; - } - else { - int j; - char *temp = argv[i]; - for (j = i - 1; j >= optind; j--) - argv[j+1] = argv[j]; - argv[optind] = temp; - } - } - else -#endif - return EOF; - } - if ((argv[optind][0] == OPTION_CHAR && argv[optind][1] == OPTION_CHAR - && argv[optind][2] == '\0') -#ifdef SWITCHAR - || (argv[optind][0] == switchar && argv[optind][1] == switchar - && argv[optind][2] == '\0') -#endif - ) { - optind++; - return(EOF); - } - } - optopt = c = argv[optind][sp]; -#ifdef CASE_INSENSITIVE_OPTIONS - if ( -#ifdef USE_ISASCII - isascii(c) && -#endif /* USE_ISASCII */ - isupper((unsigned char)c)) - optopt = c = tolower((unsigned char)c); -#endif /* CASE_INSENSITIVE_OPTIONS */ - if (c == ':' || (cp = strchr(opts, c)) == NULL) { - if (argv[optind][++sp] == '\0') { - optind++; - sp = 1; - } - message = ": illegal option -- "; - goto bad; - } - if (*++cp == ':') { - if (argv[optind][sp+1] != '\0') - optarg = &argv[optind++][sp+1]; - else if (++optind >= argc) { - sp = 1; - message = ": option requires an argument -- "; - goto bad; - } - else - optarg = argv[optind++]; - sp = 1; - } - else { - if (argv[optind][++sp] == '\0') { - sp = 1; - optind++; - } - optarg = NULL; - } - return c; -bad: - if (opterr) { - fputs(argv[0], stderr); - fputs(message, stderr); - fputc(optopt, stderr); - fputc('\n', stderr); - } - return '?'; -} - -#endif /* not HAVE_GETOPT */ - -/* -Local Variables: -c-indent-level: 4 -c-continued-statement-offset: 4 -c-brace-offset: 4 -c-argdecl-indent: 4 -c-label-offset: -4 -tab-width: 4 -End: -*/ - diff --git a/cde/programs/dtdocbook/sgmls/getopt.h b/cde/programs/dtdocbook/sgmls/getopt.h deleted file mode 100644 index 2f7e73944..000000000 --- a/cde/programs/dtdocbook/sgmls/getopt.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: getopt.h /main/3 1996/06/19 17:15:18 drk $ */ -/* Declare getopt() and associated variables. */ - -/* Don't use prototypes in case some system header file has a -conflicting definition. Systems differ on how they declare the second -parameter. */ - -extern int getopt(); - -extern char *optarg; -extern int optind; -extern int opterr; diff --git a/cde/programs/dtdocbook/sgmls/keyword.h b/cde/programs/dtdocbook/sgmls/keyword.h deleted file mode 100644 index f825ae897..000000000 --- a/cde/programs/dtdocbook/sgmls/keyword.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: keyword.h /main/3 1996/06/19 17:15:23 drk $ */ -/* KEYWORD.H: Definitions for markup declaration keyword processing. -*/ -/* Default value types for attribute definition list declaration. -*/ -#define DNULL 1 /* Default value: implied attribute. */ -#define DREQ 2 /* Default value: required attribute. */ -#define DCURR 3 /* Default value: current attribute. */ -#define DCONR 4 /* Default value: content reference attribute. */ -#define DFIXED 5 /* Default value: fixed attribute. */ - -/* External identifier types for entity and notation declarations. -*/ -#define EDSYSTEM 1 /* SYSTEM (but not PUBLIC) identifier specified.*/ -#define EDPUBLIC 2 /* PUBLIC (but not SYSTEM) identifier specified.*/ -#define EDBOTH 3 /* PUBLIC and also SYSTEM identifiers specified.*/ - -/* Marked section keywords. -*/ -#define MSTEMP 1 -#define MSRCDATA 2 -#define MSCDATA 3 -#define MSIGNORE 4 diff --git a/cde/programs/dtdocbook/sgmls/latin1.h b/cde/programs/dtdocbook/sgmls/latin1.h deleted file mode 100644 index 469a1118c..000000000 --- a/cde/programs/dtdocbook/sgmls/latin1.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: latin1.h /main/3 1996/06/19 17:15:27 drk $ */ -/* SGML Character Use: ISO Latin 1. -*/ -#define EOFCHAR '\032' /* FUNCTION: EE (entity end: files). */ -#define EOBCHAR '\034' /* NONCHAR: EOB (file entity: end of buffer. */ -#define RSCHAR '\012' /* FUNCTION: RS (record start). */ -#define RECHAR '\015' /* FUNCTION: RE (record end). */ -#define TABCHAR '\011' /* FUNCTION: TAB (horizontal tab). */ -#define SPCCHAR '\040' /* FUNCTION: SPACE (horizontal space). */ -#define GENRECHAR '\010' /* NONCHAR: Generated RE. */ -#define DELCDATA '\035' /* NONCHAR: Delimiter for CDATA entity in - attribute value. */ -#define DELSDATA '\036' /* NONCHAR: Delimiter for SDATA entity in - attribute value. */ -#define DELNONCH '\037' /* NONCHAR: non-SGML character prefix. */ - -/* These two macros are used to handle non-SGML characters. A non-SGML -by character is represented by a DELNONCH character followed by -SHIFTNON(original_character). SHIFTNON must transform any character -in the set 0, EOFCHAR, EOBCHAR, GENRECHAR, DELCDATA, DELSDATA, -DELNONCH into a character that is not one of the set 0, EOFCHAR, -EOBCHAR. Furthermore UNSHIFTNON(SHIFTNON(c)) must be equal to c for -every character c in the former set. */ -/* This is a simple definition that works for ASCII-like character sets. */ -#define SHIFTNON(ch) ((UNCH)(ch) | 0100) -#define UNSHIFTNON(ch) ((UNCH)(ch) & ~0100) - -/* A canonical NONSGML character. The character number that is shunned -in the reference concrete syntax and is not the number of a -significant (in the reference concrete syntax) character nor one of -the above characters nor 0. */ -#define CANON_NONSGML 255 - -/* A canonical DATACHAR character. The character number that is not -shunned in the reference concrete syntax and is not the number of a -significant (in the reference concrete syntax) SGML character nor one -of the above characters. */ -#define CANON_DATACHAR 254 - -/* Components for a formal public identifier for the whole of the -system character set. Protect with ifndef so that it can be overriden -in config.h. */ - -#ifndef SYSTEM_CHARSET_DESIGNATING_SEQUENCE -#define SYSTEM_CHARSET_DESIGNATING_SEQUENCE "ESC 2/13 4/1" -#endif -#ifndef SYSTEM_CHARSET_OWNER -#define SYSTEM_CHARSET_OWNER "ISO Registration Number 100" -#endif -#ifndef SYSTEM_CHARSET_DESCRIPTION -#define SYSTEM_CHARSET_DESCRIPTION "ECMA-94 Right Part of Latin Alphabet Nr. 1" -#endif diff --git a/cde/programs/dtdocbook/sgmls/lexcode.h b/cde/programs/dtdocbook/sgmls/lexcode.h deleted file mode 100644 index 2ba1fc056..000000000 --- a/cde/programs/dtdocbook/sgmls/lexcode.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lexcode.h /main/3 1996/06/19 17:15:33 drk $ */ -/* Definitions of lexical codes needed by both lextaba.c and lexrf.c. */ - -#define FCE 27 /* FRE Free character in use as an entity reference */ -#define FRE 0 /* FREECHAR that is not in a CON delimiter-in-context. */ -#define LITC 21 /* LIT LITA PIC or EE in use as a literal terminator */ -#define MSC3 15 /* ] Also MSC[2]. */ -#define NET 17 /* / When enabled. */ -#define ETI 16 /* / Actually ETAGO[2] */ -#define SPCR 19 /* Space in use as SR8. */ -#define TGO2 25 /* < TAGO; also MDO[1], PIO[1] */ -#define CDE 11 /* NONSGML delcdata CDATA/SDATA delimiter */ diff --git a/cde/programs/dtdocbook/sgmls/lexrf.c b/cde/programs/dtdocbook/sgmls/lexrf.c deleted file mode 100644 index 36b0a6360..000000000 --- a/cde/programs/dtdocbook/sgmls/lexrf.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lexrf.c /main/3 1996/06/19 17:15:37 drk $ */ -/* LEXRF: Lexical tables for reference concrete syntax. -*/ - -#include "config.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "synxtrn.h" /* Declarations for concrete syntax constants. */ -#include "action.h" /* Action names for all parsing. */ -#include "lexcode.h" - -static UNCH SRTAB[] = { TABCHAR, '\0' }; -static UNCH SRRE[] = { RECHAR, '\0' }; -static UNCH SRRS[] = { RSCHAR, '\0' }; -static UNCH SRRSB[] = { RSCHAR, 'B', '\0' }; -static UNCH SRRSRE[] = { RSCHAR, RECHAR, '\0' }; -static UNCH SRRSBRE[] = { RSCHAR, 'B', RECHAR, '\0' }; -static UNCH SRBRE[] = { 'B', RECHAR, '\0' }; - -struct lexical lex = { /* Delimiter set constants for parser use. */ - { /* Markup strings for text processor use. */ - (UNCH *)"\4&#", /* LEXCON markup string: CRO */ - (UNCH *)"[", /* LEXCON markup string: DSO */ - (UNCH *)"\3&", /* LEXCON markup string: ERO */ - (UNCH *)"\4", /* LEXCON markup string: MDC */ - (UNCH *)"\4", /* LEXCON markup string: mse */ - (UNCH *)"\5", /* LEXCON markup string: PIC */ - (UNCH *)"\4", /* LEXMARK markup string: TAGC */ - (UNCH *)"\3=", /* LEXMARK markup string: VI */ - 3, /* LEXMARK: length of null end-tag. */ - 2 /* LEXMARK: length of null start-tag. */ - }, - { /* Short reference delimiters. */ - { /* Short reference delimiter table. */ - {(UNCH *)"", SRCT}, /* Dummy entry to store SR count. */ - {SRTAB, 1}, /* TAB */ - {SRRE, 2}, /* RE */ - {SRRS, 3}, /* RS */ - {SRRSB, 4}, /* Leading blanks */ - {SRRSRE, 5}, /* Null record */ - {SRRSBRE, 6}, /* Blank record */ - {SRBRE, 7}, /* Trailing blanks */ - {(UNCH *)" ", 8}, /* Space */ - {(UNCH *)"BB", 9}, /* Two or more blanks */ - {(UNCH *)"\"", 10}, /* Quotation mark (first data character) */ - {(UNCH *)"#", 11}, /* Number sign */ - {(UNCH *)"%", 12}, /* FCE CHARACTERS start here */ - {(UNCH *)"'", 13}, - {(UNCH *)"(", 14}, - {(UNCH *)")", 15}, - {(UNCH *)"*", 16}, - {(UNCH *)"+", 17}, - {(UNCH *)",", 18}, - {(UNCH *)"-", 19}, /* Hyphen */ - {(UNCH *)"--", 20}, /* Two hyphens */ - {(UNCH *)":", 21}, - {(UNCH *)";", 22}, - {(UNCH *)"=", 23}, - {(UNCH *)"@", 24}, - {(UNCH *)"[", 25}, - {(UNCH *)"]", 26}, - {(UNCH *)"^", 27}, - {(UNCH *)"_", 28}, /* Low line */ - {(UNCH *)"{", 29}, - {(UNCH *)"|", 30}, - {(UNCH *)"}", 31}, - {(UNCH *)"~", 32}, - {0, 0} - }, - { /* Printable form of unprintable SR delims.*/ - "", /* Dummy entry to balance s.dtb. */ - "&#TAB;", /* TAB */ - "&#RE;", /* RE */ - "&#RS;", /* RS */ - "&#RS;B", /* Leading blanks */ - "&#RS;&#RE;", /* Null record */ - "&#RS;B&#RE;", /* Blank record */ - "B&#RE;", /* Trailing blanks */ - "&#SPACE;" /* Space */ - }, - 12, /* LEXCNM: Index of first FCE in srdeltab. */ - 20, /*LEXCNM:Index of "two hyphens" in srdeltab*/ - 10, /* LEXCNM: Index of first SR with data char. */ - 19, /* LEXCNM: Index of hyphen in srdeltab. */ - SRNPRT+1, /* LEXCNM: Index of 1st printable SR. */ - 8, /* LEXCNM: Index of space in srdeltab. */ - 25, /* LEXCNM: Index of left bracket in srdeltab. */ - 26, /* LEXCNM: Index of right bracket in srdeltab. */ - }, /* End of short reference delimiters. */ - { /* General delimiter characters. */ - GENRECHAR, /*LEXCNM:(BS)Generated RE; can't be markup.*/ - '"', /* LEXMARK: Char used as LIT delimiter.*/ - '\'', /* LEXMARK: Char used as LITA delimiter.*/ - '>', /* LEXLMS: Char used as MDC delimiter.*/ - ']', /* LEXLMS: Char used as MSC when enabled.*/ - '/', /* LEXCON: Char used as NET when enabled.*/ - '%', /* LEXMARK: Char used as PERO delimiter. */ - '>', /* LEXCON: Char used as PIC delimiter.*/ - '<' /* LEXCON: Char used as TAGO when enabled.*/ - }, - { /* Lexical table code assignments. */ - FCE, /* LEXCNM: FRE char as entity reference.*/ - FRE, /* LEXLMS: Free character not an entity ref.*/ - LITC, /* LEXLMS: Literal close delimiter enabled. */ - MSC3, /* LEXLMS: Marked section close delim enabled. */ - NET, /* LEXCON: Null end-tag delimiter enabled. */ - ETI, /* LEXCON: NET disabled; still used as ETI. */ - SPCR, /* LEXCNM: Space in use as SHORTREF delim. */ - TGO2, /* LEXCON: Tag open delimiter enabled. */ - CDE /* LEXLMS: CDATA/SDATA delimiters. */ - } -}; - -UNCH *lextabs[] = { - lexcnm, lexcon, lexgrp, lexlms, lexmark, lexsd, lextoke, 0 -}; diff --git a/cde/programs/dtdocbook/sgmls/lextaba.c b/cde/programs/dtdocbook/sgmls/lextaba.c deleted file mode 100644 index 2b0236e20..000000000 --- a/cde/programs/dtdocbook/sgmls/lextaba.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lextaba.c /main/3 1996/06/19 17:15:41 drk $ */ -/* lextaba.c: lexical tables for ASCII. */ - -/* These tables are munged by setnonsgml(). */ - -#include "config.h" -#include "entity.h" -#include "lexcode.h" -#include "sgmldecl.h" - -/* LEXCNM: Lexical table for mixed content (PCBCONM) parse. -*/ -/* Symbols for SGML character set divisions and function characters. */ -#define NU 1 /* NUMERAL Numerals */ -#define NMC 2 /* LC/UCNMCHAR . - Period and hyphen */ -#define NMS 3 /* LC/UCNMSTRT Lower and uppercase letters */ -#define SPC 4 /* SPACE 32 Space */ -#define NON 5 /* NONSGML 0-31 127 255 Unused, except for: */ -#define EE 6 /* NONSGML 00 26 Entity end (end of file) */ -#define EOB 7 /* NONSGML 28 End disk buffer */ -#define RS 8 /* Function 10 Line feed */ -#define RE 9 /* Function 13 Carrier return */ -#define SEP 10 /* SEPCHAR 09 TAB: horizontal tab */ -#define NSC 12 /* NONSGML delnonch Non-SGML character prefix */ - -/* Symbols for SGML delimiter roles in CON and CXT. - ETI and NET must be the same in LEXCNM and LEXCON. - FRE characters are changed to FCE if an FCE entity is declared. - They are changed back to FRE when the entity is canceled. -*/ -#define ERO 13 /* & Also CRO[1] */ -#define NMRE 14 /* 08 Generated non-markup RE */ -#define COM 15 /* - For MDO context; also SR19 and SR20. */ -#undef LIT1 -#define LIT1 18 /* " SR10 */ -#define MDO 20 /* ! Actually MDO[2] */ -#define MSC1 21 /* ] Both MSC[1] and MSC[2]; also SR26. */ -#define MSO 22 /* [ For MDO context; also SR25. */ -#define PIO 23 /* ? Actually PIO[2] */ -#define RNI 24 /* # For CRO[2]; also SR11. */ -#define TGC1 25 /* > For TAGO and MSC context; also MDC, PIC */ -#define TGO1 26 /* < TAGO; also MDO[1], PIO[1] */ - -UNCH lexcnm[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE, NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS, NON, NON, RE, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, MDO, LIT1,RNI, FRE, FRE ,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO1,FRE, TGC1,PIO, /* -@ A B C D E F G H I J K L M N O */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC1,FRE, FRE, /* -` a b c d e f g h i j k l m n o */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON -}; -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti lit spcr mdo msc mso net pio rni tagc tago fce */ -#undef ERO -#undef NMRE -#undef COM -#undef LIT1 -/* def SPCR*/ -#undef MDO -#undef MSC1 -#undef MSO -#undef PIO -#undef RNI -#undef TGC1 -/* def TGO1*/ -/* def FCE*/ -/* LEXCON: Lexical table for RCDATA and CDATA content (PCBCON?), - prolog (PCBPRO), and nested declaration set (PCBMDS) parses. - Note: NMC is same as FRE; kept for consistency with LEXCNM and LEXLMS. -*/ -/* Symbols for SGML character set divisions and function characters. */ -/* Same as for LEXCNM. */ - -/* Symbols for SGML delimiter roles in CON, CXT, and DS. - ETI and NET must be the same in LEXCNM and LEXCON. - FRE characters are changed to FCE if an FCE entity is declared. - They are changed back to FRE when the entity is canceled. -*/ -#define ERO 13 /* & Also CRO[1] */ -#define NMRE 14 /* 08 Generated non-markup RE */ -#define COM 15 /* - For MDO context. */ -/*#define ETI 16 / Actually ETAGO[2] */ -/*#define NET 17 / When enabled. */ -#define MDO 18 /* ! Actually MDO[2] */ -#define MSC2 19 /* ] Both MSC[1] and MSC[2]. */ -#define MSO 20 /* [ For MDO context. */ -#define PERO 21 /* % For prolog */ -#define PIO 22 /* ? Actually PIO[2] */ -#define RNI 23 /* # For CRO[2]. */ -#define TGC2 24 /* > For TAGO and MSC context; also MDC, PIC */ - -UNCH lexcon[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE, NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS, NON, NON, RE, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, MDO, FRE, RNI, FRE, PERO,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO2,FRE, TGC2,PIO, /* -@ A B C D E F G H I J K L M N O */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC2,FRE, FRE, /* -` a b c d e f g h i j k l m n o */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON -}; -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -#undef FRE -#undef NU -#undef NMC -#undef NMS -#undef SPC -#undef NON -#undef EE -#undef EOB -#undef RS -#undef RE -#undef SEP -#undef NSC -#undef ERO -#undef NMRE -#undef COM -/* def ETI*/ -/* def NET*/ -#undef MDO -#undef MSC2 -#undef MSO -#undef PERO -#undef PIO -#undef RNI -#undef TGC2 -/* LEXGRP: Lexical table for group parses, including PCBREF. -*/ -/* Symbols for SGML character set divisions. */ -#define BIT 0 /* Bit combinations (not NONCHAR) not allowed in a group. */ -#define NMC 1 /* NAMECHAR . - Period, underscore, and numerals */ -#define NMS 2 /* NAMESTRT Lower and uppercase letters */ -#define RE 3 /* Function 13 Carrier return */ -#define SPC 4 /* SPACE 32 09 Space; includes TAB */ -#define NON 5 /* NONCHAR 0-31 127 255 Unused, except for: */ -#define EE 6 /* Function 26 00 EE: entity end (end of file) */ -#define EOB 7 /* NONCHAR 28 End disk buffer. */ -#define RS 8 /* Function 10 RS: record start (line feed) */ - -/* Symbols for SGML delimiter roles in GRP. */ -#define AND1 9 /* & */ -#define GRPC 10 /* ) */ -#define GRPO 11 /* ( */ -#undef LIT2 -#define LIT2 12 /* " For datatags. */ -#define LITA 13 /* ' For datatags. */ -#define DTGC 14 /* ] For datatags. */ -#define DTGO 15 /* [ For datatags. */ -#define OPT1 16 /* ? */ -#define OR1 17 /* | */ -#define PERO 18 /* % */ -#define PLUS 19 /* + */ -#define REP1 20 /* * */ -#define RNI 21 /* # For #CHARS */ -#define SEQ1 22 /* , */ -#define REFC 23 /* ; For references */ - -UNCH lexgrp[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, RE, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, BIT, LIT2,RNI, BIT, PERO,AND1,LITA,GRPO,GRPC,REP1,PLUS,SEQ1,NMC, NMC, BIT, /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, BIT, REFC,BIT, BIT, BIT, OPT1,/* -@ A B C D E F G H I J K L M N O */ -BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DTGO,BIT, DTGC,BIT, BIT, /* -` a b c d e f g h i j k l m n o */ -BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, OR1, BIT, BIT, NON, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON -}; -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -#undef BIT -#undef NMC -#undef NMS -#undef RE -#undef SPC -#undef NON -#undef EE -#undef EOB -#undef RS -#undef AND1 -#undef GRPC -#undef GRPO -#undef LIT2 -#undef LITA -#undef DTGC -#undef DTGO -#undef OPT1 -#undef OR1 -#undef PERO -#undef PLUS -#undef REP1 -#undef RNI -#undef SEQ1 -#undef REFC -/* LEXLMS: Lexical table for literal parses and marked sections. -*/ -/* Symbols for SGML character set divisions and function characters. -*/ -#define FRE 0 /* Free char: not in a delimiter or minimum literal. */ -#define NU 1 /* Numeral Numerals */ -#undef MIN -#define MIN 2 /* Minimum literal '()+,-./:?= */ -#define NMS 3 /* LC/UCNMSTRT Lower and uppercase letters */ -#define SPC 4 /* SPACE 32 Space */ -#define NON 5 /* NONSGML 0-31 127 255 Unused, except for: */ -#define EE 6 /* NONSGML 00 26 Entity end (end of file) */ -#define EOB 7 /* NONSGML 28 End disk buffer */ -#define RS 8 /* Function 10 Line feed */ -#define RE 9 /* Function 13 Carrier return */ -#define SEP 10 /* SEPCHAR 09 TAB: horizontal tab */ -/*#define CDE 11 NONSGML delcdata CDATA/SDATA delimiter */ -#define NSC 12 /* NONSGML delnonch Non-SGML character prefix */ -/* Symbols for SGML delimiter roles in LIT, PI, and marked sections. - Either LIT, LITA, PIC, or EE, is changed to LITC when a literal is begun. - It is changed back when the LITC occurs (i.e., when the literal ends). -*/ -#define ERO 13 /* & */ -#define MDO 14 /* ! Actually MDO[2] */ -#define MSO 16 /* [ For MDO context. */ -#define PERO 17 /* % For prolog. */ -#define RNI 18 /* # For CRO[2] */ -#define TGC3 19 /* > Also MDC for MSC context. */ -#define TGO3 20 /* < TAGO; also MDO[1] */ - -/* Room has been left in the parse tables in case re-parsing of text - is eventually supported (i.e., saved parsed text is used by the - application to create a new SGML document, but CDATA and SDATA - entities in literals, and non-SGML characters, are left in their - parsed state to avoid the overhead of reconstituting the original - markup). In such a case, the two non-SGML characters DELCDATA and - DELSDATA are changed to CDE. - NOTE: The idea is a bad one, because the generated document would - be non-conforming, as it would contain non-SGML characters. -*/ -UNCH lexlms[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE, NON, NON, NON, NON, NON, NON, NON, NON ,SEP, RS, NON, NON, RE, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE, NON, EOB, NON, NON, NSC, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, MDO, FRE, RNI, FRE, PERO,ERO, MIN, MIN, MIN, FRE, MIN, MIN, MIN, MIN, MIN, /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , MIN, FRE, TGO3,MIN, TGC3,MIN, /* -@ A B C D E F G H I J K L M N O */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC3,FRE, FRE, /* -` a b c d e f g h i j k l m n o */ -FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, -FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON -}; -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tago tagc litc */ -/* def FRE*/ -#undef NU -#undef MIN -#undef NMS -#undef SPC -#undef NON -#undef EE -#undef EOB -#undef RS -#undef RE -#undef SEP -/* def CDE*/ -/* def NSC*/ -#undef ERO -#undef MDO -/* def MSC3*/ -#undef MSO -#undef PERO -#undef RNI -#undef TGC3 -#undef TGO3 -/* def LITC*/ -/* LEXMARK: Lexical scan table for markup: PCBMD? and PCB?TAG. -*/ -/* Symbols for SGML character set divisions. */ -#define BIT 0 /* Bit combinations not allowed; includes ESC SO SI */ -#define NMC 1 /* NAMECHAR . _ Period and underscore */ -#define NU 2 /* NUMERAL Numerals */ -#define NMS 3 /* NAMESTRT Lower and uppercase letters */ -#define SPC 4 /* SPACE 32 13 09 Space; includes RE TAB */ -#define NON 5 /* NONCHAR 0-31 127 255 Unused, except for: */ -#define EE 6 /* Function 26 00 EE: entity end (end of file) */ -#define EOB 7 /* NONCHAR 28 End disk buffer. */ -#define RS 8 /* Function 10 RS: record start (line feed) */ - -/* Symbols for SGML delimiter roles in MD and TAG. */ -#define COM1 9 /* - Actually COM[1]; also COM[2], MINUS. */ -#define ETIB 10 /* / ETI; actually ETAGO[2]. */ -#define GRPO 11 /* ( */ -#define LIT3 12 /* " */ -#define LITA 13 /* ' */ -#define DSO 14 /* [ */ -#define DSC1 15 /* ] For data attribute specifications */ -#define PERO 16 /* % */ -#define PLUS 17 /* + */ -#define REFC 18 /* ; For references */ -#define RNI 19 /* # Also CRO[2] */ -#define TGC4 20 /* > Also MDC, PIC */ -#define TGO4 21 /* < TAGO; also MDO[1] */ -#define VI 22 /* = */ - -UNCH lexmark[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, SPC, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, BIT, LIT3,RNI, BIT, PERO,BIT, LITA,GRPO,BIT, BIT, PLUS,BIT, COM1,NMC ,ETIB,/* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, BIT, REFC,TGO4,VI, TGC4,BIT, /* -@ A B C D E F G H I J K L M N O */ -BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DSO, BIT, DSC1, BIT, BIT, /* -` a b c d e f g h i j k l m n o */ -BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, BIT, BIT, BIT, NON, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, -BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON -}; -/* bit nmc nu nms spc non ee eob rs com eti grpo lit lita - dso pero plus refc rni tagc tago vi */ -#undef BIT -#undef NMC -#undef NU -#undef NMS -#undef SPC -#undef NON -#undef EE -#undef EOB -#undef RS -#undef COM1 -#undef ETIB -#undef GRPO -#undef LIT3 -#undef LITA -#undef DSO -#undef DSC -#undef PERO -#undef PLUS -#undef REFC -#undef RNI -#undef TGC4 -#undef TGO4 -#undef VI -/* LEXSD: Lexical scan table for SGML declaration. -*/ - -/* Symbols for SGML character set divisions. */ -#define SIG 0 /* Significant SGML characters. */ -#define DAT 1 /* DATACHAR Not significant, and not non-sgml. */ -#define NU 2 /* NUMERAL Numerals */ -#define NMS 3 /* NAMESTRT Lower and uppercase letters */ -#define SPC 4 /* SPACE 32 13 09 Space; includes RE TAB */ -#define NON 5 /* NONCHAR NONSGML */ -#define EE 6 /* Function 26 00 EE: entity end (end of file) */ -#define EOB 7 /* NONCHAR 28 End disk buffer. */ -#define RS 8 /* Function 10 RS: record start (line feed) */ -/* Symbols for SGML delimiter roles in SGML declaration. */ -#define COM1 9 /* - Actually COM[1]; also COM[2]. */ -#define LIT3 10 /* " */ -#define LITA 11 /* ' */ -#define TGC4 12 /* > Also MDC, PIC */ - -UNCH lexsd[256] = { /* -000 001       bs tab lf home ff cr so si */ -EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS, NON, NON, SPC, NON, NON, /* -          eof esc rt left up down */ -NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /* -032 ! " # $ % & ' ( ) * + , - . / */ -SPC, SIG, LIT3,SIG, DAT, SIG ,SIG, LITA,SIG, SIG, SIG, SIG, SIG, COM1,SIG ,SIG,/* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, SIG, SIG, SIG, SIG, TGC4,SIG, /* -@ A B C D E F G H I J K L M N O */ -SIG, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, SIG, DAT, SIG, SIG, SIG, /* -` a b c d e f g h i j k l m n o */ -DAT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, SIG, SIG, SIG, SIG, NON, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, -DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, DAT, NON -}; - -#undef SIG -#undef DAT -#undef NON -#undef NU -#undef NMS -#undef SPC -#undef EE -#undef EOB -#undef RS -#undef COM1 -#undef LIT3 -#undef LITA -#undef TGC4 - -/* LEXTRAN: Translation table for SGML names. -*/ -UNCH lextran[256] = { /* -000 001       bs tab lf home ff cr so si */ -0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , /* -          eof esc rt left up down */ -16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , /* -space! " # $ % & ' ( ) * + , - . / */ -32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , /* -@ A B C D E F G H I J K L M N O */ -64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , /* -` a b c d e f g h i j k l m n o */ -96 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /* -p q r s t u v w x y z { | } ~ 127 */ -80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 123, 124, 125, 126, 127, -128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, -144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, -160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, -176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, -192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, -208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, -224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, -240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 -}; -/* LEXTOKE: Lexical class table for tokenization scan. -*/ -#include "lextoke.h" /* Symbols for tokenization lexical classes. */ -UNCH lextoke[256] = { /* - -000 001       bs tab lf home ff cr   */ -INV, INV, INV, INV, INV, INV, INV, INV, INV, SEP, REC, INV, INV, REC, INV, INV, /* -          eof esc rt left up down */ -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, EOB, INV, INV, INV, /* -space! " # $ % & ' ( ) * + , - . / */ -SP , INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, NMC, NMC, INV, /* -0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , INV, INV, INV, INV, INV, INV, /* -@ A B C D E F G H I J K L M N O */ -INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -P Q R S T U V W X Y Z [ \ ] ^ _ */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV, /* -` a b c d e f g h i j k l m n o */ -INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /* -p q r s t u v w x y z { | } ~ 127 */ -NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, -INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV -}; - -/* This table maps ASCII to the system character set. */ -int asciicharset[] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -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, 127, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -}; diff --git a/cde/programs/dtdocbook/sgmls/lextabe.c b/cde/programs/dtdocbook/sgmls/lextabe.c deleted file mode 100644 index 07b75de94..000000000 --- a/cde/programs/dtdocbook/sgmls/lextabe.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lextabe.c /main/3 1996/06/19 17:15:46 drk $ */ -/* This file was automatically generated by genlex. Do not edit. */ - -#include "config.h" -#include "entity.h" -#include "sgmldecl.h" - -UNCH lexcnm[] = { - 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5, - 5, 5, 5, 5, 5, 5, 14, 5, 5, 5, 5, 5, 7, 5, 5, 12, - 0, 0, 0, 0, 0, 8, 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, 6, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 26, 0, 0, 0, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, -15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 23, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 18, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 22, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5, -}; - -UNCH lexcon[] = { - 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5, - 5, 5, 5, 5, 5, 5, 14, 5, 5, 5, 5, 5, 7, 5, 5, 12, - 0, 0, 0, 0, 0, 8, 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, 6, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 25, 0, 0, 0, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, -15, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 24, 22, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 20, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5, -}; - -UNCH lexgrp[] = { - 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, - 0, 0, 0, 0, 0, 8, 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, 6, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 11, 19, 17, - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 10, 23, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 18, 0, 0, 16, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 13, 0, 12, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 15, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5, -}; - -UNCH lexlms[] = { - 6, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 9, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 12, - 0, 0, 0, 0, 0, 8, 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, 6, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 20, 2, 2, 0, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 2, 0, 0, - 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 17, 0, 19, 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 18, 0, 2, 2, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 16, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 5, -}; - -UNCH lexmark[] = { - 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, - 0, 0, 0, 0, 0, 8, 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, 6, - 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 21, 11, 17, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, - 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 20, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 13, 22, 12, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 14, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 5, -}; - -UNCH lexsd[] = { - 6, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 5, - 1, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, - 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, - 9, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 12, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 11, 0, 10, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 0, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 5, -}; - -UNCH lextoke[] = { - 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 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, - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, -}; - -UNCH lextran[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -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, 127, -128, 193, 194, 195, 196, 197, 198, 199, 200, 201, 138, 139, 140, 141, 142, 143, -144, 209, 210, 211, 212, 213, 214, 215, 216, 217, 154, 155, 156, 157, 158, 159, -160, 161, 226, 227, 228, 229, 230, 231, 232, 233, 170, 171, 172, 173, 174, 175, -176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, -192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, -208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, -224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, -240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, -}; - -int asciicharset[] = { - 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, - 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97, -240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111, -124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214, -215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 173, 224, 189, 176, 109, -121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150, -151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, -}; diff --git a/cde/programs/dtdocbook/sgmls/lextoke.h b/cde/programs/dtdocbook/sgmls/lextoke.h deleted file mode 100644 index 5ec96932a..000000000 --- a/cde/programs/dtdocbook/sgmls/lextoke.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lextoke.h /main/3 1996/06/19 17:15:50 drk $ */ -/* LEXTOKE.H: Symbols for tokenization lexical classes. -*/ -#define INV 0 /* Invalid Chars Not allowed in an SGML name. */ -#define REC 1 /* Record Boundary RS and RE. */ -#define SEP 2 /* Separator TAB. */ -#define SP 3 /* SPACE */ -#define NMC 4 /* NAMECHAR . _ Period, underscore (plus NMS, NUM). */ -#define NMS 5 /* NAMESTRT Lower and uppercase letters */ -#define NU 6 /* NUMERAL Numerals */ -#define EOB 7 /* NONCHAR 28 End disk buffer. */ diff --git a/cde/programs/dtdocbook/sgmls/lineout.c b/cde/programs/dtdocbook/sgmls/lineout.c deleted file mode 100644 index 18f53904f..000000000 --- a/cde/programs/dtdocbook/sgmls/lineout.c +++ /dev/null @@ -1,676 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lineout.c /main/3 1996/06/19 17:15:55 drk $ */ -/* lineout.c - - Implements line-oriented output format. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" -#include "std.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "adl.h" /* Definitions for attribute list processing. */ -#include "sgmlmain.h" /* Main interface to SGML services. */ -#include "lineout.h" -#include "appl.h" - -static VOID flush_data P((void)); -static VOID define_external_entity P((PNE)); -static VOID define_entity P((UNCH *)); -static VOID handle_attributes P((UNCH *, struct ad *)); -static VOID handle_token_list P((UNCH *, struct ad *, int)); -static VOID handle_single_token P((UNCH *, struct ad *, int)); -static VOID output_notation P((UNCH *, UNCH *, UNCH *)); -static VOID output_internal_entity P((UNCH *, int, UNCH *)); -static VOID output_external_entity P((UNCH *, int, UNIV, UNCH *, UNCH *, - UNCH *)); -static VOID output_subdoc P((UNCH *, UNIV, UNCH *, UNCH *)); -#ifdef SUPPORT_SUBDOC -static VOID process_subdoc P((UNCH *, UNIV)); -#endif /* SUPPORT_SUBDOC */ -static VOID output_record_end P((void)); -static VOID output_pcdata P((UNS, UNCH *)); -static VOID output_cdata P((UNS, UNCH *)); -static VOID output_sdata P((UNS, UNCH *)); -static VOID output_entity_reference P((UNCH *)); -static VOID output_start_tag P((UNCH *)); -static VOID output_end_tag P((UNCH *)); -static VOID output_processing_instruction P((UNS, UNCH *)); -static VOID output_implied_attribute P((UNCH *, UNCH *)); -static char *attribute_type_string P((int)); -static VOID output_begin_attribute P((UNCH *, UNCH *, int)); -static VOID output_attribute_token P((UNS, UNCH *)); -static VOID output_end_attribute P((void)); -static VOID print_data P((UNS, UNCH *, int)); -static VOID print_string P((UNS, UNCH *, int)); -static VOID print_id P((UNIV, UNCH *, UNCH *)); -static VOID print_filename P((char *)); -static VOID output_location P((void)); -static VOID output_appinfo P((UNS, UNCH *)); - -static int have_data = 0; -static char *current_filename = 0; -static unsigned long current_lineno = 0; - -VOID process_document(subdocsw) -int subdocsw; -{ - enum sgmlevent rc; - struct rcbtag rcbtag; - struct rcbdata rcbdaf; - - while ((rc = sgmlnext(&rcbdaf, &rcbtag)) != SGMLEOD) { -#ifdef SUPPORT_SUBDOC - if (rc == SGMLDAF && !CONTERSW(rcbdaf) && NDESW(rcbdaf) - && NEXTYPE(NEPTR(rcbdaf)) == ESNSUB) { - if (!suppsw && !sgmlment(NEENAME(NEPTR(rcbdaf)))) - define_external_entity(NEPTR(rcbdaf)); - process_subdoc(NEENAME(NEPTR(rcbdaf)) + 1, - NEID(NEPTR(rcbdaf))); - continue; - } -#endif /* SUPPORT_SUBDOC */ - if (!suppsw) - switch (rc) { - case SGMLDAF: - if (CONTERSW(rcbdaf)) - break; - if (CDESW(rcbdaf)) - output_cdata(CDATALEN(rcbdaf), CDATA(rcbdaf)); - else if (SDESW(rcbdaf)) - output_sdata(CDATALEN(rcbdaf), CDATA(rcbdaf)); - else if (NDESW(rcbdaf)) { - assert(NEXTYPE(NEPTR(rcbdaf)) != ESNSUB); - if (!sgmlment(NEENAME(NEPTR(rcbdaf)))) - define_external_entity(NEPTR(rcbdaf)); - output_entity_reference(NEENAME(NEPTR(rcbdaf)) + 1); - } - else - output_pcdata(CDATALEN(rcbdaf), CDATA(rcbdaf)); - break; - case SGMLSTG: - if (CONTERSW(rcbtag)) - break; - if (ALPTR(rcbtag)) - handle_attributes((UNCH *)NULL, ALPTR(rcbtag)); - output_start_tag(CURGI(rcbtag)); - break; - case SGMLETG: - if (CONTERSW(rcbtag)) - break; - output_end_tag(CURGI(rcbtag)); - break; - case SGMLPIS: - if (CONTERSW(rcbdaf)) - break; - output_processing_instruction(PDATALEN(rcbdaf), - PDATA(rcbdaf)); - break; - case SGMLREF: - if (CONTERSW(rcbdaf)) - break; - output_record_end(); - break; - case SGMLAPP: - if (CONTERSW(rcbdaf)) - break; - if (!subdocsw) - output_appinfo(ADATALEN(rcbdaf), ADATA(rcbdaf)); - break; - default: - abort(); - } - } -} - -/* Output an indication that the document was conforming. */ - -VOID output_conforming() -{ - if (!suppsw) - printf("%c\n", CONFORMING_CODE); -} - -static VOID define_external_entity(p) -PNE p; -{ - if (NEXTYPE(p) == ESNSUB) - output_subdoc(NEENAME(p) + 1, NEID(p), NEPUBID(p), NESYSID(p)); - else { - if (!NEDCNMARK(p)) - output_notation(NEDCN(p) + 1, NEDCNPUBID(p), NEDCNSYSID(p)); - output_external_entity(NEENAME(p) + 1, NEXTYPE(p), NEID(p), - NEPUBID(p), NESYSID(p), NEDCN(p) + 1); - if (NEAL(p)) - handle_attributes(NEENAME(p) + 1, NEAL(p)); - } -} - -static VOID define_entity(ename) -UNCH *ename; -{ - int rc; - PNE np; - UNCH *tp; - - if (sgmlment(ename)) /* already defined it */ - return; - rc = sgmlgent(ename, &np, &tp); - switch (rc) { - case 1: - define_external_entity(np); - break; - case 2: - case 3: - output_internal_entity(ename + 1, rc == 3, tp); - break; - } -} - -/* ENT is the name of the entity with which these attributes are associated; -if it's NULL, they're associated with the next start tag. */ - -static VOID handle_attributes(ent, al) -UNCH *ent; -struct ad *al; -{ - int aln; - - for (aln = 1; aln <= ADN(al); aln++) { - if (GET(ADFLAGS(al, aln), AERROR)) - ; - else if (GET(ADFLAGS(al, aln), AINVALID)) - ; - else if (ADVAL(al, aln) == NULL) - output_implied_attribute(ent, ADNAME(al, aln)); - else if (ADTYPE(al, aln) >= ATKNLIST) - handle_token_list(ent, al, aln); - else - handle_single_token(ent, al, aln); - if (BITON(ADFLAGS(al, aln), AGROUP)) - aln += ADNUM(al, aln); - } -} - -static VOID handle_token_list(ent, al, aln) -UNCH *ent; -struct ad *al; -int aln; -{ - UNCH *ptr; - int i; - if (ADTYPE(al, aln) == AENTITYS) { - ptr = ADVAL(al, aln); - for (i = 0; i < ADNUM(al, aln); i++) { - /* Temporarily make token look like normal - name with length and EOS. */ - UNCH c = ptr[*ptr + 1]; - ptr[*ptr + 1] = '\0'; - *ptr += 2; - define_entity(ptr); - *ptr -= 2; - ptr += *ptr + 1; - *ptr = c; - } - } - output_begin_attribute(ent, ADNAME(al, aln), ADTYPE(al, aln)); - ptr = ADVAL(al, aln); - for (i = 0; i < ADNUM(al, aln); i++) { - /* The first byte is a length NOT including the length - byte; the tokens are not EOS terminated. */ - output_attribute_token(*ptr, ptr + 1); - ptr += *ptr + 1; - } - output_end_attribute(); -} - -static VOID handle_single_token(ent, al, aln) -UNCH *ent; -struct ad *al; -int aln; -{ - if (ADTYPE(al, aln) == ANOTEGRP && !DCNMARK(ADDATA(al, aln).x)) - output_notation(ADVAL(al, aln) + 1, - ADDATA(al, aln).x->pubid, - ADDATA(al, aln).x->sysid); - else if (ADTYPE(al, aln) == AENTITY) - define_entity(ADVAL(al, aln)); - output_begin_attribute(ent, ADNAME(al, aln), ADTYPE(al, aln)); - if (ADTYPE(al, aln) == ACHARS) - output_attribute_token(ustrlen(ADVAL(al, aln)), ADVAL(al, aln)); - else - output_attribute_token(*ADVAL(al, aln) - 2, ADVAL(al, aln) + 1); - output_end_attribute(); -} - -static VOID output_notation(name, pubid, sysid) -UNCH *name; -UNCH *pubid, *sysid; -{ - flush_data(); - print_id((UNIV)0, pubid, sysid); - printf("%c%s\n", DEFINE_NOTATION_CODE, name); -} - -static VOID output_internal_entity(ename, is_sdata, text) -UNCH *ename; -int is_sdata; -UNCH *text; -{ - flush_data(); - printf("%c%s %s ", DEFINE_INTERNAL_ENTITY_CODE, ename, - is_sdata ? "SDATA" : "CDATA"); - print_string(text ? ustrlen(text) : 0, text, 0); - putchar('\n'); -} - -static VOID output_subdoc(nm, id, pubid, sysid) -UNCH *nm; -UNIV id; -UNCH *pubid, *sysid; -{ - flush_data(); - print_id(id, pubid, sysid); - printf("%c%s\n", DEFINE_SUBDOC_ENTITY_CODE, nm); -} - -#ifdef SUPPORT_SUBDOC - -static VOID process_subdoc(nm, id) -UNCH *nm; -UNIV id; -{ - if (!suppsw) { - flush_data(); - output_location(); - printf("%c%s\n", START_SUBDOC_CODE, nm); - fflush(stdout); - } - fflush(stderr); - - if (id) { - char **argv; - int ret; - - argv = make_argv(id); - ret = run_process(argv); - if (ret != 0) - suberr++; - - current_filename = 0; - free(argv); - if (ret == 0) - get_subcaps(); - } - else { - suberr++; - appl_error(E_SUBDOC, nm); - } - - if (!suppsw) - printf("%c%s\n", END_SUBDOC_CODE, nm); -} - -#endif /* SUPPORT_SUBDOC */ - -static VOID output_external_entity(nm, xtype, id, pubid, sysid, dcn) -UNCH *nm, *dcn; -UNIV id; -UNCH *pubid, *sysid; -int xtype; -{ - char *type; - - flush_data(); - - print_id(id, pubid, sysid); - - switch (xtype) { - case ESNCDATA: - type = "CDATA"; - break; - case ESNNDATA: - type = "NDATA"; - break; - case ESNSDATA: - type = "SDATA"; - break; - default: - return; - } - printf("%c%s %s %s\n", DEFINE_EXTERNAL_ENTITY_CODE, nm, type, dcn); -} - -static VOID output_record_end() -{ - static UNCH re = RECHAR; - print_data(1, &re, 0); -} - -static VOID output_pcdata(n, s) -UNS n; -UNCH *s; -{ - print_data(n, s, 0); -} - -static VOID output_cdata(n, s) -UNS n; -UNCH *s; -{ - print_data(n, s, 0); -} - -static VOID output_sdata(n, s) -UNS n; -UNCH *s; -{ - print_data(n, s, 1); -} - -static VOID output_entity_reference(s) -UNCH *s; -{ - flush_data(); - output_location(); - printf("%c%s\n", REFERENCE_ENTITY_CODE, s); -} - -static VOID output_start_tag(s) -UNCH *s; -{ - flush_data(); - output_location(); - printf("%c%s\n", START_CODE, s); -} - -static VOID output_end_tag(s) -UNCH *s; -{ - flush_data(); - printf("%c%s\n", END_CODE, s); -} - -static VOID output_processing_instruction(n, s) -UNS n; -UNCH *s; -{ - flush_data(); - output_location(); - putchar(PI_CODE); - print_string(n, s, 0); - putchar('\n'); -} - -static VOID output_appinfo(n, s) -UNS n; -UNCH *s; -{ - flush_data(); - output_location(); - putchar(APPINFO_CODE); - print_string(n, s, 0); - putchar('\n'); -} - - -static VOID output_implied_attribute(ent, aname) -UNCH *ent, *aname; -{ - flush_data(); - if (ent) - printf("%c%s %s IMPLIED\n", DATA_ATTRIBUTE_CODE, ent, aname); - else - printf("%c%s IMPLIED\n", ATTRIBUTE_CODE, aname); -} - -static char *attribute_type_string(type) -int type; -{ - switch (type) { - case ANMTGRP: - case ANAME: - case ANMTOKE: - case ANUTOKE: - case ANUMBER: - case ANAMES: - case ANMTOKES: - case ANUTOKES: - case ANUMBERS: - case AID: - case AIDREF: - case AIDREFS: - return "TOKEN"; - case ANOTEGRP: - return "NOTATION"; - case ACHARS: - return "CDATA"; - case AENTITY: - case AENTITYS: - return "ENTITY"; - } -#if 0 - fatal("invalid attribute type %d", type); -#endif - return "INVALID"; -} - -static VOID output_begin_attribute(ent, aname, type) -UNCH *ent, *aname; -int type; -{ - flush_data(); - if (ent) - printf("%c%s %s %s", DATA_ATTRIBUTE_CODE, ent, aname, - attribute_type_string(type)); - else - printf("%c%s %s", ATTRIBUTE_CODE, aname, - attribute_type_string(type)); - -} - -static VOID output_attribute_token(vallen, val) -UNS vallen; -UNCH *val; -{ - putchar(' '); - print_string(vallen, val, 0); -} - -static VOID output_end_attribute() -{ - putchar('\n'); -} - -static VOID print_data(n, s, is_sdata) -UNS n; -UNCH *s; -int is_sdata; -{ - if (n > 0 || is_sdata) { - if (n == 1 && *s == RECHAR) - current_lineno++; - else - output_location(); - if (!have_data) - putchar(DATA_CODE); - print_string(n, s, is_sdata); - have_data = 1; - } -} - -static VOID flush_data() -{ - if (have_data) { - putchar('\n'); - have_data = 0; - } -} - -static VOID output_location() -{ - char *filename; - unsigned long lineno; - int filename_changed = 0; - - if (!locsw) - return; - if (!sgmlloc(&lineno, &filename)) - return; - if (!current_filename || strcmp(filename, current_filename) != 0) - filename_changed = 1; - else if (lineno == current_lineno) - return; - flush_data(); - printf("%c%lu", LOCATION_CODE, lineno); - current_lineno = lineno; - if (filename_changed) { - putchar(' '); - print_filename(filename); - current_filename = filename; - } - putchar('\n'); -} - -static VOID print_string(slen, s, is_sdata) -UNS slen; -UNCH *s; -int is_sdata; -{ - if (is_sdata) - fputs("\\|", stdout); - while (slen > 0) { - UNCH ch = *s++; - slen--; - if (ch == DELSDATA) { - if (is_sdata) - ; /* I don't think this should happen */ - else - fputs("\\|", stdout); - ; - } - else if (ch == DELCDATA) - ; - else { - if (ch == DELNONCH) { - if (!slen) - break; - ch = UNSHIFTNON(*s); - s++; - slen--; - } - switch (ch) { - case RECHAR: - fputs("\\n", stdout); - break; - case '\\': - fputs("\\\\", stdout); - break; - default: - if (ISASCII(ch) && isprint(ch)) - putchar(ch); - else - printf("\\%03o", ch); - break; - } - } - } - if (is_sdata) - fputs("\\|", stdout); -} - - -static VOID print_id(id, pubid, sysid) -UNIV id; -UNCH *pubid; -UNCH *sysid; -{ - - if (pubid) { - putchar(PUBID_CODE); - print_string(ustrlen(pubid), pubid, 0); - putchar('\n'); - } - - if (sysid) { - putchar(SYSID_CODE); - print_string(ustrlen(sysid), sysid, 0); - putchar('\n'); - } - - if (id) { - char *p; - - for (p = id; *p != '\0'; p++) { - putchar(FILE_CODE); - do { - switch (*p) { - case '\\': - fputs("\\\\", stdout); - break; - case '\n': - fputs("\\n", stdout); - break; - default: - if (ISASCII(*p) && isprint((UNCH)*p)) - putchar(*p); - else - printf("\\%03o", (UNCH)*p); - break; - } - } while (*++p); - putchar('\n'); - } - } -} - -static VOID print_filename(s) -char *s; -{ - for (; *s; s++) - switch (*s) { - case '\\': - fputs("\\\\", stdout); - break; - case '\n': - fputs("\\n", stdout); - break; - default: - if (ISASCII(*s) && isprint((UNCH)*s)) - putchar(*s); - else - printf("\\%03o", (UNCH)*s); - break; - } -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/lineout.h b/cde/programs/dtdocbook/sgmls/lineout.h deleted file mode 100644 index c53a2ee0c..000000000 --- a/cde/programs/dtdocbook/sgmls/lineout.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: lineout.h /main/3 1996/06/19 17:15:59 drk $ */ -/* lineout.h */ - -/* Output codes used by sgmls. */ - -#define DATA_CODE '-' -#define START_CODE '(' -#define END_CODE ')' -#define ATTRIBUTE_CODE 'A' -#define DATA_ATTRIBUTE_CODE 'D' -#define REFERENCE_ENTITY_CODE '&' -#define DEFINE_NOTATION_CODE 'N' -#define DEFINE_EXTERNAL_ENTITY_CODE 'E' -#define DEFINE_INTERNAL_ENTITY_CODE 'I' -#define PI_CODE '?' -#define DEFINE_SUBDOC_ENTITY_CODE 'S' -#define START_SUBDOC_CODE '{' -#define END_SUBDOC_CODE '}' -#define LOCATION_CODE 'L' -#define APPINFO_CODE '#' -#define PUBID_CODE 'p' -#define SYSID_CODE 's' -#define FILE_CODE 'f' -#define CONFORMING_CODE 'C' diff --git a/cde/programs/dtdocbook/sgmls/main.c b/cde/programs/dtdocbook/sgmls/main.c deleted file mode 100644 index 1e779b4ac..000000000 --- a/cde/programs/dtdocbook/sgmls/main.c +++ /dev/null @@ -1,625 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: main.c /main/3 1996/06/19 17:16:04 drk $ */ -/* main.c - - Main program for sgmls. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" -#include "std.h" -#include "getopt.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "adl.h" /* Definitions for attribute list processing. */ -#include "sgmlmain.h" /* Main interface to SGML services. */ -#include "appl.h" - -#define READCNT 512 - -/* Before using argv[0] in error messages, strip off everything up to and -including the last character in prog that occurs in PROG_PREFIX. */ - -#ifndef PROG_PREFIX -#define PROG_PREFIX "/" -#endif /* not PROG_PREFIX */ - -/* Message catalogue name. */ -#define CAT_NAME "sgmls" -/* Message set to use for application error messages. */ -#define APP_SET 4 - -#ifdef HAVE_EXTENDED_PRINTF -#define xvfprintf vfprintf -#else -extern int xvfprintf P((FILE *, char *, va_list)); -#endif - -static VOID usage P((void)); -static VOID fatal VP((int, ...)); -static VOID do_error P((int, va_list)); -static VOID swinit P((struct switches *)); -static VOID write_caps P((char *, struct sgmlcap *)); - -static UNIV make_docent P((int, char **)); -static char *munge_program_name P((char *, char *)); -static VOID die P((void)); -#ifdef SUPPORT_SUBDOC -static VOID build_subargv P((struct switches *)); -static VOID cleanup P((void)); -static char *create_subcap_file P((void)); -#endif /* SUPPORT_SUBDOC */ - -static char *errlist[] = { - 0, - "Out of memory", - "Cannot open SGML document entity", - "Cannot exec `%s': %s", - "Cannot fork: %s", - "Error waiting for process: %s", - "Program %s got fatal signal %d", - "Cannot open `%s': %s", - "Subdocument capacity botch", - "Non-existent subdocument entity `%s' not processed", -}; - -int suppsw = 0; /* Non-zero means suppress output. */ -int locsw = 0; /* Non-zero means generate location info. */ -static char *prog; /* Program name (for error messages). */ -static nl_catd catd; /* Message catalogue descriptor. */ -static char *capfile = 0; /* File for capacity report. */ -extern char *version_string; - -char options[] = { - 'c', ':', 'd', 'e', 'g', 'i', ':', 'l', 'o', ':', 'p', 'r', 's', 'u', 'v', -#ifdef CANT_REDIRECT_STDERR - 'f', ':', -#endif /* CANT_REDIRECT_STDERR */ -#ifdef TRACE - 'x', ':', 'y', ':', -#endif /* TRACE */ - '\0' -}; - -#ifdef SUPPORT_SUBDOC -int suberr = 0; /* Error in subdocument. */ -static char *subargv[sizeof(options)]; -static int subargc = 0; -static char nopenbuf[sizeof(long)*3 + 1]; -static char sgmldecl_file[L_tmpnam]; -static char subcap_file[L_tmpnam]; -#endif - -int main(argc, argv) -int argc; -char **argv; -{ - static char stderr_buf[BUFSIZ]; - int opt; -#ifdef CANT_REDIRECT_STDERR - char *errfile = 0; -#endif - struct sgmlcap cap; - struct switches sw; - int nincludes = 0; /* number of -i options */ - setbuf(stderr, stderr_buf); - - /* Define MAIN_HOOK in config.h if some function needs to be called here. */ -#ifdef MAIN_HOOK - MAIN_HOOK(argc, argv); -#endif -#ifdef SUPPORT_SUBDOC - subargv[subargc++] = argv[0]; -#endif - - prog = argv[0] = munge_program_name(argv[0], "sgmls"); - - catd = catopen(CAT_NAME, 0); - swinit(&sw); - - while ((opt = getopt(argc, argv, options)) != EOF) { - switch (opt) { - case 'l': /* Generate location information. */ - locsw = 1; - break; - case 'c': /* Print capacity usage. */ - capfile = optarg; - break; - case 's': /* Suppress output. */ - suppsw = 1; - break; - case 'd': /* Report duplicate entity declarations. */ - sw.swdupent = 1; - break; - case 'e': /* Provide entity stack trace in error msg. */ - sw.swenttr = 1; - break; -#ifdef CANT_REDIRECT_STDERR - case 'f': /* Redirect errors. */ - errfile = optarg; - break; -#endif /* CANT_REDIRECT_STDERR */ - case 'g': /* Provide GI stack trace in error messages. */ - sw.sweltr = 1; - break; - case 'p': /* Parse only the prolog. */ - sw.onlypro = 1; - suppsw = 1; - break; - case 'r': /* Give warning for defaulted references. */ - sw.swrefmsg = 1; - break; - case 'u': - sw.swundef = 1; - break; -#ifdef TRACE - case 'x': /* Trace options for the document body. */ - sw.trace = optarg; - break; - case 'y': /* Trace options for the prolog. */ - sw.ptrace = optarg; - break; -#endif /* TRACE */ - case 'v': /* Print the version number. */ - fprintf(stderr, "sgmls version %s\n", version_string); - fflush(stderr); - break; - case 'o': - sw.nopen = atol(optarg); - if (sw.nopen <= 0) - usage(); - break; - case 'i': /* Define parameter entity as "INCLUDE". */ - sw.includes = (char **)xrealloc((UNIV)sw.includes, - (nincludes + 2)*sizeof(char *)); - sw.includes[nincludes++] = optarg; - sw.includes[nincludes] = 0; - break; - case '?': - usage(); - default: - abort(); - } - } - -#ifdef CANT_REDIRECT_STDERR - if (errfile) { - FILE *fp; - errno = 0; - fp = fopen(errfile, "w"); - if (!fp) - fatal(E_OPEN, errfile, strerror(errno)); - fclose(fp); - errno = 0; - if (!freopen(errfile, "w", stderr)) { - /* Can't use fatal() since stderr is now closed */ - printf("%s: ", prog); - printf(errlist[E_OPEN], errfile, strerror(errno)); - putchar('\n'); - exit(EXIT_FAILURE); - } - } -#endif /* CANT_REDIRECT_STDERR */ - - (void)sgmlset(&sw); - -#ifdef SUPPORT_SUBDOC - build_subargv(&sw); -#endif - if (sgmlsdoc(make_docent(argc - optind, argv + optind))) - fatal(E_DOC); - - process_document(sw.nopen > 0); - sgmlend(&cap); - if (capfile) - write_caps(capfile, &cap); -#ifdef SUPPORT_SUBDOC - cleanup(); - if (suberr) - exit(EXIT_FAILURE); -#endif /* SUPPORT_SUBDOC */ - if (sgmlgcnterr() > 0) - exit(EXIT_FAILURE); - if (!sw.nopen) - output_conforming(); - exit(EXIT_SUCCESS); -} - -static char *munge_program_name(arg, dflt) -char *arg, *dflt; -{ - char *p; -#ifdef PROG_STRIP_EXTENSION - char *ext; -#endif - if (!arg || !*arg) - return dflt; - p = strchr(arg, '\0'); - for (;;) { - if (p == arg) - break; - --p; - if (strchr(PROG_PREFIX, *p)) { - p++; - break; - } - } - arg = p; -#ifdef PROG_STRIP_EXTENSION - ext = strrchr(arg, '.'); - if (ext) { - p = (char *)xmalloc(ext - arg + 1); - memcpy(p, arg, ext - arg); - p[ext - arg] = '\0'; - arg = p; - } -#endif /* PROG_STRIP_EXTENSION */ -#ifdef PROG_FOLD -#ifdef PROG_STRIP_EXTENSION - if (!ext) { -#endif - p = xmalloc(strlen(arg) + 1); - strcpy(p, arg); - arg = p; -#ifdef PROG_STRIP_EXTENSION - } -#endif - for (p = arg; *p; p++) - if (ISASCII((unsigned char)*p) && isupper((unsigned char)*p)) - *p = tolower((unsigned char)*p); -#endif /* PROG_FOLD */ - return arg; -} - -static UNIV make_docent(argc, argv) -int argc; -char **argv; -{ - UNS len = 1; - int i; - UNIV res; - char *ptr; - static char *stdinname = STDINNAME; - - if (argc == 0) { - argv = &stdinname; - argc = 1; - } - - for (i = 0; i < argc; i++) - len += strlen(argv[i]) + 1; - - res = xmalloc(len); - ptr = (char *)res; - for (i = 0; i < argc; i++) { - strcpy(ptr, argv[i]); - ptr = strchr(ptr, '\0') + 1; - } - *ptr = '\0'; - return res; -} - - -static VOID usage() -{ - /* Don't mention -o since this are for internal use only. */ - fprintf(stderr, "Usage: %s [-deglprsuv]%s [-c file] [-i entity]%s [filename ...]\n", - prog, -#ifdef CANT_REDIRECT_STDERR - " [-f file]", -#else /* not CANT_REDIRECT_STDERR */ - "", -#endif /* not CANT_REDIRECT_STDERR */ -#ifdef TRACE - " [-x flags] [-y flags]" -#else /* not TRACE */ - "" -#endif /* not TRACE */ - ); - exit(EXIT_FAILURE); -} - -static VOID die() -{ -#ifdef SUPPORT_SUBDOC - cleanup(); -#endif /* SUPPORT_SUBDOC */ - exit(EXIT_FAILURE); -} - -static VOID swinit(swp) -struct switches *swp; -{ - swp->swenttr = 0; - swp->sweltr = 0; - swp->swbufsz = READCNT+2; - swp->prog = prog; - swp->swdupent = 0; - swp->swrefmsg = 0; -#ifdef TRACE - swp->trace = 0; - swp->ptrace = 0; -#endif /* TRACE */ - swp->catd = catd; - swp->swambig = 1; /* Always check for ambiguity. */ - swp->swundef = 0; - swp->nopen = 0; - swp->onlypro = 0; - swp->includes = 0; - swp->die = die; -} - -#ifdef SUPPORT_SUBDOC - -static VOID build_subargv(swp) -struct switches *swp; -{ - if (suppsw) - subargv[subargc++] = "-s"; - if (locsw) - subargv[subargc++] = "-l"; - if (swp->swdupent) - subargv[subargc++] = "-d"; - if (swp->swenttr) - subargv[subargc++] = "-e"; - if (swp->sweltr) - subargv[subargc++] = "-g"; - if (swp->swrefmsg) - subargv[subargc++] = "-r"; -#ifdef TRACE - if (swp->trace) { - subargv[subargc++] = "-x"; - subargv[subargc++] = swp->trace; - } - if (swp->ptrace) { - subargv[subargc++] = "-y"; - subargv[subargc++] = swp->ptrace; - } -#endif /* TRACE */ - subargv[subargc++] = "-o"; - sprintf(nopenbuf, "%ld", swp->nopen + 1); - subargv[subargc++] = nopenbuf; -} - - -static -VOID handler(sig) -int sig; -{ - signal(sig, SIG_DFL); - cleanup(); - raise(sig); -} - -static -VOID cleanup() -{ - if (sgmldecl_file[0]) { - (void)remove(sgmldecl_file); - sgmldecl_file[0] = '\0'; - } - if (subcap_file[0]) { - (void)remove(subcap_file); - subcap_file[0] = '\0'; - } -} - -static -char *store_sgmldecl() -{ - if (!sgmldecl_file[0]) { - FILE *fp; - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, handler); -#ifdef SIGTERM - if (signal(SIGTERM, SIG_IGN) != SIG_IGN) - signal(SIGTERM, handler); -#endif /* SIGTERM */ -#ifdef SIGPIPE - if (signal(SIGPIPE, SIG_IGN) != SIG_IGN) - signal(SIGPIPE, handler); -#endif -#ifdef SIGHUP - if (signal(SIGHUP, SIG_IGN) != SIG_IGN) - signal(SIGHUP, handler); -#endif - tmpnam(sgmldecl_file); - errno = 0; - fp = fopen(sgmldecl_file, "w"); - if (!fp) - fatal(E_OPEN, sgmldecl_file, strerror(errno)); - sgmlwrsd(fp); - fclose(fp); - } - return sgmldecl_file; -} - -static -char *create_subcap_file() -{ - if (subcap_file[0] == '\0') { - FILE *fp; - tmpnam(subcap_file); - fp = fopen(subcap_file, "w"); - if (!fp) - fatal(E_OPEN, subcap_file, strerror(errno)); - fclose(fp); - } - return subcap_file; -} - -char **make_argv(id) -UNIV id; -{ - int nfiles; - char *p; - char **argv; - int i; - - for (p = (char *)id, nfiles = 0; *p; p = strchr(p, '\0') + 1) - nfiles++; - - argv = (char **)xmalloc((subargc + 2 + 1 + nfiles + 1)*sizeof(char *)); - memcpy((UNIV)argv, (UNIV)subargv, subargc*sizeof(char *)); - - i = subargc; - - argv[i++] = "-c"; - argv[i++] = create_subcap_file(); - - argv[i++] = store_sgmldecl(); - - for (p = (char *)id; *p; p = strchr(p, '\0') + 1) - argv[i++] = p; - argv[i] = 0; - return argv; -} - -VOID get_subcaps() -{ - long cap[NCAPACITY]; - FILE *fp; - int i; - - if (!subcap_file[0]) - return; - errno = 0; - fp = fopen(subcap_file, "r"); - if (!fp) - fatal(E_OPEN, subcap_file, strerror(errno)); - for (i = 0; i < NCAPACITY; i++) - if (fscanf(fp, "%*s %ld", cap + i) != 1) - fatal(E_CAPBOTCH); - fclose(fp); - sgmlsubcap(cap); -} - - -#endif /* SUPPORT_SUBDOC */ - -/* Print capacity statistics.*/ - -static VOID write_caps(name, p) -char *name; -struct sgmlcap *p; -{ - FILE *fp; - int i; - fp = fopen(name, "w"); - if (!fp) - fatal(E_OPEN, name, strerror(errno)); - /* This is in RACT format. */ - for (i = 0; i < NCAPACITY; i++) - fprintf(fp, "%s %ld\n", p->name[i], p->number[i]*p->points[i]); - fclose(fp); -} - -UNIV xmalloc(n) -UNS n; -{ - UNIV p = malloc(n); - if (!p) - fatal(E_NOMEM); - return p; -} - -UNIV xrealloc(s, n) -UNIV s; -UNS n; -{ - s = s ? realloc(s, n) : malloc(n); - if (!s) - fatal(E_NOMEM); - return s; -} - -static -#ifdef VARARGS -VOID fatal(va_alist) va_dcl -#else -VOID fatal(int errnum,...) -#endif -{ -#ifdef VARARGS - int errnum; -#endif - va_list ap; - -#ifdef VARARGS - va_start(ap); - errnum = va_arg(ap, int); -#else - va_start(ap, errnum); -#endif - do_error(errnum, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - -#ifdef VARARGS -VOID appl_error(va_alist) va_dcl -#else -VOID appl_error(int errnum,...) -#endif -{ -#ifdef VARARGS - int errnum; -#endif - va_list ap; - -#ifdef VARARGS - va_start(ap); - errnum = va_arg(ap, int); -#else - va_start(ap, errnum); -#endif - do_error(errnum, ap); - va_end(ap); -} - -static -VOID do_error(errnum, ap) -int errnum; -va_list ap; -{ - char *text; - fprintf(stderr, "%s: ", prog); - assert(errnum > 0); - assert(errnum < sizeof(errlist)/sizeof(errlist[0])); - text = catgets(catd, APP_SET, errnum, errlist[errnum]); - assert(text != 0); - xvfprintf(stderr, text, ap); - fputc('\n', stderr); - fflush(stderr); -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/md1.c b/cde/programs/dtdocbook/sgmls/md1.c deleted file mode 100644 index 78b5ec0c0..000000000 --- a/cde/programs/dtdocbook/sgmls/md1.c +++ /dev/null @@ -1,885 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: md1.c /main/3 1996/06/19 17:16:08 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -/* MDADL: Process ATTLIST declaration. -*/ -VOID mdadl(tbuf) -UNCH *tbuf; /* Work area for tokenization (tbuf). */ -{ - int i; /* Loop counter; temporary variable. */ - int adlim; /* Number of unused ad slots in al. */ - struct ad *alperm = 0; /* Attribute definition list. */ - int stored = 0; - - mdname = key[KATTLIST]; /* Identify declaration for messages. */ - subdcl = 0; /* No subject as yet. */ - parmno = 0; /* No parameters as yet. */ - mdessv = es; /* Save es level for entity nesting check. */ - reqadn = noteadn = 0; /* No required attributes yet. */ - idadn = conradn = 0; /* No special atts yet.*/ - AN(al) = 0; /* Number of attributes defined. */ - ADN(al) = 0; /* Number of ad's in al (atts + name vals).*/ - /* PARAMETER 1: Element name or a group of them. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1: element name or group"); - switch (pcbmd.action) { - case NAS: - nmgrp[0] = etddef(tbuf); - nmgrp[1] = 0; - break; - case GRPS: - parsegrp(nmgrp, &pcbgrnm, tbuf); - break; - case RNS: /* Reserved name started. */ - if (ustrcmp(tbuf+1, key[KNOTATION])) { - mderr(118, tbuf+1, key[KNOTATION]); - return; - } - mdnadl(tbuf); - return; - default: - mderr(121, (UNCH *)0, (UNCH *)0); - return; - } - /* Save first GI for error msgs. */ - if (nmgrp[0]) - subdcl = nmgrp[0]->etdgi+1; - /* PARAMETER 2: Attribute definition list. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2: attribute list"); - if (pcbmd.action!=NAS) { - mderr(120, (UNCH *)0, (UNCH *)0); - return; - } - while (pcbmd.action==NAS) { - al[ADN(al)+1].adname = savenm(tbuf); - if ((adlim = ATTCNT-((int)++ADN(al)))<0) { - mderr(111, (UNCH *)0, (UNCH *)0); - adlfree(al, 1); - return; - } - ++AN(al); - if (mdattdef(adlim, 0)) { - adlfree(al, 1); - return; - } - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - } - if (AN(al)>0) { /* Save list only if 1 or more good atts. */ - if (reqadn) SET(ADLF(al), ADLREQ); /* Element must have start-tag. */ - if (noteadn) SET(ADLF(al), ADLNOTE); /* Element cannot be EMPTY. */ - if (conradn) SET(ADLF(al), ADLCONR); /* Element cannot be EMPTY. */ - alperm = (struct ad *)rmalloc((1+ADN(al))*ADSZ); - memcpy((UNIV)alperm, (UNIV)al, (1+ADN(al))*ADSZ ); - ds.attcnt += AN(al); /* Number of attributes defined. */ - ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */ - TRACEADL(alperm); - } - /* Clear attribute list for next declaration. */ - MEMZERO((UNIV)al, (1+ADN(al))*ADSZ); - - /* PARAMETER 3: End of declaration. - */ - /* Next pcb.action was set during attribute definition loop. */ - TRACEMD(emd); - if (pcbmd.action!=EMD) {mderr(126, (UNCH *)0, (UNCH *)0); return;} - if (es!=mdessv) synerr(37, &pcbmd); - - /* EXECUTE: Store the definition for each element name specified. - */ - TRACEGRP(nmgrp); - for (i = 0; nmgrp[i]; i++) { - if (nmgrp[i]->adl) { /* Error if an ADL exists. */ - mderr(112, (UNCH *)0, (UNCH *)0); - continue; - } - nmgrp[i]->adl = alperm; /* If virgin, store the adl ptr. */ - stored = 1; - if (alperm && nmgrp[i]->etdmod) - etdadl(nmgrp[i]); /* Check for conflicts with ETD. */ - } - if (!stored && alperm) { - adlfree(alperm, 1); - frem((UNIV)alperm); - } -} -/* ETDADL: Check compatibility between ETD and ADL. -*/ -VOID etdadl(p) -struct etd *p; /* Pointer to element type definition. */ -{ - parmno = 0; - /* Minimizable element cannot have required attribute. */ - if (GET(p->etdmin, SMO) && GET(p->adl[0].adflags, ADLREQ)) { - mderr(40, (UNCH *)0, (UNCH *)0); - RESET(p->etdmin, SMO); - } - /* Empty element cannot have NOTATION attribute. - Attribute is not removed (too much trouble), but we trap - attempts to specify it on the start-tag in adlval(). - */ - if (GET(p->etdmod->ttype, MNONE)) { - if (GET(p->adl[0].adflags, ADLNOTE)) - mderr(83, (UNCH *)0, (UNCH *)0); - - /* Empty element cannot have CONREF attribute. - Attribute is not removed because it just acts - like IMPLIED anyway. - */ - if (GET(p->adl[0].adflags, ADLCONR)) - mderr(85, (UNCH *)0, (UNCH *)0); - } - /* "-" should not be specified for the end-tag minimization if - the element has a content reference attribute. */ - if (GET(p->adl[0].adflags, ADLCONR) && BITON(p->etdmin, EMM)) - mderr(153, (UNCH *)0, (UNCH *)0); -} -/* MDNADL: Process ATTLIST declaration for notation. - TO DO: Pass deftab and dvtab as parameters so - that prohibited types can be handled by leaving - them out of the tables. -*/ -VOID mdnadl(tbuf) -UNCH *tbuf; /* Work area for tokenization (tbuf). */ -{ - int i; /* Loop counter; temporary variable. */ - int adlim; /* Number of unused ad slots in al. */ - struct ad *alperm = 0; /* Attribute definition list. */ - int stored = 0; - - /* PARAMETER 1: Notation name or a group of them. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1: notation name or group"); - switch (pcbmd.action) { - case NAS: - nnmgrp[0] = dcndef(tbuf); - nnmgrp[1] = 0; - break; - case GRPS: - parsngrp(nnmgrp, &pcbgrnm, tbuf); - break; - default: - mderr(121, (UNCH *)0, (UNCH *)0); - return; - } - subdcl = nnmgrp[0]->ename+1; /* Save first name for error msgs. */ - /* PARAMETER 2: Attribute definition list. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2: attribute list"); - if (pcbmd.action!=NAS) { - mderr(120, (UNCH *)0, (UNCH *)0); - return; - } - while (pcbmd.action==NAS) { - al[ADN(al)+1].adname = savenm(tbuf); - if ((adlim = ATTCNT-((int)ADN(al)++))<0) { - mderr(111, (UNCH *)0, (UNCH *)0); - adlfree(al, 1); - return; - } - ++AN(al); - if (mdattdef(adlim, 1)) { - adlfree(al, 1); - return; - } - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - } - if (AN(al)>0) { /* Save list only if 1 or more good atts. */ - alperm = (struct ad *)rmalloc((1+ADN(al))*ADSZ); - memcpy((UNIV)alperm, (UNIV)al, (1+ADN(al))*ADSZ ); - ds.attcnt += AN(al); /* Number of attributes defined. */ - ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */ - TRACEADL(alperm); - } - /* Clear attribute list for next declaration. */ - MEMZERO((UNIV)al, (1+ADN(al))*ADSZ); - - /* PARAMETER 3: End of declaration. - */ - /* Next pcb.action was set during attribute definition loop. */ - TRACEMD(emd); - if (pcbmd.action!=EMD) {mderr(126, (UNCH *)0, (UNCH *)0); return;} - if (es!=mdessv) synerr(37, &pcbmd); - - /* EXECUTE: Store the definition for each notation name specified. - */ - TRACENGR(nnmgrp); - for (i = 0; nnmgrp[i]; i++) { - if (nnmgrp[i]->adl) { /* Error if an ADL exists. */ - mderr(112, (UNCH *)0, (UNCH *)0); - continue; - } - nnmgrp[i]->adl = alperm; /* If virgin, store the adl ptr. */ - if (nnmgrp[i]->entsw) - fixdatt(nnmgrp[i]); - stored = 1; - TRACEDCN(nnmgrp[i]); - } - if (!stored && alperm) { - adlfree(alperm, 1); - frem((UNIV)alperm); - } -} - -/* Data attributes have been specified for notation p, but entities -have already been declared with notation p. Fix up the definitions of -all entities with notation p. Generate an error for any data -attribute that was required. */ - -VOID fixdatt(p) -struct dcncb *p; -{ - int i; - for (i = 0; i < ENTHASH; i++) { - struct entity *ep; - for (ep = etab[i]; ep; ep = ep->enext) - if (ep->estore == ESN && ep->etx.n && ep->etx.n->nedcn == p) { - int adn; - initatt(p->adl); - /* Don't use adlval because if there were required - attributes the error message wouldn't say what - entity was involved. */ - for (adn = 1; adn <= ADN(al); adn++) { - if (GET(ADFLAGS(al,adn), AREQ)) { - sgmlerr(218, &pcbstag, ADNAME(al,adn), - ep->ename + 1); - SET(ADFLAGS(al,adn), AINVALID); - } - if (BITON(ADFLAGS(al, adn), AGROUP)) - adn += ADNUM(al, adn); - } - storedatt(ep->etx.n); - } - } -} - -/* MDATTDEF: Process an individual attribute definition. - The attribute name is parsed by the caller. - Duplicate attributes are parsed, but removed from list. - Returns 0 if successful, otherwise returns 1. -*/ -int mdattdef(adlim, datt) -int adlim; /* Remaining capacity of al (in tokens).*/ -int datt; /* Non-zero if a data attribute. */ -{ - int deftype; /* Default value type: 0=not keyword. */ - int errsw = 0; /* 1=semantic error; ignore att. */ - int novalsw = 0; /* 1=semantic error; treat as IMPLIED. */ - int attadn = (int)ADN(al); /* Save ad number of this attribute. */ - struct parse *grppcb = NULL; /* PCB for name/token grp parse. */ - int errcode; /* Error type returned by PARSEVAL, ANMTGRP. */ - UNCH *advalsv; /* Save area for permanent value ptr. */ - - /* PARAMETER 1: Attribute name (parsed by caller). - */ - TRACEMD("1: attribute name"); - if (anmget((int)ADN(al)-1, al[attadn].adname)) { - errsw = 1; - mderr(99, ADNAME(al,attadn), (UNCH *)0); - } - ADNUM(al,attadn) = ADFLAGS(al,attadn) = ADLEN(al,attadn) = 0; - ADVAL(al,attadn) = 0; ADDATA(al,attadn).x = 0; ADTYPE(al,attadn) = ANMTGRP; - /* PARAMETER 2: Declared value. - */ - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2: declared value"); - switch (pcbmd.action) { - case NAS: /* Keyword for value type. */ - switch (ADTYPE(al,attadn) = (UNCH)mapsrch(dvtab, lbuf+1)) { - case 0: - mderr(100, ADNAME(al,attadn), lbuf+1); - return 1; - case ANOTEGRP: - if (datt) { - errsw = 1; - mderr(156, (UNCH *)0, (UNCH *)0); - } - else if (!noteadn) noteadn = ADN(al); - else { - errsw = 1; - mderr(101, ADNAME(al,attadn), (UNCH *)0); - } - grppcb = &pcbgrnm; /* NOTATION requires name grp. */ - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN);/* Get GRPO*/ - break; - case AID: - if (datt) { - errsw = 1; - mderr(144, (UNCH *)0, (UNCH *)0); - } - else if (!idadn) - idadn = attadn; - else { - errsw = 1; - mderr(102, ADNAME(al,attadn), (UNCH *)0); - } - break; - case AIDREF: - case AIDREFS: - if (datt) { - errsw = 1; - mderr(155, (UNCH *)0, (UNCH *)0); - } - break; - case AENTITY: - case AENTITYS: - if (datt) { - errsw = 1; - mderr(154, (UNCH *)0, (UNCH *)0); - } - break; - } - break; - case GRPS: - grppcb = &pcbgrnt; /* Normal grp is name token grp. */ - break; - case EMD: - mderr(103, ADNAME(al,attadn), (UNCH *)0); - return 1; - default: - mderr(104, ADNAME(al,attadn), (UNCH *)0); - return 1; - } - /* PARAMETER 2A: Name token group. - */ - if (grppcb != NULL) { - TRACEMD("2A: name group"); - switch (pcbmd.action) { - case GRPS: /* Name token list. */ - SET(ADFLAGS(al,attadn), AGROUP); - /* Call routine to parse group, create ad entries in adl. */ - errcode = anmtgrp(grppcb, al+attadn, - (GRPCNT LITLEN) { - /* Treat as implied. */ - sgmlerr(224, &pcbmd, ADNAME(al,attadn), (UNCH *)0); - return 0; - } - /* No more checking for CDATA value. */ - ADNUM(al,attadn) = 0; /* CDATA is 0 tokens. */ - ADVAL(al,attadn) = savestr(lbuf);/* Store default; save ptr. */ - ADLEN(al,attadn) = len; - ds.attdef += len; - return 0; - } - /* Parse value and save token count (GROUP implies 1 token). */ - advalsv = (UNCH *)rmalloc(ustrlen(lbuf)+2); /* Storage for tokenized value. */ - errcode = parseval(lbuf, (UNS)ADTYPE(al,attadn), advalsv); - if (BITOFF(ADFLAGS(al,attadn), AGROUP)) ADNUM(al,attadn) = (UNCH)tokencnt; - - /* If value was invalid, or was a group member that was not in the group, - issue an appropriate message and set the error switch. */ - if (errcode) - {sgmlerr((UNS)errcode, &pcbmd, ADNAME(al,attadn), lbuf); errsw = 1;} - else if ( BITON(ADFLAGS(al,attadn), AGROUP) - && !amemget(&al[attadn], (int)ADNUM(al,attadn), advalsv) ) { - sgmlerr(79, &pcbmd, ADNAME(al,attadn), advalsv+1); - errsw = 1; - } - ADLEN(al,attadn) = vallen(ADTYPE(al,attadn), ADNUM(al,attadn), advalsv); - if (ADLEN(al,attadn) > LITLEN) { - sgmlerr(224, &pcbmd, ADNAME(al,attadn), (UNCH *)0); - ADLEN(al,attadn) = 0; - errsw = 1; - } - /* For valid tokenized value, save it and update statistics. */ - if (!errsw) { - ADVAL(al,attadn) = advalsv; - ds.attdef += ADLEN(al,attadn); - return 0; - } - /* If value was bad, free the value's storage and treat as - IMPLIED or REQUIRED. */ - frem((UNIV)advalsv); /* Release storage for value. */ - ADVAL(al,attadn) = NULL; /* And make value NULL. */ - return 0; -} -/* ANMTGRP: Parse a name or name token group, create attribute descriptors - for its members, and add them to the attribute descriptor list. - The parse either terminates or returns a good token, so no - switch is needed. -*/ -int anmtgrp(pcb, nt, grplim, adn, adsz) -struct parse *pcb; /* PCB for name or name token grp. */ -struct ad nt[]; /* Buffer for creating name token list. */ -int grplim; /* Maximum size of list (plus 1). */ -UNS *adn; /* Ptr to number of names or tokens in grp. */ -int adsz; /* Size of att def list. */ -{ - UNCH adtype = (UNCH)(pcb==&pcbgrnt ? ANMTGRP:ANOTEGRP);/*Attribute type.*/ - int essv = es; /* Entity stack level when grp started. */ - - *adn = 0; /* Group is empty to start. */ - while (parse(pcb)!=GRPE && *adnaction) { - case NAS_: /* Name or name token (depending on pcb). */ - case NMT_: - parsenm(lbuf, NAMECASE); - nt[*adn+1].adname = savenm(lbuf); - if (antvget((int)(adsz+*adn), nt[*adn+1].adname, (UNCH **)0)) - mderr(98, ntoa((int)*adn+1), nt[*adn+1].adname+1); - nt[++*adn].adtype = adtype; - nt[*adn].addef = NULL; - continue; - - case EE_: /* Entity ended (correctly or incorrectly). */ - if (esetdgi+1; - - /* PARAMETER 1A: Rank suffix (optional). - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1A: rank suffix"); - switch (pcbmd.action) { - case NUM: - ustrcpy(ranksuff, tbuf); - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - default: - break; - } - /* PARAMETER 2A: Start-tag minimization. - */ - TRACEMD("2A: start min"); - switch (pcbmd.action) { - case CDR: - break; - case NAS: - if (!ustrcmp(tbuf+1, key[KO])) { - if (OMITTAG==YES) SET(fmin, SMO); - break; - } - /* fall through */ - default: - if (OMITTAG==NO) {minomitted=1; break;} - mderr(129, tbuf+1, (UNCH *)0); - return; - } - /* Must omit omitted end-tag minimization, if omitted - start-tag minimization was omitted (because OMITTAG == NO). */ - if (!minomitted) { - /* PARAMETER 2B: End-tag minimization. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2B: end min"); - switch (pcbmd.action) { - case NAS: - if (ustrcmp(tbuf+1, key[KO])) {mderr(129, tbuf+1, (UNCH *)0); return;} - if (OMITTAG==YES) SET(fmin, EMO); - break; - case CDR: - SET(fmin, EMM); - break; - default: - mderr(129, tbuf+1, (UNCH *)0); - return; - } - /* PARAMETER 3: Declared content. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - } - TRACEMD("3: declared content"); - switch (pcbmd.action) { - case NAS: - dctype = mapsrch(dctab, tbuf+1); - if (!dctype) {mderr(24, tbuf+1, (UNCH *)0); return;} - /* Eliminate incompatibilities among parameters. */ - if (GET(fmin, SMO) && GET(dctype, MNONE+MCDATA+MRCDATA)) { - mderr(58, (UNCH *)0, (UNCH *)0); - RESET(fmin, SMO); - } - if (GET(dctype, MNONE) && BITON(fmin, EMM)) { - mderr(87, (UNCH *)0, (UNCH *)0); - SET(fmin, EMO); - } - /* If valid, process like a content model. */ - case GRPS: - cmodsv = parsemod((int)(pcbmd.action==GRPS ? 0 : dctype)); - if (cmodsv==0) return; - u = (dctype ? 1 : cmodsv->tu.tnum+2) * THSZ; - cmod = (struct thdr *)rmalloc(u); - memcpy((UNIV)cmod , (UNIV)cmodsv, u ); - ds.modcnt += cmod->tu.tnum; - TRACEMOD(cmod); - break; - default: - mderr(130, (UNCH *)0, (UNCH *)0); - return; - } - /* PARAMETERS 3A, 3B: Exceptions or end. - */ - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - if (BITOFF(cmod->ttype, MCDATA+MRCDATA+MNONE)) { - /* PARAMETER 3A: Minus exceptions. - */ - TRACEMD("3A: -grp"); - switch (pcbmd.action) { - case MGRP: - /* We cheat and use nnmgrp for this. */ - mexgrp = copygrp((PETD *)nnmgrp, - u = parsegrp((PETD *)nnmgrp, &pcbgrnm, tbuf)); - ++ds.pmexgcnt; ds.pmexcnt += u-1; - TRACEGRP(mexgrp); - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - default: - break; - } - /* PARAMETER 3B: Plus exceptions. - */ - TRACEMD("3B: +grp"); - switch (pcbmd.action) { - case PGRP: - pexgrp = copygrp((PETD *)nnmgrp, - u = parsegrp((PETD *)nnmgrp, &pcbgrnm, tbuf)); - ++ds.pmexgcnt; ds.pmexcnt += u-1; - TRACEGRP(pexgrp); - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - default: - break; - } - } - /* PARAMETER 4: End of declaration. - */ - TRACEMD(emd); - if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0); - if (es!=mdessv) synerr(37, &pcbmd); - - /* EXECUTE: Store the definition for each element name specified. - */ - TRACEGRP(nmgrp); - for (i = -1; nmgrp[++i];) { - etdgi = nmgrp[i]->etdgi; - if (*ranksuff) { - if ((tbuf[0] = *etdgi + ustrlen(ranksuff)) - 2 > NAMELEN) { - mderr(131, etdgi+1, ranksuff); - continue; - } - memcpy(tbuf+1, etdgi+1, *etdgi-1); - ustrcpy(tbuf+*etdgi-1, ranksuff); - etdcan(etdgi); - nmgrp[i] = etddef(tbuf); - } - if (nmgrp[i]->etdmod) {mderr(56, etdgi+1, (UNCH *)0); continue;} - etdset(nmgrp[i], fmin+ETDDCL, cmod, mexgrp, pexgrp, nmgrp[i]->etdsrm); - ++ds.etdcnt; - if (nmgrp[i]->adl) etdadl(nmgrp[i]); /* Check ETD conflicts. */ - TRACEETD(nmgrp[i]); - } -} - -VOID adlfree(al, aln) -struct ad *al; -int aln; -{ - for (; aln <= ADN(al); aln++) { - frem((UNIV)al[aln].adname); - if (ADVAL(al, aln)) - frem((UNIV)ADVAL(al, aln)); - if (BITON(ADFLAGS(al, aln), AGROUP)) { - int i; - for (i = 0; i < ADNUM(al, aln); i++) - frem((UNIV)al[aln + i + 1].adname); - aln += ADNUM(al, aln); - } - } -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/md2.c b/cde/programs/dtdocbook/sgmls/md2.c deleted file mode 100644 index c09843290..000000000 --- a/cde/programs/dtdocbook/sgmls/md2.c +++ /dev/null @@ -1,824 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: md2.c /main/3 1996/06/19 17:16:14 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -/* MDENTITY: Process ENTITY declaration. -*/ -VOID mdentity(tbuf) -UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */ -{ - struct fpi fpicb; /* Formal public identifier structure. */ - struct fpi *fpis = &fpicb; /* Ptr to current or #DEFAULT fpi. */ - union etext etx; /* Ptr to entity text. */ - UNCH estore = ESM; /* Entity storage class. */ - struct entity *ecb; /* Ptr to entity control block. */ - int parmsw = 0; /* 1=parameter entity declaration; 0 = not. */ - int defltsw = 0; /* 1=#DEFAULT declaration; 0=not. */ - PNE pne = 0; /* Ptr to N/C/SDATA entity control block. */ - - mdname = key[KENTITY]; /* Declaration name for messages. */ - subdcl = NULL; /* No subject as yet. */ - parmno = 0; /* No parameters as yet. */ - mdessv = es; /* Save es for checking entity nesting. */ - /* PARAMETER 1: Entity name. - */ - pcbmd.newstate = 0; - parsemd(nmbuf, ENTCASE, &pcblitp, NAMELEN); - TRACEMD("1: entity nm"); - switch (pcbmd.action) { - case PEN: - parsemd(nmbuf + 1, ENTCASE, &pcblitp, NAMELEN); - if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;} - if (nmbuf[1] == NAMELEN + 2) { - /* It was too long. */ - nmbuf[0] = NAMELEN + 2; - nmbuf[NAMELEN + 1] = '\0'; - mderr(65, (UNCH *)0, (UNCH *)0); - } - else - nmbuf[0] = nmbuf[1] + 1; /* Increment length for PERO. */ - nmbuf[1] = lex.d.pero; /* Prefix PERO to name. */ - parmsw = 1; /* Indicate parameter entity. */ - case NAS: - break; - case RNS: /* Reserved name started. */ - if (ustrcmp(nmbuf+1, key[KDEFAULT])) { - mderr(118, nmbuf+1, key[KDEFAULT]); - return; - } - memcpy(nmbuf, indefent, *indefent);/* Copy #DEFAULT to name buffer. */ - fpis = &fpidf; /* Use #DEFAULT fpi if external. */ - defltsw = 1; /* Indicate #DEFAULT is being defined.*/ - break; - default: - mderr(122, (UNCH *)0, (UNCH *)0); - return; - } - subdcl = nmbuf+1; /* Subject name for error messages. */ - /* PARAMETER 2: Entity text keyword (optional). - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - TRACEMD("2: keyword"); - switch (pcbmd.action) { - case NAS: - if ((estore = (UNCH)mapsrch(enttab, tbuf+1))==0) { - estore = parmsw ? ESP : ESF; - pne = (PNE)rmalloc(NESZ); - if (mdextid(tbuf, fpis, nmbuf+1+parmsw, &estore, pne)==0) - return; - if (defltsw) etx.x = NULL; - else if ((etx.x = entgen(&fpicb))==0) { - if (parmsw) - mderr(148, nmbuf+2, (UNCH *)0); - else - mderr(147, nmbuf+1, (UNCH *)0); - } - goto parm4; - } - if (parmsw && (estore==ESX || estore==ESC)) { - mderr(38, tbuf+1, (UNCH *)0); - estore = ESM; - } - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - break; - default: - estore = ESM; - break; - } - /* PARAMETER 3: Parameter literal. - */ - TRACEMD("3: literal"); - switch (pcbmd.action) { - case LITE: - case LIT: - switch (estore) { - case ESM: /* LITERAL: parameter literal required. */ - case ESC: /* CDATA: parameter literal required. */ - case ESX: /* SDATA: parameter literal required. */ - case ESI: /* PI: parameter literal required. */ - etx.c = savestr(tbuf); - break; - case ESMD: /* MD: parameter literal required. */ - etx.c = sandwich(tbuf, lex.m.mdo, lex.m.mdc); - goto bcheck; - case ESMS: /* MS: parameter literal required. */ - etx.c = sandwich(tbuf, lex.m.mss, lex.m.mse); - goto bcheck; - case ESS: /* STARTTAG: parameter literal required. */ - etx.c = sandwich(tbuf, lex.m.stag, lex.m.tagc); - goto bcheck; - case ESE: /* ENDTAG: parameter literal required. */ - etx.c = sandwich(tbuf, lex.m.etag, lex.m.tagc); - bcheck: - if (etx.c == 0) { - mderr(225, (UNCH *)0, (UNCH *)0); - return; - } - break; - } - break; - default: - mderr(123, (UNCH *)0, (UNCH *)0); - return; - } - /* PARAMETER 4: End of declaration. - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - parm4: - TRACEMD(emd); - if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0); - if (es!=mdessv) synerr(37, &pcbmd); - - /* EXECUTE: If the entity already exists, ignore the new definition. - If it is a new entity, store the definition. - */ - if ((ecb = entfind(nmbuf))!=0 && ecb->estore) { - if (ecb->dflt) { - mderr(228, nmbuf + 1, (UNCH *)0); - hout((THASH)etab, nmbuf, hash(nmbuf, ENTHASH)); - if (ecb->estore == ESN) { - frem((UNIV)NEID(ecb->etx.n)); - frem((UNIV)ecb->etx.n); - } - else if (ecb->estore >= ESFM) - frem((UNIV)ecb->etx.x); - frem((UNIV)ecb); - } - else { - /* Duplicate definition: not an error. */ - if (sw.swdupent) mderr(68, nmbuf+1, (UNCH *)0); - if (estoreename; /* Store entity name in ne. */ - NEID(pne) = etx.x; /* Store system fileid in ne. */ - NESYSID(pne) = fpis->fpisysis ? savestr(fpis->fpisysis) : 0; - NEPUBID(pne) = fpis->fpipubis ? savestr(fpis->fpipubis) : 0; - ecb->etx.n = pne; /* Store ne control block in etx. */ - TRACEESN(pne); - } - else if (pne) - frem((UNIV)pne); - if (defltsw) { - ecbdeflt = ecb; /* If #DEFAULT save ecb. */ - if (fpidf.fpipubis) - fpidf.fpipubis = savestr(fpidf.fpipubis); - if (fpidf.fpisysis) - fpidf.fpisysis = savestr(fpidf.fpisysis); - } -} -/* SANDWICH: Catenate a prefix and suffix to a string. - The result has an EOS but no length. - Return 0 if the result if longer than LITLEN. -*/ -UNCH *sandwich(s, pref, suff) -UNCH *s; /* String, with EOS. */ -UNCH *pref; /* Prefix, with length and EOS. */ -UNCH *suff; /* Suffix, with length and EOS. */ -{ - UNCH *pt; - UNS slen, tlen; - - slen = ustrlen(s); - tlen = slen + (*pref - 2) + (*suff - 2); - if (tlen > LITLEN) - return 0; - pt = (UNCH *)rmalloc(tlen + 1); - memcpy(pt, pref + 1, *pref - 2); - memcpy(pt + (*pref - 2), s, slen); - memcpy(pt + (*pref - 2) + slen, suff + 1, *suff - 1); - return pt; -} -/* MDEXTID: Process external identifier parameter of a markup declaration. - On entry, tbuf contains SYSTEM or PUBLIC if all is well. - NULL is returned if an error, otherwise fpis. If it is a - valid external data entity, the caller's estore is set to ESN - and its nxetype is set to the code for the external entity type. - The event that terminated the parse is preserved in pcb.action, - so the caller should process it before further parsing. -*/ -struct fpi *mdextid(tbuf, fpis, ename, estore, pne) -UNCH *tbuf; /* Work area for tokenization[2*(LITLEN+2)]. */ -struct fpi *fpis; /* FPI structure. */ -UNCH *ename; /* Entity or notation name, with EOS, no length.*/ - /* NOTE: No PERO on parameter entity name. */ -UNCH *estore; /* DTD, general or parameter entity, DCN. */ -PNE pne; /* Caller's external entity ptr. */ -{ - PDCB dcb; /* Ptr to DCN control block. */ - int exidtype; /* External ID type: 0=none 1=system 2=public. */ - int exetype; /* External entity type. */ - - MEMZERO((UNIV)fpis, (UNS)FPISZ); /* Initialize fpi structure. */ - /* Move entity name into fpi (any PERO was stripped by caller). */ - fpis->fpinm = ename; - entlen = 0; /* Initialize external ID length. */ - - /* PARAMETER 1: External identifier keyword or error. - */ - TRACEMD("1: extid keyword"); - if ((exidtype = mapsrch(exttab, tbuf+1))==0) { - mderr(29, (UNCH *)0, (UNCH *)0); - return (struct fpi *)0; - } - if (exidtype==EDSYSTEM) goto parm3; - - /* PARAMETER 2: Public ID literal. - */ - pcbmd.newstate = 0; - /* The length of a minimum literal cannot exceed the value of LITLEN - in the reference quantity set. */ - parsemd(pubibuf, NAMECASE, &pcblitv, REFLITLEN); - TRACEMD("2: pub ID literal"); - switch (pcbmd.action) { - case LITE: /* Use alternative literal delimiter. */ - case LIT: /* Save literal as public ID string. */ - entlen = ustrlen(pubibuf); - fpis->fpipubis = pubibuf; - break; - default: - mderr(117, (UNCH *)0, (UNCH *)0); - return (struct fpi *)0; /* Signal error to caller. */ - } - /* PARAMETER 3: System ID literal. - */ - parm3: - pcbmd.newstate = 0; - parsemd(sysibuf, NAMECASE, &pcblitc, LITLEN); - TRACEMD("3: sys ID literal"); - if (pcbmd.action==LIT || pcbmd.action==LITE) { - entlen += ustrlen(sysibuf); - fpis->fpisysis = sysibuf; - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - } - else memcpy(tbuf, sysibuf, *sysibuf); - if (*estore!=ESF || pcbmd.action!=NAS) goto genfpi; - - /* PARAMETER 4: Entity type keyword. - */ - TRACEMD("4: Entity type"); - if ((exetype = mapsrch(extettab, tbuf+1))==0) { - mderr(24, tbuf+1, (UNCH *)0); - return (struct fpi *)0; - } - if (exetype==ESNSUB && SUBDOC == NO) { - mderr(90, tbuf+1, (UNCH *)0); - return (struct fpi *)0; - } - - NEXTYPE(pne) = (UNCH)exetype; /* Save entity type in caller's ne. */ - *estore = ESN; /* Signal that entity is a data entity. */ - - if (exetype==ESNSUB) { - pne->nedcn = 0; - pcbmd.newstate = 0; /* Parse next token for caller. */ - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - goto genfpi; - } - /* PARAMETER 5: Notation name. - */ - pcbmd.newstate = 0; - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("5: notation"); - if (pcbmd.action!=NAS) {mderr(119, tbuf+1, (UNCH *)0); return (struct fpi *)0;} - /* Locate the data content notation. */ - pne->nedcn = dcb = dcndef(lbuf); - /* Note that we have defined an entity with this notation. - If attributes are later defined for this notation, we'll - have to fix up this entity. */ - dcb->entsw = 1; - - /* PARAMETER 6: Data attribute specification. - */ - pcbmd.newstate = 0; - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("6: [att list]"); - if (pcbmd.action!=MDS) { /* No attributes specified. */ - if (dcb->adl == 0) - NEAL(pne) = 0; - else { - initatt(dcb->adl); - adlval((int)ADN(al), (struct etd *)0); - storedatt(pne); - } - goto genfpi; - } - if (dcb->adl==0) { /* Atts specified, but none defined. */ - mderr(22, (UNCH *)0, (UNCH *)0); - return (struct fpi *)0; - } - pcbstag.newstate = pcbstan; /* First separator is optional. */ - if ((parseatt(dcb->adl, tbuf))==0)/* Empty list. */ - mderr(91, (UNCH *)0, (UNCH *)0); - else { - adlval((int)ADN(al), (struct etd *)0); - storedatt(pne); - } - parse(&pcbeal); /* Parse the list ending. */ - pcbmd.newstate = 0; /* Parse next token for caller. */ - parsemd(tbuf, NAMECASE, &pcblitp, LITLEN); - - /* GENFPI: Builds a formal public identifier structure, including the - entity name, offsets of the components of the public ID, and - other data a system might use to identify the actual file. - */ - genfpi: - TRACEMD("7: generate fpi"); - fpis->fpistore = *estore - ESFM + 1; /* External entity type: 1-6. */ - if (*estore == ESN) { - if (NEXTYPE(pne) == ESNSUB) - fpis->fpinedcn = 0; - else - fpis->fpinedcn = NEDCN(pne) + 1; - } - /* Analyze public ID and make structure entries. */ - if (exidtype==EDPUBLIC) { - if (FORMAL==NO) - fpis->fpiversw = -1; - else if (parsefpi(fpis)>0) { - mderr(88, fpis->fpipubis, (UNCH *)0); - fpis->fpiversw = -1; /* Signal bad formal public ID. */ - } - } - return fpis; -} - -/* Store a data attribute. */ - -VOID storedatt(pne) -PNE pne; -{ - int i; - - NEAL(pne) = (struct ad *)rmalloc((1+ADN(al))*ADSZ); - memcpy((UNIV)NEAL(pne), (UNIV)al, (1+ADN(al))*ADSZ); - for (i = 1; i <= (int)ADN(al); i++) { - if (GET(ADFLAGS(al, i), ASPEC)) - ds.attdef += ADLEN(al, i); - if (NEAL(pne)[i].addef != 0) - NEAL(pne)[i].addef = savestr(NEAL(pne)[i].addef); - } - ds.attcnt += AN(al); /* Number of attributes defined. */ -#if 0 - /* I can't see any reason to increase AVGRPCNT here. */ - ds.attgcnt += ADN(al) - AN(al); /* Number of att grp members. */ -#endif -} - -/* PARSEFPI: Parses a formal public identifier and builds a control block. - PARSEFPI returns a positive error code (1-10), or 0 if no errors. - It set fpiversw if no version was specified in the ID and the - public text is in a class that permits display versions. - Note: An empty version ("//") can be specified (usually it is - the non-device-specific form, such as a definitional entity set). -*/ -int parsefpi(f) -PFPI f; /* Ptr to formal public identifier structure. */ -{ - UNCH *l; /* Pointer to EOS of public identifier. */ - UNCH *p, *q; /* Ptrs to current field in public identifier. */ - UNS len; /* Field length */ - - p = f->fpipubis; /* Point to start of identifier. */ - l = p + ustrlen(p); /* Point to EOS of identifier. */ - if (*p=='+' || *p=='-') { /* If owner registered, unregistered. */ - f->fpiot = *p; /* Save owner type. */ - if ((p += 3)>=l) return 1; /* Get to owner ID field. */ - } - else f->fpiot = '!'; /* Indicate ISO owner identifier. */ - if ((q = pubfield(p, l, '/', &len))==0) /* Find end of owner ID field. */ - return 2; - f->fpiol = len; /* Save owner ID length. */ - f->fpio = p - f->fpipubis; /* Save offset in pubis to owner ID. */ - - if ((p = pubfield(q, l, ' ', &len))==0) /* Find end of text class field. */ - return 3; - *(--p) = EOS; /* Temporarily make class a string. */ - f->fpic = mapsrch(pubcltab, q); /* Check for valid uc class name.*/ - *p++ = ' '; /* Restore the SPACE delimiter. */ - if (f->fpic==0) return 4; /* Error if not valid uc class name.*/ - - /* The public text class in a notation identifier must be NOTATION. */ - if (f->fpistore == ESK - ESFM + 1 && f->fpic != FPINOT) return 10; - - if (*p=='-') { /* If text is unavailable public text.*/ - f->fpitt = *p; /* Save text type. */ - if ((p += 3)>=l) return 5; /* Get to text description field. */ - } - else f->fpitt = '+'; /* Indicate available public text. */ - if ((q = pubfield(p, l, '/', &len))==0) /* Find end of text description. */ - return 6; - f->fpitl = len; /* Save text description length. */ - f->fpit = p - f->fpipubis; /* Save ptr to description.*/ - - p = pubfield(q, l, '/', &len); /* Bound language field. */ - if (f->fpic != FPICHARS) { - int i; - /* Language must be all upper-case letters. */ - /* The standard only says that it *should* be two letters, so - don't enforce that. */ - for (i = 0; i < len; i++) { - /* Don't assume ASCII. */ - if (!strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", q[i])) - return 7; - } - } - f->fpill = len; - f->fpil = q - f->fpipubis; - if (p!=0) { /* If there is a version field: */ - if (f->fpicfpivl = len; /* Save version length. */ - f->fpiv = p - f->fpipubis; /* Save ptr (in pubis) to version. */ - } - else if (f->fpic>=FPICMINV) f->fpiversw = 1;/* No version: get the best. */ - return(0); -} -/* PUBFIELD: Returns ptr to next field, or NULL if ID has ended. -*/ -#ifdef USE_PROTOTYPES -UNCH *pubfield(UNCH *p, UNCH *l, UNCH d, UNS *lenp) -#else -UNCH *pubfield(p, l, d, lenp) -UNCH *p; /* Public identifier field (no length or EOS). */ -UNCH *l; /* Pointer to EOS of public identifier. */ -UNCH d; /* Field delimiter: ' ' or '/'. */ -UNS *lenp; /* Gets field length */ -#endif -{ - UNCH *psv = p+1; /* Save starting value of p. */ - - while (pTAGLVL) { - --mslevel; - sgmlerr(27, (struct parse *)0, ntoa(TAGLVL), (UNCH *)0); - } - - /* If already in IGNORE mode, return without parsing parameters. */ - if (msplevel) {++msplevel; return(pcb);} - - parmno = 0; /* No parameters as yet. */ - mdessv = es; /* Save es for checking entity nesting. */ - pcbmd.newstate = pcbmdtk; /* First separator is optional. */ - - /* PARAMETERS: TEMP, RCDATA, CDATA, IGNORE, INCLUDE, or MDS. */ - while ((ptype = parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN))==NAS){ - if ((key = mapsrch(mstab, tbuf+1))==0) { - sgmlerr(64, (struct parse *)0, ntoa(parmno), tbuf+1); - continue; - } - if (key==MSTEMP) continue; /* TEMP: for documentation. */ - msplevel = 1; /* Special parse required. */ - if (key>pcbcode) pcbcode = key; /* Update if higher priority. */ - } - if (ptype!=MDS) { - NEWCC; /* Syntax error did REPEATCC. */ - sgmlerr(97, (struct parse *)0, lex.m.dso, (UNCH *)0); - REPEATCC; /* 1st char of marked section. */ - } - if (es!=mdessv) synerr(37, pcb); - TRACEMS(1, pcbcode, mslevel, msplevel); - if (pcbcode==MSIGNORE) pcb = &pcbmsi; - else if (pcbcode) { - pcb = pcbcode==MSCDATA ? &pcbmsc : (rcessv = es, &pcbmsrc); - } - return(pcb); /* Tell caller whether to change the parse. */ -} -/* MDMSE: Process marked section end. - Issue an error if no marked section had started. -*/ -int mdmse() -{ - int retcode = 0; /* Return code: 0=same parse; 1=cancel special. */ - - if (mslevel) --mslevel; - else sgmlerr(26, (struct parse *)0, (UNCH *)0, (UNCH *)0); - - if (msplevel) if (--msplevel==0) retcode = 1; - TRACEMS(0, retcode, mslevel, msplevel); - return retcode; -} -/* MDNOT: Process NOTATION declaration. -*/ -VOID mdnot(tbuf) -UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */ -{ - struct fpi fpicb; /* Formal public identifier structure. */ - PDCB dcb; /* Ptr to notation entity in dcntab. */ - UNCH estore = ESK; /* Entity storage class. */ - - mdname = key[KNOTATION]; /* Identify declaration for messages. */ - subdcl = NULL; /* No subject as yet. */ - parmno = 0; /* No parameters as yet. */ - mdessv = es; /* Save es for checking entity nesting. */ - - /* PARAMETER 1: Notation name. - */ - pcbmd.newstate = 0; - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1: name"); - if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;} - subdcl = lbuf+1; /* Save notation name for error msgs. */ - - /* PARAMETER 2: External identifier keyword. - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2: extid"); - if (pcbmd.action!=NAS) {mderr(29, (UNCH *)0, (UNCH *)0); return;} - if (mdextid(tbuf, &fpicb, lbuf+1, &estore, (PNE)0)==0) return; - - /* PARAMETER 3: End of declaration. - Token was parsed by MDEXTID. - */ - TRACEMD(emd); - if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0); - if (es!=mdessv) synerr(37, &pcbmd); - - /* EXECUTE: Store notation name. - */ - if ((dcb = dcnfind(lbuf)) != 0 && dcb->defined) { - mderr(56, lbuf+1, (UNCH *)0); - return; - } - /* else */ - dcb = dcndef(lbuf); - dcb->defined = 1; - dcb->sysid = fpicb.fpisysis ? savestr(fpicb.fpisysis) : 0; - dcb->pubid = fpicb.fpipubis ? savestr(fpicb.fpipubis) : 0; - ++ds.dcncnt; - ds.dcntext += entlen; - TRACEDCN(dcb); - return; -} -/* DCNDEF: Define a notation and return its DCNCB. - If caller does not care if it already exists, - he should specify NULL for the notation text - so we don't clobber the existing text (if any). -*/ -struct dcncb *dcndef(nname) -UNCH *nname; /* Notation name (with length and EOS). */ -{ - return((PDCB)hin((THASH)dcntab, nname, 0, DCBSZ)); -} -/* DCNFIND: If a notation was declared, return its DCNCB. - Return NULL if it is not defined. -*/ -struct dcncb *dcnfind(nname) -UNCH *nname; /* Notation name (with length and EOS). */ -{ - return((PDCB)hfind((THASH)dcntab, nname, 0)); -} -#define SRM(i) (srhptr->srhsrm[i]) /* Current entry in SHORTREF map. */ -/* MDSRMDEF: Process short reference mapping declaration. -*/ -VOID mdsrmdef(tbuf) -UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */ -{ - struct entity *entcb; /* Ptr to defined entity. */ - PSRH srhptr; /* Ptr to short reference map hdr (in srhtab).*/ - int srn; /* Short reference delimiter number in srdeltab.*/ - int mapused = 0; /* Has map already been used? */ - - mdname = key[KSHORTREF]; /* Identify declaration for messages. */ - subdcl = NULL; /* No subject as yet. */ - parmno = 0; /* No parameters as yet. */ - if (!sd.shortref) {mderr(198, (UNCH *)0, (UNCH *)0); return;} - mdessv = es; /* Save es for checking entity nesting. */ - /* PARAMETER 1: SHORTREF map name. - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1: map nm"); - if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); return;} - if ((srhptr = srhfind(tbuf))!=0) { - mapused = 1; - /* Error if map was declared (not just used). */ - if (SRM(0)) {mderr(56, tbuf+1, (UNCH *)0); return;} - } - else srhptr = srhdef(tbuf); /* Create map with SRs mapped to NULL.*/ - SRM(0) = (PECB)srhptr; /* Indicate map was actually declared.*/ - subdcl = srhptr->ename+1; /* Save map name for error msgs. */ - - while ( pcbmd.newstate = 0, - parsemd(tbuf, NAMECASE, &pcblitp, SRMAXLEN)==LIT - || pcbmd.action==LITE ) { - /* PARAMETER 2: Delimiter string. - */ - TRACEMD("2: SR string"); - if ((srn = mapsrch(lex.s.dtb, tbuf))==0) { - mderr(124, tbuf, (UNCH *)0); - goto cleanup; - } - /* PARAMETER 3: Entity name. - */ - pcbmd.newstate = 0; - parsemd(tbuf, ENTCASE, &pcblitp, NAMELEN); - TRACEMD("3: entity"); - if (pcbmd.action!=NAS) {mderr(120, (UNCH *)0, (UNCH *)0); goto cleanup;} - if ((entcb = entfind(tbuf))==0) { - union etext etx; - etx.x = 0; - entcb = entdef(tbuf, '\0', &etx); - } - if (SRM(srn)) { - mderr(56, (srn=lex.s.fce && srn!=lex.s.hyp && srn!=lex.s.hyp2 - && srn!=lex.s.lbr && srn!=lex.s.rbr) - lexcnm[*lex.s.dtb[srn].mapnm] = lex.l.fce; - else if (srn==lex.s.spc) lexcnm[' '] = lex.l.spcr; - } - /* PARAMETER 4: End of declaration. - */ - TRACEMD(emd); - if (parmno==2) - {mderr((UNS)(pcbmd.action==EMD ? 28:123), (UNCH *)0, (UNCH *)0); goto cleanup;} - if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0); - if (es!=mdessv) synerr(37, &pcbmd); - ++ds.srcnt; - TRACESRM("SHORTREF", srhptr->srhsrm, (UNCH *)0); - return; - - cleanup: - /* Don't free the map if the map was in use (because of a USEMAP - declaration) before this declaration. */ - if (mapused) - MEMZERO((UNIV)srhptr->srhsrm, sizeof(PECB)*(lex.s.dtb[0].mapdata+1)); - else { - frem((UNIV)srhptr->srhsrm); - hout((THASH)srhtab, srhptr->ename, 0); - frem((UNIV)srhptr); - } -} -/* MDSRMUSE: Activate a short reference map. -*/ -VOID mdsrmuse(tbuf) -UNCH *tbuf; /* Work area for tokenization[LITLEN+2]. */ -{ - PSRH srhptr; /* Ptr to short reference map hdr (in srhtab).*/ - TECB srmptr; /* Ptr to short reference map (in header). */ - int i; /* Loop counter; temporary variable. */ - - mdname = key[KUSEMAP]; /* Identify declaration for messages. */ - subdcl = NULL; /* No subject as yet. */ - parmno = 0; /* No parameters as yet. */ - mdessv = es; /* Save es for checking entity nesting. */ - /* PARAMETER 1: SHORTREF map name or "#EMPTY". - */ - pcbmd.newstate = 0; - parsemd(lbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("1: map nm"); - subdcl = lbuf+1; /* Subject name for error messages. */ - switch (pcbmd.action) { - case RNS: /* Empty SHORTREF map requested. */ - if (ustrcmp(lbuf+1, key[KEMPTY])) { - mderr(118, lbuf+1, key[KEMPTY]); - return; - } - srmptr = SRMNULL; - break; - case NAS: /* Map name specified; save if undefined. */ - if ((srhptr = srhfind(lbuf))==0) { - if (!indtdsw) {mderr(125, (UNCH *)0, (UNCH *)0); return;} - srmptr = NULL; - } - else - srmptr = srhptr->srhsrm; - break; - default: - mderr(120, (UNCH *)0, (UNCH *)0); - return; - } - /* PARAMETER 2: Element name or a group of them. (In DTD only.) - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD("2: GI or grp"); - switch (pcbmd.action) { - case NAS: - if (!indtdsw) {mderr(142, (UNCH *)0, (UNCH *)0); return;} - nmgrp[0] = etddef(tbuf); - nmgrp[1] = (PETD)NULL; - break; - case GRPS: - if (!indtdsw) {mderr(142, (UNCH *)0, (UNCH *)0); return;} - parsegrp(nmgrp, &pcbgrnm, tbuf); - break; - case EMD: - if (indtdsw) {mderr(28, (UNCH *)0, (UNCH *)0); return;} - tags[ts].tsrm = srmptr; - TRACESRM("USEMAP", tags[ts].tsrm, tags[ts].tetd->etdgi+1); - goto realemd; - default: - mderr(indtdsw ? 121 : 126, (UNCH *)0, (UNCH *)0); - return; - } - /* PARAMETER 3: End of declaration. - */ - pcbmd.newstate = 0; - parsemd(tbuf, NAMECASE, &pcblitp, NAMELEN); - TRACEMD(emd); - if (pcbmd.action!=EMD) mderr(126, (UNCH *)0, (UNCH *)0); - /* If map has not yet been defined, do it and get map pointer. */ - if (!srmptr) srmptr = (srhdef(lbuf))->srhsrm; - - /* Store the map pointer for each element name specified. - */ - TRACEGRP(nmgrp); - for (i = -1; nmgrp[++i];) { - if (!nmgrp[i]->etdsrm) nmgrp[i]->etdsrm = srmptr; - else if (sw.swdupent) mderr(68, nmgrp[i]->etdgi+1, (UNCH *)0); - } - realemd: - if (es!=mdessv) synerr(37, &pcbmd); -} -/* SRHDEF: Define a SHORTREF map and return ptr to its header. - All entries in map are mapped to NULL. - Caller must determine whether it already exists. -*/ -PSRH srhdef(sname) -UNCH *sname; /* SHORTREF map name (with length and EOS). */ -{ - PSRH srh; /* Ptr to SHORTREF map hdr in srhtab. */ - - (srh = (PSRH)hin((THASH)srhtab, sname, 0, SRHSZ))->srhsrm = - (TECB)rmalloc((UNS)(lex.s.dtb[0].mapdata+1)*sizeof(PECB)); - return(srh); -} -/* SRHFIND: If a SHORTREF map was declared, return the ptr to its header. - Return NULL if it is not defined. -*/ -PSRH srhfind(sname) -UNCH *sname; /* SHORTREF map name (with length and EOS). */ -{ - return((PSRH)hfind((THASH)srhtab, sname, 0)); -} -#undef SRM - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/msg.h b/cde/programs/dtdocbook/sgmls/msg.h deleted file mode 100644 index c651979c2..000000000 --- a/cde/programs/dtdocbook/sgmls/msg.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: msg.h /main/3 1996/06/19 17:16:18 drk $ */ -/* -Severity codes: -I information (not an SGML error at all) -W warning (an SGML markup error but it knows what you mean) -E error -C critical (fatal) - -Type codes: -R resource -C ?context/content -M minimization -Q quantity -S syntax -D declaration -U unsupported feature -*/ -struct { - char *text; - char severity; - char type; -} messages[] = { -/* 0 */ {0}, -/* 1 */ {"%s element not allowed at this point in %s element", 'E', 'C'}, -/* 2 */ {"%s markup declaration not permitted here; declaration ended", 'E', 'D'}, -/* 3 */ {"Length of name, number, or token exceeded NAMELEN or LITLEN limit", 'E', 'Q'}, -/* 4 */ {"Non-SGML character ignored", 'E', 'S'}, -/* 5 */ {"%s end-tag ignored: doesn't end any open element (current is %s)", 'E', 'C'}, -/* 6 */ {"%s start-tag exceeds open element limit; possible lies from %s on", 'E', 'Q'}, -/* 7 */ {"Start-tag omitted from %s with empty content", 'E', 'M'}, -/* 8 */ {"Illegal entity end in markup or delimited text", 'E', 'S'}, -/* 9 */ {"Incorrect character in markup; markup terminated", 'E', 'S'}, -/* 10 */ {"Data not allowed at this point in %s element", 'E', 'C'}, -/* 11 */ {"No element declaration for %s end-tag GI; end-tag ignored", 'E', 'C'}, -/* 12 */ {"%s name ignored: not a syntactically valid SGML name", 'E', 'S'}, -/* 13 */ {"%s = \"%s\" attribute ignored: not defined for this element", 'E', 'C'}, -/* 14 */ {"%s = \"%s\" attribute value defaulted: invalid character", 'E', 'S'}, -/* 15 */ {"%s = \"%s\" attribute value defaulted: token too long", 'E', 'Q'}, -/* 16 */ {"%s = \"%s\" attribute value defaulted: too many tokens", 'E', 'C'}, -/* 17 */ {"%s = \"%s\" attribute value defaulted: wrong token type", 'E', 'C'}, -/* 18 */ {"%s = \"%s\" attribute value defaulted: token not in group", 'E', 'C'}, -/* 19 */ {"Required %s attribute was not specified; may affect processing", 'E', 'C'}, -/* 20 */ {"%s end-tag implied by %s end-tag; not minimizable", 'E', 'M'}, -/* 21 */ {"%s start-tag implied by %s start-tag; not minimizable", 'W', 'M'}, -/* 22 */ {"Possible attributes treated as data because none were defined", 'E', 'C'}, -/* 23 */ {"Duplicate specification occurred for \"%s\"; may affect processing", 'E', 'D'}, -/* 24 */ {"\"%s\" keyword invalid; declaration terminated", 'E', 'D'}, -/* 25 */ {"%s = \"%s\" attribute defaulted: empty string not allowed for token", 'E', 'C'}, -/* 26 */ {"Marked section end ignored; not in a marked section", 'E', 'S'}, -/* 27 */ {"Marked section start ignored; %s marked sections open already", 'E', 'Q'}, -/* 28 */ {"One or more parameters missing; declaration ignored", 'E', 'D'}, -/* 29 */ {"\"PUBLIC\" or \"SYSTEM\" required; declaration terminated", 'E', 'D'}, -/* 30 */ {"%s element ended prematurely; required %s omitted", 'E', 'C'}, -/* 31 */ {"Entity \"%s\" terminated: could not read file", 'E', 'R'}, -/* 32 */ {"Could not open file for entity \"%s\"; entity reference ignored", 'E', 'R'}, -/* 33 */ {"Insufficient main memory; unable to continue parsing", 'C', 'R'}, -/* 34 */ {"%s entity reference ignored; exceeded open entity limit (%s)", 'E', 'Q'}, -/* 35 */ {"No declaration for entity \"%s\"; reference ignored", 'E', 'C'}, -/* 36 */ {"%s entity reference occurred within own text; reference ignored", 'E', 'C'}, -/* 37 */ {"Entity nesting level out of sync", 'E', 'S'}, -/* 38 */ {"Parameter entity text cannot have %s keyword; keyword ignored", 'E', 'D'}, -/* 39 */ {"%s end-tag implied by %s start-tag; not minimizable", 'W', 'M'}, -/* 40 */ {"Start-tag minimization ignored; element has required attribute", 'E', 'D'}, -/* 41 */ {"Required %s element cannot be excluded from %s element", 'E', 'C'}, -/* 42 */ {"No DOCTYPE declaration; document type is unknown", 'E', 'C'}, -/* 43 */ {"Undefined %1$s start-tag GI was used in DTD; \"%1$s O O ANY\" assumed", 'E', 'C'}, -/* 44 */ {"Invalid character(s) ignored; attempting to resume DOCTYPE subset", 'E', 'S'}, -/* 45 */ {"No declaration for entity \"%s\"; default definition used", 'I', 'C'}, -/* 46 */ {"%s end-tag implied by NET delimiter; not minimizable", 'W', 'M'}, -/* 47 */ {"%s end-tag implied by data; not minimizable", 'W', 'M'}, -/* 48 */ {"%s end-tag implied by short start-tag (no GI); not minimizable", 'W', 'M'}, -/* 49 */ {"%s start-tag implied by data; not minimizable", 'W', 'M'}, -/* 50 */ {"%s start-tag implied by short start-tag (no GI); not minimizable", 'W', 'M'}, -/* 51 */ {"Short end-tag (no GI) ignored: no open elements", 'E', 'C'}, -/* 52 */ {"No definition for %1$s document type; \"%1$s O O ANY\" assumed", 'E', 'C'}, -/* 53 */ {"No definition for %1$s implied start-tag; \"%1$s O O ANY\" assumed", 'E', 'C'}, -/* 54 */ {"%s element ended prematurely; required subelement omitted", 'E', 'C'}, -/* 55 */ {"Content model token %s: connectors conflict; first was used", 'E', 'D'}, -/* 56 */ {"Duplicate specification occurred for \"%s\"; duplicate ignored", 'E', 'D'}, -/* 57 */ {"Bad end-tag in R/CDATA element; treated as short (no GI) end-tag", 'E', 'S'}, -/* 58 */ {"Start-tag minimization should be \"-\" for element with declared content", 'I', 'D'}, -/* 59 */ {"Reference to PI entity not permitted here; reference ignored", 'E', 'S'}, -/* 60 */ {"Non-SGML character found; should have been character reference", 'W', 'S'}, -/* 61 */ {"Numeric character reference exceeds 255; reference ignored", 'E', 'S'}, -/* 62 */ {"Invalid alphabetic character reference ignored", 'E', 'S'}, -/* 63 */ {"Invalid character in minimum literal; character ignored", 'E', 'S'}, -/* 64 */ {"Keyword %s ignored; \"%s\" is not a valid marked section keyword", 'E', 'D'}, -/* 65 */ {"Parameter entity name longer than (NAMELEN-1); truncated", 'E', 'Q'}, -/* 66 */ {"Start-tag length exceeds TAGLEN limit; parsed correctly", 'W', 'Q'}, -/* 67 */ {"%s attribute defaulted: FIXED attribute must equal default", 'W', 'C'}, -/* 68 */ {"Duplicate specification occurred for \"%s\"; duplicate ignored", 'I', 'D'}, -/* 69 */ {"%s = \"%s\" IDREF attribute ignored: referenced ID does not exist", 'E', 'C'}, -/* 70 */ {"%s = \"%s\" IDREF attribute ignored: number of IDs in list exceeds GRPCNT limit", 'E', 'Q'}, -/* 71 */ {"%s = \"%s\" ID attribute ignored: ID in use for another element", 'E', 'C'}, -/* 72 */ {"%s = \"%s\" ENTITY attribute not general entity; may affect processing", 'E', 'C'}, -/* 73 */ {"%s = \"%s\" attribute ignored: previously specified in same list", 'W', 'C'}, -/* 74 */ {"\"?\" = \"%s\" name token ignored: not in any group in this list", 'E', 'C'}, -/* 75 */ {"Normalized attribute specification length over ATTSPLEN limit", 'E', 'Q'}, -/* 76 */ {"%s = \"%s\" NOTATION ignored: element content is empty", 'E', 'C'}, -/* 77 */ {"%s = \"%s\" NOTATION undefined: may affect processing", 'E', 'C'}, -/* 78 */ {"Entity \"%2$s\" has undefined notation \"%1$s\"", 'E', 'C'}, -/* 79 */ {"%s = \"%s\" default attribute value not in group; #IMPLIED used", 'E', 'C'}, -/* 80 */ {"#CURRENT default value treated as #IMPLIED for %s ID attribute", 'E', 'D'}, -/* 81 */ {"ID attribute %s cannot have a default value; treated as #IMPLIED", 'E', 'D'}, -/* 82 */ {"%s attribute must be token, not empty string; treated as #IMPLIED", 'E', 'D'}, -/* 83 */ {"NOTATION attribute ignored for EMPTY element", 'E', 'D'}, -/* 84 */ {"%s = \"%s\" NOTATION ignored: content reference specified", 'E', 'C'}, -/* 85 */ {"#CONREF default value treated as #IMPLIED for EMPTY element", 'W', 'D'}, -/* 86 */ {"%s = \"%s\" entity not data entity; may affect processing", 'E', 'C'}, -/* 87 */ {"End-tag minimization should be \"O\" for EMPTY element", 'I', 'D'}, -/* 88 */ {"Formal public identifier \"%s\" invalid; treated as informal", 'E', 'S'}, -/* 89 */ {"Out-of-context %2$s start-tag ended %1$s document element (and parse)", 'E', 'C'}, -/* 90 */ {"\"%s\" keyword is for unsupported feature; declaration terminated", 'E', 'D'}, -/* 91 */ {"Attribute specification list in prolog cannot be empty", 'E', 'D'}, -/* 92 */ {"Document ended invalidly within a literal; parsing ended", 'C', 'S'}, -/* 93 */ {"Short ref in map \"%2$s\" to undeclared entity \"%1$s\" treated as data", 'E', 'C'}, -/* 94 */ {"Could not reopen file to continue entity \"%s\"; entity terminated", 'E', 'R'}, -/* 95 */ {"Out-of-context data ended %s document element (and parse)", 'E', 'C'}, -/* 96 */ {"Short start-tag (no GI) ended %s document element (and parse)", 'E', 'C'}, -/* 97 */ {"DSO delimiter (%s) omitted from marked section declaration", 'E', 'D'}, -/* 98 */ {"Group token %s: duplicate name or name token \"%s\" ignored", 'E', 'D'}, -/* 99 */ {"Attempt to redefine %s attribute ignored", 'E', 'D'}, -/* 100 */ {"%s definition ignored: %s is not a valid declared value keyword", 'E', 'D'}, -/* 101 */ {"%s definition ignored: NOTATION attribute already defined", 'E', 'D'}, -/* 102 */ {"%s definition ignored: ID attribute already defined", 'E', 'D'}, -/* 103 */ {"%s definition ignored: no declared value specified", 'E', 'D'}, -/* 104 */ {"%s definition ignored: invalid declared value specified", 'E', 'D'}, -/* 105 */ {"%s definition ignored: number of names or name tokens in group exceeded GRPCNT limit", 'E', 'D'}, -/* 106 */ {"%s definition ignored: name group omitted for NOTATION attribute", 'E', 'D'}, -/* 107 */ {"#CONREF default value treated as #IMPLIED for %s ID attribute", 'E', 'D'}, -/* 108 */ {"%s definition ignored: %s is not a valid default value keyword", 'E', 'D'}, -/* 109 */ {"%s definition ignored: no default value specified", 'E', 'D'}, -/* 110 */ {"%s definition ignored: invalid default value specified", 'E', 'D'}, -/* 111 */ {"More than ATTCNT attribute names and/or name (token) values; terminated", 'E', 'D'}, -/* 112 */ {"Attempted redefinition of attribute definition list ignored", 'E', 'D'}, -/* 113 */ {"Content model token %s: more than GRPCNT model group tokens; terminated", 'E', 'Q'}, -/* 114 */ {"Content model token %s: more than GRPGTCNT content model tokens; terminated", 'E', 'Q'}, -/* 115 */ {"Content model token %s: more than GRPLVL nested model groups; terminated", 'E', 'Q'}, -/* 116 */ {"Content model token %s: %s invalid; declaration terminated", 'E', 'D'}, -/* 117 */ {"\"PUBLIC\" specified without public ID; declaration terminated", 'E', 'D'}, -/* 118 */ {"\"%s\" keyword invalid (only %s permitted); declaration terminated", 'E', 'D'}, -/* 119 */ {"\"%s\" specified without notation name; declaration terminated", 'E', 'D'}, -/* 120 */ {"Parameter must be a name; declaration terminated", 'E', 'D'}, -/* 121 */ {"Parameter must be a GI or a group of them; declaration terminated", 'E', 'D'}, -/* 122 */ {"Parameter must be a name or PERO (%%); declaration terminated", 'E', 'D'}, -/* 123 */ {"Parameter must be a literal; declaration terminated", 'E', 'D'}, -/* 124 */ {"\"%s\" not valid short reference delimiter; declaration terminated", 'E', 'D'}, -/* 125 */ {"Map does not exist; declaration ignored", 'E', 'C'}, -/* 126 */ {"MDC delimiter (>) expected; following text may be misinterpreted", 'E', 'D'}, -/* 127 */ {"Document ended invalidly within prolog; parsing ended", 'C', 'S'}, -/* 128 */ {"\"PUBLIC\" or \"SYSTEM\" or DSO ([) required; declaration terminated", 'E', 'D'}, -/* 129 */ {"Minimization must be \"-\" or \"O\" (not \"%s\"); declaration terminated", 'E', 'D'}, -/* 130 */ {"Content model or keyword expected; declaration terminated", 'E', 'D'}, -/* 131 */ {"Rank stem \"%s\" + suffix \"%s\" more than NAMELEN characters; not defined", 'E', 'D'}, -/* 132 */ {"Undefined %s start-tag GI ignored; not used in DTD", 'E', 'C'}, -/* 133 */ {"Document ended invalidly within a markup declaration; parsing ended", 'C', 'S'}, -/* 134 */ {"Normalized length of literal exceeded %s; markup terminated", 'E', 'Q'}, -/* 135 */ {"R/CDATA marked section in declaration subset; prolog terminated", 'E', 'D'}, -/* 136 */ {"%s = \"%s\" ENTITIES attribute ignored: more than GRPCNT in list", 'E', 'Q'}, -/* 137 */ {"Content model is ambiguous", 'W', 'D'}, -/* 138 */ {"Invalid parameter entity name \"%s\"", 'E', 'S'}, -/* 139 */ {"Document ended invalidly within a marked section; parsing ended", 'C', 'S'}, -/* 140 */ {"Element \"%s\" used in DTD but not defined", 'I', 'D'}, -/* 141 */ {"Invalid NDATA or SUBDOC entity reference occurred; ignored", 'E', 'S'}, -/* 142 */ {"Associated element type not allowed in document instance", 'E', 'C'}, -/* 143 */ {"Illegal DSC character; in different entity from DSO", 'E', 'C'}, -/* 144 */ {"Declared value of data attribute cannot be ID", 'E', 'D' }, -/* 145 */ {"Invalid reference to external CDATA or SDATA entity; ignored", 'E', 'S'}, -/* 146 */ {"Could not find external document type \"%s\"", 'E', 'R'}, -/* 147 */ {"Could not find external general entity \"%s\"", 'I', 'R'}, -/* 148 */ {"Could not find external parameter entity \"%s\"", 'I', 'R'}, -/* 149 */ {"Reference to non-existent general entity \"%s\" ignored", 'E', 'R'}, -/* 150 */ {"Could not find entity \"%s\" using default declaration", 'E', 'R'}, -/* 151 */ {"Could not find entity \"%2$s\" in attribute %1$s using default declaration", 'E', 'R'}, -/* 152 */ {"Short reference map \"%s\" used in DTD but not defined", 'I', 'D'}, -/* 153 */ {"End-tag minimization should be \"O\" for element with CONREF attribute", 'I', 'D'}, -/* 154 */ {"Declared value of data attribute cannot be ENTITY or ENTITIES", 'E', 'D' }, -/* 155 */ {"Declared value of data attribute cannot be IDREF or IDREFS", 'E', 'D' }, -/* 156 */ {"Declared value of data attribute cannot be NOTATION", 'E', 'D' }, -/* 157 */ {"CURRENT cannot be specified for a data attribute", 'E', 'D' }, -/* 158 */ {"CONREF cannot be specified for a data attribute", 'E', 'D' }, -/* 159 */ {"Short reference map for element \"%s\" not defined; ignored", 'E', 'C'}, -/* 160 */ {"Cannot create temporary file", 'C', 'R'}, -/* 161 */ {"Document ended invalidly within SGML declaration", 'C', 'D'}, -/* 162 */ {"Capacity limit %s exceeded by %s points", 'W', 'Q'}, -/* 163 */ {"Amendment 1 requires \"ISO 8879:1986\" instead of \"ISO 8879-1986\"", 'W', 'D'}, -/* 164 */ {"Non-markup, non-minimum data character in SGML declaration", 'E', 'D'}, -/* 165 */ {"Parameter cannot be a literal", 'E', 'D'}, -/* 166 */ {"Invalid concrete syntax scope \"%s\"", 'E', 'D'}, -/* 167 */ {"Parameter must be a number", 'E', 'D'}, -/* 168 */ {"\"%s\" should have been \"%s\"", 'E', 'D'}, -/* 169 */ {"Character number %s is not supported as an additional name character", 'E', 'U'}, -/* 170 */ {"Parameter must be a literal or \"%s\"", 'E', 'D'}, -/* 171 */ {"Bad character description for character %s", 'E', 'D'}, -/* 172 */ {"Character number %s is described more than once", 'W', 'D'}, -/* 173 */ {"Character number plus number of characters exceeds 256", 'E', 'D'}, -/* 174 */ {"No description for upper half of character set: assuming \"128 128 UNUSED\"", 'W', 'D'}, -/* 175 */ {"Character number %s was not described; assuming UNUSED", 'E', 'D'}, -/* 176 */ {"Non-significant shunned character number %s not declared UNUSED", 'E', 'D'}, -/* 177 */ {"Significant character \"%s\" cannot be non-SGML", 'E', 'D'}, -/* 178 */ {"Unknown capacity set \"%s\"", 'E', 'U'}, -/* 179 */ {"No capacities specified." , 'E', 'D'}, -/* 180 */ {"Unknown concrete syntax \"%s\"", 'E', 'U'}, -/* 181 */ {"Character number exceeds 255", 'E', 'D'}, -/* 182 */ {"Concrete syntax SWITCHES not supported", 'E', 'U'}, -/* 183 */ {"\"INSTANCE\" scope not supported", 'E', 'U'}, -/* 184 */ {"Value of \"%s\" feature must be one or more", 'E', 'D'}, -/* 185 */ {"\"%s\" invalid; must be \"YES\" or \"NO\"", 'E', 'D'}, -/* 186 */ {"\"%s\" invalid; must be \"PUBLIC\" or \"SGMLREF\"", 'E', 'D'}, -/* 187 */ {"Feature \"%s\" is not supported", 'E', 'U'}, -/* 188 */ {"Too many open subdocument entities", 'E', 'Q'}, -/* 189 */ {"Invalid formal public identifier", 'I', 'D'}, -/* 190 */ {"Public text class should have been \"%s\"", 'I', 'D'}, -/* 191 */ {"Character number %s must be non-SGML", 'W', 'D'}, -/* 192 */ {"Notation \"%s\" not defined in DTD", 'W', 'D'}, -/* 193 */ {"Unclosed start or end tag requires \"SHORTTAG YES\"", 'W', 'M'}, -/* 194 */ {"Net-enabling start tag requires \"SHORTTAG YES\"", 'W', 'M'}, -/* 195 */ {"Attribute name omission requires \"SHORTTAG YES\"", 'W', 'M'}, -/* 196 */ {"Undelimited attribute value requires \"SHORTTAG YES\"", 'W', 'M'}, -/* 197 */ {"Attribute specification omitted for \"%s\": requires markup minimization", 'W', 'M'}, -/* 198 */ {"Concrete syntax does not have any short reference delimiters", 'E', 'D'}, -/* 199 */ {"Character number %s does not exist in the base character set", 'E', 'D'}, -/* 200 */ {"Character number %s is UNUSED in the syntax reference character set", 'E', 'D'}, -/* 201 */ {"Character number %s was not described in the syntax reference character set", 'E', 'D'}, -/* 202 */ {"Character number %s in the syntax reference character set has no corresponding character in the system character set", 'E', 'D'}, -/* 203 */ {"Character number %s was described using an unknown base set", 'E', 'D'}, -/* 204 */ {"Duplication specification for added funtion \"%s\"", 'E', 'D'}, -/* 205 */ {"Added function character cannot be \"%s\"", 'E', 'D'}, -/* 206 */ {"Only reference concrete syntax function characters supported", 'E', 'U'}, -/* 207 */ {"Only reference concrete syntax general delimiters supported", 'E', 'U'}, -/* 208 */ {"Only reference concrete syntax short reference delimiters supported", 'E', 'U'}, -/* 209 */ {"Unrecognized keyword \"%s\"", 'E', 'D'}, -/* 210 */ {"Unrecognized quantity name \"%s\"", 'E', 'D'}, -/* 211 */ {"Interpretation of \"%s\" is not a valid name in the declared concrete syntax", 'E', 'D'}, -/* 212 */ {"Replacement reserved name \"%s\" cannot be reference reserved name", 'E', 'D'}, -/* 213 */ {"Duplicate replacement reserved name \"%s\"", 'E', 'D'}, -/* 214 */ {"Quantity \"%s\" must not be less than %s", 'E', 'D'}, -/* 215 */ {"Only values up to %2$s are supported for quantity \"%1$s\"", 'E', 'U'}, -/* 216 */ {"Exclusions attempt to change required status of group in \"%s\"", 'E', 'C'}, -/* 217 */ {"Exclusion cannot apply to token \"%s\" in content model for \"%s\"", 'E', 'C'}, -/* 218 */ {"Required %s attribute was not specified for entity %s", 'E', 'C'}, -/* 219 */ {"UCNMSTRT must have the same number of characters as LCNMSTRT", 'E', 'D'}, -/* 220 */ {"UCNMCHAR must have the same number of characters as LCNMCHAR", 'E', 'D'}, -/* 221 */ {"Character number %s assigned to both LCNMSTRT or UCNMSTRT and LCNMCHAR or UCNMCHAR", 'E', 'D'}, -/* 222 */ {"Character number %s cannot be an additional name character", 'E', 'D'}, -/* 223 */ {"It is unsupported for \"-\" not to be assigned to UCNMCHAR or LCNMCHAR", 'E', 'U'}, -/* 224 */ {"Normalized length of value of attribute \"%s\" exceeded LITLEN", 'E', 'Q'}, -/* 225 */ {"Length of interpreted parameter literal exceeds LITLEN less the length of the bracketing delimiters", 'E', 'Q'}, -/* 226 */ {"Start tag of document element omitted; not minimizable", 'W', 'M'}, -/* 227 */ {"Unrecognized designating escape sequence \"%s\"", 'I', 'U'}, -/* 228 */ {"Earlier reference to entity \"%s\" used default entity", 'I', 'D'}, -/* 229 */ {"Reference to non-existent parameter entity \"%s\" ignored", 'E', 'R'}, -}; diff --git a/cde/programs/dtdocbook/sgmls/msgcat.c b/cde/programs/dtdocbook/sgmls/msgcat.c deleted file mode 100644 index f3a291c51..000000000 --- a/cde/programs/dtdocbook/sgmls/msgcat.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: msgcat.c /main/3 1996/06/19 17:16:22 drk $ */ -/* msgcat.c - - X/Open message catalogue functions and gencat utility. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifndef HAVE_CAT - -/* In this implementation the message catalogue format is the same as the -message text source file format (see pp 42-43 of the X/Open -Portability Guide, Issue 3, Volume 3.) This means that you don't have -to use the gencat utility, but it is still useful for checking and -merging catalogues. */ - -/* Compile this with -DGENCAT to get the gencat utility. */ - -#include "std.h" -#include "msgcat.h" - -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif - -/* Default message set. */ -#define NL_SETD 1 - -#ifndef PATH_FILE_SEP -#define PATH_FILE_SEP ':' -#endif - -#ifndef DEFAULT_NLSPATH -#define DEFAULT_NLSPATH "" -#endif - -#ifndef DEFAULT_LANG -#define DEFAULT_LANG "default" -#endif - -#define HASH_TAB_SIZE 251 - -struct message { - struct message *next; - unsigned msgnum; - unsigned setnum; - char *text; -}; - -struct cat { - char *name; - int loaded; - int bad; - struct message *table[HASH_TAB_SIZE]; -}; - -static char *read_buf = 0; -static unsigned read_buf_len = 0; - -/* Errors that can be generated by read_catalog. */ - -enum cat_err { - E_ZERO, /* not an error */ - E_BADARG, - E_NOMEM, - E_NOSUCHCOMMAND, - E_INPUT, - E_EOF, - E_BADSEP, - E_BADLINE -}; - -#ifdef GENCAT -/* These must match enum cat_err. */ -static char *cat_errlist[] = { - "Error 0", - "Invalid argument to command", - "Out of memory", - "Unrecognized command", - "Input error", - "Unexpected end of file", - "Space or tab expected after message number", - "Invalid line", -}; -#endif /* GENCAT */ - -#ifndef GENCAT -/* The value of NLSPATH. */ -static char *nlspath = 0; -/* The value of LANG. */ -static char *lang = 0; -#endif /* not GENCAT */ - -static int current_lineno = -1; -static enum cat_err cat_errno = E_ZERO; - -#ifndef GENCAT -static void load_catalog P((struct cat *)); -static FILE *find_catalog P((char *, char **)); -#endif -static int read_catalog P((FILE *, struct message **)); -static void delete_set P((struct message **, unsigned)); -static void delete_message P((struct message **, unsigned, unsigned)); -static int hash P((unsigned setnum, unsigned msgnum)); -static char *parse_text P((FILE *, int)); - -#ifndef GENCAT - -nl_catd catopen(name, oflag) -char *name; -int oflag; -{ - struct cat *catp; - int i; - - if (!name) - return 0; - - catp = (struct cat *)malloc(sizeof *catp); - if (!catp) - return 0; - for (i = 0; i < HASH_TAB_SIZE; i++) - catp->table[i] = 0; - catp->name = malloc(strlen(name) + 1); - catp->loaded = 0; - catp->bad = 0; - strcpy(catp->name, name); - return (nl_catd)catp; -} - -int catclose(catd) -nl_catd catd; -{ - int i; - struct cat *catp = (struct cat *)catd; - - if (!catp) - return 0; - - for (i = 0; i < HASH_TAB_SIZE; i++) { - struct message *p, *nextp; - for (p = catp->table[i]; p; p = nextp) { - nextp = p->next; - free(p->text); - free((char *)p); - } - } - if (catp->name) - free(catp->name); - free((char *)catp); - return 0; -} - -char *catgets(catd, setnum, msgnum, dflt) -nl_catd catd; -int setnum, msgnum; -char *dflt; -{ - struct message *p; - struct cat *catp; - - /* setnum and msgnum are required to be >= 1. */ - if (!catd || setnum <= 0 || msgnum <= 0) - return dflt; - catp = (struct cat *)catd; - if (!catp->loaded) - load_catalog(catp); - if (catp->bad) - return dflt; - for (p = catp->table[hash(setnum, msgnum)]; p; p = p->next) - if (p->msgnum == msgnum && p->setnum == setnum) - break; - if (!p) - return dflt; - return p->text; -} - -static -VOID load_catalog(catp) -struct cat *catp; -{ - FILE *fp; - char *path; - - catp->loaded = 1; - fp = find_catalog(catp->name, &path); - if (!fp) { - catp->bad = 1; - return; - } - current_lineno = 0; - if (read_catalog(fp, catp->table) < 0) - catp->bad = 1; - fclose(fp); - if (read_buf) { - free(read_buf); - read_buf = 0; - } - read_buf_len = 0; - free(path); -} - -static -FILE *find_catalog(name, pathp) -char *name; -char **pathp; -{ - char *path; - - if (!name) - return 0; - if (!nlspath) { - nlspath = getenv("NLSPATH"); - if (!nlspath) - nlspath = DEFAULT_NLSPATH; - } - if (!lang) { - lang = getenv("LANG"); - if (!lang) - lang = DEFAULT_LANG; - } - path = nlspath; - for (;;) { - char *p; - unsigned len = 0; - - for (p = path; *p != '\0' && *p != PATH_FILE_SEP; p++) { - if (*p == '%') { - if (p[1] == 'N') { - p++; - len += strlen(name); - } - else if (p[1] == 'L') { - p++; - len += strlen(lang); - } - else if (p[1] == '%') { - p++; - len++; - } - else - len++; - - } - else - len++; - } - if (len > 0) { - char *s, *try; - FILE *fp; - s = try = malloc(len + 1); - if (!s) - return 0; - for (p = path; *p != '\0' && *p != PATH_FILE_SEP; p++) { - if (*p == '%') { - if (p[1] == 'N') { - p++; - strcpy(s, name); - s += strlen(name); - } - else if (p[1] == 'L') { - p++; - strcpy(s, lang); - s += strlen(lang); - } - else if (p[1] == '%') { - p++; - *s++ = '%'; - } - else - *s++ = *p; - } - else - *s++ = *p; - } - *s++ = '\0'; - fp = fopen(try, "r"); - if (fp) { - *pathp = try; - return fp; - } - free(try); - } - if (*p == '\0') - break; - path = ++p; - } - return 0; -} - -#endif /* not GENCAT */ - -/* 0 success, -1 error */ - -static -int parse_message(c, fp, table, setnum, quote) -int c; -FILE *fp; -struct message **table; -unsigned setnum; -int quote; -{ - unsigned msgnum; - struct message *msgp; - char *text; - int hc; - - msgnum = c - '0'; - for (;;) { - c = getc(fp); - if (!isdigit(c)) - break; - msgnum = msgnum*10 + (c - '0'); - } - if (c == '\n') { - delete_message(table, setnum, msgnum); - return 0; - } - if (c != ' ' && c != '\t') { - cat_errno = E_BADSEP; - return -1; - } - text = parse_text(fp, quote); - if (!text) - return -1; - hc = hash(setnum, msgnum); - for (msgp = table[hc]; msgp; msgp = msgp->next) - if (msgp->setnum == setnum && msgp->msgnum == msgnum) - break; - if (msgp) - free(msgp->text); - else { - msgp = (struct message *)malloc(sizeof *msgp); - if (!msgp) { - cat_errno = E_NOMEM; - return -1; - } - msgp->next = table[hc]; - table[hc] = msgp; - msgp->msgnum = msgnum; - msgp->setnum = setnum; - } - msgp->text = text; - return 0; -} - -static -char *parse_text(fp, quote) -FILE *fp; -int quote; -{ - unsigned i = 0; - char *p; - int c; - int quoted; - - c = getc(fp); - if (c == quote) { - quoted = 1; - c = getc(fp); - } - else - quoted = 0; - for (;; c = getc(fp)) { - if (c == EOF) { - if (ferror(fp)) { - cat_errno = E_INPUT; - return 0; - } - break; - } - if (c == '\n') - break; - /* XXX - - Can quotes be used in quoted message text if protected by \ ? - - Is it illegal to omit the closing quote if there's an opening - quote? - - Is it illegal to have anything after a closing quote? - - */ - - if (quoted && c == quote) { - /* Skip the rest of the line. */ - while ((c = getc(fp)) != '\n') - if (c == EOF) { - if (ferror(fp)) { - cat_errno = E_INPUT; - return 0; - } - break; - } - break; - } - if (c == '\\') { - int d; - - c = getc(fp); - if (c == EOF) - break; - switch (c) { - case '\n': - current_lineno++; - continue; - case 'n': - c = '\n'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case 'r': - c = '\r'; - break; - case '\\': - c = '\\'; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c -= '0'; - d = getc(fp); - if (d >= '0' && d <= '7') { - c = c*8 + d - '0'; - d = getc(fp); - if (d >= '0' && d <= '7') - c = c*8 + d - '0'; - else if (d != EOF) - ungetc(d,fp); - } - else if (d != EOF) - ungetc(d, fp); - if (c == '\0') - continue; /* XXX */ - break; - default: - /* Ignore the quote. */ - break; - } - } - if (i >= read_buf_len) { - if (!read_buf) - read_buf = malloc(read_buf_len = 40); - else - read_buf = realloc(read_buf, read_buf_len *= 2); - if (!read_buf) { - cat_errno = E_NOMEM; - return 0; - } - } - read_buf[i++] = c; - } - p = malloc(i + 1); - if (!p) { - cat_errno = E_NOMEM; - return 0; - } - memcpy(p, read_buf, i); - p[i] = '\0'; - return p; -} - -/* 0 success, -1 error */ - -static -int parse_command(fp, table, setnump, quotep) -FILE *fp; -struct message **table; -unsigned *setnump; -int *quotep; -{ - char buf[128]; - if (fgets(buf, 128, fp) == NULL) { - cat_errno = ferror(fp) ? E_INPUT : E_EOF; - return -1; - } - if (buf[0] == ' ' || buf[0] == '\t' || buf[0] == '\n') - /* a comment */; - else if (strncmp(buf, "set", 3) == 0) { - if (sscanf(buf + 3, "%u", setnump) != 1) { - cat_errno = E_BADARG; - return -1; - } - - } - else if (strncmp(buf, "delset", 6) == 0) { - unsigned num; - if (sscanf(buf + 6, "%u", &num) != 1) { - cat_errno = E_BADARG; - return -1; - } - delete_set(table, num); - *setnump = NL_SETD; - } - else if (strncmp(buf, "quote", 5) == 0) { - char *p = buf + 5; - while (*p == ' ' || *p == '\t') - p++; - /* XXX should \ be allowed as the quote character? */ - if (*p == '\0' || *p == '\n') - *quotep = -1; - else - *quotep = *p; - } - else { - cat_errno = E_NOSUCHCOMMAND; - return -1; - } - if (strchr(buf, '\n') == 0) { - int c; - while ((c = getc(fp)) != '\n' && c != EOF) - ; - } - return 0; -} - - -static -VOID delete_set(table, setnum) -struct message **table; -unsigned setnum; -{ - int i; - - for (i = 0; i < HASH_TAB_SIZE; i++) { - struct message *p, *nextp; - for (p = table[i], table[i] = 0; p; p = nextp) { - nextp = p->next; - if (p->setnum == setnum) - free((char *)p); - else { - p->next = table[i]; - table[i] = p; - } - } - } -} - -static -VOID delete_message(table, setnum, msgnum) -struct message **table; -unsigned setnum, msgnum; -{ - struct message **pp; - - for (pp = &table[hash(setnum, msgnum)]; *pp; pp = &(*pp)->next) - if ((*pp)->setnum == setnum && (*pp)->msgnum == msgnum) { - struct message *p = *pp; - *pp = p->next; - free(p->text); - free((char *)p); - break; - } -} - -/* 0 success, -1 error. On error cat_errno is set to the error number. */ - -static -int read_catalog(fp, table) -FILE *fp; -struct message **table; -{ - int c; - unsigned setnum = NL_SETD; - int quote_char = -1; - - for (;;) { - /* start of line */ - c = getc(fp); - if (c == EOF) - break; - ++current_lineno; - if (isdigit(c)) { - if (parse_message(c, fp, table, setnum, quote_char) < 0) - return -1; - } - else if (c == '$') { - if (parse_command(fp, table, &setnum, "e_char) < 0) - return -1; - } - else if (c != '\n') { - while ((c = getc(fp)) != '\n' && c != EOF) - if (c != ' ' && c != '\t') { - cat_errno = E_BADLINE; - return -1; - } - if (c == EOF) - break; - } - } - return 0; -} - -static -int hash(setnum, msgnum) -unsigned setnum, msgnum; -{ - return ((setnum << 8) + msgnum) % HASH_TAB_SIZE; -} - -#ifdef GENCAT - -static char *program_name; - -static int message_compare P((UNIV, UNIV)); -static void print_text P((char *, FILE *)); -static void usage P((void)); - -#ifdef VARARGS -static void fatal(); -#else -static void fatal P((char *,...)); -#endif - -int main(argc, argv) -int argc; -char **argv; -{ - FILE *fp; - int i, j, nmessages; - struct message **list; - unsigned setnum; - struct message *table[HASH_TAB_SIZE]; - - program_name = argv[0]; - - if (argc < 3) - usage(); - - for (i = 0; i < HASH_TAB_SIZE; i++) - table[i] = 0; - for (i = 1; i < argc; i++) { - errno = 0; - fp = fopen(argv[i], "r"); - if (!fp) { - if (i > 1) - fatal("can't open `%s': %s", argv[i], strerror(errno)); - } - else { - current_lineno = 0; - cat_errno = E_ZERO; - if (read_catalog(fp, table) < 0) { - assert(cat_errno != E_ZERO); - assert(cat_errno - < sizeof(cat_errlist)/sizeof(cat_errlist[0])); - fatal("%s:%d: %s", argv[i], current_lineno, - cat_errlist[cat_errno]); - } - fclose(fp); - } - } - - errno = 0; - fp = fopen(argv[1], "w"); - if (!fp) - fatal("can't open `%s' for output: %s", argv[1], strerror(errno)); - nmessages = 0; - for (i = 0; i < HASH_TAB_SIZE; i++) { - struct message *p; - for (p = table[i]; p; p = p->next) - nmessages++; - } - list = (struct message **)malloc(nmessages*sizeof(struct message *)); - if (!list) - fatal("out of memory"); - j = 0; - for (i = 0; i < HASH_TAB_SIZE; i++) { - struct message *p; - for (p = table[i]; p; p = p->next) - list[j++] = p; - } - assert(j == nmessages); - - qsort((UNIV)list, nmessages, sizeof(struct message *), message_compare); - - setnum = NL_SETD; - for (i = 0; i < nmessages; i++) { - struct message *p = list[i]; - if (p->setnum != setnum) { - setnum = p->setnum; - fprintf(fp, "$set %u\n", setnum); - } - fprintf(fp, "%u ", p->msgnum); - print_text(p->text, fp); - putc('\n', fp); - } - if (fclose(fp) == EOF) - fatal("error closing `%s'", argv[1]); - return 0; -} - -static -VOID usage() -{ - fprintf(stderr, "usage: %s catfile msgfile...\n", program_name); - exit(1); -} - -static -#ifdef VARARGS -VOID fatal(va_alist) va_dcl -#else /* not VARARGS */ -VOID fatal(char *message,...) -#endif /* not VARARGS */ -{ - va_list ap; - -#ifdef VARARGS - char *message; - va_start(ap); - message = va_arg(ap, char *); -#else /* not VARARGS */ - va_start(ap, message); -#endif /* not VARARGS */ - - fprintf(stderr, "%s: ", program_name); - vfprintf(stderr, message, ap); - putc('\n', stderr); - va_end(ap); - exit(1); -} - -static -int message_compare(p1, p2) -UNIV p1, UNIV p2; -{ - struct message *m1 = *(struct message **)p1; - struct message *m2 = *(struct message **)p2; - - if (m1->setnum < m2->setnum) - return -1; - if (m1->setnum > m2->setnum) - return 1; - if (m1->msgnum < m2->msgnum) - return -1; - if (m1->msgnum > m2->msgnum) - return 1; - return 0; -} - -static -VOID print_text(s, fp) -char *s; -FILE *fp; -{ - for (; *s; s++) { - if (*s == '\\') - fputs("\\\\", fp); - else if (ISASCII(*s) && isprint((UNCH)*s)) - putc(*s, fp); - else { - switch (*s) { - case '\n': - fputs("\\n", fp); - break; - case '\b': - fputs("\\b", fp); - break; - case '\f': - fputs("\\f", fp); - break; - case '\t': - fputs("\\t", fp); - break; - case '\v': - fputs("\\v", fp); - break; - case '\r': - fputs("\\r", fp); - break; - default: - fprintf(fp, "\\%03o", (unsigned char)*s); - break; - } - } - } -} - -#endif /* GENCAT */ - -#ifdef TEST - -int main(argc, argv) -int argc; -char **argv; -{ - nl_catd catd; - int msgnum, setnum; - - if (argc != 2) { - fprintf(stderr, "usage: %s catalogue\n", argv[0]); - exit(1); - } - catd = catopen(argv[1], 0); - fprintf(stderr, "Enter set number, message number pairs:\n"); - fflush(stderr); - while (scanf("%d %d", &setnum, &msgnum) == 2) { - char *msg = catgets(catd, setnum, msgnum, ""); - fprintf(stderr, "Returned \"%s\"\n", msg); - fflush(stderr); - } - return 0; -} - -#endif /* TEST */ - -#endif /* not HAVE_CAT */ -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/msgcat.h b/cde/programs/dtdocbook/sgmls/msgcat.h deleted file mode 100644 index c625ec069..000000000 --- a/cde/programs/dtdocbook/sgmls/msgcat.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: msgcat.h /main/3 1996/06/19 17:16:27 drk $ */ - -#ifdef HAVE_CAT -#include -#else -typedef UNIV nl_catd; -#endif - -/* Don't use prototypes here in case nl_types.h declares a conflicting -prototype. */ - -nl_catd catopen(); -int catclose(); -char *catgets(); diff --git a/cde/programs/dtdocbook/sgmls/pars1.c b/cde/programs/dtdocbook/sgmls/pars1.c deleted file mode 100644 index ccfb16d24..000000000 --- a/cde/programs/dtdocbook/sgmls/pars1.c +++ /dev/null @@ -1,981 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: pars1.c /main/3 1996/06/19 17:16:31 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -#define GI (tags[ts].tetd->etdgi+1) /* GI of current element. */ -#define NEWGI (newetd->etdgi+1) /* GI of new tag. */ - -static VOID doincludes P((void)); -static int pentname P((char *)); -static struct mpos *newmpos P((void)); -static VOID commbufs P((void)); -static VOID checkdtd P((void)); - -/* PARSECON: Parse content of an element. -*/ -int parsecon(tbuf, pcb) -UNCH *tbuf; /* Work area for tokenization. */ -struct parse *pcb; /* Parse control block for this parse. */ -{ - int srn; /* SHORTREF delimiter number (1-32). */ - int refrc; /* Return code from sentref, stagetd, etc. */ - - TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq); - if (eodsw) return(EOD_); - if (didreq && (conrefsw & TAGREF)) {didreq = 0; goto conr;} - if (etagimct>0) {etagimsw = --etagimct ? 1 : 0; destack(); return(ETG_);} - if (dostag) { - conrefsw = conrefsv; - etisw = etiswsv; - if (charmode) {dostag = 0; return datarc;} - return stag(datarc); - } - if (conrefsw) { - conr: - destack(); - conrefsw = 0; - return ETG_; - } - else if (eofsw) return(EOD_); - - datarc = 0; - while (1) { - parse(pcb); - srn = (int)pcb->action - SRMIN; /* Just in case it's a SHORTREF. */ - switch (pcb->action) { - case DCE_: /* Data character in element content. */ - /* The data character might be a non-SGML character so - reprocess it using pcbconm. */ - REPEATCC; - pcb = conpcb = &pcbconm; - pcb->newstate = pcbcnet; - continue; - case DAS_: /* Current character begins data. */ - data = FPOS; - continue; - - case NLF_: /* NET or SR returns data in lookahead buffer. */ - datalen = (UNS)(ptcon - data); REPEATCC; - goto rcc; - - case LAF_: /* Return data in lookahead buffer: mixed. */ - datalen = (UNS)(ptcon+1 - data); - goto rcc; - - case NON_: /* Single nonchar in nonchbuf. */ - datalen = 2; data = nonchbuf; - goto nrcc; - - case DAR_: /* Return data except for last char. */ - REPEATCC; - case DAF_: /* Return data in source entity buffer. */ - datalen = (UNS)(FPOS - data); - rcc: - REPEATCC; - case DEF_: /* Return data in data entity. */ - nrcc: - datarc = DAF_; - if (pcb==&pcbcone) { - pcbconm.newstate = pcbcnet; - conpcb = &pcbconm; - } - if (charmode) return(datarc); - stagmin = MINNONE; stagreal = newetd = ETDCDATA; - return(stag(datarc)); - - case LAS_: /* Start lookahead buffer with current char. */ - *(ptcon = data = tbuf+1) = *FPOS; - continue; - - case LAM_: /* Move character to lookahead buffer. */ - *++ptcon = *FPOS; - continue; - - case STG_: /* Process non-null start-tag. */ - CTRSET(tagctr); /* Start counting tag length. */ - parsenm(tbuf, NAMECASE); /* Get the GI. */ - newetd = etdref(tbuf); - if (newetd && newetd->adl) { - parseatt(newetd->adl, tbuf); - adlval((int)ADN(al), newetd); - } - parsetag(&pcbstag); /* Parse the tag ending. */ - if ((CTRGET(tagctr)-tagdelsw)>=TAGLEN) - sgmlerr(66, &pcbstag, (UNCH *)0, (UNCH *)0); - if (!newetd) { - sgmlerr(132, pcb, tbuf+1, (UNCH *)0); - continue; - } - return(stagetd(&pcbstag)); - - case NST_: /* Process null start-tag. */ - return nstetd(); - - case ETC_: /* End-tag in CDATA or RCDATA. */ - case ETG_: /* Process non-null end-tag. */ - newetd = etdref(parsenm(tbuf, NAMECASE)); /* Get the GI. */ - parsetag(&pcbetag); /* Parse tag end. */ - if (!newetd) /* Error: undefined.*/ - sgmlerr(11, &pcbetag, tbuf+1, (UNCH *)0); - else if (etagetd(&pcbetag)>=0) return ETG_;/* Open element. */ - if (pcb->action!=ETC_) continue; - /* Tag is undefined or not for an open element and we are in - a CDATA or RCDATA element; issue message and treat as - null end-tag (). - */ - sgmlerr(57, &pcbetag, (UNCH *)0, (UNCH *)0); - case NET_: /* Process null end-tag. */ - if ((refrc = netetd(conpcb))!=0) return ETG_; - continue; - - case NED_: /* Process null end-tag delimiter. */ - etagmin = MINNET; - newetd = etagreal = ETDNET; - etagimct = etag(); - etagimsw = etagimct ? 1 : 0; destack(); - return ETG_; - case GTR_: - if (entget()!=-1) { - data = FPOS; - continue; - } - /* fall through */ - case EOD_: /* End of primary file. */ - if (ts<1) return(EOD_); /* Normal end: stack is empty. */ - etagimct = ts-1; /* Treat as end-tag for top tag on stack. */ - etagmin = MINETAG; etagreal = tags[0].tetd; - destack(); - eofsw = 1; /* Return EOD_ after destacking all. */ - return ETG_; - - /* Short references ending with blanks: - If the blank sequence is followed by RE, go do SR7 or SR6. - If the entity is undefined and we are in mixed content, - the blanks must be returned as data. If not, they - can be ignored. - */ - case SR9_: /* Process SR9 (two or more blanks). */ - REPEATCC; /* Make first blank the CC. */ - case SR4_: /* Process SR4 (RS, blanks). */ - parseseq(tbuf, BSEQLEN); /* Squeeze out all blanks. */ - if (*FPOS=='\r') {srn = (srn==9) ? 7 : 6; data = tbuf; goto sr6;} - else REPEATCC; - if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc; - if (refrc>0) return refrc; - if (refrc==ENTUNDEF && pcb==&pcbconm) - {data = tbuf; goto nrcc;} - continue; - - /* Short references ending with RE: - If the reference is defined, the RE is ignored. - For RE and RS RE, - no special action is needed if the reference is undefined, - as the RE will be processed immediately as the current character. - For B RE and RS B RE, - the input is primed with a special character that will - be treated as an RE that cannot be a short reference. - */ - case SR7_: /* Process SR7 (blanks, RE). */ - datalen = (UNS)(FPOS - data); - case SR2_: /* Process SR2 (RE). */ - case SR5_: /* Process SR5 (RS, RE). */ - sr6: /* Process SR6 (RS, blanks, RE). */ - if ((refrc = shortref(srn, pcb))!=ENTUNDEF) { - if (refrc==DEF_) goto nrcc; /* Defined: data entity. */ - if (refrc>0) return refrc; /* Defined: tag entity. */ - continue; /* Defined: not tag. */ - } - if (pcb!=&pcbconm) continue; /* Not mixed; ignore chars. */ - if (srn>=6) /* Return blanks as data. */ - {*FPOS = lex.d.genre; REPEATCC; goto nrcc;} - case REF_: /* Undefined SR with RE; return record end. */ - datarc = REF_; - if (charmode) return(datarc); -#if 0 - /* The standard says this situation can force a tag. - See 323:3-6, 412:1-7. */ - /* If RE would be ignored, don't treat it as start-tag - because it could force a required tag; but do change - state to show that an RE was ignored. - */ - if (scbsgml[pss].snext==scbsgmst) { - scbsgml[pss].snext = scbsgmnr; - TRACEGML(scbsgml, pss, conactsw, conact); - continue; - } -#endif - stagmin = MINNONE; stagreal = newetd = ETDCDATA; - return(stag(datarc)); - - case SR3_: /* Process SR3 (RS). */ - REPEATCC; - if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc; - if (refrc>0) return refrc; - continue; - - case RBR_: /* Two right brackets */ - srn = 26; - REPEATCC; - /* fall through */ - case SR1_: /* Process SR1 (TAB). */ - case SR8_: /* Process SR8 (space). */ - case SR19: /* Process SR19 (-). */ - case SR26: /* Process SR26 (]). */ - REPEATCC; - goto srproc; - - case FCE_: /* Process free character (SR11-18, SR21-32). */ - fce[0] = *FPOS; - srn = mapsrch(&lex.s.dtb[lex.s.fce], fce); - case SR10: /* Process SR10 ("). */ - case SR11: /* Process SR11 (#). */ - case SR20: /* Process SR20 (-). */ - case SR25: /* Process SR25 ([). */ - srproc: - if ((refrc = shortref(srn, pcb))==DEF_) goto nrcc; - if (refrc>0) return refrc; - if (refrc==ENTUNDEF) { /* Treat the SR as data. */ - data = FPOS - (srn==lex.s.hyp2);/* Two data chars if SR20.*/ - if (pcb!=&pcbconm) { /* If not in mixed content: */ - if (srn>=lex.s.data) { /* Change PCB. */ - pcb = conpcb = &pcbconm; - pcb->newstate = pcbcnda; - } - } - else pcb->newstate = pcbcnda;/* Now in data found state. */ - } - continue; - - case ERX_: /* Entity ref in RCDATA: cancel ending delims.*/ - lexcon[lex.d.tago] = lex.l.fre; - lexcon[lex.d.net] = lex.l.nonet; - lexlms[lex.d.msc] = lex.l.fre; - continue; - - case EE_: /* Entity end in RCDATA: check nesting. */ - if (esaction; /* Default (MD_ MDC_ MSS_ MSE_ PIS_). */ - } - } -} -/* STAGETD: Process start-tag etd. -*/ -int stagetd(pcb) -struct parse *pcb; /* Parse control block for this parse. */ -{ - if (!newetd->etdmod) { - sgmlerr(43, pcb, newetd->etdgi+1, (UNCH *)0); - ++ds.etdercnt; - etdset(newetd, (UNCH)SMO+EMO+ETDOCC, &undechdr, - (PETD *)0, (PETD *)0, (PECB *)0); - TRACEETD(newetd); - } - stagmin = MINNONE; stagreal = newetd; - return stag(0); -} -/* NSTETD: Process null start-tag etd. -*/ -int nstetd() -{ - newetd = ts>0 ? tags[ts].tetd - : tags[0].tetd->etdmod[2].tu.thetd; - stagmin = MINNULL; stagreal = ETDNULL; - etisw = 0; - return stag(0); -} -/* ETAGETD: Process end-tag etd. -*/ -int etagetd(pcb) -struct parse *pcb; /* Parse control block for this parse. */ -{ - etagmin = MINNONE; etagreal = newetd; - if ((etagimct = etag())<0) { - sgmlerr(E_ETAG, pcb, NEWGI, tags[ts].tetd->etdgi+1); - return etagimct; - } - etagimsw = etagimct ? 1 : 0; destack(); - return ETG_; -} -/* NETETD: Process null end-tag etd. -*/ -int netetd(pcb) -struct parse *pcb; /* Parse control block for this parse. */ -{ - if (ts<1) { - sgmlerr(51, pcb, (UNCH *)0, (UNCH *)0); - return 0; - } - etagmin = MINNULL; etagreal = ETDNULL; - etagimsw = 0; destack(); - return ETG_; -} -/* SHORTREF: Process a short (alternative) reference to an entity. - Returns ENTUNDEF if entity is not defined, otherwise returns - the return code from stagetd or etagetd if the entity was - a tag, or zero if an error occurred somewhere. -*/ -int shortref(srn, pcb) -int srn; /* Short reference number. */ -struct parse *pcb; /* Parse control block for this parse. */ -{ - int rc; /* Return code from entopen. */ - - if (tags[ts].tsrm==SRMNULL || !tags[ts].tsrm[srn]) return ENTUNDEF; - if (!tags[ts].tsrm[srn]->estore) { - sgmlerr(93, pcb, tags[ts].tsrm[srn]->ename+1, - tags[ts].tsrm[0]->ename+1); - return(ENTUNDEF); - } - rc = entopen(tags[ts].tsrm[srn]); - if (rc==ENTDATA) return DEF_; - if (rc==ENTPI) return PIS_; - return(0); -} -/* PARSEPRO: Parse prolog. - Note: ptpro cannot overrun tbuf (and therefore needn't be - tested), as long as the buffer exceeds the longest - lookahead sequence in the content parse tables. -*/ -int parsepro() -{ - struct parse *oldpcb; - - while (1) { - int rc; /* Return code: DAF MSS DCE */ - switch (parse(propcb)) { - - case LAS_: /* Start lookahead buffer with current char. */ - *(ptpro = data = tbuf+1) = *FPOS; - continue; - case LAM_: /* Move character to lookahead buffer. */ - *++ptpro = *FPOS; - continue; - case LAF_: /* Return data in lookahead buffer. */ - datalen = (UNS)(ptpro+1 - data); - REPEATCC; - rc = DAF_; - break; /* Prolog ended; data pending. */ - - case DTD_: /* Process document type declaration. */ - parsenm(tbuf, NAMECASE); /* Get declaration name. */ - if (!ustrcmp(tbuf+1, sgmlkey) - && !dtdsw && !sgmlsw++) { -#if 0 - parse(&pcbmdi); -#endif - /* If we got some appinfo, return. */ - if (sgmldecl()) - return APP_; - continue; - } - if (!ustrcmp(tbuf+1, key[KDOCTYPE]) && !dtdsw++) { - startdtd(); - mddtds(tbuf); - continue; - } - sgmlerr(E_MDNAME, propcb, tbuf+1, (UNCH *)0); - continue; - case DTE_: /* DOCTYPE declaration (and prolog) ended. */ - REPEATCC; /* Put back char that followed MSC. */ - if (es != 0) - sgmlerr(143, propcb, (UNCH *)0, (UNCH *)0); - else if (dtdrefsw) {/* Process referenced DTD before real DTE. */ - dtdrefsw = 0; /* Keep us from coming through here again. */ - REPEATCC; /* Put back MSC so it follows referenced DTD. */ - entref(indtdent); - } - else mddtde(tbuf); - continue; - - case MD_: - /* Process markup declaration within DTD or LPD. */ - parsenm(tbuf, NAMECASE); /* Get declaration name. */ - if (!ustrcmp(tbuf+1, key[KENTITY])) - mdentity(tbuf); - else if (!ustrcmp(tbuf+1, key[KUSEMAP])) - mdsrmuse(tbuf); - else if (!ustrcmp(tbuf+1, key[KATTLIST])) - mdadl(tbuf); - else if (!ustrcmp(tbuf+1, key[KSHORTREF])) - mdsrmdef(tbuf); - else if (!ustrcmp(tbuf+1, key[KELEMENT])) - mdelem(tbuf); - else if (!ustrcmp(tbuf+1, key[KNOTATION])) - mdnot(tbuf); - else - sgmlerr(E_MDNAME, propcb, tbuf+1, (UNCH *)0); - continue; - case MDC_: /* Process markup declaration comment. */ - sgmlsw++; /* SGML declaration not allowed after comment */ - parsemd(tbuf, NAMECASE, (struct parse *)0, NAMELEN); - continue; - - case MSS_: /* Process marked section start. */ - oldpcb = propcb; - propcb = mdms(tbuf, propcb); - if (propcb==&pcbmsc || propcb==&pcbmsrc) { - if (oldpcb == &pcbmds) - sgmlerr(135, oldpcb, (UNCH *)0, (UNCH *)0); - conpcb = propcb; - rc = DCE_; - break; - } - continue; - case MSE_: /* Process marked section end. */ - if (mdmse()) propcb = &pcbmds; - continue; - case MSP_: /* Marked section start in prolog outside DTD */ - rc = MSS_; - break; - case PIE_: /* PI entity: same as PIS_. */ - return(PIS_); - - case EOD_: /* Return end of primary entity. */ - if (!sw.onlypro || propcb != &pcbpro || !dtdsw) - sgmlerr(127, propcb, (UNCH *)0, (UNCH *)0); - else { - setdtype(); - checkdtd(); - } - return propcb->action; - case PIS_: /* Return processing instruction (string). */ - sgmlsw++; /* SGML declaration not allowed after PI */ - return((int)propcb->action); /* Prolog will continue later. */ - - case CIR_: /* Chars ignored; trying to resume parse. */ - synerr(E_RESTART, propcb); - REPEATCC; - continue; - case STE_: /* Start tag ended prolog */ - REPEATCC; - REPEATCC; - rc = STE_; - break; - case PEP_: /* Previous character ended prolog. */ - REPEATCC; - case DCE_: /* Data character ended prolog. */ - REPEATCC; - rc = DCE_; - break; - case EE_: /* Illegal entity end in ignored marked section. */ - /* An error message has already been given. */ - continue; - default: - abort(); - } /* switch */ - setdtype(); /* First pass only: set document type. */ - checkdtd(); - if (sw.onlypro) - return EOD_; - TRACESET(); /* Set trace switches. */ - endprolog(); - /* *DOC is first element; stack it at level 0. */ - stack(newetd = nextetd = stagreal = etagreal = docetd); - return(rc); - } /* while */ -} - -/* Allocate buffers that are used in the DTD. */ - -VOID startdtd() -{ - nmgrp = (struct etd **)rmalloc((GRPCNT+1)*sizeof(struct etd *)); - nnmgrp = (PDCB *)rmalloc((GRPCNT+1)*sizeof(PDCB)); - gbuf = (struct thdr *)rmalloc((GRPGTCNT+3)*sizeof(struct thdr)); - /* The extra 1 is for parsing the name of a parameter entity in - mdentity(). */ - nmbuf = (UNCH *)rmalloc(NAMELEN+3); - pubibuf = (UNCH *)rmalloc(LITLEN+1); - sysibuf = (UNCH *)rmalloc(LITLEN+1); - commbufs(); - doincludes(); -} - -static -VOID checkdtd() -{ - struct dcncb *np; - - if (sw.swundef) { - int i; - struct etd *ep; - struct srh *sp; - - for (i = 0; i < ETDHASH; i++) - for (ep = etdtab[i]; ep; ep = ep->etdnext) - if (!ep->etdmod) - sgmlerr(140, (struct parse *)0, ep->etdgi + 1, - (UNCH *)0); - for (sp = srhtab[0]; sp; sp = sp->enext) - if (sp->srhsrm[0] == 0) - sgmlerr(152, (struct parse *)0, sp->ename + 1, - (UNCH *)0); - } - for (np = dcntab[0]; np; np = np->enext) - if (!np->defined) - sgmlerr(192, (struct parse *)0, np->ename + 1, (UNCH *)0); -} - -/* Return non-zero if s is a valid parameter entity name. -If so put a transformed name in entbuf. */ - -static -int pentname(s) -char *s; -{ - int i; - if (lextoke[(UNCH)*s] != NMS) - return 0; - entbuf[2] = ENTCASE ? lextran[(UNCH)*s] : (UNCH)*s; - for (i = 1; s[i]; i++) { - if (i > NAMELEN - 1) - return 0; - if (lextoke[(UNCH)s[i]] < NMC || s[i] == EOBCHAR) - return 0; - entbuf[i + 2] = ENTCASE ? lextran[(UNCH)s[i]] : (UNCH)s[i]; - } - entbuf[1] = lex.d.pero; - entbuf[i + 2] = '\0'; - entbuf[0] = (UNCH)(i + 3); /* length byte, PERO and '\0' */ - return 1; -} - -/* Handle sw.includes. */ - -static -VOID doincludes() -{ - char **p; - if (!sw.includes) - return; - for (p = sw.includes; *p; p++) { - if (pentname(*p)) { - if (!entfind(entbuf)) { - union etext etx; - etx.c = savestr(key[KINCLUDE]); - entdef(entbuf, ESM, &etx); - ++ds.ecbcnt; - ds.ecbtext += ustrlen(key[KINCLUDE]); - } - } - else - sgmlerr(138, (struct parse *)0, (UNCH *)*p, (UNCH *)0); - } -} - -/* Allocate buffers that are use both in the DTD and the instance. */ - -static -VOID commbufs() -{ - al = (struct ad *)rmalloc((ATTCNT+2)*sizeof(struct ad)); - lbuf = (UNCH *)rmalloc(LITLEN + 1); -} - -static -struct mpos *newmpos() -{ - int j; - unsigned long *h; - struct mpos *p = (struct mpos *)rmalloc((GRPLVL+2)*sizeof(struct mpos)); - - assert(grplongs > 0); - h = (unsigned long *)rmalloc((GRPLVL+2)*grplongs*sizeof(unsigned long)); - for (j = 0; j < GRPLVL+2; j++) { - p[j].h = h; - h += grplongs; - } - return p; -} - -/* Perform end of prolog buffer allocation. */ - -VOID endprolog() -{ - int i; - - ambigfree(); - if (dtdsw) { - frem((UNIV)nmgrp); - frem((UNIV)nnmgrp); - frem((UNIV)gbuf); - frem((UNIV)nmbuf); - frem((UNIV)sysibuf); - frem((UNIV)pubibuf); - } - else { - commbufs(); - doincludes(); - } - scbsgml = (struct restate *)rmalloc((TAGLVL+1)*sizeof(struct restate)); - tags = (struct tag *)rmalloc((TAGLVL+1)*sizeof(struct tag)); - grplongs = (GRPCNT + LONGBITS - 1)/LONGBITS; - for (i = 0; i < TAGLVL+1; i++) - tags[i].tpos = newmpos(); - savedpos = newmpos(); -} - -/* SETDTYPE: Establish specified or default document type. -*/ -VOID setdtype() -{ - /* Initialize default model hdr for declared content. */ - undechdr.ttype = MANY+MCHARS+MGI; /* Declared content is ANY. */ - undechdr.tu.tnum = 0; /* No content model. */ - - /* Initialize content model and etd for *DOC. */ - prcon[0].ttype = MGI; /* Model is an element model. */ - prcon[0].tu.tnum = 2; /* A single group with a single GI in it. */ - prcon[1].ttype = TTSEQ; /* Non-repeatable SEQ group. */ - prcon[1].tu.tnum = 1; /* Only one token in group. */ - prcon[2].ttype = TTETD; /* Token is an etd. */ - docetd = etddef(indocetd); /* etd for document as a whole. */ - etdset(docetd, ETDOCC, prcon, (PETD *)0, (PETD *)0, SRMNULL); - - /* Put specified or default document type etd in *DOC model. */ - if (!dtype) { - sgmlerr(E_DOCTYPE, propcb, (UNCH *)0, (UNCH *)0); - dtype = indefetd; - } - prcon[2].tu.thetd = etddef(dtype); - if (!prcon[2].tu.thetd->etdmod) { - if (dtype != indefetd) - sgmlerr(52, propcb, dtype+1, (UNCH *)0); - ++ds.etdercnt; - etdset(prcon[2].tu.thetd, (UNCH)SMO+EMO+ETDUSED+ETDOCC, &undechdr, - (PETD *)0, (PETD *)0, (PECB *)0); - } - TRACEETD(docetd); - TRACEMOD(prcon); - TRACEETD(prcon[2].tu.thetd); - return; -} -/* PARSETAG: Tag end parser for SGML documents. - For start-tags, it - sets etisw to TAGNET if tag ended with ETI; otherwise to 0. -*/ -VOID parsetag(pcb) -struct parse *pcb; /* Parse control block: pcbstag or pcbetag. */ -{ - tagdelsw = 1; /* Assume tag had an ETI or TAGC. */ - switch (parse(pcb)) { - case ETIC: /* Tag closed with ETI. */ - if (!sd.shorttag) synerr(194, pcb); - etisw = TAGNET; /* Set switch for stack entry flag. */ - return; - case DSC: - synerr(9, pcb); - REPEATCC; - etisw = 0; - return; - case NVS: /* Att name or value token found. */ - case NTV: /* Name token value found. */ - synerr(E_POSSATT, pcb); - pcb->newstate = 0; /* Reset parse state. */ - REPEATCC; /* Put it back for next read. */ - tagdelsw = 0; /* Tag had no closing delimiter. */ - etisw = 0; /* Don't flag stack entry. */ - return; - case TAGO: /* Tag closing implied by TAGO. */ - if (!sd.shorttag) synerr(193, pcb); - REPEATCC; /* Put it back for next read. */ - tagdelsw = 0; /* Tag had no closing delimiter. */ - case TAGC: /* Normal close. */ - default: /* Invalid character (msg was sent). */ - etisw = 0; /* Don't flag stack entry. */ - return; - } -} -/* STAG: Check whether a start-tag is valid at this point in the document - structure, or whether other tags must precede it. - Special case processing is done for the fake tag, #CDATA, as - it is never stacked. -*/ -int stag(dataret) -int dataret; /* Data pending: DAF_ REF_ 0=not #PCDATA. */ -{ - int rc, realrc; /* Return code from context or other test. */ - int mexts = 0; /* >0=stack level of minus grp; -1=plus; 0=none.*/ - - badresw = pexsw = 0; - /* If real element (i.e., not #PCDATA) set mexts and test if empty. */ - if (dataret==0) { - mexts = pexmex(newetd); - /* If element is declared empty, it is same as a conref. */ - if (GET(newetd->etdmod->ttype, MNONE)) conrefsw = TAGREF; - } - if (GET(tags[ts].tetd->etdmod->ttype, MANY)) - rc = mexts>0 ? RCMEX : RCHIT; - else rc = context(newetd, tags[ts].tetd->etdmod, tags[ts].tpos, - &tags[ts].status, mexts); - TRACESTG(newetd, dataret, rc, nextetd, mexts); - - switch (rc) { - case RCEND: /* End current element, then retry start-tag. */ - if (ts<1) realrc = RCMISS; - else realrc = RCEND; - break; - case RCREQ: /* Stack compulsory GI, then retry start-tag. */ - realrc = RCREQ; - break; - case RCMISS: /* Start-tag invalid (#PCDATA or real). */ - if (ts>0 && GET(tags[ts].tetd->etdmod->ttype, MANY)) - realrc = RCEND; - else realrc = RCMISS; - break; - case RCMEX: /* Start-tag invalid (minus exception). */ - etagimct = ts - mexts; - realrc = RCEND; - break; - case RCHITMEX: /* Invalid minus exclusion for required element. */ -#if 0 /* This will have been detected by exclude.c. */ - sgmlerr(E_MEXERR, &pcbstag, NEWGI, tags[mexts].tetd->etdgi+1); -#endif - case RCHIT: /* Start-tag was valid. */ - realrc = RCHIT; - break; - case RCPEX: /* Start-tag valid only because of plus exception. */ - pexsw = TAGPEX; - realrc = RCHIT; - break; - default: - abort(); - } - - switch (realrc) { - case RCEND: /* End current element, then retry start-tag. */ - if (didreq) sgmlerr(07, &pcbstag, nextetd->etdgi+1, (UNCH *)0); - didreq = 0; /* No required start-tag done. */ - dostag = 1; etiswsv = etisw; /* Save real start-tag status. */ - conrefsv = conrefsw; /* Save real start-tag conref. */ - conrefsw = 0; /* Current element is not empty. */ - etagmin = MINSTAG; destack(); /* Process omitted end-tag. */ - return ETG_; - case RCREQ: /* Stack compulsory GI, then retry start-tag. */ - if (!BADPTR(nextetd)) { -#if 0 /* This will have been detected in exclude.c. */ - if ((mexts = pexmex(nextetd))>0) - sgmlerr(E_MEXERR, &pcbstag, nextetd->etdgi+1, - tags[mexts].tetd->etdgi+1); -#endif - if (!nextetd->etdmod) { - sgmlerr(53, &pcbstag, nextetd->etdgi+1, (UNCH *)0); - etdset(nextetd, (UNCH)SMO+EMO+ETDOCC, &undechdr, - (PETD *)0, (PETD *)0, (PECB *)0); - ++ds.etdercnt; - TRACEETD(nextetd); - } - } - if (BITOFF(nextetd->etdmin, SMO)) { - if (!BADPTR(stagreal)) - sgmlerr(21, &pcbstag, nextetd->etdgi+1, stagreal->etdgi+1); - else if (stagreal==ETDCDATA) - sgmlerr(49, &pcbstag, nextetd->etdgi+1, (UNCH *)0); - else sgmlerr(50, &pcbstag, nextetd->etdgi+1, (UNCH *)0); - } - didreq = 1; /* Required start-tag done. */ - dostag = 1; etiswsv = etisw; /* Save real start-tag status. */ - etisw = 0; conrefsv = conrefsw; /* Save real start-tag conref. */ - /* If element is declared empty, it is same as a conref. */ - conrefsw = (GET(nextetd->etdmod->ttype, MNONE)) ? TAGREF : 0; - stack(nextetd); /* Process omitted start-tag. */ - return STG_; - case RCMISS: /* Start-tag invalid (#PCDATA or actual). */ - dostag = 0; contersw |= 1; didreq = 0; - if (dataret) { - if (dataret==REF_) badresw = 1; - else sgmlerr(E_CHARS, conpcb, tags[ts].tetd->etdgi+1, (UNCH *)0); - return dataret; - } - sgmlerr(E_CONTEXT, &pcbstag, NEWGI, tags[ts].tetd->etdgi+1); - if (stagmin!=MINNULL) stagmin = MINNONE; stack(newetd); - return STG_; - case RCHIT: /* Start-tag was valid. */ - dostag = 0; didreq = 0; - if (dataret) return dataret; - stack(newetd); - return STG_; - } - return NOP_; /* To avoid Borland C++ warning */ -} -/* PEXMEX: See if a GI is in a plus or minus exception group on the stack. - If in a minus, returns stack level of minus group; otherwise, - returns -1 if in a plus and not a minus, and zero if in neither. -*/ -int pexmex(curetd) -struct etd *curetd; /* The etd for this GI. */ -{ - int tsl; /* Temporary stack level for looping. */ - int pex = 0; /* 1=found in plus grp; 0=not. */ - - for (tsl = ts; tsl>0; --tsl) { - if (tags[tsl].tetd->etdmex && ingrp(tags[tsl].tetd->etdmex, curetd)) - return(tsl); - if (tags[tsl].tetd->etdpex && ingrp(tags[tsl].tetd->etdpex, curetd)) - pex = -1; - } - return(pex); -} -/* STACK: Add a new entry to the tag stack. - If there is no room, issue a message and reuse last position. -*/ -VOID stack(curetd) -struct etd *curetd; /* The etd for this entry. */ -{ - /* Stack the new element type definition (error if no room). */ - if (++ts>TAGLVL) - sgmlerr(E_STAGMAX, conpcb, curetd->etdgi+1, tags[--ts].tetd->etdgi+1); - tags[ts].tetd = curetd; - - /* Set flags: plus exception + tag had ETI + context error + empty. */ - tags[ts].tflags = (UNCH)pexsw + etisw + contersw + conrefsw; contersw = 0; - - /* If tag had ETI, update ETI counter and enable NET if first ETI. */ - if (etisw && ++etictr==1) lexcon[lex.d.net] = lexcnm[lex.d.net] = lex.l.net; - - /* If etd has ALT table, use it; otherwise, use last element's ALT. */ - if (curetd->etdsrm) { - if (curetd->etdsrm != SRMNULL && curetd->etdsrm[0] == NULL) { - /* Map hasn't been defined. Ignore it. */ - sgmlerr(159, &pcbstag, curetd->etdgi + 1, (UNCH *)0); - curetd->etdsrm = 0; - tags[ts].tsrm = tags[ts-1].tsrm; - } - else - tags[ts].tsrm = curetd->etdsrm; - } - else - tags[ts].tsrm = tags[ts-1].tsrm; - - /* Initialize rest of stack entry. */ - tags[ts].status = 0; - tags[ts].tpos[0].g = 1; /* M: Index in model of next token to test.*/ - tags[ts].tpos[0].t = 1; /* P: Index in tpos of current group. */ - HITCLEAR(tags[ts].tpos[0].h); - tags[ts].tpos[1].g = 1; /* Index of group in model (dummy grp). */ - tags[ts].tpos[1].t = 1; /* 1st token is next in grp to be tested. */ - HITCLEAR(tags[ts].tpos[1].h); /* No hits yet as yet. */ - TRACESTK(&tags[ts], ts, etictr); - - exclude(); - return; -} -/* ETAG: Check validity of an end-tag by seeing if it matches any tag - on the stack. If so, return the offset of the match from the - current entry (0=current). If there is no match, issue a message - and return an error code (-1). - If the newetd is ETDNET, a NET delimiter was found, so check for - a tag that ended with ETI instead of a matching GI. -*/ -int etag() -{ - int tsl = ts+1; /* Temporary stack level for looping. */ - - /* See if end-tag is anywhere on stack, starting at current entry. */ - while (--tsl) { - if (newetd!=ETDNET ? newetd==tags[tsl].tetd : tags[tsl].tflags) { - TRACEETG(&tags[ts], newetd, tsl, ts-tsl); - return(ts-tsl); - } - } - return (-1); /* End-tag didn't match any start-tag. */ -} -/* DESTACK: - Call ECONTEXT to see if element can be ended at this point. - and issue message if there are required tags left. - Remove the current entry from the tag stack. - Issue an error if the destacked element was not minimizable - and its end-tag was omitted. -*/ -VOID destack() -{ - int ecode = 0; /* Error code (0=o.k.). */ - UNCH *eparm2 = NULL; /* Second parameter of error message. */ - int minmsgsw; /* 1=message if tag omitted; 0=no message. */ - - /* If element has a content model (i.e., not a keyword) and there - are required tags left, and no CONREF attribute was specified, - issue an error message. - */ - if (!GET(tags[ts].tetd->etdmod->ttype, MKEYWORD) - && !conrefsw - && !econtext(tags[ts].tetd->etdmod, tags[ts].tpos, &tags[ts].status)) { - if (BADPTR(nextetd)) - sgmlerr(54, conpcb, tags[ts].tetd->etdgi+1, (UNCH *)0); - else - sgmlerr(30, conpcb, tags[ts].tetd->etdgi+1, nextetd->etdgi+1); - } - /* If the current tag ended with ETI, decrement the etictr. - If etictr is now zero, disable the NET delimiter. - */ - if (GET(tags[ts--].tflags, TAGNET) && --etictr==0) - lexcon[lex.d.net] = lexcnm[lex.d.net] = lex.l.nonet; - - minmsgsw = BITOFF(tags[ts+1].tetd->etdmin, EMO); - if (!conrefsw && minmsgsw && (etagimsw || etagmin==MINETAG)) { - /* Minimization caused by NET delimiter. */ - if (BADPTR(etagreal)) ecode = 46; - /* Minimization caused by a containing end-tag. */ - else {ecode = 20; eparm2 = etagreal->etdgi+1;} - } - else if (!conrefsw && etagmin==MINSTAG && (minmsgsw || ts<=0)) { - /* Minimization caused by out-of-context start-tag. */ - if (!BADPTR(stagreal)) { - ecode = ts>0 ? 39 : 89; - eparm2 = stagreal->etdgi+1; - } - /* Minimization caused by out-of-context data. */ - else if (stagreal==ETDCDATA) ecode = ts>0 ? 47 : 95; - /* Minimization caused by out-of-context short start-tag. */ - else ecode = ts>0 ? 48 : 96; - if (ts<=0 && ecode) eodsw = 1; - } - if (ecode) sgmlerr((UNS)ecode, conpcb, tags[ts+1].tetd->etdgi+1, eparm2); - /* TEMP: See if parser bug caused stack to go below zero. */ - else if (ts<0) {sgmlerr(64, conpcb, (UNCH *)0, (UNCH *)0); ts = 0;} - TRACEDSK(&tags[ts], &tags[ts+1], ts, etictr); -} -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/pars2.c b/cde/programs/dtdocbook/sgmls/pars2.c deleted file mode 100644 index 83cb9d505..000000000 --- a/cde/programs/dtdocbook/sgmls/pars2.c +++ /dev/null @@ -1,1331 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: pars2.c /main/3 1996/06/19 17:16:36 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -/* PARSE: Parse a source input stream with specified lexical and state tables. - Return to caller with action code. -*/ -int parse(pcb) -struct parse *pcb; /* Current parse control block. */ -{ - int rc; /* Return code from ENTREF. */ - - while (1) { - NEWCC; - pcb->input = pcb->plex[*FPOS]; - pcb->state = pcb->newstate; - pcb->newstate = (*(pcb->ptab + pcb->state)) [pcb->input]; - pcb->action = (*(pcb->ptab + pcb->state + 1)) [pcb->input]; - TRACEPCB(pcb); - switch (pcb->action) { - case RC2_: /* Back up two characters. */ - REPEATCC; - case RCC_: /* Repeat current character. */ - REPEATCC; - case NOP_: /* No action necessary.*/ - continue; - - case RS_: /* Record start: ccnt=0; ++rcnt.*/ - ++RCNT; CTRSET(RSCC); - continue; - - case GET_: /* EOB or dull EOS or EE found: keep going.*/ - if (entget()==-1) {pcb->action = EOD_; break;}/* Signal if EOD.*/ - continue; - - case EOF_: /* Illegal entity end; return EE_. */ - synerr(E_EOF, pcb); - pcb->action = EE_; - case EE_: /* Important EOS or EE found: return to caller.*/ - if (entget()==-1) pcb->action = EOD_; /* Signal if EOD. */ - break; - - case PER_: /* Parameter entity reference. */ - REPEATCC; /* Use PERO as 1st char of entity name. */ - parsenm(entbuf, ENTCASE); - parse(&pcbref); /* Handle REFC or other terminator. */ - rc = entref(entbuf); - if (rc==ENTPI) {pcb->action = PIE_; break;} - continue; - - case ER_: /* General entity reference; continue. */ - parsenm(entbuf, ENTCASE); - parse(&pcbref); /* Handle REFC or other terminator. */ - rc = entref(entbuf); - if (rc==ENTDATA) {pcb->action = DEF_; break;} - if (rc==ENTPI) {pcb->action = PIE_; break;} - continue; - - - case PEX_: /* Parameter entity reference; return. */ - REPEATCC; /* Use PERO as 1st char of entity name. */ - case ERX_: /* General entity reference; return. */ - parsenm(entbuf, ENTCASE); - parse(&pcbref); /* Handle REFC or other terminator. */ - rc = entref(entbuf); - if (rc == ENTDATA){ - /* Reference to external data/subdoc entity in replaceable - character data. */ - if (BITON(entdatsw, NDECONT)) { - switch (((PNE)data)->nextype) { - case ESNCDATA: - case ESNSDATA: - /* The standard says `non-SGML data entity' - but the amendment should have changed it - to `external data entity'. */ - synerr(145, pcb); - break; - case ESNNDATA: - case ESNSUB: - /* This is definitely illegal. */ - synerr(141, pcb); - break; - } - entdatsw = 0; - continue; - } - pcb->action = DEF_; - } - else if (rc == ENTPI) { - /* Reference to PI entity not allowed in replaceable - character data. */ - synerr(59, pcb); - entpisw = 0; - continue; - } - else if (rc) pcb->action = EE_; - break; - - case CRN_: /* Character reference: numeric. */ - parsetkn(entbuf, NU, NAMELEN); - parse(&pcbref); /* Handle reference terminator. */ - pcb->action = charrefn(entbuf, pcb); - if (pcb->action==CRN_) continue; /* Invalid reference */ - break; - - case CRA_: /* Character reference: alphabetic. */ - parsenm(entbuf, NAMECASE); - parse(&pcbref); /* Handle reference terminator. */ - charrefa(entbuf); - continue; - - case SYS_: /* Invalid NONCHAR: send msg and ignore. */ - synerr(E_SYS, pcb); - if (*FPOS == DELNONCH) NEWCC; - continue; - - case NON_: /* Valid NONCHAR: prefix and shift encoding. */ - synerr(60, pcb); - pcb->action = datachar(*FPOS, pcb); - break; - case NSC_: - synerr(60, pcb); - NEWCC; - nonchbuf[1] = *FPOS; - pcb->action = NON_; - break; - case PCI_: /* Previous character was invalid (INV_). */ - REPEATCC; - case INV_: /* Markup ended by invalid char; repeat char. */ - synerr(9, pcb); - REPEATCC; - break; - - case LNR_: /* Previous char exceeded len; back up to it. */ - REPEATCC; - case LEN_: /* Token too long; ignore excess character. */ - synerr(3, pcb); - continue; - - case RCR_: /* Repeat current char and return to caller. */ - REPEATCC; - default: /* Actions for specific parse. */ - break; - } - return (int)pcb->action; - } -} -/* CHARREFA: Resolve an alphabetical reference to a function character - and put the character in the read buffer. - If reference is bad, issue an error message. -*/ -VOID charrefa(r) -UNCH *r; /* Undelimited char ref (with length and EOS). */ -{ - UNCH thechar; - - thechar = mapsrch(funtab, r+1); - if (thechar == 0) - synerr(62, &pcbref); - else { - /* This isn't ideal, because the character position will still - be wrong for one line. */ - if (thechar == RSCHAR) RCNT--; - setcurchar(thechar); - REPEATCC; - } -} - -/* Make the current character ch. */ - -VOID setcurchar(ch) -int ch; -{ - /* If we're reading directly from an internal entity, we can't - change the entity, since the entity might be referenced again. - So in this case we copy the entity. This is inefficient, but - it will only happen in a case like this: - - - - - Usually character references will have been processed while the - entity was being defined. */ - if (*FPOS != ch) { - if (!FILESW && !COPIEDSW) { - UNCH *s = savestr(FBUF + 1); - FPOS = s + (FPOS - FBUF - 1); - FBUF = s - 1; - COPIEDSW = 1; - } - *FPOS = ch; - } -} - -/* CHARREFN: Resolve a numeric character reference. - If reference is bad, issue an error message. -*/ - -int charrefn(r, pcb) -UNCH *r; /* Undelimited character reference. */ -struct parse *pcb; /* Current parse control block. */ -{ - int thechar; - - thechar = atoi((char *)r); - if (thechar<0 || thechar>255) { - synerr(61, &pcbref); - return((int)pcb->action); - } - return datachar(thechar, pcb); -} - -/* Return ch as a datachar. If this a non-SGML character which might -confuse the parser, shift it to a code that won't and place it in a -special buffer which has DELNONCH in the preceding byte. Otherwise -put it the read buffer. */ - -int datachar(ch, pcb) -int ch; -struct parse *pcb; -{ - switch (ch) { - case EOS: - case EOFCHAR: - case EOBCHAR: - case GENRECHAR: - case DELCDATA: - case DELSDATA: - case DELNONCH: - /* A potentially confusing character which must be prefixed - with DELNONCH. */ - nonchbuf[1] = SHIFTNON((UNCH)ch); - return NON_; - } - setcurchar(ch); - /* If in content, return DCE_ for element content, DAF_ for mixed. */ - /* If not content, it must be a literal parse, so return MLA_. */ - if (pcb == conpcb) { - if (pcb == &pcbcone) - return DCE_; - else { - data = FPOS; - /* Action for DAF_ will do REPEATCC. */ - NEWCC; - return DAF_; - } - } - else - return MLA_; -} -/* INITATT: Initialize al with adl. */ - -VOID initatt(adl) -struct ad *adl; -{ - notadn = 0; /* No NOTATION attribute yet. */ - conrefsw = 0; /* Assume no content reference att. */ - /* Copy attribute definition list as a template. */ - memcpy((UNIV)al, (UNIV)adl, (1+ADN(adl))*ADSZ); -} - -/* PARSEATT: Parse attribute specification list. - Make a current copy of the attribute definition list - and update it with the user's specifications. - Indicate each attribute that was specified in the - list (as opposed to defaulted) by setting the ASPEC flag. - If no attributes were specified, return NULL. Otherwise, - if in the prolog, make a permanent copy of the list and - return its pointer. If not in the prolog, return al. -*/ -struct ad *parseatt(adl, pt) -struct ad *adl; /* Attribute definition list. */ -UNCH *pt; /* Tokenization area: tbuf[TAGLEN+ATTSPLEN]. */ -{ - UNCH *antvptr; - UNCH *nm = 0; /* Pointer to saved name in tbuf (with length). */ - int adn = -1; /* Position of attribute in list (-1=empty). */ - UNCH *tbuflim = pt + ATTSPLEN; - mdessv = es; /* Save es for checking entity nesting. */ - initatt(adl); - while (pt<=tbuflim) { - parse(&pcbstag); - switch (pcbstag.action) { - case NVS: /* Att name or value token found. */ - parsenm(pt, NAMECASE); /* Case translation wanted on name. */ - pt += *(nm = pt); /* Save name while pointing past it. */ - continue; - - case AVD: /* Delimited value found. */ - case AVDA: /* Delimited value found (alternate delimiter). */ - /* Find position (adn) of saved attribute name in list. */ - adn = anmget((int)ADN(al), nm); - parselit(pt, - (adn == 0 || ADTYPE(al, adn) == ACHARS) - ? &pcblitr - : &pcblitt, - LITLEN, - (pcbstag.action==AVD) ? lex.d.lit : lex.d.lita); - if (adn == 0) { - /* Error: unrecognized attribute name. */ - sgmlerr(13, &pcbstag, nm+1, pt); - continue; - } - /* Tokenize and validate value; let it default if an error. */ - /* Put value in list and bump ptr by the normalized length - (which is always >= the actual length). */ - if (!attval(1, pt, adn, adl)) pt += ADLEN(al,adn); - continue; - case AVU: /* Attribute value found: undelimited. */ - if (!sd.shorttag) sgmlerr(196, &pcbstag, (UNCH *)0, (UNCH *)0); - parsetkn(pt, NMC, LITLEN); - /* Find position (adn) of saved attribute name in list. */ - if ((adn = anmget((int)ADN(al), nm))==0) { - /* Error: unrecognized attribute name. */ - sgmlerr(13, &pcbstag, nm+1, pt); - continue; - } - /* Tokenize and validate value; let it default if an error. */ - /* Put value in list and bump ptr by the normalized length - (which is always >= the actual length). */ - if (!attval(1, pt, adn, adl)) pt += ADLEN(al,adn); - continue; - - case NASV: /* Saved NVS was really an NTV. */ - REPEATCC; /* Put back next token starter. */ - pt = nm; /* Back up to NVS. */ - case NTV: /* Name token value found. */ - if (!sd.shorttag) sgmlerr(195, &pcbstag, (UNCH *)0, (UNCH *)0); - if (pcbstag.action==NTV) parsenm(pt, NAMECASE); - if ((adn = antvget((int)ADN(al), pt, &antvptr))==0) { - /* Error: unrecognized name token value. */ - sgmlerr(74, &pcbstag, pt+1, (UNCH *)0); - continue; - } - /* Validate value; let it default if an error. */ - /* Put value in list and bump ptr by the normalized length - (which is always >= the actual length). */ - if (!attval(0, antvptr+1, adn, adl)) pt += ADLEN(al,adn); - continue; - - default: /* All attributes have been parsed. */ - REPEATCC; /* Put next char back for tag close parse. */ - break; - } - break; - } - if (pt>tbuflim) synerr(75, &pcbstag); - if (es!=mdessv) synerr(37, &pcbstag); - if (adn<0) return((struct ad *)0); /* List was empty. */ - TRACEADL(al); - return al; -} -/* ATTVAL: Validate a specified attribute value. Issue a message if it is - the wrong type (or otherwise is not up to spec), and use the default. - Call PARSEVAL to tokenize the value, unless it is a CDATA string. - If the attribute is a group, the value is a string. - For other types, the token count is set by PARSEVAL if the value - is syntactically correct. If incorrect (or if CDATA) the token - count is zero (i.e., the value is a string). - The length of a token does not include the length byte, and - there is no EOS. A string length (as always) includes both - the length byte and the EOS. - If it is a CONREF attribute, set a switch for STAG(). - If it is a CURRENT attribute, store the value as the new default. -*/ -#define DEFVAL adl[adn].addef /* Default value of current attribute. */ -#define DEFNUM adl[adn].adnum /* Default group size of current attribute. */ -#define DEFLEN adl[adn].adlen /* Length of default value of current attribute.*/ -int attval(mtvsw, adval, adn, adl) -int mtvsw; /* Must tokenize value: 1=yes; 0=no. */ -UNCH *adval; /* Untokenized attribute value. */ -int adn; /* Attribute's position in list. */ -struct ad *adl; /* Element's master att def list. */ -{ - int errcode; /* Value/declaration conflict error code. */ - - if (GET(ADFLAGS(al,adn), ASPEC)) /* Can't respecify same attribute. */ - {sgmlerr(73, &pcbstag, ADNAME(al,adn), adval); return(1);} - SET(ADFLAGS(al,adn), ASPEC); /* Indicate att was specified. */ - if (GET(ADFLAGS(al,adn), ACONREF)) /* If attribute is content reference: */ - conrefsw = TAGREF; /* Set switch for STAG(). */ - if (mtvsw && ADTYPE(al,adn)!=ACHARS) { - /* If no syntax errors, check for proper group membership. */ - if ( ((errcode = parseval(adval, ADTYPE(al,adn), lbuf))==0) - && GET(ADFLAGS(al,adn), AGROUP) - && !amemget(&al[adn], ADNUM(al,adn), lbuf) ) errcode = 18; - /* If syntax or group membership error, send message and exit. */ - if (errcode) { - sgmlerr(errcode, &pcbstag, ADNAME(al,adn), adval); - SET(ADFLAGS(al,adn), AERROR); - return(1); - } - /* Replace specified value in adval with tokenized in lbuf. */ - ustrcpy(adval, lbuf); - if (BITOFF(ADFLAGS(al,adn), AGROUP)) ADNUM(al,adn) = (UNCH)tokencnt; - } - if (!mtvsw) - adval--; - /* If attribute is FIXED, specified value must equal default. */ - if (BITON(ADFLAGS(al,adn), AFIXED) && ustrcmp(adval, DEFVAL)) { - /* Since the value has been tokenized, don't use it in the - error message. */ - sgmlerr(67, &pcbstag, ADNAME(al,adn), (UNCH *)0); - SET(ADFLAGS(al,adn), AERROR); - return(1); - } - ADLEN(al,adn) = vallen(ADTYPE(al,adn), ADNUM(al,adn), adval); - if (ADLEN(al,adn) > LITLEN) { - sgmlerr(224, &pcbstag, ADNAME(al,adn), (UNCH *)0); - SET(ADFLAGS(al,adn), AERROR); - return 1; - } - ADVAL(al,adn) = adval; - /* If attribute is CURRENT, value is new default.*/ - if (GET(ADFLAGS(al,adn), ACURRENT)) { - if (ADLEN(al,adn)>DEFLEN) { - ds.attdef += (ADLEN(al,adn) - DEFLEN); - DEFLEN = ADLEN(al,adn); - } - DEFVAL = replace(DEFVAL, ADVAL(al,adn)); - DEFNUM = ADNUM(al,adn); - } - return(0); /* Indicate value was valid. */ -} -/* ADLVAL: Validate the completed attribute definition list (defaults plus - specified values). Issue a message if an - attribute is required or current and its value is NULL. -*/ -VOID adlval(adsz, newetd) -int adsz; /* Size of list. */ -struct etd *newetd; /* Element type definition for this element. */ -{ - int adn = 1; /* Position in list. */ - UNCH *npt, *pt; /* Ptr save areas. */ - UNCH nptsv; /* Save area for ptr value (length?). */ - struct dcncb *dpt; /* Save area for dcncb ptr. */ - - aentctr = 0; /* Number of AENTITY tokens in this att list. */ - idrctr = 0; /* Number of IDREF tokens in this att list. */ - do { - if (ADVAL(al,adn)==NULL) { /* NULL value */ - if (GET(ADFLAGS(al,adn), AREQ+ACURRENT)) { /*Error if REQ, CURRENT*/ - sgmlerr(19, &pcbstag, ADNAME(al,adn), (UNCH *)0); - SET(ADFLAGS(al,adn), AINVALID); - } - } - else switch (ADTYPE(al,adn)) { - case AENTITY: /* Return data ecb pointer if valid entity. */ - aenttst(adn, ADVAL(al,adn)); - break; - case AENTITYS: /* Return data ecb pointers if valid entities. */ - pt = ADVAL(al,adn); - tokencnt = (int)ADNUM(al,adn); - while (tokencnt--) { - nptsv = *(npt = pt + *pt+1); - *pt += 2; *npt = EOS; - aenttst(adn, pt); - *pt -= 2; *(pt = npt) = nptsv; - } - break; - case AID: - /* Define ID; msg if it already exists. */ - if (iddef(ADVAL(al,adn))) { - sgmlerr(71, &pcbstag, ADNAME(al,adn), ADVAL(al,adn)+1); - SET(ADFLAGS(al,adn), AINVALID); - continue; - } - ++ds.idcnt; - break; - case AIDREF: - idreftst(adn, ADVAL(al,adn)); - break; - case AIDREFS: - pt = ADVAL(al,adn); - tokencnt = (int)ADNUM(al,adn); - while (tokencnt--) { - nptsv = *(npt = pt + *pt+1); - *pt += 2; *npt = EOS; - idreftst(adn, pt); - *pt -= 2; *(pt = npt) = nptsv; - } - break; - case ANOTEGRP: /* Return notation identifier. */ - if (GET(ADFLAGS(al,adn), ASPEC)) notadn = adn;/*NOTATION specified*/ - if ((dpt = dcnfind(ADVAL(al,adn)))==0) { - sgmlerr(77, &pcbstag, ADNAME(al,adn), ADVAL(al,adn)+1); - SET(ADFLAGS(al,adn), AINVALID); - } - else ADDATA(al,adn).x = dpt; - break; - } - if (!sd.shorttag && !sd.omittag && ADVAL(al,adn)!=NULL - && !GET(ADFLAGS(al,adn), ASPEC+AINVALID)) - sgmlerr(197, &pcbstag, ADNAME(al,adn), (UNCH *)0); - } while ((adn+=BITON(ADFLAGS(al,adn),AGROUP) ? (int)ADNUM(al,adn)+1 : 1)<=adsz); - - /* Error if NOTATION specified with CONREF attribute or EMPTY element. */ - if (notadn && (conrefsw - || (newetd && GET(newetd->etdmod->ttype, MNONE)))) { - sgmlerr((UNS)(conrefsw ? 84 : 76), &pcbstag, - ADNAME(al,notadn), ADVAL(al,notadn)+1); - SET(ADFLAGS(al,notadn), AINVALID); - } -} -/* AENTTST: Validate an individual ENTITY token in AENTITY or AENTITYS value. -*/ -VOID aenttst(adn, pt) -int adn; /* Position in list. */ -UNCH *pt; /* Ptr to current ENTITY token in value. */ -{ - struct entity *ept; /* Save area for ecb ptr. */ - - if (++aentctr>GRPCNT) { - sgmlerr(136, &pcbstag, ADNAME(al,adn), pt+1); - SET(ADFLAGS(al,adn), AINVALID); - return; - } - if ( (ept = entfind(pt))==0 - && (ecbdeflt==0 || (ept = usedef(pt))==0) ) { - sgmlerr(ecbdeflt ? 151 : 72, &pcbstag, ADNAME(al,adn), pt+1); - SET(ADFLAGS(al,adn), AINVALID); - return; - } - if (ept->estore==ESX || ept->estore==ESC || ept->estore==ESN) { - /* Error if DCN has no notation identifier. */ - if (ept->estore==ESN && NEXTYPE(ept->etx.n)!=ESNSUB - && !NEDCNDEFINED(ept->etx.n)) { - sgmlerr(78, &pcbstag, NEDCN(ept->etx.n)+1, - pt+1); - SET(ADFLAGS(al,adn), AINVALID); - } - } - else { - sgmlerr(86, &pcbstag, ADNAME(al,adn), pt+1); - SET(ADFLAGS(al,adn), AINVALID); - } -} -/* IDREFTST: Validate an individual IDREF token in an IDREF or IDREFS value. -*/ -VOID idreftst(adn, pt) -int adn; /* Position in list. */ -UNCH *pt; /* Ptr to current IDREF token in value. */ -{ - struct fwdref *rp; - if (++idrctr>GRPCNT) { - sgmlerr(70, &pcbstag, ADNAME(al,adn), pt+1); - SET(ADFLAGS(al,adn), AINVALID); - return; - } - /* Note IDREF; indicate if ID exists. */ - if ((rp = idref(pt)) != 0) - rp->msg = saverr(69, &pcbstag, ADNAME(al,adn), pt+1); - ++ds.idrcnt; -} -/* ANMGET: Locate an attribute name in an attribute definition list. -*/ -int anmget(adsz, nm) -int adsz; /* Size of list. */ -UNCH *nm; /* Value to be found (with length byte). */ -{ - int adn = 0; /* Position in list. */ - - while (++adn <= adsz && ustrcmp(nm+1, ADNAME(al,adn))) { - if (BITON(ADFLAGS(al,adn), AGROUP)) adn += (int)ADNUM(al,adn); - } - return (adn > adsz) ? 0 : adn; -} -/* ANTVGET: Find the position of a name token value in an attribute list. - Return the position of the attribute definition, or zero - if none was found. Set pp to the value, if non-NULL. -*/ -int antvget(adsz, nm, pp) -int adsz; /* Size of list. */ -UNCH *nm; /* Value to be found (with length byte). */ -UNCH **pp; /* Store value here */ -{ - int adn = 0; /* Position in list. */ - - while (++adn<=adsz) { - /* Test only name group members. */ - if (BITON(ADFLAGS(al,adn), AGROUP)) { - int advn; /* Position of value in sub-list. */ - if ((advn = amemget(&al[adn], (int)ADNUM(al,adn), nm))!=0) { - if (pp) - *pp = al[adn+advn].adname; - return adn; - } - adn += (int)ADNUM(al,adn); - } - } - return 0; -} -/* AMEMGET: Get the position of a member in an attribute name token group. - Returns the position, or zero if not found. - The length byte is ignored in the comparison so that final - form tokens from ATTVAL can be compared to group members. -*/ -int amemget(anmtgrp, adsz, nm) -struct ad anmtgrp[]; /* Name token group. */ -int adsz; /* Size of group. */ -UNCH *nm; /* Name to be found (with length byte). */ -{ - int adn = 0; /* Position in group. */ - - while ( ++adn<=adsz && ustrncmp(nm+1, anmtgrp[adn].adname+1, (UNS)*nm-1)) ; - return (adn>adsz) ? 0 : adn; -} -/* VALLEN: Returns the length of an attribute value for capacity - calculations. Normally, the length is NORMSEP plus the number - of characters. For tokenized lists, it is NORMSEP, - plus the number of characters in the tokens, plus - NORMSEP for each token. - ACHARS and tokenized lists don't have a length byte. - -*/ -UNS vallen(type, num, def) -int type; /* ADTYPE(al,adn) */ -int num; /* ADNUM(al,adn) */ -UNCH *def; /* ADVAL(al,adn) */ -{ - if (type == ACHARS) - return ustrlen(def) + NORMSEP; - if (type < ATKNLIST) - return *def - 2 + NORMSEP; - return ustrlen(def) + num * (NORMSEP - 1) + NORMSEP; -} -/* PARSEGRP: Parse GI names, get their etds, and form an array of pointers - to them. The array is terminated by a NULL pointer. - The number of pointers (including the NULL) is returned. - The grp buffer must have room for GRPCNT+1 etds. -*/ -UNS parsegrp(grp, pcb, tbuf) -struct etd *grp[]; /* Buffer for building the group. */ -struct parse *pcb; /* Current parse control block. */ -UNCH *tbuf; -{ - int grpcnt = 0; /* Number of etds in the group. */ - int i; - int essv = es; /* Entity stack level when grp started. */ - - while (parse(pcb)!=GRPE && grpcntaction) { - case NAS_: /* GI name: get its etd for the group. */ - grp[grpcnt] = etddef(parsenm(tbuf, NAMECASE)); - for (i = 0; i < grpcnt; i++) - if (grp[i] == grp[grpcnt]) { - mderr(98, ntoa(grpcnt + 1), grp[grpcnt]->etdgi + 1); - break; - } - if (i == grpcnt) - grpcnt++; - continue; - - case EE_: /* Entity ended (correctly or incorrectly). */ - if (esaction) { - case NAS_: /* Member name: get its control block. */ - grp[grpcnt] = dcndef(parsenm(tbuf, NAMECASE)); - for (i = 0; i < grpcnt; i++) - if (grp[i] == grp[grpcnt]) { - mderr(98, ntoa(grpcnt + 1), grp[grpcnt]->ename + 1); - break; - } - if (i == grpcnt) - grpcnt++; - continue; - - case EE_: /* Entity ended (correctly or incorrectly). */ - if (es=0 && pcb->action!=TER_); - - if (parmlen<0) {--pt; sgmlerr(134, pcb, ntoa((int)maxlen),(UNCH *)0); REPEATCC;} - datalen = (UNS)(pt-tbuf);/* To return PI string to text processor. */ - *pt++ = EOS; - lexlms[del] = lexsv; /* Restore normal delimiter handling. */ - if (es!=essv) synerr(37, pcb); - return; -} - -/* Handle a data entity in a tokenized attribute value literal. -Parmlen is amount of space left. Return new parmlen. If there's not -enough space return -1, and copy up to parmlen + 1 characters. */ - -int tokdata(pt, parmlen) -UNCH *pt; -int parmlen; -{ - int skip = (pcblitt.newstate == 0); - int i; - - for (i = 0; parmlen >= 0 && i < datalen; i++) { - switch (data[i]) { - case RSCHAR: - /* ignore it */ - break; - case RECHAR: - case TABCHAR: - case SPCCHAR: - if (!skip) { - *pt++ = data[i]; - parmlen--; - skip = 1; - } - break; - default: - if (data[i] == DELNONCH) { - assert(i + 1 < datalen); - if ((parmlen -= 2) < 0) - break; - *pt++ = DELNONCH; - *pt++ = data[++i]; - skip = 0; - } - else { - *pt++ = data[i]; - parmlen--; - skip = 0; - } - break; - } - } - pcblitt.newstate = skip ? 0 : pcblittda; - return parmlen; -} - - -/* PARSEMD: Parser for markup declarations. - It returns a token each time it is called. - -*/ -int parsemd(pt, namecase, lpcb, tokenlen) -UNCH *pt; /* Token buffer: >=tokenlen+2. */ -int namecase; /* Case translation: ENTCASE NAMECASE AVALCASE. */ -struct parse *lpcb; /* Parse control block for literal parse. */ -UNS tokenlen; /* Max length of expected token: NAMELEN LITLEN */ -{ - struct parse *pcb; /* Current parse control block. */ - - pcb = (lpcb) ? &pcbmd : &pcbmdc; /* If no literal pcb, dcl is comment. */ - - doparse: while (parse(pcb)==EE_) - if (esaction==PIE_) { /* PI entity reference not allowed. */ - entpisw = 0; /* Reset PI entity indicator. */ - synerr(59, pcb); - goto doparse; - } - ++parmno; /* Increment parameter counter. */ - switch (pcb->action) { - case CDR: /* COM[1] (MINUS) occurred previously. */ - REPEATCC; - return (int)pcb->action; - case LIT: /* Literal: CDATA with LIT delimiter. */ - parselit(pt, lpcb, tokenlen, lex.d.lit); - return (int)pcb->action; - case LITE: /* Literal: CDATA with LITA delimiter. */ - parselit(pt, lpcb, tokenlen, lex.d.lita); - return((int)(pcb->action = LIT)); - case RNS: /* Reserved name started (after RNI). */ - parsenm(pt, NAMECASE); - return (int)pcb->action; - case NAS: /* Name started. */ - if (namecase!=AVALCASE) { - parsenm(pt, namecase); - return (int)pcb->action; - } - /* Treat attribute value as name character string. */ - case NMT: /* Name token string. */ - parsetkn(pt, NMC, (int)tokenlen); /* Get undelimited value. */ - return (int)pcb->action; - case NUM: /* Number or number token string. */ - parsetkn(pt, (UNCH)((int)tokenlen<=NAMELEN ? NU:NMC), (int)tokenlen); - return (int)pcb->action; - case PENR: - REPEATCC; - return (pcb->action = PEN); - case EOD_: - exiterr(133, pcb); - /* EXIT */ - default: /* End of declaration. */ - return (int)pcb->action; /* EMD GRPS MGRP PEN PGRP */ - } -} -/* PARSEMOD: If the declared content was a keyword, the token count is zero - and it is only necessary to save the type. Otherwise, - collect the outermost token count and model type bytes for a model. - The count includes tokens found in nested groups also. - After building the model, parse for its occurrence indicator. -*/ -struct thdr *parsemod(dctype) -int dctype; /* Content type (0=model). */ -{ - gbuf[0].ttype = (UNCH)dctype; /* Initialize content flags byte. */ - if (dctype) {gbuf[0].tu.tnum = 0; return gbuf;} /* Return if not model. */ - - gbuf[0].tu.tnum = 0; /* Don't count 1st group or model header. */ - gbuf[1].ttype = 0; /* Initialize 1st group type ... */ - gbuf[1].tu.tnum = 0; /* and count. */ - grplvl = 1; /* Content model is 1st level group. */ - pcbgrcm.newstate = 0; /* Go parse the model group. */ - /* Empty group is trapped during syntax parse; other errors return NULL. */ - if (!parsegcm(&pcbgrcm, &gbuf[1], &gbuf[0])) return (struct thdr *)0; - parse(&pcbgrcs); /* Get the model suffix, if there is one. */ - switch(pcbgrcs.action) { - case OPT: /* OPT occurrence indicator for model. */ - SET(gbuf[1].ttype, TOPT|TXOPT); - break; - case REP: /* REP occurrence indicator for model. */ - SET(gbuf[1].ttype, TREP|TXREP); - break; - case OREP: /* OREP occurrence indicator for model. */ - SET(gbuf[1].ttype, TOREP|TXOREP); - break; - default: /* RCR_: Repeat char and return. */ - break; - } - if (sw.swambig) ambig(); /* Check content model for ambiguity. */ - return gbuf; -} -/* PARSEGCM: Collect token headers (struct thdr) into a group (array). - An etd is defined for each GI (if none exists) and its pointer is - stored in the header. The function is called recursively. -*/ -struct thdr *parsegcm(pcb, pgh, gbuf) -struct parse *pcb; /* Current parse control block. */ -struct thdr *pgh; /* Current group header in group buffer. */ -struct thdr *gbuf; /* Header for outermost group (model). */ -{ -#define MCON gbuf->ttype /* Model type (content attributes). */ - struct thdr *pg=pgh; /* Current group token. */ - struct thdr *pgsv=pgh; /* Saved current token for occ indicator. */ - int optcnt = 0; /* Count of optional tokens in group. */ - int essv = es; /* Entity stack level when grp started. */ - - while (gbuf->tu.tnum<=GRPGTCNT && pgh->tu.tnum<=GRPCNT && parse(pcb)!=GRPE) - switch (pcb->action) { - - case NAS_: /* GI name: get its etd and store it. */ - ++gbuf->tu.tnum; ++pgh->tu.tnum; - (pgsv = ++pg)->ttype = TTETD; - pg->tu.thetd = etddef(parsenm(tbuf, NAMECASE)); - SET(MCON, MGI); - continue; - - case RNS_: /* Reserved name started (#PCDATA). */ - parsenm(tbuf, NAMECASE); - if (ustrcmp(tbuf+1, key[KPCDATA])) { - mderr(116, ntoa(gbuf->tu.tnum), tbuf+1); - return (struct thdr *)0; - } - /* If #PCDATA is the first non-group token, model is a phrase. */ - if (!MCON) SET(MCON, MPHRASE); - case DTAG: /* Data tag template ignored; treat as #PCDATA. */ - if (pcb->action==DTAG) SET(pgh->ttype, TTSEQ); /* DTAG is SEQ grp. */ - ++gbuf->tu.tnum; ++pgh->tu.tnum; - (++pg)->ttype = TTCHARS+TOREP;/* #PCDATA is OPT and REP. */ - pg->tu.thetd = ETDCDATA; - ++optcnt; /* Ct opt tokens to see if grp is opt.*/ - SET(MCON, MCHARS); - continue; - - case GRP_: /* Group started. */ - ++gbuf->tu.tnum; ++pgh->tu.tnum; - (pgsv = ++pg)->ttype = 0; /* Type will be set by connector. */ - pg->tu.tnum = 0; /* Group has number instead of etd. */ - if (++grplvl>GRPLVL) { - mderr(115, ntoa(gbuf->tu.tnum), (UNCH *)0); - return (struct thdr *)0; - } - pg = parsegcm(pcb, pg, gbuf); - if (!pg) return (struct thdr *)0; - if (GET(pgsv->ttype, TOPT)) ++optcnt; /* Indicate nested opt grp. */ - --grplvl; - continue; - - case OREP: /* OREP occurrence indicator for current token.*/ - SET(pgsv->ttype, TREP|TXREP); - /* Now treat like OPT. */ - case OPT: /* OPT occurrence indicator for current token. */ - SET(pgsv->ttype, TXOPT); - if (GET(pgsv->ttype, TOPT)) continue; /* Exit if nested opt grp. */ - SET(pgsv->ttype, TOPT); - ++optcnt; /* Count opt tokens to see if grp is optional. */ - continue; - case REP: /* REP occurrence indicator for current token. */ - SET(pgsv->ttype, TREP|TXREP); - continue; - - case OR: /* OR connector found. */ - if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTOR); - else if (GET(pgh->ttype, TTAND)!=TTOR) - mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0); - continue; - case AND: /* AND connector found. */ - if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTAND); - else if (GET(pgh->ttype, TTAND)!=TTAND) - mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0); - continue; - case SEQ: /* SEQ connector found. */ - if BITOFF(pgh->ttype, TTAND) SET(pgh->ttype, TTSEQ); - else if (GET(pgh->ttype, TTAND)!=TTSEQ) - mderr(55, ntoa(gbuf->tu.tnum), (UNCH *)0); - continue; - - case EE_: /* Entity ended (correctly or incorrectly). */ - if (estu.tnum>GRPCNT) { - mderr(113, ntoa(gbuf->tu.tnum), (UNCH *)0); - return (struct thdr *)0; - } - if (gbuf->tu.tnum>GRPGTCNT) { - mderr(114, ntoa(gbuf->tu.tnum), (UNCH *)0); - return (struct thdr *)0; - } - if (pgh->tu.tnum==1) SET(pgh->ttype, TTSEQ); /* Unit grp is SEQ. */ - /* An optional token in an OR group makes the group optional. */ - if (GET(pgh->ttype, TTMASK)==TTOR && optcnt) SET(pgh->ttype, TOPT); - /* If all tokens in any group are optional, so is the group. */ - if (pgh->tu.tnum<=optcnt) SET(pgh->ttype, TOPT); - - if (es!=essv) synerr(37, pcb); - return pg; /* Return pointer to GRPS token. */ -} -/* PARSENM: Parser for SGML names, which can be translated with LEXTRAN. - The input is read from the entity stack. CC is 1st char of name. - Returns a pointer to the parsed name. -*/ -UNCH *parsenm(tbuf, nc) -UNCH *tbuf; /* Buffer for name: >=NAMELEN+2. */ -int nc; /* Namecase translation: 1=yes; 0=no. */ -{ - UNCH len; /* Length of name (incl EOS & length byte). */ - - *(tbuf + (len = 1) ) = nc ? lextran[*FPOS] : *FPOS; - while ((NEWCC, (int)lextoke[*FPOS]>=NMC) && (len=maxlen+1. */ -UNCH scope; /* Minimum lexical class allowed. */ -int maxlen; /* Maximum length of a token. */ -#endif -{ - int i = 1; - tbuf[0] = *FPOS; - while (i < maxlen) { - NEWCC; - if (lextoke[*FPOS] < scope) { - REPEATCC; - break; - } - TRACETKN(scope, lextoke); - if (*FPOS == EOBCHAR) - entget(); - else - tbuf[i++] = *FPOS; - } - tbuf[i] = EOS; - return tbuf; -} -/* PARSESEQ: Parser for blank sequences (i.e., space and TAB characters ). - First character of sequence is already in *FPOS. -*/ -VOID parseseq(tbuf, maxlen) -UNCH *tbuf; /* Buffer for storing found sequence. */ -int maxlen; /* Maximum length of a blank sequence. */ -{ - tbuf[0] = *FPOS; - datalen = 1; - for (;;) { - NEWCC; - if (*FPOS == EOBCHAR) { - entget(); - continue; - } - if ((lextoke[*FPOS] != SEP && *FPOS != SPCCHAR) - || datalen >= maxlen) - break; - tbuf[datalen++] = *FPOS; - TRACETKN(SEP, lextoke); - } -} -/* S2VALNM: Parser for attribute values that are tokenized like names. - The input is read from a string (hence S ("string") 2 ("to") VALNM). - It stops at the first bad character. - Returns a pointer to the created name. -*/ -#ifdef USE_PROTOTYPES -UNCH *s2valnm(UNCH *nm, UNCH *s, UNCH scope, int translate) -#else -UNCH *s2valnm(nm, s, scope, translate) -UNCH *nm; /* Name to be created. */ -UNCH *s; /* Source string to be parsed as name. */ -UNCH scope; /* Minimum lexical class allowed. */ -int translate; /* Namecase translation: 1=yes; 0=no. */ -#endif -{ - UNCH len = 0; /* Length of name (incl EOS and length). */ - - for (; (int)lextoke[*s] >= scope && len < NAMELEN; s++) - nm[++len] = translate ? lextran[*s] : *s; - nm[++len] = EOS; /* Terminate name with standard EOS. */ - *nm = ++len; /* Store length ahead of name. */ - return nm; -} -/* PARSEVAL: Parser for attribute values. - The input is read from a string and tokenized in a buffer. - The input is terminated by EOS. - Each token is preceded by its actual length; there is no EOS. - If an error occurs while parsing, or - if a token doesn't conform, set the token count to 0 to show that - value was not tokenized and return the error code. - After successful parse, return buffer length and 0 error code. - The number of tokens found is set in external variable tokencnt. -*/ -int parseval(s, atype, tbuf) -UNCH *s; /* Source string to be parsed as token list. */ -UNS atype; /* Type of token list expected. */ -UNCH *tbuf; /* Work area for tokenization. */ -{ - int t; - UNCH *pt = tbuf; - - pcbval.newstate = 0; tokencnt = 0; - while (1) { - for (;;) { - pcbval.input = lextoke[*s]; - pcbval.state = pcbval.newstate; - pcbval.newstate = (*(pcbval.ptab + pcbval.state)) [pcbval.input]; - pcbval.action = (*(pcbval.ptab + pcbval.state+1)) [pcbval.input]; - TRACEVAL(&pcbval, atype, s, tokencnt); - if (pcbval.action != NOPA) - break; - s++; - } - - - switch (pcbval.action) { - case INVA: /* Invalid character; terminate parse. */ - if (*s == '\0') goto alldone; /* Normal termination. */ - tokencnt = 0; /* Value was not tokenized. */ - return(14); - case LENA: /* Length limit of token exceeded; end parse. */ - tokencnt = 0; /* Value was not tokenized. */ - return(15); - default: /* Token begun: NUMA, NASA, or NMTA. */ - break; - } - - ++tokencnt; /* One token per iteration. */ - switch (atype) { - case AENTITY: - if (tokencnt>1) {tokencnt = 0; return(16);} - case AENTITYS: - if (pcbval.action!=NASA) {tokencnt = 0; return(17);} - s2valnm(pt, s, NMC, ENTCASE); - break; - - case AID: - case AIDREF: - case ANAME: - case ANOTEGRP: - if (tokencnt>1) {tokencnt = 0; return(16);} - case AIDREFS: - case ANAMES: - if (pcbval.action!=NASA) {tokencnt = 0; return(17);} - s2valnm(pt, s, NMC, NAMECASE); - break; - - case ANMTGRP: - case ANMTOKE: - if (tokencnt>1) {tokencnt = 0; return(16);} - case ANMTOKES: - /* No test needed because NMTA, NUMA and NASA are all valid. */ - s2valnm(pt, s, NMC, NAMECASE); - break; - - case ANUMBER: - if (tokencnt>1) {tokencnt = 0; return(16);} - case ANUMBERS: - if (pcbval.action!=NUMA) {tokencnt = 0; return(17);} - s2valnm(pt, s, NU, NAMECASE); - t = lextoke[s[*pt - 2]]; - if (t == NMS || t == NMC) {tokencnt = 0; return(17);} - break; - - case ANUTOKE: - if (tokencnt>1) {tokencnt = 0; return(16);} - case ANUTOKES: - if (pcbval.action!=NUMA) {tokencnt = 0; return(17);} - s2valnm(pt, s, NMC, NAMECASE); - break; - } - *pt -= 2; - s += *pt; - pt += *pt + 1; - } - alldone: - *pt++ = EOS; - if (*tbuf == '\0') - return 25; - if (atype < ATKNLIST) - *tbuf += 2; /* include length and EOS */ - return 0; -} -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/pcbrf.c b/cde/programs/dtdocbook/sgmls/pcbrf.c deleted file mode 100644 index dc40faf9e..000000000 --- a/cde/programs/dtdocbook/sgmls/pcbrf.c +++ /dev/null @@ -1,1367 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: pcbrf.c /main/3 1996/06/19 17:16:43 drk $ */ -/* PCBRF: Parse tables for reference concrete syntax. -*/ -#include "config.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "action.h" /* Action names for all parsing. */ -#include "synxtrn.h" /* Declarations for concrete syntax constants. */ -#include "adl.h" /* Definitions for attribute list processing. */ -/* PCBCONM: State and action table for content parse of mixed content. - Initial state assumes a start-tag was just processed. -*/ -/* Symbols for state names (end with a number). */ -#define ET0 0 /* Markup found or buffer flushed; no data. */ -#define DA0 2 /* Data in buffer. */ -#define DA1 4 /* Data and space in buffer. */ -#define ER0 6 /* ERO found; start lookahead buffer. */ -#define CR0 8 /* CRO found (ERO, RNI). */ -#define RS0 10 /* RS found; possible SR 3-6. */ -#define ME0 12 /* MSC found; possible SR26. */ -#define ME1 14 /* MSC, MSC found. */ -#define ES0 16 /* TAGO found; start lookahead buffer. */ -#define EE0 18 /* End-tag start (TAGO,ETI); move to lookahead buffer. */ -#define NE0 20 /* End-tag start (TAGO,NET); process NET if not end-tag. */ -#define MD0 22 /* MDO found (TAGO, MDO[2]). */ -#define MC0 24 /* MDO, COM found. */ -#define SC0 26 /* COM found; possible SR19-20. */ -#define SP0 28 /* Space found; data pending; possible SR7 or SR9. */ -#define SR0 30 /* SPCR found; possible SR7 or SR9. */ -#define TB0 32 /* TAB found; possible SR7 or SR9. */ - -int pcbcnet = ET0; /* PCBCONM: markup found or data buffer flushed.*/ -int pcbcnda = DA0; /* PCBCONM: data in buffer. */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -et0 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,ET0 ,ET0 ,ET0 ,RS0 ,ET0 ,TB0 ,DA0 ,ET0 ,ER0 , - ET0 ,SC0 ,DA0 ,ET0 ,ET0 ,SR0 ,DA0 ,ME0 ,ET0 ,DA0 ,ET0 ,DA0 ,ES0 ,ET0 },/*et0*/ -et0a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,GET_,GET_,RSR_,SR2_,DAS_,DAS_,NSC_,LAS_, - REF_,NOP_,DAS_,NED_,SR10,DAS_,DAS_,NOP_,SR25,DAS_,SR11,DAS_,LAS_,FCE_}, - -da0 []={DA0 ,DA0 ,DA0 ,DA0 ,DA1 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 , - ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 },/*da0*/ -da0a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,DAF_,DAF_, - DAF_,DAF_,NOP_,DAF_,DAF_,DAF_,NOP_,DAF_,DAF_,NOP_,NOP_,NOP_,DAF_,DAF_}, - -da1 []={DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 , - ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 },/*da1*/ -da1a[]={NOP_,NOP_,NOP_,NOP_,DAR_,DAF_,DAF_,DAR_,DAF_,DAR_,DAR_,NOP_,DAF_,DAF_, - DAF_,DAF_,NOP_,DAF_,DAF_,DAR_,NOP_,DAF_,DAF_,NOP_,NOP_,NOP_,DAF_,DAF_}, - -er0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ER0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 },/*er0*/ -er0a[]={LAF_,LAF_,LAF_,ER_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -cr0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*cr0*/ -cr0a[]={NLF_,CRN_,NLF_,CRA_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_}, - -rs0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,RS0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*rs0*/ -rs0a[]={SR3_,SR3_,SR3_,SR3_,SR4_,SR3_,SR3_,GET_,SR3_,SR5_,SR4_,SR3_,SR3_,SR3_, - SR3_,SR3_,SR3_,NED_,SR3_,SR4_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_}, - -me0 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME0, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, - ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ME1 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*me0*/ -me0a[]={SR26,SR26,SR26,SR26,SR26,SR26,SR26,GET_,SR26,SR26,SR26,SR26,SR26,SR26, - SR26,SR26,SR26,SR26,SR26,SR26,SR26,NOP_,SR26,SR26,SR26,SR26,SR26,SR26}, - -me1 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME1, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, - ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*me1*/ -me1a[]={RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,GET_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_, - RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,MSE_,RBR_,RBR_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -es0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ES0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,EE0 ,NE0 ,ET0 ,ET0 ,MD0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*es0*/ -es0a[]={LAF_,LAF_,LAF_,STG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAM_,LAF_,LAF_,PIS_,LAF_,NST_,LAF_,LAF_}, - -ee0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,EE0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*ee0*/ -ee0a[]={LAF_,LAF_,LAF_,ETG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_,LAF_}, - -ne0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,NE0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*ne0*/ -ne0a[]={NLF_,NLF_,NLF_,ETG_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NET_,NLF_,NLF_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -md0 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, MD0, ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, - ET0 ,MC0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ET0 ,ET0, ET0, ET0 },/*md0*/ -md0a[]={LAF_,LAF_,LAF_,MD_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,MSS_,LAF_,LAF_,MDC_,LAF_,LAF_}, - -mc0 []={ET0, ET0, ET0, ET0, ET0, ET0 ,ET0, MC0, ET0 ,ET0, ET0 ,ET0, ET0, ET0, - ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0 ,ET0 ,ET0 ,ET0, ET0, ET0 },/*mc0*/ -mc0a[]={NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,MDC_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_}, - -sc0 []={ET0, ET0, ET0, ET0, ET0, ET0 ,ET0, SC0, ET0 ,ET0, ET0 ,ET0, ET0, ET0, - ET0 ,ET0 ,ET0 ,ET0, ET0, ET0, ET0, ET0 ,ET0 ,ET0 ,ET0 ,ET0, ET0, ET0 },/*sc0*/ -sc0a[]={SR19,SR19,SR19,SR19,SR19,SR19,SR19,GET_,SR19,SR19,SR19,SR19,SR19,SR19, - SR19,SR20,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -sp0 []={DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,SP0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 , - ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,ET0 ,DA0 ,ET0 ,ET0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 },/*sp0*/ -sp0a[]={NOP_,NOP_,NOP_,NOP_,SR9_,DAF_,DAF_,GTR_,DAF_,SR7_,SR9_,NOP_,NOP_,DAF_, - DAF_,DAF_,NOP_,DAF_,DAF_,SR9_,NOP_,DAF_,DAF_,NOP_,NOP_,NOP_,DAF_,DAF_}, - -sr0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,SR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*sr0*/ -sr0a[]={SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,GET_,SR8_,SR7_,SR9_,SR8_,SR8_,SR8_, - SR8_,SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_}, - -tb0 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,TB0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*tb0*/ -tb0a[]={SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,GET_,SR1_,SR7_,SR9_,SR1_,SR1_,SR1_, - SR1_,SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ - -*conmtab[] = {et0, et0a, da0, da0a, da1, da1a, er0, er0a, cr0, cr0a, rs0, rs0a, - me0, me0a, me1, me1a, es0, es0a, ee0, ee0a, ne0, ne0a, md0, md0a, - mc0, mc0a, sc0, sc0a, sp0, sp0a, sr0, sr0a, tb0, tb0a }; -struct parse pcbconm = {"CONM", lexcnm, conmtab, 0, 0, 0, 0}; -#undef ET0 -#undef DA0 -#undef DA1 -#undef ER0 -#undef CR0 -#undef RS0 -#undef ME0 -#undef ME1 -#undef ES0 -#undef EE0 -#undef NE0 -#undef MD0 -#undef MC0 -#undef SC0 -#undef SP0 -#undef SR0 -#undef TB0 -/* PCBCONE: State and action table for content parse of element content. - Initial state assumes a start-tag was just processed. -*/ -/* Symbols for state names (end with a number). */ -#define ET2 0 /* Markup found. */ -#define ER2 2 /* ERO found; start lookahead buffer. */ -#define CR2 4 /* CRO found (ERO, RNI). */ -#define RS2 6 /* RS found; possible SR 3-6 if they were declared. */ -#define ME2 8 /* MSC found. */ -#define ME3 10 /* MSC, MSC found. */ -#define ES2 12 /* TAGO found; start lookahead buffer. */ -#define EE2 14 /* End-tag start (TAGO,ETI); move to lookahead buffer. */ -#define NE2 16 /* End-tag start (TAGO,NET); process NET if not end-tag. */ -#define MD2 18 /* MDO found (TAGO, MDO[2]). */ -#define MC2 20 /* MDO, COM found. */ -#define SC2 22 /* COM found; possible SR19-20 if they were mapped. */ -#define SP2 24 /* Space found; possible SR7 or SR9. */ -#define SR2 26 /* SPCR found; possible SR7 or SR9. */ -#define TB2 28 /* TAB found; possible SR7 or SR9. */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -et2 []={ET2 ,ET2 ,ET2 ,ET2 ,SP2 ,ET2 ,ET2 ,ET2 ,RS2 ,ET2 ,TB2 ,ET2 ,ET2 ,ER2 , - ET2 ,SC2 ,ET2 ,ET2 ,ET2 ,SR2 ,ET2 ,ME2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 },/*et2*/ -et2a[]={DCE_,DCE_,DCE_,DCE_,NOP_,DCE_,GET_,GET_,RS_ ,SR2_,NOP_,DCE_,DCE_,LAS_, - NOP_,NOP_,DCE_,NED_,SR10,NOP_,DCE_,NOP_,DCE_,DCE_,SR11,DCE_,LAS_,DCE_}, - -er2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ER2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,CR2 ,ET2 ,ET2 ,ET2 },/*er2*/ -er2a[]={LAF_,LAF_,LAF_,ER_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_}, - -cr2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,CR2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*cr2*/ -cr2a[]={NLF_,CRN_,NLF_,CRA_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_}, - -rs2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,RS2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*rs2*/ -rs2a[]={SR3_,SR3_,SR3_,SR3_,SR4_,SR3_,SR3_,GET_,SR3_,SR5_,SR4_,SR3_,SR3_,SR3_, - SR3_,SR3_,SR3_,NED_,SR3_,SR4_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_,SR3_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spcr mdo msc mso pio rni tagc tago fce */ -me2 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME2, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2, - ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ME3 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*me2*/ -me2a[]={SR26,SR26,SR26,SR26,SR26,SR26,SR26,GET_,SR26,SR26,SR26,SR26,SR26,SR26, - SR26,SR26,SR26,SR26,SR26,SR26,SR26,NOP_,SR26,SR26,SR26,SR26,SR26,SR26}, - -me3 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME3, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2, - ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*me3*/ -me3a[]={RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,GET_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_, - RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,RBR_,MSE_,RBR_,RBR_}, - -es2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,EE2 ,NE2 ,ET2 ,ET2 ,MD2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*es2*/ -es2a[]={LAF_,LAF_,LAF_,STG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAM_,LAF_,LAF_,PIS_,LAF_,NST_,LAF_,LAF_}, - -ee2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,EE2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*ee2*/ -ee2a[]={LAF_,LAF_,LAF_,ETG_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_,LAF_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spc mdo msc mso pio rni tagc tago fce */ -ne2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,NE2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*ne2*/ -ne2a[]={NLF_,NLF_,NLF_,ETG_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NET_,NLF_,NLF_}, - -md2 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, MD2, ET2 ,ET2 ,ET2 ,ET2, ET2, ET2, - ET2 ,MC2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ET2 ,ET2, ET2, ET2 },/*md2*/ -md2a[]={LAF_,LAF_,LAF_,MD_ ,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,MSS_,LAF_,LAF_,MDC_,LAF_,LAF_}, - -mc2 []={ET2, ET2, ET2, ET2, ET2, ET2 ,ET2, MC2, ET2 ,ET2, ET2 ,ET2, ET2, ET2, - ET2 ,ET2, ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2 ,ET2 ,ET2 ,ET2, ET2, ET2 },/*mc2*/ -mc2a[]={NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,GET_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_, - NLF_,MDC_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_,NLF_}, - -sc2 []={ET2, ET2, ET2, ET2, ET2, ET2 ,ET2, SC2, ET2 ,ET2, ET2 ,ET2, ET2, ET2, - ET2 ,ET2 ,ET2 ,ET2, ET2, ET2, ET2, ET2 ,ET2 ,ET2 ,ET2 ,ET2, ET2, ET2 },/*sc2*/ -sc2a[]={SR19,SR19,SR19,SR19,SR19,SR19,SR19,GET_,SR19,SR19,SR19,SR19,SR19,SR19, - SR19,SR20,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19,SR19}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net lit spc mdo msc mso pio rni tagc tago fce */ -sp2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,SP2 ,RS2 ,ET2 ,ET2 ,ET2 ,ET2 ,ER2 , - ET2 ,SC2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ME2 ,ET2 ,ET2 ,ET2 ,ET2 ,ES2 ,ET2 },/*sp2*/ -sp2a[]={DCE_,DCE_,DCE_,DCE_,SR9_,DCE_,GET_,GET_,RS_ ,SR7_,SR9_,DCE_,DCE_,LAS_, - NOP_,NOP_,DCE_,NED_,SR10,SR9_,DCE_,LAS_,DCE_,DCE_,SR11,DCE_,LAS_,DCE_}, - -sr2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,SR2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*sr2*/ -sr2a[]={SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,GET_,SR8_,SR7_,SR9_,SR8_,SR8_,SR8_, - SR8_,SR8_,SR8_,SR8_,SR8_,SR9_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_,SR8_}, - -tb2 []={ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,TB2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 , - ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 },/*tb2*/ -tb2a[]={SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,GET_,SR1_,SR7_,SR9_,SR1_,SR1_,SR1_, - SR1_,SR1_,SR1_,SR1_,SR1_,SR9_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_,SR1_}, - -*conetab[] = {et2, et2a, er2, er2a, cr2, cr2a, rs2, rs2a, me2, me2a, me3, me3a, - es2, es2a, ee2, ee2a, ne2, ne2a, md2, md2a, mc2, mc2a, sc2, sc2a, - sp2, sp2a, sr2, sr2a, tb2, tb2a }; -struct parse pcbcone = {"CONE", lexcnm, conetab, 0, 0, 0, 0}; -#undef ET2 -#undef ER2 -#undef CR2 -#undef RS2 -#undef ME2 -#undef ME3 -#undef ES2 -#undef EE2 -#undef NE2 -#undef MD2 -#undef MC2 -#undef SC2 -#undef SP2 -#undef SR2 -#undef TB2 -/* PCBCONR: State and action table for content parse of replaceable character - data. Initial state assumes a start-tag was just processed. - Only entity references and character references are recognized. -*/ -/* Symbols for state names (end with a number). */ -#define ET4 0 /* Markup found or buffer flushed; no data. */ -#define DA4 2 /* Data in buffer. */ -#define ER4 4 /* ERO found; start lookahead buffer. */ -#define CR4 6 /* CRO found (ER2, RNI). */ -#define ES4 8 /* TAGO found; start lookahead buffer. */ -#define EE4 10 /* End-tag start (TAGO,ETI); move to lookahead buffer. */ -#define NE4 12 /* End-tag start (TAGO,NET); process NET if not end-tag. */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -et4 []={DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,DA4 ,DA4 ,ET4 ,ER4 , - ET4 ,DA4 ,DA4 ,ET4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ES4 },/*et4*/ -et4a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EE_ ,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,LAS_, - REF_,DAS_,DAS_,NED_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,LAS_}, - -da4 []={DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,DA4 ,DA4 ,ET4 ,ET4 , - ET4 ,DA4 ,DA4 ,ET4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,DA4 ,ET4 },/*da4*/ -da4a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_, - DAF_,NOP_,NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,DAF_}, - -er4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ER4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 , - ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,CR4 ,ET4 ,ET4 },/*er4*/ -er4a[]={LAF_,LAF_,LAF_,ERX_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_}, - -cr4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,CR4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 , - ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*cr4*/ -cr4a[]={LAF_,CRN_,LAF_,CRA_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -es4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 , - ET4 ,ET4 ,EE4 ,NE4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*es4*/ -es4a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -ee4 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,EE4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 , - ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*ee4*/ -ee4a[]={LAF_,LAF_,LAF_,ETC_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_}, - -ne4 []={EE4 ,EE4 ,EE4 ,ET4 ,EE4 ,EE4 ,EE4 ,NE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 , - EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,EE4 ,ET4 ,EE4 },/*ne4*/ -ne4a[]={RC2_,RC2_,RC2_,ETC_,RC2_,RC2_,RC2_,GET_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_, - RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,NET_,RC2_}, - -*conrtab[] = {et4, et4a, da4, da4a, er4, er4a, cr4, cr4a, - es4, es4a, ee4, ee4a, ne4, ne4a}; -struct parse pcbconr = {"CONR", lexcon, conrtab, 0, 0, 0, 0}; -#undef ET4 -#undef DA4 -#undef ER4 -#undef CR4 -#undef ES4 -#undef EE4 -#undef NE4 -/* PCBCONC: State and action table for content parse of character data. - Initial state assumes a start-tag was just processed. -*/ -/* Symbols for state names (end with a number). */ -#define ET6 0 /* Markup found or buffer flushed; no data. */ -#define DA6 2 /* Data in buffer. */ -#define ES6 4 /* TAGO found; start lookahead buffer. */ -#define EE6 6 /* End-tag start (TAGO,ETI); move to lookahead buffer. */ -#define NE6 8 /* End-tag start (TAGO,NET); process NET if not end-tag. */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -et6 []={DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,DA6 ,DA6 ,ET6 ,DA6 , - ET6 ,DA6 ,DA6 ,ET6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ES6 },/*et6*/ -et6a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EOF_,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,DAS_, - REF_,DAS_,DAS_,NED_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_,LAS_}, - -da6 []={DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,DA6 ,DA6 ,ET6 ,ET6 , - ET6 ,DA6 ,DA6 ,ET6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,DA6 ,ET6 },/*da6*/ -da6a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_, - DAF_,NOP_,NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,DAF_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -es6 []={ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ES6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 , - ET6 ,ET6 ,EE6 ,NE6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 },/*es6*/ -es6a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAM_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -ee6 []={ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,EE6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 , - ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 ,ET6 },/*ee6*/ -ee6a[]={LAF_,LAF_,LAF_,ETC_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,NET_,LAF_}, - -ne6 []={EE6 ,EE6 ,EE6 ,ET6 ,EE6 ,EE6 ,EE6 ,NE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 , - EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,EE6 ,ET6 ,EE6 },/*ne6*/ -ne6a[]={RC2_,RC2_,RC2_,ETC_,RC2_,RC2_,RC2_,GET_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_, - RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,RC2_,NET_,RC2_}, - -*conctab[] = {et6, et6a, da6, da6a, es6, es6a, ee6, ee6a, ne6, ne6a}; -struct parse pcbconc = {"CONC", lexcon, conctab, 0, 0, 0, 0}; -#undef ET6 -#undef DA6 -#undef ES6 -#undef EE6 -#undef NE6 -/* PCBPRO: State and action table for prolog parse. - Initial state assumes document just began. -*/ -/* Symbols for state names (end with a number). */ -#define ET7 0 /* Markup found. */ -#define ES7 2 /* TAGO found; start lookahead buffer. */ -#define MD7 4 /* MDO found (TAGO, MDO[2]). */ -#define MC7 6 /* MDO, COM found. */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -et7 []={ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 , - ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ES7 },/*et7*/ -et7a[]={DCE_,DCE_,DCE_,DCE_,NOP_,DCE_,EE_ ,GET_,RS_ ,NOP_,NOP_,DCE_,DCE_,DCE_, - DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,DCE_,LAS_}, - -es7 []={ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ES7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 , - ET7 ,ET7 ,ET7 ,ET7 ,MD7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 ,ET7 },/*es7*/ -es7a[]={PEP_,PEP_,PEP_,STE_,PEP_,PEP_,PEP_,GET_,PEP_,PEP_,PEP_,PEP_,PEP_,PEP_, - PEP_,PEP_,PEP_,PEP_,LAM_,PEP_,PEP_,PEP_,PIS_,PEP_,STE_,PEP_}, - -md7 []={ET7, ET7, ET7, ET7, ET7 ,ET7, ET7, MD7, ET7 ,ET7 ,ET7 ,ET7, ET7, ET7, - ET7, MC7, ET7, ET7, ET7, ET7 ,ET7, ET7, ET7, ET7 ,ET7, ET7 },/*md7*/ -md7a[]={LAF_,LAF_,LAF_,DTD_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,MSP_,LAF_,LAF_,LAF_,NOP_,LAF_}, - -mc7 []={ET7, ET7, ET7, ET7, ET7, ET7 ,ET7, MC7, ET7 ,ET7, ET7 ,ET7, ET7, ET7, - ET7, ET7, ET7, ET7, ET7, ET7 ,ET7 ,ET7, ET7 ,ET7 ,ET7, ET7 },/*mc7*/ -mc7a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,MDC_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -*protab[] = {et7, et7a, es7, es7a, md7, md7a, mc7, mc7a}; -struct parse pcbpro = {"PRO", lexcon, protab, 0, 0, 0, 0}; -#undef ET7 -#undef ES7 -#undef MD7 -#undef MC7 -/* PCBMDS: State and action table for parse of markup declaration subset. - Initial state assumes subset just began (MSO found). -*/ -/* Symbols for state names (end with a number). */ -#define ET8 0 /* Markup found. */ -#define ER8 2 /* PERO found; start lookahead buffer. */ -#define ME8 4 /* MSC found. */ -#define ME9 6 /* MSC, MSC found. */ -#define ES8 8 /* TAGO found; start lookahead buffer. */ -#define MD8 10 /* MDO found (TAGO, MDO[2]). */ -#define MC8 12 /* MDO, CD found. */ -#define DC8 14 /* Data characters found (erroneously). */ - -static UNCH -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -et8 []={DC8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,ET8 ,ET8 ,ET8 ,ET8 ,ET8 ,DC8 ,DC8 ,DC8 , - DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ME8 ,DC8 ,ER8 ,DC8 ,DC8 ,DC8 ,ES8 },/*et8*/ -et8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,GET_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -er8 []={DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 ,ER8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 , - DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 },/*er8*/ -er8a[]={NOP_,NOP_,NOP_,PER_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -me8 []={ET8, ET8, ET8, ET8, ET8 ,ET8, ET8, ME8, ET8 ,ET8 ,ET8 ,ET8, ET8, ET8, - ET8 ,ET8, ET8 ,ET8, ET8, ME9 ,ET8, ET8, ET8, ET8 ,ET8, ET8 },/*me8*/ -me8a[]={DTE_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_,GET_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_, - DTE_,DTE_,DTE_,DTE_,DTE_,NOP_,DTE_,DTE_,DTE_,DTE_,DTE_,DTE_}, - -me9 []={DC8, DC8, DC8, DC8, DC8 ,DC8, DC8, ME9, DC8 ,DC8 ,DC8 ,DC8, DC8, DC8, - DC8 ,DC8, DC8 ,DC8, DC8, DC8 ,DC8, DC8, DC8, DC8 ,ET8, DC8 },/*me9*/ -me9a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,MSE_,NOP_}, - -/* free nu nmc nms spc non ee eob rs re sep cde nsc ero - nmre com eti net mdo msc mso pero pio rni tagc tago */ -es8 []={DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ES8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 , - DC8 ,DC8 ,DC8 ,DC8 ,MD8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 },/*es8*/ -es8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,PIS_,NOP_,NOP_,NOP_}, - -md8 []={DC8, DC8, DC8, ET8, DC8 ,DC8, DC8, MD8, DC8 ,DC8 ,DC8 ,DC8, DC8, DC8, - DC8 ,MC8, DC8 ,DC8, DC8, DC8 ,ET8, DC8, DC8, DC8 ,ET8, DC8 },/*md8*/ -md8a[]={NOP_,NOP_,NOP_,MD_ ,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,MSS_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -mc8 []={DC8, DC8, DC8, DC8, DC8, DC8 ,DC8, MC8, DC8 ,DC8, DC8 ,DC8, DC8, DC8, - DC8 ,ET8, DC8 ,DC8, DC8, DC8 ,DC8 ,DC8, DC8 ,DC8 ,DC8, DC8 },/*mc8*/ -mc8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_,GET_,NOP_,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,MDC_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -dc8 []={DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,DC8 , - DC8 ,DC8 ,DC8 ,DC8 ,DC8 ,ET8 ,DC8 ,ET8 ,DC8 ,DC8 ,DC8 ,ET8 },/*dc8*/ -dc8a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,GET_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,CIR_,NOP_,CIR_,NOP_,NOP_,NOP_,CIR_}, - -*mdstab[] = {et8, et8a, er8, er8a, me8, me8a, me9, me9a, - es8, es8a, md8, md8a, mc8, mc8a, dc8, dc8a}; -struct parse pcbmds = {"MDS", lexcon, mdstab, 0, 0, 0, 0}; -#undef ET8 -#undef ER8 -#undef ME8 -#undef ME9 -#undef ES8 -#undef MD8 -#undef MC8 -#undef DC8 -/* PCBGRCM: State and action table for content model group. - Groups can nest. Reserved names are allowed. - Data tag token groups are allowed. - A non-reserved name or model group can have a suffix. - Columns are based on LEXGRP.C. -*/ -/* Symbols for state names (end with a number). */ -#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */ -#define CO1 2 /* Connector between tokens expected. */ -#define ER1 4 /* PERO found when token was expected. */ -#define SP1 6 /* Name or model: suffix or connector expected. */ -#define RN1 8 /* RNI found; possible #PCDATA. */ -#define DG1 10 /* Data tag: group begun; name expected. */ -#define DN1 12 /* Data tag: name found; SEQ connector expected. */ -#define DT1 14 /* Data tag: ignore template and pattern; MSC expected. */ -#define DR1 16 /* PERO found when data tag name was expected. */ -#define LI1 18 /* Literal in data tag group; search for LIT. */ -#define LA1 20 /* Literal in data tag group; search for LITA. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -tk01 []={TK1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,DG1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,RN1 ,TK1 ,TK1 },/*tk1*/ -tk01a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,GRP_,INV_,INV_, - INV_,GRP_,INV_,INV_,NOP_,INV_,INV_,NOP_,INV_,INV_}, - -co01 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/ -co01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,AND ,GRPE,INV_,INV_,INV_, - INV_,INV_,INV_,OR ,INV_,INV_,INV_,INV_,SEQ ,INV_}, - -er01 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/ -er01a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -sp01 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,SP1 ,CO1 ,SP1 ,CO1 ,TK1 ,SP1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 },/*sp1*/ -sp01a[]={INV_,LEN_,LEN_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,AND ,GRPE,INV_,INV_,INV_, - INV_,INV_,OPT ,OR ,INV_,REP ,OREP,INV_,SEQ ,LEN_}, - -/* bit nmc nms spc spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -rn01 []={TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,RN1 ,TK1 ,RN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*rn1*/ -rn01a[]={PCI_,PCI_,RNS_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -dg01 []={TK1 ,TK1 ,DN1 ,DG1 ,DG1 ,DG1 ,DG1 ,DG1 ,DG1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,DR1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*dg1*/ -dg01a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,INV_}, - -dn01 []={TK1 ,TK1 ,TK1 ,DN1 ,DN1 ,DN1 ,DN1 ,DN1 ,DN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,DT1 ,TK1 },/*dn1*/ -dn01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,DTAG,INV_}, - -dt01 []={TK1 ,TK1 ,TK1 ,DT1 ,DT1 ,DT1 ,DT1 ,DT1 ,DT1 ,TK1 ,DT1 ,DT1 ,LI1 ,LA1 , - CO1 ,TK1 ,TK1 ,DT1 ,DT1 ,TK1 ,TK1 ,TK1 ,DT1 ,TK1 },/*dt1*/ -dt01a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,INV_,NOP_,NOP_,NOP_,NOP_, - GRPE,INV_,INV_,NOP_,NOP_,INV_,INV_,INV_,NOP_,INV_}, - -/* bit nmc nms spc spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -dr01 []={TK1 ,TK1 ,DG1 ,TK1 ,TK1 ,DR1 ,TK1 ,DR1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*dr1*/ -dr01a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -li01 []={LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,DT1 ,LI1 , - LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 },/*li1*/ -li01a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -la01 []={LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,DT1 , - LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 },/*la1*/ -la01a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -*grcmtab[] = {tk01, tk01a, co01, co01a, er01, er01a, sp01, sp01a, - rn01, rn01a, dg01, dg01a, dn01, dn01a, dt01, dt01a, - dr01, dr01a, li01, li01a, la01, la01a}; -struct parse pcbgrcm = {"GRCM", lexgrp, grcmtab, 0, 0, 0, 0}; -#undef TK1 -#undef CO1 -#undef ER1 -#undef SP1 -#undef RN1 -#undef DG1 -#undef DN1 -#undef DT1 -#undef DR1 -#undef LI1 -#undef LA1 -/* PCBGRCS: State and action table for content model suffix. - If suffix occurs, process it. Otherwise, put character - back for the next parse. -*/ -/* Symbols for state names (end with a number). */ -#define SP4 0 /* Suffix expected. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -sp04 []={SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 , - SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 ,SP4 },/*sp4*/ -sp04a[]={RCR_,RCR_,RCR_,RCR_,RCR_,SYS_,EE_ ,GET_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_, - RCR_,RCR_,OPT ,RCR_,RCR_,REP ,OREP,RCR_,RCR_,RCR_}, - -*grcstab[] = {sp04, sp04a}; -struct parse pcbgrcs = {"GRCS", lexgrp, grcstab, 0, 0, 0, 0}; -#undef SP4 -/* PCBGRNT: State and action table for name token group parse. - Groups cannot nest. Reserved names are not allowed. - No suffixes or data tag pattern groups. -*/ -/* Symbols for state names (end with a number). */ -#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */ -#define CO1 2 /* Connector between tokens expected. */ -#define ER1 4 /* PERO found when token was expected. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -tk02 []={TK1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,CO1 },/*tk1*/ -tk02a[]={INV_,NMT_,NMT_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NMT_}, - -co02 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/ -co02a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,GRPE,INV_,INV_,INV_, - INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NOP_,INV_}, - -er02 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/ -er02a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -*grnttab[] = {tk02, tk02a, co02, co02a, er02, er02a}; -struct parse pcbgrnt = {"GRNT", lexgrp, grnttab, 0, 0, 0, 0}; -#undef TK1 -#undef CO1 -#undef ER1 -/* PCBGRNM: State and action table for name group parse. - Groups cannot nest. Reserved names are not allowed. - No suffixes or data tag pattern groups. -*/ -/* Symbols for state names (end with a number). */ -#define TK1 0 /* Token expected: name, #CHARS, data tag grp, model. */ -#define CO1 2 /* Connector between tokens expected. */ -#define ER1 4 /* PERO found when token was expected. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -tk03 []={TK1 ,TK1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*tk1*/ -tk03a[]={INV_,INV_,NAS_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,INV_}, - -co03 []={TK1 ,TK1 ,TK1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,CO1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*co1*/ -co03a[]={INV_,INV_,INV_,NOP_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,GRPE,INV_,INV_,INV_, - INV_,INV_,INV_,NOP_,INV_,INV_,INV_,INV_,NOP_,INV_}, - -er03 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,ER1 ,TK1 ,ER1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*er1*/ -er03a[]={PCI_,PCI_,PER_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -*grnmtab[] = {tk03, tk03a, co03, co03a, er03, er03a}; -struct parse pcbgrnm = {"GRNM", lexgrp, grnmtab, 0, 0, 0, 0}; -#undef TK1 -#undef CO1 -#undef ER1 -/* PCBREF: State and action table to find the end of entity, parameter entity, - and character references. The opening delimiter and name - have already been found; the parse determines whether the - tokenization of the name ended normally and processes the REFC. -*/ -/* Symbols for state names (end with a number). */ -#define ER5 0 /* Handle REFC or other entity reference termination. */ -#define ER6 2 /* Return to caller and reset state for next call. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -er05 []={ER5 ,ER6 ,ER6 ,ER6 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 , - ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER6 },/*er5*/ -er05a[]={RCR_,LEN_,LEN_,NOP_,RCR_,SYS_,RCR_,GET_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_, - RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,NOP_}, - -er06 []={ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 , - ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 ,ER5 },/*er6*/ -er06a[]={RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_, - RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_,RCR_}, - -*reftab[]={er05, er05a, er06, er06a}; -struct parse pcbref = {"ENTREF", lexgrp, reftab, 0, 0, 0, 0}; -#undef ER5 -#undef ER6 -/* -Use (typical) Name Ending Chsw References RS RE SEP -Parameter literal LITPC LIT/A OK Parm,Char RSM_ LAM_ LAM_ - Data tag template NO -System ID LITC LIT/A n/a none RSM_ LAM_ LAM_ - Processing instruction PIC -Attribute value LITRV LIT/A NO Gen,Char RS_ FUN_ FUN_ -Minimum literal LITV LIT/A n/a none RS_ FUN_ MLE_ -*/ -/* PCBLITP: Literal parse with parameter and character references; - no function character translation. -*/ -/* Symbols for state names (end with a number). */ -#define DA0 0 /* Data in buffer. */ -#define ER0 2 /* ERO found. */ -#define CR0 4 /* CRO found (ER0, RNI). */ -#define PR0 6 /* PRO found (for PCBLITP). */ - -static UNCH -/* free num min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -da13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 , - DA0 ,DA0 ,DA0 ,PR0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da3*/ -da13a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RSM_,MLA_,MLA_,MLA_,NSC_,NOP_, - MLA_,MLA_,MLA_,NOP_,MLA_,MLA_,MLA_,TER_}, - -er13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er3*/ -er13a[]={LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_, - LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_}, - -cr13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr3*/ -cr13a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_, - LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_}, - -pr13 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,PR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*pr3*/ -pr13a[]={LPR_,LPR_,LPR_,PEX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_, - LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_}, - -*litptab[] = {da13, da13a, er13, er13a, cr13, cr13a, pr13, pr13a}; -struct parse pcblitp = {"LITP", lexlms, litptab, 0, 0, 0, 0}; -#undef DA0 -#undef ER0 -#undef CR0 -#undef PR0 -/* PCBLITC: Literal parse; no references; no function char translation. - Used for character data (system data). -*/ -/* Symbols for state names (end with a number). */ -#define DA0 0 /* Data in buffer. */ - -static UNCH -/* free num min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -da2 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da2*/ -da2a[]={MLA_,MLA_,MLA_,MLA_,MLA_,SYS_,EOF_,GET_,RSM_,MLA_,MLA_,MLA_,SYS_,MLA_, - MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_}, - -*litctab[] = {da2, da2a}; -struct parse pcblitc = {"LITC", lexlms, litctab, 0, 0, 0, 0}; -#undef DA0 -/* PCBLITR: Attribute value parse; general and character references; - function chars are translated. -*/ -/* Symbols for state names (end with a number). */ -#define DA0 0 /* Data in buffer. */ -#define ER0 2 /* ERO found. */ -#define CR0 4 /* CRO found (ER0, RNI). */ - -static UNCH -/* free num min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -da11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da1*/ -da11a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RS_ ,FUN_,FUN_,MLA_,NSC_,NOP_, - MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_}, - -er11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er1*/ -er11a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_, - LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_}, - -cr11 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr1*/ -cr11a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_, - LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_}, - -*litrtab[] = {da11, da11a, er11, er11a, cr11, cr11a}; -struct parse pcblitr = {"LITR", lexlms, litrtab, 0, 0, 0, 0}; -#undef DA0 -#undef ER0 -#undef CR0 -/* PCBLITV: Literal parse; no references; RS ignored; RE/SPACE sequences - become single SPACE. Only minimum data characters allowed. -*/ -/* Symbols for state names (end with a number). */ -#define LS0 0 /* Leading SPACE or RE found. */ -#define VA0 2 /* Valid character found. */ -#define SP0 4 /* SPACE/RE sequence begun. */ - -static UNCH -/* free num min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -ls10 []={VA0 ,VA0 ,VA0 ,VA0 ,LS0 ,VA0 ,LS0 ,LS0 ,LS0 ,LS0 ,LS0 ,VA0 ,VA0 ,VA0 , - VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,LS0 },/*ls0*/ -ls10a[]={MLE_,MLA_,MLA_,MLA_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,MLE_,SYS_,SYS_,MLE_, - MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,TER_}, -va10 []={VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,SP0 ,VA0 ,VA0 ,VA0 , - VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,LS0 },/*va0*/ -da10a[]={MLE_,MLA_,MLA_,MLA_,MLA_,SYS_,EOF_,GET_,RS_ ,FUN_,MLE_,SYS_,SYS_,MLE_, - MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,TER_}, -sp10 []={VA0 ,VA0 ,VA0 ,VA0 ,SP0 ,VA0 ,VA0 ,SP0 ,SP0 ,SP0 ,SP0 ,VA0 ,VA0 ,VA0 , - VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,VA0 ,LS0 },/*sp0*/ -sp10a[]={MLE_,MLA_,MLA_,MLA_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,MLE_,SYS_,SYS_,MLE_, - MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,MLE_,RPR_}, - -*litvtab[] = {ls10, ls10a, va10, da10a, sp10, sp10a}; -struct parse pcblitv = {"LITV", lexlms, litvtab, 0, 0, 0, 0}; -#undef LS0 -#undef VA0 -#undef SP0 -/* PCBLITT: Tokenized attribute value parse. -*/ - -/* PCBLITT: Attribute value parse; general and character references; - function chars are translated. -*/ -/* Symbols for state names (end with a number). */ -#define SP0 0 /* Ignore spaces */ -#define DA0 2 /* Data character */ -#define ER0 4 /* ERO found; ignore space */ -#define ER1 6 /* ERO found; don't ignore space */ -#define CR0 8 /* CRO found (ER0, RNI); ignore space */ -#define CR1 10 /* CR0 found; don't ignore space */ - -int pcblittda = DA0; - -static UNCH -/* free num min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ - -sp14 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,SP0 ,SP0 ,SP0 ,SP0 ,DA0 ,DA0 ,ER0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*sp0*/ -sp14a[]={MLA_,MLA_,MLA_,MLA_,NOP_,NON_,EE_ ,GET_,RS_ ,NOP_,NOP_,MLA_,NSC_,NOP_, - MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_}, - -da14 []={DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,DA0 ,SP0 ,SP0 ,DA0 ,DA0 ,ER1 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,SP0 },/*da0*/ -da14a[]={MLA_,MLA_,MLA_,MLA_,MLA_,NON_,EE_ ,GET_,RS_ ,FUN_,FUN_,MLA_,NSC_,NOP_, - MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,MLA_,TER_}, - -er14 []={DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,ER0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 },/*er0*/ -er14a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_, - LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_}, - -er15 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ER1 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,CR1 ,DA0 ,DA0 ,DA0 },/*er1*/ -er15a[]={LPR_,LPR_,LPR_,ERX_,LPR_,LPR_,LPR_,GET_,LPR_,LPR_,LPR_,LPR_,LPR_,LPR_, - LPR_,LPR_,LPR_,LPR_,NOP_,LPR_,LPR_,LPR_}, - -cr14 []={DA0 ,DA0 ,DA0 ,SP0 ,DA0 ,DA0 ,DA0 ,CR0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr0*/ -cr14a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_, - LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_}, - -cr15 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,CR1 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 , - DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*cr1*/ -cr15a[]={LP2_,CRN_,LP2_,CRA_,LP2_,LP2_,LP2_,GET_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_, - LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_,LP2_}, - -*litttab[] = {sp14, sp14a, da14, da14a, er14, er14a, er15, er15a, cr14, cr14a, - cr15, cr15a}; -struct parse pcblitt = {"LITT", lexlms, litttab, 0, 0, 0, 0}; -#undef SP0 -#undef DA0 -#undef ER0 -#undef ER1 -#undef CR0 -#undef CR1 -/* PCBMD: State and action table for markup declaration tokenization. - Columns are based on LEXMARK.C. -*/ -/* Symbols for state names (end with a number). */ -#define SP1 0 /* Separator before token expected. */ -#define TK1 2 /* Token expected. */ -#define CM0 4 /* COM[1] found when sep expected: possible comment, MGRP.*/ -#define CM1 6 /* COM[1] found: possible comment, MGRP, or minus.*/ -#define CM2 8 /* COM[2] found; in comment. */ -#define CM3 10 /* Ending COM[1] found; end comment or continue it. */ -#define PR1 12 /* PERO found when token was expected. */ -#define PX1 14 /* PLUS found: PGRP or error. */ -#define RN1 16 /* RNI found; possible reserved name start. */ - -int pcbmdtk = TK1; /* PCBMD: token expected. */ - -static UNCH -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -sp21 []={SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,TK1 ,SP1 ,TK1 ,CM0 ,SP1 ,TK1 ,TK1 ,TK1 , - TK1 ,SP1 ,PR1 ,PX1 ,SP1 ,RN1 ,SP1 ,SP1 ,SP1 }, -sp21a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,INV_,GRPS,LIT ,LITE, - MDS ,INV_,NOP_,NOP_,INV_,NOP_,EMD ,INV_,INV_}, - -tk21 []={SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,SP1 ,TK1 ,TK1 ,TK1 , - TK1 ,SP1 ,PR1 ,PX1 ,SP1 ,RN1 ,SP1 ,SP1 ,SP1 }, -tk21a[]={INV_,NMT ,NUM ,NAS ,NOP_,SYS_,EE_ ,GET_,RS_ ,NOP_,INV_,GRPS,LIT ,LITE, - MDS ,INV_,NOP_,NOP_,INV_,NOP_,EMD ,INV_,INV_}, - -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -cm20 []={SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,CM0 ,SP1 ,CM0 ,SP1 ,CM2 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 }, -cm20a[]={LNR_,LNR_,LNR_,LNR_,LNR_,SYS_,LNR_,GET_,LNR_,NOP_,LNR_,LNR_,LNR_,LNR_, - LNR_,LNR_,LNR_,LNR_,LNR_,LNR_,LNR_,LNR_,LNR_}, - -cm21 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,CM1 ,TK1 ,CM2 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 }, -cm21a[]={CDR ,CDR ,CDR ,CDR ,CDR ,SYS_,CDR ,GET_,CDR ,NOP_,CDR ,MGRP,CDR ,CDR , - CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR ,CDR }, - -cm22 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,TK1 ,CM2 ,CM2 ,CM3 ,CM2 ,CM2 ,CM2 ,CM2 , - CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 }, -cm22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -cm23 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM3 ,TK1 ,CM3 ,CM2 ,TK1 ,CM2 ,CM2 ,CM2 ,CM2 , - CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 }, -cm23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -pr21 []={SP1 ,SP1 ,SP1 ,TK1 ,TK1 ,PR1 ,SP1 ,PR1 ,TK1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 ,SP1 }, -pr21a[]={PCI_,PCI_,PCI_,PER_,PEN ,SYS_,PENR,GET_,PEN ,PENR,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PENR,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -px21 []={SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,PX1 ,SP1 ,PX1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 }, -px21a[]={PCI_,PCI_,PCI_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PGRP,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -rn21 []={TK1 ,TK1 ,TK1 ,SP1 ,TK1 ,RN1 ,TK1 ,RN1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 , - TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 }, -rn21a[]={PCI_,PCI_,PCI_,RNS ,PCI_,SYS_,PCI_,GET_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -*mdtab[] = {sp21, sp21a, tk21, tk21a, cm20, cm20a, cm21, cm21a, cm22, cm22a, - cm23, cm23a, pr21, pr21a, px21, px21a, rn21, rn21a}; -struct parse pcbmd = {"MD", lexmark, mdtab, 0, 0, 0, 0}; -#undef SP1 -#undef TK1 -#undef CM0 -#undef CM1 -#undef CM2 -#undef CM3 -#undef PR1 -#undef PX1 -#undef RN1 -/* PCBMDC: State and action table for comment declaration. -*/ -/* Symbols for state names (end with a number). */ -#define CD2 0 /* COM[2] found; in comment. */ -#define CD3 2 /* Ending COM[1] found; end comment or continue it. */ -#define EM1 4 /* Ending COM[2] found; start new comment or end. */ -#define CD1 6 /* COM[1] found; new comment or error. */ - -static UNCH -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -cd22 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD3 ,CD2 ,CD2 ,CD2 ,CD2 , - CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 }, -cd22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -cd23 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD3 ,CD2 ,CD3 ,CD2 ,EM1 ,CD2 ,CD2 ,CD2 ,CD2 , - CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 }, -cd23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -em21 []={CD2 ,CD2 ,CD2 ,CD2 ,EM1 ,EM1 ,CD2 ,EM1 ,EM1 ,CD1 ,CD2 ,CD2 ,CD2 ,CD2 , - CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 }, -em21a[]={INV_,INV_,INV_,INV_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,INV_,INV_,EMD ,INV_,INV_}, - -cd21 []={CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD1 ,CD2 ,CD1 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 , - CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 ,CD2 }, -cd21a[]={PCI_,PCI_,PCI_,PCI_,PCI_,SYS_,EOF_,GET_,PCI_,NOP_,PCI_,PCI_,PCI_,PCI_, - PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_,PCI_}, - -*mdctab[] = {cd22, cd22a, cd23, cd23a, em21, em21a, cd21, cd21a}; -struct parse pcbmdc = {"MDC", lexmark, mdctab, 0, 0, 0, 0}; -#undef CD2 -#undef CD3 -#undef EM1 -#undef CD1 -/* PCBMDI: State and action table for ignoring markup declarations. - Literals are handled properly so a TAGC won't end the declaration. - An error is noted if the entity ends within a declaration that - is being ignored. - TO DO: Handle nested declaration sets. -*/ -/* Symbols for state names (end with a number). */ -#define NC1 0 /* Not in a comment; TAGC ends declaration. */ -#define IC1 2 /* COM[1] found; possible comment. */ -#define IC2 4 /* COM[2] found; in comment. */ -#define IC3 6 /* Ending COM[1] found; end comment or continue it. */ -#define LI1 8 /* Literal parameter; search for LIT. */ -#define LA1 10 /* Literal parameter; search for LITA. */ - -static UNCH -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -nc21 []={NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,IC1 ,NC1 ,NC1 ,LI1 ,LA1 , - NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 }, -nc21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,EMD ,NOP_,NOP_}, - -ic21 []={NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,IC1 ,NC1 ,IC1 ,NC1 ,IC2 ,NC1 ,NC1 ,LI1 ,LA1 , - NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 ,NC1 }, -ic21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,EMD ,NOP_,NOP_}, - -ic22 []={IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,NC1 ,IC2 ,IC2 ,IC3 ,IC2 ,IC2 ,IC2 ,IC2 , - IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 }, -ic22a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -ic23 []={IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC3 ,NC1 ,IC3 ,IC2 ,NC1 ,IC2 ,IC2 ,IC2 ,IC2 , - IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 ,IC2 },/*ic3*/ -ic23a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -li21 []={LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,NC1 ,LI1 , - LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 ,LI1 },/*li1*/ -li21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -la21 []={LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,NC1 , - LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 ,LA1 },/*la1*/ -la21a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -*mditab[] = {nc21, nc21a, ic21, ic21a, ic22, ic22a, - ic23, ic23a, li21, li21a, la21, la21a}; -struct parse pcbmdi = {"MDI", lexmark, mditab, 0, 0, 0, 0}; -#undef NC1 -#undef IC1 -#undef IC2 -#undef IC3 -#undef LI1 -#undef LA1 -/* PCBMSRC: State and action table for marked section in RCDATA mode. - Nested marked sections are not recognized; the first MSE ends it. - Initial state assumes an MS declaration was processed. - Columns are based on LEXLMS.C but LITC column needn't exist. -*/ -/* Symbols for state names (end with a number). */ -#define ET0 0 /* MSS processed or buffer flushed; no data. */ -#define DA0 2 /* Data in buffer. */ -#define ER0 4 /* ERO found; start lookahead buffer. */ -#define CR0 6 /* CRO found (ER0, RNI). */ -#define ME0 8 /* MSC found. */ -#define ME1 10 /* MSC, MSC found. */ - -static UNCH -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -et30 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 ,ER0 , - DA0 ,ME0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*et0*/ -et30a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EE_ ,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,LAS_, - DAS_,LAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_}, - -da30 []={DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,DA0 ,DA0 ,ET0 ,ET0 , - DA0 ,ET0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 ,DA0 },/*da0*/ -da30a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,DAF_, - NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -er30 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ER0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 },/*er0*/ -er30a[]={LAF_,LAF_,LAF_,ERX_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAM_,LAF_,LAF_,LAF_}, - -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -cr30 []={ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,CR0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 , - ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 ,ET0 },/*cr0*/ -cr30a[]={LAF_,CRN_,LAF_,CRA_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -me30 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME0, ET0 ,ET0 ,ET0 ,ET0, ET0 ,ET0 , - ET0, ME1, ET0 ,ET0, ET0 ,ET0, ET0 ,ET0 },/*me0*/ -me30a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -me31 []={ET0, ET0, ET0, ET0, ET0 ,ET0, ET0, ME1, ET0 ,ET0 ,ET0 ,ET0, ET0 ,ET0 , - ET0, ET0, ET0 ,ET0, ET0 ,ET0, ET0 ,ET0,},/*me1*/ -me31a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,MSE_,LAF_,LAF_}, - -*msrctab[]={et30, et30a, da30, da30a, er30, er30a, cr30, cr30a, - me30, me30a, me31, me31a}; -struct parse pcbmsrc = {"MSRCDATA", lexlms, msrctab, 0, 0, 0, 0}; -#undef ET0 -#undef DA0 -#undef ER0 -#undef CR0 -#undef ME0 -#undef ME1 -/* PCBMSC: State and action table for marked section in CDATA mode. - Nested marked sections are not recognized; the first MSE ends it. - Initial state assumes an MS declaration was processed. -*/ -/* Symbols for state names (end with a number). */ -#define ET2 0 /* MSS processed or buffer flushed; no data. */ -#define DA2 2 /* Data in buffer. */ -#define ME2 4 /* MSC found. */ -#define ME3 6 /* MSC, MSC found. */ - -static UNCH -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -et32 []={DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,DA2 ,DA2 ,ET2 ,DA2 , - DA2 ,ME2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 },/*et2*/ -et32a[]={DAS_,DAS_,DAS_,DAS_,DAS_,NON_,EOF_,GET_,RS_ ,REF_,DAS_,DAS_,NSC_,DAS_, - DAS_,LAS_,DAS_,DAS_,DAS_,DAS_,DAS_,DAS_}, - -da32 []={DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,ET2 ,ET2 ,ET2 ,ET2 ,ET2 ,DA2 ,DA2 ,ET2 ,DA2 , - DA2 ,ET2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 ,DA2 },/*da2*/ -da32a[]={NOP_,NOP_,NOP_,NOP_,NOP_,DAF_,DAF_,DAF_,DAF_,DAF_,NOP_,NOP_,DAF_,NOP_, - NOP_,DAF_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -me32 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME2, ET2 ,ET2 ,ET2 ,ET2, ET2 ,ET2 , - ET2, ME3, ET2 ,ET2, ET2 ,ET2, ET2, ET2,},/*me2*/ -me32a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAM_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_}, - -me33 []={ET2, ET2, ET2, ET2, ET2 ,ET2, ET2, ME3, ET2 ,ET2 ,ET2 ,ET2, ET2 ,ET2 , - ET2, ET2, ET2 ,ET2, ET2 ,ET2, ET2, ET2,},/*me3*/ -me33a[]={LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_,GET_,LAF_,LAF_,LAF_,LAF_,LAF_,LAF_, - LAF_,LAF_,LAF_,LAF_,LAF_,MSE_,LAF_,LAF_}, - -*msctab[]={et32, et32a, da32, da32a, me32, me32a, me33, me33a}; -struct parse pcbmsc = {"MSCDATA", lexlms, msctab, 0, 0, 0, 0}; -#undef ET2 -#undef DA2 -#undef ME2 -#undef ME3 -/* PCBMSI: State and action table for marked section in IGNORE mode. - Nested marked sections are recognized; the matching MSE ends it. - Initial state assumes an MS declaration, MSS, or MSE was processed. -*/ -/* Symbols for state names (end with a number). */ -#define ET4 0 /* Markup found or buffer flushed; no data. */ -#define ME4 2 /* MSC found. */ -#define ME5 4 /* MSC, MSC found. */ -#define ES4 6 /* TAGO found. */ -#define MD4 8 /* MDO found (TAGO, MDO[2]). */ - -static UNCH -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc refc */ -et34 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 , - ET4 ,ME4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ET4 },/*et4*/ -et34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -me34 []={ET4, ET4, ET4, ET4, ET4 ,ET4, ET4, ME4, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 , - ET4, ME5 ,ET4, ET4, ET4 ,ET4, ET4, ET4, ET4,},/*me4*/ -me34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -me35 []={ET4, ET4, ET4, ET4, ET4 ,ET4, ET4, ME5, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 , - ET4, ET4 ,ET4, ET4, ET4 ,ET4, ET4, ET4, ET4,},/*me5*/ -me35a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,MSE_,NOP_,NOP_,NOP_}, - -/* free nu min nms spc non ee eob rs re sep cde nsc ero - mdo msc mso pero rni tagc tago litc */ -es34 []={ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 ,ES4 ,ET4 ,ET4 ,ET4 ,ET4 ,ES4 ,ET4 , - MD4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 ,ET4 },/*es4*/ -es34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -md34 []={ET4, ET4, ET4, ET4, ET4 ,MD4, ET4, MD4, ET4 ,ET4 ,ET4 ,ET4, ET4, ET4 , - ET4, ET4 ,ET4, ET4, ET4 ,ET4, ET4, ET4,},/*md4*/ -md34a[]={NOP_,NOP_,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,SYS_,NOP_, - NOP_,NOP_,MSS_,NOP_,NOP_,NOP_,NOP_,NOP_}, - -*msitab[]={et34, et34a, me34, me34a, me35, me35a, es34, es34a, md34, md34a}; -struct parse pcbmsi = {"MSIGNORE", lexlms, msitab, 0, 0, 0, 0}; -#undef ET4 -#undef ME4 -#undef ME5 -#undef ES4 -#undef MD4 -#undef NS4 -/* PCBSTAG: State and action table for start-tag parse. - Columns are based on LEXMARK.C. -*/ -/* Symbols for state names (end with a number). */ -#define SP1 0 /* Separator before name expected. */ -#define AN1 2 /* Attribute name expected. */ -#define SP2 4 /* Separator or value indicator expected. */ -#define VI1 6 /* Value indicator expected. */ -#define AV1 8 /* Attribute value expected. */ - -int pcbstan = AN1; /* PCBSTAG: attribute name expected. */ - -static UNCH -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -sp41 []={SP1 ,SP1 ,SP1 ,SP1 ,AN1 ,SP1 ,SP1 ,SP1 ,AN1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 }, -sp41a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,ETIC,INV_,INV_,INV_, - INV_,DSC ,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_}, - -an41 []={SP1 ,SP1 ,SP1 ,SP2 ,AN1 ,AN1 ,AN1 ,AN1 ,AN1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 }, -an41a[]={INV_,NTV ,NTV ,NVS ,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,ETIC,INV_,INV_,INV_, - INV_,DSC ,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_}, - -sp42 []={SP1 ,SP1 ,SP1 ,SP1 ,VI1 ,SP2 ,SP2 ,SP2 ,VI1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,AV1 }, -sp42a[]={INV_,LEN_,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,NASV,INV_,INV_,INV_, - INV_,NASV,INV_,INV_,INV_,INV_,NASV,NASV,NOP_}, - -/* bit nmc num nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -vi41 []={SP1 ,AN1 ,AN1 ,AN1 ,VI1 ,VI1 ,VI1 ,VI1 ,VI1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,AV1 }, -vi41a[]={INV_,NASV,NASV,NASV,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,NASV,INV_,INV_,INV_, - INV_,NASV,INV_,INV_,INV_,INV_,NASV,NASV,NOP_}, - -av41 []={SP1 ,SP1 ,SP1 ,SP1 ,AV1 ,AV1 ,AV1 ,AV1 ,AV1 ,SP1 ,SP1 ,SP1 ,AN1 ,AN1 , - SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 ,SP1 }, -av41a[]={INV_,AVU ,AVU ,AVU ,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,AVD ,AVDA, - INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_}, - -*stagtab[] = {sp41, sp41a, an41, an41a, sp42, sp42a, vi41, vi41a, av41, av41a}; -struct parse pcbstag = {"STAG", lexmark, stagtab, 0, 0, 0, 0}; -#undef SP1 -#undef AN1 -#undef SP2 -#undef VI1 -#undef AV1 -/* PCBETAG: State and action table for end-tag parse. -*/ -#define TC1 0 /* Tag close expected (no attributes allowed). */ - -static UNCH -/* bit nmc nu nms spc non ee eob rs com eti grpo lit lita - dso dsc pero plus refc rni tagc tago vi */ -tc41 []={TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 , - TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 ,TC1 },/*tc1*/ -tc41a[]={INV_,INV_,INV_,INV_,NOP_,SYS_,EOF_,GET_,RS_ ,INV_,INV_,INV_,INV_,INV_, - INV_,INV_,INV_,INV_,INV_,INV_,TAGC,TAGO,INV_}, - -*etagtab[] = {tc41, tc41a}; -struct parse pcbetag = {"ETAG", lexmark, etagtab, 0, 0, 0, 0}; -#undef TC1 -/* PCBVAL: State and action table for tokenizing attribute values. - Columns are based on lextoke (but EOB cannot occur). -*/ -/* Symbols for state names (end with a number). */ -#define TK1 0 /* Token expected. */ -#define SP1 2 /* Separator before token expected. */ - -static UNCH -/* inv rec sep sp nmc nms nu eob */ -tk51 []={TK1 ,TK1 ,TK1 ,TK1 ,SP1 ,SP1 ,SP1 },/*tk1*/ -tk51a[]={INVA,INVA,INVA,NOPA,NMTA,NASA,NUMA}, - -sp51 []={TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 },/*sp1*/ -sp51a[]={INVA,INVA,INVA,NOPA,LENA,LENA,LENA}, - -*valtab[] = {tk51, tk51a, sp51, sp51a}; -struct parse pcbval = {"VAL", lextoke, valtab, 0, 0, 0, 0}; -#undef TK1 -#undef SP1 -/* PCBEAL: State and action table for end of attribute specification list. - If delimiter occurs, process it. Otherwise, put invalid character - back for the next parse. -*/ -/* Symbols for state names (end with a number). */ -#define AL0 0 /* Delimiter expected. */ - -static UNCH -/* bit nmc nms re spc non ee eob rs and grpc grpo lit lita - dtgc dtgo opt or pero plus rep rni seq refc */ -al00 []={AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 , - AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 ,AL0 },/*al0*/ -al00a[]={INV_,INV_,INV_,INV_,INV_,SYS_,EE_ ,GET_,INV_,INV_,INV_,INV_,INV_,INV_, - GRPE,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_,INV_}, - -*ealtab[] = {al00, al00a}; -struct parse pcbeal = {"EAL", lexgrp, ealtab, 0, 0, 0, 0}; -#undef AL0 - -/* PCBSD: State and action tables for SGML declaration parsing. */ - -/* Symbols for state names. */ - -#define SP1 0 /* Separator before token expected. */ -#define TK1 2 /* Token expected. */ -#define CM0 4 /* COM[1] found when sep expected: possible comment.*/ -#define CM1 6 /* COM[1] found: possible comment.*/ -#define CM2 8 /* COM[2] found; in comment. */ -#define CM3 10 /* Ending COM[1] found; end comment or continue it. */ - -static UNCH -/* sig dat num nms spc non ee eob rs com lit lita tagc */ - -sp31 []={SP1 ,SP1 ,SP1 ,SP1 ,TK1 ,SP1 ,SP1 ,SP1 ,TK1 ,CM0 ,TK1 ,TK1 ,SP1 }, -sp31a[]={INV_,ISIG,LEN_,LEN_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,LIT1,LIT2,ESGD}, - -tk31 []={TK1 ,TK1 ,SP1 ,SP1 ,TK1 ,TK1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,TK1 ,SP1 }, -tk31a[]={INV_,ISIG,NUM1,NAS1,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,LIT1,LIT2,ESGD}, - -cm30 []={SP1 ,CM0 ,SP1 ,SP1 ,SP1 ,CM0 ,SP1 ,CM0 ,SP1 ,CM2 ,SP1 ,SP1 ,SP1 }, -cm30a[]={PCI_,ISIG,PCI_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,NOP_,PCI_,PCI_,PCI_}, - -cm31 []={TK1 ,CM1 ,TK1 ,TK1 ,TK1 ,CM1 ,TK1 ,CM1 ,TK1 ,CM2 ,TK1 ,TK1 ,TK1 }, -cm31a[]={PCI_,ISIG,PCI_,PCI_,PCI_,SYS_,PCI_,GET_,PCI_,NOP_,PCI_,PCI_,PCI_}, - -cm32 []={CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,CM2 ,TK1 ,CM2 ,CM2 ,CM3 ,CM2 ,CM2 ,CM2 }, -cm32a[]={NOP_,ISIG,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_}, - -cm33 []={CM2 ,CM3 ,CM2 ,CM2 ,CM2 ,CM3 ,TK1 ,CM3 ,CM2 ,TK1 ,CM2 ,CM2 ,CM2 }, -cm33a[]={NOP_,ISIG,NOP_,NOP_,NOP_,SYS_,EOF_,GET_,RS_ ,NOP_,NOP_,NOP_,NOP_}, - -*sdtab[]={sp31, sp31a, tk31, tk31a, cm30, cm30a, cm31, cm31a, cm32, cm32a, - cm33, cm33a}; - -struct parse pcbsd = {"SD", lexsd, sdtab, 0, 0, 0, 0}; - -#undef SP1 -#undef TK1 -#undef CM0 -#undef CM1 -#undef CM2 -#undef CM3 diff --git a/cde/programs/dtdocbook/sgmls/portproc.c b/cde/programs/dtdocbook/sgmls/portproc.c deleted file mode 100644 index 428c25798..000000000 --- a/cde/programs/dtdocbook/sgmls/portproc.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: portproc.c /main/3 1996/06/19 17:16:49 drk $ */ -/* portproc.c - - - Semi-portable implementation of run_process(). - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifdef SUPPORT_SUBDOC - -#include "std.h" -#include "entity.h" -#include "appl.h" - -/* This code shows how you might use system() to implement run_process(). -ANSI C says very little about the behaviour of system(), and so this -is necessarily system dependent. */ - -/* Characters that are significant to the shell and so need quoting. */ -#define SHELL_MAGIC "$\\\"';&()|<>^ \t\n" -/* Character with which to quote shell arguments. */ -#define SHELL_QUOTE_CHAR '\'' -/* String that can be used to get SHELL_QUOTE_CHAR into a quoted argument. */ -#define SHELL_ESCAPE_QUOTE "'\\''" -/* Character that can be used to separate arguments to the shell. */ -#define SHELL_ARG_SEP ' ' - -static UNS shell_quote P((char *, char *)); - -int run_process(argv) -char **argv; -{ - char **p; - char *s, *command; - int ret; - UNS len = 0; - - for (p = argv; *p; p++) - len += shell_quote(*p, (char *)0); - len += p - argv; - s = command = xmalloc(len); - for (p = argv; *p; ++p) { - if (s > command) - *s++ = SHELL_ARG_SEP; - s += shell_quote(*p, s); - } - *s++ = '\0'; - errno = 0; - ret = system(command); - if (ret < 0) - appl_error(E_EXEC, argv[0], strerror(errno)); - free(command); - return ret; -} - -/* Quote a string so that it appears as a single argument to the -shell (as used for system()). Store the quoted argument in result, if -result is not NULL. Return the length. */ - -static -UNS shell_quote(s, result) -char *s, *result; -{ - UNS len = 0; - int quoted = 0; - - if (strpbrk(s, SHELL_MAGIC)) { - quoted = 1; - len++; - if (result) - result[0] = SHELL_QUOTE_CHAR; - } - for (; *s; s++) { - if (*s == SHELL_QUOTE_CHAR) { - if (result) - strcpy(result + len, SHELL_ESCAPE_QUOTE); - len += strlen(SHELL_ESCAPE_QUOTE); - } - else { - if (result) - result[len] = *s; - len++; - } - } - if (quoted) { - if (result) - result[len] = SHELL_QUOTE_CHAR; - len++; - } - return len; -} - -#endif /* SUPPORT_SUBDOC */ - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/rast.c b/cde/programs/dtdocbook/sgmls/rast.c deleted file mode 100644 index 269217fbe..000000000 --- a/cde/programs/dtdocbook/sgmls/rast.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: rast.c /main/3 1996/06/19 17:16:53 drk $ */ -/* rast.c - Translate sgmls output to RAST result format. - - Written by James Clark (jjc@jclark.com). */ - -#include "config.h" -#include "std.h" -#include "sgmls.h" -#include "getopt.h" - -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif - -#ifdef __GNUC__ -#define NO_RETURN volatile -#else -#define NO_RETURN /* as nothing */ -#endif - -#ifdef VARARGS -#define VP(parms) () -#else -#define VP(parms) P(parms) -#endif - -#ifdef USE_ISASCII -#define ISASCII(c) isascii(c) -#else -#define ISASCII(c) (1) -#endif - -NO_RETURN void error VP((char *,...)); - -static void input_error P((int, char *, unsigned long)); -static int do_file P((FILE *)); -static void usage P((void)); - -static void output_processing_instruction P((char *, unsigned)); -static void output_data P((struct sgmls_data *, int)); -static void output_data_lines P((char *, unsigned)); -static void output_internal_sdata P((char *, unsigned)); -static void output_external_entity P((struct sgmls_external_entity *)); -static void output_external_entity_info P((struct sgmls_external_entity *)); -static void output_element_start P((char *, struct sgmls_attribute *)); -static void output_element_end P((char *)); -static void output_attribute P((struct sgmls_attribute *)); -static void output_tokens P((char **, int)); -static void output_markup_chars P((char *, unsigned)); -static void output_markup_string P((char *)); -static void output_char P((int, int)); -static void output_flush P((int)); -static void output_external_id P((char *, char *)); -static void output_entity P((struct sgmls_entity *)); -static void output_external_entity_info P((struct sgmls_external_entity *)); -static void output_internal_entity P((struct sgmls_internal_entity *)); - -#define output_flush_markup() output_flush('!') -#define output_flush_data() output_flush('|') - -static FILE *outfp; -static int char_count = 0; -static char *program_name; - -int main(argc, argv) - int argc; - char **argv; -{ - int c; - int opt; - char *output_file = 0; - - program_name = argv[0]; - - while ((opt = getopt(argc, argv, "o:")) != EOF) - switch (opt) { - case 'o': - output_file = optarg; - break; - case '?': - usage(); - default: - abort(); - } - - if (output_file) { - errno = 0; - outfp = fopen(output_file, "w"); - if (!outfp) - error("couldn't open `%s' for output: %s", strerror(errno)); - } - else { - outfp = tmpfile(); - if (!outfp) - error("couldn't create temporary file: %s", strerror(errno)); - } - - if (argc - optind > 1) - usage(); - - if (argc - optind == 1) { - if (!freopen(argv[optind], "r", stdin)) - error("couldn't open `%s' for input: %s", argv[optind], strerror(errno)); - } - - (void)sgmls_set_errhandler(input_error); - - if (!do_file(stdin)) { - fclose(outfp); - if (output_file) { - if (!freopen(output_file, "w", stdout)) - error("couldn't reopen `%s' for output: %s", strerror(errno)); - } - fputs("#ERROR\n", stdout); - exit(EXIT_FAILURE); - } - - if (output_file) { - errno = 0; - if (fclose(outfp) == EOF) - error("error closing `%s': %s", output_file, strerror(errno)); - } - else { - errno = 0; - if (fseek(outfp, 0L, SEEK_SET)) - error("couldn't rewind temporary file: %s", strerror(errno)); - while ((c = getc(outfp)) != EOF) - if (putchar(c) == EOF) - error("error writing standard output: %s", strerror(errno)); - } - exit(EXIT_SUCCESS); -} - -static -void usage() -{ - fprintf(stderr, "usage: %s [-o output_file] [input_file]\n", program_name); - exit(EXIT_FAILURE); -} - -static -int do_file(fp) - FILE *fp; -{ - struct sgmls *sp; - struct sgmls_event e; - int conforming = 0; - - sp = sgmls_create(fp); - while (sgmls_next(sp, &e)) - switch (e.type) { - case SGMLS_EVENT_DATA: - output_data(e.u.data.v, e.u.data.n); - break; - case SGMLS_EVENT_ENTITY: - output_external_entity(e.u.entity); - break; - case SGMLS_EVENT_PI: - output_processing_instruction(e.u.pi.s, e.u.pi.len); - break; - case SGMLS_EVENT_START: - output_element_start(e.u.start.gi, e.u.start.attributes); - sgmls_free_attributes(e.u.start.attributes); - break; - case SGMLS_EVENT_END: - output_element_end(e.u.end.gi); - break; - case SGMLS_EVENT_SUBSTART: - { - int level = 1; - output_external_entity(e.u.entity); - while (level > 0) { - if (!sgmls_next(sp, &e)) - return 0; - switch (e.type) { - case SGMLS_EVENT_SUBSTART: - level++; - break; - case SGMLS_EVENT_SUBEND: - level--; - break; - case SGMLS_EVENT_START: - sgmls_free_attributes(e.u.start.attributes); - break; - default: - /* prevent compiler warnings */ - break; - } - } - } - break; - case SGMLS_EVENT_APPINFO: - break; - case SGMLS_EVENT_CONFORMING: - conforming = 1; - break; - default: - abort(); - } - sgmls_free(sp); - return conforming; -} - -static -void output_processing_instruction(s, len) - char *s; - unsigned len; -{ - fputs("[?", outfp); - if (len > 0) { - putc('\n', outfp); - output_data_lines(s, len); - output_flush_data(); - } - fputs("]\n", outfp); -} - -static -void output_data(v, n) - struct sgmls_data *v; - int n; -{ - int i; - for (i = 0; i < n; i++) { - if (v[i].is_sdata) - output_internal_sdata(v[i].s, v[i].len); - else if (v[i].len > 0) - output_data_lines(v[i].s, v[i].len); - } -} - -static -void output_data_lines(s, n) - char *s; - unsigned n; -{ - assert(n > 0); - for (; n > 0; --n) - output_char((unsigned char)*s++, '|'); - output_flush_data(); -} - -static -void output_internal_sdata(s, n) - char *s; - unsigned n; -{ - fputs("#SDATA-TEXT\n", outfp); - output_markup_chars(s, n); - output_flush_markup(); - fputs("#END-SDATA\n", outfp); -} - -static -void output_external_entity(e) - struct sgmls_external_entity *e; -{ - fprintf(outfp, "[&%s\n", e->name); - output_external_entity_info(e); - fputs("]\n", outfp); -} - -static -void output_element_start(gi, att) - char *gi; - struct sgmls_attribute *att; -{ - fprintf(outfp, "[%s", gi); - if (att) { - struct sgmls_attribute *p; - putc('\n', outfp); - for (p = att; p; p = p->next) - output_attribute(p); - } - fputs("]\n", outfp); -} - -static -void output_element_end(gi) - char *gi; -{ - fprintf(outfp, "[/%s]\n", gi); -} - -static -void output_attribute(p) - struct sgmls_attribute *p; -{ - fprintf(outfp, "%s=\n", p->name); - switch (p->type) { - case SGMLS_ATTR_IMPLIED: - fputs("#IMPLIED\n", outfp); - break; - case SGMLS_ATTR_CDATA: - { - struct sgmls_data *v = p->value.data.v; - int n = p->value.data.n; - int i; - for (i = 0; i < n; i++) - if (v[i].is_sdata) - output_internal_sdata(v[i].s, v[i].len); - else { - output_markup_chars(v[i].s, v[i].len); - output_flush_markup(); - } - } - break; - case SGMLS_ATTR_TOKEN: - output_tokens(p->value.token.v, p->value.token.n); - break; - case SGMLS_ATTR_ENTITY: - { - int i; - for (i = 0; i < p->value.entity.n; i++) { - struct sgmls_entity *e = p->value.entity.v[i]; - char *name; - - if (e->is_internal) - name = e->u.internal.name; - else - name = e->u.external.name; - if (i > 0) - output_markup_string(" "); - output_markup_string(name); - } - output_flush_markup(); - for (i = 0; i < p->value.entity.n; i++) - output_entity(p->value.entity.v[i]); - } - break; - case SGMLS_ATTR_NOTATION: - output_tokens(&p->value.notation->name, 1); - output_external_id(p->value.notation->pubid, p->value.notation->sysid); - break; - } -} - -static void output_tokens(v, n) - char **v; - int n; -{ - int i; - assert(n > 0); - output_markup_string(v[0]); - for (i = 1; i < n; i++) { - output_markup_string(" "); - output_markup_string(v[i]); - } - output_flush_markup(); -} - -static -void output_markup_chars(s, n) - char *s; - unsigned n; -{ - for (; n > 0; --n) - output_char((unsigned char)*s++, '!'); -} - -static -void output_markup_string(s) - char *s; -{ - while (*s) - output_char((unsigned char)*s++, '!'); -} - -static -void output_char(c, delim) - int c; - int delim; -{ - if (ISASCII(c) && isprint(c)) { - if (char_count == 0) - putc(delim, outfp); - putc(c, outfp); - char_count++; - if (char_count == 60) { - putc(delim, outfp); - putc('\n', outfp); - char_count = 0; - } - } - else { - output_flush(delim); - switch (c) { - case RECHAR: - fputs("#RE\n", outfp); - break; - case RSCHAR: - fputs("#RS\n", outfp); - break; - case TABCHAR: - fputs("#TAB\n", outfp); - break; - default: - fprintf(outfp, "#%d\n", c); - } - } -} - -static -void output_flush(delim) - int delim; -{ - if (char_count > 0) { - putc(delim, outfp); - putc('\n', outfp); - char_count = 0; - } -} - -static -void output_external_id(pubid, sysid) - char *pubid; - char *sysid; -{ - if (!pubid && !sysid) - fputs("#SYSTEM\n#NONE\n", outfp); - else { - if (pubid) { - fputs("#PUBLIC\n", outfp); - if (*pubid) { - output_markup_string(pubid); - output_flush_markup(); - } - else - fputs("#EMPTY\n", outfp); - } - if (sysid) { - fputs("#SYSTEM\n", outfp); - if (*sysid) { - output_markup_string(sysid); - output_flush_markup(); - } - else - fputs("#EMPTY\n", outfp); - } - } -} - -static -void output_entity(e) - struct sgmls_entity *e; -{ - if (e->is_internal) - output_internal_entity(&e->u.internal); - else - output_external_entity_info(&e->u.external); - fputs("#END-ENTITY", outfp); -#ifndef ASIS - putc('\n', outfp); -#endif -} - -static -void output_external_entity_info(e) - struct sgmls_external_entity *e; -{ - switch (e->type) { - case SGMLS_ENTITY_CDATA: - fputs("#CDATA-EXTERNAL", outfp); - break; - case SGMLS_ENTITY_SDATA: - fputs("#SDATA-EXTERNAL", outfp); - break; - case SGMLS_ENTITY_NDATA: - fputs("#NDATA-EXTERNAL", outfp); - break; - case SGMLS_ENTITY_SUBDOC: - fputs("#SUBDOC", outfp); - break; - } - putc('\n', outfp); - output_external_id(e->pubid, e->sysid); - if (e->type != SGMLS_ENTITY_SUBDOC) { - struct sgmls_attribute *p; - fprintf(outfp, "#NOTATION=%s\n", e->notation->name); - output_external_id(e->notation->pubid, e->notation->sysid); - for (p = e->attributes; p; p = p->next) - output_attribute(p); - } -} - -static -void output_internal_entity(e) - struct sgmls_internal_entity *e; -{ - if (e->data.is_sdata) - fputs("#SDATA-INTERNAL", outfp); - else - fputs("#CDATA-INTERNAL", outfp); - putc('\n', outfp); - output_markup_chars(e->data.s, e->data.len); - output_flush_markup(); -} - -static -void input_error(num, str, lineno) - int num; - char *str; - unsigned long lineno; -{ - error("Error at input line %lu: %s", lineno, str); -} - -NO_RETURN -#ifdef VARARGS -void error(va_alist) va_dcl -#else -void error(char *message,...) -#endif -{ -#ifdef VARARGS - char *message; -#endif - va_list ap; - - fprintf(stderr, "%s: ", program_name); -#ifdef VARARGS - va_start(ap); - message = va_arg(ap, char *); -#else - va_start(ap, message); -#endif - vfprintf(stderr, message, ap); - va_end(ap); - fputc('\n', stderr); - fflush(stderr); - exit(EXIT_FAILURE); -} diff --git a/cde/programs/dtdocbook/sgmls/rast.man b/cde/programs/dtdocbook/sgmls/rast.man deleted file mode 100644 index 2d167fc86..000000000 --- a/cde/programs/dtdocbook/sgmls/rast.man +++ /dev/null @@ -1,75 +0,0 @@ -.\" -*- nroff -*- -.tr \(ts" -.TH RAST 1 -.SH NAME -rast \- translate output of sgmls to RAST format -.SH SYNOPSIS -.B rast -[ -.BI \-o output_file -] -[ -.I input_file -] -.SH DESCRIPTION -.I Rast -translates the output of sgmls to the format of a RAST result. -RAST is the Reference Application for SGML Testing defined in the Proposed -American National Standard on Conformance Testing for Standard Generalized -Markup Language (SGML) Systems (X3.190-199X). -.I Rast -reads from -.I input_file -or from standard input if -.I input_file -is not specified. -It writes to -.I output_file -or to standard output if -.I output_file -is not specified; -use of the -.B \-o -option avoids the need for -.I rast -to use a temporary file. -.LP -Note that the -.B -c -option of -.I sgmls -can generate a capacity report in RACT format. -.SH BUGS -Production [9] in clause 14.5.5 of the draft standard is clearly wrong; -.I rast -corrects it by appending -.RI `,\ LE '. -An alternative way to correct it would be to delete the -.RB `, \(tsEND-ENTITY\(ts '. -.LP -In production [18] in clause 14.5.9, -.RI ` markup\ data +' -should be -.RI ` markup\ data *' -since internal sdata entities need not contain any characters (14.5.11), -and -.I markup\ data -cannot be empty (14.5.9, 14.5.12). -.LP -The RAST result for the example in Annex B.4 is incorrect. -The line -.B G03-A1= -should be immediately followed by a line -.BR !g03-e1! . -(The problem with production [9] also applies to this example.) -.LP -.I Rast -outputs a newline after -.B #ERROR -in order to avoid producing files with partial lines. -.SH "SEE ALSO" -.IR sgmls (1) -.br -.I -Conformance Testing for Standard Generalized Markup Language (SGML) Systems, -(X3.190-199X), Draft July 1991 diff --git a/cde/programs/dtdocbook/sgmls/rast.txt b/cde/programs/dtdocbook/sgmls/rast.txt deleted file mode 100644 index 8abff259d..000000000 --- a/cde/programs/dtdocbook/sgmls/rast.txt +++ /dev/null @@ -1,67 +0,0 @@ -# $XConsortium: rast.txt /main/2 1996/11/11 11:24:27 drk $ - - - -RAST(1) RAST(1) - - -NAME - rast - translate output of sgmls to RAST format - -SYNOPSIS - rast [ -ooutput_file ] [ input_file ] - -DESCRIPTION - Rast translates the output of sgmls to the format of a - RAST result. RAST is the Reference Application for SGML - Testing defined in the Proposed American National Standard - on Conformance Testing for Standard Generalized Markup - Language (SGML) Systems (X3.190-199X). Rast reads from - input_file or from standard input if input_file is not - specified. It writes to output_file or to standard output - if output_file is not specified; use of the -o option - avoids the need for rast to use a temporary file. - - Note that the -c option of sgmls can generate a capacity - report in RACT format. - -BUGS - Production [9] in clause 14.5.5 of the draft standard is - clearly wrong; rast corrects it by appending `, LE'. An - alternative way to correct it would be to delete the - `,"END-ENTITY"'. - - In production [18] in clause 14.5.9, `markup data+' should - be `markup data*' since internal sdata entities need not - contain any characters (14.5.11), and markup data cannot - be empty (14.5.9, 14.5.12). - - The RAST result for the example in Annex B.4 is incorrect. - The line G03-A1= should be immediately followed by a line - !g03-e1!. (The problem with production [9] also applies - to this example.) - - Rast outputs a newline after #ERROR in order to avoid pro- - ducing files with partial lines. - -SEE ALSO - sgmls(1) - Conformance Testing for Standard Generalized Markup Lan- - guage (SGML) Systems, (X3.190-199X), Draft July 1991 - - - - - - - - - - - - - - - 1 - - diff --git a/cde/programs/dtdocbook/sgmls/replace.c b/cde/programs/dtdocbook/sgmls/replace.c deleted file mode 100644 index 5795fbf16..000000000 --- a/cde/programs/dtdocbook/sgmls/replace.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: replace.c /main/3 1996/06/19 17:16:59 drk $ */ -/* replace.c - Parse ASP style replacement file. - - Written by James Clark (jjc@jclark.com). */ - -#include "sgmlsasp.h" -#include "replace.h" - -#define TABLE_SIZE 251 - -struct table_entry { - enum event_type type; - char *gi; - struct replacement replacement; - struct table_entry *next; -}; - -struct replacement_table { - struct table_entry *table[TABLE_SIZE]; -}; - -struct buffer { - char *s; - unsigned len; - unsigned size; -}; - -/* Tokens returned by get_token(). */ - -#define STRING 1 -#define STAGO 2 -#define ETAGO 3 -#define PLUS 4 - -static int get P((void)); -static int peek P((void)); -static int get_token P((void)); -static void scan_name P((struct buffer *, int)); -static struct replacement *define_replacement - P((struct replacement_table *, enum event_type, char *)); -static struct replacement_item **parse_string - P((struct replacement_item **, int)); -static UNIV xmalloc P((unsigned)); -static UNIV xrealloc P((UNIV, unsigned)); -static struct replacement_item **add_replacement_data - P((struct replacement_item **, char *, unsigned)); -static struct replacement_item **add_replacement_attr - P((struct replacement_item **, char *)); -static int hash P((enum event_type, char *)); -static NO_RETURN void parse_error VP((char *,...)); -static VOID buffer_init P((struct buffer *)); -static VOID buffer_append P((struct buffer *, int)); -static char *buffer_extract P((struct buffer *)); -#if 0 -static VOID buffer_free P((struct buffer *)); -#endif - -#define buffer_length(buf) ((buf)->len) - -#define NEW(type) ((type *)xmalloc(sizeof(type))) - -static int current_lineno; -static char *current_file; -static FILE *fp; - -struct replacement_table *make_replacement_table() -{ - int i; - struct replacement_table *tablep; - - tablep = NEW(struct replacement_table); - for (i = 0; i < TABLE_SIZE; i++) - tablep->table[i] = 0; - return tablep; -} - -void load_replacement_file(tablep, file) - struct replacement_table *tablep; - char *file; -{ - int tok; - struct buffer name; - - buffer_init(&name); - errno = 0; - fp = fopen(file, "r"); - if (!fp) { - if (errno) - error("can't open `%s': %s", file, strerror(errno)); - else - error("can't open `%s'", file); - } - - current_lineno = 1; - current_file = file; - tok = get_token(); - while (tok != EOF) { - struct replacement *p; - struct replacement_item **tail; - enum event_type type; - - if (tok != STAGO && tok != ETAGO) - parse_error("syntax error"); - type = tok == STAGO ? START_ELEMENT : END_ELEMENT; - scan_name(&name, '>'); - p = define_replacement(tablep, type, buffer_extract(&name)); - tok = get_token(); - if (tok == PLUS) { - if (p) - p->flags |= NEWLINE_BEGIN; - tok = get_token(); - } - tail = p ? &p->items : 0; - while (tok == STRING) { - tail = parse_string(tail, type == START_ELEMENT); - tok = get_token(); - } - if (tok == PLUS) { - if (p) - p->flags |= NEWLINE_END; - tok = get_token(); - } - } - fclose(fp); -} - -static -struct replacement_item **parse_string(tail, recog_attr) - struct replacement_item **tail; - int recog_attr; -{ - struct buffer buf; - unsigned len; - - buffer_init(&buf); - for (;;) { - int c = get(); - if (c == '\"') - break; - if (recog_attr && c == '[') { - if (buffer_length(&buf)) { - len = buffer_length(&buf); - tail = add_replacement_data(tail, buffer_extract(&buf), len); - } - scan_name(&buf, ']'); - tail = add_replacement_attr(tail, buffer_extract(&buf)); - } - else { - if (c == '\\') { - c = get(); - switch (c) { - case EOF: - parse_error("unfinished string at end of file"); - case 's': - buffer_append(&buf, ' '); - break; - case 'n': - buffer_append(&buf, '\n'); - break; - case 't': - buffer_append(&buf, '\t'); - break; - case 'r': - buffer_append(&buf, '\r'); - break; - case 'f': - buffer_append(&buf, '\f'); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int val = c - '0'; - c = peek(); - if ('0' <= c && c <= '7') { - (void)get(); - val = val*8 + (c - '0'); - c = peek(); - if ('0' <= c && c <= '7') { - (void)get(); - val = val*8 + (c - '0'); - } - } - buffer_append(&buf, val); - break; - } - default: - buffer_append(&buf, c); - break; - } - } - else - buffer_append(&buf, c); - } - } - len = buffer_length(&buf); - if (len > 0) - tail = add_replacement_data(tail, buffer_extract(&buf), len); - return tail; -} - -static -struct replacement_item **add_replacement_data(tail, buf, n) - struct replacement_item **tail; - char *buf; - unsigned n; -{ - if (!tail) - free(buf); - else { - *tail = NEW(struct replacement_item); - (*tail)->type = DATA_REPL; - (*tail)->u.data.n = n; - (*tail)->next = 0; - (*tail)->u.data.s = buf; - tail = &(*tail)->next; - } - return tail; -} - -static -struct replacement_item **add_replacement_attr(tail, name) - struct replacement_item **tail; - char *name; -{ - if (!tail) - free(name); - else { - *tail = NEW(struct replacement_item); - (*tail)->type = ATTR_REPL; - (*tail)->next = 0; - (*tail)->u.attr = name; - tail = &(*tail)->next; - } - return tail; -} - -static -int get_token() -{ - int c; - - for (;;) { - c = get(); - while (isspace(c)) - c = get(); - if (c != '%') - break; - do { - c = get(); - if (c == EOF) - return EOF; - } while (c != '\n'); - } - switch (c) { - case '+': - return PLUS; - case '<': - c = peek(); - if (c == '/') { - (void)get(); - return ETAGO; - } - return STAGO; - case '"': - return STRING; - case EOF: - return EOF; - default: - parse_error("bad input character `%c'", c); - } -} - -static -void scan_name(buf, term) - struct buffer *buf; - int term; -{ - int c; - for (;;) { - c = get(); - if (c == term) - break; - if (c == '\n' || c == EOF) - parse_error("missing `%c'", term); - if (fold_general_names) { - if (islower((unsigned char)c)) - c = toupper((unsigned char)c); - } - buffer_append(buf, c); - } - if (buffer_length(buf) == 0) - parse_error("empty name"); - buffer_append(buf, '\0'); -} - -static -int get() -{ - int c = getc(fp); - if (c == '\n') - current_lineno++; - return c; -} - -static -int peek() -{ - int c = getc(fp); - if (c != EOF) - ungetc(c, fp); - return c; -} - -struct replacement *lookup_replacement(tablep, type, name) - struct replacement_table *tablep; - enum event_type type; - char *name; -{ - int h = hash(type, name); - struct table_entry *p; - - for (p = tablep->table[h]; p; p = p->next) - if (strcmp(name, p->gi) == 0 && type == p->type) - return &p->replacement; - return 0; -} - -/* Return 0 if already defined. */ - -static -struct replacement *define_replacement(tablep, type, name) - struct replacement_table *tablep; - enum event_type type; - char *name; -{ - int h = hash(type, name); - struct table_entry *p; - - for (p = tablep->table[h]; p; p = p->next) - if (strcmp(name, p->gi) == 0 && type == p->type) - return 0; - p = NEW(struct table_entry); - p->next = tablep->table[h]; - tablep->table[h] = p; - p->type = type; - p->gi = name; - p->replacement.flags = 0; - p->replacement.items = 0; - return &p->replacement; -} - -static -VOID buffer_init(buf) - struct buffer *buf; -{ - buf->size = buf->len = 0; - buf->s = 0; -} - -static -char *buffer_extract(buf) - struct buffer *buf; -{ - char *s = buf->s; - buf->s = 0; - buf->len = 0; - buf->size = 0; - return s; -} - -#if 0 -static -VOID buffer_free(buf) - struct buffer *buf; -{ - if (buf->s) { - free((UNIV)buf->s); - buf->s = 0; - buf->size = buf->size = 0; - } -} -#endif - -static -VOID buffer_append(buf, c) - struct buffer *buf; - int c; -{ - if (buf->len >= buf->size) { - if (!buf->size) - buf->s = (char *)xmalloc(buf->size = 10); - else - buf->s = (char *)xrealloc((UNIV)buf->s, buf->size *= 2); - } - buf->s[buf->len] = c; - buf->len += 1; -} - -static -int hash(type, s) - enum event_type type; - char *s; -{ - unsigned long h = 0, g; - - while (*s != 0) { - h <<= 4; - h += *s++; - if ((g = h & 0xf0000000) != 0) { - h ^= g >> 24; - h ^= g; - } - } - h ^= (int)type; - return (int)(h % TABLE_SIZE); -} - -static -UNIV xmalloc(n) - unsigned n; -{ - UNIV p = (UNIV)malloc(n); - if (!p) - parse_error("out of memory"); - return p; -} - -static -UNIV xrealloc(p, size) - UNIV p; - unsigned size; -{ - p = (UNIV)realloc(p, size); - if (!p) - parse_error("out of memory"); - return p; -} - -static NO_RETURN -#ifdef VARARGS -void parse_error(va_alist) va_dcl -#else -void parse_error(char *message,...) -#endif -{ - char buf[512]; -#ifdef VARARGS - char *message; -#endif - va_list ap; - -#ifdef VARARGS - va_start(ap); - message = va_arg(ap, char *); -#else - va_start(ap, message); -#endif - vsprintf(buf, message, ap); - va_end(ap); - error("%s:%d: %s", current_file, current_lineno, buf); -} diff --git a/cde/programs/dtdocbook/sgmls/replace.h b/cde/programs/dtdocbook/sgmls/replace.h deleted file mode 100644 index 81a0fa061..000000000 --- a/cde/programs/dtdocbook/sgmls/replace.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: replace.h /main/3 1996/06/19 17:17:05 drk $ */ -/* replace.h - Interface to replacement file parser. */ - -enum replacement_type { - DATA_REPL, - ATTR_REPL - }; - -struct replacement_item { - union { - char *attr; - struct { - char *s; - unsigned n; - } data; - } u; - enum replacement_type type; - struct replacement_item *next; -}; - -#define NEWLINE_BEGIN 01 -#define NEWLINE_END 02 - -struct replacement { - unsigned flags; - struct replacement_item *items; -}; - -enum event_type { START_ELEMENT, END_ELEMENT }; - -struct replacement_table *make_replacement_table P((void)); -void load_replacement_file P((struct replacement_table *, char *)); - -struct replacement * -lookup_replacement P((struct replacement_table *, enum event_type, char *)); diff --git a/cde/programs/dtdocbook/sgmls/serv.c b/cde/programs/dtdocbook/sgmls/serv.c deleted file mode 100644 index f8103006f..000000000 --- a/cde/programs/dtdocbook/sgmls/serv.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: serv.c /main/3 1996/06/19 17:17:10 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -/* ETDDEF: Define an element type definition. - Use an existing one if there is one; otherwise create one, which - rmalloc initializes to zero which shows it is a virgin etd. -*/ -PETD etddef(ename) -UNCH *ename; /* Element name (GI) with length byte. */ -{ - PETD p; /* Pointer to an etd. */ - int hnum; /* Hash number for ename. */ - - if ((p = (PETD)hfind((THASH)etdtab,ename,hnum = hash(ename, ETDHASH)))==0){ - p = (PETD)hin((THASH)etdtab, ename, hnum, ETDSZ); - } - return p; -} -/* ETDSET: Store data in an element type definition. - The etd must be valid and virgin (except for adl and etdmin). - As an etd cannot be modified, there is no checking for existing - pointers and no freeing of their storage. -*/ -#ifdef USE_PROTOTYPES -PETD etdset(PETD p, UNCH fmin, struct thdr *cmod, PETD *mexgrp, PETD *pexgrp, - struct entity **srm) -#else -PETD etdset(p, fmin, cmod, mexgrp, pexgrp, srm) -PETD p; /* Pointer to an etd. */ -UNCH fmin; /* Minimization bit flags. */ -struct thdr *cmod; /* Pointer to content model. */ -PETD *mexgrp; /* Pointers to minus and plus exception lists. */ -PETD *pexgrp; /* Pointers to minus and plus exception lists. */ -struct entity **srm; /* Short reference map. */ -#endif -{ - p->etdmin |= fmin; - p->etdmod = cmod; - p->etdmex = mexgrp; - p->etdpex = pexgrp; - p->etdsrm = srm; - return p; -} -/* ETDREF: Retrieve the pointer to an element type definition. -*/ -PETD etdref(ename) -UNCH *ename; /* Element name (GI) with length byte.. */ -{ - - return (PETD)hfind((THASH)etdtab, ename, hash(ename, ETDHASH)); -} -/* ETDCAN: Cancel an element definition. The etd is freed and is removed - from the hash table, but its model and other pointers are not freed. -*/ -VOID etdcan(ename) -UNCH *ename; /* GI name (with length and EOS). */ -{ - PETD p; - - if ((p = (PETD)hout((THASH)etdtab, ename, hash(ename, ETDHASH)))!=0) - frem((UNIV)p); -} -/* SYMBOL TABLE FUNCTIONS: These functions manage hash tables that are used - for entities, element type definitions, IDs, and other purposes. The - interface will be expanded in the future to include multiple environments, - probably by creating arrays of the present hash tables with each table - in the array corresponding to an environment level. -*/ -/* HASH: Form hash value for a string. - From the Dragon Book, p436. -*/ -int hash(s, hashsize) -UNCH *s; /* String to be hashed. */ -int hashsize; /* Size of hash table array. */ -{ - unsigned long h = 0, g; - - while (*s != 0) { - h <<= 4; - h += *s++; - if ((g = h & 0xf0000000) != 0) { - h ^= g >> 24; - h ^= g; - } - } - return (int)(h % hashsize); -} -/* HFIND: Look for a name in a hash table. -*/ -struct hash *hfind(htab, s, h) -struct hash *htab[]; /* Hash table. */ -UNCH *s; /* Entity name. */ -int h; /* Hash value for entity name. */ -{ - struct hash *np; - - for (np = htab[h]; np != 0; np = np->enext) - if (ustrcmp(s, np->ename) == 0) return np; /* Found it. */ - return (struct hash *)0; /* Not found. */ -} -/* HIN: Locates an entry in a hash table, or allocates a new one. - Returns a pointer to a structure containing a name - and a pointer to the next entry. Other data in the - structure must be maintained by the caller. -*/ -struct hash *hin(htab, name, h, size) -struct hash *htab[]; /* Hash table. */ -UNCH *name; /* Entity name. */ -int h; /* Hash value for entity name. */ -UNS size; /* Size of structures pointed to by table. */ -{ - struct hash *np; - - if ((np = hfind(htab, name, h))!=0) return np; /* Return if name found. */ - /* Allocate space for structure and name. */ - np = (struct hash *)rmalloc(size + name[0]); - np->ename = (UNCH *)np + size; - memcpy(np->ename, name, name[0]); /* Store name in it. */ - np->enext = htab[h]; /* 1st entry is now 2nd.*/ - htab[h] = np; /* New entry is now 1st.*/ - return np; /* Return new entry ptr. */ -} -/* HOUT: Remove an entry from a hash table and return its pointer. - The caller must free any pointers in the entry and then - free the entry itself if that is what is desired; this - routine does not free any storage. -*/ -struct hash *hout(htab, s, h) -struct hash *htab[]; /* Hash table. */ -UNCH *s; /* Search argument entry name. */ -int h; /* Hash value for search entry name. */ -{ - struct hash **pp; - - for (pp = &htab[h]; *pp != 0; pp = &(*pp)->enext) - if (ustrcmp(s, (*pp)->ename) == 0) { /* Found it. */ - struct hash *tem = *pp; - *pp = (*pp)->enext; - return tem; - } - return 0; /* NULL if not found; else ptr. */ -} -/* SAVESTR: Save a null-terminated string -*/ -UNCH *savestr(s) -UNCH *s; -{ - UNCH *rp; - - rp = (UNCH *)rmalloc(ustrlen(s) + 1); - ustrcpy(rp, s); - return rp; -} -/* SAVENM: Save a name (with length and EOS) -*/ -UNCH *savenm(s) -UNCH *s; -{ - UNCH *p; - p = (UNCH *)rmalloc(*s); - memcpy(p, s, *s); - return p; -} -/* REPLACE: Free the storage for the old string (p) and store the new (s). - If the specified ptr is NULL, don't free it. -*/ -UNCH *replace(p, s) -UNCH *p; -UNCH *s; -{ - if (p) frem((UNIV)p); /* Free old storage (if any). */ - if (!s) return(s); /* Return NULL if new string is NULL. */ - return savestr(s); -} -/* RMALLOC: Interface to memory allocation with error handling. - If storage is not available, fatal error message is issued. - Storage is initialized to zeros. -*/ -UNIV rmalloc(size) -unsigned size; /* Number of bytes of initialized storage. */ -{ - UNIV p = (UNIV)calloc(size, 1); - if (!p) exiterr(33, (struct parse *)0); - return p; -} -UNIV rrealloc(p, n) -UNIV p; -UNS n; -{ - UNIV r = realloc(p, n); - if (!r) - exiterr(33, (struct parse *)0); - return r; -} - -UNCH *pt; -/* FREM: Free specified memory area gotten with rmalloc(). -*/ -VOID frem(ptr) -UNIV ptr; /* Memory area to be freed. */ -{ - free(ptr); -} -/* MAPSRCH: Find a string in a table and return its associated value. - The last entry must be a dummy consisting of a NULL pointer for - the string and whatever return code is desired if the - string is not found in the table. -*/ -int mapsrch(maptab, name) -struct map maptab[]; -UNCH *name; -{ - int i = 0; - - do { - UNCH *mapnm, *nm; - for (mapnm = maptab[i].mapnm, nm=name; *nm==*mapnm; mapnm++) { - if (!*nm++) return maptab[i].mapdata; - } - } while (maptab[++i].mapnm); - return maptab[i].mapdata; -} -/* IDDEF: Define an ID control block; return -1 if it already exists. -*/ -int iddef(iname) -UNCH *iname; /* ID name (with length and EOS). */ -{ - PID p; - struct fwdref *r; - - p = (PID)hin((THASH)itab, iname, hash(iname, IDHASH), IDSZ); - if (p->iddefed) return(-1); - p->iddefed = 1; - TRACEID("IDDEF", p); - /* Delete any forward references. */ - r = p->idrl; - p->idrl = 0; - while (r) { - struct fwdref *tem = r->next; - if (r->msg) - msgsfree(r->msg); - frem((UNIV)r); - r = tem; - } - return(0); -} -/* IDREF: Store a reference to an ID and define the ID if it doesn't yet exist. - Return 0 if already defined, otherwise pointer to a fwdref. -*/ -struct fwdref *idref(iname) -UNCH *iname; /* ID name (with length and EOS). */ -{ - PID p; - int hnum; - struct fwdref *rp; - - if ((p = (PID)hfind((THASH)itab, iname, (hnum = hash(iname, IDHASH))))==0) - p = (PID)hin((THASH)itab, iname, hnum, IDSZ); - if (p->iddefed) - return 0; - rp = (struct fwdref *)rmalloc(FWDREFSZ); - rp->next = p->idrl; - p->idrl = rp; - rp->msg = 0; - TRACEID("IDREF", p); - return rp; -} -/* IDRCK: Check idrefs. -*/ -VOID idrck() -{ - int i; - PID p; - struct fwdref *r; - - for (i = 0; i < IDHASH; i++) - for (p = itab[i]; p; p = p->idnext) - if (!p->iddefed) - for (r = p->idrl; r; r = r->next) - svderr(r->msg); -} -/* NTOA: Converts a positive integer to an ASCII string (abuf) - No leading zeros are generated. -*/ -UNCH *ntoa(i) -int i; -{ - static UNCH buf[1 + 3*sizeof(int) + 1]; - sprintf((char *)buf, "%d", i); - return buf; -} -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgml-mode.el b/cde/programs/dtdocbook/sgmls/sgml-mode.el deleted file mode 100644 index 7a3b732c3..000000000 --- a/cde/programs/dtdocbook/sgmls/sgml-mode.el +++ /dev/null @@ -1,266 +0,0 @@ -;;; sgml-mode.el --- mode for editing SGML (ISO 8879) - -;; Copyright (C) 1992 Free Software Foundation, Inc. - -;; Author: James Clark -;; Version: 1.0 - -;; This file is not yet part of GNU Emacs. - -;; GNU Emacs 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 1, or (at your option) -;; any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth -;; Floor, Boston, MA 02110-1301 USA - -;;; Commentary: - -;; Some suggestions for your .emacs file: -;; -;; (autoload 'sgml-mode "sgml-mode" "SGML mode" t) -;; -;; (setq auto-mode-alist -;; (append (list (cons "\\.sgm$" 'sgml-mode) -;; (cons "\\.sgml$" 'sgml-mode) -;; (cons "\\.dtd$" 'sgml-mode)) -;; auto-mode-alist)) - -;;; Code: - -(provide 'sgml-mode) -(require 'compile) - -;;; sgmls is a free SGML parser available from -;;; ftp.uu.net:pub/text-processing/sgml -;;; Its error messages can be parsed by next-error. -;;; The -s option suppresses output. - -(defconst sgml-validate-command - "sgmls -s" - "*The command to validate an SGML document. -The file name of current buffer file name will be appended to this, -separated by a space.") - -(defvar sgml-saved-validate-command nil - "The command last used to validate in this buffer.") - -(defvar sgml-mode-map nil "Keymap for SGML mode") - -(if sgml-mode-map - () - (setq sgml-mode-map (make-sparse-keymap)) - (define-key sgml-mode-map ">" 'sgml-close-angle) - (define-key sgml-mode-map "/" 'sgml-slash) - (define-key sgml-mode-map "\C-c\C-v" 'sgml-validate)) - -(defun sgml-mode () - "Major mode for editing SGML. -Makes > display the matching <. Makes / display matching /. -Use \\[sgml-validate] to validate your document with an SGML parser." - (interactive) - (kill-all-local-variables) - (setq local-abbrev-table text-mode-abbrev-table) - (use-local-map sgml-mode-map) - (setq mode-name "SGML") - (setq major-mode 'sgml-mode) - (make-local-variable 'paragraph-start) - ;; A start or end tag by itself on a line separates a paragraph. - ;; This is desirable because SGML discards a newline that appears - ;; immediately after a start tag or immediately before an end tag. - (setq paragraph-start - "^[ \t\n]\\|\ -\\($\\)") - (make-local-variable 'paragraph-separate) - (setq paragraph-separate - "^[ \t\n]*$\\|\ -^$") - (make-local-variable 'sgml-saved-validate-command) - (set-syntax-table text-mode-syntax-table) - (make-local-variable 'comment-start) - (setq comment-start "") - (make-local-variable 'comment-indent-hook) - (setq comment-indent-hook 'sgml-comment-indent) - (make-local-variable 'comment-start-skip) - ;; This will allow existing comments within declarations to be - ;; recognized. - (setq comment-start-skip "--[ \t]*") - (run-hooks 'text-mode-hook 'sgml-mode-hook)) - -(defun sgml-comment-indent () - (if (and (looking-at "--") - (not (and (eq (char-after (1- (point))) ?!) - (eq (char-after (- (point) 2)) ?<)))) - (progn - (skip-chars-backward " \t") - (max comment-column (1+ (current-column)))) - 0)) - -(defconst sgml-start-tag-regex - "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*" - "Regular expression that matches a non-empty start tag. -Any terminating > or / is not matched.") - -(defvar sgml-mode-markup-syntax-table nil - "Syntax table used for scanning SGML markup.") - -(if sgml-mode-markup-syntax-table - () - (setq sgml-mode-markup-syntax-table (make-syntax-table)) - (modify-syntax-entry ?< "(>" sgml-mode-markup-syntax-table) - (modify-syntax-entry ?> ")<" sgml-mode-markup-syntax-table) - (modify-syntax-entry ?- "_ 1234" sgml-mode-markup-syntax-table) - (modify-syntax-entry ?\' "\"" sgml-mode-markup-syntax-table)) - -(defconst sgml-angle-distance 4000 - "*If non-nil, is the maximum distance to search for matching < -when > is inserted.") - -(defun sgml-close-angle (arg) - "Insert > and display matching <." - (interactive "p") - (insert-char ?> arg) - (if (> arg 0) - (let ((oldpos (point)) - (blinkpos)) - (save-excursion - (save-restriction - (if sgml-angle-distance - (narrow-to-region (max (point-min) - (- (point) sgml-angle-distance)) - oldpos)) - ;; See if it's the end of a marked section. - (and (> (- (point) (point-min)) 3) - (eq (char-after (- (point) 2)) ?\]) - (eq (char-after (- (point) 3)) ?\]) - (re-search-backward "" oldpos t) - (eq (point) oldpos)) - (setq blinkpos msspos)))) - ;; This handles cases where the > ends one of the following: - ;; markup declaration starting with ]\\|!\\([[A-Za-z]\\|--\\)\\)")) - ;; Check that it's not a net-enabling start tag - ;; nor an unclosed start-tag. - (looking-at (concat sgml-start-tag-regex "[/<]")) - ;; Nor an unclosed end-tag. - (looking-at "" oldpos t) - (eq (point) oldpos)) - (setq blinkpos pipos)))))) - (if blinkpos - (progn - (goto-char blinkpos) - (if (pos-visible-in-window-p) - (sit-for 1) - (message "Matches %s" - (buffer-substring blinkpos - (progn (end-of-line) - (point))))))))))) - -;;; I doubt that null end tags are used much for large elements, -;;; so use a small distance here. -(defconst sgml-slash-distance 1000 - "*If non-nil, is the maximum distance to search for matching / -when / is inserted.") - -(defun sgml-slash (arg) - "Insert / and display any previous matching /. -Two /s are treated as matching if the first / ends a net-enabling -start tag, and the second / is the corresponding null end tag." - (interactive "p") - (insert-char ?/ arg) - (if (> arg 0) - (let ((oldpos (point)) - (blinkpos) - (level 0)) - (save-excursion - (save-restriction - (if sgml-slash-distance - (narrow-to-region (max (point-min) - (- (point) sgml-slash-distance)) - oldpos)) - (if (and (re-search-backward sgml-start-tag-regex (point-min) t) - (eq (match-end 0) (1- oldpos))) - () - (goto-char (1- oldpos)) - (while (and (not blinkpos) - (search-backward "/" (point-min) t)) - (let ((tagend (save-excursion - (if (re-search-backward sgml-start-tag-regex - (point-min) t) - (match-end 0) - nil)))) - (if (eq tagend (point)) - (if (eq level 0) - (setq blinkpos (point)) - (setq level (1- level))) - (setq level (1+ level))))))) - (if blinkpos - (progn - (goto-char blinkpos) - (if (pos-visible-in-window-p) - (sit-for 1) - (message "Matches %s" - (buffer-substring (progn - (beginning-of-line) - (point)) - (1+ blinkpos)))))))))) - -(defun sgml-validate (command) - "Validate an SGML document. -Runs COMMAND, a shell command, in a separate process asynchronously -with output going to the buffer *compilation*. -You can then use the command \\[next-error] to find the next error message -and move to the line in the SGML document that caused it." - (interactive - (list (read-string "Validate command: " - (or sgml-saved-validate-command - (concat sgml-validate-command - " " - (let ((name (buffer-file-name))) - (and name - (file-name-nondirectory name)))))))) - (setq sgml-saved-validate-command command) - (compile1 command "No more errors")) - -;;; sgml-mode.el ends here diff --git a/cde/programs/dtdocbook/sgmls/sgml1.c b/cde/programs/dtdocbook/sgmls/sgml1.c deleted file mode 100644 index 6fc74b9f6..000000000 --- a/cde/programs/dtdocbook/sgmls/sgml1.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgml1.c /main/3 1996/06/19 17:17:15 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ - -#define ETDCON (tags[ts].tetd->etdmod->ttype) /* ETD content flags. */ - -/* SGML: Main SGML driver routine. -*/ -enum sgmlevent sgmlnext(rcbdafp, rcbtagp) -struct rcbdata *rcbdafp; -struct rcbtag *rcbtagp; -{ - while (prologsw && !conactsw) { - int oconact; - conact = parsepro(); - conactsw = 0; /* Assume sgmlact() will not be skipped. */ - switch(conact) { - - case PIS_: - case EOD_: - case APP_: /* APPINFO */ - conactsw = 1; /* We can skip sgmlact() in opening state. */ - break; - - case DAF_: - newetd = stagreal = ETDCDATA; - conact = stag(datarc = DAF_); - conactsw = 1; /* We can skip sgmlact() in opening state. */ - prologsw = 0; /* End the prolog. */ - break; - case DCE_: - case MSS_: - /* prcon[2].tu.thetd holds the etd for the document element. */ - newetd = stagreal = prcon[2].tu.thetd; - stagmin = MINSTAG; /* This tag was minimized. */ - /* It's an error if the start tag of the document element - is not minimizable. */ - if (BITOFF(newetd->etdmin, SMO)) - sgmlerr(226, conpcb, (UNCH *)0, (UNCH *)0); - oconact = conact; /* Save conact. */ - conact = stag(0); /* Start the document element. */ - conactsw = 1; /* conact needs processing. */ - prologsw = 0; /* The prolog is finished. */ - if (oconact == MSS_) { - if (msplevel==0) conpcb = getpcb((int)ETDCON); - conpcb = mdms(tbuf, conpcb); /* Parse the marked section - start. */ - } - break; - default: /* STE_: not defined in SGMLACT.H. */ - if (msplevel==0) conpcb = getpcb((int)ETDCON); - prologsw = 0; /* End the prolog. */ - break; - } - } - for (;;) { - unsigned swact; /* Switch action: saved conact, new, or sgmlact.*/ - - if (conactsw) { - conactsw = 0; - swact = conact; - contersw = contersv; - } - else { - conact = parsecon(tbuf, conpcb); - swact = sgmlact((UNCH)(conact != EOD_ ? conact : LOP_)); - } - - switch (swact) { - - case MD_: /* Process markup declaration. */ - parsenm(tbuf, NAMECASE); /* Get declaration name. */ - if (!ustrcmp(tbuf+1, key[KUSEMAP])) mdsrmuse(tbuf); - else sgmlerr(E_MDNAME, conpcb, tbuf+1, (UNCH *)0); - continue; - case MDC_: /* Process markup declaration comment. */ - if (*FPOS!=lex.d.mdc) - parsemd(tbuf, NAMECASE, (struct parse *)0, NAMELEN); - continue; - - case MSS_: /* Process marked section start. */ - conpcb = mdms(tbuf, conpcb); - continue; - case MSE_: /* Process marked section end (drop to LOP_). */ - if (mdmse()) conpcb = getpcb((int)ETDCON); - continue; - - case PIS_: /* Return processing instruction (string). */ - if (entpisw) rcbdafp->data = data; - else { - parselit(tbuf, &pcblitc, PILEN, lex.d.pic); - rcbdafp->data = tbuf; - } - rcbdafp->datalen = datalen; - rcbdafp->contersw = entpisw; - entpisw = 0; /* Reset for next time.*/ - scbset(); /* Update location in current scb. */ - return SGMLPIS; - - case APP_: - rcbdafp->data = tbuf; - rcbdafp->datalen = ustrlen(tbuf); - rcbdafp->contersw = 0; - scbset(); - return SGMLAPP; - case ETG_: /* Return end-tag. */ - charmode = 0; /* Not in char mode unless CDATA or RCDATA.*/ - if (msplevel==0) conpcb = getpcb((int)ETDCON); - rcbtagp->contersw = tags[ts+1].tflags; - rcbtagp->tagmin = etagimsw ? MINETAG : etagmin; - rcbtagp->curgi = tags[ts+1].tetd->etdgi; - rcbtagp->ru.oldgi = tags[ts].tetd->etdgi; - if (etagmin==MINSTAG) rcbtagp->tagreal = - BADPTR(stagreal) ? stagreal : (PETD)stagreal->etdgi; - else rcbtagp->tagreal = - BADPTR(etagreal) ? etagreal : (PETD)etagreal->etdgi; - rcbtagp->etictr = etictr; - rcbtagp->srmnm = tags[ts].tsrm!=SRMNULL ? tags[ts].tsrm[0]->ename - : 0; - scbset(); /* Update location in current scb. */ - return SGMLETG; - - case STG_: /* Return start-tag. */ - charmode = 0; /* Not in char mode unless CDATA or RCDATA.*/ - if (!conrefsw && msplevel==0) conpcb = getpcb((int)ETDCON); - rcbtagp->contersw = tags[ts].tflags; - rcbtagp->tagmin = dostag ? MINSTAG : stagmin; - rcbtagp->curgi = tags[ts].tetd->etdgi; - /* Get attribute list if one was defined for this element. */ - rcbtagp->ru.al = !tags[ts].tetd->adl ? 0 : - rcbtagp->tagmin==MINNONE ? al : tags[ts].tetd->adl; - rcbtagp->tagreal = BADPTR(stagreal)?stagreal:(PETD)stagreal->etdgi; - rcbtagp->etictr = etictr; - rcbtagp->srmnm = tags[ts].tsrm!=SRMNULL ? tags[ts].tsrm[0]->ename - : 0; - scbset(); /* Update location in current scb. */ - return SGMLSTG; - - case DAF_: /* Return data in source entity buffer. */ - charmode = 1; - rcbdafp->datalen = datalen; - rcbdafp->data = data; - rcbdafp->contersw = contersw | entdatsw; - contersw = entdatsw = 0;/* Reset for next time.*/ - scbset(); /* Update location in current scb. */ - return SGMLDAF; - - case CON_: /* Process conact after returning REF_. */ - conactsw = 1; - contersv = contersw; - case REF_: /* Return RE found. */ - if (badresw) { - badresw = 0; - sgmlerr(E_CHARS, &pcbconm, tags[ts].tetd->etdgi+1, (UNCH *)0); - continue; - } - charmode = 1; - rcbdafp->contersw = contersw; - contersw = 0; /* Reset for next time.*/ - scbset(); /* Update location in current scb. */ - return SGMLREF; - - case EOD_: /* End of source document entity. */ - if (mslevel != 0) sgmlerr(139, conpcb, (UNCH *)0, (UNCH *)0); - idrck(); /* Check idrefs. */ - scbset(); /* Update location in current scb. */ - return SGMLEOD; - - default: /* LOP_: Loop again with no action. */ - continue; - } - } -} -/* PCBSGML: State and action table for action codes returned to text processor - by SGML.C. - Columns are based on SGMLACT.H values minus DAF_, except that end - of document has input code LOP_, regardless of its action code. -*/ -/* Symbols for state names (end with a number). */ -#define ST1 0 /* Just had a start tag. */ -#define NR1 2 /* Just had an RS or RE. */ -#define DA1 4 /* Just had some data. */ -#define NR2 6 /* Just had an RE; RE pending. */ -#define ST2 8 /* Had only markup since last RE/RS; RE pending. */ - -static UNCH sgmltab[][11] = { -/*daf_ etg_ md_ mdc_ mss_ mse_ pis_ ref_ stg_ rsr_ eod */ - {DA1 ,DA1 ,ST1 ,ST1 ,ST1 ,ST1 ,ST1 ,NR1 ,ST1 ,NR1 ,ST1 },/*st1*/ - {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_}, - - {DA1 ,DA1 ,ST1 ,ST1 ,ST1 ,ST1 ,ST1 ,NR2 ,ST1 ,NR1 ,ST1 },/*nr1*/ - {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_}, - - {DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,DA1 ,NR2 ,ST1 ,NR1 ,ST1 },/*da1*/ - {DAF_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,LOP_,STG_,LOP_,EOD_}, - - {DA1 ,DA1 ,ST2 ,ST2 ,ST2 ,ST2 ,ST2 ,NR2 ,ST1 ,NR2 ,ST1 },/*nr2*/ - {CON_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,REF_,CON_,LOP_,EOD_}, - - {DA1 ,DA1 ,ST2 ,ST2 ,ST2 ,ST2 ,ST2 ,NR1 ,ST1 ,NR2 ,ST1 },/*st2*/ - {CON_,ETG_,MD_ ,MDC_,MSS_,MSE_,PIS_,REF_,CON_,LOP_,EOD_}, -}; -int scbsgmst = ST1; /* SCBSGML: trailing stag or markup; ignore RE. */ -int scbsgmnr = NR1; /* SCBSGML: new record; do not ignore RE. */ -/* SGMLACT: Determine action to be taken by SGML.C based on current state and - specified input. - For start or end of a plus exception element, push or pop the - pcbsgml stack. - Return to caller with action code. -*/ -#ifdef USE_PROTOTYPES -int sgmlact(UNCH conret) -#else -int sgmlact(conret) -UNCH conret; /* Action returned to SGML.C by content parse. */ -#endif -{ - int action; - - if (conret==STG_ && GET(tags[ts].tflags, TAGPEX)) - {++pss; scbsgml[pss].snext = ST1;} - scbsgml[pss].sstate = scbsgml[pss].snext; - scbsgml[pss].snext = sgmltab[scbsgml[pss].sstate] - [scbsgml[pss].sinput = conret-DAF_]; - scbsgml[pss].saction = sgmltab[scbsgml[pss].sstate+1][scbsgml[pss].sinput]; - TRACEGML(scbsgml, pss, conactsw, conact); - action = scbsgml[pss].saction; - if (conret==ETG_ && GET(tags[ts+1].tflags, TAGPEX)) { - pss--; - /* An included subelement affects the enclosing state like a - processing instruction (or MDC_ or MD_), - that is to say NR1 is changed to ST1 and NR2 to ST2. */ - scbsgml[pss].sstate = scbsgml[pss].snext; - scbsgml[pss].snext = sgmltab[scbsgml[pss].sstate][PIS_ - DAF_]; - } - return action; -} -/* GETPCB: Choose pcb for new or resumed element. -*/ -struct parse *getpcb(etdcon) -int etdcon; /* Content type of new or resumed element. */ -{ - if (BITON(etdcon, MGI)) { - return(BITON(etdcon, MCHARS) ? &pcbconm : &pcbcone); - } - if (BITON(etdcon, MCDATA) || BITON(etdcon, MRCDATA)) { - charmode = 1; - return(BITON(etdcon, MCDATA) ? &pcbconc : (rcessv = es, &pcbconr)); - } - return(&pcbconm); -} - -struct markup *sgmlset(swp) -struct switches *swp; -{ - /* Initialize variables based on switches structure members. */ - sw = *swp; - rbufs = (UNCH *)rmalloc((UNS)3+sw.swbufsz) + 3; /* DOS file read area. */ - TRACEPRO(); /* Set trace switches for prolog. */ - msginit(swp); - ioinit(swp); - sdinit(); - return &lex.m; -} - -/* Points for each capacity, indexed by *CAP in sgmldecl.h. We'll replace -2 with the real NAMELEN at run time. */ - -static UNCH cappoints[] = { - 1, - 2, - 1, - 2, - 2, - 2, - 2, - 2, - 1, - 2, - 2, - 1, - 2, - 2, - 2, - 2, - 2 -}; - -static long capnumber[NCAPACITY]; -static long maxsubcap[NCAPACITY]; - -VOID sgmlend(p) -struct sgmlcap *p; -{ - int i; - for (; es >= 0; --es) - if (FILESW) - fileclos(); - - capnumber[NOTCAP] = ds.dcncnt; - capnumber[EXGRPCAP] = ds.pmexgcnt; - capnumber[ELEMCAP] = ds.etdcnt+ds.etdercnt; - capnumber[EXNMCAP] = ds.pmexcnt; - capnumber[GRPCAP] = ds.modcnt; - capnumber[ATTCAP] = ds.attcnt; - capnumber[ATTCHCAP] = ds.attdef; - capnumber[AVGRPCAP] = ds.attgcnt; - capnumber[IDCAP] = ds.idcnt; - capnumber[IDREFCAP] = ds.idrcnt; - capnumber[ENTCAP] = ds.ecbcnt; - capnumber[ENTCHCAP] = ds.ecbtext; - capnumber[MAPCAP] = ds.srcnt + ds.srcnt*lex.s.dtb[0].mapdata; - capnumber[NOTCHCAP] = ds.dcntext; - - capnumber[TOTALCAP] = 0; - - for (i = 1; i < NCAPACITY; i++) { - if (cappoints[i] > 1) - cappoints[i] = NAMELEN; - capnumber[i] += maxsubcap[i]/cappoints[i]; - capnumber[TOTALCAP] += (long)capnumber[i] * cappoints[i]; - } - p->number = capnumber; - p->points = cappoints; - p->limit = sd.capacity; - p->name = captab; - - for (i = 0; i < NCAPACITY; i++) { - long excess = capnumber[i]*cappoints[i] - sd.capacity[i]; - if (excess > 0) { - char buf[sizeof(long)*3 + 1]; - sprintf(buf, "%ld", excess); - sgmlerr(162, (struct parse *)0, - (UNCH *)captab[i], (UNCH *)buf); - } - } -} - -VOID sgmlsubcap(v) -long *v; -{ - int i; - for (i = 0; i < NCAPACITY; i++) - if (v[i] > maxsubcap[i]) - maxsubcap[i] = v[i]; -} - -int sgmlsdoc(ptr) -UNIV ptr; -{ - struct entity *e; - union etext etx; - etx.x = ptr; - - e = entdef(indocent, ESF, &etx); - if (!e) - return -1; - return entopen(e); -} - -/* SGMLGENT: Get a data entity. - Returns: - -1 if the entity does not exist - -2 if it is not a data entity - 1 if it is an external entity - 2 if it is an internal cdata entity - 3 if it is an internal sdata entity -*/ -int sgmlgent(iname, np, tp) -UNCH *iname; -PNE *np; -UNCH **tp; -{ - PECB ep; /* Pointer to an entity control block. */ - - ep = entfind(iname); - if (!ep) - return -1; - switch (ep->estore) { - case ESN: - if (np) - *np = ep->etx.n; - return 1; - case ESC: - if (tp) - *tp = ep->etx.c; - return 2; - case ESX: - if (tp) - *tp = ep->etx.c; - return 3; - } - return -2; -} - -/* Mark an entity. */ - -int sgmlment(iname) -UNCH *iname; -{ - PECB ep; - int rc; - - ep = entfind(iname); - if (!ep) - return -1; - rc = ep->mark; - ep->mark = 1; - return rc; -} - -int sgmlgcnterr() -{ - return msgcnterr(); -} - -/* This is for error handling functions that want to print a gi backtrace. */ - -UNCH *getgi(i) -int i; -{ - return i >= 0 && i <= ts ? tags[i].tetd->etdgi + 1 : NULL; -} - -/* Returns the value of prologsw for the use by error handling functions. */ - -int inprolog() -{ - return prologsw; -} - -/* Used by the error handling functions to access scbs. */ - -int getlocation(level, locp) -int level; -struct location *locp; -{ - if (level < 0 || level > es) - return 0; - if (locp) { - int es = level; - /* source macros access a variable called `es' */ - - locp->filesw = FILESW; - locp->rcnt = RCNT; - locp->ccnt = CCNT; - locp->ename = ENTITY + 1; - locp->fcb = SCBFCB; - locp->curchar = CC; - locp->nextchar = NEXTC; - } - return 1; -} - -int sgmlloc(linenop, filenamep) -unsigned long *linenop; -char **filenamep; -{ - int level = es; - int es; - - for (es = level; es >= 0 && !FILESW; es--) - ; - if (es < 0) - return 0; - *linenop = RCNT; - *filenamep = ioflid(SCBFCB); - return 1; -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgml2.c b/cde/programs/dtdocbook/sgmls/sgml2.c deleted file mode 100644 index f4eef3a07..000000000 --- a/cde/programs/dtdocbook/sgmls/sgml2.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgml2.c /main/3 1996/06/19 17:17:20 drk $ */ -/* Added exiterr() for terminal errors to prevent SGML.MSG errors. */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ -static int iorc; /* Return code from io* functions */ -/* ENTDEF: Process an entity definition and return the pointer to it. - The entity text must be in permanent storage. - There is no checking to see if the entity already exists; - the caller must have done that. -*/ -#ifdef USE_PROTOTYPES -PECB entdef(UNCH *ename, UNCH estore, union etext *petx) -#else -PECB entdef(ename, estore, petx) -UNCH *ename; /* Entity name (with length and EOS). */ -UNCH estore; /* Entity storage class. */ -union etext *petx; /* Ptr to entity text union. */ -#endif -{ - PECB p; - - p = (PECB)hin((THASH)etab, ename, hash(ename, ENTHASH), ENTSZ); - memcpy((UNIV)&p->etx, (UNIV)petx, ETEXTSZ); - p->estore = estore; - TRACEECB("ENTDEF", p); - return(p); -} -/* ENTFIND: If an entity exists, return ptr to its ecb. - Return NULL if it is not defined. -*/ -PECB entfind(ename) -UNCH *ename; /* Entity name (with length and EOS). */ -{ - PECB p; - - p = (PECB)hfind((THASH)etab, ename, hash(ename, ENTHASH)); - TRACEECB("ENTFIND", p); - return p; -} -/* ENTREF: Process a general or parameter entity reference. - If the entity is defined it returns the return code from ENTOPEN. - It returns ENTUNDEF for undefined parameter entity references - and for general entity references when defaulting is not allowed. - Otherwise, it uses the default entity text. -*/ -int entref(ename) -UNCH *ename; /* Entity name (with length and EOS). */ -{ - PECB ecb; /* Entity control block. */ - - /* Get the entity control block, if the entity has been defined. */ - if ((ecb = (PECB)hfind((THASH)etab, ename, hash(ename, ENTHASH)))==0 - || ecb->estore == 0) { - if ( ename[1]==lex.d.pero - || ecbdeflt==0 - || (ecb = usedef(ename))==0 ) { - sgmlerr(ename[1] == lex.d.pero || ecbdeflt == 0 ? 35 : 150, - (struct parse *)0, ename+1, (UNCH *)0); - return(ENTUNDEF); - } - } - return(entopen(ecb)); -} -/* ENTOPEN: Open a newly referenced entity. - Increment the stack pointer (es) and initialize the new entry. - ENTDATA if entity is CDATA or SDATA, ENTPI if it is PI, - 0 if normal and all o.k.; <0 if not. -*/ -int entopen(ecb) -struct entity *ecb; /* Entity control block. */ -{ - int i; /* Loop counter. */ - - /* See if we have exceeded the entity nesting level. */ - if (es>=ENTLVL) { - sgmlerr(34, (struct parse *)0, ecb->ename+1, ntoa(ENTLVL)); - return(ENTMAX); - } - /* If entity is an etd, pi, or data, return it without creating an scb. */ - switch (ecb->estore) { - case ESN: - if (NEXTYPE(ecb->etx.n)!=ESNSUB) { - if (!NEDCNDEFINED(ecb->etx.n)) - sgmlerr(78, (struct parse *)0, NEDCN(ecb->etx.n)+1, - ecb->ename+1); - } - else { -#if 0 - if (!NEID(ecb->etx.n)) { - sgmlerr(149, (struct parse *)0, ecb->ename + 1, (UNCH *)0); - return ENTFILE; - } -#endif - if (sw.nopen >= sd.subdoc) - sgmlerr(188, (struct parse *)0, - (UNCH *)NULL, (UNCH *)NULL); - } - data = (UNCH *)ecb->etx.n; - entdatsw = NDECONT; - return(ENTDATA); - case ESC: - case ESX: - datalen = ustrlen(ecb->etx.c); - data = ecb->etx.c; - entdatsw = (ecb->estore==ESC) ? CDECONT : SDECONT; - return(ENTDATA); - case ESI: - datalen = ustrlen(ecb->etx.c); - data = ecb->etx.c; - entpisw = 4; - return(ENTPI); - } - /* If the same entity is already open, send msg and ignore it. - Level 0 needn't be tested, as its entity name is always *DOC. - */ - for (i = 0; ++i<=es;) if (scbs[i].ecb.enext==ecb) { - sgmlerr(36, (struct parse *)0, ecb->ename+1, (UNCH *)0); - return(ENTLOOP); - } - /* Update SCB if entity trace is wanted in messages or entity is a file. - (Avoid this at start when es==-1 or memory will be corrupted.) - */ - if (es >= 0 && (sw.swenttr || FILESW)) scbset(); - - /* Stack the new source control block (we know there is room). */ - ++es; /* Increment scbs index. */ - RCNT = CCO = RSCC = 0; /* No records or chars yet. */ - COPIEDSW = 0; - memcpy((UNIV)&ECB, (UNIV)ecb, (UNS)ENTSZ); /* Copy the ecb into the scb. */ - ECBPTR = ecb; /* Save the ecb pointer in scb.ecb.enext. */ - TRACEECB("ENTOPEN", ECBPTR); - - /* For memory entities, the read buffer is the entity text. - The text starts at FBUF, so FPOS should be FBUF-1 - because it is bumped before each character is read. - */ - if (ECB.estoreestore) { - case ESF: - sgmlerr(149, (struct parse *)0, ecb->ename + 1, (UNCH *)0); - break; - case ESP: - sgmlerr(229, (struct parse *)0, ecb->ename + 2, (UNCH *)0); - break; - default: - abort(); - } - return ENTFILE; - } - fileopen(); /* Open new external file. */ - if (iorc<0) { /* If open not successful: */ - FPOS = FBUF-1; /* Clean CCNT for OPEN error msg.*/ - filerr(32, ecb->ename+1); - --es; /* Pop the stack. */ - return(ENTFILE); - } - filepend(es); /* Suspend any open file. */ - fileread(); /* First read of file must be ok.*/ - return 0; -} -/* ENTGET: Get next record of entity (if there is one). - Otherwise, close the file (if entity is a file) and - pop the entity stack. If nothing else is on the stack, - return -1 to advise the caller. -*/ -int entget() -{ - RSCC += (CCO = FPOS-FBUF); - /* Characters-in-record (ignore EOB/EOF). */ - tagctr += CCO; /* Update tag length counter. */ - switch (*FPOS) { - case EOBCHAR: /* End of file buffer: refill it. */ - rbufs[-2] = FPOS[-2]; - rbufs[-1] = FPOS[-1]; - fileread(); /* Read the file. */ - if (iorc > 0) break; - readerr: - filerr(31, ENTITY+1); /* Treat error as EOF. */ - case EOFCHAR: /* End of file: close it. */ - fileclos(); /* Call SGMLIO to close file. */ - conterr: - if (es==0) { /* Report if it is primary file. */ - FPOS = FBUF-1; /* Preserve CCNT for omitted end-tags. */ - return -1; - } - case EOS: /* End of memory entity: pop the stack. */ - TRACEECB("ENTPOP", ECBPTR); - if (COPIEDSW) { - frem((UNIV)(FBUF + 1)); - COPIEDSW = 0; - } - --es; /* Pop the SCB stack. */ - if (FBUF) break; /* Not a PEND file. */ - filecont(); /* Resume previous file. */ - if (iorc<0) { /* If CONT not successful: */ - filerr(94, ENTITY+1); - goto conterr; - } - fileread(); /* Read the file. */ - if (iorc<=0) goto readerr; /* If READ not successful: */ - rbufs[-1] = SCB.pushback; - FPOS += CCO; - CCO = 0; - if (delmscsw && es==0) { /* End of DTD. */ - delmscsw = 0; - *rbufs = lex.d.msc; - } - break; - } - return 0; -} -/* USEDEF: Use the default value for an entity reference. - Returns the ECB for the defaulted entity. -*/ -PECB usedef(ename) -UNCH *ename; /* Entity name (with length and EOS). */ -{ - union etext etx; /* Save return from entgen. */ - PECB ecb; /* Entity control block. */ - PNE pne = 0; /* Ptr to NDATA entity control block. */ - UNCH estore; /* Default entity storage type. */ - - if ((estore = ecbdeflt->estore)etx.c; - else { - /* Move entity name into fpi. */ - fpidf.fpinm = ename + 1; - if ((etx.x = entgen(&fpidf))==0) return (PECB)0; - if (estore==ESN) { - memcpy((UNIV)(pne=(PNE)rmalloc((UNS)NESZ)),(UNIV)ecbdeflt->etx.n,(UNS)NESZ); - NEID(pne) = etx.x; - etx.n = pne; - } - } - if (sw.swrefmsg) sgmlerr(45, (struct parse *)0, ename+1, (UNCH *)0); - ++ds.ecbcnt; - ecb = entdef(ename, estore, &etx); - ecb->dflt = 1; - if (pne) NEENAME(pne) = ecb->ename; - return(ecb); -} -/* SCBSET: Set source control block to current location in the current entity. - This routine is called by SGML when it returns to the text - processor and by ERROR when it reports an error. -*/ -VOID scbset() -{ - if (es >= 0 && FBUF) { - CC = *FPOS; - if (*FPOS == DELNONCH) - NEXTC = FPOS[1]; - else - NEXTC = 0; - CCO = FPOS + 1 - FBUF; - } -} -/* FILEOPEN: Call IOOPEN to open an external entity (file). -*/ -VOID fileopen() /* Open an external entity's file. */ -{ - iorc = ioopen(ECB.etx.x, &SCBFCB); -} -/* FILEREAD: Call IOREAD to read an open external entity (file). -*/ -VOID fileread() /* Read the current external entity's file. */ -{ - int newfile; - iorc = ioread(SCBFCB, rbufs, &newfile); - FPOS = (FBUF = rbufs) - 1; /* Actual read buffer. */ - if (newfile) RCNT = 0; -} -/* FILEPEND: Call IOPEND to close an open external entity (file) temporarily. -*/ -VOID filepend(es) /* Close the current external entity's file. */ -int es; /* Local index to scbs. */ -{ - while (--es>=0) { /* Find last external file on stack. */ - int off; - if (!FILESW) continue; /* Not an external file. */ - if (!FBUF) continue; /* Already suspended. */ - off = CCO; - assert(off >= -1); - if (off < 0) off = 0; - else CCO = 0; - FPOS -= CCO; - SCB.pushback = FPOS[-1]; - FBUF = 0; /* Indicate pending file. */ - RSCC += off; /* Update characters-in-record counter. */ - tagctr += off; /* Update tag length counter. */ - iopend(SCBFCB, off, rbufs); - return; - } -} -/* FILECONT: Call IOCONT to reopen an external entity (file). -*/ -VOID filecont() /* Open an external entity's file. */ -{ - iorc = iocont(SCBFCB); -} -/* FILECLOS: Call IOCLOSE to close an open external entity (file). -*/ -VOID fileclos() /* Close the current external entity's file. */ -{ - if (!SCBFCB) - return; - ioclose(SCBFCB); - /* The fcb will have been freed by sgmlio. - Make sure we don't access it again. */ - SCBFCB = NULL; -} -/* ERROR: Interface to text processor SGML I/O services for error handling. -*/ -VOID error(e) -struct error *e; -{ - scbset(); /* Update location in source control block. */ - msgprint(e); -} -/* PTRSRCH: Find a pointer in a list and return its index. - Search key must be on list as there is no limit test. - This routine is internal only -- not for user data. -*/ -UNIV mdnmtab[] = { - (UNIV)key[KATTLIST], - (UNIV)key[KDOCTYPE], - (UNIV)key[KELEMENT], - (UNIV)key[KENTITY], - (UNIV)key[KLINKTYPE], - (UNIV)key[KLINK], - (UNIV)key[KNOTATION], - (UNIV)sgmlkey, - (UNIV)key[KSHORTREF], - (UNIV)key[KUSELINK], - (UNIV)key[KUSEMAP] -}; -UNIV pcbtab[] = { - (UNIV)&pcbconc, - (UNIV)&pcbcone, - (UNIV)&pcbconm, - (UNIV)&pcbconr, - (UNIV)&pcbetag, - (UNIV)&pcbgrcm, - (UNIV)&pcbgrcs, - (UNIV)&pcbgrnm, - (UNIV)&pcbgrnt, - (UNIV)&pcblitc, - (UNIV)&pcblitp, - (UNIV)&pcblitr, - (UNIV)&pcblitt, - (UNIV)&pcblitv, - (UNIV)&pcbmd, - (UNIV)&pcbmdc, - (UNIV)&pcbmdi, - (UNIV)&pcbmds, - (UNIV)&pcbmsc, - (UNIV)&pcbmsi, - (UNIV)&pcbmsrc, - (UNIV)&pcbpro, - (UNIV)&pcbref, - (UNIV)&pcbstag, - (UNIV)&pcbval, - (UNIV)&pcbeal, - (UNIV)&pcbsd, -}; -UNS ptrsrch(ptrtab, ptr) -UNIV ptrtab[]; -UNIV ptr; -{ - UNS i; - - for (i = 0; ; ++i) - if (ptrtab[i] == ptr) - break; - return i; -} -/* MDERR: Process errors for markup declarations. - Prepare the special parameters that only exist for - markup declaration errors. -*/ -VOID mderr(number, parm1, parm2) -UNS number; /* Error number. */ -UNCH *parm1; /* Additional parameters (or NULL). */ -UNCH *parm2; /* Additional parameters (or NULL). */ -{ - struct error err; - errorinit(&err, subdcl ? MDERR : MDERR2, number); - err.parmno = parmno; - err.subdcl = subdcl; - err.eparm[0] = (UNIV)parm1; - err.eparm[1] = (UNIV)parm2; - err.errsp = (sizeof(pcbtab)/sizeof(pcbtab[0])) + ptrsrch(mdnmtab, - (UNIV)mdname); - error(&err); -} -/* SGMLERR: Process errors for SGML parser. -*/ -VOID sgmlerr(number, pcb, parm1, parm2) -UNS number; /* Error number. */ -struct parse *pcb; /* Current parse control block. */ -UNCH *parm1; /* Error message parameters. */ -UNCH *parm2; /* Error message parameters. */ -{ - struct error err; - errorinit(&err, DOCERR, number); - if (!pcb) pcb = prologsw ? propcb : conpcb; - err.errsp = ptrsrch(pcbtab, (UNIV)pcb); - err.eparm[0] = (UNIV)parm1; - err.eparm[1] = (UNIV)parm2; - error(&err); -} -/* SAVERR: Save an error for possible later use. -*/ -UNIV saverr(number, pcb, parm1, parm2) -UNS number; /* Error number. */ -struct parse *pcb; /* Current parse control block. */ -UNCH *parm1; /* Error message parameters. */ -UNCH *parm2; /* Error message parameters. */ -{ - struct error err; - errorinit(&err, DOCERR, number); - if (!pcb) pcb = prologsw ? propcb : conpcb; - err.errsp = ptrsrch(pcbtab, (UNIV)pcb); - err.eparm[0] = (UNIV)parm1; - err.eparm[1] = (UNIV)parm2; - scbset(); - return msgsave(&err); -} -/* SVDERR: Print a saved error. -*/ -VOID svderr(p) -UNIV p; -{ - msgsprint(p); -} -/* EXITERR: Process terminal errors for SGML parser. -*/ -VOID exiterr(number, pcb) -UNS number; /* Error number. */ -struct parse *pcb; /* Current parse control block. */ -{ - struct error err; - errorinit(&err, EXITERR, number); - if (!pcb) pcb = prologsw ? propcb : conpcb; - err.errsp = ptrsrch(pcbtab, (UNIV)pcb); - error(&err); - /* The error handler should have exited. */ - abort(); -} -/* SYNERR: Process syntax errors for SGML parser. -*/ -VOID synerr(number, pcb) -UNS number; /* Error number. */ -struct parse *pcb; /* Current parse control block. */ -{ - struct error err; - errorinit(&err, DOCERR, number); - err.errsp = ptrsrch(pcbtab, (UNIV)pcb); - error(&err); -} -/* FILERR: Process a file access error. -*/ -VOID filerr(number, parm) -UNS number; -UNCH *parm; -{ - struct error err; - errorinit(&err, FILERR, number); - err.eparm[0] = (UNIV)parm; - err.sverrno = errno; - error(&err); -} -/* ERRORINIT: Constructor for struct error. -*/ -VOID errorinit(e, type, number) -struct error *e; -UNS type; -UNS number; -{ - int i; - e->errtype = type; - e->errnum = number; - e->errsp = 0; - for (i = 0; i < MAXARGS; i++) - e->eparm[i] = 0; - e->parmno = 0; - e->subdcl = 0; -} -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgmlaux.h b/cde/programs/dtdocbook/sgmls/sgmlaux.h deleted file mode 100644 index f27d7e89c..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlaux.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlaux.h /main/3 1996/06/19 17:17:25 drk $ */ -/* This file controls the interface between the parser core and the auxiliary -functions in entgen.c, sgmlio.c, and sgmlmsg.c */ - -#include "std.h" -#include "entity.h" -#include "sgmldecl.h" - -/* Error types (ERRTYPE) for calls to error-handling services - performed for SGML by the text processor (SGMLIO). - NOTE: Strings in these blocks have no lengths, but cannot exceed - NAMELEN (plus 1 more byte for the zero terminator). -*/ -#define FILERR 0 /* Error: file access. */ -#define DOCERR 1 /* Error: in document markup. */ -#define MDERR 2 /* Error: in markup declaration with subdcl. */ -#define MDERR2 3 /* Error: in markup declaration with no subdcl. */ -#define EXITERR 4 /* Error: terminal error in document markup. */ -/* Quantities affecting error messages and their arguments. -*/ -#define MAXARGS 2 /* Maximum number of arguments in a msg. */ - -/* NOTE: Error handler must return, or next call to SGML must be RSET or END, - except for EXITERR errors which must not return. -*/ -struct error { /* IPB for error messages. */ - UNS errtype; /* Type of error: DOC, MD, MD2, FIL. */ - UNS errnum; /* Error number. */ - UNS errsp; /* Special parameter index in message file. */ - int sverrno; /* Saved value of errno. */ - int parmno; /* MDERROR: declaration parameter number. */ - UNCH *subdcl; /* MDERROR: subject of declaration. */ - UNIV eparm[MAXARGS]; /* Ptrs to arguments (no length, but EOS). */ -}; - -struct location { - int filesw; - unsigned long rcnt; - int ccnt; - UNCH curchar; - UNCH nextchar; - UNCH *ename; - UNIV fcb; -}; - -int ioopen P((UNIV, UNIV*)); -VOID ioclose P((UNIV)); -int ioread P((UNIV, UNCH *, int *)); -VOID iopend P((UNIV, int, UNCH *)); -int iocont P((UNIV)); -VOID ioinit P((struct switches *)); -char *ioflid P((UNIV)); - -UNIV entgen P((struct fpi *)); - -VOID msgprint P((struct error *)); -VOID msginit P((struct switches *)); -UNIV msgsave P((struct error *)); -VOID msgsprint P((UNIV)); -VOID msgsfree P((UNIV)); -int msgcnterr P((void)); - - -int inprolog P((void)); -UNCH *getgi P((int)); - -int getlocation P((int, struct location *)); -UNIV rmalloc P((unsigned int)); -UNIV rrealloc P((UNIV, UNS)); -VOID frem P((UNIV)); -VOID exiterr P((unsigned int,struct parse *)); diff --git a/cde/programs/dtdocbook/sgmls/sgmldecl.c b/cde/programs/dtdocbook/sgmls/sgmldecl.c deleted file mode 100644 index e10e1f59c..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmldecl.c +++ /dev/null @@ -1,1764 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmldecl.c /main/3 1996/06/19 17:17:29 drk $ */ -/* sgmldecl.c - - SGML declaration parsing. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "sgmlincl.h" - -/* Symbolic names for the error numbers that are be generated only by -this module. */ - -#define E_STANDARD 163 -#define E_SIGNIFICANT 164 -#define E_BADLIT 165 -#define E_SCOPE 166 -#define E_XNUM 167 -#define E_BADVERSION 168 -#define E_NMUNSUP 169 -#define E_XNMLIT 170 -#define E_CHARDESC 171 -#define E_CHARDUP 172 -#define E_CHARRANGE 173 -#define E_7BIT 174 -#define E_CHARMISSING 175 -#define E_SHUNNED 176 -#define E_NONSGML 177 -#define E_CAPSET 178 -#define E_CAPMISSING 179 -#define E_SYNTAX 180 -#define E_CHARNUM 181 -#define E_SWITCHES 182 -#define E_INSTANCE 183 -#define E_ZEROFEATURE 184 -#define E_YESNO 185 -#define E_CAPACITY 186 -#define E_NOTSUPPORTED 187 -#define E_FORMAL 189 -#define E_BADCLASS 190 -#define E_MUSTBENON 191 -#define E_BADBASECHAR 199 -#define E_SYNREFUNUSED 200 -#define E_SYNREFUNDESC 201 -#define E_SYNREFUNKNOWN 202 -#define E_SYNREFUNKNOWNSET 203 -#define E_FUNDUP 204 -#define E_BADFUN 205 -#define E_FUNCHAR 206 -#define E_GENDELIM 207 -#define E_SRDELIM 208 -#define E_BADKEY 209 -#define E_BADQUANTITY 210 -#define E_BADNAME 211 -#define E_REFNAME 212 -#define E_DUPNAME 213 -#define E_QUANTITY 214 -#define E_QTOOBIG 215 -#define E_NMSTRTCNT 219 -#define E_NMCHARCNT 220 -#define E_NMDUP 221 -#define E_NMBAD 222 -#define E_NMMINUS 223 -#define E_UNKNOWNSET 227 - -#define CANON_NMC '.' /* Canonical name character. */ -#define CANON_NMS 'A' /* Canonical name start character. */ -#define CANON_MIN ':' /* Canonical minimum data character. */ - -#define SUCCESS 1 -#define FAIL 0 -#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) -#define matches(tok, str) (ustrcmp((tok)+1, (str)) == 0) - -static UNCH standard[] = "ISO 8879:1986"; - -#define REFERENCE_SYNTAX "ISO 8879:1986//SYNTAX Reference//EN" -#define CORE_SYNTAX "ISO 8879:1986//SYNTAX Core//EN" - -static UNCH (*newkey)[REFNAMELEN+1] = 0; - -struct pmap { - char *name; - UNIV value; -}; - -/* The reference capacity set. */ -#define REFCAPSET \ -{ 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, \ -35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L, 35000L } - -long refcapset[NCAPACITY] = REFCAPSET; - -/* A pmap of known capacity sets. */ - -static struct pmap capset_map[] = { - { "ISO 8879:1986//CAPACITY Reference//EN", (UNIV)refcapset }, - { 0 }, -}; - -/* Table of capacity names. Must match *CAP in sgmldecl.h. */ - -char *captab[] = { - "TOTALCAP", - "ENTCAP", - "ENTCHCAP", - "ELEMCAP", - "GRPCAP", - "EXGRPCAP", - "EXNMCAP", - "ATTCAP", - "ATTCHCAP", - "AVGRPCAP", - "NOTCAP", - "NOTCHCAP", - "IDCAP", - "IDREFCAP", - "MAPCAP", - "LKSETCAP", - "LKNMCAP", -}; - -/* The default SGML declaration. */ -#define MAXNUMBER 99999999L - -/* Reference quantity set */ - -#define REFATTCNT 40 -#define REFATTSPLEN 960 -#define REFBSEQLEN 960 -#define REFDTAGLEN 16 -#define REFDTEMPLEN 16 -#define REFENTLVL 16 -#define REFGRPCNT 32 -#define REFGRPGTCNT 96 -#define REFGRPLVL 16 -#define REFNORMSEP 2 -#define REFPILEN 240 -#define REFTAGLEN 960 -#define REFTAGLVL 24 - -#define ALLOC_MAX 65534 - -#define BIGINT 30000 - -#define MAXATTCNT ((ALLOC_MAX/sizeof(struct ad)) - 2) -#define MAXATTSPLEN BIGINT -#define MAXBSEQLEN BIGINT -#define MAXDTAGLEN 16 -#define MAXDTEMPLEN 16 -#define MAXENTLVL ((ALLOC_MAX/sizeof(struct source)) - 1) -#define MAXGRPCNT MAXGRPGTCNT -/* Must be between 96 and 253 */ -#define MAXGRPGTCNT 253 -#define MAXGRPLVL MAXGRPGTCNT -#define MAXLITLEN BIGINT -/* This guarantees that NAMELEN < LITLEN (ie there's always space for a name -in a buffer intended for a literal.) */ -#define MAXNAMELEN (REFLITLEN - 1) -#define MAXNORMSEP 2 -#define MAXPILEN BIGINT -#define MAXTAGLEN BIGINT -#define MAXTAGLVL ((ALLOC_MAX/sizeof(struct tag)) - 1) - -/* Table of quantity names. Must match Q* in sgmldecl.h. */ - -static char *quantity_names[] = { - "ATTCNT", - "ATTSPLEN", - "BSEQLEN", - "DTAGLEN", - "DTEMPLEN", - "ENTLVL", - "GRPCNT", - "GRPGTCNT", - "GRPLVL", - "LITLEN", - "NAMELEN", - "NORMSEP", - "PILEN", - "TAGLEN", - "TAGLVL", -}; - -static int max_quantity[] = { - MAXATTCNT, - MAXATTSPLEN, - MAXBSEQLEN, - MAXDTAGLEN, - MAXDTEMPLEN, - MAXENTLVL, - MAXGRPCNT, - MAXGRPGTCNT, - MAXGRPLVL, - MAXLITLEN, - MAXNAMELEN, - MAXNORMSEP, - MAXPILEN, - MAXTAGLEN, - MAXTAGLVL, -}; - -static char *quantity_changed; - -/* Non-zero means the APPINFO parameter was not NONE. */ -static int appinfosw = 0; - -struct sgmldecl sd = { - REFCAPSET, /* capacity */ -#ifdef SUPPORT_SUBDOC - MAXNUMBER, /* subdoc */ -#else /* not SUPPORT_SUBDOC */ - 0, /* subdoc */ -#endif /* not SUPPORT_SUBDOC */ - 1, /* formal */ - 1, /* omittag */ - 1, /* shorttag */ - 1, /* shortref */ - { 1, 0 }, /* general/entity name case translation */ - { /* reference quantity set */ - REFATTCNT, - REFATTSPLEN, - REFBSEQLEN, - REFDTAGLEN, - REFDTEMPLEN, - REFENTLVL, - REFGRPCNT, - REFGRPGTCNT, - REFGRPLVL, - REFLITLEN, - REFNAMELEN, - REFNORMSEP, - REFPILEN, - REFTAGLEN, - REFTAGLVL, - }, -}; - -static int systemcharset[] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -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, 127, -128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, -144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, -160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, -176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, -192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, -208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, -224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, -240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, -}; - -static struct pmap charset_map[] = { - { "ESC 2/5 4/0", (UNIV)asciicharset }, /* ISO 646 IRV */ - { "ESC 2/8 4/2", (UNIV)asciicharset }, /* ISO Registration Number 6, ASCII */ - { SYSTEM_CHARSET_DESIGNATING_SEQUENCE, (UNIV)systemcharset }, - /* system character set */ - { 0 } -}; - -static int synrefcharset[256]; /* the syntax reference character set */ - -#define CHAR_NONSGML 01 -#define CHAR_SIGNIFICANT 02 -#define CHAR_MAGIC 04 -#define CHAR_SHUNNED 010 - -static UNCH char_flags[256]; -static int done_nonsgml = 0; -static UNCH *nlextoke = 0; /* new lextoke */ -static UNCH *nlextran = 0; /* new lextran */ - - -static UNCH kcharset[] = "CHARSET"; -static UNCH kbaseset[] = "BASESET"; -static UNCH kdescset[] = "DESCSET"; -static UNCH kunused[] = "UNUSED"; -static UNCH kcapacity[] = "CAPACITY"; -static UNCH kpublic[] = "PUBLIC"; -static UNCH ksgmlref[] = "SGMLREF"; -static UNCH kscope[] = "SCOPE"; -static UNCH kdocument[] = "DOCUMENT"; -static UNCH kinstance[] = "INSTANCE"; -static UNCH ksyntax[] = "SYNTAX"; -static UNCH kswitches[] = "SWITCHES"; -static UNCH kfeatures[] = "FEATURES"; -static UNCH kminimize[] = "MINIMIZE"; -static UNCH kdatatag[] = "DATATAG"; -static UNCH komittag[] = "OMITTAG"; -static UNCH krank[] = "RANK"; -static UNCH kshorttag[] = "SHORTTAG"; -static UNCH klink[] = "LINK"; -static UNCH ksimple[] = "SIMPLE"; -static UNCH kimplicit[] = "IMPLICIT"; -static UNCH kexplicit[] = "EXPLICIT"; -static UNCH kother[] = "OTHER"; -static UNCH kconcur[] = "CONCUR"; -static UNCH ksubdoc[] = "SUBDOC"; -static UNCH kformal[] = "FORMAL"; -static UNCH kyes[] = "YES"; -static UNCH kno[] = "NO"; -static UNCH kappinfo[] = "APPINFO"; -static UNCH knone[] = "NONE"; -static UNCH kshunchar[] = "SHUNCHAR"; -static UNCH kcontrols[] = "CONTROLS"; -static UNCH kfunction[] = "FUNCTION"; -static UNCH krs[] = "RS"; -static UNCH kre[] = "RE"; -static UNCH kspace[] = "SPACE"; -static UNCH knaming[] = "NAMING"; -static UNCH klcnmstrt[] = "LCNMSTRT"; -static UNCH kucnmstrt[] = "UCNMSTRT"; -static UNCH klcnmchar[] = "LCNMCHAR"; -static UNCH kucnmchar[] = "UCNMCHAR"; -static UNCH knamecase[] = "NAMECASE"; -static UNCH kdelim[] = "DELIM"; -static UNCH kgeneral[] = "GENERAL"; -static UNCH kentity[] = "ENTITY"; -static UNCH kshortref[] = "SHORTREF"; -static UNCH knames[] = "NAMES"; -static UNCH kquantity[] = "QUANTITY"; - -#define sderr mderr - -static UNIV pmaplookup P((struct pmap *, char *)); -static UNCH *ltous P((long)); -static VOID sdfixstandard P((UNCH *)); -static int sdparm P((UNCH *, struct parse *)); -static int sdname P((UNCH *, UNCH *)); -static int sdckname P((UNCH *, UNCH *)); -static int sdversion P((UNCH *)); -static int sdcharset P((UNCH *)); -static int sdcsdesc P((UNCH *, int *)); -static int sdpubcapacity P((UNCH *)); -static int sdcapacity P((UNCH *)); -static int sdscope P((UNCH *)); -static VOID setlexical P((void)); -static VOID noemptytag P((void)); -static int sdpubsyntax P((UNCH *)); -static int sdsyntax P((UNCH *)); -static int sdxsyntax P((UNCH *)); -static int sdtranscharnum P((UNCH *)); -static int sdtranschar P((int)); -static int sdshunchar P((UNCH *)); -static int sdsynref P((UNCH *)); -static int sdfunction P((UNCH *)); -static int sdnaming P((UNCH *)); -static int sddelim P((UNCH *)); -static int sdnames P((UNCH *)); -static int sdquantity P((UNCH *)); -static int sdfeatures P((UNCH *)); -static int sdappinfo P((UNCH *)); - -static VOID bufsalloc P((void)); -static VOID bufsrealloc P((void)); - -/* Parse the SGML declaration. Return non-zero if there was some appinfo. */ - -int sgmldecl() -{ - int i; - int errsw = 0; - UNCH endbuf[REFNAMELEN+2]; /* buffer for parsing terminating > */ - static int (*section[]) P((UNCH *)) = { - sdversion, - sdcharset, - sdcapacity, - sdscope, - sdsyntax, - sdfeatures, - sdappinfo, - }; - /* These are needed if we use mderr. */ - parmno = 0; - mdname = sgmlkey; - subdcl = NULL; - for (i = 0; i < SIZEOF(section); i++) - if ((*section[i])(tbuf) == FAIL) { - errsw = 1; - break; - } - if (!errsw) - setlexical(); - bufsrealloc(); - /* Parse the >. Don't overwrite the appinfo. */ - if (!errsw) - sdparm(endbuf, 0); - /* We must exit if we hit end of document. */ - if (pcbsd.action == EOD_) - exiterr(161, &pcbsd); - if (!errsw && pcbsd.action != ESGD) - sderr(126, (UNCH *)0, (UNCH *)0); - return appinfosw; -} - -/* Parse the literal (which should contain the version of the -standard) at the beginning of a SGML declaration. */ - -static int sdversion(tbuf) -UNCH *tbuf; -{ - if (sdparm(tbuf, &pcblitv) != LIT1) { - sderr(123, (UNCH *)0, (UNCH *)0); - return FAIL; - } - sdfixstandard(tbuf); - if (ustrcmp(tbuf, standard) != 0) - sderr(E_BADVERSION, tbuf, standard); - return SUCCESS; -} - -/* Parse the CHARSET section. Use one token lookahead. */ - -static int sdcharset(tbuf) -UNCH *tbuf; -{ - int i; - int status[256]; - - if (sdname(tbuf, kcharset) == FAIL) return FAIL; - (void)sdparm(tbuf, 0); - - if (sdcsdesc(tbuf, status) == FAIL) - return FAIL; - - for (i = 128; i < 256; i++) - if (status[i] != UNDESC) - break; - if (i >= 256) { - /* Only a 7-bit character set was described. Fill it out to 8-bits. */ - for (i = 128; i < 256; i++) - status[i] = UNUSED; -#if 0 - sderr(E_7BIT, (UNCH *)0, (UNCH *)0); -#endif - } - /* Characters that are declared UNUSED in the document character set - are assigned to non-SGML. */ - for (i = 0; i < 256; i++) { - if (status[i] == UNDESC) { - sderr(E_CHARMISSING, ltous((long)i), (UNCH *)0); - char_flags[i] |= CHAR_NONSGML; - } - else if (status[i] == UNUSED) - char_flags[i] |= CHAR_NONSGML; - } - done_nonsgml = 1; - return SUCCESS; -} - -/* Parse a character set description. Uses one character lookahead. */ - -static int sdcsdesc(tbuf, status) -UNCH *tbuf; -int *status; -{ - int i; - int nsets = 0; - struct fpi fpi; - - for (i = 0; i < 256; i++) - status[i] = UNDESC; - - for (;;) { - int nchars; - int *baseset = 0; - - if (pcbsd.action != NAS1) { - if (nsets == 0) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - break; - } - if (!matches(tbuf, kbaseset)) { - if (nsets == 0) { - sderr(118, tbuf+1, kbaseset); - return FAIL; - } - break; - } - nsets++; - MEMZERO((UNIV)&fpi, FPISZ); - if (sdparm(tbuf, &pcblitv) != LIT1) { - sderr(123, (UNCH *)0, (UNCH *)0); - return FAIL; - } - fpi.fpipubis = tbuf; - /* Give a warning if it is not a CHARSET fpi. */ - if (parsefpi(&fpi)) - sderr(E_FORMAL, (UNCH *)0, (UNCH *)0); - else if (fpi.fpic != FPICHARS) - sderr(E_BADCLASS, kcharset, (UNCH *)0); - else { - fpi.fpipubis[fpi.fpil + fpi.fpill] = '\0'; - baseset = (int *)pmaplookup(charset_map, - (char *)fpi.fpipubis + fpi.fpil); - if (!baseset) - sderr(E_UNKNOWNSET, fpi.fpipubis + fpi.fpil, (UNCH *)0); - } - if (sdname(tbuf, kdescset) == FAIL) return FAIL; - nchars = 0; - for (;;) { - long start, count; - long basenum; - if (sdparm(tbuf, 0) != NUM1) - break; - start = atol((char *)tbuf); - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - count = atol((char *)tbuf); - switch (sdparm(tbuf, &pcblitv)) { - case NUM1: - basenum = atol((char *)tbuf); - break; - case LIT1: - basenum = UNKNOWN; - break; - case NAS1: - if (matches(tbuf, kunused)) { - basenum = UNUSED; - break; - } - /* fall through */ - default: - sderr(E_CHARDESC, ltous(start), (UNCH *)0); - return FAIL; - } - if (start + count > 256) - sderr(E_CHARRANGE, (UNCH *)0, (UNCH *)0); - else { - int i; - int lim = (int)start + count; - for (i = (int)start; i < lim; i++) { - if (status[i] != UNDESC) - sderr(E_CHARDUP, ltous((long)i), (UNCH *)0); - else if (basenum == UNUSED || basenum == UNKNOWN) - status[i] = (int)basenum; - else if (baseset == 0) - status[i] = UNKNOWN_SET; - else { - int n = basenum + (i - start); - if (n < 0 || n > 255) - sderr(E_CHARRANGE, (UNCH *)0, (UNCH *)0); - else if (baseset[n] == UNUSED) - sderr(E_BADBASECHAR, ltous((long)n), (UNCH *)0); - else - status[i] = baseset[n]; - } - } - } - nchars++; - } - if (nchars == 0) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - } - return SUCCESS; -} - -/* Parse the CAPACITY section. Uses one token lookahead. */ - -static int sdcapacity(tbuf) -UNCH *tbuf; -{ - int ncap; - - if (sdckname(tbuf, kcapacity) == FAIL) - return FAIL; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kpublic)) - return sdpubcapacity(tbuf); - if (!matches(tbuf, ksgmlref)) { - sderr(E_CAPACITY, tbuf+1, (UNCH *)0); - return FAIL; - } - memcpy((UNIV)sd.capacity, (UNIV)refcapset, sizeof(sd.capacity)); - ncap = 0; - for (;;) { - int capno = -1; - int i; - - if (sdparm(tbuf, 0) != NAS1) - break; - for (i = 0; i < SIZEOF(captab); i++) - if (matches(tbuf, captab[i])) { - capno = i; - break; - } - if (capno < 0) - break; - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - sd.capacity[capno] = atol((char *)tbuf); - ncap++; - } - if (ncap == 0) { - sderr(E_CAPMISSING, (UNCH *)0, (UNCH *)0); - return FAIL; - } - - return SUCCESS; -} - -/* Parse a CAPACITY section that started with PUBLIC. Must do one -token lookahead, since sdcapacity() also does. */ - -static int sdpubcapacity(tbuf) -UNCH *tbuf; -{ - UNIV ptr; - if (sdparm(tbuf, &pcblitv) != LIT1) { - sderr(123, (UNCH *)0, (UNCH *)0); - return FAIL; - } - sdfixstandard(tbuf); - ptr = pmaplookup(capset_map, (char *)tbuf); - if (!ptr) - sderr(E_CAPSET, tbuf, (UNCH *)0); - else - memcpy((UNIV)sd.capacity, (UNIV)ptr, sizeof(sd.capacity)); - (void)sdparm(tbuf, 0); - return SUCCESS; -} - -/* Parse the SCOPE section. Uses no lookahead. */ - -static int sdscope(tbuf) -UNCH *tbuf; -{ - if (sdckname(tbuf, kscope) == FAIL) - return FAIL; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kdocument)) - ; - else if (matches(tbuf, kinstance)) - sderr(E_INSTANCE, (UNCH *)0, (UNCH *)0); - else { - sderr(E_SCOPE, tbuf+1, (UNCH *)0); - return FAIL; - } - return SUCCESS; -} - -/* Parse the SYNTAX section. Uses one token lookahead. */ - -static int sdsyntax(tbuf) -UNCH *tbuf; -{ - if (sdname(tbuf, ksyntax) == FAIL) return FAIL; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kpublic)) - return sdpubsyntax(tbuf); - return sdxsyntax(tbuf); -} - -/* Parse the SYNTAX section which starts with PUBLIC. Uses one token -lookahead. */ - -static int sdpubsyntax(tbuf) -UNCH *tbuf; -{ - int nswitches; - if (sdparm(tbuf, &pcblitv) != LIT1) - return FAIL; - sdfixstandard(tbuf); - if (ustrcmp(tbuf, CORE_SYNTAX) == 0) - sd.shortref = 0; - else if (ustrcmp(tbuf, REFERENCE_SYNTAX) == 0) - sd.shortref = 1; - else - sderr(E_SYNTAX, tbuf, (UNCH *)0); - if (sdparm(tbuf, 0) != NAS1) - return SUCCESS; - if (!matches(tbuf, kswitches)) - return SUCCESS; - nswitches = 0; - for (;;) { - int errsw = 0; - - if (sdparm(tbuf, 0) != NUM1) - break; - if (atol((char *)tbuf) > 255) { - sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0); - errsw = 1; - } - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (!errsw) { - if (atol((char *)tbuf) > 255) - sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0); - } - nswitches++; - } - if (nswitches == 0) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - sderr(E_SWITCHES, (UNCH *)0, (UNCH *)0); - return SUCCESS; -} - -/* Parse an explicit concrete syntax. Uses one token lookahead. */ - -static -int sdxsyntax(tbuf) -UNCH *tbuf; -{ - static int (*section[]) P((UNCH *)) = { - sdshunchar, - sdsynref, - sdfunction, - sdnaming, - sddelim, - sdnames, - sdquantity, - }; - int i; - - for (i = 0; i < SIZEOF(section); i++) - if ((*section[i])(tbuf) == FAIL) - return FAIL; - return SUCCESS; -} - -/* Parse the SHUNCHAR section. Uses one token lookahead. */ - -static -int sdshunchar(tbuf) -UNCH *tbuf; -{ - int i; - for (i = 0; i < 256; i++) - char_flags[i] &= ~CHAR_SHUNNED; - - if (sdckname(tbuf, kshunchar) == FAIL) - return FAIL; - - if (sdparm(tbuf, 0) == NAS1) { - if (matches(tbuf, knone)) { - (void)sdparm(tbuf, 0); - return SUCCESS; - } - if (matches(tbuf, kcontrols)) { - for (i = 0; i < 256; i++) - if (ISASCII(i) && iscntrl(i)) - char_flags[i] |= CHAR_SHUNNED; - if (sdparm(tbuf, 0) != NUM1) - return SUCCESS; - } - } - if (pcbsd.action != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - do { - long n = atol((char *)tbuf); - if (n > 255) - sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0); - else - char_flags[(int)n] |= CHAR_SHUNNED; - } while (sdparm(tbuf, 0) == NUM1); - return SUCCESS; -} - -/* Parse the syntax reference character set. Uses one token lookahead. */ - -static -int sdsynref(tbuf) -UNCH *tbuf; -{ - return sdcsdesc(tbuf, synrefcharset); -} - -/* Translate a character number from the syntax reference character set -to the system character set. If it can't be done, give an error message -and return -1. */ - -static -int sdtranscharnum(tbuf) -UNCH *tbuf; -{ - long n = atol((char *)tbuf); - if (n > 255) { - sderr(E_CHARNUM, (UNCH *)0, (UNCH *)0); - return -1; - } - return sdtranschar((int)n); -} - - -static -int sdtranschar(n) -int n; -{ - int ch = synrefcharset[n]; - if (ch >= 0) - return ch; - switch (ch) { - case UNUSED: - sderr(E_SYNREFUNUSED, ltous((long)n), (UNCH *)0); - break; - case UNDESC: - sderr(E_SYNREFUNDESC, ltous((long)n), (UNCH *)0); - break; - case UNKNOWN: - sderr(E_SYNREFUNKNOWN, ltous((long)n), (UNCH *)0); - break; - case UNKNOWN_SET: - sderr(E_SYNREFUNKNOWNSET, ltous((long)n), (UNCH *)0); - break; - default: - abort(); - } - return -1; -} - - -/* Parse the function section. Uses two tokens lookahead. "NAMING" -could be a function name. */ - -static -int sdfunction(tbuf) -UNCH *tbuf; -{ - static UNCH *fun[] = { kre, krs, kspace }; - static int funval[] = { RECHAR, RSCHAR, ' ' }; - int i; - int had_tab = 0; - int changed = 0; /* attempted to change reference syntax */ - - if (sdckname(tbuf, kfunction) == FAIL) - return FAIL; - for (i = 0; i < SIZEOF(fun); i++) { - int ch; - if (sdname(tbuf, fun[i]) == FAIL) - return FAIL; - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - ch = sdtranscharnum(tbuf); - if (ch >= 0 && ch != funval[i]) - changed = 1; - } - for (;;) { - int tabsw = 0; - int namingsw = 0; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, (UNCH *)"TAB")) { - tabsw = 1; - if (had_tab) - sderr(E_FUNDUP, (UNCH *)0, (UNCH *)0); - } - else { - for (i = 0; i < SIZEOF(fun); i++) - if (matches(tbuf, fun[i])) - sderr(E_BADFUN, fun[i], (UNCH *)0); - if (matches(tbuf, knaming)) - namingsw = 1; - else - changed = 1; - } - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (namingsw) { - if (matches(tbuf, klcnmstrt)) - break; - changed = 1; - } - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (tabsw && !had_tab) { - int ch = sdtranscharnum(tbuf); - if (ch >= 0 && ch != TABCHAR) - changed = 1; - had_tab = 1; - } - - } - if (!had_tab) - changed = 1; - if (changed) - sderr(E_FUNCHAR, (UNCH *)0, (UNCH *)0); - return SUCCESS; -} - -/* Parse the NAMING section. Uses no lookahead. */ - -static -int sdnaming(tbuf) -UNCH *tbuf; -{ - int i; - int bad = 0; - static UNCH *classes[] = { klcnmstrt, kucnmstrt, klcnmchar, kucnmchar }; - static UNCH *types[] = { kgeneral, kentity }; - -#define NCLASSES SIZEOF(classes) - - int bufsize = 4; /* allocated size of buf */ - UNCH *buf = (UNCH *)rmalloc(bufsize); /* holds characters - in naming classes */ - int bufi = 0; /* next index into buf */ - int start[NCLASSES]; /* index of first character for each class */ - int count[NCLASSES]; /* number of characters for each class */ - - for (i = 0; i < NCLASSES; i++) { - UNCH *s; - - if (sdckname(tbuf, classes[i]) == FAIL) { - frem((UNIV)buf); - return FAIL; - } - if (sdparm(tbuf, &pcblitp) != LIT1) { - sderr(123, (UNCH *)0, (UNCH *)0); - frem((UNIV)buf); - return FAIL; - } - start[i] = bufi; - - for (s = tbuf; *s; s++) { - int c = *s; - if (c == DELNONCH) { - c = UNSHIFTNON(*s); - s++; - } - c = sdtranschar(c); - if (c < 0) - bad = 1; - else if ((char_flags[c] & (CHAR_SIGNIFICANT | CHAR_MAGIC)) - && c != '.' && c != '-') { - int class = lextoke[c]; - if (class == SEP || class == SP || class == NMC - || class == NMS || class == NU) - sderr(E_NMBAD, ltous((long)c), (UNCH *)0); - else - sderr(E_NMUNSUP, ltous((long)c), (UNCH *)0); - bad = 1; - } - if (bufi >= bufsize) - buf = (UNCH *)rrealloc((UNIV)buf, bufsize *= 2); - buf[bufi++] = c; - } - - count[i] = bufi - start[i]; - (void)sdparm(tbuf, 0); - } - if (!bad && count[0] != count[1]) { - sderr(E_NMSTRTCNT, (UNCH *)0, (UNCH *)0); - bad = 1; - } - if (!bad && count[2] != count[3]) { - sderr(E_NMCHARCNT, (UNCH *)0, (UNCH *)0); - bad = 1; - } - if (!bad) { - nlextoke = (UNCH *)rmalloc(256); - memcpy((UNIV)nlextoke, lextoke, 256); - nlextoke['.'] = nlextoke['-'] = INV; - - nlextran = (UNCH *)rmalloc(256); - memcpy((UNIV)nlextran, lextran, 256); - - for (i = 0; i < count[0]; i++) { - UNCH lc = buf[start[0] + i]; - UNCH uc = buf[start[1] + i]; - nlextoke[lc] = NMS; - nlextoke[uc] = NMS; - nlextran[lc] = uc; - } - - for (i = 0; i < count[2]; i++) { - UNCH lc = buf[start[2] + i]; - UNCH uc = buf[start[3] + i]; - if (nlextoke[lc] == NMS) { - sderr(E_NMDUP, ltous((long)lc), (UNCH *)0); - bad = 1; - } - else if (nlextoke[uc] == NMS) { - sderr(E_NMDUP, ltous((long)uc), (UNCH *)0); - bad = 1; - } - else { - nlextoke[lc] = NMC; - nlextoke[uc] = NMC; - nlextran[lc] = uc; - } - } - if (nlextoke['-'] != NMC) { - sderr(E_NMMINUS, (UNCH *)0, (UNCH *)0); - bad = 1; - } - if (bad) { - if (nlextoke) { - frem((UNIV)nlextoke); - nlextoke = 0; - } - if (nlextran) { - frem((UNIV)nlextran); - nlextran = 0; - } - } - } - - frem((UNIV)buf); - - if (sdckname(tbuf, knamecase) == FAIL) - return FAIL; - for (i = 0; i < SIZEOF(types); ++i) { - if (sdname(tbuf, types[i]) == FAIL) - return FAIL; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kyes)) - sd.namecase[i] = 1; - else if (matches(tbuf, kno)) - sd.namecase[i] = 0; - else { - sderr(E_YESNO, tbuf+1, (UNCH *)0); - return FAIL; - } - } - return SUCCESS; -} - -/* Parse the DELIM section. Uses one token lookahead. */ - -static -int sddelim(tbuf) -UNCH *tbuf; -{ - int changed = 0; - if (sdname(tbuf, kdelim) == FAIL - || sdname(tbuf, kgeneral) == FAIL - || sdname(tbuf, ksgmlref) == FAIL) - return FAIL; - for (;;) { - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kshortref)) - break; - if (sdparm(tbuf, &pcblitp) != LIT1) { - sderr(123, (UNCH *)0, (UNCH *)0); - return FAIL; - } - changed = 1; - } - if (changed) { - sderr(E_GENDELIM, (UNCH *)0,(UNCH *)0); - changed = 0; - } - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, ksgmlref)) - sd.shortref = 1; - else if (matches(tbuf, knone)) - sd.shortref = 0; - else { - sderr(118, tbuf+1, ksgmlref); /* probably they forgot SGMLREF */ - return FAIL; - } - while (sdparm(tbuf, &pcblitp) == LIT1) - changed = 1; - if (changed) - sderr(E_SRDELIM, (UNCH *)0, (UNCH *)0); - return SUCCESS; -} - -/* Parse the NAMES section. Uses one token lookahead. */ - -static -int sdnames(tbuf) -UNCH *tbuf; -{ - int i; - if (sdckname(tbuf, knames) == FAIL) - return FAIL; - if (sdname(tbuf, ksgmlref) == FAIL) - return FAIL; - - while (sdparm(tbuf, 0) == NAS1) { - int j; - if (matches(tbuf, kquantity)) - break; - for (i = 0; i < NKEYS; i++) - if (matches(tbuf, key[i])) - break; - if (i >= NKEYS) { - sderr(E_BADKEY, tbuf+1, (UNCH *)0); - return FAIL; - } - if (sdparm(tbuf, &pcblitp) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (!newkey) { - newkey = (UNCH (*)[REFNAMELEN+1])rmalloc((REFNAMELEN+1)*NKEYS); - MEMZERO((UNIV)newkey, (REFNAMELEN+1)*NKEYS); - } - for (j = 0; j < NKEYS; j++) { - if (matches(tbuf, key[j])) { - sderr(E_REFNAME, tbuf + 1, (UNCH *)0); - break; - } - if (matches(tbuf, newkey[j])) { - sderr(E_DUPNAME, tbuf + 1, (UNCH *)0); - break; - } - } - if (j >= NKEYS) - ustrcpy(newkey[i], tbuf + 1); - } - /* Now install the new keys. */ - if (newkey) { - for (i = 0; i < NKEYS; i++) - if (newkey[i][0] != '\0') { - UNCH temp[REFNAMELEN + 1]; - - ustrcpy(temp, key[i]); - ustrcpy(key[i], newkey[i]); - ustrcpy(newkey[i], temp); - } - } - return SUCCESS; -} - -/* Parse the QUANTITY section. Uses one token lookahead. */ - -static int sdquantity(tbuf) -UNCH *tbuf; -{ - int quantity[NQUANTITY]; - int i; - - for (i = 0; i < NQUANTITY; i++) - quantity[i] = -1; - if (sdckname(tbuf, kquantity) == FAIL) - return FAIL; - if (sdname(tbuf, ksgmlref) == FAIL) - return FAIL; - while (sdparm(tbuf, 0) == NAS1 && !matches(tbuf, kfeatures)) { - long n; - for (i = 0; i < SIZEOF(quantity_names); i++) - if (matches(tbuf, quantity_names[i])) - break; - if (i >= SIZEOF(quantity_names)) { - sderr(E_BADQUANTITY, tbuf + 1, (UNCH *)0); - return FAIL; - } - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - n = atol((char *)tbuf); - if (n < sd.quantity[i]) - sderr(E_QUANTITY, (UNCH *)quantity_names[i], - ltous((long)sd.quantity[i])); - else if (n > max_quantity[i]) { - sderr(E_QTOOBIG, (UNCH *)quantity_names[i], - ltous((long)max_quantity[i])); - quantity[i] = max_quantity[i]; - } - else - quantity[i] = (int)n; - } - for (i = 0; i < NQUANTITY; i++) - if (quantity[i] > 0) { - sd.quantity[i] = quantity[i]; - if (!quantity_changed) - quantity_changed = (char *)rmalloc(NQUANTITY); - quantity_changed[i] = 1; - } - return SUCCESS; -} - -/* Parse the FEATURES section. Uses no lookahead. */ - -static int sdfeatures(tbuf) -UNCH *tbuf; -{ - static struct { - UNCH *name; - UNCH argtype; /* 0 = no argument, 1 = boolean, 2 = numeric */ - UNIV valp; /* UNCH * if boolean, long * if numeric. */ - } features[] = { - { kminimize, 0, 0 }, - { kdatatag, 1, 0 }, - { komittag, 1, (UNIV)&sd.omittag }, - { krank, 1, 0 }, - { kshorttag, 1, (UNIV)&sd.shorttag }, - { klink, 0, 0 }, - { ksimple, 2, 0 }, - { kimplicit, 1, 0 }, - { kexplicit, 2, 0 }, - { kother, 0, 0 }, - { kconcur, 2, 0 }, - { ksubdoc, 2, (UNIV)&sd.subdoc }, - { kformal, 1, (UNIV)&sd.formal }, - }; - - int i; - - if (sdckname(tbuf, kfeatures) == FAIL) - return FAIL; - for (i = 0; i < SIZEOF(features); i++) { - if (sdname(tbuf, features[i].name) == FAIL) return FAIL; - if (features[i].argtype > 0) { - long n; - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (matches(tbuf, kyes)) { - if (features[i].argtype > 1) { - if (sdparm(tbuf, 0) != NUM1) { - sderr(E_XNUM, (UNCH *)0, (UNCH *)0); - return FAIL; - } - n = atol((char *)tbuf); - if (n == 0) - sderr(E_ZEROFEATURE, features[i].name, (UNCH *)0); - } - else - n = 1; - } - else if (matches(tbuf, kno)) - n = 0; - else { - sderr(E_YESNO, tbuf+1, (UNCH *)0); - return FAIL; - } - if (features[i].valp == 0) { - if (n > 0) - sderr(E_NOTSUPPORTED, features[i].name, - (UNCH *)0); - } - else if (features[i].argtype > 1) - *(long *)features[i].valp = n; - else - *(UNCH *)features[i].valp = (UNCH)n; - } - } - if (!sd.shorttag) - noemptytag(); - return SUCCESS; -} - -/* Parse the APPINFO section. Uses no lookahead. */ - -static int sdappinfo(tbuf) -UNCH *tbuf; -{ - if (sdname(tbuf, kappinfo) == FAIL) return FAIL; - switch (sdparm(tbuf, &pcblitv)) { - case LIT1: - appinfosw = 1; - break; - case NAS1: - if (matches(tbuf, knone)) - break; - sderr(118, tbuf+1, knone); - return FAIL; - default: - sderr(E_XNMLIT, knone, (UNCH *)0); - return FAIL; - } - return SUCCESS; -} - -/* Change a prefix of ISO 8879-1986 to ISO 8879:1986. Amendment 1 to -the standard requires the latter. */ - -static VOID sdfixstandard(tbuf) -UNCH *tbuf; -{ - if (strncmp((char *)tbuf, "ISO 8879-1986", 13) == 0) { - sderr(E_STANDARD, (UNCH *)0, (UNCH *)0); - tbuf[8] = ':'; - } -} - -static int sdname(tbuf, key) -UNCH *tbuf; -UNCH *key; -{ - if (sdparm(tbuf, 0) != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (!matches(tbuf, key)) { - sderr(118, tbuf+1, key); - return FAIL; - } - return SUCCESS; -} - -static int sdckname(tbuf, key) -UNCH *tbuf; -UNCH *key; -{ - if (pcbsd.action != NAS1) { - sderr(120, (UNCH *)0, (UNCH *)0); - return FAIL; - } - if (!matches(tbuf, key)) { - sderr(118, tbuf+1, key); - return FAIL; - } - return SUCCESS; -} - -/* Parse a SGML declaration parameter. If lpcb is NULL, pt must be -REFNAMELEN+2 characters long, otherwise at least LITLEN+2 characters -long. LPCB should be NULL if a literal is not allowed. */ - -static int sdparm(pt, lpcb) -UNCH *pt; /* Token buffer. */ -struct parse *lpcb; /* PCB for literal parse. */ -{ - for (;;) { - parse(&pcbsd); - if (pcbsd.action != ISIG) - break; - sderr(E_SIGNIFICANT, (UNCH *)0, (UNCH *)0); - } - ++parmno; - switch (pcbsd.action) { - case LIT1: - if (!lpcb) { - sderr(E_BADLIT, (UNCH *)0, (UNCH *)0); - REPEATCC; - return pcbsd.action = INV_; - } - parselit(pt, lpcb, REFLITLEN, lex.d.lit); - return pcbsd.action; - case LIT2: - if (!lpcb) { - sderr(E_BADLIT, (UNCH *)0, (UNCH *)0); - REPEATCC; - return pcbsd.action = INV_; - } - parselit(pt, lpcb, REFLITLEN, lex.d.lita); - return pcbsd.action = LIT1; - case NAS1: - parsenm(pt, 1); - return pcbsd.action; - case NUM1: - parsetkn(pt, NU, REFNAMELEN); - return pcbsd.action; - } - return pcbsd.action; -} - -VOID sdinit() -{ - int i; - /* Shunned character numbers in the reference concrete syntax. */ - static UNCH refshun[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 255 - }; - UNCH **p; - /* A character is magic if it is a non-SGML character used for - some internal purpose in the parser. */ - char_flags[EOS] |= CHAR_MAGIC; - char_flags[EOBCHAR] |= CHAR_MAGIC; - char_flags[EOFCHAR] |= CHAR_MAGIC; - char_flags[GENRECHAR] |= CHAR_MAGIC; - char_flags[DELNONCH] |= CHAR_MAGIC; - char_flags[DELCDATA] |= CHAR_MAGIC; - char_flags[DELSDATA] |= CHAR_MAGIC; - - /* Figure out the significant SGML characters. */ - for (p = lextabs; *p; p++) { - UNCH datclass = (*p)[CANON_DATACHAR]; - UNCH nonclass = (*p)[CANON_NONSGML]; - for (i = 0; i < 256; i++) - if (!(char_flags[i] & CHAR_MAGIC) - && (*p)[i] != datclass && (*p)[i] != nonclass) - char_flags[i] |= CHAR_SIGNIFICANT; - } - for (i = 0; i < SIZEOF(refshun); i++) - char_flags[refshun[i]] |= CHAR_SHUNNED; - for (i = 0; i < 256; i++) - if (ISASCII(i) && iscntrl(i)) - char_flags[i] |= CHAR_SHUNNED; - bufsalloc(); -} - - -static -VOID bufsalloc() -{ - scbs = (struct source *)rmalloc((REFENTLVL+1)*sizeof(struct source)); - tbuf = (UNCH *)rmalloc(REFATTSPLEN+REFLITLEN+1); - /* entbuf is used for parsing numeric character references */ - entbuf = (UNCH *)rmalloc(REFNAMELEN + 2); -} - -static -VOID bufsrealloc() -{ - UNS size; - - if (ENTLVL != REFENTLVL) - scbs = (struct source *)rrealloc((UNIV)scbs, - (ENTLVL+1)*sizeof(struct source)); - /* Calculate the size for tbuf. */ - size = LITLEN + ATTSPLEN; - if (PILEN > size) - size = PILEN; - if (BSEQLEN > size) - size = BSEQLEN; - if (size != REFATTSPLEN + REFLITLEN) - tbuf = (UNCH *)rrealloc((UNIV)tbuf, size + 1); - if (NAMELEN != REFNAMELEN) - entbuf = (UNCH *)rrealloc((UNIV)entbuf, NAMELEN + 2); -} - - -/* Check that the non-SGML characters are compatible with the concrete -syntax and munge the lexical tables accordingly. If IMPLIED is -non-zero, then the SGML declaration was implied; in this case, don't -give error messages about shunned characters not being declared -non-SGML. Also make any changes that are required by the NAMING section. -*/ - -static VOID setlexical() -{ - int i; - UNCH **p; - - if (nlextoke) { - /* Handle characters that were made significant by the - NAMING section. */ - for (i = 0; i < 256; i++) - if (nlextoke[i] == NMC || nlextoke[i] == NMS) - char_flags[i] |= CHAR_SIGNIFICANT; - } - - for (i = 0; i < 256; i++) - if (char_flags[i] & CHAR_SIGNIFICANT) { - /* Significant SGML characters musn't be non-SGML. */ - if (char_flags[i] & CHAR_NONSGML) { - UNCH buf[2]; - buf[0] = i; - buf[1] = '\0'; - sderr(E_NONSGML, buf, (UNCH *)0); - char_flags[i] &= ~CHAR_NONSGML; - } - } - else { - /* Shunned characters that are not significant SGML characters - must be non-SGML. */ - if ((char_flags[i] & (CHAR_SHUNNED | CHAR_NONSGML)) - == CHAR_SHUNNED) { - sderr(E_SHUNNED, ltous((long)i), (UNCH *)0); - char_flags[i] |= CHAR_NONSGML; - } - } - - - /* Now munge the lexical tables. */ - for (p = lextabs; *p; p++) { - UNCH nonclass = (*p)[CANON_NONSGML]; - UNCH datclass = (*p)[CANON_DATACHAR]; - UNCH nmcclass = (*p)[CANON_NMC]; - UNCH nmsclass = (*p)[CANON_NMS]; - UNCH minclass = (*p)[CANON_MIN]; - for (i = 0; i < 256; i++) { - if (char_flags[i] & CHAR_NONSGML) { - /* We already know that it's not significant. */ - if (!(char_flags[i] & CHAR_MAGIC)) - (*p)[i] = nonclass; - } - else { - if (char_flags[i] & CHAR_MAGIC) { - sderr(E_MUSTBENON, ltous((long)i), (UNCH *)0); - } - else if (!(char_flags[i] & CHAR_SIGNIFICANT)) - (*p)[i] = datclass; - else if (nlextoke - /* This relies on the fact that lextoke - occurs last in lextabs. */ - && lextoke[i] != nlextoke[i]) { - switch (nlextoke[i]) { - case NMC: - (*p)[i] = nmcclass; - break; - case NMS: - (*p)[i] = nmsclass; - break; - case INV: - /* This will happen if period is not a - name character. */ - (*p)[i] = minclass; - break; - default: - abort(); - } - } - } - } - } - if (nlextran) { - memcpy((UNIV)lextran, (UNIV)nlextran, 256); - frem((UNIV)nlextran); - } - if (nlextoke) { - frem((UNIV)nlextoke); - nlextoke = 0; - } - -} - -/* Munge parse tables so that empty start and end tags are not recognized. */ - -static VOID noemptytag() -{ - static struct parse *pcbs[] = { &pcbconm, &pcbcone, &pcbconr, &pcbconc }; - int i; - - for (i = 0; i < SIZEOF(pcbs); i++) { - int maxclass, maxstate; - int j, k, act; - UNCH *plex = pcbs[i]->plex; - UNCH **ptab = pcbs[i]->ptab; - - /* Figure out the maximum lexical class. */ - maxclass = 0; - for (j = 0; j < 256; j++) - if (plex[j] > maxclass) - maxclass = plex[j]; - - /* Now figure out the maximum state number and at the same time - change actions. */ - - maxstate = 0; - - for (j = 0; j <= maxstate; j += 2) { - for (k = 0; k <= maxclass; k++) - if (ptab[j][k] > maxstate) - maxstate = ptab[j][k]; - /* If the '>' class has an empty start or end tag action, - change it to the action that the NMC class has. */ - act = ptab[j + 1][plex['>']]; - if (act == NET_ || act == NST_) - ptab[j + 1][plex['>']] = ptab[j + 1][plex['_']]; - } - } -} - -/* Lookup the value of the entry in pmap PTR whose key is KEY. */ - -static UNIV pmaplookup(ptr, key) -struct pmap *ptr; -char *key; -{ - for (; ptr->name; ptr++) - if (strcmp(key, ptr->name) == 0) - return ptr->value; - return 0; -} - -/* Return an ASCII representation of N. */ - -static UNCH *ltous(n) -long n; -{ - static char buf[sizeof(long)*3 + 2]; - sprintf(buf, "%ld", n); - return (UNCH *)buf; -} - -VOID sgmlwrsd(fp) -FILE *fp; -{ - int i; - int changed; - char *p; - char uc[256]; /* upper case characters (with different lower - case characters) */ - char lcletter[256]; /* LC letters: a-z */ - - fprintf(fp, " 0) - fprintf(fp, "SUBDOC YES %ld ", sd.subdoc); - else - fprintf(fp, "SUBDOC NO "); - fprintf(fp, "FORMAL %s\n", sd.formal ? "YES" : "NO"); - fprintf(fp, "APPINFO NONE"); - fprintf(fp, ">\n"); -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgmldecl.h b/cde/programs/dtdocbook/sgmls/sgmldecl.h deleted file mode 100644 index 92be85117..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmldecl.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmldecl.h /main/3 1996/06/19 17:17:34 drk $ */ -/* sgmldecl.h: SGML declaration parsing. */ - -#define QATTCNT 0 -#define QATTSPLEN 1 -#define QBSEQLEN 2 -#define QDTAGLEN 3 -#define QDTEMPLEN 4 -#define QENTLVL 5 -#define QGRPCNT 6 -#define QGRPGTCNT 7 -#define QGRPLVL 8 -#define QLITLEN 9 -#define QNAMELEN 10 -#define QNORMSEP 11 -#define QPILEN 12 -#define QTAGLEN 13 -#define QTAGLVL 14 - -#define NQUANTITY (QTAGLVL+1) - -#define TOTALCAP 0 -#define ENTCAP 1 -#define ENTCHCAP 2 -#define ELEMCAP 3 -#define GRPCAP 4 -#define EXGRPCAP 5 -#define EXNMCAP 6 -#define ATTCAP 7 -#define ATTCHCAP 8 -#define AVGRPCAP 9 -#define NOTCAP 10 -#define NOTCHCAP 11 -#define IDCAP 12 -#define IDREFCAP 13 -#define MAPCAP 14 -#define LKSETCAP 15 -#define LKNMCAP 16 - -extern char *captab[]; - -struct sgmldecl { - long capacity[NCAPACITY]; - long subdoc; - UNCH formal; - UNCH omittag; - UNCH shorttag; - UNCH shortref; - UNCH namecase[2]; /* case translation of general/entity names */ - int quantity[NQUANTITY]; -}; - -extern struct sgmldecl sd; - -#define OMITTAG (sd.omittag) -#define SUBDOC (sd.subdoc) -#define SHORTTAG (sd.shorttag) -#define FORMAL (sd.formal) - -#define ATTCNT (sd.quantity[QATTCNT]) -#define ATTSPLEN (sd.quantity[QATTSPLEN]) -#define BSEQLEN (sd.quantity[QBSEQLEN]) -#define ENTLVL (sd.quantity[QENTLVL]) -#define GRPGTCNT (sd.quantity[QGRPGTCNT]) -#define GRPCNT (sd.quantity[QGRPCNT]) -#define GRPLVL (sd.quantity[QGRPLVL]) -#define LITLEN (sd.quantity[QLITLEN]) -#define NAMELEN (sd.quantity[QNAMELEN]) -#define NORMSEP (sd.quantity[QNORMSEP]) -#define PILEN (sd.quantity[QPILEN]) -#define TAGLEN (sd.quantity[QTAGLEN]) -#define TAGLVL (sd.quantity[QTAGLVL]) - -#define NAMECASE (sd.namecase[0]) -#define ENTCASE (sd.namecase[1]) - -#define YES 1 -#define NO 0 - -#define UNUSED -1 -#define UNKNOWN -2 -#define UNDESC -3 -#define UNKNOWN_SET -4 - -extern int asciicharset[]; diff --git a/cde/programs/dtdocbook/sgmls/sgmlfnsm.h b/cde/programs/dtdocbook/sgmls/sgmlfnsm.h deleted file mode 100644 index a2bdebf48..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlfnsm.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlfnsm.h /main/3 1996/06/19 17:17:38 drk $ */ -/* SGMLFNSM.H: SGML function declarations (ANSI prototypes). */ -VOID adlfree P((struct ad *, int)); -VOID adlval P((int,struct etd *)); -VOID aenttst P((int, UNCH *)); -int allhit P((struct thdr *,unsigned long *,int,int)); -VOID ambig P((void)); -VOID ambigfree P((void)); -int amemget P((struct ad *,int,UNCH *)); -int anmget P((int,UNCH *)); -int anmtgrp P((struct parse *,struct ad *,int,UNS *,int)); -int antvget P((int,UNCH *,UNCH **)); -int anyhit P((unsigned long *)); -int attval P((int,UNCH *,int,struct ad *)); -VOID charrefa P((UNCH *)); -int charrefn P((UNCH *, struct parse *)); -int context P((struct etd *,struct thdr *,struct mpos *,UNCH *,int)); -struct etd **copygrp P((struct etd **,unsigned int)); -int datachar P((int, struct parse *)); -struct dcncb *dcnfind P((UNCH *)); -VOID destack P((void)); -int econtext P((struct thdr *,struct mpos *,UNCH *)); -VOID endprolog P((void)); -struct entity *entfind P((UNCH *)); -int entopen P((struct entity *)); -/* VOID eposset P((void)); NOT YET IN USE. */ -VOID error P((struct error *)); -VOID errorinit P((struct error *, unsigned, unsigned)); -int etag P((void)); -int etagetd P((struct parse *)); -VOID etdadl P((struct etd *)); -VOID etdcan P((UNCH *)); -struct etd *etddef P((UNCH *)); -struct etd *etdref P((UNCH *)); -VOID exclude P((void)); -VOID fileclos P((void)); -VOID filecont P((void)); -VOID fileopen P((void)); -VOID filepend P((int)); -VOID fileread P((void)); -VOID filerr P((unsigned, UNCH *)); -VOID fixdatt P((struct dcncb *)); -struct parse *getpcb P((int)); -int groupopt P((struct thdr *,struct mpos *)); -int groupreq P((struct etd *,struct thdr *,struct mpos *)); -int grpsz P((struct thdr *,int)); -int hash P((UNCH *,int)); -struct hash *hfind P((struct hash **,UNCH *,int)); -struct hash *hin P((struct hash **,UNCH *,int,unsigned int)); -int iddef P((UNCH *)); -VOID idrck P((void)); -struct fwdref *idref P((UNCH *)); -VOID idreftst P((int,UNCH *)); -int ingrp P((struct etd **,struct etd *)); -VOID initatt P((struct ad *)); -int mapsrch P((struct map *,UNCH *)); -VOID mdadl P((UNCH *)); -int mdattdef P((int, int)); -VOID mddtde P((UNCH *)); -VOID mddtds P((UNCH *)); -VOID mdelem P((UNCH *)); -VOID mdentity P((UNCH *)); -VOID mderr P((unsigned int,UNCH *,UNCH *)); -struct parse *mdms P((UNCH *,struct parse *)); -int mdmse P((void)); -VOID mdnadl P((UNCH *)); -VOID mdnot P((UNCH *)); -VOID mdsrmdef P((UNCH *)); -VOID mdsrmuse P((UNCH *)); -int netetd P((struct parse *)); -VOID newtoken P((struct thdr *,struct mpos *,UNCH *)); -int nstetd P((void)); -UNCH *ntoa P((int)); -int offbit P((unsigned long *,int,int)); -int parsecon P((UNCH *,struct parse *)); -int parsefpi P((struct fpi *)); -struct thdr *parsegcm P((struct parse *,struct thdr *,struct thdr *)); -VOID parselit P((UNCH *,struct parse *,unsigned int,UNCH)); -struct thdr *parsemod P((int)); -int parsepro P((void)); -VOID parseseq P((UNCH *,int)); -VOID parsetag P((struct parse *)); -int parseval P((UNCH *,unsigned int,UNCH *)); -int pexmex P((struct etd *)); -unsigned int ptrsrch P((UNIV *,UNIV)); -UNCH *pubfield P((UNCH *,UNCH *,UNCH,UNS *)); -UNCH *replace P((UNCH *,UNCH *)); -UNCH *sandwich P((UNCH *,UNCH *,UNCH *)); -UNIV saverr P((unsigned int,struct parse *,UNCH *,UNCH *)); -VOID scbset P((void)); -VOID sdinit P((void)); -VOID setcurchar P((int)); -VOID setdtype P((void)); -int sgmlact P((UNCH)); -int sgmldecl P((void)); -VOID sgmlerr P((unsigned int,struct parse *,UNCH *,UNCH *)); -int shortref P((int,struct parse *)); -struct srh *srhfind P((UNCH *)); -VOID stack P((struct etd *)); -int stag P((int)); -int stagetd P((struct parse *)); -VOID startdtd P((void)); -UNCH *savenm P((UNCH *)); -UNCH *savestr P((UNCH *)); -VOID storedatt P((PNE)); -VOID svderr P((UNIV)); -VOID synerr P((unsigned int,struct parse *)); -int testend P((struct thdr *,struct mpos *,int,int)); -int tokenopt P((struct thdr *,struct mpos *)); -int tokenreq P((struct etd *,struct thdr *,struct mpos *)); -UNS vallen P((int,int,UNCH *)); -struct dcncb *dcndef P((UNCH *)); -struct entity *entdef P((UNCH *,UNCH,union etext *)); -int entget P((void)); -int entref P((UNCH *)); -struct etd *etdset P((struct etd *,UNCH,struct thdr *,struct etd **, - struct etd **, struct entity **)); -struct hash *hout P((struct hash **,UNCH *,int)); -struct fpi *mdextid P((UNCH *,struct fpi *,UNCH *,UNCH *,struct ne *)); -int parse P((struct parse *)); -struct ad *parseatt P((struct ad *,UNCH *)); -unsigned int parsegrp P((struct etd **,struct parse *, UNCH *)); -unsigned int parsngrp P((struct dcncb **,struct parse *, UNCH *)); -int parsemd P((UNCH *,int,struct parse *,unsigned int)); -UNCH *parsenm P((UNCH *,int)); -UNCH *parsetkn P((UNCH *,UNCH,int)); -UNCH *s2valnm P((UNCH *,UNCH *,UNCH,int)); -struct srh *srhdef P((UNCH *)); -int tokdata P((UNCH *, int)); -struct entity *usedef P((UNCH *)); diff --git a/cde/programs/dtdocbook/sgmls/sgmlincl.h b/cde/programs/dtdocbook/sgmls/sgmlincl.h deleted file mode 100644 index 5b54ec8ed..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlincl.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlincl.h /main/3 1996/06/19 17:17:42 drk $ */ -/* SGMLINCL.H: Include file for parser core. */ -#ifndef SGMLINCL /* Don't include this file more than once. */ -#define SGMLINCL 1 -#include "config.h" -#include "std.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "action.h" /* Action names for all parsing. */ -#include "adl.h" /* Definitions for attribute list processing. */ -#include "error.h" /* Symbols for error codes. */ -#include "etype.h" /* Definitions for element type processing. */ -#include "keyword.h" /* Definitions for keyword processing. */ -#include "lextoke.h" /* Symbols for tokenization lexical classes. */ -#include "source.h" /* Templates for source entity control blocks. */ -#include "synxtrn.h" /* Declarations for concrete syntax constants. */ -#include "sgmlxtrn.h" /* External variable declarations. */ -#include "trace.h" /* Declarations for internal trace functions. */ -#include "sgmlmain.h" -#include "sgmlaux.h" -#include "sgmlfnsm.h" /* ANSI C: Declarations for SGML functions. */ -#endif /* ndef SGMLINCL */ diff --git a/cde/programs/dtdocbook/sgmls/sgmlio.c b/cde/programs/dtdocbook/sgmls/sgmlio.c deleted file mode 100644 index 24078071c..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlio.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlio.c /main/3 1996/06/19 17:17:46 drk $ */ -/* sgmlio.c - - IO functions for core parser. - - Written by James Clark (jjc@jclark.com). -*/ - -/* SGML must see a file in which records start with RS and end with - RE, and EOFCHAR (Ctl-Z) is present at the end. This module must - supply these characters if they are not naturally present in the - file. SGML will open two files at a time: when an entity is - nested, the new file is opened before closing the old in order to - make sure the open is successful. If it is, the original open file - is closed temporarily (IOPEND); when the stack is popped, the new - file is closed and the original file is re-opened (IOCONT). SGML - will check error returns for the initial open of a file and all - reads, and for re-openings when the stack is popped, but not for - closes. Returning <0 indicates an error; 0 or more is a successful - operation, except for IOREAD where the return value is the number - of characters read, and must exceed 0 to be successful. The first - READ must always be successful, and normally consists of just - priming the buffer with EOBCHAR (or RS EOBCHAR). SGMLIO must - assure that there is an EOBCHAR at the end of each block read, - except for the last block of the entity, which must have an - EOFCHAR. - - SGML views an entity as a contiguous whole, without regard to its - actual form of storage. SGMLIO supports entities that are - equivalent to a single file of one or more records, or to a - concatenation of files. -*/ - -/* Uses only stream I/O. This module should be portable to most ANSI - systems. */ -/* We try to ensure that if an IO operation fails, then errno will contain - a meaningful value (although it may be zero.) */ - -#include "config.h" -#ifdef HAVE_O_NOINHERIT -#include -#include -#endif /* HAVE_O_NOINHERIT */ - -#include "sgmlaux.h" /* Include files for auxiliary functions.. */ - -#ifdef HAVE_O_NOINHERIT -#define FOPENR(file) nifopen(file) -FILE *nifopen P((char *)); -#else /* not HAVE_O_NOINHERIT */ -#define FOPENR(file) fopen((file), "r") -#endif /* not HAVE_O_NOINHERIT */ - -struct iofcb { /* I/O file control block. */ - FILE *fp; /* File handle. */ - fpos_t off; /* Offset in file of current read block. */ - char *next; /* Next file (NULL if no more). */ - char *file; /* Current file (no length byte). */ - int pendoff; /* Offset into line when file suspended. */ - char bol; /* Non-zero if currently at beginning of line. */ - char first; /* Non-zero if the first read. */ - char wasbol; /* Non-zero if current block was at beginning of line. */ - char canseek; - UNCH *pendbuf; /* Saved partial buffer for suspended file - that can't be closed and reopened. */ -}; - -static char *lastfile; /* The name of the last file closed. */ -static int bufsize; /* Size of buffer passed to ioread(). */ -static char ismagic[256]; /* Table of magic chars that need to be prefixed - by DELNONCH. */ -static int stdinused = 0; - -static char *nextstr P((char *)); /* Iterate over list of strings. */ -static FILE *openfile P((char *, char *)); -static int closefile P((FILE *)); -static int isreg P((FILE *)); - -VOID ioinit(swp) -struct switches *swp; -{ - ismagic[EOBCHAR] = 1; - ismagic[EOFCHAR] = 1; - ismagic[EOS] = 1; - ismagic[(UNCH)DELNONCH] = 1; - ismagic[(UNCH)GENRECHAR] = 1; - bufsize = swp->swbufsz; -} - -int ioopen(id, pp) -UNIV id; -UNIV *pp; -{ - struct iofcb *f; - char *s; - errno = 0; - if (!id) - return -1; - s = id; - if (!*s) - return -1; - f = (struct iofcb *)rmalloc((UNS)sizeof(struct iofcb)); - f->file = s; - f->next = nextstr(s); - errno = 0; - f->fp = openfile(f->file, &f->canseek); - f->bol = 1; - f->first = 1; - f->pendbuf = 0; - *pp = (UNIV)f; - return f->fp ? 1 : -1; -} - -VOID ioclose(p) -UNIV p; -{ - struct iofcb *f = (struct iofcb *)p; - if (f->fp) - closefile(f->fp); - lastfile = f->file; - frem((UNIV)f); -} - -VOID iopend(p, off, buf) -UNIV p; -int off; -UNCH *buf; -{ - struct iofcb *f = (struct iofcb *)p; - if (!f->canseek) { - UNCH *s; - for (s = buf + off; *s != EOFCHAR && *s != EOBCHAR; s++) - ; - s++; - f->pendbuf = (UNCH *)rmalloc((UNS)(s - buf - off)); - memcpy((UNIV)f->pendbuf, (UNIV)(buf + off), (UNS)(s - buf - off)); - return; - } - f->bol = 0; - if (f->wasbol) { - if (off == 0) - f->bol = 1; - else - off--; - } - f->pendoff = off; - if (f->fp) { - fclose(f->fp); - f->fp = 0; - } -} - -int iocont(p) -UNIV p; -{ - struct iofcb *f = (struct iofcb *)p; - int c = EOF; - int off = f->pendoff; - - if (!f->canseek) - return 0; - - errno = 0; - f->fp = FOPENR(f->file); - if (!f->fp) - return -1; - if (fsetpos(f->fp, &f->off)) - return -1; - while (--off >= 0) { - c = getc(f->fp); - if (c != EOF && ismagic[c]) - off--; - } - if (c == '\n') - f->bol = 1; - if (ferror(f->fp)) - return -1; - return 0; -} - -/* Return -1 on error, otherwise the number of bytes read. The -strategy is to concatenate the files, insert a RS at the beginning of -each line, and change each '\n' into a RE. The returned data -shouldn't cross a file boundary, otherwise error messages might be -inaccurate. The first read must always succeed. */ - -int ioread(p, buf, newfilep) -UNIV p; -UNCH *buf; -int *newfilep; -{ - int i = 0; - struct iofcb *f = (struct iofcb *)p; - FILE *fp; - int c; - - *newfilep = 0; - if (f->first) { - buf[i] = EOBCHAR; - f->first = 0; - return 1; - } - if (f->pendbuf) { - for (i = 0; - (buf[i] = f->pendbuf[i]) != EOBCHAR && buf[i] != EOFCHAR; - i++) - ; - frem((UNIV)f->pendbuf); - f->pendbuf = 0; - return i + 1; - } - fp = f->fp; - for (;;) { - errno = 0; - if (f->canseek && fgetpos(fp, &f->off)) - f->canseek = 0; - errno = 0; - c = getc(fp); - if (c != EOF) - break; - if (ferror(fp)) - return -1; - if (closefile(fp) == EOF) - return -1; - if (!f->next){ - f->fp = 0; - buf[0] = EOFCHAR; - return 1; - } - f->file = f->next; - f->next = nextstr(f->next); - *newfilep = 1; - errno = 0; - fp = f->fp = openfile(f->file, &f->canseek); - if (!fp) - return -1; - f->bol = 1; - } - if (f->bol) { - f->bol = 0; - buf[i++] = RSCHAR; - f->wasbol = 1; - } - else - f->wasbol = 0; - errno = 0; - for (;;) { - if (c == '\n') { - f->bol = 1; - buf[i++] = RECHAR; - break; - } - if (ismagic[c]) { - buf[i++] = DELNONCH; - buf[i++] = SHIFTNON(c); - } - else - buf[i++] = c; - if (i >= bufsize - 2) - break; - c = getc(fp); - if (c == EOF) { - if (ferror(fp)) - return -1; - /* This is in the middle of a line. */ - break; - } - } - buf[i++] = EOBCHAR; - return i; -} - -static char *nextstr(p) -char *p; -{ - p = strchr(p, '\0'); - return *++p ? p : 0; -} - -/* Return the filename associated with p. If p is NULL, return the filename -of the last file closed. */ - -char *ioflid(p) -UNIV p; -{ - if (!p) - return lastfile; - return ((struct iofcb *)p)->file; -} - -static -FILE *openfile(name, seekp) -char *name; -char *seekp; -{ - FILE *fp; - if (strcmp(name, STDINNAME) == 0) { - if (stdinused) - return 0; - stdinused = 1; - *seekp = 0; - return stdin; - } - fp = FOPENR(name); - if (fp) - *seekp = isreg(fp); - return fp; -} - -/* Return -1 on error, 0 otherwise. */ - -static -int closefile(fp) -FILE *fp; -{ - if (fp == stdin) { - stdinused = 0; - clearerr(fp); - return 0; - } - else - return fclose(fp); -} - -#ifdef HAVE_O_NOINHERIT - -/* This is the same as fopen(name, "r") except that it tells DOS that -the file descriptor should not be inherited by child processes. */ - -FILE *nifopen(name) -char *name; -{ - int fd = open(name, O_RDONLY|O_NOINHERIT|O_TEXT); - if (fd < 0) - return 0; - return fdopen(fd, "r"); -} - -#endif /* HAVE_O_NOINHERIT */ - -#ifdef HAVE_SYS_STAT_H - -#include -#include - -#ifndef S_ISREG -#ifdef S_IFMT -#ifdef S_IFREG -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif /* S_IFREG */ -#endif /* S_IFMT */ -#endif /* not S_ISREG */ - -#endif /* HAVE_SYS_STAT_H */ - -/* Return 1 if fp might be associated with a regular file. 0 -otherwise. We check this because on many Unix systems lseek() will -succeed on a (pseudo-)terminal although terminals aren't seekable in -the way we need. */ - -static -int isreg(fp) -FILE *fp; -{ -#ifdef S_ISREG - struct stat sb; - - /* This assumes that a system that has S_ISREG will also have - fstat() and fileno(). */ - if (fstat(fileno(fp), &sb) == 0) - return S_ISREG(sb.st_mode); -#endif /* S_ISREG */ - return 1; -} - - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -comment-column: 30 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgmlmain.h b/cde/programs/dtdocbook/sgmls/sgmlmain.h deleted file mode 100644 index 958d0ff63..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlmain.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlmain.h /main/3 1996/06/19 17:17:52 drk $ */ -/* SGMLMAIN: Main interface to SGML services. - -Preprocessor variable names are the only supported interface -to data maintained by SGML. They are defined in this file or in adl.h. -*/ -/* Return control block types (RCBTYPE) from calls to parser (SGML): - Names and strings follow the convention for the IPBs. -*/ -enum sgmlevent { - SGMLEOD, /* End of document. */ - SGMLDAF, /* Data found. */ - SGMLSTG, /* Start-tag found. */ - SGMLETG, /* End-tag found. */ - SGMLREF, /* Record end found. */ - SGMLPIS, /* Processing instruction (string). */ - SGMLAPP /* APPINFO (string) */ -}; - -struct rcbdata { /* Return control block: DAF EOD REF PIS APP. */ - UNS contersw; /* 1=context error; 2,4,8=data type; 0=not. */ - UNS datalen; /* Length of data or PI (0=single nonchar). */ - UNCH *data; /* Data, PI, single nonSGML, or NDATA ecb ptr. */ -}; - -struct rcbtag { /* Return control block for STG and ETG. */ - UNS contersw; /* 1=context error; 2=NET enabled; 0/0=not. */ - UNS tagmin; /* Minim: NONE NULL NET DATA; implied by S/ETAG */ - UNCH *curgi; /* Start-tag (or end-tag) GI. */ - union { - struct ad *al; /* Start-tag: attribute list. */ - UNCH *oldgi; /* End-tag: resumed GI. */ - } ru; - struct ad *lal; /* Start-tag: link attribute list (UNUSED). */ - UNS format; /* Format class for default processing. */ - struct etd *tagreal; /* Dummy etd or ptr to GI that implied this tag.*/ - int etictr; /* Number of elements on stack with NET enabled.*/ - UNCH *srmnm; /* Current SHORTREF map name (NULL=#EMPTY). */ -}; - -/* Accessors for rcbdata and rcbtag. */ -/* Datatype abbreviations: C=unsigned char S=string U=unsigned int L=4 bytes - A=array P=ptr to structure N=name (see sgmlcb.h) -*/ -/* Data control block fields: processing instructions (SGMLPIS). -*/ -#define PDATA(d) ((d).data) /*S PI string. */ -#define PDATALEN(d) ((d).datalen) /*U Length of PI string. */ -#define PIESW(d) (((d).contersw & 4)) /*U 1=PIDATA entity returned. */ -/* Data control block fields: other data types. -*/ -#define CDATA(d) ((d).data) /*S CDATA content string. */ -#define CDATALEN(d) ((d).datalen) /*U Length of CDATA content string. */ -#define CONTERSW(d) (((d).contersw &1))/*U 1=CDATA or TAG out of context. */ -#define CDESW(d) (((d).contersw & 2)) /*U 1=CDATA entity returned. */ -#define SDESW(d) (((d).contersw & 4)) /*U 1=SDATA entity returned. */ -#define NDESW(d) (((d).contersw & 8)) /*U 1=NDATA entity returned. */ -#define NEPTR(d) ((PNE)(d).data) /*P Ptr to NDATA control block. */ -#define MARKUP(d) ((d).data) /*A Markup delimiter strings. */ -#define DTYPELEN(d) ((d).datalen) /*U Length of doc type name +len+EOS. */ -#define DOCTYPE(d) ((d).data) /*S Document type name (with len+EOS). */ -#define ADATA(d) ((d).data) /*S APPINFO */ -#define ADATALEN(d) ((d).datalen) /*U Length of APPINFO string. */ -/* Tag control block fields. -*/ -#define ALPTR(t) ((t).ru.al) /*P Ptr to SGML attribute list. */ -#define CURGI(t) ((t).curgi+1) /*N GI of started or ended element. */ -#define OLDGI(t) ((t).ru.oldgi) /*S GI of resumed element. */ -#define TAGMIN(t) (t).tagmin /*U Minimization for current tag. */ -#define TAGREAL(t) ((t).tagreal) /*P Dummy etd that implied this tag. */ -#define TAGRLNM(t) ((UNCH *)(t).tagreal) /*P GI of tag that implied this tag.*/ -#define ETISW(t) (((t).contersw & 2)) /*U 1=NET delimiter enabled by ETI. */ -#define PEXSW(t) (((t).contersw & 4)) /*U 1=Element was plus exception. */ -#define MTYSW(t) (((t).contersw & 8)) /*U 1=Element is empty. */ -#define ETICTR(t) ((t).etictr) /*U Number of active NET delimiters. */ -#define SRMNM(t) ((t).srmnm) /*S Name of current SHORTREF map. */ -#define SRMCNT(t) ((t).contersw) /*U Number of SHORTREF maps defined. */ -#define FORMAT(t) ((t).format) /*U Format class.*/ - -/* These function names are chosen so as to be distinct in the first 6 -letters. */ - -/* Initialize. */ -struct markup *sgmlset P((struct switches *)); -/* Cleanup and return capacity usage statistics. */ -VOID sgmlend P((struct sgmlcap *)); -/* Set document entity. */ -int sgmlsdoc P((UNIV)); -/* Get entity. */ -int sgmlgent P((UNCH *, PNE *, UNCH **)); -/* Mark an entity. Return is non-zero if already marked.*/ -int sgmlment P((UNCH *)); -/* Get the next sgml event. */ -enum sgmlevent sgmlnext P((struct rcbdata *, struct rcbtag *)); -/* Get the error count. */ -int sgmlgcnterr P((void)); -/* Get the current location. */ -int sgmlloc P((unsigned long *, char **)); -/* Write out the SGML declaration. */ -VOID sgmlwrsd P((FILE *)); -/* Note subdocument capacity usage. */ -VOID sgmlsubcap P((long *)); diff --git a/cde/programs/dtdocbook/sgmls/sgmlmsg.c b/cde/programs/dtdocbook/sgmls/sgmlmsg.c deleted file mode 100644 index e71bdd592..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlmsg.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlmsg.c /main/3 1996/06/19 17:17:57 drk $ */ -/* sgmlmsg.c - - message handling for core parser - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" -#include "sgmlaux.h" -#include "msg.h" - -static nl_catd catd; - -#define TEXT_SET 1 /* message set number for text of messages */ -#define HEADER_SET 2 /* message set number for header strings */ -#define PARM_SET 3 /* message set number for special parameters */ - -#ifdef HAVE_EXTENDED_PRINTF -#define xfprintf fprintf -#else -extern int xfprintf VP((FILE *, char *,...)); -#endif - -#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) - -static char *gettext P((int)); -static char *getheader P((int)); -static char *getparm P((int)); -static VOID elttrace P((FILE *, int)); -static int printit P((FILE *, struct error *)); -static char *transparm P((UNCH *, char *)); -static VOID spaces P((FILE *, int)); - -#define PARMBUFSIZ 50 -static char parmbuf[PARMBUFSIZ*2]; -static char *parmbuf1 = parmbuf; -static char *parmbuf2 = parmbuf + PARMBUFSIZ; - -static char *prog; /* program name */ -static int sweltr; /* non-zero means print an element trace */ -static int swenttr; /* non-zero means print an entity trace */ -static int cnterr = 0; -static VOID (*die) P((void)); - -static char *headers[] = { -"In file included", -"SGML error", /* parameters: type, severity, number */ -"Unsupported feature", /* type U errors */ -"Error", /* for type R errors */ -"Warning", /* severity type I */ -" at %s, %.0sline %lu", /* ignore entity name and ccnt */ -" at entity %s, line %lu", -"%.0s%.0s in declaration parameter %d", /* ignore first two parameters */ -"%.0s in declaration parameter %d", /* ignore first parameter */ -"%.0s", /* parse mode */ -" at end of file", -" at end of entity", -" at record start", -" at record end", -" at \"%c\"", -" at \"\\%03o\"", -" accessing \"%s\"", -"Element structure:" -}; - -/* Indexes into headers[] */ - -#define HDRPFX 0 -#define HDRALL 1 -#define HDRUNSUP 2 -#define HDRSYS 3 -#define HDRWARN 4 -#define HDRLOC 5 -#define HDRELOC 6 -#define HDRMD 7 -#define HDRMD2 8 -#define HDRMODE 9 -#define HDREOF 10 -#define HDREE 11 -#define HDRRS 12 -#define HDRRE 13 -#define HDRPRT 14 -#define HDRCTL 15 -#define HDRFIL 16 -#define HDRELT 17 - -/* Special parameters (error::errsp) */ -static char *parms[] = { -"character data", -"element content", -"mixed content", -"replaceable character data", -"tag close", -"content model group", -"content model occurrence indicator", -"name group", -"name token group", -"system data", -"parameter literal", -"attribute value literal", -"tokenized attribute value literal", -"minimum literal", -"markup declaration", -"markup declaration comment", -"ignored markup declaration", -"declaration subset", -"CDATA marked section", -"IGNORE marked section", -"RCDATA marked section", -"prolog", -"reference", -"attribute specification list", -"tokenized attribute value", -"attribute specification list close", -"SGML declaration", -"attribute definition list", -"document type", -"element", -"entity", -"link type", -"link set", -"notation", -"SGML", -"short reference mapping", -"link set use", -"short reference use", -}; - -static FILE *tfp; /* temporary file for saved messages */ - -struct saved { - long start; - long end; - char exiterr; - char countit; -}; - -VOID msgprint(e) -struct error *e; -{ - if (printit(stderr, e)) - ++cnterr; - fflush(stderr); - if (e->errtype == EXITERR) { - if (die) { - (*die)(); - abort(); - } - else - exit(EXIT_FAILURE); - } -} - -/* Save an error message. */ - -UNIV msgsave(e) -struct error *e; -{ - struct saved *sv; - - sv = (struct saved *)rmalloc(sizeof(struct saved)); - if (!tfp) { - tfp = tmpfile(); - if (!tfp) - exiterr(160, (struct parse *)0); - } - sv->start = ftell(tfp); - sv->countit = (char)printit(tfp, e); - sv->end = ftell(tfp); - sv->exiterr = (char)(e->errtype == EXITERR); - return (UNIV)sv; -} - -/* Print a saved error message. */ - -VOID msgsprint(p) -UNIV p; -{ - struct saved *sv = (struct saved *)p; - long cnt; - - assert(p != 0); - assert(tfp != 0); - if (fseek(tfp, sv->start, SEEK_SET) < 0) - return; - /* Temporary files are opened in binary mode, so this is portable. */ - cnt = sv->end - sv->start; - while (--cnt >= 0) { - int c = getc(tfp); - if (c == EOF) - break; - putc(c, stderr); - } - fflush(stderr); - if (sv->countit) - ++cnterr; - if (sv->exiterr) - exit(EXIT_FAILURE); -} - -/* Free a sved error message. */ - -VOID msgsfree(p) -UNIV p; -{ - frem(p); -} - -/* Return 1 if it should be counted as an error. */ - -static int printit(efp, e) -FILE *efp; -struct error *e; -{ - int indent; - int countit; - int hdrcode; - int filelevel = -1, prevfilelevel = -1, toplevel; - struct location loc; - char type[2], severity[2]; - - assert(e->errnum < SIZEOF(messages)); - assert(messages[e->errnum].text != NULL); - if (prog) { - fprintf(efp, "%s: ", prog); - indent = strlen(prog) + 2; /* don't rely on return value of fprintf */ - /* Don't want to waste too much space on indenting. */ - if (indent > 10) - indent = 4; - } - else - indent = 4; - - for (toplevel = 0; getlocation(toplevel, &loc); toplevel++) - if (loc.filesw) { - prevfilelevel = filelevel; - filelevel = toplevel; - } - toplevel--; - - if (e->errtype == FILERR) { - toplevel--; - filelevel = prevfilelevel; - } - if (swenttr && filelevel > 0) { - int level = 0; - int middle = 0; /* in the middle of a line */ - do { - (void)getlocation(level, &loc); - if (loc.filesw) { - if (middle) { - fputs(":\n", efp); - spaces(efp, indent); - } - else - middle = 1; - xfprintf(efp, getheader(HDRPFX)); - xfprintf(efp, getheader(HDRLOC), ioflid(loc.fcb), - loc.ename, loc.rcnt, loc.ccnt); - } - else if (middle) - xfprintf(efp, getheader(HDRELOC), - loc.ename, loc.rcnt + 1, loc.ccnt); - } - while (++level != filelevel); - if (middle) { - fputs(":\n", efp); - spaces(efp, indent); - } - } - - /* We use strings for the type and severity, - so that the format can use %.0s to ignore them. */ - - type[0] = messages[e->errnum].type; - type[1] = '\0'; - severity[0] = messages[e->errnum].severity; - severity[1] = '\0'; - - countit = (severity[0] != 'I'); - if (!countit) - hdrcode = HDRWARN; - else if (type[0] == 'R') - hdrcode = HDRSYS; - else if (type[0] == 'U') - hdrcode = HDRUNSUP; - else - hdrcode = HDRALL; - - xfprintf(efp, getheader(hdrcode), type, severity, e->errnum); - - if (filelevel >= 0) { - (void)getlocation(filelevel, &loc); - xfprintf(efp, getheader(HDRLOC), - ioflid(loc.fcb), loc.ename, loc.rcnt, loc.ccnt); - while (filelevel < toplevel) { - ++filelevel; - if (swenttr) { - (void)getlocation(filelevel, &loc); - xfprintf(efp, getheader(HDRELOC), - loc.ename, loc.rcnt + 1, loc.ccnt); - } - } - } - - /* It is necessary to copy the result of getparm() because - the specification of catgets() says in can return a - pointer to a static buffer which may get overwritten - by the next call to catgets(). */ - - switch (e->errtype) { - case MDERR: - strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1); - xfprintf(efp, getheader(HDRMD), parmbuf, - (e->subdcl ? e->subdcl : (UNCH *)""), e->parmno); - break; - case MDERR2: - /* no subdcl parameter */ - strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1); - xfprintf(efp, getheader(HDRMD2), parmbuf, e->parmno); - break; - case DOCERR: - case EXITERR: - if (toplevel < 0) - break; - strncpy(parmbuf, getparm(e->errsp), PARMBUFSIZ*2 - 1); - xfprintf(efp, getheader(HDRMODE), parmbuf); - switch (loc.curchar) { - case EOFCHAR: - xfprintf(efp, getheader(HDREOF)); - break; - case RSCHAR: - xfprintf(efp, getheader(HDRRS)); - break; - case RECHAR: - xfprintf(efp, getheader(HDRRE)); - break; - case DELNONCH: - xfprintf(efp, getheader(HDRCTL), UNSHIFTNON(loc.nextchar)); - break; - case EOS: - xfprintf(efp, getheader(HDREE)); - break; - case EOBCHAR: - break; - default: - if (ISASCII(loc.curchar) && isprint(loc.curchar)) - xfprintf(efp, getheader(HDRPRT), loc.curchar); - else - xfprintf(efp, getheader(HDRCTL), loc.curchar); - break; - } - break; - case FILERR: - if (getlocation(toplevel + 1, &loc)) - xfprintf(efp, getheader(HDRFIL), ioflid(loc.fcb)); - break; - } - fputs(":\n", efp); - - if (e->errtype == FILERR && e->sverrno != 0) { - char *errstr = strerror(e->sverrno); - UNS len = strlen(errstr); - /* Strip a trailing newline if there is one. */ - if (len > 0 && errstr[len - 1] == '\n') - len--; - spaces(efp, indent); - for (; len > 0; len--, errstr++) - putc(*errstr, efp); - fputs(":\n", efp); - } - - spaces(efp, indent); - - xfprintf(efp, gettext(e->errnum), - transparm((UNCH *)e->eparm[0], parmbuf1), - transparm((UNCH *)e->eparm[1], parmbuf2)); - putc('\n', efp); - - if (sweltr) - elttrace(efp, indent); - return countit; -} - -/* Print an element trace. */ -static VOID elttrace(efp, indent) -FILE *efp; -int indent; -{ - int i = 1; - UNCH *gi; - - gi = getgi(i); - if (!gi) - return; - spaces(efp, indent); - xfprintf(efp, getheader(HDRELT)); - do { - fprintf(efp, " %s", gi); - gi = getgi(++i); - } while (gi); - putc('\n', efp); -} - -static VOID spaces(efp, indent) -FILE *efp; -int indent; -{ - while (--indent >= 0) - putc(' ', efp); -} - -VOID msginit(swp) -struct switches *swp; -{ - catd = swp->catd; - prog = swp->prog; - sweltr = swp->sweltr; - swenttr = swp->swenttr; - die = swp->die; -} - -/* Return the error count. */ - -int msgcnterr() -{ - return cnterr; -} - -/* Transform a parameter into a form suitable for printing. */ - -static char *transparm(s, buf) -UNCH *s; -char *buf; -{ - char *ptr; - int cnt; - - if (!s) - return 0; - - ptr = buf; - cnt = PARMBUFSIZ - 4; /* space for `...\0' */ - - while (*s) { - UNCH ch = *s++; - if (ch == DELNONCH) { - if (*s == '\0') - break; - ch = UNSHIFTNON(*s); - s++; - } - if (ch == DELCDATA || ch == DELSDATA) - ; - else if (ch == '\\') { - if (cnt < 2) - break; - *ptr++ = '\\'; - *ptr++ = '\\'; - cnt -= 2; - } - else if (ISASCII(ch) && isprint(ch)) { - if (cnt < 1) - break; - *ptr++ = ch; - cnt--; - } - else { - if (cnt < 4) - break; - sprintf(ptr, "\\%03o", ch); - ptr += 4; - cnt -= 4; - } - } - if (!*s) - *ptr = '\0'; - else - strcpy(ptr, "..."); - return buf; -} - -/* The message and set numbers in the catgets function must be > 0. */ - -static char *gettext(n) -int n; -{ - assert(n > 0 && n < SIZEOF(messages)); - assert(messages[n].text != 0); - return catgets(catd, TEXT_SET, n, messages[n].text); -} - -static char *getheader(n) -int n; -{ - assert(n >= 0 && n < SIZEOF(headers)); - return catgets(catd, HEADER_SET, n + 1, headers[n]); -} - -static char *getparm(n) -int n; -{ - assert(n >= 0 && n < SIZEOF(parms)); - return catgets(catd, PARM_SET, n + 1, parms[n]); -} - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/sgmls.c b/cde/programs/dtdocbook/sgmls/sgmls.c deleted file mode 100644 index fce49d12b..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmls.c +++ /dev/null @@ -1,1059 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmls.c /main/3 1996/06/19 17:18:02 drk $ */ -/* sgmls.c: - Library for reading output of sgmls. - - Written by James Clark (jjc@jclark.com). */ - -#include "config.h" -#include "std.h" -#include "sgmls.h" -#include "lineout.h" - -#ifdef __GNUC__ -#define NO_RETURN volatile -#else -#define NO_RETURN /* as nothing */ -#endif - -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif - -#ifndef __STDC__ -#define const /* as nothing */ -#endif - -typedef struct sgmls_data data_s; -typedef struct sgmls_notation notation_s; -typedef struct sgmls_internal_entity internal_entity_s; -typedef struct sgmls_external_entity external_entity_s; -typedef struct sgmls_entity entity_s; -typedef struct sgmls_attribute attribute_s; -typedef struct sgmls_event event_s; - -/* lists are sorted in reverse order of level */ -struct list { - int subdoc_level; /* -1 if associated with finished subdoc */ - struct list *next; - char *name; -}; - -struct entity_list { - int subdoc_level; - struct entity_list *next; - entity_s entity; -}; - -struct notation_list { - int subdoc_level; - struct notation_list *next; - notation_s notation; -}; - -struct sgmls { - FILE *fp; - char *buf; - unsigned buf_size; - struct entity_list *entities; - struct notation_list *notations; - attribute_s *attributes; - unsigned long lineno; - char *filename; - unsigned filename_size; - unsigned long input_lineno; - int subdoc_level; - char **files; /* from `f' commands */ - int nfiles; - char *sysid; /* from `s' command */ - char *pubid; /* from `p' command */ -}; - -enum error_code { - E_ZERO, /* Not an error */ - E_NOMEM, /* Out of memory */ - E_BADESCAPE, /* Bad escape */ - E_NULESCAPE, /* \000 other than in data */ - E_NUL, /* A null input character */ - E_BADENTITY, /* Reference to undefined entity */ - E_INTERNALENTITY, /* Internal entity when external was needed */ - E_SYSTEM, /* System input error */ - E_COMMAND, /* Bad command letter */ - E_MISSING, /* Missing arguments */ - E_NUMBER, /* Not a number */ - E_ATTR, /* Bad attribute type */ - E_BADNOTATION, /* Reference to undefined notation */ - E_BADINTERNAL, /* Bad internal entity type */ - E_BADEXTERNAL, /* Bad external entity type */ - E_EOF, /* EOF in middle of line */ - E_SDATA, /* \| other than in data */ - E_LINELENGTH /* line longer than UNSIGNED_MAX */ -}; - -static char *errlist[] = { - 0, - "Out of memory", - "Bad escape", - "\\0 escape not in data", - "Nul character in input", - "Reference to undefined entity", - "Internal entity when external was needed", - "System input error", - "Bad command letter", - "Missing arguments", - "Not a number", - "Bad attribute type", - "Reference to undefined notation", - "Bad internal entity type", - "Bad external entity type", - "EOF in middle of line", - "\\| other than in data", - "Too many V commands", - "Input line too long" -}; - -static void NO_RETURN error P((enum error_code)); -static int parse_data P((char *, unsigned long *)); -static void parse_location P((char *, struct sgmls *)); -static void parse_notation P((char *, notation_s *)); -static void parse_internal_entity P((char *, internal_entity_s *)); -static void parse_external_entity - P((char *, struct sgmls *, external_entity_s *)); -static void parse_subdoc_entity P((char *, external_entity_s *)); -static attribute_s *parse_attribute P((struct sgmls *, char *)); -static void grow_datav P((void)); -static char *unescape P((char *)); -static char *unescape_file P((char *)); -static int unescape1 P((char *)); -static char *scan_token P((char **)); -static int count_args P((char *)); -static struct list *list_find P((struct list *, char *, int)); -static UNIV xmalloc P((unsigned)); -static UNIV xrealloc P((UNIV , unsigned)); -static char *strsave P((char *)); -static int read_line P((struct sgmls *)); -static notation_s *lookup_notation P((struct sgmls *, char *)); -static entity_s *lookup_entity P((struct sgmls *, char *)); -static external_entity_s *lookup_external_entity P((struct sgmls *, char *)); -static void define_external_entity P((struct sgmls *, external_entity_s *)); -static void define_internal_entity P((struct sgmls *, internal_entity_s *)); -static void define_notation P((struct sgmls *, notation_s *)); -static data_s *copy_data P((data_s *, int)); -static void list_finish_level P((struct list **, int)); -static void add_attribute P((attribute_s **, attribute_s *)); -static void default_errhandler P((int, char *, unsigned long)); - -#define xfree(s) do { if (s) free(s); } while (0) - -static sgmls_errhandler *errhandler = default_errhandler; -static unsigned long input_lineno = 0; - -static data_s *datav = 0; -static int datav_size = 0; - -struct sgmls *sgmls_create(fp) - FILE *fp; -{ - struct sgmls *sp; - - sp = (struct sgmls *)malloc(sizeof(struct sgmls)); - if (!sp) - return 0; - sp->fp = fp; - sp->entities = 0; - sp->notations = 0; - sp->attributes = 0; - sp->lineno = 0; - sp->filename = 0; - sp->filename_size = 0; - sp->input_lineno = 0; - sp->buf_size = 0; - sp->buf = 0; - sp->subdoc_level = 0; - sp->files = 0; - sp->nfiles = 0; - sp->sysid = 0; - sp->pubid = 0; - return sp; -} - -void sgmls_free(sp) - struct sgmls *sp; -{ - struct entity_list *ep; - struct notation_list *np; - - if (!sp) - return; - xfree(sp->filename); - sgmls_free_attributes(sp->attributes); - - for (ep = sp->entities; ep;) { - struct entity_list *tem = ep->next; - if (ep->entity.is_internal) { - xfree(ep->entity.u.internal.data.s); - free(ep->entity.u.internal.name); - } - else { - int i; - for (i = 0; i < ep->entity.u.external.nfilenames; i++) - xfree(ep->entity.u.external.filenames[i]); - xfree(ep->entity.u.external.filenames); - xfree(ep->entity.u.external.sysid); - xfree(ep->entity.u.external.pubid); - sgmls_free_attributes(ep->entity.u.external.attributes); - free(ep->entity.u.internal.name); - } - free(ep); - ep = tem; - } - - for (np = sp->notations; np;) { - struct notation_list *tem = np->next; - xfree(np->notation.sysid); - xfree(np->notation.pubid); - free(np->notation.name); - free(np); - np = tem; - } - - xfree(sp->buf); - xfree(sp->pubid); - xfree(sp->sysid); - if (sp->files) { - int i; - for (i = 0; i < sp->nfiles; i++) - free(sp->files[i]); - free(sp->files); - } - free(sp); - - xfree(datav); - datav = 0; - datav_size = 0; -} - -sgmls_errhandler *sgmls_set_errhandler(handler) - sgmls_errhandler *handler; -{ - sgmls_errhandler *old = errhandler; - if (handler) - errhandler = handler; - return old; -} - -int sgmls_next(sp, e) - struct sgmls *sp; - event_s *e; -{ - while (read_line(sp)) { - char *buf = sp->buf; - - e->filename = sp->filename; - e->lineno = sp->lineno; - - switch (buf[0]) { - case DATA_CODE: - e->u.data.n = parse_data(buf + 1, &sp->lineno); - e->u.data.v = datav; - e->type = SGMLS_EVENT_DATA; - return 1; - case START_CODE: - { - char *p; - e->u.start.attributes = sp->attributes; - sp->attributes = 0; - e->type = SGMLS_EVENT_START; - p = buf + 1; - e->u.start.gi = scan_token(&p); - return 1; - } - case END_CODE: - { - char *p = buf + 1; - e->type = SGMLS_EVENT_END; - e->u.end.gi = scan_token(&p); - return 1; - } - case START_SUBDOC_CODE: - case END_SUBDOC_CODE: - { - char *p = buf + 1; - char *name = scan_token(&p); - if (buf[0] == START_SUBDOC_CODE) { - e->u.entity = lookup_external_entity(sp, name); - sp->subdoc_level++; - e->type = SGMLS_EVENT_SUBSTART; - } - else { - e->type = SGMLS_EVENT_SUBEND; - list_finish_level((struct list **)&sp->entities, sp->subdoc_level); - list_finish_level((struct list **)&sp->notations, sp->subdoc_level); - sp->subdoc_level--; - e->u.entity = lookup_external_entity(sp, name); - } - return 1; - } - case ATTRIBUTE_CODE: - add_attribute(&sp->attributes, parse_attribute(sp, buf + 1)); - break; - case DATA_ATTRIBUTE_CODE: - { - char *p = buf + 1; - char *name; - attribute_s *a; - external_entity_s *ext; - - name = scan_token(&p); - a = parse_attribute(sp, p); - ext = lookup_external_entity(sp, name); - add_attribute(&ext->attributes, a); - } - break; - case REFERENCE_ENTITY_CODE: - { - char *p = buf + 1; - char *name; - name = scan_token(&p); - e->u.entity = lookup_external_entity(sp, name); - e->type = SGMLS_EVENT_ENTITY; - return 1; - } - case DEFINE_NOTATION_CODE: - { - notation_s notation; - - parse_notation(buf + 1, ¬ation); - define_notation(sp, ¬ation); - } - break; - case DEFINE_EXTERNAL_ENTITY_CODE: - { - external_entity_s external; - - parse_external_entity(buf + 1, sp, &external); - define_external_entity(sp, &external); - } - break; - case DEFINE_SUBDOC_ENTITY_CODE: - { - external_entity_s external; - - parse_subdoc_entity(buf + 1, &external); - define_external_entity(sp, &external); - } - break; - case DEFINE_INTERNAL_ENTITY_CODE: - { - internal_entity_s internal; - - parse_internal_entity(buf + 1, &internal); - define_internal_entity(sp, &internal); - } - break; - case PI_CODE: - e->u.pi.len = unescape1(buf + 1); - e->u.pi.s = buf + 1; - e->type = SGMLS_EVENT_PI; - return 1; - case LOCATION_CODE: - parse_location(buf + 1, sp); - break; - case APPINFO_CODE: - e->u.appinfo = unescape(buf + 1); - e->type = SGMLS_EVENT_APPINFO; - return 1; - case SYSID_CODE: - sp->sysid = strsave(unescape(buf + 1)); - break; - case PUBID_CODE: - sp->pubid = strsave(unescape(buf + 1)); - break; - case FILE_CODE: - sp->files = xrealloc(sp->files, (sp->nfiles + 1)*sizeof(char *)); - sp->files[sp->nfiles] = strsave(unescape_file(buf + 1)); - sp->nfiles += 1; - break; - case CONFORMING_CODE: - e->type = SGMLS_EVENT_CONFORMING; - return 1; - default: - error(E_COMMAND); - } - } - - return 0; -} - -static -int parse_data(p, linenop) - char *p; - unsigned long *linenop; -{ - int n = 0; - char *start = p; - char *q; - int is_sdata = 0; - - /* No need to copy before first escape. */ - - for (; *p != '\\' && *p != '\0'; p++) - ; - q = p; - while (*p) { - if (*p == '\\') { - switch (*++p) { - case '\\': - *q++ = *p++; - break; - case 'n': - *q++ = RECHAR; - *linenop += 1; - p++; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int val = *p++ - '0'; - if (*p >= '0' && *p <= '7') { - val = val*8 + (*p++ - '0'); - if (*p >= '0' && *p <= '7') - val = val*8 + (*p++ - '0'); - } - *q++ = (char)val; - } - break; - case '|': - if (q > start || is_sdata) { - if (n >= datav_size) - grow_datav(); - datav[n].s = start; - datav[n].len = q - start; - datav[n].is_sdata = is_sdata; - n++; - } - is_sdata = !is_sdata; - start = q; - p++; - break; - default: - error(E_BADESCAPE); - } - } - else - *q++ = *p++; - } - - if (q > start || is_sdata) { - if (n >= datav_size) - grow_datav(); - datav[n].s = start; - datav[n].len = q - start; - datav[n].is_sdata = is_sdata; - n++; - } - return n; -} - -static -void grow_datav() -{ - unsigned size = datav_size ? 2*datav_size : 2; - datav = (data_s *)xrealloc((UNIV)datav, size*sizeof(data_s)); - datav_size = size; -} - -static -void parse_location(s, sp) - char *s; - struct sgmls *sp; -{ - unsigned size; - - if (*s < '0' || *s > '9' || sscanf(s, "%lu", &sp->lineno) != 1) - error(E_NUMBER); - do { - ++s; - } while (*s >= '0' && *s <= '9'); - - if (*s != ' ') - return; - s++; - s = unescape_file(s); - size = strlen(s) + 1; - if (size <= sp->filename_size) - strcpy(sp->filename, s); - else { - sp->filename = xrealloc(sp->filename, size); - strcpy(sp->filename, s); - sp->filename_size = size; - } -} - -static -void parse_notation(s, n) - char *s; - notation_s *n; -{ - n->name = strsave(scan_token(&s)); -} - -static -void parse_internal_entity(s, e) - char *s; - internal_entity_s *e; -{ - char *type; - - e->name = strsave(scan_token(&s)); - type = scan_token(&s); - if (strcmp(type, "CDATA") == 0) - e->data.is_sdata = 0; - else if (strcmp(type, "SDATA") == 0) - e->data.is_sdata = 1; - else - error(E_BADINTERNAL); - e->data.len = unescape1(s); - if (e->data.len == 0) - e->data.s = 0; - else { - e->data.s = xmalloc(e->data.len); - memcpy(e->data.s, s, e->data.len); - } -} - -static -void parse_external_entity(s, sp, e) - char *s; - struct sgmls *sp; - external_entity_s *e; -{ - char *type; - char *notation; - - e->name = strsave(scan_token(&s)); - type = scan_token(&s); - if (strcmp(type, "CDATA") == 0) - e->type = SGMLS_ENTITY_CDATA; - else if (strcmp(type, "SDATA") == 0) - e->type = SGMLS_ENTITY_SDATA; - else if (strcmp(type, "NDATA") == 0) - e->type = SGMLS_ENTITY_NDATA; - else - error(E_BADEXTERNAL); - notation = scan_token(&s); - e->notation = lookup_notation(sp, notation); -} - -static -void parse_subdoc_entity(s, e) - char *s; - external_entity_s *e; -{ - e->name = strsave(scan_token(&s)); - e->type = SGMLS_ENTITY_SUBDOC; -} - -static -attribute_s *parse_attribute(sp, s) - struct sgmls *sp; - char *s; -{ - attribute_s *a; - char *type; - - a = (attribute_s *)xmalloc(sizeof(*a)); - a->name = strsave(scan_token(&s)); - type = scan_token(&s); - if (strcmp(type, "CDATA") == 0) { - unsigned long lineno = 0; - a->type = SGMLS_ATTR_CDATA; - a->value.data.n = parse_data(s, &lineno); - a->value.data.v = copy_data(datav, a->value.data.n); - } - else if (strcmp(type, "IMPLIED") == 0) { - a->type = SGMLS_ATTR_IMPLIED; - } - else if (strcmp(type, "NOTATION") == 0) { - a->type = SGMLS_ATTR_NOTATION; - a->value.notation = lookup_notation(sp, scan_token(&s)); - } - else if (strcmp(type, "ENTITY") == 0) { - int n, i; - a->type = SGMLS_ATTR_ENTITY; - n = count_args(s); - if (n == 0) - error(E_MISSING); - a->value.entity.v = (entity_s **)xmalloc(n*sizeof(entity_s *)); - a->value.entity.n = n; - for (i = 0; i < n; i++) - a->value.entity.v[i] = lookup_entity(sp, scan_token(&s)); - } - else if (strcmp(type, "TOKEN") == 0) { - int n, i; - a->type = SGMLS_ATTR_TOKEN; - n = count_args(s); - if (n == 0) - error(E_MISSING); - a->value.token.v = (char **)xmalloc(n * sizeof(char *)); - for (i = 0; i < n; i++) - a->value.token.v[i] = strsave(scan_token(&s)); - a->value.token.n = n; - } - else - error(E_ATTR); - return a; -} - -void sgmls_free_attributes(p) - attribute_s *p; -{ - while (p) { - attribute_s *nextp = p->next; - switch (p->type) { - case SGMLS_ATTR_CDATA: - if (p->value.data.v) { - free(p->value.data.v[0].s); - free(p->value.data.v); - } - break; - case SGMLS_ATTR_TOKEN: - { - int i; - for (i = 0; i < p->value.token.n; i++) - free(p->value.token.v[i]); - xfree(p->value.token.v); - } - break; - case SGMLS_ATTR_ENTITY: - xfree(p->value.entity.v); - break; - case SGMLS_ATTR_IMPLIED: - case SGMLS_ATTR_NOTATION: - break; - } - free(p->name); - free(p); - p = nextp; - } -} - -static -data_s *copy_data(v, n) - data_s *v; - int n; -{ - if (n == 0) - return 0; - else { - int i; - unsigned total; - char *p; - data_s *result; - - result = (data_s *)xmalloc(n*sizeof(data_s)); - total = 0; - for (i = 0; i < n; i++) - total += v[i].len; - if (!total) - total++; - p = xmalloc(total); - for (i = 0; i < n; i++) { - result[i].s = p; - memcpy(result[i].s, v[i].s, v[i].len); - result[i].len = v[i].len; - p += v[i].len; - result[i].is_sdata = v[i].is_sdata; - } - return result; - } -} - -/* Unescape s, and return nul-terminated data. Give an error -if the data contains 0. */ - -static -char *unescape(s) - char *s; -{ - int len = unescape1(s); - if (memchr(s, '\0', len)) - error(E_NULESCAPE); - s[len] = '\0'; - return s; -} - -/* Like unescape(), but REs are represented by 012 not 015. */ - -static -char *unescape_file(s) - char *s; -{ - char *p; - p = s = unescape(s); - while ((p = strchr(p, RECHAR)) != 0) - *p++ = '\n'; - return s; - -} - -/* Unescape s, and return length of data. The data may contain 0. */ - -static -int unescape1(s) - char *s; -{ - const char *p; - char *q; - - q = strchr(s, '\\'); - if (!q) - return strlen(s); - p = q; - while (*p) { - if (*p == '\\') { - switch (*++p) { - case '\\': - *q++ = *p++; - break; - case 'n': - *q++ = RECHAR; - p++; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int val = *p++ - '0'; - if (*p >= '0' && *p <= '7') { - val = val*8 + (*p++ - '0'); - if (*p >= '0' && *p <= '7') - val = val*8 + (*p++ - '0'); - } - *q++ = (char)val; - } - break; - case '|': - error(E_SDATA); - default: - error(E_BADESCAPE); - } - } - else - *q++ = *p++; - } - return q - s; -} - -static -char *scan_token(pp) - char **pp; -{ - char *start = *pp; - while (**pp != '\0') { - if (**pp == ' ') { - **pp = '\0'; - *pp += 1; - break; - } - *pp += 1; - } - if (!*start) - error(E_MISSING); - return start; -} - -static -int count_args(p) - char *p; -{ - int n = 0; - - while (*p != '\0') { - n++; - do { - ++p; - if (*p == ' ') { - p++; - break; - } - } while (*p != '\0'); - } - return n; -} - -static -int read_line(sp) - struct sgmls *sp; -{ - unsigned i = 0; - FILE *fp = sp->fp; - int c; - char *buf = sp->buf; - unsigned buf_size = sp->buf_size; - - c = getc(fp); - if (c == EOF) { - input_lineno = sp->input_lineno; - if (ferror(fp)) - error(E_SYSTEM); - return 0; - } - - sp->input_lineno++; - input_lineno = sp->input_lineno; - for (;;) { - if (i >= buf_size) { - if (buf_size == 0) - buf_size = 24; - else if (buf_size > (unsigned)UINT_MAX/2) { - if (buf_size == (unsigned)UINT_MAX) - error(E_LINELENGTH); - buf_size = (unsigned)UINT_MAX; - } - else - buf_size *= 2; - buf = xrealloc(buf, buf_size); - sp->buf = buf; - sp->buf_size = buf_size; - } - if (c == '\0') - error(E_NUL); - if (c == '\n') { - buf[i] = '\0'; - break; - } - buf[i++] = c; - c = getc(fp); - if (c == EOF) { - if (ferror(fp)) - error(E_SYSTEM); - else - error(E_EOF); - } - } - return 1; -} - -static -notation_s *lookup_notation(sp, name) -struct sgmls *sp; -char *name; -{ - struct notation_list *p - = (struct notation_list *)list_find((struct list *)sp->notations, name, - sp->subdoc_level); - if (!p) - error(E_BADNOTATION); - return &p->notation; -} - -static -entity_s *lookup_entity(sp, name) -struct sgmls *sp; -char *name; -{ - struct entity_list *p - = (struct entity_list *)list_find((struct list *)sp->entities, name, - sp->subdoc_level); - if (!p) - error(E_BADENTITY); - return &p->entity; -} - -static -external_entity_s *lookup_external_entity(sp, name) -struct sgmls *sp; -char *name; -{ - entity_s *p = lookup_entity(sp, name); - if (p->is_internal) - error(E_INTERNALENTITY); - return &p->u.external; -} - -static -void define_external_entity(sp, e) -struct sgmls *sp; -external_entity_s *e; -{ - struct entity_list *p; - e->attributes = 0; - e->filenames = sp->files; - e->nfilenames = sp->nfiles; - sp->files = 0; - sp->nfiles = 0; - e->pubid = sp->pubid; - sp->pubid = 0; - e->sysid = sp->sysid; - sp->sysid = 0; - p = (struct entity_list *)xmalloc(sizeof(struct entity_list)); - memcpy((UNIV)&p->entity.u.external, (UNIV)e, sizeof(*e)); - p->entity.is_internal = 0; - p->subdoc_level = sp->subdoc_level; - p->next = sp->entities; - sp->entities = p; -} - -static -void define_internal_entity(sp, e) -struct sgmls *sp; -internal_entity_s *e; -{ - struct entity_list *p; - p = (struct entity_list *)xmalloc(sizeof(struct entity_list)); - memcpy((UNIV)&p->entity.u.internal, (UNIV)e, sizeof(*e)); - p->entity.is_internal = 1; - p->subdoc_level = sp->subdoc_level; - p->next = sp->entities; - sp->entities = p; -} - -static -void define_notation(sp, np) -struct sgmls *sp; -notation_s *np; -{ - struct notation_list *p; - np->sysid = sp->sysid; - sp->sysid = 0; - np->pubid = sp->pubid; - sp->pubid = 0; - p = (struct notation_list *)xmalloc(sizeof(struct notation_list)); - memcpy((UNIV)&p->notation, (UNIV)np, sizeof(*np)); - p->subdoc_level = sp->subdoc_level; - p->next = sp->notations; - sp->notations = p; -} - -static -struct list *list_find(p, name, level) - struct list *p; - char *name; - int level; -{ - for (; p && p->subdoc_level == level; p = p->next) - if (strcmp(p->name, name) == 0) - return p; - return 0; -} - -/* Move all the items in the list whose subdoc level is level to the -end of the list and make their subdoc_level -1. */ - -static -void list_finish_level(listp, level) - struct list **listp; - int level; -{ - struct list **pp, *next_level, *old_level; - for (pp = listp; *pp && (*pp)->subdoc_level == level; pp = &(*pp)->next) - (*pp)->subdoc_level = -1; - next_level = *pp; - *pp = 0; - old_level = *listp; - *listp = next_level; - for (pp = listp; *pp; pp = &(*pp)->next) - ; - *pp = old_level; -} - -static -void add_attribute(pp, a) - attribute_s **pp, *a; -{ - for (; *pp && strcmp((*pp)->name, a->name) < 0; pp = &(*pp)->next) - ; - a->next = *pp; - *pp = a; -} - - -static -char *strsave(s) -char *s; -{ - if (!s) - return s; - else { - char *p = xmalloc(strlen(s) + 1); - strcpy(p, s); - return p; - } -} - -static -UNIV xmalloc(n) - unsigned n; -{ - UNIV p = malloc(n); - if (!p) - error(E_NOMEM); - return p; -} - -/* ANSI C says first argument to realloc can be NULL, but not everybody - appears to support this. */ - -static -UNIV xrealloc(p, n) - UNIV p; - unsigned n; -{ - p = p ? realloc(p, n) : malloc(n); - if (!p) - error(E_NOMEM); - return p; -} - -static NO_RETURN -void error(num) - enum error_code num; -{ - (*errhandler)((int)num, errlist[num], input_lineno); - abort(); -} - -static -void default_errhandler(num, msg, lineno) - int num; - char *msg; - unsigned long lineno; -{ - fprintf(stderr, "Line %lu: %s\n", lineno, msg); - exit(1); -} diff --git a/cde/programs/dtdocbook/sgmls/sgmls.h b/cde/programs/dtdocbook/sgmls/sgmls.h deleted file mode 100644 index a37dcc0b8..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmls.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmls.h /main/3 1996/06/19 17:18:07 drk $ */ -/* sgmls.h - Interface to a library for reading output of sgmls. */ - -struct sgmls_data { - char *s; - unsigned len; - char is_sdata; -}; - -struct sgmls_notation { - char *name; - char *sysid; - char *pubid; -}; - -struct sgmls_internal_entity { - char *name; - struct sgmls_data data; -}; - -enum sgmls_external_entity_type { - SGMLS_ENTITY_CDATA, - SGMLS_ENTITY_SDATA, - SGMLS_ENTITY_NDATA, - SGMLS_ENTITY_SUBDOC - }; - -struct sgmls_external_entity { - char *name; - enum sgmls_external_entity_type type; - char **filenames; - int nfilenames; - char *pubid; - char *sysid; - struct sgmls_attribute *attributes; - struct sgmls_notation *notation; -}; - -struct sgmls_entity { - union { - struct sgmls_internal_entity internal; - struct sgmls_external_entity external; - } u; - char is_internal; -}; - -enum sgmls_attribute_type { - SGMLS_ATTR_IMPLIED, - SGMLS_ATTR_CDATA, - SGMLS_ATTR_TOKEN, - SGMLS_ATTR_ENTITY, - SGMLS_ATTR_NOTATION -}; - -struct sgmls_attribute { - struct sgmls_attribute *next; - char *name; - enum sgmls_attribute_type type; - union { - struct { - struct sgmls_data *v; - int n; - } data; - struct { - struct sgmls_entity **v; - int n; - } entity; - struct { - char **v; - int n; - } token; - struct sgmls_notation *notation; - } value; -}; - -enum sgmls_event_type { - SGMLS_EVENT_DATA, /* data */ - SGMLS_EVENT_ENTITY, /* external entity reference */ - SGMLS_EVENT_PI, /* processing instruction */ - SGMLS_EVENT_START, /* element start */ - SGMLS_EVENT_END, /* element end */ - SGMLS_EVENT_SUBSTART, /* subdocument start */ - SGMLS_EVENT_SUBEND, /* subdocument end */ - SGMLS_EVENT_APPINFO, /* appinfo */ - SGMLS_EVENT_CONFORMING /* the document was conforming */ - }; - -struct sgmls_event { - enum sgmls_event_type type; - union { - struct { - struct sgmls_data *v; - int n; - } data; - struct sgmls_external_entity *entity; - struct { - char *s; - unsigned len; - } pi; - struct { - char *gi; - struct sgmls_attribute *attributes; - } start; - struct { - char *gi; - } end; - char *appinfo; - } u; - char *filename; /* SGML filename */ - unsigned long lineno; /* SGML lineno */ -}; - -#ifdef __STDC__ -void sgmls_free_attributes(struct sgmls_attribute *); -struct sgmls *sgmls_create(FILE *); -int sgmls_next(struct sgmls *, struct sgmls_event *); -void sgmls_free(struct sgmls *); -typedef void sgmls_errhandler(int, char *, unsigned long); -sgmls_errhandler *sgmls_set_errhandler(sgmls_errhandler *); -#else /* not __STDC__ */ -void sgmls_free_attributes(); -struct sgmls *sgmls_create(); -int sgmls_next(); -void sgmls_free(); -typedef void sgmls_errhandler(); -sgmls_errhandler *sgmls_set_errhandler(); -#endif /* not __STDC__ */ diff --git a/cde/programs/dtdocbook/sgmls/sgmls.man b/cde/programs/dtdocbook/sgmls/sgmls.man deleted file mode 100644 index b9967a0a5..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmls.man +++ /dev/null @@ -1,871 +0,0 @@ -'\" t -.\" Uncomment the next line to get a man page accurate for MS-DOS -.\"nr Os 1 -.\" Uncomment the next line if tracing is enabled. -.\"nr Tr 1 -.if \n(.g .if !r Os .nr Os 0 -.tr \(ts" -.ds S \s-1SGML\s0 -.de TS -.br -.sp .5 -.. -.de TE -.br -.sp .5 -.. -.de TQ -.br -.ns -.TP \\$1 -.. -.TH SGMLS 1 -.SH NAME -sgmls \- a validating SGML parser -.sp -An \*S System Conforming to -.if n .br -International Standard ISO 8879 \(em -.br -Standard Generalized Markup Language -.SH SYNOPSIS -.B sgmls -[ -.B \-deglprsuv -] -[ -.BI \-c file -] -.if \n(Os=1 \{\ -[ -.BI \-f file -] -.\} -[ -.BI \-i name -] -.if \n(Tr \{\ -[ -.BI \-x flags -] -[ -.BI \-y flags -] -.\} -[ -.I filename\|.\|.\|. -] -.SH DESCRIPTION -.I Sgmls -parses and validates -the \*S document entity in -.I filename\|.\|.\|. -and prints on the standard output a simple \s-1ASCII\s0 representation of its -Element Structure Information Set. -(This is the information set which a structure-controlled -conforming \*S application should act upon.) -Note that the document entity may be spread amongst several files; -for example, the SGML declaration, document type declaration and document -instance set could each be in a separate file. -If no filenames are specified, then -.I sgmls -will read the document entity from the standard input. -A filename of -.B \- -can also be used to refer to the standard input. -.LP -The following options are available: -.TP -.BI \-c file -Write a report of capacity usage to -.IR file . -The report is in the format of a RACT result. -RACT is the Reference Application for Capacity Testing defined in the -Proposed American National Standard -.I -Conformance Testing for Standard Generalized Markup Language (SGL) Systems -(X3.190-199X), -Draft July 1991. -.TP -.B \-d -Warn about duplicate entity declarations. -.TP -.B \-e -Describe open entities in error messages. -Error messages always include the position of the most recently -opened external entity. -.if \n(Os=1 \{\ -.TP -.BI \-f file -Redirect errors to -.IR file . -.\} -.TP -.B \-g -Show the \s-1GI\s0s of open elements in error messages. -.TP -.BI \-i name -Pretend that -.RS -.IP -.BI -.LP -occurs at the start of the document type declaration subset -in the \*S document entity. -Since repeated definitions of an entity are ignored, -this definition will take precedence over any other definitions -of this entity in the document type declaration. -Multiple -.B \-i -options are allowed. -If the \*S declaration replaces the reserved name -.B INCLUDE -then the new reserved name will be the replacement text of the entity. -Typically the document type declaration will contain -.IP -.BI -.LP -and will use -.BI % name ; -in the status keyword specification of a marked section declaration. -In this case the effect of the option will be to cause the marked -section not to be ignored. -.RE -.TP -.B \-l -Output -.B L -commands giving the current line number and filename. -.TP -.B \-p -Parse only the prolog. -.I Sgmls -will exit after parsing the document type declaration. -Implies -.BR \-s . -.TP -.B \-r -Warn about defaulted references. -.TP -.B \-s -Suppress output. -Error messages will still be printed. -.TP -.B \-u -Warn about undefined elements: elements used in the DTD but not defined. -Also warn about undefined short reference maps. -.TP -.B \-v -Print the version number. -.if \n(Tr \{\ -.TP -.BI \-x flags -.br -.ns -.TP -.BI \-y flags -Enable debugging output; -.B \-x -applies to the document body, -.B \-y -to the prolog. -Each character in the -.I flags -argument enables tracing of a particular activity. -.RS -.TP -.B t -Trace state transitions. -.TP -.B a -Trace attribute activity. -.TP -.B c -Trace context checking. -.TP -.B d -Trace declaration parsing. -.TP -.B e -Trace entities. -.TP -.B g -Trace groups. -.TP -.B i -Trace \s-1ID\s0s. -.TP -.B m -Trace marked sections. -.TP -.B n -Trace notations. -.RE -.\} -.SS "Entity Manager" -An external entity resides in one or more files. -The entity manager component of -.I sgmls -maps a sequence of files into an entity in three sequential stages: -.IP 1. -each carriage return character is turned into a non-SGML character; -.IP 2. -each newline character is turned into a record end character, -and at the same time -a record start character is inserted at the beginning of each line; -.IP 3. -the files are concatenated. -.LP -A system identifier is -interpreted as a list of filenames separated by -.if \n(Os=0 colons. -.if \n(Os=1 semi-colons. -A filename of -.B \- -can be used to refer to the standard input. -If no system identifier is supplied, then the entity manager will -attempt to generate a filename using the public identifier -(if there is one) and other information available to it. -Notation identifiers are not subject to this treatment. -This process is controlled by the environment variable -.BR \s-1SGML_PATH\s0 ; -this contains a -.if \n(Os=0 colon-separated -.if \n(Os=1 semicolon-separated -list of filename templates. -A filename template is a filename that may contain -substitution fields; a substitution field is a -.B % -character followed by a single letter that indicates the value -of the substitution. -If -.B \s-1SGML_PATH\s0 -uses the -.B %S -field (the value of which is the system identifier), -then the entity manager will also use -.B \s-1SGML_PATH\s0 -to generate a filename -when a system identifier that does not contain any -.if \n(Os=0 colons -.if \n(Os=1 semi-colons -is supplied. -The value of a substitution can either be a string -or it can be -.IR null . -The entity manager transforms the list of -filename templates into a list of filenames by substituting for each -substitution field and discarding any template -that contained a substitution field whose value was null. -It then uses the first resulting filename that exists and is readable. -Substitution values are transformed before being used for substitution: -firstly, any names that were subject to upper case substitution -are folded to lower case; -secondly, -.if \n(Os=0 \{\ -.\" Unix -space characters are mapped to underscores -and slashes are mapped to percents. -.\} -.if \n(Os=1 \{\ -.\" MS-DOS -the characters -.B +,./:=? -and space characters are deleted. -.\} -The value of the -.B %S -field is not transformed. -The values of substitution fields are as follows: -.TP -.B %% -A single -.BR % . -.TP -.B %D -The entity's data content notation. -This substitution will succeed only for external data entities. -.TP -.B %N -The entity, notation or document type name. -.TP -.B %P -The public identifier if there was a public identifier, -otherwise null. -.TP -.B %S -The system identifier if there was a system identifier -otherwise null. -.TP -.B %X -(This is provided mainly for compatibility with \s-1ARCSGML\s0.) -A three-letter string chosen as follows: -.LP -.RS -.ne 11 -.TS -tab(&); -c|c|c s -c|c|c s -c|c|c|c -c|c|c|c -l|lB|lB|lB. -&&With public identifier -&&_ -&No public&Device&Device -&identifier&independent&dependent -_ -Data or subdocument entity&nsd&pns&vns -General SGML text entity&gml&pge&vge -Parameter entity&spe&ppe&vpe -Document type definition&dtd&pdt&vdt -Link process definition&lpd&plp&vlp -.TE -.LP -The device dependent version is selected if the public text class -allows a public text display version but no public text display -version was specified. -.RE -.TP -.B %Y -The type of thing for which the filename is being generated: -.TS -tab(&); -l lB. -SGML subdocument entity&sgml -Data entity&data -General text entity&text -Parameter entity&parm -Document type definition&dtd -Link process definition&lpd -.TE -.LP -The value of the following substitution fields will be null -unless a valid formal public identifier was supplied. -.TP -.B %A -Null if the text identifier in the -formal public identifier contains an unavailable text indicator, -otherwise the empty string. -.TP -.B %C -The public text class, mapped to lower case. -.TP -.B %E -The public text designating sequence (escape sequence) -if the public text class is -.BR \s-1CHARSET\s0 , -otherwise null. -.TP -.B %I -The empty string if the owner identifier in the formal public identifier -is an \s-1ISO\s0 owner identifier, -otherwise null. -.TP -.B %L -The public text language, mapped to lower case, -unless the public text class is -.BR \s-1CHARSET\s0 , -in which case null. -.TP -.B %O -The owner identifier (with the -.B +// -or -.B \-// -prefix stripped.) -.TP -.B %R -The empty string if the owner identifier in the formal public identifier -is a registered owner identifier, -otherwise null. -.TP -.B %T -The public text description. -.TP -.B %U -The empty string if the owner identifier in the formal public identifier -is an unregistered owner identifier, -otherwise null. -.TP -.B %V -The public text display version. -This substitution will be null if the public text class -does not allow a display version or if no version was specified. -If an empty version was specified, a value of -.B default -will be used. -.br -.ne 18 -.SS "System declaration" -The system declaration for -.I sgmls -is as follows: -.LP -.TS -tab(&); -c1 s1 s1 s1 s1 s1 s1 s1 s -c s s s s s s s s -l l s s s s s s s -l l s s s s s s s -l l s s s s s s s -l l l s s s s s s -c s s s s s s s s -l l l l l l l l l -l l l l l l l l l -l l l l l l l l l -l l s s s s s s s -l l l s s s s s s -l l l s s s s s s -c s s s s s s s s -l l l l l l l l l. -SYSTEM "ISO 8879:1986" -CHARSET -BASESET&"ISO 646-1983//CHARSET -&\h'\w'"'u'International Reference Version (IRV)//ESC 2/5 4/0" -DESCSET&0\0128\00 -CAPACITY&PUBLIC&"ISO 8879:1986//CAPACITY Reference//EN" -FEATURES -MINIMIZE&DATATAG&NO&OMITTAG&YES&RANK&NO&SHORTTAG&YES -LINK&SIMPLE&NO&IMPLICIT&NO&EXPLICIT&NO -OTHER&CONCUR&NO&SUBDOC&YES 1&FORMAL&YES -SCOPE&DOCUMENT -SYNTAX&PUBLIC&"ISO 8879:1986//SYNTAX Reference//EN" -SYNTAX&PUBLIC&"ISO 8879:1986//SYNTAX Core//EN" -VALIDATE -&GENERAL&YES&MODEL&YES&EXCLUDE&YES&CAPACITY&YES -&NONSGML&YES&SGML&YES&FORMAL&YES -.T& -c s s s s s s s s -l l l l l l l l l. -SDIF -&PACK&NO&UNPACK&NO -.TE -.LP -The memory usage of -.I sgmls -is not a function of the capacity points used by a document; -however, -.I sgmls -can handle capacities significantly greater than the reference capacity set. -.LP -In some environments, -higher values may be supported for the \s-1SUBDOC\s0 parameter. -.LP -Documents that do not use optional features are also supported. -For example, if -.B FORMAL\ NO -is specified in the \*S declaration, -public identifiers will not be required to be valid formal public identifiers. -.LP -Certain parts of the concrete syntax may be changed: -.RS -.LP -The shunned character numbers can be changed. -.LP -Eight bit characters can be assigned to -\s-1LCNMSTRT\s0, \s-1UCNMSTRT\s0, \s-1LCNMCHAR\s0 and \s-1UCNMCHAR\s0. -Declaring this requires that the syntax reference character set be declared -like this: -.RS -.ne 3 -.TS -tab(&); -l l. -BASESET&"ISO Registration Number 100//CHARSET -&\h'\w'"'u'ECMA-94 Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET&0\0256\00 -.TE -.RE -.LP -Uppercase substitution can be performed or not performed -both for entity names and for other names. -.LP -Either short reference delimiters assigned by the reference delimiter set -or no short reference delimiters are supported. -.LP -The reserved names can be changed. -.LP -The quantity set can be increased within certain limits -subject to there being sufficient memory available. -The upper limit on \s-1\%NAMELEN\s0 is 239. -The upper limits on -\s-1\%ATTCNT\s0, \s-1\%ATTSPLEN\s0, \s-1\%BSEQLEN\s0, \s-1\%ENTLVL\s0, -\s-1\%LITLEN\s0, \s-1\%PILEN\s0, \s-1\%TAGLEN\s0, and \s-1\%TAGLVL\s0 -are more than thirty times greater than the reference limits. -The upper limit on -\s-1\%GRPCNT\s0, \s-1\%GRPGTCNT\s0, and \s-1\%GRPLVL\s0 is 253. -\s-1\%NORMSEP\s0 -cannot be changed. -\s-1\%DTAGLEN\s0 -are -\s-1\%DTEMPLEN\s0 -irrelevant since -.I sgmls -does not support the -\s-1\%DATATAG\s0 -feature. -.RE -.SS "\*S declaration" -The \*S declaration may be omitted, -the following declaration will be implied: -.TS -tab(&); -c1 s1 s1 s1 s1 s1 s1 s1 s -c s s s s s s s s -l l s s s s s s s. - -.TE -with the exception that characters 128 through 254 will be assigned to -\s-1DATACHAR\s0. -When exporting documents that use characters in this range, -an accurate description of the upper half of the document character set -should be added to this declaration. -For ISO Latin-1, an appropriate description would be: -.br -.ne 5 -.TS -tab(&); -l l. -BASESET&"ISO Registration Number 100//CHARSET -&\h'\w'"'u'ECMA-94 Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET&128\032\0UNUSED -&160\095\032 -&255\0\01\0UNUSED -.TE -.SS "Output format" -The output is a series of lines. -Lines can be arbitrarily long. -Each line consists of an initial command character -and one or more arguments. -Arguments are separated by a single space, -but when a command takes a fixed number of arguments -the last argument can contain spaces. -There is no space between the command character and the first argument. -Arguments can contain the following escape sequences. -.TP -.B \e\e -A -.BR \e. -.TP -.B \en -A record end character. -.TP -.B \e| -Internal \s-1SDATA\s0 entities are bracketed by these. -.TP -.BI \e nnn -The character whose code is -.I nnn -octal. -.LP -A record start character will be represented by -.BR \e012 . -Most applications will need to ignore -.B \e012 -and translate -.B \en -into newline. -.LP -The possible command characters and arguments are as follows: -.TP -.BI ( gi -The start of an element whose generic identifier is -.IR gi . -Any attributes for this element -will have been specified with -.B A -commands. -.TP -.BI ) gi -The end an element whose generic identifier is -.IR gi . -.TP -.BI \- data -Data. -.TP -.BI & name -A reference to an external data entity -.IR name ; -.I name -will have been defined using an -.B E -command. -.TP -.BI ? pi -A processing instruction with data -.IR pi . -.TP -.BI A name\ val -The next element to start has an attribute -.I name -with value -.I val -which takes one of the following forms: -.RS -.TP -.B IMPLIED -The value of the attribute is implied. -.TP -.BI CDATA\ data -The attribute is character data. -This is used for attributes whose declared value is -.BR \s-1CDATA\s0 . -.TP -.BI NOTATION\ nname -The attribute is a notation name; -.I nname -will have been defined using a -.B N -command. -This is used for attributes whose declared value is -.BR \s-1NOTATION\s0 . -.TP -.BI ENTITY\ name\|.\|.\|. -The attribute is a list of general entity names. -Each entity name will have been defined using an -.BR I , -.B E -or -.B S -command. -This is used for attributes whose declared value is -.B \s-1ENTITY\s0 -or -.BR \s-1ENTITIES\s0 . -.TP -.BI TOKEN\ token\|.\|.\|. -The attribute is a list of tokens. -This is used for attributes whose declared value is anything else. -.RE -.TP -.BI D ename\ name\ val -This is the same as the -.B A -command, except that it specifies a data attribute for an -external entity named -.IR ename . -Any -.B D -commands will come after the -.B E -command that defines the entity to which they apply, but -before any -.B & -or -.B A -commands that reference the entity. -.TP -.BI N nname -.IR nname. -Define a notation -This command will be preceded by a -.B p -command if the notation was declared with a public identifier, -and by a -.B s -command if the notation was declared with a system identifier. -A notation will only be defined if it is to be referenced -in an -.B E -command or in an -.B A -command for an attribute with a declared value of -.BR \s-1NOTATION\s0 . -.TP -.BI E ename\ typ\ nname -Define an external data entity named -.I ename -with type -.I typ -.RB ( \s-1CDATA\s0 , -.B \s-1NDATA\s0 -or -.BR \s-1SDATA\s0 ) -and notation -.IR not. -This command will be preceded by one or more -.B f -commands giving the filenames generated by the entity manager from the system -and public identifiers, -by a -.B p -command if a public identifier was declared for the entity, -and by a -.B s -command if a system identifier was declared for the entity. -.I not -will have been defined using a -.B N -command. -Data attributes may be specified for the entity using -.B D -commands. -An external data entity will only be defined if it is to be referenced in a -.B & -command or in an -.B A -command for an attribute whose declared value is -.B \s-1ENTITY\s0 -or -.BR \s-1ENTITIES\s0 . -.TP -.BI I ename\ typ\ text -Define an internal data entity named -.I ename -with type -.I typ -.RB ( \s-1CDATA\s0 -or -.BR \s-1SDATA\s0 ) -and entity text -.IR text . -An internal data entity will only be defined if it is referenced in an -.B A -command for an attribute whose declared value is -.B \s-1ENTITY\s0 -or -.BR \s-1ENTITIES\s0 . -.TP -.BI S ename -Define a subdocument entity named -.IR ename . -This command will be preceded by one or more -.B f -commands giving the filenames generated by the entity manager from the system -and public identifiers, -by a -.B p -command if a public identifier was declared for the entity, -and by a -.B s -command if a system identifier was declared for the entity. -A subdocument entity will only be defined if it is referenced -in a -.B { -command -or in an -.B A -command for an attribute whose declared value is -.B \s-1ENTITY\s0 -or -.BR \s-1ENTITIES\s0 . -.TP -.BI s sysid -This command applies to the next -.BR E , -.B S -or -.B N -command and specifies the associated system identifier. -.TP -.BI p pubid -This command applies to the next -.BR E , -.B S -or -.B N -command and specifies the associated public identifier. -.TP -.BI f filename -This command applies to the next -.B E -or -.B S -command and specifies an associated filename. -There will be more than one -.B f -command for a single -.B E -or -.B S -command if the system identifier used a -.if \n(Os=0 colon. -.if \n(Os=1 semi-colon. -.TP -.BI { ename -The start of the \*S subdocument entity -.IR ename ; -.I ename -will have been defined using a -.B S -command. -.TP -.BI } ename -The end of the \*S subdocument entity -.IR ename . -.TP -.BI L lineno\ file -.TQ -.BI L lineno -Set the current line number and filename. -The -.I filename -argument will be omitted if only the line number has changed. -This will be output only if the -.B \-l -option has been given. -.TP -.BI # text -An \s-1APPINFO\s0 parameter of -.I text -was specified in the \*S declaration. -This is not strictly part of the ESIS, but a structure-controlled -application is permitted to act on it. -No -.B # -command will be output if -.B \s-1APPINFO\s0\ \s-1NONE\s0 -was specified. -A -.B # -command will occur at most once, -and may be preceded only by a single -.B L -command. -.TP -.B C -This command indicates that the document was a conforming \*S document. -If this command is output, it will be the last command. -An \*S document is not conforming if it references a subdocument entity -that is not conforming. -.SH BUGS -Some non-SGML characters in literals are counted as two characters for the -purposes of quantity and capacity calculations. -.SH "SEE ALSO" -The \*S Handbook, Charles F. Goldfarb -.br -\s-1ISO\s0 8879 (Standard Generalized Markup Language), -International Organization for Standardization -.SH ORIGIN -\s-1ARCSGML\s0 was written by Charles F. Goldfarb. -.LP -.I Sgmls -was derived from \s-1ARCSGML\s0 by James Clark (jjc@jclark.com), -to whom bugs should be reported. diff --git a/cde/programs/dtdocbook/sgmls/sgmls.pl b/cde/programs/dtdocbook/sgmls/sgmls.pl deleted file mode 100755 index edb9eb60f..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmls.pl +++ /dev/null @@ -1,247 +0,0 @@ -#! /usr/bin/perl - -# This is a skeleton of a perl script for processing the output of -# sgmls. You must change the parts marked with "XXX". - -# XXX This is for troff: in data, turn \ into \e (which prints as \). -# Backslashes in SDATA entities are left as backslashes. - -$backslash_in_data = "\\e"; - -$prog = $0; - -$prog =~ s|.*/||; - -$level = 0; - -while () { - chop; - $command = substr($_, 0, 1); - substr($_, 0, 1) = ""; - if ($command eq '(') { - &start_element($_); - $level++; - } - elsif ($command eq ')') { - $level--; - &end_element($_); - foreach $key (keys %attribute_value) { - @splitkey = split($;, $key); - if ($splitkey[0] == $level) { - delete $attribute_value{$key}; - delete $attribute_type{$key}; - } - } - } - elsif ($command eq '-') { - &unescape_data($_); - &data($_); - } - elsif ($command eq 'A') { - @field = split(/ /, $_, 3); - $attribute_type{$level,$field[0]} = $field[1]; - &unescape_data($field[2]); - $attribute_value{$level,$field[0]} = $field[2]; - } - elsif ($command eq '&') { - &entity($_); - } - elsif ($command eq 'D') { - @field = split(/ /, $_, 4); - $data_attribute_type{$field[0], $field[1]} = $field[2]; - &unescape_data($field[3]); - $data_attribute_value{$field[0], $field[1]} = $field[3]; - } - elsif ($command eq 'N') { - $notation{$_} = 1; - if (defined($sysid)) { - $notation_sysid{$_} = $sysid; - undef($sysid); - } - if (defined($pubid)) { - $notation_pubid{$_} = $pubid; - undef($pubid); - } - } - elsif ($command eq 'I') { - @field = split(/ /, $_, 3); - $entity_type{$field[0]} = $field[1]; - &unescape($field[2]); - # You may want to substitute \e for \ if the type is CDATA. - $entity_text{$field[0]} = $field[2]; - $entity_code{$field[0]} = 'I'; - } - elsif ($command eq 'E') { - @field = split(/ /, $_); - $entity_code{$field[0]} = 'E'; - $entity_type{$field[0]} = $field[1]; - $entity_notation{$field[0]} = $field[2]; - if (defined(@files)) { - foreach $i (0..$#files) { - $entity_filename{$field[0], $i} = $files[i]; - } - undef(@files); - } - if (defined($sysid)) { - $entity_sysid{$field[0]} = $sysid; - undef($sysid); - } - if (defined($pubid)) { - $entity_pubid{$field[0]} = $pubid; - undef($pubid); - } - } - elsif ($command eq 'S') { - $entity_code{$_} = 'S'; - if (defined(@files)) { - foreach $i (0..$#files) { - $entity_filename{$_, $i} = $files[i]; - } - undef(@files); - } - if (defined($sysid)) { - $entity_sysid{$_} = $sysid; - undef($sysid); - } - if (defined($pubid)) { - $entity_pubid{$_} = $pubid; - undef($pubid); - } - } - elsif ($command eq '?') { - &unescape($_); - &pi($_); - } - elsif ($command eq 'L') { - @field = split(/ /, $_); - $lineno = $field[0]; - if ($#field >= 1) { - &unescape($field[1]); - $filename = $field[1]; - } - } - elsif ($command eq 'V') { - @field = split(/ /, $_, 2); - &unescape($field[1]); - $environment{$field[0]} = $field[1]; - } - elsif ($command eq '{') { - &start_subdoc($_); - } - elsif ($command eq '}') { - &end_subdoc($_); - } - elsif ($command eq 'f') { - &unescape($_); - push(@files, $_); - } - elsif ($command eq 'p') { - &unescape($_); - $pubid = $_; - } - elsif ($command eq 's') { - &unescape($_); - $sysid = $_; - } - elsif ($command eq 'C') { - $conforming = 1; - } - else { - warn "$prog:$ARGV:$.: unrecognized command \`$command'\n"; - } -} - -sub unescape { - $_[0] =~ s/\\([0-7][0-7]?[0-7]?|.)/&esc($1)/eg; -} - -sub esc { - local($_) = $_[0]; - if ($_ eq '012' || $_ eq '12') { - ""; # ignore RS - } - elsif (/^[0-7]/) { - sprintf("%c", oct); - } - elsif ($_ eq 'n') { - "\n"; - } - elsif ($_ eq '|') { - ""; - } - elsif ($_ eq "\\") { - "\\"; - } - else { - $_; - } -} - -sub unescape_data { - local($sdata) = 0; - $_[0] =~ s/\\([0-7][0-7]?[0-7]?|.)/&esc_data($1)/eg; -} - -sub esc_data { - local($_) = $_[0]; - if ($_ eq '012' || $_ eq '12') { - ""; # ignore RS - } - elsif (/^[0-7]/) { - sprintf("%c", oct); - } - elsif ($_ eq 'n') { - "\n"; - } - elsif ($_ eq '|') { - $sdata = !$sdata; - ""; - } - elsif ($_ eq "\\") { - $sdata ? "\\" : $backslash_in_data; - } - else { - $_; - } -} - - -sub start_element { - local($gi) = $_[0]; - # XXX -} - -sub end_element { - local($gi) = $_[0]; - # XXX -} - -sub data { - local($data) = $_[0]; - # XXX -} - -# A processing instruction. - -sub pi { - local($data) = $_[0]; - # XXX -} - -# A reference to an external entity. - -sub entity { - local($name) = $_[0]; - # XXX -} - -sub start_subdoc { - local($name) = $_[0]; - # XXX -} - -sub end_subdoc { - local($name) = $_[0]; - # XXX -} - diff --git a/cde/programs/dtdocbook/sgmls/sgmls.txt b/cde/programs/dtdocbook/sgmls/sgmls.txt deleted file mode 100644 index 9b50e21c7..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmls.txt +++ /dev/null @@ -1,661 +0,0 @@ -# $XConsortium: sgmls.txt /main/2 1996/11/11 11:24:56 drk $ - - - -SGMLS(1) SGMLS(1) - - -NAME - sgmls - a validating SGML parser - - An SGML System Conforming to - International Standard ISO 8879 -- - Standard Generalized Markup Language - -SYNOPSIS - sgmls [ -deglprsuv ] [ -cfile ] [ -iname ] [ filename... - ] - -DESCRIPTION - Sgmls parses and validates the SGML document entity in - filename... and prints on the standard output a simple - ASCII representation of its Element Structure Information - Set. (This is the information set which a structure- - controlled conforming SGML application should act upon.) - Note that the document entity may be spread amongst sev- - eral files; for example, the SGML declaration, document - type declaration and document instance set could each be - in a separate file. If no filenames are specified, then - sgmls will read the document entity from the standard - input. A filename of - can also be used to refer to the - standard input. - - The following options are available: - - -cfile Write a report of capacity usage to file. The - report is in the format of a RACT result. RACT is - the Reference Application for Capacity Testing - defined in the Proposed American National Standard - Conformance Testing for Standard Generalized Markup - Language (SGL) Systems (X3.190-199X), Draft July - 1991. - - -d Warn about duplicate entity declarations. - - -e Describe open entities in error messages. Error - messages always include the position of the most - recently opened external entity. - - -g Show the GIs of open elements in error messages. - - -iname Pretend that - - - - occurs at the start of the document type declara- - tion subset in the SGML document entity. Since - repeated definitions of an entity are ignored, this - definition will take precedence over any other def- - initions of this entity in the document type decla- - ration. Multiple -i options are allowed. If the - SGML declaration replaces the reserved name INCLUDE - - - - 1 - - - - - -SGMLS(1) SGMLS(1) - - - then the new reserved name will be the replacement - text of the entity. Typically the document type - declaration will contain - - - - and will use %name; in the status keyword specifi- - cation of a marked section declaration. In this - case the effect of the option will be to cause the - marked section not to be ignored. - - -l Output L commands giving the current line number - and filename. - - -p Parse only the prolog. Sgmls will exit after pars- - ing the document type declaration. Implies -s. - - -r Warn about defaulted references. - - -s Suppress output. Error messages will still be - printed. - - -u Warn about undefined elements: elements used in the - DTD but not defined. Also warn about undefined - short reference maps. - - -v Print the version number. - - Entity Manager - An external entity resides in one or more files. The - entity manager component of sgmls maps a sequence of files - into an entity in three sequential stages: - - 1. each carriage return character is turned into a - non-SGML character; - - 2. each newline character is turned into a record end - character, and at the same time a record start - character is inserted at the beginning of each - line; - - 3. the files are concatenated. - - A system identifier is interpreted as a list of filenames - separated by colons. A filename of - can be used to refer - to the standard input. If no system identifier is sup- - plied, then the entity manager will attempt to generate a - filename using the public identifier (if there is one) and - other information available to it. Notation identifiers - are not subject to this treatment. This process is con- - trolled by the environment variable SGML_PATH; this con- - tains a colon-separated list of filename templates. A - filename template is a filename that may contain substitu- - tion fields; a substitution field is a % character - - - - 2 - - - - - -SGMLS(1) SGMLS(1) - - - followed by a single letter that indicates the value of - the substitution. If SGML_PATH uses the %S field (the - value of which is the system identifier), then the entity - manager will also use SGML_PATH to generate a filename - when a system identifier that does not contain any colons - is supplied. The value of a substitution can either be a - string or it can be null. The entity manager transforms - the list of filename templates into a list of filenames by - substituting for each substitution field and discarding - any template that contained a substitution field whose - value was null. It then uses the first resulting filename - that exists and is readable. Substitution values are - transformed before being used for substitution: firstly, - any names that were subject to upper case substitution are - folded to lower case; secondly, space characters are - mapped to underscores and slashes are mapped to percents. - The value of the %S field is not transformed. The values - of substitution fields are as follows: - - %% A single %. - - %D The entity's data content notation. This substitu- - tion will succeed only for external data entities. - - %N The entity, notation or document type name. - - %P The public identifier if there was a public identi- - fier, otherwise null. - - %S The system identifier if there was a system identi- - fier otherwise null. - - %X (This is provided mainly for compatibility with - ARCSGML.) A three-letter string chosen as follows: - | | - | | With public identifier - | +-------------+----------- - | No public | Device | Device - | identifier | independent | dependent - ---------------------------+------------+-------------+----------- - Data or subdocument entity | nsd | pns | vns - General SGML text entity | gml | pge | vge - Parameter entity | spe | ppe | vpe - Document type definition | dtd | pdt | vdt - Link process definition | lpd | plp | vlp - - The device dependent version is selected if the - public text class allows a public text display ver- - sion but no public text display version was speci- - fied. - - %Y The type of thing for which the filename is being - generated: - - - - - 3 - - - - - -SGMLS(1) SGMLS(1) - - - SGML subdocument entity sgml - Data entity data - General text entity text - Parameter entity parm - Document type definition dtd - Link process definition lpd - - The value of the following substitution fields will be - null unless a valid formal public identifier was supplied. - - %A Null if the text identifier in the formal public - identifier contains an unavailable text indicator, - otherwise the empty string. - - %C The public text class, mapped to lower case. - - %E The public text designating sequence (escape - sequence) if the public text class is CHARSET, oth- - erwise null. - - %I The empty string if the owner identifier in the - formal public identifier is an ISO owner identi- - fier, otherwise null. - - %L The public text language, mapped to lower case, - unless the public text class is CHARSET, in which - case null. - - %O The owner identifier (with the +// or -// prefix - stripped.) - - %R The empty string if the owner identifier in the - formal public identifier is a registered owner - identifier, otherwise null. - - %T The public text description. - - %U The empty string if the owner identifier in the - formal public identifier is an unregistered owner - identifier, otherwise null. - - %V The public text display version. This substitution - will be null if the public text class does not - allow a display version or if no version was speci- - fied. If an empty version was specified, a value - of default will be used. - - - - - - - - - - - - 4 - - - - - -SGMLS(1) SGMLS(1) - - - System declaration - The system declaration for sgmls is as follows: - - SYSTEM "ISO 8879:1986" - CHARSET - BASESET "ISO 646-1983//CHARSET - International Reference Version (IRV)//ESC 2/5 4/0" - DESCSET 0 128 0 - CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" - FEATURES - MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES - LINK SIMPLE NO IMPLICIT NO EXPLICIT NO - OTHER CONCUR NO SUBDOC YES 1 FORMAL YES - SCOPE DOCUMENT - SYNTAX PUBLIC "ISO 8879:1986//SYNTAX Reference//EN" - SYNTAX PUBLIC "ISO 8879:1986//SYNTAX Core//EN" - VALIDATE - GENERAL YES MODEL YES EXCLUDE YES CAPACITY YES - NONSGML YES SGML YES FORMAL YES - SDIF - PACK NO UNPACK NO - - The memory usage of sgmls is not a function of the capac- - ity points used by a document; however, sgmls can handle - capacities significantly greater than the reference capac- - ity set. - - In some environments, higher values may be supported for - the SUBDOC parameter. - - Documents that do not use optional features are also sup- - ported. For example, if FORMAL NO is specified in the - SGML declaration, public identifiers will not be required - to be valid formal public identifiers. - - Certain parts of the concrete syntax may be changed: - - The shunned character numbers can be changed. - - Eight bit characters can be assigned to LCNMSTRT, - UCNMSTRT, LCNMCHAR and UCNMCHAR. Declaring this - requires that the syntax reference character set be - declared like this: - BASESET "ISO Registration Number 100//CHARSET - ECMA-94 Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" - DESCSET 0 256 0 - - Uppercase substitution can be performed or not per- - formed both for entity names and for other names. - - Either short reference delimiters assigned by the - reference delimiter set or no short reference - delimiters are supported. - - - - - 5 - - - - - -SGMLS(1) SGMLS(1) - - - The reserved names can be changed. - - The quantity set can be increased within certain - limits subject to there being sufficient memory - available. The upper limit on NAMELEN is 239. The - upper limits on ATTCNT, ATTSPLEN, BSEQLEN, ENTLVL, - LITLEN, PILEN, TAGLEN, and TAGLVL are more than - thirty times greater than the reference limits. - The upper limit on GRPCNT, GRPGTCNT, and GRPLVL is - 253. NORMSEP cannot be changed. DTAGLEN are - DTEMPLEN irrelevant since sgmls does not support - the DATATAG feature. - - SGML declaration - The SGML declaration may be omitted, the following decla- - ration will be implied: - - with the exception that characters 128 through 254 will be - assigned to DATACHAR. When exporting documents that use - characters in this range, an accurate description of the - upper half of the document character set should be added - to this declaration. For ISO Latin-1, an appropriate - description would be: - BASESET "ISO Registration Number 100//CHARSET - ECMA-94 Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" - DESCSET 128 32 UNUSED - 160 95 32 - 255 1 UNUSED - - Output format - The output is a series of lines. Lines can be arbitrarily - long. Each line consists of an initial command character - and one or more arguments. Arguments are separated by a - single space, but when a command takes a fixed number of - arguments the last argument can contain spaces. There is - no space between the command character and the first - - - - 6 - - - - - -SGMLS(1) SGMLS(1) - - - argument. Arguments can contain the following escape - sequences. - - \\ A \. - - \n A record end character. - - \| Internal SDATA entities are bracketed by these. - - \nnn The character whose code is nnn octal. - - A record start character will be represented by \012. - Most applications will need to ignore \012 and translate - \n into newline. - - The possible command characters and arguments are as fol- - lows: - - (gi The start of an element whose generic identifier is - gi. Any attributes for this element will have been - specified with A commands. - - )gi The end an element whose generic identifier is gi. - - -data Data. - - &name A reference to an external data entity name; name - will have been defined using an E command. - - ?pi A processing instruction with data pi. - - Aname val - The next element to start has an attribute name - with value val which takes one of the following - forms: - - IMPLIED - The value of the attribute is implied. - - CDATA data - The attribute is character data. This is - used for attributes whose declared value is - CDATA. - - NOTATION nname - The attribute is a notation name; nname will - have been defined using a N command. This - is used for attributes whose declared value - is NOTATION. - - ENTITY name... - The attribute is a list of general entity - names. Each entity name will have been - defined using an I, E or S command. This is - - - - 7 - - - - - -SGMLS(1) SGMLS(1) - - - used for attributes whose declared value is - ENTITY or ENTITIES. - - TOKEN token... - The attribute is a list of tokens. This is - used for attributes whose declared value is - anything else. - - Dename name val - This is the same as the A command, except that it - specifies a data attribute for an external entity - named ename. Any D commands will come after the E - command that defines the entity to which they - apply, but before any & or A commands that refer- - ence the entity. - - Nnname nname. Define a notation This command will be pre- - ceded by a p command if the notation was declared - with a public identifier, and by a s command if the - notation was declared with a system identifier. A - notation will only be defined if it is to be refer- - enced in an E command or in an A command for an - attribute with a declared value of NOTATION. - - Eename typ nname - Define an external data entity named ename with - type typ (CDATA, NDATA or SDATA) and notation not. - This command will be preceded by one or more f com- - mands giving the filenames generated by the entity - manager from the system and public identifiers, by - a p command if a public identifier was declared for - the entity, and by a s command if a system identi- - fier was declared for the entity. not will have - been defined using a N command. Data attributes - may be specified for the entity using D commands. - An external data entity will only be defined if it - is to be referenced in a & command or in an A com- - mand for an attribute whose declared value is - ENTITY or ENTITIES. - - Iename typ text - Define an internal data entity named ename with - type typ (CDATA or SDATA) and entity text text. An - internal data entity will only be defined if it is - referenced in an A command for an attribute whose - declared value is ENTITY or ENTITIES. - - Sename Define a subdocument entity named ename. This com- - mand will be preceded by one or more f commands - giving the filenames generated by the entity man- - ager from the system and public identifiers, by a p - command if a public identifier was declared for the - entity, and by a s command if a system identifier - was declared for the entity. A subdocument entity - - - - 8 - - - - - -SGMLS(1) SGMLS(1) - - - will only be defined if it is referenced in a { - command or in an A command for an attribute whose - declared value is ENTITY or ENTITIES. - - ssysid This command applies to the next E, S or N command - and specifies the associated system identifier. - - ppubid This command applies to the next E, S or N command - and specifies the associated public identifier. - - ffilename - This command applies to the next E or S command and - specifies an associated filename. There will be - more than one f command for a single E or S command - if the system identifier used a colon. - - {ename The start of the SGML subdocument entity ename; - ename will have been defined using a S command. - - }ename The end of the SGML subdocument entity ename. - - Llineno file - Llineno - Set the current line number and filename. The - filename argument will be omitted if only the line - number has changed. This will be output only if - the -l option has been given. - - #text An APPINFO parameter of text was specified in the - SGML declaration. This is not strictly part of the - ESIS, but a structure-controlled application is - permitted to act on it. No # command will be out- - put if APPINFO NONE was specified. A # command - will occur at most once, and may be preceded only - by a single L command. - - C This command indicates that the document was a con- - forming SGML document. If this command is output, - it will be the last command. An SGML document is - not conforming if it references a subdocument - entity that is not conforming. - -BUGS - Some non-SGML characters in literals are counted as two - characters for the purposes of quantity and capacity cal- - culations. - -SEE ALSO - The SGML Handbook, Charles F. Goldfarb - ISO 8879 (Standard Generalized Markup Language), Interna- - tional Organization for Standardization - -ORIGIN - ARCSGML was written by Charles F. Goldfarb. - - - - 9 - - - - - -SGMLS(1) SGMLS(1) - - - Sgmls was derived from ARCSGML by James Clark - (jjc@jclark.com), to whom bugs should be reported. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - - diff --git a/cde/programs/dtdocbook/sgmls/sgmlsasp.c b/cde/programs/dtdocbook/sgmls/sgmlsasp.c deleted file mode 100644 index 56648efd4..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlsasp.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlsasp.c /main/3 1996/06/19 17:18:11 drk $ */ -/* sgmlsasp.c - Translate sgmls output using ASP replacement file. - - Written by James Clark (jjc@jclark.com). */ - -#include "sgmlsasp.h" -#include "sgmls.h" -#include "replace.h" -#include "getopt.h" - -/* Non-zero if general (non-entity) names should be folded to upper case. */ -int fold_general_names = 1; - -static char *program_name; -static char last_char = '\n'; - -static void output_begin_line P((void)); -static void output_data P((struct sgmls_data *, int)); -static void output_pi P((char *, unsigned)); -static void output_token P((char *)); -static void output_attribute P((struct sgmls_attribute *)); -static void output_data_char P((int)); -static void output_replacement - P((struct replacement *, struct sgmls_attribute *)); -static void do_file P((FILE *, struct replacement_table *)); -static void usage P((void)); -static void input_error P((int, char *, unsigned long)); - -#define output_char(c) (last_char = (c), putchar(c)) - -int main(argc, argv) - int argc; - char **argv; -{ - struct replacement_table *tablep; - int i; - int opt; - program_name = argv[0]; - - while ((opt = getopt(argc, argv, "n")) != EOF) - switch (opt) { - case 'n': - fold_general_names = 0; - break; - case '?': - usage(); - default: - assert(0); - } - if (argc - optind <= 0) - usage(); - tablep = make_replacement_table(); - for (i = optind; i < argc; i++) - load_replacement_file(tablep, argv[i]); - (void)sgmls_set_errhandler(input_error); - do_file(stdin, tablep); - exit(0); -} - -static -void usage() -{ - fprintf(stderr, "usage: %s [-n] replacement_file...\n", program_name); - exit(1); -} - -static -void input_error(num, str, lineno) - int num; - char *str; - unsigned long lineno; -{ - error("Error at input line %lu: %s", lineno, str); -} - -static -void do_file(fp, tablep) - FILE *fp; - struct replacement_table *tablep; -{ - struct sgmls *sp; - struct sgmls_event e; - - sp = sgmls_create(fp); - while (sgmls_next(sp, &e)) - switch (e.type) { - case SGMLS_EVENT_DATA: - output_data(e.u.data.v, e.u.data.n); - break; - case SGMLS_EVENT_ENTITY: - /* XXX what should we do here? */ - break; - case SGMLS_EVENT_PI: - output_pi(e.u.pi.s, e.u.pi.len); - break; - case SGMLS_EVENT_START: - output_replacement(lookup_replacement(tablep, - START_ELEMENT, e.u.start.gi), - e.u.start.attributes); - sgmls_free_attributes(e.u.start.attributes); - break; - case SGMLS_EVENT_END: - output_replacement(lookup_replacement(tablep, END_ELEMENT, e.u.end.gi), - 0); - break; - case SGMLS_EVENT_SUBSTART: - break; - case SGMLS_EVENT_SUBEND: - break; - case SGMLS_EVENT_APPINFO: - break; - case SGMLS_EVENT_CONFORMING: - break; - default: - abort(); - } - sgmls_free(sp); -} - -static -void output_data(v, n) -struct sgmls_data *v; -int n; -{ - int i; - - for (i = 0; i < n; i++) { - char *s = v[i].s; - int len = v[i].len; - for (; len > 0; len--, s++) - output_data_char(*s); - } -} - -static -void output_pi(s, len) - char *s; - unsigned len; -{ - for (; len > 0; len--, s++) - output_data_char(*s); -} - -static -void output_replacement(repl, attributes) -struct replacement *repl; -struct sgmls_attribute *attributes; -{ - struct replacement_item *p; - struct sgmls_attribute *a; - int i; - - if (!repl) - return; - if (repl->flags & NEWLINE_BEGIN) - output_begin_line(); - - for (p = repl->items; p; p = p->next) - switch (p->type) { - case DATA_REPL: - for (i = 0; i < p->u.data.n; i++) - output_char(p->u.data.s[i]); - break; - case ATTR_REPL: - for (a = attributes; a; a = a->next) - if (strcmp(a->name, p->u.attr) == 0) { - output_attribute(a); - break; - } - break; - default: - abort(); - } - - if (repl->flags & NEWLINE_END) - output_begin_line(); -} - -static -void output_attribute(p) -struct sgmls_attribute *p; -{ - switch (p->type) { - case SGMLS_ATTR_IMPLIED: - break; - case SGMLS_ATTR_CDATA: - output_data(p->value.data.v, p->value.data.n); - break; - case SGMLS_ATTR_TOKEN: - { - char **token = p->value.token.v; - int n = p->value.token.n; - - if (n > 0) { - int i; - output_token(token[0]); - for (i = 1; i < n; i++) { - output_char(' '); - output_token(token[i]); - } - } - } - break; - case SGMLS_ATTR_ENTITY: - { - struct sgmls_entity **v = p->value.entity.v; - int n = p->value.entity.n; - int i; - - for (i = 0; i < n; i++) { - if (i > 0) - output_char(' '); - output_token(v[i]->is_internal - ? v[i]->u.internal.name - : v[i]->u.external.name); - } - } - break; - case SGMLS_ATTR_NOTATION: - if (p->value.notation) - output_token(p->value.notation->name); - break; - default: - abort(); - } -} - -static -void output_token(s) - char *s; -{ - for (; *s; s++) - output_char(*s); -} - -static -void output_data_char(c) - int c; -{ - if (c != RSCHAR) { - if (c == RECHAR) - c = '\n'; - output_char(c); - } -} - -static -void output_begin_line() -{ - if (last_char != '\n') - output_char('\n'); -} - -NO_RETURN -#ifdef VARARGS -void error(va_alist) va_dcl -#else -void error(char *message,...) -#endif -{ -#ifdef VARARGS - char *message; -#endif - va_list ap; - - fprintf(stderr, "%s: ", program_name); -#ifdef VARARGS - va_start(ap); - message = va_arg(ap, char *); -#else - va_start(ap, message); -#endif - vfprintf(stderr, message, ap); - va_end(ap); - fputc('\n', stderr); - fflush(stderr); - exit(EXIT_FAILURE); -} diff --git a/cde/programs/dtdocbook/sgmls/sgmlsasp.man b/cde/programs/dtdocbook/sgmls/sgmlsasp.man deleted file mode 100644 index ab0337113..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlsasp.man +++ /dev/null @@ -1,30 +0,0 @@ -.\" -*- nroff -*- -.TH SGMLSASP 1 -.SH NAME -sgmlsasp \- translate output of sgmls using ASP replacement files -.SH SYNOPSIS -.B sgmls -.RB [ \-n ] -.I replacement_file\|.\|.\|. -.SH DESCRIPTION -.I sgmlsasp -translates the standard input using the specification in -.I replacement_file\|.\|.\|. -and writes the result to the standard output. -The standard input must be in the format output by -.IR sgmls . -Each replacement file must be in the format of an -Amsterdam SGML parser (ASP) replacement file; -this format is described in the ASP documentation. -Duplicate replacements are silently ignored. -The -.B \-n -option disables upper-case substitution (folding) for names in -replacement files; this option should be used with concrete syntaxes -that do not specify upper-case substitution for general names (that -is, names that are not entity names). -.SH BUGS -References to external data entities are ignored. -(Support for external data entities is not implemented in ASP.) -.SH "SEE ALSO" -.IR sgmls (1) diff --git a/cde/programs/dtdocbook/sgmls/sgmlsasp.txt b/cde/programs/dtdocbook/sgmls/sgmlsasp.txt deleted file mode 100644 index e43f08047..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlsasp.txt +++ /dev/null @@ -1,67 +0,0 @@ -# $XConsortium: sgmlsasp.txt /main/2 1996/11/11 11:25:31 drk $ - - - -SGMLSASP(1) SGMLSASP(1) - - -NAME - sgmlsasp - translate output of sgmls using ASP replacement - files - -SYNOPSIS - sgmls [-n] replacement_file... - -DESCRIPTION - sgmlsasp translates the standard input using the specifi- - cation in replacement_file... and writes the result to - the standard output. The standard input must be in the - format output by sgmls. Each replacement file must be in - the format of an Amsterdam SGML parser (ASP) replacement - file; this format is described in the ASP documentation. - Duplicate replacements are silently ignored. The -n - option disables upper-case substitution (folding) for - names in replacement files; this option should be used - with concrete syntaxes that do not specify upper-case sub- - stitution for general names (that is, names that are not - entity names). - -BUGS - References to external data entities are ignored. (Sup- - port for external data entities is not implemented in - ASP.) - -SEE ALSO - sgmls(1) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - diff --git a/cde/programs/dtdocbook/sgmls/sgmlxtrn.c b/cde/programs/dtdocbook/sgmls/sgmlxtrn.c deleted file mode 100644 index 480a1d327..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlxtrn.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlxtrn.c /main/3 1996/06/19 17:18:20 drk $ */ -/* Standard Generalized Markup Language Users' Group (SGMLUG) - SGML Parser Materials (ARCSGML 1.0) - -(C) 1983-1988 Charles F. Goldfarb (assigned to IBM Corporation) -(C) 1988-1991 IBM Corporation - -Licensed to the SGML Users' Group for distribution under the terms of -the following license: */ - -char license[] = -"SGMLUG hereby grants to any user: (1) an irrevocable royalty-free,\n\ -worldwide, non-exclusive license to use, execute, reproduce, display,\n\ -perform and distribute copies of, and to prepare derivative works\n\ -based upon these materials; and (2) the right to authorize others to\n\ -do any of the foregoing.\n"; - -#include "sgmlincl.h" - -/* SGMLXTRN: Storage allocation and initialization for all public variables. - Exceptions: Constants lex????? and del????? are defined in - LEX?????.C modules; constants pcb????? are defined in PCB?????.c. -*/ -int badresw = 0; /* 1=REF_ out of context; 0=valid. */ -int charmode = 0; /* >0=in #CHARS; 0=not. */ -int conactsw = 0; /* 1=return saved content action 0=get new one.*/ -int conrefsw = 0; /* 1=content reference att specified; 0=no. */ -int contersv = 0; /* Save contersw while processing pending REF. */ -int contersw = 0; /* 1=element or #CHARS out of context; 0=valid. */ -int datarc = 0; /* Return code for data: DAF_ or REF_. */ -int delmscsw = 0; /* 1=DELMSC must be read on return to es==0. */ -int didreq = 0; /* 1=required implied tag processed; 0=no. */ -int dostag = 0; /* 1=retry newetd instead of parsing; 0=parse. */ -int dtdsw = 0; /* DOCTYPE declaration found: 1=yes; 0=no. */ -int entdatsw = 0; /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */ -int entpisw = 0; /* 4=PI entity occurred; 0=not. */ -int eodsw = 0; /* 1=eod found in error; 0=not yet. */ -int eofsw = 0; /* 1=eof found in body of document; 0=not yet. */ -int es = -1; /* Index of current source in stack. */ -int etagimct = 0; /* Implicitly ended elements left on stack. */ -int etagimsw = 0; /* 1=end-tag implied by other end-tag; 0=not. */ -int etagmin = MINNONE; /* Minim: NONE NULL NET DATA; implied by S/ETAG*/ -int etictr = 0; /* Number of "NET enabled" tags on stack. */ -int etisw = 0; /* 1=tag ended with eti; 0=did not. */ -int indtdsw = 0; /* Are we in the DTD? 1=yes; 0=no. */ -int mslevel = 0; /* Nesting level of marked sections. */ -int msplevel = 0; /* Nested MS levels subject to special parse. */ -int prologsw = 1; /* 1=in prolog; 0=not. */ -int pss = 0; /* SGMLACT: scbsgml stack level. */ -int sgmlsw = 0; /* SGML declaration found: 1=yes; 0=no. */ -int stagmin = MINNONE; /* Minimization: NONE, NULL tag, implied by STAG*/ -int tagctr = 0; /* Tag source chars read. */ -int ts = -1; /* Index of current tag in stack. */ -struct parse *propcb = &pcbpro; /* Current PCB for prolog parse. */ -int aentctr = 0; /* Number of ENTITY tokens in this att list. */ -int conact = 0; /* Return code from content parse. */ -int conrefsv = 0; /* Save conrefsw when doing implied start-tag.*/ -int dtdrefsw = 0; /* External DTD? 1=yes; 0=no. */ -int etiswsv = 0; /* Save etisw when processing implied start-tag.*/ -int grplvl = 0; /* Current level of nested grps in model. */ -int idrctr = 0; /* Number of IDREF tokens in this att list. */ -int mdessv = 0; /* ES level at start of markup declaration. */ -int notadn = 0; /* Position of NOTATION attribute in list. */ -int parmno = 0; /* Current markup declaration parameter number. */ -int pexsw = 0; /* 1=tag valid solely because of plus exception.*/ -int rcessv = 0; /* ES level at start of RCDATA content. */ -int tagdelsw = 0; /* 1=tag ended with delimiter; 0=no delimiter. */ -int tokencnt = 0; /* Number of tokens found in attribute value. */ -struct entity *ecbdeflt = 0; /* #DEFAULT ecb (NULL if no default entity). */ -struct etd *docetd = 0; /* The etd for the document as a whole. */ -struct etd *etagreal = 0; /* Actual or dummy etd that implied this tag. */ -struct etd *newetd = 0; /* The etd for a start- or end-tag recognized. */ -struct etd *nextetd = 0; /* ETD that must come next (only one choice). */ -struct etd *stagreal = 0; /* Actual or dummy etd that implied this tag. */ -struct parse *conpcb = 0; /* Current PCB for content parse. */ -UNCH *data = 0; /* Pointer to returned data in buffer. */ -UNCH *mdname = 0; /* Name of current markup declaration. */ -UNCH *ptcon = 0; /* Current pointer into tbuf. */ -UNCH *ptpro = 0; /* Current pointer into tbuf. */ -UNCH *rbufs = 0; /* DOS file read area: start position for read. */ -UNCH *subdcl = 0; /* Subject of markup declaration (e.g., GI). */ -int Tstart = 0; /* Save starting token for AND group testing. */ -UNS conradn = 0; /* 1=CONREF attribute in list (0=no). */ -UNS datalen = 0; /* Length of returned data in buffer. */ -UNS entlen = 0; /* Length of TAG or EXTERNAL entity text. */ -UNS idadn = 0; /* Number of ID attribute (0 if none). */ -UNS noteadn = 0; /* Number of NOTATION attribute (0 if none). */ -UNS reqadn = 0; /* Num of atts with REQUIRED default (0=none). */ -int grplongs; /* Number of longs for GRPCNT bitvector. */ - -/* Variable arrays and structures. -*/ -struct ad *al = 0; /* Current attribute list work area. */ -struct dcncb *dcntab[1]; /* List of data content notation names. */ -struct entity *etab[ENTHASH]; /* Entity hash table. */ -struct etd *etdtab[ETDHASH]; /* Element type definition hash table. */ -struct fpi fpidf; /* Fpi for #DEFAULT entity. */ -struct id *itab[IDHASH]; /* Unique identifier hash table. */ -struct etd **nmgrp = 0; /* Element name group */ -PDCB *nnmgrp = 0; /* Notation name group */ -struct restate *scbsgml = 0; /* SGMLACT: return action state stack. */ -struct source *scbs = 0; /* Stack of open sources ("SCB stack"). */ -struct srh *srhtab[1]; /* List of SHORTREF table headers. */ -struct sgmlstat ds; /* Document statistics. */ -struct switches sw; /* Parser control switches set by text proc. */ -struct tag *tags = 0; /* Stack of open elements ("tag stack"). */ -struct thdr *gbuf = 0; /* Buffer for creating group. */ -struct thdr prcon[3]; /* 0-2: Model for *DOC content. */ -struct thdr undechdr; /* 0:Default model hdr for undeclared content.*/ -UNCH *dtype = 0; /* Document type name. */ -UNCH *entbuf = 0; /* Buffer for entity reference name. */ -UNCH fce[2]; /* String form of FCE char. - (fce[1] must be EOS).*/ -/* Buffer for non-SGML character reference.*/ -UNCH nonchbuf[2] = { DELNONCH }; -UNCH *tbuf; /* Work area for tokenization. */ -UNCH *lbuf = 0; /* In tbuf: Literal parse area.*/ -UNCH *sysibuf = 0; /* Buffer for system identifiers. */ -UNCH *pubibuf = 0; /* Buffer for public identifiers. */ -UNCH *nmbuf = 0; /* Name buffer used by mdentity. */ -struct mpos *savedpos; - -/* Constants. -*/ -struct map dctab[] = { /* Keywords for declared content parameter.*/ - { key[KRCDATA], MRCDATA+MPHRASE }, - { key[KCDATA], MCDATA+MPHRASE }, - { key[KANY], MANY+MCHARS+MGI }, - { key[KEMPTY], MNONE+MPHRASE }, - { NULL, 0 } -}; -struct map deftab[] = { /* Default value keywords. */ - { key[KIMPLIED], DNULL }, - { key[KREQUIRED], DREQ }, - { key[KCURRENT], DCURR }, - { key[KCONREF], DCONR }, - { key[KFIXED], DFIXED}, - { NULL, 0} -}; -struct map dvtab[] = { /* Declared value: keywords and type codes.*/ -/* TYPE NUMBER */ -/* grp ANMTGRP Case 1 0 Grp size */ -/* grp member ANMTGRP Case 0 Position */ -/* grp ANOTEGRP Case 1 1 Grp size */ - { key[KNOTATION], ANOTEGRP}, /* Case 1 Position */ - { key[KCDATA], ACHARS }, /* Case 2 Always 0 */ - { key[KENTITY], AENTITY }, /* Case 3 Normal 1 */ - { key[KID], AID }, /* Case 4 Normal 1 */ - { key[KIDREF], AIDREF }, /* Case 5 Normal 1 */ - { key[KNAME], ANAME }, /* Case 6 Normal 1 */ - { key[KNMTOKEN], ANMTOKE }, /* Case 7 Normal 1 */ - { key[KNUMBER], ANUMBER }, /* Case 8 Normal 1 */ - { key[KNUTOKEN], ANUTOKE }, /* Case 9 Normal 1 */ - { key[KENTITIES], AENTITYS}, /* Case A Normal 1 */ - { key[KIDREFS], AIDREFS }, /* Case B # tokens */ - { key[KNAMES], ANAMES }, /* Case C # tokens */ - { key[KNMTOKENS], ANMTOKES}, /* Case D # tokens */ - { key[KNUMBERS], ANUMBERS}, /* Case E # tokens */ - { key[KNUTOKENS], ANUTOKES}, /* Case F # tokens */ - { NULL, 0 } /* Case 0 ERROR */ -}; -struct map enttab[] = { /* Entity declaration second parameter. */ - { key[KCDATA], ESC }, - { key[KSDATA], ESX }, - { key[KMS], ESMS}, - { key[KPI], ESI }, - { key[KSTARTTAG], ESS }, - { key[KENDTAG], ESE }, - { key[KMD], ESMD}, - { NULL, 0 } -}; -struct map exttab[] = { /* Keywords for external identifier. */ - { key[KSYSTEM], EDSYSTEM }, - { key[KPUBLIC], EDPUBLIC }, - { NULL, 0 } -}; -struct map extettab[] = { /* Keywords for external entity type. */ - { key[KCDATA], ESNCDATA }, - { key[KNDATA], ESNNDATA }, - { key[KSDATA], ESNSDATA }, - { key[KSUBDOC], ESNSUB }, - { NULL, 0 } -}; -struct map funtab[] = { /* Function character reference names. */ - { key[KRE], RECHAR }, - { key[KRS], RSCHAR }, - { key[KSPACE], SPCCHAR }, - /* We should use an extra table for added functions. */ - { (UNCH *)"TAB", TABCHAR }, - { NULL, 0 } -}; -struct map mstab[] = { /* Marked section keywords. */ - { key[KTEMP], MSTEMP }, - { key[KINCLUDE], MSTEMP }, /* Treat INCLUDE like TEMP; both are NOPs.*/ - { key[KRCDATA], MSRCDATA}, - { key[KCDATA], MSCDATA }, - { key[KIGNORE], MSIGNORE}, - { NULL, 0 } -}; -struct map pubcltab[] = { /* Names for public text class. */ - { (UNCH *)"CAPACITY", FPICAP }, - { (UNCH *)"CHARSET", FPICHARS}, - { (UNCH *)"DOCUMENT", FPIDOC }, - { (UNCH *)"DTD", FPIDTD }, - { (UNCH *)"ELEMENTS", FPIELEM }, - { (UNCH *)"ENTITIES", FPIENT }, - { (UNCH *)"LPD", FPILPD }, - { (UNCH *)"NONSGML", FPINON }, - { (UNCH *)"NOTATION", FPINOT }, - { (UNCH *)"SHORTREF", FPISHORT}, - { (UNCH *)"SUBDOC", FPISUB }, - { (UNCH *)"SYNTAX", FPISYN }, - { (UNCH *)"TEXT", FPITEXT }, - { NULL, 0 } -}; -UNCH indefent[] = "\12#DEFAULT"; /* Internal name: default entity name. */ -UNCH indefetd[] = "\12*DOCTYPE"; /* Internal name: default document type. */ -UNCH indocent[] = "\12*SGMLDOC"; /* Internal name: SGML document entity. */ -UNCH indocetd[] = "\6*DOC"; /* Internal name: document level etd. */ -UNCH indtdent[] = "\11*DTDENT"; /* Internal name: external DTD entity. */ - -struct etd dumetd[3]; -struct entity *dumpecb; -UNCH sgmlkey[] = "SGML"; diff --git a/cde/programs/dtdocbook/sgmls/sgmlxtrn.h b/cde/programs/dtdocbook/sgmls/sgmlxtrn.h deleted file mode 100644 index da6e0e344..000000000 --- a/cde/programs/dtdocbook/sgmls/sgmlxtrn.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sgmlxtrn.h /main/3 1996/06/19 17:18:25 drk $ */ -/* SGMLXTRN.H: External declarations for SGML public variables. - Exceptions: Constants lex????? and del????? are defined in - LEX?????.C modules; constants pcb????? are defined in PCB?????.c. -*/ -#ifndef SGMLXTRN /* Don't include this file more than once. */ -#define SGMLXTRN -extern int badresw; /* 1=REF_ out of context; 0=valid. */ -extern int charmode; /* >0=in #CHARS; 0=not. */ -extern int conactsw; /* 1=return saved content action 0=get new one.*/ -extern int conrefsw; /* 1=content reference att specified; 0=no. */ -extern int contersv; /* Save contersw while processing pending REF. */ -extern int contersw; /* 1=element or #CHARS out of context; 0=valid. */ -extern int datarc; /* Return code for data: DAF_ or REF_. */ -extern int delmscsw; /* 1=DELMSC must be read on return to es==0. */ -extern int didreq; /* 1=required implied tag processed; 0=no. */ -extern int dostag; /* 1=retry newetd instead of parsing; 0=parse. */ -extern int dtdsw; /* DOCTYPE declaration found: 1=yes; 0=no. */ -extern int entdatsw; /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */ -extern int entpisw; /* 4=PI entity occurred; 0=not. */ -extern int eodsw; /* 1=eod found in error; 0=not yet. */ -extern int eofsw; /* 1=eof found in body of document; 0=not yet. */ -extern int etagimct; /* Implicitly ended elements left on stack. */ -extern int etagimsw; /* 1=end-tag implied by other end-tag; 0=not. */ -extern int etagmin; /* Minim: NONE NULL NET DATA; implied by S/ETAG*/ -extern int etictr; /* Number of "NET enabled" tags on stack. */ -extern int etisw; /* 1=tag ended with eti; 0=did not. */ -extern int indtdsw; /* Are we in the DTD? 1=yes; 0=no. */ -extern int mslevel; /* Nesting level of marked sections. */ -extern int msplevel; /* Nested MS levels subject to special parse. */ -extern int prologsw; /* 1=in prolog; 0=not. */ -extern int pss; /* SGMLACT: scbsgml stack level. */ -extern int sgmlsw; /* SGML declaration found: 1=yes; 0=no. */ -extern int stagmin; /* Minimization: NONE, NULL tag, implied by STAG*/ -extern int tagctr; /* Tag source chars read. */ -extern int ts; /* Index of current tag in stack. */ -extern struct parse *propcb; /* Current PCB for prolog parse. */ -extern int aentctr; /* Number of ENTITY tokens in this att list. */ -extern int conact; /* Return code from content parse. */ -extern int conrefsv; /* Save conrefsw when doing implied start-tag.*/ -extern int dtdrefsw; /* External DTD? 1=yes; 0=no. */ -extern int etiswsv; /* Save etisw when processing implied start-tag.*/ -extern int grplvl; /* Current level of nested grps in model. */ -extern int idrctr; /* Number of IDREF tokens in this att list. */ -extern int mdessv; /* ES level at start of markup declaration. */ -extern int notadn; /* Position of NOTATION attribute in list. */ -extern int parmno; /* Current markup declaration parameter number. */ -extern int pexsw; /* 1=tag valid solely because of plus exception.*/ -extern int rcessv; /* ES level at start of RCDATA content. */ -extern int tagdelsw; /* 1=tag ended with delimiter; 0=no delimiter. */ -extern int tokencnt; /* Number of tokens found in attribute value. */ -extern struct entity *ecbdeflt; /* #DEFAULT ecb (NULL if no default entity). */ -extern struct etd *docetd; /* The etd for the document as a whole. */ -extern struct etd *etagreal; /* Actual or dummy etd that implied this tag. */ -extern struct etd *newetd; /* The etd for a start- or end-tag recognized. */ -extern struct etd *nextetd; /* ETD that must come next (only one choice). */ -extern struct etd *stagreal; /* Actual or dummy etd that implied this tag. */ -extern struct parse *conpcb; /* Current PCB for content parse. */ -extern UNCH *data; /* Pointer to returned data in buffer. */ -extern UNCH *mdname; /* Name of current markup declaration. */ -extern UNCH *ptcon; /* Current pointer into tbuf. */ -extern UNCH *ptpro; /* Current pointer into tbuf. */ -extern UNCH *rbufs; /* DOS file read area: start position for read. */ -extern UNCH *subdcl; /* Subject of markup declaration (e.g., GI). */ -extern int Tstart; /* Save starting token for AND group testing. */ -extern UNS conradn; /* 1=CONREF attribute in list (0=no). */ -extern UNS datalen; /* Length of returned data in buffer. */ -extern UNS entlen; /* Length of TAG or EXTERNAL entity text. */ -extern UNS idadn; /* Number of ID attribute (0 if none). */ -extern UNS noteadn; /* Number of NOTATION attribute (0 if none). */ -extern UNS reqadn; /* Num of atts with REQUIRED default (0=none). */ -extern int grplongs; /* Number of longs for GRPCNT bitvector. */ -/* Variable arrays and structures. -*/ -extern struct ad *al; /* Current attribute list work area. */ -extern struct dcncb *dcntab[];/* List of data content notation names. */ -extern struct entity *etab[]; /* Entity hash table. */ -extern struct etd *etdtab[]; /* Element type definition hash table. */ -extern struct fpi fpidf; /* Fpi for #DEFAULT entity. */ -extern struct id *itab[]; /* Unique identifier hash table. */ -extern struct etd **nmgrp; /* Element name group */ -extern PDCB *nnmgrp; /* Notation name group */ -extern struct restate *scbsgml; /* SGMLACT: return action state stack. */ -extern struct srh *srhtab[]; /* List of SHORTREF table headers. */ -extern struct sgmlstat ds; /* Document statistics. */ -extern struct switches sw; /* Parser control switches set by text proc. */ -extern struct tag *tags; /* Stack of open elements ("tag stack"). */ -extern struct thdr *gbuf; /* Buffer for creating group. */ -extern struct thdr prcon[]; /* 0-2: Model for *DOC content. */ -extern struct thdr undechdr; /* 0: Default model hdr for undeclared content. */ -extern UNCH *dtype; /* Document type name. */ -extern UNCH *entbuf; /* Buffer for entity reference name. */ -extern UNCH fce[]; /* String form of FCE char (fce[1] must be EOS).*/ -extern UNCH nonchbuf[]; /* Buffer for valid nonchar character reference.*/ -extern UNCH *tbuf; /* Work area for tokenization. */ -extern UNCH *lbuf; /* In tbuf: Literal parse area; TAGLEN limit.*/ -extern struct entity *dumpecb; /* SRMNULL points to this. */ -extern UNCH *sysibuf; -extern UNCH *pubibuf; -extern UNCH *nmbuf; /* Name buffer used by mdentity. */ -extern struct mpos *savedpos; - -/* Constants. -*/ -extern int scbsgmnr; /* SCBSGML: new record; do not ignore RE. */ -extern int scbsgmst; /* SCBSGML: trailing stag or markup; ignore RE. */ -extern struct map dctab[]; /* Keywords for declared content parameter. */ -extern struct map deftab[]; /* Default value keywords. */ -extern struct map dvtab[]; /* Declared value: keywords and type codes.*/ -extern struct map enttab[]; /* Entity declaration second parameter. */ -extern struct map exttab[]; /* Keywords for external identifier. */ -extern struct map extettab[]; /* Keywords for external entity type. */ -extern struct map funtab[]; /* Function character reference names. */ -extern struct map mstab[]; /* Marked section keywords. */ -extern struct map pubcltab[]; /* Keywords for public text class. */ -extern UNCH indefent[]; /* Internal name: default entity name. */ -extern UNCH indefetd[]; /* Internal name: default document type. */ -extern UNCH indocent[]; /* Internal name: SGML document entity. */ -extern UNCH indocetd[]; /* Internal name: etd for document as a whole. */ -extern UNCH indtdent[]; /* Internal name: external DTD entity. */ -extern char license[]; /* SGML Users' Group free license. */ -#endif /* ndef SGMLXTRN */ diff --git a/cde/programs/dtdocbook/sgmls/source.h b/cde/programs/dtdocbook/sgmls/source.h deleted file mode 100644 index 02861044d..000000000 --- a/cde/programs/dtdocbook/sgmls/source.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: source.h /main/3 1996/06/19 17:18:30 drk $ */ -/* SOURCE.H: Entity and source control block structures and definitions. -*/ -#define ENTHASH 503 /* Size of entity hash table. Must be prime. */ -/* Entity storage class values for estore member of entity structure. */ -#define EST 1 /* String: Tag (usually a fixed STARTGI). */ - /* */ -#define ESMD 2 /* String: Markup declaration. */ -#define ESMS 3 /* String: Marked section. */ -#define ESM 4 /* String: ordinary text. */ - /* */ -#define ESS 5 /* ETD: Start-tag. */ -#define ESE 6 /* ETD: End-tag. */ -#define ESI 7 /* String: PI. */ -#define ESX 8 /* String: SDATA general entity. */ -#define ESC 9 /* String: CDATA general entity. */ - /* */ -#define ESFM 10 /* LPU: minimum external (file) storage class. */ -#define ESN 10 /* XCB: N/C/SDATA or SUBDOC control block. */ - /* */ -#define ESF 11 /* LPU: General entity. */ -#define ESP 12 /* LPU: Parameter entity. */ -#define ESD 13 /* LPU: Document type definition. */ -#define ESL 14 /* LPU: Link process definition. */ -#define ESK 15 /* LPU: Data content notation. */ - /* */ - -union etext { /* Entity text. */ - UNIV x; /* External ID generated by system. */ - UNCH *c; /* Character string. */ - struct ne *n; /* N/C/SDATA or SUBDOC entity control block. */ -}; -#define ETEXTSZ sizeof(union etext) -struct entity { /* Entity control block. */ - struct entity *enext; /* Next entity in chain. */ - UNCH *ename; /* Entity name with length and EOS. */ - UNCH estore; /* Storage class (see values above). */ - UNCH dflt; /* Declared as default entity. */ - UNCH mark; /* For use by for sgmlment. */ - union etext etx; /* Entity text. */ -}; -#define ENTSZ sizeof(struct entity) -typedef struct entity *PECB; /* Ptr to entity control block. */ -typedef struct entity **TECB; /* Table of entity control blocks. */ - -struct source { /* Source control block. */ - struct entity ecb; /* Entity control block. */ - unsigned long rcnt; /* Source record number. */ - int ccnt; /* Source record chars since last RS. */ - int curoff; /* Offset of curchar (chars read in this block).*/ - UNCH curchar; /* Current character. */ - UNCH nextchar; /* If curchar was DELNONCH, next character. */ - UNIV fcb; /* SGMLIO fcb ptr returned by OPEN. */ - UNCH *fbuf; /* 1st char in buffer (0=PEND) or entity text. */ - UNCH *fpos; /* Current char in buffer or entity text. */ - UNCH pushback; /* Character before pend position */ - char copied; /* Is this a copy of the internal entity? */ -}; -#define SCBSZ sizeof(struct source) -typedef struct source *PSCB; /* Ptr to source control block. */ - -extern int es; /* Index of current source in stack. */ -extern struct source *scbs; /* Stack of open sources ("SCB stack"). */ - -/* Member definitions for source and entity control blocks. -*/ -#define SCB (scbs[es]) /* Ptr to current source control block. */ - -#define ECB SCB.ecb /* Pointer to current entity control block. */ -#define FBUF SCB.fbuf /* Pointer to start of entity buffer. */ -#define FPOS SCB.fpos /* Pointer to current char of current source. */ -#define RSCC SCB.ccnt /* CCNT at start of block (across EOB/EOS/EOF). */ -#define CCO SCB.curoff /* Offset in read buffer of current char. */ -#define CC SCB.curchar /* Current character of current source entity. */ -#define NEXTC SCB.nextchar /* Next character in current source entity. */ -#define CCNT (SCB.ccnt+CCO) /* Position of CC in current record (RS=0). */ -#define RCNT SCB.rcnt /* Position of record in entity (origin=1). */ -#define SCBFCB SCB.fcb /* Current file control block (if FILESW). */ -#define ECBPTR ((ECB.enext)) /* Pointer to this entity's ECB. */ -#define ENTITY ((ECB.ename)) /* Current entity name. */ -#define FILESW (ECB.estore>=ESFM) /* 1=Entity is external file; 0=internal. */ -#define NEWCC (++FPOS) /* Get next current character. */ -#define REPEATCC (--FPOS) /* Repeat previous current character. */ -#define COPIEDSW SCB.copied /* Non-zero means entity was copied. */ - -struct srh { /* Short reference map header. */ - struct srh *enext; /* Next short reference map in chain. */ - UNCH *ename; /* Short reference map name. */ - TECB srhsrm; /* Ptr to short reference map. */ -}; -#define SRHSZ (sizeof(struct srh)) -typedef struct srh *PSRH; /* Ptr to short reference map header. */ -#define SRMNULL (&dumpecb) /* Dummy ptr to empty short reference map. */ - -/* Definitions for ENTOPEN/ENTREF return codes. -*/ -#define ENTUNDEF -1 /* Callers of ENTOPEN: entity undefined. */ -#define ENTLOOP -2 /* ENTOPEN: endless loop entity. */ -#define ENTMAX -3 /* ENTOPEN: too many open entities. */ -#define ENTFILE -4 /* ENTOPEN: file I/O error. */ -#define ENTDATA -5 /* ENTOPEN: CDATA or SDATA entity. */ -#define ENTPI -6 /* ENTOPEN: PI entity. */ - -/* Definitions for ENTDATA switches set in contersw. -*/ -#define CDECONT 2 /* 0010 CDATA entity referenced. */ -#define SDECONT 4 /* 0100 SDATA entity referenced. */ -#define NDECONT 8 /* 1000 NDATA entity referenced. */ - -/* Definitions for manipulating signed source character counters. -*/ -#define CTRSET(CTR) (CTR = (int) -(FPOS+1-FBUF)) /* Init source char ctr. */ -#define CTRGET(CTR) (CTR + (int) (FPOS+1-FBUF)) /* Read source char ctr. */ - - diff --git a/cde/programs/dtdocbook/sgmls/std.h b/cde/programs/dtdocbook/sgmls/std.h deleted file mode 100644 index 8accc53fc..000000000 --- a/cde/programs/dtdocbook/sgmls/std.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: std.h /main/3 1996/06/19 17:18:34 drk $ */ -/* std.h - - Include standard header files. -*/ - -#ifndef STD_H -#define STD_H 1 - -#include -#include -#include -#include -#ifdef SUPPORT_SUBDOC -#include -#endif /* SUPPORT_SUBDOC */ - -#ifndef STDDEF_H_MISSING -#include -#endif /* not STDDEF_H_MISSING */ - -#ifndef LIMITS_H_MISSING -#include -#endif /* not LIMITS_H_MISSING */ - -#ifndef UINT_MAX -#define UINT_MAX (sizeof(unsigned int) == 2 ? 0x7fff : \ - (sizeof(unsigned int) == 4 ? 0x7fffffff : cant_guess_UINT_MAX)) -#endif - -#ifdef VARARGS -#include -#else -#include -#endif - -#ifdef BSD_STRINGS -#include -#define memcpy(to, from, n) bcopy(from, to, n) -#define memcmp(p, q, n) bcmp(p, q, n) -#define strchr(s, c) index(s, c) -#define strrchr(s, c) rindex(s, c) -#else /* not BSD_STRINGS */ -#include -#endif /* not BSD_STRINGS */ - -#ifdef STRERROR_MISSING -#ifdef USE_PROTOTYPES -extern char *strerror(int); -#else -extern char *strerror(); -#endif -#endif /* STRERROR_MISSING */ - -#ifdef STDLIB_H_MISSING -UNIV malloc(); -UNIV calloc(); -UNIV realloc(); -char *getenv(); -long atol(); -#else /* not STDLIB_H_MISSING */ -#include -#endif /* not STDLIB_H_MISSING */ - -#ifdef REMOVE_MISSING -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#define remove unlink -#endif /* REMOVE_MISSING */ - -#ifdef RAISE_MISSING -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#define raise(sig) kill(getpid(), sig) -#endif /* RAISE_MISSING */ - -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifdef FPOS_MISSING -typedef long fpos_t; -#define fsetpos(stream, pos) fseek(stream, *(pos), SEEK_SET) -#define fgetpos(stream, pos) ((*(pos) = ftell(stream)) == -1L) -#endif /* FPOS_MISSING */ - -/* Old BSD systems lack L_tmpnam and tmpnam(). This is a partial -emulation using mktemp(). It requires that the argument to tmpnam() -be non-NULL. */ - -#ifndef L_tmpnam -#define tmpnam_template "/tmp/sgmlsXXXXXX" -#define L_tmpnam (sizeof(tmpnam_template)) -#undef tmpnam -#define tmpnam(buf) \ - (mktemp(strcpy(buf, tmpnam_template)) == 0 || (buf)[0] == '\0' ? 0 : (buf)) -#endif /* not L_tmpnam */ - -#ifndef errno -extern int errno; -#endif - -#endif /* not STD_H */ diff --git a/cde/programs/dtdocbook/sgmls/stklen.c b/cde/programs/dtdocbook/sgmls/stklen.c deleted file mode 100644 index 2b04b96f0..000000000 --- a/cde/programs/dtdocbook/sgmls/stklen.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: stklen.c /main/3 1996/06/19 17:18:38 drk $ */ -/* This tells Borland C++ to allocate a 14k stack. */ -unsigned _stklen = 14*1024; diff --git a/cde/programs/dtdocbook/sgmls/strerror.c b/cde/programs/dtdocbook/sgmls/strerror.c deleted file mode 100644 index 27bcb44e2..000000000 --- a/cde/programs/dtdocbook/sgmls/strerror.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: strerror.c /main/3 1996/06/19 17:18:42 drk $ */ -/* strerror.c - - ANSI C strerror() function. - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifdef STRERROR_MISSING -#include - -char *strerror(n) -int n; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - static char buf[sizeof("Error ") + 1 + 3*sizeof(int)]; - - if (n >= 0 && n < sys_nerr && sys_errlist[n] != 0) - return sys_errlist[n]; - else { - sprintf(buf, "Error %d", n); - return buf; - } -} - -#endif /* STRERROR_MISSING */ -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/synrf.c b/cde/programs/dtdocbook/sgmls/synrf.c deleted file mode 100644 index bda55e77d..000000000 --- a/cde/programs/dtdocbook/sgmls/synrf.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: synrf.c /main/3 1996/06/19 17:18:46 drk $ */ -/* SYNRF: Reserved names and other constants for reference concrete syntax. -*/ -#include "config.h" -#include "entity.h" /* Templates for entity control blocks. */ -#include "synxtrn.h" /* Declarations for concrete syntax constants. */ -#include "adl.h" /* Definitions for attribute list processing. */ -UNCH key[NKEYS][REFNAMELEN+1] = { - "ANY", - "ATTLIST", - "CDATA", - "CONREF", - "CURRENT", - "DEFAULT", - "DOCTYPE", - "ELEMENT", - "EMPTY", - "ENDTAG", - "ENTITIES", - "ENTITY", - "FIXED", - "ID", - "IDLINK", - "IDREF", - "IDREFS", - "IGNORE", - "IMPLIED", - "INCLUDE", - "INITIAL", - "LINK", - "LINKTYPE", - "MD", - "MS", - "NAME", - "NAMES", - "NDATA", - "NMTOKEN", - "NMTOKENS", - "NOTATION", - "NUMBER", - "NUMBERS", - "NUTOKEN", - "NUTOKENS", - "O", - "PCDATA", - "PI", - "POSTLINK", - "PUBLIC", - "RCDATA", - "RE", - "REQUIRED", - "RESTORE", - "RS", - "SDATA", - "SHORTREF", - "SIMPLE", - "SPACE", - "STARTTAG", - "SUBDOC", - "SYSTEM", - "TEMP", - "USELINK", - "USEMAP" -}; -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/synxtrn.h b/cde/programs/dtdocbook/sgmls/synxtrn.h deleted file mode 100644 index 28e78fb1f..000000000 --- a/cde/programs/dtdocbook/sgmls/synxtrn.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: synxtrn.h /main/3 1996/06/19 17:18:50 drk $ */ -/* SYNXTRN.H: External declarations for concrete syntax constants. -*/ -/* Short References -*/ -#define SRCT 32 /* Number of short reference delimiters. */ -#define SRMAXLEN 3 /* Maximum length of a SHORTREF delimiter. */ -#define SRNPRT 8 /* Number of non-printable SHORTREF delimiters. */ -struct srdel { - struct map dtb[SRCT+2]; /* LEXCNM: Short reference delimiters. */ - char *pdtb[SRNPRT+1]; /* LEXCNM: Printable form of unprintable SRs. */ - int fce; /* LEXCNM: Index of first FCE in srdeltab. */ - int hyp2; /* LEXCNM: Index of "two hyphens" in srdeltab. */ - int data; /* LEXCNM: Index of first SR with data char. */ - int hyp; /* LEXCNM: Index of hyphen in srdeltab. */ - int prtmin; /* LEXCNM: Index of 1st printable SR. */ - int spc; /* LEXCNM: Index of space in srdeltab. */ - int lbr; /* LEXCNM: Index of left bracket in srdeltab. */ - int rbr; /* LEXCNM: Index of right bracket in srdeltab. */ -}; -struct delim { - UNCH genre; /* LEXCON: Generated RE; cannot be markup. */ - UNCH lit; /* LEXMARK: Char used as LIT delimiter.*/ - UNCH lita; /* LEXMARK: Char used as LITA delimiter.*/ - UNCH mdc; /* LEXLMS: Char used as MDC delimiter.*/ - UNCH msc; /* LEXCON: Char used as MSC delimiter. */ - UNCH net; /* LEXCON: Char used as NET when enabled.*/ - UNCH pero; /* LEXMARK: Char used as PERO delimiter. */ - UNCH pic; /* LEXCON: Char used as PIC delimiter.*/ - UNCH tago; /* LEXCON: Char used as TAGO when enabled.*/ -}; -struct lexcode { - UNCH fce; /* LEXCNM: FRE character as entity reference. */ - UNCH fre; /* LEXCON: Free character not an entity ref. */ - UNCH litc; /* LEXLMS: Literal close delimiter enabled. */ - UNCH msc; /* LEXLMS: Marked section close delim enabled. */ - UNCH net; /* LEXCON: Null end-tag delimiter enabled. */ - UNCH nonet; /* LEXCON: NET disabled; still used as ETI. */ - UNCH spcr; /* LEXCNM: Space in use as SHORTREF delimiter. */ - UNCH tago; /* LEXCON: Tag open delimiter enabled. */ - UNCH cde; /* LEXLMS: CDATA/SDATA delimiters. */ -}; -struct lexical { - struct markup m; /* Markup strings for text processor. */ - struct srdel s; /* Short reference delimiters. */ - struct delim d; /* General delimiter characters. */ - struct lexcode l; /* Lexical table code assignments. */ -}; -extern struct lexical lex; /* Delimiter set constants. */ -extern UNCH lexcnm[]; /* Lexical table: mixed content. */ -extern UNCH lexcon[]; /* Lexical table for content (except mixed). */ -extern UNCH lexgrp[]; /* Lexical table for groups. */ -extern UNCH lexlms[]; /* Lexical table: literals and marked sections. */ -extern UNCH lexmark[]; /* Lexical table for markup. */ -extern UNCH lexsd[]; /* Lexical table for SGML declaration. */ -extern UNCH lextran[]; /* Case translation table for SGML names. */ -extern UNCH lextoke[]; /* Lexical table for tokenization. */ -extern UNCH *lextabs[]; /* List of all lexical tables. */ -extern struct parse pcbconc; /* PCB: character data. */ -extern struct parse pcbcone; /* PCB: element content (no data allowed). */ -extern struct parse pcbconm; /* PCB: mixed content (data allowed). */ -extern struct parse pcbconr; /* PCB: replaceable character data. */ -extern struct parse pcbetag; /* PCB: end-tags. */ -extern struct parse pcbgrcm; /* PCB: content model group. */ -extern struct parse pcbgrcs; /* PCB: content model suffix. */ -extern struct parse pcbgrnm; /* PCB: name group. */ -extern struct parse pcbgrnt; /* PCB: name token group. */ -extern struct parse pcblitc; /* PCB: literal with CDATA. */ -extern struct parse pcblitp; /* PCB: literal with CDATA, parm & char refs. */ -extern struct parse pcblitr; /* PCB: attribute value with general refs. */ -extern struct parse pcblitt; /* PCB: tokenized attribute value. */ -extern struct parse pcblitv; /* PCB: literal with CDATA, function char trans.*/ -extern struct parse pcbmd; /* PCB: markup declaration. */ -extern struct parse pcbmdc; /* PCB: comment declaration. */ -extern struct parse pcbmdi; /* PCB: markup declaration (ignored). */ -extern struct parse pcbmds; /* PCB: markup declaration subset. */ -extern struct parse pcbmsc; /* PCB: marked section in CDATA mode. */ -extern struct parse pcbmsi; /* PCB: marked section in IGNORE mode. */ -extern struct parse pcbmsrc; /* PCB: marked section in RCDATA mode. */ -extern struct parse pcbpro; /* PCB: prolog. */ -extern struct parse pcbref; /* PCB: reference. */ -extern struct parse pcbstag; /* PCB: start-tag. */ -extern struct parse pcbval; /* PCB: attribute value. */ -extern struct parse pcbeal; /* PCB: end of attribute list. */ -extern struct parse pcbsd; /* PCB: SGML declaration. */ -extern int pcbcnda; /* PCBCONM: data in buffer. */ -extern int pcbcnet; /* PCBCONM: markup found or data buffer flushed.*/ -extern int pcbmdtk; /* PCBMD: token expected. */ -extern int pcbstan; /* PCBSTAG: attribute name expected. */ -extern int pcblittda; /* PCBLITT: data character found */ - -#define KANY 0 -#define KATTLIST 1 -#define KCDATA 2 -#define KCONREF 3 -#define KCURRENT 4 -#define KDEFAULT 5 -#define KDOCTYPE 6 -#define KELEMENT 7 -#define KEMPTY 8 -#define KENDTAG 9 -#define KENTITIES 10 -#define KENTITY 11 -#define KFIXED 12 -#define KID 13 -#define KIDLINK 14 -#define KIDREF 15 -#define KIDREFS 16 -#define KIGNORE 17 -#define KIMPLIED 18 -#define KINCLUDE 19 -#define KINITIAL 20 -#define KLINK 21 -#define KLINKTYPE 22 -#define KMD 23 -#define KMS 24 -#define KNAME 25 -#define KNAMES 26 -#define KNDATA 27 -#define KNMTOKEN 28 -#define KNMTOKENS 29 -#define KNOTATION 30 -#define KNUMBER 31 -#define KNUMBERS 32 -#define KNUTOKEN 33 -#define KNUTOKENS 34 -#define KO 35 -#define KPCDATA 36 -#define KPI 37 -#define KPOSTLINK 38 -#define KPUBLIC 39 -#define KRCDATA 40 -#define KRE 41 -#define KREQUIRED 42 -#define KRESTORE 43 -#define KRS 44 -#define KSDATA 45 -#define KSHORTREF 46 -#define KSIMPLE 47 -#define KSPACE 48 -#define KSTARTTAG 49 -#define KSUBDOC 50 -#define KSYSTEM 51 -#define KTEMP 52 -#define KUSELINK 53 -#define KUSEMAP 54 - -#define NKEYS (KUSEMAP+1) - -extern UNCH key[NKEYS][REFNAMELEN+1]; - -/* Holds the SGML keyword (not alterable by concrete syntax). */ -extern UNCH sgmlkey[]; diff --git a/cde/programs/dtdocbook/sgmls/test/CLEAN b/cde/programs/dtdocbook/sgmls/test/CLEAN deleted file mode 100755 index 5ce81845f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/CLEAN +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -rm -fr badout baderr badcap badrast difout diferr difcap difrast -rm -f *~ core gmon.out *.gprof - -exit 0 diff --git a/cde/programs/dtdocbook/sgmls/test/Eckhardt.gml b/cde/programs/dtdocbook/sgmls/test/Eckhardt.gml deleted file mode 100644 index df894c55f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/Eckhardt.gml +++ /dev/null @@ -1,4 +0,0 @@ -K.L. Eckhardt -Mgr., West Coast Development Center -FLA/029 -San Jose diff --git a/cde/programs/dtdocbook/sgmls/test/GEN b/cde/programs/dtdocbook/sgmls/test/GEN deleted file mode 100755 index 57af968dd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/GEN +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -unset SGML_PATH -sgmls="../sgmls -gerdu" -rast="../rast" - -for file -do - $sgmls -c cap/$file $file >out/$file 2>err/$file - test -f cap/$file || touch cap/$file - $rast rast/$file -done diff --git a/cde/programs/dtdocbook/sgmls/test/RUN b/cde/programs/dtdocbook/sgmls/test/RUN deleted file mode 100755 index db8aac228..000000000 --- a/cde/programs/dtdocbook/sgmls/test/RUN +++ /dev/null @@ -1,50 +0,0 @@ -#! /bin/sh - -unset SGML_PATH -sgmls="../sgmls -gerdu" -rast="../rast" - -for d in badout difout baderr diferr badcap difcap badrast difrast -do - rm -fr $d/* - test -d $d || mkdir $d -done - -if diff -c /dev/null /dev/null >/dev/null 2>&1 -then - c=-c -else - c= -fi - -for file in *.sgm -do - echo $file - $sgmls -c badcap/$file $file >badout/$file 2>baderr/$file - $rast badrast/$file - if diff $c out/$file badout/$file >difout/$file - then - rm badout/$file difout/$file - else - echo outputs for $file differ - fi - if diff $c err/$file baderr/$file >diferr/$file - then - rm baderr/$file diferr/$file - else - echo errors for $file differ - fi - test -f badcap/$file || touch badcap/$file - if diff $c cap/$file badcap/$file >difcap/$file - then - rm badcap/$file difcap/$file - else - echo capacities for $file differ - fi - if diff $c rast/$file badrast/$file >difrast/$file - then - rm badrast/$file difrast/$file - else - echo RAST result for $file differs - fi -done diff --git a/cde/programs/dtdocbook/sgmls/test/ambig.sgm b/cde/programs/dtdocbook/sgmls/test/ambig.sgm deleted file mode 100644 index 3dec6fcb0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/ambig.sgm +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/basicdoc.sgm b/cde/programs/dtdocbook/sgmls/test/basicdoc.sgm deleted file mode 100644 index e4899b2e4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/basicdoc.sgm +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cde/programs/dtdocbook/sgmls/test/cap/ambig.sgm b/cde/programs/dtdocbook/sgmls/test/cap/ambig.sgm deleted file mode 100644 index 5645556bc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/ambig.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1573 -ENTCAP 8 -ENTCHCAP 53 -ELEMCAP 344 -GRPCAP 1168 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/basicdoc.sgm b/cde/programs/dtdocbook/sgmls/test/cap/basicdoc.sgm deleted file mode 100644 index 5be4ddcfe..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/basicdoc.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 9672 -ENTCAP 176 -ENTCHCAP 437 -ELEMCAP 832 -GRPCAP 5024 -EXGRPCAP 112 -EXNMCAP 448 -ATTCAP 1320 -ATTCHCAP 299 -AVGRPCAP 232 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 792 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/comment.sgm b/cde/programs/dtdocbook/sgmls/test/cap/comment.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/conref.sgm b/cde/programs/dtdocbook/sgmls/test/cap/conref.sgm deleted file mode 100644 index f4766a4d9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/conref.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 32 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/default.sgm b/cde/programs/dtdocbook/sgmls/test/cap/default.sgm deleted file mode 100644 index 3fa5f1bdc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/default.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 62 -ENTCAP 16 -ENTCHCAP 10 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 4 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/endless.sgm b/cde/programs/dtdocbook/sgmls/test/cap/endless.sgm deleted file mode 100644 index 0efcc1af4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/endless.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 40 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 24 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/errexit.sgm b/cde/programs/dtdocbook/sgmls/test/cap/errexit.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/esis.sgm b/cde/programs/dtdocbook/sgmls/test/cap/esis.sgm deleted file mode 100644 index bac0afb83..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/esis.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1785 -ENTCAP 120 -ENTCHCAP 94 -ELEMCAP 136 -GRPCAP 160 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 192 -ATTCHCAP 69 -AVGRPCAP 72 -NOTCAP 32 -NOTCHCAP 62 -IDCAP 24 -IDREFCAP 32 -MAPCAP 792 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/exdtd.sgm b/cde/programs/dtdocbook/sgmls/test/cap/exdtd.sgm deleted file mode 100644 index 3a275b24f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/exdtd.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 63 -ENTCAP 24 -ENTCHCAP 9 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 6 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/grplvl.sgm b/cde/programs/dtdocbook/sgmls/test/cap/grplvl.sgm deleted file mode 100644 index 4dd1497ad..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/grplvl.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 2032 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 2024 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/idref.sgm b/cde/programs/dtdocbook/sgmls/test/cap/idref.sgm deleted file mode 100644 index 246bfd831..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/idref.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 96 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 24 -IDREFCAP 32 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/intent.sgm b/cde/programs/dtdocbook/sgmls/test/cap/intent.sgm deleted file mode 100644 index 70c3b4cc1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/intent.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 144 -ENTCAP 40 -ENTCHCAP 88 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/memo.sgm b/cde/programs/dtdocbook/sgmls/test/cap/memo.sgm deleted file mode 100644 index 56078c4b3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/memo.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1200 -ENTCAP 64 -ENTCHCAP 22 -ELEMCAP 120 -GRPCAP 144 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 26 -AVGRPCAP 16 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 792 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/memo2.sgm b/cde/programs/dtdocbook/sgmls/test/cap/memo2.sgm deleted file mode 100644 index 621257e10..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/memo2.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1208 -ENTCAP 72 -ENTCHCAP 22 -ELEMCAP 120 -GRPCAP 144 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 26 -AVGRPCAP 16 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 792 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/names.sgm b/cde/programs/dtdocbook/sgmls/test/cap/names.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/names.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/nonsgml.sgm b/cde/programs/dtdocbook/sgmls/test/cap/nonsgml.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/nonsgml.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/pubes.sgm b/cde/programs/dtdocbook/sgmls/test/cap/pubes.sgm deleted file mode 100644 index 6e40c3d64..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/pubes.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 208 -ENTCAP 40 -ENTCHCAP 160 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/sgmldecl.sgm b/cde/programs/dtdocbook/sgmls/test/cap/sgmldecl.sgm deleted file mode 100644 index 5117f621e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/sgmldecl.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 112 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 96 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/subdoc.sgm b/cde/programs/dtdocbook/sgmls/test/cap/subdoc.sgm deleted file mode 100644 index 0964f60e4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/subdoc.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1224 -ENTCAP 72 -ENTCHCAP 30 -ELEMCAP 128 -GRPCAP 144 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 26 -AVGRPCAP 16 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 792 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test001.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test001.sgm deleted file mode 100644 index cbddc2a73..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test001.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 192 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 80 -GRPCAP 112 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test002.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test002.sgm deleted file mode 100644 index 3601148ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test002.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 690 -ENTCAP 208 -ENTCHCAP 362 -ELEMCAP 40 -GRPCAP 64 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test003.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test003.sgm deleted file mode 100644 index e5355c674..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test003.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 736 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 184 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 240 -ATTCHCAP 101 -AVGRPCAP 120 -NOTCAP 16 -NOTCHCAP 58 -IDCAP 8 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test004.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test004.sgm deleted file mode 100644 index 194469036..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test004.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 42 -ENTCAP 8 -ENTCHCAP 10 -ELEMCAP 8 -GRPCAP 16 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test005.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test005.sgm deleted file mode 100644 index 0ef489fa7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test005.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 144 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 64 -GRPCAP 80 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test006.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test006.sgm deleted file mode 100644 index 57bdf9515..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test006.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1806 -ENTCAP 64 -ENTCHCAP 38 -ELEMCAP 40 -GRPCAP 64 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 1584 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test007.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test007.sgm deleted file mode 100644 index 4bef2d33d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test007.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 88 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 40 -GRPCAP 48 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test008.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test008.sgm deleted file mode 100644 index 332c7db83..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test008.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 184 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 56 -GRPCAP 56 -EXGRPCAP 32 -EXNMCAP 40 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test009.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test009.sgm deleted file mode 100644 index 4e160b3f5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test009.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1456 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 1384 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 40 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test010.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test010.sgm deleted file mode 100644 index 6cdc91726..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test010.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 130 -ENTCAP 32 -ENTCHCAP 32 -ELEMCAP 16 -GRPCAP 16 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 10 -AVGRPCAP 8 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test011.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test011.sgm deleted file mode 100644 index 38c1263ee..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test011.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 72 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 24 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test012.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test012.sgm deleted file mode 100644 index 018d8433d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test012.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 226 -ENTCAP 24 -ENTCHCAP 20 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 80 -ATTCHCAP 72 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 14 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test013.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test013.sgm deleted file mode 100644 index 19baa82b5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test013.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 298 -ENTCAP 16 -ENTCHCAP 10 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 264 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test014.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test014.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test014.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test015.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test015.sgm deleted file mode 100644 index 6ab81df81..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test015.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 27 -ENTCAP 8 -ENTCHCAP 3 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test016.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test016.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test016.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test017.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test017.sgm deleted file mode 100644 index 8c9c8b893..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test017.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 48 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 24 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test018.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test018.sgm deleted file mode 100644 index 4ee99337e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test018.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 51 -ENTCAP 16 -ENTCHCAP 8 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 3 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test019.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test019.sgm deleted file mode 100644 index b8b650c78..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test019.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 58 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 10 -AVGRPCAP 16 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test020.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test020.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test020.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test021.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test021.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test022.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test022.sgm deleted file mode 100644 index 36204f908..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test022.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 18 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test023.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test023.sgm deleted file mode 100644 index dbfcc75d0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test023.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 294 -ENTCAP 8 -ENTCHCAP 14 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 264 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test024.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test024.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test024.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test025.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test025.sgm deleted file mode 100644 index 8709797f6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test025.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 56 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 16 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test026.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test026.sgm deleted file mode 100644 index c6a470905..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test026.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 72 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 40 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test027.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test027.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test027.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test028.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test028.sgm deleted file mode 100644 index e7d18ac1f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test028.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 1023 -ENTCAP 8 -ENTCHCAP 47 -ELEMCAP 192 -GRPCAP 776 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test029.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test029.sgm deleted file mode 100644 index 4f89f64f9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test029.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 83 -ENTCAP 8 -ENTCHCAP 11 -ELEMCAP 32 -GRPCAP 32 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test030.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test030.sgm deleted file mode 100644 index b6a9050d2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test030.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 48 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 40 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test031.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test031.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test031.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test032.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test032.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test032.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test033.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test033.sgm deleted file mode 100644 index 626ef42fc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test033.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 756 -ENTCAP 32 -ENTCHCAP 708 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test034.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test034.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test034.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test035.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test035.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test035.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test036.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test036.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test036.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test037.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test037.sgm deleted file mode 100644 index 5084f8a4d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test037.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 280 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 264 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test038.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test038.sgm deleted file mode 100644 index e375c235d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test038.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 200 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 96 -GRPCAP 104 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test039.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test039.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test039.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test040.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test040.sgm deleted file mode 100644 index 706d6fb8e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test040.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 104 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 40 -GRPCAP 48 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test041.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test041.sgm deleted file mode 100644 index a4c5b97f2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test041.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 42 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 16 -GRPCAP 16 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test042.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test042.sgm deleted file mode 100644 index 1f73b0546..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test042.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 26 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test043.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test043.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test043.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test044.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test044.sgm deleted file mode 100644 index 9165843c5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test044.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 64 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 24 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test045.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test045.sgm deleted file mode 100644 index b2fd2062a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test045.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 80 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 32 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test046.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test046.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test046.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test047.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test047.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test047.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test048.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test048.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test048.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test049.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test049.sgm deleted file mode 100644 index faa71fcaa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test049.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test050.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test050.sgm deleted file mode 100644 index 9165843c5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test050.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 64 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 24 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test051.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test051.sgm deleted file mode 100644 index e249c3d84..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test051.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 56 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 32 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test052.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test052.sgm deleted file mode 100644 index 0efcc1af4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test052.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 40 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 24 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test053.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test053.sgm deleted file mode 100644 index 60720eff4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test053.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 72 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 32 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test054.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test054.sgm deleted file mode 100644 index 9165843c5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test054.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 64 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 24 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test055.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test055.sgm deleted file mode 100644 index 12e61fe8d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test055.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 120 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 40 -GRPCAP 56 -EXGRPCAP 8 -EXNMCAP 16 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test056.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test056.sgm deleted file mode 100644 index 45f54a0c0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test056.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 88 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 40 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test057.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test057.sgm deleted file mode 100644 index 9165843c5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test057.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 64 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 24 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test058.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test058.sgm deleted file mode 100644 index cd04025fa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test058.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 49 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test059.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test059.sgm deleted file mode 100644 index f73a20174..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test059.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 25 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test060.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test060.sgm deleted file mode 100644 index faa71fcaa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test060.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test061.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test061.sgm deleted file mode 100644 index cd04025fa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test061.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 49 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test062.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test062.sgm deleted file mode 100644 index a16197db0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test062.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 78 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 5 -AVGRPCAP 24 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test063.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test063.sgm deleted file mode 100644 index 00fb07c6e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test063.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 39 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 5 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test064.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test064.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test064.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test065.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test065.sgm deleted file mode 100644 index e26106175..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test065.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 0 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 0 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test066.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test066.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test066.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test067.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test067.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test067.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test068.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test068.sgm deleted file mode 100644 index 9d3947a18..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test068.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test069.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test069.sgm deleted file mode 100644 index baecb1ceb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test069.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 45 -ENTCAP 8 -ENTCHCAP 21 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test070.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test070.sgm deleted file mode 100644 index c80369007..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test070.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 44 -ENTCAP 8 -ENTCHCAP 20 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test071.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test071.sgm deleted file mode 100644 index baecb1ceb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test071.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 45 -ENTCAP 8 -ENTCHCAP 21 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test072.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test072.sgm deleted file mode 100644 index 69c74fc0e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test072.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 64 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 32 -GRPCAP 32 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test073.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test073.sgm deleted file mode 100644 index 85baef57a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test073.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test074.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test074.sgm deleted file mode 100644 index 4247eaebd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test074.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 8 -ENTCHCAP 12 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test075.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test075.sgm deleted file mode 100644 index a88a460c9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test075.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 32 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 16 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test076.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test076.sgm deleted file mode 100644 index 73a2e3c9a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test076.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 32 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 0 -EXGRPCAP 8 -EXNMCAP 8 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test077.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test077.sgm deleted file mode 100644 index 6ab81df81..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test077.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 27 -ENTCAP 8 -ENTCHCAP 3 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test078.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test078.sgm deleted file mode 100644 index 69738a0ee..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test078.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 19 -ENTCAP 8 -ENTCHCAP 3 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test079.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test079.sgm deleted file mode 100644 index 842c1d97e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test079.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 16 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test080.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test080.sgm deleted file mode 100644 index 842c1d97e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test080.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 16 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test081.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test081.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test081.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test082.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test082.sgm deleted file mode 100644 index 505b5b526..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test082.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 264 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 240 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test083.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test083.sgm deleted file mode 100644 index c13fede82..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test083.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 382 -ENTCAP 24 -ENTCHCAP 350 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test084.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test084.sgm deleted file mode 100644 index b88ff3771..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test084.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 8 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test085.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test085.sgm deleted file mode 100644 index 99e248b42..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test085.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 20 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test086.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test086.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test086.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test087.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test087.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test087.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test088.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test088.sgm deleted file mode 100644 index 407a401ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test088.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test089.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test089.sgm deleted file mode 100644 index 36204f908..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test089.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 18 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test090.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test090.sgm deleted file mode 100644 index b88ff3771..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test090.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 8 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test091.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test091.sgm deleted file mode 100644 index f6be6a3ec..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test091.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 21 -ENTCAP 8 -ENTCHCAP 5 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test092.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test092.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test092.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test093.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test093.sgm deleted file mode 100644 index 842c1d97e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test093.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 16 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test094.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test094.sgm deleted file mode 100644 index 60faafb10..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test094.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 8 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test095.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test095.sgm deleted file mode 100644 index 47b99080d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test095.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 34 -ENTCAP 8 -ENTCHCAP 10 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test096.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test096.sgm deleted file mode 100644 index 07a1ad7b8..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test096.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 36 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 12 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test097.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test097.sgm deleted file mode 100644 index cfe5c2f23..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test097.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 53 -ENTCAP 24 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 3 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test098.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test098.sgm deleted file mode 100644 index 1cd53c8a4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test098.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 48 -ENTCAP 16 -ENTCHCAP 16 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test099.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test099.sgm deleted file mode 100644 index 0f29ee383..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test099.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 35 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 3 -AVGRPCAP 16 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test100.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test100.sgm deleted file mode 100644 index 8564bb913..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test100.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 20 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 4 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test101.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test101.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test101.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test102.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test102.sgm deleted file mode 100644 index d977348ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test102.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 103 -ENTCAP 24 -ENTCHCAP 18 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 16 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 13 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test103.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test103.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test103.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test104.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test104.sgm deleted file mode 100644 index c310ae8cb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test104.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 34 -ENTCAP 16 -ENTCHCAP 10 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test105.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test105.sgm deleted file mode 100644 index bcb19daa9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test105.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 32 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 24 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test106.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test106.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test106.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test107.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test107.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test107.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test108.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test108.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test108.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test109.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test109.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test109.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test110.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test110.sgm deleted file mode 100644 index 36204f908..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test110.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 18 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test111.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test111.sgm deleted file mode 100644 index f9fa32f82..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test111.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 47 -ENTCAP 16 -ENTCHCAP 15 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test112.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test112.sgm deleted file mode 100644 index 36204f908..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test112.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 18 -ENTCAP 8 -ENTCHCAP 2 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test113.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test113.sgm deleted file mode 100644 index f6be6a3ec..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test113.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 21 -ENTCAP 8 -ENTCHCAP 5 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test114.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test114.sgm deleted file mode 100644 index e68caffeb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test114.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 30 -ENTCAP 16 -ENTCHCAP 6 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test115.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test115.sgm deleted file mode 100644 index b88ff3771..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test115.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 8 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test116.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test116.sgm deleted file mode 100644 index 51f1efd11..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test116.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 8 -ENTCHCAP 8 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test117.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test117.sgm deleted file mode 100644 index 85baef57a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test117.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test118.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test118.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test119.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test119.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test119.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test120.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test120.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test120.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test121.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test121.sgm deleted file mode 100644 index 4dd9c37ed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test121.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test122.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test122.sgm deleted file mode 100644 index 85baef57a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test122.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test123.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test123.sgm deleted file mode 100644 index f1bfa6b2e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test123.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 16 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 16 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test124.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test124.sgm deleted file mode 100644 index 7211d634a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test124.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 23 -ENTCAP 8 -ENTCHCAP 7 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test125.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test125.sgm deleted file mode 100644 index 7211d634a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test125.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 23 -ENTCAP 8 -ENTCHCAP 7 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test126.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test126.sgm deleted file mode 100644 index ed1a26d0f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test126.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test127.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test127.sgm deleted file mode 100644 index 0b9a87fbd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test127.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 36 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test128.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test128.sgm deleted file mode 100644 index ed1a26d0f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test128.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 28 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test129.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test129.sgm deleted file mode 100644 index 0b9a87fbd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test129.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 36 -ENTCAP 8 -ENTCHCAP 4 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test130.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test130.sgm deleted file mode 100644 index 0ce96cf38..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test130.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 291 -ENTCAP 8 -ENTCHCAP 3 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 264 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test131.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test131.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test131.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test132.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test132.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test132.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test133.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test133.sgm deleted file mode 100644 index ca85a65d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test133.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 88 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 24 -GRPCAP 32 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 8 -IDREFCAP 8 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test134.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test134.sgm deleted file mode 100644 index faa71fcaa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test134.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 24 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 8 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test135.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test135.sgm deleted file mode 100644 index ad8a44553..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test135.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 8 -ENTCAP 0 -ENTCHCAP 0 -ELEMCAP 8 -GRPCAP 0 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 0 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 0 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/cap/test136.sgm b/cde/programs/dtdocbook/sgmls/test/cap/test136.sgm deleted file mode 100644 index cd04025fa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/cap/test136.sgm +++ /dev/null @@ -1,17 +0,0 @@ -TOTALCAP 49 -ENTCAP 8 -ENTCHCAP 1 -ELEMCAP 8 -GRPCAP 8 -EXGRPCAP 0 -EXNMCAP 0 -ATTCAP 16 -ATTCHCAP 0 -AVGRPCAP 0 -NOTCAP 8 -NOTCHCAP 0 -IDCAP 0 -IDREFCAP 0 -MAPCAP 0 -LKSETCAP 0 -LKNMCAP 0 diff --git a/cde/programs/dtdocbook/sgmls/test/comment.sgm b/cde/programs/dtdocbook/sgmls/test/comment.sgm deleted file mode 100644 index 196a873f5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/comment.sgm +++ /dev/null @@ -1 +0,0 @@ - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/default.sgm b/cde/programs/dtdocbook/sgmls/test/default.sgm deleted file mode 100644 index e5d82b07d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/default.sgm +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -]> -&j1;&j2;&j1; diff --git a/cde/programs/dtdocbook/sgmls/test/endless.sgm b/cde/programs/dtdocbook/sgmls/test/endless.sgm deleted file mode 100644 index b1fb3b1a4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/endless.sgm +++ /dev/null @@ -1,5 +0,0 @@ - - -]> -data diff --git a/cde/programs/dtdocbook/sgmls/test/err/ambig.sgm b/cde/programs/dtdocbook/sgmls/test/err/ambig.sgm deleted file mode 100644 index 18a62fd7b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/ambig.sgm +++ /dev/null @@ -1,18 +0,0 @@ -sgmls: SGML error at ambig.sgm, line 3 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 4 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 6 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 9 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 10 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 12 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 13 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 14 in declaration parameter 4: - Content model is ambiguous -sgmls: SGML error at ambig.sgm, line 15 in declaration parameter 4: - Content model is ambiguous diff --git a/cde/programs/dtdocbook/sgmls/test/err/basicdoc.sgm b/cde/programs/dtdocbook/sgmls/test/err/basicdoc.sgm deleted file mode 100644 index ef6b286aa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/basicdoc.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: In file included at basicdoc.sgm, line 1: - SGML error at ibm$bas.dtd, line 77 in declaration parameter 98: - More than ATTCNT attribute names and/or name (token) values; terminated -sgmls: In file included at basicdoc.sgm, line 1: - SGML error at ibm$bas.dtd, line 79 at "<": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: SGML error at basicdoc.sgm, line 1 at record end: - Document ended invalidly within prolog; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/comment.sgm b/cde/programs/dtdocbook/sgmls/test/err/comment.sgm deleted file mode 100644 index 542d6638e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/comment.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at comment.sgm, line 1 at end of file: - Illegal entity end in markup or delimited text -sgmls: SGML error at comment.sgm, line 1 at record end: - Document ended invalidly within a markup declaration; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/conref.sgm b/cde/programs/dtdocbook/sgmls/test/err/conref.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/default.sgm b/cde/programs/dtdocbook/sgmls/test/err/default.sgm deleted file mode 100644 index ff0a01fe6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/default.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: SGML error at default.sgm, line 4 in declaration parameter 6: - Formal public identifier "pubis" invalid; treated as informal -sgmls: Error at default.sgm, line 8 at ";": - Could not find entity "j1" using default declaration - Element structure: DFLT -sgmls: Error at default.sgm, line 8 at ";": - Could not find entity "j1" using default declaration - Element structure: DFLT diff --git a/cde/programs/dtdocbook/sgmls/test/err/endless.sgm b/cde/programs/dtdocbook/sgmls/test/err/endless.sgm deleted file mode 100644 index aacda4b6c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/endless.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at endless.sgm, line 5 at record end: - ENDLESS end-tag implied by *DOC end-tag; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/errexit.sgm b/cde/programs/dtdocbook/sgmls/test/err/errexit.sgm deleted file mode 100644 index 9c3844798..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/errexit.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at errexit.sgm, line 2 at record end: - Document ended invalidly within a literal; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/esis.sgm b/cde/programs/dtdocbook/sgmls/test/err/esis.sgm deleted file mode 100644 index 3a7c43e2c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/esis.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: Warning at memo.sgm, line 4 at ";": - No declaration for entity "Eckhardt"; default definition used - Element structure: MEMO PROLOG diff --git a/cde/programs/dtdocbook/sgmls/test/err/exdtd.sgm b/cde/programs/dtdocbook/sgmls/test/err/exdtd.sgm deleted file mode 100644 index 29a4fea7b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/exdtd.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at exdtd.sgm, line 2 at record start: - Element "JUNK" used in DTD but not defined diff --git a/cde/programs/dtdocbook/sgmls/test/err/grplvl.sgm b/cde/programs/dtdocbook/sgmls/test/err/grplvl.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/idref.sgm b/cde/programs/dtdocbook/sgmls/test/err/idref.sgm deleted file mode 100644 index cb303e74f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/idref.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at idref.sgm, line 17 at "z": - IDREF = "Z" IDREF attribute ignored: referenced ID does not exist - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/intent.sgm b/cde/programs/dtdocbook/sgmls/test/err/intent.sgm deleted file mode 100644 index 112fffb48..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/intent.sgm +++ /dev/null @@ -1,5 +0,0 @@ -sgmls: In file included at intent.sgm, line 11 at entity e3, line 1: - In file included at intent1.gml, line 2: - SGML error at intent2.gml, line 1 at record end: - No declaration for entity "e2."; reference ignored - Element structure: GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/memo.sgm b/cde/programs/dtdocbook/sgmls/test/err/memo.sgm deleted file mode 100644 index 3a7c43e2c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/memo.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: Warning at memo.sgm, line 4 at ";": - No declaration for entity "Eckhardt"; default definition used - Element structure: MEMO PROLOG diff --git a/cde/programs/dtdocbook/sgmls/test/err/memo2.sgm b/cde/programs/dtdocbook/sgmls/test/err/memo2.sgm deleted file mode 100644 index 9470c326d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/memo2.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: Warning at memo2.sgm, line 4 at record end: - No declaration for entity "Eckhardt"; default definition used - Element structure: MEMO2 PROLOG diff --git a/cde/programs/dtdocbook/sgmls/test/err/names.sgm b/cde/programs/dtdocbook/sgmls/test/err/names.sgm deleted file mode 100644 index 403781213..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/names.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at names.sgm, line 39 in declaration parameter 120: - Replacement reserved name "ATTLIST" cannot be reference reserved name -sgmls: SGML error at names.sgm, line 40 in declaration parameter 122: - Duplicate replacement reserved name "DOC.TYPE" diff --git a/cde/programs/dtdocbook/sgmls/test/err/nonsgml.sgm b/cde/programs/dtdocbook/sgmls/test/err/nonsgml.sgm deleted file mode 100644 index c7cfdf097..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/nonsgml.sgm +++ /dev/null @@ -1,93 +0,0 @@ -sgmls: SGML error at nonsgml.sgm, line 6 at "\000": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\001": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\002": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\003": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\004": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\005": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\006": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\007": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\010": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\013": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\014": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\016": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\017": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\020": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\021": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\022": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\023": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\024": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\025": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\026": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\027": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\030": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\031": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\032": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\033": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\034": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\035": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\036": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\037": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\177": - Non-SGML character found; should have been character reference - Element structure: DOC -sgmls: SGML error at nonsgml.sgm, line 6 at "\377": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/pubes.sgm b/cde/programs/dtdocbook/sgmls/test/err/pubes.sgm deleted file mode 100644 index 9610350e2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/pubes.sgm +++ /dev/null @@ -1,14 +0,0 @@ -sgmls: SGML error at pubes.sgm, line 7 in declaration parameter 4: - Formal public identifier "public ID on 3 lines -- not formal --" invalid; treated as informal -sgmls: Warning at pubes.sgm, line 7 in declaration parameter 4: - Could not find external general entity "a" -sgmls: Warning at pubes.sgm, line 9 in declaration parameter 4: - Could not find external general entity "b" -sgmls: Warning at pubes.sgm, line 10 in declaration parameter 4: - Could not find external general entity "c" -sgmls: Warning at pubes.sgm, line 11 in declaration parameter 4: - Could not find external general entity "d" -sgmls: SGML error at pubes.sgm, line 13 in declaration parameter 4: - Formal public identifier "+//Owner//entities Text name//EN" invalid; treated as informal -sgmls: Warning at pubes.sgm, line 13 in declaration parameter 4: - Could not find external general entity "e" diff --git a/cde/programs/dtdocbook/sgmls/test/err/sgmldecl.sgm b/cde/programs/dtdocbook/sgmls/test/err/sgmldecl.sgm deleted file mode 100644 index ffa18f896..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/sgmldecl.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at sgmldecl.sgm, line 20 in declaration parameter 28: - Invalid formal public identifier diff --git a/cde/programs/dtdocbook/sgmls/test/err/subdoc.sgm b/cde/programs/dtdocbook/sgmls/test/err/subdoc.sgm deleted file mode 100644 index 3a7c43e2c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/subdoc.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: Warning at memo.sgm, line 4 at ";": - No declaration for entity "Eckhardt"; default definition used - Element structure: MEMO PROLOG diff --git a/cde/programs/dtdocbook/sgmls/test/err/test001.sgm b/cde/programs/dtdocbook/sgmls/test/err/test001.sgm deleted file mode 100644 index 0340a3bb8..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test001.sgm +++ /dev/null @@ -1,48 +0,0 @@ -sgmls: Warning at test001.sgm, line 6 in declaration parameter 4: - End-tag minimization should be "O" for EMPTY element -sgmls: Warning at test001.sgm, line 11 at record start: - Element "TAG" used in DTD but not defined -sgmls: Warning at test001.sgm, line 11 at record start: - Element "MANY" used in DTD but not defined -sgmls: SGML error at test001.sgm, line 14 at ";": - No declaration for entity "entity"; reference ignored - Element structure: GDOC BODY P -sgmls: SGML error at test001.sgm, line 16 at "d": - BAD markup declaration not permitted here; declaration ended - Element structure: GDOC BODY P -sgmls: SGML error at test001.sgm, line 26 at ".": - No declaration for entity "en."; reference ignored - Element structure: GDOC BODY P -sgmls: SGML error at test001.sgm, line 34 at "A": - Length of name, number, or token exceeded NAMELEN or LITLEN limit - Element structure: GDOC BODY -sgmls: SGML error at test001.sgm, line 34 at "B": - Length of name, number, or token exceeded NAMELEN or LITLEN limit - Element structure: GDOC BODY -sgmls: SGML error at test001.sgm, line 34 at "C": - Length of name, number, or token exceeded NAMELEN or LITLEN limit - Element structure: GDOC BODY -sgmls: SGML error at test001.sgm, line 34 at "D": - Length of name, number, or token exceeded NAMELEN or LITLEN limit - Element structure: GDOC BODY -sgmls: SGML error at test001.sgm, line 34 at "E": - Length of name, number, or token exceeded NAMELEN or LITLEN limit - Element structure: GDOC BODY -sgmls: SGML error at test001.sgm, line 35 at "w": - Possible attributes treated as data because none were defined - Element structure: GDOC BODY TAGISBIG -sgmls: SGML error at test001.sgm, line 35 at " ": - Undefined MANY start-tag GI was used in DTD; "MANY O O ANY" assumed - Element structure: GDOC BODY TAGISBIG -sgmls: SGML error at test001.sgm, line 36 at "#": - Incorrect character in markup; markup terminated - Element structure: GDOC BODY TAGISBIG MANY -sgmls: SGML error at test001.sgm, line 36 at "g": - Undefined TAG start-tag GI was used in DTD; "TAG O O ANY" assumed - Element structure: GDOC BODY TAGISBIG MANY -sgmls: SGML error at test001.sgm, line 36 at ">": - TAGISBIG element ended prematurely; required TAG omitted - Element structure: GDOC BODY TAGISBIG -sgmls: SGML error at test001.sgm, line 36 at ">": - T1 end-tag ignored: doesn't end any open element (current is BODY) - Element structure: GDOC BODY diff --git a/cde/programs/dtdocbook/sgmls/test/err/test002.sgm b/cde/programs/dtdocbook/sgmls/test/err/test002.sgm deleted file mode 100644 index 7bf4faa98..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test002.sgm +++ /dev/null @@ -1,47 +0,0 @@ -sgmls: Warning at test002.sgm, line 13 in declaration parameter 3: - Duplicate specification occurred for "e2"; duplicate ignored -sgmls: Warning at test002.sgm, line 15 in declaration parameter 3: - Could not find external general entity "phoney" -sgmls: SGML error at test002.sgm, line 21 at ";": - No declaration for entity "%dummy"; reference ignored -sgmls: SGML error at test002.sgm, line 29 at entity %e8, line 1 at end of entity: - Illegal entity end in markup or delimited text -sgmls: SGML error at test002.sgm, line 29 at ";": - Entity nesting level out of sync -sgmls: Warning at test002.sgm, line 31 in declaration parameter 3: - Could not find external general entity "g1" -sgmls: Warning at test002.sgm, line 32 in declaration parameter 4: - Could not find external parameter entity "g2" -sgmls: SGML error at test002.sgm, line 33 in declaration parameter 4: - Formal public identifier "public name" invalid; treated as informal -sgmls: Warning at test002.sgm, line 33 in declaration parameter 4: - Could not find external general entity "g4" -sgmls: Warning at test002.sgm, line 34 in declaration parameter 5: - Could not find external parameter entity "g5" -sgmls: SGML error at test002.sgm, line 37 in declaration parameter 5: - Formal public identifier "public name" invalid; treated as informal -sgmls: SGML error at test002.sgm, line 38 in declaration parameter 6: - Formal public identifier "public name" invalid; treated as informal -sgmls: SGML error at test002.sgm, line 42 at "\003": - Non-SGML character found; should have been character reference - Element structure: GDOC T1 -sgmls: SGML error at test002.sgm, line 44 at "a": - Possible attributes treated as data because none were defined - Element structure: GDOC T1 -sgmls: In file included at test002.sgm, line 46: - SGML error at test2e.gml, line 4 at ";": - No declaration for entity "fake"; reference ignored - Element structure: GDOC -sgmls: Error at test002.sgm, line 47 at record end: - Reference to non-existent general entity "phoney" ignored - Element structure: GDOC TAG1 -sgmls: In file included at test002.sgm, line 51: - SGML error at test2x.gml, line 1 at ";": - x entity reference occurred within own text; reference ignored - Element structure: GDOC TAG1 -sgmls: SGML error at test002.sgm, line 52 at ";": - Invalid alphabetic character reference ignored - Element structure: GDOC TAG1 -sgmls: SGML error at test002.sgm, line 53 at ";": - Numeric character reference exceeds 255; reference ignored - Element structure: GDOC TAG1 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test003.sgm b/cde/programs/dtdocbook/sgmls/test/err/test003.sgm deleted file mode 100644 index 1dc29b259..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test003.sgm +++ /dev/null @@ -1,43 +0,0 @@ -sgmls: SGML error at test003.sgm, line 5 in declaration parameter 4: - Duplicate specification occurred for "DCN2"; duplicate ignored -sgmls: SGML error at test003.sgm, line 9 in declaration parameter 4: - ID attribute ATT1 cannot have a default value; treated as #IMPLIED -sgmls: SGML error at test003.sgm, line 9 in declaration parameter 6: - ATT2 definition ignored: ID attribute already defined -sgmls: SGML error at test003.sgm, line 9 in declaration parameter 7: - ID attribute ATT2 cannot have a default value; treated as #IMPLIED -sgmls: SGML error at test003.sgm, line 28 at "e": - No declaration for entity "name"; reference ignored -sgmls: Warning at test003.sgm, line 35 in declaration parameter 0: - End-tag minimization should be "O" for element with CONREF attribute -sgmls: SGML error at test003.sgm, line 49 in declaration parameter 10: - Group token 1: duplicate name or name token "1" ignored -sgmls: SGML error at test003.sgm, line 50 in declaration parameter 12: - Attempt to redefine ATT2 attribute ignored -sgmls: SGML error at test003.sgm, line 56 at """: - ATT1 = "" attribute defaulted: empty string not allowed for token - Element structure: TAG1 -sgmls: SGML error at test003.sgm, line 56 at "3": - ATT1 = "3" attribute ignored: previously specified in same list - Element structure: TAG1 -sgmls: SGML error at test003.sgm, line 58 at "2": - ATT2 = "val2" attribute ignored: previously specified in same list - Element structure: TAG1 DTAG1 DTAG2 -sgmls: SGML error at test003.sgm, line 60 at "2": - ATT2 = "val2" attribute ignored: not defined for this element - Element structure: TAG1 -sgmls: SGML error at test003.sgm, line 62 at """: - ATT1 = "value 1" attribute value defaulted: too many tokens - Element structure: TAG1 -sgmls: SGML error at test003.sgm, line 63 at """: - ATT2 = "value 2" attribute ignored: not defined for this element - Element structure: TAG1 -sgmls: SGML error at test003.sgm, line 64 at "m": - Possible attributes treated as data because none were defined - Element structure: TAG1 TAG3 -sgmls: SGML error at test003.sgm, line 74 at """: - ATT4 = "value 4 here" attribute value defaulted: wrong token type - Element structure: TAG1 TAG3 -sgmls: SGML error at test003.sgm, line 79 at "m": - Possible attributes treated as data because none were defined - Element structure: TAG1 TAG3 TAG7 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test004.sgm b/cde/programs/dtdocbook/sgmls/test/err/test004.sgm deleted file mode 100644 index d530626e5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test004.sgm +++ /dev/null @@ -1,17 +0,0 @@ -sgmls: Warning at test004.sgm, line 7 at record start: - Element "T" used in DTD but not defined -sgmls: SGML error at test004.sgm, line 8 at "K": - Keyword 1 ignored; "JUNK" is not a valid marked section keyword - Element structure: GDOC -sgmls: SGML error at test004.sgm, line 13 at "2": - Keyword 3 ignored; "MS2" is not a valid marked section keyword - Element structure: GDOC -sgmls: SGML error at test004.sgm, line 14 at "<": - Incorrect character in markup; markup terminated - Element structure: GDOC -sgmls: SGML error at test004.sgm, line 14 at "<": - DSO delimiter ([) omitted from marked section declaration - Element structure: GDOC -sgmls: SGML error at test004.sgm, line 22 at ">": - Marked section end ignored; not in a marked section - Element structure: GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test005.sgm b/cde/programs/dtdocbook/sgmls/test/err/test005.sgm deleted file mode 100644 index afefdd719..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test005.sgm +++ /dev/null @@ -1,47 +0,0 @@ -sgmls: Warning at test005.sgm, line 6 at record start: - Element "APPENDIX" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "REAR" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "T1" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "T2" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "T3" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "T4" used in DTD but not defined -sgmls: Warning at test005.sgm, line 6 at record start: - Element "FRONT" used in DTD but not defined -sgmls: SGML error at test005.sgm, line 6 at ">": - Undefined FRONT start-tag GI was used in DTD; "FRONT O O ANY" assumed - Element structure: GDOC -sgmls: SGML error at test005.sgm, line 7 at ">": - Undefined T2 start-tag GI was used in DTD; "T2 O O ANY" assumed - Element structure: GDOC BODY -sgmls: SGML error at test005.sgm, line 7 at ">": - Undefined T3 start-tag GI was used in DTD; "T3 O O ANY" assumed - Element structure: GDOC BODY -sgmls: SGML error at test005.sgm, line 7 at ">": - BODY element ended prematurely; required T4 omitted - Element structure: GDOC BODY -sgmls: SGML error at test005.sgm, line 8 at ">": - Undefined REAR start-tag GI was used in DTD; "REAR O O ANY" assumed - Element structure: GDOC -sgmls: SGML error at test005.sgm, line 9 at ">": - GDOC element not allowed at this point in *DOC element -sgmls: SGML error at test005.sgm, line 9 at ">": - Undefined APPENDIX start-tag GI was used in DTD; "APPENDIX O O ANY" assumed - Element structure: GDOC -sgmls: SGML error at test005.sgm, line 10 at ">": - GDOC element not allowed at this point in *DOC element -sgmls: SGML error at test005.sgm, line 10 at ">": - REAR element not allowed at this point in GDOC element - Element structure: GDOC -sgmls: SGML error at test005.sgm, line 10 at ">": - GDOC element ended prematurely; required subelement omitted - Element structure: GDOC -sgmls: SGML error at test005.sgm, line 11 at ">": - GDOC element not allowed at this point in *DOC element -sgmls: SGML error at test005.sgm, line 12 at ">": - Undefined T4 start-tag GI was used in DTD; "T4 O O ANY" assumed - Element structure: GDOC BODY diff --git a/cde/programs/dtdocbook/sgmls/test/err/test006.sgm b/cde/programs/dtdocbook/sgmls/test/err/test006.sgm deleted file mode 100644 index ec57a17d9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test006.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: SGML error at test006.sgm, line 11 in declaration parameter 5: - Duplicate specification occurred for "&#RE;"; duplicate ignored -sgmls: SGML error at test006.sgm, line 11 in declaration parameter 6: - MDC delimiter (>) expected; following text may be misinterpreted -sgmls: SGML error at test006.sgm, line 13 at "<": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: Warning at test006.sgm, line 28 in declaration parameter 3: - Duplicate specification occurred for "P"; duplicate ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test007.sgm b/cde/programs/dtdocbook/sgmls/test/err/test007.sgm deleted file mode 100644 index 5189f22eb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test007.sgm +++ /dev/null @@ -1,15 +0,0 @@ -sgmls: Warning at test007.sgm, line 5 in declaration parameter 4: - End-tag minimization should be "O" for EMPTY element -sgmls: SGML error at test007.sgm, line 8 at "/": - GDOC start-tag implied by BODY start-tag; not minimizable -sgmls: SGML error at test007.sgm, line 8 at " ": - H1 start-tag implied by data; not minimizable - Element structure: GDOC BODY -sgmls: SGML error at test007.sgm, line 8 at "/": - H1 end-tag implied by NET delimiter; not minimizable - Element structure: GDOC BODY -sgmls: SGML error at test007.sgm, line 8 at ".": - T1 start-tag implied by data; not minimizable - Element structure: GDOC -sgmls: SGML error at test007.sgm, line 8 at ".": - Out-of-context data ended GDOC document element (and parse) diff --git a/cde/programs/dtdocbook/sgmls/test/err/test008.sgm b/cde/programs/dtdocbook/sgmls/test/err/test008.sgm deleted file mode 100644 index f6c2dada2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test008.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: Warning at test008.sgm, line 8 at record start: - Element "X" used in DTD but not defined -sgmls: SGML error at test008.sgm, line 9 at ">": - Exclusion cannot apply to token "B" in content model for "CHAP" - Element structure: GDOC BODY CHAP -sgmls: SGML error at test008.sgm, line 9 at "/": - Undefined X start-tag GI was used in DTD; "X O O ANY" assumed - Element structure: GDOC BODY CHAP A diff --git a/cde/programs/dtdocbook/sgmls/test/err/test009.sgm b/cde/programs/dtdocbook/sgmls/test/err/test009.sgm deleted file mode 100644 index 785ee6a14..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test009.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: Warning at test009.sgm, line 27 at record start: - Element "A" used in DTD but not defined -sgmls: SGML error at test009.sgm, line 44 at ">": - Start-tag length exceeds TAGLEN limit; parsed correctly diff --git a/cde/programs/dtdocbook/sgmls/test/err/test010.sgm b/cde/programs/dtdocbook/sgmls/test/err/test010.sgm deleted file mode 100644 index 2ad1cc9d4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test010.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: SGML error at test010.sgm, line 7 at "3": - Reference to PI entity not permitted here; reference ignored -sgmls: SGML error at test010.sgm, line 7 at "3": - Reference to PI entity not permitted here; reference ignored -sgmls: SGML error at test010.sgm, line 7 at "3": - Reference to PI entity not permitted here; reference ignored -sgmls: SGML error at test010.sgm, line 8 at "3": - Reference to PI entity not permitted here; reference ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test011.sgm b/cde/programs/dtdocbook/sgmls/test/err/test011.sgm deleted file mode 100644 index 214c8c0ee..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test011.sgm +++ /dev/null @@ -1,19 +0,0 @@ -sgmls: Warning at test011.sgm, line 4 in declaration parameter 4: - Start-tag minimization should be "-" for element with declared content -sgmls: Warning at test011.sgm, line 6 in declaration parameter 4: - Start-tag minimization should be "-" for element with declared content -sgmls: SGML error at test011.sgm, line 9 at ">": - QT end-tag ignored: doesn't end any open element (current is RT) - Element structure: DOC RT -sgmls: SGML error at test011.sgm, line 9 at ">": - Bad end-tag in R/CDATA element; treated as short (no GI) end-tag - Element structure: DOC RT -sgmls: SGML error at test011.sgm, line 10 at ">": - RT end-tag ignored: doesn't end any open element (current is QT) - Element structure: DOC QT -sgmls: SGML error at test011.sgm, line 11 at ">": - No element declaration for X end-tag GI; end-tag ignored - Element structure: DOC CT -sgmls: SGML error at test011.sgm, line 11 at ">": - Bad end-tag in R/CDATA element; treated as short (no GI) end-tag - Element structure: DOC CT diff --git a/cde/programs/dtdocbook/sgmls/test/err/test012.sgm b/cde/programs/dtdocbook/sgmls/test/err/test012.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test013.sgm b/cde/programs/dtdocbook/sgmls/test/err/test013.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test014.sgm b/cde/programs/dtdocbook/sgmls/test/err/test014.sgm deleted file mode 100644 index 41d19e87d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test014.sgm +++ /dev/null @@ -1,5 +0,0 @@ -sgmls: Warning at test014.sgm, line 6 at record start: - Short reference map "MAP" used in DTD but not defined -sgmls: SGML error at test014.sgm, line 6 at ">": - Short reference map for element "DOC" not defined; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test015.sgm b/cde/programs/dtdocbook/sgmls/test/err/test015.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test016.sgm b/cde/programs/dtdocbook/sgmls/test/err/test016.sgm deleted file mode 100644 index ca2ce352b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test016.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test016.sgm, line 4 at "\002": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test017.sgm b/cde/programs/dtdocbook/sgmls/test/err/test017.sgm deleted file mode 100644 index 607cd0a58..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test017.sgm +++ /dev/null @@ -1,12 +0,0 @@ -sgmls: SGML error at test017.sgm, line 7 in declaration parameter 4: - Declared value of data attribute cannot be ENTITY or ENTITIES -sgmls: SGML error at test017.sgm, line 8 in declaration parameter 7: - Declared value of data attribute cannot be ID -sgmls: SGML error at test017.sgm, line 9 in declaration parameter 10: - Declared value of data attribute cannot be IDREF or IDREFS -sgmls: SGML error at test017.sgm, line 10 in declaration parameter 13: - Declared value of data attribute cannot be NOTATION -sgmls: SGML error at test017.sgm, line 11 in declaration parameter 18: - CURRENT cannot be specified for a data attribute -sgmls: SGML error at test017.sgm, line 12 in declaration parameter 21: - CONREF cannot be specified for a data attribute diff --git a/cde/programs/dtdocbook/sgmls/test/err/test018.sgm b/cde/programs/dtdocbook/sgmls/test/err/test018.sgm deleted file mode 100644 index 4630ef8bb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test018.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test018.sgm, line 8 at ";": - Invalid reference to external CDATA or SDATA entity; ignored -sgmls: SGML error at test018.sgm, line 8 at ";": - Invalid NDATA or SUBDOC entity reference occurred; ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test019.sgm b/cde/programs/dtdocbook/sgmls/test/err/test019.sgm deleted file mode 100644 index bbec953b2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test019.sgm +++ /dev/null @@ -1,17 +0,0 @@ -sgmls: SGML error at test019.sgm, line 45 at "o": - Attribute name omission requires "SHORTTAG YES" -sgmls: SGML error at test019.sgm, line 46 at "o": - Attribute specification omitted for "NAME": requires markup minimization - Element structure: DOC -sgmls: SGML error at test019.sgm, line 48 at "f": - Undelimited attribute value requires "SHORTTAG YES" - Element structure: DOC -sgmls: SGML error at test019.sgm, line 48 at "/": - Net-enabling start tag requires "SHORTTAG YES" - Element structure: DOC -sgmls: SGML error at test019.sgm, line 49 at "<": - Unclosed start or end tag requires "SHORTTAG YES" - Element structure: DOC -sgmls: SGML error at test019.sgm, line 49 at "<": - Unclosed start or end tag requires "SHORTTAG YES" - Element structure: DOC DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test020.sgm b/cde/programs/dtdocbook/sgmls/test/err/test020.sgm deleted file mode 100644 index 4b6f1817d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test020.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test020.sgm, line 3 at record end: - Document ended invalidly within prolog; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/test021.sgm b/cde/programs/dtdocbook/sgmls/test/err/test021.sgm deleted file mode 100644 index 21319db38..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test021.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test021.sgm, line 2 at record end: - Document ended invalidly within a markup declaration; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/test022.sgm b/cde/programs/dtdocbook/sgmls/test/err/test022.sgm deleted file mode 100644 index a505d1a2f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test022.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test022.sgm, line 4 at entity %confuse, line 1 at "]": - Illegal DSC character; in different entity from DSO -sgmls: SGML error at test022.sgm, line 5 at "]": - Invalid character(s) ignored; attempting to resume DOCTYPE subset diff --git a/cde/programs/dtdocbook/sgmls/test/err/test023.sgm b/cde/programs/dtdocbook/sgmls/test/err/test023.sgm deleted file mode 100644 index d28d9d2f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test023.sgm +++ /dev/null @@ -1,14 +0,0 @@ -sgmls: SGML error at test023.sgm, line 5 in declaration parameter 2: - One or more parameters missing; declaration ignored -sgmls: SGML error at test023.sgm, line 8 in declaration parameter 2: - MDC delimiter (>) expected; following text may be misinterpreted - Element structure: DOC -sgmls: SGML error at test023.sgm, line 9 in declaration parameter 2: - Associated element type not allowed in document instance - Element structure: DOC -sgmls: SGML error at test023.sgm, line 10 in declaration parameter 2: - Associated element type not allowed in document instance - Element structure: DOC -sgmls: SGML error at test023.sgm, line 11 in declaration parameter 1: - Map does not exist; declaration ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test024.sgm b/cde/programs/dtdocbook/sgmls/test/err/test024.sgm deleted file mode 100644 index a9794edb1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test024.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test024.sgm, line 6 at ">": - Undefined BAD start-tag GI ignored; not used in DTD - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test025.sgm b/cde/programs/dtdocbook/sgmls/test/err/test025.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test026.sgm b/cde/programs/dtdocbook/sgmls/test/err/test026.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test027.sgm b/cde/programs/dtdocbook/sgmls/test/err/test027.sgm deleted file mode 100644 index 71b25179c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test027.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test027.sgm, line 3 in declaration parameter 4: - AN1 definition ignored: CDATA is not a valid default value keyword diff --git a/cde/programs/dtdocbook/sgmls/test/err/test028.sgm b/cde/programs/dtdocbook/sgmls/test/err/test028.sgm deleted file mode 100644 index 048014992..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test028.sgm +++ /dev/null @@ -1,6 +0,0 @@ -sgmls: SGML error at test028.sgm, line 5 in declaration parameter 4: - Content model token 97: more than GRPGTCNT content model tokens; terminated -sgmls: SGML error at test028.sgm, line 6 at "<": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: Warning at test028.sgm, line 8 at record start: - Element "BAD" used in DTD but not defined diff --git a/cde/programs/dtdocbook/sgmls/test/err/test029.sgm b/cde/programs/dtdocbook/sgmls/test/err/test029.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test030.sgm b/cde/programs/dtdocbook/sgmls/test/err/test030.sgm deleted file mode 100644 index 723c86b29..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test030.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test030.sgm, line 30 at ">": - Start-tag length exceeds TAGLEN limit; parsed correctly diff --git a/cde/programs/dtdocbook/sgmls/test/err/test031.sgm b/cde/programs/dtdocbook/sgmls/test/err/test031.sgm deleted file mode 100644 index 3cf1e4aab..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test031.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test031.sgm, line 2 at "[": - R/CDATA marked section in declaration subset; prolog terminated -sgmls: SGML error at test031.sgm, line 2 at "[": - No definition for PLAIN document type; "PLAIN O O ANY" assumed diff --git a/cde/programs/dtdocbook/sgmls/test/err/test032.sgm b/cde/programs/dtdocbook/sgmls/test/err/test032.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test033.sgm b/cde/programs/dtdocbook/sgmls/test/err/test033.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test034.sgm b/cde/programs/dtdocbook/sgmls/test/err/test034.sgm deleted file mode 100644 index 926950996..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test034.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test034.sgm, line 2 at "L": - SGML markup declaration not permitted here; declaration ended -sgmls: SGML error at test034.sgm, line 2 at " ": - No DOCTYPE declaration; document type is unknown diff --git a/cde/programs/dtdocbook/sgmls/test/err/test035.sgm b/cde/programs/dtdocbook/sgmls/test/err/test035.sgm deleted file mode 100644 index 8a150c709..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test035.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test035.sgm, line 2 at "L": - SGML markup declaration not permitted here; declaration ended -sgmls: SGML error at test035.sgm, line 2 at " ": - No DOCTYPE declaration; document type is unknown diff --git a/cde/programs/dtdocbook/sgmls/test/err/test036.sgm b/cde/programs/dtdocbook/sgmls/test/err/test036.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test037.sgm b/cde/programs/dtdocbook/sgmls/test/err/test037.sgm deleted file mode 100644 index 651f8d130..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test037.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test037.sgm, line 6 at ";": - No declaration for entity "num"; reference ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test038.sgm b/cde/programs/dtdocbook/sgmls/test/err/test038.sgm deleted file mode 100644 index 7feb06966..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test038.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test038.sgm, line 17 at record end: - BOOK element ended prematurely; required subelement omitted - Element structure: BIBLIO BOOK diff --git a/cde/programs/dtdocbook/sgmls/test/err/test039.sgm b/cde/programs/dtdocbook/sgmls/test/err/test039.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test040.sgm b/cde/programs/dtdocbook/sgmls/test/err/test040.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test041.sgm b/cde/programs/dtdocbook/sgmls/test/err/test041.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test042.sgm b/cde/programs/dtdocbook/sgmls/test/err/test042.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test043.sgm b/cde/programs/dtdocbook/sgmls/test/err/test043.sgm deleted file mode 100644 index 74259c86d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test043.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test043.sgm, line 3 at "[": - R/CDATA marked section in declaration subset; prolog terminated diff --git a/cde/programs/dtdocbook/sgmls/test/err/test044.sgm b/cde/programs/dtdocbook/sgmls/test/err/test044.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test045.sgm b/cde/programs/dtdocbook/sgmls/test/err/test045.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test046.sgm b/cde/programs/dtdocbook/sgmls/test/err/test046.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test047.sgm b/cde/programs/dtdocbook/sgmls/test/err/test047.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test048.sgm b/cde/programs/dtdocbook/sgmls/test/err/test048.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test049.sgm b/cde/programs/dtdocbook/sgmls/test/err/test049.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test050.sgm b/cde/programs/dtdocbook/sgmls/test/err/test050.sgm deleted file mode 100644 index c1b69a101..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test050.sgm +++ /dev/null @@ -1,6 +0,0 @@ -sgmls: SGML error at test050.sgm, line 5 at ">": - Exclusion cannot apply to token "B" in content model for "DOC" - Element structure: DOC -sgmls: SGML error at test050.sgm, line 7 at ">": - DOC element ended prematurely; required B omitted - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test051.sgm b/cde/programs/dtdocbook/sgmls/test/err/test051.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test052.sgm b/cde/programs/dtdocbook/sgmls/test/err/test052.sgm deleted file mode 100644 index a884bdb11..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test052.sgm +++ /dev/null @@ -1,5 +0,0 @@ -sgmls: SGML error at test052.sgm, line 7 at record end: - A start-tag implied by data; not minimizable - Element structure: DOC -sgmls: SGML error at test052.sgm, line 8 at ">": - Out-of-context A start-tag ended DOC document element (and parse) diff --git a/cde/programs/dtdocbook/sgmls/test/err/test053.sgm b/cde/programs/dtdocbook/sgmls/test/err/test053.sgm deleted file mode 100644 index 28d460c53..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test053.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test053.sgm, line 5 at ">": - Exclusion cannot apply to token "A" in content model for "DOC" - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test054.sgm b/cde/programs/dtdocbook/sgmls/test/err/test054.sgm deleted file mode 100644 index 6bb9c1c09..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test054.sgm +++ /dev/null @@ -1,6 +0,0 @@ -sgmls: SGML error at test054.sgm, line 5 at ">": - Exclusion cannot apply to token "B" in content model for "DOC" - Element structure: DOC -sgmls: SGML error at test054.sgm, line 7 at ">": - DOC element ended prematurely; required B omitted - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test055.sgm b/cde/programs/dtdocbook/sgmls/test/err/test055.sgm deleted file mode 100644 index 09b71630e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test055.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test055.sgm, line 5 at ">": - Exclusions attempt to change required status of group in "DOC" - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test056.sgm b/cde/programs/dtdocbook/sgmls/test/err/test056.sgm deleted file mode 100644 index c855270eb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test056.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test056.sgm, line 5 at ">": - Exclusion cannot apply to token "C" in content model for "DOC" - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test057.sgm b/cde/programs/dtdocbook/sgmls/test/err/test057.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test058.sgm b/cde/programs/dtdocbook/sgmls/test/err/test058.sgm deleted file mode 100644 index 121054b56..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test058.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test058.sgm, line 4 at ">": - Required ATT attribute was not specified; may affect processing diff --git a/cde/programs/dtdocbook/sgmls/test/err/test059.sgm b/cde/programs/dtdocbook/sgmls/test/err/test059.sgm deleted file mode 100644 index 7bcef88a2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test059.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test059.sgm, line 6 at record start: - Notation "DCN" not defined in DTD diff --git a/cde/programs/dtdocbook/sgmls/test/err/test060.sgm b/cde/programs/dtdocbook/sgmls/test/err/test060.sgm deleted file mode 100644 index 3b7a113d3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test060.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test060.sgm, line 7 at record start: - Notation "DCN" not defined in DTD diff --git a/cde/programs/dtdocbook/sgmls/test/err/test061.sgm b/cde/programs/dtdocbook/sgmls/test/err/test061.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test062.sgm b/cde/programs/dtdocbook/sgmls/test/err/test062.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test063.sgm b/cde/programs/dtdocbook/sgmls/test/err/test063.sgm deleted file mode 100644 index 3ec7637eb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test063.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test063.sgm, line 4 in declaration parameter 5: - Formal public identifier "pubid" invalid; treated as informal diff --git a/cde/programs/dtdocbook/sgmls/test/err/test064.sgm b/cde/programs/dtdocbook/sgmls/test/err/test064.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test065.sgm b/cde/programs/dtdocbook/sgmls/test/err/test065.sgm deleted file mode 100644 index 1f489f13b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test065.sgm +++ /dev/null @@ -1,12 +0,0 @@ -sgmls: SGML error at test065.sgm, line 2 at "e": - No declaration for entity "%e"; reference ignored -sgmls: SGML error at test065.sgm, line 2 at ")": - Incorrect character in markup; markup terminated -sgmls: SGML error at test065.sgm, line 2 at ")": - Incorrect character in markup; markup terminated -sgmls: SGML error at test065.sgm, line 2 in declaration parameter 2: - Minimization must be "-" or "O" (not "ELEMENT"); declaration terminated -sgmls: SGML error at test065.sgm, line 3 at "]": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: SGML error at test065.sgm, line 3 at record end: - Document ended invalidly within prolog; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/test066.sgm b/cde/programs/dtdocbook/sgmls/test/err/test066.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test067.sgm b/cde/programs/dtdocbook/sgmls/test/err/test067.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test068.sgm b/cde/programs/dtdocbook/sgmls/test/err/test068.sgm deleted file mode 100644 index bafea0bb2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test068.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test068.sgm, line 6 at entity e, line 1 at "\035": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test069.sgm b/cde/programs/dtdocbook/sgmls/test/err/test069.sgm deleted file mode 100644 index a2550361c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test069.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test069.sgm, line 6 at entity e, line 1 at "\035": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test070.sgm b/cde/programs/dtdocbook/sgmls/test/err/test070.sgm deleted file mode 100644 index e22a306cd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test070.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test070.sgm, line 6 at entity e, line 1 at "\035": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test071.sgm b/cde/programs/dtdocbook/sgmls/test/err/test071.sgm deleted file mode 100644 index 86075f056..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test071.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test071.sgm, line 6 at entity e, line 1 at "\035": - Non-SGML character ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test072.sgm b/cde/programs/dtdocbook/sgmls/test/err/test072.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test073.sgm b/cde/programs/dtdocbook/sgmls/test/err/test073.sgm deleted file mode 100644 index 0fcf91647..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test073.sgm +++ /dev/null @@ -1,6 +0,0 @@ -sgmls: SGML error at test073.sgm, line 10 in declaration parameter 18: - More than ATTCNT attribute names and/or name (token) values; terminated -sgmls: SGML error at test073.sgm, line 12 at "]": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: SGML error at test073.sgm, line 12 at record end: - Document ended invalidly within prolog; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/test074.sgm b/cde/programs/dtdocbook/sgmls/test/err/test074.sgm deleted file mode 100644 index 200be7572..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test074.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test074.sgm, line 4 at entity %e, line 1 at end of entity: - Illegal entity end in markup or delimited text diff --git a/cde/programs/dtdocbook/sgmls/test/err/test075.sgm b/cde/programs/dtdocbook/sgmls/test/err/test075.sgm deleted file mode 100644 index 6a8bf8490..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test075.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test075.sgm, line 5 in declaration parameter 2: - Group token 3: duplicate name or name token "DCN2" ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test076.sgm b/cde/programs/dtdocbook/sgmls/test/err/test076.sgm deleted file mode 100644 index 982561651..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test076.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test076.sgm, line 2 in declaration parameter 5: - Group token 2: duplicate name or name token "A" ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test077.sgm b/cde/programs/dtdocbook/sgmls/test/err/test077.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test078.sgm b/cde/programs/dtdocbook/sgmls/test/err/test078.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test079.sgm b/cde/programs/dtdocbook/sgmls/test/err/test079.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test080.sgm b/cde/programs/dtdocbook/sgmls/test/err/test080.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test081.sgm b/cde/programs/dtdocbook/sgmls/test/err/test081.sgm deleted file mode 100644 index 221640e6a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test081.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test081.sgm, line 3 at "n": - ATT = "1n" attribute value defaulted: wrong token type diff --git a/cde/programs/dtdocbook/sgmls/test/err/test082.sgm b/cde/programs/dtdocbook/sgmls/test/err/test082.sgm deleted file mode 100644 index 1912c654d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test082.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test082.sgm, line 11 at """: - Normalized length of value of attribute "ATT2" exceeded LITLEN diff --git a/cde/programs/dtdocbook/sgmls/test/err/test083.sgm b/cde/programs/dtdocbook/sgmls/test/err/test083.sgm deleted file mode 100644 index 9211f0430..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test083.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test083.sgm, line 6 in declaration parameter 3: - Length of interpreted parameter literal exceeds LITLEN less the length of the bracketing delimiters -sgmls: SGML error at test083.sgm, line 7 at "]": - Invalid character(s) ignored; attempting to resume DOCTYPE subset diff --git a/cde/programs/dtdocbook/sgmls/test/err/test084.sgm b/cde/programs/dtdocbook/sgmls/test/err/test084.sgm deleted file mode 100644 index ccf388b3b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test084.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test084.sgm, line 3 in declaration parameter 2: - Parameter entity name longer than (NAMELEN-1); truncated diff --git a/cde/programs/dtdocbook/sgmls/test/err/test085.sgm b/cde/programs/dtdocbook/sgmls/test/err/test085.sgm deleted file mode 100644 index 5d830eb1f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test085.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test085.sgm, line 5 at record start: - Start tag of document element omitted; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/test086.sgm b/cde/programs/dtdocbook/sgmls/test/err/test086.sgm deleted file mode 100644 index 99f8a3210..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test086.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test086.sgm, line 4 at record start: - Start tag of document element omitted; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/test087.sgm b/cde/programs/dtdocbook/sgmls/test/err/test087.sgm deleted file mode 100644 index 44c098dde..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test087.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test087.sgm, line 4 at "[": - Start tag of document element omitted; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/test088.sgm b/cde/programs/dtdocbook/sgmls/test/err/test088.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test089.sgm b/cde/programs/dtdocbook/sgmls/test/err/test089.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test090.sgm b/cde/programs/dtdocbook/sgmls/test/err/test090.sgm deleted file mode 100644 index ea7d9711d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test090.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test090.sgm, line 5 at record start: - Start tag of document element omitted; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/test091.sgm b/cde/programs/dtdocbook/sgmls/test/err/test091.sgm deleted file mode 100644 index 254e595e3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test091.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test091.sgm, line 5 at record start: - Start tag of document element omitted; not minimizable diff --git a/cde/programs/dtdocbook/sgmls/test/err/test092.sgm b/cde/programs/dtdocbook/sgmls/test/err/test092.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test093.sgm b/cde/programs/dtdocbook/sgmls/test/err/test093.sgm deleted file mode 100644 index 41e5c450c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test093.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test093.sgm, line 4 at ";": - No declaration for entity "%x"; reference ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test094.sgm b/cde/programs/dtdocbook/sgmls/test/err/test094.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test095.sgm b/cde/programs/dtdocbook/sgmls/test/err/test095.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test096.sgm b/cde/programs/dtdocbook/sgmls/test/err/test096.sgm deleted file mode 100644 index 0b5981d18..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test096.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test096.sgm, line 8 at """: - A1 attribute defaulted: FIXED attribute must equal default -sgmls: SGML error at test096.sgm, line 8 at """: - A2 attribute defaulted: FIXED attribute must equal default diff --git a/cde/programs/dtdocbook/sgmls/test/err/test097.sgm b/cde/programs/dtdocbook/sgmls/test/err/test097.sgm deleted file mode 100644 index 6768e0e61..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test097.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: Warning at test097.sgm, line 4 at ";": - No declaration for entity "e"; default definition used -sgmls: Warning at test097.sgm, line 5 in declaration parameter 3: - Earlier reference to entity "e" used default entity diff --git a/cde/programs/dtdocbook/sgmls/test/err/test098.sgm b/cde/programs/dtdocbook/sgmls/test/err/test098.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test099.sgm b/cde/programs/dtdocbook/sgmls/test/err/test099.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test100.sgm b/cde/programs/dtdocbook/sgmls/test/err/test100.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test101.sgm b/cde/programs/dtdocbook/sgmls/test/err/test101.sgm deleted file mode 100644 index 9249e6089..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test101.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: SGML error at test101.sgm, line 3 at "x": - Normalized length of value of attribute "A" exceeded LITLEN -sgmls: SGML error at test101.sgm, line 3 at "x": - Length of name, number, or token exceeded NAMELEN or LITLEN limit diff --git a/cde/programs/dtdocbook/sgmls/test/err/test102.sgm b/cde/programs/dtdocbook/sgmls/test/err/test102.sgm deleted file mode 100644 index 6076d45ce..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test102.sgm +++ /dev/null @@ -1,4 +0,0 @@ -sgmls: Warning at test102.sgm, line 6 at ";": - No declaration for entity "myent"; default definition used -sgmls: Warning at test102.sgm, line 6 in declaration parameter 7: - Earlier reference to entity "myent" used default entity diff --git a/cde/programs/dtdocbook/sgmls/test/err/test103.sgm b/cde/programs/dtdocbook/sgmls/test/err/test103.sgm deleted file mode 100644 index 823dd3891..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test103.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test103.sgm, line 5 at """: - Normalized length of value of attribute "A" exceeded LITLEN diff --git a/cde/programs/dtdocbook/sgmls/test/err/test104.sgm b/cde/programs/dtdocbook/sgmls/test/err/test104.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test105.sgm b/cde/programs/dtdocbook/sgmls/test/err/test105.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test106.sgm b/cde/programs/dtdocbook/sgmls/test/err/test106.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test107.sgm b/cde/programs/dtdocbook/sgmls/test/err/test107.sgm deleted file mode 100644 index aa7218d10..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test107.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test107.sgm, line 5 at """: - A = "\015foo" attribute value defaulted: invalid character diff --git a/cde/programs/dtdocbook/sgmls/test/err/test108.sgm b/cde/programs/dtdocbook/sgmls/test/err/test108.sgm deleted file mode 100644 index 35e5ae78c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test108.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test108.sgm, line 5 at """: - A = "\012foo" attribute value defaulted: invalid character diff --git a/cde/programs/dtdocbook/sgmls/test/err/test109.sgm b/cde/programs/dtdocbook/sgmls/test/err/test109.sgm deleted file mode 100644 index 99b1204e8..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test109.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test109.sgm, line 5 at """: - A = "\011foo" attribute value defaulted: invalid character diff --git a/cde/programs/dtdocbook/sgmls/test/err/test110.sgm b/cde/programs/dtdocbook/sgmls/test/err/test110.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test111.sgm b/cde/programs/dtdocbook/sgmls/test/err/test111.sgm deleted file mode 100644 index 5bdeb486e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test111.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test111.sgm, line 4 at entity %p, line 1 at "\000": - Non-SGML character ignored diff --git a/cde/programs/dtdocbook/sgmls/test/err/test112.sgm b/cde/programs/dtdocbook/sgmls/test/err/test112.sgm deleted file mode 100644 index 2a2f189f3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test112.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test112.sgm, line 6 at entity e, line 1 at "\000": - Non-SGML character found; should have been character reference - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test113.sgm b/cde/programs/dtdocbook/sgmls/test/err/test113.sgm deleted file mode 100644 index aa9e71c80..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test113.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test113.sgm, line 6 at entity e, line 1 at "\000": - Non-SGML character ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test114.sgm b/cde/programs/dtdocbook/sgmls/test/err/test114.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test115.sgm b/cde/programs/dtdocbook/sgmls/test/err/test115.sgm deleted file mode 100644 index d193ebe10..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test115.sgm +++ /dev/null @@ -1,5 +0,0 @@ -sgmls: Warning at test115.sgm, line 3 in declaration parameter 4: - Could not find external general entity "a" -sgmls: Error at test115.sgm, line 5 at ";": - Reference to non-existent general entity "a" ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test116.sgm b/cde/programs/dtdocbook/sgmls/test/err/test116.sgm deleted file mode 100644 index d56101b36..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test116.sgm +++ /dev/null @@ -1,9 +0,0 @@ -sgmls: SGML error at test116.sgm, line 6 in declaration parameter 4: - "ZZ" not valid short reference delimiter; declaration terminated -sgmls: SGML error at test116.sgm, line 8 at "<": - Invalid character(s) ignored; attempting to resume DOCTYPE subset -sgmls: Warning at test116.sgm, line 10 at record start: - Short reference map "MYMAP" used in DTD but not defined -sgmls: SGML error at test116.sgm, line 10 at ">": - Short reference map for element "DOC" not defined; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test117.sgm b/cde/programs/dtdocbook/sgmls/test/err/test117.sgm deleted file mode 100644 index 4a6eec6a2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test117.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at test117.sgm, line 6 at record start: - Short reference map "MYMAP" used in DTD but not defined diff --git a/cde/programs/dtdocbook/sgmls/test/err/test118.sgm b/cde/programs/dtdocbook/sgmls/test/err/test118.sgm deleted file mode 100644 index 4c0639473..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test118.sgm +++ /dev/null @@ -1,8 +0,0 @@ -sgmls: SGML error at test118.sgm, line 47 at "X": - Normalized length of literal exceeded 240; markup terminated -sgmls: SGML error at test118.sgm, line 47 at "X": - Length of name, number, or token exceeded NAMELEN or LITLEN limit -sgmls: SGML error at test118.sgm, line 49 at end of file: - Illegal entity end in markup or delimited text -sgmls: SGML error at test118.sgm, line 49 at record end: - Document ended invalidly within a literal; parsing ended diff --git a/cde/programs/dtdocbook/sgmls/test/err/test119.sgm b/cde/programs/dtdocbook/sgmls/test/err/test119.sgm deleted file mode 100644 index dbe34ff39..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test119.sgm +++ /dev/null @@ -1,13 +0,0 @@ -sgmls: SGML error at test119.sgm, line 36 in declaration parameter 115: - Unrecognized keyword "DTD" -sgmls: SGML error at test119.sgm, line 36 at " ": - No DOCTYPE declaration; document type is unknown -sgmls: SGML error at test119.sgm, line 43 at "e": - DOCTYPE markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test119.sgm, line 44 at "t": - ELEMENT markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test119.sgm, line 46 at ">": - Undefined DOC start-tag GI ignored; not used in DTD - Element structure: *DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/err/test120.sgm b/cde/programs/dtdocbook/sgmls/test/err/test120.sgm deleted file mode 100644 index ae6636e4f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test120.sgm +++ /dev/null @@ -1,13 +0,0 @@ -sgmls: SGML error at test120.sgm, line 36 in declaration parameter 115: - Unrecognized keyword "FOO" -sgmls: SGML error at test120.sgm, line 36 at " ": - No DOCTYPE declaration; document type is unknown -sgmls: SGML error at test120.sgm, line 43 at "e": - DOCTYPE markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test120.sgm, line 44 at "t": - ELEMENT markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test120.sgm, line 46 at ">": - Undefined DOC start-tag GI ignored; not used in DTD - Element structure: *DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/err/test121.sgm b/cde/programs/dtdocbook/sgmls/test/err/test121.sgm deleted file mode 100644 index 9537840e6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test121.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test121.sgm, line 3 in declaration parameter 4: - ID attribute A cannot have a default value; treated as #IMPLIED diff --git a/cde/programs/dtdocbook/sgmls/test/err/test122.sgm b/cde/programs/dtdocbook/sgmls/test/err/test122.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test123.sgm b/cde/programs/dtdocbook/sgmls/test/err/test123.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test124.sgm b/cde/programs/dtdocbook/sgmls/test/err/test124.sgm deleted file mode 100644 index c6c3a6865..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test124.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test124.sgm, line 6 at ";": - Reference to PI entity not permitted here; reference ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test125.sgm b/cde/programs/dtdocbook/sgmls/test/err/test125.sgm deleted file mode 100644 index 996ce219f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test125.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test125.sgm, line 6 at ";": - Reference to PI entity not permitted here; reference ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test126.sgm b/cde/programs/dtdocbook/sgmls/test/err/test126.sgm deleted file mode 100644 index 45fbeab4c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test126.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test126.sgm, line 7 at ";": - Invalid NDATA or SUBDOC entity reference occurred; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test127.sgm b/cde/programs/dtdocbook/sgmls/test/err/test127.sgm deleted file mode 100644 index f427639b5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test127.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test127.sgm, line 7 at ";": - Invalid NDATA or SUBDOC entity reference occurred; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test128.sgm b/cde/programs/dtdocbook/sgmls/test/err/test128.sgm deleted file mode 100644 index 3812b9f48..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test128.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test128.sgm, line 7 at ";": - Invalid reference to external CDATA or SDATA entity; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test129.sgm b/cde/programs/dtdocbook/sgmls/test/err/test129.sgm deleted file mode 100644 index fe0202dc6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test129.sgm +++ /dev/null @@ -1,3 +0,0 @@ -sgmls: SGML error at test129.sgm, line 7 at ";": - Invalid reference to external CDATA or SDATA entity; ignored - Element structure: DOC diff --git a/cde/programs/dtdocbook/sgmls/test/err/test130.sgm b/cde/programs/dtdocbook/sgmls/test/err/test130.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test131.sgm b/cde/programs/dtdocbook/sgmls/test/err/test131.sgm deleted file mode 100644 index b3c55932e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test131.sgm +++ /dev/null @@ -1,13 +0,0 @@ -sgmls: SGML error at test131.sgm, line 36 in declaration parameter 115: - Unrecognized keyword "NONSGML" -sgmls: SGML error at test131.sgm, line 36 at " ": - No DOCTYPE declaration; document type is unknown -sgmls: SGML error at test131.sgm, line 43 at "e": - DOCTYPE markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test131.sgm, line 44 at "t": - ELEMENT markup declaration not permitted here; declaration ended - Element structure: *DOCTYPE -sgmls: SGML error at test131.sgm, line 46 at ">": - Undefined DOC start-tag GI ignored; not used in DTD - Element structure: *DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/err/test132.sgm b/cde/programs/dtdocbook/sgmls/test/err/test132.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/err/test133.sgm b/cde/programs/dtdocbook/sgmls/test/err/test133.sgm deleted file mode 100644 index 9e3059240..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test133.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at test133.sgm, line 6 in declaration parameter 0: - End-tag minimization should be "O" for element with CONREF attribute diff --git a/cde/programs/dtdocbook/sgmls/test/err/test134.sgm b/cde/programs/dtdocbook/sgmls/test/err/test134.sgm deleted file mode 100644 index 1abbec374..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test134.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at test134.sgm, line 45 in declaration parameter 0: - End-tag minimization should be "O" for element with CONREF attribute diff --git a/cde/programs/dtdocbook/sgmls/test/err/test135.sgm b/cde/programs/dtdocbook/sgmls/test/err/test135.sgm deleted file mode 100644 index 067c3fd3a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test135.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: Warning at test135.sgm, line 44 in declaration parameter 4: - End-tag minimization should be "O" for EMPTY element diff --git a/cde/programs/dtdocbook/sgmls/test/err/test136.sgm b/cde/programs/dtdocbook/sgmls/test/err/test136.sgm deleted file mode 100644 index 576ccecae..000000000 --- a/cde/programs/dtdocbook/sgmls/test/err/test136.sgm +++ /dev/null @@ -1,2 +0,0 @@ -sgmls: SGML error at test136.sgm, line 4 at ">": - Required ATT attribute was not specified for entity e diff --git a/cde/programs/dtdocbook/sgmls/test/errexit.sgm b/cde/programs/dtdocbook/sgmls/test/errexit.sgm deleted file mode 100644 index b1a5a69df..000000000 --- a/cde/programs/dtdocbook/sgmls/test/errexit.sgm +++ /dev/null @@ -1,2 +0,0 @@ - - - - - - - - - - - - - - - -]> - - - - -A null character �. "Quoted". A backslash \. -e1 = `&e1;' -e2 = `&e2;' -e3 = `&e3;' -e5 = `&e5;' - -e6 = `&e6;' - -e7 = `&e7;' - - diff --git a/cde/programs/dtdocbook/sgmls/test/ex.dtd b/cde/programs/dtdocbook/sgmls/test/ex.dtd deleted file mode 100644 index 05d957e18..000000000 --- a/cde/programs/dtdocbook/sgmls/test/ex.dtd +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/exdtd.sgm b/cde/programs/dtdocbook/sgmls/test/exdtd.sgm deleted file mode 100644 index 80f502582..000000000 --- a/cde/programs/dtdocbook/sgmls/test/exdtd.sgm +++ /dev/null @@ -1,2 +0,0 @@ - - - -]> - -foo diff --git a/cde/programs/dtdocbook/sgmls/test/idref.sgm b/cde/programs/dtdocbook/sgmls/test/idref.sgm deleted file mode 100644 index 096ba76e0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/idref.sgm +++ /dev/null @@ -1,20 +0,0 @@ - - - - -]> - - - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/intent.sgm b/cde/programs/dtdocbook/sgmls/test/intent.sgm deleted file mode 100644 index 7f70050e4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/intent.sgm +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - -] -- end of gdoc dtd --> - -A reference to the &e1 and the &e2;. -The entity &e3 is done. - diff --git a/cde/programs/dtdocbook/sgmls/test/intent1.gml b/cde/programs/dtdocbook/sgmls/test/intent1.gml deleted file mode 100644 index 085a59eb9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/intent1.gml +++ /dev/null @@ -1,2 +0,0 @@ -INTENT1 references &e1 and the &e2;. -The entity &intent2 and is done. diff --git a/cde/programs/dtdocbook/sgmls/test/intent2.gml b/cde/programs/dtdocbook/sgmls/test/intent2.gml deleted file mode 100644 index 0ffc35950..000000000 --- a/cde/programs/dtdocbook/sgmls/test/intent2.gml +++ /dev/null @@ -1 +0,0 @@ -INTENT2 references &e1 and &e2. diff --git a/cde/programs/dtdocbook/sgmls/test/memo.dtd b/cde/programs/dtdocbook/sgmls/test/memo.dtd deleted file mode 100644 index e83df2e3e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/memo.dtd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/memo.sgm b/cde/programs/dtdocbook/sgmls/test/memo.sgm deleted file mode 100644 index 76adedb15..000000000 --- a/cde/programs/dtdocbook/sgmls/test/memo.sgm +++ /dev/null @@ -1,22 +0,0 @@ - -March 11, 1985 -C.F. Goldfarb -&Eckhardt; -With SGML, "What You See Isn't All You Get" - -Dear Keith, - -This memo is being written to demonstrate the power and simplicity of -the SGML markup minimization and WYSIWYG support. - -Although only one tag is visible in the document (to identify an optional -"carbon copy" recipient), the SGML parser recognizes 15 different -element types. This allows each element to be formatted differently; -for example, the start and end of a quotation can have differing -curved quotation marks (the normal typesetting convention), even though -identical straight quotation marks were used as the WYSIWYG entry convention. - -Yours truly, - -Charles F. Goldfarb -Distribution diff --git a/cde/programs/dtdocbook/sgmls/test/memo2.dtd b/cde/programs/dtdocbook/sgmls/test/memo2.dtd deleted file mode 100644 index 704ccbeed..000000000 --- a/cde/programs/dtdocbook/sgmls/test/memo2.dtd +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/memo2.sgm b/cde/programs/dtdocbook/sgmls/test/memo2.sgm deleted file mode 100644 index 58d916cda..000000000 --- a/cde/programs/dtdocbook/sgmls/test/memo2.sgm +++ /dev/null @@ -1,22 +0,0 @@ - -March 11, 1985 -C.F. Goldfarb -&Eckhardt -With SGML, "What You See Isn't All You Get" - -Dear Keith, - -This memo is being written to demonstrate the power and simplicity of - the SGML markup minimization and WYSIWYG support. - -Although only one tag is visible in the document (to identify an optional - "carbon copy" recipient), the SGML parser recognizes 15 different - element types. This allows each element to be formatted differently; - for example, the start and end of a quotation can have differing - curved quotation marks (the normal typesetting convention), even though - identical straight quotation marks were used as the WYSIWYG entry convention. - -Yours truly, - -Charles F. Goldfarb -Distribution diff --git a/cde/programs/dtdocbook/sgmls/test/names.sgm b/cde/programs/dtdocbook/sgmls/test/names.sgm deleted file mode 100644 index 0bebe2d23..000000000 --- a/cde/programs/dtdocbook/sgmls/test/names.sgm +++ /dev/null @@ -1,50 +0,0 @@ - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/nonsgml.sgm b/cde/programs/dtdocbook/sgmls/test/nonsgml.sgm deleted file mode 100644 index 6caf303bd..000000000 Binary files a/cde/programs/dtdocbook/sgmls/test/nonsgml.sgm and /dev/null differ diff --git a/cde/programs/dtdocbook/sgmls/test/out/ambig.sgm b/cde/programs/dtdocbook/sgmls/test/out/ambig.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/ambig.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/basicdoc.sgm b/cde/programs/dtdocbook/sgmls/test/out/basicdoc.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/comment.sgm b/cde/programs/dtdocbook/sgmls/test/out/comment.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/conref.sgm b/cde/programs/dtdocbook/sgmls/test/out/conref.sgm deleted file mode 100644 index e619b371e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/conref.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT CDATA sub -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/default.sgm b/cde/programs/dtdocbook/sgmls/test/out/default.sgm deleted file mode 100644 index 09a4698cf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/default.sgm +++ /dev/null @@ -1,8 +0,0 @@ -NDCN1 -ssysis -fsysis -Ej2 NDATA DCN1 -AFILE ENTITY j2 -(DFLT -&j2 -)DFLT diff --git a/cde/programs/dtdocbook/sgmls/test/out/endless.sgm b/cde/programs/dtdocbook/sgmls/test/out/endless.sgm deleted file mode 100644 index 5c67b4526..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/endless.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(ENDLESS -(A -(A --data -)A -)A -)ENDLESS diff --git a/cde/programs/dtdocbook/sgmls/test/out/errexit.sgm b/cde/programs/dtdocbook/sgmls/test/out/errexit.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/esis.sgm b/cde/programs/dtdocbook/sgmls/test/out/esis.sgm deleted file mode 100644 index 3c2e5fdb9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/esis.sgm +++ /dev/null @@ -1,154 +0,0 @@ -?a processing instruction before the document element -(DOC -?a processing instruction inside the document element -AA1 TOKEN BAR -ssysid2 -NN2 -AA2 NOTATION N2 -AA3 CDATA a3: e1 = `e1 contents' e2 = `\|e2 contents\|'; -Ie1 CDATA e1 contents -AA4 ENTITY e1 -AA5 TOKEN ID1 -AA6 TOKEN ID2 -AA7 TOKEN XYZZY -AA8 TOKEN .NMTOKEN -AA9 TOKEN 42 -AA10 TOKEN 10PT -Ie2 SDATA e2 contents -NN1 -se3.file1:e3.file2 -fe3.file1 -fe3.file2 -Ee3 CDATA N1 -De3 A1 CDATA a1 contents -De3 A2 TOKEN A2VAL -De3 A3 TOKEN A3VAL1 A3VAL2 -p-//dummy//NOTATION n3//EN -NN3 -se4.file -fe4.file -Ee4 SDATA N3 -p-//dummy//NOTATION n4//EN -ssysid4 -NN4 -se5.file -fe5.file -Ee5 NDATA N4 -smemo.sgm -fmemo.sgm -Se6 -AA11 ENTITY e1 e2 e3 e4 e5 e6 -AA12 TOKEN ID1 ID2 -AA13 TOKEN NAME1 NAME2 -AA14 TOKEN .NAME1 .NAME2 -AA15 TOKEN 6 28 -AA16 TOKEN 10PT 12PT -(E --A null character \000. "Quoted". A backslash \\.\ne1 = `e1 contents'\ne2 = `\|e2 contents\|'\ne3 = ` -&e3 --'\ne5 = ` -&e5 --' -)E -AA1 TOKEN FOO -AA2 NOTATION N3 -AA3 IMPLIED -AA4 IMPLIED -AA5 TOKEN ID2 -AA6 IMPLIED -AA7 IMPLIED -AA8 IMPLIED -AA9 IMPLIED -AA10 IMPLIED -AA11 IMPLIED -AA12 IMPLIED -AA13 IMPLIED -AA14 IMPLIED -AA15 IMPLIED -AA16 IMPLIED -(E --e6 = ` -{e6 -ASEC CDATA Internal Use Only -ASTATUS TOKEN FINAL -(MEMO -(PROLOG -(DATE --March 11, 1985 -)DATE -(FROM --C.F. Goldfarb -)FROM -(TO -(WHOM --K.L. Eckhardt -)WHOM -(TITLE --Mgr., West Coast Development Center -)TITLE -(ZIP --FLA/029 -)ZIP -(LOCATION --San Jose -)LOCATION -)TO -(SUBJECT --With SGML, -(Q --What You See Isn't All You Get -)Q -)SUBJECT -)PROLOG -(BODY -(P --Dear Keith, -)P -(P --This memo is being written to demonstrate the power and simplicity of\nthe SGML markup minimization and WYSIWYG support. -)P -(P --Although only one tag is visible in the document (to identify an optional\n -(Q --carbon copy -)Q -- recipient), the SGML parser recognizes 15 different\nelement types. This allows each element to be formatted differently;\nfor example, the start and end of a quotation can have differing\ncurved quotation marks (the normal typesetting convention), even though\nidentical straight quotation marks were used as the WYSIWYG entry convention. -)P -(P --Yours truly, -)P -(P --Charles F. Goldfarb -)P -(CC --Distribution -)CC -)BODY -)MEMO -}e6 --' -)E -AA1 TOKEN FOO -AA2 NOTATION N4 -AA3 IMPLIED -AA4 IMPLIED -AA5 TOKEN ID3 -AA6 TOKEN ID1 -AA7 IMPLIED -AA8 IMPLIED -AA9 IMPLIED -AA10 IMPLIED -AA11 IMPLIED -AA12 IMPLIED -AA13 IMPLIED -AA14 IMPLIED -AA15 IMPLIED -AA16 IMPLIED -(E --e7 = ` -?e7 contents --' -)E -)DOC -?a processing instruction after the document element -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/exdtd.sgm b/cde/programs/dtdocbook/sgmls/test/out/exdtd.sgm deleted file mode 100644 index 5887d6558..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/exdtd.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(EX --data -)EX -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/grplvl.sgm b/cde/programs/dtdocbook/sgmls/test/out/grplvl.sgm deleted file mode 100644 index c253675b2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/grplvl.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --foo -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/idref.sgm b/cde/programs/dtdocbook/sgmls/test/out/idref.sgm deleted file mode 100644 index 947839247..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/idref.sgm +++ /dev/null @@ -1,30 +0,0 @@ -(DOC -AID TOKEN X -AIDREF IMPLIED -(FOO -)FOO -AID IMPLIED -AIDREF TOKEN Y -(FOO -)FOO -AID IMPLIED -AIDREF TOKEN X -(FOO -)FOO -AID IMPLIED -AIDREF TOKEN Z -(FOO -)FOO -AID TOKEN Y -AIDREF IMPLIED -(FOO -)FOO -AID IMPLIED -AIDREF TOKEN Y -(FOO -)FOO -AID TOKEN W -AIDREF IMPLIED -(FOO -)FOO -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/intent.sgm b/cde/programs/dtdocbook/sgmls/test/out/intent.sgm deleted file mode 100644 index 425a22b1b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/intent.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(GDOC --A reference to the e1 text and the e2 text.\nThe entity e3 contains the e1 text and the e2 text and INTENT1 references e1 text and the e2 text.\nThe entity INTENT2 references e1 text and and is done.\n as well is done. -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/memo.sgm b/cde/programs/dtdocbook/sgmls/test/out/memo.sgm deleted file mode 100644 index e2b2e1fd6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/memo.sgm +++ /dev/null @@ -1,57 +0,0 @@ -ASEC CDATA Internal Use Only -ASTATUS TOKEN FINAL -(MEMO -(PROLOG -(DATE --March 11, 1985 -)DATE -(FROM --C.F. Goldfarb -)FROM -(TO -(WHOM --K.L. Eckhardt -)WHOM -(TITLE --Mgr., West Coast Development Center -)TITLE -(ZIP --FLA/029 -)ZIP -(LOCATION --San Jose -)LOCATION -)TO -(SUBJECT --With SGML, -(Q --What You See Isn't All You Get -)Q -)SUBJECT -)PROLOG -(BODY -(P --Dear Keith, -)P -(P --This memo is being written to demonstrate the power and simplicity of\nthe SGML markup minimization and WYSIWYG support. -)P -(P --Although only one tag is visible in the document (to identify an optional\n -(Q --carbon copy -)Q -- recipient), the SGML parser recognizes 15 different\nelement types. This allows each element to be formatted differently;\nfor example, the start and end of a quotation can have differing\ncurved quotation marks (the normal typesetting convention), even though\nidentical straight quotation marks were used as the WYSIWYG entry convention. -)P -(P --Yours truly, -)P -(P --Charles F. Goldfarb -)P -(CC --Distribution -)CC -)BODY -)MEMO -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/memo2.sgm b/cde/programs/dtdocbook/sgmls/test/out/memo2.sgm deleted file mode 100644 index bee8a32dc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/memo2.sgm +++ /dev/null @@ -1,57 +0,0 @@ -ASEC CDATA Internal Use Only -ASTATUS TOKEN FINAL -(MEMO2 -(PROLOG -(DATE --March 11, 1985 -)DATE -(FROM --C.F. Goldfarb -)FROM -(TO -(WHOM --K.L. Eckhardt -)WHOM -(TITLE --Mgr., West Coast Development Center -)TITLE -(ZIP --FLA/029 -)ZIP -(LOCATION --San Jose -)LOCATION -)TO -(SUBJECT --With SGML, -(Q --What You See Isn't All You Get -)Q -)SUBJECT -)PROLOG -(BODY -(P --Dear Keith, -)P -(P --This memo is being written to demonstrate the power and simplicity of\nthe SGML markup minimization and WYSIWYG support. -)P -(P --Although only one tag is visible in the document (to identify an optional\n -(Q --carbon copy -)Q -- recipient), the SGML parser recognizes 15 different\nelement types. This allows each element to be formatted differently;\nfor example, the start and end of a quotation can have differing\ncurved quotation marks (the normal typesetting convention), even though\nidentical straight quotation marks were used as the WYSIWYG entry convention. -)P -(P --Yours truly, -)P -(P --Charles F. Goldfarb -)P -(CC --Distribution -)CC -)BODY -)MEMO2 -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/names.sgm b/cde/programs/dtdocbook/sgmls/test/out/names.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/names.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/nonsgml.sgm b/cde/programs/dtdocbook/sgmls/test/out/nonsgml.sgm deleted file mode 100644 index 158d2a254..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/nonsgml.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --\000\001\002\003\004\005\006\007\010\013\014\n\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 \177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377 -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/pubes.sgm b/cde/programs/dtdocbook/sgmls/test/out/pubes.sgm deleted file mode 100644 index 09942fdcb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/pubes.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(TAG1 -)TAG1 diff --git a/cde/programs/dtdocbook/sgmls/test/out/sgmldecl.sgm b/cde/programs/dtdocbook/sgmls/test/out/sgmldecl.sgm deleted file mode 100644 index b6924348a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/sgmldecl.sgm +++ /dev/null @@ -1,5 +0,0 @@ -#some application information -(DOC --Some text. -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/subdoc.sgm b/cde/programs/dtdocbook/sgmls/test/out/subdoc.sgm deleted file mode 100644 index 934feb951..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/subdoc.sgm +++ /dev/null @@ -1,66 +0,0 @@ -(DOC --foo -smemo.sgm -fmemo.sgm -Smemo -{memo -ASEC CDATA Internal Use Only -ASTATUS TOKEN FINAL -(MEMO -(PROLOG -(DATE --March 11, 1985 -)DATE -(FROM --C.F. Goldfarb -)FROM -(TO -(WHOM --K.L. Eckhardt -)WHOM -(TITLE --Mgr., West Coast Development Center -)TITLE -(ZIP --FLA/029 -)ZIP -(LOCATION --San Jose -)LOCATION -)TO -(SUBJECT --With SGML, -(Q --What You See Isn't All You Get -)Q -)SUBJECT -)PROLOG -(BODY -(P --Dear Keith, -)P -(P --This memo is being written to demonstrate the power and simplicity of\nthe SGML markup minimization and WYSIWYG support. -)P -(P --Although only one tag is visible in the document (to identify an optional\n -(Q --carbon copy -)Q -- recipient), the SGML parser recognizes 15 different\nelement types. This allows each element to be formatted differently;\nfor example, the start and end of a quotation can have differing\ncurved quotation marks (the normal typesetting convention), even though\nidentical straight quotation marks were used as the WYSIWYG entry convention. -)P -(P --Yours truly, -)P -(P --Charles F. Goldfarb -)P -(CC --Distribution -)CC -)BODY -)MEMO -}memo --bar -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test001.sgm b/cde/programs/dtdocbook/sgmls/test/out/test001.sgm deleted file mode 100644 index 0d77fb457..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test001.sgm +++ /dev/null @@ -1,43 +0,0 @@ -(GDOC -(BODY -(H1 --A heading with a -(Q --quotation -)Q -- in it. -)H1 -(P --A paragraph with an invalid reference in it\nafter the heading. -)P -(P --Another paragraph with a markup declaration>\nand a -?processing instruction -- in it. -)P -(P --Content that "looks" like a\n<1start-tag> and an but isn't. -)P -?pi1\n\012pi2 =\n\012=pi3-- -\n\012 -(P --Here is a syntactically valid (but undefined)\n#tity reference to "en.".\n(Note that this paragraph ends with\na slash.) -)P -(T1 -)T1 -(T1 -)T1 -(T1 -(T2 -)T2 --t1data -)T1 -(TAGISBIG -(MANY --worded tag>\n -(TAG --#with@junk> -)TAG -)MANY -)TAGISBIG -)BODY -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test002.sgm b/cde/programs/dtdocbook/sgmls/test/out/test002.sgm deleted file mode 100644 index 14ee10d98..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test002.sgm +++ /dev/null @@ -1,19 +0,0 @@ -(GDOC -(T1 --A reference to the content of e1 and the content of e2.\nThe \003entity e3 contains the content of e1 and the content of e2 as well.\n -(T2 --att1 ="The entity e3 contains the content of e1 and the content of e2 as well." -)T2 -)T1 -AATT1 CDATA valt1a1 is test2e.gml: [ Imbedded entity with "delimiters" that are ignored in the attribute value but processed in the content: ] -(TAG1 -?processing instruction --p1 --c--\n"p2 p3" 3\nent2 has first value included.\nIn x: self-reference ignored.\n\na\n\011\002b\n -?a  ō Ô --\n/\n\324\|\324\|\324 -?\324 -AA CDATA p1 --c-- "p2 p3" 3 -(T -)T -)TAG1 -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test003.sgm b/cde/programs/dtdocbook/sgmls/test/out/test003.sgm deleted file mode 100644 index b09652d80..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test003.sgm +++ /dev/null @@ -1,88 +0,0 @@ -(TAG1 -AATT2 CDATA val2 -AATT3 CDATA x -(DTAG1 -AATT1 TOKEN 44 -(DTAG2 -AATT1 TOKEN 3 -AATT2 CDATA -AATT3 CDATA x -(DTAG1 -AATT1 TOKEN 1 -ssome private notation -NDCN21 -AATT2 NOTATION DCN21 -AATT3 TOKEN 1 -(DTAG3 --text -)DTAG3 -)DTAG1 -)DTAG2 -)DTAG1 --\n -AATT1 TOKEN VAL1 -(TAG2 -)TAG2 --\n -(TAG3 -(TAG4 --min1/\n -AATT1 CDATA value1 -AATT2 TOKEN MIN2 -(TAG5 -)TAG5 -)TAG4 --\n -AATT1 CDATA value 1 -AATT2 TOKEN MIN2 -(TAG6 -)TAG6 --\n -AATT1 TOKEN MIN1 -p-////NOTATION some known notation//EN -NDCN2 -AATT2 NOTATION DCN2 -AATT3 TOKEN VALUE3 -AATT5 TOKEN MIN5 -AATT6 CDATA value6 -(TAG7 -(TAG8 --min1 min2 >\n -ANUMS TOKEN 1 -(CURE --spec -)CURE --\n -ANUMS TOKEN 1 -(CURE --def -)CURE --\n -ANUMS TOKEN 3 2 1 -(CURE --spec -)CURE --\n -ANUMS TOKEN 3 2 1 -(CURE --repeat spec -)CURE --\n -ANUMS TOKEN 3 2 1 -(CURE --def -)CURE --\n -ANUMS TOKEN 4 5 -(CURE --smaller spec -)CURE --\n -ANUMS TOKEN 4 5 -(CURE --def -)CURE -)TAG8 -)TAG7 -)TAG3 -)TAG1 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test004.sgm b/cde/programs/dtdocbook/sgmls/test/out/test004.sgm deleted file mode 100644 index a2764ebcc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test004.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(GDOC --d1\nms1m1e\nd1e\nms4\nms4data\n\n\nms4e\n -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test005.sgm b/cde/programs/dtdocbook/sgmls/test/out/test005.sgm deleted file mode 100644 index ad35962ae..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test005.sgm +++ /dev/null @@ -1,24 +0,0 @@ -(GDOC -(FRONT -)FRONT -(BODY -(T2 -)T2 -(T3 -)T3 -)BODY -(REAR -)REAR -)GDOC -(FRONT -)FRONT -(APPENDIX -)APPENDIX -(BODY -(T4 -)T4 -)BODY -(REAR -)REAR -(REAR -)REAR diff --git a/cde/programs/dtdocbook/sgmls/test/out/test006.sgm b/cde/programs/dtdocbook/sgmls/test/out/test006.sgm deleted file mode 100644 index d602cc5d4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test006.sgm +++ /dev/null @@ -1,48 +0,0 @@ -(GDOC -(P --abc -(Q --quote -)Q -- def -(IE --index entry -)IE -)P -(P --abc -(Q --quote2 -)Q -- def -(IE --index entry -)IE --\nghi jkl mno -)P -(P -)P -(P --a -(Q --quoted -)Q -- string\nanother -)P -(P -(Q --quoted string with -(NESTEDQ --nested and -(Q --inner -)Q -- nested -)NESTEDQ -- quotes -)Q -)P -(P --string\nR: record\nR: record\nS: sub-record\nS: sub-record\nR: record\nS: sub-record\nR: record -)P -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test007.sgm b/cde/programs/dtdocbook/sgmls/test/out/test007.sgm deleted file mode 100644 index 103412049..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test007.sgm +++ /dev/null @@ -1,9 +0,0 @@ -(GDOC -(BODY -(H1 --A < -)H1 -)BODY -(T1 -)T1 -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test008.sgm b/cde/programs/dtdocbook/sgmls/test/out/test008.sgm deleted file mode 100644 index 4bb11de91..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test008.sgm +++ /dev/null @@ -1,22 +0,0 @@ -(GDOC -(BODY -(CHAP -(A --A data -(X --X data -)X --more A data -)A -(B --B text -)B -(X --x text -)X -)CHAP -)BODY -(Y --Y text -)Y -)GDOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test009.sgm b/cde/programs/dtdocbook/sgmls/test/out/test009.sgm deleted file mode 100644 index fee85687d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test009.sgm +++ /dev/null @@ -1,7 +0,0 @@ -AATT1 CDATA 111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111111111 -AATT2 CDATA 222222222222222222222222222222222222222222222222222222222222222222222222222222 2222222222222222222222222222222222222222222222222222222222222222222222222222222 2222222222222222222222222222222222222222222222222222222222222222222222222 -AATT3 CDATA 333333333333333333333333333333333333333333333333333333333333333333333333333333 3333333333333333333333333333333333333333333333333333333333333333333333333333333 3333333333333333333333333333333333333333333333333333333333333333333333333 -AATT4 CDATA 444444444444444444444444444444444444444444444444444444444444444444444444444444 4444444444444444444444444444444444444444444444444444444444444444444444444444444 4444444444444444444444444444444444444444444444444444444444444444444444444 -AATT5 IMPLIED -(T1 -)T1 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test010.sgm b/cde/programs/dtdocbook/sgmls/test/out/test010.sgm deleted file mode 100644 index f9d487b50..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test010.sgm +++ /dev/null @@ -1,8 +0,0 @@ -?BE3 -AATT1 TOKEN X -AATT2 CDATA 1\|A\|2 -(DOC --data -?BE4 --\n -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test011.sgm b/cde/programs/dtdocbook/sgmls/test/out/test011.sgm deleted file mode 100644 index 9512a29cb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test011.sgm +++ /dev/null @@ -1,14 +0,0 @@ -(DOC -(RT --da ta -)RT -(QT --data -)QT -(CT --da&#space;ta -)CT -(CT --da&#space;ta -)CT -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test012.sgm b/cde/programs/dtdocbook/sgmls/test/out/test012.sgm deleted file mode 100644 index f70b3aa68..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test012.sgm +++ /dev/null @@ -1,20 +0,0 @@ -s3=dcn1-private -NDCN1 -se2.file -fe2.file -Ee2 SDATA DCN1 -De2 A1 CDATA dcn1-a1 def -De2 A2 TOKEN D1 D2 D3 D4 -De2 A3 CDATA dcn1-a3 def -se1.file -fe1.file -Ee1 NDATA DCN1 -De1 A1 CDATA a1val -De1 A2 TOKEN D1 D2 D3 D4 -De1 A3 CDATA a3val -Ie3 CDATA e3data -AA1 ENTITY e2 e1 e3 -(QT -)QT -?-- Comment -- -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test013.sgm b/cde/programs/dtdocbook/sgmls/test/out/test013.sgm deleted file mode 100644 index 6cd3d799c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test013.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --fooThis should be included.bar -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test014.sgm b/cde/programs/dtdocbook/sgmls/test/out/test014.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test014.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test015.sgm b/cde/programs/dtdocbook/sgmls/test/out/test015.sgm deleted file mode 100644 index c0cfe08ae..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test015.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT TOKEN FOO BAR -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test016.sgm b/cde/programs/dtdocbook/sgmls/test/out/test016.sgm deleted file mode 100644 index 4cf78ebc7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test016.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --\002xy -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test017.sgm b/cde/programs/dtdocbook/sgmls/test/out/test017.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test017.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test018.sgm b/cde/programs/dtdocbook/sgmls/test/out/test018.sgm deleted file mode 100644 index dc70c4e88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test018.sgm +++ /dev/null @@ -1,3 +0,0 @@ -AATT CDATA foobar -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test019.sgm b/cde/programs/dtdocbook/sgmls/test/out/test019.sgm deleted file mode 100644 index d58d26590..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test019.sgm +++ /dev/null @@ -1,15 +0,0 @@ -ANAME TOKEN FOO -(DOC -ANAME TOKEN SOMENAME -(FOO -)FOO --\nSome text<>.\n -ANAME TOKEN FOO -(DOC --foo -)DOC --\n -ANAME IMPLIED -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test020.sgm b/cde/programs/dtdocbook/sgmls/test/out/test020.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test021.sgm b/cde/programs/dtdocbook/sgmls/test/out/test021.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test022.sgm b/cde/programs/dtdocbook/sgmls/test/out/test022.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test022.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test023.sgm b/cde/programs/dtdocbook/sgmls/test/out/test023.sgm deleted file mode 100644 index 3fc3c99e6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test023.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -->\n>\ndoc|doc)>\n>\nfoo]bar -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test024.sgm b/cde/programs/dtdocbook/sgmls/test/out/test024.sgm deleted file mode 100644 index db46b5ca3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test024.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --\011\nbar -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test025.sgm b/cde/programs/dtdocbook/sgmls/test/out/test025.sgm deleted file mode 100644 index 7f535e640..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test025.sgm +++ /dev/null @@ -1,8 +0,0 @@ -(FOO -(END --stuff -)END -(BAR -)BAR -)FOO -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test026.sgm b/cde/programs/dtdocbook/sgmls/test/out/test026.sgm deleted file mode 100644 index fa89739c7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test026.sgm +++ /dev/null @@ -1,9 +0,0 @@ -(DOC -(A --foo -)A -(C --bar -)C -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test027.sgm b/cde/programs/dtdocbook/sgmls/test/out/test027.sgm deleted file mode 100644 index 90d926ef7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test027.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(TEST -)TEST diff --git a/cde/programs/dtdocbook/sgmls/test/out/test028.sgm b/cde/programs/dtdocbook/sgmls/test/out/test028.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test028.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test029.sgm b/cde/programs/dtdocbook/sgmls/test/out/test029.sgm deleted file mode 100644 index bfa8ff56a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test029.sgm +++ /dev/null @@ -1,12 +0,0 @@ -(DOC -(A --a -)A -(B --b -)B -(C --c -)C -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test030.sgm b/cde/programs/dtdocbook/sgmls/test/out/test030.sgm deleted file mode 100644 index 8b8deae62..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test030.sgm +++ /dev/null @@ -1,7 +0,0 @@ -AA1 CDATA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -AA2 CDATA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -AA3 CDATA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -AA4 CDATA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -AA5 TOKEN FOO BAR BAZ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test031.sgm b/cde/programs/dtdocbook/sgmls/test/out/test031.sgm deleted file mode 100644 index 21c496842..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test031.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(PLAIN --produce core dump\n -)PLAIN diff --git a/cde/programs/dtdocbook/sgmls/test/out/test032.sgm b/cde/programs/dtdocbook/sgmls/test/out/test032.sgm deleted file mode 100644 index 25660733c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test032.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(PLAIN --Ordinary text\neven ä\n and and\n]...oops\n -)PLAIN -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test033.sgm b/cde/programs/dtdocbook/sgmls/test/out/test033.sgm deleted file mode 100644 index ece47663d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test033.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT TOKEN FOO XYZ XYZ XYZ XYZ BAR FOOBAR FOO BAR -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test034.sgm b/cde/programs/dtdocbook/sgmls/test/out/test034.sgm deleted file mode 100644 index 7c9d25c02..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test034.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(*DOCTYPE --"ISO 8879-1986"> -)*DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/out/test035.sgm b/cde/programs/dtdocbook/sgmls/test/out/test035.sgm deleted file mode 100644 index e94f72493..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test035.sgm +++ /dev/null @@ -1,4 +0,0 @@ -?a processing instruction is not allowed before the SGML declaration -(*DOCTYPE --"ISO 8879-1986"> -)*DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/out/test036.sgm b/cde/programs/dtdocbook/sgmls/test/out/test036.sgm deleted file mode 100644 index 8c681a813..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test036.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(PLAIN --one blank, but no newline \nbefore eof -)PLAIN -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test037.sgm b/cde/programs/dtdocbook/sgmls/test/out/test037.sgm deleted file mode 100644 index fdb567193..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test037.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --ab -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test038.sgm b/cde/programs/dtdocbook/sgmls/test/out/test038.sgm deleted file mode 100644 index 8ae9c25f7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test038.sgm +++ /dev/null @@ -1,18 +0,0 @@ -(BIBLIO -(BOOK -(AUTHOR -- Harold Abelson and Gerald Jay Sussman -)AUTHOR -(TITLE -- Structure and Interpretation of Computer Programs -)TITLE -(PUBLISH -- MIT Press -)PUBLISH -(YEAR -- 1985 \n -)YEAR -)BOOK -(BOOK -)BOOK -)BIBLIO diff --git a/cde/programs/dtdocbook/sgmls/test/out/test039.sgm b/cde/programs/dtdocbook/sgmls/test/out/test039.sgm deleted file mode 100644 index 45a3f0821..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test039.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --Hello world. -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test040.sgm b/cde/programs/dtdocbook/sgmls/test/out/test040.sgm deleted file mode 100644 index 85f9a4c07..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test040.sgm +++ /dev/null @@ -1,9 +0,0 @@ -(DOC -(A -(T -)T -(R -)R -)A -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test041.sgm b/cde/programs/dtdocbook/sgmls/test/out/test041.sgm deleted file mode 100644 index 18cacae2c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test041.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(DOC -(FOO -)FOO -(FOO -)FOO -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test042.sgm b/cde/programs/dtdocbook/sgmls/test/out/test042.sgm deleted file mode 100644 index 8c0381d2b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test042.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT CDATA <> -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test043.sgm b/cde/programs/dtdocbook/sgmls/test/out/test043.sgm deleted file mode 100644 index b8069254f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test043.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --some cdata\n]>\nstuff -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test044.sgm b/cde/programs/dtdocbook/sgmls/test/out/test044.sgm deleted file mode 100644 index 4a6a0cb70..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test044.sgm +++ /dev/null @@ -1,8 +0,0 @@ -(DOC -(A -(R --x -)R -)A -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test045.sgm b/cde/programs/dtdocbook/sgmls/test/out/test045.sgm deleted file mode 100644 index a2be75ca0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test045.sgm +++ /dev/null @@ -1,8 +0,0 @@ -(DOC -(E -(R -)R --\ndata -)E -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test046.sgm b/cde/programs/dtdocbook/sgmls/test/out/test046.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test046.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test047.sgm b/cde/programs/dtdocbook/sgmls/test/out/test047.sgm deleted file mode 100644 index e5eefd00a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test047.sgm +++ /dev/null @@ -1,6 +0,0 @@ -(DOC --data -?pi --\n -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test048.sgm b/cde/programs/dtdocbook/sgmls/test/out/test048.sgm deleted file mode 100644 index febfc6785..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test048.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --x y -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test049.sgm b/cde/programs/dtdocbook/sgmls/test/out/test049.sgm deleted file mode 100644 index 2e272199a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test049.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AA IMPLIED -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test050.sgm b/cde/programs/dtdocbook/sgmls/test/out/test050.sgm deleted file mode 100644 index 0ffc1b9c2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test050.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(A -)A -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test051.sgm b/cde/programs/dtdocbook/sgmls/test/out/test051.sgm deleted file mode 100644 index a550e5745..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test051.sgm +++ /dev/null @@ -1,8 +0,0 @@ -(DOC -(E -?pi --\n -?pi -)E -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test052.sgm b/cde/programs/dtdocbook/sgmls/test/out/test052.sgm deleted file mode 100644 index 0ffc1b9c2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test052.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(A -)A -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test053.sgm b/cde/programs/dtdocbook/sgmls/test/out/test053.sgm deleted file mode 100644 index bdfce8ed7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test053.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(B -)B -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test054.sgm b/cde/programs/dtdocbook/sgmls/test/out/test054.sgm deleted file mode 100644 index 0ffc1b9c2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test054.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(A -)A -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test055.sgm b/cde/programs/dtdocbook/sgmls/test/out/test055.sgm deleted file mode 100644 index 0ffc1b9c2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test055.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(A -)A -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test056.sgm b/cde/programs/dtdocbook/sgmls/test/out/test056.sgm deleted file mode 100644 index 0ffc1b9c2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test056.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(A -)A -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test057.sgm b/cde/programs/dtdocbook/sgmls/test/out/test057.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test057.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test058.sgm b/cde/programs/dtdocbook/sgmls/test/out/test058.sgm deleted file mode 100644 index e5dc6e4bd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test058.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(DOC -NDCN -se -fe -Ee SDATA DCN -&e -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test059.sgm b/cde/programs/dtdocbook/sgmls/test/out/test059.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test059.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test060.sgm b/cde/programs/dtdocbook/sgmls/test/out/test060.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test060.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test061.sgm b/cde/programs/dtdocbook/sgmls/test/out/test061.sgm deleted file mode 100644 index fc497edcf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test061.sgm +++ /dev/null @@ -1,9 +0,0 @@ -(DOC -NDCN -se -fe -Ee NDATA DCN -De ATT IMPLIED -&e -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test062.sgm b/cde/programs/dtdocbook/sgmls/test/out/test062.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test062.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test063.sgm b/cde/programs/dtdocbook/sgmls/test/out/test063.sgm deleted file mode 100644 index 071c3d299..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test063.sgm +++ /dev/null @@ -1,9 +0,0 @@ -(DOC -ppubid -s -NDCN -se1 -fe1 -Ee NDATA DCN -&e -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test064.sgm b/cde/programs/dtdocbook/sgmls/test/out/test064.sgm deleted file mode 100644 index 59440952a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test064.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --This should be an A : A -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test065.sgm b/cde/programs/dtdocbook/sgmls/test/out/test065.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test066.sgm b/cde/programs/dtdocbook/sgmls/test/out/test066.sgm deleted file mode 100644 index 9444f3764..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test066.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --data -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test067.sgm b/cde/programs/dtdocbook/sgmls/test/out/test067.sgm deleted file mode 100644 index a52e8b546..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test067.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --\035\036 -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test068.sgm b/cde/programs/dtdocbook/sgmls/test/out/test068.sgm deleted file mode 100644 index 005504229..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test068.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --\035]> -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test069.sgm b/cde/programs/dtdocbook/sgmls/test/out/test069.sgm deleted file mode 100644 index e4d035d3e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test069.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -- \035]> -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test070.sgm b/cde/programs/dtdocbook/sgmls/test/out/test070.sgm deleted file mode 100644 index e4d035d3e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test070.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -- \035]> -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test071.sgm b/cde/programs/dtdocbook/sgmls/test/out/test071.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test071.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test072.sgm b/cde/programs/dtdocbook/sgmls/test/out/test072.sgm deleted file mode 100644 index a20ad8c3d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test072.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(DOC -(A -)A -(C -)C -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test073.sgm b/cde/programs/dtdocbook/sgmls/test/out/test073.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test074.sgm b/cde/programs/dtdocbook/sgmls/test/out/test074.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test074.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test075.sgm b/cde/programs/dtdocbook/sgmls/test/out/test075.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test075.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test076.sgm b/cde/programs/dtdocbook/sgmls/test/out/test076.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test076.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test077.sgm b/cde/programs/dtdocbook/sgmls/test/out/test077.sgm deleted file mode 100644 index 6de4ef15f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test077.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT IMPLIED -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test078.sgm b/cde/programs/dtdocbook/sgmls/test/out/test078.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test078.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test079.sgm b/cde/programs/dtdocbook/sgmls/test/out/test079.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test079.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test080.sgm b/cde/programs/dtdocbook/sgmls/test/out/test080.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test080.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test081.sgm b/cde/programs/dtdocbook/sgmls/test/out/test081.sgm deleted file mode 100644 index f0483b1d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test081.sgm +++ /dev/null @@ -1,3 +0,0 @@ -AATT IMPLIED -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test082.sgm b/cde/programs/dtdocbook/sgmls/test/out/test082.sgm deleted file mode 100644 index 5b445be5f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test082.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT1 TOKEN 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 123456 -AATT2 IMPLIED -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test083.sgm b/cde/programs/dtdocbook/sgmls/test/out/test083.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test083.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test084.sgm b/cde/programs/dtdocbook/sgmls/test/out/test084.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test084.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test085.sgm b/cde/programs/dtdocbook/sgmls/test/out/test085.sgm deleted file mode 100644 index 9e4b3171f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test085.sgm +++ /dev/null @@ -1,5 +0,0 @@ -(DOC -?data -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test086.sgm b/cde/programs/dtdocbook/sgmls/test/out/test086.sgm deleted file mode 100644 index f5b80c012..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test086.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test087.sgm b/cde/programs/dtdocbook/sgmls/test/out/test087.sgm deleted file mode 100644 index f5b80c012..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test087.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test088.sgm b/cde/programs/dtdocbook/sgmls/test/out/test088.sgm deleted file mode 100644 index 9444f3764..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test088.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --data -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test089.sgm b/cde/programs/dtdocbook/sgmls/test/out/test089.sgm deleted file mode 100644 index e9c45214f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test089.sgm +++ /dev/null @@ -1,5 +0,0 @@ -(DOC -?pi --data -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test090.sgm b/cde/programs/dtdocbook/sgmls/test/out/test090.sgm deleted file mode 100644 index f5b80c012..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test090.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test091.sgm b/cde/programs/dtdocbook/sgmls/test/out/test091.sgm deleted file mode 100644 index f5b80c012..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test091.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -(DOC -)DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test092.sgm b/cde/programs/dtdocbook/sgmls/test/out/test092.sgm deleted file mode 100644 index 1b0b05afc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test092.sgm +++ /dev/null @@ -1,5 +0,0 @@ -(DOC -?processing instruction --data -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test093.sgm b/cde/programs/dtdocbook/sgmls/test/out/test093.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test093.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test094.sgm b/cde/programs/dtdocbook/sgmls/test/out/test094.sgm deleted file mode 100644 index 3a80610f5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test094.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --x\|\|y -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test095.sgm b/cde/programs/dtdocbook/sgmls/test/out/test095.sgm deleted file mode 100644 index a3e055c3c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test095.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --This is test95.dat. -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test096.sgm b/cde/programs/dtdocbook/sgmls/test/out/test096.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test096.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test097.sgm b/cde/programs/dtdocbook/sgmls/test/out/test097.sgm deleted file mode 100644 index 31dfb76e6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test097.sgm +++ /dev/null @@ -1,5 +0,0 @@ -AA CDATA x -(DOC --y -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test098.sgm b/cde/programs/dtdocbook/sgmls/test/out/test098.sgm deleted file mode 100644 index a4348ab4a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test098.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --foo\nfoo\n -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test099.sgm b/cde/programs/dtdocbook/sgmls/test/out/test099.sgm deleted file mode 100644 index 0fed56ec1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test099.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AA TOKEN R -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test100.sgm b/cde/programs/dtdocbook/sgmls/test/out/test100.sgm deleted file mode 100644 index fd0f52630..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test100.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AA TOKEN -A -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test101.sgm b/cde/programs/dtdocbook/sgmls/test/out/test101.sgm deleted file mode 100644 index 388f6a370..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test101.sgm +++ /dev/null @@ -1,3 +0,0 @@ -AA IMPLIED -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test102.sgm b/cde/programs/dtdocbook/sgmls/test/out/test102.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test102.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test103.sgm b/cde/programs/dtdocbook/sgmls/test/out/test103.sgm deleted file mode 100644 index 388f6a370..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test103.sgm +++ /dev/null @@ -1,3 +0,0 @@ -AA IMPLIED -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test104.sgm b/cde/programs/dtdocbook/sgmls/test/out/test104.sgm deleted file mode 100644 index 7f7c2fd50..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test104.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --x x x -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test105.sgm b/cde/programs/dtdocbook/sgmls/test/out/test105.sgm deleted file mode 100644 index 51e694f2b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test105.sgm +++ /dev/null @@ -1,6 +0,0 @@ -AA1 CDATA \n -AA2 CDATA \012 -AA3 CDATA \011 -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test106.sgm b/cde/programs/dtdocbook/sgmls/test/out/test106.sgm deleted file mode 100644 index 0a158f298..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test106.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AA TOKEN FOO BAR -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test107.sgm b/cde/programs/dtdocbook/sgmls/test/out/test107.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test107.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test108.sgm b/cde/programs/dtdocbook/sgmls/test/out/test108.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test108.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test109.sgm b/cde/programs/dtdocbook/sgmls/test/out/test109.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test109.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test110.sgm b/cde/programs/dtdocbook/sgmls/test/out/test110.sgm deleted file mode 100644 index ffaef322f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test110.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC -?\000 -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test111.sgm b/cde/programs/dtdocbook/sgmls/test/out/test111.sgm deleted file mode 100644 index 6ab35cfc3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test111.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(DOC -NN -sxy -fxy -Ee CDATA N -&e -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test112.sgm b/cde/programs/dtdocbook/sgmls/test/out/test112.sgm deleted file mode 100644 index 27324c0f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test112.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --\000 -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test113.sgm b/cde/programs/dtdocbook/sgmls/test/out/test113.sgm deleted file mode 100644 index a1b0b607c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test113.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -? -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test114.sgm b/cde/programs/dtdocbook/sgmls/test/out/test114.sgm deleted file mode 100644 index 1a30b0f67..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test114.sgm +++ /dev/null @@ -1,4 +0,0 @@ -(DOC --00 -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test115.sgm b/cde/programs/dtdocbook/sgmls/test/out/test115.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test115.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test116.sgm b/cde/programs/dtdocbook/sgmls/test/out/test116.sgm deleted file mode 100644 index 3bff1a0ce..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test116.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC --- -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test117.sgm b/cde/programs/dtdocbook/sgmls/test/out/test117.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test117.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test118.sgm b/cde/programs/dtdocbook/sgmls/test/out/test118.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test119.sgm b/cde/programs/dtdocbook/sgmls/test/out/test119.sgm deleted file mode 100644 index 31b32ea31..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test119.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(*DOCTYPE --FOO\nQUANTITY SGMLREF\nFEATURES\nMINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES\nLINK SIMPLE NO IMPLICIT NO EXPLICIT NO\nOTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES\nAPPINFO NONE>\n doc [\n doc - o empty>\n]>\n -)*DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/out/test120.sgm b/cde/programs/dtdocbook/sgmls/test/out/test120.sgm deleted file mode 100644 index 3a8c6eafd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test120.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(*DOCTYPE --BAR\nQUANTITY SGMLREF\nFEATURES\nMINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES\nLINK SIMPLE NO IMPLICIT NO EXPLICIT NO\nOTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES\nAPPINFO NONE>\n doc [\n doc - o empty>\n]>\n -)*DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/out/test121.sgm b/cde/programs/dtdocbook/sgmls/test/out/test121.sgm deleted file mode 100644 index 388f6a370..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test121.sgm +++ /dev/null @@ -1,3 +0,0 @@ -AA IMPLIED -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test122.sgm b/cde/programs/dtdocbook/sgmls/test/out/test122.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test122.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test123.sgm b/cde/programs/dtdocbook/sgmls/test/out/test123.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test123.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test124.sgm b/cde/programs/dtdocbook/sgmls/test/out/test124.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test124.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test125.sgm b/cde/programs/dtdocbook/sgmls/test/out/test125.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test125.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test126.sgm b/cde/programs/dtdocbook/sgmls/test/out/test126.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test126.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test127.sgm b/cde/programs/dtdocbook/sgmls/test/out/test127.sgm deleted file mode 100644 index 36c530fe9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test127.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -- -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test128.sgm b/cde/programs/dtdocbook/sgmls/test/out/test128.sgm deleted file mode 100644 index 98ff64d88..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test128.sgm +++ /dev/null @@ -1,2 +0,0 @@ -(DOC -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test129.sgm b/cde/programs/dtdocbook/sgmls/test/out/test129.sgm deleted file mode 100644 index 36c530fe9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test129.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -- -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/out/test130.sgm b/cde/programs/dtdocbook/sgmls/test/out/test130.sgm deleted file mode 100644 index e69de29bb..000000000 diff --git a/cde/programs/dtdocbook/sgmls/test/out/test131.sgm b/cde/programs/dtdocbook/sgmls/test/out/test131.sgm deleted file mode 100644 index 31b32ea31..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test131.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(*DOCTYPE --FOO\nQUANTITY SGMLREF\nFEATURES\nMINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES\nLINK SIMPLE NO IMPLICIT NO EXPLICIT NO\nOTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES\nAPPINFO NONE>\n doc [\n doc - o empty>\n]>\n -)*DOCTYPE diff --git a/cde/programs/dtdocbook/sgmls/test/out/test132.sgm b/cde/programs/dtdocbook/sgmls/test/out/test132.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test132.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test133.sgm b/cde/programs/dtdocbook/sgmls/test/out/test133.sgm deleted file mode 100644 index f8b889cf5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test133.sgm +++ /dev/null @@ -1,11 +0,0 @@ -AID TOKEN FOO -(DOC -(A -)A -(A -AREF TOKEN FOO -(XREF -)XREF -)A -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test134.sgm b/cde/programs/dtdocbook/sgmls/test/out/test134.sgm deleted file mode 100644 index c897d1b67..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test134.sgm +++ /dev/null @@ -1,4 +0,0 @@ -AATT CDATA foo -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test135.sgm b/cde/programs/dtdocbook/sgmls/test/out/test135.sgm deleted file mode 100644 index bd6412618..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test135.sgm +++ /dev/null @@ -1,3 +0,0 @@ -(DOC -)DOC -C diff --git a/cde/programs/dtdocbook/sgmls/test/out/test136.sgm b/cde/programs/dtdocbook/sgmls/test/out/test136.sgm deleted file mode 100644 index 15b8b498b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/out/test136.sgm +++ /dev/null @@ -1,7 +0,0 @@ -(DOC -NDCN -se -fe -Ee NDATA DCN -&e -)DOC diff --git a/cde/programs/dtdocbook/sgmls/test/pubes.sgm b/cde/programs/dtdocbook/sgmls/test/pubes.sgm deleted file mode 100644 index 3a32c975d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/pubes.sgm +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - -]> -fooThis should be included.bar| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test014.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test014.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test014.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test015.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test015.sgm deleted file mode 100644 index 99cf1be7c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test015.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -ATT= -!FOO BAR! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test016.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test016.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test016.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test017.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test017.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test017.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test018.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test018.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test018.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test019.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test019.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test019.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test020.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test020.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test020.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test021.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test021.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test021.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test022.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test022.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test022.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test023.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test023.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test023.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test024.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test024.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test024.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test025.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test025.sgm deleted file mode 100644 index 624da7ef0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test025.sgm +++ /dev/null @@ -1,7 +0,0 @@ -[FOO] -[END] -|stuff| -[/END] -[BAR] -[/BAR] -[/FOO] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test026.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test026.sgm deleted file mode 100644 index 9f3cd8218..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test026.sgm +++ /dev/null @@ -1,8 +0,0 @@ -[DOC] -[A] -|foo| -[/A] -[C] -|bar| -[/C] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test027.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test027.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test027.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test028.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test028.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test028.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test029.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test029.sgm deleted file mode 100644 index f1fd3706d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test029.sgm +++ /dev/null @@ -1,11 +0,0 @@ -[DOC] -[A] -|a| -[/A] -[B] -|b| -[/B] -[C] -|c| -[/C] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test030.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test030.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test030.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test031.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test031.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test031.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test032.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test032.sgm deleted file mode 100644 index 0097c3f53..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test032.sgm +++ /dev/null @@ -1,11 +0,0 @@ -[PLAIN] -|Ordinary text| -#RE -|even ä| -#RE -| and and| -#RE -|]...oops| -#RE -| | -[/PLAIN] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test033.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test033.sgm deleted file mode 100644 index 977ced308..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test033.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -ATT= -!FOO XYZ XYZ XYZ XYZ BAR FOOBAR FOO BAR! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test034.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test034.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test034.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test035.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test035.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test035.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test036.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test036.sgm deleted file mode 100644 index bb0432992..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test036.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[PLAIN] -|one blank, but no newline | -#RE -|before eof | -[/PLAIN] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test037.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test037.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test037.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test038.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test038.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test038.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test039.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test039.sgm deleted file mode 100644 index 6bbc04f28..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test039.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|Hello world.| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test040.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test040.sgm deleted file mode 100644 index 174a32310..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test040.sgm +++ /dev/null @@ -1,8 +0,0 @@ -[DOC] -[A] -[T] -[/T] -[R] -[/R] -[/A] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test041.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test041.sgm deleted file mode 100644 index a91cad017..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test041.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -[FOO] -[/FOO] -[FOO] -[/FOO] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test042.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test042.sgm deleted file mode 100644 index c25b181d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test042.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -ATT= -!<>! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test043.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test043.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test043.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test044.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test044.sgm deleted file mode 100644 index 5b3246df0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test044.sgm +++ /dev/null @@ -1,7 +0,0 @@ -[DOC] -[A] -[R] -|x| -[/R] -[/A] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test045.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test045.sgm deleted file mode 100644 index 7594e0705..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test045.sgm +++ /dev/null @@ -1,8 +0,0 @@ -[DOC] -[E] -[R] -[/R] -#RE -|data| -[/E] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test046.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test046.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test046.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test047.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test047.sgm deleted file mode 100644 index 2a98b26d2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test047.sgm +++ /dev/null @@ -1,7 +0,0 @@ -[DOC] -|data| -[? -|pi| -] -#RE -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test048.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test048.sgm deleted file mode 100644 index 324e465ad..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test048.sgm +++ /dev/null @@ -1,19 +0,0 @@ -[DOC] -|x | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| | -| y| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test049.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test049.sgm deleted file mode 100644 index a2986541e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test049.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -A= -#IMPLIED -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test050.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test050.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test050.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test051.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test051.sgm deleted file mode 100644 index 732741639..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test051.sgm +++ /dev/null @@ -1,11 +0,0 @@ -[DOC] -[E] -[? -|pi| -] -#RE -[? -|pi| -] -[/E] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test052.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test052.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test052.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test053.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test053.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test053.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test054.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test054.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test054.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test055.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test055.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test055.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test056.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test056.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test056.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test057.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test057.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test057.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test058.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test058.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test058.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test059.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test059.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test059.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test060.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test060.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test060.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test061.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test061.sgm deleted file mode 100644 index a59c6fdf2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test061.sgm +++ /dev/null @@ -1,12 +0,0 @@ -[DOC] -[&e -#NDATA-EXTERNAL -#SYSTEM -!e! -#NOTATION=DCN -#SYSTEM -#NONE -ATT= -#IMPLIED -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test062.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test062.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test062.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test063.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test063.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test063.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test064.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test064.sgm deleted file mode 100644 index 60ee3cb8b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test064.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|This should be an A : A| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test065.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test065.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test065.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test066.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test066.sgm deleted file mode 100644 index 6268d69b2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test066.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|data| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test067.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test067.sgm deleted file mode 100644 index eeefa9e4a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test067.sgm +++ /dev/null @@ -1,4 +0,0 @@ -[DOC] -#29 -#30 -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test068.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test068.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test068.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test069.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test069.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test069.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test070.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test070.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test070.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test071.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test071.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test071.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test072.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test072.sgm deleted file mode 100644 index 430807f7e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test072.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -[A] -[/A] -[C] -[/C] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test073.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test073.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test073.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test074.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test074.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test074.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test075.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test075.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test075.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test076.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test076.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test076.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test077.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test077.sgm deleted file mode 100644 index 565b41736..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test077.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -ATT= -#IMPLIED -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test078.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test078.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test078.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test079.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test079.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test079.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test080.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test080.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test080.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test081.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test081.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test081.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test082.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test082.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test082.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test083.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test083.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test083.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test084.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test084.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test084.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test085.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test085.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test085.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test086.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test086.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test086.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test087.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test087.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test087.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test088.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test088.sgm deleted file mode 100644 index 6268d69b2..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test088.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|data| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test089.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test089.sgm deleted file mode 100644 index 733f1858d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test089.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -[? -|pi| -] -|data| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test090.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test090.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test090.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test091.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test091.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test091.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test092.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test092.sgm deleted file mode 100644 index 350b3a078..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test092.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -[? -|processing instruction| -] -|data| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test093.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test093.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test093.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test094.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test094.sgm deleted file mode 100644 index d1b962f9c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test094.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -|x| -#SDATA-TEXT -#END-SDATA -|y| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test095.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test095.sgm deleted file mode 100644 index ce8b8bd49..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test095.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|This is test95.dat.| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test096.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test096.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test096.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test097.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test097.sgm deleted file mode 100644 index 887d1be66..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test097.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC -A= -!x! -] -|y| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test098.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test098.sgm deleted file mode 100644 index 63807583c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test098.sgm +++ /dev/null @@ -1,6 +0,0 @@ -[DOC] -|foo| -#RE -|foo| -#RE -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test099.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test099.sgm deleted file mode 100644 index 554149a55..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test099.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -A= -!R! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test100.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test100.sgm deleted file mode 100644 index 97af2ae5e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test100.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -A= -!-A! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test101.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test101.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test101.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test102.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test102.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test102.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test103.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test103.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test103.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test104.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test104.sgm deleted file mode 100644 index 528ea1e79..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test104.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|x x x | -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test105.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test105.sgm deleted file mode 100644 index 676c48339..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test105.sgm +++ /dev/null @@ -1,9 +0,0 @@ -[DOC -A1= -#RE -A2= -#RS -A3= -#TAB -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test106.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test106.sgm deleted file mode 100644 index abc33d16b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test106.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -A= -!FOO BAR! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test107.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test107.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test107.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test108.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test108.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test108.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test109.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test109.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test109.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test110.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test110.sgm deleted file mode 100644 index fbb7281d7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test110.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC] -[? -#0 -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test111.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test111.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test111.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test112.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test112.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test112.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test113.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test113.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test113.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test114.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test114.sgm deleted file mode 100644 index 402d9261b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test114.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|00| -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test115.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test115.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test115.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test116.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test116.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test116.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test117.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test117.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test117.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test118.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test118.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test118.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test119.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test119.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test119.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test120.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test120.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test120.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test121.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test121.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test121.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test122.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test122.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test122.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test123.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test123.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test123.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test124.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test124.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test124.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test125.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test125.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test125.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test126.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test126.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test126.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test127.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test127.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test127.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test128.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test128.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test128.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test129.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test129.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test129.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test130.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test130.sgm deleted file mode 100644 index a64daedb3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test130.sgm +++ /dev/null @@ -1,3 +0,0 @@ -[DOC] -|This is it. | -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test131.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test131.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test131.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test132.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test132.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test132.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test133.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test133.sgm deleted file mode 100644 index 671a91caf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test133.sgm +++ /dev/null @@ -1,14 +0,0 @@ -[DOC -ID= -!FOO! -] -[A] -[/A] -[A] -[XREF -REF= -!FOO! -] -[/XREF] -[/A] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test134.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test134.sgm deleted file mode 100644 index 3738fcd2b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test134.sgm +++ /dev/null @@ -1,5 +0,0 @@ -[DOC -ATT= -!foo! -] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test135.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test135.sgm deleted file mode 100644 index 26f3865f0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test135.sgm +++ /dev/null @@ -1,2 +0,0 @@ -[DOC] -[/DOC] diff --git a/cde/programs/dtdocbook/sgmls/test/rast/test136.sgm b/cde/programs/dtdocbook/sgmls/test/rast/test136.sgm deleted file mode 100644 index ba45d2574..000000000 --- a/cde/programs/dtdocbook/sgmls/test/rast/test136.sgm +++ /dev/null @@ -1 +0,0 @@ -#ERROR diff --git a/cde/programs/dtdocbook/sgmls/test/sgmldecl.sgm b/cde/programs/dtdocbook/sgmls/test/sgmldecl.sgm deleted file mode 100644 index c671da17c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/sgmldecl.sgm +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -]> - -Some text. - diff --git a/cde/programs/dtdocbook/sgmls/test/subdoc.sgm b/cde/programs/dtdocbook/sgmls/test/subdoc.sgm deleted file mode 100644 index c8b4e938e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/subdoc.sgm +++ /dev/null @@ -1,7 +0,0 @@ - - -]> - -foo&memo;bar - diff --git a/cde/programs/dtdocbook/sgmls/test/test001.sgm b/cde/programs/dtdocbook/sgmls/test/test001.sgm deleted file mode 100644 index 9e15ac7ff..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test001.sgm +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - -]> - - -

A heading with a quotation in it.

-

A paragraph with an invalid &entity; reference in it -after the heading.

-

Another paragraph with a -and a in it.

-

Content that "looks" like a -<1start-tag> and an but isn't. - - -

- - -t1data/ - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/test002.sgm b/cde/programs/dtdocbook/sgmls/test/test002.sgm deleted file mode 100644 index 86c2c8e44..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test002.sgm +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - "> - "> - - - - "> - - - - - - - - - - - -] -- end of gdoc dtd --> - -A reference to the &e1 and the &e2;. -The entity &e3 -. - - -&phoney -&t2expi -&a; -&ent2; -&x; -a&#x; -&#tab;ĸb -&x2; - -/ -&be1&be2;&be3 -&be4; - - diff --git a/cde/programs/dtdocbook/sgmls/test/test003.sgm b/cde/programs/dtdocbook/sgmls/test/test003.sgm deleted file mode 100644 index b7fd4c9d6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test003.sgm +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -]> - - - - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/test004.sgm b/cde/programs/dtdocbook/sgmls/test/test004.sgm deleted file mode 100644 index 7534170a5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test004.sgm +++ /dev/null @@ -1,23 +0,0 @@ - - - - -]> - -d1m1e -]]>d1e -m3e -]]>ms2e]]> -ms4 -ms4e -]]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test005.sgm b/cde/programs/dtdocbook/sgmls/test/test005.sgm deleted file mode 100644 index 80c51492b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test005.sgm +++ /dev/null @@ -1,13 +0,0 @@ - - - -]> - - - - - - - - diff --git a/cde/programs/dtdocbook/sgmls/test/test006.sgm b/cde/programs/dtdocbook/sgmls/test/test006.sgm deleted file mode 100644 index 8142f42d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test006.sgm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -]> -index entry - -abc "quote2" def -index entry -ghi jkl mno - - -a "quoted" string -another - -"quoted string with 'nested and "inner" nested' quotes" - -string - -record -record - sub-record - sub-record -record - sub-record -record -/ diff --git a/cde/programs/dtdocbook/sgmls/test/test007.sgm b/cde/programs/dtdocbook/sgmls/test/test007.sgm deleted file mode 100644 index 1e0e971c0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test007.sgm +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -]> - -<> -

- - - - -] > - -B text -x textY text diff --git a/cde/programs/dtdocbook/sgmls/test/test009.sgm b/cde/programs/dtdocbook/sgmls/test/test009.sgm deleted file mode 100644 index 141e34bc0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test009.sgm +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - -]> - - diff --git a/cde/programs/dtdocbook/sgmls/test/test010.sgm b/cde/programs/dtdocbook/sgmls/test/test010.sgm deleted file mode 100644 index 5ce3c764c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test010.sgm +++ /dev/null @@ -1,14 +0,0 @@ - - - %md1; - - - - - %be3; -]> - -data -&be4; - diff --git a/cde/programs/dtdocbook/sgmls/test/test011.sgm b/cde/programs/dtdocbook/sgmls/test/test011.sgm deleted file mode 100644 index f9606acf6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test011.sgm +++ /dev/null @@ -1,13 +0,0 @@ - - - - - -]> - -da&#space;ta -data -da&#space;ta - diff --git a/cde/programs/dtdocbook/sgmls/test/test012.sgm b/cde/programs/dtdocbook/sgmls/test/test012.sgm deleted file mode 100644 index 5e612e50c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test012.sgm +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - -]> - - - diff --git a/cde/programs/dtdocbook/sgmls/test/test013.sgm b/cde/programs/dtdocbook/sgmls/test/test013.sgm deleted file mode 100644 index bc316374c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test013.sgm +++ /dev/null @@ -1,10 +0,0 @@ - -"> -"> - - -]> - -[foobar]]] - diff --git a/cde/programs/dtdocbook/sgmls/test/test014.sgm b/cde/programs/dtdocbook/sgmls/test/test014.sgm deleted file mode 100644 index e445ff4f1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test014.sgm +++ /dev/null @@ -1,7 +0,0 @@ - - - -]> - - diff --git a/cde/programs/dtdocbook/sgmls/test/test015.sgm b/cde/programs/dtdocbook/sgmls/test/test015.sgm deleted file mode 100644 index 17d81f838..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test015.sgm +++ /dev/null @@ -1,8 +0,0 @@ - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test016.sgm b/cde/programs/dtdocbook/sgmls/test/test016.sgm deleted file mode 100644 index 024d01a29..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test016.sgm +++ /dev/null @@ -1,4 +0,0 @@ - -]> -xy diff --git a/cde/programs/dtdocbook/sgmls/test/test017.sgm b/cde/programs/dtdocbook/sgmls/test/test017.sgm deleted file mode 100644 index c0c8f15b1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test017.sgm +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test018.sgm b/cde/programs/dtdocbook/sgmls/test/test018.sgm deleted file mode 100644 index ed8dd3e04..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test018.sgm +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test019.sgm b/cde/programs/dtdocbook/sgmls/test/test019.sgm deleted file mode 100644 index 4d14da5ab..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test019.sgm +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - -]> - - -Some text<>. - diff --git a/cde/programs/dtdocbook/sgmls/test/test020.sgm b/cde/programs/dtdocbook/sgmls/test/test020.sgm deleted file mode 100644 index 64ddd146f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test020.sgm +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/cde/programs/dtdocbook/sgmls/test/test021.sgm b/cde/programs/dtdocbook/sgmls/test/test021.sgm deleted file mode 100644 index 2a16506ac..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test021.sgm +++ /dev/null @@ -1,2 +0,0 @@ - -"> -%confuse; -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test023.sgm b/cde/programs/dtdocbook/sgmls/test/test023.sgm deleted file mode 100644 index 52c8ec3e5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test023.sgm +++ /dev/null @@ -1,12 +0,0 @@ - - - - -]> - - - - - -foo]bar diff --git a/cde/programs/dtdocbook/sgmls/test/test024.sgm b/cde/programs/dtdocbook/sgmls/test/test024.sgm deleted file mode 100644 index a7ec45117..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test024.sgm +++ /dev/null @@ -1,7 +0,0 @@ - -]> - - - -bar diff --git a/cde/programs/dtdocbook/sgmls/test/test025.sgm b/cde/programs/dtdocbook/sgmls/test/test025.sgm deleted file mode 100644 index db4a7bae3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test025.sgm +++ /dev/null @@ -1,12 +0,0 @@ - - -]> - - - -stuff - - - diff --git a/cde/programs/dtdocbook/sgmls/test/test026.sgm b/cde/programs/dtdocbook/sgmls/test/test026.sgm deleted file mode 100644 index bd2b2712a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test026.sgm +++ /dev/null @@ -1,6 +0,0 @@ - - -]> -foo -bar diff --git a/cde/programs/dtdocbook/sgmls/test/test027.sgm b/cde/programs/dtdocbook/sgmls/test/test027.sgm deleted file mode 100644 index 6bdbc624f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test027.sgm +++ /dev/null @@ -1,5 +0,0 @@ - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test028.sgm b/cde/programs/dtdocbook/sgmls/test/test028.sgm deleted file mode 100644 index efeb17781..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test028.sgm +++ /dev/null @@ -1,8 +0,0 @@ - - - -> - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test029.sgm b/cde/programs/dtdocbook/sgmls/test/test029.sgm deleted file mode 100644 index f6ca1face..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test029.sgm +++ /dev/null @@ -1,9 +0,0 @@ - - - -]> - -a -b -c diff --git a/cde/programs/dtdocbook/sgmls/test/test030.sgm b/cde/programs/dtdocbook/sgmls/test/test030.sgm deleted file mode 100644 index 445c1dcf8..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test030.sgm +++ /dev/null @@ -1,30 +0,0 @@ - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test031.sgm b/cde/programs/dtdocbook/sgmls/test/test031.sgm deleted file mode 100644 index bb326a1ec..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test031.sgm +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/cde/programs/dtdocbook/sgmls/test/test032.sgm b/cde/programs/dtdocbook/sgmls/test/test032.sgm deleted file mode 100644 index d534ba0cb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test032.sgm +++ /dev/null @@ -1,10 +0,0 @@ - -]> - - and and -]...oops -]]> diff --git a/cde/programs/dtdocbook/sgmls/test/test033.sgm b/cde/programs/dtdocbook/sgmls/test/test033.sgm deleted file mode 100644 index 5e77588bd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test033.sgm +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - -]> - diff --git a/cde/programs/dtdocbook/sgmls/test/test034.sgm b/cde/programs/dtdocbook/sgmls/test/test034.sgm deleted file mode 100644 index 10da15b81..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test034.sgm +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/cde/programs/dtdocbook/sgmls/test/test035.sgm b/cde/programs/dtdocbook/sgmls/test/test035.sgm deleted file mode 100644 index ec16c06d0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test035.sgm +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/cde/programs/dtdocbook/sgmls/test/test036.sgm b/cde/programs/dtdocbook/sgmls/test/test036.sgm deleted file mode 100644 index f3ae634b1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test036.sgm +++ /dev/null @@ -1,5 +0,0 @@ - -]> - -one blank, but no newline diff --git a/cde/programs/dtdocbook/sgmls/test/test037.sgm b/cde/programs/dtdocbook/sgmls/test/test037.sgm deleted file mode 100644 index 366596fc9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test037.sgm +++ /dev/null @@ -1,6 +0,0 @@ - - -]> - -a#b diff --git a/cde/programs/dtdocbook/sgmls/test/test038.sgm b/cde/programs/dtdocbook/sgmls/test/test038.sgm deleted file mode 100644 index c394703c0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test038.sgm +++ /dev/null @@ -1,17 +0,0 @@ - - - -]> - - - Harold Abelson and Gerald Jay Sussman - Structure and Interpretation of Computer Programs -<publish> MIT Press -<year> 1985 - -<book> diff --git a/cde/programs/dtdocbook/sgmls/test/test039.sgm b/cde/programs/dtdocbook/sgmls/test/test039.sgm deleted file mode 100644 index 2fa4f01b1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test039.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc o o (#PCDATA)> -]> -<![ IGNORE [This should be ignored]]> -Hello world. diff --git a/cde/programs/dtdocbook/sgmls/test/test040.sgm b/cde/programs/dtdocbook/sgmls/test/test040.sgm deleted file mode 100644 index fb1e3443d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test040.sgm +++ /dev/null @@ -1,9 +0,0 @@ -<!doctype doc [ -<!element doc - o (a*) +(r)> -<!element a - o (t,(s|r))> -<!element (r|s|t) - - (#pcdata)> -]> -<doc> -<a> -<t></> -<r></r> diff --git a/cde/programs/dtdocbook/sgmls/test/test041.sgm b/cde/programs/dtdocbook/sgmls/test/test041.sgm deleted file mode 100644 index 07caef0e3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test041.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - o (foo*)> -<!element foo - o (#pcdata)> -<!entity e starttag ""> -]> -<doc> -<foo> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test042.sgm b/cde/programs/dtdocbook/sgmls/test/test042.sgm deleted file mode 100644 index 4ec1b7e90..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test042.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc att cdata #implied> -<!entity e starttag ""> -]> -<doc att="&e;"> diff --git a/cde/programs/dtdocbook/sgmls/test/test043.sgm b/cde/programs/dtdocbook/sgmls/test/test043.sgm deleted file mode 100644 index cb7453d65..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test043.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc o o (#pcdata)> -<![ cdata [some cdata]]> -]> -stuff diff --git a/cde/programs/dtdocbook/sgmls/test/test044.sgm b/cde/programs/dtdocbook/sgmls/test/test044.sgm deleted file mode 100644 index 26dc44fa5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test044.sgm +++ /dev/null @@ -1,10 +0,0 @@ -<!doctype doc [ -<!element doc - - (a)> -<!element a - - (#pcdata) +(r)> -<!element r - - (#pcdata)> -]> -<doc> -<a> -<r>x</r> -</a> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test045.sgm b/cde/programs/dtdocbook/sgmls/test/test045.sgm deleted file mode 100644 index 4ec850313..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test045.sgm +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - - (e*)> -<!ELEMENT e - - (#PCDATA|a)* +(r)> -<!ELEMENT (a&r) - - (#PCDATA)> -]> -<doc> -<e> - -<r></r>data</e> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test046.sgm b/cde/programs/dtdocbook/sgmls/test/test046.sgm deleted file mode 100644 index f8792741f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test046.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - - (#PCDATA)> -]> -<doc> - -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test047.sgm b/cde/programs/dtdocbook/sgmls/test/test047.sgm deleted file mode 100644 index 29018969d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test047.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -]> -<doc> -data -<?pi> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test048.sgm b/cde/programs/dtdocbook/sgmls/test/test048.sgm deleted file mode 100644 index 297e2c1c0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test048.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o (#pcdata)> -]> -<doc> -x y diff --git a/cde/programs/dtdocbook/sgmls/test/test049.sgm b/cde/programs/dtdocbook/sgmls/test/test049.sgm deleted file mode 100644 index 80abfa095..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test049.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE doc [ -<!ATTLIST doc - a CDATA #CONREF -> -<!ELEMENT doc - O (#PCDATA)> -]> -<doc> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test050.sgm b/cde/programs/dtdocbook/sgmls/test/test050.sgm deleted file mode 100644 index cfddb7fa9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test050.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (a, b) -(b)> -<!element (a | b) - - (#pcdata)> -]> -<doc> -<a></a> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test051.sgm b/cde/programs/dtdocbook/sgmls/test/test051.sgm deleted file mode 100644 index f47d934fc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test051.sgm +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - - (e*)> -<!ELEMENT e - - (#PCDATA|a)*> -<!ELEMENT a - - (#PCDATA)> -]> -<doc> -<e> - -<?pi> -<?pi></e> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test052.sgm b/cde/programs/dtdocbook/sgmls/test/test052.sgm deleted file mode 100644 index aaba7efaf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test052.sgm +++ /dev/null @@ -1,10 +0,0 @@ -<!-- The RE after <doc> should cause an error. - See the Handbook, 323:3-6, 412:1-7. --> -<!doctype doc [ -<!element doc - o (a, #pcdata)> -<!element a - o (#pcdata)> -]> -<doc> -<a></a> -more stuff -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test053.sgm b/cde/programs/dtdocbook/sgmls/test/test053.sgm deleted file mode 100644 index b07ab209d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test053.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - ((a)?, b) -(a)> -<!element (a | b) - - (#pcdata)> -]> -<doc> -<b></b> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test054.sgm b/cde/programs/dtdocbook/sgmls/test/test054.sgm deleted file mode 100644 index cfddb7fa9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test054.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (a, b) -(b)> -<!element (a | b) - - (#pcdata)> -]> -<doc> -<a></a> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test055.sgm b/cde/programs/dtdocbook/sgmls/test/test055.sgm deleted file mode 100644 index 3d38f2313..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test055.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (a, (b, (c | d))?) -(c, d)> -<!element (a | b | c | d) - - (#pcdata)> -]> -<doc> -<a></a> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test056.sgm b/cde/programs/dtdocbook/sgmls/test/test056.sgm deleted file mode 100644 index 43bce59d4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test056.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (a, (b, c)?) -(c)> -<!element (a | b | c) - - (#pcdata)> -]> -<doc> -<a></a> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test057.sgm b/cde/programs/dtdocbook/sgmls/test/test057.sgm deleted file mode 100644 index 0ff450889..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test057.sgm +++ /dev/null @@ -1,11 +0,0 @@ -<!-- In my view, this isn't an error because (A? | B) is inherently -optional, and therefore is treated as if it were (A? | B)? -[414:10-12]. Excluding A has the same effect as if the group were -(B)?, and there if therefore no change to the required or optional -status of the group. --> -<!doctype doc [ -<!element doc - - (a? | b) -(a)> -<!element (a | b) - - (#pcdata)> -]> -<doc> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test058.sgm b/cde/programs/dtdocbook/sgmls/test/test058.sgm deleted file mode 100644 index 1a6a5e0b0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test058.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!notation dcn SYSTEM> -<!attlist #notation dcn att cdata #required> -<!entity e SYSTEM "e" SDATA dcn> -<!element doc - o (#PCDATA)> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test059.sgm b/cde/programs/dtdocbook/sgmls/test/test059.sgm deleted file mode 100644 index 627f2e3ef..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test059.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!-- I think this is an error even if `e' is not referenced. See 401:5-6. --> -<!doctype doc [ -<!entity e SYSTEM "e" NDATA dcn> -<!element doc - o (#PCDATA)> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test060.sgm b/cde/programs/dtdocbook/sgmls/test/test060.sgm deleted file mode 100644 index c32d64bc6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test060.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!-- I think this is an error even if no entity with this notation is -referenced. See 428:14-16. --> -<!doctype doc [ -<!attlist #notation dcn att cdata #implied> -<!element doc - o (#PCDATA)> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test061.sgm b/cde/programs/dtdocbook/sgmls/test/test061.sgm deleted file mode 100644 index d39341b45..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test061.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!notation dcn SYSTEM> -<!entity e SYSTEM "e" NDATA dcn> -<!attlist #notation dcn att cdata #implied> -<!element doc - o (#PCDATA)> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test062.sgm b/cde/programs/dtdocbook/sgmls/test/test062.sgm deleted file mode 100644 index 2d1fa5595..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test062.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!notation dcn SYSTEM> -<!attlist #notation dcn att (foo|bar|baz) #implied> -<!entity e SYSTEM "e" NDATA dcn [ att = foo ]> -<!element doc - o (#PCDATA)> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test063.sgm b/cde/programs/dtdocbook/sgmls/test/test063.sgm deleted file mode 100644 index 92c4cedb4..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test063.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - o (#pcdata)> -<!entity e system "e1" ndata dcn> -<!notation dcn PUBLIC "pubid" ""> -]> -<doc> -&e diff --git a/cde/programs/dtdocbook/sgmls/test/test064.sgm b/cde/programs/dtdocbook/sgmls/test/test064.sgm deleted file mode 100644 index 7d9a0bcea..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test064.sgm +++ /dev/null @@ -1,4 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - - (#PCDATA)> -]> -<doc>This should be an A : A</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test065.sgm b/cde/programs/dtdocbook/sgmls/test/test065.sgm deleted file mode 100644 index 26c7b54b3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test065.sgm +++ /dev/null @@ -1,3 +0,0 @@ -<!doctype doc [ -<!element (%e) - - any> -]> diff --git a/cde/programs/dtdocbook/sgmls/test/test066.sgm b/cde/programs/dtdocbook/sgmls/test/test066.sgm deleted file mode 100644 index de0389f51..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test066.sgm +++ /dev/null @@ -1,48 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 1 UNUSED - 1 127 0 -FUNCTION RE 14 - RS 11 - SPACE 33 - TAB SEPCHAR 10 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "./" - UCNMCHAR "./" - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - o (#pcdata)> -]> -<doc> -data diff --git a/cde/programs/dtdocbook/sgmls/test/test067.sgm b/cde/programs/dtdocbook/sgmls/test/test067.sgm deleted file mode 100644 index 7eb73442d..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test067.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o (#pcdata)> -]> -<doc> - diff --git a/cde/programs/dtdocbook/sgmls/test/test068.sgm b/cde/programs/dtdocbook/sgmls/test/test068.sgm deleted file mode 100644 index 22f7c6249..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test068.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!entity e "]>"> -]> -<doc> -&e; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test069.sgm b/cde/programs/dtdocbook/sgmls/test/test069.sgm deleted file mode 100644 index c6e051826..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test069.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!entity e "<![ RCDATA [ ]> ]]>"> -]> -<doc> -&e; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test070.sgm b/cde/programs/dtdocbook/sgmls/test/test070.sgm deleted file mode 100644 index 4443de9d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test070.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!entity e "<![ CDATA [ ]> ]]>"> -]> -<doc> -&e; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test071.sgm b/cde/programs/dtdocbook/sgmls/test/test071.sgm deleted file mode 100644 index 2b0118341..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test071.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!entity e "<![ IGNORE [ ]> ]]>"> -]> -<doc> -&e; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test072.sgm b/cde/programs/dtdocbook/sgmls/test/test072.sgm deleted file mode 100644 index 068cfd6fb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test072.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o ((a? & b?) & c?)> -<!element (a | b | c) - o empty> -]> -<doc><a><c> diff --git a/cde/programs/dtdocbook/sgmls/test/test073.sgm b/cde/programs/dtdocbook/sgmls/test/test073.sgm deleted file mode 100644 index 6d56113cc..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test073.sgm +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - - (placrule)> -<!ELEMENT placrule - O EMPTY> -<!ATTLIST placrule - a (a01|a02|a03|a04|a05) #IMPLIED - b (a06|a07|a08) #IMPLIED - c (a09|a10|a11|a12|a13|a14|a15|a16|a17|a18|a19) #IMPLIED - d (a20|a21) #IMPLIED - e (a22|a23|a24|a25|a26|a27|a28|a29|a30|a31|a32) #IMPLIED - f (a33|a34|a35) #IMPLIED -> -]> diff --git a/cde/programs/dtdocbook/sgmls/test/test074.sgm b/cde/programs/dtdocbook/sgmls/test/test074.sgm deleted file mode 100644 index 31d479416..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test074.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!entity % e "<![ ignore ["> -%e; ]]> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test075.sgm b/cde/programs/dtdocbook/sgmls/test/test075.sgm deleted file mode 100644 index 457184688..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test075.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!notation dcn1 system> -<!notation dcn2 system> -<!attlist #notation (dcn1 | dcn2 | dcn2) att cdata #implied> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test076.sgm b/cde/programs/dtdocbook/sgmls/test/test076.sgm deleted file mode 100644 index efb695110..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test076.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - - any +(a | a)> -<!element a - - any> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test077.sgm b/cde/programs/dtdocbook/sgmls/test/test077.sgm deleted file mode 100644 index 0ea3c5296..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test077.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!entity % a "att"> -<!-- an Ee is a parameter separator --> -<!attlist doc %a;cdata #implied> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test078.sgm b/cde/programs/dtdocbook/sgmls/test/test078.sgm deleted file mode 100644 index 75d1e1431..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test078.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!entity %-- a comment--e "foo"> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test079.sgm b/cde/programs/dtdocbook/sgmls/test/test079.sgm deleted file mode 100644 index ec57b7748..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test079.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!entity % percent "%"> -<!entity %percent;e "foo"> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test080.sgm b/cde/programs/dtdocbook/sgmls/test/test080.sgm deleted file mode 100644 index 6a7c0762a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test080.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - - any> -<!entity % name "e"> -<!entity %%name; "foo"> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test081.sgm b/cde/programs/dtdocbook/sgmls/test/test081.sgm deleted file mode 100644 index 1d03e5253..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test081.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!attlist doc att number 1n> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test082.sgm b/cde/programs/dtdocbook/sgmls/test/test082.sgm deleted file mode 100644 index d7d8cce8f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test082.sgm +++ /dev/null @@ -1,14 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!attlist doc -att1 numbers -"12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 -12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 -12345678 12345678 12345678 12345678 12345678 12345678 12345678 123456" -att2 numbers -"12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 -12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678 -12345678 12345678 12345678 12345678 12345678 12345678 12345678 1234567" -> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test083.sgm b/cde/programs/dtdocbook/sgmls/test/test083.sgm deleted file mode 100644 index 13c4f0473..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test083.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity % e10 "1234567890"> -<!entity % e100 "%e10;%e10;%e10;%e10;%e10;%e10;%e10;%e10;%e10;%e10;"> -<!entity x starttag "%e100;%e100;%e10;%e10;%e10;12345678"> -<!entity y starttag "%e100;%e100;%e10;%e10;%e10;123456789"> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test084.sgm b/cde/programs/dtdocbook/sgmls/test/test084.sgm deleted file mode 100644 index 46189be95..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test084.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity % e2345676 ""> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test085.sgm b/cde/programs/dtdocbook/sgmls/test/test085.sgm deleted file mode 100644 index 5a231b9f6..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test085.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity ent pi "data"> -]> -&ent; -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test086.sgm b/cde/programs/dtdocbook/sgmls/test/test086.sgm deleted file mode 100644 index 7b9ccf4bf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test086.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -]> -&#RE -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test087.sgm b/cde/programs/dtdocbook/sgmls/test/test087.sgm deleted file mode 100644 index 04073af05..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test087.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -]> -<![ include []]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test088.sgm b/cde/programs/dtdocbook/sgmls/test/test088.sgm deleted file mode 100644 index 7f0d44586..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test088.sgm +++ /dev/null @@ -1,4 +0,0 @@ -<!doctype doc [ -<!element doc o o (#pcdata)> -]> -<![ include [data]]> diff --git a/cde/programs/dtdocbook/sgmls/test/test089.sgm b/cde/programs/dtdocbook/sgmls/test/test089.sgm deleted file mode 100644 index a2e4ce58b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test089.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc o o any> -<!entity ent pi "pi"> -]> -&ent; -data diff --git a/cde/programs/dtdocbook/sgmls/test/test090.sgm b/cde/programs/dtdocbook/sgmls/test/test090.sgm deleted file mode 100644 index 7dbc4f902..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test090.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity ent ""> -]> -&ent; -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test091.sgm b/cde/programs/dtdocbook/sgmls/test/test091.sgm deleted file mode 100644 index 928d1eb25..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test091.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity ent starttag "doc"> -]> -&ent; diff --git a/cde/programs/dtdocbook/sgmls/test/test092.sgm b/cde/programs/dtdocbook/sgmls/test/test092.sgm deleted file mode 100644 index 299c32cc1..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test092.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc o o any> -]> -&#RE -<?processing instruction> -data diff --git a/cde/programs/dtdocbook/sgmls/test/test093.sgm b/cde/programs/dtdocbook/sgmls/test/test093.sgm deleted file mode 100644 index 64279d594..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test093.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity #default "text"> -<!entity e "%x;"> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test094.sgm b/cde/programs/dtdocbook/sgmls/test/test094.sgm deleted file mode 100644 index cbbc14e32..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test094.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!entity e sdata ""> -]> -<doc>x&e;y</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test095.sgm b/cde/programs/dtdocbook/sgmls/test/test095.sgm deleted file mode 100644 index c5a15a0c3..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test095.sgm +++ /dev/null @@ -1,4 +0,0 @@ -<!doctype doc [ -<!element doc - o (#pcdata)> -<!entity e system "test95.dat" -- or whatever --> -]> diff --git a/cde/programs/dtdocbook/sgmls/test/test096.sgm b/cde/programs/dtdocbook/sgmls/test/test096.sgm deleted file mode 100644 index e012e8896..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test096.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!attlist doc - a1 name #fixed "foo" - a2 names #fixed "foo" -> -<!element doc - o empty> -]> -<doc a1="bar" a2="bar baz"> diff --git a/cde/programs/dtdocbook/sgmls/test/test097.sgm b/cde/programs/dtdocbook/sgmls/test/test097.sgm deleted file mode 100644 index 032edb827..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test097.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!entity #default "x"> -<!element doc - - (#pcdata)> -<!attlist doc a cdata "&e;"> -<!entity e "y"> -]> -<doc>&e;</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test098.sgm b/cde/programs/dtdocbook/sgmls/test/test098.sgm deleted file mode 100644 index 44b6ff672..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test098.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - o (#pcdata)> -<!entity e "&x;&x;"> -<!entity x system "test98.txt"> -]> -<doc> -&e; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test099.sgm b/cde/programs/dtdocbook/sgmls/test/test099.sgm deleted file mode 100644 index 45c8b62c9..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test099.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - O ANY> -<!ATTLIST doc a (r|s) #FIXED "r"> -]> -<doc r> diff --git a/cde/programs/dtdocbook/sgmls/test/test100.sgm b/cde/programs/dtdocbook/sgmls/test/test100.sgm deleted file mode 100644 index b6a2e8c13..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test100.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - O ANY> -<!ATTLIST doc a NMTOKEN -A> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test101.sgm b/cde/programs/dtdocbook/sgmls/test/test101.sgm deleted file mode 100644 index 48de4df75..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test101.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - O ANY> -<!ATTLIST doc a CDATA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test102.sgm b/cde/programs/dtdocbook/sgmls/test/test102.sgm deleted file mode 100644 index 381835938..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test102.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE doc [ -<!ENTITY #DEFAULT "Default Entity"> -<!ELEMENT doc - O EMPTY> -<!NOTATION nota SYSTEM "Notation NOTA"> -<!ATTLIST #NOTATION nota att CDATA #IMPLIED> -<!ENTITY myent SYSTEM "tttt" SDATA nota [att="&myent;"]> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test103.sgm b/cde/programs/dtdocbook/sgmls/test/test103.sgm deleted file mode 100644 index 1127bdfcd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test103.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - O ANY> -<!ATTLIST doc a CDATA --- the following literal has 239 x's -- -"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test104.sgm b/cde/programs/dtdocbook/sgmls/test/test104.sgm deleted file mode 100644 index 1f351cd50..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test104.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity % amp "&"> -<!entity e "x%amp;#SPACE;"> -]> -<doc> -&e;&e;&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test105.sgm b/cde/programs/dtdocbook/sgmls/test/test105.sgm deleted file mode 100644 index 1b4f6e25f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test105.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a1 cdata #implied a2 cdata #implied a3 cdata #implied> -]> -<doc a1=" " a2=" " a3=" "> diff --git a/cde/programs/dtdocbook/sgmls/test/test106.sgm b/cde/programs/dtdocbook/sgmls/test/test106.sgm deleted file mode 100644 index 6f4465d08..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test106.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a names #implied> -]> -<doc a=" foo bar "> diff --git a/cde/programs/dtdocbook/sgmls/test/test107.sgm b/cde/programs/dtdocbook/sgmls/test/test107.sgm deleted file mode 100644 index 01c1113e5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test107.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a name #implied> -]> -<doc a=" foo"> diff --git a/cde/programs/dtdocbook/sgmls/test/test108.sgm b/cde/programs/dtdocbook/sgmls/test/test108.sgm deleted file mode 100644 index be40ed561..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test108.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a name #implied> -]> -<doc a=" foo"> diff --git a/cde/programs/dtdocbook/sgmls/test/test109.sgm b/cde/programs/dtdocbook/sgmls/test/test109.sgm deleted file mode 100644 index 85ce81c40..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test109.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a name #implied> -]> -<doc a=" foo"> diff --git a/cde/programs/dtdocbook/sgmls/test/test110.sgm b/cde/programs/dtdocbook/sgmls/test/test110.sgm deleted file mode 100644 index 070d4e819..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test110.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity e PI "�"> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test111.sgm b/cde/programs/dtdocbook/sgmls/test/test111.sgm deleted file mode 100644 index 12b0f740a..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test111.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!entity % p 'SYSTEM "x�y"'> -<!notation n system> -<!entity e %p; cdata n> -<!element doc - o any> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test112.sgm b/cde/programs/dtdocbook/sgmls/test/test112.sgm deleted file mode 100644 index 5af19225c..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test112.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity e "�"> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test113.sgm b/cde/programs/dtdocbook/sgmls/test/test113.sgm deleted file mode 100644 index 78e2977ae..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test113.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity e "<?�>"> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test114.sgm b/cde/programs/dtdocbook/sgmls/test/test114.sgm deleted file mode 100644 index 0786244fb..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test114.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!entity % amp "&"> -<!entity e "%amp;#48;"> -<!element doc - o any> -]> -<doc> -&e;&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test115.sgm b/cde/programs/dtdocbook/sgmls/test/test115.sgm deleted file mode 100644 index ba518d0fa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test115.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE doc [ -<!ELEMENT doc - O ANY> -<!ENTITY a SYSTEM ""> -]> -<doc>&a; diff --git a/cde/programs/dtdocbook/sgmls/test/test116.sgm b/cde/programs/dtdocbook/sgmls/test/test116.sgm deleted file mode 100644 index 70286d411..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test116.sgm +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE doc [ -<!USEMAP mymap doc> -<!ELEMENT doc - O ANY> -<!SHORTREF mymap - "-" e1 - "ZZ" e1 -> -<!ENTITY e1 "myentity"> -]> -<doc>-</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test117.sgm b/cde/programs/dtdocbook/sgmls/test/test117.sgm deleted file mode 100644 index 63e6c10c0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test117.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!usemap mymap chapter> -<!element doc - o (chapter*)> -<!element chapter - o any> -]> -<doc></doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test118.sgm b/cde/programs/dtdocbook/sgmls/test/test118.sgm deleted file mode 100644 index ac28885be..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test118.sgm +++ /dev/null @@ -1,49 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF -QUANTITY SGMLREF -LITLEN 241 -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL NO -APPINFO NONE> -<!doctype doc [ -<!element doc - o any> -<!-- the public identifier has 241 characters in --> -<!notation dcn public "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test119.sgm b/cde/programs/dtdocbook/sgmls/test/test119.sgm deleted file mode 100644 index 55610b6b0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test119.sgm +++ /dev/null @@ -1,46 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF DTD FOO -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - o empty> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test120.sgm b/cde/programs/dtdocbook/sgmls/test/test120.sgm deleted file mode 100644 index 88cb821aa..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test120.sgm +++ /dev/null @@ -1,46 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF FOO BAR -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - o empty> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test121.sgm b/cde/programs/dtdocbook/sgmls/test/test121.sgm deleted file mode 100644 index 29a6fed53..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test121.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o empty> -<!attlist doc a id "id"> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test122.sgm b/cde/programs/dtdocbook/sgmls/test/test122.sgm deleted file mode 100644 index cde1f8d24..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test122.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!element x 01 - o (#pcdata)> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test123.sgm b/cde/programs/dtdocbook/sgmls/test/test123.sgm deleted file mode 100644 index 0e33c8c8f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test123.sgm +++ /dev/null @@ -1,5 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!element x234567 0 - o any> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test124.sgm b/cde/programs/dtdocbook/sgmls/test/test124.sgm deleted file mode 100644 index fe532fb4f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test124.sgm +++ /dev/null @@ -1,6 +0,0 @@ -<!doctype doc [ -<!element doc - o any> -<!entity pi pi "pi data"> -]> -<doc> -<![ RCDATA [π]]> diff --git a/cde/programs/dtdocbook/sgmls/test/test125.sgm b/cde/programs/dtdocbook/sgmls/test/test125.sgm deleted file mode 100644 index 3d0b4ce59..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test125.sgm +++ /dev/null @@ -1,7 +0,0 @@ -<!doctype doc [ -<!element doc - - rcdata> -<!entity pi pi "pi data"> -]> -<doc> -π -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test126.sgm b/cde/programs/dtdocbook/sgmls/test/test126.sgm deleted file mode 100644 index ec61634fe..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test126.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - - rcdata> -<!notation dcn system> -<!entity ndata system "file" ndata dcn> -]> -<doc> -&ndata; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test127.sgm b/cde/programs/dtdocbook/sgmls/test/test127.sgm deleted file mode 100644 index e72a8378b..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test127.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!notation dcn system> -<!entity ndata system "file" ndata dcn> -]> -<doc> -<![ RCDATA [ &ndata; ]]> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test128.sgm b/cde/programs/dtdocbook/sgmls/test/test128.sgm deleted file mode 100644 index f4d42eff7..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test128.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - - rcdata> -<!notation dcn system> -<!entity cdata system "file" cdata dcn> -]> -<doc> -&cdata; -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test129.sgm b/cde/programs/dtdocbook/sgmls/test/test129.sgm deleted file mode 100644 index e87c14247..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test129.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!element doc - - (#pcdata)> -<!notation dcn system> -<!entity cdata system "file" cdata dcn> -]> -<doc> -<![ RCDATA [ &cdata; ]]> -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test130.sgm b/cde/programs/dtdocbook/sgmls/test/test130.sgm deleted file mode 100644 index c10fea71f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test130.sgm +++ /dev/null @@ -1,9 +0,0 @@ -<!doctype doc [ -<!element doc o o (#pcdata)> -<!entity e "foo"> -<!shortref map "&#space;" e> -]> -<doc> -<!-- There's a blank at the end of the next line --> -This is it. -</doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test131.sgm b/cde/programs/dtdocbook/sgmls/test/test131.sgm deleted file mode 100644 index 1ad2871cd..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test131.sgm +++ /dev/null @@ -1,46 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF NONSGML FOO -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - o empty> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test132.sgm b/cde/programs/dtdocbook/sgmls/test/test132.sgm deleted file mode 100644 index 6cf2c9ae8..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test132.sgm +++ /dev/null @@ -1,46 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF POSTLINK FOO -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - o empty> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test133.sgm b/cde/programs/dtdocbook/sgmls/test/test133.sgm deleted file mode 100644 index 85917a1e0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test133.sgm +++ /dev/null @@ -1,9 +0,0 @@ -<!doctype doc [ -<!element doc - o (a*)> -<!attlist doc id id #implied> -<!element a o o (xref|#pcdata)*> -<!element xref - - (#pcdata)> -<!attlist xref ref idref #conref> -]> -<doc id=foo> -<a><a><xref ref=foo> diff --git a/cde/programs/dtdocbook/sgmls/test/test134.sgm b/cde/programs/dtdocbook/sgmls/test/test134.sgm deleted file mode 100644 index f986d42d5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test134.sgm +++ /dev/null @@ -1,47 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG NO RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - - (#pcdata)> -<!attlist doc att cdata #conref> -]> -<doc att="foo"> diff --git a/cde/programs/dtdocbook/sgmls/test/test135.sgm b/cde/programs/dtdocbook/sgmls/test/test135.sgm deleted file mode 100644 index 9d0ec64bf..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test135.sgm +++ /dev/null @@ -1,46 +0,0 @@ -<!SGML "ISO 8879:1986" -CHARSET -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 9 UNUSED - 9 2 9 - 11 2 UNUSED - 13 1 13 - 14 18 UNUSED - 32 95 32 - 127 1 UNUSED -BASESET "ISO Registration Number 100//CHARSET ECMA-94 - Right Part of Latin Alphabet Nr. 1//ESC 2/13 4/1" -DESCSET 128 127 0 - 255 1 UNUSED -CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN" -SCOPE DOCUMENT -SYNTAX -SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255 -BASESET "ISO 646-1983//CHARSET International Reference Version - (IRV)//ESC 2/5 4/0" -DESCSET 0 128 0 -FUNCTION RE 13 - RS 10 - SPACE 32 - TAB SEPCHAR 9 -NAMING LCNMSTRT "" - UCNMSTRT "" - LCNMCHAR "-." - UCNMCHAR "-." - NAMECASE GENERAL YES - ENTITY NO -DELIM GENERAL SGMLREF - SHORTREF SGMLREF -NAMES SGMLREF -QUANTITY SGMLREF -FEATURES -MINIMIZE DATATAG NO OMITTAG NO RANK NO SHORTTAG YES -LINK SIMPLE NO IMPLICIT NO EXPLICIT NO -OTHER CONCUR NO SUBDOC YES 99999999 FORMAL YES -APPINFO NONE> -<!doctype doc [ -<!element doc - - empty> -]> -<doc> diff --git a/cde/programs/dtdocbook/sgmls/test/test136.sgm b/cde/programs/dtdocbook/sgmls/test/test136.sgm deleted file mode 100644 index 38406122f..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test136.sgm +++ /dev/null @@ -1,8 +0,0 @@ -<!doctype doc [ -<!notation dcn SYSTEM> -<!entity e SYSTEM "e" NDATA dcn> -<!attlist #notation dcn att cdata #required> -<!element doc - o (#PCDATA)> -]> -<doc> -&e; diff --git a/cde/programs/dtdocbook/sgmls/test/test2e.gml b/cde/programs/dtdocbook/sgmls/test/test2e.gml deleted file mode 100644 index 5b8de6b5e..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test2e.gml +++ /dev/null @@ -1,4 +0,0 @@ -[ Imbedded entity with -"delimiters" that are ignored in the attribute value -but processed in the content: -<t</t><?><!> &fake; ] diff --git a/cde/programs/dtdocbook/sgmls/test/test2x.gml b/cde/programs/dtdocbook/sgmls/test/test2x.gml deleted file mode 100644 index 04a406318..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test2x.gml +++ /dev/null @@ -1 +0,0 @@ -In x: &x; self-reference ignored. diff --git a/cde/programs/dtdocbook/sgmls/test/test4e.gml b/cde/programs/dtdocbook/sgmls/test/test4e.gml deleted file mode 100644 index 17a50fcd5..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test4e.gml +++ /dev/null @@ -1 +0,0 @@ -<![TEMP[MS in entity]]> diff --git a/cde/programs/dtdocbook/sgmls/test/test95.dat b/cde/programs/dtdocbook/sgmls/test/test95.dat deleted file mode 100644 index 2d4392b50..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test95.dat +++ /dev/null @@ -1 +0,0 @@ -This is test95.dat. diff --git a/cde/programs/dtdocbook/sgmls/test/test98.txt b/cde/programs/dtdocbook/sgmls/test/test98.txt deleted file mode 100644 index 483614dc0..000000000 --- a/cde/programs/dtdocbook/sgmls/test/test98.txt +++ /dev/null @@ -1,2 +0,0 @@ -# $XConsortium: test98.txt /main/2 1996/11/11 11:26:10 drk $ -foo diff --git a/cde/programs/dtdocbook/sgmls/thinkc.cfg b/cde/programs/dtdocbook/sgmls/thinkc.cfg deleted file mode 100755 index a8962e147..000000000 --- a/cde/programs/dtdocbook/sgmls/thinkc.cfg +++ /dev/null @@ -1,144 +0,0 @@ -/* thinkc.cfg: Configuration file for sgmls on the MAC with THINK C. */ -/* Contributed by John Chew (jjch@@AIS.Berger-Levrault.FR) */ - -/* Define this to allow tracing. */ -/* #define TRACE 1 */ - -/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports -X/Open extensions; if they do, then, for example, - - printf("%2$s%1$s", "bar", "foo") - -should print `foobar'. */ - -/* #define HAVE_EXTENDED_PRINTF 1 */ - -/* Define HAVE_CAT if your system provides the X/Open message -catalogue functions catopen() and catgets(), and you want to use them. -An implementations of these functions is included and will be used if -you don't define this. On SunOS 4.1.1, if you do define this you -should set CC=/usr/xpg2bin/cc in the makefile. */ - -/* #define HAVE_CAT 1 */ - -#ifdef __STDC__ -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 -#endif - -#ifdef __OBJECTCENTER__ -/* Define this if you have <varargs.h> but not <stdarg.h> */ -/* #define VARARGS 1 */ -#endif - -#ifndef USE_PROTOTYPES -/* Use VARARGS if prototypes are not supported. */ -#ifndef VARARGS -#define VARARGS 1 -#endif -#endif /* not USE_PROTOTYPES */ - -/* Define this if you do not have strerror(). */ -/* #define STRERROR_MISSING 1 */ - -/* Define this unless the character testing functions in ctype.h -are defined for all values representable as an unsigned char. You do -not need to define this if your system is ANSI C conformant. You -should define for old Unix systems. */ -/* #define USE_ISASCII 1 */ - -/* Define this if your system provides the BSD style string operations -rather than ANSI C ones (eg bcopy() rather than memcpy(), and index() -rather than strchr()). */ -/* #define BSD_STRINGS 1 */ - -/* Define this if you have getopt(). */ -/* #define HAVE_GETOPT 1 */ - -#define PATH_FILE_SEP ':' -#define DEFAULT_PATH "/8214808651/lib/%O/%C/%T;%N.%X;%N.%D" -#define PATH_ENV_VAR "SGML_PATH" -#define SYSID_FILE_SEP ':' -#define MIN_DAT_SUBS_FROM " /" -#define MIN_DAT_SUBS_TO "_%" - -/* Define this if you have access(). */ -/* #define HAVE_ACCESS 1 */ - -/* Define this if you have <unistd.h>. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define this if you have waitpid(). */ -/* #define HAVE_WAITPID 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C. */ -/* #define SUPPORT_SUBDOC 1 */ - -/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */ -/* #define POSIX 1 */ - -/* POSIX.1 compliant systems will certainly have access(), <unistd.h>, -and waitpid(). */ -#ifdef POSIX -#ifndef HAVE_ACCESS -#define HAVE_ACCESS 1 -#endif -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif -#ifndef HAVE_WAITPID -#define HAVE_WAITPID 1 -#endif -#endif /* POSIX */ - -/* Define this if you have the vfork() system call. */ -/* #define HAVE_VFORK 1 */ - -/* Define this if you have <vfork.h>. */ -/* #define HAVE_VFORK_H 1 */ - -/* Define this if you don't have <stdlib.h> */ -/* #define STDLIB_H_MISSING 1 */ - -/* Define this if you don't have <stddef.h> */ -/* #define STDDEF_H_MISSING 1 */ - -/* Define this if you don't have remove(); unlink() will be used instead. */ -/* #define REMOVE_MISSING 1 */ - -/* Define this if you don't have raise(); kill() will be used instead. */ -/* #define RAISE_MISSING 1 */ - -/* Universal pointer type. */ -/* Use this if your compiler doesn't fully support void * */ -/* typedef char *UNIV; */ -/* Otherwise use this */ -typedef void *UNIV; - -typedef void VOID; /* void as a function return type */ - -/* If you don't have an ANSI C conformant <limits.h>, define -CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed. -The <limits.h> on some versions of System Release V 3.2 is not ANSI C -conformant: the value of CHAR_MIN is 0 even though the `char' type is -signed. */ - -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include <limits.h> -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* Assume the system character set is ISO Latin-1. */ -#include "latin1.h" - -#include <console.h> - -/* This is called by main(). It prompts for a Unix style command line. */ -#define MAIN_HOOK(argc, argv) (argc = ccommand(&argv)) diff --git a/cde/programs/dtdocbook/sgmls/tools.h b/cde/programs/dtdocbook/sgmls/tools.h deleted file mode 100644 index 40045fd5f..000000000 --- a/cde/programs/dtdocbook/sgmls/tools.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tools.h /main/3 1996/06/19 17:18:54 drk $ */ -/* TOOLS.H: Definitions for type declarations, printing, bit handling, etc. -*/ - -#if CHAR_SIGNED -typedef unsigned char UNCH; -#else -typedef char UNCH; -#endif - -#if CHAR_SIGNED -#define ustrcmp(s1, s2) strcmp((char *)(s1), (char *)(s2)) -#define ustrcpy(s1, s2) strcpy((char *)(s1), (char *)(s2)) -#define ustrchr(s, c) (UNCH *)strchr((char *)(s), c) -#define ustrncmp(s1, s2, n) strncmp((char *)(s1), (char *)(s2), n) -#define ustrncpy(s1, s2, n) strncpy((char *)(s1), (char *)(s2), n) -#define ustrlen(s1) strlen((char *)(s1)) -#else -#define ustrcmp strcmp -#define ustrcpy strcpy -#define ustrchr strchr -#define ustrncmp strncmp -#define ustrncpy strncpy -#define ustrlen strlen -#endif - -#if 0 -int ustrcmp(UNCH *, UNCH *); -UNCH *ustrchr(UNCH *, int); -int ustrncmp(UNCH *, UNCH *, UNS); -int ustrncpy(UNCH *, UNCH *, UNS); -int ustrlen(UNCH *); -#endif - -typedef unsigned UNS; - -#ifdef USE_ISASCII -#define ISASCII(c) isascii(c) -#else -#define ISASCII(c) (1) -#endif - -#ifdef BSD_STRINGS -#define MEMZERO(s, n) bzero(s, n) -#else /* not BSD_STRINGS */ -#define MEMZERO(s, n) memset(s, '\0', n) -#endif /* not BSD_STRINGS */ - -/* Macros for bit manipulation. -*/ -#define SET(word, bits) ((word) |= (bits)) /* Turn bits on */ -#define RESET(word, bits) ((word) &= ~(bits)) /* Turn bits off */ -#define GET(word, bits) ((word) & (bits)) /* 1=any bit on */ -#define BITOFF(word, bits) (GET(word, bits)==0) /* 1=no bits on */ -#define BITON(word, bits) ((word) & (bits)) /* 1=any bit on */ - -#define ETDCDATA (dumetd) /* Dummy etd pointer for #PCDATA. */ -#define ETDNULL (dumetd + 1) /* Dummy etd pointer for null tag. */ -#define ETDNET (dumetd + 2) /* Dummy etd pointer for NET delimiter. */ -#define BADPTR(p) \ - ((p) == NULL || (p) == ETDCDATA || (p) == ETDNULL || (p) == ETDNET) -#define PTRNUM(p) ((p) == NULL ? 0 : ((p) - dumetd) + 1) - -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif - -/* VP is used for prototypes of varargs functions. You can't have a -prototype if the function is defined using varargs.h rather than -stdarg.h. */ -#ifdef VARARGS -#define VP(parms) () -#else -#define VP(parms) P(parms) -#endif diff --git a/cde/programs/dtdocbook/sgmls/trace.h b/cde/programs/dtdocbook/sgmls/trace.h deleted file mode 100644 index f8eb0fef8..000000000 --- a/cde/programs/dtdocbook/sgmls/trace.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: trace.h /main/3 1996/06/19 17:18:59 drk $ */ -/* TRACE.H: Declarations for internal trace functions. */ - -#ifdef TRACE - -/* Trace variables. -*/ -extern int trace; /* Switch: 1=trace state transitions; 0=don't. */ -extern int atrace; /* Switch: 1=trace attribute activity; 0=don't. */ -extern int ctrace; /* Switch: 1=trace context checking; 0=don't. */ -extern int dtrace; /* Switch: 1=trace declaration parsing; 0=don't.*/ -extern int etrace; /* Switch: 1=trace entity activity; 0=don't.*/ -extern int gtrace; /* Switch: 1=trace group creations; 0=don't. */ -extern int itrace; /* Switch: 1=trace ID activity; 0=don't. */ -extern int mtrace; /* Switch: 1=trace MS activity; 0=don't. */ -extern int ntrace; /* Switch: 1=trace data notation activity. */ -extern char emd[]; /* For "EMD" parameter type in dtrace calls. */ - -VOID traceadl P((struct ad *)); -VOID tracecon P((int,int,int,struct parse *,int,int)); -VOID tracedcn P((struct dcncb *)); -VOID tracedsk P((struct tag *,struct tag *,int,int)); -VOID traceecb P((char *,struct entity *)); -VOID traceend P((char *,struct thdr *,struct mpos *,int,int,int)); -VOID traceesn P((struct ne *)); -VOID traceetd P((struct etd *)); -VOID traceetg P((struct tag *,struct etd *,int,int)); -VOID tracegi P((char *,struct etd *,struct thdr *,struct mpos *,int)); -VOID tracegml P((struct restate *,int,int,int)); -VOID tracegrp P((struct etd **)); -VOID traceid P((char *,struct id *)); -VOID tracemd P((char *)); -VOID tracemod P((struct thdr *)); -VOID tracems P((int,int,int,int)); -VOID tracengr P((struct dcncb **)); -VOID tracepcb P((struct parse *)); -VOID tracepro P((void)); -VOID traceset P((void)); -VOID tracesrm P((char *,struct entity **,UNCH *)); -VOID tracestg P((struct etd *,int,int,struct etd *,int)); -VOID tracestk P((struct tag *,int,int)); -VOID tracetkn P((int,UNCH *)); -VOID traceval P((struct parse *,unsigned int,UNCH *,int)); - -#define TRACEADL(al) ((void)(atrace && (traceadl(al), 1))) -#define TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq) \ - ((void)(gtrace \ - && (tracecon(etagimct, dostag, datarc, pcb, conrefsw, didreq), 1))) -#define TRACEDCN(dcn) ((void)(ntrace && (tracedcn(dcn), 1))) -#define TRACEDSK(pts, ptso, ts3, etictr) \ - ((void)(gtrace && (tracedsk(pts, ptso, ts3, etictr), 1))) -#define TRACEECB(action, p) \ - ((void)(etrace && (traceecb(action, p), 1))) -#define TRACEEND(stagenm, mod, pos, rc, opt, Tstart) \ - ((void)(ctrace && (traceend(stagenm, mod, pos, rc, opt, Tstart), 1))) -#define TRACEESN(p) \ - ((void)((etrace || atrace || ntrace) && (traceesn(p), 1))) -#define TRACEETD(p) ((void)(gtrace && (traceetd(p), 1))) -#define TRACEETG(pts, curetd, tsl, etagimct) \ - ((void)(gtrace && (traceetg(pts, curetd, tsl, etagimct), 1))) -#define TRACEGI(stagenm, gi, mod, pos, Tstart) \ - ((void)(ctrace && (tracegi(stagenm, gi, mod, pos, Tstart), 1))) -#define TRACEGML(scb, pss, conactsw, conact) \ - ((void)(trace && (tracegml(scb, pss, conactsw, conact), 1))) -#define TRACEGRP(p) ((void)(gtrace && (tracegrp(p), 1))) -#define TRACEID(action, p) ((void)(itrace && (traceid(action, p), 1))) -#define TRACEMD(p) ((void)(dtrace && (tracemd(p), 1))) -#define TRACEMOD(p) ((void)(gtrace && (tracemod(p), 1))) -#define TRACEMS(action, code, mslevel, msplevel) \ - ((void)(mtrace && (tracems(action, code, mslevel, msplevel), 1))) -#define TRACENGR(p) ((void)(gtrace && (tracengr(p), 1))) -#define TRACEPCB(p) ((void)(trace && (tracepcb(p), 1))) -#define TRACEPRO() (tracepro()) -#define TRACESET() (traceset()) -#define TRACESRM(action, pg, gi) \ - ((void)(etrace && (tracesrm(action, pg, gi), 1))) -#define TRACESTG(curetd, dataret, rc, nextetd, mexts) \ - ((void)(gtrace && (tracestg(curetd, dataret, rc, nextetd, mexts), 1))) -#define TRACESTK(pts, ts2, etictr) \ - ((void)(gtrace && (tracestk(pts, ts2, etictr), 1))) -#define TRACETKN(scope, lextoke) \ - ((void)(trace && (tracetkn(scope, lextoke), 1))) -#define TRACEVAL(pcb, atype, aval, tokencnt) \ - ((void)(atrace && (traceval(pcb, atype, aval, tokencnt), 1))) - -#else /* not TRACE */ - -#define TRACEADL(al) /* empty */ -#define TRACECON(etagimct, dostag, datarc, pcb, conrefsw, didreq) /* empty */ -#define TRACEDCN(dcn) /* empty */ -#define TRACEDSK(pts, ptso, ts3, etictr) /* empty */ -#define TRACEECB(action, p) /* empty */ -#define TRACEEND(stagenm, mod, pos, rc, opt, Tstart) /* empty */ -#define TRACEESN(p) /* empty */ -#define TRACEETG(pts, curetd, tsl, etagimct) /* empty */ -#define TRACEETD(p) /* empty */ -#define TRACEGI(stagenm, gi, mod, pos, Tstart) /* empty */ -#define TRACEGML(scb, pss, conactsw, conact) /* empty */ -#define TRACEGRP(p) /* empty */ -#define TRACEID(action, p) /* empty */ -#define TRACEMD(p) /* empty */ -#define TRACEMOD(p) /* empty */ -#define TRACEMS(action, code, mslevel, msplevel) /* empty */ -#define TRACENGR(p) /* empty */ -#define TRACEPCB(p) /* empty */ -#define TRACEPRO() /* empty */ -#define TRACESET() /* empty */ -#define TRACESRM(action, pg, gi) /* empty */ -#define TRACESTG(curetd, dataret, rc, nextetd, mexts) /* empty */ -#define TRACESTK(pts, ts2, etictr) /* empty */ -#define TRACETKN(scope, lextoke) /* empty */ -#define TRACEVAL(pcb, atype, aval, tokencnt) /* empty */ - -#endif /* not TRACE */ diff --git a/cde/programs/dtdocbook/sgmls/traceset.c b/cde/programs/dtdocbook/sgmls/traceset.c deleted file mode 100644 index 594ae63cf..000000000 --- a/cde/programs/dtdocbook/sgmls/traceset.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: traceset.c /main/3 1996/06/19 17:19:04 drk $ */ -#include "sgmlincl.h" /* #INCLUDE statements for SGML parser. */ - -#ifdef TRACE - -#include "context.h" - -/* Token status: RCHIT RCMISS RCEND RCREQ RCNREQ */ -#define STATUX tags[ts].status - -/* Trace variables. -*/ -int trace = 0; /* Switch: 1=trace state transitions; 0=don't. */ -int atrace = 0; /* Switch: 1=trace attribute activity; 0=don't. */ -int ctrace = 0; /* Switch: 1=trace context checking; 0=don't. */ -int dtrace = 0; /* Switch: 1=trace declaration parsing; 0=don't.*/ -int etrace = 0; /* Switch: 1=trace entity activity; 0=don't.*/ -int gtrace = 0; /* Switch: 1=trace group creations; 0=don't. */ -int itrace = 0; /* Switch: 1=trace ID activity; 0=don't. */ -int mtrace = 0; /* Switch: 1=trace MS activity; 0=don't. */ -int ntrace = 0; /* Switch: 1=trace notation activity; 0=don't. */ -char emd[] = "EMD"; /* For "EMD" parameter type in dtrace calls. */ - -/* Return a printable representation of c. -*/ -static -char *printable(c) -int c; -{ - static char buf[5]; - if (c >= 040 && c < 0177) { - buf[0] = c; - buf[1] = '\0'; - } - else - sprintf(buf, "\\%03o", (UNCH)c); - return buf; -} - -static -VOID dotrace(s) -char *s; -{ - trace = (s && strchr(s, 't') != 0); - atrace = (s && strchr(s, 'a') != 0); - ctrace = (s && strchr(s, 'c') != 0); - dtrace = (s && strchr(s, 'd') != 0); - etrace = (s && strchr(s, 'e') != 0); - gtrace = (s && strchr(s, 'g') != 0); - itrace = (s && strchr(s, 'i') != 0); - mtrace = (s && strchr(s, 'm') != 0); - ntrace = (s && strchr(s, 'n') != 0); -} -/* TRACESET: Set switches for tracing body of document. -*/ -VOID traceset() -{ - dotrace(sw.trace); - - if (trace||atrace||ctrace||dtrace||etrace||gtrace||itrace||mtrace||ntrace) - fprintf(stderr, -"TRACESET: state=%d;att=%d;con=%d;dcl=%d;ent=%d;grp=%d;id=%d;ms=%d;dcn=%d.\n", - trace, atrace, ctrace, dtrace, etrace, gtrace, itrace, - mtrace, ntrace); -} -/* TRACEPRO: Set switches for tracing prolog. - */ -VOID tracepro() -{ - dotrace(sw.ptrace); - - if (trace||atrace||dtrace||etrace||gtrace||mtrace||ntrace) - fprintf(stderr, - "TRACEPRO: state=%d; att=%d; dcl=%d; ent=%d; grp=%d; ms=%d; dcn=%d.\n", - trace, atrace, dtrace, etrace, gtrace, mtrace, ntrace); -} -/* TRACEPCB: Trace character just parsed and other pcb data. - */ -VOID tracepcb(pcb) -struct parse *pcb; -{ - fprintf(stderr, "%-8s %2u-%2u-%2u-%2u from %s [%3d] in %s, %d:%d.\n", - pcb->pname, pcb->state, pcb->input, pcb->action, - pcb->newstate, printable(*FPOS), *FPOS, ENTITY+1, RCNT, - RSCC+FPOS+1-FBUF); -} -/* TRACETKN: Trace character just read during token parse. - */ -VOID tracetkn(scope, lextoke) -int scope; -UNCH lextoke[]; /* Lexical table for token and name parses. */ -{ - fprintf(stderr, "TOKEN %2d-%2d from %s [%3d] in %s, %d:%d.\n", - scope, lextoke[*FPOS], - printable(*FPOS), *FPOS, ENTITY+1, RCNT, - RSCC+FPOS+1-FBUF); -} -/* TRACEGML: Trace state of main SGML driver routine. - */ -VOID tracegml(scb, pss, conactsw, conact) -struct restate *scb; -int pss, conactsw, conact; -{ - fprintf(stderr, - "SGML%02d %2d-%2d-%2d-%2d in main driver; conactsw=%d; conact=%d.\n", - pss, scb[pss].sstate, scb[pss].sinput, scb[pss].saction, - scb[pss].snext, conactsw, conact); -} -/* TRACEVAL: Trace parse of an attribute value that is a token list. - */ -VOID traceval(pcb, atype, aval, tokencnt) -struct parse *pcb; -UNS atype; /* Type of token list expected. */ -UNCH *aval; /* Value string to be parsed as token list. */ -int tokencnt; /* Number of tokens found in attribute value. */ -{ - fprintf(stderr, - "%-8s %2d-%2d-%2d-%2d at %p, atype=%02x, tokencnt=%d: ", - pcb->pname, pcb->state, pcb->input, pcb->action, - pcb->newstate, (UNIV)aval, atype, tokencnt); - fprintf(stderr, "%s\n", aval); -} -/* TRACESTK: Trace entry just placed on tag stack. - */ -VOID tracestk(pts, ts2, etictr) -struct tag *pts; /* Stack entry for this tag. */ -int ts2; /* Stack depth. */ -int etictr; /* Number of "netok" tags on stack. */ -{ - fprintf(stderr, - "STACK %s begun; stack depth %d; tflag=%02x; etictr=%d", - pts->tetd->etdgi+1, ts2, pts->tflags, etictr); - fprintf(stderr, " srm=%s.\n", - pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY"); -} -/* TRACEDSK: Trace entry just removed from tag stack. - */ -VOID tracedsk(pts, ptso, ts3, etictr) -struct tag *pts; /* Stack entry for new open tag. */ -struct tag *ptso; /* Stack entry for tag just ended. */ -int ts3; /* Stack depth. */ -int etictr; /* Number of "netok" tags on stack. */ -{ - fprintf(stderr, - "DESTACK %s ended; otflag=%02x; %s resumed; depth=%d; tflag=%02x; etictr=%d", - ptso->tetd->etdgi+1, ptso->tflags, - pts->tetd->etdgi+1, ts3, pts->tflags, etictr); - fprintf(stderr, " srm=%s.\n", - pts->tsrm!=SRMNULL ? (char *)(pts->tsrm[0]->ename+1) : "#EMPTY"); -} -/* TRACECON: Trace interactions between content parse and stag/context - processing. - */ -VOID tracecon(etagimct, dostag, datarc, pcb, conrefsw, didreq) -int etagimct; /* Implicitly ended elements left on stack. */ -int dostag; /* 1=retry newetd instead of parsing; 0=parse. */ -int datarc; /* Return code for data: DAF_ or REF_ or zero. */ -struct parse *pcb; /* Parse control block for this parse. */ -int conrefsw; /* 1=content reference att specified; 0=no. */ -int didreq; /* 1=required implied empty tag processed; 0=no.*/ -{ - fprintf(stderr, - "CONTENT etagimct=%d dostag=%d datarc=%d pname=%s action=%d \ -conrefsw=%d didreq=%d\n", - etagimct, dostag, datarc, pcb->pname, pcb->action, - conrefsw, didreq); -} -/* TRACESTG: Trace start-tag context validation input and results. - */ -VOID tracestg(curetd, dataret, rc, nextetd, mexts) -struct etd *curetd; /* The etd for this tag. */ -int dataret; /* Data pending: DAF_ REF_ 0=not #PCDATA. */ -int rc; /* Return code from context or other test. */ -struct etd *nextetd; /* The etd for a forced start-tag (if rc==2). */ -int mexts; /* >0=stack level of minus grp; -1=plus; 0=none.*/ -{ - fprintf(stderr, - "STARTTAG newetd=%p; dataret=%d; rc=%d; nextetd=%p; mexts=%d.\n", - (UNIV)curetd, dataret, rc, (UNIV)nextetd, mexts); -} -/* TRACEETG: Trace end-tag matching test on stack. - */ -VOID traceetg(pts, curetd, tsl, etagimct) -struct tag *pts; /* Stack entry for this tag. */ -struct etd *curetd; /* The etd for this tag. */ -int tsl; /* Temporary stack level for looping. */ -int etagimct; /* Num of implicitly ended tags left on stack. */ -{ - fprintf(stderr, - "ENDTAG tsl=%d; newetd=%p; stacketd=%p; tflags=%02x; etagimct=%d.\n", - tsl, (UNIV)curetd, (UNIV)pts->tetd, pts->tflags, etagimct); -} -/* TRACEECB: Trace entity control block activity. - */ -VOID traceecb(action, p) -char *action; -struct entity *p; -{ - static char estype1[] = " TMMMSEIXCNFPDLK"; - static char estype2[] = " DS "; - if (!p) - return; - fprintf(stderr, - "%-8s (es=%d) type %c%c entity %s at %p containing ", - action, es, estype1[p->estore], estype2[p->estore], p->ename+1, - (UNIV)p); - if (p->estore==ESN && strcmp(action, "ENTDEF")) - traceesn(p->etx.n); - else if (p->etx.x==0) - fprintf(stderr, "[NOTHING]"); - else - fprintf(stderr, "%s", - p->etx.c[0] ? (char *)p->etx.c : "[EMPTY]"); - putc('\n', stderr); -} -/* TRACEDCN: Trace data content notation activity. - */ -VOID tracedcn(p) -struct dcncb *p; -{ - fprintf(stderr, - "DCN dcn=%p; adl=%p; notation is %s\n", - (UNIV)p, (UNIV)p->adl, p->ename+1); - if (p->adl) - traceadl(p->adl); -} -/* TRACEESN: Print a data entity control block. - */ -VOID traceesn(p) -PNE p; -{ - fprintf(stderr, "ESN Entity name is %s; entity type is %s.\n", - (NEENAME(p)!=0) ? ((char *)NEENAME(p))+1 : "[UNDEFINED]", - /* NEXTYPE(p)); */ - (NEXTYPE(p)==1 ? "CDATA" : (NEXTYPE(p)==2 ? "NDATA" : "SDATA"))); - fprintf(stderr, " System ID is %s\n", - (NEID(p)!=0) ? (char *)NEID(p) : "[UNDEFINED]"); - if (p->nedcn!=0) - tracedcn(p->nedcn); -} -/* TRACESRM: Print the members of a short reference map. - */ -VOID tracesrm(action, pg, gi) -char *action; -TECB pg; -UNCH *gi; -{ - int i = 0; /* Loop counter. */ - - if (pg==SRMNULL) - fprintf(stderr, "%-8s SHORTREF table empty for %s.\n", action, gi); - else { - fprintf(stderr, "%-8s %s at %p mapped for %s.\n", - action, pg[0]->ename+1, (UNIV)pg, - gi ? (char *)gi : "definition"); - while (++i<=lex.s.dtb[0].mapdata) - if (pg[i]) - fprintf(stderr, "%14s%02u %p %s\n", - "SR", i, (UNIV)pg[i], pg[i]->ename+1); - } -} -/* TRACEADL: Print an attribute definition list. - */ -VOID traceadl(al) -struct ad al[]; -{ - int i=0; - - fprintf(stderr, "ADLIST %p %d membe%s; %d attribut%s\n", - (UNIV)al, ADN(al), ADN(al)==1 ? "r" : "rs", AN(al), - AN(al)==1 ? "e" : "es"); - while (++i<=ADN(al)) { - fprintf(stderr, - (BITOFF(ADFLAGS(al,i), AGROUP) && ADTYPE(al,i)<=ANOTEGRP) - ? " %p %-8s %02x %02x %2d %2d %p %p\n" - : " %p %-8s %02x %02x %2d %2d %p %p\n", - &al[i], ADNAME(al,i), ADFLAGS(al,i), ADTYPE(al,i), ADNUM(al,i), - ADLEN(al,i), ADVAL(al,i), ADDATA(al,i).x); - if (ADVAL(al,i)) { - fprintf(stderr, "%s", ADVAL(al,i)); - if (ADTYPE(al,i)==AENTITY && ADDATA(al,i).n!=0) { - fprintf(stderr, "=>"); - traceesn(ADDATA(al,i).n); - } - else if (ADTYPE(al,i)==ANOTEGRP) - fprintf(stderr, "=>%s", - (ADDATA(al,i).x->dcnid!=0) - ? (char *)ADDATA(al,i).x->dcnid - : "[UNDEFINED]"); - } - else - fprintf(stderr, "[%s]", - GET(ADFLAGS(al,i), AREQ) - ? "REQUIRED" - : (GET(ADFLAGS(al,i), ACURRENT) ? "CURRENT" : "NULL")); - } - fprintf(stderr, "\n"); -} -/* TRACEMOD: Print the members of a model. - */ -VOID tracemod(pg) -struct thdr pg[]; -{ - fprintf(stderr, "MODEL %p %02x %d\n", - (UNIV)&pg[0], pg[0].ttype, pg[0].tu.tnum); - if ((pg[0].ttype & MKEYWORD) == 0) { - int i; - - for (i = 1; i < pg[0].tu.tnum + 2; i++) { - if (GET(pg[i].ttype, TTMASK) == TTETD) - fprintf(stderr, " %p %02x %s\n", - (UNIV)&pg[i], pg[i].ttype, pg[i].tu.thetd->etdgi+1); - else if (GET(pg[i].ttype, TTMASK) == TTCHARS) - fprintf(stderr, " %p %02x %s\n", - (UNIV)&pg[i], pg[i].ttype, "#PCDATA"); - else - fprintf(stderr, " %p %02x %d\n", - (UNIV)&pg[i], pg[i].ttype, pg[i].tu.tnum); - } - } - fprintf(stderr, "\n"); -} -/* TRACEGRP: Print the members of a name (i.e., etd) group. - */ -VOID tracegrp(pg) -struct etd *pg[]; -{ - int i = -1; /* Loop counter. */ - - fprintf(stderr, "ETDGRP %p\n", (UNIV)pg); - while (pg[++i]!=0) - fprintf(stderr, " %p %s\n", (UNIV)pg[i], pg[i]->etdgi+1); -} -/* TRACENGR: Print the members of a notation (i.e., dcncb) group. - */ -VOID tracengr(pg) -struct dcncb *pg[]; -{ - int i = -1; /* Loop counter. */ - - fprintf(stderr, "DCNGRP %p\n", (UNIV)pg); - while (pg[++i]!=0) - fprintf(stderr, " %p %s\n", (UNIV)pg[i], pg[i]->ename+1); -} -/* TRACEETD: Print an element type definition. - */ -VOID traceetd(p) -struct etd *p; /* Pointer to an etd. */ -{ - fprintf(stderr, -"ETD etd=%p %s min=%02x cmod=%p ttype=%02x mex=%p, pex=%p, ", - (UNIV)p, p->etdgi+1, p->etdmin, (UNIV)p->etdmod, - p->etdmod->ttype, (UNIV)p->etdmex, (UNIV)p->etdpex); - fprintf(stderr, "adl=%p, srm=%s.\n", - (UNIV)p->adl, - (p->etdsrm==SRMNULL) - ? "#EMPTY" - : (p->etdsrm) ? (char *)(p->etdsrm[0]->ename+1) : "#CURRENT"); -} -/* TRACEID: Print an ID control block. - */ -VOID traceid(action, p) -char *action; -struct id *p; /* Pointer to an ID. */ -{ - fprintf(stderr, "%-8s %s at %p is %s; ", action, p->idname+1, (UNIV)p, - p->iddefed ? "defined" : "undefined"); - fprintf(stderr, "last ref=%p\n", (UNIV)p->idrl); -} -/* TRACEMD: Trace a markup declaration parameter. - */ -VOID tracemd(parmid) -char *parmid; /* Parameter identifier. */ -{ - fprintf(stderr, "MDPARM %-8s for %-8s, token %02d, type %02u, %s.\n", - mdname, subdcl ? (char *)subdcl : "[NONE]", parmno, pcbmd.action, parmid); -} -/* TRACEMS: Trace marked section activity. - */ -VOID tracems(action, code, mslevel, msplevel) -int action; /* 1=began new level; 0=resumed previous. */ -int code; -int mslevel; /* Nesting level of marked sections. */ -int msplevel; /* Nested MS levels subject to special parse. */ -{ - fprintf(stderr, - "MS%c %2d %s nesting level %d (msp %d).\n", - (action ? ' ' : 'E'), code, (action ? "began" : "resumed"), - mslevel, msplevel); -} - -static -VOID tracehits(h) -unsigned long *h; -{ - int i; - fprintf(stderr, " H="); - for (i = grplongs - 1; i >= 0; --i) - fprintf(stderr, "%0*lx", LONGBITS/4, h[i]); -} - -/* TRACEGI: Trace GI testing stages in CONTEXT.C processing. - */ -VOID tracegi(stagenm, gi, mod, pos, Tstart) -char *stagenm; -struct etd *gi; /* ETD of new GI. */ -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -int Tstart; /* Initial T for this group. */ -{ - int i = 0; /* Loop counter. */ - - fprintf(stderr, "%-10s %d:", stagenm, P); - while (++i<=P) - fprintf(stderr, " %d-%d", pos[i].g, pos[i].t); - fprintf(stderr, " (%u) gocc=%02x gtype=%02x gnum=%d", - M, GOCC, GTYPE, GNUM); - tracehits(H); - fprintf(stderr, " status=%d Tstart=%d\n", STATUX, Tstart); - fprintf(stderr, - "=>%-8s tocc=%02x ttype=%02x thetd=%p (%s) gietd=%p (%s)\n", - tags[ts].tetd->etdgi+1, TOCC, TTYPE, (UNIV)TOKEN.tu.thetd, - (TTYPE - ? (TTYPE==TTETD ? (char *)(TOKEN.tu.thetd->etdgi+1) : "#GROUP") - : "#PCDATA"), - (UNIV)gi, - (gi==ETDCDATA ? "#PCDATA" : (char *)(gi->etdgi+1))); -} -/* TRACEEND: Trace testing for end of group in CONTEXT.C processing. - */ -VOID traceend(stagenm, mod, pos, rc, opt, Tstart) -char *stagenm; -struct thdr mod[]; /* Model of current open element. */ -struct mpos pos[]; /* Position in open element's model. */ -int rc; /* Return code: RCNREQ RCHIT RCMISS RCEND */ -int opt; /* ALLHIT parm: 1=test optionals; 0=ignore. */ -int Tstart; /* Initial T for this group. */ -{ - int i = 0; /* Loop counter. */ - - fprintf(stderr, "%-10s %d:", stagenm, P); - while (++i<=P) - fprintf(stderr, " %d-%d", pos[i].g, pos[i].t); - fprintf(stderr, " (%u) gocc=%02x gtype=%02x gnum=%d", - M, GOCC, GTYPE, GNUM); - tracehits(H); - fprintf(stderr, " status=%d Tstart=%d\n", STATUX, Tstart); - fprintf(stderr, "=>%-8s tocc=%02x ttype=%02x thetd=%p (%s)", - tags[ts].tetd->etdgi+1, TOCC, TTYPE, (UNIV)TOKEN.tu.thetd, - (TTYPE - ? (TTYPE==TTETD ? (char *)(TOKEN.tu.thetd->etdgi+1) : "#GROUP") - : "#PCDATA")); - fprintf(stderr, " rc=%d offbitT=%d allhit=%d\n", - rc, offbit(H, (int)T, GNUM), allhit(&GHDR, H, 0, opt)); -} - -#endif /* TRACE */ -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/unix.cfg b/cde/programs/dtdocbook/sgmls/unix.cfg deleted file mode 100644 index 0bc841080..000000000 --- a/cde/programs/dtdocbook/sgmls/unix.cfg +++ /dev/null @@ -1,147 +0,0 @@ -/* unix.cfg: Configuration file for sgmls on Unix. */ - -/* A list of filename templates to use for searching for external entities. -The filenames are separated by the character specified in PATH_FILE_SEP. -See sgmls.man for details. */ -#define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D" -/* The character that separates the filenames templates. */ -#define PATH_FILE_SEP ':' -/* The character that separates filenames in a system identifier. -Usually the same as PATH_FILE_SEP. */ -#define SYSID_FILE_SEP ':' -/* The environment variable that contains the list of filename templates. */ -#define PATH_ENV_VAR "SGML_PATH" - -/* MIN_DAT_SUBS_FROM and MIN_DATS_SUBS_TO tell sgmls how to transform a name -or system identifier into a legal filename. A character in -MIN_DAT_SUBS_FROM will be transformed into the character in the -corresponding position in MIN_DAT_SUBS_TO. If there is no such -position, then the character is removed. */ -/* This says that spaces should be transformed to underscores, and -slashes to percents. */ -#define MIN_DAT_SUBS_FROM " /" -#define MIN_DAT_SUBS_TO "_%" - -/* Define this to allow tracing. */ -/* #define TRACE 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C, so you might not want -to define it if you are porting to a new system. Otherwise I suggest -you leave it defined. */ -#define SUPPORT_SUBDOC 1 - -/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports -X/Open extensions; if they do, then, for example, - - printf("%2$s%1$s", "bar", "foo") - -should print `foobar'. */ - -/* #define HAVE_EXTENDED_PRINTF 1 */ - -/* Define HAVE_CAT if your system provides the X/Open message -catalogue functions catopen() and catgets(), and you want to use them. -An implementations of these functions is included and will be used if -you don't define this. On SunOS 4.1.1, if you do define this you -should set CC=/usr/xpg2bin/cc in the makefile. */ - -/* #define HAVE_CAT 1 */ - -#ifdef __STDC__ -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 -#endif - -/* Can't use <stdarg.h> without prototypes. */ -#ifndef USE_PROTOTYPES -#define VARARGS 1 -#endif - -/* If your compiler defines __STDC__ but doesn't provide <stdarg.h>, -you must define VARARGS yourself here. */ -/* #define VARARGS 1 */ - -/* Define this if you do not have strerror(). */ -#define STRERROR_MISSING 1 - -/* Define this unless the character testing functions in ctype.h -are defined for all values representable as an unsigned char. You do -not need to define this if your system is ANSI C conformant. You -should define for old Unix systems. */ -/* #define USE_ISASCII 1 */ - -/* Define this if your system provides the BSD style string operations -rather than ANSI C ones (eg bcopy() rather than memcpy(), and index() -rather than strchr()). */ -/* #define BSD_STRINGS 1 */ - -/* Define this if you have getopt(). */ -#define HAVE_GETOPT 1 - -/* Define this if you have access(). */ -#define HAVE_ACCESS 1 - -/* Define this if you have <unistd.h>. */ -#define HAVE_UNISTD_H 1 - -/* Define this if you have <sys/stat.h>. */ -#define HAVE_SYS_STAT_H 1 - -/* Define this if you have waitpid(). */ -#define HAVE_WAITPID 1 - -/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */ -#define POSIX 1 - -/* Define this if you have the vfork() system call. */ -#define HAVE_VFORK 1 - -/* Define this if you have <vfork.h>. */ -#define HAVE_VFORK_H 1 - -/* Define this if you don't have <stdlib.h> */ -/* #define STDLIB_H_MISSING 1 */ - -/* Define this if you don't have <stddef.h> */ -/* #define STDDEF_H_MISSING 1 */ - -/* Define this if you don't have <limits.h> */ -/* #define LIMITS_H_MISSING 1 */ - -/* Define this if you don't have remove(); unlink() will be used instead. */ -#define REMOVE_MISSING 1 - -/* Define this if you don't have raise(); kill() will be used instead. */ -#define RAISE_MISSING 1 - -/* Define this if you don't have fsetpos() and fgetpos(). */ -#define FPOS_MISSING 1 - -/* Universal pointer type. */ -/* If your compiler doesn't fully support void *, change `void' to `char'. */ -typedef void *UNIV; - -/* If your compiler doesn't support void as a function return type, -change `void' to `int'. */ -typedef void VOID; - -/* If you don't have an ANSI C conformant <limits.h>, define -CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed. -The <limits.h> on some versions of System Release V 3.2 is not ANSI C -conformant: the value of CHAR_MIN is 0 even though the `char' type is -signed. */ - -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include <limits.h> -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* Assume the system character set is ISO Latin-1. */ -#include "latin1.h" diff --git a/cde/programs/dtdocbook/sgmls/unixproc.c b/cde/programs/dtdocbook/sgmls/unixproc.c deleted file mode 100644 index af8b69e11..000000000 --- a/cde/programs/dtdocbook/sgmls/unixproc.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: unixproc.c /main/3 1996/06/19 17:19:08 drk $ */ -/* unixproc.c - - - Unix implementation of run_process(). - - Written by James Clark (jjc@jclark.com). -*/ - -#include "config.h" - -#ifdef SUPPORT_SUBDOC - -#ifdef POSIX - -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> - -#endif /* POSIX */ - -#include "std.h" -#include "entity.h" -#include "appl.h" - -#ifndef POSIX - -#define WIFSTOPPED(s) (((s) & 0377) == 0177) -#define WIFSIGNALED(s) (((s) & 0377) != 0 && ((s) & 0377 != 0177)) -#define WIFEXITED(s) (((s) & 0377) == 0) -#define WEXITSTATUS(s) (((s) >> 8) & 0377) -#define WTERMSIG(s) ((s) & 0177) -#define WSTOPSIG(s) (((s) >> 8) & 0377) -#define _SC_OPEN_MAX 0 -#define sysconf(name) (20) -typedef int pid_t; - -#endif /* not POSIX */ - -#ifndef HAVE_VFORK -#define vfork() fork() -#endif /* not HAVE_VFORK */ - -#ifdef HAVE_VFORK_H -#include <vfork.h> -#endif /* HAVE_VFORK_H */ - -int run_process(argv) -char **argv; -{ - pid_t pid; - int status; - int ret; - - /* Can't trust Unix implementations to support fflush(NULL). */ - fflush(stderr); - fflush(stdout); - - pid = vfork(); - if (pid == 0) { - /* child */ - int i; - int open_max = (int)sysconf(_SC_OPEN_MAX); - - for (i = 3; i < open_max; i++) - (void)close(i); - execvp(argv[0], argv); - appl_error(E_EXEC, argv[0], strerror(errno)); - fflush(stderr); - _exit(127); - } - if (pid < 0) { - appl_error(E_FORK, strerror(errno)); - return -1; - } - /* parent */ - while ((ret = wait(&status)) != pid) - if (ret < 0) { - appl_error(E_WAIT, strerror(errno)); - return -1; - } - if (WIFSIGNALED(status)) { - appl_error(E_SIGNAL, argv[0], WTERMSIG(status)); - return -1; - } - /* Must have exited normally. */ - return WEXITSTATUS(status); -} - -#endif /* SUPPORT_SUBDOC */ - -/* -Local Variables: -c-indent-level: 5 -c-continued-statement-offset: 5 -c-brace-offset: -5 -c-argdecl-indent: 0 -c-label-offset: -5 -End: -*/ diff --git a/cde/programs/dtdocbook/sgmls/version.c b/cde/programs/dtdocbook/sgmls/version.c deleted file mode 100644 index 5b28634f2..000000000 --- a/cde/programs/dtdocbook/sgmls/version.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: version.c /main/3 1996/06/19 17:19:13 drk $ */ -char *version_string = "1.1"; diff --git a/cde/programs/dtdocbook/sgmls/vms.cfg b/cde/programs/dtdocbook/sgmls/vms.cfg deleted file mode 100644 index 783474acd..000000000 --- a/cde/programs/dtdocbook/sgmls/vms.cfg +++ /dev/null @@ -1,218 +0,0 @@ -/* vms.cfg: Configuration file for sgmls on VAX/VMS. -/* For VAX/VMS V5.3 and VAX C V3.2-044. -Contributed by John Lavagnino <LAV@BINAH.CC.BRANDEIS.EDU>. */ - -/* Define HAVE_EXTENDED_PRINTF if your *printf functions supports -X/Open extensions; if they do, then, for example, - - printf("%2$s%1$s", "bar", "foo") - -should print `foobar'. */ - -/* #define HAVE_EXTENDED_PRINTF 1 */ - -/* Define HAVE_CAT if your system provides the X/Open message -catalogue functions catopen() and catgets(), and you want to use them. -An implementations of these functions is included and will be used if -you don't define this. On SunOS 4.1.1, if you do define this you -should set CC=/usr/xpg2bin/cc in the makefile. */ - -/* #define HAVE_CAT 1 */ - -#ifdef __STDC__ -/* Define this if your compiler supports prototypes. */ -#define USE_PROTOTYPES 1 -#endif -#define USE_PROTOTYPES 1 - -#ifdef __OBJECTCENTER__ -/* Define this if you have <varargs.h> but not <stdarg.h> */ -#define VARARGS 1 -#endif - -#ifndef USE_PROTOTYPES -/* Use VARARGS if prototypes are not supported. */ -#ifndef VARARGS -#define VARARGS 1 -#endif -#endif /* not USE_PROTOTYPES */ - -/* Define this if you do not have strerror(). */ -/* #define STRERROR_MISSING 1 */ - -/* Define this unless the character testing functions in ctype.h -are defined for all values representable as an unsigned char. You do -not need to define this if your system is ANSI C conformant. You -should define for old Unix systems. */ -/* This has been defined for VMS because its iscntrl says that - 128 through 159 are controls; SHUNCHAR CONTROLS believes that, and you - can get messages like - "Non-significant shunned character number 158 not declared UNUSED" - as a result: that's what happens with the grplvl.sgm test. (See - sgmldecl.c for the use of iscntrl that leads to this, and Goldfarb - page 455 for the rule that's being followed.) With this - symbol defined, the VMS version of isascii is used together with - iscntrl, and isascii is false for eight-bit characters. - The setting here also affects the form of the output: without the - isascii test the program is led to believe that some codes with the - eighth bit set are OK to put in the output without translation, - because with the eighth bit masked off they look like ordinary letters. - That happened with output from the test02.sgm test file. See - lineout.c, uses of isprint, for the code that's involved here. - JDL */ -#define USE_ISASCII 1 - -/* Define this if your system provides the BSD style string operations -rather than ANSI C ones (eg bcopy() rather than memcpy(), and index() -rather than strchr()). */ -/* #define BSD_STRINGS 1 */ - -/* Define this if you have getopt(). */ -/* #define HAVE_GETOPT 1 */ - -/* Much VMSish stuff here. - Not sure what a good default path is: the one here's just a - guess. The unix.cfg default was: - - #define DEFAULT_PATH "/usr/local/lib/sgml/%O/%C/%T:%N.%X:%N.%D" - - which is better in that it uses elements from the formal - identifier rather than the parameter entity name. - FILE_SEP variables set to comma rather than colon: colon can appear - in a filename, and comma is the usual thing on VMS to separate - directories in a pathlist. - In MIN_DAT_SUBS we map slashes to dashes, since % is not a legal - VMS filename character. */ - -#define PATH_FILE_SEP ',' -#define DEFAULT_PATH "sgml_public:%N.%C" -#define PATH_ENV_VAR "SGML_PATH" -#define SYSID_FILE_SEP ',' -#define MIN_DAT_SUBS_FROM " /" -#define MIN_DAT_SUBS_TO "_-" - -/* Define this if you have access(). */ -/* VMS has access(), but it's one of those half-implemented functions - in the run-time library: it checks only UIC protection and not - ACLs, in VAX C V3.2-044. So it's better to use the replacement - code provided in entgen.c that just tries to open the file. */ -/* #define HAVE_ACCESS 1 */ - -/* Define this if you have <unistd.h>. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define this if you have waitpid(). */ -/* #define HAVE_WAITPID 1 */ - -/* Define this to omit tracing functions */ -/* #define FINAL 1 */ - -/* Define this you want support for subdocuments. This is implemented -using features that are not part of Standard C. */ -/* Turned off on VMS: the unixproc.c and portproc.c approaches both - sort of work, but there are problems getting the output of the - subprocess to go the same place as the main process output. - Decided I didn't need this enough to mess with it for now. JDL */ -/* #define SUPPORT_SUBDOC 1 */ - -/* Define this if your system is POSIX.1 (ISO 9945-1:1990) compliant. */ -/* #define POSIX 1 */ - -/* POSIX.1 compliant systems will certainly have access(), <unistd.h>, -and waitpid(). */ -#ifdef POSIX -#ifndef HAVE_ACCESS -#define HAVE_ACCESS 1 -#endif -#ifndef HAVE_UNISTD_H -#define HAVE_UNISTD_H 1 -#endif -#ifndef HAVE_WAITPID -#define HAVE_WAITPID 1 -#endif -#endif /* POSIX */ - -/* Define this if you have the vfork() system call. */ -#define HAVE_VFORK 1 - -/* Define this if you have <vfork.h>. */ -/* #define HAVE_VFORK_H 1 */ - -/* Define this if you don't have <stdlib.h> */ -/* #define STDLIB_H_MISSING 1 */ - -/* Define this if you don't have <stddef.h> */ -/* #define STDDEF_H_MISSING 1 */ - -/* Define this if you don't have remove(); unlink() will be used instead. */ -/* #define REMOVE_MISSING 1 */ - -/* Define this if you don't have raise(); kill() will be used instead. */ -#define RAISE_MISSING 1 - -/* Universal pointer type. */ -/* Use this if your compiler doesn't fully support void * */ -/* typedef char *UNIV; */ -/* Otherwise use this */ -typedef void *UNIV; - -/* VAX C V3.2-044 rejects the following typedef for some reason. - But the #define seems to work. */ -/* typedef void VOID; */ /* void as a function return type */ -#define VOID void - -/* If you don't have an ANSI C conformant <limits.h>, define -CHAR_SIGNED as 1 or 0 according to whether the `char' type is signed. -The <limits.h> on some versions of System Release V 3.2 is not ANSI C -conformant: the value of CHAR_MIN is 0 even though the `char' type is -signed. */ - -/* #define CHAR_SIGNED 1 */ -/* #define CHAR_SIGNED 0 */ -#ifndef CHAR_SIGNED -#include <limits.h> -#if CHAR_MIN < 0 -#define CHAR_SIGNED 1 -#else -#define CHAR_SIGNED 0 -#endif -#endif /* not CHAR_SIGNED */ - -/* Assume the system character set is ISO Latin-1. */ -#include "latin1.h" - -/* Stuff for use in main.c to remove VMS device, directory, extension, - and version number from error messages. - We don't need PROG_FOLD, which does upper-to-lower-case folding, - because VMS does it already. */ - -#define PROG_PREFIX "]:" -#define PROG_STRIP_EXTENSION 1 - -/* Define VMS exit codes. - stdlib.h is here because it defines its own EXIT_SUCCESS and - EXIT_FAILURE, which are just 0 and 2; we want nice values that - don't trigger VMS messages like - %NONAME-E-NOMSG, Message number 00000002 - So we run stdlib.h here and then redefine these exit codes - afterwards. */ - -#ifdef VMS -# pragma nostandard -# include stdlib -# include ssdef -# include stsdef -# pragma standard -# define EXIT_SUCCESS SS$_NORMAL -# define EXIT_FAILURE (STS$K_SEVERE | STS$M_INHIB_MSG) -#endif - -/* Odd VMS include file for process functions (system, execvp). */ - -#ifdef VMS -# ifdef SUPPORT_SUBDOC -# pragma nostandard -# include processes -# pragma standard -# endif -#endif diff --git a/cde/programs/dtdocbook/sgmls/xfprintf.c b/cde/programs/dtdocbook/sgmls/xfprintf.c deleted file mode 100644 index 315e25679..000000000 --- a/cde/programs/dtdocbook/sgmls/xfprintf.c +++ /dev/null @@ -1,591 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: xfprintf.c /main/3 1996/06/19 17:19:16 drk $ */ -/* xfprintf.c - - X/Open extended v?fprintf implemented in terms of v?fprintf. - - Written by James Clark (jjc@jclark.com). -*/ - -/* Compile with: - - -DVARARGS to use varargs.h instead of stdarg.h - -DLONG_DOUBLE_MISSING if your compiler doesn't like `long double' - -DFP_SUPPORT to include floating point stuff -*/ - -#include "config.h" - -#ifndef HAVE_EXTENDED_PRINTF - -#include "std.h" - -#ifdef lint -/* avoid stupid lint warnings */ -#undef va_arg -#define va_arg(ap, type) (ap, (type)0) -#endif - -#ifdef FP_SUPPORT -#ifdef LONG_DOUBLE_MISSING -typedef double long_double; -#else -typedef long double long_double; -#endif -#endif /* FP_SUPPORT */ - -#ifndef __STDC__ -#define const /* as nothing */ -#endif - -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif - -#ifdef VARARGS -typedef int (*printer)(); -#else -typedef int (*printer)(UNIV, const char *, ...); -#endif - -enum arg_type { - NONE, - INT, - UNSIGNED, - LONG, - UNSIGNED_LONG, -#ifdef FP_SUPPORT - DOUBLE, - LONG_DOUBLE, -#endif /* FP_SUPPORT */ - PCHAR, - PINT, - PLONG, - PSHORT -}; - -union arg { - int i; - unsigned u; - long l; - unsigned long ul; -#ifdef FP_SUPPORT - double d; - long_double ld; -#endif /* FP_SUPPORT */ - char *pc; - UNIV pv; - int *pi; - short *ps; - long *pl; -}; - -#define NEXT 0 -#define MISSING 10 - -struct spec { - enum arg_type type; - char pos; - char field_width; - char precision; -}; - -#define FLAG_CHARS "-+ #0" - -static int parse_spec P((const char **, struct spec *)); -static int find_arg_types P((const char *, enum arg_type *)); -static void get_arg P((enum arg_type, va_list *, union arg *)); -static int do_arg P((UNIV, printer, const char *, enum arg_type, union arg *)); -static int xdoprt P((UNIV, printer, const char *, va_list)); -static int printit P((UNIV, printer, const char *, va_list, int, union arg *)); -static int maybe_positional P((const char *)); - -/* Return 1 if sucessful, 0 otherwise. **pp points to character after % */ - -static int parse_spec(pp, sp) -const char **pp; -struct spec *sp; -{ - char modifier = 0; - sp->pos = NEXT; - if (isdigit((unsigned char)(**pp)) && (*pp)[1] == '$') { - if (**pp == '0') - return 0; - sp->pos = **pp - '0'; - *pp += 2; - } - - while (**pp != '\0' && strchr(FLAG_CHARS, **pp)) - *pp += 1; - - /* handle the field width */ - - sp->field_width = MISSING; - if (**pp == '*') { - *pp += 1; - if (isdigit((unsigned char)**pp) && (*pp)[1] == '$') { - if (**pp == '0') - return 0; - sp->field_width = **pp - '0'; - *pp += 2; - } - else - sp->field_width = NEXT; - } - else { - while (isdigit((unsigned char)**pp)) - *pp += 1; - } - - /* handle the precision */ - sp->precision = MISSING; - if (**pp == '.') { - *pp += 1; - if (**pp == '*') { - *pp += 1; - if (isdigit((unsigned char)**pp) && (*pp)[1] == '$') { - if (**pp == '0') - return 0; - sp->precision = **pp - '0'; - *pp += 2; - } - else - sp->precision = NEXT; - } - else { - while (isdigit((unsigned char)**pp)) - *pp += 1; - } - } - /* handle h l or L */ - - if (**pp == 'h' || **pp == 'l' || **pp == 'L') { - modifier = **pp; - *pp += 1; - } - - switch (**pp) { - case 'd': - case 'i': - sp->type = modifier == 'l' ? LONG : INT; - break; - case 'o': - case 'u': - case 'x': - case 'X': - sp->type = modifier == 'l' ? UNSIGNED_LONG : UNSIGNED; - break; -#ifdef FP_SUPPORT - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - sp->type = modifier == 'L' ? LONG_DOUBLE : DOUBLE; - break; -#endif /* FP_SUPPORT */ - case 'c': - sp->type = INT; - break; - case 's': - sp->type = PCHAR; - break; - case 'p': - /* a pointer to void has the same representation as a pointer to char */ - sp->type = PCHAR; - break; - case 'n': - if (modifier == 'h') - sp->type = PSHORT; - else if (modifier == 'l') - sp->type = PLONG; - else - sp->type = PINT; - break; - case '%': - sp->type = NONE; - break; - default: - return 0; - } - *pp += 1; - return 1; -} - - -static int find_arg_types(format, arg_type) - const char *format; - enum arg_type *arg_type; -{ - int i, pos; - const char *p; - struct spec spec; - - for (i = 0; i < 9; i++) - arg_type[i] = NONE; - - pos = 0; - - p = format; - while (*p) - if (*p == '%') { - p++; - if (!parse_spec(&p, &spec)) - return 0; - if (spec.type != NONE) { - int n; - if (spec.pos == NEXT) - n = pos++; - else - n = spec.pos - 1; - if (n < 9) { - enum arg_type t = arg_type[n]; - if (t != NONE && t != spec.type) - return 0; - arg_type[n] = spec.type; - } - } - if (spec.field_width != MISSING) { - int n; - if (spec.field_width == NEXT) - n = pos++; - else - n = spec.field_width - 1; - if (n < 9) { - enum arg_type t = arg_type[n]; - if (t != NONE && t != INT) - return 0; - arg_type[n] = INT; - } - } - if (spec.precision != MISSING) { - int n; - if (spec.precision == NEXT) - n = pos++; - else - n = spec.precision - 1; - if (n < 9) { - enum arg_type t = arg_type[n]; - if (t != NONE && t != INT) - return 0; - arg_type[n] = INT; - } - } - } - else - p++; - return 1; -} - -static void get_arg(arg_type, app, argp) - enum arg_type arg_type; - va_list *app; - union arg *argp; -{ - switch (arg_type) { - case NONE: - break; - case INT: - argp->i = va_arg(*app, int); - break; - case UNSIGNED: - argp->u = va_arg(*app, unsigned); - break; - case LONG: - argp->l = va_arg(*app, long); - break; - case UNSIGNED_LONG: - argp->ul = va_arg(*app, unsigned long); - break; -#ifdef FP_SUPPORT - case DOUBLE: - argp->d = va_arg(*app, double); - break; - case LONG_DOUBLE: - argp->ld = va_arg(*app, long_double); - break; -#endif /* FP_SUPPORT */ - case PCHAR: - argp->pc = va_arg(*app, char *); - break; - case PINT: - argp->pi = va_arg(*app, int *); - break; - case PSHORT: - argp->ps = va_arg(*app, short *); - break; - case PLONG: - argp->pl = va_arg(*app, long *); - break; - default: - abort(); - } -} - -static int do_arg(handle, func, buf, arg_type, argp) - UNIV handle; - printer func; - const char *buf; - enum arg_type arg_type; - union arg *argp; -{ - switch (arg_type) { - case NONE: - return (*func)(handle, buf); - case INT: - return (*func)(handle, buf, argp->i); - case UNSIGNED: - return (*func)(handle, buf, argp->u); - case LONG: - return (*func)(handle, buf, argp->l); - case UNSIGNED_LONG: - return (*func)(handle, buf, argp->ul); -#ifdef FP_SUPPORT - case DOUBLE: - return (*func)(handle, buf, argp->d); - case LONG_DOUBLE: - return (*func)(handle, buf, argp->ld); -#endif /* FP_SUPPORT */ - case PCHAR: - return (*func)(handle, buf, argp->pc); - case PINT: - return (*func)(handle, buf, argp->pi); - case PSHORT: - return (*func)(handle, buf, argp->ps); - case PLONG: - return (*func)(handle, buf, argp->pl); - default: - abort(); - } - /* NOTREACHED */ -} - -static int printit(handle, func, p, ap, nargs, arg) - UNIV handle; - printer func; - const char *p; - va_list ap; - int nargs; - union arg *arg; -{ - char buf[512]; /* enough for a spec */ - int count = 0; - int pos = 0; - - while (*p) - if (*p == '%') { - char *q; - struct spec spec; - const char *start; - int had_field_width; - union arg *argp; - union arg a; - int res; - - start = ++p; - if (!parse_spec(&p, &spec)) - abort(); /* should have caught it in find_arg_types */ - - buf[0] = '%'; - q = buf + 1; - - if (spec.pos != NEXT) - start += 2; - - /* substitute in precision and field width if necessary */ - had_field_width = 0; - while (start < p) { - if (*start == '*') { - char c; - int n, val; - - start++; - if (!had_field_width && spec.field_width != MISSING) { - c = spec.field_width; - had_field_width = 1; - } - else - c = spec.precision; - if (c == NEXT) - n = pos++; - else { - start += 2; - n = c - 1; - } - if (n >= nargs) - val = va_arg(ap, int); - else - val = arg[n].i; - - /* ignore negative precision */ - if (val >= 0 || q[-1] != '.') { - (void)sprintf(q, "%d", val); - q = strchr(q, '\0'); - } - } - else - *q++ = *start++; - } - *q++ = '\0'; - - argp = 0; - if (spec.type != NONE) { - int n = spec.pos == NEXT ? pos++ : spec.pos - 1; - if (n >= nargs) { - get_arg(spec.type, &ap, &a); - argp = &a; - } - else - argp = arg + n; - } - - res = do_arg(handle, func, buf, spec.type, argp); - if (res < 0) - return -1; - count += res; - } - else { - if ((*func)(handle, "%c", *p++) < 0) - return -1; - count++; - } - return count; -} - -/* Do a quick check to see if it may contains any positional thingies. */ - -static int maybe_positional(format) - const char *format; -{ - const char *p; - - p = format; - for (;;) { - p = strchr(p, '$'); - if (!p) - return 0; - if (p - format >= 2 - && isdigit((unsigned char)p[-1]) - && (p[-2] == '%' || p[-2] == '*')) - break; /* might be a positional thingy */ - } - return 1; -} - -static int xdoprt(handle, func, format, ap) - UNIV handle; - printer func; - const char *format; - va_list ap; -{ - enum arg_type arg_type[9]; - union arg arg[9]; - int nargs, i; - - if (!find_arg_types(format, arg_type)) - return -1; - - for (nargs = 0; nargs < 9; nargs++) - if (arg_type[nargs] == NONE) - break; - - for (i = nargs; i < 9; i++) - if (arg_type[i] != NONE) - return -1; - - for (i = 0; i < nargs; i++) - get_arg(arg_type[i], &ap, arg + i); - - return printit(handle, func, format, ap, nargs, arg); -} - -#ifdef VARARGS -static int do_fprintf(va_alist) va_dcl -#else -static int do_fprintf(UNIV p, const char *format,...) -#endif -{ -#ifdef VARARGS - UNIV p; - const char *format; -#endif - va_list ap; - int res; - -#ifdef VARARGS - va_start(ap); - p = va_arg(ap, UNIV); - format = va_arg(ap, char *); -#else - va_start(ap, format); -#endif - - res = vfprintf((FILE *)p, format, ap); - va_end(ap); - return res; -} - -#ifdef VARARGS -int xfprintf(va_alist) va_dcl -#else -int xfprintf(FILE *fp, const char *format, ...) -#endif -{ -#ifdef VARARGS - FILE *fp; - char *format; -#endif - va_list ap; - int res; - -#ifdef VARARGS - va_start(ap); - fp = va_arg(ap, FILE *); - format = va_arg(ap, char *); -#else - va_start(ap, format); -#endif - if (maybe_positional(format)) - res = xdoprt((UNIV)fp, do_fprintf, format, ap); - else - res = vfprintf(fp, format, ap); - va_end(ap); - return res; -} - -int xvfprintf(fp, format, ap) - FILE *fp; - const char *format; - va_list ap; -{ - int res; - if (maybe_positional(format)) - res = xdoprt((UNIV)fp, do_fprintf, format, ap); - else - res = vfprintf(fp, format, ap); - return res; -} - -#endif /* not HAVE_EXTENDED_PRINTF */ diff --git a/cde/programs/dtdocbook/tcl/Imakefile b/cde/programs/dtdocbook/tcl/Imakefile deleted file mode 100644 index b5e1c7c73..000000000 --- a/cde/programs/dtdocbook/tcl/Imakefile +++ /dev/null @@ -1,95 +0,0 @@ -XCOMM $XConsortium: Imakefile /main/4 1996/08/08 14:42:19 cde-hp $ -#define DoNormalLib YES -#define DoSharedLib NO -#define DoDebugLib NO -#define DoProfileLib NO -#define LibName tcl -#define LibHeaders NO -#define LibInstall NO - -VERSION = 8.5 - -#if defined(LinuxArchitecture) -prefix = /usr/lib -#elif defined(OpenBSDArchitecture) -prefix = /usr/local/lib/tcl -#elif defined(NetBSDArchitecture) -prefix = /usr/pkg/lib -#else -prefix = /usr/local/lib -#endif - -XCOMM Directory from which applications will reference the library of Tcl -XCOMM scripts (note: you can set the TCL_LIBRARY environment variable at -XCOMM run-time to override this value): -#ifdef TclLibrary -TCL_LIBRARY = TclLibrary -#else -TCL_LIBRARY = $(prefix)/tcl$(VERSION) -#endif - -DEPEND_DEFINES = $(DEPENDDEFINES) - -#if defined(SunArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H -DNEED_MATHERR \ - -DTCL_GOT_TIMEZONE - -#elif defined(IBMArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H -DNEED_MATHERR -Dvfork=fork \ - -DTCL_GOT_TIMEZONE -DHAVE_SYS_SELECT_H - -#elif defined(AlphaArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H -DNEED_MATHERR \ - -DTCL_GOT_TIMEZONE -DTIME_WITH_SYS_TIME - -#elif defined(OpenBSDArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H \ - -DTCL_GOT_TIMEZONE - -#elif defined(FreeBSDArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H \ - -DTCL_GOT_TIMEZONE - -#elif defined(NetBSDArchitecture) -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H -DNEED_MATHERR \ - -DTCL_GOT_TIMEZONE - -#else -EXTRA_DEFINES = -DTCL_LIBRARY=\"${TCL_LIBRARY}\" \ - -DNO_UNION_WAIT -DHAVE_UNISTD_H -DNEED_MATHERR \ - -DTCL_GOT_TIMEZONE -#endif - -INCLUDES = -I. - -SRCS = panic.c regexp.c tclAsync.c tclBasic.c tclCkalloc.c \ - tclClock.c tclCmdAH.c tclCmdIL.c tclCmdMZ.c tclDate.c \ - tclEnv.c tclEvent.c tclExpr.c tclFHandle.c tclFileName.c \ - tclGet.c tclHash.c tclHistory.c tclIO.c tclIOCmd.c \ - tclIOSock.c tclIOUtil.c tclInterp.c tclLink.c tclLoad.c \ - tclLoadNone.c tclMain.c tclMtherr.c tclNotify.c tclParse.c \ - tclPkg.c tclPosixStr.c tclPreserve.c tclProc.c \ - tclUnixChan.c tclUnixFile.c tclUnixInit.c tclUnixNotfy.c \ - tclUnixPipe.c tclUnixSock.c tclUnixTime.c tclUtil.c \ - tclVar.c - -OBJS = panic.o regexp.o tclAsync.o tclBasic.o tclCkalloc.o \ - tclClock.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclDate.o \ - tclEnv.o tclEvent.o tclExpr.o tclFHandle.o tclFileName.o \ - tclGet.o tclHash.o tclHistory.o tclIO.o tclIOCmd.o \ - tclIOSock.o tclIOUtil.o tclInterp.o tclLink.o tclLoad.o \ - tclLoadNone.o tclMain.o tclMtherr.o tclNotify.o tclParse.o \ - tclPkg.o tclPosixStr.o tclPreserve.o tclProc.o \ - tclUnixChan.o tclUnixFile.o tclUnixInit.o tclUnixNotfy.o \ - tclUnixPipe.o tclUnixSock.o tclUnixTime.o tclUtil.o \ - tclVar.o - -#include <Library.tmpl> - -DependTarget() diff --git a/cde/programs/dtdocbook/tcl/license.terms b/cde/programs/dtdocbook/tcl/license.terms deleted file mode 100644 index 3dcd816f4..000000000 --- a/cde/programs/dtdocbook/tcl/license.terms +++ /dev/null @@ -1,32 +0,0 @@ -This software is copyrighted by the Regents of the University of -California, Sun Microsystems, Inc., and other parties. The following -terms apply to all files associated with the software unless explicitly -disclaimed in individual files. - -The authors hereby grant permission to use, copy, modify, distribute, -and license this software and its documentation for any purpose, provided -that existing copyright notices are retained in all copies and that this -notice is included verbatim in any distributions. No written agreement, -license, or royalty fee is required for any of the authorized uses. -Modifications to this software may be copyrighted by their authors -and need not follow the licensing terms described here, provided that -the new terms are clearly indicated on the first page of each file where -they apply. - -IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY -FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY -DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE -IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE -NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR -MODIFICATIONS. - -RESTRICTED RIGHTS: Use, duplication or disclosure by the government -is subject to the restrictions as set forth in subparagraph (c) (1) (ii) -of the Rights in Technical Data and Computer Software Clause as DFARS -252.227-7013 and FAR 52.227-19. diff --git a/cde/programs/dtdocbook/tcl/panic.c b/cde/programs/dtdocbook/tcl/panic.c deleted file mode 100644 index 7a2064e22..000000000 --- a/cde/programs/dtdocbook/tcl/panic.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: panic.c /main/2 1996/08/08 14:42:24 cde-hp $ */ -/* - * panic.c -- - * - * Source code for the "panic" library procedure for Tcl; - * individual applications will probably override this with - * an application-specific panic procedure. - * - * Copyright (c) 1988-1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) panic.c 1.11 96/02/15 11:50:29 - */ - -#include <stdio.h> -#ifdef NO_STDLIB_H -# include "../compat/stdlib.h" -#else -# include <stdlib.h> -#endif - -#include "tcl.h" - -/* - * The panicProc variable contains a pointer to an application - * specific panic procedure. - */ - -void (*panicProc) _ANSI_ARGS_(TCL_VARARGS(char *,format)) = NULL; - - - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetPanicProc -- - * - * Replace the default panic behavior with the specified functiion. - * - * Results: - * None. - * - * Side effects: - * Sets the panicProc variable. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetPanicProc(void (*proc) _ANSI_ARGS_(TCL_VARARGS(char *,format))) -{ - panicProc = proc; -} - -/* - *---------------------------------------------------------------------- - * - * panic -- - * - * Print an error message and kill the process. - * - * Results: - * None. - * - * Side effects: - * The process dies, entering the debugger if possible. - * - *---------------------------------------------------------------------- - */ - - /* VARARGS ARGSUSED */ -void -panic(char *format /* Format string, suitable for passing to fprintf. */, - char *arg1, char *arg2, char *arg3 /* Additional arguments (variable in number) to pass to fprintf. */, - char *arg4, char *arg5, char *arg6, char *arg7, char *arg8) -{ - if (panicProc != NULL) { - (void) (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - } else { - (void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, - arg7, arg8); - (void) fprintf(stderr, "\n"); - (void) fflush(stderr); - abort(); - } -} diff --git a/cde/programs/dtdocbook/tcl/patchlevel.h b/cde/programs/dtdocbook/tcl/patchlevel.h deleted file mode 100644 index 438894038..000000000 --- a/cde/programs/dtdocbook/tcl/patchlevel.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: patchlevel.h /main/2 1996/08/08 14:42:32 cde-hp $ */ -/* - * patchlevel.h -- - * - * This file does nothing except define a "patch level" for Tcl. - * The patch level has the form "X.YpZ" where X.Y is the base - * release, and Z is a serial number that is used to sequence - * patches for a given release. Thus 7.4p1 is the first patch - * to release 7.4, 7.4p2 is the patch that follows 7.4p1, and - * so on. The "pZ" is omitted in an original new release, and - * it is replaced with "bZ" for beta releases or "aZ for alpha - * releases. The patch level ensures that patches are applied - * in the correct order and only to appropriate sources. - * - * Copyright (c) 1993-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) patchlevel.h 1.17 96/04/08 14:15:07 - */ - -#define TCL_PATCH_LEVEL "7.5" diff --git a/cde/programs/dtdocbook/tcl/regexp.c b/cde/programs/dtdocbook/tcl/regexp.c deleted file mode 100644 index 9933eff00..000000000 --- a/cde/programs/dtdocbook/tcl/regexp.c +++ /dev/null @@ -1,1321 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: regexp.c /main/3 1996/10/03 11:14:58 drk $ */ -/* - * TclRegComp and TclRegExec -- TclRegSub is elsewhere - * - * Copyright (c) 1986 by University of Toronto. - * Written by Henry Spencer. Not derived from licensed software. - * - * Permission is granted to anyone to use this software for any - * purpose on any computer system, and to redistribute it freely, - * subject to the following restrictions: - * - * 1. The author is not responsible for the consequences of use of - * this software, no matter how awful, even if they arise - * from defects in it. - * - * 2. The origin of this software must not be misrepresented, either - * by explicit claim or by omission. - * - * 3. Altered versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * Beware that some of this code is subtly aware of the way operator - * precedence is structured in regular expressions. Serious changes in - * regular-expression syntax might require a total rethink. - * - * *** NOTE: this code has been altered slightly for use in Tcl: *** - * *** 1. Use ckalloc and ckfree instead of malloc and free. *** - * *** 2. Add extra argument to regexp to specify the real *** - * *** start of the string separately from the start of the *** - * *** current search. This is needed to search for multiple *** - * *** matches within a string. *** - * *** 3. Names have been changed, e.g. from regcomp to *** - * *** TclRegComp, to avoid clashes with other *** - * *** regexp implementations used by applications. *** - * *** 4. Added errMsg declaration and TclRegError procedure *** - * *** 5. Various lint-like things, such as casting arguments *** - * *** in procedure calls. *** - * - * *** NOTE: This code has been altered for use in MT-Sturdy Tcl *** - * *** 1. All use of static variables has been changed to access *** - * *** fields of a structure. *** - * *** 2. This in addition to changes to TclRegError makes the *** - * *** code multi-thread safe. *** - * - * SCCS: @(#) regexp.c 1.12 96/04/02 13:54:57 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The variable below is set to NULL before invoking regexp functions - * and checked after those functions. If an error occurred then TclRegError - * will set the variable to point to a (static) error message. This - * mechanism unfortunately does not support multi-threading, but the - * procedures TclRegError and TclGetRegError can be modified to use - * thread-specific storage for the variable and thereby make the code - * thread-safe. - */ - -static char *errMsg = NULL; - -/* - * The "internal use only" fields in regexp.h are present to pass info from - * compile to execute that permits the execute phase to run lots faster on - * simple cases. They are: - * - * regstart char that must begin a match; '\0' if none obvious - * reganch is the match anchored (at beginning-of-line only)? - * regmust string (pointer into program) that match must include, or NULL - * regmlen length of regmust string - * - * Regstart and reganch permit very fast decisions on suitable starting points - * for a match, cutting down the work a lot. Regmust permits fast rejection - * of lines that cannot possibly match. The regmust tests are costly enough - * that TclRegComp() supplies a regmust only if the r.e. contains something - * potentially expensive (at present, the only such thing detected is * or + - * at the start of the r.e., which can involve a lot of backup). Regmlen is - * supplied because the test in TclRegExec() needs it and TclRegComp() is - * computing it anyway. - */ - -/* - * Structure for regexp "program". This is essentially a linear encoding - * of a nondeterministic finite-state machine (aka syntax charts or - * "railroad normal form" in parsing technology). Each node is an opcode - * plus a "next" pointer, possibly plus an operand. "Next" pointers of - * all nodes except BRANCH implement concatenation; a "next" pointer with - * a BRANCH on both ends of it is connecting two alternatives. (Here we - * have one of the subtle syntax dependencies: an individual BRANCH (as - * opposed to a collection of them) is never concatenated with anything - * because of operator precedence.) The operand of some types of node is - * a literal string; for others, it is a node leading into a sub-FSM. In - * particular, the operand of a BRANCH node is the first node of the branch. - * (NB this is *not* a tree structure: the tail of the branch connects - * to the thing following the set of BRANCHes.) The opcodes are: - */ - -/* definition number opnd? meaning */ -#define END 0 /* no End of program. */ -#define BOL 1 /* no Match "" at beginning of line. */ -#define EOL 2 /* no Match "" at end of line. */ -#define ANY 3 /* no Match any one character. */ -#define ANYOF 4 /* str Match any character in this string. */ -#define ANYBUT 5 /* str Match any character not in this string. */ -#define BRANCH 6 /* node Match this alternative, or the next... */ -#define BACK 7 /* no Match "", "next" ptr points backward. */ -#define EXACTLY 8 /* str Match this string. */ -#define NOTHING 9 /* no Match empty string. */ -#define STAR 10 /* node Match this (simple) thing 0 or more times. */ -#define PLUS 11 /* node Match this (simple) thing 1 or more times. */ -#define OPEN 20 /* no Mark this point in input as start of #n. */ - /* OPEN+1 is number 1, etc. */ -#define CLOSE (OPEN+NSUBEXP) /* no Analogous to OPEN. */ - -/* - * Opcode notes: - * - * BRANCH The set of branches constituting a single choice are hooked - * together with their "next" pointers, since precedence prevents - * anything being concatenated to any individual branch. The - * "next" pointer of the last BRANCH in a choice points to the - * thing following the whole choice. This is also where the - * final "next" pointer of each individual branch points; each - * branch starts with the operand node of a BRANCH node. - * - * BACK Normal "next" pointers all implicitly point forward; BACK - * exists to make loop structures possible. - * - * STAR,PLUS '?', and complex '*' and '+', are implemented as circular - * BRANCH structures using BACK. Simple cases (one character - * per match) are implemented with STAR and PLUS for speed - * and to minimize recursive plunges. - * - * OPEN,CLOSE ...are numbered at compile time. - */ - -/* - * A node is one char of opcode followed by two chars of "next" pointer. - * "Next" pointers are stored as two 8-bit pieces, high order first. The - * value is a positive offset from the opcode of the node containing it. - * An operand, if any, simply follows the node. (Note that much of the - * code generation knows about this implicit relationship.) - * - * Using two bytes for the "next" pointer is vast overkill for most things, - * but allows patterns to get big without disasters. - */ -#define OP(p) (*(p)) -#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377)) -#define OPERAND(p) ((p) + 3) - -/* - * See regmagic.h for one further detail of program structure. - */ - - -/* - * Utility definitions. - */ -#ifndef CHARBITS -#define UCHARAT(p) ((int)*(unsigned char *)(p)) -#else -#define UCHARAT(p) ((int)*(p)&CHARBITS) -#endif - -#define FAIL(m) { TclRegError(m); return(NULL); } -#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') -#define META "^$.[()|?+*\\" - -/* - * Flags to be passed up and down. - */ -#define HASWIDTH 01 /* Known never to match null string. */ -#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */ -#define SPSTART 04 /* Starts with * or +. */ -#define WORST 0 /* Worst case. */ - -/* - * Global work variables for TclRegComp(). - */ -struct regcomp_state { - char *regparse; /* Input-scan pointer. */ - int regnpar; /* () count. */ - char *regcode; /* Code-emit pointer; ®dummy = don't. */ - long regsize; /* Code size. */ -}; - -static char regdummy; - -/* - * The first byte of the regexp internal "program" is actually this magic - * number; the start node begins in the second byte. - */ -#define MAGIC 0234 - - -/* - * Forward declarations for TclRegComp()'s friends. - */ - -static char * reg _ANSI_ARGS_((int paren, int *flagp, - struct regcomp_state *rcstate)); -static char * regatom _ANSI_ARGS_((int *flagp, - struct regcomp_state *rcstate)); -static char * regbranch _ANSI_ARGS_((int *flagp, - struct regcomp_state *rcstate)); -static void regc _ANSI_ARGS_((int b, - struct regcomp_state *rcstate)); -static void reginsert _ANSI_ARGS_((int op, char *opnd, - struct regcomp_state *rcstate)); -static char * regnext _ANSI_ARGS_((char *p)); -static char * regnode _ANSI_ARGS_((int op, - struct regcomp_state *rcstate)); -static void regoptail _ANSI_ARGS_((char *p, char *val)); -static char * regpiece _ANSI_ARGS_((int *flagp, - struct regcomp_state *rcstate)); -static void regtail _ANSI_ARGS_((char *p, char *val)); - -#ifdef STRCSPN -static int strcspn _ANSI_ARGS_((char *s1, char *s2)); -#endif - -/* - - TclRegComp - compile a regular expression into internal code - * - * We can't allocate space until we know how big the compiled form will be, - * but we can't compile it (and thus know how big it is) until we've got a - * place to put the code. So we cheat: we compile it twice, once with code - * generation turned off and size counting turned on, and once "for real". - * This also means that we don't allocate space until we are sure that the - * thing really will compile successfully, and we never have to move the - * code and thus invalidate pointers into it. (Note that it has to be in - * one piece because free() must be able to free it all.) - * - * Beware that the optimization-preparation code in here knows about some - * of the structure of the compiled regexp. - */ -regexp * -TclRegComp(char *exp) -{ - regexp *r; - char *scan; - char *longest; - int len; - int flags; - struct regcomp_state state; - struct regcomp_state *rcstate= &state; - - if (exp == NULL) - FAIL("NULL argument"); - - /* First pass: determine size, legality. */ - rcstate->regparse = exp; - rcstate->regnpar = 1; - rcstate->regsize = 0L; - rcstate->regcode = ®dummy; - regc(MAGIC, rcstate); - if (reg(0, &flags, rcstate) == NULL) - return(NULL); - - /* Small enough for pointer-storage convention? */ - if (rcstate->regsize >= 32767L) /* Probably could be 65535L. */ - FAIL("regexp too big"); - - /* Allocate space. */ - r = (regexp *)ckalloc(sizeof(regexp) + (unsigned)rcstate->regsize); - if (r == NULL) - FAIL("out of space"); - - /* Second pass: emit code. */ - rcstate->regparse = exp; - rcstate->regnpar = 1; - rcstate->regcode = r->program; - regc(MAGIC, rcstate); - if (reg(0, &flags, rcstate) == NULL) - return(NULL); - - /* Dig out information for optimizations. */ - r->regstart = '\0'; /* Worst-case defaults. */ - r->reganch = 0; - r->regmust = NULL; - r->regmlen = 0; - scan = r->program+1; /* First BRANCH. */ - if (OP(regnext(scan)) == END) { /* Only one top-level choice. */ - scan = OPERAND(scan); - - /* Starting-point info. */ - if (OP(scan) == EXACTLY) - r->regstart = *OPERAND(scan); - else if (OP(scan) == BOL) - r->reganch++; - - /* - * If there's something expensive in the r.e., find the - * longest literal string that must appear and make it the - * regmust. Resolve ties in favor of later strings, since - * the regstart check works with the beginning of the r.e. - * and avoiding duplication strengthens checking. Not a - * strong reason, but sufficient in the absence of others. - */ - if (flags&SPSTART) { - longest = NULL; - len = 0; - for (; scan != NULL; scan = regnext(scan)) - if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) { - longest = OPERAND(scan); - len = strlen(OPERAND(scan)); - } - r->regmust = longest; - r->regmlen = len; - } - } - - return(r); -} - -/* - - reg - regular expression, i.e. main body or parenthesized thing - * - * Caller must absorb opening parenthesis. - * - * Combining parenthesis handling with the base level of regular expression - * is a trifle forced, but the need to tie the tails of the branches to what - * follows makes it hard to avoid. - */ -static char * -reg(int paren /* Parenthesized? */, int *flagp, struct regcomp_state *rcstate) -{ - char *ret; - char *br; - char *ender; - int parno = 0; - int flags; - - *flagp = HASWIDTH; /* Tentatively. */ - - /* Make an OPEN node, if parenthesized. */ - if (paren) { - if (rcstate->regnpar >= NSUBEXP) - FAIL("too many ()"); - parno = rcstate->regnpar; - rcstate->regnpar++; - ret = regnode(OPEN+parno,rcstate); - } else - ret = NULL; - - /* Pick up the branches, linking them together. */ - br = regbranch(&flags,rcstate); - if (br == NULL) - return(NULL); - if (ret != NULL) - regtail(ret, br); /* OPEN -> first. */ - else - ret = br; - if (!(flags&HASWIDTH)) - *flagp &= ~HASWIDTH; - *flagp |= flags&SPSTART; - while (*rcstate->regparse == '|') { - rcstate->regparse++; - br = regbranch(&flags,rcstate); - if (br == NULL) - return(NULL); - regtail(ret, br); /* BRANCH -> BRANCH. */ - if (!(flags&HASWIDTH)) - *flagp &= ~HASWIDTH; - *flagp |= flags&SPSTART; - } - - /* Make a closing node, and hook it on the end. */ - ender = regnode((paren) ? CLOSE+parno : END,rcstate); - regtail(ret, ender); - - /* Hook the tails of the branches to the closing node. */ - for (br = ret; br != NULL; br = regnext(br)) - regoptail(br, ender); - - /* Check for proper termination. */ - if (paren && *rcstate->regparse++ != ')') { - FAIL("unmatched ()"); - } else if (!paren && *rcstate->regparse != '\0') { - if (*rcstate->regparse == ')') { - FAIL("unmatched ()"); - } else - FAIL("junk on end"); /* "Can't happen". */ - /* NOTREACHED */ - } - - return(ret); -} - -/* - - regbranch - one alternative of an | operator - * - * Implements the concatenation operator. - */ -static char * -regbranch(int *flagp, struct regcomp_state *rcstate) -{ - char *ret; - char *chain; - char *latest; - int flags; - - *flagp = WORST; /* Tentatively. */ - - ret = regnode(BRANCH,rcstate); - chain = NULL; - while (*rcstate->regparse != '\0' && *rcstate->regparse != '|' && - *rcstate->regparse != ')') { - latest = regpiece(&flags, rcstate); - if (latest == NULL) - return(NULL); - *flagp |= flags&HASWIDTH; - if (chain == NULL) /* First piece. */ - *flagp |= flags&SPSTART; - else - regtail(chain, latest); - chain = latest; - } - if (chain == NULL) /* Loop ran zero times. */ - (void) regnode(NOTHING,rcstate); - - return(ret); -} - -/* - - regpiece - something followed by possible [*+?] - * - * Note that the branching code sequences used for ? and the general cases - * of * and + are somewhat optimized: they use the same NOTHING node as - * both the endmarker for their branch list and the body of the last branch. - * It might seem that this node could be dispensed with entirely, but the - * endmarker role is not redundant. - */ -static char * -regpiece(int *flagp, struct regcomp_state *rcstate) -{ - char *ret; - char op; - char *next; - int flags; - - ret = regatom(&flags,rcstate); - if (ret == NULL) - return(NULL); - - op = *rcstate->regparse; - if (!ISMULT(op)) { - *flagp = flags; - return(ret); - } - - if (!(flags&HASWIDTH) && op != '?') - FAIL("*+ operand could be empty"); - *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); - - if (op == '*' && (flags&SIMPLE)) - reginsert(STAR, ret, rcstate); - else if (op == '*') { - /* Emit x* as (x&|), where & means "self". */ - reginsert(BRANCH, ret, rcstate); /* Either x */ - regoptail(ret, regnode(BACK,rcstate)); /* and loop */ - regoptail(ret, ret); /* back */ - regtail(ret, regnode(BRANCH,rcstate)); /* or */ - regtail(ret, regnode(NOTHING,rcstate)); /* null. */ - } else if (op == '+' && (flags&SIMPLE)) - reginsert(PLUS, ret, rcstate); - else if (op == '+') { - /* Emit x+ as x(&|), where & means "self". */ - next = regnode(BRANCH,rcstate); /* Either */ - regtail(ret, next); - regtail(regnode(BACK,rcstate), ret); /* loop back */ - regtail(next, regnode(BRANCH,rcstate)); /* or */ - regtail(ret, regnode(NOTHING,rcstate)); /* null. */ - } else if (op == '?') { - /* Emit x? as (x|) */ - reginsert(BRANCH, ret, rcstate); /* Either x */ - regtail(ret, regnode(BRANCH,rcstate)); /* or */ - next = regnode(NOTHING,rcstate); /* null. */ - regtail(ret, next); - regoptail(ret, next); - } - rcstate->regparse++; - if (ISMULT(*rcstate->regparse)) - FAIL("nested *?+"); - - return(ret); -} - -/* - - regatom - the lowest level - * - * Optimization: gobbles an entire sequence of ordinary characters so that - * it can turn them into a single node, which is smaller to store and - * faster to run. Backslashed characters are exceptions, each becoming a - * separate node; the code is simpler that way and it's not worth fixing. - */ -static char * -regatom(int *flagp, struct regcomp_state *rcstate) -{ - char *ret; - int flags; - - *flagp = WORST; /* Tentatively. */ - - switch (*rcstate->regparse++) { - case '^': - ret = regnode(BOL,rcstate); - break; - case '$': - ret = regnode(EOL,rcstate); - break; - case '.': - ret = regnode(ANY,rcstate); - *flagp |= HASWIDTH|SIMPLE; - break; - case '[': { - int clss; - int classend; - - if (*rcstate->regparse == '^') { /* Complement of range. */ - ret = regnode(ANYBUT,rcstate); - rcstate->regparse++; - } else - ret = regnode(ANYOF,rcstate); - if (*rcstate->regparse == ']' || *rcstate->regparse == '-') - regc(*rcstate->regparse++,rcstate); - while (*rcstate->regparse != '\0' && *rcstate->regparse != ']') { - if (*rcstate->regparse == '-') { - rcstate->regparse++; - if (*rcstate->regparse == ']' || *rcstate->regparse == '\0') - regc('-',rcstate); - else { - clss = UCHARAT(rcstate->regparse-2)+1; - classend = UCHARAT(rcstate->regparse); - if (clss > classend+1) - FAIL("invalid [] range"); - for (; clss <= classend; clss++) - regc((char)clss,rcstate); - rcstate->regparse++; - } - } else - regc(*rcstate->regparse++,rcstate); - } - regc('\0',rcstate); - if (*rcstate->regparse != ']') - FAIL("unmatched []"); - rcstate->regparse++; - *flagp |= HASWIDTH|SIMPLE; - } - break; - case '(': - ret = reg(1, &flags, rcstate); - if (ret == NULL) - return(NULL); - *flagp |= flags&(HASWIDTH|SPSTART); - break; - case '\0': - case '|': - case ')': - FAIL("internal urp"); /* Supposed to be caught earlier. */ - /* NOTREACHED */ - break; - case '?': - case '+': - case '*': - FAIL("?+* follows nothing"); - /* NOTREACHED */ - break; - case '\\': - if (*rcstate->regparse == '\0') - FAIL("trailing \\"); - ret = regnode(EXACTLY,rcstate); - regc(*rcstate->regparse++,rcstate); - regc('\0',rcstate); - *flagp |= HASWIDTH|SIMPLE; - break; - default: { - int len; - char ender; - - rcstate->regparse--; - len = strcspn(rcstate->regparse, META); - if (len <= 0) - FAIL("internal disaster"); - ender = *(rcstate->regparse+len); - if (len > 1 && ISMULT(ender)) - len--; /* Back off clear of ?+* operand. */ - *flagp |= HASWIDTH; - if (len == 1) - *flagp |= SIMPLE; - ret = regnode(EXACTLY,rcstate); - while (len > 0) { - regc(*rcstate->regparse++,rcstate); - len--; - } - regc('\0',rcstate); - } - break; - } - - return(ret); -} - -/* - - regnode - emit a node - */ -static char * /* Location. */ -regnode(int op, struct regcomp_state *rcstate) -{ - char *ret; - char *ptr; - - ret = rcstate->regcode; - if (ret == ®dummy) { - rcstate->regsize += 3; - return(ret); - } - - ptr = ret; - *ptr++ = (char)op; - *ptr++ = '\0'; /* Null "next" pointer. */ - *ptr++ = '\0'; - rcstate->regcode = ptr; - - return(ret); -} - -/* - - regc - emit (if appropriate) a byte of code - */ -static void -regc(int b, struct regcomp_state *rcstate) -{ - if (rcstate->regcode != ®dummy) - *rcstate->regcode++ = (char)b; - else - rcstate->regsize++; -} - -/* - - reginsert - insert an operator in front of already-emitted operand - * - * Means relocating the operand. - */ -static void -reginsert(int op, char *opnd, struct regcomp_state *rcstate) -{ - char *src; - char *dst; - char *place; - - if (rcstate->regcode == ®dummy) { - rcstate->regsize += 3; - return; - } - - src = rcstate->regcode; - rcstate->regcode += 3; - dst = rcstate->regcode; - while (src > opnd) - *--dst = *--src; - - place = opnd; /* Op node, where operand used to be. */ - *place++ = (char)op; - *place++ = '\0'; - *place = '\0'; -} - -/* - - regtail - set the next-pointer at the end of a node chain - */ -static void -regtail(char *p, char *val) -{ - char *scan; - char *temp; - int offset; - - if (p == ®dummy) - return; - - /* Find last node. */ - scan = p; - for (;;) { - temp = regnext(scan); - if (temp == NULL) - break; - scan = temp; - } - - if (OP(scan) == BACK) - offset = scan - val; - else - offset = val - scan; - *(scan+1) = (char)((offset>>8)&0377); - *(scan+2) = (char)(offset&0377); -} - -/* - - regoptail - regtail on operand of first argument; nop if operandless - */ -static void -regoptail(char *p, char *val) -{ - /* "Operandless" and "op != BRANCH" are synonymous in practice. */ - if (p == NULL || p == ®dummy || OP(p) != BRANCH) - return; - regtail(OPERAND(p), val); -} - -/* - * TclRegExec and friends - */ - -/* - * Global work variables for TclRegExec(). - */ -struct regexec_state { - char *reginput; /* String-input pointer. */ - char *regbol; /* Beginning of input, for ^ check. */ - char **regstartp; /* Pointer to startp array. */ - char **regendp; /* Ditto for endp. */ -}; - -/* - * Forwards. - */ -static int regtry _ANSI_ARGS_((regexp *prog, char *string, - struct regexec_state *restate)); -static int regmatch _ANSI_ARGS_((char *prog, - struct regexec_state *restate)); -static int regrepeat _ANSI_ARGS_((char *p, - struct regexec_state *restate)); - -#ifdef DEBUG -int regnarrate = 0; -void regdump _ANSI_ARGS_((regexp *r)); -static char *regprop _ANSI_ARGS_((char *op)); -#endif - -/* - - TclRegExec - match a regexp against a string - */ -int -TclRegExec(regexp *prog, char *string, char *start) -{ - char *s; - struct regexec_state state; - struct regexec_state *restate= &state; - - /* Be paranoid... */ - if (prog == NULL || string == NULL) { - TclRegError("NULL parameter"); - return(0); - } - - /* Check validity of program. */ - if (UCHARAT(prog->program) != MAGIC) { - TclRegError("corrupted program"); - return(0); - } - - /* If there is a "must appear" string, look for it. */ - if (prog->regmust != NULL) { - s = string; - while ((s = strchr(s, prog->regmust[0])) != NULL) { - if (strncmp(s, prog->regmust, (size_t) prog->regmlen) - == 0) - break; /* Found it. */ - s++; - } - if (s == NULL) /* Not present. */ - return(0); - } - - /* Mark beginning of line for ^ . */ - restate->regbol = start; - - /* Simplest case: anchored match need be tried only once. */ - if (prog->reganch) - return(regtry(prog, string, restate)); - - /* Messy cases: unanchored match. */ - s = string; - if (prog->regstart != '\0') - /* We know what char it must start with. */ - while ((s = strchr(s, prog->regstart)) != NULL) { - if (regtry(prog, s, restate)) - return(1); - s++; - } - else - /* We don't -- general case. */ - do { - if (regtry(prog, s, restate)) - return(1); - } while (*s++ != '\0'); - - /* Failure. */ - return(0); -} - -/* - - regtry - try match at specific point - */ -static int /* 0 failure, 1 success */ -regtry(regexp *prog, char *string, struct regexec_state *restate) -{ - int i; - char **sp; - char **ep; - - restate->reginput = string; - restate->regstartp = prog->startp; - restate->regendp = prog->endp; - - sp = prog->startp; - ep = prog->endp; - for (i = NSUBEXP; i > 0; i--) { - *sp++ = NULL; - *ep++ = NULL; - } - if (regmatch(prog->program + 1,restate)) { - prog->startp[0] = string; - prog->endp[0] = restate->reginput; - return(1); - } else - return(0); -} - -/* - - regmatch - main matching routine - * - * Conceptually the strategy is simple: check to see whether the current - * node matches, call self recursively to see whether the rest matches, - * and then act accordingly. In practice we make some effort to avoid - * recursion, in particular by going through "ordinary" nodes (that don't - * need to know whether the rest of the match failed) by a loop instead of - * by recursion. - */ -static int /* 0 failure, 1 success */ -regmatch(char *prog, struct regexec_state *restate) -{ - char *scan; /* Current node. */ - char *next; /* Next node. */ - - scan = prog; -#ifdef DEBUG - if (scan != NULL && regnarrate) - fprintf(stderr, "%s(\n", regprop(scan)); -#endif - while (scan != NULL) { -#ifdef DEBUG - if (regnarrate) - fprintf(stderr, "%s...\n", regprop(scan)); -#endif - next = regnext(scan); - - switch (OP(scan)) { - case BOL: - if (restate->reginput != restate->regbol) { - return 0; - } - break; - case EOL: - if (*restate->reginput != '\0') { - return 0; - } - break; - case ANY: - if (*restate->reginput == '\0') { - return 0; - } - restate->reginput++; - break; - case EXACTLY: { - int len; - char *opnd; - - opnd = OPERAND(scan); - /* Inline the first character, for speed. */ - if (*opnd != *restate->reginput) { - return 0 ; - } - len = strlen(opnd); - if (len > 1 && strncmp(opnd, restate->reginput, (size_t) len) - != 0) { - return 0; - } - restate->reginput += len; - break; - } - case ANYOF: - if (*restate->reginput == '\0' - || strchr(OPERAND(scan), *restate->reginput) == NULL) { - return 0; - } - restate->reginput++; - break; - case ANYBUT: - if (*restate->reginput == '\0' - || strchr(OPERAND(scan), *restate->reginput) != NULL) { - return 0; - } - restate->reginput++; - break; - case NOTHING: - break; - case BACK: - break; - case OPEN+1: - case OPEN+2: - case OPEN+3: - case OPEN+4: - case OPEN+5: - case OPEN+6: - case OPEN+7: - case OPEN+8: - case OPEN+9: { - int no; - char *save; - - doOpen: - no = OP(scan) - OPEN; - save = restate->reginput; - - if (regmatch(next,restate)) { - /* - * Don't set startp if some later invocation of the - * same parentheses already has. - */ - if (restate->regstartp[no] == NULL) { - restate->regstartp[no] = save; - } - return 1; - } else { - return 0; - } - } - case CLOSE+1: - case CLOSE+2: - case CLOSE+3: - case CLOSE+4: - case CLOSE+5: - case CLOSE+6: - case CLOSE+7: - case CLOSE+8: - case CLOSE+9: { - int no; - char *save; - - doClose: - no = OP(scan) - CLOSE; - save = restate->reginput; - - if (regmatch(next,restate)) { - /* - * Don't set endp if some later - * invocation of the same parentheses - * already has. - */ - if (restate->regendp[no] == NULL) - restate->regendp[no] = save; - return 1; - } else { - return 0; - } - } - case BRANCH: { - char *save; - - if (OP(next) != BRANCH) { /* No choice. */ - next = OPERAND(scan); /* Avoid recursion. */ - } else { - do { - save = restate->reginput; - if (regmatch(OPERAND(scan),restate)) - return(1); - restate->reginput = save; - scan = regnext(scan); - } while (scan != NULL && OP(scan) == BRANCH); - return 0; - } - break; - } - case STAR: - case PLUS: { - char nextch; - int no; - char *save; - int min; - - /* - * Lookahead to avoid useless match attempts - * when we know what character comes next. - */ - nextch = '\0'; - if (OP(next) == EXACTLY) - nextch = *OPERAND(next); - min = (OP(scan) == STAR) ? 0 : 1; - save = restate->reginput; - no = regrepeat(OPERAND(scan),restate); - while (no >= min) { - /* If it could work, try it. */ - if (nextch == '\0' || *restate->reginput == nextch) - if (regmatch(next,restate)) - return(1); - /* Couldn't or didn't -- back up. */ - no--; - restate->reginput = save + no; - } - return(0); - } - case END: - return(1); /* Success! */ - default: - if (OP(scan) > OPEN && OP(scan) < OPEN+NSUBEXP) { - goto doOpen; - } else if (OP(scan) > CLOSE && OP(scan) < CLOSE+NSUBEXP) { - goto doClose; - } - TclRegError("memory corruption"); - return 0; - } - - scan = next; - } - - /* - * We get here only if there's trouble -- normally "case END" is - * the terminating point. - */ - TclRegError("corrupted pointers"); - return(0); -} - -/* - - regrepeat - repeatedly match something simple, report how many - */ -static int -regrepeat(char *p, struct regexec_state *restate) -{ - int count = 0; - char *scan; - char *opnd; - - scan = restate->reginput; - opnd = OPERAND(p); - switch (OP(p)) { - case ANY: - count = strlen(scan); - scan += count; - break; - case EXACTLY: - while (*opnd == *scan) { - count++; - scan++; - } - break; - case ANYOF: - while (*scan != '\0' && strchr(opnd, *scan) != NULL) { - count++; - scan++; - } - break; - case ANYBUT: - while (*scan != '\0' && strchr(opnd, *scan) == NULL) { - count++; - scan++; - } - break; - default: /* Oh dear. Called inappropriately. */ - TclRegError("internal foulup"); - count = 0; /* Best compromise. */ - break; - } - restate->reginput = scan; - - return(count); -} - -/* - - regnext - dig the "next" pointer out of a node - */ -static char * -regnext(char *p) -{ - int offset; - - if (p == ®dummy) - return(NULL); - - offset = NEXT(p); - if (offset == 0) - return(NULL); - - if (OP(p) == BACK) - return(p-offset); - else - return(p+offset); -} - -#ifdef DEBUG - -static char *regprop(); - -/* - - regdump - dump a regexp onto stdout in vaguely comprehensible form - */ -void -regdump(regexp *r) -{ - char *s; - char op = EXACTLY; /* Arbitrary non-END op. */ - char *next; - - - s = r->program + 1; - while (op != END) { /* While that wasn't END last time... */ - op = OP(s); - printf("%2ld%s", (long) s-r->program, regprop(s)); /* Where, what. */ - next = regnext(s); - if (next == NULL) /* Next ptr. */ - printf("(0)"); - else - printf("(%ld)", (long) (s-r->program)+(next-s)); - s += 3; - if (op == ANYOF || op == ANYBUT || op == EXACTLY) { - /* Literal string, where present. */ - while (*s != '\0') { - putchar(*s); - s++; - } - s++; - } - putchar('\n'); - } - - /* Header fields of interest. */ - if (r->regstart != '\0') - printf("start `%c' ", r->regstart); - if (r->reganch) - printf("anchored "); - if (r->regmust != NULL) - printf("must have \"%s\"", r->regmust); - printf("\n"); -} - -/* - - regprop - printable representation of opcode - */ -static char * -regprop(char *op) -{ - char *p; - static char buf[50]; - - (void) strcpy(buf, ":"); - - switch (OP(op)) { - case BOL: - p = "BOL"; - break; - case EOL: - p = "EOL"; - break; - case ANY: - p = "ANY"; - break; - case ANYOF: - p = "ANYOF"; - break; - case ANYBUT: - p = "ANYBUT"; - break; - case BRANCH: - p = "BRANCH"; - break; - case EXACTLY: - p = "EXACTLY"; - break; - case NOTHING: - p = "NOTHING"; - break; - case BACK: - p = "BACK"; - break; - case END: - p = "END"; - break; - case OPEN+1: - case OPEN+2: - case OPEN+3: - case OPEN+4: - case OPEN+5: - case OPEN+6: - case OPEN+7: - case OPEN+8: - case OPEN+9: - sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN); - p = NULL; - break; - case CLOSE+1: - case CLOSE+2: - case CLOSE+3: - case CLOSE+4: - case CLOSE+5: - case CLOSE+6: - case CLOSE+7: - case CLOSE+8: - case CLOSE+9: - sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE); - p = NULL; - break; - case STAR: - p = "STAR"; - break; - case PLUS: - p = "PLUS"; - break; - default: - if (OP(op) > OPEN && OP(op) < OPEN+NSUBEXP) { - sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN); - p = NULL; - break; - } else if (OP(op) > CLOSE && OP(op) < CLOSE+NSUBEXP) { - sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE); - p = NULL; - } else { - TclRegError("corrupted opcode"); - } - break; - } - if (p != NULL) - (void) strcat(buf, p); - return(buf); -} -#endif - -/* - * The following is provided for those people who do not have strcspn() in - * their C libraries. They should get off their butts and do something - * about it; at least one public-domain implementation of those (highly - * useful) string routines has been published on Usenet. - */ -#ifdef STRCSPN -/* - * strcspn - find length of initial segment of s1 consisting entirely - * of characters not from s2 - */ - -static int -strcspn(char *s1, char *s2) -{ - char *scan1; - char *scan2; - int count; - - count = 0; - for (scan1 = s1; *scan1 != '\0'; scan1++) { - for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */ - if (*scan1 == *scan2++) - return(count); - count++; - } - return(count); -} -#endif - -/* - *---------------------------------------------------------------------- - * - * TclRegError -- - * - * This procedure is invoked by the regexp code when an error - * occurs. It saves the error message so it can be seen by the - * code that called Spencer's code. - * - * Results: - * None. - * - * Side effects: - * The value of "string" is saved in "errMsg". - * - *---------------------------------------------------------------------- - */ - -void -TclRegError(char *string /* Error message. */) -{ - errMsg = string; -} - -char * -TclGetRegError(void) -{ - return errMsg; -} diff --git a/cde/programs/dtdocbook/tcl/tcl.h b/cde/programs/dtdocbook/tcl/tcl.h deleted file mode 100644 index 15757472f..000000000 --- a/cde/programs/dtdocbook/tcl/tcl.h +++ /dev/null @@ -1,1072 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tcl.h /main/4 1996/10/04 10:01:47 drk $ */ -/* - * tcl.h -- - * - * This header file describes the externally-visible facilities - * of the Tcl interpreter. - * - * Copyright (c) 1987-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tcl.h 1.266 96/04/10 11:25:19 - */ - -#ifndef _TCL -#define _TCL - -/* - * The following definitions set up the proper options for Windows - * compilers. We use this method because there is no autoconf equivalent. - */ - -#if defined(_WIN32) && !defined(__WIN32__) -# define __WIN32__ -#endif - -#ifdef __WIN32__ -# undef USE_PROTOTYPE -# undef HAS_STDARG -# define USE_PROTOTYPE -# define HAS_STDARG -#endif - -#ifndef BUFSIZ -#include <stdio.h> -#endif - -#include <sys/types.h> /* for pid_t */ - -#define TCL_VERSION "7.5" -#define TCL_MAJOR_VERSION 7 -#define TCL_MINOR_VERSION 5 - -/* - * Definitions that allow Tcl functions with variable numbers of - * arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS - * is used in procedure prototypes. TCL_VARARGS_DEF is used to declare - * the arguments in a function definiton: it takes the type and name of - * the first argument and supplies the appropriate argument declaration - * string for use in the function definition. TCL_VARARGS_START - * initializes the va_list data structure and returns the first argument. - */ - -#if defined(__STDC__) || defined(HAS_STDARG) -# define TCL_VARARGS(type, name) (type name, ...) -# define TCL_VARARGS_DEF(type, name) (type name, ...) -# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name) -#else -# ifdef __cplusplus -# define TCL_VARARGS(type, name) (type name, ...) -# define TCL_VARARGS_DEF(type, name) (type va_alist, ...) -# else -# define TCL_VARARGS(type, name) () -# define TCL_VARARGS_DEF(type, name) (va_alist) -# endif -# define TCL_VARARGS_START(type, name, list) \ - (va_start(list), va_arg(list, type)) -#endif - -/* - * Definitions that allow this header file to be used either with or - * without ANSI C features like function prototypes. - */ - -#undef _ANSI_ARGS_ -#undef CONST - -#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE) -# define _USING_PROTOTYPES_ 1 -# define _ANSI_ARGS_(x) x -# define CONST const -#else -# define _ANSI_ARGS_(x) () -# define CONST -#endif - -#ifdef __cplusplus -# define EXTERN extern "C" -#else -# define EXTERN extern -#endif - -/* - * Macro to use instead of "void" for arguments that must have - * type "void *" in ANSI C; maps them to type "char *" in - * non-ANSI systems. - */ -#ifndef __WIN32__ -#ifndef VOID -# ifdef __STDC__ -# define VOID void -# else -# define VOID char -# endif -#endif -#else /* __WIN32__ */ -/* - * The following code is copied from winnt.h - */ -#ifndef VOID -#define VOID void -typedef char CHAR; -typedef short SHORT; -typedef long LONG; -#endif -#endif /* __WIN32__ */ - -/* - * Miscellaneous declarations. - */ - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef _CLIENTDATA -# if defined(__STDC__) || defined(__cplusplus) - typedef void *ClientData; -# else - typedef int *ClientData; -# endif /* __STDC__ */ -#define _CLIENTDATA -#endif - -/* - * Data structures defined opaquely in this module. The definitions - * below just provide dummy types. A few fields are made visible in - * Tcl_Interp structures, namely those for returning string values. - * Note: any change to the Tcl_Interp definition below must be mirrored - * in the "real" definition in tclInt.h. - */ - -typedef struct Tcl_Interp{ - char *result; /* Points to result string returned by last - * command. */ - void (*freeProc) _ANSI_ARGS_((char *blockPtr)); - /* Zero means result is statically allocated. - * TCL_DYNAMIC means result was allocated with - * ckalloc and should be freed with ckfree. - * Other values give address of procedure - * to invoke to free the result. Must be - * freed by Tcl_Eval before executing next - * command. */ - int errorLine; /* When TCL_ERROR is returned, this gives - * the line number within the command where - * the error occurred (1 means first line). */ -} Tcl_Interp; - -typedef struct Tcl_AsyncHandler_ *Tcl_AsyncHandler; -typedef struct Tcl_Command_ *Tcl_Command; -typedef struct Tcl_Event Tcl_Event; -typedef struct Tcl_File_ *Tcl_File; -typedef struct Tcl_Channel_ *Tcl_Channel; -typedef struct Tcl_RegExp_ *Tcl_RegExp; -typedef struct Tcl_TimerToken_ *Tcl_TimerToken; -typedef struct Tcl_Trace_ *Tcl_Trace; - -/* - * When a TCL command returns, the string pointer interp->result points to - * a string containing return information from the command. In addition, - * the command procedure returns an integer value, which is one of the - * following: - * - * TCL_OK Command completed normally; interp->result contains - * the command's result. - * TCL_ERROR The command couldn't be completed successfully; - * interp->result describes what went wrong. - * TCL_RETURN The command requests that the current procedure - * return; interp->result contains the procedure's - * return value. - * TCL_BREAK The command requests that the innermost loop - * be exited; interp->result is meaningless. - * TCL_CONTINUE Go on to the next iteration of the current loop; - * interp->result is meaningless. - */ - -#define TCL_OK 0 -#define TCL_ERROR 1 -#define TCL_RETURN 2 -#define TCL_BREAK 3 -#define TCL_CONTINUE 4 - -#define TCL_RESULT_SIZE 200 - -/* - * Argument descriptors for math function callbacks in expressions: - */ - -typedef enum {TCL_INT, TCL_DOUBLE, TCL_EITHER} Tcl_ValueType; -typedef struct Tcl_Value { - Tcl_ValueType type; /* Indicates intValue or doubleValue is - * valid, or both. */ - long intValue; /* Integer value. */ - double doubleValue; /* Double-precision floating value. */ -} Tcl_Value; - -/* - * Procedure types defined by Tcl: - */ - -typedef int (Tcl_AppInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); -typedef int (Tcl_AsyncProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int code)); -typedef void (Tcl_ChannelProc) _ANSI_ARGS_((ClientData clientData, int mask)); -typedef void (Tcl_CloseProc) _ANSI_ARGS_((ClientData data)); -typedef void (Tcl_CmdDeleteProc) _ANSI_ARGS_((ClientData clientData)); -typedef int (Tcl_CmdProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char *argv[])); -typedef void (Tcl_CmdTraceProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int level, char *command, Tcl_CmdProc *proc, - ClientData cmdClientData, int argc, char *argv[])); -typedef int (Tcl_EventProc) _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); -typedef void (Tcl_EventCheckProc) _ANSI_ARGS_((ClientData clientData, - int flags)); -typedef int (Tcl_EventDeleteProc) _ANSI_ARGS_((Tcl_Event *evPtr, - ClientData clientData)); -typedef void (Tcl_EventSetupProc) _ANSI_ARGS_((ClientData clientData, - int flags)); -typedef void (Tcl_ExitProc) _ANSI_ARGS_((ClientData clientData)); -typedef void (Tcl_FileProc) _ANSI_ARGS_((ClientData clientData, int mask)); -typedef void (Tcl_FileFreeProc) _ANSI_ARGS_((ClientData clientData)); -typedef void (Tcl_FreeProc) _ANSI_ARGS_((char *blockPtr)); -typedef void (Tcl_IdleProc) _ANSI_ARGS_((ClientData clientData)); -typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp)); -typedef int (Tcl_MathProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, Tcl_Value *resultPtr)); -typedef int (Tcl_PackageInitProc) _ANSI_ARGS_((Tcl_Interp *interp)); -typedef void (Tcl_TcpAcceptProc) _ANSI_ARGS_((ClientData callbackData, - Tcl_Channel chan, char *address, int port)); -typedef void (Tcl_TimerProc) _ANSI_ARGS_((ClientData clientData)); -typedef char *(Tcl_VarTraceProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *part1, char *part2, int flags)); - -/* - * The structure returned by Tcl_GetCmdInfo and passed into - * Tcl_SetCmdInfo: - */ - -typedef struct Tcl_CmdInfo { - Tcl_CmdProc *proc; /* Procedure to implement command. */ - ClientData clientData; /* ClientData passed to proc. */ - Tcl_CmdDeleteProc *deleteProc; /* Procedure to call when command - * is deleted. */ - ClientData deleteData; /* Value to pass to deleteProc (usually - * the same as clientData). */ -} Tcl_CmdInfo; - -/* - * The structure defined below is used to hold dynamic strings. The only - * field that clients should use is the string field, and they should - * never modify it. - */ - -#define TCL_DSTRING_STATIC_SIZE 200 -typedef struct Tcl_DString { - char *string; /* Points to beginning of string: either - * staticSpace below or a malloc'ed array. */ - int length; /* Number of non-NULL characters in the - * string. */ - int spaceAvl; /* Total number of bytes available for the - * string and its terminating NULL char. */ - char staticSpace[TCL_DSTRING_STATIC_SIZE]; - /* Space to use in common case where string - * is small. */ -} Tcl_DString; - -#define Tcl_DStringLength(dsPtr) ((dsPtr)->length) -#define Tcl_DStringValue(dsPtr) ((dsPtr)->string) -#define Tcl_DStringTrunc Tcl_DStringSetLength - -/* - * Definitions for the maximum number of digits of precision that may - * be specified in the "tcl_precision" variable, and the number of - * characters of buffer space required by Tcl_PrintDouble. - */ - -#define TCL_MAX_PREC 17 -#define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10) - -/* - * Flag that may be passed to Tcl_ConvertElement to force it not to - * output braces (careful! if you change this flag be sure to change - * the definitions at the front of tclUtil.c). - */ - -#define TCL_DONT_USE_BRACES 1 - -/* - * Flag values passed to Tcl_RecordAndEval. - * WARNING: these bit choices must not conflict with the bit choices - * for evalFlag bits in tclInt.h!! - */ - -#define TCL_NO_EVAL 0x10000 -#define TCL_EVAL_GLOBAL 0x20000 - -/* - * Special freeProc values that may be passed to Tcl_SetResult (see - * the man page for details): - */ - -#define TCL_VOLATILE ((Tcl_FreeProc *) 1) -#define TCL_STATIC ((Tcl_FreeProc *) 0) -#define TCL_DYNAMIC ((Tcl_FreeProc *) 3) - -/* - * Flag values passed to variable-related procedures. - */ - -#define TCL_GLOBAL_ONLY 1 -#define TCL_APPEND_VALUE 2 -#define TCL_LIST_ELEMENT 4 -#define TCL_TRACE_READS 0x10 -#define TCL_TRACE_WRITES 0x20 -#define TCL_TRACE_UNSETS 0x40 -#define TCL_TRACE_DESTROYED 0x80 -#define TCL_INTERP_DESTROYED 0x100 -#define TCL_LEAVE_ERR_MSG 0x200 - -/* - * Types for linked variables: - */ - -#define TCL_LINK_INT 1 -#define TCL_LINK_DOUBLE 2 -#define TCL_LINK_BOOLEAN 3 -#define TCL_LINK_STRING 4 -#define TCL_LINK_READ_ONLY 0x80 - -/* - * The following declarations either map ckalloc and ckfree to - * malloc and free, or they map them to procedures with all sorts - * of debugging hooks defined in tclCkalloc.c. - */ - -#ifdef TCL_MEM_DEBUG - -# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__) -# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__) -# define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__) - -EXTERN int Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName)); -EXTERN void Tcl_ValidateAllMemory _ANSI_ARGS_((char *file, - int line)); - -#else - -# define ckalloc(x) malloc(x) -# define ckfree(x) free(x) -# define ckrealloc(x,y) realloc(x,y) - -# define Tcl_DumpActiveMemory(x) -# define Tcl_ValidateAllMemory(x,y) - -#endif /* TCL_MEM_DEBUG */ - -/* - * Macro to free result of interpreter. - */ - -#define Tcl_FreeResult(interp) \ - if ((interp)->freeProc != 0) { \ - if (((interp)->freeProc == TCL_DYNAMIC) \ - || ((interp)->freeProc == (Tcl_FreeProc *) free)) { \ - ckfree((interp)->result); \ - } else { \ - (*(interp)->freeProc)((interp)->result); \ - } \ - (interp)->freeProc = 0; \ - } - -/* - * Forward declaration of Tcl_HashTable. Needed by some C++ compilers - * to prevent errors when the forward reference to Tcl_HashTable is - * encountered in the Tcl_HashEntry structure. - */ - -#ifdef __cplusplus -struct Tcl_HashTable; -#endif - -/* - * Structure definition for an entry in a hash table. No-one outside - * Tcl should access any of these fields directly; use the macros - * defined below. - */ - -typedef struct Tcl_HashEntry { - struct Tcl_HashEntry *nextPtr; /* Pointer to next entry in this - * hash bucket, or NULL for end of - * chain. */ - struct Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ - struct Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to - * first entry in this entry's chain: - * used for deleting the entry. */ - ClientData clientData; /* Application stores something here - * with Tcl_SetHashValue. */ - union { /* Key has one of these forms: */ - char *oneWordValue; /* One-word value for key. */ - int words[1]; /* Multiple integer words for key. - * The actual size will be as large - * as necessary for this table's - * keys. */ - char string[4]; /* String for key. The actual size - * will be as large as needed to hold - * the key. */ - } key; /* MUST BE LAST FIELD IN RECORD!! */ -} Tcl_HashEntry; - -/* - * Structure definition for a hash table. Must be in tcl.h so clients - * can allocate space for these structures, but clients should never - * access any fields in this structure. - */ - -#define TCL_SMALL_HASH_TABLE 4 -typedef struct Tcl_HashTable { - Tcl_HashEntry **buckets; /* Pointer to bucket array. Each - * element points to first entry in - * bucket's hash chain, or NULL. */ - Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; - /* Bucket array used for small tables - * (to avoid mallocs and frees). */ - int numBuckets; /* Total number of buckets allocated - * at **bucketPtr. */ - int numEntries; /* Total number of entries present - * in table. */ - int rebuildSize; /* Enlarge table when numEntries gets - * to be this large. */ - int downShift; /* Shift count used in hashing - * function. Designed to use high- - * order bits of randomized keys. */ - int mask; /* Mask value used in hashing - * function. */ - int keyType; /* Type of keys used in this table. - * It's either TCL_STRING_KEYS, - * TCL_ONE_WORD_KEYS, or an integer - * giving the number of ints that - * is the size of the key. - */ - Tcl_HashEntry *(*findProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr, - char *key)); - Tcl_HashEntry *(*createProc) _ANSI_ARGS_((struct Tcl_HashTable *tablePtr, - char *key, int *newPtr)); -} Tcl_HashTable; - -/* - * Structure definition for information used to keep track of searches - * through hash tables: - */ - -typedef struct Tcl_HashSearch { - Tcl_HashTable *tablePtr; /* Table being searched. */ - int nextIndex; /* Index of next bucket to be - * enumerated after present one. */ - Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the - * the current bucket. */ -} Tcl_HashSearch; - -/* - * Acceptable key types for hash tables: - */ - -#define TCL_STRING_KEYS 0 -#define TCL_ONE_WORD_KEYS 1 - -/* - * Macros for clients to use to access fields of hash entries: - */ - -#define Tcl_GetHashValue(h) ((h)->clientData) -#define Tcl_SetHashValue(h, value) ((h)->clientData = (ClientData) (value)) -#define Tcl_GetHashKey(tablePtr, h) \ - ((char *) (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \ - : (h)->key.string)) - -/* - * Macros to use for clients to use to invoke find and create procedures - * for hash tables: - */ - -#define Tcl_FindHashEntry(tablePtr, key) \ - (*((tablePtr)->findProc))(tablePtr, key) -#define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ - (*((tablePtr)->createProc))(tablePtr, key, newPtr) - -/* - * Flag values to pass to Tcl_DoOneEvent to disable searches - * for some kinds of events: - */ - -#define TCL_DONT_WAIT (1<<1) -#define TCL_WINDOW_EVENTS (1<<2) -#define TCL_FILE_EVENTS (1<<3) -#define TCL_TIMER_EVENTS (1<<4) -#define TCL_IDLE_EVENTS (1<<5) /* WAS 0x10 ???? */ -#define TCL_ALL_EVENTS (~TCL_DONT_WAIT) - -/* - * The following structure defines a generic event for the Tcl event - * system. These are the things that are queued in calls to Tcl_QueueEvent - * and serviced later by Tcl_DoOneEvent. There can be many different - * kinds of events with different fields, corresponding to window events, - * timer events, etc. The structure for a particular event consists of - * a Tcl_Event header followed by additional information specific to that - * event. - */ - -struct Tcl_Event { - Tcl_EventProc *proc; /* Procedure to call to service this event. */ - struct Tcl_Event *nextPtr; /* Next in list of pending events, or NULL. */ -}; - -/* - * Positions to pass to Tk_QueueEvent: - */ - -typedef enum { - TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK -} Tcl_QueuePosition; - -/* - * The following structure keeps is used to hold a time value, either as - * an absolute time (the number of seconds from the epoch) or as an - * elapsed time. On Unix systems the epoch is Midnight Jan 1, 1970 GMT. - * On Macintosh systems the epoch is Midnight Jan 1, 1904 GMT. - */ - -typedef struct Tcl_Time { - long sec; /* Seconds. */ - long usec; /* Microseconds. */ -} Tcl_Time; - -/* - * Bits to pass to Tcl_CreateFileHandler and Tcl_CreateChannelHandler - * to indicate what sorts of events are of interest: - */ - -#define TCL_READABLE (1<<1) -#define TCL_WRITABLE (1<<2) -#define TCL_EXCEPTION (1<<3) - -/* - * Flag values to pass to Tcl_OpenCommandChannel to indicate the - * disposition of the stdio handles. TCL_STDIN, TCL_STDOUT, TCL_STDERR, - * are also used in Tcl_GetStdChannel. - */ - -#define TCL_STDIN (1<<1) -#define TCL_STDOUT (1<<2) -#define TCL_STDERR (1<<3) -#define TCL_ENFORCE_MODE (1<<4) - -/* - * Typedefs for the various operations in a channel type: - */ - -typedef int (Tcl_DriverBlockModeProc) _ANSI_ARGS_((ClientData instanceData, - Tcl_File inFile, Tcl_File outFile, int mode)); -typedef int (Tcl_DriverCloseProc) _ANSI_ARGS_((ClientData instanceData, - Tcl_Interp *interp, Tcl_File inFile, Tcl_File outFile)); -typedef int (Tcl_DriverInputProc) _ANSI_ARGS_((ClientData instanceData, - Tcl_File inFile, char *buf, int toRead, - int *errorCodePtr)); -typedef int (Tcl_DriverOutputProc) _ANSI_ARGS_((ClientData instanceData, - Tcl_File outFile, char *buf, int toWrite, - int *errorCodePtr)); -typedef int (Tcl_DriverSeekProc) _ANSI_ARGS_((ClientData instanceData, - Tcl_File inFile, Tcl_File outFile, long offset, int mode, - int *errorCodePtr)); -typedef int (Tcl_DriverSetOptionProc) _ANSI_ARGS_(( - ClientData instanceData, Tcl_Interp *interp, - char *optionName, char *value)); -typedef int (Tcl_DriverGetOptionProc) _ANSI_ARGS_(( - ClientData instanceData, char *optionName, - Tcl_DString *dsPtr)); - -/* - * Enum for different end of line translation and recognition modes. - */ - -typedef enum Tcl_EolTranslation { - TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */ - TCL_TRANSLATE_CR, /* Eol == \r. */ - TCL_TRANSLATE_LF, /* Eol == \n. */ - TCL_TRANSLATE_CRLF /* Eol == \r\n. */ -} Tcl_EolTranslation; - -/* - * struct Tcl_ChannelType: - * - * One such structure exists for each type (kind) of channel. - * It collects together in one place all the functions that are - * part of the specific channel type. - */ - -typedef struct Tcl_ChannelType { - char *typeName; /* The name of the channel type in Tcl - * commands. This storage is owned by - * channel type. */ - Tcl_DriverBlockModeProc *blockModeProc; - /* Set blocking mode for the - * raw channel. May be NULL. */ - Tcl_DriverCloseProc *closeProc; /* Procedure to call to close - * the channel. */ - Tcl_DriverInputProc *inputProc; /* Procedure to call for input - * on channel. */ - Tcl_DriverOutputProc *outputProc; /* Procedure to call for output - * on channel. */ - Tcl_DriverSeekProc *seekProc; /* Procedure to call to seek - * on the channel. May be NULL. */ - Tcl_DriverSetOptionProc *setOptionProc; - /* Set an option on a channel. */ - Tcl_DriverGetOptionProc *getOptionProc; - /* Get an option from a channel. */ -} Tcl_ChannelType; - -/* - * The following flags determine whether the blockModeProc above should - * set the channel into blocking or nonblocking mode. They are passed - * as arguments to the blockModeProc procedure in the above structure. - */ - -#define TCL_MODE_BLOCKING 0 /* Put channel into blocking mode. */ -#define TCL_MODE_NONBLOCKING 1 /* Put channel into nonblocking - * mode. */ - -/* - * Types for file handles: - */ - -#define TCL_UNIX_FD 1 -#define TCL_MAC_FILE 2 -#define TCL_MAC_SOCKET 3 -#define TCL_WIN_PIPE 4 -#define TCL_WIN_FILE 5 -#define TCL_WIN_SOCKET 6 -#define TCL_WIN_CONSOLE 7 - -/* - * Enum for different types of file paths. - */ - -typedef enum Tcl_PathType { - TCL_PATH_ABSOLUTE, - TCL_PATH_RELATIVE, - TCL_PATH_VOLUME_RELATIVE -} Tcl_PathType; - -/* - * The following interface is exported for backwards compatibility, but - * is only implemented on Unix. Portable applications should use - * Tcl_OpenCommandChannel, instead. - */ - -EXTERN int Tcl_CreatePipeline _ANSI_ARGS_((Tcl_Interp *interp, - int argc, char **argv, pid_t **pidArrayPtr, - int *inPipePtr, int *outPipePtr, - int *errFilePtr)); - -/* - * Exported Tcl procedures: - */ - -EXTERN void Tcl_AddErrorInfo _ANSI_ARGS_((Tcl_Interp *interp, - char *message)); -EXTERN void Tcl_AllowExceptions _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN void Tcl_AppendElement _ANSI_ARGS_((Tcl_Interp *interp, - char *string)); -EXTERN void Tcl_AppendResult _ANSI_ARGS_( - TCL_VARARGS(Tcl_Interp *,interp)); -EXTERN int Tcl_AppInit _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN Tcl_AsyncHandler Tcl_AsyncCreate _ANSI_ARGS_((Tcl_AsyncProc *proc, - ClientData clientData)); -EXTERN void Tcl_AsyncDelete _ANSI_ARGS_((Tcl_AsyncHandler async)); -EXTERN int Tcl_AsyncInvoke _ANSI_ARGS_((Tcl_Interp *interp, - int code)); -EXTERN void Tcl_AsyncMark _ANSI_ARGS_((Tcl_AsyncHandler async)); -EXTERN int Tcl_AsyncReady _ANSI_ARGS_((void)); -EXTERN void Tcl_BackgroundError _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN char Tcl_Backslash _ANSI_ARGS_((char *src, - int *readPtr)); -EXTERN void Tcl_CallWhenDeleted _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_InterpDeleteProc *proc, - ClientData clientData)); -EXTERN void Tcl_CancelIdleCall _ANSI_ARGS_((Tcl_IdleProc *idleProc, - ClientData clientData)); -EXTERN VOID * Tcl_Ckalloc _ANSI_ARGS_((unsigned int size)); -EXTERN void Tcl_Ckfree _ANSI_ARGS_((char *ptr)); -EXTERN int Tcl_Close _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Channel chan)); -EXTERN int Tcl_CommandComplete _ANSI_ARGS_((char *cmd)); -EXTERN char * Tcl_Concat _ANSI_ARGS_((int argc, char **argv)); -EXTERN int Tcl_ConvertElement _ANSI_ARGS_((char *src, - char *dst, int flags)); -EXTERN int Tcl_CreateAlias _ANSI_ARGS_((Tcl_Interp *slave, - char *slaveCmd, Tcl_Interp *target, - char *targetCmd, int argc, char **argv)); -EXTERN Tcl_Channel Tcl_CreateChannel _ANSI_ARGS_(( - Tcl_ChannelType *typePtr, char *chanName, - Tcl_File inFile, Tcl_File outFile, - ClientData instanceData)); -EXTERN void Tcl_CreateChannelHandler _ANSI_ARGS_(( - Tcl_Channel chan, int mask, - Tcl_ChannelProc *proc, ClientData clientData)); -EXTERN void Tcl_CreateCloseHandler _ANSI_ARGS_(( - Tcl_Channel chan, Tcl_CloseProc *proc, - ClientData clientData)); -EXTERN Tcl_Command Tcl_CreateCommand _ANSI_ARGS_((Tcl_Interp *interp, - char *cmdName, Tcl_CmdProc *proc, - ClientData clientData, - Tcl_CmdDeleteProc *deleteProc)); -EXTERN void Tcl_CreateEventSource _ANSI_ARGS_(( - Tcl_EventSetupProc *setupProc, Tcl_EventCheckProc - *checkProc, ClientData clientData)); -EXTERN void Tcl_CreateExitHandler _ANSI_ARGS_((Tcl_ExitProc *proc, - ClientData clientData)); -EXTERN void Tcl_CreateFileHandler _ANSI_ARGS_(( - Tcl_File file, int mask, Tcl_FileProc *proc, - ClientData clientData)); -EXTERN Tcl_Interp * Tcl_CreateInterp _ANSI_ARGS_((void)); -EXTERN void Tcl_CreateMathFunc _ANSI_ARGS_((Tcl_Interp *interp, - char *name, int numArgs, Tcl_ValueType *argTypes, - Tcl_MathProc *proc, ClientData clientData)); -EXTERN void Tcl_CreateModalTimeout _ANSI_ARGS_((int milliseconds, - Tcl_TimerProc *proc, ClientData clientData)); -EXTERN Tcl_Interp *Tcl_CreateSlave _ANSI_ARGS_((Tcl_Interp *interp, - char *slaveName, int isSafe)); -EXTERN Tcl_TimerToken Tcl_CreateTimerHandler _ANSI_ARGS_((int milliseconds, - Tcl_TimerProc *proc, ClientData clientData)); -EXTERN Tcl_Trace Tcl_CreateTrace _ANSI_ARGS_((Tcl_Interp *interp, - int level, Tcl_CmdTraceProc *proc, - ClientData clientData)); -EXTERN char * Tcl_DbCkalloc _ANSI_ARGS_((unsigned int size, - char *file, int line)); -EXTERN int Tcl_DbCkfree _ANSI_ARGS_((char *ptr, - char *file, int line)); -EXTERN char * Tcl_DbCkrealloc _ANSI_ARGS_((char *ptr, - unsigned int size, char *file, int line)); -EXTERN void Tcl_DeleteAssocData _ANSI_ARGS_((Tcl_Interp *interp, - char *name)); -EXTERN int Tcl_DeleteCommand _ANSI_ARGS_((Tcl_Interp *interp, - char *cmdName)); -EXTERN void Tcl_DeleteChannelHandler _ANSI_ARGS_(( - Tcl_Channel chan, Tcl_ChannelProc *proc, - ClientData clientData)); -EXTERN void Tcl_DeleteCloseHandler _ANSI_ARGS_(( - Tcl_Channel chan, Tcl_CloseProc *proc, - ClientData clientData)); -EXTERN void Tcl_DeleteEventSource _ANSI_ARGS_(( - Tcl_EventSetupProc *setupProc, - Tcl_EventCheckProc *checkProc, - ClientData clientData)); -EXTERN void Tcl_DeleteEvents _ANSI_ARGS_(( - Tcl_EventDeleteProc *proc, - ClientData clientData)); -EXTERN void Tcl_DeleteExitHandler _ANSI_ARGS_((Tcl_ExitProc *proc, - ClientData clientData)); -EXTERN void Tcl_DeleteFileHandler _ANSI_ARGS_(( - Tcl_File file)); -EXTERN void Tcl_DeleteHashEntry _ANSI_ARGS_(( - Tcl_HashEntry *entryPtr)); -EXTERN void Tcl_DeleteHashTable _ANSI_ARGS_(( - Tcl_HashTable *tablePtr)); -EXTERN void Tcl_DeleteInterp _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN void Tcl_DeleteModalTimeout _ANSI_ARGS_(( - Tcl_TimerProc *proc, ClientData clientData)); -EXTERN void Tcl_DeleteTimerHandler _ANSI_ARGS_(( - Tcl_TimerToken token)); -EXTERN void Tcl_DeleteTrace _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Trace trace)); -EXTERN void Tcl_DetachPids _ANSI_ARGS_((int numPids, pid_t *pidPtr)); -EXTERN void Tcl_DontCallWhenDeleted _ANSI_ARGS_(( - Tcl_Interp *interp, Tcl_InterpDeleteProc *proc, - ClientData clientData)); -EXTERN int Tcl_DoOneEvent _ANSI_ARGS_((int flags)); -EXTERN void Tcl_DoWhenIdle _ANSI_ARGS_((Tcl_IdleProc *proc, - ClientData clientData)); -EXTERN char * Tcl_DStringAppend _ANSI_ARGS_((Tcl_DString *dsPtr, - char *string, int length)); -EXTERN char * Tcl_DStringAppendElement _ANSI_ARGS_(( - Tcl_DString *dsPtr, char *string)); -EXTERN void Tcl_DStringEndSublist _ANSI_ARGS_((Tcl_DString *dsPtr)); -EXTERN void Tcl_DStringFree _ANSI_ARGS_((Tcl_DString *dsPtr)); -EXTERN void Tcl_DStringGetResult _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_DString *dsPtr)); -EXTERN void Tcl_DStringInit _ANSI_ARGS_((Tcl_DString *dsPtr)); -EXTERN void Tcl_DStringResult _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_DString *dsPtr)); -EXTERN void Tcl_DStringSetLength _ANSI_ARGS_((Tcl_DString *dsPtr, - int length)); -EXTERN void Tcl_DStringStartSublist _ANSI_ARGS_(( - Tcl_DString *dsPtr)); -EXTERN int Tcl_Eof _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN char * Tcl_ErrnoId _ANSI_ARGS_((void)); -EXTERN char * Tcl_ErrnoMsg _ANSI_ARGS_((int err)); -EXTERN int Tcl_Eval _ANSI_ARGS_((Tcl_Interp *interp, char *cmd)); -EXTERN int Tcl_EvalFile _ANSI_ARGS_((Tcl_Interp *interp, - char *fileName)); -EXTERN void Tcl_EventuallyFree _ANSI_ARGS_((ClientData clientData, - Tcl_FreeProc *freeProc)); -EXTERN void Tcl_Exit _ANSI_ARGS_((int status)); -EXTERN int Tcl_ExprBoolean _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int *ptr)); -EXTERN int Tcl_ExprDouble _ANSI_ARGS_((Tcl_Interp *interp, - char *string, double *ptr)); -EXTERN int Tcl_ExprLong _ANSI_ARGS_((Tcl_Interp *interp, - char *string, long *ptr)); -EXTERN int Tcl_ExprString _ANSI_ARGS_((Tcl_Interp *interp, - char *string)); -EXTERN int Tcl_FileReady _ANSI_ARGS_((Tcl_File file, - int mask)); -EXTERN void Tcl_FindExecutable _ANSI_ARGS_((char *argv0)); -EXTERN Tcl_HashEntry * Tcl_FirstHashEntry _ANSI_ARGS_(( - Tcl_HashTable *tablePtr, - Tcl_HashSearch *searchPtr)); -EXTERN int Tcl_Flush _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN void Tcl_FreeFile _ANSI_ARGS_(( - Tcl_File file)); -EXTERN int Tcl_GetAlias _ANSI_ARGS_((Tcl_Interp *interp, - char *slaveCmd, Tcl_Interp **targetInterpPtr, - char **targetCmdPtr, int *argcPtr, - char ***argvPtr)); -EXTERN ClientData Tcl_GetAssocData _ANSI_ARGS_((Tcl_Interp *interp, - char *name, Tcl_InterpDeleteProc **procPtr)); -EXTERN int Tcl_GetBoolean _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int *boolPtr)); -EXTERN Tcl_Channel Tcl_GetChannel _ANSI_ARGS_((Tcl_Interp *interp, - char *chanName, int *modePtr)); -EXTERN int Tcl_GetChannelBufferSize _ANSI_ARGS_(( - Tcl_Channel chan)); -EXTERN Tcl_File Tcl_GetChannelFile _ANSI_ARGS_((Tcl_Channel chan, - int direction)); -EXTERN ClientData Tcl_GetChannelInstanceData _ANSI_ARGS_(( - Tcl_Channel chan)); -EXTERN int Tcl_GetChannelOption _ANSI_ARGS_((Tcl_Channel chan, - char *optionName, Tcl_DString *dsPtr)); -EXTERN char * Tcl_GetChannelName _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN Tcl_ChannelType * Tcl_GetChannelType _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN int Tcl_GetCommandInfo _ANSI_ARGS_((Tcl_Interp *interp, - char *cmdName, Tcl_CmdInfo *infoPtr)); -EXTERN char * Tcl_GetCommandName _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Command command)); -EXTERN char * Tcl_GetCwd _ANSI_ARGS_((char *buf, int len)); -EXTERN int Tcl_GetDouble _ANSI_ARGS_((Tcl_Interp *interp, - char *string, double *doublePtr)); -EXTERN int Tcl_GetErrno _ANSI_ARGS_((void)); -EXTERN Tcl_File Tcl_GetFile _ANSI_ARGS_((ClientData fileData, - int type)); -EXTERN ClientData Tcl_GetFileInfo _ANSI_ARGS_((Tcl_File file, - int *typePtr)); -EXTERN char * Tcl_GetHostName _ANSI_ARGS_((void)); -EXTERN int Tcl_GetInt _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int *intPtr)); -EXTERN int Tcl_GetInterpPath _ANSI_ARGS_((Tcl_Interp *askInterp, - Tcl_Interp *slaveInterp)); -EXTERN Tcl_Interp *Tcl_GetMaster _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN ClientData Tcl_GetNotifierData _ANSI_ARGS_((Tcl_File file, - Tcl_FileFreeProc **freeProcPtr)); -EXTERN int Tcl_GetOpenFile _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int write, int checkUsage, - ClientData *filePtr)); -EXTERN Tcl_PathType Tcl_GetPathType _ANSI_ARGS_((char *path)); -EXTERN int Tcl_Gets _ANSI_ARGS_((Tcl_Channel chan, - Tcl_DString *dsPtr)); -EXTERN Tcl_Interp *Tcl_GetSlave _ANSI_ARGS_((Tcl_Interp *interp, - char *slaveName)); -EXTERN Tcl_Channel Tcl_GetStdChannel _ANSI_ARGS_((int type)); -EXTERN char * Tcl_GetVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, int flags)); -EXTERN char * Tcl_GetVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, int flags)); -EXTERN int Tcl_GlobalEval _ANSI_ARGS_((Tcl_Interp *interp, - char *command)); -EXTERN char * Tcl_HashStats _ANSI_ARGS_((Tcl_HashTable *tablePtr)); -EXTERN int Tcl_Init _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN void Tcl_InitHashTable _ANSI_ARGS_((Tcl_HashTable *tablePtr, - int keyType)); -EXTERN void Tcl_InitMemory _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN int Tcl_InputBlocked _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN int Tcl_InputBuffered _ANSI_ARGS_((Tcl_Channel chan)); -EXTERN int Tcl_InterpDeleted _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN int Tcl_IsSafe _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN char * Tcl_JoinPath _ANSI_ARGS_((int argc, char **argv, - Tcl_DString *resultPtr)); -EXTERN int Tcl_LinkVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, char *addr, int type)); -EXTERN void Tcl_Main _ANSI_ARGS_((int argc, char **argv, - Tcl_AppInitProc *appInitProc)); -EXTERN Tcl_Channel Tcl_MakeFileChannel _ANSI_ARGS_((ClientData inFile, - ClientData outFile, int mode)); -EXTERN int Tcl_MakeSafe _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN Tcl_Channel Tcl_MakeTcpClientChannel _ANSI_ARGS_(( - ClientData tcpSocket)); -EXTERN char * Tcl_Merge _ANSI_ARGS_((int argc, char **argv)); -EXTERN Tcl_HashEntry * Tcl_NextHashEntry _ANSI_ARGS_(( - Tcl_HashSearch *searchPtr)); -EXTERN Tcl_Channel Tcl_OpenCommandChannel _ANSI_ARGS_(( - Tcl_Interp *interp, int argc, char **argv, - int flags)); -EXTERN Tcl_Channel Tcl_OpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp, - char *fileName, char *modeString, - int permissions)); -EXTERN Tcl_Channel Tcl_OpenTcpClient _ANSI_ARGS_((Tcl_Interp *interp, - int port, char *address, char *myaddr, - int myport, int async)); -EXTERN Tcl_Channel Tcl_OpenTcpServer _ANSI_ARGS_((Tcl_Interp *interp, - int port, char *host, - Tcl_TcpAcceptProc *acceptProc, - ClientData callbackData)); -EXTERN char * Tcl_ParseVar _ANSI_ARGS_((Tcl_Interp *interp, - char *string, char **termPtr)); -EXTERN int Tcl_PkgProvide _ANSI_ARGS_((Tcl_Interp *interp, - char *name, char *version)); -EXTERN char * Tcl_PkgRequire _ANSI_ARGS_((Tcl_Interp *interp, - char *name, char *version, int exact)); -EXTERN char * Tcl_PosixError _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN void Tcl_Preserve _ANSI_ARGS_((ClientData data)); -EXTERN void Tcl_PrintDouble _ANSI_ARGS_((Tcl_Interp *interp, - double value, char *dst)); -EXTERN int Tcl_PutEnv _ANSI_ARGS_((CONST char *string)); -EXTERN void Tcl_QueueEvent _ANSI_ARGS_((Tcl_Event *evPtr, - Tcl_QueuePosition position)); -EXTERN int Tcl_Read _ANSI_ARGS_((Tcl_Channel chan, - char *bufPtr, int toRead)); -EXTERN void Tcl_ReapDetachedProcs _ANSI_ARGS_((void)); -EXTERN int Tcl_RecordAndEval _ANSI_ARGS_((Tcl_Interp *interp, - char *cmd, int flags)); -EXTERN Tcl_RegExp Tcl_RegExpCompile _ANSI_ARGS_((Tcl_Interp *interp, - char *string)); -EXTERN int Tcl_RegExpExec _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_RegExp regexp, char *string, char *start)); -EXTERN int Tcl_RegExpMatch _ANSI_ARGS_((Tcl_Interp *interp, - char *string, char *pattern)); -EXTERN void Tcl_RegExpRange _ANSI_ARGS_((Tcl_RegExp regexp, - int index, char **startPtr, char **endPtr)); -EXTERN void Tcl_RegisterChannel _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Channel chan)); -EXTERN void Tcl_Release _ANSI_ARGS_((ClientData clientData)); -EXTERN void Tcl_ResetResult _ANSI_ARGS_((Tcl_Interp *interp)); -#define Tcl_Return Tcl_SetResult -EXTERN int Tcl_ScanElement _ANSI_ARGS_((char *string, - int *flagPtr)); -EXTERN int Tcl_Seek _ANSI_ARGS_((Tcl_Channel chan, - int offset, int mode)); -EXTERN void Tcl_SetAssocData _ANSI_ARGS_((Tcl_Interp *interp, - char *name, Tcl_InterpDeleteProc *proc, - ClientData clientData)); -EXTERN void Tcl_SetChannelBufferSize _ANSI_ARGS_(( - Tcl_Channel chan, int sz)); -EXTERN int Tcl_SetChannelOption _ANSI_ARGS_(( - Tcl_Interp *interp, Tcl_Channel chan, - char *optionName, char *newValue)); -EXTERN int Tcl_SetCommandInfo _ANSI_ARGS_((Tcl_Interp *interp, - char *cmdName, Tcl_CmdInfo *infoPtr)); -EXTERN void Tcl_SetErrno _ANSI_ARGS_((int errno)); -EXTERN void Tcl_SetErrorCode _ANSI_ARGS_( - TCL_VARARGS(Tcl_Interp *,interp)); -EXTERN void Tcl_SetMaxBlockTime _ANSI_ARGS_((Tcl_Time *timePtr)); -EXTERN void Tcl_SetNotifierData _ANSI_ARGS_((Tcl_File file, - Tcl_FileFreeProc *freeProcPtr, ClientData data)); -EXTERN void Tcl_SetPanicProc _ANSI_ARGS_((void (*proc) - _ANSI_ARGS_(TCL_VARARGS(char *, format)))); -EXTERN int Tcl_SetRecursionLimit _ANSI_ARGS_((Tcl_Interp *interp, - int depth)); -EXTERN void Tcl_SetResult _ANSI_ARGS_((Tcl_Interp *interp, - char *string, Tcl_FreeProc *freeProc)); -EXTERN void Tcl_SetStdChannel _ANSI_ARGS_((Tcl_Channel channel, - int type)); -EXTERN char * Tcl_SetVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, char *newValue, int flags)); -EXTERN char * Tcl_SetVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, char *newValue, - int flags)); -EXTERN char * Tcl_SignalId _ANSI_ARGS_((int sig)); -EXTERN char * Tcl_SignalMsg _ANSI_ARGS_((int sig)); -EXTERN void Tcl_Sleep _ANSI_ARGS_((int ms)); -EXTERN int Tcl_SplitList _ANSI_ARGS_((Tcl_Interp *interp, - char *list, int *argcPtr, char ***argvPtr)); -EXTERN void Tcl_SplitPath _ANSI_ARGS_((char *path, - int *argcPtr, char ***argvPtr)); -EXTERN void Tcl_StaticPackage _ANSI_ARGS_((Tcl_Interp *interp, - char *pkgName, Tcl_PackageInitProc *initProc, - Tcl_PackageInitProc *safeInitProc)); -EXTERN int Tcl_StringMatch _ANSI_ARGS_((char *string, - char *pattern)); -EXTERN int Tcl_Tell _ANSI_ARGS_((Tcl_Channel chan)); -#define Tcl_TildeSubst Tcl_TranslateFileName -EXTERN int Tcl_TraceVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, int flags, Tcl_VarTraceProc *proc, - ClientData clientData)); -EXTERN int Tcl_TraceVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, int flags, - Tcl_VarTraceProc *proc, ClientData clientData)); -EXTERN char * Tcl_TranslateFileName _ANSI_ARGS_((Tcl_Interp *interp, - char *name, Tcl_DString *bufferPtr)); -EXTERN void Tcl_UnlinkVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName)); -EXTERN int Tcl_UnregisterChannel _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Channel chan)); -EXTERN int Tcl_UnsetVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, int flags)); -EXTERN int Tcl_UnsetVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, int flags)); -EXTERN void Tcl_UntraceVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, int flags, Tcl_VarTraceProc *proc, - ClientData clientData)); -EXTERN void Tcl_UntraceVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, int flags, - Tcl_VarTraceProc *proc, ClientData clientData)); -EXTERN void Tcl_UpdateLinkedVar _ANSI_ARGS_((Tcl_Interp *interp, - char *varName)); -EXTERN int Tcl_UpVar _ANSI_ARGS_((Tcl_Interp *interp, - char *frameName, char *varName, - char *localName, int flags)); -EXTERN int Tcl_UpVar2 _ANSI_ARGS_((Tcl_Interp *interp, - char *frameName, char *part1, char *part2, - char *localName, int flags)); -EXTERN int Tcl_VarEval _ANSI_ARGS_( - TCL_VARARGS(Tcl_Interp *,interp)); -EXTERN ClientData Tcl_VarTraceInfo _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, int flags, - Tcl_VarTraceProc *procPtr, - ClientData prevClientData)); -EXTERN ClientData Tcl_VarTraceInfo2 _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, int flags, - Tcl_VarTraceProc *procPtr, - ClientData prevClientData)); -EXTERN int Tcl_WaitForEvent _ANSI_ARGS_((Tcl_Time *timePtr)); -EXTERN int Tcl_WaitPid _ANSI_ARGS_((pid_t pid, int *statPtr, - int options)); -EXTERN void Tcl_WatchFile _ANSI_ARGS_((Tcl_File file, - int mask)); -EXTERN int Tcl_Write _ANSI_ARGS_((Tcl_Channel chan, - char *s, int slen)); - -#endif /* _TCL */ diff --git a/cde/programs/dtdocbook/tcl/tclAsync.c b/cde/programs/dtdocbook/tcl/tclAsync.c deleted file mode 100644 index 0dc6c0fa5..000000000 --- a/cde/programs/dtdocbook/tcl/tclAsync.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclAsync.c /main/2 1996/08/08 14:42:49 cde-hp $ */ -/* - * tclAsync.c -- - * - * This file provides low-level support needed to invoke signal - * handlers in a safe way. The code here doesn't actually handle - * signals, though. This code is based on proposals made by - * Mark Diekhans and Don Libes. - * - * Copyright (c) 1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclAsync.c 1.6 96/02/15 11:46:15 - */ - -#include "tclInt.h" - -/* - * One of the following structures exists for each asynchronous - * handler: - */ - -typedef struct AsyncHandler { - int ready; /* Non-zero means this handler should - * be invoked in the next call to - * Tcl_AsyncInvoke. */ - struct AsyncHandler *nextPtr; /* Next in list of all handlers for - * the process. */ - Tcl_AsyncProc *proc; /* Procedure to call when handler - * is invoked. */ - ClientData clientData; /* Value to pass to handler when it - * is invoked. */ -} AsyncHandler; - -/* - * The variables below maintain a list of all existing handlers. - */ - -static AsyncHandler *firstHandler; /* First handler defined for process, - * or NULL if none. */ -static AsyncHandler *lastHandler; /* Last handler or NULL. */ - -/* - * The variable below is set to 1 whenever a handler becomes ready and - * it is cleared to zero whenever Tcl_AsyncInvoke is called. It can be - * checked elsewhere in the application by calling Tcl_AsyncReady to see - * if Tcl_AsyncInvoke should be invoked. - */ - -static int asyncReady = 0; - -/* - * The variable below indicates whether Tcl_AsyncInvoke is currently - * working. If so then we won't set asyncReady again until - * Tcl_AsyncInvoke returns. - */ - -static int asyncActive = 0; - -/* - *---------------------------------------------------------------------- - * - * Tcl_AsyncCreate -- - * - * This procedure creates the data structures for an asynchronous - * handler, so that no memory has to be allocated when the handler - * is activated. - * - * Results: - * The return value is a token for the handler, which can be used - * to activate it later on. - * - * Side effects: - * Information about the handler is recorded. - * - *---------------------------------------------------------------------- - */ - -Tcl_AsyncHandler -Tcl_AsyncCreate(Tcl_AsyncProc *proc /* Procedure to call when handler is invoked. */, - ClientData clientData /* Argument to pass to handler. */) -{ - AsyncHandler *asyncPtr; - - asyncPtr = (AsyncHandler *) ckalloc(sizeof(AsyncHandler)); - asyncPtr->ready = 0; - asyncPtr->nextPtr = NULL; - asyncPtr->proc = proc; - asyncPtr->clientData = clientData; - if (firstHandler == NULL) { - firstHandler = asyncPtr; - } else { - lastHandler->nextPtr = asyncPtr; - } - lastHandler = asyncPtr; - return (Tcl_AsyncHandler) asyncPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AsyncMark -- - * - * This procedure is called to request that an asynchronous handler - * be invoked as soon as possible. It's typically called from - * an interrupt handler, where it isn't safe to do anything that - * depends on or modifies application state. - * - * Results: - * None. - * - * Side effects: - * The handler gets marked for invocation later. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_AsyncMark(Tcl_AsyncHandler async /* Token for handler. */) -{ - ((AsyncHandler *) async)->ready = 1; - if (!asyncActive) { - asyncReady = 1; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AsyncInvoke -- - * - * This procedure is called at a "safe" time at background level - * to invoke any active asynchronous handlers. - * - * Results: - * The return value is a normal Tcl result, which is intended to - * replace the code argument as the current completion code for - * interp. - * - * Side effects: - * Depends on the handlers that are active. - * - *---------------------------------------------------------------------- - */ -/* interp, If invoked from Tcl_Eval just after completing a command, - * points to interpreter. Otherwise it is NULL. */ -/* code, If interp is non-NULL, this gives completion code from command - * that just completed. */ - -int -Tcl_AsyncInvoke(Tcl_Interp *interp, int code) -{ - AsyncHandler *asyncPtr; - - if (asyncReady == 0) { - return code; - } - asyncReady = 0; - asyncActive = 1; - if (interp == NULL) { - code = 0; - } - - /* - * Make one or more passes over the list of handlers, invoking - * at most one handler in each pass. After invoking a handler, - * go back to the start of the list again so that (a) if a new - * higher-priority handler gets marked while executing a lower - * priority handler, we execute the higher-priority handler - * next, and (b) if a handler gets deleted during the execution - * of a handler, then the list structure may change so it isn't - * safe to continue down the list anyway. - */ - - while (1) { - for (asyncPtr = firstHandler; asyncPtr != NULL; - asyncPtr = asyncPtr->nextPtr) { - if (asyncPtr->ready) { - break; - } - } - if (asyncPtr == NULL) { - break; - } - asyncPtr->ready = 0; - code = (*asyncPtr->proc)(asyncPtr->clientData, interp, code); - } - asyncActive = 0; - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AsyncDelete -- - * - * Frees up all the state for an asynchronous handler. The handler - * should never be used again. - * - * Results: - * None. - * - * Side effects: - * The state associated with the handler is deleted. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_AsyncDelete(Tcl_AsyncHandler async /* Token for handler to delete. */) -{ - AsyncHandler *asyncPtr = (AsyncHandler *) async; - AsyncHandler *prevPtr; - - if (firstHandler == asyncPtr) { - firstHandler = asyncPtr->nextPtr; - if (firstHandler == NULL) { - lastHandler = NULL; - } - } else { - prevPtr = firstHandler; - while (prevPtr->nextPtr != asyncPtr) { - prevPtr = prevPtr->nextPtr; - } - prevPtr->nextPtr = asyncPtr->nextPtr; - if (lastHandler == asyncPtr) { - lastHandler = prevPtr; - } - } - ckfree((char *) asyncPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AsyncReady -- - * - * This procedure can be used to tell whether Tcl_AsyncInvoke - * needs to be called. This procedure is the external interface - * for checking the internal asyncReady variable. - * - * Results: - * The return value is 1 whenever a handler is ready and is 0 - * when no handlers are ready. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_AsyncReady(void) -{ - return asyncReady; -} diff --git a/cde/programs/dtdocbook/tcl/tclBasic.c b/cde/programs/dtdocbook/tcl/tclBasic.c deleted file mode 100644 index ba16ba1fa..000000000 --- a/cde/programs/dtdocbook/tcl/tclBasic.c +++ /dev/null @@ -1,1864 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $TOG: tclBasic.c /main/5 1998/04/17 11:24:16 mgreess $ */ -/* - * tclBasic.c -- - * - * Contains the basic facilities for TCL command interpretation, - * including interpreter creation and deletion, command creation - * and deletion, and command parsing and execution. - * - * Copyright (c) 1987-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclBasic.c 1.210 96/03/25 17:17:54 - */ - -#include "tclInt.h" -#ifndef TCL_GENERIC_ONLY -# include "tclPort.h" -#endif -#include "patchlevel.h" - -/* - * Static procedures in this file: - */ - -static void DeleteInterpProc _ANSI_ARGS_((Tcl_Interp *interp)); - -/* - * The following structure defines all of the commands in the Tcl core, - * and the C procedures that execute them. - */ - -typedef struct { - char *name; /* Name of command. */ - Tcl_CmdProc *proc; /* Procedure that executes command. */ -} CmdInfo; - -/* - * Built-in commands, and the procedures associated with them: - */ - -static CmdInfo builtInCmds[] = { - /* - * Commands in the generic core: - */ - - {"append", Tcl_AppendCmd}, - {"array", Tcl_ArrayCmd}, - {"break", Tcl_BreakCmd}, - {"case", Tcl_CaseCmd}, - {"catch", Tcl_CatchCmd}, - {"clock", Tcl_ClockCmd}, - {"concat", Tcl_ConcatCmd}, - {"continue", Tcl_ContinueCmd}, - {"error", Tcl_ErrorCmd}, - {"eval", Tcl_EvalCmd}, - {"exit", Tcl_ExitCmd}, - {"expr", Tcl_ExprCmd}, - {"fileevent", Tcl_FileEventCmd}, - {"for", Tcl_ForCmd}, - {"foreach", Tcl_ForeachCmd}, - {"format", Tcl_FormatCmd}, - {"global", Tcl_GlobalCmd}, - {"history", Tcl_HistoryCmd}, - {"if", Tcl_IfCmd}, - {"incr", Tcl_IncrCmd}, - {"info", Tcl_InfoCmd}, - {"interp", Tcl_InterpCmd}, - {"join", Tcl_JoinCmd}, - {"lappend", Tcl_LappendCmd}, - {"lindex", Tcl_LindexCmd}, - {"linsert", Tcl_LinsertCmd}, - {"list", Tcl_ListCmd}, - {"llength", Tcl_LlengthCmd}, - {"load", Tcl_LoadCmd}, - {"lrange", Tcl_LrangeCmd}, - {"lreplace", Tcl_LreplaceCmd}, - {"lsearch", Tcl_LsearchCmd}, - {"lsort", Tcl_LsortCmd}, - {"package", Tcl_PackageCmd}, - {"proc", Tcl_ProcCmd}, - {"regexp", Tcl_RegexpCmd}, - {"regsub", Tcl_RegsubCmd}, - {"rename", Tcl_RenameCmd}, - {"return", Tcl_ReturnCmd}, - {"scan", Tcl_ScanCmd}, - {"set", Tcl_SetCmd}, - {"split", Tcl_SplitCmd}, - {"string", Tcl_StringCmd}, - {"subst", Tcl_SubstCmd}, - {"switch", Tcl_SwitchCmd}, - {"trace", Tcl_TraceCmd}, - {"unset", Tcl_UnsetCmd}, - {"uplevel", Tcl_UplevelCmd}, - {"upvar", Tcl_UpvarCmd}, - {"while", Tcl_WhileCmd}, - - /* - * Commands in the UNIX core: - */ - -#ifndef TCL_GENERIC_ONLY - {"after", Tcl_AfterCmd}, - {"cd", Tcl_CdCmd}, - {"close", Tcl_CloseCmd}, - {"eof", Tcl_EofCmd}, - {"fblocked", Tcl_FblockedCmd}, - {"fconfigure", Tcl_FconfigureCmd}, - {"file", Tcl_FileCmd}, - {"flush", Tcl_FlushCmd}, - {"gets", Tcl_GetsCmd}, - {"glob", Tcl_GlobCmd}, - {"open", Tcl_OpenCmd}, - {"pid", Tcl_PidCmd}, - {"puts", Tcl_PutsCmd}, - {"pwd", Tcl_PwdCmd}, - {"read", Tcl_ReadCmd}, - {"seek", Tcl_SeekCmd}, - {"socket", Tcl_SocketCmd}, - {"tell", Tcl_TellCmd}, - {"time", Tcl_TimeCmd}, - {"update", Tcl_UpdateCmd}, - {"vwait", Tcl_VwaitCmd}, - {"unsupported0", TclUnsupported0Cmd}, - -#ifndef MAC_TCL - {"exec", Tcl_ExecCmd}, - {"source", Tcl_SourceCmd}, -#endif - -#ifdef MAC_TCL - {"beep", Tcl_MacBeepCmd}, - {"cp", Tcl_CpCmd}, - {"echo", Tcl_EchoCmd}, - {"ls", Tcl_LsCmd}, - {"mkdir", Tcl_MkdirCmd}, - {"mv", Tcl_MvCmd}, - {"rm", Tcl_RmCmd}, - {"rmdir", Tcl_RmdirCmd}, - {"source", Tcl_MacSourceCmd}, -#endif /* MAC_TCL */ - -#endif /* TCL_GENERIC_ONLY */ - {NULL, (Tcl_CmdProc *) NULL} -}; - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateInterp -- - * - * Create a new TCL command interpreter. - * - * Results: - * The return value is a token for the interpreter, which may be - * used in calls to procedures like Tcl_CreateCmd, Tcl_Eval, or - * Tcl_DeleteInterp. - * - * Side effects: - * The command interpreter is initialized with an empty variable - * table and the built-in commands. - * - *---------------------------------------------------------------------- - */ - -Tcl_Interp * -Tcl_CreateInterp(void) -{ - Interp *iPtr; - Command *cmdPtr; - CmdInfo *cmdInfoPtr; - Tcl_Channel chan; - int i; - - iPtr = (Interp *) ckalloc(sizeof(Interp)); - iPtr->result = iPtr->resultSpace; - iPtr->freeProc = 0; - iPtr->errorLine = 0; - Tcl_InitHashTable(&iPtr->commandTable, TCL_STRING_KEYS); - Tcl_InitHashTable(&iPtr->mathFuncTable, TCL_STRING_KEYS); - Tcl_InitHashTable(&iPtr->globalTable, TCL_STRING_KEYS); - iPtr->numLevels = 0; - iPtr->maxNestingDepth = 1000; - iPtr->framePtr = NULL; - iPtr->varFramePtr = NULL; - iPtr->activeTracePtr = NULL; - iPtr->returnCode = TCL_OK; - iPtr->errorInfo = NULL; - iPtr->errorCode = NULL; - iPtr->numEvents = 0; - iPtr->events = NULL; - iPtr->curEvent = 0; - iPtr->curEventNum = 0; - iPtr->revPtr = NULL; - iPtr->historyFirst = NULL; - iPtr->revDisables = 1; - iPtr->evalFirst = iPtr->evalLast = NULL; - iPtr->appendResult = NULL; - iPtr->appendAvl = 0; - iPtr->appendUsed = 0; - for (i = 0; i < NUM_REGEXPS; i++) { - iPtr->patterns[i] = NULL; - iPtr->patLengths[i] = -1; - iPtr->regexps[i] = NULL; - } - Tcl_InitHashTable(&iPtr->packageTable, TCL_STRING_KEYS); - iPtr->packageUnknown = NULL; - strcpy(iPtr->pdFormat, DEFAULT_PD_FORMAT); - iPtr->pdPrec = DEFAULT_PD_PREC; - iPtr->cmdCount = 0; - iPtr->noEval = 0; - iPtr->evalFlags = 0; - iPtr->scriptFile = NULL; - iPtr->flags = 0; - iPtr->tracePtr = NULL; - iPtr->assocData = (Tcl_HashTable *) NULL; - iPtr->resultSpace[0] = 0; - - /* - * Create the built-in commands. Do it here, rather than calling - * Tcl_CreateCommand, because it's faster (there's no need to - * check for a pre-existing command by the same name). - */ - - for (cmdInfoPtr = builtInCmds; cmdInfoPtr->name != NULL; cmdInfoPtr++) { - int new; - Tcl_HashEntry *hPtr; - - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, - cmdInfoPtr->name, &new); - if (new) { - cmdPtr = (Command *) ckalloc(sizeof(Command)); - cmdPtr->hPtr = hPtr; - cmdPtr->proc = cmdInfoPtr->proc; - cmdPtr->clientData = (ClientData) NULL; - cmdPtr->deleteProc = NULL; - cmdPtr->deleteData = (ClientData) NULL; - cmdPtr->deleted = 0; - Tcl_SetHashValue(hPtr, cmdPtr); - } - } - -#ifndef TCL_GENERIC_ONLY - TclSetupEnv((Tcl_Interp *) iPtr); -#endif - - /* - * Do Safe-Tcl init stuff - */ - - (void) TclInterpInit((Tcl_Interp *)iPtr); - - /* - * Set up variables such as tcl_library and tcl_precision. - */ - - TclPlatformInit((Tcl_Interp *)iPtr); - Tcl_SetVar((Tcl_Interp *) iPtr, "tcl_patchLevel", TCL_PATCH_LEVEL, - TCL_GLOBAL_ONLY); - Tcl_SetVar((Tcl_Interp *) iPtr, "tcl_version", TCL_VERSION, - TCL_GLOBAL_ONLY); - Tcl_TraceVar2((Tcl_Interp *) iPtr, "tcl_precision", (char *) NULL, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - TclPrecTraceProc, (ClientData) NULL); - - /* - * Register Tcl's version number. - */ - - Tcl_PkgProvide((Tcl_Interp *) iPtr, "Tcl", TCL_VERSION); - - /* - * Add the standard channels. - */ - - chan = Tcl_GetStdChannel(TCL_STDIN); - if (chan != (Tcl_Channel) NULL) { - Tcl_RegisterChannel((Tcl_Interp *) iPtr, chan); - } - chan = Tcl_GetStdChannel(TCL_STDOUT); - if (chan != (Tcl_Channel) NULL) { - Tcl_RegisterChannel((Tcl_Interp *) iPtr, chan); - } - chan = Tcl_GetStdChannel(TCL_STDERR); - if (chan != (Tcl_Channel) NULL) { - Tcl_RegisterChannel((Tcl_Interp *) iPtr, chan); - } - - return (Tcl_Interp *) iPtr; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_CallWhenDeleted -- - * - * Arrange for a procedure to be called before a given - * interpreter is deleted. The procedure is called as soon - * as Tcl_DeleteInterp is called; if Tcl_CallWhenDeleted is - * called on an interpreter that has already been deleted, - * the procedure will be called when the last Tcl_Release is - * done on the interpreter. - * - * Results: - * None. - * - * Side effects: - * When Tcl_DeleteInterp is invoked to delete interp, - * proc will be invoked. See the manual entry for - * details. - * - *-------------------------------------------------------------- - */ -/* interp, Interpreter to watch. */ -/* proc, Procedure to call when interpreter is about to be deleted. */ -/* clientData, One-word value to pass to proc. */ - -void -Tcl_CallWhenDeleted(Tcl_Interp *interp, Tcl_InterpDeleteProc *proc, ClientData clientData) -{ - Interp *iPtr = (Interp *) interp; - static int assocDataCounter = 0; - int new; - char buffer[128]; - AssocData *dPtr = (AssocData *) ckalloc(sizeof(AssocData)); - Tcl_HashEntry *hPtr; - - sprintf(buffer, "Assoc Data Key #%d", assocDataCounter); - assocDataCounter++; - - if (iPtr->assocData == (Tcl_HashTable *) NULL) { - iPtr->assocData = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(iPtr->assocData, TCL_STRING_KEYS); - } - hPtr = Tcl_CreateHashEntry(iPtr->assocData, buffer, &new); - dPtr->proc = proc; - dPtr->clientData = clientData; - Tcl_SetHashValue(hPtr, dPtr); -} - -/* - *-------------------------------------------------------------- - * - * Tcl_DontCallWhenDeleted -- - * - * Cancel the arrangement for a procedure to be called when - * a given interpreter is deleted. - * - * Results: - * None. - * - * Side effects: - * If proc and clientData were previously registered as a - * callback via Tcl_CallWhenDeleted, they are unregistered. - * If they weren't previously registered then nothing - * happens. - * - *-------------------------------------------------------------- - */ -/* interp, Interpreter to watch. */ -/* proc, Procedure to call when interpreter is about to be deleted. */ -/* clientData, One-word value to pass to proc. */ - -void -Tcl_DontCallWhenDeleted(Tcl_Interp *interp, Tcl_InterpDeleteProc *proc, ClientData clientData) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashTable *hTablePtr; - Tcl_HashSearch hSearch; - Tcl_HashEntry *hPtr; - AssocData *dPtr; - - hTablePtr = iPtr->assocData; - if (hTablePtr == (Tcl_HashTable *) NULL) { - return; - } - for (hPtr = Tcl_FirstHashEntry(hTablePtr, &hSearch); hPtr != NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - dPtr = (AssocData *) Tcl_GetHashValue(hPtr); - if ((dPtr->proc == proc) && (dPtr->clientData == clientData)) { - ckfree((char *) dPtr); - Tcl_DeleteHashEntry(hPtr); - return; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetAssocData -- - * - * Creates a named association between user-specified data, a delete - * function and this interpreter. If the association already exists - * the data is overwritten with the new data. The delete function will - * be invoked when the interpreter is deleted. - * - * Results: - * None. - * - * Side effects: - * Sets the associated data, creates the association if needed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetAssocData( -Tcl_Interp *interp /* Interpreter to associate with. */, -char *name /* Name for association. */, -Tcl_InterpDeleteProc *proc /* Proc to call when interpreter is about to be deleted. */, -ClientData clientData /* One-word value to pass to proc. */ -) -{ - Interp *iPtr = (Interp *) interp; - AssocData *dPtr; - Tcl_HashEntry *hPtr; - int new; - - if (iPtr->assocData == (Tcl_HashTable *) NULL) { - iPtr->assocData = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(iPtr->assocData, TCL_STRING_KEYS); - } - hPtr = Tcl_CreateHashEntry(iPtr->assocData, name, &new); - if (new == 0) { - dPtr = (AssocData *) Tcl_GetHashValue(hPtr); - } else { - dPtr = (AssocData *) ckalloc(sizeof(AssocData)); - } - dPtr->proc = proc; - dPtr->clientData = clientData; - - Tcl_SetHashValue(hPtr, dPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteAssocData -- - * - * Deletes a named association of user-specified data with - * the specified interpreter. - * - * Results: - * None. - * - * Side effects: - * Deletes the association. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteAssocData( - Tcl_Interp *interp /* Interpreter to associate with. */, - char *name /* Name of association. */ -) -{ - Interp *iPtr = (Interp *) interp; - AssocData *dPtr; - Tcl_HashEntry *hPtr; - - if (iPtr->assocData == (Tcl_HashTable *) NULL) { - return; - } - hPtr = Tcl_FindHashEntry(iPtr->assocData, name); - if (hPtr == (Tcl_HashEntry *) NULL) { - return; - } - dPtr = (AssocData *) Tcl_GetHashValue(hPtr); - if (dPtr->proc != NULL) { - (dPtr->proc) (dPtr->clientData, interp); - } - ckfree((char *) dPtr); - Tcl_DeleteHashEntry(hPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetAssocData -- - * - * Returns the client data associated with this name in the - * specified interpreter. - * - * Results: - * The client data in the AssocData record denoted by the named - * association, or NULL. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_GetAssocData( - Tcl_Interp *interp /* Interpreter associated with. */, - char *name /* Name of association. */, - Tcl_InterpDeleteProc **procPtr /* Pointer to place to store address - * of current deletion callback. */ -) -{ - Interp *iPtr = (Interp *) interp; - AssocData *dPtr; - Tcl_HashEntry *hPtr; - - if (iPtr->assocData == (Tcl_HashTable *) NULL) { - return (ClientData) NULL; - } - hPtr = Tcl_FindHashEntry(iPtr->assocData, name); - if (hPtr == (Tcl_HashEntry *) NULL) { - return (ClientData) NULL; - } - dPtr = (AssocData *) Tcl_GetHashValue(hPtr); - if (procPtr != (Tcl_InterpDeleteProc **) NULL) { - *procPtr = dPtr->proc; - } - return dPtr->clientData; -} - -/* - *---------------------------------------------------------------------- - * - * DeleteInterpProc -- - * - * Helper procedure to delete an interpreter. This procedure is - * called when the last call to Tcl_Preserve on this interpreter - * is matched by a call to Tcl_Release. The procedure cleans up - * all resources used in the interpreter and calls all currently - * registered interpreter deletion callbacks. - * - * Results: - * None. - * - * Side effects: - * Whatever the interpreter deletion callbacks do. Frees resources - * used by the interpreter. - * - *---------------------------------------------------------------------- - */ - -static void -DeleteInterpProc( - Tcl_Interp *interp /* Interpreter to delete. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - int i; - Tcl_HashTable *hTablePtr; - AssocData *dPtr; - - /* - * Punt if there is an error in the Tcl_Release/Tcl_Preserve matchup. - */ - - if (iPtr->numLevels > 0) { - panic("DeleteInterpProc called with active evals"); - } - - /* - * The interpreter should already be marked deleted; otherwise how - * did we get here? - */ - - if (!(iPtr->flags & DELETED)) { - panic("DeleteInterpProc called on interpreter not marked deleted"); - } - - /* - * First delete all the commands. There's a special hack here - * because "tkerror" is just a synonym for "bgerror" (they share - * a Command structure). Just delete the hash table entry for - * "tkerror" without invoking its callback or cleaning up its - * Command structure. - */ - - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, "tkerror"); - if (hPtr != NULL) { - Tcl_DeleteHashEntry(hPtr); - } - for (hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search); - hPtr != NULL; - hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search)) { - Tcl_DeleteCommand(interp, - Tcl_GetHashKey(&iPtr->commandTable, hPtr)); - } - Tcl_DeleteHashTable(&iPtr->commandTable); - for (hPtr = Tcl_FirstHashEntry(&iPtr->mathFuncTable, &search); - hPtr != NULL; - hPtr = Tcl_NextHashEntry(&search)) { - ckfree((char *) Tcl_GetHashValue(hPtr)); - } - Tcl_DeleteHashTable(&iPtr->mathFuncTable); - - /* - * Invoke deletion callbacks; note that a callback can create new - * callbacks, so we iterate. - */ - - while (iPtr->assocData != (Tcl_HashTable *) NULL) { - hTablePtr = iPtr->assocData; - iPtr->assocData = (Tcl_HashTable *) NULL; - for (hPtr = Tcl_FirstHashEntry(hTablePtr, &search); - hPtr != NULL; - hPtr = Tcl_FirstHashEntry(hTablePtr, &search)) { - dPtr = (AssocData *) Tcl_GetHashValue(hPtr); - Tcl_DeleteHashEntry(hPtr); - if (dPtr->proc != NULL) { - (*dPtr->proc)(dPtr->clientData, interp); - } - ckfree((char *) dPtr); - } - Tcl_DeleteHashTable(hTablePtr); - ckfree((char *) hTablePtr); - } - - /* - * Delete all global variables: - */ - - TclDeleteVars(iPtr, &iPtr->globalTable); - - /* - * Free up the result *after* deleting variables, since variable - * deletion could have transferred ownership of the result string - * to Tcl. - */ - - Tcl_FreeResult(interp); - interp->result = NULL; - - if (iPtr->errorInfo != NULL) { - ckfree(iPtr->errorInfo); - iPtr->errorInfo = NULL; - } - if (iPtr->errorCode != NULL) { - ckfree(iPtr->errorCode); - iPtr->errorCode = NULL; - } - if (iPtr->events != NULL) { - int i; - - for (i = 0; i < iPtr->numEvents; i++) { - ckfree(iPtr->events[i].command); - } - ckfree((char *) iPtr->events); - iPtr->events = NULL; - } - while (iPtr->revPtr != NULL) { - HistoryRev *nextPtr = iPtr->revPtr->nextPtr; - - ckfree(iPtr->revPtr->newBytes); - ckfree((char *) iPtr->revPtr); - iPtr->revPtr = nextPtr; - } - if (iPtr->appendResult != NULL) { - ckfree(iPtr->appendResult); - iPtr->appendResult = NULL; - } - for (i = 0; i < NUM_REGEXPS; i++) { - if (iPtr->patterns[i] == NULL) { - break; - } - ckfree(iPtr->patterns[i]); - ckfree((char *) iPtr->regexps[i]); - iPtr->regexps[i] = NULL; - } - TclFreePackageInfo(iPtr); - while (iPtr->tracePtr != NULL) { - Trace *nextPtr = iPtr->tracePtr->nextPtr; - - ckfree((char *) iPtr->tracePtr); - iPtr->tracePtr = nextPtr; - } - - ckfree((char *) iPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InterpDeleted -- - * - * Returns nonzero if the interpreter has been deleted with a call - * to Tcl_DeleteInterp. - * - * Results: - * Nonzero if the interpreter is deleted, zero otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_InterpDeleted(Tcl_Interp *interp) -{ - return (((Interp *) interp)->flags & DELETED) ? 1 : 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteInterp -- - * - * Ensures that the interpreter will be deleted eventually. If there - * are no Tcl_Preserve calls in effect for this interpreter, it is - * deleted immediately, otherwise the interpreter is deleted when - * the last Tcl_Preserve is matched by a call to Tcl_Release. In either - * case, the procedure runs the currently registered deletion callbacks. - * - * Results: - * None. - * - * Side effects: - * The interpreter is marked as deleted. The caller may still use it - * safely if there are calls to Tcl_Preserve in effect for the - * interpreter, but further calls to Tcl_Eval etc in this interpreter - * will fail. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteInterp( - Tcl_Interp *interp /* Token for command interpreter (returned - * by a previous call to Tcl_CreateInterp). */ -) -{ - Interp *iPtr = (Interp *) interp; - - /* - * If the interpreter has already been marked deleted, just punt. - */ - - if (iPtr->flags & DELETED) { - return; - } - - /* - * Mark the interpreter as deleted. No further evals will be allowed. - */ - - iPtr->flags |= DELETED; - - /* - * Ensure that the interpreter is eventually deleted. - */ - - Tcl_EventuallyFree((ClientData) interp, - (Tcl_FreeProc *) DeleteInterpProc); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateCommand -- - * - * Define a new command in a command table. - * - * Results: - * The return value is a token for the command, which can - * be used in future calls to Tcl_NameOfCommand. - * - * Side effects: - * If a command named cmdName already exists for interp, it is - * deleted. In the future, when cmdName is seen as the name of - * a command by Tcl_Eval, proc will be called. When the command - * is deleted from the table, deleteProc will be called. See the - * manual entry for details on the calling sequence. - * - *---------------------------------------------------------------------- - */ - -Tcl_Command -Tcl_CreateCommand( - Tcl_Interp *interp, /* Token for command interpreter (returned - * by a previous call to Tcl_CreateInterp). */ - char *cmdName, /* Name of command. */ - Tcl_CmdProc *proc, /* Command procedure to associate with - * cmdName. */ - ClientData clientData, /* Arbitrary one-word value to pass to proc. */ - Tcl_CmdDeleteProc *deleteProc - /* If not NULL, gives a procedure to call when - * this command is deleted. */ -) -{ - Interp *iPtr = (Interp *) interp; - Command *cmdPtr; - Tcl_HashEntry *hPtr; - int new; - - /* - * The code below was added in 11/95 to preserve backwards compatibility - * when "tkerror" was renamed "bgerror": if anyone attempts to define - * "tkerror" as a command, it is actually created as "bgerror". This - * code should eventually be removed. - */ - - if ((cmdName[0] == 't') && (strcmp(cmdName, "tkerror") == 0)) { - cmdName = "bgerror"; - } - - if (iPtr->flags & DELETED) { - - /* - * The interpreter is being deleted. Don't create any new - * commands; it's not safe to muck with the interpreter anymore. - */ - - return (Tcl_Command) NULL; - } - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new); - if (!new) { - /* - * Command already exists: delete the old one. - */ - - Tcl_DeleteCommand(interp, Tcl_GetHashKey(&iPtr->commandTable, hPtr)); - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new); - if (!new) { - /* - * Drat. The stupid deletion callback recreated the command. - * Just throw away the new command (if we try to delete it again, - * we could get stuck in an infinite loop). - */ - - ckfree((char *) Tcl_GetHashValue(hPtr)); - } - } - cmdPtr = (Command *) ckalloc(sizeof(Command)); - Tcl_SetHashValue(hPtr, cmdPtr); - cmdPtr->hPtr = hPtr; - cmdPtr->proc = proc; - cmdPtr->clientData = clientData; - cmdPtr->deleteProc = deleteProc; - cmdPtr->deleteData = clientData; - cmdPtr->deleted = 0; - - /* - * The code below provides more backwards compatibility for the - * renaming of "tkerror" to "bgerror". Like the code above, this - * code should eventually become unnecessary. - */ - - if ((cmdName[0] == 'b') && (strcmp(cmdName, "bgerror") == 0)) { - /* - * We're currently creating the "bgerror" command; create - * a "tkerror" command that shares the same Command structure. - */ - - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, "tkerror", &new); - Tcl_SetHashValue(hPtr, cmdPtr); - } - return (Tcl_Command) cmdPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetCommandInfo -- - * - * Modifies various information about a Tcl command. - * - * Results: - * If cmdName exists in interp, then the information at *infoPtr - * is stored with the command in place of the current information - * and 1 is returned. If the command doesn't exist then 0 is - * returned. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_SetCommandInfo( - Tcl_Interp *interp, /* Interpreter in which to look - * for command. */ - char *cmdName, /* Name of desired command. */ - Tcl_CmdInfo *infoPtr /* Where to store information about - * command. */ -) -{ - Tcl_HashEntry *hPtr; - Command *cmdPtr; - - hPtr = Tcl_FindHashEntry(&((Interp *) interp)->commandTable, cmdName); - if (hPtr == NULL) { - return 0; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - cmdPtr->proc = infoPtr->proc; - cmdPtr->clientData = infoPtr->clientData; - cmdPtr->deleteProc = infoPtr->deleteProc; - cmdPtr->deleteData = infoPtr->deleteData; - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetCommandInfo -- - * - * Returns various information about a Tcl command. - * - * Results: - * If cmdName exists in interp, then *infoPtr is modified to - * hold information about cmdName and 1 is returned. If the - * command doesn't exist then 0 is returned and *infoPtr isn't - * modified. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetCommandInfo( - Tcl_Interp *interp, /* Interpreter in which to look - * for command. */ - char *cmdName, /* Name of desired command. */ - Tcl_CmdInfo *infoPtr /* Where to store information about - * command. */ -) -{ - Tcl_HashEntry *hPtr; - Command *cmdPtr; - - hPtr = Tcl_FindHashEntry(&((Interp *) interp)->commandTable, cmdName); - if (hPtr == NULL) { - return 0; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - infoPtr->proc = cmdPtr->proc; - infoPtr->clientData = cmdPtr->clientData; - infoPtr->deleteProc = cmdPtr->deleteProc; - infoPtr->deleteData = cmdPtr->deleteData; - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetCommandName -- - * - * Given a token returned by Tcl_CreateCommand, this procedure - * returns the current name of the command (which may have changed - * due to renaming). - * - * Results: - * The return value is the name of the given command. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_GetCommandName( - Tcl_Interp *interp, /* Interpreter containing the command. */ - Tcl_Command command /* Token for the command, returned by a - * previous call to Tcl_CreateCommand. - * The command must not have been deleted. */ -) -{ - Command *cmdPtr = (Command *) command; - Interp *iPtr = (Interp *) interp; - - if ((cmdPtr == NULL) || (cmdPtr->hPtr == NULL)) { - - /* - * This should only happen if command was "created" after the - * interpreter began to be deleted, so there isn't really any - * command. Just return an empty string. - */ - - return ""; - } - return Tcl_GetHashKey(&iPtr->commandTable, cmdPtr->hPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteCommand -- - * - * Remove the given command from the given interpreter. - * - * Results: - * 0 is returned if the command was deleted successfully. - * -1 is returned if there didn't exist a command by that - * name. - * - * Side effects: - * CmdName will no longer be recognized as a valid command for - * interp. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_DeleteCommand( - Tcl_Interp *interp, /* Token for command interpreter (returned - * by a previous call to Tcl_CreateInterp). */ - char *cmdName /* Name of command to remove. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr, *tkErrorHPtr; - Command *cmdPtr; - - /* - * The code below was added in 11/95 to preserve backwards compatibility - * when "tkerror" was renamed "bgerror": if anyone attempts to delete - * "tkerror", delete both it and "bgerror". This code should - * eventually be removed. - */ - - if ((cmdName[0] == 't') && (strcmp(cmdName, "tkerror") == 0)) { - cmdName = "bgerror"; - } - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, cmdName); - if (hPtr == NULL) { - return -1; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - - /* - * The code here is tricky. We can't delete the hash table entry - * before invoking the deletion callback because there are cases - * where the deletion callback needs to invoke the command (e.g. - * object systems such as OTcl). However, this means that the - * callback could try to delete or rename the command. The deleted - * flag allows us to detect these cases and skip nested deletes. - */ - - if (cmdPtr->deleted) { - - /* - * Another deletion is already in progress. Remove the hash - * table entry now, but don't invoke a callback or free the - * command structure. - */ - - Tcl_DeleteHashEntry(cmdPtr->hPtr); - cmdPtr->hPtr = NULL; - return 0; - } - cmdPtr->deleted = 1; - if (cmdPtr->deleteProc != NULL) { - (*cmdPtr->deleteProc)(cmdPtr->deleteData); - } - - /* - * The code below provides more backwards compatibility for the - * renaming of "tkerror" to "bgerror". Like the code above, this - * code should eventually become unnecessary. - */ - - if ((cmdName[0] == 'b') && (strcmp(cmdName, "bgerror") == 0)) { - - /* - * When the "bgerror" command is deleted, delete "tkerror" - * as well. It shared the same Command structure as "bgerror", - * so all we have to do is throw away the hash table entry. - * NOTE: we have to be careful since tkerror may already have - * been deleted before bgerror. - */ - - tkErrorHPtr = Tcl_FindHashEntry(&iPtr->commandTable, "tkerror"); - if (tkErrorHPtr != (Tcl_HashEntry *) NULL) { - Tcl_DeleteHashEntry(tkErrorHPtr); - } - } - - /* - * Don't use hPtr to delete the hash entry here, because it's - * possible that the deletion callback renamed the command. - * Instead, use cmdPtr->hptr, and make sure that no-one else - * has already deleted the hash entry. - */ - - if (cmdPtr->hPtr != NULL) { - Tcl_DeleteHashEntry(cmdPtr->hPtr); - } - ckfree((char *) cmdPtr); - - return 0; -} - -/* - *----------------------------------------------------------------- - * - * Tcl_Eval -- - * - * Parse and execute a command in the Tcl language. - * - * Results: - * The return value is one of the return codes defined in tcl.hd - * (such as TCL_OK), and interp->result contains a string value - * to supplement the return code. The value of interp->result - * will persist only until the next call to Tcl_Eval: copy it or - * lose it! *TermPtr is filled in with the character just after - * the last one that was part of the command (usually a NULL - * character or a closing bracket). - * - * Side effects: - * Almost certainly; depends on the command. - * - *----------------------------------------------------------------- - */ - -int -Tcl_Eval( - Tcl_Interp *interp, /* Token for command interpreter (returned - * by a previous call to Tcl_CreateInterp). */ - char *cmd /* Pointer to TCL command to interpret. */ -) -{ - /* - * The storage immediately below is used to generate a copy - * of the command, after all argument substitutions. Pv will - * contain the argv values passed to the command procedure. - */ - -# define NUM_CHARS 200 - char copyStorage[NUM_CHARS]; - ParseValue pv; - char *oldBuffer; - - /* - * This procedure generates an (argv, argc) array for the command, - * It starts out with stack-allocated space but uses dynamically- - * allocated storage to increase it if needed. - */ - -# define NUM_ARGS 10 - char *(argStorage[NUM_ARGS]); - char **argv = argStorage; - int argc; - int argSize = NUM_ARGS; - - char *src; /* Points to current character - * in cmd. */ - char termChar; /* Return when this character is found - * (either ']' or '\0'). Zero means - * that newlines terminate commands. */ - int flags; /* Interp->evalFlags value when the - * procedure was called. */ - int result; /* Return value. */ - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr; - Command *cmdPtr; - char *termPtr; /* Contains character just after the - * last one in the command. */ - char *cmdStart; /* Points to first non-blank char. in - * command (used in calling trace - * procedures). */ - char *ellipsis = ""; /* Used in setting errorInfo variable; - * set to "..." to indicate that not - * all of offending command is included - * in errorInfo. "" means that the - * command is all there. */ - Trace *tracePtr; - int oldCount = iPtr->cmdCount; /* Used to tell whether any commands - * at all were executed. */ - - /* - * Initialize the result to an empty string and clear out any - * error information. This makes sure that we return an empty - * result if there are no commands in the command string. - */ - - Tcl_FreeResult((Tcl_Interp *) iPtr); - iPtr->result = iPtr->resultSpace; - iPtr->resultSpace[0] = 0; - result = TCL_OK; - - /* - * Initialize the area in which command copies will be assembled. - */ - - pv.buffer = copyStorage; - pv.end = copyStorage + NUM_CHARS - 1; - pv.expandProc = TclExpandParseValue; - pv.clientData = (ClientData) NULL; - - src = cmd; - flags = iPtr->evalFlags; - iPtr->evalFlags = 0; - if (flags & TCL_BRACKET_TERM) { - termChar = ']'; - } else { - termChar = 0; - } - termPtr = src; - cmdStart = src; - - /* - * Check depth of nested calls to Tcl_Eval: if this gets too large, - * it's probably because of an infinite loop somewhere. - */ - - iPtr->numLevels++; - if (iPtr->numLevels > iPtr->maxNestingDepth) { - iPtr->numLevels--; - iPtr->result = "too many nested calls to Tcl_Eval (infinite loop?)"; - iPtr->termPtr = termPtr; - return TCL_ERROR; - } - - /* - * There can be many sub-commands (separated by semi-colons or - * newlines) in one command string. This outer loop iterates over - * individual commands. - */ - - while (*src != termChar) { - - /* - * If we have been deleted, return an error preventing further - * evals. - */ - - if (iPtr->flags & DELETED) { - Tcl_ResetResult(interp); - interp->result = "attempt to call eval in deleted interpreter"; - Tcl_SetErrorCode(interp, "CORE", "IDELETE", interp->result, - (char *) NULL); - iPtr->numLevels--; - return TCL_ERROR; - } - - iPtr->flags &= ~(ERR_IN_PROGRESS | ERROR_CODE_SET); - - /* - * Skim off leading white space and semi-colons, and skip - * comments. - */ - - while (1) { - char c = *src; - - if ((CHAR_TYPE(c) != TCL_SPACE) && (c != ';') && (c != '\n')) { - break; - } - src += 1; - } - if (*src == '#') { - while (*src != 0) { - if (*src == '\\') { - int length; - Tcl_Backslash(src, &length); - src += length; - } else if (*src == '\n') { - src++; - termPtr = src; - break; - } else { - src++; - } - } - continue; - } - cmdStart = src; - - /* - * Parse the words of the command, generating the argc and - * argv for the command procedure. May have to call - * TclParseWords several times, expanding the argv array - * between calls. - */ - - pv.next = oldBuffer = pv.buffer; - argc = 0; - while (1) { - int newArgs, maxArgs; - char **newArgv; - int i; - - /* - * Note: the "- 2" below guarantees that we won't use the - * last two argv slots here. One is for a NULL pointer to - * mark the end of the list, and the other is to leave room - * for inserting the command name "unknown" as the first - * argument (see below). - */ - - maxArgs = argSize - argc - 2; - result = TclParseWords((Tcl_Interp *) iPtr, src, flags, - maxArgs, &termPtr, &newArgs, &argv[argc], &pv); - src = termPtr; - if (result != TCL_OK) { - ellipsis = "..."; - goto done; - } - - /* - * Careful! Buffer space may have gotten reallocated while - * parsing words. If this happened, be sure to update all - * of the older argv pointers to refer to the new space. - */ - - if (oldBuffer != pv.buffer) { - int i; - - for (i = 0; i < argc; i++) { - argv[i] = pv.buffer + (argv[i] - oldBuffer); - } - oldBuffer = pv.buffer; - } - argc += newArgs; - if (newArgs < maxArgs) { - argv[argc] = (char *) NULL; - break; - } - - /* - * Args didn't all fit in the current array. Make it bigger. - */ - - argSize *= 2; - newArgv = (char **) - ckalloc((unsigned) argSize * sizeof(char *)); - for (i = 0; i < argc; i++) { - newArgv[i] = argv[i]; - } - if (argv != argStorage) { - ckfree((char *) argv); - } - argv = newArgv; - } - - /* - * If this is an empty command (or if we're just parsing - * commands without evaluating them), then just skip to the - * next command. - */ - - if ((argc == 0) || iPtr->noEval) { - continue; - } - argv[argc] = NULL; - - /* - * Save information for the history module, if needed. - */ - - if (flags & TCL_RECORD_BOUNDS) { - iPtr->evalFirst = cmdStart; - iPtr->evalLast = src-1; - } - - /* - * Find the procedure to execute this command. If there isn't - * one, then see if there is a command "unknown". If so, - * invoke it instead, passing it the words of the original - * command as arguments. - */ - - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, argv[0]); - if (hPtr == NULL) { - int i; - - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, "unknown"); - if (hPtr == NULL) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "invalid command name \"", - argv[0], "\"", (char *) NULL); - result = TCL_ERROR; - goto done; - } - for (i = argc; i >= 0; i--) { - argv[i+1] = argv[i]; - } - argv[0] = "unknown"; - argc++; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - - /* - * Call trace procedures, if any. - */ - - for (tracePtr = iPtr->tracePtr; tracePtr != NULL; - tracePtr = tracePtr->nextPtr) { - char saved; - - if (tracePtr->level < iPtr->numLevels) { - continue; - } - saved = *src; - *src = 0; - (*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels, - cmdStart, cmdPtr->proc, cmdPtr->clientData, argc, argv); - *src = saved; - } - - /* - * At long last, invoke the command procedure. Reset the - * result to its default empty value first (it could have - * gotten changed by earlier commands in the same command - * string). - */ - - iPtr->cmdCount++; - Tcl_FreeResult(iPtr); - iPtr->result = iPtr->resultSpace; - iPtr->resultSpace[0] = 0; - result = (*cmdPtr->proc)(cmdPtr->clientData, interp, argc, argv); - if (Tcl_AsyncReady()) { - result = Tcl_AsyncInvoke(interp, result); - } - if (result != TCL_OK) { - break; - } - } - - done: - - /* - * If no commands at all were executed, check for asynchronous - * handlers so that they at least get one change to execute. - * This is needed to handle event loops written in Tcl with - * empty bodies (I'm not sure that loops like this are a good - * idea, * but...). - */ - - if ((oldCount == iPtr->cmdCount) && (Tcl_AsyncReady())) { - result = Tcl_AsyncInvoke(interp, result); - } - - /* - * Free up any extra resources that were allocated. - */ - - if (pv.buffer != copyStorage) { - ckfree((char *) pv.buffer); - } - if (argv != argStorage) { - ckfree((char *) argv); - } - iPtr->numLevels--; - if (iPtr->numLevels == 0) { - if (result == TCL_RETURN) { - result = TclUpdateReturnInfo(iPtr); - } - if ((result != TCL_OK) && (result != TCL_ERROR) - && !(flags & TCL_ALLOW_EXCEPTIONS)) { - Tcl_ResetResult(interp); - if (result == TCL_BREAK) { - iPtr->result = "invoked \"break\" outside of a loop"; - } else if (result == TCL_CONTINUE) { - iPtr->result = "invoked \"continue\" outside of a loop"; - } else { - iPtr->result = iPtr->resultSpace; - sprintf(iPtr->resultSpace, "command returned bad code: %d", - result); - } - result = TCL_ERROR; - } - } - - /* - * If an error occurred, record information about what was being - * executed when the error occurred. - */ - - if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) { - int numChars; - char *p; - - /* - * Compute the line number where the error occurred. - */ - - iPtr->errorLine = 1; - for (p = cmd; p != cmdStart; p++) { - if (*p == '\n') { - iPtr->errorLine++; - } - } - for ( ; isspace(UCHAR(*p)) || (*p == ';'); p++) { - if (*p == '\n') { - iPtr->errorLine++; - } - } - - /* - * Figure out how much of the command to print in the error - * message (up to a certain number of characters, or up to - * the first new-line). - */ - - numChars = src - cmdStart; - if (numChars > (NUM_CHARS-50)) { - numChars = NUM_CHARS-50; - ellipsis = " ..."; - } - - if (!(iPtr->flags & ERR_IN_PROGRESS)) { - sprintf(copyStorage, "\n while executing\n\"%.*s%s\"", - numChars, cmdStart, ellipsis); - } else { - sprintf(copyStorage, "\n invoked from within\n\"%.*s%s\"", - numChars, cmdStart, ellipsis); - } - Tcl_AddErrorInfo(interp, copyStorage); - iPtr->flags &= ~ERR_ALREADY_LOGGED; - } else { - iPtr->flags &= ~ERR_ALREADY_LOGGED; - } - iPtr->termPtr = termPtr; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateTrace -- - * - * Arrange for a procedure to be called to trace command execution. - * - * Results: - * The return value is a token for the trace, which may be passed - * to Tcl_DeleteTrace to eliminate the trace. - * - * Side effects: - * From now on, proc will be called just before a command procedure - * is called to execute a Tcl command. Calls to proc will have the - * following form: - * - * void - * proc(clientData, interp, level, command, cmdProc, cmdClientData, - * argc, argv) - * ClientData clientData; - * Tcl_Interp *interp; - * int level; - * char *command; - * int (*cmdProc)(); - * ClientData cmdClientData; - * int argc; - * char **argv; - * { - * } - * - * The clientData and interp arguments to proc will be the same - * as the corresponding arguments to this procedure. Level gives - * the nesting level of command interpretation for this interpreter - * (0 corresponds to top level). Command gives the ASCII text of - * the raw command, cmdProc and cmdClientData give the procedure that - * will be called to process the command and the ClientData value it - * will receive, and argc and argv give the arguments to the - * command, after any argument parsing and substitution. Proc - * does not return a value. - * - *---------------------------------------------------------------------- - */ - -Tcl_Trace -Tcl_CreateTrace( - Tcl_Interp *interp, /* Interpreter in which to create the trace. */ - int level, /* Only call proc for commands at nesting level - * <= level (1 => top level). */ - Tcl_CmdTraceProc *proc, /* Procedure to call before executing each - * command. */ - ClientData clientData /* Arbitrary one-word value to pass to proc. */ -) -{ - Trace *tracePtr; - Interp *iPtr = (Interp *) interp; - - tracePtr = (Trace *) ckalloc(sizeof(Trace)); - tracePtr->level = level; - tracePtr->proc = proc; - tracePtr->clientData = clientData; - tracePtr->nextPtr = iPtr->tracePtr; - iPtr->tracePtr = tracePtr; - - return (Tcl_Trace) tracePtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteTrace -- - * - * Remove a trace. - * - * Results: - * None. - * - * Side effects: - * From now on there will be no more calls to the procedure given - * in trace. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteTrace( - Tcl_Interp *interp, /* Interpreter that contains trace. */ - Tcl_Trace trace /* Token for trace (returned previously by - * Tcl_CreateTrace). */ -) -{ - Interp *iPtr = (Interp *) interp; - Trace *tracePtr = (Trace *) trace; - Trace *tracePtr2; - - if (iPtr->tracePtr == tracePtr) { - iPtr->tracePtr = tracePtr->nextPtr; - ckfree((char *) tracePtr); - } else { - for (tracePtr2 = iPtr->tracePtr; tracePtr2 != NULL; - tracePtr2 = tracePtr2->nextPtr) { - if (tracePtr2->nextPtr == tracePtr) { - tracePtr2->nextPtr = tracePtr->nextPtr; - ckfree((char *) tracePtr); - return; - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AddErrorInfo -- - * - * Add information to a message being accumulated that describes - * the current error. - * - * Results: - * None. - * - * Side effects: - * The contents of message are added to the "errorInfo" variable. - * If Tcl_Eval has been called since the current value of errorInfo - * was set, errorInfo is cleared before adding the new message. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_AddErrorInfo( - Tcl_Interp *interp, /* Interpreter to which error information - * pertains. */ - char *message /* Message to record. */ -) -{ - Interp *iPtr = (Interp *) interp; - - /* - * If an error is already being logged, then the new errorInfo - * is the concatenation of the old info and the new message. - * If this is the first piece of info for the error, then the - * new errorInfo is the concatenation of the message in - * interp->result and the new message. - */ - - if (!(iPtr->flags & ERR_IN_PROGRESS)) { - Tcl_SetVar2(interp, "errorInfo", (char *) NULL, interp->result, - TCL_GLOBAL_ONLY); - iPtr->flags |= ERR_IN_PROGRESS; - - /* - * If the errorCode variable wasn't set by the code that generated - * the error, set it to "NONE". - */ - - if (!(iPtr->flags & ERROR_CODE_SET)) { - (void) Tcl_SetVar2(interp, "errorCode", (char *) NULL, "NONE", - TCL_GLOBAL_ONLY); - } - } - Tcl_SetVar2(interp, "errorInfo", (char *) NULL, message, - TCL_GLOBAL_ONLY|TCL_APPEND_VALUE); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_VarEval -- - * - * Given a variable number of string arguments, concatenate them - * all together and execute the result as a Tcl command. - * - * Results: - * A standard Tcl return result. An error message or other - * result may be left in interp->result. - * - * Side effects: - * Depends on what was done by the command. - * - *---------------------------------------------------------------------- - */ - /* VARARGS2 */ /* ARGSUSED */ -int -Tcl_VarEval TCL_VARARGS_DEF(Tcl_Interp *, arg1) -{ - va_list argList; - Tcl_DString buf; - char *string; - Tcl_Interp *interp; - int result; - - /* - * Copy the strings one after the other into a single larger - * string. Use stack-allocated space for small commands, but if - * the command gets too large than call ckalloc to create the - * space. - */ - - interp = arg1; - va_start(argList, arg1); - - Tcl_DStringInit(&buf); - while (1) { - string = va_arg(argList, char *); - if (string == NULL) { - break; - } - Tcl_DStringAppend(&buf, string, -1); - } - va_end(argList); - - result = Tcl_Eval(interp, Tcl_DStringValue(&buf)); - Tcl_DStringFree(&buf); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GlobalEval -- - * - * Evaluate a command at global level in an interpreter. - * - * Results: - * A standard Tcl result is returned, and interp->result is - * modified accordingly. - * - * Side effects: - * The command string is executed in interp, and the execution - * is carried out in the variable context of global level (no - * procedures active), just as if an "uplevel #0" command were - * being executed. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GlobalEval( - Tcl_Interp *interp, /* Interpreter in which to evaluate command. */ - char *command /* Command to evaluate. */ -) -{ - Interp *iPtr = (Interp *) interp; - int result; - CallFrame *savedVarFramePtr; - - savedVarFramePtr = iPtr->varFramePtr; - iPtr->varFramePtr = NULL; - result = Tcl_Eval(interp, command); - iPtr->varFramePtr = savedVarFramePtr; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetRecursionLimit -- - * - * Set the maximum number of recursive calls that may be active - * for an interpreter at once. - * - * Results: - * The return value is the old limit on nesting for interp. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_SetRecursionLimit( - Tcl_Interp *interp, /* Interpreter whose nesting limit - * is to be set. */ - int depth /* New value for maximimum depth. */ -) -{ - Interp *iPtr = (Interp *) interp; - int old; - - old = iPtr->maxNestingDepth; - if (depth > 0) { - iPtr->maxNestingDepth = depth; - } - return old; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AllowExceptions -- - * - * Sets a flag in an interpreter so that exceptions can occur - * in the next call to Tcl_Eval without them being turned into - * errors. - * - * Results: - * None. - * - * Side effects: - * The TCL_ALLOW_EXCEPTIONS flag gets set in the interpreter's - * evalFlags structure. See the reference documentation for - * more details. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_AllowExceptions( - Tcl_Interp *interp /* Interpreter in which to set flag. */ -) -{ - Interp *iPtr = (Interp *) interp; - - iPtr->evalFlags |= TCL_ALLOW_EXCEPTIONS; -} diff --git a/cde/programs/dtdocbook/tcl/tclCkalloc.c b/cde/programs/dtdocbook/tcl/tclCkalloc.c deleted file mode 100644 index 123db466a..000000000 --- a/cde/programs/dtdocbook/tcl/tclCkalloc.c +++ /dev/null @@ -1,745 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclCkalloc.c /main/2 1996/08/08 14:42:59 cde-hp $ */ -/* - * tclCkalloc.c -- - * - * Interface to malloc and free that provides support for debugging problems - * involving overwritten, double freeing memory and loss of memory. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * This code contributed by Karl Lehenbauer and Mark Diekhans - * - * - * SCCS: @(#) tclCkalloc.c 1.17 96/03/14 13:05:56 - */ - -#include "tclInt.h" - -#define FALSE 0 -#define TRUE 1 - -#ifdef TCL_MEM_DEBUG -#ifndef TCL_GENERIC_ONLY -#include "tclPort.h" -#endif - -/* - * One of the following structures is allocated each time the - * "memory tag" command is invoked, to hold the current tag. - */ - -typedef struct MemTag { - int refCount; /* Number of mem_headers referencing - * this tag. */ - char string[4]; /* Actual size of string will be as - * large as needed for actual tag. This - * must be the last field in the structure. */ -} MemTag; - -#define TAG_SIZE(bytesInString) ((unsigned) sizeof(MemTag) + bytesInString - 3) - -static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers - * (set by "memory tag" command). */ - -/* - * One of the following structures is allocated just before each - * dynamically allocated chunk of memory, both to record information - * about the chunk and to help detect chunk under-runs. - */ - -#define LOW_GUARD_SIZE (8 + (32 - (sizeof(long) + sizeof(int)))%8) -struct mem_header { - struct mem_header *flink; - struct mem_header *blink; - MemTag *tagPtr; /* Tag from "memory tag" command; may be - * NULL. */ - char *file; - long length; - int line; - unsigned char low_guard[LOW_GUARD_SIZE]; - /* Aligns body on 8-byte boundary, plus - * provides at least 8 additional guard bytes - * to detect underruns. */ - char body[1]; /* First byte of client's space. Actual - * size of this field will be larger than - * one. */ -}; - -static struct mem_header *allocHead = NULL; /* List of allocated structures */ - -#define GUARD_VALUE 0141 - -/* - * The following macro determines the amount of guard space *above* each - * chunk of memory. - */ - -#define HIGH_GUARD_SIZE 8 - -/* - * The following macro computes the offset of the "body" field within - * mem_header. It is used to get back to the header pointer from the - * body pointer that's used by clients. - */ - -#define BODY_OFFSET \ - ((unsigned long) (&((struct mem_header *) 0)->body)) - -static int total_mallocs = 0; -static int total_frees = 0; -static int current_bytes_malloced = 0; -static int maximum_bytes_malloced = 0; -static int current_malloc_packets = 0; -static int maximum_malloc_packets = 0; -static int break_on_malloc = 0; -static int trace_on_at_malloc = 0; -static int alloc_tracing = FALSE; -static int init_malloced_bodies = TRUE; -#ifdef MEM_VALIDATE - static int validate_memory = TRUE; -#else - static int validate_memory = FALSE; -#endif - -/* - * Prototypes for procedures defined in this file: - */ - -static int MemoryCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); - -/* - *---------------------------------------------------------------------- - * - * dump_memory_info -- - * Display the global memory management statistics. - * - *---------------------------------------------------------------------- - */ -static void -dump_memory_info(outFile) - FILE *outFile; -{ - fprintf(outFile,"total mallocs %10d\n", - total_mallocs); - fprintf(outFile,"total frees %10d\n", - total_frees); - fprintf(outFile,"current packets allocated %10d\n", - current_malloc_packets); - fprintf(outFile,"current bytes allocated %10d\n", - current_bytes_malloced); - fprintf(outFile,"maximum packets allocated %10d\n", - maximum_malloc_packets); - fprintf(outFile,"maximum bytes allocated %10d\n", - maximum_bytes_malloced); -} - -/* - *---------------------------------------------------------------------- - * - * ValidateMemory -- - * Procedure to validate allocted memory guard zones. - * - *---------------------------------------------------------------------- - */ -static void -ValidateMemory (memHeaderP, file, line, nukeGuards) - struct mem_header *memHeaderP; - char *file; - int line; - int nukeGuards; -{ - unsigned char *hiPtr; - int idx; - int guard_failed = FALSE; - int byte; - - for (idx = 0; idx < LOW_GUARD_SIZE; idx++) { - byte = *(memHeaderP->low_guard + idx); - if (byte != GUARD_VALUE) { - guard_failed = TRUE; - fflush (stdout); - byte &= 0xff; - fprintf(stderr, "low guard byte %d is 0x%x \t%c\n", idx, byte, - (isprint(UCHAR(byte)) ? byte : ' ')); - } - } - if (guard_failed) { - dump_memory_info (stderr); - fprintf (stderr, "low guard failed at %lx, %s %d\n", - (long unsigned int) memHeaderP->body, file, line); - fflush (stderr); /* In case name pointer is bad. */ - fprintf (stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length, - memHeaderP->file, memHeaderP->line); - panic ("Memory validation failure"); - } - - hiPtr = (unsigned char *)memHeaderP->body + memHeaderP->length; - for (idx = 0; idx < HIGH_GUARD_SIZE; idx++) { - byte = *(hiPtr + idx); - if (byte != GUARD_VALUE) { - guard_failed = TRUE; - fflush (stdout); - byte &= 0xff; - fprintf(stderr, "hi guard byte %d is 0x%x \t%c\n", idx, byte, - (isprint(UCHAR(byte)) ? byte : ' ')); - } - } - - if (guard_failed) { - dump_memory_info (stderr); - fprintf (stderr, "high guard failed at %lx, %s %d\n", - (long unsigned int) memHeaderP->body, file, line); - fflush (stderr); /* In case name pointer is bad. */ - fprintf (stderr, "%ld bytes allocated at (%s %d)\n", - memHeaderP->length, memHeaderP->file, - memHeaderP->line); - panic ("Memory validation failure"); - } - - if (nukeGuards) { - memset ((char *) memHeaderP->low_guard, 0, LOW_GUARD_SIZE); - memset ((char *) hiPtr, 0, HIGH_GUARD_SIZE); - } - -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ValidateAllMemory -- - * Validates guard regions for all allocated memory. - * - *---------------------------------------------------------------------- - */ -void -Tcl_ValidateAllMemory (file, line) - char *file; - int line; -{ - struct mem_header *memScanP; - - for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) - ValidateMemory (memScanP, file, line, FALSE); - -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DumpActiveMemory -- - * Displays all allocated memory to stderr. - * - * Results: - * Return TCL_ERROR if an error accessing the file occures, `errno' - * will have the file error number left in it. - *---------------------------------------------------------------------- - */ -int -Tcl_DumpActiveMemory (fileName) - char *fileName; -{ - FILE *fileP; - struct mem_header *memScanP; - char *address; - - fileP = fopen(fileName, "w"); - if (fileP == NULL) - return TCL_ERROR; - - for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) { - address = &memScanP->body [0]; - fprintf (fileP, "%8lx - %8lx %7ld @ %s %d %s", - (long unsigned int) address, - (long unsigned int) address + memScanP->length - 1, - memScanP->length, memScanP->file, memScanP->line, - (memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string); - (void) fputc('\n', fileP); - } - fclose (fileP); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DbCkalloc - debugging ckalloc - * - * Allocate the requested amount of space plus some extra for - * guard bands at both ends of the request, plus a size, panicing - * if there isn't enough space, then write in the guard bands - * and return the address of the space in the middle that the - * user asked for. - * - * The second and third arguments are file and line, these contain - * the filename and line number corresponding to the caller. - * These are sent by the ckalloc macro; it uses the preprocessor - * autodefines __FILE__ and __LINE__. - * - *---------------------------------------------------------------------- - */ -char * -Tcl_DbCkalloc(size, file, line) - unsigned int size; - char *file; - int line; -{ - struct mem_header *result; - - if (validate_memory) - Tcl_ValidateAllMemory (file, line); - - result = (struct mem_header *)malloc((unsigned)size + - sizeof(struct mem_header) + HIGH_GUARD_SIZE); - if (result == NULL) { - fflush(stdout); - dump_memory_info(stderr); - panic("unable to alloc %d bytes, %s line %d", size, file, - line); - } - - /* - * Fill in guard zones and size. Also initialize the contents of - * the block with bogus bytes to detect uses of initialized data. - * Link into allocated list. - */ - if (init_malloced_bodies) { - memset ((VOID *) result, GUARD_VALUE, - size + sizeof(struct mem_header) + HIGH_GUARD_SIZE); - } else { - memset ((char *) result->low_guard, GUARD_VALUE, LOW_GUARD_SIZE); - memset (result->body + size, GUARD_VALUE, HIGH_GUARD_SIZE); - } - result->length = size; - result->tagPtr = curTagPtr; - if (curTagPtr != NULL) { - curTagPtr->refCount++; - } - result->file = file; - result->line = line; - result->flink = allocHead; - result->blink = NULL; - if (allocHead != NULL) - allocHead->blink = result; - allocHead = result; - - total_mallocs++; - if (trace_on_at_malloc && (total_mallocs >= trace_on_at_malloc)) { - (void) fflush(stdout); - fprintf(stderr, "reached malloc trace enable point (%d)\n", - total_mallocs); - fflush(stderr); - alloc_tracing = TRUE; - trace_on_at_malloc = 0; - } - - if (alloc_tracing) - fprintf(stderr,"ckalloc %lx %d %s %d\n", - (long unsigned int) result->body, size, file, line); - - if (break_on_malloc && (total_mallocs >= break_on_malloc)) { - break_on_malloc = 0; - (void) fflush(stdout); - fprintf(stderr,"reached malloc break limit (%d)\n", - total_mallocs); - fprintf(stderr, "program will now enter C debugger\n"); - (void) fflush(stderr); - abort(); - } - - current_malloc_packets++; - if (current_malloc_packets > maximum_malloc_packets) - maximum_malloc_packets = current_malloc_packets; - current_bytes_malloced += size; - if (current_bytes_malloced > maximum_bytes_malloced) - maximum_bytes_malloced = current_bytes_malloced; - - return result->body; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DbCkfree - debugging ckfree - * - * Verify that the low and high guards are intact, and if so - * then free the buffer else panic. - * - * The guards are erased after being checked to catch duplicate - * frees. - * - * The second and third arguments are file and line, these contain - * the filename and line number corresponding to the caller. - * These are sent by the ckfree macro; it uses the preprocessor - * autodefines __FILE__ and __LINE__. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_DbCkfree(ptr, file, line) - char * ptr; - char *file; - int line; -{ - /* - * The following cast is *very* tricky. Must convert the pointer - * to an integer before doing arithmetic on it, because otherwise - * the arithmetic will be done differently (and incorrectly) on - * word-addressed machines such as Crays (will subtract only bytes, - * even though BODY_OFFSET is in words on these machines). - */ - - struct mem_header *memp = (struct mem_header *) - (((unsigned long) ptr) - BODY_OFFSET); - - if (alloc_tracing) - fprintf(stderr, "ckfree %lx %ld %s %d\n", - (long unsigned int) memp->body, memp->length, file, line); - - if (validate_memory) - Tcl_ValidateAllMemory (file, line); - - ValidateMemory (memp, file, line, TRUE); - if (init_malloced_bodies) { - memset((VOID *) ptr, GUARD_VALUE, (size_t) memp->length); - } - - total_frees++; - current_malloc_packets--; - current_bytes_malloced -= memp->length; - - if (memp->tagPtr != NULL) { - memp->tagPtr->refCount--; - if ((memp->tagPtr->refCount == 0) && (curTagPtr != memp->tagPtr)) { - free((char *) memp->tagPtr); - } - } - - /* - * Delink from allocated list - */ - if (memp->flink != NULL) - memp->flink->blink = memp->blink; - if (memp->blink != NULL) - memp->blink->flink = memp->flink; - if (allocHead == memp) - allocHead = memp->flink; - free((char *) memp); - return 0; -} - -/* - *-------------------------------------------------------------------- - * - * Tcl_DbCkrealloc - debugging ckrealloc - * - * Reallocate a chunk of memory by allocating a new one of the - * right size, copying the old data to the new location, and then - * freeing the old memory space, using all the memory checking - * features of this package. - * - *-------------------------------------------------------------------- - */ -char * -Tcl_DbCkrealloc(ptr, size, file, line) - char *ptr; - unsigned int size; - char *file; - int line; -{ - char *new; - unsigned int copySize; - - /* - * See comment from Tcl_DbCkfree before you change the following - * line. - */ - - struct mem_header *memp = (struct mem_header *) - (((unsigned long) ptr) - BODY_OFFSET); - - copySize = size; - if (copySize > memp->length) { - copySize = memp->length; - } - new = Tcl_DbCkalloc(size, file, line); - memcpy((VOID *) new, (VOID *) ptr, (size_t) copySize); - Tcl_DbCkfree(ptr, file, line); - return(new); -} - -/* - *---------------------------------------------------------------------- - * - * MemoryCmd -- - * Implements the TCL memory command: - * memory info - * memory display - * break_on_malloc count - * trace_on_at_malloc count - * trace on|off - * validate on|off - * - * Results: - * Standard TCL results. - * - *---------------------------------------------------------------------- - */ - /* ARGSUSED */ -static int -MemoryCmd (clientData, interp, argc, argv) - ClientData clientData; - Tcl_Interp *interp; - int argc; - char **argv; -{ - char *fileName; - Tcl_DString buffer; - int result; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option [args..]\"", (char *) NULL); - return TCL_ERROR; - } - - if (strcmp(argv[1],"active") == 0) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " active file\"", (char *) NULL); - return TCL_ERROR; - } - fileName = Tcl_TranslateFileName(interp, argv[2], &buffer); - if (fileName == NULL) { - return TCL_ERROR; - } - result = Tcl_DumpActiveMemory (fileName); - Tcl_DStringFree(&buffer); - if (result != TCL_OK) { - Tcl_AppendResult(interp, "error accessing ", argv[2], - (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; - } - if (strcmp(argv[1],"break_on_malloc") == 0) { - if (argc != 3) - goto argError; - if (Tcl_GetInt(interp, argv[2], &break_on_malloc) != TCL_OK) - return TCL_ERROR; - return TCL_OK; - } - if (strcmp(argv[1],"info") == 0) { - dump_memory_info(stdout); - return TCL_OK; - } - if (strcmp(argv[1],"init") == 0) { - if (argc != 3) - goto bad_suboption; - init_malloced_bodies = (strcmp(argv[2],"on") == 0); - return TCL_OK; - } - if (strcmp(argv[1],"tag") == 0) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " tag string\"", (char *) NULL); - return TCL_ERROR; - } - if ((curTagPtr != NULL) && (curTagPtr->refCount == 0)) { - free((char *) curTagPtr); - } - curTagPtr = (MemTag *) malloc(TAG_SIZE(strlen(argv[2]))); - curTagPtr->refCount = 0; - strcpy(curTagPtr->string, argv[2]); - return TCL_OK; - } - if (strcmp(argv[1],"trace") == 0) { - if (argc != 3) - goto bad_suboption; - alloc_tracing = (strcmp(argv[2],"on") == 0); - return TCL_OK; - } - - if (strcmp(argv[1],"trace_on_at_malloc") == 0) { - if (argc != 3) - goto argError; - if (Tcl_GetInt(interp, argv[2], &trace_on_at_malloc) != TCL_OK) - return TCL_ERROR; - return TCL_OK; - } - if (strcmp(argv[1],"validate") == 0) { - if (argc != 3) - goto bad_suboption; - validate_memory = (strcmp(argv[2],"on") == 0); - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be active, break_on_malloc, info, init, ", - "tag, trace, trace_on_at_malloc, or validate", (char *) NULL); - return TCL_ERROR; - -argError: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " count\"", (char *) NULL); - return TCL_ERROR; - -bad_suboption: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " on|off\"", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InitMemory -- - * Initialize the memory command. - * - *---------------------------------------------------------------------- - */ -void -Tcl_InitMemory(interp) - Tcl_Interp *interp; -{ -Tcl_CreateCommand (interp, "memory", MemoryCmd, (ClientData) NULL, - (Tcl_CmdDeleteProc *) NULL); -} - -#else - - -/* - *---------------------------------------------------------------------- - * - * Tcl_Ckalloc -- - * Interface to malloc when TCL_MEM_DEBUG is disabled. It does check - * that memory was actually allocated. - * - *---------------------------------------------------------------------- - */ -VOID * -Tcl_Ckalloc (unsigned int size) -{ - char *result; - - result = malloc(size); - if (result == NULL) - panic("unable to alloc %d bytes", size); - return result; -} - - -char * -Tcl_DbCkalloc(unsigned int size, char *file, int line) -{ - char *result; - - result = (char *) malloc(size); - - if (result == NULL) { - fflush(stdout); - panic("unable to alloc %d bytes, %s line %d", size, file, - line); - } - return result; -} - -char * -Tcl_DbCkrealloc(char *ptr, unsigned int size, char *file, int line) -{ - char *result; - - result = (char *) realloc(ptr, size); - - if (result == NULL) { - fflush(stdout); - panic("unable to realloc %d bytes, %s line %d", size, file, - line); - } - return result; -} -/* - *---------------------------------------------------------------------- - * - * TckCkfree -- - * Interface to free when TCL_MEM_DEBUG is disabled. Done here rather - * in the macro to keep some modules from being compiled with - * TCL_MEM_DEBUG enabled and some with it disabled. - * - *---------------------------------------------------------------------- - */ -void -Tcl_Ckfree (char *ptr) -{ - free (ptr); -} - -int -Tcl_DbCkfree(char *ptr, char *file, int line) -{ - free (ptr); - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InitMemory -- - * Dummy initialization for memory command, which is only available - * if TCL_MEM_DEBUG is on. - * - *---------------------------------------------------------------------- - */ - /* ARGSUSED */ -void -Tcl_InitMemory(Tcl_Interp *interp) -{ -} - -#undef Tcl_DumpActiveMemory -#undef Tcl_ValidateAllMemory - -extern int Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName)); -extern void Tcl_ValidateAllMemory _ANSI_ARGS_((char *file, - int line)); - -int -Tcl_DumpActiveMemory (char *fileName) -{ - return TCL_OK; -} - -void -Tcl_ValidateAllMemory (char *file, int line) -{ -} - -#endif diff --git a/cde/programs/dtdocbook/tcl/tclClock.c b/cde/programs/dtdocbook/tcl/tclClock.c deleted file mode 100644 index c495c4896..000000000 --- a/cde/programs/dtdocbook/tcl/tclClock.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclClock.c /main/2 1996/08/08 14:43:05 cde-hp $ */ -/* - * tclClock.c -- - * - * Contains the time and date related commands. This code - * is derived from the time and date facilities of TclX, - * by Mark Diekhans and Karl Lehenbauer. - * - * Copyright 1991-1995 Karl Lehenbauer and Mark Diekhans. - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclClock.c 1.19 96/03/13 11:28:45 - */ - -#include "tcl.h" -#include "tclInt.h" -#include "tclPort.h" - -/* - * Function prototypes for local procedures in this file: - */ - -static int FormatClock _ANSI_ARGS_((Tcl_Interp *interp, - unsigned long clockVal, int useGMT, - char *format)); -static int ParseTime _ANSI_ARGS_((Tcl_Interp *interp, - char *string, unsigned long *timePtr)); - -/* - *----------------------------------------------------------------------------- - * - * Tcl_ClockCmd -- - * - * This procedure is invoked to process the "clock" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *----------------------------------------------------------------------------- - */ - -int -Tcl_ClockCmd ( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int c; - size_t length; - char **argPtr; - int useGMT = 0; - unsigned long clockVal; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'c') && (strncmp(argv[1], "clicks", length) == 0)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # arguments: must be \"", - argv[0], " clicks\"", (char *) NULL); - return TCL_ERROR; - } - sprintf(interp->result, "%lu", TclGetClicks()); - return TCL_OK; - } else if ((c == 'f') && (strncmp(argv[1], "format", length) == 0)) { - char *format = "%a %b %d %X %Z %Y"; - - if ((argc < 3) || (argc > 7)) { - wrongFmtArgs: - Tcl_AppendResult(interp, "wrong # args: ", argv [0], - " format clockval ?-format string? ?-gmt boolean?", - (char *) NULL); - return TCL_ERROR; - } - - if (ParseTime(interp, argv[2], &clockVal) != TCL_OK) { - return TCL_ERROR; - } - - argPtr = argv+3; - argc -= 3; - while ((argc > 1) && (argPtr[0][0] == '-')) { - if (strcmp(argPtr[0], "-format") == 0) { - format = argPtr[1]; - } else if (strcmp(argPtr[0], "-gmt") == 0) { - if (Tcl_GetBoolean(interp, argPtr[1], &useGMT) != TCL_OK) { - return TCL_ERROR; - } - } else { - Tcl_AppendResult(interp, "bad option \"", argPtr[0], - "\": must be -format or -gmt", (char *) NULL); - return TCL_ERROR; - } - argPtr += 2; - argc -= 2; - } - if (argc != 0) { - goto wrongFmtArgs; - } - - return FormatClock(interp, clockVal, useGMT, format); - } else if ((c == 's') && (strncmp(argv[1], "scan", length) == 0)) { - unsigned long baseClock; - long zone; - char * baseStr = NULL; - - if ((argc < 3) || (argc > 7)) { - wrongScanArgs: - Tcl_AppendResult (interp, "wrong # args: ", argv [0], - " scan dateString ?-base clockValue? ?-gmt boolean?", - (char *) NULL); - return TCL_ERROR; - } - - argPtr = argv+3; - argc -= 3; - while ((argc > 1) && (argPtr[0][0] == '-')) { - if (strcmp(argPtr[0], "-base") == 0) { - baseStr = argPtr[1]; - } else if (strcmp(argPtr[0], "-gmt") == 0) { - if (Tcl_GetBoolean(interp, argPtr[1], &useGMT) != TCL_OK) { - return TCL_ERROR; - } - } else { - Tcl_AppendResult(interp, "bad option \"", argPtr[0], - "\": must be -base or -gmt", (char *) NULL); - return TCL_ERROR; - } - argPtr += 2; - argc -= 2; - } - if (argc != 0) { - goto wrongScanArgs; - } - - if (baseStr != NULL) { - if (ParseTime(interp, baseStr, &baseClock) != TCL_OK) - return TCL_ERROR; - } else { - baseClock = TclGetSeconds(); - } - - if (useGMT) { - zone = -50000; /* Force GMT */ - } else { - zone = TclGetTimeZone(baseClock); - } - - if (TclGetDate(argv[2], baseClock, zone, &clockVal) < 0) { - Tcl_AppendResult(interp, "unable to convert date-time string \"", - argv[2], "\"", (char *) NULL); - return TCL_ERROR; - } - - sprintf(interp->result, "%lu", (long) clockVal); - return TCL_OK; - } else if ((c == 's') && (strncmp(argv[1], "seconds", length) == 0)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # arguments: must be \"", - argv[0], " seconds\"", (char *) NULL); - return TCL_ERROR; - } - sprintf(interp->result, "%lu", TclGetSeconds()); - return TCL_OK; - } else { - Tcl_AppendResult(interp, "unknown option \"", argv[1], - "\": must be clicks, format, scan, or seconds", - (char *) NULL); - return TCL_ERROR; - } -} - -/* - *----------------------------------------------------------------------------- - * - * ParseTime -- - * - * Given a string, produce the corresponding time_t value. - * - * Results: - * The return value is normally TCL_OK; in this case *timePtr - * will be set to the integer value equivalent to string. If - * string is improperly formed then TCL_ERROR is returned and - * an error message will be left in interp->result. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -static int -ParseTime(Tcl_Interp *interp, char *string, unsigned long *timePtr) -{ - char *end, *p; - unsigned long i; - - /* - * Since some strtoul functions don't detect negative numbers, check - * in advance. - */ - errno = 0; - for (p = (char *) string; isspace(UCHAR(*p)); p++) { - /* Empty loop body. */ - } - if (*p == '+') { - p++; - } - i = strtoul(p, &end, 0); - if (end == p) { - goto badTime; - } - if (errno == ERANGE) { - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - return TCL_ERROR; - } - while ((*end != '\0') && isspace(UCHAR(*end))) { - end++; - } - if (*end != '\0') { - goto badTime; - } - - *timePtr = (time_t) i; - if (*timePtr != i) { - goto badTime; - } - return TCL_OK; - - badTime: - Tcl_AppendResult (interp, "expected unsigned time but got \"", - string, "\"", (char *) NULL); - return TCL_ERROR; -} - -/* - *----------------------------------------------------------------------------- - * - * FormatClock -- - * - * Formats a time value based on seconds into a human readable - * string. - * - * Results: - * Standard Tcl result. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -static int -FormatClock( - Tcl_Interp *interp, /* Current interpreter. */ - unsigned long clockVal, /* Time in seconds. */ - int useGMT, /* Boolean */ - char *format /* Format string */ -) -{ - struct tm *timeDataPtr; - Tcl_DString buffer; - int bufSize; -#ifdef TCL_USE_TIMEZONE_VAR - int savedTimeZone; - char *savedTZEnv; -#endif - -#ifdef HAVE_TZSET - /* - * Some systems forgot to call tzset in localtime, make sure its done. - */ - static int calledTzset = 0; - - if (!calledTzset) { - tzset(); - calledTzset = 1; - } -#endif - -#ifdef TCL_USE_TIMEZONE_VAR - /* - * This is a horrible kludge for systems not having the timezone in - * struct tm. No matter what was specified, they use the global time - * zone. (Thanks Solaris). - */ - if (useGMT) { - char *varValue; - - varValue = Tcl_GetVar2(interp, "env", "TZ", TCL_GLOBAL_ONLY); - if (varValue != NULL) { - savedTZEnv = strcpy(ckalloc(strlen(varValue) + 1), varValue); - } else { - savedTZEnv = NULL; - } - Tcl_SetVar2(interp, "env", "TZ", "GMT", TCL_GLOBAL_ONLY); - savedTimeZone = timezone; - timezone = 0; - tzset(); - } -#endif - - if (useGMT) { - timeDataPtr = gmtime((time_t *) &clockVal); - } else { - timeDataPtr = localtime((time_t *) &clockVal); - } - - /* - * Format the time, increasing the buffer size until strftime succeeds. - */ - bufSize = TCL_DSTRING_STATIC_SIZE - 1; - Tcl_DStringInit(&buffer); - Tcl_DStringSetLength(&buffer, bufSize); - - while (strftime(buffer.string, (unsigned int) bufSize, format, - timeDataPtr) == 0) { - bufSize *= 2; - Tcl_DStringSetLength(&buffer, bufSize); - } - -#ifdef TCL_USE_TIMEZONE_VAR - if (useGMT) { - if (savedTZEnv != NULL) { - Tcl_SetVar2(interp, "env", "TZ", savedTZEnv, TCL_GLOBAL_ONLY); - ckfree(savedTZEnv); - } else { - Tcl_UnsetVar2(interp, "env", "TZ", TCL_GLOBAL_ONLY); - } - timezone = savedTimeZone; - tzset(); - } -#endif - - Tcl_DStringResult(interp, &buffer); - return TCL_OK; -} - diff --git a/cde/programs/dtdocbook/tcl/tclCmdAH.c b/cde/programs/dtdocbook/tcl/tclCmdAH.c deleted file mode 100644 index 19f62d9e8..000000000 --- a/cde/programs/dtdocbook/tcl/tclCmdAH.c +++ /dev/null @@ -1,1715 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclCmdAH.c /main/2 1996/08/08 14:43:11 cde-hp $ */ -/* - * tclCmdAH.c -- - * - * This file contains the top-level command routines for most of - * the Tcl built-in commands whose names begin with the letters - * A to H. - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclCmdAH.c 1.107 96/04/09 17:14:39 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * Prototypes for local procedures defined in this file: - */ - -static char * GetTypeFromMode _ANSI_ARGS_((int mode)); -static int StoreStatData _ANSI_ARGS_((Tcl_Interp *interp, - char *varName, struct stat *statPtr)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_BreakCmd -- - * - * This procedure is invoked to process the "break" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_BreakCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc != 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], "\"", (char *) NULL); - return TCL_ERROR; - } - return TCL_BREAK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CaseCmd -- - * - * This procedure is invoked to process the "case" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_CaseCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i, result; - int body; - char *string; - int caseArgc, splitArgs; - char **caseArgv; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " string ?in? patList body ... ?default body?\"", - (char *) NULL); - return TCL_ERROR; - } - string = argv[1]; - body = -1; - if (strcmp(argv[2], "in") == 0) { - i = 3; - } else { - i = 2; - } - caseArgc = argc - i; - caseArgv = argv + i; - - /* - * If all of the pattern/command pairs are lumped into a single - * argument, split them out again. - */ - - splitArgs = 0; - if (caseArgc == 1) { - result = Tcl_SplitList(interp, caseArgv[0], &caseArgc, &caseArgv); - if (result != TCL_OK) { - return result; - } - splitArgs = 1; - } - - for (i = 0; i < caseArgc; i += 2) { - int patArgc, j; - char **patArgv; - char *p; - - if (i == (caseArgc-1)) { - interp->result = "extra case pattern with no body"; - result = TCL_ERROR; - goto cleanup; - } - - /* - * Check for special case of single pattern (no list) with - * no backslash sequences. - */ - - for (p = caseArgv[i]; *p != 0; p++) { - if (isspace(UCHAR(*p)) || (*p == '\\')) { - break; - } - } - if (*p == 0) { - if ((*caseArgv[i] == 'd') - && (strcmp(caseArgv[i], "default") == 0)) { - body = i+1; - } - if (Tcl_StringMatch(string, caseArgv[i])) { - body = i+1; - goto match; - } - continue; - } - - /* - * Break up pattern lists, then check each of the patterns - * in the list. - */ - - result = Tcl_SplitList(interp, caseArgv[i], &patArgc, &patArgv); - if (result != TCL_OK) { - goto cleanup; - } - for (j = 0; j < patArgc; j++) { - if (Tcl_StringMatch(string, patArgv[j])) { - body = i+1; - break; - } - } - ckfree((char *) patArgv); - if (j < patArgc) { - break; - } - } - - match: - if (body != -1) { - result = Tcl_Eval(interp, caseArgv[body]); - if (result == TCL_ERROR) { - char msg[100]; - sprintf(msg, "\n (\"%.50s\" arm line %d)", caseArgv[body-1], - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - goto cleanup; - } - - /* - * Nothing matched: return nothing. - */ - - result = TCL_OK; - - cleanup: - if (splitArgs) { - ckfree((char *) caseArgv); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CatchCmd -- - * - * This procedure is invoked to process the "catch" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_CatchCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int result; - - if ((argc != 2) && (argc != 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " command ?varName?\"", (char *) NULL); - return TCL_ERROR; - } - result = Tcl_Eval(interp, argv[1]); - if (argc == 3) { - if (Tcl_SetVar(interp, argv[2], interp->result, 0) == NULL) { - Tcl_SetResult(interp, "couldn't save command result in variable", - TCL_STATIC); - return TCL_ERROR; - } - } - Tcl_ResetResult(interp); - sprintf(interp->result, "%d", result); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CdCmd -- - * - * This procedure is invoked to process the "cd" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_CdCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *dirName; - Tcl_DString buffer; - int result; - - if (argc > 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " dirName\"", (char *) NULL); - return TCL_ERROR; - } - - if (argc == 2) { - dirName = argv[1]; - } else { - dirName = "~"; - } - dirName = Tcl_TranslateFileName(interp, dirName, &buffer); - if (dirName == NULL) { - return TCL_ERROR; - } - result = TclChdir(interp, dirName); - Tcl_DStringFree(&buffer); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ConcatCmd -- - * - * This procedure is invoked to process the "concat" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ConcatCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc >= 2) { - interp->result = Tcl_Concat(argc-1, argv+1); - interp->freeProc = TCL_DYNAMIC; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ContinueCmd -- - * - * This procedure is invoked to process the "continue" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ContinueCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc != 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - "\"", (char *) NULL); - return TCL_ERROR; - } - return TCL_CONTINUE; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ErrorCmd -- - * - * This procedure is invoked to process the "error" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ErrorCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - - if ((argc < 2) || (argc > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " message ?errorInfo? ?errorCode?\"", (char *) NULL); - return TCL_ERROR; - } - if ((argc >= 3) && (argv[2][0] != 0)) { - Tcl_AddErrorInfo(interp, argv[2]); - iPtr->flags |= ERR_ALREADY_LOGGED; - } - if (argc == 4) { - Tcl_SetVar2(interp, "errorCode", (char *) NULL, argv[3], - TCL_GLOBAL_ONLY); - iPtr->flags |= ERROR_CODE_SET; - } - Tcl_SetResult(interp, argv[1], TCL_VOLATILE); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_EvalCmd -- - * - * This procedure is invoked to process the "eval" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_EvalCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int result; - char *cmd; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 2) { - result = Tcl_Eval(interp, argv[1]); - } else { - - /* - * More than one argument: concatenate them together with spaces - * between, then evaluate the result. - */ - - cmd = Tcl_Concat(argc-1, argv+1); - result = Tcl_Eval(interp, cmd); - ckfree(cmd); - } - if (result == TCL_ERROR) { - char msg[60]; - sprintf(msg, "\n (\"eval\" body line %d)", interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ExitCmd -- - * - * This procedure is invoked to process the "exit" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ExitCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int value; - - if ((argc != 1) && (argc != 2)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?returnCode?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 1) { - value = 0; - } else if (Tcl_GetInt(interp, argv[1], &value) != TCL_OK) { - return TCL_ERROR; - } - Tcl_Exit(value); - /*NOTREACHED*/ - return TCL_OK; /* Better not ever reach this! */ -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ExprCmd -- - * - * This procedure is invoked to process the "expr" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ExprCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_DString buffer; - int i, result; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - if (argc == 2) { - return Tcl_ExprString(interp, argv[1]); - } - Tcl_DStringInit(&buffer); - Tcl_DStringAppend(&buffer, argv[1], -1); - for (i = 2; i < argc; i++) { - Tcl_DStringAppend(&buffer, " ", 1); - Tcl_DStringAppend(&buffer, argv[i], -1); - } - result = Tcl_ExprString(interp, buffer.string); - Tcl_DStringFree(&buffer); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FileCmd -- - * - * This procedure is invoked to process the "file" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FileCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *fileName, *extension; - int c, statOp, result; - size_t length; - int mode = 0; /* Initialized only to prevent - * compiler warning message. */ - struct stat statBuf; - Tcl_DString buffer; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option name ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][0]; - length = strlen(argv[1]); - result = TCL_OK; - Tcl_DStringInit(&buffer); - - /* - * First handle operations on the file name. - */ - - if ((c == 'd') && (strncmp(argv[1], "dirname", length) == 0)) { - int pargc; - char **pargv; - - if (argc != 3) { - argv[1] = "dirname"; - goto not3Args; - } - - fileName = argv[2]; - - /* - * If there is only one element, and it starts with a tilde, - * perform tilde substitution and resplit the path. - */ - - Tcl_SplitPath(fileName, &pargc, &pargv); - if ((pargc == 1) && (*fileName == '~')) { - ckfree((char*) pargv); - fileName = Tcl_TranslateFileName(interp, fileName, &buffer); - if (fileName == NULL) { - result = TCL_ERROR; - goto done; - } - Tcl_SplitPath(fileName, &pargc, &pargv); - Tcl_DStringSetLength(&buffer, 0); - } - - /* - * Return all but the last component. If there is only one - * component, return it if the path was non-relative, otherwise - * return the current directory. - */ - - if (pargc > 1) { - Tcl_JoinPath(pargc-1, pargv, &buffer); - Tcl_DStringResult(interp, &buffer); - } else if ((pargc == 0) - || (Tcl_GetPathType(pargv[0]) == TCL_PATH_RELATIVE)) { - Tcl_SetResult(interp, - (tclPlatform == TCL_PLATFORM_MAC) ? ":" : ".", TCL_STATIC); - } else { - Tcl_SetResult(interp, pargv[0], TCL_VOLATILE); - } - ckfree((char *)pargv); - goto done; - - } else if ((c == 't') && (strncmp(argv[1], "tail", length) == 0) - && (length >= 2)) { - int pargc; - char **pargv; - - if (argc != 3) { - argv[1] = "tail"; - goto not3Args; - } - - Tcl_SplitPath(argv[2], &pargc, &pargv); - if (pargc > 0) { - if ((pargc > 1) - || (Tcl_GetPathType(pargv[0]) == TCL_PATH_RELATIVE)) { - Tcl_SetResult(interp, pargv[pargc-1], TCL_VOLATILE); - } - } - ckfree((char *)pargv); - goto done; - - } else if ((c == 'r') && (strncmp(argv[1], "rootname", length) == 0) - && (length >= 2)) { - char tmp; - if (argc != 3) { - argv[1] = "rootname"; - goto not3Args; - } - extension = TclGetExtension(argv[2]); - if (extension == NULL) { - Tcl_SetResult(interp, argv[2], TCL_VOLATILE); - } else { - tmp = *extension; - *extension = 0; - Tcl_SetResult(interp, argv[2], TCL_VOLATILE); - *extension = tmp; - } - goto done; - } else if ((c == 'e') && (strncmp(argv[1], "extension", length) == 0) - && (length >= 3)) { - if (argc != 3) { - argv[1] = "extension"; - goto not3Args; - } - extension = TclGetExtension(argv[2]); - - if (extension != NULL) { - Tcl_SetResult(interp, extension, TCL_VOLATILE); - } - goto done; - } else if ((c == 'p') && (strncmp(argv[1], "pathtype", length) == 0)) { - if (argc != 3) { - argv[1] = "pathtype"; - goto not3Args; - } - switch (Tcl_GetPathType(argv[2])) { - case TCL_PATH_ABSOLUTE: - Tcl_SetResult(interp, "absolute", TCL_STATIC); - break; - case TCL_PATH_RELATIVE: - Tcl_SetResult(interp, "relative", TCL_STATIC); - break; - case TCL_PATH_VOLUME_RELATIVE: - Tcl_SetResult(interp, "volumerelative", TCL_STATIC); - break; - } - goto done; - } else if ((c == 's') && (strncmp(argv[1], "split", length) == 0) - && (length >= 2)) { - int pargc, i; - char **pargvList; - - if (argc != 3) { - argv[1] = "split"; - goto not3Args; - } - - Tcl_SplitPath(argv[2], &pargc, &pargvList); - for (i = 0; i < pargc; i++) { - Tcl_AppendElement(interp, pargvList[i]); - } - ckfree((char *) pargvList); - goto done; - } else if ((c == 'j') && (strncmp(argv[1], "join", length) == 0)) { - Tcl_JoinPath(argc-2, argv+2, &buffer); - Tcl_DStringResult(interp, &buffer); - goto done; - } - - /* - * Next, handle operations that can be satisfied with the "access" - * kernel call. - */ - - fileName = Tcl_TranslateFileName(interp, argv[2], &buffer); - if (fileName == NULL) { - result = TCL_ERROR; - goto done; - } - if ((c == 'r') && (strncmp(argv[1], "readable", length) == 0) - && (length >= 5)) { - if (argc != 3) { - argv[1] = "readable"; - goto not3Args; - } - mode = R_OK; - checkAccess: - if (access(fileName, mode) == -1) { - interp->result = "0"; - } else { - interp->result = "1"; - } - goto done; - } else if ((c == 'w') && (strncmp(argv[1], "writable", length) == 0)) { - if (argc != 3) { - argv[1] = "writable"; - goto not3Args; - } - mode = W_OK; - goto checkAccess; - } else if ((c == 'e') && (strncmp(argv[1], "executable", length) == 0) - && (length >= 3)) { - if (argc != 3) { - argv[1] = "executable"; - goto not3Args; - } - mode = X_OK; - goto checkAccess; - } else if ((c == 'e') && (strncmp(argv[1], "exists", length) == 0) - && (length >= 3)) { - if (argc != 3) { - argv[1] = "exists"; - goto not3Args; - } - mode = F_OK; - goto checkAccess; - } - - /* - * Lastly, check stuff that requires the file to be stat-ed. - */ - - if ((c == 'a') && (strncmp(argv[1], "atime", length) == 0)) { - if (argc != 3) { - argv[1] = "atime"; - goto not3Args; - } - if (stat(fileName, &statBuf) == -1) { - goto badStat; - } - sprintf(interp->result, "%ld", (long) statBuf.st_atime); - goto done; - } else if ((c == 'i') && (strncmp(argv[1], "isdirectory", length) == 0) - && (length >= 3)) { - if (argc != 3) { - argv[1] = "isdirectory"; - goto not3Args; - } - statOp = 2; - } else if ((c == 'i') && (strncmp(argv[1], "isfile", length) == 0) - && (length >= 3)) { - if (argc != 3) { - argv[1] = "isfile"; - goto not3Args; - } - statOp = 1; - } else if ((c == 'l') && (strncmp(argv[1], "lstat", length) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " lstat name varName\"", (char *) NULL); - result = TCL_ERROR; - goto done; - } - - if (lstat(fileName, &statBuf) == -1) { - Tcl_AppendResult(interp, "couldn't lstat \"", argv[2], - "\": ", Tcl_PosixError(interp), (char *) NULL); - result = TCL_ERROR; - goto done; - } - result = StoreStatData(interp, argv[3], &statBuf); - goto done; - } else if ((c == 'm') && (strncmp(argv[1], "mtime", length) == 0)) { - if (argc != 3) { - argv[1] = "mtime"; - goto not3Args; - } - if (stat(fileName, &statBuf) == -1) { - goto badStat; - } - sprintf(interp->result, "%ld", (long) statBuf.st_mtime); - goto done; - } else if ((c == 'o') && (strncmp(argv[1], "owned", length) == 0)) { - if (argc != 3) { - argv[1] = "owned"; - goto not3Args; - } - statOp = 0; - } else if ((c == 'r') && (strncmp(argv[1], "readlink", length) == 0) - && (length >= 5)) { - char linkValue[MAXPATHLEN+1]; - int linkLength; - - if (argc != 3) { - argv[1] = "readlink"; - goto not3Args; - } - - /* - * If S_IFLNK isn't defined it means that the machine doesn't - * support symbolic links, so the file can't possibly be a - * symbolic link. Generate an EINVAL error, which is what - * happens on machines that do support symbolic links when - * you invoke readlink on a file that isn't a symbolic link. - */ - -#ifndef S_IFLNK - linkLength = -1; - errno = EINVAL; -#else - linkLength = readlink(fileName, linkValue, sizeof(linkValue) - 1); -#endif /* S_IFLNK */ - if (linkLength == -1) { - Tcl_AppendResult(interp, "couldn't readlink \"", argv[2], - "\": ", Tcl_PosixError(interp), (char *) NULL); - result = TCL_ERROR; - goto done; - } - linkValue[linkLength] = 0; - Tcl_SetResult(interp, linkValue, TCL_VOLATILE); - goto done; - } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0) - && (length >= 2)) { - if (argc != 3) { - argv[1] = "size"; - goto not3Args; - } - if (stat(fileName, &statBuf) == -1) { - goto badStat; - } - sprintf(interp->result, "%lu", (unsigned long) statBuf.st_size); - goto done; - } else if ((c == 's') && (strncmp(argv[1], "stat", length) == 0) - && (length >= 2)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " stat name varName\"", (char *) NULL); - result = TCL_ERROR; - goto done; - } - - if (stat(fileName, &statBuf) == -1) { - badStat: - Tcl_AppendResult(interp, "couldn't stat \"", argv[2], - "\": ", Tcl_PosixError(interp), (char *) NULL); - result = TCL_ERROR; - goto done; - } - result = StoreStatData(interp, argv[3], &statBuf); - goto done; - } else if ((c == 't') && (strncmp(argv[1], "type", length) == 0) - && (length >= 2)) { - if (argc != 3) { - argv[1] = "type"; - goto not3Args; - } - if (lstat(fileName, &statBuf) == -1) { - goto badStat; - } - interp->result = GetTypeFromMode((int) statBuf.st_mode); - goto done; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be atime, dirname, executable, exists, ", - "extension, isdirectory, isfile, join, ", - "lstat, mtime, owned, pathtype, readable, readlink, ", - "root, size, split, stat, tail, type, ", - "or writable", - (char *) NULL); - result = TCL_ERROR; - goto done; - } - if (stat(fileName, &statBuf) == -1) { - interp->result = "0"; - goto done; - } - switch (statOp) { - case 0: - /* - * For Windows and Macintosh, there are no user ids - * associated with a file, so we always return 1. - */ - -#if (defined(__WIN32__) || defined(MAC_TCL)) - mode = 1; -#else - mode = (geteuid() == statBuf.st_uid); -#endif - break; - case 1: - mode = S_ISREG(statBuf.st_mode); - break; - case 2: - mode = S_ISDIR(statBuf.st_mode); - break; - } - if (mode) { - interp->result = "1"; - } else { - interp->result = "0"; - } - - done: - Tcl_DStringFree(&buffer); - return result; - - not3Args: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " name\"", (char *) NULL); - result = TCL_ERROR; - goto done; -} - -/* - *---------------------------------------------------------------------- - * - * StoreStatData -- - * - * This is a utility procedure that breaks out the fields of a - * "stat" structure and stores them in textual form into the - * elements of an associative array. - * - * Results: - * Returns a standard Tcl return value. If an error occurs then - * a message is left in interp->result. - * - * Side effects: - * Elements of the associative array given by "varName" are modified. - * - *---------------------------------------------------------------------- - */ - -static int -StoreStatData( - Tcl_Interp *interp, /* Interpreter for error reports. */ - char *varName, /* Name of associative array variable - * in which to store stat results. */ - struct stat *statPtr /* Pointer to buffer containing - * stat data to store in varName. */ -) -{ - char string[30]; - - sprintf(string, "%ld", (long) statPtr->st_dev); - if (Tcl_SetVar2(interp, varName, "dev", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_ino); - if (Tcl_SetVar2(interp, varName, "ino", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_mode); - if (Tcl_SetVar2(interp, varName, "mode", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_nlink); - if (Tcl_SetVar2(interp, varName, "nlink", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_uid); - if (Tcl_SetVar2(interp, varName, "uid", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_gid); - if (Tcl_SetVar2(interp, varName, "gid", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%lu", (unsigned long) statPtr->st_size); - if (Tcl_SetVar2(interp, varName, "size", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_atime); - if (Tcl_SetVar2(interp, varName, "atime", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_mtime); - if (Tcl_SetVar2(interp, varName, "mtime", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - sprintf(string, "%ld", (long) statPtr->st_ctime); - if (Tcl_SetVar2(interp, varName, "ctime", string, TCL_LEAVE_ERR_MSG) - == NULL) { - return TCL_ERROR; - } - if (Tcl_SetVar2(interp, varName, "type", - GetTypeFromMode((int) statPtr->st_mode), TCL_LEAVE_ERR_MSG) == NULL) { - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * GetTypeFromMode -- - * - * Given a mode word, returns a string identifying the type of a - * file. - * - * Results: - * A static text string giving the file type from mode. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -GetTypeFromMode(int mode) -{ - if (S_ISREG(mode)) { - return "file"; - } else if (S_ISDIR(mode)) { - return "directory"; - } else if (S_ISCHR(mode)) { - return "characterSpecial"; - } else if (S_ISBLK(mode)) { - return "blockSpecial"; - } else if (S_ISFIFO(mode)) { - return "fifo"; - } else if (S_ISLNK(mode)) { - return "link"; - } else if (S_ISSOCK(mode)) { - return "socket"; - } - return "unknown"; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ForCmd -- - * - * This procedure is invoked to process the "for" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ForCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int result, value; - - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " start test next command\"", (char *) NULL); - return TCL_ERROR; - } - - result = Tcl_Eval(interp, argv[1]); - if (result != TCL_OK) { - if (result == TCL_ERROR) { - Tcl_AddErrorInfo(interp, "\n (\"for\" initial command)"); - } - return result; - } - while (1) { - result = Tcl_ExprBoolean(interp, argv[2], &value); - if (result != TCL_OK) { - return result; - } - if (!value) { - break; - } - result = Tcl_Eval(interp, argv[4]); - if ((result != TCL_OK) && (result != TCL_CONTINUE)) { - if (result == TCL_ERROR) { - char msg[60]; - sprintf(msg, "\n (\"for\" body line %d)", interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - break; - } - result = Tcl_Eval(interp, argv[3]); - if (result == TCL_BREAK) { - break; - } else if (result != TCL_OK) { - if (result == TCL_ERROR) { - Tcl_AddErrorInfo(interp, "\n (\"for\" loop-end command)"); - } - return result; - } - } - if (result == TCL_BREAK) { - result = TCL_OK; - } - if (result == TCL_OK) { - Tcl_ResetResult(interp); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ForeachCmd -- - * - * This procedure is invoked to process the "foreach" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ForeachCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int result = TCL_OK; - int i; /* i selects a value list */ - int j, maxj; /* Number of loop iterations */ - int v; /* v selects a loop variable */ - int numLists; /* Count of value lists */ -#define STATIC_SIZE 4 - int indexArray[STATIC_SIZE]; /* Array of value list indices */ - int varcListArray[STATIC_SIZE]; /* Number of loop variables per list */ - char **varvListArray[STATIC_SIZE]; /* Array of variable name lists */ - int argcListArray[STATIC_SIZE]; /* Array of value list sizes */ - char **argvListArray[STATIC_SIZE]; /* Array of value lists */ - - int *index = indexArray; - int *varcList = varcListArray; - char ***varvList = varvListArray; - int *argcList = argcListArray; - char ***argvList = argvListArray; - - if (argc < 4 || (argc%2 != 0)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " varList list ?varList list ...? command\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Manage numList parallel value lists. - * argvList[i] is a value list counted by argcList[i] - * varvList[i] is the list of variables associated with the value list - * varcList[i] is the number of variables associated with the value list - * index[i] is the current pointer into the value list argvList[i] - */ - - numLists = (argc-2)/2; - if (numLists > STATIC_SIZE) { - index = (int *) ckalloc(numLists * sizeof(int)); - varcList = (int *) ckalloc(numLists * sizeof(int)); - varvList = (char ***) ckalloc(numLists * sizeof(char **)); - argcList = (int *) ckalloc(numLists * sizeof(int)); - argvList = (char ***) ckalloc(numLists * sizeof(char **)); - } - for (i=0 ; i<numLists ; i++) { - index[i] = 0; - varcList[i] = 0; - varvList[i] = (char **)NULL; - argcList[i] = 0; - argvList[i] = (char **)NULL; - } - - /* - * Break up the value lists and variable lists into elements - */ - - maxj = 0; - for (i=0 ; i<numLists ; i++) { - result = Tcl_SplitList(interp, argv[1+i*2], &varcList[i], &varvList[i]); - if (result != TCL_OK) { - goto errorReturn; - } - result = Tcl_SplitList(interp, argv[2+i*2], &argcList[i], &argvList[i]); - if (result != TCL_OK) { - goto errorReturn; - } - j = argcList[i] / varcList[i]; - if ((argcList[i] % varcList[i]) != 0) { - j++; - } - if (j > maxj) { - maxj = j; - } - } - - /* - * Iterate maxj times through the lists in parallel - * If some value lists run out of values, set loop vars to "" - */ - for (j = 0; j < maxj; j++) { - for (i=0 ; i<numLists ; i++) { - for (v=0 ; v<varcList[i] ; v++) { - int k = index[i]++; - char *value = ""; - if (k < argcList[i]) { - value = argvList[i][k]; - } - if (Tcl_SetVar(interp, varvList[i][v], value, 0) == NULL) { - Tcl_AppendResult(interp, "couldn't set loop variable: \"", - varvList[i][v], "\"", (char *)NULL); - result = TCL_ERROR; - goto errorReturn; - } - } - } - - result = Tcl_Eval(interp, argv[argc-1]); - if (result != TCL_OK) { - if (result == TCL_CONTINUE) { - result = TCL_OK; - } else if (result == TCL_BREAK) { - result = TCL_OK; - break; - } else if (result == TCL_ERROR) { - char msg[100]; - sprintf(msg, "\n (\"foreach\" body line %d)", - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - break; - } else { - break; - } - } - } - if (result == TCL_OK) { - Tcl_ResetResult(interp); - } -errorReturn: - for (i=0 ; i<numLists ; i++) { - if (argvList[i] != (char **)NULL) { - ckfree((char *) argvList[i]); - } - if (varvList[i] != (char **)NULL) { - ckfree((char *) varvList[i]); - } - } - if (numLists > STATIC_SIZE) { - ckfree((char *) index); - ckfree((char *) varcList); - ckfree((char *) argcList); - ckfree((char *) varvList); - ckfree((char *) argvList); - } -#undef STATIC_SIZE - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FormatCmd -- - * - * This procedure is invoked to process the "format" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FormatCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *format; /* Used to read characters from the format - * string. */ - char newFormat[40]; /* A new format specifier is generated here. */ - int width; /* Field width from field specifier, or 0 if - * no width given. */ - int precision; /* Field precision from field specifier, or 0 - * if no precision given. */ - int size; /* Number of bytes needed for result of - * conversion, based on type of conversion - * ("e", "s", etc.), width, and precision. */ - int intValue; /* Used to hold value to pass to sprintf, if - * it's a one-word integer or char value */ - char *ptrValue = NULL; /* Used to hold value to pass to sprintf, if - * it's a one-word value. */ - double doubleValue; /* Used to hold value to pass to sprintf if - * it's a double value. */ - int whichValue; /* Indicates which of intValue, ptrValue, - * or doubleValue has the value to pass to - * sprintf, according to the following - * definitions: */ -# define INT_VALUE 0 -# define PTR_VALUE 1 -# define DOUBLE_VALUE 2 - char *dst = interp->result; /* Where result is stored. Starts off at - * interp->resultSpace, but may get dynamically - * re-allocated if this isn't enough. */ - int dstSize = 0; /* Number of non-null characters currently - * stored at dst. */ - int dstSpace = TCL_RESULT_SIZE; - /* Total amount of storage space available - * in dst (not including null terminator. */ - int noPercent; /* Special case for speed: indicates there's - * no field specifier, just a string to copy. */ - int argIndex; /* Index of argument to substitute next. */ - int gotXpg = 0; /* Non-zero means that an XPG3 %n$-style - * specifier has been seen. */ - int gotSequential = 0; /* Non-zero means that a regular sequential - * (non-XPG3) conversion specifier has been - * seen. */ - int useShort; /* Value to be printed is short (half word). */ - char *end; /* Used to locate end of numerical fields. */ - - /* - * This procedure is a bit nasty. The goal is to use sprintf to - * do most of the dirty work. There are several problems: - * 1. this procedure can't trust its arguments. - * 2. we must be able to provide a large enough result area to hold - * whatever's generated. This is hard to estimate. - * 2. there's no way to move the arguments from argv to the call - * to sprintf in a reasonable way. This is particularly nasty - * because some of the arguments may be two-word values (doubles). - * So, what happens here is to scan the format string one % group - * at a time, making many individual calls to sprintf. - */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " formatString ?arg arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - argIndex = 2; - for (format = argv[1]; *format != 0; ) { - char *newPtr = newFormat; - - width = precision = noPercent = useShort = 0; - whichValue = PTR_VALUE; - - /* - * Get rid of any characters before the next field specifier. - */ - - if (*format != '%') { - char *p; - - ptrValue = p = format; - while ((*format != '%') && (*format != 0)) { - *p = *format; - p++; - format++; - } - size = p - ptrValue; - noPercent = 1; - goto doField; - } - - if (format[1] == '%') { - ptrValue = format; - size = 1; - noPercent = 1; - format += 2; - goto doField; - } - - /* - * Parse off a field specifier, compute how many characters - * will be needed to store the result, and substitute for - * "*" size specifiers. - */ - - *newPtr = '%'; - newPtr++; - format++; - if (isdigit(UCHAR(*format))) { - int tmp; - - /* - * Check for an XPG3-style %n$ specification. Note: there - * must not be a mixture of XPG3 specs and non-XPG3 specs - * in the same format string. - */ - - tmp = strtoul(format, &end, 10); - if (*end != '$') { - goto notXpg; - } - format = end+1; - gotXpg = 1; - if (gotSequential) { - goto mixedXPG; - } - argIndex = tmp+1; - if ((argIndex < 2) || (argIndex >= argc)) { - goto badIndex; - } - goto xpgCheckDone; - } - - notXpg: - gotSequential = 1; - if (gotXpg) { - goto mixedXPG; - } - - xpgCheckDone: - while ((*format == '-') || (*format == '#') || (*format == '0') - || (*format == ' ') || (*format == '+')) { - *newPtr = *format; - newPtr++; - format++; - } - if (isdigit(UCHAR(*format))) { - width = strtoul(format, &end, 10); - format = end; - } else if (*format == '*') { - if (argIndex >= argc) { - goto badIndex; - } - if (Tcl_GetInt(interp, argv[argIndex], &width) != TCL_OK) { - goto fmtError; - } - argIndex++; - format++; - } - if (width > 1000) { - /* - * Don't allow arbitrarily large widths: could cause core - * dump when we try to allocate a zillion bytes of memory - * below. - */ - - width = 1000; - } else if (width < 0) { - width = 0; - } - if (width != 0) { - sprintf(newPtr, "%d", width); - while (*newPtr != 0) { - newPtr++; - } - } - if (*format == '.') { - *newPtr = '.'; - newPtr++; - format++; - } - if (isdigit(UCHAR(*format))) { - precision = strtoul(format, &end, 10); - format = end; - } else if (*format == '*') { - if (argIndex >= argc) { - goto badIndex; - } - if (Tcl_GetInt(interp, argv[argIndex], &precision) != TCL_OK) { - goto fmtError; - } - argIndex++; - format++; - } - if (precision != 0) { - sprintf(newPtr, "%d", precision); - while (*newPtr != 0) { - newPtr++; - } - } - if (*format == 'l') { - format++; - } else if (*format == 'h') { - useShort = 1; - *newPtr = 'h'; - newPtr++; - format++; - } - *newPtr = *format; - newPtr++; - *newPtr = 0; - if (argIndex >= argc) { - goto badIndex; - } - switch (*format) { - case 'i': - newPtr[-1] = 'd'; - case 'd': - case 'o': - case 'u': - case 'x': - case 'X': - if (Tcl_GetInt(interp, argv[argIndex], (int *) &intValue) - != TCL_OK) { - goto fmtError; - } - whichValue = INT_VALUE; - size = 40 + precision; - break; - case 's': - ptrValue = argv[argIndex]; - size = strlen(argv[argIndex]); - break; - case 'c': - if (Tcl_GetInt(interp, argv[argIndex], (int *) &intValue) - != TCL_OK) { - goto fmtError; - } - whichValue = INT_VALUE; - size = 1; - break; - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - if (Tcl_GetDouble(interp, argv[argIndex], &doubleValue) - != TCL_OK) { - goto fmtError; - } - whichValue = DOUBLE_VALUE; - size = 320; - if (precision > 10) { - size += precision; - } - break; - case 0: - interp->result = - "format string ended in middle of field specifier"; - goto fmtError; - default: - sprintf(interp->result, "bad field specifier \"%c\"", *format); - goto fmtError; - } - argIndex++; - format++; - - /* - * Make sure that there's enough space to hold the formatted - * result, then format it. - */ - - doField: - if (width > size) { - size = width; - } - if ((dstSize + size) > dstSpace) { - char *newDst; - int newSpace; - - newSpace = 2*(dstSize + size); - newDst = (char *) ckalloc((unsigned) newSpace+1); - if (dstSize != 0) { - memcpy((VOID *) newDst, (VOID *) dst, (size_t) dstSize); - } - if (dstSpace != TCL_RESULT_SIZE) { - ckfree(dst); - } - dst = newDst; - dstSpace = newSpace; - } - if (noPercent) { - memcpy((VOID *) (dst+dstSize), (VOID *) ptrValue, (size_t) size); - dstSize += size; - dst[dstSize] = 0; - } else { - if (whichValue == DOUBLE_VALUE) { - sprintf(dst+dstSize, newFormat, doubleValue); - } else if (whichValue == INT_VALUE) { - if (useShort) { - sprintf(dst+dstSize, newFormat, (short) intValue); - } else { - sprintf(dst+dstSize, newFormat, intValue); - } - } else { - sprintf(dst+dstSize, newFormat, ptrValue); - } - dstSize += strlen(dst+dstSize); - } - } - - interp->result = dst; - if (dstSpace != TCL_RESULT_SIZE) { - interp->freeProc = TCL_DYNAMIC; - } else { - interp->freeProc = 0; - } - return TCL_OK; - - mixedXPG: - interp->result = "cannot mix \"%\" and \"%n$\" conversion specifiers"; - goto fmtError; - - badIndex: - if (gotXpg) { - interp->result = "\"%n$\" argument index out of range"; - } else { - interp->result = "not enough arguments for all format specifiers"; - } - - fmtError: - if (dstSpace != TCL_RESULT_SIZE) { - ckfree(dst); - } - return TCL_ERROR; -} diff --git a/cde/programs/dtdocbook/tcl/tclCmdIL.c b/cde/programs/dtdocbook/tcl/tclCmdIL.c deleted file mode 100644 index 87bb5d45d..000000000 --- a/cde/programs/dtdocbook/tcl/tclCmdIL.c +++ /dev/null @@ -1,1521 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclCmdIL.c /main/2 1996/08/08 14:43:16 cde-hp $ */ -/* - * tclCmdIL.c -- - * - * This file contains the top-level command routines for most of - * the Tcl built-in commands whose names begin with the letters - * I through L. It contains only commands in the generic core - * (i.e. those that don't depend much upon UNIX facilities). - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclCmdIL.c 1.119 96/03/22 12:10:14 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The following variable holds the full path name of the binary - * from which this application was executed, or NULL if it isn't - * know. The value of the variable is set by the procedure - * Tcl_FindExecutable. The storage space is dynamically allocated. - */ - -char *tclExecutableName = NULL; - -/* - * The variables below are used to implement the "lsort" command. - * Unfortunately, this use of static variables prevents "lsort" - * from being thread-safe, but there's no alternative given the - * current implementation of qsort. In a threaded environment - * these variables should be made thread-local if possible, or else - * "lsort" needs internal mutual exclusion. - */ - -static Tcl_Interp *sortInterp = NULL; /* Interpreter for "lsort" command. - * NULL means no lsort is active. */ -static enum {ASCII, INTEGER, REAL, COMMAND} sortMode; - /* Mode for sorting: compare as strings, - * compare as numbers, or call - * user-defined command for - * comparison. */ -static Tcl_DString sortCmd; /* Holds command if mode is COMMAND. - * pre-initialized to hold base of - * command. */ -static int sortIncreasing; /* 0 means sort in decreasing order, - * 1 means increasing order. */ -static int sortCode; /* Anything other than TCL_OK means a - * problem occurred while sorting; this - * executing a comparison command, so - * the sort was aborted. */ - -/* - * Forward declarations for procedures defined in this file: - */ - -static int SortCompareProc _ANSI_ARGS_((CONST VOID *first, - CONST VOID *second)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_IfCmd -- - * - * This procedure is invoked to process the "if" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_IfCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i, result, value; - - i = 1; - while (1) { - /* - * At this point in the loop, argv and argc refer to an expression - * to test, either for the main expression or an expression - * following an "elseif". The arguments after the expression must - * be "then" (optional) and a script to execute if the expression is - * true. - */ - - if (i >= argc) { - Tcl_AppendResult(interp, "wrong # args: no expression after \"", - argv[i-1], "\" argument", (char *) NULL); - return TCL_ERROR; - } - result = Tcl_ExprBoolean(interp, argv[i], &value); - if (result != TCL_OK) { - return result; - } - i++; - if ((i < argc) && (strcmp(argv[i], "then") == 0)) { - i++; - } - if (i >= argc) { - Tcl_AppendResult(interp, "wrong # args: no script following \"", - argv[i-1], "\" argument", (char *) NULL); - return TCL_ERROR; - } - if (value) { - return Tcl_Eval(interp, argv[i]); - } - - /* - * The expression evaluated to false. Skip the command, then - * see if there is an "else" or "elseif" clause. - */ - - i++; - if (i >= argc) { - return TCL_OK; - } - if ((argv[i][0] == 'e') && (strcmp(argv[i], "elseif") == 0)) { - i++; - continue; - } - break; - } - - /* - * Couldn't find a "then" or "elseif" clause to execute. Check now - * for an "else" clause. We know that there's at least one more - * argument when we get here. - */ - - if (strcmp(argv[i], "else") == 0) { - i++; - if (i >= argc) { - Tcl_AppendResult(interp, - "wrong # args: no script following \"else\" argument", - (char *) NULL); - return TCL_ERROR; - } - } - return Tcl_Eval(interp, argv[i]); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_IncrCmd -- - * - * This procedure is invoked to process the "incr" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_IncrCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int value; - char *oldString, *result; - char newString[30]; - - if ((argc != 2) && (argc != 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " varName ?increment?\"", (char *) NULL); - return TCL_ERROR; - } - - oldString = Tcl_GetVar(interp, argv[1], TCL_LEAVE_ERR_MSG); - if (oldString == NULL) { - return TCL_ERROR; - } - if (Tcl_GetInt(interp, oldString, &value) != TCL_OK) { - Tcl_AddErrorInfo(interp, - "\n (reading value of variable to increment)"); - return TCL_ERROR; - } - if (argc == 2) { - value += 1; - } else { - int increment; - - if (Tcl_GetInt(interp, argv[2], &increment) != TCL_OK) { - Tcl_AddErrorInfo(interp, - "\n (reading increment)"); - return TCL_ERROR; - } - value += increment; - } - sprintf(newString, "%d", value); - result = Tcl_SetVar(interp, argv[1], newString, TCL_LEAVE_ERR_MSG); - if (result == NULL) { - return TCL_ERROR; - } - interp->result = result; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InfoCmd -- - * - * This procedure is invoked to process the "info" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_InfoCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - size_t length; - int c; - Arg *argPtr; - Proc *procPtr; - Var *varPtr; - Command *cmdPtr; - Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'a') && (strncmp(argv[1], "args", length)) == 0) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " args procname\"", (char *) NULL); - return TCL_ERROR; - } - procPtr = TclFindProc(iPtr, argv[2]); - if (procPtr == NULL) { - infoNoSuchProc: - Tcl_AppendResult(interp, "\"", argv[2], - "\" isn't a procedure", (char *) NULL); - return TCL_ERROR; - } - for (argPtr = procPtr->argPtr; argPtr != NULL; - argPtr = argPtr->nextPtr) { - Tcl_AppendElement(interp, argPtr->name); - } - return TCL_OK; - } else if ((c == 'b') && (strncmp(argv[1], "body", length)) == 0) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " body procname\"", (char *) NULL); - return TCL_ERROR; - } - procPtr = TclFindProc(iPtr, argv[2]); - if (procPtr == NULL) { - goto infoNoSuchProc; - } - iPtr->result = procPtr->command; - return TCL_OK; - } else if ((c == 'c') && (strncmp(argv[1], "cmdcount", length) == 0) - && (length >= 2)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " cmdcount\"", (char *) NULL); - return TCL_ERROR; - } - sprintf(iPtr->result, "%d", iPtr->cmdCount); - return TCL_OK; - } else if ((c == 'c') && (strncmp(argv[1], "commands", length) == 0) - && (length >= 4)) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " commands ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - for (hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - char *name = Tcl_GetHashKey(&iPtr->commandTable, hPtr); - if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { - continue; - } - Tcl_AppendElement(interp, name); - } - return TCL_OK; - } else if ((c == 'c') && (strncmp(argv[1], "complete", length) == 0) - && (length >= 4)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " complete command\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_CommandComplete(argv[2])) { - interp->result = "1"; - } else { - interp->result = "0"; - } - return TCL_OK; - } else if ((c == 'd') && (strncmp(argv[1], "default", length)) == 0) { - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " default procname arg varname\"", - (char *) NULL); - return TCL_ERROR; - } - procPtr = TclFindProc(iPtr, argv[2]); - if (procPtr == NULL) { - goto infoNoSuchProc; - } - for (argPtr = procPtr->argPtr; ; argPtr = argPtr->nextPtr) { - if (argPtr == NULL) { - Tcl_AppendResult(interp, "procedure \"", argv[2], - "\" doesn't have an argument \"", argv[3], - "\"", (char *) NULL); - return TCL_ERROR; - } - if (strcmp(argv[3], argPtr->name) == 0) { - if (argPtr->defValue != NULL) { - if (Tcl_SetVar((Tcl_Interp *) iPtr, argv[4], - argPtr->defValue, 0) == NULL) { - defStoreError: - Tcl_AppendResult(interp, - "couldn't store default value in variable \"", - argv[4], "\"", (char *) NULL); - return TCL_ERROR; - } - iPtr->result = "1"; - } else { - if (Tcl_SetVar((Tcl_Interp *) iPtr, argv[4], "", 0) - == NULL) { - goto defStoreError; - } - iPtr->result = "0"; - } - return TCL_OK; - } - } - } else if ((c == 'e') && (strncmp(argv[1], "exists", length) == 0)) { - char *p; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " exists varName\"", (char *) NULL); - return TCL_ERROR; - } - p = Tcl_GetVar((Tcl_Interp *) iPtr, argv[2], 0); - - /* - * The code below handles the special case where the name is for - * an array: Tcl_GetVar will reject this since you can't read - * an array variable without an index. - */ - - if (p == NULL) { - Tcl_HashEntry *hPtr; - Var *varPtr; - - if (strchr(argv[2], '(') != NULL) { - noVar: - iPtr->result = "0"; - return TCL_OK; - } - if (iPtr->varFramePtr == NULL) { - hPtr = Tcl_FindHashEntry(&iPtr->globalTable, argv[2]); - } else { - hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, argv[2]); - } - if (hPtr == NULL) { - goto noVar; - } - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & VAR_UPVAR) { - varPtr = varPtr->value.upvarPtr; - } - if (!(varPtr->flags & VAR_ARRAY)) { - goto noVar; - } - } - iPtr->result = "1"; - return TCL_OK; - } else if ((c == 'g') && (strncmp(argv[1], "globals", length) == 0)) { - char *name; - - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " globals ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - for (hPtr = Tcl_FirstHashEntry(&iPtr->globalTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & VAR_UNDEFINED) { - continue; - } - name = Tcl_GetHashKey(&iPtr->globalTable, hPtr); - if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { - continue; - } - Tcl_AppendElement(interp, name); - } - return TCL_OK; - } else if ((c == 'h') && (strncmp(argv[1], "hostname", length) == 0)) { - if (argc > 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " hostname\"", (char *) NULL); - return TCL_ERROR; - } - Tcl_AppendResult(interp, Tcl_GetHostName(), NULL); - return TCL_OK; - } else if ((c == 'l') && (strncmp(argv[1], "level", length) == 0) - && (length >= 2)) { - if (argc == 2) { - if (iPtr->varFramePtr == NULL) { - iPtr->result = "0"; - } else { - sprintf(iPtr->result, "%d", iPtr->varFramePtr->level); - } - return TCL_OK; - } else if (argc == 3) { - int level; - CallFrame *framePtr; - - if (Tcl_GetInt(interp, argv[2], &level) != TCL_OK) { - return TCL_ERROR; - } - if (level <= 0) { - if (iPtr->varFramePtr == NULL) { - levelError: - Tcl_AppendResult(interp, "bad level \"", argv[2], - "\"", (char *) NULL); - return TCL_ERROR; - } - level += iPtr->varFramePtr->level; - } - for (framePtr = iPtr->varFramePtr; framePtr != NULL; - framePtr = framePtr->callerVarPtr) { - if (framePtr->level == level) { - break; - } - } - if (framePtr == NULL) { - goto levelError; - } - iPtr->result = Tcl_Merge(framePtr->argc, framePtr->argv); - iPtr->freeProc = TCL_DYNAMIC; - return TCL_OK; - } - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " level [number]\"", (char *) NULL); - return TCL_ERROR; - } else if ((c == 'l') && (strncmp(argv[1], "library", length) == 0) - && (length >= 2)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " library\"", (char *) NULL); - return TCL_ERROR; - } - interp->result = Tcl_GetVar(interp, "tcl_library", TCL_GLOBAL_ONLY); - if (interp->result == NULL) { - interp->result = "no library has been specified for Tcl"; - return TCL_ERROR; - } - return TCL_OK; - } else if ((c == 'l') && (strncmp(argv[1], "loaded", length) == 0) - && (length >= 3)) { - if ((argc != 2) && (argc != 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " loaded ?interp?\"", (char *) NULL); - return TCL_ERROR; - } - return TclGetLoadedPackages(interp, argv[2]); - } else if ((c == 'l') && (strncmp(argv[1], "locals", length) == 0) - && (length >= 3)) { - char *name; - - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " locals ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - if (iPtr->varFramePtr == NULL) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(&iPtr->varFramePtr->varTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR)) { - continue; - } - name = Tcl_GetHashKey(&iPtr->varFramePtr->varTable, hPtr); - if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { - continue; - } - Tcl_AppendElement(interp, name); - } - return TCL_OK; - } else if ((c == 'n') && (strncmp(argv[1], "nameofexecutable", - length) == 0)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " nameofexecutable\"", (char *) NULL); - return TCL_ERROR; - } - if (tclExecutableName != NULL) { - interp->result = tclExecutableName; - } - return TCL_OK; - } else if ((c == 'p') && (strncmp(argv[1], "patchlevel", length) == 0) - && (length >= 2)) { - char *value; - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " patchlevel\"", (char *) NULL); - return TCL_ERROR; - } - value = Tcl_GetVar(interp, "tcl_patchLevel", - TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); - if (value == NULL) { - return TCL_ERROR; - } - interp->result = value; - return TCL_OK; - } else if ((c == 'p') && (strncmp(argv[1], "procs", length) == 0) - && (length >= 2)) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " procs ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - for (hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - char *name = Tcl_GetHashKey(&iPtr->commandTable, hPtr); - - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - if (!TclIsProc(cmdPtr)) { - continue; - } - if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { - continue; - } - Tcl_AppendElement(interp, name); - } - return TCL_OK; - } else if ((c == 's') && (strncmp(argv[1], "script", length) == 0) - && (length >= 2)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " script\"", (char *) NULL); - return TCL_ERROR; - } - if (iPtr->scriptFile != NULL) { - /* - * Can't depend on iPtr->scriptFile to be non-volatile: - * if this command is returned as the result of the script, - * then iPtr->scriptFile will go away. - */ - - Tcl_SetResult(interp, iPtr->scriptFile, TCL_VOLATILE); - } - return TCL_OK; - } else if ((c == 's') && (strncmp(argv[1], "sharedlibextension", - length) == 0) && (length >= 2)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " sharedlibextension\"", (char *) NULL); - return TCL_ERROR; - } -#ifdef TCL_SHLIB_EXT - interp->result = TCL_SHLIB_EXT; -#endif - return TCL_OK; - } else if ((c == 't') && (strncmp(argv[1], "tclversion", length) == 0)) { - char *value; - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " tclversion\"", (char *) NULL); - return TCL_ERROR; - } - value = Tcl_GetVar(interp, "tcl_version", - TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); - if (value == NULL) { - return TCL_ERROR; - } - interp->result = value; - return TCL_OK; - } else if ((c == 'v') && (strncmp(argv[1], "vars", length)) == 0) { - Tcl_HashTable *tablePtr; - char *name; - - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " vars ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - if (iPtr->varFramePtr == NULL) { - tablePtr = &iPtr->globalTable; - } else { - tablePtr = &iPtr->varFramePtr->varTable; - } - for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & VAR_UNDEFINED) { - continue; - } - name = Tcl_GetHashKey(tablePtr, hPtr); - if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { - continue; - } - Tcl_AppendElement(interp, name); - } - return TCL_OK; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be args, body, cmdcount, commands, ", - "complete, default, ", - "exists, globals, hostname, level, library, loaded, locals, ", - "nameofexecutable, patchlevel, procs, script, ", - "sharedlibextension, tclversion, or vars", - (char *) NULL); - return TCL_ERROR; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_JoinCmd -- - * - * This procedure is invoked to process the "join" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_JoinCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *joinString; - char **listArgv; - int listArgc, i; - - if (argc == 2) { - joinString = " "; - } else if (argc == 3) { - joinString = argv[2]; - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list ?joinString?\"", (char *) NULL); - return TCL_ERROR; - } - - if (Tcl_SplitList(interp, argv[1], &listArgc, &listArgv) != TCL_OK) { - return TCL_ERROR; - } - for (i = 0; i < listArgc; i++) { - if (i == 0) { - Tcl_AppendResult(interp, listArgv[0], (char *) NULL); - } else { - Tcl_AppendResult(interp, joinString, listArgv[i], (char *) NULL); - } - } - ckfree((char *) listArgv); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LindexCmd -- - * - * This procedure is invoked to process the "lindex" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LindexCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *p, *element, *next; - int index, size, parenthesized, result, returnLast; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list index\"", (char *) NULL); - return TCL_ERROR; - } - if ((*argv[2] == 'e') && (strncmp(argv[2], "end", strlen(argv[2])) == 0)) { - returnLast = 1; - index = INT_MAX; - } else { - returnLast = 0; - if (Tcl_GetInt(interp, argv[2], &index) != TCL_OK) { - return TCL_ERROR; - } - } - if (index < 0) { - return TCL_OK; - } - for (p = argv[1] ; index >= 0; index--) { - result = TclFindElement(interp, p, &element, &next, &size, - &parenthesized); - if (result != TCL_OK) { - return result; - } - if ((*next == 0) && returnLast) { - break; - } - p = next; - } - if (size == 0) { - return TCL_OK; - } - if (size >= TCL_RESULT_SIZE) { - interp->result = (char *) ckalloc((unsigned) size+1); - interp->freeProc = TCL_DYNAMIC; - } - if (parenthesized) { - memcpy((VOID *) interp->result, (VOID *) element, (size_t) size); - interp->result[size] = 0; - } else { - TclCopyAndCollapse(size, element, interp->result); - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LinsertCmd -- - * - * This procedure is invoked to process the "linsert" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LinsertCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *p, *element, savedChar; - int i, index, count, result, size; - - if (argc < 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list index element ?element ...?\"", (char *) NULL); - return TCL_ERROR; - } - if ((*argv[2] == 'e') && (strncmp(argv[2], "end", strlen(argv[2])) == 0)) { - index = INT_MAX; - } else if (Tcl_GetInt(interp, argv[2], &index) != TCL_OK) { - return TCL_ERROR; - } - - /* - * Skip over the first "index" elements of the list, then add - * all of those elements to the result. - */ - - size = 0; - element = argv[1]; - for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) { - result = TclFindElement(interp, p, &element, &p, &size, (int *) NULL); - if (result != TCL_OK) { - return result; - } - } - if (*p == 0) { - Tcl_AppendResult(interp, argv[1], (char *) NULL); - } else { - char *end; - - end = element+size; - if (element != argv[1]) { - while ((*end != 0) && !isspace(UCHAR(*end))) { - end++; - } - } - savedChar = *end; - *end = 0; - Tcl_AppendResult(interp, argv[1], (char *) NULL); - *end = savedChar; - } - - /* - * Add the new list elements. - */ - - for (i = 3; i < argc; i++) { - Tcl_AppendElement(interp, argv[i]); - } - - /* - * Append the remainder of the original list. - */ - - if (*p != 0) { - Tcl_AppendResult(interp, " ", p, (char *) NULL); - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ListCmd -- - * - * This procedure is invoked to process the "list" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ListCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc >= 2) { - interp->result = Tcl_Merge(argc-1, argv+1); - interp->freeProc = TCL_DYNAMIC; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LlengthCmd -- - * - * This procedure is invoked to process the "llength" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LlengthCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int count, result; - char *element, *p; - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list\"", (char *) NULL); - return TCL_ERROR; - } - for (count = 0, p = argv[1]; *p != 0 ; count++) { - result = TclFindElement(interp, p, &element, &p, (int *) NULL, - (int *) NULL); - if (result != TCL_OK) { - return result; - } - if (*element == 0) { - break; - } - } - sprintf(interp->result, "%d", count); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LrangeCmd -- - * - * This procedure is invoked to process the "lrange" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LrangeCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int first, last, result; - char *begin, *end, c, *dummy, *next; - int count, firstIsEnd; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list first last\"", (char *) NULL); - return TCL_ERROR; - } - if ((*argv[2] == 'e') && (strncmp(argv[2], "end", strlen(argv[2])) == 0)) { - firstIsEnd = 1; - first = INT_MAX; - } else { - firstIsEnd = 0; - if (Tcl_GetInt(interp, argv[2], &first) != TCL_OK) { - return TCL_ERROR; - } - } - if (first < 0) { - first = 0; - } - if ((*argv[3] == 'e') && (strncmp(argv[3], "end", strlen(argv[3])) == 0)) { - last = INT_MAX; - } else { - if (Tcl_GetInt(interp, argv[3], &last) != TCL_OK) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "expected integer or \"end\" but got \"", - argv[3], "\"", (char *) NULL); - return TCL_ERROR; - } - } - if ((first > last) && !firstIsEnd) { - return TCL_OK; - } - - /* - * Extract a range of fields. - */ - - for (count = 0, begin = argv[1]; count < first; begin = next, count++) { - result = TclFindElement(interp, begin, &dummy, &next, (int *) NULL, - (int *) NULL); - if (result != TCL_OK) { - return result; - } - if (*next == 0) { - if (firstIsEnd) { - first = count; - } else { - begin = next; - } - break; - } - } - for (count = first, end = begin; (count <= last) && (*end != 0); - count++) { - result = TclFindElement(interp, end, &dummy, &end, (int *) NULL, - (int *) NULL); - if (result != TCL_OK) { - return result; - } - } - if (end == begin) { - return TCL_OK; - } - - /* - * Chop off trailing spaces. - */ - - while (isspace(UCHAR(end[-1]))) { - end--; - } - c = *end; - *end = 0; - Tcl_SetResult(interp, begin, TCL_VOLATILE); - *end = c; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LreplaceCmd -- - * - * This procedure is invoked to process the "lreplace" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LreplaceCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *p1, *p2, *element, savedChar, *dummy, *next; - int i, first, last, count, result, size, firstIsEnd; - - if (argc < 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " list first last ?element element ...?\"", (char *) NULL); - return TCL_ERROR; - } - if ((*argv[2] == 'e') && (strncmp(argv[2], "end", strlen(argv[2])) == 0)) { - firstIsEnd = 1; - first = INT_MAX; - } else { - firstIsEnd = 0; - if (Tcl_GetInt(interp, argv[2], &first) != TCL_OK) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad index \"", argv[2], - "\": must be integer or \"end\"", (char *) NULL); - return TCL_ERROR; - } - } - if ((*argv[3] == 'e') && (strncmp(argv[3], "end", strlen(argv[3])) == 0)) { - last = INT_MAX; - } else { - if (Tcl_GetInt(interp, argv[3], &last) != TCL_OK) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad index \"", argv[3], - "\": must be integer or \"end\"", (char *) NULL); - return TCL_ERROR; - } - } - if (first < 0) { - first = 0; - } - - /* - * Skip over the elements of the list before "first". - */ - - size = 0; - element = argv[1]; - for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) { - result = TclFindElement(interp, p1, &element, &next, &size, - (int *) NULL); - if (result != TCL_OK) { - return result; - } - if ((*next == 0) && firstIsEnd) { - break; - } - p1 = next; - } - if (*p1 == 0) { - Tcl_AppendResult(interp, "list doesn't contain element ", - argv[2], (char *) NULL); - return TCL_ERROR; - } - - /* - * Skip over the elements of the list up through "last". - */ - - for (p2 = p1 ; (count <= last) && (*p2 != 0); count++) { - result = TclFindElement(interp, p2, &dummy, &p2, (int *) NULL, - (int *) NULL); - if (result != TCL_OK) { - return result; - } - } - - /* - * Add the elements before "first" to the result. Drop any terminating - * white space, since a separator will be added below, if needed. - */ - - while ((p1 != argv[1]) && (isspace(UCHAR(p1[-1])))) { - p1--; - } - savedChar = *p1; - *p1 = 0; - Tcl_AppendResult(interp, argv[1], (char *) NULL); - *p1 = savedChar; - - /* - * Add the new list elements. - */ - - for (i = 4; i < argc; i++) { - Tcl_AppendElement(interp, argv[i]); - } - - /* - * Append the remainder of the original list. - */ - - if (*p2 != 0) { - if (*interp->result == 0) { - Tcl_SetResult(interp, p2, TCL_VOLATILE); - } else { - Tcl_AppendResult(interp, " ", p2, (char *) NULL); - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LsearchCmd -- - * - * This procedure is invoked to process the "lsearch" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LsearchCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ -#define EXACT 0 -#define GLOB 1 -#define REGEXP 2 - int listArgc; - char **listArgv; - int i, match, mode, index; - - mode = GLOB; - if (argc == 4) { - if (strcmp(argv[1], "-exact") == 0) { - mode = EXACT; - } else if (strcmp(argv[1], "-glob") == 0) { - mode = GLOB; - } else if (strcmp(argv[1], "-regexp") == 0) { - mode = REGEXP; - } else { - Tcl_AppendResult(interp, "bad search mode \"", argv[1], - "\": must be -exact, -glob, or -regexp", (char *) NULL); - return TCL_ERROR; - } - } else if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?mode? list pattern\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_SplitList(interp, argv[argc-2], &listArgc, &listArgv) != TCL_OK) { - return TCL_ERROR; - } - index = -1; - for (i = 0; i < listArgc; i++) { - match = 0; - switch (mode) { - case EXACT: - match = (strcmp(listArgv[i], argv[argc-1]) == 0); - break; - case GLOB: - match = Tcl_StringMatch(listArgv[i], argv[argc-1]); - break; - case REGEXP: - match = Tcl_RegExpMatch(interp, listArgv[i], argv[argc-1]); - if (match < 0) { - ckfree((char *) listArgv); - return TCL_ERROR; - } - break; - } - if (match) { - index = i; - break; - } - } - sprintf(interp->result, "%d", index); - ckfree((char *) listArgv); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LsortCmd -- - * - * This procedure is invoked to process the "lsort" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LsortCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int listArgc, i, c; - size_t length; - char **listArgv; - char *command = NULL; /* Initialization needed only to - * prevent compiler warning. */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?-ascii? ?-integer? ?-real? ?-increasing? ?-decreasing?", - " ?-command string? list\"", (char *) NULL); - return TCL_ERROR; - } - - if (sortInterp != NULL) { - interp->result = "can't invoke \"lsort\" recursively"; - return TCL_ERROR; - } - - /* - * Parse arguments to set up the mode for the sort. - */ - - sortInterp = interp; - sortMode = ASCII; - sortIncreasing = 1; - sortCode = TCL_OK; - for (i = 1; i < argc-1; i++) { - length = strlen(argv[i]); - if (length < 2) { - badSwitch: - Tcl_AppendResult(interp, "bad switch \"", argv[i], - "\": must be -ascii, -integer, -real, -increasing", - " -decreasing, or -command", (char *) NULL); - sortCode = TCL_ERROR; - goto done; - } - c = argv[i][1]; - if ((c == 'a') && (strncmp(argv[i], "-ascii", length) == 0)) { - sortMode = ASCII; - } else if ((c == 'c') && (strncmp(argv[i], "-command", length) == 0)) { - if (i == argc-2) { - Tcl_AppendResult(interp, "\"-command\" must be", - " followed by comparison command", (char *) NULL); - sortCode = TCL_ERROR; - goto done; - } - sortMode = COMMAND; - command = argv[i+1]; - i++; - } else if ((c == 'd') - && (strncmp(argv[i], "-decreasing", length) == 0)) { - sortIncreasing = 0; - } else if ((c == 'i') && (length >= 4) - && (strncmp(argv[i], "-increasing", length) == 0)) { - sortIncreasing = 1; - } else if ((c == 'i') && (length >= 4) - && (strncmp(argv[i], "-integer", length) == 0)) { - sortMode = INTEGER; - } else if ((c == 'r') - && (strncmp(argv[i], "-real", length) == 0)) { - sortMode = REAL; - } else { - goto badSwitch; - } - } - if (sortMode == COMMAND) { - Tcl_DStringInit(&sortCmd); - Tcl_DStringAppend(&sortCmd, command, -1); - } - - if (Tcl_SplitList(interp, argv[argc-1], &listArgc, &listArgv) != TCL_OK) { - sortCode = TCL_ERROR; - goto done; - } - qsort((VOID *) listArgv, (size_t) listArgc, sizeof (char *), - SortCompareProc); - if (sortCode == TCL_OK) { - Tcl_ResetResult(interp); - interp->result = Tcl_Merge(listArgc, listArgv); - interp->freeProc = TCL_DYNAMIC; - } - if (sortMode == COMMAND) { - Tcl_DStringFree(&sortCmd); - } - ckfree((char *) listArgv); - - done: - sortInterp = NULL; - return sortCode; -} - -/* - *---------------------------------------------------------------------- - * - * SortCompareProc -- - * - * This procedure is invoked by qsort to determine the proper - * ordering between two elements. - * - * Results: - * < 0 means first is "smaller" than "second", > 0 means "first" - * is larger than "second", and 0 means they should be treated - * as equal. - * - * Side effects: - * None, unless a user-defined comparison command does something - * weird. - * - *---------------------------------------------------------------------- - */ - -static int -SortCompareProc(CONST VOID *first, CONST VOID *second) /* Elements to be compared. */ -{ - int order; - char *firstString = *((char **) first); - char *secondString = *((char **) second); - - order = 0; - if (sortCode != TCL_OK) { - /* - * Once an error has occurred, skip any future comparisons - * so as to preserve the error message in sortInterp->result. - */ - - return order; - } - if (sortMode == ASCII) { - order = strcmp(firstString, secondString); - } else if (sortMode == INTEGER) { - int a, b; - - if ((Tcl_GetInt(sortInterp, firstString, &a) != TCL_OK) - || (Tcl_GetInt(sortInterp, secondString, &b) != TCL_OK)) { - Tcl_AddErrorInfo(sortInterp, - "\n (converting list element from string to integer)"); - sortCode = TCL_ERROR; - return order; - } - if (a > b) { - order = 1; - } else if (b > a) { - order = -1; - } - } else if (sortMode == REAL) { - double a, b; - - if ((Tcl_GetDouble(sortInterp, firstString, &a) != TCL_OK) - || (Tcl_GetDouble(sortInterp, secondString, &b) != TCL_OK)) { - Tcl_AddErrorInfo(sortInterp, - "\n (converting list element from string to real)"); - sortCode = TCL_ERROR; - return order; - } - if (a > b) { - order = 1; - } else if (b > a) { - order = -1; - } - } else { - int oldLength; - char *end; - - /* - * Generate and evaluate a command to determine which string comes - * first. - */ - - oldLength = Tcl_DStringLength(&sortCmd); - Tcl_DStringAppendElement(&sortCmd, firstString); - Tcl_DStringAppendElement(&sortCmd, secondString); - sortCode = Tcl_Eval(sortInterp, Tcl_DStringValue(&sortCmd)); - Tcl_DStringTrunc(&sortCmd, oldLength); - if (sortCode != TCL_OK) { - Tcl_AddErrorInfo(sortInterp, - "\n (user-defined comparison command)"); - return order; - } - - /* - * Parse the result of the command. - */ - - order = strtol(sortInterp->result, &end, 0); - if ((end == sortInterp->result) || (*end != 0)) { - Tcl_ResetResult(sortInterp); - Tcl_AppendResult(sortInterp, - "comparison command returned non-numeric result", - (char *) NULL); - sortCode = TCL_ERROR; - return order; - } - } - if (!sortIncreasing) { - order = -order; - } - return order; -} diff --git a/cde/programs/dtdocbook/tcl/tclCmdMZ.c b/cde/programs/dtdocbook/tcl/tclCmdMZ.c deleted file mode 100644 index 574e7fb34..000000000 --- a/cde/programs/dtdocbook/tcl/tclCmdMZ.c +++ /dev/null @@ -1,2145 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclCmdMZ.c /main/3 1996/10/03 11:07:23 drk $ */ -/* - * tclCmdMZ.c -- - * - * This file contains the top-level command routines for most of - * the Tcl built-in commands whose names begin with the letters - * M to Z. It contains only commands in the generic core (i.e. - * those that don't depend much upon UNIX facilities). - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclCmdMZ.c 1.65 96/02/09 14:59:52 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * Structure used to hold information about variable traces: - */ - -typedef struct { - int flags; /* Operations for which Tcl command is - * to be invoked. */ - char *errMsg; /* Error message returned from Tcl command, - * or NULL. Malloc'ed. */ - int length; /* Number of non-NULL chars. in command. */ - char command[4]; /* Space for Tcl command to invoke. Actual - * size will be as large as necessary to - * hold command. This field must be the - * last in the structure, so that it can - * be larger than 4 bytes. */ -} TraceVarInfo; - -/* - * Forward declarations for procedures defined in this file: - */ - -static char * TraceVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_PwdCmd -- - * - * This procedure is invoked to process the "pwd" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_PwdCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *dirName; - - if (argc != 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], "\"", (char *) NULL); - return TCL_ERROR; - } - - dirName = TclGetCwd(interp); - if (dirName == NULL) { - return TCL_ERROR; - } - interp->result = dirName; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegexpCmd -- - * - * This procedure is invoked to process the "regexp" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_RegexpCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int noCase = 0; - int indices = 0; - Tcl_RegExp regExpr; - char **argPtr, *string, *pattern, *start, *end; - int match = 0; /* Initialization needed only to - * prevent compiler warning. */ - int i; - Tcl_DString stringDString, patternDString; - - if (argc < 3) { - wrongNumArgs: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?switches? exp string ?matchVar? ?subMatchVar ", - "subMatchVar ...?\"", (char *) NULL); - return TCL_ERROR; - } - argPtr = argv+1; - argc--; - while ((argc > 0) && (argPtr[0][0] == '-')) { - if (strcmp(argPtr[0], "-indices") == 0) { - indices = 1; - } else if (strcmp(argPtr[0], "-nocase") == 0) { - noCase = 1; - } else if (strcmp(argPtr[0], "--") == 0) { - argPtr++; - argc--; - break; - } else { - Tcl_AppendResult(interp, "bad switch \"", argPtr[0], - "\": must be -indices, -nocase, or --", (char *) NULL); - return TCL_ERROR; - } - argPtr++; - argc--; - } - if (argc < 2) { - goto wrongNumArgs; - } - - /* - * Convert the string and pattern to lower case, if desired, and - * perform the matching operation. - */ - - if (noCase) { - char *p; - - Tcl_DStringInit(&patternDString); - Tcl_DStringAppend(&patternDString, argPtr[0], -1); - pattern = Tcl_DStringValue(&patternDString); - for (p = pattern; *p != 0; p++) { - if (isupper(UCHAR(*p))) { - *p = (char)tolower(UCHAR(*p)); - } - } - Tcl_DStringInit(&stringDString); - Tcl_DStringAppend(&stringDString, argPtr[1], -1); - string = Tcl_DStringValue(&stringDString); - for (p = string; *p != 0; p++) { - if (isupper(UCHAR(*p))) { - *p = (char)tolower(UCHAR(*p)); - } - } - } else { - pattern = argPtr[0]; - string = argPtr[1]; - } - regExpr = Tcl_RegExpCompile(interp, pattern); - if (regExpr != NULL) { - match = Tcl_RegExpExec(interp, regExpr, string, string); - } - if (noCase) { - Tcl_DStringFree(&stringDString); - Tcl_DStringFree(&patternDString); - } - if (regExpr == NULL) { - return TCL_ERROR; - } - if (match < 0) { - return TCL_ERROR; - } - if (!match) { - interp->result = "0"; - return TCL_OK; - } - - /* - * If additional variable names have been specified, return - * index information in those variables. - */ - - argc -= 2; - for (i = 0; i < argc; i++) { - char *result, info[50]; - - Tcl_RegExpRange(regExpr, i, &start, &end); - if (start == NULL) { - if (indices) { - result = Tcl_SetVar(interp, argPtr[i+2], "-1 -1", 0); - } else { - result = Tcl_SetVar(interp, argPtr[i+2], "", 0); - } - } else { - if (indices) { - sprintf(info, "%d %d", (int)(start - string), - (int)(end - string - 1)); - result = Tcl_SetVar(interp, argPtr[i+2], info, 0); - } else { - char savedChar, *first, *last; - - first = argPtr[1] + (start - string); - last = argPtr[1] + (end - string); - savedChar = *last; - *last = 0; - result = Tcl_SetVar(interp, argPtr[i+2], first, 0); - *last = savedChar; - } - } - if (result == NULL) { - Tcl_AppendResult(interp, "couldn't set variable \"", - argPtr[i+2], "\"", (char *) NULL); - return TCL_ERROR; - } - } - interp->result = "1"; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegsubCmd -- - * - * This procedure is invoked to process the "regsub" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_RegsubCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int noCase = 0, all = 0; - Tcl_RegExp regExpr; - char *string, *pattern, *p, *firstChar, *newValue, **argPtr; - int match, flags, code, numMatches; - char *start, *end, *subStart, *subEnd; - char *src, c; - Tcl_DString stringDString, patternDString; - - if (argc < 5) { - wrongNumArgs: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?switches? exp string subSpec varName\"", (char *) NULL); - return TCL_ERROR; - } - argPtr = argv+1; - argc--; - while (argPtr[0][0] == '-') { - if (strcmp(argPtr[0], "-nocase") == 0) { - noCase = 1; - } else if (strcmp(argPtr[0], "-all") == 0) { - all = 1; - } else if (strcmp(argPtr[0], "--") == 0) { - argPtr++; - argc--; - break; - } else { - Tcl_AppendResult(interp, "bad switch \"", argPtr[0], - "\": must be -all, -nocase, or --", (char *) NULL); - return TCL_ERROR; - } - argPtr++; - argc--; - } - if (argc != 4) { - goto wrongNumArgs; - } - - /* - * Convert the string and pattern to lower case, if desired. - */ - - if (noCase) { - Tcl_DStringInit(&patternDString); - Tcl_DStringAppend(&patternDString, argPtr[0], -1); - pattern = Tcl_DStringValue(&patternDString); - for (p = pattern; *p != 0; p++) { - if (isupper(UCHAR(*p))) { - *p = (char)tolower(UCHAR(*p)); - } - } - Tcl_DStringInit(&stringDString); - Tcl_DStringAppend(&stringDString, argPtr[1], -1); - string = Tcl_DStringValue(&stringDString); - for (p = string; *p != 0; p++) { - if (isupper(UCHAR(*p))) { - *p = (char)tolower(UCHAR(*p)); - } - } - } else { - pattern = argPtr[0]; - string = argPtr[1]; - } - regExpr = Tcl_RegExpCompile(interp, pattern); - if (regExpr == NULL) { - code = TCL_ERROR; - goto done; - } - - /* - * The following loop is to handle multiple matches within the - * same source string; each iteration handles one match and its - * corresponding substitution. If "-all" hasn't been specified - * then the loop body only gets executed once. - */ - - flags = 0; - numMatches = 0; - for (p = string; *p != 0; ) { - match = Tcl_RegExpExec(interp, regExpr, p, string); - if (match < 0) { - code = TCL_ERROR; - goto done; - } - if (!match) { - break; - } - numMatches += 1; - - /* - * Copy the portion of the source string before the match to the - * result variable. - */ - - Tcl_RegExpRange(regExpr, 0, &start, &end); - src = argPtr[1] + (start - string); - c = *src; - *src = 0; - newValue = Tcl_SetVar(interp, argPtr[3], argPtr[1] + (p - string), - flags); - *src = c; - flags = TCL_APPEND_VALUE; - if (newValue == NULL) { - cantSet: - Tcl_AppendResult(interp, "couldn't set variable \"", - argPtr[3], "\"", (char *) NULL); - code = TCL_ERROR; - goto done; - } - - /* - * Append the subSpec argument to the variable, making appropriate - * substitutions. This code is a bit hairy because of the backslash - * conventions and because the code saves up ranges of characters in - * subSpec to reduce the number of calls to Tcl_SetVar. - */ - - for (src = firstChar = argPtr[2], c = *src; c != 0; src++, c = *src) { - int index; - - if (c == '&') { - index = 0; - } else if (c == '\\') { - c = src[1]; - if ((c >= '0') && (c <= '9')) { - index = c - '0'; - } else if ((c == '\\') || (c == '&')) { - *src = c; - src[1] = 0; - newValue = Tcl_SetVar(interp, argPtr[3], firstChar, - TCL_APPEND_VALUE); - *src = '\\'; - src[1] = c; - if (newValue == NULL) { - goto cantSet; - } - firstChar = src+2; - src++; - continue; - } else { - continue; - } - } else { - continue; - } - if (firstChar != src) { - c = *src; - *src = 0; - newValue = Tcl_SetVar(interp, argPtr[3], firstChar, - TCL_APPEND_VALUE); - *src = c; - if (newValue == NULL) { - goto cantSet; - } - } - Tcl_RegExpRange(regExpr, index, &subStart, &subEnd); - if ((subStart != NULL) && (subEnd != NULL)) { - char *first, *last, saved; - - first = argPtr[1] + (subStart - string); - last = argPtr[1] + (subEnd - string); - saved = *last; - *last = 0; - newValue = Tcl_SetVar(interp, argPtr[3], first, - TCL_APPEND_VALUE); - *last = saved; - if (newValue == NULL) { - goto cantSet; - } - } - if (*src == '\\') { - src++; - } - firstChar = src+1; - } - if (firstChar != src) { - if (Tcl_SetVar(interp, argPtr[3], firstChar, - TCL_APPEND_VALUE) == NULL) { - goto cantSet; - } - } - if (end == p) { - char tmp[2]; - - /* - * Always consume at least one character of the input string - * in order to prevent infinite loops. - */ - - tmp[0] = argPtr[1][p - string]; - tmp[1] = 0; - newValue = Tcl_SetVar(interp, argPtr[3], tmp, flags); - if (newValue == NULL) { - goto cantSet; - } - p = end + 1; - } else { - p = end; - } - if (!all) { - break; - } - } - - /* - * Copy the portion of the source string after the last match to the - * result variable. - */ - - if ((*p != 0) || (numMatches == 0)) { - if (Tcl_SetVar(interp, argPtr[3], argPtr[1] + (p - string), - flags) == NULL) { - goto cantSet; - } - } - sprintf(interp->result, "%d", numMatches); - code = TCL_OK; - - done: - if (noCase) { - Tcl_DStringFree(&stringDString); - Tcl_DStringFree(&patternDString); - } - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RenameCmd -- - * - * This procedure is invoked to process the "rename" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_RenameCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Command *cmdPtr; - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr; - int new; - char *srcName, *dstName; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " oldName newName\"", (char *) NULL); - return TCL_ERROR; - } - if (argv[2][0] == '\0') { - if (Tcl_DeleteCommand(interp, argv[1]) != 0) { - Tcl_AppendResult(interp, "can't delete \"", argv[1], - "\": command doesn't exist", (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; - } - - srcName = argv[1]; - dstName = argv[2]; - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, dstName); - if (hPtr != NULL) { - Tcl_AppendResult(interp, "can't rename to \"", argv[2], - "\": command already exists", (char *) NULL); - return TCL_ERROR; - } - - /* - * The code below was added in 11/95 to preserve backwards compatibility - * when "tkerror" was renamed "bgerror": we guarantee that the hash - * table entries for both commands refer to a single shared Command - * structure. This code should eventually become unnecessary. - */ - - if ((srcName[0] == 't') && (strcmp(srcName, "tkerror") == 0)) { - srcName = "bgerror"; - } - dstName = argv[2]; - if ((dstName[0] == 't') && (strcmp(dstName, "tkerror") == 0)) { - dstName = "bgerror"; - } - - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, srcName); - if (hPtr == NULL) { - Tcl_AppendResult(interp, "can't rename \"", argv[1], - "\": command doesn't exist", (char *) NULL); - return TCL_ERROR; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - - /* - * Prevent formation of alias loops through renaming. - */ - - if (TclPreventAliasLoop(interp, interp, dstName, cmdPtr->proc, - cmdPtr->clientData) != TCL_OK) { - return TCL_ERROR; - } - - Tcl_DeleteHashEntry(hPtr); - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, dstName, &new); - Tcl_SetHashValue(hPtr, cmdPtr); - cmdPtr->hPtr = hPtr; - - /* - * The code below provides more backwards compatibility for the - * "tkerror" => "bgerror" renaming. As with the other compatibility - * code above, it should eventually be removed. - */ - - if ((dstName[0] == 'b') && (strcmp(dstName, "bgerror") == 0)) { - /* - * The destination command is "bgerror"; create a "tkerror" - * command that shares the same Command structure. - */ - - hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, "tkerror", &new); - Tcl_SetHashValue(hPtr, cmdPtr); - } - if ((srcName[0] == 'b') && (strcmp(srcName, "bgerror") == 0)) { - /* - * The source command is "bgerror": delete the hash table - * entry for "tkerror" if it exists. - */ - - Tcl_DeleteHashEntry(Tcl_FindHashEntry(&iPtr->commandTable, "tkerror")); - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ReturnCmd -- - * - * This procedure is invoked to process the "return" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ReturnCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - int c, code; - - if (iPtr->errorInfo != NULL) { - ckfree(iPtr->errorInfo); - iPtr->errorInfo = NULL; - } - if (iPtr->errorCode != NULL) { - ckfree(iPtr->errorCode); - iPtr->errorCode = NULL; - } - code = TCL_OK; - for (argv++, argc--; argc > 1; argv += 2, argc -= 2) { - if (strcmp(argv[0], "-code") == 0) { - c = argv[1][0]; - if ((c == 'o') && (strcmp(argv[1], "ok") == 0)) { - code = TCL_OK; - } else if ((c == 'e') && (strcmp(argv[1], "error") == 0)) { - code = TCL_ERROR; - } else if ((c == 'r') && (strcmp(argv[1], "return") == 0)) { - code = TCL_RETURN; - } else if ((c == 'b') && (strcmp(argv[1], "break") == 0)) { - code = TCL_BREAK; - } else if ((c == 'c') && (strcmp(argv[1], "continue") == 0)) { - code = TCL_CONTINUE; - } else if (Tcl_GetInt(interp, argv[1], &code) != TCL_OK) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad completion code \"", - argv[1], "\": must be ok, error, return, break, ", - "continue, or an integer", (char *) NULL); - return TCL_ERROR; - } - } else if (strcmp(argv[0], "-errorinfo") == 0) { - iPtr->errorInfo = (char *) ckalloc((unsigned) (strlen(argv[1]) + 1)); - strcpy(iPtr->errorInfo, argv[1]); - } else if (strcmp(argv[0], "-errorcode") == 0) { - iPtr->errorCode = (char *) ckalloc((unsigned) (strlen(argv[1]) + 1)); - strcpy(iPtr->errorCode, argv[1]); - } else { - Tcl_AppendResult(interp, "bad option \"", argv[0], - ": must be -code, -errorcode, or -errorinfo", - (char *) NULL); - return TCL_ERROR; - } - } - if (argc == 1) { - Tcl_SetResult(interp, argv[0], TCL_VOLATILE); - } - iPtr->returnCode = code; - return TCL_RETURN; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ScanCmd -- - * - * This procedure is invoked to process the "scan" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ScanCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ -# define MAX_FIELDS 20 - typedef struct { - char fmt; /* Format for field. */ - int size; /* How many bytes to allow for - * field. */ - char *location; /* Where field will be stored. */ - } Field; - Field fields[MAX_FIELDS]; /* Info about all the fields in the - * format string. */ - Field *curField; - int numFields = 0; /* Number of fields actually - * specified. */ - int suppress; /* Current field is assignment- - * suppressed. */ - int totalSize = 0; /* Number of bytes needed to store - * all results combined. */ - char *results; /* Where scanned output goes. - * Malloced; NULL means not allocated - * yet. */ - int numScanned; /* sscanf's result. */ - char *fmt; - int i, widthSpecified, length, code; - - /* - * The variables below are used to hold a copy of the format - * string, so that we can replace format specifiers like "%f" - * and "%F" with specifiers like "%lf" - */ - -# define STATIC_SIZE 5 - char copyBuf[STATIC_SIZE], *fmtCopy; - char *dst; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " string format ?varName varName ...?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * This procedure operates in four stages: - * 1. Scan the format string, collecting information about each field. - * 2. Allocate an array to hold all of the scanned fields. - * 3. Call sscanf to do all the dirty work, and have it store the - * parsed fields in the array. - * 4. Pick off the fields from the array and assign them to variables. - */ - - code = TCL_OK; - results = NULL; - length = strlen(argv[2]) * 2 + 1; - if (length < STATIC_SIZE) { - fmtCopy = copyBuf; - } else { - fmtCopy = (char *) ckalloc((unsigned) length); - } - dst = fmtCopy; - for (fmt = argv[2]; *fmt != 0; fmt++) { - *dst = *fmt; - dst++; - if (*fmt != '%') { - continue; - } - fmt++; - if (*fmt == '%') { - *dst = *fmt; - dst++; - continue; - } - if (*fmt == '*') { - suppress = 1; - *dst = *fmt; - dst++; - fmt++; - } else { - suppress = 0; - } - widthSpecified = 0; - while (isdigit(UCHAR(*fmt))) { - widthSpecified = 1; - *dst = *fmt; - dst++; - fmt++; - } - if ((*fmt == 'l') || (*fmt == 'h') || (*fmt == 'L')) { - fmt++; - } - *dst = *fmt; - dst++; - if (suppress) { - continue; - } - if (numFields == MAX_FIELDS) { - interp->result = "too many fields to scan"; - code = TCL_ERROR; - goto done; - } - curField = &fields[numFields]; - numFields++; - switch (*fmt) { - case 'd': - case 'i': - case 'o': - case 'x': - curField->fmt = 'd'; - curField->size = sizeof(int); - break; - - case 'u': - curField->fmt = 'u'; - curField->size = sizeof(int); - break; - - case 's': - curField->fmt = 's'; - curField->size = strlen(argv[1]) + 1; - break; - - case 'c': - if (widthSpecified) { - interp->result = - "field width may not be specified in %c conversion"; - code = TCL_ERROR; - goto done; - } - curField->fmt = 'c'; - curField->size = sizeof(int); - break; - - case 'e': - case 'f': - case 'g': - dst[-1] = 'l'; - dst[0] = 'f'; - dst++; - curField->fmt = 'f'; - curField->size = sizeof(double); - break; - - case '[': - curField->fmt = 's'; - curField->size = strlen(argv[1]) + 1; - do { - fmt++; - if (*fmt == 0) { - interp->result = "unmatched [ in format string"; - code = TCL_ERROR; - goto done; - } - *dst = *fmt; - dst++; - } while (*fmt != ']'); - break; - - default: - sprintf(interp->result, "bad scan conversion character \"%c\"", - *fmt); - code = TCL_ERROR; - goto done; - } - curField->size = TCL_ALIGN(curField->size); - totalSize += curField->size; - } - *dst = 0; - - if (numFields != (argc-3)) { - interp->result = - "different numbers of variable names and field specifiers"; - code = TCL_ERROR; - goto done; - } - - /* - * Step 2: - */ - - results = (char *) ckalloc((unsigned) totalSize); - for (i = 0, totalSize = 0, curField = fields; - i < numFields; i++, curField++) { - curField->location = results + totalSize; - totalSize += curField->size; - } - - /* - * Fill in the remaining fields with NULL; the only purpose of - * this is to keep some memory analyzers, like Purify, from - * complaining. - */ - - for ( ; i < MAX_FIELDS; i++, curField++) { - curField->location = NULL; - } - - /* - * Step 3: - */ - - numScanned = sscanf(argv[1], fmtCopy, - fields[0].location, fields[1].location, fields[2].location, - fields[3].location, fields[4].location, fields[5].location, - fields[6].location, fields[7].location, fields[8].location, - fields[9].location, fields[10].location, fields[11].location, - fields[12].location, fields[13].location, fields[14].location, - fields[15].location, fields[16].location, fields[17].location, - fields[18].location, fields[19].location); - - /* - * Step 4: - */ - - if (numScanned < numFields) { - numFields = numScanned; - } - for (i = 0, curField = fields; i < numFields; i++, curField++) { - switch (curField->fmt) { - char string[TCL_DOUBLE_SPACE]; - - case 'd': - sprintf(string, "%d", *((int *) curField->location)); - if (Tcl_SetVar(interp, argv[i+3], string, 0) == NULL) { - storeError: - Tcl_AppendResult(interp, - "couldn't set variable \"", argv[i+3], "\"", - (char *) NULL); - code = TCL_ERROR; - goto done; - } - break; - - case 'u': - sprintf(string, "%u", *((int *) curField->location)); - if (Tcl_SetVar(interp, argv[i+3], string, 0) == NULL) { - goto storeError; - } - break; - - case 'c': - sprintf(string, "%d", *((char *) curField->location) & 0xff); - if (Tcl_SetVar(interp, argv[i+3], string, 0) == NULL) { - goto storeError; - } - break; - - case 's': - if (Tcl_SetVar(interp, argv[i+3], curField->location, 0) - == NULL) { - goto storeError; - } - break; - - case 'f': - Tcl_PrintDouble(interp, *((double *) curField->location), - string); - if (Tcl_SetVar(interp, argv[i+3], string, 0) == NULL) { - goto storeError; - } - break; - } - } - sprintf(interp->result, "%d", numScanned); - done: - if (results != NULL) { - ckfree(results); - } - if (fmtCopy != copyBuf) { - ckfree(fmtCopy); - } - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SourceCmd -- - * - * This procedure is invoked to process the "source" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SourceCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " fileName\"", (char *) NULL); - return TCL_ERROR; - } - return Tcl_EvalFile(interp, argv[1]); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SplitCmd -- - * - * This procedure is invoked to process the "split" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SplitCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - char *splitChars; - char *p, *p2; - char *elementStart; - - if (argc == 2) { - splitChars = " \n\t\r"; - } else if (argc == 3) { - splitChars = argv[2]; - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " string ?splitChars?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Handle the special case of splitting on every character. - */ - - if (*splitChars == 0) { - char string[2]; - string[1] = 0; - for (p = argv[1]; *p != 0; p++) { - string[0] = *p; - Tcl_AppendElement(interp, string); - } - return TCL_OK; - } - - /* - * Normal case: split on any of a given set of characters. - * Discard instances of the split characters. - */ - - for (p = elementStart = argv[1]; *p != 0; p++) { - char c = *p; - for (p2 = splitChars; *p2 != 0; p2++) { - if (*p2 == c) { - *p = 0; - Tcl_AppendElement(interp, elementStart); - *p = c; - elementStart = p+1; - break; - } - } - } - if (p != argv[1]) { - Tcl_AppendElement(interp, elementStart); - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_StringCmd -- - * - * This procedure is invoked to process the "string" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_StringCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - size_t length; - char *p; - int match, c, first; - int left = 0, right = 0; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'c') && (strncmp(argv[1], "compare", length) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " compare string1 string2\"", (char *) NULL); - return TCL_ERROR; - } - match = strcmp(argv[2], argv[3]); - if (match > 0) { - interp->result = "1"; - } else if (match < 0) { - interp->result = "-1"; - } else { - interp->result = "0"; - } - return TCL_OK; - } else if ((c == 'f') && (strncmp(argv[1], "first", length) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " first string1 string2\"", (char *) NULL); - return TCL_ERROR; - } - first = 1; - - firstLast: - match = -1; - c = *argv[2]; - length = strlen(argv[2]); - for (p = argv[3]; *p != 0; p++) { - if (*p != c) { - continue; - } - if (strncmp(argv[2], p, length) == 0) { - match = p-argv[3]; - if (first) { - break; - } - } - } - sprintf(interp->result, "%d", match); - return TCL_OK; - } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)) { - int index; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " index string charIndex\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[3], &index) != TCL_OK) { - return TCL_ERROR; - } - if ((index >= 0) && (index < (int) strlen(argv[2]))) { - interp->result[0] = argv[2][index]; - interp->result[1] = 0; - } - return TCL_OK; - } else if ((c == 'l') && (strncmp(argv[1], "last", length) == 0) - && (length >= 2)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " last string1 string2\"", (char *) NULL); - return TCL_ERROR; - } - first = 0; - goto firstLast; - } else if ((c == 'l') && (strncmp(argv[1], "length", length) == 0) - && (length >= 2)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " length string\"", (char *) NULL); - return TCL_ERROR; - } - sprintf(interp->result, "%ld", (long)strlen(argv[2])); - return TCL_OK; - } else if ((c == 'm') && (strncmp(argv[1], "match", length) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " match pattern string\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_StringMatch(argv[3], argv[2]) != 0) { - interp->result = "1"; - } else { - interp->result = "0"; - } - return TCL_OK; - } else if ((c == 'r') && (strncmp(argv[1], "range", length) == 0)) { - int first, last, stringLength; - - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " range string first last\"", (char *) NULL); - return TCL_ERROR; - } - stringLength = strlen(argv[2]); - if (Tcl_GetInt(interp, argv[3], &first) != TCL_OK) { - return TCL_ERROR; - } - if ((*argv[4] == 'e') - && (strncmp(argv[4], "end", strlen(argv[4])) == 0)) { - last = stringLength-1; - } else { - if (Tcl_GetInt(interp, argv[4], &last) != TCL_OK) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, - "expected integer or \"end\" but got \"", - argv[4], "\"", (char *) NULL); - return TCL_ERROR; - } - } - if (first < 0) { - first = 0; - } - if (last >= stringLength) { - last = stringLength-1; - } - if (last >= first) { - char saved, *p; - - p = argv[2] + last + 1; - saved = *p; - *p = 0; - Tcl_SetResult(interp, argv[2] + first, TCL_VOLATILE); - *p = saved; - } - return TCL_OK; - } else if ((c == 't') && (strncmp(argv[1], "tolower", length) == 0) - && (length >= 3)) { - char *p; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " tolower string\"", (char *) NULL); - return TCL_ERROR; - } - Tcl_SetResult(interp, argv[2], TCL_VOLATILE); - for (p = interp->result; *p != 0; p++) { - if (isupper(UCHAR(*p))) { - *p = (char)tolower(UCHAR(*p)); - } - } - return TCL_OK; - } else if ((c == 't') && (strncmp(argv[1], "toupper", length) == 0) - && (length >= 3)) { - char *p; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " toupper string\"", (char *) NULL); - return TCL_ERROR; - } - Tcl_SetResult(interp, argv[2], TCL_VOLATILE); - for (p = interp->result; *p != 0; p++) { - if (islower(UCHAR(*p))) { - *p = (char) toupper(UCHAR(*p)); - } - } - return TCL_OK; - } else if ((c == 't') && (strncmp(argv[1], "trim", length) == 0) - && (length == 4)) { - char *trimChars; - char *p, *checkPtr; - - left = right = 1; - - trim: - if (argc == 4) { - trimChars = argv[3]; - } else if (argc == 3) { - trimChars = " \t\n\r"; - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " string ?chars?\"", (char *) NULL); - return TCL_ERROR; - } - p = argv[2]; - if (left) { - for (c = *p; c != 0; p++, c = *p) { - for (checkPtr = trimChars; *checkPtr != c; checkPtr++) { - if (*checkPtr == 0) { - goto doneLeft; - } - } - } - } - doneLeft: - Tcl_SetResult(interp, p, TCL_VOLATILE); - if (right) { - char *donePtr; - - p = interp->result + strlen(interp->result) - 1; - donePtr = &interp->result[-1]; - for (c = *p; p != donePtr; p--, c = *p) { - for (checkPtr = trimChars; *checkPtr != c; checkPtr++) { - if (*checkPtr == 0) { - goto doneRight; - } - } - } - doneRight: - p[1] = 0; - } - return TCL_OK; - } else if ((c == 't') && (strncmp(argv[1], "trimleft", length) == 0) - && (length > 4)) { - left = 1; - argv[1] = "trimleft"; - goto trim; - } else if ((c == 't') && (strncmp(argv[1], "trimright", length) == 0) - && (length > 4)) { - right = 1; - argv[1] = "trimright"; - goto trim; - } else if ((c == 'w') && (strncmp(argv[1], "wordend", length) == 0) - && (length > 4)) { - int length, index, cur; - char *string; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " string index\"", (char *) NULL); - return TCL_ERROR; - } - string = argv[2]; - if (Tcl_GetInt(interp, argv[3], &index) != TCL_OK) { - return TCL_ERROR; - } - length = strlen(argv[2]); - if (index < 0) { - index = 0; - } - if (index >= length) { - cur = length; - goto wordendDone; - } - for (cur = index ; cur < length; cur++) { - c = UCHAR(string[cur]); - if (!isalnum(c) && (c != '_')) { - break; - } - } - if (cur == index) { - cur = index+1; - } - wordendDone: - sprintf(interp->result, "%d", cur); - return TCL_OK; - } else if ((c == 'w') && (strncmp(argv[1], "wordstart", length) == 0) - && (length > 4)) { - int length, index, cur; - char *string; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " string index\"", (char *) NULL); - return TCL_ERROR; - } - string = argv[2]; - if (Tcl_GetInt(interp, argv[3], &index) != TCL_OK) { - return TCL_ERROR; - } - length = strlen(argv[2]); - if (index >= length) { - index = length-1; - } - if (index <= 0) { - cur = 0; - goto wordstartDone; - } - for (cur = index ; cur >= 0; cur--) { - c = UCHAR(string[cur]); - if (!isalnum(c) && (c != '_')) { - break; - } - } - if (cur != index) { - cur += 1; - } - wordstartDone: - sprintf(interp->result, "%d", cur); - return TCL_OK; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be compare, first, index, last, length, match, ", - "range, tolower, toupper, trim, trimleft, trimright, ", - "wordend, or wordstart", (char *) NULL); - return TCL_ERROR; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SubstCmd -- - * - * This procedure is invoked to process the "subst" Tcl command. - * See the user documentation for details on what it does. This - * command is an almost direct copy of an implementation by - * Andrew Payne. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SubstCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_DString result; - char *p, *old, *value; - int code, count, doVars, doCmds, doBackslashes, i; - size_t length; - char c; - - /* - * Parse command-line options. - */ - - doVars = doCmds = doBackslashes = 1; - for (i = 1; i < (argc-1); i++) { - p = argv[i]; - if (*p != '-') { - break; - } - length = strlen(p); - if (length < 4) { - badSwitch: - Tcl_AppendResult(interp, "bad switch \"", p, - "\": must be -nobackslashes, -nocommands, ", - "or -novariables", (char *) NULL); - return TCL_ERROR; - } - if ((p[3] == 'b') && (strncmp(p, "-nobackslashes", length) == 0)) { - doBackslashes = 0; - } else if ((p[3] == 'c') && (strncmp(p, "-nocommands", length) == 0)) { - doCmds = 0; - } else if ((p[3] == 'v') && (strncmp(p, "-novariables", length) == 0)) { - doVars = 0; - } else { - goto badSwitch; - } - } - if (i != (argc-1)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?-nobackslashes? ?-nocommands? ?-novariables? string\"", - (char *) NULL); - return TCL_ERROR; - } - - /* - * Scan through the string one character at a time, performing - * command, variable, and backslash substitutions. - */ - - Tcl_DStringInit(&result); - old = p = argv[i]; - while (*p != 0) { - switch (*p) { - case '\\': - if (doBackslashes) { - if (p != old) { - Tcl_DStringAppend(&result, old, p-old); - } - c = Tcl_Backslash(p, &count); - Tcl_DStringAppend(&result, &c, 1); - p += count; - old = p; - } else { - p++; - } - break; - - case '$': - if (doVars) { - if (p != old) { - Tcl_DStringAppend(&result, old, p-old); - } - value = Tcl_ParseVar(interp, p, &p); - if (value == NULL) { - Tcl_DStringFree(&result); - return TCL_ERROR; - } - Tcl_DStringAppend(&result, value, -1); - old = p; - } else { - p++; - } - break; - - case '[': - if (doCmds) { - if (p != old) { - Tcl_DStringAppend(&result, old, p-old); - } - iPtr->evalFlags = TCL_BRACKET_TERM; - code = Tcl_Eval(interp, p+1); - if (code == TCL_ERROR) { - Tcl_DStringFree(&result); - return code; - } - old = p = iPtr->termPtr+1; - Tcl_DStringAppend(&result, iPtr->result, -1); - Tcl_ResetResult(interp); - } else { - p++; - } - break; - - default: - p++; - break; - } - } - if (p != old) { - Tcl_DStringAppend(&result, old, p-old); - } - Tcl_DStringResult(interp, &result); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SwitchCmd -- - * - * This procedure is invoked to process the "switch" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SwitchCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ -#define EXACT 0 -#define GLOB 1 -#define REGEXP 2 - int i, code, mode, matched; - int body; - char *string; - int switchArgc, splitArgs; - char **switchArgv; - - switchArgc = argc-1; - switchArgv = argv+1; - mode = EXACT; - while ((switchArgc > 0) && (*switchArgv[0] == '-')) { - if (strcmp(*switchArgv, "-exact") == 0) { - mode = EXACT; - } else if (strcmp(*switchArgv, "-glob") == 0) { - mode = GLOB; - } else if (strcmp(*switchArgv, "-regexp") == 0) { - mode = REGEXP; - } else if (strcmp(*switchArgv, "--") == 0) { - switchArgc--; - switchArgv++; - break; - } else { - Tcl_AppendResult(interp, "bad option \"", switchArgv[0], - "\": should be -exact, -glob, -regexp, or --", - (char *) NULL); - return TCL_ERROR; - } - switchArgc--; - switchArgv++; - } - if (switchArgc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ?switches? string pattern body ... ?default body?\"", - (char *) NULL); - return TCL_ERROR; - } - string = *switchArgv; - switchArgc--; - switchArgv++; - - /* - * If all of the pattern/command pairs are lumped into a single - * argument, split them out again. - */ - - splitArgs = 0; - if (switchArgc == 1) { - code = Tcl_SplitList(interp, switchArgv[0], &switchArgc, &switchArgv); - if (code != TCL_OK) { - return code; - } - splitArgs = 1; - } - - for (i = 0; i < switchArgc; i += 2) { - if (i == (switchArgc-1)) { - interp->result = "extra switch pattern with no body"; - code = TCL_ERROR; - goto cleanup; - } - - /* - * See if the pattern matches the string. - */ - - matched = 0; - if ((*switchArgv[i] == 'd') && (i == switchArgc-2) - && (strcmp(switchArgv[i], "default") == 0)) { - matched = 1; - } else { - switch (mode) { - case EXACT: - matched = (strcmp(string, switchArgv[i]) == 0); - break; - case GLOB: - matched = Tcl_StringMatch(string, switchArgv[i]); - break; - case REGEXP: - matched = Tcl_RegExpMatch(interp, string, switchArgv[i]); - if (matched < 0) { - code = TCL_ERROR; - goto cleanup; - } - break; - } - } - if (!matched) { - continue; - } - - /* - * We've got a match. Find a body to execute, skipping bodies - * that are "-". - */ - - for (body = i+1; ; body += 2) { - if (body >= switchArgc) { - Tcl_AppendResult(interp, "no body specified for pattern \"", - switchArgv[i], "\"", (char *) NULL); - code = TCL_ERROR; - goto cleanup; - } - if ((switchArgv[body][0] != '-') || (switchArgv[body][1] != 0)) { - break; - } - } - code = Tcl_Eval(interp, switchArgv[body]); - if (code == TCL_ERROR) { - char msg[100]; - sprintf(msg, "\n (\"%.50s\" arm line %d)", switchArgv[i], - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - goto cleanup; - } - - /* - * Nothing matched: return nothing. - */ - - code = TCL_OK; - - cleanup: - if (splitArgs) { - ckfree((char *) switchArgv); - } - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TimeCmd -- - * - * This procedure is invoked to process the "time" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_TimeCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int count, i, result; - double timePer; - Tcl_Time start, stop; - - if (argc == 2) { - count = 1; - } else if (argc == 3) { - if (Tcl_GetInt(interp, argv[2], &count) != TCL_OK) { - return TCL_ERROR; - } - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " command ?count?\"", (char *) NULL); - return TCL_ERROR; - } - TclGetTime(&start); - for (i = count ; i > 0; i--) { - result = Tcl_Eval(interp, argv[1]); - if (result != TCL_OK) { - if (result == TCL_ERROR) { - char msg[60]; - sprintf(msg, "\n (\"time\" body line %d)", - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - return result; - } - } - TclGetTime(&stop); - timePer = (stop.sec - start.sec)*1000000 + (stop.usec - start.usec); - Tcl_ResetResult(interp); - sprintf(interp->result, "%.0f microseconds per iteration", - (count <= 0) ? 0 : timePer/count); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TraceCmd -- - * - * This procedure is invoked to process the "trace" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_TraceCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int c; - size_t length; - - if (argc < 2) { - Tcl_AppendResult(interp, "too few args: should be \"", - argv[0], " option [arg arg ...]\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][1]; - length = strlen(argv[1]); - if ((c == 'a') && (strncmp(argv[1], "variable", length) == 0) - && (length >= 2)) { - char *p; - int flags, length; - TraceVarInfo *tvarPtr; - - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " variable name ops command\"", (char *) NULL); - return TCL_ERROR; - } - - flags = 0; - for (p = argv[3] ; *p != 0; p++) { - if (*p == 'r') { - flags |= TCL_TRACE_READS; - } else if (*p == 'w') { - flags |= TCL_TRACE_WRITES; - } else if (*p == 'u') { - flags |= TCL_TRACE_UNSETS; - } else { - goto badOps; - } - } - if (flags == 0) { - goto badOps; - } - - length = strlen(argv[4]); - tvarPtr = (TraceVarInfo *) ckalloc((unsigned) - (sizeof(TraceVarInfo) - sizeof(tvarPtr->command) + length + 1)); - tvarPtr->flags = flags; - tvarPtr->errMsg = NULL; - tvarPtr->length = length; - flags |= TCL_TRACE_UNSETS; - strcpy(tvarPtr->command, argv[4]); - if (Tcl_TraceVar(interp, argv[2], flags, TraceVarProc, - (ClientData) tvarPtr) != TCL_OK) { - ckfree((char *) tvarPtr); - return TCL_ERROR; - } - } else if ((c == 'd') && (strncmp(argv[1], "vdelete", length) - && (length >= 2)) == 0) { - char *p; - int flags, length; - TraceVarInfo *tvarPtr; - ClientData clientData; - - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " vdelete name ops command\"", (char *) NULL); - return TCL_ERROR; - } - - flags = 0; - for (p = argv[3] ; *p != 0; p++) { - if (*p == 'r') { - flags |= TCL_TRACE_READS; - } else if (*p == 'w') { - flags |= TCL_TRACE_WRITES; - } else if (*p == 'u') { - flags |= TCL_TRACE_UNSETS; - } else { - goto badOps; - } - } - if (flags == 0) { - goto badOps; - } - - /* - * Search through all of our traces on this variable to - * see if there's one with the given command. If so, then - * delete the first one that matches. - */ - - length = strlen(argv[4]); - clientData = 0; - while ((clientData = Tcl_VarTraceInfo(interp, argv[2], 0, - TraceVarProc, clientData)) != 0) { - tvarPtr = (TraceVarInfo *) clientData; - if ((tvarPtr->length == length) && (tvarPtr->flags == flags) - && (strncmp(argv[4], tvarPtr->command, - (size_t) length) == 0)) { - Tcl_UntraceVar(interp, argv[2], flags | TCL_TRACE_UNSETS, - TraceVarProc, clientData); - if (tvarPtr->errMsg != NULL) { - ckfree(tvarPtr->errMsg); - } - ckfree((char *) tvarPtr); - break; - } - } - } else if ((c == 'i') && (strncmp(argv[1], "vinfo", length) == 0) - && (length >= 2)) { - ClientData clientData; - char ops[4], *p; - char *prefix = "{"; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " vinfo name\"", (char *) NULL); - return TCL_ERROR; - } - clientData = 0; - while ((clientData = Tcl_VarTraceInfo(interp, argv[2], 0, - TraceVarProc, clientData)) != 0) { - TraceVarInfo *tvarPtr = (TraceVarInfo *) clientData; - p = ops; - if (tvarPtr->flags & TCL_TRACE_READS) { - *p = 'r'; - p++; - } - if (tvarPtr->flags & TCL_TRACE_WRITES) { - *p = 'w'; - p++; - } - if (tvarPtr->flags & TCL_TRACE_UNSETS) { - *p = 'u'; - p++; - } - *p = '\0'; - Tcl_AppendResult(interp, prefix, (char *) NULL); - Tcl_AppendElement(interp, ops); - Tcl_AppendElement(interp, tvarPtr->command); - Tcl_AppendResult(interp, "}", (char *) NULL); - prefix = " {"; - } - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be variable, vdelete, or vinfo", - (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; - - badOps: - Tcl_AppendResult(interp, "bad operations \"", argv[3], - "\": should be one or more of rwu", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * TraceVarProc -- - * - * This procedure is called to handle variable accesses that have - * been traced using the "trace" command. - * - * Results: - * Normally returns NULL. If the trace command returns an error, - * then this procedure returns an error string. - * - * Side effects: - * Depends on the command associated with the trace. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static char * -TraceVarProc( - ClientData clientData, /* Information about the variable trace. */ - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *name1, /* Name of variable or array. */ - char *name2, /* Name of element within array; NULL means - * scalar variable is being referenced. */ - int flags /* OR-ed bits giving operation and other - * information. */ -) -{ - TraceVarInfo *tvarPtr = (TraceVarInfo *) clientData; - char *result; - int code; - Interp dummy; - Tcl_DString cmd; - - result = NULL; - if (tvarPtr->errMsg != NULL) { - ckfree(tvarPtr->errMsg); - tvarPtr->errMsg = NULL; - } - if ((tvarPtr->flags & flags) && !(flags & TCL_INTERP_DESTROYED)) { - - /* - * Generate a command to execute by appending list elements - * for the two variable names and the operation. The five - * extra characters are for three space, the opcode character, - * and the terminating null. - */ - - if (name2 == NULL) { - name2 = ""; - } - Tcl_DStringInit(&cmd); - Tcl_DStringAppend(&cmd, tvarPtr->command, tvarPtr->length); - Tcl_DStringAppendElement(&cmd, name1); - Tcl_DStringAppendElement(&cmd, name2); - if (flags & TCL_TRACE_READS) { - Tcl_DStringAppend(&cmd, " r", 2); - } else if (flags & TCL_TRACE_WRITES) { - Tcl_DStringAppend(&cmd, " w", 2); - } else if (flags & TCL_TRACE_UNSETS) { - Tcl_DStringAppend(&cmd, " u", 2); - } - - /* - * Execute the command. Be careful to save and restore the - * result from the interpreter used for the command. - */ - - if (interp->freeProc == 0) { - dummy.freeProc = (Tcl_FreeProc *) 0; - dummy.result = ""; - Tcl_SetResult((Tcl_Interp *) &dummy, interp->result, TCL_VOLATILE); - } else { - dummy.freeProc = interp->freeProc; - dummy.result = interp->result; - interp->freeProc = (Tcl_FreeProc *) 0; - } - code = Tcl_Eval(interp, Tcl_DStringValue(&cmd)); - Tcl_DStringFree(&cmd); - if (code != TCL_OK) { - tvarPtr->errMsg = (char *) ckalloc((unsigned) (strlen(interp->result) + 1)); - strcpy(tvarPtr->errMsg, interp->result); - result = tvarPtr->errMsg; - Tcl_ResetResult(interp); /* Must clear error state. */ - } - Tcl_SetResult(interp, dummy.result, - (dummy.freeProc == 0) ? TCL_VOLATILE : dummy.freeProc); - } - if (flags & TCL_TRACE_DESTROYED) { - result = NULL; - if (tvarPtr->errMsg != NULL) { - ckfree(tvarPtr->errMsg); - } - ckfree((char *) tvarPtr); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_WhileCmd -- - * - * This procedure is invoked to process the "while" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_WhileCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int result, value; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " test command\"", (char *) NULL); - return TCL_ERROR; - } - - while (1) { - result = Tcl_ExprBoolean(interp, argv[1], &value); - if (result != TCL_OK) { - return result; - } - if (!value) { - break; - } - result = Tcl_Eval(interp, argv[2]); - if ((result != TCL_OK) && (result != TCL_CONTINUE)) { - if (result == TCL_ERROR) { - char msg[60]; - sprintf(msg, "\n (\"while\" body line %d)", - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - break; - } - } - if (result == TCL_BREAK) { - result = TCL_OK; - } - if (result == TCL_OK) { - Tcl_ResetResult(interp); - } - return result; -} diff --git a/cde/programs/dtdocbook/tcl/tclDate.c b/cde/programs/dtdocbook/tcl/tclDate.c deleted file mode 100644 index 17cee4b19..000000000 --- a/cde/programs/dtdocbook/tcl/tclDate.c +++ /dev/null @@ -1,1617 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclDate.c /main/2 1996/08/08 14:43:30 cde-hp $ */ -/* - * tclGetdate.c -- - * - * This file is generated from a yacc grammar defined in - * the file tclGetdate.y - * - * Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans. - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * @(#) tclDate.c 1.24 96/04/18 16:53:56 - */ - -#include "tclInt.h" -#include "tclPort.h" - -#ifdef MAC_TCL -# define EPOCH 1904 -# define START_OF_TIME 1904 -# define END_OF_TIME 2039 -#else -# define EPOCH 1970 -# define START_OF_TIME 1902 -# define END_OF_TIME 2037 - -extern struct tm *localtime(); -#endif - -#define HOUR(x) ((int) (60 * x)) -#define SECSPERDAY (24L * 60L * 60L) - - -/* - * An entry in the lexical lookup table. - */ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* - * Daylight-savings mode: on, off, or not yet known. - */ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* - * Meridian: am, pm, or 24-hour style. - */ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* - * Global variables. We could get rid of most of these by using a good - * union as the yacc stack. (This routine was originally written before - * yacc had the %union construct.) Maybe someday; right now we only use - * the %union very rarely. - */ -static char *TclDateInput; -static DSTMODE TclDateDSTmode; -static time_t TclDateDayOrdinal; -static time_t TclDateDayNumber; -static int TclDateHaveDate; -static int TclDateHaveDay; -static int TclDateHaveRel; -static int TclDateHaveTime; -static int TclDateHaveZone; -static time_t TclDateTimezone; -static time_t TclDateDay; -static time_t TclDateHour; -static time_t TclDateMinutes; -static time_t TclDateMonth; -static time_t TclDateSeconds; -static time_t TclDateYear; -static MERIDIAN TclDateMeridian; -static time_t TclDateRelMonth; -static time_t TclDateRelSeconds; - - -/* - * Prototypes of internal functions. - */ -static void -TclDateerror _ANSI_ARGS_((char *s)); - -static time_t -ToSeconds _ANSI_ARGS_((time_t Hours, - time_t Minutes, - time_t Seconds, - MERIDIAN Meridian)); - -static int -Convert _ANSI_ARGS_((time_t Month, - time_t Day, - time_t Year, - time_t Hours, - time_t Minutes, - time_t Seconds, - MERIDIAN Meridia, - DSTMODE DSTmode, - time_t *TimePtr)); - -static time_t -DSTcorrect _ANSI_ARGS_((time_t Start, - time_t Future)); - -static time_t -RelativeDate _ANSI_ARGS_((time_t Start, - time_t DayOrdinal, - time_t DayNumber)); - -static int -RelativeMonth _ANSI_ARGS_((time_t Start, - time_t RelMonth, - time_t *TimePtr)); -static int -LookupWord _ANSI_ARGS_((char *buff)); - -static int -TclDatelex _ANSI_ARGS_((void)); - -int -TclDateparse _ANSI_ARGS_((void)); -typedef union -#ifdef __cplusplus - YYSTYPE -#endif - { - time_t Number; - enum _MERIDIAN Meridian; -} YYSTYPE; -# define tAGO 257 -# define tDAY 258 -# define tDAYZONE 259 -# define tID 260 -# define tMERIDIAN 261 -# define tMINUTE_UNIT 262 -# define tMONTH 263 -# define tMONTH_UNIT 264 -# define tSEC_UNIT 265 -# define tSNUMBER 266 -# define tUNUMBER 267 -# define tZONE 268 -# define tEPOCH 269 -# define tDST 270 - - - -#ifdef __cplusplus - -#ifndef TclDateerror - void TclDateerror(const char *); -#endif - -#ifndef TclDatelex -#ifdef __EXTERN_C__ - extern "C" { int TclDatelex(void); } -#else - int TclDatelex(void); -#endif -#endif - int TclDateparse(void); - -#endif -#define TclDateclearin TclDatechar = -1 -#define TclDateerrok TclDateerrflag = 0 -extern int TclDatechar; -extern int TclDateerrflag; -YYSTYPE TclDatelval; -YYSTYPE TclDateval; -typedef int TclDatetabelem; -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 150 -#endif -#if YYMAXDEPTH > 0 -int TclDate_TclDates[YYMAXDEPTH], *TclDates = TclDate_TclDates; -YYSTYPE TclDate_TclDatev[YYMAXDEPTH], *TclDatev = TclDate_TclDatev; -#else /* user does initial allocation */ -int *TclDates; -YYSTYPE *TclDatev; -#endif -static int TclDatemaxdepth = YYMAXDEPTH; -# define YYERRCODE 256 - - -/* - * Month and day table. - */ -static TABLE MonthDayTable[] = { - { "january", tMONTH, 1 }, - { "february", tMONTH, 2 }, - { "march", tMONTH, 3 }, - { "april", tMONTH, 4 }, - { "may", tMONTH, 5 }, - { "june", tMONTH, 6 }, - { "july", tMONTH, 7 }, - { "august", tMONTH, 8 }, - { "september", tMONTH, 9 }, - { "sept", tMONTH, 9 }, - { "october", tMONTH, 10 }, - { "november", tMONTH, 11 }, - { "december", tMONTH, 12 }, - { "sunday", tDAY, 0 }, - { "monday", tDAY, 1 }, - { "tuesday", tDAY, 2 }, - { "tues", tDAY, 2 }, - { "wednesday", tDAY, 3 }, - { "wednes", tDAY, 3 }, - { "thursday", tDAY, 4 }, - { "thur", tDAY, 4 }, - { "thurs", tDAY, 4 }, - { "friday", tDAY, 5 }, - { "saturday", tDAY, 6 }, - { NULL } -}; - -/* - * Time units table. - */ -static TABLE UnitsTable[] = { - { "year", tMONTH_UNIT, 12 }, - { "month", tMONTH_UNIT, 1 }, - { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, - { "week", tMINUTE_UNIT, 7 * 24 * 60 }, - { "day", tMINUTE_UNIT, 1 * 24 * 60 }, - { "hour", tMINUTE_UNIT, 60 }, - { "minute", tMINUTE_UNIT, 1 }, - { "min", tMINUTE_UNIT, 1 }, - { "second", tSEC_UNIT, 1 }, - { "sec", tSEC_UNIT, 1 }, - { NULL } -}; - -/* - * Assorted relative-time words. - */ -static TABLE OtherTable[] = { - { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, - { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, - { "today", tMINUTE_UNIT, 0 }, - { "now", tMINUTE_UNIT, 0 }, - { "last", tUNUMBER, -1 }, - { "this", tMINUTE_UNIT, 0 }, - { "next", tUNUMBER, 2 }, -#if 0 - { "first", tUNUMBER, 1 }, -/* { "second", tUNUMBER, 2 }, */ - { "third", tUNUMBER, 3 }, - { "fourth", tUNUMBER, 4 }, - { "fifth", tUNUMBER, 5 }, - { "sixth", tUNUMBER, 6 }, - { "seventh", tUNUMBER, 7 }, - { "eighth", tUNUMBER, 8 }, - { "ninth", tUNUMBER, 9 }, - { "tenth", tUNUMBER, 10 }, - { "eleventh", tUNUMBER, 11 }, - { "twelfth", tUNUMBER, 12 }, -#endif - { "ago", tAGO, 1 }, - { "epoch", tEPOCH, 0 }, - { NULL } -}; - -/* - * The timezone table. (Note: This table was modified to not use any floating - * point constants to work around an SGI compiler bug). - */ -static TABLE TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) } , /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif - { "nft", tZONE, HOUR( 7/2) }, /* Newfoundland */ - { "nst", tZONE, HOUR( 7/2) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR( 7/2) }, /* Newfoundland Daylight */ - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR( 1) }, /* Central European */ - { "met", tZONE, -HOUR( 1) }, /* Middle European */ - { "mewt", tZONE, -HOUR( 1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR( 1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR( 1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR( 1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR( 1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR( 1) }, /* French Summer */ - { "eet", tZONE, -HOUR( 2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */ - { "it", tZONE, -HOUR( 7/2) }, /* Iran */ - { "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */ - { "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */ - { "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, nad SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(13/2) }, /* North Sumatra */ - { "sst", tZONE, -HOUR( 7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR( 7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR( 7) }, /* West Australian Daylight */ - { "jt", tZONE, -HOUR(15/2) }, /* Java (3pm in Cronusland!) */ - { "cct", tZONE, -HOUR( 8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR( 9) }, /* Japan Standard, USSR Zone 8 */ - { "cast", tZONE, -HOUR(19/2) }, /* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(19/2) }, /* Central Australian Daylight */ - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - /* ADDED BY Marco Nijdam */ - { "dst", tDST, HOUR( 0) }, /* DST on (hour is ignored) */ - /* End ADDED */ - { NULL } -}; - -/* - * Military timezone table. - */ -static TABLE MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - -/* - * Dump error messages in the bit bucket. - */ -static void -TclDateerror(char *s) -{ -} - - -static time_t -ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian) -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return -1; - return ((Hours % 12) * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return -1; - return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds; - } - return -1; /* Should never be reached */ -} - - -static int -Convert(time_t Month, time_t Day, time_t Year, - time_t Hours, time_t Minutes, time_t Seconds, - MERIDIAN Meridian, DSTMODE DSTmode, time_t *TimePtr) -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t Julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - if (Month < 1 || Month > 12 - || Year < START_OF_TIME || Year > END_OF_TIME - || Day < 1 || Day > DaysInMonth[(int)--Month]) - return -1; - - for (Julian = Day - 1, i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - if (Year >= EPOCH) { - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - } else { - for (i = Year; i < EPOCH; i++) - Julian -= 365 + (i % 4 == 0); - } - Julian *= SECSPERDAY; - Julian += TclDateTimezone * 60L; - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return -1; - Julian += tod; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= 60 * 60; - *TimePtr = Julian; - return 0; -} - - -static time_t -DSTcorrect(time_t Start, time_t Future) -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber) -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static int -RelativeMonth(time_t Start, time_t RelMonth, time_t *TimePtr) -{ - struct tm *tm; - time_t Month; - time_t Year; - time_t Julian; - - if (RelMonth == 0) { - *TimePtr = 0; - return 0; - } - tm = localtime(&Start); - Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - if (Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe, &Julian) < 0) - return -1; - *TimePtr = DSTcorrect(Start, Julian); - return 0; -} - - -static int -LookupWord(char *buff) -{ - char *p; - char *q; - TABLE *tp; - int i; - int abbrev; - - /* - * Make it lowercase. - */ - for (p = buff; *p; p++) { - if (isupper(*p)) { - *p = (char) tolower(*p); - } - } - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - TclDatelval.Meridian = MERam; - return tMERIDIAN; - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - TclDatelval.Meridian = MERpm; - return tMERIDIAN; - } - - /* - * See if we have an abbreviation for a month. - */ - if (strlen(buff) == 3) { - abbrev = 1; - } else if (strlen(buff) == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - } else { - abbrev = 0; - } - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } else if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - - for (tp = TimezoneTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - - for (tp = UnitsTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - - /* - * Strip off any plural and try the units table again. - */ - i = strlen(buff) - 1; - if (buff[i] == 's') { - buff[i] = '\0'; - for (tp = UnitsTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - } - - for (tp = OtherTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - - /* - * Military timezones. - */ - if (buff[1] == '\0' && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - } - - /* - * Drop out any periods and try the timezone table again. - */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) { - if (strcmp(buff, tp->name) == 0) { - TclDatelval.Number = tp->value; - return tp->type; - } - } - - return tID; -} - - -static int -TclDatelex(void) -{ - char c; - char *p; - char buff[20]; - int Count; - int sign; - - for ( ; ; ) { - while (isspace((unsigned char) (*TclDateInput))) { - TclDateInput++; - } - - if (isdigit(c = *TclDateInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++TclDateInput)) { - /* - * skip the '-' sign - */ - continue; - } - } else { - sign = 0; - } - for (TclDatelval.Number = 0; isdigit(c = *TclDateInput++); ) { - TclDatelval.Number = 10 * TclDatelval.Number + c - '0'; - } - TclDateInput--; - if (sign < 0) { - TclDatelval.Number = -TclDatelval.Number; - } - return sign ? tSNUMBER : tUNUMBER; - } - if (isalpha(c)) { - for (p = buff; isalpha(c = *TclDateInput++) || c == '.'; ) { - if (p < &buff[sizeof buff - 1]) { - *p++ = c; - } - } - *p = '\0'; - TclDateInput--; - return LookupWord(buff); - } - if (c != '(') { - return *TclDateInput++; - } - Count = 0; - do { - c = *TclDateInput++; - if (c == '\0') { - return c; - } else if (c == '(') { - Count++; - } else if (c == ')') { - Count--; - } - } while (Count > 0); - } -} - -/* - * Specify zone is of -50000 to force GMT. (This allows BST to work). - */ - -int -TclGetDate(char *p, unsigned long now, long zone, unsigned long *timePtr) -{ - struct tm *tm; - time_t Start; - time_t Time; - time_t tod; - - TclDateInput = p; - tm = localtime((time_t *) &now); - TclDateYear = tm->tm_year; - TclDateMonth = tm->tm_mon + 1; - TclDateDay = tm->tm_mday; - TclDateTimezone = zone; - if (zone == -50000) { - TclDateDSTmode = DSToff; /* assume GMT */ - TclDateTimezone = 0; - } else { - TclDateDSTmode = DSTmaybe; - } - TclDateHour = 0; - TclDateMinutes = 0; - TclDateSeconds = 0; - TclDateMeridian = MER24; - TclDateRelSeconds = 0; - TclDateRelMonth = 0; - TclDateHaveDate = 0; - TclDateHaveDay = 0; - TclDateHaveRel = 0; - TclDateHaveTime = 0; - TclDateHaveZone = 0; - - if (TclDateparse() || TclDateHaveTime > 1 || TclDateHaveZone > 1 || TclDateHaveDate > 1 || - TclDateHaveDay > 1) { - return -1; - } - - if (TclDateHaveDate || TclDateHaveTime || TclDateHaveDay) { - if (Convert(TclDateMonth, TclDateDay, TclDateYear, TclDateHour, TclDateMinutes, TclDateSeconds, - TclDateMeridian, TclDateDSTmode, &Start) < 0) - return -1; - } - else { - Start = now; - if (!TclDateHaveRel) - Start -= ((tm->tm_hour * 60L) + tm->tm_min * 60L) + tm->tm_sec; - } - - Start += TclDateRelSeconds; - if (RelativeMonth(Start, TclDateRelMonth, &Time) < 0) { - return -1; - } - Start += Time; - - if (TclDateHaveDay && !TclDateHaveDate) { - tod = RelativeDate(Start, TclDateDayOrdinal, TclDateDayNumber); - Start += tod; - } - - *timePtr = Start; - return 0; -} -TclDatetabelem TclDateexca[] ={ --1, 1, - 0, -1, - -2, 0, - }; -# define YYNPROD 41 -# define YYLAST 227 -TclDatetabelem TclDateact[]={ - - 14, 11, 23, 28, 17, 12, 19, 18, 16, 9, - 10, 13, 42, 21, 46, 45, 44, 48, 41, 37, - 36, 35, 32, 29, 34, 33, 31, 43, 39, 38, - 30, 15, 8, 7, 6, 5, 4, 3, 2, 1, - 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, 0, 47, 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, 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, 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, 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, 0, 0, 0, - 0, 0, 0, 22, 0, 0, 20, 25, 24, 27, - 26, 42, 0, 0, 0, 0, 40 }; -TclDatetabelem TclDatepact[]={ - --10000000, -258,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000, -45, - -267,-10000000, -244,-10000000, -14, -231, -240,-10000000,-10000000,-10000000, --10000000, -246,-10000000, -247, -248,-10000000,-10000000,-10000000,-10000000, -15, --10000000,-10000000,-10000000,-10000000,-10000000, -40, -20,-10000000, -251,-10000000, --10000000, -252,-10000000, -253,-10000000, -249,-10000000,-10000000,-10000000 }; -TclDatetabelem TclDatepgo[]={ - - 0, 28, 39, 38, 37, 36, 35, 34, 33, 32, - 31 }; -TclDatetabelem TclDater1[]={ - - 0, 2, 2, 3, 3, 3, 3, 3, 3, 4, - 4, 4, 4, 4, 5, 5, 5, 7, 7, 7, - 6, 6, 6, 6, 6, 6, 6, 8, 8, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 9, 1, - 1 }; -TclDatetabelem TclDater2[]={ - - 0, 0, 4, 3, 3, 3, 3, 3, 2, 5, - 9, 9, 13, 13, 5, 3, 3, 3, 5, 5, - 7, 11, 5, 9, 5, 3, 7, 5, 2, 5, - 5, 3, 5, 5, 3, 5, 5, 3, 3, 1, - 3 }; -TclDatetabelem TclDatechk[]={ - --10000000, -2, -3, -4, -5, -6, -7, -8, -9, 267, - 268, 259, 263, 269, 258, -10, 266, 262, 265, 264, - 261, 58, 258, 47, 263, 262, 265, 264, 270, 267, - 44, 257, 262, 265, 264, 267, 267, 267, 44, -1, - 266, 58, 261, 47, 267, 267, 267, -1, 266 }; -TclDatetabelem TclDatedef[]={ - - 1, -2, 2, 3, 4, 5, 6, 7, 8, 38, - 15, 16, 0, 25, 17, 28, 0, 31, 34, 37, - 9, 0, 19, 0, 24, 29, 33, 36, 14, 22, - 18, 27, 30, 32, 35, 39, 20, 26, 0, 10, - 11, 0, 40, 0, 23, 39, 21, 12, 13 }; -typedef struct -#ifdef __cplusplus - TclDatetoktype -#endif -{ char *t_name; int t_val; } TclDatetoktype; -#ifndef YYDEBUG -# define YYDEBUG 0 /* don't allow debugging */ -#endif - -#if YYDEBUG - -TclDatetoktype TclDatetoks[] = -{ - "tAGO", 257, - "tDAY", 258, - "tDAYZONE", 259, - "tID", 260, - "tMERIDIAN", 261, - "tMINUTE_UNIT", 262, - "tMONTH", 263, - "tMONTH_UNIT", 264, - "tSEC_UNIT", 265, - "tSNUMBER", 266, - "tUNUMBER", 267, - "tZONE", 268, - "tEPOCH", 269, - "tDST", 270, - "-unknown-", -1 /* ends search */ -}; - -char * TclDatereds[] = -{ - "-no such reduction-", - "spec : /* empty */", - "spec : spec item", - "item : time", - "item : zone", - "item : date", - "item : day", - "item : rel", - "item : number", - "time : tUNUMBER tMERIDIAN", - "time : tUNUMBER ':' tUNUMBER o_merid", - "time : tUNUMBER ':' tUNUMBER tSNUMBER", - "time : tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid", - "time : tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER", - "zone : tZONE tDST", - "zone : tZONE", - "zone : tDAYZONE", - "day : tDAY", - "day : tDAY ','", - "day : tUNUMBER tDAY", - "date : tUNUMBER '/' tUNUMBER", - "date : tUNUMBER '/' tUNUMBER '/' tUNUMBER", - "date : tMONTH tUNUMBER", - "date : tMONTH tUNUMBER ',' tUNUMBER", - "date : tUNUMBER tMONTH", - "date : tEPOCH", - "date : tUNUMBER tMONTH tUNUMBER", - "rel : relunit tAGO", - "rel : relunit", - "relunit : tUNUMBER tMINUTE_UNIT", - "relunit : tSNUMBER tMINUTE_UNIT", - "relunit : tMINUTE_UNIT", - "relunit : tSNUMBER tSEC_UNIT", - "relunit : tUNUMBER tSEC_UNIT", - "relunit : tSEC_UNIT", - "relunit : tSNUMBER tMONTH_UNIT", - "relunit : tUNUMBER tMONTH_UNIT", - "relunit : tMONTH_UNIT", - "number : tUNUMBER", - "o_merid : /* empty */", - "o_merid : tMERIDIAN", -}; -#endif /* YYDEBUG */ -/* - * Copyright (c) 1993 by Sun Microsystems, Inc. - */ - - -/* -** Skeleton parser driver for yacc output -*/ - -/* -** yacc user known macros and defines -*/ -#define YYERROR goto TclDateerrlab -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYBACKUP( newtoken, newvalue )\ -{\ - if ( TclDatechar >= 0 || ( TclDater2[ TclDatetmp ] >> 1 ) != 1 )\ - {\ - TclDateerror( "syntax error - cannot backup" );\ - goto TclDateerrlab;\ - }\ - TclDatechar = newtoken;\ - TclDatestate = *TclDateps;\ - TclDatelval = newvalue;\ - goto TclDatenewstate;\ -} -#define YYRECOVERING() (!!TclDateerrflag) -#define YYNEW(type) malloc(sizeof(type) * TclDatenewmax) -#define YYCOPY(to, from, type) \ - (type *) memcpy(to, (char *) from, TclDatenewmax * sizeof(type)) -#define YYENLARGE( from, type) \ - (type *) realloc((char *) from, TclDatenewmax * sizeof(type)) -#ifndef YYDEBUG -# define YYDEBUG 1 /* make debugging available */ -#endif - -/* -** user known globals -*/ -int TclDatedebug; /* set to 1 to get debugging */ - -/* -** driver internal defines -*/ -#define YYFLAG (-10000000) - -/* -** global variables used by the parser -*/ -YYSTYPE *TclDatepv; /* top of value stack */ -int *TclDateps; /* top of state stack */ - -int TclDatestate; /* current state */ -int TclDatetmp; /* extra var (lasts between blocks) */ - -int TclDatenerrs; /* number of errors */ -int TclDateerrflag; /* error recovery flag */ -int TclDatechar; /* current input token number */ - - - -#ifdef YYNMBCHARS -#define YYLEX() TclDatecvtok(TclDatelex()) -/* -** TclDatecvtok - return a token if i is a wchar_t value that exceeds 255. -** If i<255, i itself is the token. If i>255 but the neither -** of the 30th or 31st bit is on, i is already a token. -*/ -#if defined(__STDC__) || defined(__cplusplus) -int TclDatecvtok(int i) -#else -int TclDatecvtok(i) int i; -#endif -{ - int first = 0; - int last = YYNMBCHARS - 1; - int mid; - wchar_t j; - - if(i&0x60000000){/*Must convert to a token. */ - if( TclDatembchars[last].character < i ){ - return i;/*Giving up*/ - } - while ((last>=first)&&(first>=0)) {/*Binary search loop*/ - mid = (first+last)/2; - j = TclDatembchars[mid].character; - if( j==i ){/*Found*/ - return TclDatembchars[mid].tvalue; - }else if( j<i ){ - first = mid + 1; - }else{ - last = mid -1; - } - } - /*No entry in the table.*/ - return i;/* Giving up.*/ - }else{/* i is already a token. */ - return i; - } -} -#else/*!YYNMBCHARS*/ -#define YYLEX() TclDatelex() -#endif/*!YYNMBCHARS*/ - -/* -** TclDateparse - return 0 if worked, 1 if syntax error not recovered from -*/ -#if defined(__STDC__) || defined(__cplusplus) -int TclDateparse(void) -#else -int TclDateparse() -#endif -{ - YYSTYPE *TclDatepvt; /* top of value stack for $vars */ - -#if defined(__cplusplus) || defined(lint) -/* - hacks to please C++ and lint - goto's inside switch should never be - executed; TclDatepvt is set to 0 to avoid "used before set" warning. -*/ - static int __yaccpar_lint_hack__ = 0; - switch (__yaccpar_lint_hack__) - { - case 1: goto TclDateerrlab; - case 2: goto TclDatenewstate; - } - TclDatepvt = 0; -#endif - - /* - ** Initialize externals - TclDateparse may be called more than once - */ - TclDatepv = &TclDatev[-1]; - TclDateps = &TclDates[-1]; - TclDatestate = 0; - TclDatetmp = 0; - TclDatenerrs = 0; - TclDateerrflag = 0; - TclDatechar = -1; - -#if YYMAXDEPTH <= 0 - if (TclDatemaxdepth <= 0) - { - if ((TclDatemaxdepth = YYEXPAND(0)) <= 0) - { - TclDateerror("yacc initialization error"); - YYABORT; - } - } -#endif - - { - YYSTYPE *TclDate_pv; /* top of value stack */ - int *TclDate_ps; /* top of state stack */ - int TclDate_state; /* current state */ - int TclDate_n; /* internal state number info */ - goto TclDatestack; /* moved from 6 lines above to here to please C++ */ - - /* - ** get globals into registers. - ** branch to here only if YYBACKUP was called. - */ - TclDate_pv = TclDatepv; - TclDate_ps = TclDateps; - TclDate_state = TclDatestate; - goto TclDate_newstate; - - /* - ** get globals into registers. - ** either we just started, or we just finished a reduction - */ - TclDatestack: - TclDate_pv = TclDatepv; - TclDate_ps = TclDateps; - TclDate_state = TclDatestate; - - /* - ** top of for (;;) loop while no reductions done - */ - TclDate_stack: - /* - ** put a state and value onto the stacks - */ -#if YYDEBUG - /* - ** if debugging, look up token value in list of value vs. - ** name pairs. 0 and negative (-1) are special values. - ** Note: linear search is used since time is not a real - ** consideration while debugging. - */ - if ( TclDatedebug ) - { - int TclDate_i; - - printf( "State %d, token ", TclDate_state ); - if ( TclDatechar == 0 ) - printf( "end-of-file\n" ); - else if ( TclDatechar < 0 ) - printf( "-none-\n" ); - else - { - for ( TclDate_i = 0; TclDatetoks[TclDate_i].t_val >= 0; - TclDate_i++ ) - { - if ( TclDatetoks[TclDate_i].t_val == TclDatechar ) - break; - } - printf( "%s\n", TclDatetoks[TclDate_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ++TclDate_ps >= &TclDates[ TclDatemaxdepth ] ) /* room on stack? */ - { - /* - ** reallocate and recover. Note that pointers - ** have to be reset, or bad things will happen - */ - int TclDateps_index = (TclDate_ps - TclDates); - int TclDatepv_index = (TclDate_pv - TclDatev); - int TclDatepvt_index = (TclDatepvt - TclDatev); - int TclDatenewmax; -#ifdef YYEXPAND - TclDatenewmax = YYEXPAND(TclDatemaxdepth); -#else - TclDatenewmax = 2 * TclDatemaxdepth; /* double table size */ - if (TclDatemaxdepth == YYMAXDEPTH) /* first time growth */ - { - char *newTclDates = (char *)YYNEW(int); - char *newTclDatev = (char *)YYNEW(YYSTYPE); - if (newTclDates != 0 && newTclDatev != 0) - { - TclDates = YYCOPY(newTclDates, TclDates, int); - TclDatev = YYCOPY(newTclDatev, TclDatev, YYSTYPE); - } - else - TclDatenewmax = 0; /* failed */ - } - else /* not first time */ - { - TclDates = YYENLARGE(TclDates, int); - TclDatev = YYENLARGE(TclDatev, YYSTYPE); - if (TclDates == 0 || TclDatev == 0) - TclDatenewmax = 0; /* failed */ - } -#endif - if (TclDatenewmax <= TclDatemaxdepth) /* tables not expanded */ - { - TclDateerror( "yacc stack overflow" ); - YYABORT; - } - TclDatemaxdepth = TclDatenewmax; - - TclDate_ps = TclDates + TclDateps_index; - TclDate_pv = TclDatev + TclDatepv_index; - TclDatepvt = TclDatev + TclDatepvt_index; - } - *TclDate_ps = TclDate_state; - *++TclDate_pv = TclDateval; - - /* - ** we have a new state - find out what to do - */ - TclDate_newstate: - if ( ( TclDate_n = TclDatepact[ TclDate_state ] ) <= YYFLAG ) - goto TclDatedefault; /* simple state */ -#if YYDEBUG - /* - ** if debugging, need to mark whether new token grabbed - */ - TclDatetmp = TclDatechar < 0; -#endif - if ( ( TclDatechar < 0 ) && ( ( TclDatechar = YYLEX() ) < 0 ) ) - TclDatechar = 0; /* reached EOF */ -#if YYDEBUG - if ( TclDatedebug && TclDatetmp ) - { - int TclDate_i; - - printf( "Received token " ); - if ( TclDatechar == 0 ) - printf( "end-of-file\n" ); - else if ( TclDatechar < 0 ) - printf( "-none-\n" ); - else - { - for ( TclDate_i = 0; TclDatetoks[TclDate_i].t_val >= 0; - TclDate_i++ ) - { - if ( TclDatetoks[TclDate_i].t_val == TclDatechar ) - break; - } - printf( "%s\n", TclDatetoks[TclDate_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ( ( TclDate_n += TclDatechar ) < 0 ) || ( TclDate_n >= YYLAST ) ) - goto TclDatedefault; - if ( TclDatechk[ TclDate_n = TclDateact[ TclDate_n ] ] == TclDatechar ) /*valid shift*/ - { - TclDatechar = -1; - TclDateval = TclDatelval; - TclDate_state = TclDate_n; - if ( TclDateerrflag > 0 ) - TclDateerrflag--; - goto TclDate_stack; - } - - TclDatedefault: - if ( ( TclDate_n = TclDatedef[ TclDate_state ] ) == -2 ) - { -#if YYDEBUG - TclDatetmp = TclDatechar < 0; -#endif - if ( ( TclDatechar < 0 ) && ( ( TclDatechar = YYLEX() ) < 0 ) ) - TclDatechar = 0; /* reached EOF */ -#if YYDEBUG - if ( TclDatedebug && TclDatetmp ) - { - int TclDate_i; - - printf( "Received token " ); - if ( TclDatechar == 0 ) - printf( "end-of-file\n" ); - else if ( TclDatechar < 0 ) - printf( "-none-\n" ); - else - { - for ( TclDate_i = 0; - TclDatetoks[TclDate_i].t_val >= 0; - TclDate_i++ ) - { - if ( TclDatetoks[TclDate_i].t_val - == TclDatechar ) - { - break; - } - } - printf( "%s\n", TclDatetoks[TclDate_i].t_name ); - } - } -#endif /* YYDEBUG */ - /* - ** look through exception table - */ - { - int *TclDatexi = TclDateexca; - - while ( ( *TclDatexi != -1 ) || - ( TclDatexi[1] != TclDate_state ) ) - { - TclDatexi += 2; - } - while ( ( *(TclDatexi += 2) >= 0 ) && - ( *TclDatexi != TclDatechar ) ) - ; - if ( ( TclDate_n = TclDatexi[1] ) < 0 ) - YYACCEPT; - } - } - - /* - ** check for syntax error - */ - if ( TclDate_n == 0 ) /* have an error */ - { - /* no worry about speed here! */ - switch ( TclDateerrflag ) - { - case 0: /* new error */ - TclDateerror( "syntax error" ); - goto skip_init; - /* - ** get globals into registers. - ** we have a user generated syntax type error - */ - TclDate_pv = TclDatepv; - TclDate_ps = TclDateps; - TclDate_state = TclDatestate; - skip_init: - TclDatenerrs++; - /* FALLTHRU */ - case 1: - case 2: /* incompletely recovered error */ - /* try again... */ - TclDateerrflag = 3; - /* - ** find state where "error" is a legal - ** shift action - */ - while ( TclDate_ps >= TclDates ) - { - TclDate_n = TclDatepact[ *TclDate_ps ] + YYERRCODE; - if ( TclDate_n >= 0 && TclDate_n < YYLAST && - TclDatechk[TclDateact[TclDate_n]] == YYERRCODE) { - /* - ** simulate shift of "error" - */ - TclDate_state = TclDateact[ TclDate_n ]; - goto TclDate_stack; - } - /* - ** current state has no shift on - ** "error", pop stack - */ -#if YYDEBUG -# define _POP_ "Error recovery pops state %d, uncovers state %d\n" - if ( TclDatedebug ) - printf( _POP_, *TclDate_ps, - TclDate_ps[-1] ); -# undef _POP_ -#endif - TclDate_ps--; - TclDate_pv--; - } - /* - ** there is no state on stack with "error" as - ** a valid shift. give up. - */ - YYABORT; - case 3: /* no shift yet; eat a token */ -#if YYDEBUG - /* - ** if debugging, look up token in list of - ** pairs. 0 and negative shouldn't occur, - ** but since timing doesn't matter when - ** debugging, it doesn't hurt to leave the - ** tests here. - */ - if ( TclDatedebug ) - { - int TclDate_i; - - printf( "Error recovery discards " ); - if ( TclDatechar == 0 ) - printf( "token end-of-file\n" ); - else if ( TclDatechar < 0 ) - printf( "token -none-\n" ); - else - { - for ( TclDate_i = 0; - TclDatetoks[TclDate_i].t_val >= 0; - TclDate_i++ ) - { - if ( TclDatetoks[TclDate_i].t_val - == TclDatechar ) - { - break; - } - } - printf( "token %s\n", - TclDatetoks[TclDate_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( TclDatechar == 0 ) /* reached EOF. quit */ - YYABORT; - TclDatechar = -1; - goto TclDate_newstate; - } - }/* end if ( TclDate_n == 0 ) */ - /* - ** reduction by production TclDate_n - ** put stack tops, etc. so things right after switch - */ -#if YYDEBUG - /* - ** if debugging, print the string that is the user's - ** specification of the reduction which is just about - ** to be done. - */ - if ( TclDatedebug ) - printf( "Reduce by (%d) \"%s\"\n", - TclDate_n, TclDatereds[ TclDate_n ] ); -#endif - TclDatetmp = TclDate_n; /* value to switch over */ - TclDatepvt = TclDate_pv; /* $vars top of value stack */ - /* - ** Look in goto table for next state - ** Sorry about using TclDate_state here as temporary - ** register variable, but why not, if it works... - ** If TclDater2[ TclDate_n ] doesn't have the low order bit - ** set, then there is no action to be done for - ** this reduction. So, no saving & unsaving of - ** registers done. The only difference between the - ** code just after the if and the body of the if is - ** the goto TclDate_stack in the body. This way the test - ** can be made before the choice of what to do is needed. - */ - { - /* length of production doubled with extra bit */ - int TclDate_len = TclDater2[ TclDate_n ]; - - if ( !( TclDate_len & 01 ) ) - { - TclDate_len >>= 1; - TclDateval = ( TclDate_pv -= TclDate_len )[1]; /* $$ = $1 */ - TclDate_state = TclDatepgo[ TclDate_n = TclDater1[ TclDate_n ] ] + - *( TclDate_ps -= TclDate_len ) + 1; - if ( TclDate_state >= YYLAST || - TclDatechk[ TclDate_state = - TclDateact[ TclDate_state ] ] != -TclDate_n ) - { - TclDate_state = TclDateact[ TclDatepgo[ TclDate_n ] ]; - } - goto TclDate_stack; - } - TclDate_len >>= 1; - TclDateval = ( TclDate_pv -= TclDate_len )[1]; /* $$ = $1 */ - TclDate_state = TclDatepgo[ TclDate_n = TclDater1[ TclDate_n ] ] + - *( TclDate_ps -= TclDate_len ) + 1; - if ( TclDate_state >= YYLAST || - TclDatechk[ TclDate_state = TclDateact[ TclDate_state ] ] != -TclDate_n ) - { - TclDate_state = TclDateact[ TclDatepgo[ TclDate_n ] ]; - } - } - /* save until reenter driver code */ - TclDatestate = TclDate_state; - TclDateps = TclDate_ps; - TclDatepv = TclDate_pv; - } - /* - ** code supplied by user is placed in this switch - */ - switch( TclDatetmp ) - { - -case 3:{ - TclDateHaveTime++; - } break; -case 4:{ - TclDateHaveZone++; - } break; -case 5:{ - TclDateHaveDate++; - } break; -case 6:{ - TclDateHaveDay++; - } break; -case 7:{ - TclDateHaveRel++; - } break; -case 9:{ - TclDateHour = TclDatepvt[-1].Number; - TclDateMinutes = 0; - TclDateSeconds = 0; - TclDateMeridian = TclDatepvt[-0].Meridian; - } break; -case 10:{ - TclDateHour = TclDatepvt[-3].Number; - TclDateMinutes = TclDatepvt[-1].Number; - TclDateSeconds = 0; - TclDateMeridian = TclDatepvt[-0].Meridian; - } break; -case 11:{ - TclDateHour = TclDatepvt[-3].Number; - TclDateMinutes = TclDatepvt[-1].Number; - TclDateMeridian = MER24; - TclDateDSTmode = DSToff; - TclDateTimezone = - (TclDatepvt[-0].Number % 100 + (TclDatepvt[-0].Number / 100) * 60); - } break; -case 12:{ - TclDateHour = TclDatepvt[-5].Number; - TclDateMinutes = TclDatepvt[-3].Number; - TclDateSeconds = TclDatepvt[-1].Number; - TclDateMeridian = TclDatepvt[-0].Meridian; - } break; -case 13:{ - TclDateHour = TclDatepvt[-5].Number; - TclDateMinutes = TclDatepvt[-3].Number; - TclDateSeconds = TclDatepvt[-1].Number; - TclDateMeridian = MER24; - TclDateDSTmode = DSToff; - TclDateTimezone = - (TclDatepvt[-0].Number % 100 + (TclDatepvt[-0].Number / 100) * 60); - } break; -case 14:{ - TclDateTimezone = TclDatepvt[-1].Number; - TclDateDSTmode = DSTon; - } break; -case 15:{ - TclDateTimezone = TclDatepvt[-0].Number; - TclDateDSTmode = DSToff; - } break; -case 16:{ - TclDateTimezone = TclDatepvt[-0].Number; - TclDateDSTmode = DSTon; - } break; -case 17:{ - TclDateDayOrdinal = 1; - TclDateDayNumber = TclDatepvt[-0].Number; - } break; -case 18:{ - TclDateDayOrdinal = 1; - TclDateDayNumber = TclDatepvt[-1].Number; - } break; -case 19:{ - TclDateDayOrdinal = TclDatepvt[-1].Number; - TclDateDayNumber = TclDatepvt[-0].Number; - } break; -case 20:{ - TclDateMonth = TclDatepvt[-2].Number; - TclDateDay = TclDatepvt[-0].Number; - } break; -case 21:{ - TclDateMonth = TclDatepvt[-4].Number; - TclDateDay = TclDatepvt[-2].Number; - TclDateYear = TclDatepvt[-0].Number; - } break; -case 22:{ - TclDateMonth = TclDatepvt[-1].Number; - TclDateDay = TclDatepvt[-0].Number; - } break; -case 23:{ - TclDateMonth = TclDatepvt[-3].Number; - TclDateDay = TclDatepvt[-2].Number; - TclDateYear = TclDatepvt[-0].Number; - } break; -case 24:{ - TclDateMonth = TclDatepvt[-0].Number; - TclDateDay = TclDatepvt[-1].Number; - } break; -case 25:{ - TclDateMonth = 1; - TclDateDay = 1; - TclDateYear = EPOCH; - } break; -case 26:{ - TclDateMonth = TclDatepvt[-1].Number; - TclDateDay = TclDatepvt[-2].Number; - TclDateYear = TclDatepvt[-0].Number; - } break; -case 27:{ - TclDateRelSeconds = -TclDateRelSeconds; - TclDateRelMonth = -TclDateRelMonth; - } break; -case 29:{ - TclDateRelSeconds += TclDatepvt[-1].Number * TclDatepvt[-0].Number * 60L; - } break; -case 30:{ - TclDateRelSeconds += TclDatepvt[-1].Number * TclDatepvt[-0].Number * 60L; - } break; -case 31:{ - TclDateRelSeconds += TclDatepvt[-0].Number * 60L; - } break; -case 32:{ - TclDateRelSeconds += TclDatepvt[-1].Number; - } break; -case 33:{ - TclDateRelSeconds += TclDatepvt[-1].Number; - } break; -case 34:{ - TclDateRelSeconds++; - } break; -case 35:{ - TclDateRelMonth += TclDatepvt[-1].Number * TclDatepvt[-0].Number; - } break; -case 36:{ - TclDateRelMonth += TclDatepvt[-1].Number * TclDatepvt[-0].Number; - } break; -case 37:{ - TclDateRelMonth += TclDatepvt[-0].Number; - } break; -case 38:{ - if (TclDateHaveTime && TclDateHaveDate && !TclDateHaveRel) - TclDateYear = TclDatepvt[-0].Number; - else { - TclDateHaveTime++; - if (TclDatepvt[-0].Number < 100) { - TclDateHour = TclDatepvt[-0].Number; - TclDateMinutes = 0; - } - else { - TclDateHour = TclDatepvt[-0].Number / 100; - TclDateMinutes = TclDatepvt[-0].Number % 100; - } - TclDateSeconds = 0; - TclDateMeridian = MER24; - } - } break; -case 39:{ - TclDateval.Meridian = MER24; - } break; -case 40:{ - TclDateval.Meridian = TclDatepvt[-0].Meridian; - } break; - } - goto TclDatestack; /* reset registers in driver code */ -} - diff --git a/cde/programs/dtdocbook/tcl/tclEnv.c b/cde/programs/dtdocbook/tcl/tclEnv.c deleted file mode 100644 index d45992d32..000000000 --- a/cde/programs/dtdocbook/tcl/tclEnv.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclEnv.c /main/2 1996/08/08 14:43:36 cde-hp $ */ -/* - * tclEnv.c -- - * - * Tcl support for environment variables, including a setenv - * procedure. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclEnv.c 1.34 96/04/15 18:18:36 - */ - -/* - * The putenv and setenv definitions below cause any system prototypes for - * those procedures to be ignored so that there won't be a clash when the - * versions in this file are compiled. - */ - -#define putenv ignore_putenv -#define setenv ignore_setenv -#include "tclInt.h" -#include "tclPort.h" -#undef putenv -#undef setenv - -/* - * The structure below is used to keep track of all of the interpereters - * for which we're managing the "env" array. It's needed so that they - * can all be updated whenever an environment variable is changed - * anywhere. - */ - -typedef struct EnvInterp { - Tcl_Interp *interp; /* Interpreter for which we're managing - * the env array. */ - struct EnvInterp *nextPtr; /* Next in list of all such interpreters, - * or zero. */ -} EnvInterp; - -static EnvInterp *firstInterpPtr; - /* First in list of all managed interpreters, - * or NULL if none. */ - -static int environSize = 0; /* Non-zero means that the all of the - * environ-related information is malloc-ed - * and the environ array itself has this - * many total entries allocated to it (not - * all may be in use at once). Zero means - * that the environment array is in its - * original static state. */ - -/* - * Declarations for local procedures defined in this file: - */ - -static void EnvExitProc _ANSI_ARGS_((ClientData clientData)); -static void EnvInit _ANSI_ARGS_((void)); -static char * EnvTraceProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); -static int FindVariable _ANSI_ARGS_((CONST char *name, - int *lengthPtr)); -void TclSetEnv _ANSI_ARGS_((CONST char *name, - CONST char *value)); -void TclUnsetEnv _ANSI_ARGS_((CONST char *name)); - -/* - *---------------------------------------------------------------------- - * - * TclSetupEnv -- - * - * This procedure is invoked for an interpreter to make environment - * variables accessible from that interpreter via the "env" - * associative array. - * - * Results: - * None. - * - * Side effects: - * The interpreter is added to a list of interpreters managed - * by us, so that its view of envariables can be kept consistent - * with the view in other interpreters. If this is the first - * call to Tcl_SetupEnv, then additional initialization happens, - * such as copying the environment to dynamically-allocated space - * for ease of management. - * - *---------------------------------------------------------------------- - */ - -void -TclSetupEnv( - Tcl_Interp *interp /* Interpreter whose "env" array is to be - * managed. */ -) -{ - EnvInterp *eiPtr; - int i; - - /* - * First, initialize our environment-related information, if - * necessary. - */ - - if (environSize == 0) { - EnvInit(); - } - - /* - * Next, add the interpreter to the list of those that we manage. - */ - - eiPtr = (EnvInterp *) ckalloc(sizeof(EnvInterp)); - eiPtr->interp = interp; - eiPtr->nextPtr = firstInterpPtr; - firstInterpPtr = eiPtr; - - /* - * Store the environment variable values into the interpreter's - * "env" array, and arrange for us to be notified on future - * writes and unsets to that array. - */ - - (void) Tcl_UnsetVar2(interp, "env", (char *) NULL, TCL_GLOBAL_ONLY); - for (i = 0; ; i++) { - char *p, *p2; - - p = environ[i]; - if (p == NULL) { - break; - } - for (p2 = p; *p2 != '='; p2++) { - /* Empty loop body. */ - } - *p2 = 0; - (void) Tcl_SetVar2(interp, "env", p, p2+1, TCL_GLOBAL_ONLY); - *p2 = '='; - } - Tcl_TraceVar2(interp, "env", (char *) NULL, - TCL_GLOBAL_ONLY | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, - EnvTraceProc, (ClientData) NULL); -} - -/* - *---------------------------------------------------------------------- - * - * FindVariable -- - * - * Locate the entry in environ for a given name. - * - * Results: - * The return value is the index in environ of an entry with the - * name "name", or -1 if there is no such entry. The integer at - * *lengthPtr is filled in with the length of name (if a matching - * entry is found) or the length of the environ array (if no matching - * entry is found). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -FindVariable( - CONST char *name, /* Name of desired environment variable. */ - int *lengthPtr /* Used to return length of name (for - * successful searches) or number of non-NULL - * entries in environ (for unsuccessful - * searches). */ -) -{ - int i; - CONST char *p1, *p2; - - for (i = 0, p1 = environ[i]; p1 != NULL; i++, p1 = environ[i]) { - for (p2 = name; *p2 == *p1; p1++, p2++) { - /* NULL loop body. */ - } - if ((*p1 == '=') && (*p2 == '\0')) { - *lengthPtr = p2-name; - return i; - } - } - *lengthPtr = i; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetEnv -- - * - * Get an environment variable or return NULL if the variable - * doesn't exist. This procedure is intended to be a - * stand-in for the UNIX "getenv" procedure so that applications - * using that procedure will interface properly to Tcl. To make - * it a stand-in, the Makefile must define "TclGetEnv" to "getenv". - * - * Results: - * ptr to value on success, NULL if error. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -TclGetEnv( - char *name /* Name of desired environment variable. */ -) -{ - int i; - size_t len; - - for (i = 0; environ[i] != NULL; i++) { - len = (size_t) ((char *) strchr(environ[i], '=') - environ[i]); - if ((len > 0 && !strncmp(name, environ[i], len)) - || (*name == '\0')) { - /* - * The caller of this function should regard this - * as static memory. - */ - return &environ[i][len+1]; - } - } - - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * TclSetEnv -- - * - * Set an environment variable, replacing an existing value - * or creating a new variable if there doesn't exist a variable - * by the given name. This procedure is intended to be a - * stand-in for the UNIX "setenv" procedure so that applications - * using that procedure will interface properly to Tcl. To make - * it a stand-in, the Makefile must define "TclSetEnv" to "setenv". - * - * Results: - * None. - * - * Side effects: - * The environ array gets updated, as do all of the interpreters - * that we manage. - * - *---------------------------------------------------------------------- - */ - -void -TclSetEnv( - CONST char *name, /* Name of variable whose value is to be - * set. */ - CONST char *value /* New value for variable. */ -) -{ - int index, length, nameLength; - char *p; - EnvInterp *eiPtr; - - if (environSize == 0) { - EnvInit(); - } - - /* - * Figure out where the entry is going to go. If the name doesn't - * already exist, enlarge the array if necessary to make room. If - * the name exists, free its old entry. - */ - - index = FindVariable(name, &length); - if (index == -1) { - if ((length+2) > environSize) { - char **newEnviron; - - newEnviron = (char **) ckalloc((unsigned) - ((length+5) * sizeof(char *))); - memcpy((VOID *) newEnviron, (VOID *) environ, - length*sizeof(char *)); - ckfree((char *) environ); - environ = newEnviron; - environSize = length+5; - } - index = length; - environ[index+1] = NULL; - nameLength = strlen(name); - } else { - /* - * Compare the new value to the existing value. If they're - * the same then quit immediately (e.g. don't rewrite the - * value or propagate it to other interpreters). Otherwise, - * when there are N interpreters there will be N! propagations - * of the same value among the interpreters. - */ - - if (strcmp(value, environ[index]+length+1) == 0) { - return; - } - ckfree(environ[index]); - nameLength = length; - } - - /* - * Create a new entry and enter it into the table. - */ - - p = (char *) ckalloc((unsigned) (nameLength + strlen(value) + 2)); - environ[index] = p; - strcpy(p, name); - p += nameLength; - *p = '='; - strcpy(p+1, value); - - /* - * Update all of the interpreters. - */ - - for (eiPtr= firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) { - (void) Tcl_SetVar2(eiPtr->interp, "env", (char *) name, - p+1, TCL_GLOBAL_ONLY); - } - - /* - * Update the system environment. - */ - - TclSetSystemEnv(name, value); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PutEnv -- - * - * Set an environment variable. Similar to setenv except that - * the information is passed in a single string of the form - * NAME=value, rather than as separate name strings. This procedure - * is intended to be a stand-in for the UNIX "putenv" procedure - * so that applications using that procedure will interface - * properly to Tcl. To make it a stand-in, the Makefile will - * define "Tcl_PutEnv" to "putenv". - * - * Results: - * None. - * - * Side effects: - * The environ array gets updated, as do all of the interpreters - * that we manage. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_PutEnv( - CONST char *string /* Info about environment variable in the - * form NAME=value. */ -) -{ - int nameLength; - char *name, *value; - - if (string == NULL) { - return 0; - } - - /* - * Separate the string into name and value parts, then call - * TclSetEnv to do all of the real work. - */ - - value = strchr(string, '='); - if (value == NULL) { - return 0; - } - nameLength = value - string; - if (nameLength == 0) { - return 0; - } - name = (char *) ckalloc((unsigned) nameLength+1); - memcpy(name, string, (size_t) nameLength); - name[nameLength] = 0; - TclSetEnv(name, value+1); - ckfree(name); - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * TclUnsetEnv -- - * - * Remove an environment variable, updating the "env" arrays - * in all interpreters managed by us. This function is intended - * to replace the UNIX "unsetenv" function (but to do this the - * Makefile must be modified to redefine "TclUnsetEnv" to - * "unsetenv". - * - * Results: - * None. - * - * Side effects: - * Interpreters are updated, as is environ. - * - *---------------------------------------------------------------------- - */ - -void -TclUnsetEnv( - CONST char *name /* Name of variable to remove. */ -) -{ - int index, dummy; - char **envPtr; - EnvInterp *eiPtr; - - if (environSize == 0) { - EnvInit(); - } - - /* - * Update the environ array. - */ - - index = FindVariable(name, &dummy); - if (index == -1) { - return; - } - ckfree(environ[index]); - for (envPtr = environ+index+1; ; envPtr++) { - envPtr[-1] = *envPtr; - if (*envPtr == NULL) { - break; - } - } - - /* - * Update all of the interpreters. - */ - - for (eiPtr = firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) { - (void) Tcl_UnsetVar2(eiPtr->interp, "env", (char *) name, - TCL_GLOBAL_ONLY); - } - - /* - * Update the system environment. - */ - - TclSetSystemEnv(name, NULL); -} - -/* - *---------------------------------------------------------------------- - * - * EnvTraceProc -- - * - * This procedure is invoked whenever an environment variable - * is modified or deleted. It propagates the change to the - * "environ" array and to any other interpreters for whom - * we're managing an "env" array. - * - * Results: - * Always returns NULL to indicate success. - * - * Side effects: - * Environment variable changes get propagated. If the whole - * "env" array is deleted, then we stop managing things for - * this interpreter (usually this happens because the whole - * interpreter is being deleted). - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static char * -EnvTraceProc( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter whose "env" variable is - * being modified. */ - char *name1, /* Better be "env". */ - char *name2, /* Name of variable being modified, or - * NULL if whole array is being deleted. */ - int flags /* Indicates what's happening. */ -) -{ - /* - * First see if the whole "env" variable is being deleted. If - * so, just forget about this interpreter. - */ - - if (name2 == NULL) { - EnvInterp *eiPtr, *prevPtr; - - if ((flags & (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED)) - != (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED)) { - panic("EnvTraceProc called with confusing arguments"); - } - eiPtr = firstInterpPtr; - if (eiPtr->interp == interp) { - firstInterpPtr = eiPtr->nextPtr; - } else { - for (prevPtr = eiPtr, eiPtr = eiPtr->nextPtr; ; - prevPtr = eiPtr, eiPtr = eiPtr->nextPtr) { - if (eiPtr == NULL) { - panic("EnvTraceProc couldn't find interpreter"); - } - if (eiPtr->interp == interp) { - prevPtr->nextPtr = eiPtr->nextPtr; - break; - } - } - } - ckfree((char *) eiPtr); - return NULL; - } - - /* - * If a value is being set, call TclSetEnv to do all of the work. - */ - - if (flags & TCL_TRACE_WRITES) { - TclSetEnv(name2, Tcl_GetVar2(interp, "env", name2, TCL_GLOBAL_ONLY)); - } - - if (flags & TCL_TRACE_UNSETS) { - TclUnsetEnv(name2); - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * EnvInit -- - * - * This procedure is called to initialize our management - * of the environ array. - * - * Results: - * None. - * - * Side effects: - * Environ gets copied to malloc-ed storage, so that in - * the future we don't have to worry about which entries - * are malloc-ed and which are static. - * - *---------------------------------------------------------------------- - */ - -static void -EnvInit(void) -{ -#ifdef MAC_TCL - environSize = TclMacCreateEnv(); -#else - char **newEnviron; - int i, length; - - if (environSize != 0) { - return; - } - for (length = 0; environ[length] != NULL; length++) { - /* Empty loop body. */ - } - environSize = length+5; - newEnviron = (char **) ckalloc((unsigned) - (environSize * sizeof(char *))); - for (i = 0; i < length; i++) { - newEnviron[i] = (char *) ckalloc((unsigned) (strlen(environ[i]) + 1)); - strcpy(newEnviron[i], environ[i]); - } - newEnviron[length] = NULL; - environ = newEnviron; - Tcl_CreateExitHandler(EnvExitProc, (ClientData) NULL); -#endif -} - -/* - *---------------------------------------------------------------------- - * - * EnvExitProc -- - * - * This procedure is called just before the process exits. It - * frees the memory associated with environment variables. - * - * Results: - * None. - * - * Side effects: - * Memory is freed. - * - *---------------------------------------------------------------------- - */ - -static void -EnvExitProc( - ClientData clientData /* Not used. */ -) -{ - char **p; - - for (p = environ; *p != NULL; p++) { - ckfree(*p); - } - ckfree((char *) environ); -} diff --git a/cde/programs/dtdocbook/tcl/tclEvent.c b/cde/programs/dtdocbook/tcl/tclEvent.c deleted file mode 100644 index 2f2bdaead..000000000 --- a/cde/programs/dtdocbook/tcl/tclEvent.c +++ /dev/null @@ -1,2241 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclEvent.c /main/2 1996/08/08 14:43:41 cde-hp $ */ -/* - * tclEvent.c -- - * - * This file provides basic event-managing facilities for Tcl, - * including an event queue, and mechanisms for attaching - * callbacks to certain events. - * - * It also contains the command procedures for the commands - * "after", "vwait", and "update". - * - * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclEvent.c 1.127 96/03/22 12:12:33 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * For each file registered in a call to Tcl_CreateFileHandler, - * there is one record of the following type. All of these records - * are chained together into a single list. - */ - -typedef struct FileHandler { - Tcl_File file; /* Generic file handle for file. */ - int mask; /* Mask of desired events: TCL_READABLE, etc. */ - int readyMask; /* Events that were ready the last time that - * FileHandlerCheckProc checked this file. */ - Tcl_FileProc *proc; /* Procedure to call, in the style of - * Tcl_CreateFileHandler. This is NULL - * if the handler was created by - * Tcl_CreateFileHandler2. */ - ClientData clientData; /* Argument to pass to proc. */ - struct FileHandler *nextPtr;/* Next in list of all files we care - * about (NULL for end of list). */ -} FileHandler; - -static FileHandler *firstFileHandlerPtr = (FileHandler *) NULL; - /* List of all file handlers. */ -static int fileEventSourceCreated = 0; - /* Non-zero means that the file event source - * hasn't been registerd with the Tcl - * notifier yet. */ - -/* - * The following structure is what is added to the Tcl event queue when - * file handlers are ready to fire. - */ - -typedef struct FileHandlerEvent { - Tcl_Event header; /* Information that is standard for - * all events. */ - Tcl_File file; /* File descriptor that is ready. Used - * to find the FileHandler structure for - * the file (can't point directly to the - * FileHandler structure because it could - * go away while the event is queued). */ -} FileHandlerEvent; - -/* - * For each timer callback that's pending (either regular or "modal"), - * there is one record of the following type. The normal handlers - * (created by Tcl_CreateTimerHandler) are chained together in a - * list sorted by time (earliest event first). - */ - -typedef struct TimerHandler { - Tcl_Time time; /* When timer is to fire. */ - Tcl_TimerProc *proc; /* Procedure to call. */ - ClientData clientData; /* Argument to pass to proc. */ - Tcl_TimerToken token; /* Identifies event so it can be - * deleted. Not used in modal - * timeouts. */ - struct TimerHandler *nextPtr; /* Next event in queue, or NULL for - * end of queue. */ -} TimerHandler; - -static TimerHandler *firstTimerHandlerPtr = NULL; - /* First event in queue. */ -static int timerEventSourceCreated = 0; /* 0 means that the timer event source - * hasn't yet been registered with the - * Tcl notifier. */ - -/* - * The information below describes a stack of modal timeouts managed by - * Tcl_CreateModalTimer and Tcl_DeleteModalTimer. Only the first element - * in the list is used at any given time. - */ - -static TimerHandler *firstModalHandlerPtr = NULL; - -/* - * The following structure is what's added to the Tcl event queue when - * timer handlers are ready to fire. - */ - -typedef struct TimerEvent { - Tcl_Event header; /* Information that is standard for - * all events. */ - Tcl_Time time; /* All timer events that specify this - * time or earlier are ready - * to fire. */ -} TimerEvent; - -/* - * There is one of the following structures for each of the - * handlers declared in a call to Tcl_DoWhenIdle. All of the - * currently-active handlers are linked together into a list. - */ - -typedef struct IdleHandler { - Tcl_IdleProc (*proc); /* Procedure to call. */ - ClientData clientData; /* Value to pass to proc. */ - int generation; /* Used to distinguish older handlers from - * recently-created ones. */ - struct IdleHandler *nextPtr;/* Next in list of active handlers. */ -} IdleHandler; - -static IdleHandler *idleList = NULL; - /* First in list of all idle handlers. */ -static IdleHandler *lastIdlePtr = NULL; - /* Last in list (or NULL for empty list). */ -static int idleGeneration = 0; /* Used to fill in the "generation" fields - * of IdleHandler structures. Increments - * each time Tcl_DoOneEvent starts calling - * idle handlers, so that all old handlers - * can be called without calling any of the - * new ones created by old ones. */ - -/* - * The data structure below is used by the "after" command to remember - * the command to be executed later. All of the pending "after" commands - * for an interpreter are linked together in a list. - */ - -typedef struct AfterInfo { - struct AfterAssocData *assocPtr; - /* Pointer to the "tclAfter" assocData for - * the interp in which command will be - * executed. */ - char *command; /* Command to execute. Malloc'ed, so must - * be freed when structure is deallocated. */ - int id; /* Integer identifier for command; used to - * cancel it. */ - Tcl_TimerToken token; /* Used to cancel the "after" command. NULL - * means that the command is run as an - * idle handler rather than as a timer - * handler. NULL means this is an "after - * idle" handler rather than a - * timer handler. */ - struct AfterInfo *nextPtr; /* Next in list of all "after" commands for - * this interpreter. */ -} AfterInfo; - -/* - * One of the following structures is associated with each interpreter - * for which an "after" command has ever been invoked. A pointer to - * this structure is stored in the AssocData for the "tclAfter" key. - */ - -typedef struct AfterAssocData { - Tcl_Interp *interp; /* The interpreter for which this data is - * registered. */ - AfterInfo *firstAfterPtr; /* First in list of all "after" commands - * still pending for this interpreter, or - * NULL if none. */ -} AfterAssocData; - -/* - * The data structure below is used to report background errors. One - * such structure is allocated for each error; it holds information - * about the interpreter and the error until bgerror can be invoked - * later as an idle handler. - */ - -typedef struct BgError { - Tcl_Interp *interp; /* Interpreter in which error occurred. NULL - * means this error report has been cancelled - * (a previous report generated a break). */ - char *errorMsg; /* The error message (interp->result when - * the error occurred). Malloc-ed. */ - char *errorInfo; /* Value of the errorInfo variable - * (malloc-ed). */ - char *errorCode; /* Value of the errorCode variable - * (malloc-ed). */ - struct BgError *nextPtr; /* Next in list of all pending error - * reports for this interpreter, or NULL - * for end of list. */ -} BgError; - -/* - * One of the structures below is associated with the "tclBgError" - * assoc data for each interpreter. It keeps track of the head and - * tail of the list of pending background errors for the interpreter. - */ - -typedef struct ErrAssocData { - BgError *firstBgPtr; /* First in list of all background errors - * waiting to be processed for this - * interpreter (NULL if none). */ - BgError *lastBgPtr; /* Last in list of all background errors - * waiting to be processed for this - * interpreter (NULL if none). */ -} ErrAssocData; - -/* - * For each exit handler created with a call to Tcl_CreateExitHandler - * there is a structure of the following type: - */ - -typedef struct ExitHandler { - Tcl_ExitProc *proc; /* Procedure to call when process exits. */ - ClientData clientData; /* One word of information to pass to proc. */ - struct ExitHandler *nextPtr;/* Next in list of all exit handlers for - * this application, or NULL for end of list. */ -} ExitHandler; - -static ExitHandler *firstExitPtr = NULL; - /* First in list of all exit handlers for - * application. */ - -/* - * Structures of the following type are used during the execution - * of Tcl_WaitForFile, to keep track of the file and timeout. - */ - -typedef struct FileWait { - Tcl_File file; /* File to wait on. */ - int mask; /* Conditions to wait for (TCL_READABLE, - * etc.) */ - int timeout; /* Original "timeout" argument to - * Tcl_WaitForFile. */ - Tcl_Time abortTime; /* Time at which to abort the wait. */ - int present; /* Conditions present on the file during - * the last time through the event loop. */ - int done; /* Non-zero means we're done: either one of - * the desired conditions is present or the - * timeout period has elapsed. */ -} FileWait; - -/* - * The following variable is a "secret" indication to Tcl_Exit that - * it should dump out the state of memory before exiting. If the - * value is non-NULL, it gives the name of the file in which to - * dump memory usage information. - */ - -char *tclMemDumpFileName = NULL; - -/* - * Prototypes for procedures referenced only in this file: - */ - -static void AfterCleanupProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp)); -static void AfterProc _ANSI_ARGS_((ClientData clientData)); -static void BgErrorDeleteProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp)); -static void FileHandlerCheckProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static int FileHandlerEventProc _ANSI_ARGS_((Tcl_Event *evPtr, - int flags)); -static void FileHandlerExitProc _ANSI_ARGS_((ClientData data)); -static void FileHandlerSetupProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static void FreeAfterPtr _ANSI_ARGS_((AfterInfo *afterPtr)); -static AfterInfo * GetAfterEvent _ANSI_ARGS_((AfterAssocData *assocPtr, - char *string)); -static void HandleBgErrors _ANSI_ARGS_((ClientData clientData)); -static void TimerHandlerCheckProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static int TimerHandlerEventProc _ANSI_ARGS_((Tcl_Event *evPtr, - int flags)); -static void TimerHandlerExitProc _ANSI_ARGS_((ClientData data)); -static void TimerHandlerSetupProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static char * VwaitVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); - -/* - *-------------------------------------------------------------- - * - * Tcl_CreateFileHandler -- - * - * Arrange for a given procedure to be invoked whenever - * a given file becomes readable or writable. - * - * Results: - * None. - * - * Side effects: - * From now on, whenever the I/O channel given by file becomes - * ready in the way indicated by mask, proc will be invoked. - * See the manual entry for details on the calling sequence - * to proc. If file is already registered then the old mask - * and proc and clientData values will be replaced with - * new ones. - * - *-------------------------------------------------------------- - */ - -void -Tcl_CreateFileHandler( - Tcl_File file, /* Handle of stream to watch. */ - int mask, /* OR'ed combination of TCL_READABLE, - * TCL_WRITABLE, and TCL_EXCEPTION: - * indicates conditions under which - * proc should be called. */ - Tcl_FileProc *proc, /* Procedure to call for each - * selected event. */ - ClientData clientData /* Arbitrary data to pass to proc. */ -) -{ - FileHandler *filePtr; - - if (!fileEventSourceCreated) { - fileEventSourceCreated = 1; - Tcl_CreateEventSource(FileHandlerSetupProc, FileHandlerCheckProc, - (ClientData) NULL); - Tcl_CreateExitHandler(FileHandlerExitProc, (ClientData) NULL); - } - - /* - * Make sure the file isn't already registered. Create a - * new record in the normal case where there's no existing - * record. - */ - - for (filePtr = firstFileHandlerPtr; filePtr != NULL; - filePtr = filePtr->nextPtr) { - if (filePtr->file == file) { - break; - } - } - if (filePtr == NULL) { - filePtr = (FileHandler *) ckalloc(sizeof(FileHandler)); - filePtr->file = file; - filePtr->nextPtr = firstFileHandlerPtr; - firstFileHandlerPtr = filePtr; - } - - /* - * The remainder of the initialization below is done regardless - * of whether or not this is a new record or a modification of - * an old one. - */ - - filePtr->mask = mask; - filePtr->readyMask = 0; - filePtr->proc = proc; - filePtr->clientData = clientData; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_DeleteFileHandler -- - * - * Cancel a previously-arranged callback arrangement for - * a file. - * - * Results: - * None. - * - * Side effects: - * If a callback was previously registered on file, remove it. - * - *-------------------------------------------------------------- - */ - -void -Tcl_DeleteFileHandler( - Tcl_File file /* Stream id for which to remove - * callback procedure. */ -) -{ - FileHandler *filePtr, *prevPtr; - - /* - * Find the entry for the given file (and return if there - * isn't one). - */ - - for (prevPtr = NULL, filePtr = firstFileHandlerPtr; ; - prevPtr = filePtr, filePtr = filePtr->nextPtr) { - if (filePtr == NULL) { - return; - } - if (filePtr->file == file) { - break; - } - } - - /* - * Clean up information in the callback record. - */ - - if (prevPtr == NULL) { - firstFileHandlerPtr = filePtr->nextPtr; - } else { - prevPtr->nextPtr = filePtr->nextPtr; - } - ckfree((char *) filePtr); -} - -/* - *---------------------------------------------------------------------- - * - * FileHandlerExitProc -- - * - * Cleanup procedure to delete the file event source during exit - * cleanup. - * - * Results: - * None. - * - * Side effects: - * Destroys the file event source. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -FileHandlerExitProc( - ClientData clientData /* Not used. */ -) -{ - Tcl_DeleteEventSource(FileHandlerSetupProc, FileHandlerCheckProc, - (ClientData) NULL); -} - -/* - *---------------------------------------------------------------------- - * - * FileHandlerSetupProc -- - * - * This procedure is part of the "event source" for file handlers. - * It is invoked by Tcl_DoOneEvent before it calls select (or - * whatever it uses to wait). - * - * Results: - * None. - * - * Side effects: - * Tells the notifier which files should be waited for. - * - *---------------------------------------------------------------------- - */ - -static void -FileHandlerSetupProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_FILE_EVENTS then we do - * nothing. */ -) -{ - FileHandler *filePtr; - - if (!(flags & TCL_FILE_EVENTS)) { - return; - } - for (filePtr = firstFileHandlerPtr; filePtr != NULL; - filePtr = filePtr->nextPtr) { - if (filePtr->mask != 0) { - Tcl_WatchFile(filePtr->file, filePtr->mask); - } - } -} - -/* - *---------------------------------------------------------------------- - * - * FileHandlerCheckProc -- - * - * This procedure is the second part of the "event source" for - * file handlers. It is invoked by Tcl_DoOneEvent after it calls - * select (or whatever it uses to wait for events). - * - * Results: - * None. - * - * Side effects: - * Makes entries on the Tcl event queue for each file that is - * now ready. - * - *---------------------------------------------------------------------- - */ - -static void -FileHandlerCheckProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_FILE_EVENTS then we do - * nothing. */ -) -{ - FileHandler *filePtr; - FileHandlerEvent *fileEvPtr; - - if (!(flags & TCL_FILE_EVENTS)) { - return; - } - for (filePtr = firstFileHandlerPtr; filePtr != NULL; - filePtr = filePtr->nextPtr) { - if (filePtr->mask != 0) { - filePtr->readyMask = Tcl_FileReady(filePtr->file, filePtr->mask); - if (filePtr->readyMask != 0) { - fileEvPtr = (FileHandlerEvent *) ckalloc( - sizeof(FileHandlerEvent)); - fileEvPtr->header.proc = FileHandlerEventProc; - fileEvPtr->file = filePtr->file; - Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL); - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * FileHandlerEventProc -- - * - * This procedure is called by Tcl_DoOneEvent when a file event - * reaches the front of the event queue. This procedure is responsible - * for actually handling the event by invoking the callback for the - * file handler. - * - * Results: - * Returns 1 if the event was handled, meaning it should be removed - * from the queue. Returns 0 if the event was not handled, meaning - * it should stay on the queue. The only time the event isn't - * handled is if the TCL_FILE_EVENTS flag bit isn't set. - * - * Side effects: - * Whatever the file handler's callback procedure does - * - *---------------------------------------------------------------------- - */ - -static int -FileHandlerEventProc( - Tcl_Event *evPtr, /* Event to service. */ - int flags /* Flags that indicate what events to - * handle, such as TCL_FILE_EVENTS. */ -) -{ - FileHandler *filePtr; - FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) evPtr; - int mask; - - if (!(flags & TCL_FILE_EVENTS)) { - return 0; - } - - /* - * Search through the file handlers to find the one whose handle matches - * the event. We do this rather than keeping a pointer to the file - * handler directly in the event, so that the handler can be deleted - * while the event is queued without leaving a dangling pointer. - */ - - for (filePtr = firstFileHandlerPtr; filePtr != NULL; - filePtr = filePtr->nextPtr) { - if (filePtr->file != fileEvPtr->file) { - continue; - } - - /* - * The code is tricky for two reasons: - * 1. The file handler's desired events could have changed - * since the time when the event was queued, so AND the - * ready mask with the desired mask. - * 2. The file could have been closed and re-opened since - * the time when the event was queued. This is why the - * ready mask is stored in the file handler rather than - * the queued event: it will be zeroed when a new - * file handler is created for the newly opened file. - */ - - mask = filePtr->readyMask & filePtr->mask; - filePtr->readyMask = 0; - if (mask != 0) { - (*filePtr->proc)(filePtr->clientData, mask); - } - break; - } - return 1; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_CreateTimerHandler -- - * - * Arrange for a given procedure to be invoked at a particular - * time in the future. - * - * Results: - * The return value is a token for the timer event, which - * may be used to delete the event before it fires. - * - * Side effects: - * When milliseconds have elapsed, proc will be invoked - * exactly once. - * - *-------------------------------------------------------------- - */ - -Tcl_TimerToken -Tcl_CreateTimerHandler( - int milliseconds, /* How many milliseconds to wait - * before invoking proc. */ - Tcl_TimerProc *proc, /* Procedure to invoke. */ - ClientData clientData /* Arbitrary data to pass to proc. */ -) -{ - TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr; - static int id = 0; - - if (!timerEventSourceCreated) { - timerEventSourceCreated = 1; - Tcl_CreateEventSource(TimerHandlerSetupProc, TimerHandlerCheckProc, - (ClientData) NULL); - Tcl_CreateExitHandler(TimerHandlerExitProc, (ClientData) NULL); - } - - timerHandlerPtr = (TimerHandler *) ckalloc(sizeof(TimerHandler)); - - /* - * Compute when the event should fire. - */ - - TclGetTime(&timerHandlerPtr->time); - timerHandlerPtr->time.sec += milliseconds/1000; - timerHandlerPtr->time.usec += (milliseconds%1000)*1000; - if (timerHandlerPtr->time.usec >= 1000000) { - timerHandlerPtr->time.usec -= 1000000; - timerHandlerPtr->time.sec += 1; - } - - /* - * Fill in other fields for the event. - */ - - timerHandlerPtr->proc = proc; - timerHandlerPtr->clientData = clientData; - id++; - timerHandlerPtr->token = (Tcl_TimerToken) (intptr_t) id; - - /* - * Add the event to the queue in the correct position - * (ordered by event firing time). - */ - - for (tPtr2 = firstTimerHandlerPtr, prevPtr = NULL; tPtr2 != NULL; - prevPtr = tPtr2, tPtr2 = tPtr2->nextPtr) { - if ((tPtr2->time.sec > timerHandlerPtr->time.sec) - || ((tPtr2->time.sec == timerHandlerPtr->time.sec) - && (tPtr2->time.usec > timerHandlerPtr->time.usec))) { - break; - } - } - timerHandlerPtr->nextPtr = tPtr2; - if (prevPtr == NULL) { - firstTimerHandlerPtr = timerHandlerPtr; - } else { - prevPtr->nextPtr = timerHandlerPtr; - } - return timerHandlerPtr->token; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_DeleteTimerHandler -- - * - * Delete a previously-registered timer handler. - * - * Results: - * None. - * - * Side effects: - * Destroy the timer callback identified by TimerToken, - * so that its associated procedure will not be called. - * If the callback has already fired, or if the given - * token doesn't exist, then nothing happens. - * - *-------------------------------------------------------------- - */ - -void -Tcl_DeleteTimerHandler( - Tcl_TimerToken token /* Result previously returned by - * Tcl_DeleteTimerHandler. */ -) -{ - TimerHandler *timerHandlerPtr, *prevPtr; - - for (timerHandlerPtr = firstTimerHandlerPtr, prevPtr = NULL; - timerHandlerPtr != NULL; prevPtr = timerHandlerPtr, - timerHandlerPtr = timerHandlerPtr->nextPtr) { - if (timerHandlerPtr->token != token) { - continue; - } - if (prevPtr == NULL) { - firstTimerHandlerPtr = timerHandlerPtr->nextPtr; - } else { - prevPtr->nextPtr = timerHandlerPtr->nextPtr; - } - ckfree((char *) timerHandlerPtr); - return; - } -} - -/* - *-------------------------------------------------------------- - * - * Tcl_CreateModalTimeout -- - * - * Arrange for a given procedure to be invoked at a particular - * time in the future, independently of all other timer events. - * - * Results: - * None. - * - * Side effects: - * When milliseconds have elapsed, proc will be invoked - * exactly once. - * - *-------------------------------------------------------------- - */ - -void -Tcl_CreateModalTimeout( - int milliseconds, /* How many milliseconds to wait - * before invoking proc. */ - Tcl_TimerProc *proc, /* Procedure to invoke. */ - ClientData clientData /* Arbitrary data to pass to proc. */ -) -{ - TimerHandler *timerHandlerPtr; - - if (!timerEventSourceCreated) { - timerEventSourceCreated = 1; - Tcl_CreateEventSource(TimerHandlerSetupProc, TimerHandlerCheckProc, - (ClientData) NULL); - Tcl_CreateExitHandler(TimerHandlerExitProc, (ClientData) NULL); - } - - timerHandlerPtr = (TimerHandler *) ckalloc(sizeof(TimerHandler)); - - /* - * Compute when the timeout should fire and fill in the other fields - * of the handler. - */ - - TclGetTime(&timerHandlerPtr->time); - timerHandlerPtr->time.sec += milliseconds/1000; - timerHandlerPtr->time.usec += (milliseconds%1000)*1000; - if (timerHandlerPtr->time.usec >= 1000000) { - timerHandlerPtr->time.usec -= 1000000; - timerHandlerPtr->time.sec += 1; - } - timerHandlerPtr->proc = proc; - timerHandlerPtr->clientData = clientData; - - /* - * Push the handler on the top of the modal stack. - */ - - timerHandlerPtr->nextPtr = firstModalHandlerPtr; - firstModalHandlerPtr = timerHandlerPtr; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_DeleteModalTimeout -- - * - * Remove the topmost modal timer handler from the stack of - * modal handlers. - * - * Results: - * None. - * - * Side effects: - * Destroys the topmost modal timeout handler, which must - * match proc and clientData. - * - *-------------------------------------------------------------- - */ - -void -Tcl_DeleteModalTimeout( - Tcl_TimerProc *proc, /* Callback procedure for the timeout. */ - ClientData clientData /* Arbitrary data to pass to proc. */ -) -{ - TimerHandler *timerHandlerPtr; - - timerHandlerPtr = firstModalHandlerPtr; - firstModalHandlerPtr = timerHandlerPtr->nextPtr; - if ((timerHandlerPtr->proc != proc) - || (timerHandlerPtr->clientData != clientData)) { - panic("Tcl_DeleteModalTimeout found timeout stack corrupted"); - } - ckfree((char *) timerHandlerPtr); -} - -/* - *---------------------------------------------------------------------- - * - * TimerHandlerSetupProc -- - * - * This procedure is part of the "event source" for timers. - * It is invoked by Tcl_DoOneEvent before it calls select (or - * whatever it uses to wait). - * - * Results: - * None. - * - * Side effects: - * Tells the notifier how long to sleep if it decides to block. - * - *---------------------------------------------------------------------- - */ - -static void -TimerHandlerSetupProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_TIMER_EVENTS then we only - * consider modal timers. */ -) -{ - TimerHandler *timerHandlerPtr, *tPtr2; - Tcl_Time blockTime; - - /* - * Find the timer handler (regular or modal) that fires first. - */ - - timerHandlerPtr = firstTimerHandlerPtr; - if (!(flags & TCL_TIMER_EVENTS)) { - timerHandlerPtr = NULL; - } - if (timerHandlerPtr != NULL) { - tPtr2 = firstModalHandlerPtr; - if (tPtr2 != NULL) { - if ((timerHandlerPtr->time.sec > tPtr2->time.sec) - || ((timerHandlerPtr->time.sec == tPtr2->time.sec) - && (timerHandlerPtr->time.usec > tPtr2->time.usec))) { - timerHandlerPtr = tPtr2; - } - } - } else { - timerHandlerPtr = firstModalHandlerPtr; - } - if (timerHandlerPtr == NULL) { - return; - } - - TclGetTime(&blockTime); - blockTime.sec = timerHandlerPtr->time.sec - blockTime.sec; - blockTime.usec = timerHandlerPtr->time.usec - blockTime.usec; - if (blockTime.usec < 0) { - blockTime.sec -= 1; - blockTime.usec += 1000000; - } - if (blockTime.sec < 0) { - blockTime.sec = 0; - blockTime.usec = 0; - } - Tcl_SetMaxBlockTime(&blockTime); -} - -/* - *---------------------------------------------------------------------- - * - * TimerHandlerCheckProc -- - * - * This procedure is the second part of the "event source" for - * file handlers. It is invoked by Tcl_DoOneEvent after it calls - * select (or whatever it uses to wait for events). - * - * Results: - * None. - * - * Side effects: - * Makes entries on the Tcl event queue for each file that is - * now ready. - * - *---------------------------------------------------------------------- - */ - -static void -TimerHandlerCheckProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_TIMER_EVENTS then we only - * consider modal timeouts. */ -) -{ - TimerHandler *timerHandlerPtr; - TimerEvent *timerEvPtr; - int triggered, gotTime; - Tcl_Time curTime; - - triggered = 0; - gotTime = 0; - timerHandlerPtr = firstTimerHandlerPtr; - if ((flags & TCL_TIMER_EVENTS) && (timerHandlerPtr != NULL)) { - TclGetTime(&curTime); - gotTime = 1; - if ((timerHandlerPtr->time.sec < curTime.sec) - || ((timerHandlerPtr->time.sec == curTime.sec) - && (timerHandlerPtr->time.usec <= curTime.usec))) { - triggered = 1; - } - } - timerHandlerPtr = firstModalHandlerPtr; - if (timerHandlerPtr != NULL) { - if (!gotTime) { - TclGetTime(&curTime); - } - if ((timerHandlerPtr->time.sec < curTime.sec) - || ((timerHandlerPtr->time.sec == curTime.sec) - && (timerHandlerPtr->time.usec <= curTime.usec))) { - triggered = 1; - } - } - if (triggered) { - timerEvPtr = (TimerEvent *) ckalloc(sizeof(TimerEvent)); - timerEvPtr->header.proc = TimerHandlerEventProc; - timerEvPtr->time.sec = curTime.sec; - timerEvPtr->time.usec = curTime.usec; - Tcl_QueueEvent((Tcl_Event *) timerEvPtr, TCL_QUEUE_TAIL); - } -} - -/* - *---------------------------------------------------------------------- - * - * TimerHandlerExitProc -- - * - * Callback invoked during exit cleanup to destroy the timer event - * source. - * - * Results: - * None. - * - * Side effects: - * Destroys the timer event source. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -TimerHandlerExitProc( - ClientData clientData /* Not used. */ -) -{ - Tcl_DeleteEventSource(TimerHandlerSetupProc, TimerHandlerCheckProc, - (ClientData) NULL); -} - -/* - *---------------------------------------------------------------------- - * - * TimerHandlerEventProc -- - * - * This procedure is called by Tcl_DoOneEvent when a timer event - * reaches the front of the event queue. This procedure handles - * the event by invoking the callbacks for all timers that are - * ready. - * - * Results: - * Returns 1 if the event was handled, meaning it should be removed - * from the queue. Returns 0 if the event was not handled, meaning - * it should stay on the queue. The only time the event isn't - * handled is if the TCL_TIMER_EVENTS flag bit isn't set. - * - * Side effects: - * Whatever the timer handler callback procedures do. - * - *---------------------------------------------------------------------- - */ - -static int -TimerHandlerEventProc( - Tcl_Event *evPtr, /* Event to service. */ - int flags /* Flags that indicate what events to - * handle, such as TCL_FILE_EVENTS. */ -) -{ - TimerHandler *timerHandlerPtr; - TimerEvent *timerEvPtr = (TimerEvent *) evPtr; - - /* - * Invoke the current modal timeout first, if there is one and - * it has triggered. - */ - - timerHandlerPtr = firstModalHandlerPtr; - if (firstModalHandlerPtr != NULL) { - if ((timerHandlerPtr->time.sec < timerEvPtr->time.sec) - || ((timerHandlerPtr->time.sec == timerEvPtr->time.sec) - && (timerHandlerPtr->time.usec <= timerEvPtr->time.usec))) { - (*timerHandlerPtr->proc)(timerHandlerPtr->clientData); - } - } - - /* - * Invoke any normal timers that have fired. - */ - - if (!(flags & TCL_TIMER_EVENTS)) { - return 1; - } - - while (1) { - timerHandlerPtr = firstTimerHandlerPtr; - if (timerHandlerPtr == NULL) { - break; - } - if ((timerHandlerPtr->time.sec > timerEvPtr->time.sec) - || ((timerHandlerPtr->time.sec == timerEvPtr->time.sec) - && (timerHandlerPtr->time.usec >= timerEvPtr->time.usec))) { - break; - } - - /* - * Remove the handler from the queue before invoking it, - * to avoid potential reentrancy problems. - */ - - firstTimerHandlerPtr = timerHandlerPtr->nextPtr; - (*timerHandlerPtr->proc)(timerHandlerPtr->clientData); - ckfree((char *) timerHandlerPtr); - } - return 1; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_DoWhenIdle -- - * - * Arrange for proc to be invoked the next time the system is - * idle (i.e., just before the next time that Tcl_DoOneEvent - * would have to wait for something to happen). - * - * Results: - * None. - * - * Side effects: - * Proc will eventually be called, with clientData as argument. - * See the manual entry for details. - * - *-------------------------------------------------------------- - */ - -void -Tcl_DoWhenIdle( - Tcl_IdleProc *proc, /* Procedure to invoke. */ - ClientData clientData /* Arbitrary value to pass to proc. */ -) -{ - IdleHandler *idlePtr; - - idlePtr = (IdleHandler *) ckalloc(sizeof(IdleHandler)); - idlePtr->proc = proc; - idlePtr->clientData = clientData; - idlePtr->generation = idleGeneration; - idlePtr->nextPtr = NULL; - if (lastIdlePtr == NULL) { - idleList = idlePtr; - } else { - lastIdlePtr->nextPtr = idlePtr; - } - lastIdlePtr = idlePtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CancelIdleCall -- - * - * If there are any when-idle calls requested to a given procedure - * with given clientData, cancel all of them. - * - * Results: - * None. - * - * Side effects: - * If the proc/clientData combination were on the when-idle list, - * they are removed so that they will never be called. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CancelIdleCall( - Tcl_IdleProc *proc, /* Procedure that was previously registered. */ - ClientData clientData /* Arbitrary value to pass to proc. */ -) -{ - IdleHandler *idlePtr, *prevPtr; - IdleHandler *nextPtr; - - for (prevPtr = NULL, idlePtr = idleList; idlePtr != NULL; - prevPtr = idlePtr, idlePtr = idlePtr->nextPtr) { - while ((idlePtr->proc == proc) - && (idlePtr->clientData == clientData)) { - nextPtr = idlePtr->nextPtr; - ckfree((char *) idlePtr); - idlePtr = nextPtr; - if (prevPtr == NULL) { - idleList = idlePtr; - } else { - prevPtr->nextPtr = idlePtr; - } - if (idlePtr == NULL) { - lastIdlePtr = prevPtr; - return; - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * TclIdlePending -- - * - * This function is called by the notifier subsystem to determine - * whether there are any idle handlers currently scheduled. - * - * Results: - * Returns 0 if the idle list is empty, otherwise it returns 1. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclIdlePending(void) -{ - return (idleList == NULL) ? 0 : 1; -} - -/* - *---------------------------------------------------------------------- - * - * TclServiceIdle -- - * - * This procedure is invoked by the notifier when it becomes idle. - * - * Results: - * The return value is 1 if the procedure actually found an idle - * handler to invoke. If no handler was found then 0 is returned. - * - * Side effects: - * Invokes all pending idle handlers. - * - *---------------------------------------------------------------------- - */ - -int -TclServiceIdle(void) -{ - IdleHandler *idlePtr; - int oldGeneration; - int foundIdle; - - if (idleList == NULL) { - return 0; - } - - foundIdle = 0; - oldGeneration = idleGeneration; - idleGeneration++; - - /* - * The code below is trickier than it may look, for the following - * reasons: - * - * 1. New handlers can get added to the list while the current - * one is being processed. If new ones get added, we don't - * want to process them during this pass through the list (want - * to check for other work to do first). This is implemented - * using the generation number in the handler: new handlers - * will have a different generation than any of the ones currently - * on the list. - * 2. The handler can call Tcl_DoOneEvent, so we have to remove - * the handler from the list before calling it. Otherwise an - * infinite loop could result. - * 3. Tcl_CancelIdleCall can be called to remove an element from - * the list while a handler is executing, so the list could - * change structure during the call. - */ - - for (idlePtr = idleList; - ((idlePtr != NULL) - && ((oldGeneration - idlePtr->generation) >= 0)); - idlePtr = idleList) { - idleList = idlePtr->nextPtr; - if (idleList == NULL) { - lastIdlePtr = NULL; - } - foundIdle = 1; - (*idlePtr->proc)(idlePtr->clientData); - ckfree((char *) idlePtr); - } - - return foundIdle; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_BackgroundError -- - * - * This procedure is invoked to handle errors that occur in Tcl - * commands that are invoked in "background" (e.g. from event or - * timer bindings). - * - * Results: - * None. - * - * Side effects: - * The command "bgerror" is invoked later as an idle handler to - * process the error, passing it the error message. If that fails, - * then an error message is output on stderr. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_BackgroundError( - Tcl_Interp *interp /* Interpreter in which an error has - * occurred. */ -) -{ - BgError *errPtr; - char *varValue; - ErrAssocData *assocPtr; - - /* - * The Tcl_AddErrorInfo call below (with an empty string) ensures that - * errorInfo gets properly set. It's needed in cases where the error - * came from a utility procedure like Tcl_GetVar instead of Tcl_Eval; - * in these cases errorInfo still won't have been set when this - * procedure is called. - */ - - Tcl_AddErrorInfo(interp, ""); - errPtr = (BgError *) ckalloc(sizeof(BgError)); - errPtr->interp = interp; - errPtr->errorMsg = (char *) ckalloc((unsigned) (strlen(interp->result) - + 1)); - strcpy(errPtr->errorMsg, interp->result); - varValue = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY); - if (varValue == NULL) { - varValue = errPtr->errorMsg; - } - errPtr->errorInfo = (char *) ckalloc((unsigned) (strlen(varValue) + 1)); - strcpy(errPtr->errorInfo, varValue); - varValue = Tcl_GetVar(interp, "errorCode", TCL_GLOBAL_ONLY); - if (varValue == NULL) { - varValue = ""; - } - errPtr->errorCode = (char *) ckalloc((unsigned) (strlen(varValue) + 1)); - strcpy(errPtr->errorCode, varValue); - errPtr->nextPtr = NULL; - - assocPtr = (ErrAssocData *) Tcl_GetAssocData(interp, "tclBgError", - (Tcl_InterpDeleteProc **) NULL); - if (assocPtr == NULL) { - - /* - * This is the first time a background error has occurred in - * this interpreter. Create associated data to keep track of - * pending error reports. - */ - - assocPtr = (ErrAssocData *) ckalloc(sizeof(ErrAssocData)); - assocPtr->firstBgPtr = NULL; - assocPtr->lastBgPtr = NULL; - Tcl_SetAssocData(interp, "tclBgError", BgErrorDeleteProc, - (ClientData) assocPtr); - } - if (assocPtr->firstBgPtr == NULL) { - assocPtr->firstBgPtr = errPtr; - Tcl_DoWhenIdle(HandleBgErrors, (ClientData) assocPtr); - } else { - assocPtr->lastBgPtr->nextPtr = errPtr; - } - assocPtr->lastBgPtr = errPtr; - Tcl_ResetResult(interp); -} - -/* - *---------------------------------------------------------------------- - * - * HandleBgErrors -- - * - * This procedure is invoked as an idle handler to process all of - * the accumulated background errors. - * - * Results: - * None. - * - * Side effects: - * Depends on what actions "bgerror" takes for the errors. - * - *---------------------------------------------------------------------- - */ - -static void -HandleBgErrors( - ClientData clientData /* Pointer to ErrAssocData structure. */ -) -{ - Tcl_Interp *interp; - char *command; - char *argv[2]; - int code; - BgError *errPtr; - ErrAssocData *assocPtr = (ErrAssocData *) clientData; - Tcl_Channel errChannel; - - while (assocPtr->firstBgPtr != NULL) { - interp = assocPtr->firstBgPtr->interp; - if (interp == NULL) { - goto doneWithReport; - } - - /* - * Restore important state variables to what they were at - * the time the error occurred. - */ - - Tcl_SetVar(interp, "errorInfo", assocPtr->firstBgPtr->errorInfo, - TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "errorCode", assocPtr->firstBgPtr->errorCode, - TCL_GLOBAL_ONLY); - - /* - * Create and invoke the bgerror command. - */ - - argv[0] = "bgerror"; - argv[1] = assocPtr->firstBgPtr->errorMsg; - command = Tcl_Merge(2, argv); - Tcl_AllowExceptions(interp); - Tcl_Preserve((ClientData) interp); - code = Tcl_GlobalEval(interp, command); - ckfree(command); - if (code == TCL_ERROR) { - - /* - * We have to get the error output channel at the latest possible - * time, because the eval (above) might have changed the channel. - */ - - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (errChannel != (Tcl_Channel) NULL) { - if (strcmp(interp->result, - "\"bgerror\" is an invalid command name or ambiguous abbreviation") - == 0) { - Tcl_Write(errChannel, assocPtr->firstBgPtr->errorInfo, -1); - Tcl_Write(errChannel, "\n", -1); - } else { - Tcl_Write(errChannel, - "bgerror failed to handle background error.\n", - -1); - Tcl_Write(errChannel, " Original error: ", -1); - Tcl_Write(errChannel, assocPtr->firstBgPtr->errorMsg, - -1); - Tcl_Write(errChannel, "\n", -1); - Tcl_Write(errChannel, " Error in bgerror: ", -1); - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", -1); - } - Tcl_Flush(errChannel); - } - } else if (code == TCL_BREAK) { - - /* - * Break means cancel any remaining error reports for this - * interpreter. - */ - - for (errPtr = assocPtr->firstBgPtr; errPtr != NULL; - errPtr = errPtr->nextPtr) { - if (errPtr->interp == interp) { - errPtr->interp = NULL; - } - } - } - - Tcl_Release((ClientData) interp); - - /* - * Discard the command and the information about the error report. - */ - - doneWithReport: - ckfree(assocPtr->firstBgPtr->errorMsg); - ckfree(assocPtr->firstBgPtr->errorInfo); - ckfree(assocPtr->firstBgPtr->errorCode); - errPtr = assocPtr->firstBgPtr->nextPtr; - ckfree((char *) assocPtr->firstBgPtr); - assocPtr->firstBgPtr = errPtr; - } - assocPtr->lastBgPtr = NULL; -} - -/* - *---------------------------------------------------------------------- - * - * BgErrorDeleteProc -- - * - * This procedure is associated with the "tclBgError" assoc data - * for an interpreter; it is invoked when the interpreter is - * deleted in order to free the information assoicated with any - * pending error reports. - * - * Results: - * None. - * - * Side effects: - * Background error information is freed: if there were any - * pending error reports, they are cancelled. - * - *---------------------------------------------------------------------- - */ - -static void -BgErrorDeleteProc( - ClientData clientData, /* Pointer to ErrAssocData structure. */ - Tcl_Interp *interp /* Interpreter being deleted. */ -) -{ - ErrAssocData *assocPtr = (ErrAssocData *) clientData; - BgError *errPtr; - - while (assocPtr->firstBgPtr != NULL) { - errPtr = assocPtr->firstBgPtr; - assocPtr->firstBgPtr = errPtr->nextPtr; - ckfree(errPtr->errorMsg); - ckfree(errPtr->errorInfo); - ckfree(errPtr->errorCode); - ckfree((char *) errPtr); - } - ckfree((char *) assocPtr); - Tcl_CancelIdleCall(HandleBgErrors, (ClientData) assocPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateExitHandler -- - * - * Arrange for a given procedure to be invoked just before the - * application exits. - * - * Results: - * None. - * - * Side effects: - * Proc will be invoked with clientData as argument when the - * application exits. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CreateExitHandler( - Tcl_ExitProc *proc, /* Procedure to invoke. */ - ClientData clientData /* Arbitrary value to pass to proc. */ -) -{ - ExitHandler *exitPtr; - - exitPtr = (ExitHandler *) ckalloc(sizeof(ExitHandler)); - exitPtr->proc = proc; - exitPtr->clientData = clientData; - exitPtr->nextPtr = firstExitPtr; - firstExitPtr = exitPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteExitHandler -- - * - * This procedure cancels an existing exit handler matching proc - * and clientData, if such a handler exits. - * - * Results: - * None. - * - * Side effects: - * If there is an exit handler corresponding to proc and clientData - * then it is cancelled; if no such handler exists then nothing - * happens. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteExitHandler( - Tcl_ExitProc *proc, /* Procedure that was previously registered. */ - ClientData clientData /* Arbitrary value to pass to proc. */ -) -{ - ExitHandler *exitPtr, *prevPtr; - - for (prevPtr = NULL, exitPtr = firstExitPtr; exitPtr != NULL; - prevPtr = exitPtr, exitPtr = exitPtr->nextPtr) { - if ((exitPtr->proc == proc) - && (exitPtr->clientData == clientData)) { - if (prevPtr == NULL) { - firstExitPtr = exitPtr->nextPtr; - } else { - prevPtr->nextPtr = exitPtr->nextPtr; - } - ckfree((char *) exitPtr); - return; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Exit -- - * - * This procedure is called to terminate the application. - * - * Results: - * None. - * - * Side effects: - * All existing exit handlers are invoked, then the application - * ends. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_Exit( - int status /* Exit status for application; typically - * 0 for normal return, 1 for error return. */ -) -{ - ExitHandler *exitPtr; - - for (exitPtr = firstExitPtr; exitPtr != NULL; exitPtr = firstExitPtr) { - /* - * Be careful to remove the handler from the list before invoking - * its callback. This protects us against double-freeing if the - * callback should call Tcl_DeleteExitHandler on itself. - */ - - firstExitPtr = exitPtr->nextPtr; - (*exitPtr->proc)(exitPtr->clientData); - ckfree((char *) exitPtr); - } -#ifdef TCL_MEM_DEBUG - if (tclMemDumpFileName != NULL) { - Tcl_DumpActiveMemory(tclMemDumpFileName); - } -#endif - - TclPlatformExit(status); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AfterCmd -- - * - * This procedure is invoked to process the "after" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_AfterCmd( - ClientData clientData, /* Points to the "tclAfter" assocData for - * this interpreter, or NULL if the assocData - * hasn't been created yet.*/ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - /* - * The variable below is used to generate unique identifiers for - * after commands. This id can wrap around, which can potentially - * cause problems. However, there are not likely to be problems - * in practice, because after commands can only be requested to - * about a month in the future, and wrap-around is unlikely to - * occur in less than about 1-10 years. Thus it's unlikely that - * any old ids will still be around when wrap-around occurs. - */ - - static int nextId = 1; - int ms; - AfterInfo *afterPtr; - AfterAssocData *assocPtr = (AfterAssocData *) clientData; - Tcl_CmdInfo cmdInfo; - size_t length; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option ?arg arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Create the "after" information associated for this interpreter, - * if it doesn't already exist. Associate it with the command too, - * so that it will be passed in as the ClientData argument in the - * future. - */ - - if (assocPtr == NULL) { - assocPtr = (AfterAssocData *) ckalloc(sizeof(AfterAssocData)); - assocPtr->interp = interp; - assocPtr->firstAfterPtr = NULL; - Tcl_SetAssocData(interp, "tclAfter", AfterCleanupProc, - (ClientData) assocPtr); - cmdInfo.proc = Tcl_AfterCmd; - cmdInfo.clientData = (ClientData) assocPtr; - cmdInfo.deleteProc = NULL; - cmdInfo.deleteData = (ClientData) assocPtr; - Tcl_SetCommandInfo(interp, argv[0], &cmdInfo); - } - - /* - * Parse the command. - */ - - length = strlen(argv[1]); - if (isdigit(UCHAR(argv[1][0]))) { - if (Tcl_GetInt(interp, argv[1], &ms) != TCL_OK) { - return TCL_ERROR; - } - if (ms < 0) { - ms = 0; - } - if (argc == 2) { - Tcl_Sleep(ms); - return TCL_OK; - } - afterPtr = (AfterInfo *) ckalloc((unsigned) (sizeof(AfterInfo))); - afterPtr->assocPtr = assocPtr; - if (argc == 3) { - afterPtr->command = (char *) ckalloc((unsigned) - (strlen(argv[2]) + 1)); - strcpy(afterPtr->command, argv[2]); - } else { - afterPtr->command = Tcl_Concat(argc-2, argv+2); - } - afterPtr->id = nextId; - nextId += 1; - afterPtr->token = Tcl_CreateTimerHandler(ms, AfterProc, - (ClientData) afterPtr); - afterPtr->nextPtr = assocPtr->firstAfterPtr; - assocPtr->firstAfterPtr = afterPtr; - sprintf(interp->result, "after#%d", afterPtr->id); - } else if (strncmp(argv[1], "cancel", length) == 0) { - char *arg; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " cancel id|command\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - arg = argv[2]; - } else { - arg = Tcl_Concat(argc-2, argv+2); - } - for (afterPtr = assocPtr->firstAfterPtr; afterPtr != NULL; - afterPtr = afterPtr->nextPtr) { - if (strcmp(afterPtr->command, arg) == 0) { - break; - } - } - if (afterPtr == NULL) { - afterPtr = GetAfterEvent(assocPtr, arg); - } - if (arg != argv[2]) { - ckfree(arg); - } - if (afterPtr != NULL) { - if (afterPtr->token != NULL) { - Tcl_DeleteTimerHandler(afterPtr->token); - } else { - Tcl_CancelIdleCall(AfterProc, (ClientData) afterPtr); - } - FreeAfterPtr(afterPtr); - } - } else if ((strncmp(argv[1], "idle", length) == 0) - && (length >= 2)) { - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " idle script script ...\"", (char *) NULL); - return TCL_ERROR; - } - afterPtr = (AfterInfo *) ckalloc((unsigned) (sizeof(AfterInfo))); - afterPtr->assocPtr = assocPtr; - if (argc == 3) { - afterPtr->command = (char *) ckalloc((unsigned) - (strlen(argv[2]) + 1)); - strcpy(afterPtr->command, argv[2]); - } else { - afterPtr->command = Tcl_Concat(argc-2, argv+2); - } - afterPtr->id = nextId; - nextId += 1; - afterPtr->token = NULL; - afterPtr->nextPtr = assocPtr->firstAfterPtr; - assocPtr->firstAfterPtr = afterPtr; - Tcl_DoWhenIdle(AfterProc, (ClientData) afterPtr); - sprintf(interp->result, "after#%d", afterPtr->id); - } else if ((strncmp(argv[1], "info", length) == 0) - && (length >= 2)) { - if (argc == 2) { - char buffer[30]; - - for (afterPtr = assocPtr->firstAfterPtr; afterPtr != NULL; - afterPtr = afterPtr->nextPtr) { - if (assocPtr->interp == interp) { - sprintf(buffer, "after#%d", afterPtr->id); - Tcl_AppendElement(interp, buffer); - } - } - return TCL_OK; - } - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " info ?id?\"", (char *) NULL); - return TCL_ERROR; - } - afterPtr = GetAfterEvent(assocPtr, argv[2]); - if (afterPtr == NULL) { - Tcl_AppendResult(interp, "event \"", argv[2], - "\" doesn't exist", (char *) NULL); - return TCL_ERROR; - } - Tcl_AppendElement(interp, afterPtr->command); - Tcl_AppendElement(interp, - (afterPtr->token == NULL) ? "idle" : "timer"); - } else { - Tcl_AppendResult(interp, "bad argument \"", argv[1], - "\": must be cancel, idle, info, or a number", - (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * GetAfterEvent -- - * - * This procedure parses an "after" id such as "after#4" and - * returns a pointer to the AfterInfo structure. - * - * Results: - * The return value is either a pointer to an AfterInfo structure, - * if one is found that corresponds to "string" and is for interp, - * or NULL if no corresponding after event can be found. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static AfterInfo * -GetAfterEvent( - AfterAssocData *assocPtr, /* Points to "after"-related information for - * this interpreter. */ - char *string /* Textual identifier for after event, such - * as "after#6". */ -) -{ - AfterInfo *afterPtr; - int id; - char *end; - - if (strncmp(string, "after#", 6) != 0) { - return NULL; - } - string += 6; - id = strtoul(string, &end, 10); - if ((end == string) || (*end != 0)) { - return NULL; - } - for (afterPtr = assocPtr->firstAfterPtr; afterPtr != NULL; - afterPtr = afterPtr->nextPtr) { - if (afterPtr->id == id) { - return afterPtr; - } - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * AfterProc -- - * - * Timer callback to execute commands registered with the - * "after" command. - * - * Results: - * None. - * - * Side effects: - * Executes whatever command was specified. If the command - * returns an error, then the command "bgerror" is invoked - * to process the error; if bgerror fails then information - * about the error is output on stderr. - * - *---------------------------------------------------------------------- - */ - -static void -AfterProc( - ClientData clientData /* Describes command to execute. */ -) -{ - AfterInfo *afterPtr = (AfterInfo *) clientData; - AfterAssocData *assocPtr = afterPtr->assocPtr; - AfterInfo *prevPtr; - int result; - Tcl_Interp *interp; - - /* - * First remove the callback from our list of callbacks; otherwise - * someone could delete the callback while it's being executed, which - * could cause a core dump. - */ - - if (assocPtr->firstAfterPtr == afterPtr) { - assocPtr->firstAfterPtr = afterPtr->nextPtr; - } else { - for (prevPtr = assocPtr->firstAfterPtr; prevPtr->nextPtr != afterPtr; - prevPtr = prevPtr->nextPtr) { - /* Empty loop body. */ - } - prevPtr->nextPtr = afterPtr->nextPtr; - } - - /* - * Execute the callback. - */ - - interp = assocPtr->interp; - Tcl_Preserve((ClientData) interp); - result = Tcl_GlobalEval(interp, afterPtr->command); - if (result != TCL_OK) { - Tcl_AddErrorInfo(interp, "\n (\"after\" script)"); - Tcl_BackgroundError(interp); - } - Tcl_Release((ClientData) interp); - - /* - * Free the memory for the callback. - */ - - ckfree(afterPtr->command); - ckfree((char *) afterPtr); -} - -/* - *---------------------------------------------------------------------- - * - * FreeAfterPtr -- - * - * This procedure removes an "after" command from the list of - * those that are pending and frees its resources. This procedure - * does *not* cancel the timer handler; if that's needed, the - * caller must do it. - * - * Results: - * None. - * - * Side effects: - * The memory associated with afterPtr is released. - * - *---------------------------------------------------------------------- - */ - -static void -FreeAfterPtr( - AfterInfo *afterPtr /* Command to be deleted. */ -) -{ - AfterInfo *prevPtr; - AfterAssocData *assocPtr = afterPtr->assocPtr; - - if (assocPtr->firstAfterPtr == afterPtr) { - assocPtr->firstAfterPtr = afterPtr->nextPtr; - } else { - for (prevPtr = assocPtr->firstAfterPtr; prevPtr->nextPtr != afterPtr; - prevPtr = prevPtr->nextPtr) { - /* Empty loop body. */ - } - prevPtr->nextPtr = afterPtr->nextPtr; - } - ckfree(afterPtr->command); - ckfree((char *) afterPtr); -} - -/* - *---------------------------------------------------------------------- - * - * AfterCleanupProc -- - * - * This procedure is invoked whenever an interpreter is deleted - * to cleanup the AssocData for "tclAfter". - * - * Results: - * None. - * - * Side effects: - * After commands are removed. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -AfterCleanupProc( - ClientData clientData, /* Points to AfterAssocData for the - * interpreter. */ - Tcl_Interp *interp /* Interpreter that is being deleted. */ -) -{ - AfterAssocData *assocPtr = (AfterAssocData *) clientData; - AfterInfo *afterPtr; - - while (assocPtr->firstAfterPtr != NULL) { - afterPtr = assocPtr->firstAfterPtr; - assocPtr->firstAfterPtr = afterPtr->nextPtr; - if (afterPtr->token != NULL) { - Tcl_DeleteTimerHandler(afterPtr->token); - } else { - Tcl_CancelIdleCall(AfterProc, (ClientData) afterPtr); - } - ckfree(afterPtr->command); - ckfree((char *) afterPtr); - } - ckfree((char *) assocPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_VwaitCmd -- - * - * This procedure is invoked to process the "vwait" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_VwaitCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int done, foundEvent; - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " name\"", (char *) NULL); - return TCL_ERROR; - } - Tcl_TraceVar(interp, argv[1], - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VwaitVarProc, (ClientData) &done); - done = 0; - foundEvent = 1; - while (!done && foundEvent) { - foundEvent = Tcl_DoOneEvent(0); - } - Tcl_UntraceVar(interp, argv[1], - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VwaitVarProc, (ClientData) &done); - - /* - * Clear out the interpreter's result, since it may have been set - * by event handlers. - */ - - Tcl_ResetResult(interp); - if (!foundEvent) { - Tcl_AppendResult(interp, "can't wait for variable \"", argv[1], - "\": would wait forever", (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - - /* ARGSUSED */ -static char * -VwaitVarProc( - ClientData clientData, /* Pointer to integer to set to 1. */ - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *name1, /* Name of variable. */ - char *name2, /* Second part of variable name. */ - int flags /* Information about what happened. */ -) -{ - int *donePtr = (int *) clientData; - - *donePtr = 1; - return (char *) NULL; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UpdateCmd -- - * - * This procedure is invoked to process the "update" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_UpdateCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int flags = 0; /* Initialization needed only to stop - * compiler warnings. */ - - if (argc == 1) { - flags = TCL_ALL_EVENTS|TCL_DONT_WAIT; - } else if (argc == 2) { - if (strncmp(argv[1], "idletasks", strlen(argv[1])) != 0) { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be idletasks", (char *) NULL); - return TCL_ERROR; - } - flags = TCL_IDLE_EVENTS|TCL_DONT_WAIT; - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ?idletasks?\"", (char *) NULL); - return TCL_ERROR; - } - - while (Tcl_DoOneEvent(flags) != 0) { - /* Empty loop body */ - } - - /* - * Must clear the interpreter's result because event handlers could - * have executed commands. - */ - - Tcl_ResetResult(interp); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclWaitForFile -- - * - * This procedure waits synchronously for a file to become readable - * or writable, with an optional timeout. - * - * Results: - * The return value is an OR'ed combination of TCL_READABLE, - * TCL_WRITABLE, and TCL_EXCEPTION, indicating the conditions - * that are present on file at the time of the return. This - * procedure will not return until either "timeout" milliseconds - * have elapsed or at least one of the conditions given by mask - * has occurred for file (a return value of 0 means that a timeout - * occurred). No normal events will be serviced during the - * execution of this procedure. - * - * Side effects: - * Time passes. - * - *---------------------------------------------------------------------- - */ - -int -TclWaitForFile( - Tcl_File file, /* Handle for file on which to wait. */ - int mask, /* What to wait for: OR'ed combination of - * TCL_READABLE, TCL_WRITABLE, and - * TCL_EXCEPTION. */ - int timeout /* Maximum amount of time to wait for one - * of the conditions in mask to occur, in - * milliseconds. A value of 0 means don't - * wait at all, and a value of -1 means - * wait forever. */ -) -{ - Tcl_Time abortTime, now, blockTime; - int present; - - /* - * If there is a non-zero finite timeout, compute the time when - * we give up. - */ - - if (timeout > 0) { - TclGetTime(&now); - abortTime.sec = now.sec + timeout/1000; - abortTime.usec = now.usec + (timeout%1000)*1000; - if (abortTime.usec >= 1000000) { - abortTime.usec -= 1000000; - abortTime.sec += 1; - } - } - - /* - * Loop in a mini-event loop of our own, waiting for either the - * file to become ready or a timeout to occur. - */ - - while (1) { - Tcl_WatchFile(file, mask); - if (timeout > 0) { - blockTime.sec = abortTime.sec - now.sec; - blockTime.usec = abortTime.usec - now.usec; - if (blockTime.usec < 0) { - blockTime.sec -= 1; - blockTime.usec += 1000000; - } - if (blockTime.sec < 0) { - blockTime.sec = 0; - blockTime.usec = 0; - } - Tcl_WaitForEvent(&blockTime); - } else if (timeout == 0) { - blockTime.sec = 0; - blockTime.usec = 0; - Tcl_WaitForEvent(&blockTime); - } else { - Tcl_WaitForEvent((Tcl_Time *) NULL); - } - present = Tcl_FileReady(file, mask); - if (present != 0) { - break; - } - if (timeout == 0) { - break; - } - TclGetTime(&now); - if ((abortTime.sec < now.sec) - || ((abortTime.sec == now.sec) - && (abortTime.usec <= now.usec))) { - break; - } - } - return present; -} diff --git a/cde/programs/dtdocbook/tcl/tclExpr.c b/cde/programs/dtdocbook/tcl/tclExpr.c deleted file mode 100644 index 85f4832d9..000000000 --- a/cde/programs/dtdocbook/tcl/tclExpr.c +++ /dev/null @@ -1,2105 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclExpr.c /main/2 1996/08/08 14:43:48 cde-hp $ */ -/* - * tclExpr.c -- - * - * This file contains the code to evaluate expressions for - * Tcl. - * - * This implementation of floating-point support was modelled - * after an initial implementation by Bill Carpenter. - * - * Copyright (c) 1987-1994 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclExpr.c 1.91 96/02/15 11:42:44 - */ - -#include "tclInt.h" -#ifdef NO_FLOAT_H -# include "../compat/float.h" -#else -# include <float.h> -#endif -#ifndef TCL_NO_MATH -#include <math.h> -#endif - -/* - * The stuff below is a bit of a hack so that this file can be used - * in environments that include no UNIX, i.e. no errno. Just define - * errno here. - */ - -#ifndef TCL_GENERIC_ONLY -#include "tclPort.h" -#else -#define NO_ERRNO_H -#endif - -#ifdef NO_ERRNO_H -int errno; -#define EDOM 33 -#define ERANGE 34 -#endif - -/* - * The data structure below is used to describe an expression value, - * which can be either an integer (the usual case), a double-precision - * floating-point value, or a string. A given number has only one - * value at a time. - */ - -#define STATIC_STRING_SPACE 150 - -typedef struct { - long intValue; /* Integer value, if any. */ - double doubleValue; /* Floating-point value, if any. */ - ParseValue pv; /* Used to hold a string value, if any. */ - char staticSpace[STATIC_STRING_SPACE]; - /* Storage for small strings; large ones - * are malloc-ed. */ - int type; /* Type of value: TYPE_INT, TYPE_DOUBLE, - * or TYPE_STRING. */ -} Value; - -/* - * Valid values for type: - */ - -#define TYPE_INT 0 -#define TYPE_DOUBLE 1 -#define TYPE_STRING 2 - -/* - * The data structure below describes the state of parsing an expression. - * It's passed among the routines in this module. - */ - -typedef struct { - char *originalExpr; /* The entire expression, as originally - * passed to Tcl_ExprString et al. */ - char *expr; /* Position to the next character to be - * scanned from the expression string. */ - int token; /* Type of the last token to be parsed from - * expr. See below for definitions. - * Corresponds to the characters just - * before expr. */ -} ExprInfo; - -/* - * The token types are defined below. In addition, there is a table - * associating a precedence with each operator. The order of types - * is important. Consult the code before changing it. - */ - -#define VALUE 0 -#define OPEN_PAREN 1 -#define CLOSE_PAREN 2 -#define COMMA 3 -#define END 4 -#define UNKNOWN 5 - -/* - * Binary operators: - */ - -#define MULT 8 -#define DIVIDE 9 -#define MOD 10 -#define PLUS 11 -#define MINUS 12 -#define LEFT_SHIFT 13 -#define RIGHT_SHIFT 14 -#define LESS 15 -#define GREATER 16 -#define LEQ 17 -#define GEQ 18 -#define EQUAL 19 -#define NEQ 20 -#define BIT_AND 21 -#define BIT_XOR 22 -#define BIT_OR 23 -#define AND 24 -#define OR 25 -#define QUESTY 26 -#define COLON 27 - -/* - * Unary operators: - */ - -#define UNARY_MINUS 28 -#define UNARY_PLUS 29 -#define NOT 30 -#define BIT_NOT 31 - -/* - * Precedence table. The values for non-operator token types are ignored. - */ - -static int precTable[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 12, 12, 12, /* MULT, DIVIDE, MOD */ - 11, 11, /* PLUS, MINUS */ - 10, 10, /* LEFT_SHIFT, RIGHT_SHIFT */ - 9, 9, 9, 9, /* LESS, GREATER, LEQ, GEQ */ - 8, 8, /* EQUAL, NEQ */ - 7, /* BIT_AND */ - 6, /* BIT_XOR */ - 5, /* BIT_OR */ - 4, /* AND */ - 3, /* OR */ - 2, /* QUESTY */ - 1, /* COLON */ - 13, 13, 13, 13 /* UNARY_MINUS, UNARY_PLUS, NOT, - * BIT_NOT */ -}; - -/* - * Mapping from operator numbers to strings; used for error messages. - */ - -static char *operatorStrings[] = { - "VALUE", "(", ")", ",", "END", "UNKNOWN", "6", "7", - "*", "/", "%", "+", "-", "<<", ">>", "<", ">", "<=", - ">=", "==", "!=", "&", "^", "|", "&&", "||", "?", ":", - "-", "+", "!", "~" -}; - -/* - * The following slight modification to DBL_MAX is needed because of - * a compiler bug on Sprite (4/15/93). - */ - -#ifdef sprite -#undef DBL_MAX -#define DBL_MAX 1.797693134862316e+307 -#endif - -/* - * Macros for testing floating-point values for certain special - * cases. Test for not-a-number by comparing a value against - * itself; test for infinity by comparing against the largest - * floating-point value. - */ - -#define IS_NAN(v) ((v) != (v)) -#ifdef DBL_MAX -# define IS_INF(v) (((v) > DBL_MAX) || ((v) < -DBL_MAX)) -#else -# define IS_INF(v) 0 -#endif - -/* - * The following global variable is use to signal matherr that Tcl - * is responsible for the arithmetic, so errors can be handled in a - * fashion appropriate for Tcl. Zero means no Tcl math is in - * progress; non-zero means Tcl is doing math. - */ - -int tcl_MathInProgress = 0; - -/* - * The variable below serves no useful purpose except to generate - * a reference to matherr, so that the Tcl version of matherr is - * linked in rather than the system version. Without this reference - * the need for matherr won't be discovered during linking until after - * libtcl.a has been processed, so Tcl's version won't be used. - */ - -#ifdef NEED_MATHERR -extern int matherr(); -int (*tclMatherrPtr)() = matherr; -#endif - -/* - * Declarations for local procedures to this file: - */ - -static int ExprAbsFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); -static int ExprBinaryFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); -static int ExprDoubleFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); -static int ExprGetValue _ANSI_ARGS_((Tcl_Interp *interp, - ExprInfo *infoPtr, int prec, Value *valuePtr)); -static int ExprIntFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); -static int ExprLex _ANSI_ARGS_((Tcl_Interp *interp, - ExprInfo *infoPtr, Value *valuePtr)); -static int ExprLooksLikeInt _ANSI_ARGS_((char *p)); -static void ExprMakeString _ANSI_ARGS_((Tcl_Interp *interp, - Value *valuePtr)); -static int ExprMathFunc _ANSI_ARGS_((Tcl_Interp *interp, - ExprInfo *infoPtr, Value *valuePtr)); -static int ExprParseString _ANSI_ARGS_((Tcl_Interp *interp, - char *string, Value *valuePtr)); -static int ExprRoundFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); -static int ExprTopLevel _ANSI_ARGS_((Tcl_Interp *interp, - char *string, Value *valuePtr)); -static int ExprUnaryFunc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tcl_Value *args, - Tcl_Value *resultPtr)); - -/* - * Built-in math functions: - */ - -typedef struct { - char *name; /* Name of function. */ - int numArgs; /* Number of arguments for function. */ - Tcl_ValueType argTypes[MAX_MATH_ARGS]; - /* Acceptable types for each argument. */ - Tcl_MathProc *proc; /* Procedure that implements this function. */ - ClientData clientData; /* Additional argument to pass to the function - * when invoking it. */ -} BuiltinFunc; - -static BuiltinFunc funcTable[] = { -#ifndef TCL_NO_MATH - {"acos", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) acos}, - {"asin", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) asin}, - {"atan", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) atan}, - {"atan2", 2, {TCL_DOUBLE, TCL_DOUBLE}, ExprBinaryFunc, (ClientData) atan2}, - {"ceil", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) ceil}, - {"cos", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) cos}, - {"cosh", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) cosh}, - {"exp", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) exp}, - {"floor", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) floor}, - {"fmod", 2, {TCL_DOUBLE, TCL_DOUBLE}, ExprBinaryFunc, (ClientData) fmod}, - {"hypot", 2, {TCL_DOUBLE, TCL_DOUBLE}, ExprBinaryFunc, (ClientData) hypot}, - {"log", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) log}, - {"log10", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) log10}, - {"pow", 2, {TCL_DOUBLE, TCL_DOUBLE}, ExprBinaryFunc, (ClientData) pow}, - {"sin", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) sin}, - {"sinh", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) sinh}, - {"sqrt", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) sqrt}, - {"tan", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) tan}, - {"tanh", 1, {TCL_DOUBLE}, ExprUnaryFunc, (ClientData) tanh}, -#endif - {"abs", 1, {TCL_EITHER}, ExprAbsFunc, 0}, - {"double", 1, {TCL_EITHER}, ExprDoubleFunc, 0}, - {"int", 1, {TCL_EITHER}, ExprIntFunc, 0}, - {"round", 1, {TCL_EITHER}, ExprRoundFunc, 0}, - - {0}, -}; - -/* - *-------------------------------------------------------------- - * - * ExprParseString -- - * - * Given a string (such as one coming from command or variable - * substitution), make a Value based on the string. The value - * will be a floating-point or integer, if possible, or else it - * will just be a copy of the string. - * - * Results: - * TCL_OK is returned under normal circumstances, and TCL_ERROR - * is returned if a floating-point overflow or underflow occurred - * while reading in a number. The value at *valuePtr is modified - * to hold a number, if possible. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -static int -ExprParseString( - Tcl_Interp *interp, /* Where to store error message. */ - char *string, /* String to turn into value. */ - Value *valuePtr /* Where to store value information. - * Caller must have initialized pv field. */ -) -{ - char *term, *p, *start; - - if (*string != 0) { - if (ExprLooksLikeInt(string)) { - valuePtr->type = TYPE_INT; - errno = 0; - - /* - * Note: use strtoul instead of strtol for integer conversions - * to allow full-size unsigned numbers, but don't depend on - * strtoul to handle sign characters; it won't in some - * implementations. - */ - - for (p = string; isspace(UCHAR(*p)); p++) { - /* Empty loop body. */ - } - if (*p == '-') { - start = p+1; - valuePtr->intValue = -((int)strtoul(start, &term, 0)); - } else if (*p == '+') { - start = p+1; - valuePtr->intValue = strtoul(start, &term, 0); - } else { - start = p; - valuePtr->intValue = strtoul(start, &term, 0); - } - if (*term == 0) { - if (errno == ERANGE) { - /* - * This procedure is sometimes called with string in - * interp->result, so we have to clear the result before - * logging an error message. - */ - - Tcl_ResetResult(interp); - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - return TCL_ERROR; - } else { - return TCL_OK; - } - } - } else { - errno = 0; -#ifdef __NetBSD__ - valuePtr->doubleValue = (double)strtof(string, &term); -#else - valuePtr->doubleValue = strtod(string, &term); -#endif - if ((term != string) && (*term == 0)) { - if (errno != 0) { - Tcl_ResetResult(interp); - TclExprFloatError(interp, valuePtr->doubleValue); - return TCL_ERROR; - } - valuePtr->type = TYPE_DOUBLE; - return TCL_OK; - } - } - } - - /* - * Not a valid number. Save a string value (but don't do anything - * if it's already the value). - */ - - valuePtr->type = TYPE_STRING; - if (string != valuePtr->pv.buffer) { - int length, shortfall; - - length = strlen(string); - valuePtr->pv.next = valuePtr->pv.buffer; - shortfall = length - (valuePtr->pv.end - valuePtr->pv.buffer); - if (shortfall > 0) { - (*valuePtr->pv.expandProc)(&valuePtr->pv, shortfall); - } - strcpy(valuePtr->pv.buffer, string); - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * ExprLex -- - * - * Lexical analyzer for expression parser: parses a single value, - * operator, or other syntactic element from an expression string. - * - * Results: - * TCL_OK is returned unless an error occurred while doing lexical - * analysis or executing an embedded command. In that case a - * standard Tcl error is returned, using interp->result to hold - * an error message. In the event of a successful return, the token - * and field in infoPtr is updated to refer to the next symbol in - * the expression string, and the expr field is advanced past that - * token; if the token is a value, then the value is stored at - * valuePtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ExprLex( - Tcl_Interp *interp, /* Interpreter to use for error - * reporting. */ - ExprInfo *infoPtr, /* Describes the state of the parse. */ - Value *valuePtr /* Where to store value, if that is - * what's parsed from string. Caller - * must have initialized pv field - * correctly. */ -) -{ - char *p; - char *var, *term; - int result; - - p = infoPtr->expr; - while (isspace(UCHAR(*p))) { - p++; - } - if (*p == 0) { - infoPtr->token = END; - infoPtr->expr = p; - return TCL_OK; - } - - /* - * First try to parse the token as an integer or floating-point number. - * Don't want to check for a number if the first character is "+" - * or "-". If we do, we might treat a binary operator as unary by - * mistake, which will eventually cause a syntax error. - */ - - if ((*p != '+') && (*p != '-')) { - if (ExprLooksLikeInt(p)) { - errno = 0; - valuePtr->intValue = strtoul(p, &term, 0); - if (errno == ERANGE) { - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - return TCL_ERROR; - } - infoPtr->token = VALUE; - infoPtr->expr = term; - valuePtr->type = TYPE_INT; - return TCL_OK; - } else { - errno = 0; -#ifdef __NetBSD__ - valuePtr->doubleValue = (double)strtof(p, &term); -#else - valuePtr->doubleValue = strtod(p, &term); -#endif - if (term != p) { - if (errno != 0) { - TclExprFloatError(interp, valuePtr->doubleValue); - return TCL_ERROR; - } - infoPtr->token = VALUE; - infoPtr->expr = term; - valuePtr->type = TYPE_DOUBLE; - return TCL_OK; - } - } - } - - infoPtr->expr = p+1; - switch (*p) { - case '$': - - /* - * Variable. Fetch its value, then see if it makes sense - * as an integer or floating-point number. - */ - - infoPtr->token = VALUE; - var = Tcl_ParseVar(interp, p, &infoPtr->expr); - if (var == NULL) { - return TCL_ERROR; - } - Tcl_ResetResult(interp); - if (((Interp *) interp)->noEval) { - valuePtr->type = TYPE_INT; - valuePtr->intValue = 0; - return TCL_OK; - } - return ExprParseString(interp, var, valuePtr); - - case '[': - infoPtr->token = VALUE; - ((Interp *) interp)->evalFlags = TCL_BRACKET_TERM; - result = Tcl_Eval(interp, p+1); - infoPtr->expr = ((Interp *) interp)->termPtr; - if (result != TCL_OK) { - return result; - } - infoPtr->expr++; - if (((Interp *) interp)->noEval) { - valuePtr->type = TYPE_INT; - valuePtr->intValue = 0; - Tcl_ResetResult(interp); - return TCL_OK; - } - result = ExprParseString(interp, interp->result, valuePtr); - if (result != TCL_OK) { - return result; - } - Tcl_ResetResult(interp); - return TCL_OK; - - case '"': - infoPtr->token = VALUE; - result = TclParseQuotes(interp, infoPtr->expr, '"', 0, - &infoPtr->expr, &valuePtr->pv); - if (result != TCL_OK) { - return result; - } - Tcl_ResetResult(interp); - return ExprParseString(interp, valuePtr->pv.buffer, valuePtr); - - case '{': - infoPtr->token = VALUE; - result = TclParseBraces(interp, infoPtr->expr, &infoPtr->expr, - &valuePtr->pv); - if (result != TCL_OK) { - return result; - } - Tcl_ResetResult(interp); - return ExprParseString(interp, valuePtr->pv.buffer, valuePtr); - - case '(': - infoPtr->token = OPEN_PAREN; - return TCL_OK; - - case ')': - infoPtr->token = CLOSE_PAREN; - return TCL_OK; - - case ',': - infoPtr->token = COMMA; - return TCL_OK; - - case '*': - infoPtr->token = MULT; - return TCL_OK; - - case '/': - infoPtr->token = DIVIDE; - return TCL_OK; - - case '%': - infoPtr->token = MOD; - return TCL_OK; - - case '+': - infoPtr->token = PLUS; - return TCL_OK; - - case '-': - infoPtr->token = MINUS; - return TCL_OK; - - case '?': - infoPtr->token = QUESTY; - return TCL_OK; - - case ':': - infoPtr->token = COLON; - return TCL_OK; - - case '<': - switch (p[1]) { - case '<': - infoPtr->expr = p+2; - infoPtr->token = LEFT_SHIFT; - break; - case '=': - infoPtr->expr = p+2; - infoPtr->token = LEQ; - break; - default: - infoPtr->token = LESS; - break; - } - return TCL_OK; - - case '>': - switch (p[1]) { - case '>': - infoPtr->expr = p+2; - infoPtr->token = RIGHT_SHIFT; - break; - case '=': - infoPtr->expr = p+2; - infoPtr->token = GEQ; - break; - default: - infoPtr->token = GREATER; - break; - } - return TCL_OK; - - case '=': - if (p[1] == '=') { - infoPtr->expr = p+2; - infoPtr->token = EQUAL; - } else { - infoPtr->token = UNKNOWN; - } - return TCL_OK; - - case '!': - if (p[1] == '=') { - infoPtr->expr = p+2; - infoPtr->token = NEQ; - } else { - infoPtr->token = NOT; - } - return TCL_OK; - - case '&': - if (p[1] == '&') { - infoPtr->expr = p+2; - infoPtr->token = AND; - } else { - infoPtr->token = BIT_AND; - } - return TCL_OK; - - case '^': - infoPtr->token = BIT_XOR; - return TCL_OK; - - case '|': - if (p[1] == '|') { - infoPtr->expr = p+2; - infoPtr->token = OR; - } else { - infoPtr->token = BIT_OR; - } - return TCL_OK; - - case '~': - infoPtr->token = BIT_NOT; - return TCL_OK; - - default: - if (isalpha(UCHAR(*p))) { - infoPtr->expr = p; - return ExprMathFunc(interp, infoPtr, valuePtr); - } - infoPtr->expr = p+1; - infoPtr->token = UNKNOWN; - return TCL_OK; - } -} - -/* - *---------------------------------------------------------------------- - * - * ExprGetValue -- - * - * Parse a "value" from the remainder of the expression in infoPtr. - * - * Results: - * Normally TCL_OK is returned. The value of the expression is - * returned in *valuePtr. If an error occurred, then interp->result - * contains an error message and TCL_ERROR is returned. - * InfoPtr->token will be left pointing to the token AFTER the - * expression, and infoPtr->expr will point to the character just - * after the terminating token. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ExprGetValue( - Tcl_Interp *interp, /* Interpreter to use for error - * reporting. */ - ExprInfo *infoPtr, /* Describes the state of the parse - * just before the value (i.e. ExprLex - * will be called to get first token - * of value). */ - int prec, /* Treat any un-parenthesized operator - * with precedence <= this as the end - * of the expression. */ - Value *valuePtr /* Where to store the value of the - * expression. Caller must have - * initialized pv field. */ -) -{ - Interp *iPtr = (Interp *) interp; - Value value2; /* Second operand for current - * operator. */ - int operator; /* Current operator (either unary - * or binary). */ - int badType; /* Type of offending argument; used - * for error messages. */ - int gotOp; /* Non-zero means already lexed the - * operator (while picking up value - * for unary operator). Don't lex - * again. */ - int result; - - /* - * There are two phases to this procedure. First, pick off an initial - * value. Then, parse (binary operator, value) pairs until done. - */ - - gotOp = 0; - value2.pv.buffer = value2.pv.next = value2.staticSpace; - value2.pv.end = value2.pv.buffer + STATIC_STRING_SPACE - 1; - value2.pv.expandProc = TclExpandParseValue; - value2.pv.clientData = (ClientData) NULL; - result = ExprLex(interp, infoPtr, valuePtr); - if (result != TCL_OK) { - goto done; - } - if (infoPtr->token == OPEN_PAREN) { - - /* - * Parenthesized sub-expression. - */ - - result = ExprGetValue(interp, infoPtr, -1, valuePtr); - if (result != TCL_OK) { - goto done; - } - if (infoPtr->token != CLOSE_PAREN) { - Tcl_AppendResult(interp, "unmatched parentheses in expression \"", - infoPtr->originalExpr, "\"", (char *) NULL); - result = TCL_ERROR; - goto done; - } - } else { - if (infoPtr->token == MINUS) { - infoPtr->token = UNARY_MINUS; - } - if (infoPtr->token == PLUS) { - infoPtr->token = UNARY_PLUS; - } - if (infoPtr->token >= UNARY_MINUS) { - - /* - * Process unary operators. - */ - - operator = infoPtr->token; - result = ExprGetValue(interp, infoPtr, precTable[infoPtr->token], - valuePtr); - if (result != TCL_OK) { - goto done; - } - if (!iPtr->noEval) { - switch (operator) { - case UNARY_MINUS: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = -valuePtr->intValue; - } else if (valuePtr->type == TYPE_DOUBLE){ - valuePtr->doubleValue = -valuePtr->doubleValue; - } else { - badType = valuePtr->type; - goto illegalType; - } - break; - case UNARY_PLUS: - if ((valuePtr->type != TYPE_INT) - && (valuePtr->type != TYPE_DOUBLE)) { - badType = valuePtr->type; - goto illegalType; - } - break; - case NOT: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = !valuePtr->intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - /* - * Theoretically, should be able to use - * "!valuePtr->intValue", but apparently some - * compilers can't handle it. - */ - if (valuePtr->doubleValue == 0.0) { - valuePtr->intValue = 1; - } else { - valuePtr->intValue = 0; - } - valuePtr->type = TYPE_INT; - } else { - badType = valuePtr->type; - goto illegalType; - } - break; - case BIT_NOT: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = ~valuePtr->intValue; - } else { - badType = valuePtr->type; - goto illegalType; - } - break; - } - } - gotOp = 1; - } else if (infoPtr->token != VALUE) { - goto syntaxError; - } - } - - /* - * Got the first operand. Now fetch (operator, operand) pairs. - */ - - if (!gotOp) { - result = ExprLex(interp, infoPtr, &value2); - if (result != TCL_OK) { - goto done; - } - } - while (1) { - operator = infoPtr->token; - value2.pv.next = value2.pv.buffer; - if ((operator < MULT) || (operator >= UNARY_MINUS)) { - if ((operator == END) || (operator == CLOSE_PAREN) - || (operator == COMMA)) { - result = TCL_OK; - goto done; - } else { - goto syntaxError; - } - } - if (precTable[operator] <= prec) { - result = TCL_OK; - goto done; - } - - /* - * If we're doing an AND or OR and the first operand already - * determines the result, don't execute anything in the - * second operand: just parse. Same style for ?: pairs. - */ - - if ((operator == AND) || (operator == OR) || (operator == QUESTY)) { - if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = valuePtr->doubleValue != 0; - valuePtr->type = TYPE_INT; - } else if (valuePtr->type == TYPE_STRING) { - if (!iPtr->noEval) { - badType = TYPE_STRING; - goto illegalType; - } - - /* - * Must set valuePtr->intValue to avoid referencing - * uninitialized memory in the "if" below; the atual - * value doesn't matter, since it will be ignored. - */ - - valuePtr->intValue = 0; - } - if (((operator == AND) && !valuePtr->intValue) - || ((operator == OR) && valuePtr->intValue)) { - iPtr->noEval++; - result = ExprGetValue(interp, infoPtr, precTable[operator], - &value2); - iPtr->noEval--; - if (operator == OR) { - valuePtr->intValue = 1; - } - continue; - } else if (operator == QUESTY) { - /* - * Special note: ?: operators must associate right to - * left. To make this happen, use a precedence one lower - * than QUESTY when calling ExprGetValue recursively. - */ - - if (valuePtr->intValue != 0) { - valuePtr->pv.next = valuePtr->pv.buffer; - result = ExprGetValue(interp, infoPtr, - precTable[QUESTY] - 1, valuePtr); - if (result != TCL_OK) { - goto done; - } - if (infoPtr->token != COLON) { - goto syntaxError; - } - value2.pv.next = value2.pv.buffer; - iPtr->noEval++; - result = ExprGetValue(interp, infoPtr, - precTable[QUESTY] - 1, &value2); - iPtr->noEval--; - } else { - iPtr->noEval++; - result = ExprGetValue(interp, infoPtr, - precTable[QUESTY] - 1, &value2); - iPtr->noEval--; - if (result != TCL_OK) { - goto done; - } - if (infoPtr->token != COLON) { - goto syntaxError; - } - valuePtr->pv.next = valuePtr->pv.buffer; - result = ExprGetValue(interp, infoPtr, - precTable[QUESTY] - 1, valuePtr); - } - continue; - } else { - result = ExprGetValue(interp, infoPtr, precTable[operator], - &value2); - } - } else { - result = ExprGetValue(interp, infoPtr, precTable[operator], - &value2); - } - if (result != TCL_OK) { - goto done; - } - if ((infoPtr->token < MULT) && (infoPtr->token != VALUE) - && (infoPtr->token != END) && (infoPtr->token != COMMA) - && (infoPtr->token != CLOSE_PAREN)) { - goto syntaxError; - } - - if (iPtr->noEval) { - continue; - } - - /* - * At this point we've got two values and an operator. Check - * to make sure that the particular data types are appropriate - * for the particular operator, and perform type conversion - * if necessary. - */ - - switch (operator) { - - /* - * For the operators below, no strings are allowed and - * ints get converted to floats if necessary. - */ - - case MULT: case DIVIDE: case PLUS: case MINUS: - if ((valuePtr->type == TYPE_STRING) - || (value2.type == TYPE_STRING)) { - badType = TYPE_STRING; - goto illegalType; - } - if (valuePtr->type == TYPE_DOUBLE) { - if (value2.type == TYPE_INT) { - value2.doubleValue = value2.intValue; - value2.type = TYPE_DOUBLE; - } - } else if (value2.type == TYPE_DOUBLE) { - if (valuePtr->type == TYPE_INT) { - valuePtr->doubleValue = valuePtr->intValue; - valuePtr->type = TYPE_DOUBLE; - } - } - break; - - /* - * For the operators below, only integers are allowed. - */ - - case MOD: case LEFT_SHIFT: case RIGHT_SHIFT: - case BIT_AND: case BIT_XOR: case BIT_OR: - if (valuePtr->type != TYPE_INT) { - badType = valuePtr->type; - goto illegalType; - } else if (value2.type != TYPE_INT) { - badType = value2.type; - goto illegalType; - } - break; - - /* - * For the operators below, any type is allowed but the - * two operands must have the same type. Convert integers - * to floats and either to strings, if necessary. - */ - - case LESS: case GREATER: case LEQ: case GEQ: - case EQUAL: case NEQ: - if (valuePtr->type == TYPE_STRING) { - if (value2.type != TYPE_STRING) { - ExprMakeString(interp, &value2); - } - } else if (value2.type == TYPE_STRING) { - if (valuePtr->type != TYPE_STRING) { - ExprMakeString(interp, valuePtr); - } - } else if (valuePtr->type == TYPE_DOUBLE) { - if (value2.type == TYPE_INT) { - value2.doubleValue = value2.intValue; - value2.type = TYPE_DOUBLE; - } - } else if (value2.type == TYPE_DOUBLE) { - if (valuePtr->type == TYPE_INT) { - valuePtr->doubleValue = valuePtr->intValue; - valuePtr->type = TYPE_DOUBLE; - } - } - break; - - /* - * For the operators below, no strings are allowed, but - * no int->double conversions are performed. - */ - - case AND: case OR: - if (valuePtr->type == TYPE_STRING) { - badType = valuePtr->type; - goto illegalType; - } - if (value2.type == TYPE_STRING) { - badType = value2.type; - goto illegalType; - } - break; - - /* - * For the operators below, type and conversions are - * irrelevant: they're handled elsewhere. - */ - - case QUESTY: case COLON: - break; - - /* - * Any other operator is an error. - */ - - default: - interp->result = "unknown operator in expression"; - result = TCL_ERROR; - goto done; - } - - /* - * Carry out the function of the specified operator. - */ - - switch (operator) { - case MULT: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = valuePtr->intValue * value2.intValue; - } else { - valuePtr->doubleValue *= value2.doubleValue; - } - break; - case DIVIDE: - case MOD: - if (valuePtr->type == TYPE_INT) { - long divisor, quot, rem; - int negative; - - if (value2.intValue == 0) { - divideByZero: - interp->result = "divide by zero"; - Tcl_SetErrorCode(interp, "ARITH", "DIVZERO", - interp->result, (char *) NULL); - result = TCL_ERROR; - goto done; - } - - /* - * The code below is tricky because C doesn't guarantee - * much about the properties of the quotient or - * remainder, but Tcl does: the remainder always has - * the same sign as the divisor and a smaller absolute - * value. - */ - - divisor = value2.intValue; - negative = 0; - if (divisor < 0) { - divisor = -divisor; - valuePtr->intValue = -valuePtr->intValue; - negative = 1; - } - quot = valuePtr->intValue / divisor; - rem = valuePtr->intValue % divisor; - if (rem < 0) { - rem += divisor; - quot -= 1; - } - if (negative) { - rem = -rem; - } - valuePtr->intValue = (operator == DIVIDE) ? quot : rem; - } else { - if (value2.doubleValue == 0.0) { - goto divideByZero; - } - valuePtr->doubleValue /= value2.doubleValue; - } - break; - case PLUS: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = valuePtr->intValue + value2.intValue; - } else { - valuePtr->doubleValue += value2.doubleValue; - } - break; - case MINUS: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = valuePtr->intValue - value2.intValue; - } else { - valuePtr->doubleValue -= value2.doubleValue; - } - break; - case LEFT_SHIFT: - valuePtr->intValue <<= value2.intValue; - break; - case RIGHT_SHIFT: - /* - * The following code is a bit tricky: it ensures that - * right shifts propagate the sign bit even on machines - * where ">>" won't do it by default. - */ - - if (valuePtr->intValue < 0) { - valuePtr->intValue = - ~((~valuePtr->intValue) >> value2.intValue); - } else { - valuePtr->intValue >>= value2.intValue; - } - break; - case LESS: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue < value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue < value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) < 0; - } - valuePtr->type = TYPE_INT; - break; - case GREATER: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue > value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue > value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) > 0; - } - valuePtr->type = TYPE_INT; - break; - case LEQ: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue <= value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue <= value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) <= 0; - } - valuePtr->type = TYPE_INT; - break; - case GEQ: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue >= value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue >= value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) >= 0; - } - valuePtr->type = TYPE_INT; - break; - case EQUAL: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue == value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue == value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) == 0; - } - valuePtr->type = TYPE_INT; - break; - case NEQ: - if (valuePtr->type == TYPE_INT) { - valuePtr->intValue = - valuePtr->intValue != value2.intValue; - } else if (valuePtr->type == TYPE_DOUBLE) { - valuePtr->intValue = - valuePtr->doubleValue != value2.doubleValue; - } else { - valuePtr->intValue = - strcmp(valuePtr->pv.buffer, value2.pv.buffer) != 0; - } - valuePtr->type = TYPE_INT; - break; - case BIT_AND: - valuePtr->intValue &= value2.intValue; - break; - case BIT_XOR: - valuePtr->intValue ^= value2.intValue; - break; - case BIT_OR: - valuePtr->intValue |= value2.intValue; - break; - - /* - * For AND and OR, we know that the first value has already - * been converted to an integer. Thus we need only consider - * the possibility of int vs. double for the second value. - */ - - case AND: - if (value2.type == TYPE_DOUBLE) { - value2.intValue = value2.doubleValue != 0; - value2.type = TYPE_INT; - } - valuePtr->intValue = valuePtr->intValue && value2.intValue; - break; - case OR: - if (value2.type == TYPE_DOUBLE) { - value2.intValue = value2.doubleValue != 0; - value2.type = TYPE_INT; - } - valuePtr->intValue = valuePtr->intValue || value2.intValue; - break; - - case COLON: - interp->result = "can't have : operator without ? first"; - result = TCL_ERROR; - goto done; - } - } - - done: - if (value2.pv.buffer != value2.staticSpace) { - ckfree(value2.pv.buffer); - } - return result; - - syntaxError: - Tcl_AppendResult(interp, "syntax error in expression \"", - infoPtr->originalExpr, "\"", (char *) NULL); - result = TCL_ERROR; - goto done; - - illegalType: - Tcl_AppendResult(interp, "can't use ", (badType == TYPE_DOUBLE) ? - "floating-point value" : "non-numeric string", - " as operand of \"", operatorStrings[operator], "\"", - (char *) NULL); - result = TCL_ERROR; - goto done; -} - -/* - *-------------------------------------------------------------- - * - * ExprMakeString -- - * - * Convert a value from int or double representation to - * a string. - * - * Results: - * The information at *valuePtr gets converted to string - * format, if it wasn't that way already. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -static void -ExprMakeString( - Tcl_Interp *interp, /* Interpreter to use for precision - * information. */ - Value *valuePtr /* Value to be converted. */ -) -{ - int shortfall; - - shortfall = 150 - (valuePtr->pv.end - valuePtr->pv.buffer); - if (shortfall > 0) { - (*valuePtr->pv.expandProc)(&valuePtr->pv, shortfall); - } - if (valuePtr->type == TYPE_INT) { - sprintf(valuePtr->pv.buffer, "%ld", valuePtr->intValue); - } else if (valuePtr->type == TYPE_DOUBLE) { - Tcl_PrintDouble(interp, valuePtr->doubleValue, valuePtr->pv.buffer); - } - valuePtr->type = TYPE_STRING; -} - -/* - *-------------------------------------------------------------- - * - * ExprTopLevel -- - * - * This procedure provides top-level functionality shared by - * procedures like Tcl_ExprInt, Tcl_ExprDouble, etc. - * - * Results: - * The result is a standard Tcl return value. If an error - * occurs then an error message is left in interp->result. - * The value of the expression is returned in *valuePtr, in - * whatever form it ends up in (could be string or integer - * or double). Caller may need to convert result. Caller - * is also responsible for freeing string memory in *valuePtr, - * if any was allocated. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -static int -ExprTopLevel( - Tcl_Interp *interp, /* Context in which to evaluate the - * expression. */ - char *string, /* Expression to evaluate. */ - Value *valuePtr /* Where to store result. Should - * not be initialized by caller. */ -) -{ - ExprInfo info; - int result; - - /* - * Create the math functions the first time an expression is - * evaluated. - */ - - if (!(((Interp *) interp)->flags & EXPR_INITIALIZED)) { - BuiltinFunc *funcPtr; - - ((Interp *) interp)->flags |= EXPR_INITIALIZED; - for (funcPtr = funcTable; funcPtr->name != NULL; - funcPtr++) { - Tcl_CreateMathFunc(interp, funcPtr->name, funcPtr->numArgs, - funcPtr->argTypes, funcPtr->proc, funcPtr->clientData); - } - } - - info.originalExpr = string; - info.expr = string; - valuePtr->pv.buffer = valuePtr->pv.next = valuePtr->staticSpace; - valuePtr->pv.end = valuePtr->pv.buffer + STATIC_STRING_SPACE - 1; - valuePtr->pv.expandProc = TclExpandParseValue; - valuePtr->pv.clientData = (ClientData) NULL; - - result = ExprGetValue(interp, &info, -1, valuePtr); - if (result != TCL_OK) { - return result; - } - if (info.token != END) { - Tcl_AppendResult(interp, "syntax error in expression \"", - string, "\"", (char *) NULL); - return TCL_ERROR; - } - if ((valuePtr->type == TYPE_DOUBLE) && (IS_NAN(valuePtr->doubleValue) - || IS_INF(valuePtr->doubleValue))) { - /* - * IEEE floating-point error. - */ - - TclExprFloatError(interp, valuePtr->doubleValue); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean -- - * - * Procedures to evaluate an expression and return its value - * in a particular form. - * - * Results: - * Each of the procedures below returns a standard Tcl result. - * If an error occurs then an error message is left in - * interp->result. Otherwise the value of the expression, - * in the appropriate form, is stored at *resultPtr. If - * the expression had a result that was incompatible with the - * desired form then an error is returned. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -int -Tcl_ExprLong( - Tcl_Interp *interp, /* Context in which to evaluate the - * expression. */ - char *string, /* Expression to evaluate. */ - long *ptr /* Where to store result. */ -) -{ - Value value; - int result; - - result = ExprTopLevel(interp, string, &value); - if (result == TCL_OK) { - if (value.type == TYPE_INT) { - *ptr = value.intValue; - } else if (value.type == TYPE_DOUBLE) { - *ptr = (long) value.doubleValue; - } else { - interp->result = "expression didn't have numeric value"; - result = TCL_ERROR; - } - } - if (value.pv.buffer != value.staticSpace) { - ckfree(value.pv.buffer); - } - return result; -} - -int -Tcl_ExprDouble( - Tcl_Interp *interp, /* Context in which to evaluate the - * expression. */ - char *string, /* Expression to evaluate. */ - double *ptr /* Where to store result. */ -) -{ - Value value; - int result; - - result = ExprTopLevel(interp, string, &value); - if (result == TCL_OK) { - if (value.type == TYPE_INT) { - *ptr = value.intValue; - } else if (value.type == TYPE_DOUBLE) { - *ptr = value.doubleValue; - } else { - interp->result = "expression didn't have numeric value"; - result = TCL_ERROR; - } - } - if (value.pv.buffer != value.staticSpace) { - ckfree(value.pv.buffer); - } - return result; -} - -int -Tcl_ExprBoolean( - Tcl_Interp *interp, /* Context in which to evaluate the - * expression. */ - char *string, /* Expression to evaluate. */ - int *ptr /* Where to store 0/1 result. */ -) -{ - Value value; - int result; - - result = ExprTopLevel(interp, string, &value); - if (result == TCL_OK) { - if (value.type == TYPE_INT) { - *ptr = value.intValue != 0; - } else if (value.type == TYPE_DOUBLE) { - *ptr = value.doubleValue != 0.0; - } else { - result = Tcl_GetBoolean(interp, value.pv.buffer, ptr); - } - } - if (value.pv.buffer != value.staticSpace) { - ckfree(value.pv.buffer); - } - return result; -} - -/* - *-------------------------------------------------------------- - * - * Tcl_ExprString -- - * - * Evaluate an expression and return its value in string form. - * - * Results: - * A standard Tcl result. If the result is TCL_OK, then the - * interpreter's result is set to the string value of the - * expression. If the result is TCL_OK, then interp->result - * contains an error message. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -int -Tcl_ExprString( - Tcl_Interp *interp, /* Context in which to evaluate the - * expression. */ - char *string /* Expression to evaluate. */ -) -{ - Value value; - int result; - - result = ExprTopLevel(interp, string, &value); - if (result == TCL_OK) { - if (value.type == TYPE_INT) { - sprintf(interp->result, "%ld", value.intValue); - } else if (value.type == TYPE_DOUBLE) { - Tcl_PrintDouble(interp, value.doubleValue, interp->result); - } else { - if (value.pv.buffer != value.staticSpace) { - interp->result = value.pv.buffer; - interp->freeProc = TCL_DYNAMIC; - value.pv.buffer = value.staticSpace; - } else { - Tcl_SetResult(interp, value.pv.buffer, TCL_VOLATILE); - } - } - } - if (value.pv.buffer != value.staticSpace) { - ckfree(value.pv.buffer); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateMathFunc -- - * - * Creates a new math function for expressions in a given - * interpreter. - * - * Results: - * None. - * - * Side effects: - * The function defined by "name" is created; if such a function - * already existed then its definition is overriden. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CreateMathFunc( - Tcl_Interp *interp, /* Interpreter in which function is - * to be available. */ - char *name, /* Name of function (e.g. "sin"). */ - int numArgs, /* Nnumber of arguments required by - * function. */ - Tcl_ValueType *argTypes, /* Array of types acceptable for - * each argument. */ - Tcl_MathProc *proc, /* Procedure that implements the - * math function. */ - ClientData clientData /* Additional value to pass to the - * function. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr; - MathFunc *mathFuncPtr; - int new, i; - - hPtr = Tcl_CreateHashEntry(&iPtr->mathFuncTable, name, &new); - if (new) { - Tcl_SetHashValue(hPtr, ckalloc(sizeof(MathFunc))); - } - mathFuncPtr = (MathFunc *) Tcl_GetHashValue(hPtr); - if (numArgs > MAX_MATH_ARGS) { - numArgs = MAX_MATH_ARGS; - } - mathFuncPtr->numArgs = numArgs; - for (i = 0; i < numArgs; i++) { - mathFuncPtr->argTypes[i] = argTypes[i]; - } - mathFuncPtr->proc = proc; - mathFuncPtr->clientData = clientData; -} - -/* - *---------------------------------------------------------------------- - * - * ExprMathFunc -- - * - * This procedure is invoked to parse a math function from an - * expression string, carry out the function, and return the - * value computed. - * - * Results: - * TCL_OK is returned if all went well and the function's value - * was computed successfully. If an error occurred, TCL_ERROR - * is returned and an error message is left in interp->result. - * After a successful return infoPtr has been updated to refer - * to the character just after the function call, the token is - * set to VALUE, and the value is stored in valuePtr. - * - * Side effects: - * Embedded commands could have arbitrary side-effects. - * - *---------------------------------------------------------------------- - */ - -static int -ExprMathFunc( - Tcl_Interp *interp, /* Interpreter to use for error - * reporting. */ - ExprInfo *infoPtr, /* Describes the state of the parse. - * infoPtr->expr must point to the - * first character of the function's - * name. */ - Value *valuePtr /* Where to store value, if that is - * what's parsed from string. Caller - * must have initialized pv field - * correctly. */ -) -{ - Interp *iPtr = (Interp *) interp; - MathFunc *mathFuncPtr; /* Info about math function. */ - Tcl_Value args[MAX_MATH_ARGS]; /* Arguments for function call. */ - Tcl_Value funcResult; /* Result of function call. */ - Tcl_HashEntry *hPtr; - char *p, *funcName, savedChar; - int i, result; - - /* - * Find the end of the math function's name and lookup the MathFunc - * record for the function. - */ - - p = funcName = infoPtr->expr; - while (isalnum(UCHAR(*p)) || (*p == '_')) { - p++; - } - infoPtr->expr = p; - result = ExprLex(interp, infoPtr, valuePtr); - if (result != TCL_OK) { - return TCL_ERROR; - } - if (infoPtr->token != OPEN_PAREN) { - goto syntaxError; - } - savedChar = *p; - *p = 0; - hPtr = Tcl_FindHashEntry(&iPtr->mathFuncTable, funcName); - if (hPtr == NULL) { - Tcl_AppendResult(interp, "unknown math function \"", funcName, - "\"", (char *) NULL); - *p = savedChar; - return TCL_ERROR; - } - *p = savedChar; - mathFuncPtr = (MathFunc *) Tcl_GetHashValue(hPtr); - - /* - * Scan off the arguments for the function, if there are any. - */ - - if (mathFuncPtr->numArgs == 0) { - result = ExprLex(interp, infoPtr, valuePtr); - if ((result != TCL_OK) || (infoPtr->token != CLOSE_PAREN)) { - goto syntaxError; - } - } else { - for (i = 0; ; i++) { - valuePtr->pv.next = valuePtr->pv.buffer; - result = ExprGetValue(interp, infoPtr, -1, valuePtr); - if (result != TCL_OK) { - return result; - } - if (valuePtr->type == TYPE_STRING) { - interp->result = - "argument to math function didn't have numeric value"; - return TCL_ERROR; - } - - /* - * Copy the value to the argument record, converting it if - * necessary. - */ - - if (valuePtr->type == TYPE_INT) { - if (mathFuncPtr->argTypes[i] == TCL_DOUBLE) { - args[i].type = TCL_DOUBLE; - args[i].doubleValue = valuePtr->intValue; - } else { - args[i].type = TCL_INT; - args[i].intValue = valuePtr->intValue; - } - } else { - if (mathFuncPtr->argTypes[i] == TCL_INT) { - args[i].type = TCL_INT; - args[i].intValue = (long) valuePtr->doubleValue; - } else { - args[i].type = TCL_DOUBLE; - args[i].doubleValue = valuePtr->doubleValue; - } - } - - /* - * Check for a comma separator between arguments or a close-paren - * to end the argument list. - */ - - if (i == (mathFuncPtr->numArgs-1)) { - if (infoPtr->token == CLOSE_PAREN) { - break; - } - if (infoPtr->token == COMMA) { - interp->result = "too many arguments for math function"; - return TCL_ERROR; - } else { - goto syntaxError; - } - } - if (infoPtr->token != COMMA) { - if (infoPtr->token == CLOSE_PAREN) { - interp->result = "too few arguments for math function"; - return TCL_ERROR; - } else { - goto syntaxError; - } - } - } - } - if (iPtr->noEval) { - valuePtr->type = TYPE_INT; - valuePtr->intValue = 0; - infoPtr->token = VALUE; - return TCL_OK; - } - - /* - * Invoke the function and copy its result back into valuePtr. - */ - - tcl_MathInProgress++; - result = (*mathFuncPtr->proc)(mathFuncPtr->clientData, interp, args, - &funcResult); - tcl_MathInProgress--; - if (result != TCL_OK) { - return result; - } - if (funcResult.type == TCL_INT) { - valuePtr->type = TYPE_INT; - valuePtr->intValue = funcResult.intValue; - } else { - valuePtr->type = TYPE_DOUBLE; - valuePtr->doubleValue = funcResult.doubleValue; - } - infoPtr->token = VALUE; - return TCL_OK; - - syntaxError: - Tcl_AppendResult(interp, "syntax error in expression \"", - infoPtr->originalExpr, "\"", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * TclExprFloatError -- - * - * This procedure is called when an error occurs during a - * floating-point operation. It reads errno and sets - * interp->result accordingly. - * - * Results: - * Interp->result is set to hold an error message. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TclExprFloatError( - Tcl_Interp *interp, /* Where to store error message. */ - double value /* Value returned after error; used to - * distinguish underflows from overflows. */ -) -{ - char buf[20]; - - if ((errno == EDOM) || (value != value)) { - interp->result = "domain error: argument not in valid range"; - Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", interp->result, - (char *) NULL); - } else if ((errno == ERANGE) || IS_INF(value)) { - if (value == 0.0) { - interp->result = "floating-point value too small to represent"; - Tcl_SetErrorCode(interp, "ARITH", "UNDERFLOW", interp->result, - (char *) NULL); - } else { - interp->result = "floating-point value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "OVERFLOW", interp->result, - (char *) NULL); - } - } else { - sprintf(buf, "%d", errno); - Tcl_AppendResult(interp, "unknown floating-point error, ", - "errno = ", buf, (char *) NULL); - Tcl_SetErrorCode(interp, "ARITH", "UNKNOWN", interp->result, - (char *) NULL); - } -} - -/* - *---------------------------------------------------------------------- - * - * Math Functions -- - * - * This page contains the procedures that implement all of the - * built-in math functions for expressions. - * - * Results: - * Each procedure returns TCL_OK if it succeeds and places result - * information at *resultPtr. If it fails it returns TCL_ERROR - * and leaves an error message in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ExprUnaryFunc( - ClientData clientData, /* Contains address of procedure that - * takes one double argument and - * returns a double result. */ - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - double (*func) _ANSI_ARGS_((double)) = (double (*)_ANSI_ARGS_((double))) clientData; - - errno = 0; - resultPtr->type = TCL_DOUBLE; - resultPtr->doubleValue = (*func)(args[0].doubleValue); - if (errno != 0) { - TclExprFloatError(interp, resultPtr->doubleValue); - return TCL_ERROR; - } - return TCL_OK; -} - -static int -ExprBinaryFunc( - ClientData clientData, /* Contains address of procedure that - * takes two double arguments and - * returns a double result. */ - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - double (*func) _ANSI_ARGS_((double, double)) - = (double (*)_ANSI_ARGS_((double, double))) clientData; - - errno = 0; - resultPtr->type = TCL_DOUBLE; - resultPtr->doubleValue = (*func)(args[0].doubleValue, args[1].doubleValue); - if (errno != 0) { - TclExprFloatError(interp, resultPtr->doubleValue); - return TCL_ERROR; - } - return TCL_OK; -} - - /* ARGSUSED */ -static int -ExprAbsFunc( - ClientData clientData, - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - resultPtr->type = TCL_DOUBLE; - if (args[0].type == TCL_DOUBLE) { - resultPtr->type = TCL_DOUBLE; - if (args[0].doubleValue < 0) { - resultPtr->doubleValue = -args[0].doubleValue; - } else { - resultPtr->doubleValue = args[0].doubleValue; - } - } else { - resultPtr->type = TCL_INT; - if (args[0].intValue < 0) { - resultPtr->intValue = -args[0].intValue; - if (resultPtr->intValue < 0) { - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", interp->result, - (char *) NULL); - return TCL_ERROR; - } - } else { - resultPtr->intValue = args[0].intValue; - } - } - return TCL_OK; -} - - /* ARGSUSED */ -static int -ExprDoubleFunc( - ClientData clientData, - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - resultPtr->type = TCL_DOUBLE; - if (args[0].type == TCL_DOUBLE) { - resultPtr->doubleValue = args[0].doubleValue; - } else { - resultPtr->doubleValue = args[0].intValue; - } - return TCL_OK; -} - - /* ARGSUSED */ -static int -ExprIntFunc( - ClientData clientData, - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - resultPtr->type = TCL_INT; - if (args[0].type == TCL_INT) { - resultPtr->intValue = args[0].intValue; - } else { - if (args[0].doubleValue < 0) { - if (args[0].doubleValue < (double) (long) LONG_MIN) { - tooLarge: - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - return TCL_ERROR; - } - } else { - if (args[0].doubleValue > (double) LONG_MAX) { - goto tooLarge; - } - } - resultPtr->intValue = (long) args[0].doubleValue; - } - return TCL_OK; -} - - /* ARGSUSED */ -static int -ExprRoundFunc( - ClientData clientData, - Tcl_Interp *interp, - Tcl_Value *args, - Tcl_Value *resultPtr -) -{ - resultPtr->type = TCL_INT; - if (args[0].type == TCL_INT) { - resultPtr->intValue = args[0].intValue; - } else { - if (args[0].doubleValue < 0) { - if (args[0].doubleValue <= (((double) (long) LONG_MIN) - 0.5)) { - tooLarge: - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - return TCL_ERROR; - } - resultPtr->intValue = (long) (args[0].doubleValue - 0.5); - } else { - if (args[0].doubleValue >= (((double) LONG_MAX + 0.5))) { - goto tooLarge; - } - resultPtr->intValue = (long) (args[0].doubleValue + 0.5); - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * ExprLooksLikeInt -- - * - * This procedure decides whether the leading characters of a - * string look like an integer or something else (such as a - * floating-point number or string). - * - * Results: - * The return value is 1 if the leading characters of p look - * like a valid Tcl integer. If they look like a floating-point - * number (e.g. "e01" or "2.4"), or if they don't look like a - * number at all, then 0 is returned. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ExprLooksLikeInt( - char *p /* Pointer to string. */ -) -{ - while (isspace(UCHAR(*p))) { - p++; - } - if ((*p == '+') || (*p == '-')) { - p++; - } - if (!isdigit(UCHAR(*p))) { - return 0; - } - p++; - while (isdigit(UCHAR(*p))) { - p++; - } - if ((*p != '.') && (*p != 'e') && (*p != 'E')) { - return 1; - } - return 0; -} diff --git a/cde/programs/dtdocbook/tcl/tclFHandle.c b/cde/programs/dtdocbook/tcl/tclFHandle.c deleted file mode 100644 index f6794beea..000000000 --- a/cde/programs/dtdocbook/tcl/tclFHandle.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclFHandle.c /main/2 1996/08/08 14:43:54 cde-hp $ */ -/* - * tclFHandle.c -- - * - * This file contains functions for manipulating Tcl file handles. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclFHandle.c 1.6 96/02/13 16:29:55 - */ - -#include "tcl.h" -#include "tclPort.h" - -/* - * The FileHashKey structure is used to associate the OS file handle and type - * with the corresponding notifier data in a FileHandle. - */ - -typedef struct FileHashKey { - int type; /* File handle type. */ - ClientData osHandle; /* Platform specific OS file handle. */ -} FileHashKey; - -typedef struct FileHandle { - FileHashKey key; /* Hash key for a given file. */ - ClientData data; /* Platform specific notifier data. */ - Tcl_FileFreeProc *proc; /* Callback to invoke when file is freed. */ -} FileHandle; - -/* - * Static variables used in this file: - */ - -static Tcl_HashTable fileTable; /* Hash table containing file handles. */ -static int initialized = 0; /* 1 if this module has been initialized. */ - -/* - * Static procedures used in this file: - */ - -static void FileExitProc _ANSI_ARGS_((ClientData clientData)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetFile -- - * - * This function retrieves the file handle associated with a - * platform specific file handle of the given type. It creates - * a new file handle if needed. - * - * Results: - * Returns the file handle associated with the file descriptor. - * - * Side effects: - * Initializes the file handle table if necessary. - * - *---------------------------------------------------------------------- - */ - -Tcl_File -Tcl_GetFile( - ClientData osHandle, /* Platform specific file handle. */ - int type /* Type of file handle. */ -) -{ - FileHashKey key; - Tcl_HashEntry *entryPtr; - int new; - - if (!initialized) { - Tcl_InitHashTable(&fileTable, sizeof(FileHashKey)/sizeof(int)); - Tcl_CreateExitHandler(FileExitProc, 0); - initialized = 1; - } - key.osHandle = osHandle; - key.type = type; - entryPtr = Tcl_CreateHashEntry(&fileTable, (char *) &key, &new); - if (new) { - FileHandle *newHandlePtr; - newHandlePtr = (FileHandle *) ckalloc(sizeof(FileHandle)); - newHandlePtr->key = key; - newHandlePtr->data = NULL; - newHandlePtr->proc = NULL; - Tcl_SetHashValue(entryPtr, newHandlePtr); - } - - return (Tcl_File) Tcl_GetHashValue(entryPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FreeFile -- - * - * Deallocates an entry in the file handle table. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_FreeFile( - Tcl_File handle -) -{ - Tcl_HashEntry *entryPtr; - FileHandle *handlePtr = (FileHandle *) handle; - - /* - * Invoke free procedure, then delete the handle. - */ - - if (handlePtr->proc) { - (*handlePtr->proc)(handlePtr->data); - } - - entryPtr = Tcl_FindHashEntry(&fileTable, (char *) &handlePtr->key); - if (entryPtr) { - Tcl_DeleteHashEntry(entryPtr); - ckfree((char *) handlePtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetFileInfo -- - * - * This function retrieves the platform specific file data and - * type from the file handle. - * - * Results: - * If typePtr is not NULL, sets *typePtr to the type of the file. - * Returns the platform specific file data. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_GetFileInfo( - Tcl_File handle, - int *typePtr -) -{ - FileHandle *handlePtr = (FileHandle *) handle; - - if (typePtr) { - *typePtr = handlePtr->key.type; - } - return handlePtr->key.osHandle; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetNotifierData -- - * - * This function is used by the notifier to associate platform - * specific notifier information and a deletion procedure with - * a file handle. - * - * Results: - * None. - * - * Side effects: - * Updates the data and delProc slots in the file handle. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetNotifierData( - Tcl_File handle, - Tcl_FileFreeProc *proc, - ClientData data -) -{ - FileHandle *handlePtr = (FileHandle *) handle; - handlePtr->proc = proc; - handlePtr->data = data; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetNotifierData -- - * - * This function is used by the notifier to retrieve the platform - * specific notifier information associated with a file handle. - * - * Results: - * Returns the data stored in a file handle by a previous call to - * Tcl_SetNotifierData, and places a pointer to the free proc - * in the location referred to by procPtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_GetNotifierData( - Tcl_File handle, - Tcl_FileFreeProc **procPtr -) -{ - FileHandle *handlePtr = (FileHandle *) handle; - if (procPtr != NULL) { - *procPtr = handlePtr->proc; - } - return handlePtr->data; -} - -/* - *---------------------------------------------------------------------- - * - * FileExitProc -- - * - * This function an exit handler that frees any memory allocated - * for the file handle table. - * - * Results: - * None. - * - * Side effects: - * Cleans up the file handle table. - * - *---------------------------------------------------------------------- - */ - -static void -FileExitProc( - ClientData clientData /* Not used. */ -) -{ - Tcl_HashSearch search; - Tcl_HashEntry *entryPtr; - - entryPtr = Tcl_FirstHashEntry(&fileTable, &search); - - while (entryPtr) { - ckfree(Tcl_GetHashValue(entryPtr)); - entryPtr = Tcl_NextHashEntry(&search); - } - - Tcl_DeleteHashTable(&fileTable); -} diff --git a/cde/programs/dtdocbook/tcl/tclFileName.c b/cde/programs/dtdocbook/tcl/tclFileName.c deleted file mode 100644 index f9ffbbdfd..000000000 --- a/cde/programs/dtdocbook/tcl/tclFileName.c +++ /dev/null @@ -1,1628 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclFileName.c /main/2 1996/08/08 14:43:59 cde-hp $ */ -/* - * tclFileName.c -- - * - * This file contains routines for converting file names betwen - * native and network form. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclFileName.c 1.23 96/04/19 12:34:28 - */ - -#include "tclInt.h" -#include "tclPort.h" -#include "tclRegexp.h" - -/* - * This variable indicates whether the cleanup procedure has been - * registered for this file yet. - */ - -static int initialized = 0; - -/* - * The following regular expression matches the root portion of a Windows - * absolute or volume relative path. It will match both UNC and drive relative - * paths. - */ - -#define WIN_ROOT_PATTERN "^(([a-zA-Z]:)|[/\\][/\\]+([^/\\]+)[/\\]+([^/\\]+)|([/\\]))([/\\])*" - -/* - * The following regular expression matches the root portion of a Macintosh - * absolute path. It will match degenerate Unix-style paths, tilde paths, - * Unix-style paths, and Mac paths. - */ - -#define MAC_ROOT_PATTERN "^((/+([.][.]?/+)*([.][.]?)?)|(~[^:/]*)(/[^:]*)?|(~[^:]*)(:.*)?|/+([.][.]?/+)*([^:/]+)(/[^:]*)?|([^:]+):.*)$" - -/* - * The following variables are used to hold precompiled regular expressions - * for use in filename matching. - */ - -static regexp *winRootPatternPtr = NULL; -static regexp *macRootPatternPtr = NULL; - -/* - * The following variable is set in the TclPlatformInit call to one - * of: TCL_PLATFORM_UNIX, TCL_PLATFORM_MAC, or TCL_PLATFORM_WINDOWS. - */ - -TclPlatformType tclPlatform = TCL_PLATFORM_UNIX; - -/* - * Prototypes for local procedures defined in this file: - */ - -static char * DoTildeSubst _ANSI_ARGS_((Tcl_Interp *interp, - char *user, Tcl_DString *resultPtr)); -static char * ExtractWinRoot _ANSI_ARGS_((char *path, - Tcl_DString *resultPtr, int offset)); -static void FileNameCleanup _ANSI_ARGS_((ClientData clientData)); -static int SkipToChar _ANSI_ARGS_((char **stringPtr, - char *match)); -static char * SplitMacPath _ANSI_ARGS_((char *path, - Tcl_DString *bufPtr)); -static char * SplitWinPath _ANSI_ARGS_((char *path, - Tcl_DString *bufPtr)); -static char * SplitUnixPath _ANSI_ARGS_((char *path, - Tcl_DString *bufPtr)); - -/* - *---------------------------------------------------------------------- - * - * FileNameCleanup -- - * - * This procedure is a Tcl_ExitProc used to clean up the static - * data structures used in this file. - * - * Results: - * None. - * - * Side effects: - * Deallocates storage used by the procedures in this file. - * - *---------------------------------------------------------------------- - */ - -static void -FileNameCleanup( - ClientData clientData /* Not used. */ -) -{ - if (winRootPatternPtr != NULL) { - ckfree((char *)winRootPatternPtr); - } - if (macRootPatternPtr != NULL) { - ckfree((char *)macRootPatternPtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * ExtractWinRoot -- - * - * Matches the root portion of a Windows path and appends it - * to the specified Tcl_DString. - * - * Results: - * Returns the position in the path immediately after the root - * including any trailing slashes. - * Appends a cleaned up version of the root to the Tcl_DString - * at the specified offest. - * - * Side effects: - * Modifies the specified Tcl_DString. - * - *---------------------------------------------------------------------- - */ - -static char * -ExtractWinRoot( - char *path, /* Path to parse. */ - Tcl_DString *resultPtr, /* Buffer to hold result. */ - int offset /* Offset in buffer where result should be - * stored. */ -) -{ - int length; - - /* - * Initialize the path name parser for Windows path names. - */ - - if (winRootPatternPtr == NULL) { - winRootPatternPtr = TclRegComp(WIN_ROOT_PATTERN); - if (!initialized) { - Tcl_CreateExitHandler(FileNameCleanup, NULL); - initialized = 1; - } - } - - /* - * Match the root portion of a Windows path name. - */ - - if (!TclRegExec(winRootPatternPtr, path, path)) { - return path; - } - - Tcl_DStringSetLength(resultPtr, offset); - - if (winRootPatternPtr->startp[2] != NULL) { - Tcl_DStringAppend(resultPtr, winRootPatternPtr->startp[2], 2); - if (winRootPatternPtr->startp[6] != NULL) { - Tcl_DStringAppend(resultPtr, "/", 1); - } - } else if (winRootPatternPtr->startp[4] != NULL) { - Tcl_DStringAppend(resultPtr, "//", 2); - length = winRootPatternPtr->endp[3] - - winRootPatternPtr->startp[3]; - Tcl_DStringAppend(resultPtr, winRootPatternPtr->startp[3], length); - Tcl_DStringAppend(resultPtr, "/", 1); - length = winRootPatternPtr->endp[4] - - winRootPatternPtr->startp[4]; - Tcl_DStringAppend(resultPtr, winRootPatternPtr->startp[4], length); - } else { - Tcl_DStringAppend(resultPtr, "/", 1); - } - return winRootPatternPtr->endp[0]; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetPathType -- - * - * Determines whether a given path is relative to the current - * directory, relative to the current volume, or absolute. - * - * Results: - * Returns one of TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, or - * TCL_PATH_VOLUME_RELATIVE. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_PathType -Tcl_GetPathType( - char *path -) -{ - Tcl_PathType type = TCL_PATH_ABSOLUTE; - - switch (tclPlatform) { - case TCL_PLATFORM_UNIX: - /* - * Paths that begin with / or ~ are absolute. - */ - - if ((path[0] != '/') && (path[0] != '~')) { - type = TCL_PATH_RELATIVE; - } - break; - - case TCL_PLATFORM_MAC: - if (path[0] == ':') { - type = TCL_PATH_RELATIVE; - } else if (path[0] != '~') { - - /* - * Since we have eliminated the easy cases, use the - * root pattern to look for the other types. - */ - - if (!macRootPatternPtr) { - macRootPatternPtr = TclRegComp(MAC_ROOT_PATTERN); - if (!initialized) { - Tcl_CreateExitHandler(FileNameCleanup, NULL); - initialized = 1; - } - } - if (!TclRegExec(macRootPatternPtr, path, path) - || (macRootPatternPtr->startp[2] != NULL)) { - type = TCL_PATH_RELATIVE; - } - } - break; - - case TCL_PLATFORM_WINDOWS: - if (path[0] != '~') { - - /* - * Since we have eliminated the easy cases, check for - * drive relative paths using the regular expression. - */ - - if (!winRootPatternPtr) { - winRootPatternPtr = TclRegComp(WIN_ROOT_PATTERN); - if (!initialized) { - Tcl_CreateExitHandler(FileNameCleanup, NULL); - initialized = 1; - } - } - if (TclRegExec(winRootPatternPtr, path, path)) { - if (winRootPatternPtr->startp[5] - || (winRootPatternPtr->startp[2] - && !(winRootPatternPtr->startp[6]))) { - type = TCL_PATH_VOLUME_RELATIVE; - } - } else { - type = TCL_PATH_RELATIVE; - } - } - break; - } - return type; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SplitPath -- - * - * Split a path into a list of path components. The first element - * of the list will have the same path type as the original path. - * - * Results: - * Returns a standard Tcl result. The interpreter result contains - * a list of path components. - * *argvPtr will be filled in with the address of an array - * whose elements point to the elements of path, in order. - * *argcPtr will get filled in with the number of valid elements - * in the array. A single block of memory is dynamically allocated - * to hold both the argv array and a copy of the path elements. - * The caller must eventually free this memory by calling ckfree() - * on *argvPtr. Note: *argvPtr and *argcPtr are only modified - * if the procedure returns normally. - * - * Side effects: - * Allocates memory. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SplitPath( - char *path, /* Pointer to string containing a path. */ - int *argcPtr, /* Pointer to location to fill in with - * the number of elements in the path. */ - char ***argvPtr /* Pointer to place to store pointer to array - * of pointers to path elements. */ -) -{ - int i, size; - char *p; - Tcl_DString buffer; - Tcl_DStringInit(&buffer); - - /* - * Perform platform specific splitting. These routines will leave the - * result in the specified buffer. Individual elements are terminated - * with a null character. - */ - - p = NULL; /* Needed only to prevent gcc warnings. */ - switch (tclPlatform) { - case TCL_PLATFORM_UNIX: - p = SplitUnixPath(path, &buffer); - break; - - case TCL_PLATFORM_WINDOWS: - p = SplitWinPath(path, &buffer); - break; - - case TCL_PLATFORM_MAC: - p = SplitMacPath(path, &buffer); - break; - } - - /* - * Compute the number of elements in the result. - */ - - size = Tcl_DStringLength(&buffer); - *argcPtr = 0; - for (i = 0; i < size; i++) { - if (p[i] == '\0') { - (*argcPtr)++; - } - } - - /* - * Allocate a buffer large enough to hold the contents of the - * DString plus the argv pointers and the terminating NULL pointer. - */ - - *argvPtr = (char **) ckalloc((unsigned) - ((((*argcPtr) + 1) * sizeof(char *)) + size)); - - /* - * Position p after the last argv pointer and copy the contents of - * the DString. - */ - - p = (char *) &(*argvPtr)[(*argcPtr) + 1]; - memcpy((VOID *) p, (VOID *) Tcl_DStringValue(&buffer), (size_t) size); - - /* - * Now set up the argv pointers. - */ - - for (i = 0; i < *argcPtr; i++) { - (*argvPtr)[i] = p; - while ((*p++) != '\0') {} - } - (*argvPtr)[i] = NULL; - - Tcl_DStringFree(&buffer); -} - -/* - *---------------------------------------------------------------------- - * - * SplitUnixPath -- - * - * This routine is used by Tcl_SplitPath to handle splitting - * Unix paths. - * - * Results: - * Stores a null separated array of strings in the specified - * Tcl_DString. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -SplitUnixPath( - char *path, /* Pointer to string containing a path. */ - Tcl_DString *bufPtr /* Pointer to DString to use for the result. */ -) -{ - int length; - char *p, *elementStart; - - /* - * Deal with the root directory as a special case. - */ - - if (path[0] == '/') { - Tcl_DStringAppend(bufPtr, "/", 2); - p = path+1; - } else { - p = path; - } - - /* - * Split on slashes. Embedded elements that start with tilde will be - * prefixed with "./" so they are not affected by tilde substitution. - */ - - for (;;) { - elementStart = p; - while ((*p != '\0') && (*p != '/')) { - p++; - } - length = p - elementStart; - if (length > 0) { - if ((elementStart[0] == '~') && (elementStart != path)) { - Tcl_DStringAppend(bufPtr, "./", 2); - } - Tcl_DStringAppend(bufPtr, elementStart, length); - Tcl_DStringAppend(bufPtr, "", 1); - } - if (*p++ == '\0') { - break; - } - } - return Tcl_DStringValue(bufPtr); -} - -/* - *---------------------------------------------------------------------- - * - * SplitWinPath -- - * - * This routine is used by Tcl_SplitPath to handle splitting - * Windows paths. - * - * Results: - * Stores a null separated array of strings in the specified - * Tcl_DString. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -SplitWinPath( - char *path, /* Pointer to string containing a path. */ - Tcl_DString *bufPtr /* Pointer to DString to use for the result. */ -) -{ - int length; - char *p, *elementStart; - - p = ExtractWinRoot(path, bufPtr, 0); - - /* - * Terminate the root portion, if we matched something. - */ - - if (p != path) { - Tcl_DStringAppend(bufPtr, "", 1); - } - - /* - * Split on slashes. Embedded elements that start with tilde will be - * prefixed with "./" so they are not affected by tilde substitution. - */ - - do { - elementStart = p; - while ((*p != '\0') && (*p != '/') && (*p != '\\')) { - p++; - } - length = p - elementStart; - if (length > 0) { - if ((elementStart[0] == '~') && (elementStart != path)) { - Tcl_DStringAppend(bufPtr, "./", 2); - } - Tcl_DStringAppend(bufPtr, elementStart, length); - Tcl_DStringAppend(bufPtr, "", 1); - } - } while (*p++ != '\0'); - - return Tcl_DStringValue(bufPtr); -} - -/* - *---------------------------------------------------------------------- - * - * SplitMacPath -- - * - * This routine is used by Tcl_SplitPath to handle splitting - * Macintosh paths. - * - * Results: - * Returns a newly allocated argv array. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -SplitMacPath( - char *path, /* Pointer to string containing a path. */ - Tcl_DString *bufPtr /* Pointer to DString to use for the result. */ -) -{ - int isMac = 0; /* 1 if is Mac-style, 0 if Unix-style path. */ - int i, length; - char *p, *elementStart; - - /* - * Initialize the path name parser for Macintosh path names. - */ - - if (macRootPatternPtr == NULL) { - macRootPatternPtr = TclRegComp(MAC_ROOT_PATTERN); - if (!initialized) { - Tcl_CreateExitHandler(FileNameCleanup, NULL); - initialized = 1; - } - } - - /* - * Match the root portion of a Mac path name. - */ - - i = 0; /* Needed only to prevent gcc warnings. */ - if (TclRegExec(macRootPatternPtr, path, path) == 1) { - /* - * Treat degenerate absolute paths like / and /../.. as - * Mac relative file names for lack of anything else to do. - */ - - if (macRootPatternPtr->startp[2] != NULL) { - Tcl_DStringAppend(bufPtr, ":", 1); - Tcl_DStringAppend(bufPtr, path, macRootPatternPtr->endp[0] - - macRootPatternPtr->startp[0] + 1); - return Tcl_DStringValue(bufPtr); - } - - if (macRootPatternPtr->startp[5] != NULL) { - - /* - * Unix-style tilde prefixed paths. - */ - - isMac = 0; - i = 5; - } else if (macRootPatternPtr->startp[7] != NULL) { - - /* - * Mac-style tilde prefixed paths. - */ - - isMac = 1; - i = 7; - } else if (macRootPatternPtr->startp[10] != NULL) { - - /* - * Normal Unix style paths. - */ - - isMac = 0; - i = 10; - } else if (macRootPatternPtr->startp[12] != NULL) { - - /* - * Normal Mac style paths. - */ - - isMac = 1; - i = 12; - } - - length = macRootPatternPtr->endp[i] - - macRootPatternPtr->startp[i]; - - /* - * Append the element and terminate it with a : and a null. Note that - * we are forcing the DString to contain an extra null at the end. - */ - - Tcl_DStringAppend(bufPtr, macRootPatternPtr->startp[i], length); - Tcl_DStringAppend(bufPtr, ":", 2); - p = macRootPatternPtr->endp[i]; - } else { - isMac = (strchr(path, ':') != NULL); - p = path; - } - - if (isMac) { - - /* - * p is pointing at the first colon in the path. There - * will always be one, since this is a Mac-style path. - */ - - elementStart = p++; - while ((p = strchr(p, ':')) != NULL) { - length = p - elementStart; - if (length == 1) { - while (*p == ':') { - Tcl_DStringAppend(bufPtr, "::", 3); - elementStart = p++; - } - } else { - /* - * If this is a simple component, drop the leading colon. - */ - - if ((elementStart[1] != '~') - && (strchr(elementStart+1, '/') == NULL)) { - elementStart++; - length--; - } - Tcl_DStringAppend(bufPtr, elementStart, length); - Tcl_DStringAppend(bufPtr, "", 1); - elementStart = p++; - } - } - if (elementStart[1] != '\0' || elementStart == path) { - if ((elementStart[1] != '~') && (elementStart[1] != '\0') - && (strchr(elementStart+1, '/') == NULL)) { - elementStart++; - } - Tcl_DStringAppend(bufPtr, elementStart, -1); - Tcl_DStringAppend(bufPtr, "", 1); - } - } else { - - /* - * Split on slashes, suppress extra /'s, and convert .. to ::. - */ - - for (;;) { - elementStart = p; - while ((*p != '\0') && (*p != '/')) { - p++; - } - length = p - elementStart; - if (length > 0) { - if ((length == 1) && (elementStart[0] == '.')) { - Tcl_DStringAppend(bufPtr, ":", 2); - } else if ((length == 2) && (elementStart[0] == '.') - && (elementStart[1] == '.')) { - Tcl_DStringAppend(bufPtr, "::", 3); - } else { - if (*elementStart == '~') { - Tcl_DStringAppend(bufPtr, ":", 1); - } - Tcl_DStringAppend(bufPtr, elementStart, length); - Tcl_DStringAppend(bufPtr, "", 1); - } - } - if (*p++ == '\0') { - break; - } - } - } - return Tcl_DStringValue(bufPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_JoinPath -- - * - * Combine a list of paths in a platform specific manner. - * - * Results: - * Appends the joined path to the end of the specified - * returning a pointer to the resulting string. Note that - * the Tcl_DString must already be initialized. - * - * Side effects: - * Modifies the Tcl_DString. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_JoinPath( - int argc, - char **argv, - Tcl_DString *resultPtr /* Pointer to previously initialized DString. */ -) -{ - int oldLength, length, i, needsSep; - Tcl_DString buffer; - char *p, c, *dest; - - Tcl_DStringInit(&buffer); - oldLength = Tcl_DStringLength(resultPtr); - - switch (tclPlatform) { - case TCL_PLATFORM_UNIX: - for (i = 0; i < argc; i++) { - p = argv[i]; - /* - * If the path is absolute, reset the result buffer. - * Consume any duplicate leading slashes or a ./ in - * front of a tilde prefixed path that isn't at the - * beginning of the path. - */ - - if (*p == '/') { - Tcl_DStringSetLength(resultPtr, oldLength); - Tcl_DStringAppend(resultPtr, "/", 1); - while (*p == '/') { - p++; - } - } else if (*p == '~') { - Tcl_DStringSetLength(resultPtr, oldLength); - } else if ((Tcl_DStringLength(resultPtr) != oldLength) - && (p[0] == '.') && (p[1] == '/') - && (p[2] == '~')) { - p += 2; - } - - if (*p == '\0') { - continue; - } - - /* - * Append a separator if needed. - */ - - length = Tcl_DStringLength(resultPtr); - if ((length != oldLength) - && (Tcl_DStringValue(resultPtr)[length-1] != '/')) { - Tcl_DStringAppend(resultPtr, "/", 1); - length++; - } - - /* - * Append the element, eliminating duplicate and trailing - * slashes. - */ - - Tcl_DStringSetLength(resultPtr, (int) (length + strlen(p))); - dest = Tcl_DStringValue(resultPtr) + length; - for (; *p != '\0'; p++) { - if (*p == '/') { - while (p[1] == '/') { - p++; - } - if (p[1] != '\0') { - *dest++ = '/'; - } - } else { - *dest++ = *p; - } - } - length = dest - Tcl_DStringValue(resultPtr); - Tcl_DStringSetLength(resultPtr, length); - } - break; - - case TCL_PLATFORM_WINDOWS: - /* - * Iterate over all of the components. If a component is - * absolute, then reset the result and start building the - * path from the current component on. - */ - - for (i = 0; i < argc; i++) { - p = ExtractWinRoot(argv[i], resultPtr, oldLength); - length = Tcl_DStringLength(resultPtr); - - /* - * If the pointer didn't move, then this is a relative path - * or a tilde prefixed path. - */ - - if (p == argv[i]) { - /* - * Remove the ./ from tilde prefixed elements unless - * it is the first component. - */ - - if ((length != oldLength) - && (p[0] == '.') - && ((p[1] == '/') || (p[1] == '\\')) - && (p[2] == '~')) { - p += 2; - } else if (*p == '~') { - Tcl_DStringSetLength(resultPtr, oldLength); - length = oldLength; - } - } - - if (*p != '\0') { - /* - * Check to see if we need to append a separator. - */ - - - if (length != oldLength) { - c = Tcl_DStringValue(resultPtr)[length-1]; - if ((c != '/') && (c != ':')) { - Tcl_DStringAppend(resultPtr, "/", 1); - } - } - - /* - * Append the element, eliminating duplicate and - * trailing slashes. - */ - - length = Tcl_DStringLength(resultPtr); - Tcl_DStringSetLength(resultPtr, (int) (length + strlen(p))); - dest = Tcl_DStringValue(resultPtr) + length; - for (; *p != '\0'; p++) { - if ((*p == '/') || (*p == '\\')) { - while ((p[1] == '/') || (p[1] == '\\')) { - p++; - } - if (p[1] != '\0') { - *dest++ = '/'; - } - } else { - *dest++ = *p; - } - } - length = dest - Tcl_DStringValue(resultPtr); - Tcl_DStringSetLength(resultPtr, length); - } - } - break; - - case TCL_PLATFORM_MAC: - needsSep = 1; - for (i = 0; i < argc; i++) { - Tcl_DStringSetLength(&buffer, 0); - p = SplitMacPath(argv[i], &buffer); - if ((*p != ':') && (*p != '\0') - && (strchr(p, ':') != NULL)) { - Tcl_DStringSetLength(resultPtr, oldLength); - length = strlen(p); - Tcl_DStringAppend(resultPtr, p, length); - needsSep = 0; - p += length+1; - } - - /* - * Now append the rest of the path elements, skipping - * : unless it is the first element of the path, and - * watching out for :: et al. so we don't end up with - * too many colons in the result. - */ - - for (; *p != '\0'; p += length+1) { - if (p[0] == ':' && p[1] == '\0') { - if (Tcl_DStringLength(resultPtr) != oldLength) { - p++; - } else { - needsSep = 0; - } - } else { - c = p[1]; - if (*p == ':') { - if (!needsSep) { - p++; - } - } else { - if (needsSep) { - Tcl_DStringAppend(resultPtr, ":", 1); - } - } - needsSep = (c == ':') ? 0 : 1; - } - length = strlen(p); - Tcl_DStringAppend(resultPtr, p, length); - } - } - break; - - } - Tcl_DStringFree(&buffer); - return Tcl_DStringValue(resultPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TranslateFileName -- - * - * Converts a file name into a form usable by the native system - * interfaces. If the name starts with a tilde, it will produce - * a name where the tilde and following characters have been - * replaced by the home directory location for the named user. - * - * Results: - * The result is a pointer to a static string containing - * the new name. If there was an error in processing the - * name, then an error message is left in interp->result - * and the return value is NULL. The result will be stored - * in bufferPtr; the caller must call Tcl_DStringFree(bufferPtr) - * to free the name if the return value was not NULL. - * - * Side effects: - * Information may be left in bufferPtr. - * - *---------------------------------------------------------------------- */ - -char * -Tcl_TranslateFileName( - Tcl_Interp *interp, /* Interpreter in which to store error - * message (if necessary). */ - char *name, /* File name, which may begin with "~" - * (to indicate current user's home directory) - * or "~<user>" (to indicate any user's - * home directory). */ - Tcl_DString *bufferPtr /* May be used to hold result. Must not hold - * anything at the time of the call, and need - * not even be initialized. */ -) -{ - char *p; - - /* - * Handle tilde substitutions, if needed. - */ - - if (name[0] == '~') { - int argc, length; - char **argv; - Tcl_DString temp; - - Tcl_SplitPath(name, &argc, &argv); - - /* - * Strip the trailing ':' off of a Mac path - * before passing the user name to DoTildeSubst. - */ - - if (tclPlatform == TCL_PLATFORM_MAC) { - length = strlen(argv[0]); - argv[0][length-1] = '\0'; - } - - Tcl_DStringInit(&temp); - argv[0] = DoTildeSubst(interp, argv[0]+1, &temp); - if (argv[0] == NULL) { - Tcl_DStringFree(&temp); - ckfree((char *)argv); - return NULL; - } - Tcl_DStringInit(bufferPtr); - Tcl_JoinPath(argc, argv, bufferPtr); - Tcl_DStringFree(&temp); - ckfree((char*)argv); - } else { - Tcl_DStringInit(bufferPtr); - Tcl_JoinPath(1, &name, bufferPtr); - } - - /* - * Convert forward slashes to backslashes in Windows paths because - * some system interfaces don't accept forward slashes. - */ - - if (tclPlatform == TCL_PLATFORM_WINDOWS) { - for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) { - if (*p == '/') { - *p = '\\'; - } - } - } - return Tcl_DStringValue(bufferPtr); -} - -/* - *---------------------------------------------------------------------- - * - * TclGetExtension -- - * - * This function returns a pointer to the beginning of the - * extension part of a file name. - * - * Results: - * Returns a pointer into name which indicates where the extension - * starts. If there is no extension, returns NULL. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -TclGetExtension( - char *name /* File name to parse. */ -) -{ - char *p, *lastSep; - - /* - * First find the last directory separator. - */ - - lastSep = NULL; /* Needed only to prevent gcc warnings. */ - switch (tclPlatform) { - case TCL_PLATFORM_UNIX: - lastSep = strrchr(name, '/'); - break; - - case TCL_PLATFORM_MAC: - if (strchr(name, ':') == NULL) { - lastSep = strrchr(name, '/'); - } else { - lastSep = strrchr(name, ':'); - } - break; - - case TCL_PLATFORM_WINDOWS: - lastSep = NULL; - for (p = name; *p != '\0'; p++) { - if (strchr("/\\:", *p) != NULL) { - lastSep = p; - } - } - break; - } - p = strrchr(name, '.'); - if ((p != NULL) && (lastSep != NULL) - && (lastSep > p)) { - p = NULL; - } - return p; -} - -/* - *---------------------------------------------------------------------- - * - * DoTildeSubst -- - * - * Given a string following a tilde, this routine returns the - * corresponding home directory. - * - * Results: - * The result is a pointer to a static string containing the home - * directory in native format. If there was an error in processing - * the substitution, then an error message is left in interp->result - * and the return value is NULL. On success, the results are appended - * to resultPtr, and the contents of resultPtr are returned. - * - * Side effects: - * Information may be left in resultPtr. - * - *---------------------------------------------------------------------- - */ - -static char * -DoTildeSubst( - Tcl_Interp *interp, /* Interpreter in which to store error - * message (if necessary). */ - char *user, /* Name of user whose home directory should be - * substituted, or "" for current user. */ - Tcl_DString *resultPtr /* May be used to hold result. Must not hold - * anything at the time of the call, and need - * not even be initialized. */ -) -{ - char *dir; - - if (*user == '\0') { - dir = TclGetEnv("HOME"); - if (dir == NULL) { - if (interp) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "couldn't find HOME environment ", - "variable to expand path", (char *) NULL); - } - return NULL; - } - Tcl_JoinPath(1, &dir, resultPtr); - } else { - if (TclGetUserHome(user, resultPtr) == NULL) { - if (interp) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "user \"", user, "\" doesn't exist", - (char *) NULL); - } - return NULL; - } - } - return resultPtr->string; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GlobCmd -- - * - * This procedure is invoked to process the "glob" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_GlobCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i, noComplain, firstArg; - char c; - int result = TCL_OK; - Tcl_DString buffer; - char *separators, *head, *tail; - - noComplain = 0; - for (firstArg = 1; (firstArg < argc) && (argv[firstArg][0] == '-'); - firstArg++) { - if (strcmp(argv[firstArg], "-nocomplain") == 0) { - noComplain = 1; - } else if (strcmp(argv[firstArg], "--") == 0) { - firstArg++; - break; - } else { - Tcl_AppendResult(interp, "bad switch \"", argv[firstArg], - "\": must be -nocomplain or --", (char *) NULL); - return TCL_ERROR; - } - } - if (firstArg >= argc) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?switches? name ?name ...?\"", (char *) NULL); - return TCL_ERROR; - } - - Tcl_DStringInit(&buffer); - separators = NULL; /* Needed only to prevent gcc warnings. */ - for (i = firstArg; i < argc; i++) { - head = tail = ""; - - switch (tclPlatform) { - case TCL_PLATFORM_UNIX: - separators = "/"; - break; - case TCL_PLATFORM_WINDOWS: - separators = "/\\:"; - break; - case TCL_PLATFORM_MAC: - separators = (strchr(argv[i], ':') == NULL) ? "/" : ":"; - break; - } - - Tcl_DStringSetLength(&buffer, 0); - - /* - * Perform tilde substitution, if needed. - */ - - if (argv[i][0] == '~') { - char *p; - - /* - * Find the first path separator after the tilde. - */ - - for (tail = argv[i]; *tail != '\0'; tail++) { - if (*tail == '\\') { - if (strchr(separators, tail[1]) != NULL) { - break; - } - } else if (strchr(separators, *tail) != NULL) { - break; - } - } - - /* - * Determine the home directory for the specified user. Note that - * we don't allow special characters in the user name. - */ - - c = *tail; - *tail = '\0'; - p = strpbrk(argv[i]+1, "\\[]*?{}"); - if (p == NULL) { - head = DoTildeSubst(interp, argv[i]+1, &buffer); - } else { - if (!noComplain) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "globbing characters not ", - "supported in user names", (char *) NULL); - } - head = NULL; - } - *tail = c; - if (head == NULL) { - if (noComplain) { - Tcl_ResetResult(interp); - continue; - } else { - result = TCL_ERROR; - goto done; - } - } - if (head != Tcl_DStringValue(&buffer)) { - Tcl_DStringAppend(&buffer, head, -1); - } - } else { - tail = argv[i]; - } - - result = TclDoGlob(interp, separators, &buffer, tail); - if (result != TCL_OK) { - if (noComplain) { - Tcl_ResetResult(interp); - continue; - } else { - goto done; - } - } - } - - if ((*interp->result == 0) && !noComplain) { - char *sep = ""; - - Tcl_AppendResult(interp, "no files matched glob pattern", - (argc == 2) ? " \"" : "s \"", (char *) NULL); - for (i = firstArg; i < argc; i++) { - Tcl_AppendResult(interp, sep, argv[i], (char *) NULL); - sep = " "; - } - Tcl_AppendResult(interp, "\"", (char *) NULL); - result = TCL_ERROR; - } -done: - Tcl_DStringFree(&buffer); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * SkipToChar -- - * - * This function traverses a glob pattern looking for the next - * unquoted occurrence of the specified character at the same braces - * nesting level. - * - * Results: - * Updates stringPtr to point to the matching character, or to - * the end of the string if nothing matched. The return value - * is 1 if a match was found at the top level, otherwise it is 0. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -SkipToChar( - char **stringPtr, /* Pointer string to check. */ - char *match /* Pointer to character to find. */ -) -{ - int quoted, level; - char *p; - - quoted = 0; - level = 0; - - for (p = *stringPtr; *p != '\0'; p++) { - if (quoted) { - quoted = 0; - continue; - } - if ((level == 0) && (*p == *match)) { - *stringPtr = p; - return 1; - } - if (*p == '{') { - level++; - } else if (*p == '}') { - level--; - } else if (*p == '\\') { - quoted = 1; - } - } - *stringPtr = p; - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * TclDoGlob -- - * - * This recursive procedure forms the heart of the globbing - * code. It performs a depth-first traversal of the tree - * given by the path name to be globbed. The directory and - * remainder are assumed to be native format paths. - * - * Results: - * The return value is a standard Tcl result indicating whether - * an error occurred in globbing. After a normal return the - * result in interp will be set to hold all of the file names - * given by the dir and rem arguments. After an error the - * result in interp will hold an error message. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclDoGlob( - Tcl_Interp *interp, /* Interpreter to use for error reporting - * (e.g. unmatched brace). */ - char *separators, /* String containing separator characters - * that should be used to identify globbing - * boundaries. */ - Tcl_DString *headPtr, /* Completely expanded prefix. */ - char *tail /* The unexpanded remainder of the path. */ -) -{ - int level, baseLength, quoted, count; - int result = TCL_OK; - char *p, *openBrace, *closeBrace, *name, savedChar; - char lastChar = 0; - int length = Tcl_DStringLength(headPtr); - - if (length > 0) { - lastChar = Tcl_DStringValue(headPtr)[length-1]; - } - - /* - * Consume any leading directory separators, leaving tail pointing - * just past the last initial separator. - */ - - count = 0; - name = tail; - for (; *tail != '\0'; tail++) { - if ((*tail == '\\') && (strchr(separators, tail[1]) != NULL)) { - tail++; - } else if (strchr(separators, *tail) == NULL) { - break; - } - count++; - } - - /* - * Deal with path separators. On the Mac, we have to watch out - * for multiple separators, since they are special in Mac-style - * paths. - */ - - switch (tclPlatform) { - case TCL_PLATFORM_MAC: - if (*separators == '/') { - if (((length == 0) && (count == 0)) - || ((length > 0) && (lastChar != ':'))) { - Tcl_DStringAppend(headPtr, ":", 1); - } - } else { - if (count == 0) { - if ((length > 0) && (lastChar != ':')) { - Tcl_DStringAppend(headPtr, ":", 1); - } - } else { - if (lastChar == ':') { - count--; - } - while (count-- > 0) { - Tcl_DStringAppend(headPtr, ":", 1); - } - } - } - break; - case TCL_PLATFORM_WINDOWS: - /* - * If this is a drive relative path, add the colon and the - * trailing slash if needed. Otherwise add the slash if - * this is the first absolute element, or a later relative - * element. Add an extra slash if this is a UNC path. - */ - - if (*name == ':') { - Tcl_DStringAppend(headPtr, ":", 1); - if (count > 1) { - Tcl_DStringAppend(headPtr, "/", 1); - } - } else if ((*tail != '\0') - && (((length > 0) - && (strchr(separators, lastChar) == NULL)) - || ((length == 0) && (count > 0)))) { - Tcl_DStringAppend(headPtr, "/", 1); - if ((length == 0) && (count > 1)) { - Tcl_DStringAppend(headPtr, "/", 1); - } - } - - break; - case TCL_PLATFORM_UNIX: - /* - * Add a separator if this is the first absolute element, or - * a later relative element. - */ - - if ((*tail != '\0') - && (((length > 0) - && (strchr(separators, lastChar) == NULL)) - || ((length == 0) && (count > 0)))) { - Tcl_DStringAppend(headPtr, "/", 1); - } - break; - } - - /* - * Look for the first matching pair of braces or the first - * directory separator that is not inside a pair of braces. - */ - - openBrace = closeBrace = NULL; - level = 0; - quoted = 0; - for (p = tail; *p != '\0'; p++) { - if (quoted) { - quoted = 0; - } else if (*p == '\\') { - quoted = 1; - if (strchr(separators, p[1]) != NULL) { - break; /* Quoted directory separator. */ - } - } else if (strchr(separators, *p) != NULL) { - break; /* Unquoted directory separator. */ - } else if (*p == '{') { - openBrace = p; - p++; - if (SkipToChar(&p, "}")) { - closeBrace = p; /* Balanced braces. */ - break; - } - Tcl_ResetResult(interp); - interp->result = "unmatched open-brace in file name"; - return TCL_ERROR; - } else if (*p == '}') { - Tcl_ResetResult(interp); - interp->result = "unmatched close-brace in file name"; - return TCL_ERROR; - } - } - - /* - * Substitute the alternate patterns from the braces and recurse. - */ - - if (openBrace != NULL) { - char *element; - Tcl_DString newName; - Tcl_DStringInit(&newName); - - /* - * For each element within in the outermost pair of braces, - * append the element and the remainder to the fixed portion - * before the first brace and recursively call TclDoGlob. - */ - - Tcl_DStringAppend(&newName, tail, openBrace-tail); - baseLength = Tcl_DStringLength(&newName); - length = Tcl_DStringLength(headPtr); - *closeBrace = '\0'; - for (p = openBrace; p != closeBrace; ) { - p++; - element = p; - SkipToChar(&p, ","); - Tcl_DStringSetLength(headPtr, length); - Tcl_DStringSetLength(&newName, baseLength); - Tcl_DStringAppend(&newName, element, p-element); - Tcl_DStringAppend(&newName, closeBrace+1, -1); - result = TclDoGlob(interp, separators, - headPtr, Tcl_DStringValue(&newName)); - if (result != TCL_OK) { - break; - } - } - *closeBrace = '}'; - Tcl_DStringFree(&newName); - return result; - } - - /* - * At this point, there are no more brace substitutions to perform on - * this path component. The variable p is pointing at a quoted or - * unquoted directory separator or the end of the string. So we need - * to check for special globbing characters in the current pattern. - */ - - savedChar = *p; - *p = '\0'; - - if (strpbrk(tail, "*[]?\\") != NULL) { - *p = savedChar; - /* - * Look for matching files in the current directory. The - * implementation of this function is platform specific, but may - * recursively call TclDoGlob. For each file that matches, it will - * add the match onto the interp->result, or call TclDoGlob if there - * are more characters to be processed. - */ - - return TclMatchFiles(interp, separators, headPtr, tail, p); - } - *p = savedChar; - Tcl_DStringAppend(headPtr, tail, p-tail); - if (*p != '\0') { - return TclDoGlob(interp, separators, headPtr, p); - } - - /* - * There are no more wildcards in the pattern and no more unprocessed - * characters in the tail, so now we can construct the path and verify - * the existence of the file. - */ - - switch (tclPlatform) { - case TCL_PLATFORM_MAC: - if (strchr(Tcl_DStringValue(headPtr), ':') == NULL) { - Tcl_DStringAppend(headPtr, ":", 1); - } - name = Tcl_DStringValue(headPtr); - if (access(name, F_OK) == 0) { - if ((name[1] != '\0') && (strchr(name+1, ':') == NULL)) { - Tcl_AppendElement(interp, name+1); - } else { - Tcl_AppendElement(interp, name); - } - } - break; - case TCL_PLATFORM_WINDOWS: { - int exists; - /* - * We need to convert slashes to backslashes before checking - * for the existence of the file. Once we are done, we need - * to convert the slashes back. - */ - - if (Tcl_DStringLength(headPtr) == 0) { - if (((*name == '\\') && (name[1] == '/' || name[1] == '\\')) - || (*name == '/')) { - Tcl_DStringAppend(headPtr, "\\", 1); - } else { - Tcl_DStringAppend(headPtr, ".", 1); - } - } else { - for (p = Tcl_DStringValue(headPtr); *p != '\0'; p++) { - if (*p == '/') { - *p = '\\'; - } - } - } - name = Tcl_DStringValue(headPtr); - exists = (access(name, F_OK) == 0); - for (p = name; *p != '\0'; p++) { - if (*p == '\\') { - *p = '/'; - } - } - if (exists) { - Tcl_AppendElement(interp, name); - } - break; - } - case TCL_PLATFORM_UNIX: - if (Tcl_DStringLength(headPtr) == 0) { - if ((*name == '\\' && name[1] == '/') || (*name == '/')) { - Tcl_DStringAppend(headPtr, "/", 1); - } else { - Tcl_DStringAppend(headPtr, ".", 1); - } - } - name = Tcl_DStringValue(headPtr); - if (access(name, F_OK) == 0) { - Tcl_AppendElement(interp, name); - } - break; - } - - return TCL_OK; -} diff --git a/cde/programs/dtdocbook/tcl/tclGet.c b/cde/programs/dtdocbook/tcl/tclGet.c deleted file mode 100644 index 38954ac7a..000000000 --- a/cde/programs/dtdocbook/tcl/tclGet.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclGet.c /main/2 1996/08/08 14:44:07 cde-hp $ */ -/* - * tclGet.c -- - * - * This file contains procedures to convert strings into - * other forms, like integers or floating-point numbers or - * booleans, doing syntax checking along the way. - * - * Copyright (c) 1990-1993 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclGet.c 1.24 96/02/15 11:42:47 - */ - -#include "tclInt.h" -#include "tclPort.h" - - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetInt -- - * - * Given a string, produce the corresponding integer value. - * - * Results: - * The return value is normally TCL_OK; in this case *intPtr - * will be set to the integer value equivalent to string. If - * string is improperly formed then TCL_ERROR is returned and - * an error message will be left in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetInt( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - char *string, /* String containing a (possibly signed) - * integer in a form acceptable to strtol. */ - int *intPtr /* Place to store converted result. */ -) -{ - char *end, *p; - int i; - - /* - * Note: use strtoul instead of strtol for integer conversions - * to allow full-size unsigned numbers, but don't depend on strtoul - * to handle sign characters; it won't in some implementations. - */ - - errno = 0; - for (p = string; isspace(UCHAR(*p)); p++) { - /* Empty loop body. */ - } - if (*p == '-') { - p++; - i = -(int)strtoul(p, &end, 0); - } else if (*p == '+') { - p++; - i = strtoul(p, &end, 0); - } else { - i = strtoul(p, &end, 0); - } - if (end == p) { - badInteger: - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "expected integer but got \"", string, - "\"", (char *) NULL); - } - return TCL_ERROR; - } - if (errno == ERANGE) { - if (interp != (Tcl_Interp *) NULL) { - interp->result = "integer value too large to represent"; - Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", - interp->result, (char *) NULL); - } - return TCL_ERROR; - } - while ((*end != '\0') && isspace(UCHAR(*end))) { - end++; - } - if (*end != 0) { - goto badInteger; - } - *intPtr = i; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetDouble -- - * - * Given a string, produce the corresponding double-precision - * floating-point value. - * - * Results: - * The return value is normally TCL_OK; in this case *doublePtr - * will be set to the double-precision value equivalent to string. - * If string is improperly formed then TCL_ERROR is returned and - * an error message will be left in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetDouble( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - char *string, /* String containing a floating-point number - * in a form acceptable to strtod. */ - double *doublePtr /* Place to store converted result. */ -) -{ - char *end; - double d; - - errno = 0; - d = strtod(string, &end); - if (end == string) { - badDouble: - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "expected floating-point number but got \"", - string, "\"", (char *) NULL); - } - return TCL_ERROR; - } - if (errno != 0) { - if (interp != (Tcl_Interp *) NULL) { - TclExprFloatError(interp, d); - } - return TCL_ERROR; - } - while ((*end != 0) && isspace(UCHAR(*end))) { - end++; - } - if (*end != 0) { - goto badDouble; - } - *doublePtr = d; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetBoolean -- - * - * Given a string, return a 0/1 boolean value corresponding - * to the string. - * - * Results: - * The return value is normally TCL_OK; in this case *boolPtr - * will be set to the 0/1 value equivalent to string. If - * string is improperly formed then TCL_ERROR is returned and - * an error message will be left in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetBoolean( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - char *string, /* String containing a boolean number - * specified either as 1/0 or true/false or - * yes/no. */ - int *boolPtr /* Place to store converted result, which - * will be 0 or 1. */ -) -{ - int i; - char lowerCase[10], c; - size_t length; - - /* - * Convert the input string to all lower-case. - */ - - for (i = 0; i < 9; i++) { - c = string[i]; - if (c == 0) { - break; - } - if ((c >= 'A') && (c <= 'Z')) { - c += (char) ('a' - 'A'); - } - lowerCase[i] = c; - } - lowerCase[i] = 0; - - length = strlen(lowerCase); - c = lowerCase[0]; - if ((c == '0') && (lowerCase[1] == '\0')) { - *boolPtr = 0; - } else if ((c == '1') && (lowerCase[1] == '\0')) { - *boolPtr = 1; - } else if ((c == 'y') && (strncmp(lowerCase, "yes", length) == 0)) { - *boolPtr = 1; - } else if ((c == 'n') && (strncmp(lowerCase, "no", length) == 0)) { - *boolPtr = 0; - } else if ((c == 't') && (strncmp(lowerCase, "true", length) == 0)) { - *boolPtr = 1; - } else if ((c == 'f') && (strncmp(lowerCase, "false", length) == 0)) { - *boolPtr = 0; - } else if ((c == 'o') && (length >= 2)) { - if (strncmp(lowerCase, "on", length) == 0) { - *boolPtr = 1; - } else if (strncmp(lowerCase, "off", length) == 0) { - *boolPtr = 0; - } else { - goto badBoolean; - } - } else { - badBoolean: - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "expected boolean value but got \"", - string, "\"", (char *) NULL); - } - return TCL_ERROR; - } - return TCL_OK; -} diff --git a/cde/programs/dtdocbook/tcl/tclHash.c b/cde/programs/dtdocbook/tcl/tclHash.c deleted file mode 100644 index 646f11d5e..000000000 --- a/cde/programs/dtdocbook/tcl/tclHash.c +++ /dev/null @@ -1,960 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclHash.c /main/2 1996/08/08 14:44:13 cde-hp $ */ -/* - * tclHash.c -- - * - * Implementation of in-memory hash tables for Tcl and Tcl-based - * applications. - * - * Copyright (c) 1991-1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclHash.c 1.15 96/02/15 11:50:23 - */ - -#include "tclInt.h" - -/* - * When there are this many entries per bucket, on average, rebuild - * the hash table to make it larger. - */ - -#define REBUILD_MULTIPLIER 3 - - -/* - * The following macro takes a preliminary integer hash value and - * produces an index into a hash tables bucket list. The idea is - * to make it so that preliminary values that are arbitrarily similar - * will end up in different buckets. The hash function was taken - * from a random-number generator. - */ - -#define RANDOM_INDEX(tablePtr, i) \ - (((((long) (i))*1103515245) >> (tablePtr)->downShift) & (tablePtr)->mask) - -/* - * Procedure prototypes for static procedures in this file: - */ - -static Tcl_HashEntry * ArrayFind _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key)); -static Tcl_HashEntry * ArrayCreate _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key, int *newPtr)); -static Tcl_HashEntry * BogusFind _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key)); -static Tcl_HashEntry * BogusCreate _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key, int *newPtr)); -static unsigned int HashString _ANSI_ARGS_((char *string)); -static void RebuildTable _ANSI_ARGS_((Tcl_HashTable *tablePtr)); -static Tcl_HashEntry * StringFind _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key)); -static Tcl_HashEntry * StringCreate _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key, int *newPtr)); -static Tcl_HashEntry * OneWordFind _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key)); -static Tcl_HashEntry * OneWordCreate _ANSI_ARGS_((Tcl_HashTable *tablePtr, - char *key, int *newPtr)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_InitHashTable -- - * - * Given storage for a hash table, set up the fields to prepare - * the hash table for use. - * - * Results: - * None. - * - * Side effects: - * TablePtr is now ready to be passed to Tcl_FindHashEntry and - * Tcl_CreateHashEntry. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_InitHashTable( - Tcl_HashTable *tablePtr, /* Pointer to table record, which - * is supplied by the caller. */ - int keyType /* Type of keys to use in table: - * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, - * or an integer >= 2. */ -) -{ - tablePtr->buckets = tablePtr->staticBuckets; - tablePtr->staticBuckets[0] = tablePtr->staticBuckets[1] = 0; - tablePtr->staticBuckets[2] = tablePtr->staticBuckets[3] = 0; - tablePtr->numBuckets = TCL_SMALL_HASH_TABLE; - tablePtr->numEntries = 0; - tablePtr->rebuildSize = TCL_SMALL_HASH_TABLE*REBUILD_MULTIPLIER; - tablePtr->downShift = 28; - tablePtr->mask = 3; - tablePtr->keyType = keyType; - if (keyType == TCL_STRING_KEYS) { - tablePtr->findProc = StringFind; - tablePtr->createProc = StringCreate; - } else if (keyType == TCL_ONE_WORD_KEYS) { - tablePtr->findProc = OneWordFind; - tablePtr->createProc = OneWordCreate; - } else { - tablePtr->findProc = ArrayFind; - tablePtr->createProc = ArrayCreate; - }; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteHashEntry -- - * - * Remove a single entry from a hash table. - * - * Results: - * None. - * - * Side effects: - * The entry given by entryPtr is deleted from its table and - * should never again be used by the caller. It is up to the - * caller to free the clientData field of the entry, if that - * is relevant. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteHashEntry( - Tcl_HashEntry *entryPtr -) -{ - Tcl_HashEntry *prevPtr; - - if (*entryPtr->bucketPtr == entryPtr) { - *entryPtr->bucketPtr = entryPtr->nextPtr; - } else { - for (prevPtr = *entryPtr->bucketPtr; ; prevPtr = prevPtr->nextPtr) { - if (prevPtr == NULL) { - panic("malformed bucket chain in Tcl_DeleteHashEntry"); - } - if (prevPtr->nextPtr == entryPtr) { - prevPtr->nextPtr = entryPtr->nextPtr; - break; - } - } - } - entryPtr->tablePtr->numEntries--; - ckfree((char *) entryPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteHashTable -- - * - * Free up everything associated with a hash table except for - * the record for the table itself. - * - * Results: - * None. - * - * Side effects: - * The hash table is no longer useable. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteHashTable( - Tcl_HashTable *tablePtr /* Table to delete. */ -) -{ - Tcl_HashEntry *hPtr, *nextPtr; - int i; - - /* - * Free up all the entries in the table. - */ - - for (i = 0; i < tablePtr->numBuckets; i++) { - hPtr = tablePtr->buckets[i]; - while (hPtr != NULL) { - nextPtr = hPtr->nextPtr; - ckfree((char *) hPtr); - hPtr = nextPtr; - } - } - - /* - * Free up the bucket array, if it was dynamically allocated. - */ - - if (tablePtr->buckets != tablePtr->staticBuckets) { - ckfree((char *) tablePtr->buckets); - } - - /* - * Arrange for panics if the table is used again without - * re-initialization. - */ - - tablePtr->findProc = BogusFind; - tablePtr->createProc = BogusCreate; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FirstHashEntry -- - * - * Locate the first entry in a hash table and set up a record - * that can be used to step through all the remaining entries - * of the table. - * - * Results: - * The return value is a pointer to the first entry in tablePtr, - * or NULL if tablePtr has no entries in it. The memory at - * *searchPtr is initialized so that subsequent calls to - * Tcl_NextHashEntry will return all of the entries in the table, - * one at a time. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_HashEntry * -Tcl_FirstHashEntry( - Tcl_HashTable *tablePtr, /* Table to search. */ - Tcl_HashSearch *searchPtr /* Place to store information about - * progress through the table. */ -) -{ - searchPtr->tablePtr = tablePtr; - searchPtr->nextIndex = 0; - searchPtr->nextEntryPtr = NULL; - return Tcl_NextHashEntry(searchPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_NextHashEntry -- - * - * Once a hash table enumeration has been initiated by calling - * Tcl_FirstHashEntry, this procedure may be called to return - * successive elements of the table. - * - * Results: - * The return value is the next entry in the hash table being - * enumerated, or NULL if the end of the table is reached. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_HashEntry * -Tcl_NextHashEntry( - Tcl_HashSearch *searchPtr /* Place to store information about - * progress through the table. Must - * have been initialized by calling - * Tcl_FirstHashEntry. */ -) -{ - Tcl_HashEntry *hPtr; - - while (searchPtr->nextEntryPtr == NULL) { - if (searchPtr->nextIndex >= searchPtr->tablePtr->numBuckets) { - return NULL; - } - searchPtr->nextEntryPtr = - searchPtr->tablePtr->buckets[searchPtr->nextIndex]; - searchPtr->nextIndex++; - } - hPtr = searchPtr->nextEntryPtr; - searchPtr->nextEntryPtr = hPtr->nextPtr; - return hPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_HashStats -- - * - * Return statistics describing the layout of the hash table - * in its hash buckets. - * - * Results: - * The return value is a malloc-ed string containing information - * about tablePtr. It is the caller's responsibility to free - * this string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_HashStats( - Tcl_HashTable *tablePtr /* Table for which to produce stats. */ -) -{ -#define NUM_COUNTERS 10 - int count[NUM_COUNTERS], overflow, i, j; - double average, tmp; - Tcl_HashEntry *hPtr; - char *result, *p; - - /* - * Compute a histogram of bucket usage. - */ - - for (i = 0; i < NUM_COUNTERS; i++) { - count[i] = 0; - } - overflow = 0; - average = 0.0; - for (i = 0; i < tablePtr->numBuckets; i++) { - j = 0; - for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) { - j++; - } - if (j < NUM_COUNTERS) { - count[j]++; - } else { - overflow++; - } - tmp = j; - average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; - } - - /* - * Print out the histogram and a few other pieces of information. - */ - - result = (char *) ckalloc((unsigned) ((NUM_COUNTERS*60) + 300)); - sprintf(result, "%d entries in table, %d buckets\n", - tablePtr->numEntries, tablePtr->numBuckets); - p = result + strlen(result); - for (i = 0; i < NUM_COUNTERS; i++) { - sprintf(p, "number of buckets with %d entries: %d\n", - i, count[i]); - p += strlen(p); - } - sprintf(p, "number of buckets with %d or more entries: %d\n", - NUM_COUNTERS, overflow); - p += strlen(p); - sprintf(p, "average search distance for entry: %.1f", average); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * HashString -- - * - * Compute a one-word summary of a text string, which can be - * used to generate a hash index. - * - * Results: - * The return value is a one-word summary of the information in - * string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static unsigned int -HashString( - char *string /* String from which to compute hash value. */ -) -{ - unsigned int result; - int c; - - /* - * I tried a zillion different hash functions and asked many other - * people for advice. Many people had their own favorite functions, - * all different, but no-one had much idea why they were good ones. - * I chose the one below (multiply by 9 and add new character) - * because of the following reasons: - * - * 1. Multiplying by 10 is perfect for keys that are decimal strings, - * and multiplying by 9 is just about as good. - * 2. Times-9 is (shift-left-3) plus (old). This means that each - * character's bits hang around in the low-order bits of the - * hash value for ever, plus they spread fairly rapidly up to - * the high-order bits to fill out the hash value. This seems - * works well both for decimal and non-decimal strings. - */ - - result = 0; - while (1) { - c = *string; - string++; - if (c == 0) { - break; - } - result += (result<<3) + c; - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * StringFind -- - * - * Given a hash table with string keys, and a string key, find - * the entry with a matching key. - * - * Results: - * The return value is a token for the matching entry in the - * hash table, or NULL if there was no matching entry. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -StringFind( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key /* Key to use to find matching entry. */ -) -{ - Tcl_HashEntry *hPtr; - char *p1, *p2; - int index; - - index = HashString(key) & tablePtr->mask; - - /* - * Search all of the entries in the appropriate bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) { - if (*p1 != *p2) { - break; - } - if (*p1 == '\0') { - return hPtr; - } - } - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * StringCreate -- - * - * Given a hash table with string keys, and a string key, find - * the entry with a matching key. If there is no matching entry, - * then create a new entry that does match. - * - * Results: - * The return value is a pointer to the matching entry. If this - * is a newly-created entry, then *newPtr will be set to a non-zero - * value; otherwise *newPtr will be set to 0. If this is a new - * entry the value stored in the entry will initially be 0. - * - * Side effects: - * A new entry may be added to the hash table. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -StringCreate( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key, /* Key to use to find or create matching - * entry. */ - int *newPtr /* Store info here telling whether a new - * entry was created. */ -) -{ - Tcl_HashEntry *hPtr; - char *p1, *p2; - int index; - - index = HashString(key) & tablePtr->mask; - - /* - * Search all of the entries in this bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) { - if (*p1 != *p2) { - break; - } - if (*p1 == '\0') { - *newPtr = 0; - return hPtr; - } - } - } - - /* - * Entry not found. Add a new one to the bucket. - */ - - *newPtr = 1; - hPtr = (Tcl_HashEntry *) ckalloc((unsigned) - (sizeof(Tcl_HashEntry) + strlen(key) - (sizeof(hPtr->key) -1))); - hPtr->tablePtr = tablePtr; - hPtr->bucketPtr = &(tablePtr->buckets[index]); - hPtr->nextPtr = *hPtr->bucketPtr; - hPtr->clientData = 0; - strcpy(hPtr->key.string, key); - *hPtr->bucketPtr = hPtr; - tablePtr->numEntries++; - - /* - * If the table has exceeded a decent size, rebuild it with many - * more buckets. - */ - - if (tablePtr->numEntries >= tablePtr->rebuildSize) { - RebuildTable(tablePtr); - } - return hPtr; -} - -/* - *---------------------------------------------------------------------- - * - * OneWordFind -- - * - * Given a hash table with one-word keys, and a one-word key, find - * the entry with a matching key. - * - * Results: - * The return value is a token for the matching entry in the - * hash table, or NULL if there was no matching entry. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -OneWordFind( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key /* Key to use to find matching entry. */ -) -{ - Tcl_HashEntry *hPtr; - int index; - - index = RANDOM_INDEX(tablePtr, key); - - /* - * Search all of the entries in the appropriate bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - if (hPtr->key.oneWordValue == key) { - return hPtr; - } - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * OneWordCreate -- - * - * Given a hash table with one-word keys, and a one-word key, find - * the entry with a matching key. If there is no matching entry, - * then create a new entry that does match. - * - * Results: - * The return value is a pointer to the matching entry. If this - * is a newly-created entry, then *newPtr will be set to a non-zero - * value; otherwise *newPtr will be set to 0. If this is a new - * entry the value stored in the entry will initially be 0. - * - * Side effects: - * A new entry may be added to the hash table. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -OneWordCreate( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key, /* Key to use to find or create matching - * entry. */ - int *newPtr /* Store info here telling whether a new - * entry was created. */ -) -{ - Tcl_HashEntry *hPtr; - int index; - - index = RANDOM_INDEX(tablePtr, key); - - /* - * Search all of the entries in this bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - if (hPtr->key.oneWordValue == key) { - *newPtr = 0; - return hPtr; - } - } - - /* - * Entry not found. Add a new one to the bucket. - */ - - *newPtr = 1; - hPtr = (Tcl_HashEntry *) ckalloc(sizeof(Tcl_HashEntry)); - hPtr->tablePtr = tablePtr; - hPtr->bucketPtr = &(tablePtr->buckets[index]); - hPtr->nextPtr = *hPtr->bucketPtr; - hPtr->clientData = 0; - hPtr->key.oneWordValue = key; - *hPtr->bucketPtr = hPtr; - tablePtr->numEntries++; - - /* - * If the table has exceeded a decent size, rebuild it with many - * more buckets. - */ - - if (tablePtr->numEntries >= tablePtr->rebuildSize) { - RebuildTable(tablePtr); - } - return hPtr; -} - -/* - *---------------------------------------------------------------------- - * - * ArrayFind -- - * - * Given a hash table with array-of-int keys, and a key, find - * the entry with a matching key. - * - * Results: - * The return value is a token for the matching entry in the - * hash table, or NULL if there was no matching entry. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -ArrayFind( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key /* Key to use to find matching entry. */ -) -{ - Tcl_HashEntry *hPtr; - int *arrayPtr = (int *) key; - int *iPtr1, *iPtr2; - int index, count; - - for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr; - count > 0; count--, iPtr1++) { - index += *iPtr1; - } - index = RANDOM_INDEX(tablePtr, index); - - /* - * Search all of the entries in the appropriate bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, - count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) { - if (count == 0) { - return hPtr; - } - if (*iPtr1 != *iPtr2) { - break; - } - } - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * ArrayCreate -- - * - * Given a hash table with one-word keys, and a one-word key, find - * the entry with a matching key. If there is no matching entry, - * then create a new entry that does match. - * - * Results: - * The return value is a pointer to the matching entry. If this - * is a newly-created entry, then *newPtr will be set to a non-zero - * value; otherwise *newPtr will be set to 0. If this is a new - * entry the value stored in the entry will initially be 0. - * - * Side effects: - * A new entry may be added to the hash table. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashEntry * -ArrayCreate( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key, /* Key to use to find or create matching - * entry. */ - int *newPtr /* Store info here telling whether a new - * entry was created. */ -) -{ - Tcl_HashEntry *hPtr; - int *arrayPtr = (int *) key; - int *iPtr1, *iPtr2; - int index, count; - - for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr; - count > 0; count--, iPtr1++) { - index += *iPtr1; - } - index = RANDOM_INDEX(tablePtr, index); - - /* - * Search all of the entries in the appropriate bucket. - */ - - for (hPtr = tablePtr->buckets[index]; hPtr != NULL; - hPtr = hPtr->nextPtr) { - for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, - count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) { - if (count == 0) { - *newPtr = 0; - return hPtr; - } - if (*iPtr1 != *iPtr2) { - break; - } - } - } - - /* - * Entry not found. Add a new one to the bucket. - */ - - *newPtr = 1; - hPtr = (Tcl_HashEntry *) ckalloc((unsigned) (sizeof(Tcl_HashEntry) - + (tablePtr->keyType*sizeof(int)) - 4)); - hPtr->tablePtr = tablePtr; - hPtr->bucketPtr = &(tablePtr->buckets[index]); - hPtr->nextPtr = *hPtr->bucketPtr; - hPtr->clientData = 0; - for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, count = tablePtr->keyType; - count > 0; count--, iPtr1++, iPtr2++) { - *iPtr2 = *iPtr1; - } - *hPtr->bucketPtr = hPtr; - tablePtr->numEntries++; - - /* - * If the table has exceeded a decent size, rebuild it with many - * more buckets. - */ - - if (tablePtr->numEntries >= tablePtr->rebuildSize) { - RebuildTable(tablePtr); - } - return hPtr; -} - -/* - *---------------------------------------------------------------------- - * - * BogusFind -- - * - * This procedure is invoked when an Tcl_FindHashEntry is called - * on a table that has been deleted. - * - * Results: - * If panic returns (which it shouldn't) this procedure returns - * NULL. - * - * Side effects: - * Generates a panic. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static Tcl_HashEntry * -BogusFind( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key /* Key to use to find matching entry. */ -) -{ - panic("called Tcl_FindHashEntry on deleted table"); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * BogusCreate -- - * - * This procedure is invoked when an Tcl_CreateHashEntry is called - * on a table that has been deleted. - * - * Results: - * If panic returns (which it shouldn't) this procedure returns - * NULL. - * - * Side effects: - * Generates a panic. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static Tcl_HashEntry * -BogusCreate( - Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - char *key, /* Key to use to find or create matching - * entry. */ - int *newPtr /* Store info here telling whether a new - * entry was created. */ -) -{ - panic("called Tcl_CreateHashEntry on deleted table"); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * RebuildTable -- - * - * This procedure is invoked when the ratio of entries to hash - * buckets becomes too large. It creates a new table with a - * larger bucket array and moves all of the entries into the - * new table. - * - * Results: - * None. - * - * Side effects: - * Memory gets reallocated and entries get re-hashed to new - * buckets. - * - *---------------------------------------------------------------------- - */ - -static void -RebuildTable( - Tcl_HashTable *tablePtr /* Table to enlarge. */ -) -{ - int oldSize, count, index; - Tcl_HashEntry **oldBuckets; - Tcl_HashEntry **oldChainPtr, **newChainPtr; - Tcl_HashEntry *hPtr; - - oldSize = tablePtr->numBuckets; - oldBuckets = tablePtr->buckets; - - /* - * Allocate and initialize the new bucket array, and set up - * hashing constants for new array size. - */ - - tablePtr->numBuckets *= 4; - tablePtr->buckets = (Tcl_HashEntry **) ckalloc((unsigned) - (tablePtr->numBuckets * sizeof(Tcl_HashEntry *))); - for (count = tablePtr->numBuckets, newChainPtr = tablePtr->buckets; - count > 0; count--, newChainPtr++) { - *newChainPtr = NULL; - } - tablePtr->rebuildSize *= 4; - tablePtr->downShift -= 2; - tablePtr->mask = (tablePtr->mask << 2) + 3; - - /* - * Rehash all of the existing entries into the new bucket array. - */ - - for (oldChainPtr = oldBuckets; oldSize > 0; oldSize--, oldChainPtr++) { - for (hPtr = *oldChainPtr; hPtr != NULL; hPtr = *oldChainPtr) { - *oldChainPtr = hPtr->nextPtr; - if (tablePtr->keyType == TCL_STRING_KEYS) { - index = HashString(hPtr->key.string) & tablePtr->mask; - } else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) { - index = RANDOM_INDEX(tablePtr, hPtr->key.oneWordValue); - } else { - int *iPtr; - int count; - - for (index = 0, count = tablePtr->keyType, - iPtr = hPtr->key.words; count > 0; count--, iPtr++) { - index += *iPtr; - } - index = RANDOM_INDEX(tablePtr, index); - } - hPtr->bucketPtr = &(tablePtr->buckets[index]); - hPtr->nextPtr = *hPtr->bucketPtr; - *hPtr->bucketPtr = hPtr; - } - } - - /* - * Free up the old bucket array, if it was dynamically allocated. - */ - - if (oldBuckets != tablePtr->staticBuckets) { - ckfree((char *) oldBuckets); - } -} diff --git a/cde/programs/dtdocbook/tcl/tclHistory.c b/cde/programs/dtdocbook/tcl/tclHistory.c deleted file mode 100644 index 374c5bc1e..000000000 --- a/cde/programs/dtdocbook/tcl/tclHistory.c +++ /dev/null @@ -1,1130 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclHistory.c /main/2 1996/08/08 14:44:19 cde-hp $ */ -/* - * tclHistory.c -- - * - * This module implements history as an optional addition to Tcl. - * It can be called to record commands ("events") before they are - * executed, and it provides a command that may be used to perform - * history substitutions. - * - * Copyright (c) 1990-1993 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclHistory.c 1.40 96/02/15 11:50:24 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * This history stuff is mostly straightforward, except for one thing - * that makes everything very complicated. Suppose that the following - * commands get executed: - * echo foo - * history redo - * It's important that the history event recorded for the second command - * be "echo foo", not "history redo". Otherwise, if another "history redo" - * command is typed, it will result in infinite recursions on the - * "history redo" command. Thus, the actual recorded history must be - * echo foo - * echo foo - * To do this, the history command revises recorded history as part of - * its execution. In the example above, when "history redo" starts - * execution, the current event is "history redo", but the history - * command arranges for the current event to be changed to "echo foo". - * - * There are three additional complications. The first is that history - * substitution may only be part of a command, as in the following - * command sequence: - * echo foo bar - * echo [history word 3] - * In this case, the second event should be recorded as "echo bar". Only - * part of the recorded event is to be modified. Fortunately, Tcl_Eval - * helps with this by recording (in the evalFirst and evalLast fields of - * the intepreter) the location of the command being executed, so the - * history module can replace exactly the range of bytes corresponding - * to the history substitution command. - * - * The second complication is that there are two ways to revise history: - * replace a command, and replace the result of a command. Consider the - * two examples below: - * format {result is %d} $num | format {result is %d} $num - * print [history redo] | print [history word 3] - * Recorded history for these two cases should be as follows: - * format {result is %d} $num | format {result is %d} $num - * print [format {result is %d} $num] | print $num - * In the left case, the history command was replaced with another command - * to be executed (the brackets were retained), but in the case on the - * right the result of executing the history command was replaced (i.e. - * brackets were replaced too). - * - * The third complication is that there could potentially be many - * history substitutions within a single command, as in: - * echo [history word 3] [history word 2] - * There could even be nested history substitutions, as in: - * history subs abc [history word 2] - * If history revisions were made immediately during each "history" command - * invocations, it would be very difficult to produce the correct cumulative - * effect from several substitutions in the same command. To get around - * this problem, the actual history revision isn't made during the execution - * of the "history" command. Information about the changes is just recorded, - * in xxx records, and the actual changes are made during the next call to - * Tcl_RecordHistory (when we know that execution of the previous command - * has finished). - */ - -/* - * Default space allocation for command strings: - */ - -#define INITIAL_CMD_SIZE 40 - -/* - * Forward declarations for procedures defined later in this file: - */ - -static void DoRevs _ANSI_ARGS_((Interp *iPtr)); -static HistoryEvent * GetEvent _ANSI_ARGS_((Interp *iPtr, char *string)); -static char * GetWords _ANSI_ARGS_((Interp *iPtr, char *command, - char *words)); -static void InitHistory _ANSI_ARGS_((Interp *iPtr)); -static void InsertRev _ANSI_ARGS_((Interp *iPtr, - HistoryRev *revPtr)); -static void MakeSpace _ANSI_ARGS_((HistoryEvent *hPtr, int size)); -static void RevCommand _ANSI_ARGS_((Interp *iPtr, char *string)); -static void RevResult _ANSI_ARGS_((Interp *iPtr, char *string)); -static int SubsAndEval _ANSI_ARGS_((Interp *iPtr, char *cmd, - char *old, char *new)); - -/* - *---------------------------------------------------------------------- - * - * InitHistory -- - * - * Initialize history-related state in an interpreter. - * - * Results: - * None. - * - * Side effects: - * History info is initialized in iPtr. - * - *---------------------------------------------------------------------- - */ - -static void -InitHistory( - Interp *iPtr /* Interpreter to initialize. */ -) -{ - int i; - - if (iPtr->numEvents != 0) { - return; - } - iPtr->numEvents = 20; - iPtr->events = (HistoryEvent *) - ckalloc((unsigned) (iPtr->numEvents * sizeof(HistoryEvent))); - for (i = 0; i < iPtr->numEvents; i++) { - iPtr->events[i].command = (char *) ckalloc(INITIAL_CMD_SIZE); - *iPtr->events[i].command = 0; - iPtr->events[i].bytesAvl = INITIAL_CMD_SIZE; - } - iPtr->curEvent = 0; - iPtr->curEventNum = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RecordAndEval -- - * - * This procedure adds its command argument to the current list of - * recorded events and then executes the command by calling - * Tcl_Eval. - * - * Results: - * The return value is a standard Tcl return value, the result of - * executing cmd. - * - * Side effects: - * The command is recorded and executed. In addition, pending history - * revisions are carried out, and information is set up to enable - * Tcl_Eval to identify history command ranges. This procedure also - * initializes history information for the interpreter, if it hasn't - * already been initialized. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_RecordAndEval( - Tcl_Interp *interp, /* Token for interpreter in which command - * will be executed. */ - char *cmd, /* Command to record. */ - int flags /* Additional flags. TCL_NO_EVAL means - * only record: don't execute command. - * TCL_EVAL_GLOBAL means use Tcl_GlobalEval - * instead of Tcl_Eval. */ -) -{ - Interp *iPtr = (Interp *) interp; - HistoryEvent *eventPtr; - int length, result; - - if (iPtr->numEvents == 0) { - InitHistory(iPtr); - } - DoRevs(iPtr); - - /* - * Don't record empty commands. - */ - - while (isspace(UCHAR(*cmd))) { - cmd++; - } - if (*cmd == '\0') { - Tcl_ResetResult(interp); - return TCL_OK; - } - - iPtr->curEventNum++; - iPtr->curEvent++; - if (iPtr->curEvent >= iPtr->numEvents) { - iPtr->curEvent = 0; - } - eventPtr = &iPtr->events[iPtr->curEvent]; - - /* - * Chop off trailing newlines before recording the command. - */ - - length = strlen(cmd); - while (cmd[length-1] == '\n') { - length--; - } - MakeSpace(eventPtr, length + 1); - strncpy(eventPtr->command, cmd, (size_t) length); - eventPtr->command[length] = 0; - - /* - * Execute the command. Note: history revision isn't possible after - * a nested call to this procedure, because the event at the top of - * the history list no longer corresponds to what's going on when - * a nested call here returns. Thus, must leave history revision - * disabled when we return. - */ - - result = TCL_OK; - if (!(flags & TCL_NO_EVAL)) { - iPtr->historyFirst = cmd; - iPtr->revDisables = 0; - iPtr->evalFlags = (flags & ~TCL_EVAL_GLOBAL) | TCL_RECORD_BOUNDS; - if (flags & TCL_EVAL_GLOBAL) { - result = Tcl_GlobalEval(interp, cmd); - } else { - result = Tcl_Eval(interp, cmd); - } - } - iPtr->revDisables = 1; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_HistoryCmd -- - * - * This procedure is invoked to process the "history" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_HistoryCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - HistoryEvent *eventPtr; - size_t length; - int c; - - if (iPtr->numEvents == 0) { - InitHistory(iPtr); - } - - /* - * If no arguments, treat the same as "history info". - */ - - if (argc == 1) { - goto infoCmd; - } - - c = argv[1][0]; - length = strlen(argv[1]); - - if ((c == 'a') && (strncmp(argv[1], "add", length)) == 0) { - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " add event ?exec?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 4) { - if (strncmp(argv[3], "exec", strlen(argv[3])) != 0) { - Tcl_AppendResult(interp, "bad argument \"", argv[3], - "\": should be \"exec\"", (char *) NULL); - return TCL_ERROR; - } - return Tcl_RecordAndEval(interp, argv[2], 0); - } - return Tcl_RecordAndEval(interp, argv[2], TCL_NO_EVAL); - } else if ((c == 'c') && (strncmp(argv[1], "change", length)) == 0) { - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " change newValue ?event?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - eventPtr = &iPtr->events[iPtr->curEvent]; - iPtr->revDisables += 1; - while (iPtr->revPtr != NULL) { - HistoryRev *nextPtr; - - ckfree(iPtr->revPtr->newBytes); - nextPtr = iPtr->revPtr->nextPtr; - ckfree((char *) iPtr->revPtr); - iPtr->revPtr = nextPtr; - } - } else { - eventPtr = GetEvent(iPtr, argv[3]); - if (eventPtr == NULL) { - return TCL_ERROR; - } - } - MakeSpace(eventPtr, (int) strlen(argv[2]) + 1); - strcpy(eventPtr->command, argv[2]); - return TCL_OK; - } else if ((c == 'e') && (strncmp(argv[1], "event", length)) == 0) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " event ?event?\"", (char *) NULL); - return TCL_ERROR; - } - eventPtr = GetEvent(iPtr, argc==2 ? "-1" : argv[2]); - if (eventPtr == NULL) { - return TCL_ERROR; - } - RevResult(iPtr, eventPtr->command); - Tcl_SetResult(interp, eventPtr->command, TCL_VOLATILE); - return TCL_OK; - } else if ((c == 'i') && (strncmp(argv[1], "info", length)) == 0) { - int count, indx, i; - char *newline; - - if ((argc != 2) && (argc != 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " info ?count?\"", (char *) NULL); - return TCL_ERROR; - } - infoCmd: - if (argc == 3) { - if (Tcl_GetInt(interp, argv[2], &count) != TCL_OK) { - return TCL_ERROR; - } - if (count > iPtr->numEvents) { - count = iPtr->numEvents; - } - } else { - count = iPtr->numEvents; - } - newline = ""; - for (i = 0, indx = iPtr->curEvent + 1 + iPtr->numEvents - count; - i < count; i++, indx++) { - char *cur, *next, savedChar; - char serial[20]; - - if (indx >= iPtr->numEvents) { - indx -= iPtr->numEvents; - } - cur = iPtr->events[indx].command; - if (*cur == '\0') { - continue; /* No command recorded here. */ - } - sprintf(serial, "%6d ", iPtr->curEventNum + 1 - (count - i)); - Tcl_AppendResult(interp, newline, serial, (char *) NULL); - newline = "\n"; - - /* - * Tricky formatting here: for multi-line commands, indent - * the continuation lines. - */ - - while (1) { - next = strchr(cur, '\n'); - if (next == NULL) { - break; - } - next++; - savedChar = *next; - *next = 0; - Tcl_AppendResult(interp, cur, "\t", (char *) NULL); - *next = savedChar; - cur = next; - } - Tcl_AppendResult(interp, cur, (char *) NULL); - } - return TCL_OK; - } else if ((c == 'k') && (strncmp(argv[1], "keep", length)) == 0) { - int count, i, src; - HistoryEvent *events; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " keep number\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[2], &count) != TCL_OK) { - return TCL_ERROR; - } - if ((count <= 0) || (count > 1000)) { - Tcl_AppendResult(interp, "illegal keep count \"", argv[2], - "\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Create a new history array and copy as much existing history - * as possible from the old array. - */ - - events = (HistoryEvent *) - ckalloc((unsigned) (count * sizeof(HistoryEvent))); - if (count < iPtr->numEvents) { - src = iPtr->curEvent + 1 - count; - if (src < 0) { - src += iPtr->numEvents; - } - } else { - src = iPtr->curEvent + 1; - } - for (i = 0; i < count; i++, src++) { - if (src >= iPtr->numEvents) { - src = 0; - } - if (i < iPtr->numEvents) { - events[i] = iPtr->events[src]; - iPtr->events[src].command = NULL; - } else { - events[i].command = (char *) ckalloc(INITIAL_CMD_SIZE); - events[i].command[0] = 0; - events[i].bytesAvl = INITIAL_CMD_SIZE; - } - } - - /* - * Throw away everything left in the old history array, and - * substitute the new one for the old one. - */ - - for (i = 0; i < iPtr->numEvents; i++) { - if (iPtr->events[i].command != NULL) { - ckfree(iPtr->events[i].command); - } - } - ckfree((char *) iPtr->events); - iPtr->events = events; - if (count < iPtr->numEvents) { - iPtr->curEvent = count-1; - } else { - iPtr->curEvent = iPtr->numEvents-1; - } - iPtr->numEvents = count; - return TCL_OK; - } else if ((c == 'n') && (strncmp(argv[1], "nextid", length)) == 0) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " nextid\"", (char *) NULL); - return TCL_ERROR; - } - sprintf(iPtr->result, "%d", iPtr->curEventNum+1); - return TCL_OK; - } else if ((c == 'r') && (strncmp(argv[1], "redo", length)) == 0) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " redo ?event?\"", (char *) NULL); - return TCL_ERROR; - } - eventPtr = GetEvent(iPtr, argc==2 ? "-1" : argv[2]); - if (eventPtr == NULL) { - return TCL_ERROR; - } - RevCommand(iPtr, eventPtr->command); - return Tcl_Eval(interp, eventPtr->command); - } else if ((c == 's') && (strncmp(argv[1], "substitute", length)) == 0) { - if ((argc > 5) || (argc < 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " substitute old new ?event?\"", (char *) NULL); - return TCL_ERROR; - } - eventPtr = GetEvent(iPtr, argc==4 ? "-1" : argv[4]); - if (eventPtr == NULL) { - return TCL_ERROR; - } - return SubsAndEval(iPtr, eventPtr->command, argv[2], argv[3]); - } else if ((c == 'w') && (strncmp(argv[1], "words", length)) == 0) { - char *words; - - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " words num-num/pat ?event?\"", (char *) NULL); - return TCL_ERROR; - } - eventPtr = GetEvent(iPtr, argc==3 ? "-1" : argv[3]); - if (eventPtr == NULL) { - return TCL_ERROR; - } - words = GetWords(iPtr, eventPtr->command, argv[2]); - if (words == NULL) { - return TCL_ERROR; - } - RevResult(iPtr, words); - iPtr->result = words; - iPtr->freeProc = TCL_DYNAMIC; - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be add, change, event, info, keep, nextid, ", - "redo, substitute, or words", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * MakeSpace -- - * - * Given a history event, make sure it has enough space for - * a string of a given length (enlarge the string area if - * necessary). - * - * Results: - * None. - * - * Side effects: - * More memory may get allocated. - * - *---------------------------------------------------------------------- - */ - -static void -MakeSpace( - HistoryEvent *hPtr, - int size /* # of bytes needed in hPtr. */ -) -{ - if (hPtr->bytesAvl < size) { - ckfree(hPtr->command); - hPtr->command = (char *) ckalloc((unsigned) size); - hPtr->bytesAvl = size; - } -} - -/* - *---------------------------------------------------------------------- - * - * InsertRev -- - * - * Add a new revision to the list of those pending for iPtr. - * Do it in a way that keeps the revision list sorted in - * increasing order of firstIndex. Also, eliminate revisions - * that are subsets of other revisions. - * - * Results: - * None. - * - * Side effects: - * RevPtr is added to iPtr's revision list. - * - *---------------------------------------------------------------------- - */ - -static void -InsertRev( - Interp *iPtr, /* Interpreter to use. */ - HistoryRev *revPtr /* Revision to add to iPtr's list. */ -) -{ - HistoryRev *curPtr; - HistoryRev *prevPtr; - - for (curPtr = iPtr->revPtr, prevPtr = NULL; curPtr != NULL; - prevPtr = curPtr, curPtr = curPtr->nextPtr) { - /* - * If this revision includes the new one (or vice versa) then - * just eliminate the one that is a subset of the other. - */ - - if ((revPtr->firstIndex <= curPtr->firstIndex) - && (revPtr->lastIndex >= curPtr->firstIndex)) { - curPtr->firstIndex = revPtr->firstIndex; - curPtr->lastIndex = revPtr->lastIndex; - curPtr->newSize = revPtr->newSize; - ckfree(curPtr->newBytes); - curPtr->newBytes = revPtr->newBytes; - ckfree((char *) revPtr); - return; - } - if ((revPtr->firstIndex >= curPtr->firstIndex) - && (revPtr->lastIndex <= curPtr->lastIndex)) { - ckfree(revPtr->newBytes); - ckfree((char *) revPtr); - return; - } - - if (revPtr->firstIndex < curPtr->firstIndex) { - break; - } - } - - /* - * Insert revPtr just after prevPtr. - */ - - if (prevPtr == NULL) { - revPtr->nextPtr = iPtr->revPtr; - iPtr->revPtr = revPtr; - } else { - revPtr->nextPtr = prevPtr->nextPtr; - prevPtr->nextPtr = revPtr; - } -} - -/* - *---------------------------------------------------------------------- - * - * RevCommand -- - * - * This procedure is invoked by the "history" command to record - * a command revision. See the comments at the beginning of the - * file for more information about revisions. - * - * Results: - * None. - * - * Side effects: - * Revision information is recorded. - * - *---------------------------------------------------------------------- - */ - -static void -RevCommand( - Interp *iPtr, /* Interpreter in which to perform the - * substitution. */ - char *string /* String to substitute. */ -) -{ - HistoryRev *revPtr; - - if ((iPtr->evalFirst == NULL) || (iPtr->revDisables > 0)) { - return; - } - revPtr = (HistoryRev *) ckalloc(sizeof(HistoryRev)); - revPtr->firstIndex = iPtr->evalFirst - iPtr->historyFirst; - revPtr->lastIndex = iPtr->evalLast - iPtr->historyFirst; - revPtr->newSize = strlen(string); - revPtr->newBytes = (char *) ckalloc((unsigned) (revPtr->newSize+1)); - strcpy(revPtr->newBytes, string); - InsertRev(iPtr, revPtr); -} - -/* - *---------------------------------------------------------------------- - * - * RevResult -- - * - * This procedure is invoked by the "history" command to record - * a result revision. See the comments at the beginning of the - * file for more information about revisions. - * - * Results: - * None. - * - * Side effects: - * Revision information is recorded. - * - *---------------------------------------------------------------------- - */ - -static void -RevResult( - Interp *iPtr, /* Interpreter in which to perform the - * substitution. */ - char *string /* String to substitute. */ -) -{ - HistoryRev *revPtr; - char *evalFirst, *evalLast; - char *argv[2]; - - if ((iPtr->evalFirst == NULL) || (iPtr->revDisables > 0)) { - return; - } - - /* - * Expand the replacement range to include the brackets that surround - * the command. If there aren't any brackets (i.e. this command was - * invoked at top-level) then don't do any revision. Also, if there - * are several commands in brackets, of which this is just one, - * then don't do any revision. - */ - - evalFirst = iPtr->evalFirst; - evalLast = iPtr->evalLast + 1; - while (1) { - if (evalFirst == iPtr->historyFirst) { - return; - } - evalFirst--; - if (*evalFirst == '[') { - break; - } - if (!isspace(UCHAR(*evalFirst))) { - return; - } - } - if (*evalLast != ']') { - return; - } - - revPtr = (HistoryRev *) ckalloc(sizeof(HistoryRev)); - revPtr->firstIndex = evalFirst - iPtr->historyFirst; - revPtr->lastIndex = evalLast - iPtr->historyFirst; - argv[0] = string; - revPtr->newBytes = Tcl_Merge(1, argv); - revPtr->newSize = strlen(revPtr->newBytes); - InsertRev(iPtr, revPtr); -} - -/* - *---------------------------------------------------------------------- - * - * DoRevs -- - * - * This procedure is called to apply the history revisions that - * have been recorded in iPtr. - * - * Results: - * None. - * - * Side effects: - * The most recent entry in the history for iPtr may be modified. - * - *---------------------------------------------------------------------- - */ - -static void -DoRevs( - Interp *iPtr /* Interpreter whose history is to - * be modified. */ -) -{ - HistoryRev *revPtr; - HistoryEvent *eventPtr; - char *newCommand, *p; - unsigned int size; - int bytesSeen, count; - - if (iPtr->revPtr == NULL) { - return; - } - - /* - * The revision is done in two passes. The first pass computes the - * amount of space needed for the revised event, and the second pass - * pieces together the new event and frees up the revisions. - */ - - eventPtr = &iPtr->events[iPtr->curEvent]; - size = strlen(eventPtr->command) + 1; - for (revPtr = iPtr->revPtr; revPtr != NULL; revPtr = revPtr->nextPtr) { - size -= revPtr->lastIndex + 1 - revPtr->firstIndex; - size += revPtr->newSize; - } - - newCommand = (char *) ckalloc(size); - p = newCommand; - bytesSeen = 0; - for (revPtr = iPtr->revPtr; revPtr != NULL; ) { - HistoryRev *nextPtr = revPtr->nextPtr; - - count = revPtr->firstIndex - bytesSeen; - if (count > 0) { - strncpy(p, eventPtr->command + bytesSeen, (size_t) count); - p += count; - } - strncpy(p, revPtr->newBytes, (size_t) revPtr->newSize); - p += revPtr->newSize; - bytesSeen = revPtr->lastIndex+1; - ckfree(revPtr->newBytes); - ckfree((char *) revPtr); - revPtr = nextPtr; - } - strcpy(p, eventPtr->command + bytesSeen); - - /* - * Replace the command in the event. - */ - - ckfree(eventPtr->command); - eventPtr->command = newCommand; - eventPtr->bytesAvl = size; - iPtr->revPtr = NULL; -} - -/* - *---------------------------------------------------------------------- - * - * GetEvent -- - * - * Given a textual description of an event (see the manual page - * for legal values) find the corresponding event and return its - * command string. - * - * Results: - * The return value is a pointer to the event named by "string". - * If no such event exists, then NULL is returned and an error - * message is left in iPtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static HistoryEvent * -GetEvent( - Interp *iPtr, /* Interpreter in which to look. */ - char *string /* Description of event. */ -) -{ - int eventNum, index; - HistoryEvent *eventPtr; - int length; - - /* - * First check for a numeric specification of an event. - */ - - if (isdigit(UCHAR(*string)) || (*string == '-')) { - if (Tcl_GetInt((Tcl_Interp *) iPtr, string, &eventNum) != TCL_OK) { - return NULL; - } - if (eventNum < 0) { - eventNum += iPtr->curEventNum; - } - if (eventNum > iPtr->curEventNum) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "event \"", string, - "\" hasn't occurred yet", (char *) NULL); - return NULL; - } - if ((eventNum <= iPtr->curEventNum-iPtr->numEvents) - || (eventNum <= 0)) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "event \"", string, - "\" is too far in the past", (char *) NULL); - return NULL; - } - index = iPtr->curEvent + (eventNum - iPtr->curEventNum); - if (index < 0) { - index += iPtr->numEvents; - } - return &iPtr->events[index]; - } - - /* - * Next, check for an event that contains the string as a prefix or - * that matches the string in the sense of Tcl_StringMatch. - */ - - length = strlen(string); - for (index = iPtr->curEvent - 1; ; index--) { - if (index < 0) { - index += iPtr->numEvents; - } - if (index == iPtr->curEvent) { - break; - } - eventPtr = &iPtr->events[index]; - if ((strncmp(eventPtr->command, string, (size_t) length) == 0) - || Tcl_StringMatch(eventPtr->command, string)) { - return eventPtr; - } - } - - Tcl_AppendResult((Tcl_Interp *) iPtr, "no event matches \"", string, - "\"", (char *) NULL); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * SubsAndEval -- - * - * Generate a new command by making a textual substitution in - * the "cmd" argument. Then execute the new command. - * - * Results: - * The return value is a standard Tcl error. - * - * Side effects: - * History gets revised if the substitution is occurring on - * a recorded command line. Also, the re-executed command - * may produce side-effects. - * - *---------------------------------------------------------------------- - */ - -static int -SubsAndEval( - Interp *iPtr, /* Interpreter in which to execute - * new command. */ - char *cmd, /* Command in which to substitute. */ - char *old, /* String to search for in command. */ - char *new /* Replacement string for "old". */ -) -{ - char *src, *dst, *newCmd; - int count, oldLength, newLength, length, result; - - /* - * Figure out how much space it will take to hold the - * substituted command (and complain if the old string - * doesn't appear in the original command). - */ - - oldLength = strlen(old); - newLength = strlen(new); - src = cmd; - count = 0; - while (1) { - src = strstr(src, old); - if (src == NULL) { - break; - } - src += oldLength; - count++; - } - if (count == 0) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "\"", old, - "\" doesn't appear in event", (char *) NULL); - return TCL_ERROR; - } - length = strlen(cmd) + count*(newLength - oldLength); - - /* - * Generate a substituted command. - */ - - newCmd = (char *) ckalloc((unsigned) (length + 1)); - dst = newCmd; - while (1) { - src = strstr(cmd, old); - if (src == NULL) { - strcpy(dst, cmd); - break; - } - strncpy(dst, cmd, (size_t) (src-cmd)); - dst += src-cmd; - strcpy(dst, new); - dst += newLength; - cmd = src + oldLength; - } - - RevCommand(iPtr, newCmd); - result = Tcl_Eval((Tcl_Interp *) iPtr, newCmd); - ckfree(newCmd); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * GetWords -- - * - * Given a command string, return one or more words from the - * command string. - * - * Results: - * The return value is a pointer to a dynamically-allocated - * string containing the words of command specified by "words". - * If the word specifier has improper syntax then an error - * message is placed in iPtr->result and NULL is returned. - * - * Side effects: - * Memory is allocated. It is the caller's responsibilty to - * free the returned string.. - * - *---------------------------------------------------------------------- - */ - -static char * -GetWords( - Interp *iPtr, /* Tcl interpreter in which to place - * an error message if needed. */ - char *command, /* Command string. */ - char *words /* Description of which words to extract - * from the command. Either num[-num] or - * a pattern. */ -) -{ - char *result; - char *start, *end, *dst; - char *next; - int first; /* First word desired. -1 means last word - * only. */ - int last; /* Last word desired. -1 means use everything - * up to the end. */ - int index; /* Index of current word. */ - char *pattern; - - /* - * Figure out whether we're looking for a numerical range or for - * a pattern. - */ - - pattern = NULL; - first = 0; - last = -1; - if (*words == '$') { - if (words[1] != '\0') { - goto error; - } - first = -1; - } else if (isdigit(UCHAR(*words))) { - first = strtoul(words, &start, 0); - if (*start == 0) { - last = first; - } else if (*start == '-') { - start++; - if (*start == '$') { - start++; - } else if (isdigit(UCHAR(*start))) { - last = strtoul(start, &start, 0); - } else { - goto error; - } - if (*start != 0) { - goto error; - } - } - if ((first > last) && (last != -1)) { - goto error; - } - } else { - pattern = words; - } - - /* - * Scan through the words one at a time, copying those that are - * relevant into the result string. Allocate a result area large - * enough to hold all the words if necessary. - */ - - result = (char *) ckalloc((unsigned) (strlen(command) + 1)); - dst = result; - for (next = command; isspace(UCHAR(*next)); next++) { - /* Empty loop body: just find start of first word. */ - } - for (index = 0; *next != 0; index++) { - start = next; - end = TclWordEnd(next, 0, (int *) NULL); - if (*end != 0) { - end++; - for (next = end; isspace(UCHAR(*next)); next++) { - /* Empty loop body: just find start of next word. */ - } - } - if ((first > index) || ((first == -1) && (*next != 0))) { - continue; - } - if ((last != -1) && (last < index)) { - continue; - } - if (pattern != NULL) { - int match; - char savedChar = *end; - - *end = 0; - match = Tcl_StringMatch(start, pattern); - *end = savedChar; - if (!match) { - continue; - } - } - if (dst != result) { - *dst = ' '; - dst++; - } - strncpy(dst, start, (size_t) (end-start)); - dst += end-start; - } - *dst = 0; - - /* - * Check for an out-of-range argument index. - */ - - if ((last >= index) || (first >= index)) { - ckfree(result); - Tcl_AppendResult((Tcl_Interp *) iPtr, "word selector \"", words, - "\" specified non-existent words", (char *) NULL); - return NULL; - } - return result; - - error: - Tcl_AppendResult((Tcl_Interp *) iPtr, "bad word selector \"", words, - "\": should be num-num or pattern", (char *) NULL); - return NULL; -} diff --git a/cde/programs/dtdocbook/tcl/tclIO.c b/cde/programs/dtdocbook/tcl/tclIO.c deleted file mode 100644 index 7bd237770..000000000 --- a/cde/programs/dtdocbook/tcl/tclIO.c +++ /dev/null @@ -1,5130 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclIO.c /main/2 1996/08/08 14:44:24 cde-hp $ */ -/* - * tclIO.c -- - * - * This file provides the generic portions (those that are the same on - * all platforms and for all channel types) of Tcl's IO facilities. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclIO.c 1.211 96/04/18 09:59:06 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * Make sure that both EAGAIN and EWOULDBLOCK are defined. This does not - * compile on systems where neither is defined. We want both defined so - * that we can test safely for both. In the code we still have to test for - * both because there may be systems on which both are defined and have - * different values. - */ - -#if ((!defined(EWOULDBLOCK)) && (defined(EAGAIN))) -# define EWOULDBLOCK EAGAIN -#endif -#if ((!defined(EAGAIN)) && (defined(EWOULDBLOCK))) -# define EAGAIN EWOULDBLOCK -#endif -#if ((!defined(EAGAIN)) && (!defined(EWOULDBLOCK))) - error one of EWOULDBLOCK or EAGAIN must be defined -#endif - -/* - * struct ChannelBuffer: - * - * Buffers data being sent to or from a channel. - */ - -typedef struct ChannelBuffer { - int nextAdded; /* The next position into which a character - * will be put in the buffer. */ - int nextRemoved; /* Position of next byte to be removed - * from the buffer. */ - int bufSize; /* How big is the buffer? */ - struct ChannelBuffer *nextPtr; - /* Next buffer in chain. */ - char buf[4]; /* Placeholder for real buffer. The real - * buffer occuppies this space + bufSize-4 - * bytes. This must be the last field in - * the structure. */ -} ChannelBuffer; - -#define CHANNELBUFFER_HEADER_SIZE (sizeof(ChannelBuffer) - 4) - -/* - * The following defines the *default* buffer size for channels. - */ - -#define CHANNELBUFFER_DEFAULT_SIZE (1024 * 4) - -/* - * Structure to record a close callback. One such record exists for - * each close callback registered for a channel. - */ - -typedef struct CloseCallback { - Tcl_CloseProc *proc; /* The procedure to call. */ - ClientData clientData; /* Arbitrary one-word data to pass - * to the callback. */ - struct CloseCallback *nextPtr; /* For chaining close callbacks. */ -} CloseCallback; - -/* - * Forward declaration of Channel; being used in struct EventScriptRecord, - * below. - */ - -typedef struct Channel *ChanPtr; - -/* - * The following structure describes the information saved from a call to - * "fileevent". This is used later when the event being waited for to - * invoke the saved script in the interpreter designed in this record. - */ - -typedef struct EventScriptRecord { - struct Channel *chanPtr; /* The channel for which this script is - * registered. This is used only when an - * error occurs during evaluation of the - * script, to delete the handler. */ - char *script; /* Script to invoke. */ - Tcl_Interp *interp; /* In what interpreter to invoke script? */ - int mask; /* Events must overlap current mask for the - * stored script to be invoked. */ - struct EventScriptRecord *nextPtr; - /* Next in chain of records. */ -} EventScriptRecord; - -/* - * Forward declaration of ChannelHandler; being used in struct Channel, - * below. - */ - -typedef struct ChannelHandler *ChannelHandlerPtr; - -/* - * struct Channel: - * - * One of these structures is allocated for each open channel. It contains data - * specific to the channel but which belongs to the generic part of the Tcl - * channel mechanism, and it points at an instance specific (and type - * specific) * instance data, and at a channel type structure. - */ - -typedef struct Channel { - char *channelName; /* The name of the channel instance in Tcl - * commands. Storage is owned by the generic IO - * code, is dynamically allocated. */ - int flags; /* ORed combination of the flags defined - * below. */ - Tcl_EolTranslation inputTranslation; - /* What translation to apply for end of line - * sequences on input? */ - Tcl_EolTranslation outputTranslation; - /* What translation to use for generating - * end of line sequences in output? */ - int inEofChar; /* If nonzero, use this as a signal of EOF - * on input. */ - int outEofChar; /* If nonzero, append this to the channel - * when it is closed if it is open for - * writing. */ - int unreportedError; /* Non-zero if an error report was deferred - * because it happened in the background. The - * value is the POSIX error code. */ - ClientData instanceData; /* Instance specific data. */ - Tcl_File inFile; /* File to use for input, or NULL. */ - Tcl_File outFile; /* File to use for output, or NULL. */ - Tcl_ChannelType *typePtr; /* Pointer to channel type structure. */ - int refCount; /* How many interpreters hold references to - * this IO channel? */ - CloseCallback *closeCbPtr; /* Callbacks registered to be called when the - * channel is closed. */ - ChannelBuffer *curOutPtr; /* Current output buffer being filled. */ - ChannelBuffer *outQueueHead;/* Points at first buffer in output queue. */ - ChannelBuffer *outQueueTail;/* Points at last buffer in output queue. */ - - ChannelBuffer *saveInBufPtr;/* Buffer saved for input queue - eliminates - * need to allocate a new buffer for "gets" - * that crosses buffer boundaries. */ - ChannelBuffer *inQueueHead; /* Points at first buffer in input queue. */ - ChannelBuffer *inQueueTail; /* Points at last buffer in input queue. */ - - struct ChannelHandler *chPtr;/* List of channel handlers registered - * for this channel. */ - int interestMask; /* Mask of all events this channel has - * handlers for. */ - struct Channel *nextChanPtr;/* Next in list of channels currently open. */ - EventScriptRecord *scriptRecordPtr; - /* Chain of all scripts registered for - * event handlers ("fileevent") on this - * channel. */ - int bufSize; /* What size buffers to allocate? */ -} Channel; - -/* - * Values for the flags field in Channel. Any ORed combination of the - * following flags can be stored in the field. These flags record various - * options and state bits about the channel. In addition to the flags below, - * the channel can also have TCL_READABLE (1<<1) and TCL_WRITABLE (1<<2) set. - */ - -#define CHANNEL_NONBLOCKING (1<<3) /* Channel is currently in - * nonblocking mode. */ -#define CHANNEL_LINEBUFFERED (1<<4) /* Output to the channel must be - * flushed after every newline. */ -#define CHANNEL_UNBUFFERED (1<<5) /* Output to the channel must always - * be flushed immediately. */ -#define BUFFER_READY (1<<6) /* Current output buffer (the - * curOutPtr field in the - * channel structure) should be - * output as soon as possible event - * though it may not be full. */ -#define BG_FLUSH_SCHEDULED (1<<7) /* A background flush of the - * queued output buffers has been - * scheduled. */ -#define CHANNEL_CLOSED (1<<8) /* Channel has been closed. No - * further Tcl-level IO on the - * channel is allowed. */ -#define CHANNEL_EOF (1<<9) /* EOF occurred on this channel. - * This bit is cleared before every - * input operation. */ -#define CHANNEL_STICKY_EOF (1<<10) /* EOF occurred on this channel because - * we saw the input eofChar. This bit - * prevents clearing of the EOF bit - * before every input operation. */ -#define CHANNEL_BLOCKED (1<<11) /* EWOULDBLOCK or EAGAIN occurred - * on this channel. This bit is - * cleared before every input or - * output operation. */ -#define INPUT_SAW_CR (1<<12) /* Channel is in CRLF eol input - * translation mode and the last - * byte seen was a "\r". */ - -/* - * For each channel handler registered in a call to Tcl_CreateChannelHandler, - * there is one record of the following type. All of records for a specific - * channel are chained together in a singly linked list which is stored in - * the channel structure. - */ - -typedef struct ChannelHandler { - Channel *chanPtr; /* The channel structure for this channel. */ - int mask; /* Mask of desired events. */ - Tcl_ChannelProc *proc; /* Procedure to call in the type of - * Tcl_CreateChannelHandler. */ - ClientData clientData; /* Argument to pass to procedure. */ - struct ChannelHandler *nextPtr; - /* Next one in list of registered handlers. */ -} ChannelHandler; - -/* - * This structure keeps track of the current ChannelHandler being invoked in - * the current invocation of ChannelHandlerEventProc. There is a potential - * problem if a ChannelHandler is deleted while it is the current one, since - * ChannelHandlerEventProc needs to look at the nextPtr field. To handle this - * problem, structures of the type below indicate the next handler to be - * processed for any (recursively nested) dispatches in progress. The - * nextHandlerPtr field is updated if the handler being pointed to is deleted. - * The nextPtr field is used to chain together all recursive invocations, so - * that Tcl_DeleteChannelHandler can find all the recursively nested - * invocations of ChannelHandlerEventProc and compare the handler being - * deleted against the NEXT handler to be invoked in that invocation; when it - * finds such a situation, Tcl_DeleteChannelHandler updates the nextHandlerPtr - * field of the structure to the next handler. - */ - -typedef struct NextChannelHandler { - ChannelHandler *nextHandlerPtr; /* The next handler to be invoked in - * this invocation. */ - struct NextChannelHandler *nestedHandlerPtr; - /* Next nested invocation of - * ChannelHandlerEventProc. */ -} NextChannelHandler; - -/* - * This variable holds the list of nested ChannelHandlerEventProc invocations. - */ - -static NextChannelHandler *nestedHandlerPtr = (NextChannelHandler *) NULL; - -/* - * List of all channels currently open. - */ - -static Channel *firstChanPtr = (Channel *) NULL; - -/* - * Has a channel exit handler been created yet? - */ - -static int channelExitHandlerCreated = 0; - -/* - * Has the channel event source been created and registered with the - * notifier? - */ - -static int channelEventSourceCreated = 0; - -/* - * The following structure describes the event that is added to the Tcl - * event queue by the channel handler check procedure. - */ - -typedef struct ChannelHandlerEvent { - Tcl_Event header; /* Standard header for all events. */ - Channel *chanPtr; /* The channel that is ready. */ - int readyMask; /* Events that have occurred. */ -} ChannelHandlerEvent; - -/* - * Static buffer used to sprintf channel option values and return - * them to the caller. - */ - -static char optionVal[128]; - -/* - * Static variables to hold channels for stdin, stdout and stderr. - */ - -static Tcl_Channel stdinChannel = NULL; -static int stdinInitialized = 0; -static Tcl_Channel stdoutChannel = NULL; -static int stdoutInitialized = 0; -static Tcl_Channel stderrChannel = NULL; -static int stderrInitialized = 0; - -/* - * Static functions in this file: - */ - -static int ChannelEventDeleteProc _ANSI_ARGS_(( - Tcl_Event *evPtr, ClientData clientData)); -static void ChannelEventSourceExitProc _ANSI_ARGS_(( - ClientData data)); -static int ChannelHandlerEventProc _ANSI_ARGS_(( - Tcl_Event *evPtr, int flags)); -static void ChannelHandlerCheckProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static void ChannelHandlerSetupProc _ANSI_ARGS_(( - ClientData clientData, int flags)); -static void ChannelEventScriptInvoker _ANSI_ARGS_(( - ClientData clientData, int flags)); -static int CloseChannel _ANSI_ARGS_((Tcl_Interp *interp, - Channel *chanPtr, int errorCode)); -static void CloseChannelsOnExit _ANSI_ARGS_((ClientData data)); -static int CopyAndTranslateBuffer _ANSI_ARGS_(( - Channel *chanPtr, char *result, int space)); -static void CreateScriptRecord _ANSI_ARGS_(( - Tcl_Interp *interp, Channel *chanPtr, - int mask, char *script)); -static void DeleteChannelTable _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp)); -static void DeleteScriptRecord _ANSI_ARGS_((Tcl_Interp *interp, - Channel *chanPtr, int mask)); -static void DiscardInputQueued _ANSI_ARGS_(( - Channel *chanPtr, int discardSavedBuffers)); -static void DiscardOutputQueued _ANSI_ARGS_(( - Channel *chanPtr)); -static int FlushChannel _ANSI_ARGS_((Tcl_Interp *interp, - Channel *chanPtr, int calledFromAsyncFlush)); -static void FlushEventProc _ANSI_ARGS_((ClientData clientData, - int mask)); -static Tcl_HashTable *GetChannelTable _ANSI_ARGS_((Tcl_Interp *interp)); -static int GetEOL _ANSI_ARGS_((Channel *chanPtr)); -static int GetInput _ANSI_ARGS_((Channel *chanPtr)); -static void RecycleBuffer _ANSI_ARGS_((Channel *chanPtr, - ChannelBuffer *bufPtr, int mustDiscard)); -static void ReturnScriptRecord _ANSI_ARGS_((Tcl_Interp *interp, - Channel *chanPtr, int mask)); -static int ScanBufferForEOL _ANSI_ARGS_((Channel *chanPtr, - ChannelBuffer *bufPtr, - Tcl_EolTranslation translation, int eofChar, - int *bytesToEOLPtr, int *crSeenPtr)); -static int ScanInputForEOL _ANSI_ARGS_((Channel *chanPtr, - int *bytesQueuedPtr)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetStdChannel -- - * - * This function is used to change the channels that are used - * for stdin/stdout/stderr in new interpreters. - * - * Results: - * None - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetStdChannel( - Tcl_Channel channel, - int type /* One of TCL_STDIN, TCL_STDOUT, TCL_STDERR. */ -) -{ - switch (type) { - case TCL_STDIN: - stdinInitialized = 1; - stdinChannel = channel; - break; - case TCL_STDOUT: - stdoutInitialized = 1; - stdoutChannel = channel; - break; - case TCL_STDERR: - stderrInitialized = 1; - stderrChannel = channel; - break; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetStdChannel -- - * - * Returns the specified standard channel. - * - * Results: - * Returns the specified standard channel, or NULL. - * - * Side effects: - * May cause the creation of a standard channel and the underlying - * file. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_GetStdChannel( - int type /* One of TCL_STDIN, TCL_STDOUT, TCL_STDERR. */ -) -{ - Tcl_Channel channel = NULL; - - /* - * If the channels were not created yet, create them now and - * store them in the static variables. Note that we need to set - * stdinInitialized before calling TclGetDefaultStdChannel in order - * to avoid recursive loops when TclGetDefaultStdChannel calls - * Tcl_CreateChannel. - */ - - switch (type) { - case TCL_STDIN: - if (!stdinInitialized) { - stdinInitialized = 1; - stdinChannel = TclGetDefaultStdChannel(TCL_STDIN); - } - channel = stdinChannel; - break; - case TCL_STDOUT: - if (!stdoutInitialized) { - stdoutInitialized = 1; - stdoutChannel = TclGetDefaultStdChannel(TCL_STDOUT); - } - channel = stdoutChannel; - break; - case TCL_STDERR: - if (!stderrInitialized) { - stderrInitialized = 1; - stderrChannel = TclGetDefaultStdChannel(TCL_STDERR); - } - channel = stderrChannel; - break; - } - return channel; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateCloseHandler - * - * Creates a close callback which will be called when the channel is - * closed. - * - * Results: - * None. - * - * Side effects: - * Causes the callback to be called in the future when the channel - * will be closed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CreateCloseHandler( - Tcl_Channel chan, /* The channel for which to create the - * close callback. */ - Tcl_CloseProc *proc, /* The callback routine to call when the - * channel will be closed. */ - ClientData clientData /* Arbitrary data to pass to the - * close callback. */ -) -{ - Channel *chanPtr; - CloseCallback *cbPtr; - - chanPtr = (Channel *) chan; - - cbPtr = (CloseCallback *) ckalloc((unsigned) sizeof(CloseCallback)); - cbPtr->proc = proc; - cbPtr->clientData = clientData; - - cbPtr->nextPtr = chanPtr->closeCbPtr; - chanPtr->closeCbPtr = cbPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteCloseHandler -- - * - * Removes a callback that would have been called on closing - * the channel. If there is no matching callback then this - * function has no effect. - * - * Results: - * None. - * - * Side effects: - * The callback will not be called in the future when the channel - * is eventually closed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteCloseHandler( - Tcl_Channel chan, /* The channel for which to cancel the - * close callback. */ - Tcl_CloseProc *proc, /* The procedure for the callback to - * remove. */ - ClientData clientData /* The callback data for the callback - * to remove. */ -) -{ - Channel *chanPtr; - CloseCallback *cbPtr, *cbPrevPtr; - - chanPtr = (Channel *) chan; - for (cbPtr = chanPtr->closeCbPtr, cbPrevPtr = (CloseCallback *) NULL; - cbPtr != (CloseCallback *) NULL; - cbPtr = cbPtr->nextPtr) { - if ((cbPtr->proc == proc) && (cbPtr->clientData == clientData)) { - if (cbPrevPtr == (CloseCallback *) NULL) { - chanPtr->closeCbPtr = cbPtr->nextPtr; - } else { - cbPrevPtr = cbPtr->nextPtr; - } - ckfree((char *) cbPtr); - break; - } else { - cbPrevPtr = cbPtr; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * CloseChannelsOnExit -- - * - * Closes all the existing channels, on exit. This routine is called - * during exit processing. - * - * Results: - * None. - * - * Side effects: - * Closes all channels. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -CloseChannelsOnExit( - ClientData clientData /* NULL - unused. */ -) -{ - Channel *chanPtr; /* Iterates over open channels. */ - Channel *nextChanPtr; /* Iterates over open channels. */ - - - for (chanPtr = firstChanPtr; chanPtr != (Channel *) NULL; - chanPtr = nextChanPtr) { - nextChanPtr = chanPtr->nextChanPtr; - - /* - * Close it only if the refcount indicates that the channel is not - * referenced from any interpreter. If it is, that interpreter will - * close the channel when it gets destroyed. - */ - - if (chanPtr->refCount <= 0) { - - /* - * Switch the channel back into synchronous mode to ensure that it - * gets flushed now. - */ - - (void) Tcl_SetChannelOption(NULL, (Tcl_Channel) chanPtr, - "-blocking", "on"); - - Tcl_Close((Tcl_Interp *) NULL, (Tcl_Channel) chanPtr); - } - } -} - -/* - *---------------------------------------------------------------------- - * - * GetChannelTable -- - * - * Gets and potentially initializes the channel table for an - * interpreter. If it is initializing the table it also inserts - * channels for stdin, stdout and stderr if the interpreter is - * trusted. - * - * Results: - * A pointer to the hash table created, for use by the caller. - * - * Side effects: - * Initializes the channel table for an interpreter. May create - * channels for stdin, stdout and stderr. - * - *---------------------------------------------------------------------- - */ - -static Tcl_HashTable * -GetChannelTable( - Tcl_Interp *interp -) -{ - Tcl_HashTable *hTblPtr; /* Hash table of channels. */ - Tcl_Channel stdinChannel, stdoutChannel, stderrChannel; - - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, "tclIO", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - hTblPtr = (Tcl_HashTable *) ckalloc((unsigned) sizeof(Tcl_HashTable)); - Tcl_InitHashTable(hTblPtr, TCL_STRING_KEYS); - - (void) Tcl_SetAssocData(interp, "tclIO", - (Tcl_InterpDeleteProc *) DeleteChannelTable, - (ClientData) hTblPtr); - - /* - * If the interpreter is trusted (not "safe"), insert channels - * for stdin, stdout and stderr (possibly creating them in the - * process). - */ - - if (Tcl_IsSafe(interp) == 0) { - stdinChannel = Tcl_GetStdChannel(TCL_STDIN); - if (stdinChannel != NULL) { - Tcl_RegisterChannel(interp, stdinChannel); - } - stdoutChannel = Tcl_GetStdChannel(TCL_STDOUT); - if (stdoutChannel != NULL) { - Tcl_RegisterChannel(interp, stdoutChannel); - } - stderrChannel = Tcl_GetStdChannel(TCL_STDERR); - if (stderrChannel != NULL) { - Tcl_RegisterChannel(interp, stderrChannel); - } - } - - } - return hTblPtr; -} - -/* - *---------------------------------------------------------------------- - * - * DeleteChannelTable -- - * - * Deletes the channel table for an interpreter, closing any open - * channels whose refcount reaches zero. This procedure is invoked - * when an interpreter is deleted, via the AssocData cleanup - * mechanism. - * - * Results: - * None. - * - * Side effects: - * Deletes the hash table of channels. May close channels. May flush - * output on closed channels. Removes any channeEvent handlers that were - * registered in this interpreter. - * - *---------------------------------------------------------------------- - */ - -static void -DeleteChannelTable( - ClientData clientData, /* The per-interpreter data structure. */ - Tcl_Interp *interp /* The interpreter being deleted. */ -) -{ - Tcl_HashTable *hTblPtr; /* The hash table. */ - Tcl_HashSearch hSearch; /* Search variable. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - Channel *chanPtr; /* Channel being deleted. */ - EventScriptRecord *sPtr, *prevPtr, *nextPtr; - /* Variables to loop over all channel events - * registered, to delete the ones that refer - * to the interpreter being deleted. */ - - /* - * Delete all the registered channels - this will close channels whose - * refcount reaches zero. - */ - - hTblPtr = (Tcl_HashTable *) clientData; - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) { - - chanPtr = (Channel *) Tcl_GetHashValue(hPtr); - - /* - * Remove any fileevents registered in this interpreter. - */ - - for (sPtr = chanPtr->scriptRecordPtr, - prevPtr = (EventScriptRecord *) NULL; - sPtr != (EventScriptRecord *) NULL; - sPtr = nextPtr) { - nextPtr = sPtr->nextPtr; - if (sPtr->interp == interp) { - if (prevPtr == (EventScriptRecord *) NULL) { - chanPtr->scriptRecordPtr = nextPtr; - } else { - prevPtr->nextPtr = nextPtr; - } - - Tcl_DeleteChannelHandler((Tcl_Channel) chanPtr, - ChannelEventScriptInvoker, (ClientData) sPtr); - - Tcl_EventuallyFree((ClientData) sPtr->script, TCL_DYNAMIC); - ckfree((char *) sPtr); - } else { - prevPtr = sPtr; - } - } - - /* - * Cannot call Tcl_UnregisterChannel because that procedure calls - * Tcl_GetAssocData to get the channel table, which might already - * be inaccessible from the interpreter structure. Instead, we - * emulate the behavior of Tcl_UnregisterChannel directly here. - */ - - Tcl_DeleteHashEntry(hPtr); - chanPtr->refCount--; - if (chanPtr->refCount <= 0) { - chanPtr->flags |= CHANNEL_CLOSED; - if (!(chanPtr->flags & BG_FLUSH_SCHEDULED)) { - Tcl_Close(interp, (Tcl_Channel) chanPtr); - } - } - } - Tcl_DeleteHashTable(hTblPtr); - ckfree((char *) hTblPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UnregisterChannel -- - * - * Deletes the hash entry for a channel associated with an interpreter. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Deletes the hash entry for a channel associated with an interpreter. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_UnregisterChannel( - Tcl_Interp *interp, /* Interpreter in which channel is defined. */ - Tcl_Channel chan /* Channel to delete. */ -) -{ - Tcl_HashTable *hTblPtr; /* Hash table of channels. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - Channel *chanPtr; /* The real IO channel. */ - - chanPtr = (Channel *) chan; - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, "tclIO", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - return TCL_OK; - } - hPtr = Tcl_FindHashEntry(hTblPtr, chanPtr->channelName); - if (hPtr == (Tcl_HashEntry *) NULL) { - return TCL_OK; - } - if ((Channel *) Tcl_GetHashValue(hPtr) != chanPtr) { - return TCL_OK; - } - Tcl_DeleteHashEntry(hPtr); - chanPtr->refCount--; - if (chanPtr->refCount <= 0) { - chanPtr->flags |= CHANNEL_CLOSED; - if (!(chanPtr->flags & BG_FLUSH_SCHEDULED)) { - if (Tcl_Close(interp, chan) != TCL_OK) { - return TCL_ERROR; - } - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegisterChannel -- - * - * Adds an already-open channel to the channel table of an interpreter. - * - * Results: - * None. - * - * Side effects: - * May increment the reference count of a channel. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_RegisterChannel( - Tcl_Interp *interp, /* Interpreter in which to add the channel. */ - Tcl_Channel chan /* The channel to add to this interpreter - * channel table. */ -) -{ - Tcl_HashTable *hTblPtr; /* Hash table of channels. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - int new; /* Is the hash entry new or does it exist? */ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - - if (chanPtr->channelName == (char *) NULL) { - panic("Tcl_RegisterChannel: channel without name"); - } - hTblPtr = GetChannelTable(interp); - hPtr = Tcl_CreateHashEntry(hTblPtr, chanPtr->channelName, &new); - if (new == 0) { - if (chan == (Tcl_Channel) Tcl_GetHashValue(hPtr)) { - return; - } - panic("Tcl_RegisterChannel: duplicate channel names"); - } - Tcl_SetHashValue(hPtr, (ClientData) chanPtr); - chanPtr->refCount++; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannel -- - * - * Finds an existing Tcl_Channel structure by name in a given - * interpreter. This function is public because it is used by - * channel-type-specific functions. - * - * Results: - * A Tcl_Channel or NULL on failure. If failed, interp->result - * contains an error message. It also returns, in modePtr, the - * modes in which the channel is opened. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_GetChannel( - Tcl_Interp *interp, /* Interpreter in which to find or create - * the channel. */ - char *chanName, /* The name of the channel. */ - int *modePtr /* Where to store the mode in which the - * channel was opened? Will contain an ORed - * combination of TCL_READABLE and - * TCL_WRITABLE, if non-NULL. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - Tcl_HashTable *hTblPtr; /* Hash table of channels. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - char *name; /* Translated name. */ - - /* - * Substitute "stdin", etc. Note that even though we immediately - * find the channel using Tcl_GetStdChannel, we still need to look - * it up in the specified interpreter to ensure that it is present - * in the channel table. Otherwise, safe interpreters would always - * have access to the standard channels. - */ - - name = chanName; - if ((chanName[0] == 's') && (chanName[1] == 't')) { - chanPtr = NULL; - if (strcmp(chanName, "stdin") == 0) { - chanPtr = (Channel *)Tcl_GetStdChannel(TCL_STDIN); - } else if (strcmp(chanName, "stdout") == 0) { - chanPtr = (Channel *)Tcl_GetStdChannel(TCL_STDOUT); - } else if (strcmp(chanName, "stderr") == 0) { - chanPtr = (Channel *)Tcl_GetStdChannel(TCL_STDERR); - } - if (chanPtr != NULL) { - name = chanPtr->channelName; - } - } - - hTblPtr = GetChannelTable(interp); - hPtr = Tcl_FindHashEntry(hTblPtr, name); - if (hPtr == (Tcl_HashEntry *) NULL) { - Tcl_AppendResult(interp, "can not find channel named \"", - chanName, "\"", (char *) NULL); - return NULL; - } - - chanPtr = (Channel *) Tcl_GetHashValue(hPtr); - if (modePtr != NULL) { - *modePtr = (chanPtr->flags & (TCL_READABLE|TCL_WRITABLE)); - } - - return (Tcl_Channel) chanPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateChannel -- - * - * Creates a new entry in the hash table for a Tcl_Channel - * record. - * - * Results: - * Returns the new Tcl_Channel. - * - * Side effects: - * Creates a new Tcl_Channel instance and inserts it into the - * hash table. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_CreateChannel( - Tcl_ChannelType *typePtr, /* The channel type record. */ - char *chanName, /* Name of channel to record. */ - Tcl_File inFile, /* File to use for input, or NULL. */ - Tcl_File outFile, /* File to use for output, or NULL. */ - ClientData instanceData /* Instance specific data. */ -) -{ - Channel *chanPtr; /* The channel structure newly created. */ - - chanPtr = (Channel *) ckalloc((unsigned) sizeof(Channel)); - - if (chanName != (char *) NULL) { - chanPtr->channelName = ckalloc((unsigned) (strlen(chanName) + 1)); - strcpy(chanPtr->channelName, chanName); - } else { - panic("Tcl_CreateChannel: NULL channel name"); - } - - chanPtr->flags = 0; - if (inFile != (Tcl_File) NULL) { - chanPtr->flags |= TCL_READABLE; - } - if (outFile != (Tcl_File) NULL) { - chanPtr->flags |= TCL_WRITABLE; - } - - /* - * Set the channel up initially in AUTO input translation mode to - * accept "\n", "\r" and "\r\n". Output translation mode is set to - * a platform specific default value. The eofChar is set to 0 for both - * input and output, so that Tcl does not look for an in-file EOF - * indicator (e.g. ^Z) and does not append an EOF indicator to files. - */ - - chanPtr->inputTranslation = TCL_TRANSLATE_AUTO; - chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION; - chanPtr->inEofChar = 0; - chanPtr->outEofChar = 0; - - chanPtr->unreportedError = 0; - chanPtr->instanceData = instanceData; - chanPtr->inFile = inFile; - chanPtr->outFile = outFile; - chanPtr->typePtr = typePtr; - chanPtr->refCount = 0; - chanPtr->closeCbPtr = (CloseCallback *) NULL; - chanPtr->curOutPtr = (ChannelBuffer *) NULL; - chanPtr->outQueueHead = (ChannelBuffer *) NULL; - chanPtr->outQueueTail = (ChannelBuffer *) NULL; - chanPtr->saveInBufPtr = (ChannelBuffer *) NULL; - chanPtr->inQueueHead = (ChannelBuffer *) NULL; - chanPtr->inQueueTail = (ChannelBuffer *) NULL; - chanPtr->chPtr = (ChannelHandler *) NULL; - chanPtr->interestMask = 0; - chanPtr->scriptRecordPtr = (EventScriptRecord *) NULL; - chanPtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE; - - /* - * Link the channel into the list of all channels; create an on-exit - * handler if there is not one already, to close off all the channels - * in the list on exit. - */ - - chanPtr->nextChanPtr = firstChanPtr; - firstChanPtr = chanPtr; - - if (!channelExitHandlerCreated) { - channelExitHandlerCreated = 1; - Tcl_CreateExitHandler(CloseChannelsOnExit, (ClientData) NULL); - } - - /* - * Install this channel in the first empty standard channel slot. - */ - - if (Tcl_GetStdChannel(TCL_STDIN) == NULL) { - Tcl_SetStdChannel((Tcl_Channel)chanPtr, TCL_STDIN); - } else if (Tcl_GetStdChannel(TCL_STDOUT) == NULL) { - Tcl_SetStdChannel((Tcl_Channel)chanPtr, TCL_STDOUT); - } else if (Tcl_GetStdChannel(TCL_STDERR) == NULL) { - Tcl_SetStdChannel((Tcl_Channel)chanPtr, TCL_STDERR); - } - - return (Tcl_Channel) chanPtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelName -- - * - * Returns the string identifying the channel name. - * - * Results: - * The string containing the channel name. This memory is - * owned by the generic layer and should not be modified by - * the caller. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_GetChannelName( - Tcl_Channel chan /* The channel for which to return the name. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - return chanPtr->channelName; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelType -- - * - * Given a channel structure, returns the channel type structure. - * - * Results: - * Returns a pointer to the channel type structure. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_ChannelType * -Tcl_GetChannelType( - Tcl_Channel chan /* The channel to return type for. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - return chanPtr->typePtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelFile -- - * - * Returns a file associated with a channel. - * - * Results: - * The file or NULL if failed (e.g. the channel is not open for the - * requested direction). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_File -Tcl_GetChannelFile( - Tcl_Channel chan, /* The channel to get file from. */ - int direction /* TCL_WRITABLE or TCL_READABLE. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - switch (direction) { - case TCL_WRITABLE: - return chanPtr->outFile; - case TCL_READABLE: - return chanPtr->inFile; - default: - return NULL; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelInstanceData -- - * - * Returns the client data associated with a channel. - * - * Results: - * The client data. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_GetChannelInstanceData( - Tcl_Channel chan /* Channel for which to return client data. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - return chanPtr->instanceData; -} - -/* - *---------------------------------------------------------------------- - * - * RecycleBuffer -- - * - * Helper function to recycle input and output buffers. Ensures - * that two input buffers are saved (one in the input queue and - * another in the saveInBufPtr field) and that curOutPtr is set - * to a buffer. Only if these conditions are met is the buffer - * freed to the OS. - * - * Results: - * None. - * - * Side effects: - * May free a buffer to the OS. - * - *---------------------------------------------------------------------- - */ - -static void -RecycleBuffer( - Channel *chanPtr, /* Channel for which to recycle buffers. */ - ChannelBuffer *bufPtr, /* The buffer to recycle. */ - int mustDiscard /* If nonzero, free the buffer to the - * OS, always. */ -) -{ - /* - * Do we have to free the buffer to the OS? - */ - - if (mustDiscard) { - ckfree((char *) bufPtr); - return; - } - - /* - * Only save buffers for the input queue if the channel is readable. - */ - - if (chanPtr->flags & TCL_READABLE) { - if (chanPtr->inQueueHead == (ChannelBuffer *) NULL) { - chanPtr->inQueueHead = bufPtr; - chanPtr->inQueueTail = bufPtr; - goto keepit; - } - if (chanPtr->saveInBufPtr == (ChannelBuffer *) NULL) { - chanPtr->saveInBufPtr = bufPtr; - goto keepit; - } - } - - /* - * Only save buffers for the output queue if the channel is writable. - */ - - if (chanPtr->flags & TCL_WRITABLE) { - if (chanPtr->curOutPtr == (ChannelBuffer *) NULL) { - chanPtr->curOutPtr = bufPtr; - goto keepit; - } - } - - /* - * If we reached this code we return the buffer to the OS. - */ - - ckfree((char *) bufPtr); - return; - -keepit: - bufPtr->nextRemoved = 0; - bufPtr->nextAdded = 0; - bufPtr->nextPtr = (ChannelBuffer *) NULL; -} - -/* - *---------------------------------------------------------------------- - * - * DiscardOutputQueued -- - * - * Discards all output queued in the output queue of a channel. - * - * Results: - * None. - * - * Side effects: - * Recycles buffers. - * - *---------------------------------------------------------------------- - */ - -static void -DiscardOutputQueued( - Channel *chanPtr /* The channel for which to discard output. */ -) -{ - ChannelBuffer *bufPtr; - - while (chanPtr->outQueueHead != (ChannelBuffer *) NULL) { - bufPtr = chanPtr->outQueueHead; - chanPtr->outQueueHead = bufPtr->nextPtr; - RecycleBuffer(chanPtr, bufPtr, 0); - } - chanPtr->outQueueHead = (ChannelBuffer *) NULL; - chanPtr->outQueueTail = (ChannelBuffer *) NULL; -} - -/* - *---------------------------------------------------------------------- - * - * FlushChannel -- - * - * This function flushes as much of the queued output as is possible - * now. If calledFromAsyncFlush is nonzero, it is being called in an - * event handler to flush channel output asynchronously. - * - * Results: - * 0 if successful, else the error code that was returned by the - * channel type operation. - * - * Side effects: - * May produce output on a channel. May block indefinitely if the - * channel is synchronous. May schedule an async flush on the channel. - * May recycle memory for buffers in the output queue. - * - *---------------------------------------------------------------------- - */ - -static int -FlushChannel( - Tcl_Interp *interp, /* For error reporting during close. */ - Channel *chanPtr, /* The channel to flush on. */ - int calledFromAsyncFlush /* If nonzero then we are being - * called from an asynchronous - * flush callback. */ -) -{ - ChannelBuffer *bufPtr; /* Iterates over buffered output - * queue. */ - int toWrite; /* Amount of output data in current - * buffer available to be written. */ - int written; /* Amount of output data actually - * written in current round. */ - int errorCode; /* Stores POSIX error codes from - * channel driver operations. */ - - errorCode = 0; - - /* - * Loop over the queued buffers and attempt to flush as - * much as possible of the queued output to the channel. - */ - - while (1) { - - /* - * If the queue is empty and there is a ready current buffer, OR if - * the current buffer is full, then move the current buffer to the - * queue. - */ - - if (((chanPtr->curOutPtr != (ChannelBuffer *) NULL) && - (chanPtr->curOutPtr->nextAdded == chanPtr->curOutPtr->bufSize)) - || ((chanPtr->flags & BUFFER_READY) && - (chanPtr->outQueueHead == (ChannelBuffer *) NULL))) { - chanPtr->flags &= (~(BUFFER_READY)); - chanPtr->curOutPtr->nextPtr = (ChannelBuffer *) NULL; - if (chanPtr->outQueueHead == (ChannelBuffer *) NULL) { - chanPtr->outQueueHead = chanPtr->curOutPtr; - } else { - chanPtr->outQueueTail->nextPtr = chanPtr->curOutPtr; - } - chanPtr->outQueueTail = chanPtr->curOutPtr; - chanPtr->curOutPtr = (ChannelBuffer *) NULL; - } - bufPtr = chanPtr->outQueueHead; - - /* - * If we are not being called from an async flush and an async - * flush is active, we just return without producing any output. - */ - - if ((!calledFromAsyncFlush) && - (chanPtr->flags & BG_FLUSH_SCHEDULED)) { - return 0; - } - - /* - * If the output queue is still empty, break out of the while loop. - */ - - if (bufPtr == (ChannelBuffer *) NULL) { - break; /* Out of the "while (1)". */ - } - - /* - * Produce the output on the channel. - */ - - toWrite = bufPtr->nextAdded - bufPtr->nextRemoved; - written = (chanPtr->typePtr->outputProc) (chanPtr->instanceData, - chanPtr->outFile, bufPtr->buf + bufPtr->nextRemoved, - toWrite, &errorCode); - - /* - * If the write failed completely attempt to start the asynchronous - * flush mechanism and break out of this loop - do not attempt to - * write any more output at this time. - */ - - if (written < 0) { - - /* - * If the last attempt to write was interrupted, simply retry. - */ - - if (errorCode == EINTR) { - continue; - } - - /* - * If we would have blocked, attempt to set up an asynchronous - * background flushing for this channel if the channel is - * nonblocking, or block until more output can be written if - * the channel is blocking. - */ - - if ((errorCode == EWOULDBLOCK) || (errorCode == EAGAIN)) { - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - if (!(chanPtr->flags & BG_FLUSH_SCHEDULED)) { - Tcl_CreateFileHandler(chanPtr->outFile, - TCL_WRITABLE, FlushEventProc, - (ClientData) chanPtr); - } - chanPtr->flags |= BG_FLUSH_SCHEDULED; - errorCode = 0; - break; /* Out of the "while (1)" loop. */ - } else { - - /* - * If the device driver did not emulate blocking behavior - * then we must do it it here. - */ - - TclWaitForFile(chanPtr->outFile, TCL_WRITABLE, -1); - continue; - } - } - - /* - * Decide whether to report the error upwards or defer it. If - * we got an error during async flush we discard all queued - * output. - */ - - if (calledFromAsyncFlush) { - if (chanPtr->unreportedError == 0) { - chanPtr->unreportedError = errorCode; - } - } else { - Tcl_SetErrno(errorCode); - } - - /* - * When we get an error we throw away all the output - * currently queued. - */ - - DiscardOutputQueued(chanPtr); - continue; - } - - bufPtr->nextRemoved += written; - - /* - * If this buffer is now empty, recycle it. - */ - - if (bufPtr->nextRemoved == bufPtr->nextAdded) { - chanPtr->outQueueHead = bufPtr->nextPtr; - if (chanPtr->outQueueHead == (ChannelBuffer *) NULL) { - chanPtr->outQueueTail = (ChannelBuffer *) NULL; - } - RecycleBuffer(chanPtr, bufPtr, 0); - } - } /* Closes "while (1)". */ - - /* - * If the queue became empty and we have an asynchronous flushing - * mechanism active, cancel the asynchronous flushing. - */ - - if ((chanPtr->outQueueHead == (ChannelBuffer *) NULL) && - (chanPtr->flags & BG_FLUSH_SCHEDULED)) { - chanPtr->flags &= (~(BG_FLUSH_SCHEDULED)); - if (chanPtr->outFile != (Tcl_File) NULL) { - Tcl_DeleteFileHandler(chanPtr->outFile); - } - } - - /* - * If the channel is flagged as closed, delete it when the refcount - * drops to zero, the output queue is empty and there is no output - * in the current output buffer. - */ - - if ((chanPtr->flags & CHANNEL_CLOSED) && (chanPtr->refCount <= 0) && - (chanPtr->outQueueHead == (ChannelBuffer *) NULL) && - ((chanPtr->curOutPtr == (ChannelBuffer *) NULL) || - (chanPtr->curOutPtr->nextAdded == - chanPtr->curOutPtr->nextRemoved))) { - return CloseChannel(interp, chanPtr, errorCode); - } - return errorCode; -} - -/* - *---------------------------------------------------------------------- - * - * CloseChannel -- - * - * Utility procedure to close a channel and free its associated - * resources. - * - * Results: - * 0 on success or a POSIX error code if the operation failed. - * - * Side effects: - * May close the actual channel; may free memory. - * - *---------------------------------------------------------------------- - */ - -static int -CloseChannel( - Tcl_Interp *interp, /* For error reporting. */ - Channel *chanPtr, /* The channel to close. */ - int errorCode /* Status of operation so far. */ -) -{ - int result; /* Of calling driver close - * operation. */ - Channel *prevChanPtr; /* Preceding channel in list of - * all channels - used to splice a - * channel out of the list on close. */ - - /* - * No more input can be consumed so discard any leftover input. - */ - - DiscardInputQueued(chanPtr, 1); - - /* - * Discard a leftover buffer in the current output buffer field. - */ - - if (chanPtr->curOutPtr != (ChannelBuffer *) NULL) { - ckfree((char *) chanPtr->curOutPtr); - chanPtr->curOutPtr = (ChannelBuffer *) NULL; - } - - /* - * The caller guarantees that there are no more buffers - * queued for output. - */ - - if (chanPtr->outQueueHead != (ChannelBuffer *) NULL) { - panic("TclFlush, closed channel: queued output left"); - } - - /* - * If the EOF character is set in the channel, append that to the - * output device. - */ - - if ((chanPtr->outEofChar != 0) && (chanPtr->outFile != NULL)) { - int dummy; - char c; - - c = (char) chanPtr->outEofChar; - (chanPtr->typePtr->outputProc) (chanPtr->instanceData, - chanPtr->outFile, &c, 1, &dummy); - } - - /* - * Remove TCL_READABLE and TCL_WRITABLE from chanPtr->flags, so - * that close callbacks can not do input or output (assuming they - * squirreled the channel away in their clientData). This also - * prevents infinite loops if the callback calls any C API that - * could call FlushChannel. - */ - - chanPtr->flags &= (~(TCL_READABLE|TCL_WRITABLE)); - - /* - * Splice this channel out of the list of all channels. - */ - - if (chanPtr == firstChanPtr) { - firstChanPtr = chanPtr->nextChanPtr; - } else { - for (prevChanPtr = firstChanPtr; - (prevChanPtr != (Channel *) NULL) && - (prevChanPtr->nextChanPtr != chanPtr); - prevChanPtr = prevChanPtr->nextChanPtr) { - /* Empty loop body. */ - } - if (prevChanPtr == (Channel *) NULL) { - panic("FlushChannel: damaged channel list"); - } - prevChanPtr->nextChanPtr = chanPtr->nextChanPtr; - } - - if (chanPtr->channelName != (char *) NULL) { - ckfree(chanPtr->channelName); - } - - /* - * OK, close the channel itself. - */ - - result = (chanPtr->typePtr->closeProc) (chanPtr->instanceData, interp, - chanPtr->inFile, chanPtr->outFile); - - /* - * If we are being called synchronously, report either - * any latent error on the channel or the current error. - */ - - if (chanPtr->unreportedError != 0) { - errorCode = chanPtr->unreportedError; - } - if (errorCode == 0) { - errorCode = result; - if (errorCode != 0) { - Tcl_SetErrno(errorCode); - } - } - - Tcl_EventuallyFree((ClientData) chanPtr, TCL_DYNAMIC); - - return errorCode; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Close -- - * - * Closes a channel. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Closes the channel if this is the last reference. - * - * NOTE: - * Tcl_Close removes the channel as far as the user is concerned. - * However, it may continue to exist for a while longer if it has - * a background flush scheduled. The device itself is eventually - * closed and the channel record removed, in CloseChannel, above. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_Close( - Tcl_Interp *interp, /* Interpreter for errors. */ - Tcl_Channel chan /* The channel being closed. Must - * not be referenced in any - * interpreter. */ -) -{ - ChannelHandler *chPtr, *chNext; /* Iterate over channel handlers. */ - CloseCallback *cbPtr; /* Iterate over close callbacks - * for this channel. */ - EventScriptRecord *ePtr, *eNextPtr; /* Iterate over eventscript records. */ - Channel *chanPtr; /* The real IO channel. */ - int result; /* Of calling FlushChannel. */ - - chanPtr = (Channel *) chan; - - if (chanPtr->refCount > 0) { - panic("called Tcl_Close on channel with refcount > 0"); - } - - /* - * Remove the channel from the standard channel table. - */ - - if (Tcl_GetStdChannel(TCL_STDIN) == chan) { - Tcl_SetStdChannel(NULL, TCL_STDIN); - } else if (Tcl_GetStdChannel(TCL_STDOUT) == chan) { - Tcl_SetStdChannel(NULL, TCL_STDOUT); - } else if (Tcl_GetStdChannel(TCL_STDERR) == chan) { - Tcl_SetStdChannel(NULL, TCL_STDERR); - } - - /* - * Remove all the channel handler records attached to the channel - * itself. - */ - - for (chPtr = chanPtr->chPtr; - chPtr != (ChannelHandler *) NULL; - chPtr = chNext) { - chNext = chPtr->nextPtr; - ckfree((char *) chPtr); - } - chanPtr->chPtr = (ChannelHandler *) NULL; - - /* - * Must set the interest mask now to 0, otherwise infinite loops - * will occur if Tcl_DoOneEvent is called before the channel is - * finally deleted in FlushChannel. This can happen if the channel - * has a background flush active. - */ - - chanPtr->interestMask = 0; - - /* - * Remove any EventScript records for this channel. - */ - - for (ePtr = chanPtr->scriptRecordPtr; - ePtr != (EventScriptRecord *) NULL; - ePtr = eNextPtr) { - eNextPtr = ePtr->nextPtr; - Tcl_EventuallyFree((ClientData)ePtr->script, TCL_DYNAMIC); - ckfree((char *) ePtr); - } - chanPtr->scriptRecordPtr = (EventScriptRecord *) NULL; - - /* - * Invoke the registered close callbacks and delete their records. - */ - - while (chanPtr->closeCbPtr != (CloseCallback *) NULL) { - cbPtr = chanPtr->closeCbPtr; - chanPtr->closeCbPtr = cbPtr->nextPtr; - (cbPtr->proc) (cbPtr->clientData); - ckfree((char *) cbPtr); - } - - /* - * And remove any events for this channel from the event queue. - */ - - Tcl_DeleteEvents(ChannelEventDeleteProc, (ClientData) chanPtr); - - /* - * Ensure that the last output buffer will be flushed. - */ - - if ((chanPtr->curOutPtr != (ChannelBuffer *) NULL) && - (chanPtr->curOutPtr->nextAdded > chanPtr->curOutPtr->nextRemoved)) { - chanPtr->flags |= BUFFER_READY; - } - - /* - * The call to FlushChannel will flush any queued output and invoke - * the close function of the channel driver, or it will set up the - * channel to be flushed and closed asynchronously. - */ - - chanPtr->flags |= CHANNEL_CLOSED; - result = FlushChannel(interp, chanPtr, 0); - if (result != 0) { - return TCL_ERROR; - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * ChannelEventDeleteProc -- - * - * This procedure returns 1 if the event passed in is for the - * channel passed in as the second argument. This procedure is - * used as a filter for events to delete in a call to - * Tcl_DeleteEvents in CloseChannel. - * - * Results: - * 1 if matching, 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ChannelEventDeleteProc( - Tcl_Event *evPtr, /* The event to check for a match. */ - ClientData clientData /* The channel to check for. */ -) -{ - ChannelHandlerEvent *cEvPtr; - Channel *chanPtr; - - if (evPtr->proc != ChannelHandlerEventProc) { - return 0; - } - cEvPtr = (ChannelHandlerEvent *) evPtr; - chanPtr = (Channel *) clientData; - if (cEvPtr->chanPtr != chanPtr) { - return 0; - } - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Write -- - * - * Puts a sequence of characters into an output buffer, may queue the - * buffer for output if it gets full, and also remembers whether the - * current buffer is ready e.g. if it contains a newline and we are in - * line buffering mode. - * - * Results: - * The number of bytes written or -1 in case of error. If -1, - * Tcl_GetErrno will return the error code. - * - * Side effects: - * May buffer up output and may cause output to be produced on the - * channel. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Write( - Tcl_Channel chan, /* The channel to buffer output for. */ - char *srcPtr, /* Output to buffer. */ - int slen /* Its length. Negative means - * the output is null terminated - * and we must compute its length. */ -) -{ - Channel *chanPtr; /* The actual channel. */ - ChannelBuffer *outBufPtr; /* Current output buffer. */ - int foundNewline; /* Did we find a newline in output? */ - char *dPtr, *sPtr; /* Search variables for newline. */ - int crsent; /* In CRLF eol translation mode, - * remember the fact that a CR was - * output to the channel without - * its following NL. */ - int i; /* Loop index for newline search. */ - int destCopied; /* How many bytes were used in this - * destination buffer to hold the - * output? */ - int totalDestCopied; /* How many bytes total were - * copied to the channel buffer? */ - int srcCopied; /* How many bytes were copied from - * the source string? */ - char *destPtr; /* Where in line to copy to? */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return -1; - } - - /* - * If the channel is not open for writing punt. - */ - - if (!(chanPtr->flags & TCL_WRITABLE)) { - Tcl_SetErrno(EACCES); - return -1; - } - - /* - * If length passed is negative, assume that the output is null terminated - * and compute its length. - */ - - if (slen < 0) { - slen = strlen(srcPtr); - } - - /* - * If we are in network (or windows) translation mode, record the fact - * that we have not yet sent a CR to the channel. - */ - - crsent = 0; - - /* - * Loop filling buffers and flushing them until all output has been - * consumed. - */ - - srcCopied = 0; - totalDestCopied = 0; - - while (slen > 0) { - - /* - * Make sure there is a current output buffer to accept output. - */ - - if (chanPtr->curOutPtr == (ChannelBuffer *) NULL) { - chanPtr->curOutPtr = (ChannelBuffer *) ckalloc((unsigned) - (CHANNELBUFFER_HEADER_SIZE + chanPtr->bufSize)); - chanPtr->curOutPtr->nextAdded = 0; - chanPtr->curOutPtr->nextRemoved = 0; - chanPtr->curOutPtr->bufSize = chanPtr->bufSize; - chanPtr->curOutPtr->nextPtr = (ChannelBuffer *) NULL; - } - - outBufPtr = chanPtr->curOutPtr; - - destCopied = outBufPtr->bufSize - outBufPtr->nextAdded; - if (destCopied > slen) { - destCopied = slen; - } - - destPtr = outBufPtr->buf + outBufPtr->nextAdded; - switch (chanPtr->outputTranslation) { - case TCL_TRANSLATE_LF: - srcCopied = destCopied; - memcpy((VOID *) destPtr, (VOID *) srcPtr, (size_t) destCopied); - break; - case TCL_TRANSLATE_CR: - srcCopied = destCopied; - memcpy((VOID *) destPtr, (VOID *) srcPtr, (size_t) destCopied); - for (dPtr = destPtr; dPtr < destPtr + destCopied; dPtr++) { - if (*dPtr == '\n') { - *dPtr = '\r'; - } - } - break; - case TCL_TRANSLATE_CRLF: - for (srcCopied = 0, dPtr = destPtr, sPtr = srcPtr; - dPtr < destPtr + destCopied; - dPtr++, sPtr++, srcCopied++) { - if (*sPtr == '\n') { - if (crsent) { - *dPtr = '\n'; - crsent = 0; - } else { - *dPtr = '\r'; - crsent = 1; - sPtr--, srcCopied--; - } - } else { - *dPtr = *sPtr; - } - } - break; - case TCL_TRANSLATE_AUTO: - panic("Tcl_Write: AUTO output translation mode not supported"); - default: - panic("Tcl_Write: unknown output translation mode"); - } - - /* - * The current buffer is ready for output if it is full, or if it - * contains a newline and this channel is line-buffered, or if it - * contains any output and this channel is unbuffered. - */ - - outBufPtr->nextAdded += destCopied; - if (!(chanPtr->flags & BUFFER_READY)) { - if (outBufPtr->nextAdded == outBufPtr->bufSize) { - chanPtr->flags |= BUFFER_READY; - } else if (chanPtr->flags & CHANNEL_LINEBUFFERED) { - for (sPtr = srcPtr, i = 0, foundNewline = 0; - (i < srcCopied) && (!foundNewline); - i++, sPtr++) { - if (*sPtr == '\n') { - foundNewline = 1; - break; - } - } - if (foundNewline) { - chanPtr->flags |= BUFFER_READY; - } - } else if (chanPtr->flags & CHANNEL_UNBUFFERED) { - chanPtr->flags |= BUFFER_READY; - } - } - - totalDestCopied += srcCopied; - srcPtr += srcCopied; - slen -= srcCopied; - - if (chanPtr->flags & BUFFER_READY) { - if (FlushChannel(NULL, chanPtr, 0) != 0) { - return -1; - } - } - } /* Closes "while" */ - - return totalDestCopied; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Flush -- - * - * Flushes output data on a channel. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May flush output queued on this channel. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Flush( - Tcl_Channel chan /* The Channel to flush. */ -) -{ - int result; /* Of calling FlushChannel. */ - Channel *chanPtr; /* The actual channel. */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return TCL_ERROR; - } - - /* - * If the channel is not open for writing punt. - */ - - if (!(chanPtr->flags & TCL_WRITABLE)) { - Tcl_SetErrno(EACCES); - return TCL_ERROR; - } - - /* - * Force current output buffer to be output also. - */ - - if ((chanPtr->curOutPtr != (ChannelBuffer *) NULL) && - (chanPtr->curOutPtr->nextAdded > 0)) { - chanPtr->flags |= BUFFER_READY; - } - - result = FlushChannel(NULL, chanPtr, 0); - if (result != 0) { - return TCL_ERROR; - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * DiscardInputQueued -- - * - * Discards any input read from the channel but not yet consumed - * by Tcl reading commands. - * - * Results: - * None. - * - * Side effects: - * May discard input from the channel. If discardLastBuffer is zero, - * leaves one buffer in place for back-filling. - * - *---------------------------------------------------------------------- - */ - -static void -DiscardInputQueued( - Channel *chanPtr, /* Channel on which to discard - * the queued input. */ - int discardSavedBuffers /* If non-zero, discard all buffers including - * last one. */ -) -{ - ChannelBuffer *bufPtr, *nxtPtr; /* Loop variables. */ - - bufPtr = chanPtr->inQueueHead; - chanPtr->inQueueHead = (ChannelBuffer *) NULL; - chanPtr->inQueueTail = (ChannelBuffer *) NULL; - for (; bufPtr != (ChannelBuffer *) NULL; bufPtr = nxtPtr) { - nxtPtr = bufPtr->nextPtr; - RecycleBuffer(chanPtr, bufPtr, discardSavedBuffers); - } - - /* - * If discardSavedBuffers is nonzero, must also discard any previously - * saved buffer in the saveInBufPtr field. - */ - - if (discardSavedBuffers) { - if (chanPtr->saveInBufPtr != (ChannelBuffer *) NULL) { - ckfree((char *) chanPtr->saveInBufPtr); - chanPtr->saveInBufPtr = (ChannelBuffer *) NULL; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * GetInput -- - * - * Reads input data from a device or file into an input buffer. - * - * Results: - * A Posix error code or 0. - * - * Side effects: - * Reads from the underlying device. - * - *---------------------------------------------------------------------- - */ - -static int -GetInput( - Channel *chanPtr /* Channel to read input from. */ -) -{ - int toRead; /* How much to read? */ - int result; /* Of calling driver. */ - int nread; /* How much was read from channel? */ - ChannelBuffer *bufPtr; /* New buffer to add to input queue. */ - - /* - * See if we can fill an existing buffer. If we can, read only - * as much as will fit in it. Otherwise allocate a new buffer, - * add it to the input queue and attempt to fill it to the max. - */ - - if ((chanPtr->inQueueTail != (ChannelBuffer *) NULL) && - (chanPtr->inQueueTail->nextAdded < chanPtr->inQueueTail->bufSize)) { - bufPtr = chanPtr->inQueueTail; - toRead = bufPtr->bufSize - bufPtr->nextAdded; - } else { - if (chanPtr->saveInBufPtr != (ChannelBuffer *) NULL) { - bufPtr = chanPtr->saveInBufPtr; - chanPtr->saveInBufPtr = (ChannelBuffer *) NULL; - } else { - bufPtr = (ChannelBuffer *) ckalloc( - ((unsigned) CHANNELBUFFER_HEADER_SIZE + chanPtr->bufSize)); - bufPtr->bufSize = chanPtr->bufSize; - } - bufPtr->nextRemoved = 0; - bufPtr->nextAdded = 0; - toRead = bufPtr->bufSize; - if (chanPtr->inQueueTail == (ChannelBuffer *) NULL) { - chanPtr->inQueueHead = bufPtr; - } else { - chanPtr->inQueueTail->nextPtr = bufPtr; - } - chanPtr->inQueueTail = bufPtr; - bufPtr->nextPtr = (ChannelBuffer *) NULL; - } - - while (1) { - - /* - * If EOF is set, we should avoid calling the driver because on some - * platforms it is impossible to read from a device after EOF. - */ - - if (chanPtr->flags & CHANNEL_EOF) { - break; - } - nread = (chanPtr->typePtr->inputProc) (chanPtr->instanceData, - chanPtr->inFile, bufPtr->buf + bufPtr->nextAdded, - toRead, &result); - if (nread == 0) { - chanPtr->flags |= CHANNEL_EOF; - break; - } else if (nread < 0) { - if ((result == EWOULDBLOCK) || (result == EAGAIN)) { - chanPtr->flags |= CHANNEL_BLOCKED; - result = EAGAIN; - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - Tcl_SetErrno(result); - return result; - } else { - - /* - * If the device driver did not emulate blocking behavior - * then we have to do it here. - */ - - TclWaitForFile(chanPtr->inFile, TCL_READABLE, -1); - } - } else { - Tcl_SetErrno(result); - return result; - } - } else { - bufPtr->nextAdded += nread; - - /* - * If we get a short read, signal up that we may be BLOCKED. We - * should avoid calling the driver because on some platforms we - * will block in the low level reading code even though the - * channel is set into nonblocking mode. - */ - - if (nread < toRead) { - chanPtr->flags |= CHANNEL_BLOCKED; - } - break; - } - } - - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * CopyAndTranslateBuffer -- - * - * Copy at most one buffer of input to the result space, doing - * eol translations according to mode in effect currently. - * - * Results: - * Number of characters (as opposed to bytes) copied. May return - * zero if no input is available to be translated. - * - * Side effects: - * Consumes buffered input. May deallocate one buffer. - * - *---------------------------------------------------------------------- - */ - -static int -CopyAndTranslateBuffer( - Channel *chanPtr, /* The channel from which to read input. */ - char *result, /* Where to store the copied input. */ - int space /* How many bytes are available in result - * to store the copied input? */ -) -{ - int bytesInBuffer; /* How many bytes are available to be - * copied in the current input buffer? */ - int copied; /* How many characters were already copied - * into the destination space? */ - ChannelBuffer *bufPtr; /* The buffer from which to copy bytes. */ - char curByte; /* The byte we are currently translating. */ - int i; /* Iterates over the copied input looking - * for the input eofChar. */ - - /* - * If there is no input at all, return zero. The invariant is that either - * there is no buffer in the queue, or if the first buffer is empty, it - * is also the last buffer (and thus there is no input in the queue). - * Note also that if the buffer is empty, we leave it in the queue. - */ - - if (chanPtr->inQueueHead == (ChannelBuffer *) NULL) { - return 0; - } - bufPtr = chanPtr->inQueueHead; - bytesInBuffer = bufPtr->nextAdded - bufPtr->nextRemoved; - if (bytesInBuffer < space) { - space = bytesInBuffer; - } - copied = 0; - switch (chanPtr->inputTranslation) { - case TCL_TRANSLATE_LF: - - if (space == 0) { - return 0; - } - - /* - * Copy the current chunk into the result buffer. - */ - - memcpy((VOID *) result, - (VOID *)(bufPtr->buf + bufPtr->nextRemoved), - (size_t) space); - bufPtr->nextRemoved += space; - copied = space; - break; - - case TCL_TRANSLATE_CR: - - if (space == 0) { - return 0; - } - - /* - * Copy the current chunk into the result buffer, then - * replace all \r with \n. - */ - - memcpy((VOID *) result, - (VOID *)(bufPtr->buf + bufPtr->nextRemoved), - (size_t) space); - bufPtr->nextRemoved += space; - for (copied = 0; copied < space; copied++) { - if (result[copied] == '\r') { - result[copied] = '\n'; - } - } - break; - - case TCL_TRANSLATE_CRLF: - - /* - * If there is a held-back "\r" at EOF, produce it now. - */ - - if (space == 0) { - if ((chanPtr->flags & (INPUT_SAW_CR | CHANNEL_EOF)) == - (INPUT_SAW_CR | CHANNEL_EOF)) { - result[0] = '\r'; - chanPtr->flags &= (~(INPUT_SAW_CR)); - return 1; - } - return 0; - } - - /* - * Copy the current chunk and replace "\r\n" with "\n" - * (but not standalone "\r"!). - */ - - for (copied = 0; - (copied < space) && - (bufPtr->nextRemoved < bufPtr->nextAdded); - copied++) { - curByte = bufPtr->buf[bufPtr->nextRemoved]; - bufPtr->nextRemoved++; - if (curByte == '\r') { - if (chanPtr->flags & INPUT_SAW_CR) { - result[copied] = '\r'; - } else { - chanPtr->flags |= INPUT_SAW_CR; - copied--; - } - } else if (curByte == '\n') { - chanPtr->flags &= (~(INPUT_SAW_CR)); - result[copied] = '\n'; - } else { - if (chanPtr->flags & INPUT_SAW_CR) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - result[copied] = '\r'; - copied++; - } - result[copied] = curByte; - } - } - break; - - case TCL_TRANSLATE_AUTO: - - if (space == 0) { - return 0; - } - - /* - * Loop over the current buffer, converting "\r" and "\r\n" - * to "\n". - */ - - for (copied = 0; - (copied < space) && - (bufPtr->nextRemoved < bufPtr->nextAdded); ) { - curByte = bufPtr->buf[bufPtr->nextRemoved]; - bufPtr->nextRemoved++; - if (curByte == '\r') { - result[copied] = '\n'; - copied++; - if (bufPtr->nextRemoved < bufPtr->nextAdded) { - if (bufPtr->buf[bufPtr->nextRemoved] == '\n') { - bufPtr->nextRemoved++; - } - chanPtr->flags &= (~(INPUT_SAW_CR)); - } else { - chanPtr->flags |= INPUT_SAW_CR; - } - } else { - if (curByte == '\n') { - if (!(chanPtr->flags & INPUT_SAW_CR)) { - result[copied] = '\n'; - copied++; - } - } else { - result[copied] = curByte; - copied++; - } - chanPtr->flags &= (~(INPUT_SAW_CR)); - } - } - break; - - default: - panic("unknown eol translation mode"); - } - - /* - * If an in-stream EOF character is set for this channel,, check that - * the input we copied so far does not contain the EOF char. If it does, - * copy only up to and excluding that character. - */ - - if (chanPtr->inEofChar != 0) { - for (i = 0; i < copied; i++) { - if (result[i] == (char) chanPtr->inEofChar) { - break; - } - } - if (i < copied) { - - /* - * Set sticky EOF so that no further input is presented - * to the caller. - */ - - chanPtr->flags |= (CHANNEL_EOF | CHANNEL_STICKY_EOF); - - /* - * Reset the start of valid data in the input buffer to the - * position of the eofChar, so that subsequent reads will - * encounter it immediately. First we set it to the position - * of the last byte consumed if all result bytes were the - * product of one input byte; since it is possible that "\r\n" - * contracted to "\n" in the result, we have to search back - * from that position until we find the eofChar, because it - * is possible that its actual position in the buffer is n - * bytes further back (n is the number of "\r\n" sequences - * that were contracted to "\n" in the result). - */ - - bufPtr->nextRemoved -= (copied - i); - while ((bufPtr->nextRemoved > 0) && - (bufPtr->buf[bufPtr->nextRemoved] != - (char) chanPtr->inEofChar)) { - bufPtr->nextRemoved--; - } - copied = i; - } - } - - /* - * If the current buffer is empty recycle it. - */ - - if (bufPtr->nextRemoved == bufPtr->nextAdded) { - chanPtr->inQueueHead = bufPtr->nextPtr; - if (chanPtr->inQueueHead == (ChannelBuffer *) NULL) { - chanPtr->inQueueTail = (ChannelBuffer *) NULL; - } - RecycleBuffer(chanPtr, bufPtr, 0); - } - - /* - * Return the number of characters copied into the result buffer. - * This may be different from the number of bytes consumed, because - * of EOL translations. - */ - - return copied; -} - -/* - *---------------------------------------------------------------------- - * - * ScanBufferForEOL -- - * - * Scans one buffer for EOL according to the specified EOL - * translation mode. If it sees the input eofChar for the channel - * it stops also. - * - * Results: - * TRUE if EOL is found, FALSE otherwise. Also sets output parameter - * bytesToEOLPtr to the number of bytes so far to EOL, and crSeenPtr - * to whether a "\r" was seen. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ScanBufferForEOL( - Channel *chanPtr, - ChannelBuffer *bufPtr, /* Buffer to scan for EOL. */ - Tcl_EolTranslation translation, /* Translation mode to use. */ - int eofChar, /* EOF char to look for. */ - int *bytesToEOLPtr, /* Running counter. */ - int *crSeenPtr /* Has "\r" been seen? */ -) -{ - char *rPtr; /* Iterates over input string. */ - char *sPtr; /* Where to stop search? */ - int EOLFound; - int bytesToEOL; - - for (EOLFound = 0, rPtr = bufPtr->buf + bufPtr->nextRemoved, - sPtr = bufPtr->buf + bufPtr->nextAdded, - bytesToEOL = *bytesToEOLPtr; - (!EOLFound) && (rPtr < sPtr); - rPtr++) { - switch (translation) { - case TCL_TRANSLATE_AUTO: - if ((*rPtr == (char) eofChar) && (eofChar != 0)) { - chanPtr->flags |= (CHANNEL_EOF | CHANNEL_STICKY_EOF); - EOLFound = 1; - } else if (*rPtr == '\n') { - - /* - * CopyAndTranslateBuffer wants to know the length - * of the result, not the input. The input is one - * larger because "\r\n" shrinks to "\n". - */ - - if (!(*crSeenPtr)) { - bytesToEOL++; - EOLFound = 1; - } else { - - /* - * This is a lf at the begining of a buffer - * where the previous buffer ended in a cr. - * Consume this lf because we've already emitted - * the newline for this crlf sequence. ALSO, if - * bytesToEOL is 0 (which means that we are at the - * first character of the scan), unset the - * INPUT_SAW_CR flag in the channel, because we - * already handled it; leaving it set would cause - * CopyAndTranslateBuffer to potentially consume - * another lf if one follows the current byte. - */ - - bufPtr->nextRemoved++; - *crSeenPtr = 0; - chanPtr->flags &= (~(INPUT_SAW_CR)); - } - } else if (*rPtr == '\r') { - bytesToEOL++; - EOLFound = 1; - } else { - *crSeenPtr = 0; - bytesToEOL++; - } - break; - case TCL_TRANSLATE_LF: - if ((*rPtr == (char) eofChar) && (eofChar != 0)) { - chanPtr->flags |= (CHANNEL_EOF | CHANNEL_STICKY_EOF); - EOLFound = 1; - } else { - if (*rPtr == '\n') { - EOLFound = 1; - } - bytesToEOL++; - } - break; - case TCL_TRANSLATE_CR: - if ((*rPtr == (char) eofChar) && (eofChar != 0)) { - chanPtr->flags |= (CHANNEL_EOF | CHANNEL_STICKY_EOF); - EOLFound = 1; - } else { - if (*rPtr == '\r') { - EOLFound = 1; - } - bytesToEOL++; - } - break; - case TCL_TRANSLATE_CRLF: - if ((*rPtr == (char) eofChar) && (eofChar != 0)) { - chanPtr->flags |= (CHANNEL_EOF | CHANNEL_STICKY_EOF); - EOLFound = 1; - } else if (*rPtr == '\n') { - - /* - * CopyAndTranslateBuffer wants to know the length - * of the result, not the input. The input is one - * larger because crlf shrinks to lf. - */ - - if (*crSeenPtr) { - EOLFound = 1; - } else { - bytesToEOL++; - } - } else { - if (*rPtr == '\r') { - *crSeenPtr = 1; - } else { - *crSeenPtr = 0; - } - bytesToEOL++; - } - break; - default: - panic("unknown eol translation mode"); - } - } - - *bytesToEOLPtr = bytesToEOL; - return EOLFound; -} - -/* - *---------------------------------------------------------------------- - * - * ScanInputForEOL -- - * - * Scans queued input for chanPtr for an end of line (according to the - * current EOL translation mode) and returns the number of bytes - * upto and including the end of line, or -1 if none was found. - * - * Results: - * Count of bytes upto and including the end of line if one is present - * or -1 if none was found. Also returns in an output parameter the - * number of bytes queued if no end of line was found. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ScanInputForEOL( - Channel *chanPtr, /* Channel for which to scan queued - * input for end of line. */ - int *bytesQueuedPtr /* Where to store the number of bytes - * currently queued if no end of line - * was found. */ -) -{ - ChannelBuffer *bufPtr; /* Iterates over queued buffers. */ - int bytesToEOL; /* How many bytes to end of line? */ - int EOLFound; /* Did we find an end of line? */ - int crSeen; /* Did we see a "\r" in CRLF mode? */ - - *bytesQueuedPtr = 0; - bytesToEOL = 0; - EOLFound = 0; - for (bufPtr = chanPtr->inQueueHead, - crSeen = (chanPtr->flags & INPUT_SAW_CR) ? 1 : 0; - (!EOLFound) && (bufPtr != (ChannelBuffer *) NULL); - bufPtr = bufPtr->nextPtr) { - EOLFound = ScanBufferForEOL(chanPtr, bufPtr, chanPtr->inputTranslation, - chanPtr->inEofChar, &bytesToEOL, &crSeen); - } - - if (EOLFound == 0) { - *bytesQueuedPtr = bytesToEOL; - return -1; - } - return bytesToEOL; -} - -/* - *---------------------------------------------------------------------- - * - * GetEOL -- - * - * Accumulate input into the channel input buffer queue until an - * end of line has been seen. - * - * Results: - * Number of bytes buffered or -1 on failure. - * - * Side effects: - * Consumes input from the channel. - * - *---------------------------------------------------------------------- - */ - -static int -GetEOL( - Channel *chanPtr /* Channel to queue input on. */ -) -{ - int result; /* Of getting another buffer from the - * channel. */ - int bytesToEOL; /* How many bytes in buffer up to and - * including the end of line? */ - int bytesQueued; /* How many bytes are queued currently - * in the input chain of the channel? */ - - while (1) { - bytesToEOL = ScanInputForEOL(chanPtr, &bytesQueued); - if (bytesToEOL > 0) { - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - return bytesToEOL; - } - if (chanPtr->flags & CHANNEL_EOF) { - /* - * Boundary case where cr was at the end of the previous buffer - * and this buffer just has a newline. At EOF our caller wants - * to see -1 for the line length. - */ - return (bytesQueued == 0) ? -1 : bytesQueued ; - } - if (chanPtr->flags & CHANNEL_BLOCKED) { - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - return -1; - } - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - } - result = GetInput(chanPtr); - if (result != 0) { - if (result == EAGAIN) { - chanPtr->flags |= CHANNEL_BLOCKED; - } - return -1; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Read -- - * - * Reads a given number of characters from a channel. - * - * Results: - * The number of characters read, or -1 on error. Use Tcl_GetErrno() - * to retrieve the error code for the error that occurred. - * - * Side effects: - * May cause input to be buffered. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Read( - Tcl_Channel chan, /* The channel from which to read. */ - char *bufPtr, /* Where to store input read. */ - int toRead /* Maximum number of characters to read. */ -) -{ - Channel *chanPtr; /* The real IO channel. */ - int copied; /* How many characters were copied into - * the result string? */ - int copiedNow; /* How many characters were copied from - * the current input buffer? */ - int result; /* Of calling GetInput. */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return -1; - } - - /* - * Punt if the channel is not opened for reading. - */ - - if (!(chanPtr->flags & TCL_READABLE)) { - Tcl_SetErrno(EACCES); - return -1; - } - - /* - * If we have not encountered a sticky EOF, clear the EOF bit. Either - * way clear the BLOCKED bit. We want to discover these anew during - * each operation. - */ - - if (!(chanPtr->flags & CHANNEL_STICKY_EOF)) { - chanPtr->flags &= (~(CHANNEL_EOF)); - } - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - - for (copied = 0; copied < toRead; copied += copiedNow) { - copiedNow = CopyAndTranslateBuffer(chanPtr, bufPtr + copied, - toRead - copied); - if (copiedNow == 0) { - if (chanPtr->flags & CHANNEL_EOF) { - return copied; - } - if (chanPtr->flags & CHANNEL_BLOCKED) { - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - return copied; - } - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - } - result = GetInput(chanPtr); - if (result != 0) { - if (result == EAGAIN) { - return copied; - } - return -1; - } - } - } - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - return copied; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Gets -- - * - * Reads a complete line of input from the channel. - * - * Results: - * Length of line read or -1 if error, EOF or blocked. If -1, use - * Tcl_GetErrno() to retrieve the POSIX error code for the - * error or condition that occurred. - * - * Side effects: - * May flush output on the channel. May cause input to be - * consumed from the channel. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Gets( - Tcl_Channel chan, /* Channel from which to read. */ - Tcl_DString *lineRead /* The characters of the line read - * (excluding the terminating newline if - * present) will be appended to this - * DString. The caller must have initialized - * it and is responsible for managing the - * storage. */ -) -{ - Channel *chanPtr; /* The channel to read from. */ - char *buf; /* Points into DString where data - * will be stored. */ - int offset; /* Offset from start of DString at - * which to append the line just read. */ - int copiedTotal; /* Accumulates total length of input copied. */ - int copiedNow; /* How many bytes were copied from the - * current input buffer? */ - int lineLen; /* Length of line read, including the - * translated newline. If this is zero - * and neither EOF nor BLOCKED is set, - * the current line is empty. */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return -1; - } - - /* - * Punt if the channel is not opened for reading. - */ - - if (!(chanPtr->flags & TCL_READABLE)) { - Tcl_SetErrno(EACCES); - return -1; - } - - /* - * If we have not encountered a sticky EOF, clear the EOF bit - * (sticky EOF is set if we have seen the input eofChar, to prevent - * reading beyond the eofChar). Also, always clear the BLOCKED bit. - * We want to discover these conditions anew in each operation. - */ - - if (!(chanPtr->flags & CHANNEL_STICKY_EOF)) { - chanPtr->flags &= (~(CHANNEL_EOF)); - } - chanPtr->flags &= (~(CHANNEL_BLOCKED)); - lineLen = GetEOL(chanPtr); - if (lineLen < 0) { - return -1; - } - if (lineLen == 0) { - if (chanPtr->flags & (CHANNEL_EOF | CHANNEL_BLOCKED)) { - return -1; - } - return 0; - } - offset = Tcl_DStringLength(lineRead); - Tcl_DStringSetLength(lineRead, lineLen + offset); - buf = Tcl_DStringValue(lineRead) + offset; - - for (copiedTotal = 0; copiedTotal < lineLen; copiedTotal += copiedNow) { - copiedNow = CopyAndTranslateBuffer(chanPtr, buf + copiedTotal, - lineLen - copiedTotal); - } - if ((copiedTotal > 0) && (buf[copiedTotal - 1] == '\n')) { - copiedTotal--; - } - Tcl_DStringSetLength(lineRead, copiedTotal + offset); - return copiedTotal; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Seek -- - * - * Implements seeking on Tcl Channels. This is a public function - * so that other C facilities may be implemented on top of it. - * - * Results: - * The new access point or -1 on error. If error, use Tcl_GetErrno() - * to retrieve the POSIX error code for the error that occurred. - * - * Side effects: - * May flush output on the channel. May discard queued input. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Seek( - Tcl_Channel chan, /* The channel on which to seek. */ - int offset, /* Offset to seek to. */ - int mode /* Relative to which location to seek? */ -) -{ - Channel *chanPtr; /* The real IO channel. */ - ChannelBuffer *bufPtr; /* Iterates over queued input - * and output buffers. */ - int inputBuffered, outputBuffered; - int result; /* Of device driver operations. */ - int curPos; /* Position on the device. */ - int wasAsync; /* Was the channel nonblocking before the - * seek operation? If so, must restore to - * nonblocking mode after the seek. */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return -1; - } - - /* - * Disallow seek on channels that are open for neither writing nor - * reading (e.g. socket server channels). - */ - - if (!(chanPtr->flags & (TCL_WRITABLE|TCL_READABLE))) { - Tcl_SetErrno(EACCES); - return -1; - } - - /* - * Disallow seek on channels whose type does not have a seek procedure - * defined. This means that the channel does not support seeking. - */ - - if (chanPtr->typePtr->seekProc == (Tcl_DriverSeekProc *) NULL) { - Tcl_SetErrno(EINVAL); - return -1; - } - - /* - * Compute how much input and output is buffered. If both input and - * output is buffered, cannot compute the current position. - */ - - for (bufPtr = chanPtr->inQueueHead, inputBuffered = 0; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - inputBuffered += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - for (bufPtr = chanPtr->outQueueHead, outputBuffered = 0; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - outputBuffered += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - if ((chanPtr->curOutPtr != (ChannelBuffer *) NULL) && - (chanPtr->curOutPtr->nextAdded > chanPtr->curOutPtr->nextRemoved)) { - chanPtr->flags |= BUFFER_READY; - outputBuffered += - (chanPtr->curOutPtr->nextAdded - chanPtr->curOutPtr->nextRemoved); - } - if ((inputBuffered != 0) && (outputBuffered != 0)) { - Tcl_SetErrno(EFAULT); - return -1; - } - - /* - * If we are seeking relative to the current position, compute the - * corrected offset taking into account the amount of unread input. - */ - - if (mode == SEEK_CUR) { - offset -= inputBuffered; - } - - /* - * Discard any queued input - this input should not be read after - * the seek. - */ - - DiscardInputQueued(chanPtr, 0); - - /* - * Reset EOF and BLOCKED flags. We invalidate them by moving the - * access point. Also clear CR related flags. - */ - - chanPtr->flags &= - (~(CHANNEL_EOF | CHANNEL_STICKY_EOF | CHANNEL_BLOCKED | INPUT_SAW_CR)); - - /* - * If the channel is in asynchronous output mode, switch it back - * to synchronous mode and cancel any async flush that may be - * scheduled. After the flush, the channel will be put back into - * asynchronous output mode. - */ - - wasAsync = 0; - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - wasAsync = 1; - result = 0; - if (chanPtr->typePtr->blockModeProc != NULL) { - result = (chanPtr->typePtr->blockModeProc) (chanPtr->instanceData, - chanPtr->inFile, chanPtr->outFile, TCL_MODE_BLOCKING); - } - if (result != 0) { - Tcl_SetErrno(result); - return -1; - } - chanPtr->flags &= (~(CHANNEL_NONBLOCKING)); - if (chanPtr->flags & BG_FLUSH_SCHEDULED) { - Tcl_DeleteFileHandler(chanPtr->outFile); - chanPtr->flags &= (~(BG_FLUSH_SCHEDULED)); - } - } - - /* - * If the flush fails we cannot recover the original position. In - * that case the seek is not attempted because we do not know where - * the access position is - instead we return the error. FlushChannel - * has already called Tcl_SetErrno() to report the error upwards. - * If the flush succeeds we do the seek also. - */ - - if (FlushChannel(NULL, chanPtr, 0) != 0) { - curPos = -1; - } else { - - /* - * Now seek to the new position in the channel as requested by the - * caller. - */ - - curPos = (chanPtr->typePtr->seekProc) (chanPtr->instanceData, - chanPtr->inFile, chanPtr->outFile, (long) offset, - mode, &result); - if (curPos == -1) { - Tcl_SetErrno(result); - } - } - - /* - * Restore to nonblocking mode if that was the previous behavior. - * - * NOTE: Even if there was an async flush active we do not restore - * it now because we already flushed all the queued output, above. - */ - - if (wasAsync) { - chanPtr->flags |= CHANNEL_NONBLOCKING; - result = 0; - if (chanPtr->typePtr->blockModeProc != NULL) { - result = (chanPtr->typePtr->blockModeProc) (chanPtr->instanceData, - chanPtr->inFile, chanPtr->outFile, TCL_MODE_NONBLOCKING); - } - if (result != 0) { - Tcl_SetErrno(result); - return -1; - } - } - - return curPos; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Tell -- - * - * Returns the position of the next character to be read/written on - * this channel. - * - * Results: - * A nonnegative integer on success, -1 on failure. If failed, - * use Tcl_GetErrno() to retrieve the POSIX error code for the - * error that occurred. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Tell( - Tcl_Channel chan /* The channel to return pos for. */ -) -{ - Channel *chanPtr; /* The actual channel to tell on. */ - ChannelBuffer *bufPtr; /* Iterates over queued input - * and output buffers. */ - int inputBuffered, outputBuffered; - int result; /* Of calling device driver. */ - int curPos; /* Position on device. */ - - chanPtr = (Channel *) chan; - - /* - * Check for unreported error. - */ - - if (chanPtr->unreportedError != 0) { - Tcl_SetErrno(chanPtr->unreportedError); - chanPtr->unreportedError = 0; - return -1; - } - - /* - * Disallow tell on channels that are open for neither - * writing nor reading (e.g. socket server channels). - */ - - if (!(chanPtr->flags & (TCL_WRITABLE|TCL_READABLE))) { - Tcl_SetErrno(EACCES); - return -1; - } - - /* - * Disallow tell on channels whose type does not have a seek procedure - * defined. This means that the channel does not support seeking. - */ - - if (chanPtr->typePtr->seekProc == (Tcl_DriverSeekProc *) NULL) { - Tcl_SetErrno(EINVAL); - return -1; - } - - /* - * Compute how much input and output is buffered. If both input and - * output is buffered, cannot compute the current position. - */ - - for (bufPtr = chanPtr->inQueueHead, inputBuffered = 0; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - inputBuffered += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - for (bufPtr = chanPtr->outQueueHead, outputBuffered = 0; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - outputBuffered += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - if (chanPtr->curOutPtr != (ChannelBuffer *) NULL) { - outputBuffered += - (chanPtr->curOutPtr->nextAdded - chanPtr->curOutPtr->nextRemoved); - } - if ((inputBuffered != 0) && (outputBuffered != 0)) { - Tcl_SetErrno(EFAULT); - return -1; - } - - /* - * Get the current position in the device and compute the position - * where the next character will be read or written. - */ - - curPos = (chanPtr->typePtr->seekProc) (chanPtr->instanceData, - chanPtr->inFile, chanPtr->outFile, (long) 0, SEEK_CUR, &result); - if (curPos == -1) { - Tcl_SetErrno(result); - return -1; - } - if (inputBuffered != 0) { - return (curPos - inputBuffered); - } - return (curPos + outputBuffered); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Eof -- - * - * Returns 1 if the channel is at EOF, 0 otherwise. - * - * Results: - * 1 or 0, always. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Eof( - Tcl_Channel chan /* Does this channel have EOF? */ -) -{ - Channel *chanPtr; /* The real channel structure. */ - - chanPtr = (Channel *) chan; - return ((chanPtr->flags & CHANNEL_STICKY_EOF) || - ((chanPtr->flags & CHANNEL_EOF) && (Tcl_InputBuffered(chan) == 0))) - ? 1 : 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InputBlocked -- - * - * Returns 1 if input is blocked on this channel, 0 otherwise. - * - * Results: - * 0 or 1, always. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_InputBlocked( - Tcl_Channel chan /* Is this channel blocked? */ -) -{ - Channel *chanPtr; /* The real channel structure. */ - - chanPtr = (Channel *) chan; - return (chanPtr->flags & CHANNEL_BLOCKED) ? 1 : 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InputBuffered -- - * - * Returns the number of bytes of input currently buffered in the - * internal buffer of a channel. - * - * Results: - * The number of input bytes buffered, or zero if the channel is not - * open for reading. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_InputBuffered( - Tcl_Channel chan /* The channel to query. */ -) -{ - Channel *chanPtr; - int bytesBuffered; - ChannelBuffer *bufPtr; - - chanPtr = (Channel *) chan; - for (bytesBuffered = 0, bufPtr = chanPtr->inQueueHead; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - bytesBuffered += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - return bytesBuffered; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetChannelBufferSize -- - * - * Sets the size of buffers to allocate to store input or output - * in the channel. The size must be between 10 bytes and 1 MByte. - * - * Results: - * None. - * - * Side effects: - * Sets the size of buffers subsequently allocated for this channel. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetChannelBufferSize( - Tcl_Channel chan, /* The channel whose buffer size - * to set. */ - int sz /* The size to set. */ -) -{ - Channel *chanPtr; - - if (sz < 10) { - sz = CHANNELBUFFER_DEFAULT_SIZE; - } - - /* - * Allow only buffers that are smaller than one megabyte. - */ - - if (sz > (1024 * 1024)) { - sz = CHANNELBUFFER_DEFAULT_SIZE; - } - - chanPtr = (Channel *) chan; - chanPtr->bufSize = sz; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelBufferSize -- - * - * Retrieves the size of buffers to allocate for this channel. - * - * Results: - * The size. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetChannelBufferSize( - Tcl_Channel chan /* The channel for which to find the - * buffer size. */ -) -{ - Channel *chanPtr; - - chanPtr = (Channel *) chan; - return chanPtr->bufSize; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetChannelOption -- - * - * Gets a mode associated with an IO channel. If the optionName arg - * is non NULL, retrieves the value of that option. If the optionName - * arg is NULL, retrieves a list of alternating option names and - * values for the given channel. - * - * Results: - * A standard Tcl result. Also sets the supplied DString to the - * string value of the option(s) returned. - * - * Side effects: - * The string returned by this function is in static storage and - * may be reused at any time subsequent to the call. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetChannelOption( - Tcl_Channel chan, /* Channel on which to get option. */ - char *optionName, /* Option to get. */ - Tcl_DString *dsPtr /* Where to store value(s). */ -) -{ - Channel *chanPtr; /* The real IO channel. */ - size_t len; /* Length of optionName string. */ - - chanPtr = (Channel *) chan; - - /* - * If the optionName is NULL it means that we want a list of all - * options and values. - */ - - if (optionName == (char *) NULL) { - len = 0; - } else { - len = strlen(optionName); - } - - if ((len == 0) || ((len > 2) && (optionName[1] == 'b') && - (strncmp(optionName, "-blocking", len) == 0))) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-blocking"); - } - Tcl_DStringAppendElement(dsPtr, - (chanPtr->flags & CHANNEL_NONBLOCKING) ? "0" : "1"); - if (len > 0) { - return TCL_OK; - } - } - if ((len == 0) || ((len > 7) && (optionName[1] == 'b') && - (strncmp(optionName, "-buffering", len) == 0))) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-buffering"); - } - if (chanPtr->flags & CHANNEL_LINEBUFFERED) { - Tcl_DStringAppendElement(dsPtr, "line"); - } else if (chanPtr->flags & CHANNEL_UNBUFFERED) { - Tcl_DStringAppendElement(dsPtr, "none"); - } else { - Tcl_DStringAppendElement(dsPtr, "full"); - } - if (len > 0) { - return TCL_OK; - } - } - if ((len == 0) || ((len > 7) && (optionName[1] == 'b') && - (strncmp(optionName, "-buffersize", len) == 0))) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-buffersize"); - } - sprintf(optionVal, "%d", chanPtr->bufSize); - Tcl_DStringAppendElement(dsPtr, optionVal); - if (len > 0) { - return TCL_OK; - } - } - if ((len == 0) || - ((len > 1) && (optionName[1] == 'e') && - (strncmp(optionName, "-eofchar", len) == 0))) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-eofchar"); - } - if ((chanPtr->flags & (TCL_READABLE|TCL_WRITABLE)) == - (TCL_READABLE|TCL_WRITABLE)) { - Tcl_DStringStartSublist(dsPtr); - } - if (chanPtr->flags & TCL_READABLE) { - if (chanPtr->inEofChar == 0) { - Tcl_DStringAppendElement(dsPtr, ""); - } else { - char buf[4]; - - sprintf(buf, "%c", chanPtr->inEofChar); - Tcl_DStringAppendElement(dsPtr, buf); - } - } - if (chanPtr->flags & TCL_WRITABLE) { - if (chanPtr->outEofChar == 0) { - Tcl_DStringAppendElement(dsPtr, ""); - } else { - char buf[4]; - - sprintf(buf, "%c", chanPtr->outEofChar); - Tcl_DStringAppendElement(dsPtr, buf); - } - } - if ((chanPtr->flags & (TCL_READABLE|TCL_WRITABLE)) == - (TCL_READABLE|TCL_WRITABLE)) { - Tcl_DStringEndSublist(dsPtr); - } - if (len > 0) { - return TCL_OK; - } - } - if ((len == 0) || - ((len > 1) && (optionName[1] == 't') && - (strncmp(optionName, "-translation", len) == 0))) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-translation"); - } - if ((chanPtr->flags & (TCL_READABLE|TCL_WRITABLE)) == - (TCL_READABLE|TCL_WRITABLE)) { - Tcl_DStringStartSublist(dsPtr); - } - if (chanPtr->flags & TCL_READABLE) { - if (chanPtr->inputTranslation == TCL_TRANSLATE_AUTO) { - Tcl_DStringAppendElement(dsPtr, "auto"); - } else if (chanPtr->inputTranslation == TCL_TRANSLATE_CR) { - Tcl_DStringAppendElement(dsPtr, "cr"); - } else if (chanPtr->inputTranslation == TCL_TRANSLATE_CRLF) { - Tcl_DStringAppendElement(dsPtr, "crlf"); - } else { - Tcl_DStringAppendElement(dsPtr, "lf"); - } - } - if (chanPtr->flags & TCL_WRITABLE) { - if (chanPtr->outputTranslation == TCL_TRANSLATE_AUTO) { - Tcl_DStringAppendElement(dsPtr, "auto"); - } else if (chanPtr->outputTranslation == TCL_TRANSLATE_CR) { - Tcl_DStringAppendElement(dsPtr, "cr"); - } else if (chanPtr->outputTranslation == TCL_TRANSLATE_CRLF) { - Tcl_DStringAppendElement(dsPtr, "crlf"); - } else { - Tcl_DStringAppendElement(dsPtr, "lf"); - } - } - if ((chanPtr->flags & (TCL_READABLE|TCL_WRITABLE)) == - (TCL_READABLE|TCL_WRITABLE)) { - Tcl_DStringEndSublist(dsPtr); - } - if (len > 0) { - return TCL_OK; - } - } - if (chanPtr->typePtr->getOptionProc != (Tcl_DriverGetOptionProc *) NULL) { - return (chanPtr->typePtr->getOptionProc) (chanPtr->instanceData, - optionName, dsPtr); - } - if (len == 0) { - return TCL_OK; - } - Tcl_SetErrno(EINVAL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetChannelOption -- - * - * Sets an option on a channel. - * - * Results: - * A standard Tcl result. Also sets interp->result on error if - * interp is not NULL. - * - * Side effects: - * May modify an option on a device. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_SetChannelOption( - Tcl_Interp *interp, /* For error reporting - can be NULL. */ - Tcl_Channel chan, /* Channel on which to set mode. */ - char *optionName, /* Which option to set? */ - char *newValue /* New value for option. */ -) -{ - int result; /* Result of channel type operation. */ - int newMode; /* New (numeric) mode to sert. */ - Channel *chanPtr; /* The real IO channel. */ - size_t len; /* Length of optionName string. */ - int argc; - char **argv; - - chanPtr = (Channel *) chan; - - len = strlen(optionName); - - if ((len > 2) && (optionName[1] == 'b') && - (strncmp(optionName, "-blocking", len) == 0)) { - if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) { - return TCL_ERROR; - } - if (newMode) { - newMode = TCL_MODE_BLOCKING; - } else { - newMode = TCL_MODE_NONBLOCKING; - } - result = 0; - if (chanPtr->typePtr->blockModeProc != NULL) { - result = (chanPtr->typePtr->blockModeProc) (chanPtr->instanceData, - chanPtr->inFile, chanPtr->outFile, newMode); - } - if (result != 0) { - Tcl_SetErrno(result); - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "error setting blocking mode: ", - Tcl_PosixError(interp), (char *) NULL); - } - return TCL_ERROR; - } - if (newMode == TCL_MODE_BLOCKING) { - chanPtr->flags &= (~(CHANNEL_NONBLOCKING)); - if (chanPtr->outFile != (Tcl_File) NULL) { - Tcl_DeleteFileHandler(chanPtr->outFile); - chanPtr->flags &= (~(BG_FLUSH_SCHEDULED)); - } - } else { - chanPtr->flags |= CHANNEL_NONBLOCKING; - } - return TCL_OK; - } - - if ((len > 7) && (optionName[1] == 'b') && - (strncmp(optionName, "-buffering", len) == 0)) { - len = strlen(newValue); - if ((newValue[0] == 'f') && (strncmp(newValue, "full", len) == 0)) { - chanPtr->flags &= - (~(CHANNEL_UNBUFFERED|CHANNEL_LINEBUFFERED)); - } else if ((newValue[0] == 'l') && - (strncmp(newValue, "line", len) == 0)) { - chanPtr->flags &= (~(CHANNEL_UNBUFFERED)); - chanPtr->flags |= CHANNEL_LINEBUFFERED; - } else if ((newValue[0] == 'n') && - (strncmp(newValue, "none", len) == 0)) { - chanPtr->flags &= (~(CHANNEL_LINEBUFFERED)); - chanPtr->flags |= CHANNEL_UNBUFFERED; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "bad value for -buffering: ", - "must be one of full, line, or none", - (char *) NULL); - return TCL_ERROR; - } - } - return TCL_OK; - } - - if ((len > 7) && (optionName[1] == 'b') && - (strncmp(optionName, "-buffersize", len) == 0)) { - chanPtr->bufSize = atoi(newValue); - if ((chanPtr->bufSize < 10) || (chanPtr->bufSize > (1024 * 1024))) { - chanPtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE; - } - return TCL_OK; - } - - if ((len > 1) && (optionName[1] == 'e') && - (strncmp(optionName, "-eofchar", len) == 0)) { - if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) { - return TCL_ERROR; - } - if (argc == 0) { - chanPtr->inEofChar = 0; - chanPtr->outEofChar = 0; - } else if (argc == 1) { - if (chanPtr->flags & TCL_WRITABLE) { - chanPtr->outEofChar = (int) argv[0][0]; - } - if (chanPtr->flags & TCL_READABLE) { - chanPtr->inEofChar = (int) argv[0][0]; - } - } else if (argc != 2) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -eofchar: should be a list of one or", - " two elements", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } else { - if (chanPtr->flags & TCL_READABLE) { - chanPtr->inEofChar = (int) argv[0][0]; - } - if (chanPtr->flags & TCL_WRITABLE) { - chanPtr->outEofChar = (int) argv[1][0]; - } - } - if (argv != (char **) NULL) { - ckfree((char *) argv); - } - return TCL_OK; - } - - if ((len > 1) && (optionName[1] == 't') && - (strncmp(optionName, "-translation", len) == 0)) { - if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) { - return TCL_ERROR; - } - if (argc == 1) { - if (chanPtr->flags & TCL_READABLE) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - if (strcmp(argv[0], "auto") == 0) { - chanPtr->inputTranslation = TCL_TRANSLATE_AUTO; - } else if (strcmp(argv[0], "binary") == 0) { - chanPtr->inEofChar = 0; - chanPtr->inputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "lf") == 0) { - chanPtr->inputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "cr") == 0) { - chanPtr->inputTranslation = TCL_TRANSLATE_CR; - } else if (strcmp(argv[0], "crlf") == 0) { - chanPtr->inputTranslation = TCL_TRANSLATE_CRLF; - } else if (strcmp(argv[0], "platform") == 0) { - chanPtr->inputTranslation = TCL_PLATFORM_TRANSLATION; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -translation: ", - "must be one of auto, binary, cr, lf, crlf,", - " or platform", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } - } - if (chanPtr->flags & TCL_WRITABLE) { - if (strcmp(argv[0], "auto") == 0) { - /* - * This is a hack to get TCP sockets to produce output - * in CRLF mode if they are being set into AUTO mode. - * A better solution for achieving this effect will be - * coded later. - */ - - if (strcmp(chanPtr->typePtr->typeName, "tcp") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CRLF; - } else { - chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION; - } - } else if (strcmp(argv[0], "binary") == 0) { - chanPtr->outEofChar = 0; - chanPtr->outputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "lf") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "cr") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CR; - } else if (strcmp(argv[0], "crlf") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CRLF; - } else if (strcmp(argv[0], "platform") == 0) { - chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -translation: ", - "must be one of auto, binary, cr, lf, crlf,", - " or platform", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } - } - } else if (argc != 2) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -translation: must be a one or two", - " element list", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } else { - if (chanPtr->flags & TCL_READABLE) { - if (argv[0][0] == '\0') { - /* Empty body. */ - } else if (strcmp(argv[0], "auto") == 0) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_TRANSLATE_AUTO; - } else if (strcmp(argv[0], "binary") == 0) { - chanPtr->inEofChar = 0; - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "lf") == 0) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[0], "cr") == 0) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_TRANSLATE_CR; - } else if (strcmp(argv[0], "crlf") == 0) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_TRANSLATE_CRLF; - } else if (strcmp(argv[0], "platform") == 0) { - chanPtr->flags &= (~(INPUT_SAW_CR)); - chanPtr->inputTranslation = TCL_PLATFORM_TRANSLATION; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -translation: ", - "must be one of auto, binary, cr, lf, crlf,", - " or platform", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } - } - if (chanPtr->flags & TCL_WRITABLE) { - if (argv[1][0] == '\0') { - /* Empty body. */ - } else if (strcmp(argv[1], "auto") == 0) { - /* - * This is a hack to get TCP sockets to produce output - * in CRLF mode if they are being set into AUTO mode. - * A better solution for achieving this effect will be - * coded later. - */ - - if (strcmp(chanPtr->typePtr->typeName, "tcp") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CRLF; - } else { - chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION; - } - } else if (strcmp(argv[1], "binary") == 0) { - chanPtr->outEofChar = 0; - chanPtr->outputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[1], "lf") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_LF; - } else if (strcmp(argv[1], "cr") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CR; - } else if (strcmp(argv[1], "crlf") == 0) { - chanPtr->outputTranslation = TCL_TRANSLATE_CRLF; - } else if (strcmp(argv[1], "platform") == 0) { - chanPtr->outputTranslation = TCL_PLATFORM_TRANSLATION; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "bad value for -translation: ", - "must be one of auto, binary, cr, lf, crlf,", - " or platform", (char *) NULL); - } - ckfree((char *) argv); - return TCL_ERROR; - } - } - } - ckfree((char *) argv); - return TCL_OK; - } - - if (chanPtr->typePtr->setOptionProc != (Tcl_DriverSetOptionProc *) NULL) { - return (chanPtr->typePtr->setOptionProc) (chanPtr->instanceData, - interp, optionName, newValue); - } - - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "bad option \"", optionName, - "\": should be -blocking, -buffering, -buffersize, ", - "-eofchar, -translation, ", - "or channel type specific option", - (char *) NULL); - } - - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * ChannelEventSourceExitProc -- - * - * This procedure is called during exit cleanup to delete the channel - * event source. It deletes the event source for channels. - * - * Results: - * None. - * - * Side effects: - * Destroys the channel event source. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -ChannelEventSourceExitProc( - ClientData clientData /* Not used. */ -) -{ - Tcl_DeleteEventSource(ChannelHandlerSetupProc, ChannelHandlerCheckProc, - (ClientData) NULL); - channelEventSourceCreated = 0; -} - -/* - *---------------------------------------------------------------------- - * - * ChannelHandlerSetupProc -- - * - * This procedure is part of the event source for channel handlers. - * It is invoked by Tcl_DoOneEvent before it waits for events. The - * job of this procedure is to provide information to Tcl_DoOneEvent - * on how to wait for events (what files to watch). - * - * Results: - * None. - * - * Side effects: - * Tells the notifier what channels to watch. - * - *---------------------------------------------------------------------- - */ - -static void -ChannelHandlerSetupProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_FILE_EVENTS then we do - * nothing. */ -) -{ - Tcl_Time dontBlock; - Channel *chanPtr, *nextChanPtr; - - if (!(flags & TCL_FILE_EVENTS)) { - return; - } - - dontBlock.sec = 0; dontBlock.usec = 0; - - for (chanPtr = firstChanPtr; chanPtr != (Channel *) NULL; - chanPtr = nextChanPtr) { - nextChanPtr = chanPtr->nextChanPtr; - if (chanPtr->interestMask & TCL_READABLE) { - if ((!(chanPtr->flags & CHANNEL_BLOCKED)) && - (chanPtr->inQueueHead != (ChannelBuffer *) NULL) && - (chanPtr->inQueueHead->nextRemoved < - chanPtr->inQueueHead->nextAdded)) { - Tcl_SetMaxBlockTime(&dontBlock); - } else if (chanPtr->inFile != (Tcl_File) NULL) { - Tcl_WatchFile(chanPtr->inFile, TCL_READABLE); - } - } - if (chanPtr->interestMask & TCL_WRITABLE) { - if (chanPtr->outFile != (Tcl_File) NULL) { - Tcl_WatchFile(chanPtr->outFile, TCL_WRITABLE); - } - } - if (chanPtr->interestMask & TCL_EXCEPTION) { - if (chanPtr->inFile != (Tcl_File) NULL) { - Tcl_WatchFile(chanPtr->inFile, TCL_EXCEPTION); - } - if (chanPtr->outFile != (Tcl_File) NULL) { - Tcl_WatchFile(chanPtr->outFile, TCL_EXCEPTION); - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * ChannelHandlerCheckProc -- - * - * This procedure is the second part (of three) of the event source - * for channels. It is invoked by Tcl_DoOneEvent after the wait for - * events is over. The job of this procedure is to test each channel - * to see if it is ready now, and if so, to create events and put them - * on the Tcl event queue. - * - * Results: - * None. - * - * Side effects: - * Makes entries on the Tcl event queue for each channel that is - * ready now. - * - *---------------------------------------------------------------------- - */ - -static void -ChannelHandlerCheckProc( - ClientData clientData, /* Not used. */ - int flags /* Flags passed to Tk_DoOneEvent: - * if it doesn't include - * TCL_FILE_EVENTS then we do - * nothing. */ -) -{ - Channel *chanPtr, *nextChanPtr; - ChannelHandlerEvent *ePtr; - int readyMask; - - if (!(flags & TCL_FILE_EVENTS)) { - return; - } - - for (chanPtr = firstChanPtr; - chanPtr != (Channel *) NULL; - chanPtr = nextChanPtr) { - nextChanPtr = chanPtr->nextChanPtr; - - readyMask = 0; - - /* - * Check for readability. - */ - - if (chanPtr->interestMask & TCL_READABLE) { - - /* - * The channel is considered ready for reading if there is input - * buffered AND the last attempt to read from the channel did not - * return EWOULDBLOCK, OR if the underlying file is ready. - * - * NOTE that the input queue may contain empty buffers, hence the - * special check to see if the first input buffer is empty. The - * invariant is that if there is an empty buffer in the queue - * there is only one buffer in the queue, hence an empty first - * buffer indicates that there is no input queued. - */ - - if ((!(chanPtr->flags & CHANNEL_BLOCKED)) && - ((chanPtr->inQueueHead != (ChannelBuffer *) NULL) && - (chanPtr->inQueueHead->nextRemoved < - chanPtr->inQueueHead->nextAdded))) { - readyMask |= TCL_READABLE; - } else if (chanPtr->inFile != (Tcl_File) NULL) { - readyMask |= - Tcl_FileReady(chanPtr->inFile, TCL_READABLE); - } - } - - /* - * Check for writability. - */ - - if (chanPtr->interestMask & TCL_WRITABLE) { - - /* - * The channel is considered ready for writing if there is no - * output buffered waiting to be written to the device, AND the - * underlying file is ready. - */ - - if ((chanPtr->outQueueHead == (ChannelBuffer *) NULL) && - (chanPtr->outFile != (Tcl_File) NULL)) { - readyMask |= - Tcl_FileReady(chanPtr->outFile, TCL_WRITABLE); - } - } - - /* - * Check for exceptions. - */ - - if (chanPtr->interestMask & TCL_EXCEPTION) { - if (chanPtr->inFile != (Tcl_File) NULL) { - readyMask |= - Tcl_FileReady(chanPtr->inFile, TCL_EXCEPTION); - } - if (chanPtr->outFile != (Tcl_File) NULL) { - readyMask |= - Tcl_FileReady(chanPtr->outFile, TCL_EXCEPTION); - } - } - - /* - * If there are any events for this channel, put a notice into the - * Tcl event queue. - */ - - if (readyMask != 0) { - ePtr = (ChannelHandlerEvent *) ckalloc((unsigned) - sizeof(ChannelHandlerEvent)); - ePtr->header.proc = ChannelHandlerEventProc; - ePtr->chanPtr = chanPtr; - ePtr->readyMask = readyMask; - Tcl_QueueEvent((Tcl_Event *) ePtr, TCL_QUEUE_TAIL); - } - } -} - -/* - *---------------------------------------------------------------------- - * - * FlushEventProc -- - * - * This routine dispatches a background flush event. - * - * Errors that occur during the write operation are stored - * inside the channel structure for future reporting by the next - * operation that uses this channel. - * - * Results: - * None. - * - * Side effects: - * Causes production of output on a channel. - * - *---------------------------------------------------------------------- - */ - -static void -FlushEventProc( - ClientData clientData, /* Channel to produce output on. */ - int mask /* Not used. */ -) -{ - (void) FlushChannel(NULL, (Channel *) clientData, 1); -} - -/* - *---------------------------------------------------------------------- - * - * ChannelHandlerEventProc -- - * - * This procedure is called by Tcl_DoOneEvent when a channel event - * reaches the front of the event queue. This procedure is responsible - * for actually handling the event by invoking the callback for the - * channel handler. - * - * Results: - * Returns 1 if the event was handled, meaning that it should be - * removed from the queue. Returns 0 if the event was not handled - * meaning that it should stay in the queue. The only time the event - * will not be handled is if the TCL_FILE_EVENTS flag bit is not - * set in the flags passed. - * - * NOTE: If the handler is deleted between the time the event is added - * to the queue and the time it reaches the head of the queue, the - * event is silently discarded (i.e. we return 1). - * - * Side effects: - * Whatever the channel handler callback procedure does. - * - *---------------------------------------------------------------------- - */ - -static int -ChannelHandlerEventProc( - Tcl_Event *evPtr, /* Event to service. */ - int flags /* Flags that indicate what events to - * handle, such as TCL_FILE_EVENTS. */ -) -{ - Channel *chanPtr; - ChannelHandler *chPtr; - ChannelHandlerEvent *ePtr; - NextChannelHandler nh; - - if (!(flags & TCL_FILE_EVENTS)) { - return 0; - } - - ePtr = (ChannelHandlerEvent *) evPtr; - chanPtr = ePtr->chanPtr; - - /* - * Add this invocation to the list of recursive invocations of - * ChannelHandlerEventProc. - */ - - nh.nextHandlerPtr = (ChannelHandler *) NULL; - nh.nestedHandlerPtr = nestedHandlerPtr; - nestedHandlerPtr = &nh; - - for (chPtr = chanPtr->chPtr; chPtr != (ChannelHandler *) NULL; ) { - - /* - * If this channel handler is interested in any of the events that - * have occurred on the channel, invoke its procedure. - */ - - if ((chPtr->mask & ePtr->readyMask) != 0) { - nh.nextHandlerPtr = chPtr->nextPtr; - (*(chPtr->proc))(chPtr->clientData, ePtr->readyMask); - chPtr = nh.nextHandlerPtr; - } else { - chPtr = chPtr->nextPtr; - } - } - - nestedHandlerPtr = nh.nestedHandlerPtr; - - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateChannelHandler -- - * - * Arrange for a given procedure to be invoked whenever the - * channel indicated by the chanPtr arg becomes readable or - * writable. - * - * Results: - * None. - * - * Side effects: - * From now on, whenever the I/O channel given by chanPtr becomes - * ready in the way indicated by mask, proc will be invoked. - * See the manual entry for details on the calling sequence - * to proc. If there is already an event handler for chan, proc - * and clientData, then the mask will be updated. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CreateChannelHandler( - Tcl_Channel chan, /* The channel to create the handler for. */ - int mask, /* OR'ed combination of TCL_READABLE, - * TCL_WRITABLE, and TCL_EXCEPTION: - * indicates conditions under which - * proc should be called. Use 0 to - * disable a registered handler. */ - Tcl_ChannelProc *proc, /* Procedure to call for each - * selected event. */ - ClientData clientData /* Arbitrary data to pass to proc. */ -) -{ - ChannelHandler *chPtr; - Channel *chanPtr; - - chanPtr = (Channel *) chan; - - /* - * Ensure that the channel event source is registered with the Tcl - * notification mechanism. - */ - - if (!channelEventSourceCreated) { - channelEventSourceCreated = 1; - Tcl_CreateEventSource(ChannelHandlerSetupProc, ChannelHandlerCheckProc, - (ClientData) NULL); - Tcl_CreateExitHandler(ChannelEventSourceExitProc, (ClientData) NULL); - } - - /* - * Check whether this channel handler is not already registered. If - * it is not, create a new record, else reuse existing record (smash - * current values). - */ - - for (chPtr = chanPtr->chPtr; - chPtr != (ChannelHandler *) NULL; - chPtr = chPtr->nextPtr) { - if ((chPtr->chanPtr == chanPtr) && (chPtr->proc == proc) && - (chPtr->clientData == clientData)) { - break; - } - } - if (chPtr == (ChannelHandler *) NULL) { - chPtr = (ChannelHandler *) ckalloc((unsigned) sizeof(ChannelHandler)); - chPtr->mask = 0; - chPtr->proc = proc; - chPtr->clientData = clientData; - chPtr->chanPtr = chanPtr; - chPtr->nextPtr = chanPtr->chPtr; - chanPtr->chPtr = chPtr; - } - - /* - * The remainder of the initialization below is done regardless of - * whether or not this is a new record or a modification of an old - * one. - */ - - chPtr->mask = mask; - - /* - * Recompute the interest mask for the channel - this call may actually - * be disabling an existing handler.. - */ - - chanPtr->interestMask = 0; - for (chPtr = chanPtr->chPtr; - chPtr != (ChannelHandler *) NULL; - chPtr = chPtr->nextPtr) { - chanPtr->interestMask |= chPtr->mask; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteChannelHandler -- - * - * Cancel a previously arranged callback arrangement for an IO - * channel. - * - * Results: - * None. - * - * Side effects: - * If a callback was previously registered for this chan, proc and - * clientData , it is removed and the callback will no longer be called - * when the channel becomes ready for IO. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteChannelHandler( - Tcl_Channel chan, /* The channel for which to remove the - * callback. */ - Tcl_ChannelProc *proc, /* The procedure in the callback to delete. */ - ClientData clientData /* The client data in the callback - * to delete. */ -) -{ - ChannelHandler *chPtr, *prevChPtr; - Channel *chanPtr; - NextChannelHandler *nhPtr; - - chanPtr = (Channel *) chan; - - /* - * Find the entry and the previous one in the list. - */ - - for (prevChPtr = (ChannelHandler *) NULL, chPtr = chanPtr->chPtr; - chPtr != (ChannelHandler *) NULL; - chPtr = chPtr->nextPtr) { - if ((chPtr->chanPtr == chanPtr) && (chPtr->clientData == clientData) - && (chPtr->proc == proc)) { - break; - } - prevChPtr = chPtr; - } - - /* - * If ChannelHandlerEventProc is about to process this handler, tell it to - * process the next one instead - we are going to delete *this* one. - */ - - for (nhPtr = nestedHandlerPtr; - nhPtr != (NextChannelHandler *) NULL; - nhPtr = nhPtr->nestedHandlerPtr) { - if (nhPtr->nextHandlerPtr == chPtr) { - nhPtr->nextHandlerPtr = chPtr->nextPtr; - } - } - - /* - * If found, splice the entry out of the list. - */ - - if (chPtr == (ChannelHandler *) NULL) { - return; - } - - if (prevChPtr == (ChannelHandler *) NULL) { - chanPtr->chPtr = chPtr->nextPtr; - } else { - prevChPtr->nextPtr = chPtr->nextPtr; - } - ckfree((char *) chPtr); - - /* - * Recompute the interest list for the channel, so that infinite loops - * will not result if Tcl_DeleteChanelHandler is called inside an event. - */ - - chanPtr->interestMask = 0; - for (chPtr = chanPtr->chPtr; - chPtr != (ChannelHandler *) NULL; - chPtr = chPtr->nextPtr) { - chanPtr->interestMask |= chPtr->mask; - } -} - -/* - *---------------------------------------------------------------------- - * - * ReturnScriptRecord -- - * - * Get a script stored for this channel with this interpreter. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Sets interp->result to the script. - * - *---------------------------------------------------------------------- - */ - -static void -ReturnScriptRecord( - Tcl_Interp *interp, /* The interpreter in which the script - * is to be executed. */ - Channel *chanPtr, /* The channel for which the script is - * stored. */ - int mask /* Events in mask must overlap with events - * for which this script is stored. */ -) -{ - EventScriptRecord *esPtr; - - for (esPtr = chanPtr->scriptRecordPtr; - esPtr != (EventScriptRecord *) NULL; - esPtr = esPtr->nextPtr) { - if ((esPtr->interp == interp) && (esPtr->mask == mask)) { - interp->result = esPtr->script; - return; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * DeleteScriptRecord -- - * - * Delete a script record for this combination of channel, interp - * and mask. - * - * Results: - * None. - * - * Side effects: - * Deletes a script record and cancels a channel event handler. - * - *---------------------------------------------------------------------- - */ - -static void -DeleteScriptRecord( - Tcl_Interp *interp, /* Interpreter in which script was to be - * executed. */ - Channel *chanPtr, /* The channel for which to delete the - * script record (if any). */ - int mask /* Events in mask must exactly match mask - * of script to delete. */ -) -{ - EventScriptRecord *esPtr, *prevEsPtr; - - for (esPtr = chanPtr->scriptRecordPtr, - prevEsPtr = (EventScriptRecord *) NULL; - esPtr != (EventScriptRecord *) NULL; - prevEsPtr = esPtr, esPtr = esPtr->nextPtr) { - if ((esPtr->interp == interp) && (esPtr->mask == mask)) { - if (esPtr == chanPtr->scriptRecordPtr) { - chanPtr->scriptRecordPtr = esPtr->nextPtr; - } else { - prevEsPtr->nextPtr = esPtr->nextPtr; - } - - Tcl_DeleteChannelHandler((Tcl_Channel) chanPtr, - ChannelEventScriptInvoker, (ClientData) esPtr); - - Tcl_EventuallyFree((ClientData)esPtr->script, TCL_DYNAMIC); - ckfree((char *) esPtr); - - break; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * CreateScriptRecord -- - * - * Creates a record to store a script to be executed when a specific - * event fires on a specific channel. - * - * Results: - * None. - * - * Side effects: - * Causes the script to be stored for later execution. - * - *---------------------------------------------------------------------- - */ - -static void -CreateScriptRecord( - Tcl_Interp *interp, /* Interpreter in which to execute - * the stored script. */ - Channel *chanPtr, /* Channel for which script is to - * be stored. */ - int mask, /* Set of events for which script - * will be invoked. */ - char *script /* A copy of this script is stored - * in the newly created record. */ -) -{ - EventScriptRecord *esPtr; - - for (esPtr = chanPtr->scriptRecordPtr; - esPtr != (EventScriptRecord *) NULL; - esPtr = esPtr->nextPtr) { - if ((esPtr->interp == interp) && (esPtr->mask == mask)) { - Tcl_EventuallyFree((ClientData)esPtr->script, TCL_DYNAMIC); - esPtr->script = (char *) NULL; - break; - } - } - if (esPtr == (EventScriptRecord *) NULL) { - esPtr = (EventScriptRecord *) ckalloc((unsigned) - sizeof(EventScriptRecord)); - Tcl_CreateChannelHandler((Tcl_Channel) chanPtr, mask, - ChannelEventScriptInvoker, (ClientData) esPtr); - esPtr->nextPtr = chanPtr->scriptRecordPtr; - chanPtr->scriptRecordPtr = esPtr; - } - esPtr->chanPtr = chanPtr; - esPtr->interp = interp; - esPtr->mask = mask; - esPtr->script = ckalloc((unsigned) (strlen(script) + 1)); - strcpy(esPtr->script, script); -} - -/* - *---------------------------------------------------------------------- - * - * ChannelEventScriptInvoker -- - * - * Invokes a script scheduled by "fileevent" for when the channel - * becomes ready for IO. This function is invoked by the channel - * handler which was created by the Tcl "fileevent" command. - * - * Results: - * None. - * - * Side effects: - * Whatever the script does. - * - *---------------------------------------------------------------------- - */ - -static void -ChannelEventScriptInvoker( - ClientData clientData, /* The script+interp record. */ - int mask /* Not used. */ -) -{ - Tcl_Interp *interp; /* Interpreter in which to eval the script. */ - Channel *chanPtr; /* The channel for which this handler is - * registered. */ - char *script; /* Script to eval. */ - EventScriptRecord *esPtr; /* The event script + interpreter to eval it - * in. */ - int result; /* Result of call to eval script. */ - - esPtr = (EventScriptRecord *) clientData; - - chanPtr = esPtr->chanPtr; - mask = esPtr->mask; - interp = esPtr->interp; - script = esPtr->script; - - /* - * We must preserve the channel, script and interpreter because each of - * these may be deleted in the evaluation. If an error later occurs, we - * want to have the relevant data around for error reporting and so we - * can safely delete it. - */ - - Tcl_Preserve((ClientData) chanPtr); - Tcl_Preserve((ClientData) script); - Tcl_Preserve((ClientData) interp); - result = Tcl_GlobalEval(esPtr->interp, script); - - /* - * On error, cause a background error and remove the channel handler - * and the script record. - */ - - if (result != TCL_OK) { - Tcl_BackgroundError(interp); - DeleteScriptRecord(interp, chanPtr, mask); - } - Tcl_Release((ClientData) chanPtr); - Tcl_Release((ClientData) script); - Tcl_Release((ClientData) interp); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FileEventCmd -- - * - * This procedure implements the "fileevent" Tcl command. See the - * user documentation for details on what it does. This command is - * based on the Tk command "fileevent" which in turn is based on work - * contributed by Mark Diekhans. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May create a channel handler for the specified channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FileEventCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter in which the channel - * for which to create the handler - * is found. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Channel *chanPtr; /* The channel to create - * the handler for. */ - Tcl_Channel chan; /* The opaque type for the channel. */ - int c; /* First char of mode argument. */ - int mask; /* Mask for events of interest. */ - size_t length; /* Length of mode argument. */ - - /* - * Parse arguments. - */ - - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: must be \"", argv[0], - " channelId event ?script?", (char *) NULL); - return TCL_ERROR; - } - c = argv[2][0]; - length = strlen(argv[2]); - if ((c == 'r') && (strncmp(argv[2], "readable", length) == 0)) { - mask = TCL_READABLE; - } else if ((c == 'w') && (strncmp(argv[2], "writable", length) == 0)) { - mask = TCL_WRITABLE; - } else { - Tcl_AppendResult(interp, "bad event name \"", argv[2], - "\": must be readable or writable", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - - chanPtr = (Channel *) chan; - if ((chanPtr->flags & mask) == 0) { - Tcl_AppendResult(interp, "channel is not ", - (mask == TCL_READABLE) ? "readable" : "writable", - (char *) NULL); - return TCL_ERROR; - } - - /* - * If we are supposed to return the script, do so. - */ - - if (argc == 3) { - ReturnScriptRecord(interp, chanPtr, mask); - return TCL_OK; - } - - /* - * If we are supposed to delete a stored script, do so. - */ - - if (argv[3][0] == 0) { - DeleteScriptRecord(interp, chanPtr, mask); - return TCL_OK; - } - - /* - * Make the script record that will link between the event and the - * script to invoke. This also creates a channel event handler which - * will evaluate the script in the supplied interpreter. - */ - - CreateScriptRecord(interp, chanPtr, mask, argv[3]); - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclTestChannelCmd -- - * - * Implements the Tcl "testchannel" debugging command and its - * subcommands. This is part of the testing environment but must be - * in this file instead of tclTest.c because it needs access to the - * fields of struct Channel. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -TclTestChannelCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter for result. */ - int argc, /* Count of additional args. */ - char **argv /* Additional arg strings. */ -) -{ - char *cmdName; /* Sub command. */ - Tcl_HashTable *hTblPtr; /* Hash table of channels. */ - Tcl_HashSearch hSearch; /* Search variable. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - Channel *chanPtr; /* The actual channel. */ - Tcl_Channel chan; /* The opaque type. */ - size_t len; /* Length of subcommand string. */ - int IOQueued; /* How much IO is queued inside channel? */ - ChannelBuffer *bufPtr; /* For iterating over queued IO. */ - char buf[128]; /* For sprintf. */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " subcommand ?additional args..?\"", (char *) NULL); - return TCL_ERROR; - } - cmdName = argv[1]; - len = strlen(cmdName); - - chanPtr = (Channel *) NULL; - if (argc > 2) { - chan = Tcl_GetChannel(interp, argv[2], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - chanPtr = (Channel *) chan; - } - - if ((cmdName[0] == 'i') && (strncmp(cmdName, "info", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " info channelName\"", (char *) NULL); - return TCL_ERROR; - } - Tcl_AppendElement(interp, argv[2]); - Tcl_AppendElement(interp, chanPtr->typePtr->typeName); - if (chanPtr->flags & TCL_READABLE) { - Tcl_AppendElement(interp, "read"); - } else { - Tcl_AppendElement(interp, ""); - } - if (chanPtr->flags & TCL_WRITABLE) { - Tcl_AppendElement(interp, "write"); - } else { - Tcl_AppendElement(interp, ""); - } - if (chanPtr->flags & CHANNEL_NONBLOCKING) { - Tcl_AppendElement(interp, "nonblocking"); - } else { - Tcl_AppendElement(interp, "blocking"); - } - if (chanPtr->flags & CHANNEL_LINEBUFFERED) { - Tcl_AppendElement(interp, "line"); - } else if (chanPtr->flags & CHANNEL_UNBUFFERED) { - Tcl_AppendElement(interp, "none"); - } else { - Tcl_AppendElement(interp, "full"); - } - if (chanPtr->flags & BG_FLUSH_SCHEDULED) { - Tcl_AppendElement(interp, "async_flush"); - } else { - Tcl_AppendElement(interp, ""); - } - if (chanPtr->flags & CHANNEL_EOF) { - Tcl_AppendElement(interp, "eof"); - } else { - Tcl_AppendElement(interp, ""); - } - if (chanPtr->flags & CHANNEL_BLOCKED) { - Tcl_AppendElement(interp, "blocked"); - } else { - Tcl_AppendElement(interp, "unblocked"); - } - if (chanPtr->inputTranslation == TCL_TRANSLATE_AUTO) { - Tcl_AppendElement(interp, "auto"); - if (chanPtr->flags & INPUT_SAW_CR) { - Tcl_AppendElement(interp, "saw_cr"); - } else { - Tcl_AppendElement(interp, ""); - } - } else if (chanPtr->inputTranslation == TCL_TRANSLATE_LF) { - Tcl_AppendElement(interp, "lf"); - Tcl_AppendElement(interp, ""); - } else if (chanPtr->inputTranslation == TCL_TRANSLATE_CR) { - Tcl_AppendElement(interp, "cr"); - Tcl_AppendElement(interp, ""); - } else if (chanPtr->inputTranslation == TCL_TRANSLATE_CRLF) { - Tcl_AppendElement(interp, "crlf"); - if (chanPtr->flags & INPUT_SAW_CR) { - Tcl_AppendElement(interp, "queued_cr"); - } else { - Tcl_AppendElement(interp, ""); - } - } - if (chanPtr->outputTranslation == TCL_TRANSLATE_AUTO) { - Tcl_AppendElement(interp, "auto"); - } else if (chanPtr->outputTranslation == TCL_TRANSLATE_LF) { - Tcl_AppendElement(interp, "lf"); - } else if (chanPtr->outputTranslation == TCL_TRANSLATE_CR) { - Tcl_AppendElement(interp, "cr"); - } else if (chanPtr->outputTranslation == TCL_TRANSLATE_CRLF) { - Tcl_AppendElement(interp, "crlf"); - } - for (IOQueued = 0, bufPtr = chanPtr->inQueueHead; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - IOQueued += bufPtr->nextAdded - bufPtr->nextRemoved; - } - sprintf(buf, "%d", IOQueued); - Tcl_AppendElement(interp, buf); - - IOQueued = 0; - if (chanPtr->curOutPtr != (ChannelBuffer *) NULL) { - IOQueued = chanPtr->curOutPtr->nextAdded - - chanPtr->curOutPtr->nextRemoved; - } - for (bufPtr = chanPtr->outQueueHead; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - IOQueued += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - sprintf(buf, "%d", IOQueued); - Tcl_AppendElement(interp, buf); - - sprintf(buf, "%d", Tcl_Tell((Tcl_Channel) chanPtr)); - Tcl_AppendElement(interp, buf); - - sprintf(buf, "%d", chanPtr->refCount); - Tcl_AppendElement(interp, buf); - - return TCL_OK; - } - - if ((cmdName[0] == 'i') && - (strncmp(cmdName, "inputbuffered", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - - for (IOQueued = 0, bufPtr = chanPtr->inQueueHead; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - IOQueued += bufPtr->nextAdded - bufPtr->nextRemoved; - } - sprintf(buf, "%d", IOQueued); - Tcl_AppendResult(interp, buf, (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 'm') && (strncmp(cmdName, "mode", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - - if (chanPtr->flags & TCL_READABLE) { - Tcl_AppendElement(interp, "read"); - } else { - Tcl_AppendElement(interp, ""); - } - if (chanPtr->flags & TCL_WRITABLE) { - Tcl_AppendElement(interp, "write"); - } else { - Tcl_AppendElement(interp, ""); - } - return TCL_OK; - } - - if ((cmdName[0] == 'n') && (strncmp(cmdName, "name", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - Tcl_AppendResult(interp, chanPtr->channelName, (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 'o') && (strncmp(cmdName, "open", len) == 0)) { - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, "tclIO", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - Tcl_AppendElement(interp, Tcl_GetHashKey(hTblPtr, hPtr)); - } - return TCL_OK; - } - - if ((cmdName[0] == 'o') && - (strncmp(cmdName, "outputbuffered", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - - IOQueued = 0; - if (chanPtr->curOutPtr != (ChannelBuffer *) NULL) { - IOQueued = chanPtr->curOutPtr->nextAdded - - chanPtr->curOutPtr->nextRemoved; - } - for (bufPtr = chanPtr->outQueueHead; - bufPtr != (ChannelBuffer *) NULL; - bufPtr = bufPtr->nextPtr) { - IOQueued += (bufPtr->nextAdded - bufPtr->nextRemoved); - } - sprintf(buf, "%d", IOQueued); - Tcl_AppendResult(interp, buf, (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 'q') && - (strncmp(cmdName, "queuedcr", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - - Tcl_AppendResult(interp, - (chanPtr->flags & INPUT_SAW_CR) ? "1" : "0", - (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 'r') && (strncmp(cmdName, "readable", len) == 0)) { - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, "tclIO", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - chanPtr = (Channel *) Tcl_GetHashValue(hPtr); - if (chanPtr->flags & TCL_READABLE) { - Tcl_AppendElement(interp, Tcl_GetHashKey(hTblPtr, hPtr)); - } - } - return TCL_OK; - } - - if ((cmdName[0] == 'r') && (strncmp(cmdName, "refcount", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - - sprintf(buf, "%d", chanPtr->refCount); - Tcl_AppendResult(interp, buf, (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 't') && (strncmp(cmdName, "type", len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "channel name required", - (char *) NULL); - return TCL_ERROR; - } - Tcl_AppendResult(interp, chanPtr->typePtr->typeName, (char *) NULL); - return TCL_OK; - } - - if ((cmdName[0] == 'w') && (strncmp(cmdName, "writable", len) == 0)) { - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, "tclIO", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - chanPtr = (Channel *) Tcl_GetHashValue(hPtr); - if (chanPtr->flags & TCL_WRITABLE) { - Tcl_AppendElement(interp, Tcl_GetHashKey(hTblPtr, hPtr)); - } - } - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad option \"", cmdName, "\": should be ", - "info, open, readable, or writable", - (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * TclTestChannelEventCmd -- - * - * This procedure implements the "testchannelevent" command. It is - * used to test the Tcl channel event mechanism. It is present in - * this file instead of tclTest.c because it needs access to the - * internal structure of the channel. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Creates, deletes and returns channel event handlers. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -TclTestChannelEventCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Channel *chanPtr; - EventScriptRecord *esPtr, *prevEsPtr, *nextEsPtr; - char *cmd; - int index, i, mask, len; - - if ((argc < 3) || (argc > 5)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelName cmd ?arg1? ?arg2?\"", (char *) NULL); - return TCL_ERROR; - } - chanPtr = (Channel *) Tcl_GetChannel(interp, argv[1], NULL); - if (chanPtr == (Channel *) NULL) { - return TCL_ERROR; - } - cmd = argv[2]; - len = strlen(cmd); - if ((cmd[0] == 'a') && (strncmp(cmd, "add", (unsigned) len) == 0)) { - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelName add eventSpec script\"", (char *) NULL); - return TCL_ERROR; - } - if (strcmp(argv[3], "readable") == 0) { - mask = TCL_READABLE; - } else if (strcmp(argv[3], "writable") == 0) { - mask = TCL_WRITABLE; - } else { - Tcl_AppendResult(interp, "bad event name \"", argv[3], - "\": must be readable or writable", (char *) NULL); - return TCL_ERROR; - } - - esPtr = (EventScriptRecord *) ckalloc((unsigned) - sizeof(EventScriptRecord)); - esPtr->nextPtr = chanPtr->scriptRecordPtr; - chanPtr->scriptRecordPtr = esPtr; - - esPtr->chanPtr = chanPtr; - esPtr->interp = interp; - esPtr->mask = mask; - esPtr->script = ckalloc((unsigned) (strlen(argv[4]) + 1)); - strcpy(esPtr->script, argv[4]); - - Tcl_CreateChannelHandler((Tcl_Channel) chanPtr, mask, - ChannelEventScriptInvoker, (ClientData) esPtr); - - return TCL_OK; - } - - if ((cmd[0] == 'd') && (strncmp(cmd, "delete", (unsigned) len) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelName delete index\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[3], &index) == TCL_ERROR) { - return TCL_ERROR; - } - if (index < 0) { - Tcl_AppendResult(interp, "bad event index: ", argv[3], - ": must be nonnegative", (char *) NULL); - return TCL_ERROR; - } - for (i = 0, esPtr = chanPtr->scriptRecordPtr; - (i < index) && (esPtr != (EventScriptRecord *) NULL); - i++, esPtr = esPtr->nextPtr) { - /* Empty loop body. */ - } - if (esPtr == (EventScriptRecord *) NULL) { - Tcl_AppendResult(interp, "bad event index ", argv[3], - ": out of range", (char *) NULL); - return TCL_ERROR; - } - if (esPtr == chanPtr->scriptRecordPtr) { - chanPtr->scriptRecordPtr = esPtr->nextPtr; - } else { - for (prevEsPtr = chanPtr->scriptRecordPtr; - (prevEsPtr != (EventScriptRecord *) NULL) && - (prevEsPtr->nextPtr != esPtr); - prevEsPtr = prevEsPtr->nextPtr) { - /* Empty loop body. */ - } - if (prevEsPtr == (EventScriptRecord *) NULL) { - panic("TclTestChannelEventCmd: damaged event script list"); - } - prevEsPtr->nextPtr = esPtr->nextPtr; - } - Tcl_DeleteChannelHandler((Tcl_Channel) chanPtr, - ChannelEventScriptInvoker, (ClientData) esPtr); - Tcl_EventuallyFree((ClientData)esPtr->script, TCL_DYNAMIC); - ckfree((char *) esPtr); - - return TCL_OK; - } - - if ((cmd[0] == 'l') && (strncmp(cmd, "list", (unsigned) len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelName list\"", (char *) NULL); - return TCL_ERROR; - } - for (esPtr = chanPtr->scriptRecordPtr; - esPtr != (EventScriptRecord *) NULL; - esPtr = esPtr->nextPtr) { - Tcl_AppendElement(interp, - esPtr->mask == TCL_READABLE ? "readable" : "writable"); - Tcl_AppendElement(interp, esPtr->script); - } - return TCL_OK; - } - - if ((cmd[0] == 'r') && (strncmp(cmd, "removeall", (unsigned) len) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelName removeall\"", (char *) NULL); - return TCL_ERROR; - } - for (esPtr = chanPtr->scriptRecordPtr; - esPtr != (EventScriptRecord *) NULL; - esPtr = nextEsPtr) { - nextEsPtr = esPtr->nextPtr; - Tcl_DeleteChannelHandler((Tcl_Channel) chanPtr, - ChannelEventScriptInvoker, (ClientData) esPtr); - Tcl_EventuallyFree((ClientData)esPtr->script, TCL_DYNAMIC); - ckfree((char *) esPtr); - } - chanPtr->scriptRecordPtr = (EventScriptRecord *) NULL; - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad command ", cmd, ", must be one of ", - "add, delete, list, or removeall", (char *) NULL); - return TCL_ERROR; - -} diff --git a/cde/programs/dtdocbook/tcl/tclIOCmd.c b/cde/programs/dtdocbook/tcl/tclIOCmd.c deleted file mode 100644 index de3de4f42..000000000 --- a/cde/programs/dtdocbook/tcl/tclIOCmd.c +++ /dev/null @@ -1,1552 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclIOCmd.c /main/2 1996/08/08 14:44:34 cde-hp $ */ -/* - * tclIOCmd.c -- - * - * Contains the definitions of most of the Tcl commands relating to IO. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclIOCmd.c 1.94 96/04/15 06:40:02 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * Return at most this number of bytes in one call to Tcl_Read: - */ - -#define TCL_READ_CHUNK_SIZE 4096 - -/* - * Callback structure for accept callback in a TCP server. - */ - -typedef struct AcceptCallback { - char *script; /* Script to invoke. */ - Tcl_Interp *interp; /* Interpreter in which to run it. */ -} AcceptCallback; - -/* - * Static functions for this file: - */ - -static void AcceptCallbackProc _ANSI_ARGS_((ClientData callbackData, - Tcl_Channel chan, char *address, int port)); -static void RegisterTcpServerInterpCleanup _ANSI_ARGS_((Tcl_Interp *interp, - AcceptCallback *acceptCallbackPtr)); -static void TcpAcceptCallbacksDeleteProc _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp)); -static void TcpServerCloseProc _ANSI_ARGS_((ClientData callbackData)); -static void UnregisterTcpServerInterpCleanupProc _ANSI_ARGS_(( - Tcl_Interp *interp, AcceptCallback *acceptCallbackPtr)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_PutsCmd -- - * - * This procedure is invoked to process the "puts" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Produces output on a channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_PutsCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to puts on. */ - int i; /* Counter. */ - int newline; /* Add a newline at end? */ - char *channelId; /* Name of channel for puts. */ - int result; /* Result of puts operation. */ - int mode; /* Mode in which channel is opened. */ - - i = 1; - newline = 1; - if ((argc >= 2) && (strcmp(argv[1], "-nonewline") == 0)) { - newline = 0; - i++; - } - if ((i < (argc-3)) || (i >= argc)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?-nonewline? ?channelId? string\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * The code below provides backwards compatibility with an old - * form of the command that is no longer recommended or documented. - */ - - if (i == (argc-3)) { - if (strncmp(argv[i+2], "nonewline", strlen(argv[i+2])) != 0) { - Tcl_AppendResult(interp, "bad argument \"", argv[i+2], - "\": should be \"nonewline\"", (char *) NULL); - return TCL_ERROR; - } - newline = 0; - } - if (i == (argc-1)) { - channelId = "stdout"; - } else { - channelId = argv[i]; - i++; - } - chan = Tcl_GetChannel(interp, channelId, &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_WRITABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", channelId, - "\" wasn't opened for writing", (char *) NULL); - return TCL_ERROR; - } - - result = Tcl_Write(chan, argv[i], -1); - if (result < 0) { - goto error; - } - if (newline != 0) { - result = Tcl_Write(chan, "\n", 1); - if (result < 0) { - goto error; - } - } - return TCL_OK; -error: - Tcl_AppendResult(interp, "error writing \"", Tcl_GetChannelName(chan), - "\": ", Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FlushCmd -- - * - * This procedure is called to process the Tcl "flush" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May cause output to appear on the specified channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FlushCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to flush on. */ - int result; /* Result of call to channel - * level function. */ - int mode; /* Mode in which channel is opened. */ - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_WRITABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[1], - "\" wasn't opened for writing", (char *) NULL); - return TCL_ERROR; - } - - result = Tcl_Flush(chan); - if (result != TCL_OK) { - Tcl_AppendResult(interp, "error flushing \"", Tcl_GetChannelName(chan), - "\": ", Tcl_PosixError(interp), (char *) NULL); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetsCmd -- - * - * This procedure is called to process the Tcl "gets" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May consume input from channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_GetsCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to read from. */ - char *varName; /* Assign to this variable? */ - char buf[128]; /* Buffer to store string - * representation of how long - * a line was read. */ - Tcl_DString ds; /* Dynamic string to hold the - * buffer for the line just read. */ - int lineLen; /* Length of line just read. */ - int mode; /* Mode in which channel is opened. */ - - if ((argc != 2) && (argc != 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId ?varName?\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_READABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[1], - "\" wasn't opened for reading", (char *) NULL); - return TCL_ERROR; - } - - if (argc != 3) { - varName = (char *) NULL; - } else { - varName = argv[2]; - } - Tcl_DStringInit(&ds); - lineLen = Tcl_Gets(chan, &ds); - if (lineLen < 0) { - if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) { - Tcl_DStringFree(&ds); - Tcl_AppendResult(interp, "error reading \"", - Tcl_GetChannelName(chan), "\": ", Tcl_PosixError(interp), - (char *) NULL); - return TCL_ERROR; - } - lineLen = -1; - } - if (varName == (char *) NULL) { - Tcl_DStringResult(interp, &ds); - } else { - if (Tcl_SetVar(interp, varName, Tcl_DStringValue(&ds), - TCL_LEAVE_ERR_MSG) == NULL) { - Tcl_DStringFree(&ds); - return TCL_ERROR; - } - Tcl_ResetResult(interp); - sprintf(buf, "%d", lineLen); - Tcl_AppendResult(interp, buf, (char *) NULL); - } - Tcl_DStringFree(&ds); - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ReadCmd -- - * - * This procedure is invoked to process the Tcl "read" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May consume input from channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ReadCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to read from. */ - int newline, i; /* Discard newline at end? */ - int toRead; /* How many bytes to read? */ - int toReadNow; /* How many bytes to attempt to - * read in the current iteration? */ - int charactersRead; /* How many characters were read? */ - int charactersReadNow; /* How many characters were read - * in this iteration? */ - int mode; /* Mode in which channel is opened. */ - Tcl_DString ds; /* Used to accumulate the data - * read by Tcl_Read. */ - int bufSize; /* Channel buffer size; used to decide - * in what chunk sizes to read from - * the channel. */ - - if ((argc != 2) && (argc != 3)) { -argerror: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId ?numBytes?\" or \"", argv[0], - " ?-nonewline? channelId\"", (char *) NULL); - return TCL_ERROR; - } - i = 1; - newline = 0; - if (strcmp(argv[i], "-nonewline") == 0) { - newline = 1; - i++; - } - - if (i == argc) { - goto argerror; - } - - chan = Tcl_GetChannel(interp, argv[i], &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_READABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[i], - "\" wasn't opened for reading", (char *) NULL); - return TCL_ERROR; - } - - i++; /* Consumed channel name. */ - - /* - * Compute how many bytes to read, and see whether the final - * newline should be dropped. - */ - - toRead = INT_MAX; - if (i < argc) { - if (isdigit((unsigned char) (argv[i][0]))) { - if (Tcl_GetInt(interp, argv[i], &toRead) != TCL_OK) { - return TCL_ERROR; - } - } else if (strcmp(argv[i], "nonewline") == 0) { - newline = 1; - } else { - Tcl_AppendResult(interp, "bad argument \"", argv[i], - "\": should be \"nonewline\"", (char *) NULL); - return TCL_ERROR; - } - } - - bufSize = Tcl_GetChannelBufferSize(chan); - Tcl_DStringInit(&ds); - for (charactersRead = 0; charactersRead < toRead; ) { - toReadNow = toRead - charactersRead; - if (toReadNow > bufSize) { - toReadNow = bufSize; - } - Tcl_DStringSetLength(&ds, charactersRead + toReadNow); - charactersReadNow = - Tcl_Read(chan, Tcl_DStringValue(&ds) + charactersRead, toReadNow); - if (charactersReadNow < 0) { - Tcl_DStringFree(&ds); - Tcl_AppendResult(interp, "error reading \"", - Tcl_GetChannelName(chan), "\": ", - Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; - } - - /* - * If we had a short read it means that we have either EOF - * or BLOCKED on the channel, so break out. - */ - - charactersRead += charactersReadNow; - if (charactersReadNow < toReadNow) { - break; /* Out of "for" loop. */ - } - } - - /* - * Tcl_Read does not put a NULL at the end of the string, so we must - * do it here. - */ - - Tcl_DStringSetLength(&ds, charactersRead); - Tcl_DStringResult(interp, &ds); - Tcl_DStringFree(&ds); - - /* - * If requested, remove the last newline in the channel if at EOF. - */ - - if ((charactersRead > 0) && (newline) && - (interp->result[charactersRead-1] == '\n')) { - interp->result[charactersRead-1] = '\0'; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclUnsupported0Cmd -- - * - * This procedure is invoked to process the Tcl "unsupported0" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May copy a chunk from one channel to another. - * - *---------------------------------------------------------------------- - */ - -int -TclUnsupported0Cmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter in which both channels - * are defined. */ - int argc, /* How many arguments? */ - char **argv /* The argument strings. */ -) -{ - Tcl_Channel inChan, outChan; - int requested; - char *bufPtr; - int actuallyRead, actuallyWritten, totalRead, toReadNow, mode; - - /* - * Assume we want to copy the entire channel. - */ - - requested = INT_MAX; - - if ((argc < 3) || (argc > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " inChanId outChanId ?chunkSize?\"", (char *) NULL); - return TCL_ERROR; - } - inChan = Tcl_GetChannel(interp, argv[1], &mode); - if (inChan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_READABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[1], - "\" wasn't opened for reading", (char *) NULL); - return TCL_ERROR; - } - outChan = Tcl_GetChannel(interp, argv[2], &mode); - if (outChan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_WRITABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[2], - "\" wasn't opened for writing", (char *) NULL); - return TCL_ERROR; - } - - if (argc == 4) { - if (Tcl_GetInt(interp, argv[3], &requested) != TCL_OK) { - return TCL_ERROR; - } - if (requested < 0) { - requested = INT_MAX; - } - } - - bufPtr = ckalloc((unsigned) TCL_READ_CHUNK_SIZE); - for (totalRead = 0; - requested > 0; - totalRead += actuallyRead, requested -= actuallyRead) { - toReadNow = requested; - if (toReadNow > TCL_READ_CHUNK_SIZE) { - toReadNow = TCL_READ_CHUNK_SIZE; - } - actuallyRead = Tcl_Read(inChan, bufPtr, toReadNow); - if (actuallyRead < 0) { - ckfree(bufPtr); - Tcl_AppendResult(interp, argv[0], ": ", Tcl_GetChannelName(inChan), - Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; - } - if (actuallyRead == 0) { - ckfree(bufPtr); - sprintf(interp->result, "%d", totalRead); - return TCL_OK; - } - actuallyWritten = Tcl_Write(outChan, bufPtr, actuallyRead); - if (actuallyWritten < 0) { - ckfree(bufPtr); - Tcl_AppendResult(interp, argv[0], ": ", Tcl_GetChannelName(outChan), - Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; - } - } - ckfree(bufPtr); - - sprintf(interp->result, "%d", totalRead); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SeekCmd -- - * - * This procedure is invoked to process the Tcl "seek" command. See - * the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Moves the position of the access point on the specified channel. - * May flush queued output. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SeekCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to tell on. */ - int offset, mode; /* Where to seek? */ - int result; /* Of calling Tcl_Seek. */ - - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId offset ?origin?\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[2], &offset) != TCL_OK) { - return TCL_ERROR; - } - mode = SEEK_SET; - if (argc == 4) { - size_t length; - int c; - - length = strlen(argv[3]); - c = argv[3][0]; - if ((c == 's') && (strncmp(argv[3], "start", length) == 0)) { - mode = SEEK_SET; - } else if ((c == 'c') && (strncmp(argv[3], "current", length) == 0)) { - mode = SEEK_CUR; - } else if ((c == 'e') && (strncmp(argv[3], "end", length) == 0)) { - mode = SEEK_END; - } else { - Tcl_AppendResult(interp, "bad origin \"", argv[3], - "\": should be start, current, or end", (char *) NULL); - return TCL_ERROR; - } - } - - result = Tcl_Seek(chan, offset, mode); - if (result < 0) { - Tcl_AppendResult(interp, "error during seek on \"", - Tcl_GetChannelName(chan), "\": ", - Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TellCmd -- - * - * This procedure is invoked to process the Tcl "tell" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_TellCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to tell on. */ - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId\"", (char *) NULL); - return TCL_ERROR; - } - /* - * Try to find a channel with the right name and permissions in - * the IO channel table of this interpreter. - */ - - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - sprintf(interp->result, "%d", Tcl_Tell(chan)); - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CloseCmd -- - * - * This procedure is invoked to process the Tcl "close" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May discard queued input; may flush queued output. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_CloseCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to close. */ - int len; /* Length of error output. */ - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if (Tcl_UnregisterChannel(interp, chan) != TCL_OK) { - - /* - * If there is an error message and it ends with a newline, remove - * the newline. This is done for command pipeline channels where the - * error output from the subprocesses is stored in interp->result. - * - * NOTE: This is likely to not have any effect on regular error - * messages produced by drivers during the closing of a channel, - * because the Tcl convention is that such error messages do not - * have a terminating newline. - */ - - len = strlen(interp->result); - if ((len > 0) && (interp->result[len - 1] == '\n')) { - interp->result[len - 1] = '\0'; - } - - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FconfigureCmd -- - * - * This procedure is invoked to process the Tcl "fconfigure" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * May modify the behavior of an IO channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FconfigureCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to set a mode on. */ - int result; /* Of Tcl_Set/GetChannelOption. */ - int i; /* Iterate over arg-value pairs. */ - Tcl_DString ds; /* DString to hold result of - * calling Tcl_GetChannelOption. */ - - if ((argc < 2) || (((argc % 2) == 1) && (argc != 3))) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId ?optionName? ?value? ?optionName value?...\"", - (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if (argc == 2) { - Tcl_DStringInit(&ds); - if (Tcl_GetChannelOption(chan, (char *) NULL, &ds) != TCL_OK) { - Tcl_AppendResult(interp, "option retrieval failed", - (char *) NULL); - return TCL_ERROR; - } - Tcl_DStringResult(interp, &ds); - Tcl_DStringFree(&ds); - return TCL_OK; - } - if (argc == 3) { - Tcl_DStringInit(&ds); - if (Tcl_GetChannelOption(chan, argv[2], &ds) != TCL_OK) { - Tcl_DStringFree(&ds); - Tcl_AppendResult(interp, "bad option \"", argv[2], - "\": must be -blocking, -buffering, -buffersize, ", - "-eofchar, -translation, ", - "or a channel type specific option", (char *) NULL); - return TCL_ERROR; - } - Tcl_DStringResult(interp, &ds); - Tcl_DStringFree(&ds); - return TCL_OK; - } - for (i = 3; i < argc; i += 2) { - result = Tcl_SetChannelOption(interp, chan, argv[i-1], argv[i]); - if (result != TCL_OK) { - return result; - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_EofCmd -- - * - * This procedure is invoked to process the Tcl "eof" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Sets interp->result to "0" or "1" depending on whether the - * specified channel has an EOF condition. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_EofCmd( - ClientData unused, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to query for EOF. */ - int mode; /* Mode in which channel is opened. */ - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - sprintf(interp->result, "%d", Tcl_Eof(chan) ? 1 : 0); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ExecCmd -- - * - * This procedure is invoked to process the "exec" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ExecCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ -#ifdef MAC_TCL - Tcl_AppendResult(interp, "exec not implemented under Mac OS", - (char *)NULL); - return TCL_ERROR; -#else /* !MAC_TCL */ - int keepNewline, firstWord, background, length, result; - Tcl_Channel chan; - Tcl_DString ds; - int readSoFar, readNow, bufSize; - - /* - * Check for a leading "-keepnewline" argument. - */ - - keepNewline = 0; - for (firstWord = 1; (firstWord < argc) && (argv[firstWord][0] == '-'); - firstWord++) { - if (strcmp(argv[firstWord], "-keepnewline") == 0) { - keepNewline = 1; - } else if (strcmp(argv[firstWord], "--") == 0) { - firstWord++; - break; - } else { - Tcl_AppendResult(interp, "bad switch \"", argv[firstWord], - "\": must be -keepnewline or --", (char *) NULL); - return TCL_ERROR; - } - } - - if (argc <= firstWord) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?switches? arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * See if the command is to be run in background. - */ - - background = 0; - if ((argv[argc-1][0] == '&') && (argv[argc-1][1] == 0)) { - argc--; - argv[argc] = NULL; - background = 1; - } - - chan = Tcl_OpenCommandChannel(interp, argc-firstWord, - argv+firstWord, - (background ? 0 : TCL_STDOUT | TCL_STDERR)); - - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - - if (background) { - - /* - * Get the list of PIDs from the pipeline into interp->result and - * detach the PIDs (instead of waiting for them). - */ - - TclGetAndDetachPids(interp, chan); - - if (Tcl_Close(interp, chan) != TCL_OK) { - return TCL_ERROR; - } - return TCL_OK; - } - - if (Tcl_GetChannelFile(chan, TCL_READABLE) != NULL) { -#define EXEC_BUFFER_SIZE 4096 - - Tcl_DStringInit(&ds); - readSoFar = 0; bufSize = 0; - while (1) { - bufSize += EXEC_BUFFER_SIZE; - Tcl_DStringSetLength(&ds, bufSize); - readNow = Tcl_Read(chan, Tcl_DStringValue(&ds) + readSoFar, - EXEC_BUFFER_SIZE); - if (readNow < 0) { - Tcl_DStringFree(&ds); - Tcl_AppendResult(interp, - "error reading output from command: ", - Tcl_PosixError(interp), (char *) NULL); - return TCL_ERROR; - } - readSoFar += readNow; - if (readNow < EXEC_BUFFER_SIZE) { - break; /* Out of "while (1)" loop. */ - } - } - Tcl_DStringSetLength(&ds, readSoFar); - Tcl_DStringResult(interp, &ds); - Tcl_DStringFree(&ds); - } - - result = Tcl_Close(interp, chan); - - /* - * If the last character of interp->result is a newline, then remove - * the newline character (the newline would just confuse things). - * Special hack: must replace the old terminating null character - * as a signal to Tcl_AppendResult et al. that we've mucked with - * the string. - */ - - length = strlen(interp->result); - if (!keepNewline && (length > 0) && - (interp->result[length-1] == '\n')) { - interp->result[length-1] = '\0'; - interp->result[length] = 'x'; - } - - return result; -#endif /* !MAC_TCL */ -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FblockedCmd -- - * - * This procedure is invoked to process the Tcl "fblocked" command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Sets interp->result to "0" or "1" depending on whether the - * a preceding input operation on the channel would have blocked. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_FblockedCmd( - ClientData unused, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to query for blocked. */ - int mode; /* Mode in which channel was opened. */ - - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " channelId\"", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(interp, argv[1], &mode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((mode & TCL_READABLE) == 0) { - Tcl_AppendResult(interp, "channel \"", argv[1], - "\" wasn't opened for reading", (char *) NULL); - return TCL_ERROR; - } - - sprintf(interp->result, "%d", Tcl_InputBlocked(chan) ? 1 : 0); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_OpenCmd -- - * - * This procedure is invoked to process the "open" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_OpenCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int pipeline, prot; - char *modeString; - Tcl_Channel chan; - - if ((argc < 2) || (argc > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " fileName ?access? ?permissions?\"", (char *) NULL); - return TCL_ERROR; - } - prot = 0666; - if (argc == 2) { - modeString = "r"; - } else { - modeString = argv[2]; - if (argc == 4) { - if (Tcl_GetInt(interp, argv[3], &prot) != TCL_OK) { - return TCL_ERROR; - } - } - } - - pipeline = 0; - if (argv[1][0] == '|') { - pipeline = 1; - } - - /* - * Open the file or create a process pipeline. - */ - - if (!pipeline) { - chan = Tcl_OpenFileChannel(interp, argv[1], modeString, prot); - } else { - int mode, seekFlag, cmdArgc; - char **cmdArgv; - - if (Tcl_SplitList(interp, argv[1]+1, &cmdArgc, &cmdArgv) != TCL_OK) { - return TCL_ERROR; - } - - mode = TclGetOpenMode(interp, modeString, &seekFlag); - if (mode == -1) { - chan = NULL; - } else { - int flags = TCL_STDERR | TCL_ENFORCE_MODE; - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { - case O_RDONLY: - flags |= TCL_STDOUT; - break; - case O_WRONLY: - flags |= TCL_STDIN; - break; - case O_RDWR: - flags |= (TCL_STDIN | TCL_STDOUT); - break; - default: - panic("Tcl_OpenCmd: invalid mode value"); - break; - } - chan = Tcl_OpenCommandChannel(interp, cmdArgc, cmdArgv, flags); - } - ckfree((char *) cmdArgv); - } - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - Tcl_RegisterChannel(interp, chan); - Tcl_AppendResult(interp, Tcl_GetChannelName(chan), (char *) NULL); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TcpAcceptCallbacksDeleteProc -- - * - * Assocdata cleanup routine called when an interpreter is being - * deleted to set the interp field of all the accept callback records - * registered with the interpreter to NULL. This will prevent the - * interpreter from being used in the future to eval accept scripts. - * - * Results: - * None. - * - * Side effects: - * Deallocates memory and sets the interp field of all the accept - * callback records to NULL to prevent this interpreter from being - * used subsequently to eval accept scripts. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -TcpAcceptCallbacksDeleteProc( - ClientData clientData, /* Data which was passed when the assocdata - * was registered. */ - Tcl_Interp *interp /* Interpreter being deleted - not used. */ -) -{ - Tcl_HashTable *hTblPtr; - Tcl_HashEntry *hPtr; - Tcl_HashSearch hSearch; - AcceptCallback *acceptCallbackPtr; - - hTblPtr = (Tcl_HashTable *) clientData; - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - acceptCallbackPtr = (AcceptCallback *) Tcl_GetHashValue(hPtr); - acceptCallbackPtr->interp = (Tcl_Interp *) NULL; - } - Tcl_DeleteHashTable(hTblPtr); - ckfree((char *) hTblPtr); -} - -/* - *---------------------------------------------------------------------- - * - * RegisterTcpServerInterpCleanup -- - * - * Registers an accept callback record to have its interp - * field set to NULL when the interpreter is deleted. - * - * Results: - * None. - * - * Side effects: - * When, in the future, the interpreter is deleted, the interp - * field of the accept callback data structure will be set to - * NULL. This will prevent attempts to eval the accept script - * in a deleted interpreter. - * - *---------------------------------------------------------------------- - */ - -static void -RegisterTcpServerInterpCleanup( - Tcl_Interp *interp, /* Interpreter for which we want to be - * informed of deletion. */ - AcceptCallback *acceptCallbackPtr - /* The accept callback record whose - * interp field we want set to NULL when - * the interpreter is deleted. */ -) -{ - Tcl_HashTable *hTblPtr; /* Hash table for accept callback - * records to smash when the interpreter - * will be deleted. */ - Tcl_HashEntry *hPtr; /* Entry for this record. */ - int new; /* Is the entry new? */ - - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, - "tclTCPAcceptCallbacks", - NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - hTblPtr = (Tcl_HashTable *) ckalloc((unsigned) sizeof(Tcl_HashTable)); - Tcl_InitHashTable(hTblPtr, TCL_ONE_WORD_KEYS); - (void) Tcl_SetAssocData(interp, "tclTCPAcceptCallbacks", - TcpAcceptCallbacksDeleteProc, (ClientData) hTblPtr); - } - hPtr = Tcl_CreateHashEntry(hTblPtr, (char *) acceptCallbackPtr, &new); - if (!new) { - panic("RegisterTcpServerCleanup: damaged accept record table"); - } - Tcl_SetHashValue(hPtr, (ClientData) acceptCallbackPtr); -} - -/* - *---------------------------------------------------------------------- - * - * UnregisterTcpServerInterpCleanupProc -- - * - * Unregister a previously registered accept callback record. The - * interp field of this record will no longer be set to NULL in - * the future when the interpreter is deleted. - * - * Results: - * None. - * - * Side effects: - * Prevents the interp field of the accept callback record from - * being set to NULL in the future when the interpreter is deleted. - * - *---------------------------------------------------------------------- - */ - -static void -UnregisterTcpServerInterpCleanupProc( - Tcl_Interp *interp, /* Interpreter in which the accept callback - * record was registered. */ - AcceptCallback *acceptCallbackPtr - /* The record for which to delete the - * registration. */ -) -{ - Tcl_HashTable *hTblPtr; - Tcl_HashEntry *hPtr; - - hTblPtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, - "tclTCPAcceptCallbacks", NULL); - if (hTblPtr == (Tcl_HashTable *) NULL) { - return; - } - hPtr = Tcl_FindHashEntry(hTblPtr, (char *) acceptCallbackPtr); - if (hPtr == (Tcl_HashEntry *) NULL) { - return; - } - Tcl_DeleteHashEntry(hPtr); -} - -/* - *---------------------------------------------------------------------- - * - * AcceptCallbackProc -- - * - * This callback is invoked by the TCP channel driver when it - * accepts a new connection from a client on a server socket. - * - * Results: - * None. - * - * Side effects: - * Whatever the script does. - * - *---------------------------------------------------------------------- - */ - -static void -AcceptCallbackProc( - ClientData callbackData, /* The data stored when the callback - * was created in the call to - * Tcl_OpenTcpServer. */ - Tcl_Channel chan, /* Channel for the newly accepted - * connection. */ - char *address, /* Address of client that was - * accepted. */ - int port /* Port of client that was accepted. */ -) -{ - AcceptCallback *acceptCallbackPtr; - Tcl_Interp *interp; - char *script; - char portBuf[10]; - int result; - - acceptCallbackPtr = (AcceptCallback *) callbackData; - - /* - * Check if the callback is still valid; the interpreter may have gone - * away, this is signalled by setting the interp field of the callback - * data to NULL. - */ - - if (acceptCallbackPtr->interp != (Tcl_Interp *) NULL) { - - script = acceptCallbackPtr->script; - interp = acceptCallbackPtr->interp; - - Tcl_Preserve((ClientData) script); - Tcl_Preserve((ClientData) interp); - - sprintf(portBuf, "%d", port); - Tcl_RegisterChannel(interp, chan); - result = Tcl_VarEval(interp, script, " ", Tcl_GetChannelName(chan), - " ", address, " ", portBuf, (char *) NULL); - if (result != TCL_OK) { - Tcl_BackgroundError(interp); - Tcl_UnregisterChannel(interp, chan); - } - Tcl_Release((ClientData) interp); - Tcl_Release((ClientData) script); - } else { - - /* - * The interpreter has been deleted, so there is no useful - * way to utilize the client socket - just close it. - */ - - Tcl_Close((Tcl_Interp *) NULL, chan); - } -} - -/* - *---------------------------------------------------------------------- - * - * TcpServerCloseProc -- - * - * This callback is called when the TCP server channel for which it - * was registered is being closed. It informs the interpreter in - * which the accept script is evaluated (if that interpreter still - * exists) that this channel no longer needs to be informed if the - * interpreter is deleted. - * - * Results: - * None. - * - * Side effects: - * In the future, if the interpreter is deleted this channel will - * no longer be informed. - * - *---------------------------------------------------------------------- - */ - -static void -TcpServerCloseProc( - ClientData callbackData /* The data passed in the call to - * Tcl_CreateCloseHandler. */ -) -{ - AcceptCallback *acceptCallbackPtr; - /* The actual data. */ - - acceptCallbackPtr = (AcceptCallback *) callbackData; - if (acceptCallbackPtr->interp != (Tcl_Interp *) NULL) { - UnregisterTcpServerInterpCleanupProc(acceptCallbackPtr->interp, - acceptCallbackPtr); - } - Tcl_EventuallyFree((ClientData) acceptCallbackPtr->script, TCL_DYNAMIC); - ckfree((char *) acceptCallbackPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SocketCmd -- - * - * This procedure is invoked to process the "socket" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Creates a socket based channel. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_SocketCmd( - ClientData notUsed, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int a, server, port; - char *arg, *copyScript, *host, *script; - char *myaddr = NULL; - int myport = 0; - int async = 0; - Tcl_Channel chan; - AcceptCallback *acceptCallbackPtr; - - server = 0; - script = NULL; - - if (TclHasSockets(interp) != TCL_OK) { - return TCL_ERROR; - } - - for (a = 1; a < argc; a++) { - arg = argv[a]; - if (arg[0] == '-') { - if (strcmp(arg, "-server") == 0) { - if (async == 1) { - Tcl_AppendResult(interp, - "cannot set -async option for server sockets", - (char *) NULL); - return TCL_ERROR; - } - server = 1; - a++; - if (a >= argc) { - Tcl_AppendResult(interp, - "no argument given for -server option", - (char *) NULL); - return TCL_ERROR; - } - script = argv[a]; - } else if (strcmp(arg, "-myaddr") == 0) { - a++; - if (a >= argc) { - Tcl_AppendResult(interp, - "no argument given for -myaddr option", - (char *) NULL); - return TCL_ERROR; - } - myaddr = argv[a]; - } else if (strcmp(arg, "-myport") == 0) { - a++; - if (a >= argc) { - Tcl_AppendResult(interp, - "no argument given for -myport option", - (char *) NULL); - return TCL_ERROR; - } - if (TclSockGetPort(interp, argv[a], "tcp", &myport) - != TCL_OK) { - return TCL_ERROR; - } - } else if (strcmp(arg, "-async") == 0) { - if (server == 1) { - Tcl_AppendResult(interp, - "cannot set -async option for server sockets", - (char *) NULL); - return TCL_ERROR; - } - async = 1; - } else { - Tcl_AppendResult(interp, "bad option \"", arg, - "\", must be -async, -myaddr, -myport, or -server", - (char *) NULL); - return TCL_ERROR; - } - } else { - break; - } - } - if (server) { - host = myaddr; /* NULL implies INADDR_ANY */ - if (myport != 0) { - Tcl_AppendResult(interp, "Option -myport is not valid for servers", - NULL); - return TCL_ERROR; - } - } else if (a < argc) { - host = argv[a]; - a++; - } else { -wrongNumArgs: - Tcl_AppendResult(interp, "wrong # args: should be either:\n", - argv[0], - " ?-myaddr addr? ?-myport myport? ?-async? host port\n", - argv[0], - " -server command ?-myaddr addr? port", - (char *) NULL); - return TCL_ERROR; - } - - if (a == argc-1) { - if (TclSockGetPort(interp, argv[a], "tcp", &port) != TCL_OK) { - return TCL_ERROR; - } - } else { - goto wrongNumArgs; - } - - if (server) { - acceptCallbackPtr = (AcceptCallback *) ckalloc((unsigned) - sizeof(AcceptCallback)); - copyScript = ckalloc((unsigned) strlen(script) + 1); - strcpy(copyScript, script); - acceptCallbackPtr->script = copyScript; - acceptCallbackPtr->interp = interp; - chan = Tcl_OpenTcpServer(interp, port, host, AcceptCallbackProc, - (ClientData) acceptCallbackPtr); - if (chan == (Tcl_Channel) NULL) { - ckfree(copyScript); - ckfree((char *) acceptCallbackPtr); - return TCL_ERROR; - } - - /* - * Register with the interpreter to let us know when the - * interpreter is deleted (by having the callback set the - * acceptCallbackPtr->interp field to NULL). This is to - * avoid trying to eval the script in a deleted interpreter. - */ - - RegisterTcpServerInterpCleanup(interp, acceptCallbackPtr); - - /* - * Register a close callback. This callback will inform the - * interpreter (if it still exists) that this channel does not - * need to be informed when the interpreter is deleted. - */ - - Tcl_CreateCloseHandler(chan, TcpServerCloseProc, - (ClientData) acceptCallbackPtr); - } else { - chan = Tcl_OpenTcpClient(interp, port, host, myaddr, myport, async); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - } - Tcl_RegisterChannel(interp, chan); - Tcl_AppendResult(interp, Tcl_GetChannelName(chan), (char *) NULL); - - return TCL_OK; -} diff --git a/cde/programs/dtdocbook/tcl/tclIOSock.c b/cde/programs/dtdocbook/tcl/tclIOSock.c deleted file mode 100644 index bf43356f2..000000000 --- a/cde/programs/dtdocbook/tcl/tclIOSock.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclIOSock.c /main/2 1996/08/08 14:44:39 cde-hp $ */ -/* - * tclIOSock.c -- - * - * Common routines used by all socket based channel types. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclIOSock.c 1.16 96/03/12 07:04:33 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - *---------------------------------------------------------------------- - * - * TclSockGetPort -- - * - * Maps from a string, which could be a service name, to a port. - * Used by socket creation code to get port numbers and resolve - * registered service names to port numbers. - * - * Results: - * A standard Tcl result. On success, the port number is - * returned in portPtr. On failure, an error message is left in - * interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclSockGetPort( - Tcl_Interp *interp, - char *string, /* Integer or service name */ - char *proto, /* "tcp" or "udp", typically */ - int *portPtr /* Return port number */ -) -{ - struct servent *sp = getservbyname(string, proto); - if (sp != NULL) { - *portPtr = ntohs((unsigned short) sp->s_port); - return TCL_OK; - } - if (Tcl_GetInt(interp, string, portPtr) != TCL_OK) { - return TCL_ERROR; - } - if (*portPtr > 0xFFFF) { - Tcl_AppendResult(interp, "couldn't open socket: port number too high", - (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclSockMinimumBuffers -- - * - * Ensure minimum buffer sizes (non zero). - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Sets SO_SNDBUF and SO_RCVBUF sizes. - * - *---------------------------------------------------------------------- - */ - -int -TclSockMinimumBuffers( - int sock, /* Socket file descriptor */ - int size /* Minimum buffer size */ -) -{ - int current; - int len = sizeof(int); - - getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *) ¤t, &len); - if (current < size) { - len = sizeof(int); - setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *) &size, len); - } - len = sizeof(int); - getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *) ¤t, &len); - if (current < size) { - len = sizeof(int); - setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *) &size, len); - } - return TCL_OK; -} diff --git a/cde/programs/dtdocbook/tcl/tclIOUtil.c b/cde/programs/dtdocbook/tcl/tclIOUtil.c deleted file mode 100644 index 1a1cb9c2b..000000000 --- a/cde/programs/dtdocbook/tcl/tclIOUtil.c +++ /dev/null @@ -1,1320 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclIOUtil.c /main/3 1996/10/03 17:17:59 drk $ */ -/* - * tclIOUtil.c -- - * - * This file contains a collection of utility procedures that - * are shared by the platform specific IO drivers. - * - * Parts of this file are based on code contributed by Karl - * Lehenbauer, Mark Diekhans and Peter da Silva. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclIOUtil.c 1.122 96/04/02 18:46:40 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * A linked list of the following structures is used to keep track - * of child processes that have been detached but haven't exited - * yet, so we can make sure that they're properly "reaped" (officially - * waited for) and don't lie around as zombies cluttering the - * system. - */ - -typedef struct Detached { - pid_t pid; /* Id of process that's been detached - * but isn't known to have exited. */ - struct Detached *nextPtr; /* Next in list of all detached - * processes. */ -} Detached; - -static Detached *detList = NULL; /* List of all detached proceses. */ - -/* - * Declarations for local procedures defined in this file: - */ - -static Tcl_File FileForRedirect _ANSI_ARGS_((Tcl_Interp *interp, - char *spec, int atOk, char *arg, int flags, - char *nextArg, int *skipPtr, int *closePtr)); - -/* - *---------------------------------------------------------------------- - * - * FileForRedirect -- - * - * This procedure does much of the work of parsing redirection - * operators. It handles "@" if specified and allowed, and a file - * name, and opens the file if necessary. - * - * Results: - * The return value is the descriptor number for the file. If an - * error occurs then NULL is returned and an error message is left - * in interp->result. Several arguments are side-effected; see - * the argument list below for details. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static Tcl_File -FileForRedirect( - Tcl_Interp *interp, /* Intepreter to use for error - * reporting. */ - char *spec, /* Points to character just after - * redirection character. */ - int atOk, /* Non-zero means '@' notation is - * OK, zero means it isn't. */ - char *arg, /* Pointer to entire argument - * containing spec: used for error - * reporting. */ - int flags, /* Flags to use for opening file. */ - char *nextArg, /* Next argument in argc/argv - * array, if needed for file name. - * May be NULL. */ - int *skipPtr, /* This value is incremented if - * nextArg is used for redirection - * spec. */ - int *closePtr /* This value is set to 1 if the file - * that's returned must be closed, 0 - * if it was specified with "@" so - * it must be left open. */ -) -{ - int writing = (flags & O_WRONLY); - Tcl_Channel chan; - Tcl_File file; - - if (atOk && (*spec == '@')) { - spec++; - if (*spec == 0) { - spec = nextArg; - if (spec == NULL) { - goto badLastArg; - } - *skipPtr += 1; - } - chan = Tcl_GetChannel(interp, spec, NULL); - if (chan == (Tcl_Channel) NULL) { - return NULL; - } - *closePtr = 0; - file = Tcl_GetChannelFile(chan, writing ? TCL_WRITABLE : TCL_READABLE); - if (file == NULL) { - Tcl_AppendResult(interp, - "channel \"", - Tcl_GetChannelName(chan), - "\" wasn't opened for ", - writing ? "writing" : "reading", (char *) NULL); - return NULL; - } - if (writing) { - - /* - * Be sure to flush output to the file, so that anything - * written by the child appears after stuff we've already - * written. - */ - - Tcl_Flush(chan); - } - } else { - Tcl_DString buffer; - char *name; - - if (*spec == 0) { - spec = nextArg; - if (spec == NULL) { - goto badLastArg; - } - *skipPtr += 1; - } - name = Tcl_TranslateFileName(interp, spec, &buffer); - if (name) { - file = TclOpenFile(name, flags); - } else { - file = NULL; - } - Tcl_DStringFree(&buffer); - if (file == NULL) { - Tcl_AppendResult(interp, "couldn't ", - (writing) ? "write" : "read", " file \"", spec, "\": ", - Tcl_PosixError(interp), (char *) NULL); - return NULL; - } - *closePtr = 1; - } - return file; - - badLastArg: - Tcl_AppendResult(interp, "can't specify \"", arg, - "\" as last word in command", (char *) NULL); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetOpenMode -- - * - * Description: - * Computes a POSIX mode mask for opening a file, from a given string, - * and also sets a flag to indicate whether the caller should seek to - * EOF after opening the file. - * - * Results: - * On success, returns mode to pass to "open". If an error occurs, the - * returns -1 and if interp is not NULL, sets interp->result to an - * error message. - * - * Side effects: - * Sets the integer referenced by seekFlagPtr to 1 to tell the caller - * to seek to EOF after opening the file. - * - * Special note: - * This code is based on a prototype implementation contributed - * by Mark Diekhans. - * - *---------------------------------------------------------------------- - */ - -int -TclGetOpenMode( - Tcl_Interp *interp, /* Interpreter to use for error - * reporting - may be NULL. */ - char *string, /* Mode string, e.g. "r+" or - * "RDONLY CREAT". */ - int *seekFlagPtr /* Set this to 1 if the caller - * should seek to EOF during the - * opening of the file. */ -) -{ - int mode, modeArgc, c, i, gotRW; - char **modeArgv, *flag; -#define RW_MODES (O_RDONLY|O_WRONLY|O_RDWR) - - /* - * Check for the simpler fopen-like access modes (e.g. "r"). They - * are distinguished from the POSIX access modes by the presence - * of a lower-case first letter. - */ - - *seekFlagPtr = 0; - mode = 0; - if (islower(UCHAR(string[0]))) { - switch (string[0]) { - case 'r': - mode = O_RDONLY; - break; - case 'w': - mode = O_WRONLY|O_CREAT|O_TRUNC; - break; - case 'a': - mode = O_WRONLY|O_CREAT; - *seekFlagPtr = 1; - break; - default: - error: - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "illegal access mode \"", string, "\"", - (char *) NULL); - } - return -1; - } - if (string[1] == '+') { - mode &= ~(O_RDONLY|O_WRONLY); - mode |= O_RDWR; - if (string[2] != 0) { - goto error; - } - } else if (string[1] != 0) { - goto error; - } - return mode; - } - - /* - * The access modes are specified using a list of POSIX modes - * such as O_CREAT. - * - * IMPORTANT NOTE: We rely on Tcl_SplitList working correctly when - * a NULL interpreter is passed in. - */ - - if (Tcl_SplitList(interp, string, &modeArgc, &modeArgv) != TCL_OK) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AddErrorInfo(interp, - "\n while processing open access modes \""); - Tcl_AddErrorInfo(interp, string); - Tcl_AddErrorInfo(interp, "\""); - } - return -1; - } - - gotRW = 0; - for (i = 0; i < modeArgc; i++) { - flag = modeArgv[i]; - c = flag[0]; - if ((c == 'R') && (strcmp(flag, "RDONLY") == 0)) { - mode = (mode & ~RW_MODES) | O_RDONLY; - gotRW = 1; - } else if ((c == 'W') && (strcmp(flag, "WRONLY") == 0)) { - mode = (mode & ~RW_MODES) | O_WRONLY; - gotRW = 1; - } else if ((c == 'R') && (strcmp(flag, "RDWR") == 0)) { - mode = (mode & ~RW_MODES) | O_RDWR; - gotRW = 1; - } else if ((c == 'A') && (strcmp(flag, "APPEND") == 0)) { - mode |= O_APPEND; - *seekFlagPtr = 1; - } else if ((c == 'C') && (strcmp(flag, "CREAT") == 0)) { - mode |= O_CREAT; - } else if ((c == 'E') && (strcmp(flag, "EXCL") == 0)) { - mode |= O_EXCL; - } else if ((c == 'N') && (strcmp(flag, "NOCTTY") == 0)) { -#ifdef O_NOCTTY - mode |= O_NOCTTY; -#else - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "access mode \"", flag, - "\" not supported by this system", (char *) NULL); - } - ckfree((char *) modeArgv); - return -1; -#endif - } else if ((c == 'N') && (strcmp(flag, "NONBLOCK") == 0)) { -#if defined(O_NDELAY) || defined(O_NONBLOCK) -# ifdef O_NONBLOCK - mode |= O_NONBLOCK; -# else - mode |= O_NDELAY; -# endif -#else - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "access mode \"", flag, - "\" not supported by this system", (char *) NULL); - } - ckfree((char *) modeArgv); - return -1; -#endif - } else if ((c == 'T') && (strcmp(flag, "TRUNC") == 0)) { - mode |= O_TRUNC; - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "invalid access mode \"", flag, - "\": must be RDONLY, WRONLY, RDWR, APPEND, CREAT", - " EXCL, NOCTTY, NONBLOCK, or TRUNC", (char *) NULL); - } - ckfree((char *) modeArgv); - return -1; - } - } - ckfree((char *) modeArgv); - if (!gotRW) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "access mode must include either", - " RDONLY, WRONLY, or RDWR", (char *) NULL); - } - return -1; - } - return mode; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_EvalFile -- - * - * Read in a file and process the entire file as one gigantic - * Tcl command. - * - * Results: - * A standard Tcl result, which is either the result of executing - * the file or an error indicating why the file couldn't be read. - * - * Side effects: - * Depends on the commands in the file. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_EvalFile( - Tcl_Interp *interp, /* Interpreter in which to process file. */ - char *fileName /* Name of file to process. Tilde-substitution - * will be performed on this name. */ -) -{ - int result; - struct stat statBuf; - char *cmdBuffer = (char *) NULL; - char *oldScriptFile = (char *) NULL; - Interp *iPtr = (Interp *) interp; - Tcl_DString buffer; - char *nativeName = (char *) NULL; - Tcl_Channel chan = (Tcl_Channel) NULL; - - Tcl_ResetResult(interp); - oldScriptFile = iPtr->scriptFile; - iPtr->scriptFile = fileName; - Tcl_DStringInit(&buffer); - nativeName = Tcl_TranslateFileName(interp, fileName, &buffer); - if (nativeName == NULL) { - goto error; - } - - /* - * If Tcl_TranslateFileName didn't already copy the file name, do it - * here. This way we don't depend on fileName staying constant - * throughout the execution of the script (e.g., what if it happens - * to point to a Tcl variable that the script could change?). - */ - - if (nativeName != Tcl_DStringValue(&buffer)) { - Tcl_DStringSetLength(&buffer, 0); - Tcl_DStringAppend(&buffer, nativeName, -1); - nativeName = Tcl_DStringValue(&buffer); - } - if (stat(nativeName, &statBuf) == -1) { - Tcl_SetErrno(errno); - Tcl_AppendResult(interp, "couldn't read file \"", fileName, - "\": ", Tcl_PosixError(interp), (char *) NULL); - goto error; - } - chan = Tcl_OpenFileChannel(interp, nativeName, "r", 0644); - if (chan == (Tcl_Channel) NULL) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "couldn't read file \"", fileName, - "\": ", Tcl_PosixError(interp), (char *) NULL); - goto error; - } - cmdBuffer = (char *) ckalloc((unsigned) statBuf.st_size+1); - result = Tcl_Read(chan, cmdBuffer, statBuf.st_size); - if (result < 0) { - Tcl_Close(interp, chan); - Tcl_AppendResult(interp, "couldn't read file \"", fileName, - "\": ", Tcl_PosixError(interp), (char *) NULL); - goto error; - } - cmdBuffer[result] = 0; - if (Tcl_Close(interp, chan) != TCL_OK) { - goto error; - } - - result = Tcl_Eval(interp, cmdBuffer); - if (result == TCL_RETURN) { - result = TclUpdateReturnInfo(iPtr); - } else if (result == TCL_ERROR) { - char msg[200]; - - /* - * Record information telling where the error occurred. - */ - - sprintf(msg, "\n (file \"%.150s\" line %d)", fileName, - interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - iPtr->scriptFile = oldScriptFile; - ckfree(cmdBuffer); - Tcl_DStringFree(&buffer); - return result; - -error: - if (cmdBuffer != (char *) NULL) { - ckfree(cmdBuffer); - } - iPtr->scriptFile = oldScriptFile; - Tcl_DStringFree(&buffer); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DetachPids -- - * - * This procedure is called to indicate that one or more child - * processes have been placed in background and will never be - * waited for; they should eventually be reaped by - * Tcl_ReapDetachedProcs. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DetachPids( - int numPids, /* Number of pids to detach: gives size - * of array pointed to by pidPtr. */ - pid_t *pidPtr /* Array of pids to detach. */ -) -{ - Detached *detPtr; - int i; - - for (i = 0; i < numPids; i++) { - detPtr = (Detached *) ckalloc(sizeof(Detached)); - detPtr->pid = pidPtr[i]; - detPtr->nextPtr = detList; - detList = detPtr; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ReapDetachedProcs -- - * - * This procedure checks to see if any detached processes have - * exited and, if so, it "reaps" them by officially waiting on - * them. It should be called "occasionally" to make sure that - * all detached processes are eventually reaped. - * - * Results: - * None. - * - * Side effects: - * Processes are waited on, so that they can be reaped by the - * system. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_ReapDetachedProcs(void) -{ - Detached *detPtr; - Detached *nextPtr, *prevPtr; - int status; - pid_t pid; - - for (detPtr = detList, prevPtr = NULL; detPtr != NULL; ) { - pid = Tcl_WaitPid(detPtr->pid, &status, WNOHANG); - if ((pid == 0) || ((pid == (pid_t)-1) && (errno != ECHILD))) { - prevPtr = detPtr; - detPtr = detPtr->nextPtr; - continue; - } - nextPtr = detPtr->nextPtr; - if (prevPtr == NULL) { - detList = detPtr->nextPtr; - } else { - prevPtr->nextPtr = detPtr->nextPtr; - } - ckfree((char *) detPtr); - detPtr = nextPtr; - } -} - -/* - *---------------------------------------------------------------------- - * - * TclCleanupChildren -- - * - * This is a utility procedure used to wait for child processes - * to exit, record information about abnormal exits, and then - * collect any stderr output generated by them. - * - * Results: - * The return value is a standard Tcl result. If anything at - * weird happened with the child processes, TCL_ERROR is returned - * and a message is left in interp->result. - * - * Side effects: - * If the last character of interp->result is a newline, then it - * is removed unless keepNewline is non-zero. File errorId gets - * closed, and pidPtr is freed back to the storage allocator. - * - *---------------------------------------------------------------------- - */ - -int -TclCleanupChildren( - Tcl_Interp *interp, /* Used for error messages. */ - int numPids, /* Number of entries in pidPtr array. */ - pid_t *pidPtr, /* Array of process ids of children. */ - Tcl_Channel errorChan /* Channel for file containing stderr output - * from pipeline. NULL means there isn't any - * stderr output. */ -) -{ - int result = TCL_OK; - pid_t pid; - int i, abnormalExit, anyErrorInfo; - WAIT_STATUS_TYPE waitStatus; - char *msg; - - abnormalExit = 0; - for (i = 0; i < numPids; i++) { - pid = Tcl_WaitPid(pidPtr[i], (int *) &waitStatus, 0); - if (pid == (pid_t)-1) { - result = TCL_ERROR; - if (interp != (Tcl_Interp *) NULL) { - msg = Tcl_PosixError(interp); - if (errno == ECHILD) { - /* - * This changeup in message suggested by Mark Diekhans - * to remind people that ECHILD errors can occur on - * some systems if SIGCHLD isn't in its default state. - */ - - msg = - "child process lost (is SIGCHLD ignored or trapped?)"; - } - Tcl_AppendResult(interp, "error waiting for process to exit: ", - msg, (char *) NULL); - } - continue; - } - - /* - * Create error messages for unusual process exits. An - * extra newline gets appended to each error message, but - * it gets removed below (in the same fashion that an - * extra newline in the command's output is removed). - */ - - if (!WIFEXITED(waitStatus) || (WEXITSTATUS(waitStatus) != 0)) { - char msg1[20], msg2[20]; - - result = TCL_ERROR; - sprintf(msg1, "%ld", (long)pid); - if (WIFEXITED(waitStatus)) { - if (interp != (Tcl_Interp *) NULL) { - sprintf(msg2, "%d", WEXITSTATUS(waitStatus)); - Tcl_SetErrorCode(interp, "CHILDSTATUS", msg1, msg2, - (char *) NULL); - } - abnormalExit = 1; - } else if (WIFSIGNALED(waitStatus)) { - if (interp != (Tcl_Interp *) NULL) { - char *p; - - p = Tcl_SignalMsg((int) (WTERMSIG(waitStatus))); - Tcl_SetErrorCode(interp, "CHILDKILLED", msg1, - Tcl_SignalId((int) (WTERMSIG(waitStatus))), p, - (char *) NULL); - Tcl_AppendResult(interp, "child killed: ", p, "\n", - (char *) NULL); - } - } else if (WIFSTOPPED(waitStatus)) { - if (interp != (Tcl_Interp *) NULL) { - char *p; - - p = Tcl_SignalMsg((int) (WSTOPSIG(waitStatus))); - Tcl_SetErrorCode(interp, "CHILDSUSP", msg1, - Tcl_SignalId((int) (WSTOPSIG(waitStatus))), - p, (char *) NULL); - Tcl_AppendResult(interp, "child suspended: ", p, "\n", - (char *) NULL); - } - } else { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, - "child wait status didn't make sense\n", - (char *) NULL); - } - } - } - } - - /* - * Read the standard error file. If there's anything there, - * then return an error and add the file's contents to the result - * string. - */ - - anyErrorInfo = 0; - if (errorChan != NULL) { - - /* - * Make sure we start at the beginning of the file. - */ - - Tcl_Seek(errorChan, 0L, SEEK_SET); - - if (interp != (Tcl_Interp *) NULL) { - while (1) { -#define BUFFER_SIZE 1000 - char buffer[BUFFER_SIZE+1]; - int count; - - count = Tcl_Read(errorChan, buffer, BUFFER_SIZE); - if (count == 0) { - break; - } - result = TCL_ERROR; - if (count < 0) { - Tcl_AppendResult(interp, - "error reading stderr output file: ", - Tcl_PosixError(interp), (char *) NULL); - break; /* out of the "while (1)" loop. */ - } - buffer[count] = 0; - Tcl_AppendResult(interp, buffer, (char *) NULL); - anyErrorInfo = 1; - } - } - - Tcl_Close(NULL, errorChan); - } - - /* - * If a child exited abnormally but didn't output any error information - * at all, generate an error message here. - */ - - if (abnormalExit && !anyErrorInfo && (interp != (Tcl_Interp *) NULL)) { - Tcl_AppendResult(interp, "child process exited abnormally", - (char *) NULL); - } - - return result; -} - -/* - *---------------------------------------------------------------------- - * - * TclCreatePipeline -- - * - * Given an argc/argv array, instantiate a pipeline of processes - * as described by the argv. - * - * Results: - * The return value is a count of the number of new processes - * created, or -1 if an error occurred while creating the pipeline. - * *pidArrayPtr is filled in with the address of a dynamically - * allocated array giving the ids of all of the processes. It - * is up to the caller to free this array when it isn't needed - * anymore. If inPipePtr is non-NULL, *inPipePtr is filled in - * with the file id for the input pipe for the pipeline (if any): - * the caller must eventually close this file. If outPipePtr - * isn't NULL, then *outPipePtr is filled in with the file id - * for the output pipe from the pipeline: the caller must close - * this file. If errFilePtr isn't NULL, then *errFilePtr is filled - * with a file id that may be used to read error output after the - * pipeline completes. - * - * Side effects: - * Processes and pipes are created. - * - *---------------------------------------------------------------------- - */ - -int -TclCreatePipeline( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - int argc, /* Number of entries in argv. */ - char **argv, /* Array of strings describing commands in - * pipeline plus I/O redirection with <, - * <<, >, etc. Argv[argc] must be NULL. */ - pid_t **pidArrayPtr, /* Word at *pidArrayPtr gets filled in with - * address of array of pids for processes - * in pipeline (first pid is first process - * in pipeline). */ - Tcl_File *inPipePtr, /* If non-NULL, input to the pipeline comes - * from a pipe (unless overridden by - * redirection in the command). The file - * id with which to write to this pipe is - * stored at *inPipePtr. NULL means command - * specified its own input source. */ - Tcl_File *outPipePtr, /* If non-NULL, output to the pipeline goes - * to a pipe, unless overriden by redirection - * in the command. The file id with which to - * read frome this pipe is stored at - * *outPipePtr. NULL means command specified - * its own output sink. */ - Tcl_File *errFilePtr /* If non-NULL, all stderr output from the - * pipeline will go to a temporary file - * created here, and a descriptor to read - * the file will be left at *errFilePtr. - * The file will be removed already, so - * closing this descriptor will be the end - * of the file. If this is NULL, then - * all stderr output goes to our stderr. - * If the pipeline specifies redirection - * then the file will still be created - * but it will never get any data. */ -) -{ -#if defined( MAC_TCL ) - Tcl_AppendResult(interp, - "command pipelines not supported on Macintosh OS", NULL); - return -1; -#else /* !MAC_TCL */ - pid_t *pidPtr = NULL; /* Points to malloc-ed array holding all - * the pids of child processes. */ - int numPids = 0; /* Actual number of processes that exist - * at *pidPtr right now. */ - int cmdCount; /* Count of number of distinct commands - * found in argc/argv. */ - char *input = NULL; /* If non-null, then this points to a - * string containing input data (specified - * via <<) to be piped to the first process - * in the pipeline. */ - Tcl_File inputFile = NULL; - /* If != NULL, gives file to use as input for - * first process in pipeline (specified via < - * or <@). */ - int closeInput = 0; /* If non-zero, then must close inputId - * when cleaning up (zero means the file needs - * to stay open for some other reason). */ - Tcl_File outputFile = NULL; - /* Writable file for output from last command - * in pipeline (could be file or pipe). NULL - * means use stdout. */ - int closeOutput = 0; /* Non-zero means must close outputId when - * cleaning up (similar to closeInput). */ - Tcl_File errorFile = NULL; - /* Writable file for error output from all - * commands in pipeline. NULL means use - * stderr. */ - int closeError = 0; /* Non-zero means must close errorId when - * cleaning up. */ - int skip; /* Number of arguments to skip (because they - * specify redirection). */ - int lastBar; - int i, j; - char *p; - int hasPipes = TclHasPipes(); - char finalOut[L_tmpnam]; - char intIn[L_tmpnam]; - - finalOut[0] = '\0'; - intIn[0] = '\0'; - - if (inPipePtr != NULL) { - *inPipePtr = NULL; - } - if (outPipePtr != NULL) { - *outPipePtr = NULL; - } - if (errFilePtr != NULL) { - *errFilePtr = NULL; - } - - /* - * First, scan through all the arguments to figure out the structure - * of the pipeline. Process all of the input and output redirection - * arguments and remove them from the argument list in the pipeline. - * Count the number of distinct processes (it's the number of "|" - * arguments plus one) but don't remove the "|" arguments. - */ - - cmdCount = 1; - lastBar = -1; - for (i = 0; i < argc; i++) { - if ((argv[i][0] == '|') && (((argv[i][1] == 0)) - || ((argv[i][1] == '&') && (argv[i][2] == 0)))) { - if ((i == (lastBar+1)) || (i == (argc-1))) { - interp->result = "illegal use of | or |& in command"; - return -1; - } - lastBar = i; - cmdCount++; - continue; - } else if (argv[i][0] == '<') { - if ((inputFile != NULL) && closeInput) { - TclCloseFile(inputFile); - } - inputFile = NULL; - skip = 1; - if (argv[i][1] == '<') { - input = argv[i]+2; - if (*input == 0) { - input = argv[i+1]; - if (input == 0) { - Tcl_AppendResult(interp, "can't specify \"", argv[i], - "\" as last word in command", (char *) NULL); - goto error; - } - skip = 2; - } - } else { - input = 0; - inputFile = FileForRedirect(interp, argv[i]+1, 1, argv[i], - O_RDONLY, argv[i+1], &skip, &closeInput); - if (inputFile == NULL) { - goto error; - } - - /* When Win32s dies out, this code can be removed */ - if (!hasPipes) { - if (!closeInput) { - Tcl_AppendResult(interp, "redirection with '@'", - " notation is not supported on this system", - (char *) NULL); - goto error; - } - strcpy(intIn, skip == 1 ? argv[i]+1 : argv[i+1]); - } - } - } else if (argv[i][0] == '>') { - int append, useForStdErr, useForStdOut, mustClose, atOk, flags; - Tcl_File file; - - skip = atOk = 1; - append = useForStdErr = 0; - useForStdOut = 1; - if (argv[i][1] == '>') { - p = argv[i] + 2; - append = 1; - atOk = 0; - flags = O_WRONLY|O_CREAT; - } else { - p = argv[i] + 1; - flags = O_WRONLY|O_CREAT|O_TRUNC; - } - if (*p == '&') { - useForStdErr = 1; - p++; - } - file = FileForRedirect(interp, p, atOk, argv[i], flags, argv[i+1], - &skip, &mustClose); - if (file == NULL) { - goto error; - } - - /* When Win32s dies out, this code can be removed */ - if (!hasPipes) { - if (!mustClose) { - Tcl_AppendResult(interp, "redirection with '@'", - " notation is not supported on this system", - (char *) NULL); - goto error; - } - strcpy(finalOut, skip == 1 ? p : argv[i+1]); - } - - if (hasPipes && append) { - TclSeekFile(file, 0L, 2); - } - - /* - * Got the file descriptor. Now use it for standard output, - * standard error, or both, depending on the redirection. - */ - - if (useForStdOut) { - if ((outputFile != NULL) && closeOutput) { - TclCloseFile(outputFile); - } - outputFile = file; - closeOutput = mustClose; - } - if (useForStdErr) { - if ((errorFile != NULL) && closeError) { - TclCloseFile(errorFile); - } - errorFile = file; - closeError = (useForStdOut) ? 0 : mustClose; - } - } else if ((argv[i][0] == '2') && (argv[i][1] == '>')) { - int append, atOk, flags; - - if ((errorFile != NULL) && closeError) { - TclCloseFile(errorFile); - } - skip = 1; - p = argv[i] + 2; - if (*p == '>') { - p++; - append = 1; - atOk = 0; - flags = O_WRONLY|O_CREAT; - } else { - append = 0; - atOk = 1; - flags = O_WRONLY|O_CREAT|O_TRUNC; - } - errorFile = FileForRedirect(interp, p, atOk, argv[i], flags, - argv[i+1], &skip, &closeError); - if (errorFile == NULL) { - goto error; - } - if (hasPipes && append) { - TclSeekFile(errorFile, 0L, 2); - } - } else { - continue; - } - for (j = i+skip; j < argc; j++) { - argv[j-skip] = argv[j]; - } - argc -= skip; - i -= 1; /* Process next arg from same position. */ - } - if (argc == 0) { - interp->result = "didn't specify command to execute"; - return -1; - } - - if ((hasPipes && inputFile == NULL) || (!hasPipes && intIn[0] == '\0')) { - if (input != NULL) { - - /* - * The input for the first process is immediate data coming from - * Tcl. Create a temporary file for it and put the data into the - * file. - */ - - inputFile = TclCreateTempFile(input); - closeInput = 1; - if (inputFile == NULL) { - Tcl_AppendResult(interp, - "couldn't create input file for command: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - } else if (inPipePtr != NULL) { - Tcl_File inPipe, outPipe; - /* - * The input for the first process in the pipeline is to - * come from a pipe that can be written from this end. - */ - - if (!hasPipes || TclCreatePipe(&inPipe, &outPipe) == 0) { - Tcl_AppendResult(interp, - "couldn't create input pipe for command: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - inputFile = inPipe; - closeInput = 1; - *inPipePtr = outPipe; - } - } - - /* - * Set up a pipe to receive output from the pipeline, if no other - * output sink has been specified. - */ - - if ((outputFile == NULL) && (outPipePtr != NULL)) { - if (!hasPipes) { - tmpnam(finalOut); - } else { - Tcl_File inPipe, outPipe; - if (TclCreatePipe(&inPipe, &outPipe) == 0) { - Tcl_AppendResult(interp, - "couldn't create output pipe for command: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - outputFile = outPipe; - closeOutput = 1; - *outPipePtr = inPipe; - } - } - - /* - * Set up the standard error output sink for the pipeline, if - * requested. Use a temporary file which is opened, then deleted. - * Could potentially just use pipe, but if it filled up it could - * cause the pipeline to deadlock: we'd be waiting for processes - * to complete before reading stderr, and processes couldn't complete - * because stderr was backed up. - */ - - if (errFilePtr && !errorFile) { - *errFilePtr = TclCreateTempFile(NULL); - if (*errFilePtr == NULL) { - Tcl_AppendResult(interp, - "couldn't create error file for command: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - errorFile = *errFilePtr; - closeError = 0; - } - - /* - * Scan through the argc array, forking off a process for each - * group of arguments between "|" arguments. - */ - - pidPtr = (pid_t *) ckalloc((unsigned) (cmdCount * sizeof(pid_t))); - Tcl_ReapDetachedProcs(); - - if (TclSpawnPipeline(interp, pidPtr, &numPids, argc, argv, - inputFile, outputFile, errorFile, intIn, finalOut) == 0) { - goto error; - } - *pidArrayPtr = pidPtr; - - /* - * All done. Cleanup open files lying around and then return. - */ - -cleanup: - if ((inputFile != NULL) && closeInput) { - TclCloseFile(inputFile); - } - if ((outputFile != NULL) && closeOutput) { - TclCloseFile(outputFile); - } - if ((errorFile != NULL) && closeError) { - TclCloseFile(errorFile); - } - return numPids; - - /* - * An error occurred. There could have been extra files open, such - * as pipes between children. Clean them all up. Detach any child - * processes that have been created. - */ - -error: - if ((inPipePtr != NULL) && (*inPipePtr != NULL)) { - TclCloseFile(*inPipePtr); - *inPipePtr = NULL; - } - if ((outPipePtr != NULL) && (*outPipePtr != NULL)) { - TclCloseFile(*outPipePtr); - *outPipePtr = NULL; - } - if ((errFilePtr != NULL) && (*errFilePtr != NULL)) { - TclCloseFile(*errFilePtr); - *errFilePtr = NULL; - } - if (pidPtr != NULL) { - for (i = 0; i < numPids; i++) { - if (pidPtr[i] != (pid_t)-1) { - Tcl_DetachPids(1, &pidPtr[i]); - } - } - ckfree((char *) pidPtr); - } - numPids = -1; - goto cleanup; -#endif /* !MAC_TCL */ -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetErrno -- - * - * Gets the current value of the Tcl error code variable. This is - * currently the global variable "errno" but could in the future - * change to something else. - * - * Results: - * The value of the Tcl error code variable. - * - * Side effects: - * None. Note that the value of the Tcl error code variable is - * UNDEFINED if a call to Tcl_SetErrno did not precede this call. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetErrno(void) -{ - return errno; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetErrno -- - * - * Sets the Tcl error code variable to the supplied value. - * - * Results: - * None. - * - * Side effects: - * Modifies the value of the Tcl error code variable. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetErrno( - int err /* The new value. */ -) -{ - errno = err; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PosixError -- - * - * This procedure is typically called after UNIX kernel calls - * return errors. It stores machine-readable information about - * the error in $errorCode returns an information string for - * the caller's use. - * - * Results: - * The return value is a human-readable string describing the - * error. - * - * Side effects: - * The global variable $errorCode is reset. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_PosixError( - Tcl_Interp *interp /* Interpreter whose $errorCode variable - * is to be changed. */ -) -{ - char *id, *msg; - - msg = Tcl_ErrnoMsg(errno); - id = Tcl_ErrnoId(); - Tcl_SetErrorCode(interp, "POSIX", id, msg, (char *) NULL); - return msg; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_OpenCommandChannel -- - * - * Opens an I/O channel to one or more subprocesses specified - * by argc and argv. The flags argument determines the - * disposition of the stdio handles. If the TCL_STDIN flag is - * set then the standard input for the first subprocess will - * be tied to the channel: writing to the channel will provide - * input to the subprocess. If TCL_STDIN is not set, then - * standard input for the first subprocess will be the same as - * this application's standard input. If TCL_STDOUT is set then - * standard output from the last subprocess can be read from the - * channel; otherwise it goes to this application's standard - * output. If TCL_STDERR is set, standard error output for all - * subprocesses is returned to the channel and results in an error - * when the channel is closed; otherwise it goes to this - * application's standard error. If TCL_ENFORCE_MODE is not set, - * then argc and argv can redirect the stdio handles to override - * TCL_STDIN, TCL_STDOUT, and TCL_STDERR; if it is set, then it - * is an error for argc and argv to override stdio channels for - * which TCL_STDIN, TCL_STDOUT, and TCL_STDERR have been set. - * - * Results: - * A new command channel, or NULL on failure with an error - * message left in interp. - * - * Side effects: - * Creates processes, opens pipes. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_OpenCommandChannel( - Tcl_Interp *interp, /* Interpreter for error reporting. Can - * NOT be NULL. */ - int argc, /* How many arguments. */ - char **argv, /* Array of arguments for command pipe. */ - int flags /* Or'ed combination of TCL_STDIN, TCL_STDOUT, - * TCL_STDERR, and TCL_ENFORCE_MODE. */ -) -{ - Tcl_File *inPipePtr, *outPipePtr, *errFilePtr; - Tcl_File inPipe, outPipe, errFile; - int numPids; - pid_t *pidPtr; - Tcl_Channel channel; - - inPipe = outPipe = errFile = NULL; - - inPipePtr = (flags & TCL_STDIN) ? &inPipe : NULL; - outPipePtr = (flags & TCL_STDOUT) ? &outPipe : NULL; - errFilePtr = (flags & TCL_STDERR) ? &errFile : NULL; - - numPids = TclCreatePipeline(interp, argc, argv, &pidPtr, inPipePtr, - outPipePtr, errFilePtr); - - if (numPids < 0) { - goto error; - } - - /* - * Verify that the pipes that were created satisfy the - * readable/writable constraints. - */ - - if (flags & TCL_ENFORCE_MODE) { - if ((flags & TCL_STDOUT) && (outPipe == NULL)) { - Tcl_AppendResult(interp, "can't read output from command:", - " standard output was redirected", (char *) NULL); - goto error; - } - if ((flags & TCL_STDIN) && (inPipe == NULL)) { - Tcl_AppendResult(interp, "can't write input to command:", - " standard input was redirected", (char *) NULL); - goto error; - } - } - - channel = TclCreateCommandChannel(outPipe, inPipe, errFile, - numPids, pidPtr); - - if (channel == (Tcl_Channel) NULL) { - Tcl_AppendResult(interp, "pipe for command could not be created", - (char *) NULL); - goto error; - } - return channel; - -error: - if (numPids > 0) { - Tcl_DetachPids(numPids, pidPtr); - ckfree((char *) pidPtr); - } - if (inPipe != NULL) { - TclClosePipeFile(inPipe); - } - if (outPipe != NULL) { - TclClosePipeFile(outPipe); - } - if (errFile != NULL) { - TclClosePipeFile(errFile); - } - return NULL; -} diff --git a/cde/programs/dtdocbook/tcl/tclInt.h b/cde/programs/dtdocbook/tcl/tclInt.h deleted file mode 100644 index aad4be705..000000000 --- a/cde/programs/dtdocbook/tcl/tclInt.h +++ /dev/null @@ -1,1101 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclInt.h /main/4 1996/10/04 10:01:56 drk $ */ -/* - * tclInt.h -- - * - * Declarations of things used internally by the Tcl interpreter. - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclInt.h 1.200 96/04/11 17:24:12 - */ - -#ifndef _TCLINT -#define _TCLINT - -/* - * Common include files needed by most of the Tcl source files are - * included here, so that system-dependent personalizations for the - * include files only have to be made in once place. This results - * in a few extra includes, but greater modularity. The order of - * the three groups of #includes is important. For example, stdio.h - * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is - * needed by stdlib.h in some configurations. - */ - -#include <stdio.h> -#include <stdint.h> - -#include <sys/types.h> /* for pid_t */ - -#ifndef _TCL -#include "tcl.h" -#endif -#ifndef _REGEXP -#include "tclRegexp.h" -#endif - -#include <ctype.h> -#ifdef NO_LIMITS_H -# include "../compat/limits.h" -#else -# include <limits.h> -#endif -#ifdef NO_STDLIB_H -# include "../compat/stdlib.h" -#else -# include <stdlib.h> -#endif -#ifdef NO_STRING_H -#include "../compat/string.h" -#else -#include <string.h> -#endif -#if defined(__STDC__) || defined(HAS_STDARG) -# include <stdarg.h> -#else -# include <varargs.h> -#endif - -/* - *---------------------------------------------------------------- - * Data structures related to variables. These are used primarily - * in tclVar.c - *---------------------------------------------------------------- - */ - -/* - * The following structure defines a variable trace, which is used to - * invoke a specific C procedure whenever certain operations are performed - * on a variable. - */ - -typedef struct VarTrace { - Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given - * by flags are performed on variable. */ - ClientData clientData; /* Argument to pass to proc. */ - int flags; /* What events the trace procedure is - * interested in: OR-ed combination of - * TCL_TRACE_READS, TCL_TRACE_WRITES, and - * TCL_TRACE_UNSETS. */ - struct VarTrace *nextPtr; /* Next in list of traces associated with - * a particular variable. */ -} VarTrace; - -/* - * When a variable trace is active (i.e. its associated procedure is - * executing), one of the following structures is linked into a list - * associated with the variable's interpreter. The information in - * the structure is needed in order for Tcl to behave reasonably - * if traces are deleted while traces are active. - */ - -typedef struct ActiveVarTrace { - struct Var *varPtr; /* Variable that's being traced. */ - struct ActiveVarTrace *nextPtr; - /* Next in list of all active variable - * traces for the interpreter, or NULL - * if no more. */ - VarTrace *nextTracePtr; /* Next trace to check after current - * trace procedure returns; if this - * trace gets deleted, must update pointer - * to avoid using free'd memory. */ -} ActiveVarTrace; - -/* - * The following structure describes an enumerative search in progress on - * an array variable; this are invoked with options to the "array" - * command. - */ - -typedef struct ArraySearch { - int id; /* Integer id used to distinguish among - * multiple concurrent searches for the - * same array. */ - struct Var *varPtr; /* Pointer to array variable that's being - * searched. */ - Tcl_HashSearch search; /* Info kept by the hash module about - * progress through the array. */ - Tcl_HashEntry *nextEntry; /* Non-null means this is the next element - * to be enumerated (it's leftover from - * the Tcl_FirstHashEntry call or from - * an "array anymore" command). NULL - * means must call Tcl_NextHashEntry - * to get value to return. */ - struct ArraySearch *nextPtr;/* Next in list of all active searches - * for this variable, or NULL if this is - * the last one. */ -} ArraySearch; - -/* - * The structure below defines a variable, which associates a string name - * with a string value. Pointers to these structures are kept as the - * values of hash table entries, and the name of each variable is stored - * in the hash entry. - */ - -typedef struct Var { - int valueLength; /* Holds the number of non-null bytes - * actually occupied by the variable's - * current value in value.string (extra - * space is sometimes left for expansion). - * For array and global variables this is - * meaningless. */ - int valueSpace; /* Total number of bytes of space allocated - * at value.string. 0 means there is no - * space allocated. */ - union { - char *string; /* String value of variable, used for scalar - * variables and array elements. Malloc-ed. */ - Tcl_HashTable *tablePtr;/* For array variables, this points to - * information about the hash table used - * to implement the associative array. - * Points to malloc-ed data. */ - struct Var *upvarPtr; /* If this is a global variable being - * referred to in a procedure, or a variable - * created by "upvar", this field points to - * the record for the higher-level variable. */ - } value; - Tcl_HashEntry *hPtr; /* Hash table entry that refers to this - * variable, or NULL if the variable has - * been detached from its hash table (e.g. - * an array is deleted, but some of its - * elements are still referred to in upvars). */ - int refCount; /* Counts number of active uses of this - * variable, not including its main hash - * table entry: 1 for each additional variable - * whose upVarPtr points here, 1 for each - * nested trace active on variable. This - * record can't be deleted until refCount - * becomes 0. */ - VarTrace *tracePtr; /* First in list of all traces set for this - * variable. */ - ArraySearch *searchPtr; /* First in list of all searches active - * for this variable, or NULL if none. */ - int flags; /* Miscellaneous bits of information about - * variable. See below for definitions. */ -} Var; - -/* - * Flag bits for variables: - * - * VAR_ARRAY - 1 means this is an array variable rather - * than a scalar variable. - * VAR_UPVAR - 1 means this variable just contains a - * pointer to another variable that has the - * real value. Variables like this come - * about through the "upvar" and "global" - * commands. - * VAR_UNDEFINED - 1 means that the variable is currently - * undefined. Undefined variables usually - * go away completely, but if an undefined - * variable has a trace on it, or if it is - * a global variable being used by a procedure, - * then it stays around even when undefined. - * VAR_TRACE_ACTIVE - 1 means that trace processing is currently - * underway for a read or write access, so - * new read or write accesses should not cause - * trace procedures to be called and the - * variable can't be deleted. - */ - -#define VAR_ARRAY 1 -#define VAR_UPVAR 2 -#define VAR_UNDEFINED 4 -#define VAR_TRACE_ACTIVE 0x10 - -/* - *---------------------------------------------------------------- - * Data structures related to procedures. These are used primarily - * in tclProc.c - *---------------------------------------------------------------- - */ - -/* - * The structure below defines an argument to a procedure, which - * consists of a name and an (optional) default value. - */ - -typedef struct Arg { - struct Arg *nextPtr; /* Next argument for this procedure, - * or NULL if this is the last argument. */ - char *defValue; /* Pointer to arg's default value, or NULL - * if no default value. */ - char name[4]; /* Name of argument starts here. The name - * is followed by space for the default, - * if there is one. The actual size of this - * field will be as large as necessary to - * hold both name and default value. THIS - * MUST BE THE LAST FIELD IN THE STRUCTURE!! */ -} Arg; - -/* - * The structure below defines a command procedure, which consists of - * a collection of Tcl commands plus information about arguments and - * variables. - */ - -typedef struct Proc { - struct Interp *iPtr; /* Interpreter for which this command - * is defined. */ - int refCount; /* Reference count: 1 if still present - * in command table plus 1 for each call - * to the procedure that is currently - * active. This structure can be freed - * when refCount becomes zero. */ - char *command; /* Command that constitutes the body of - * the procedure (dynamically allocated). */ - Arg *argPtr; /* Pointer to first of procedure's formal - * arguments, or NULL if none. */ -} Proc; - -/* - * The structure below defines a command trace. This is used to allow Tcl - * clients to find out whenever a command is about to be executed. - */ - -typedef struct Trace { - int level; /* Only trace commands at nesting level - * less than or equal to this. */ - Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */ - ClientData clientData; /* Arbitrary value to pass to proc. */ - struct Trace *nextPtr; /* Next in list of traces for this interp. */ -} Trace; - -/* - * The structure below defines an entry in the assocData hash table which - * is associated with an interpreter. The entry contains a pointer to a - * function to call when the interpreter is deleted, and a pointer to - * a user-defined piece of data. - */ - -typedef struct AssocData { - Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */ - ClientData clientData; /* Value to pass to proc. */ -} AssocData; - -/* - * The structure below defines a frame, which is a procedure invocation. - * These structures exist only while procedures are being executed, and - * provide a sort of call stack. - */ - -typedef struct CallFrame { - Tcl_HashTable varTable; /* Hash table containing all of procedure's - * local variables. */ - int level; /* Level of this procedure, for "uplevel" - * purposes (i.e. corresponds to nesting of - * callerVarPtr's, not callerPtr's). 1 means - * outer-most procedure, 0 means top-level. */ - int argc; /* This and argv below describe name and - * arguments for this procedure invocation. */ - char **argv; /* Array of arguments. */ - struct CallFrame *callerPtr; - /* Value of interp->framePtr when this - * procedure was invoked (i.e. next in - * stack of all active procedures). */ - struct CallFrame *callerVarPtr; - /* Value of interp->varFramePtr when this - * procedure was invoked (i.e. determines - * variable scoping within caller; same - * as callerPtr unless an "uplevel" command - * or something equivalent was active in - * the caller). */ -} CallFrame; - -/* - * The structure below defines one history event (a previously-executed - * command that can be re-executed in whole or in part). - */ - -typedef struct { - char *command; /* String containing previously-executed - * command. */ - int bytesAvl; /* Total # of bytes available at *event (not - * all are necessarily in use now). */ -} HistoryEvent; - -/* - *---------------------------------------------------------------- - * Data structures related to history. These are used primarily - * in tclHistory.c - *---------------------------------------------------------------- - */ - -/* - * The structure below defines a pending revision to the most recent - * history event. Changes are linked together into a list and applied - * during the next call to Tcl_RecordHistory. See the comments at the - * beginning of tclHistory.c for information on revisions. - */ - -typedef struct HistoryRev { - int firstIndex; /* Index of the first byte to replace in - * current history event. */ - int lastIndex; /* Index of last byte to replace in - * current history event. */ - int newSize; /* Number of bytes in newBytes. */ - char *newBytes; /* Replacement for the range given by - * firstIndex and lastIndex (malloced). */ - struct HistoryRev *nextPtr; /* Next in chain of revisions to apply, or - * NULL for end of list. */ -} HistoryRev; - -/* - *---------------------------------------------------------------- - * Data structures related to expressions. These are used only in - * tclExpr.c. - *---------------------------------------------------------------- - */ - -/* - * The data structure below defines a math function (e.g. sin or hypot) - * for use in Tcl expressions. - */ - -#define MAX_MATH_ARGS 5 -typedef struct MathFunc { - int numArgs; /* Number of arguments for function. */ - Tcl_ValueType argTypes[MAX_MATH_ARGS]; - /* Acceptable types for each argument. */ - Tcl_MathProc *proc; /* Procedure that implements this function. */ - ClientData clientData; /* Additional argument to pass to the function - * when invoking it. */ -} MathFunc; - -/* - *---------------------------------------------------------------- - * One of the following structures exists for each command in - * an interpreter. The Tcl_Command opaque type actually refers - * to these structures. - *---------------------------------------------------------------- - */ - -typedef struct Command { - Tcl_HashEntry *hPtr; /* Pointer to the hash table entry in - * interp->commandTable that refers to - * this command. Used to get a command's - * name from its Tcl_Command handle. NULL - * means that the hash table entry has - * been removed already (this can happen - * if deleteProc causes the command to be - * deleted or recreated). */ - Tcl_CmdProc *proc; /* Procedure to process command. */ - ClientData clientData; /* Arbitrary value to pass to proc. */ - Tcl_CmdDeleteProc *deleteProc; - /* Procedure to invoke when deleting - * command. */ - ClientData deleteData; /* Arbitrary value to pass to deleteProc - * (usually the same as clientData). */ - int deleted; /* Means that the command is in the process - * of being deleted (its deleteProc is - * currently executing). Any other attempts - * to delete the command should be ignored. */ -} Command; - -/* - *---------------------------------------------------------------- - * This structure defines an interpreter, which is a collection of - * commands plus other state information related to interpreting - * commands, such as variable storage. Primary responsibility for - * this data structure is in tclBasic.c, but almost every Tcl - * source file uses something in here. - *---------------------------------------------------------------- - */ - -typedef struct Interp { - - /* - * Note: the first three fields must match exactly the fields in - * a Tcl_Interp struct (see tcl.h). If you change one, be sure to - * change the other. - */ - - char *result; /* Points to result returned by last - * command. */ - Tcl_FreeProc *freeProc; /* Zero means result is statically allocated. - * TCL_DYNAMIC means result was allocated with - * ckalloc and should be freed with ckfree. - * Other values give address of procedure - * to invoke to free the result. Must be - * freed by Tcl_Eval before executing next - * command. */ - int errorLine; /* When TCL_ERROR is returned, this gives - * the line number within the command where - * the error occurred (1 means first line). */ - Tcl_HashTable commandTable; /* Contains all of the commands currently - * registered in this interpreter. Indexed - * by strings; values have type (Command *). */ - Tcl_HashTable mathFuncTable;/* Contains all of the math functions currently - * defined for the interpreter. Indexed by - * strings (function names); values have - * type (MathFunc *). */ - - /* - * Information related to procedures and variables. See tclProc.c - * and tclvar.c for usage. - */ - - Tcl_HashTable globalTable; /* Contains all global variables for - * interpreter. */ - int numLevels; /* Keeps track of how many nested calls to - * Tcl_Eval are in progress for this - * interpreter. It's used to delay deletion - * of the table until all Tcl_Eval invocations - * are completed. */ - int maxNestingDepth; /* If numLevels exceeds this value then Tcl - * assumes that infinite recursion has - * occurred and it generates an error. */ - CallFrame *framePtr; /* Points to top-most in stack of all nested - * procedure invocations. NULL means there - * are no active procedures. */ - CallFrame *varFramePtr; /* Points to the call frame whose variables - * are currently in use (same as framePtr - * unless an "uplevel" command is being - * executed). NULL means no procedure is - * active or "uplevel 0" is being exec'ed. */ - ActiveVarTrace *activeTracePtr; - /* First in list of active traces for interp, - * or NULL if no active traces. */ - int returnCode; /* Completion code to return if current - * procedure exits with a TCL_RETURN code. */ - char *errorInfo; /* Value to store in errorInfo if returnCode - * is TCL_ERROR. Malloc'ed, may be NULL */ - char *errorCode; /* Value to store in errorCode if returnCode - * is TCL_ERROR. Malloc'ed, may be NULL */ - - /* - * Information related to history: - */ - - int numEvents; /* Number of previously-executed commands - * to retain. */ - HistoryEvent *events; /* Array containing numEvents entries - * (dynamically allocated). */ - int curEvent; /* Index into events of place where current - * (or most recent) command is recorded. */ - int curEventNum; /* Event number associated with the slot - * given by curEvent. */ - HistoryRev *revPtr; /* First in list of pending revisions. */ - char *historyFirst; /* First char. of current command executed - * from history module or NULL if none. */ - int revDisables; /* 0 means history revision OK; > 0 gives - * a count of number of times revision has - * been disabled. */ - char *evalFirst; /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval - * sets this field to point to the first - * char. of text from which the current - * command came. Otherwise Tcl_Eval sets - * this to NULL. */ - char *evalLast; /* Similar to evalFirst, except points to - * last character of current command. */ - - /* - * Information used by Tcl_AppendResult to keep track of partial - * results. See Tcl_AppendResult code for details. - */ - - char *appendResult; /* Storage space for results generated - * by Tcl_AppendResult. Malloc-ed. NULL - * means not yet allocated. */ - int appendAvl; /* Total amount of space available at - * partialResult. */ - int appendUsed; /* Number of non-null bytes currently - * stored at partialResult. */ - - /* - * A cache of compiled regular expressions. See Tcl_RegExpCompile - * in tclUtil.c for details. - */ - -#define NUM_REGEXPS 5 - char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled - * regular expression patterns. NULL - * means that this slot isn't used. - * Malloc-ed. */ - int patLengths[NUM_REGEXPS];/* Number of non-null characters in - * corresponding entry in patterns. - * -1 means entry isn't used. */ - regexp *regexps[NUM_REGEXPS]; - /* Compiled forms of above strings. Also - * malloc-ed, or NULL if not in use yet. */ - - /* - * Information about packages. Used only in tclPkg.c. - */ - - Tcl_HashTable packageTable; /* Describes all of the packages loaded - * in or available to this interpreter. - * Keys are package names, values are - * (Package *) pointers. */ - char *packageUnknown; /* Command to invoke during "package - * require" commands for packages that - * aren't described in packageTable. - * Malloc'ed, may be NULL. */ - - /* - * Information used by Tcl_PrintDouble: - */ - - char pdFormat[10]; /* Format string used by Tcl_PrintDouble. */ - int pdPrec; /* Current precision (used to restore the - * the tcl_precision variable after a bogus - * value has been put into it). */ - - /* - * Miscellaneous information: - */ - - int cmdCount; /* Total number of times a command procedure - * has been called for this interpreter. */ - int noEval; /* Non-zero means no commands should actually - * be executed: just parse only. Used in - * expressions when the result is already - * determined. */ - int evalFlags; /* Flags to control next call to Tcl_Eval. - * Normally zero, but may be set before - * calling Tcl_Eval. See below for valid - * values. */ - char *termPtr; /* Character just after the last one in - * a command. Set by Tcl_Eval before - * returning. */ - char *scriptFile; /* NULL means there is no nested source - * command active; otherwise this points to - * the name of the file being sourced (it's - * not malloc-ed: it points to an argument - * to Tcl_EvalFile. */ - int flags; /* Various flag bits. See below. */ - Trace *tracePtr; /* List of traces for this interpreter. */ - Tcl_HashTable *assocData; /* Hash table for associating data with - * this interpreter. Cleaned up when - * this interpreter is deleted. */ - char resultSpace[TCL_RESULT_SIZE+1]; - /* Static space for storing small results. */ -} Interp; - -/* - * EvalFlag bits for Interp structures: - * - * TCL_BRACKET_TERM 1 means that the current script is terminated by - * a close bracket rather than the end of the string. - * TCL_RECORD_BOUNDS Tells Tcl_Eval to record information in the - * evalFirst and evalLast fields for each command - * executed directly from the string (top-level - * commands and those from command substitution). - * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with - * a code other than TCL_OK or TCL_ERROR; 0 means - * codes other than these should be turned into errors. - */ - -#define TCL_BRACKET_TERM 1 -#define TCL_RECORD_BOUNDS 2 -#define TCL_ALLOW_EXCEPTIONS 4 - -/* - * Flag bits for Interp structures: - * - * DELETED: Non-zero means the interpreter has been deleted: - * don't process any more commands for it, and destroy - * the structure as soon as all nested invocations of - * Tcl_Eval are done. - * ERR_IN_PROGRESS: Non-zero means an error unwind is already in progress. - * Zero means a command proc has been invoked since last - * error occurred. - * ERR_ALREADY_LOGGED: Non-zero means information has already been logged - * in $errorInfo for the current Tcl_Eval instance, - * so Tcl_Eval needn't log it (used to implement the - * "error message log" command). - * ERROR_CODE_SET: Non-zero means that Tcl_SetErrorCode has been - * called to record information for the current - * error. Zero means Tcl_Eval must clear the - * errorCode variable if an error is returned. - * EXPR_INITIALIZED: 1 means initialization specific to expressions has - * been carried out. - */ - -#define DELETED 1 -#define ERR_IN_PROGRESS 2 -#define ERR_ALREADY_LOGGED 4 -#define ERROR_CODE_SET 8 -#define EXPR_INITIALIZED 0x10 - -/* - * Default value for the pdPrec and pdFormat fields of interpreters: - */ - -#define DEFAULT_PD_PREC 6 -#define DEFAULT_PD_FORMAT "%g" - -/* - *---------------------------------------------------------------- - * Data structures related to command parsing. These are used in - * tclParse.c and its clients. - *---------------------------------------------------------------- - */ - -/* - * The following data structure is used by various parsing procedures - * to hold information about where to store the results of parsing - * (e.g. the substituted contents of a quoted argument, or the result - * of a nested command). At any given time, the space available - * for output is fixed, but a procedure may be called to expand the - * space available if the current space runs out. - */ - -typedef struct ParseValue { - char *buffer; /* Address of first character in - * output buffer. */ - char *next; /* Place to store next character in - * output buffer. */ - char *end; /* Address of the last usable character - * in the buffer. */ - void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed)); - /* Procedure to call when space runs out; - * it will make more space. */ - ClientData clientData; /* Arbitrary information for use of - * expandProc. */ -} ParseValue; - -/* - * A table used to classify input characters to assist in parsing - * Tcl commands. The table should be indexed with a signed character - * using the CHAR_TYPE macro. The character may have a negative - * value. - */ - -extern char tclTypeTable[]; -#define CHAR_TYPE(c) (tclTypeTable+128)[c] - -/* - * Possible values returned by CHAR_TYPE: - * - * TCL_NORMAL - All characters that don't have special significance - * to the Tcl language. - * TCL_SPACE - Character is space, tab, or return. - * TCL_COMMAND_END - Character is newline or null or semicolon or - * close-bracket. - * TCL_QUOTE - Character is a double-quote. - * TCL_OPEN_BRACKET - Character is a "[". - * TCL_OPEN_BRACE - Character is a "{". - * TCL_CLOSE_BRACE - Character is a "}". - * TCL_BACKSLASH - Character is a "\". - * TCL_DOLLAR - Character is a "$". - */ - -#define TCL_NORMAL 0 -#define TCL_SPACE 1 -#define TCL_COMMAND_END 2 -#define TCL_QUOTE 3 -#define TCL_OPEN_BRACKET 4 -#define TCL_OPEN_BRACE 5 -#define TCL_CLOSE_BRACE 6 -#define TCL_BACKSLASH 7 -#define TCL_DOLLAR 8 - -/* - * Maximum number of levels of nesting permitted in Tcl commands (used - * to catch infinite recursion). - */ - -#define MAX_NESTING_DEPTH 1000 - -/* - * The macro below is used to modify a "char" value (e.g. by casting - * it to an unsigned character) so that it can be used safely with - * macros such as isspace. - */ - -#define UCHAR(c) ((unsigned char) (c)) - -/* - * Given a size or address, the macro below "aligns" it to the machine's - * memory unit size (e.g. an 8-byte boundary) so that anything can be - * placed at the aligned address without fear of an alignment error. - */ - -#define TCL_ALIGN(x) ((x + 7) & ~7) - -/* - * For each event source (created with Tcl_CreateEventSource) there - * is a structure of the following type: - */ - -typedef struct TclEventSource { - Tcl_EventSetupProc *setupProc; /* This procedure is called by - * Tcl_DoOneEvent to set up information - * for the wait operation, such as - * files to wait for or maximum - * timeout. */ - Tcl_EventCheckProc *checkProc; /* This procedure is called by - * Tcl_DoOneEvent after its wait - * operation to see what events - * are ready and queue them. */ - ClientData clientData; /* Arbitrary one-word argument to pass - * to setupProc and checkProc. */ - struct TclEventSource *nextPtr; /* Next in list of all event sources - * defined for applicaton. */ -} TclEventSource; - -/* - * The following macros are used to specify the runtime platform - * setting of the tclPlatform variable. - */ - -typedef enum { - TCL_PLATFORM_UNIX, /* Any Unix-like OS. */ - TCL_PLATFORM_MAC, /* MacOS. */ - TCL_PLATFORM_WINDOWS /* Any Microsoft Windows OS. */ -} TclPlatformType; - -/* - *---------------------------------------------------------------- - * Variables shared among Tcl modules but not used by the outside - * world: - *---------------------------------------------------------------- - */ - -extern Tcl_Time tclBlockTime; -extern int tclBlockTimeSet; -extern char * tclExecutableName; -extern TclEventSource * tclFirstEventSourcePtr; -extern Tcl_ChannelType tclFileChannelType; -extern char * tclMemDumpFileName; -extern TclPlatformType tclPlatform; - -/* - *---------------------------------------------------------------- - * Procedures shared among Tcl modules but not used by the outside - * world: - *---------------------------------------------------------------- - */ - -EXTERN void panic(); -EXTERN int TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp, - int numPids, pid_t *pidPtr, Tcl_Channel errorChan)); -EXTERN int TclCloseFile _ANSI_ARGS_((Tcl_File file)); -EXTERN char * TclConvertToNative _ANSI_ARGS_((Tcl_Interp *interp, - char *name, Tcl_DString *bufferPtr)); -EXTERN char * TclConvertToNetwork _ANSI_ARGS_((Tcl_Interp *interp, - char *name, Tcl_DString *bufferPtr)); -EXTERN void TclCopyAndCollapse _ANSI_ARGS_((int count, char *src, - char *dst)); -EXTERN int TclChdir _ANSI_ARGS_((Tcl_Interp *interp, - char *dirName)); -EXTERN void TclClosePipeFile _ANSI_ARGS_((Tcl_File file)); -EXTERN Tcl_Channel TclCreateCommandChannel _ANSI_ARGS_(( - Tcl_File readFile, Tcl_File writeFile, - Tcl_File errorFile, int numPids, pid_t *pidPtr)); -EXTERN int TclCreatePipe _ANSI_ARGS_((Tcl_File *readPipe, - Tcl_File *writePipe)); -EXTERN int TclCreatePipeline _ANSI_ARGS_((Tcl_Interp *interp, - int argc, char **argv, pid_t **pidArrayPtr, - Tcl_File *inPipePtr, - Tcl_File *outPipePtr, - Tcl_File *errFilePtr)); -EXTERN Tcl_File TclCreateTempFile _ANSI_ARGS_((char *contents)); -EXTERN void TclDeleteVars _ANSI_ARGS_((Interp *iPtr, - Tcl_HashTable *tablePtr)); -EXTERN int TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp, - char *separators, Tcl_DString *headPtr, - char *tail)); -EXTERN void TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr, - int needed)); -EXTERN void TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp, - double value)); -EXTERN int TclFindElement _ANSI_ARGS_((Tcl_Interp *interp, - char *list, char **elementPtr, char **nextPtr, - int *sizePtr, int *bracePtr)); -EXTERN Proc * TclFindProc _ANSI_ARGS_((Interp *iPtr, - char *procName)); -EXTERN void TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr)); -EXTERN char * TclGetCwd _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN unsigned long TclGetClicks _ANSI_ARGS_((void)); -EXTERN char * TclGetExtension _ANSI_ARGS_((char *name)); -EXTERN void TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Channel chan)); -EXTERN int TclGetDate _ANSI_ARGS_((char *p, - unsigned long now, long zone, - unsigned long *timePtr)); -EXTERN Tcl_Channel TclGetDefaultStdChannel _ANSI_ARGS_((int type)); -EXTERN char * TclGetEnv _ANSI_ARGS_((char *name)); -EXTERN int TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp, - char *string, CallFrame **framePtrPtr)); -EXTERN int TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int *seekFlagPtr)); -EXTERN unsigned long TclGetSeconds _ANSI_ARGS_((void)); -EXTERN void TclGetTime _ANSI_ARGS_((Tcl_Time *time)); -EXTERN int TclGetTimeZone _ANSI_ARGS_((unsigned long time)); -EXTERN char * TclGetUserHome _ANSI_ARGS_((char *name, - Tcl_DString *bufferPtr)); -EXTERN int TclGetListIndex _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int *indexPtr)); -EXTERN int TclGetLoadedPackages _ANSI_ARGS_((Tcl_Interp *interp, - char *targetName)); -EXTERN char * TclGetUserHome _ANSI_ARGS_((char *name, - Tcl_DString *bufferPtr)); -EXTERN int TclGuessPackageName _ANSI_ARGS_((char *fileName, - Tcl_DString *bufPtr)); -EXTERN int TclHasPipes _ANSI_ARGS_((void)); -EXTERN int TclHasSockets _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN int TclIdlePending _ANSI_ARGS_((void)); -EXTERN int TclInterpInit _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN Proc * TclIsProc _ANSI_ARGS_((Command *cmdPtr)); -EXTERN int TclLoadFile _ANSI_ARGS_((Tcl_Interp *interp, - char *fileName, char *sym1, char *sym2, - Tcl_PackageInitProc **proc1Ptr, - Tcl_PackageInitProc **proc2Ptr)); -EXTERN int TclMakeFileTable _ANSI_ARGS_((Tcl_Interp *interp, - int noStdio)); -EXTERN int TclMatchFiles _ANSI_ARGS_((Tcl_Interp *interp, - char *separators, Tcl_DString *dirPtr, - char *pattern, char *tail)); -EXTERN int TclNeedSpace _ANSI_ARGS_((char *start, char *end)); -EXTERN Tcl_File TclOpenFile _ANSI_ARGS_((char *fname, int mode)); -EXTERN int TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp, - char *string, char **termPtr, ParseValue *pvPtr)); -EXTERN int TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int flags, char **termPtr, - ParseValue *pvPtr)); -EXTERN int TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int termChar, int flags, - char **termPtr, ParseValue *pvPtr)); -EXTERN int TclParseWords _ANSI_ARGS_((Tcl_Interp *interp, - char *string, int flags, int maxWords, - char **termPtr, int *argcPtr, char **argv, - ParseValue *pvPtr)); -EXTERN void TclPlatformExit _ANSI_ARGS_((int status)); -EXTERN void TclPlatformInit _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN char * TclPrecTraceProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); -EXTERN int TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Interp *cmdInterp, char *cmdName, - Tcl_CmdProc *proc, ClientData clientData)); -EXTERN int TclReadFile _ANSI_ARGS_((Tcl_File file, - int shouldBlock, char *buf, int toRead)); -EXTERN int TclSeekFile _ANSI_ARGS_((Tcl_File file, - int offset, int whence)); -EXTERN int TclServiceIdle _ANSI_ARGS_((void)); -EXTERN void TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp)); -EXTERN int TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp, - char *string, char *proto, int *portPtr)); -EXTERN int TclSockMinimumBuffers _ANSI_ARGS_((int sock, - int size)); -EXTERN int TclSpawnPipeline _ANSI_ARGS_((Tcl_Interp *interp, - pid_t *pidPtr, int *numPids, int argc, char **argv, - Tcl_File inputFile, - Tcl_File outputFile, - Tcl_File errorFile, - char *intIn, char *finalOut)); -EXTERN int TclTestChannelCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int TclTestChannelEventCmd _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp, - int argc, char **argv)); -EXTERN int TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr)); -EXTERN int TclWaitForFile _ANSI_ARGS_((Tcl_File file, - int mask, int timeout)); -EXTERN char * TclWordEnd _ANSI_ARGS_((char *start, int nested, - int *semiPtr)); -EXTERN int TclWriteFile _ANSI_ARGS_((Tcl_File file, - int shouldBlock, char *buf, int toWrite)); - -/* - *---------------------------------------------------------------- - * Command procedures in the generic core: - *---------------------------------------------------------------- - */ - -EXTERN int Tcl_AfterCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_AppendCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ArrayCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_CaseCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_CatchCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_CdCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ClockCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_CloseCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ConcatCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_CpCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_EofCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ErrorCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_EvalCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ExitCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ExprCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FblockedCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FconfigureCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FileCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FileEventCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FlushCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ForCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ForeachCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_FormatCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_GetsCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_GlobalCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_IfCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_InfoCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_InterpCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_JoinCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LappendCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LindexCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LinsertCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LlengthCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ListCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LoadCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LrangeCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LreplaceCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LsCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LsearchCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_LsortCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_MacBeepCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_MacSourceCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_MkdirCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_MvCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_PackageCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_PidCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ProcCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_PutsCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ReadCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_RenameCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ReturnCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_RmCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_RmdirCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SplitCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SocketCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SourceCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_StringCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SubstCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_SwitchCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_TellCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_TimeCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_UnsetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_UpdateCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_UplevelCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_UpvarCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_VwaitCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int TclUnsupported0Cmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); - -#endif /* _TCLINT */ diff --git a/cde/programs/dtdocbook/tcl/tclInterp.c b/cde/programs/dtdocbook/tcl/tclInterp.c deleted file mode 100644 index 2edc352f5..000000000 --- a/cde/programs/dtdocbook/tcl/tclInterp.c +++ /dev/null @@ -1,2434 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $TOG: tclInterp.c /main/3 1998/04/17 11:24:35 mgreess $ */ -/* - * tclInterp.c -- - * - * This file implements the "interp" command which allows creation - * and manipulation of Tcl interpreters from within Tcl scripts. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclInterp.c 1.66 96/04/15 17:26:10 - */ - -#include <stdio.h> -#include "tclInt.h" -#include "tclPort.h" - -/* - * Counter for how many aliases were created (global) - */ - -static int aliasCounter = 0; - -/* - * - * struct Slave: - * - * Used by the "interp" command to record and find information about slave - * interpreters. Maps from a command name in the master to information about - * a slave interpreter, e.g. what aliases are defined in it. - */ - -typedef struct { - Tcl_Interp *masterInterp; /* Master interpreter for this slave. */ - Tcl_HashEntry *slaveEntry; /* Hash entry in masters slave table for - * this slave interpreter. Used to find - * this record, and used when deleting the - * slave interpreter to delete it from the - * masters table. */ - Tcl_Interp *slaveInterp; /* The slave interpreter. */ - Tcl_Command interpCmd; /* Interpreter object command. */ - Tcl_HashTable aliasTable; /* Table which maps from names of commands - * in slave interpreter to struct Alias - * defined below. */ -} Slave; - -/* - * struct Alias: - * - * Stores information about an alias. Is stored in the slave interpreter - * and used by the source command to find the target command in the master - * when the source command is invoked. - */ - -typedef struct { - char *aliasName; /* Name of alias command. */ - char *targetName; /* Name of target command in master interp. */ - Tcl_Interp *targetInterp; /* Master interpreter. */ - int argc; /* Count of additional args to pass. */ - char **argv; /* Actual additional args to pass. */ - Tcl_HashEntry *aliasEntry; /* Entry for the alias hash table in slave. - * This is used by alias deletion to remove - * the alias from the slave interpreter - * alias table. */ - Tcl_HashEntry *targetEntry; /* Entry for target command in master. - * This is used in the master interpreter to - * map back from the target command to aliases - * redirecting to it. Random access to this - * hash table is never required - we are using - * a hash table only for convenience. */ - Tcl_Command slaveCmd; /* Source command in slave interpreter. */ -} Alias; - -/* - * struct Target: - * - * Maps from master interpreter commands back to the source commands in slave - * interpreters. This is needed because aliases can be created between sibling - * interpreters and must be deleted when the target interpreter is deleted. In - * case they would not be deleted the source interpreter would be left with a - * "dangling pointer". One such record is stored in the Master record of the - * master interpreter (in the targetTable hashtable, see below) with the - * master for each alias which directs to a command in the master. These - * records are used to remove the source command for an from a slave if/when - * the master is deleted. - */ - -typedef struct { - Tcl_Command slaveCmd; /* Command for alias in slave interp. */ - Tcl_Interp *slaveInterp; /* Slave Interpreter. */ -} Target; - -/* - * struct Master: - * - * This record is used for three purposes: First, slaveTable (a hashtable) - * maps from names of commands to slave interpreters. This hashtable is - * used to store information about slave interpreters of this interpreter, - * to map over all slaves, etc. The second purpose is to store information - * about all aliases in slaves (or siblings) which direct to target commands - * in this interpreter (using the targetTable hashtable). The third field in - * the record, isSafe, denotes whether the interpreter is safe or not. Safe - * interpreters have restricted functionality, can only create safe slave - * interpreters and can only load safe extensions. - */ - -typedef struct { - Tcl_HashTable slaveTable; /* Hash table for slave interpreters. - * Maps from command names to Slave records. */ - int isSafe; /* Am I a "safe" interpreter? */ - Tcl_HashTable targetTable; /* Hash table for Target Records. Contains - * all Target records which denote aliases - * from slaves or sibling interpreters that - * direct to commands in this interpreter. This - * table is used to remove dangling pointers - * from the slave (or sibling) interpreters - * when this interpreter is deleted. */ -} Master; - -/* - * Prototypes for local static procedures: - */ - -static int AliasCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *currentInterp, int argc, char **argv)); -static void AliasCmdDeleteProc _ANSI_ARGS_(( - ClientData clientData)); -static int AliasHelper _ANSI_ARGS_((Tcl_Interp *curInterp, - Tcl_Interp *slaveInterp, Tcl_Interp *masterInterp, - Master *masterPtr, char *aliasName, - char *targetName, int argc, char **argv)); -static int CreateInterpObject _ANSI_ARGS_((Tcl_Interp *interp, - int argc, char **argv)); -static Tcl_Interp *CreateSlave _ANSI_ARGS_((Tcl_Interp *interp, - char *slavePath, int safe)); -static int DeleteAlias _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Interp *slaveInterp, char *aliasName)); -static int DescribeAlias _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Interp *slaveInterp, char *aliasName)); -static int DeleteInterpObject _ANSI_ARGS_((Tcl_Interp *interp, - int argc, char **argv)); -static int DeleteOneInterpObject _ANSI_ARGS_((Tcl_Interp *interp, - char *path)); -static Tcl_Interp *GetInterp _ANSI_ARGS_((Tcl_Interp *interp, - Master *masterPtr, char *path, - Master **masterPtrPtr)); -static int GetTarget _ANSI_ARGS_((Tcl_Interp *interp, char *path, - char *aliasName)); -static void MasterRecordDeleteProc _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp)); -static int MakeSafe _ANSI_ARGS_((Tcl_Interp *interp)); -static int SlaveAliasHelper _ANSI_ARGS_((Tcl_Interp *interp, - int argc, char **argv)); -static int SlaveObjectCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); -static void SlaveObjectDeleteProc _ANSI_ARGS_(( - ClientData clientData)); -static void SlaveRecordDeleteProc _ANSI_ARGS_(( - ClientData clientData, Tcl_Interp *interp)); - -/* - * These are all the Tcl core commands which are available in a safe - * interpeter: - */ - -static char *TclCommandsToKeep[] = { - "after", "append", "array", - "break", - "case", "catch", "clock", "close", "concat", "continue", - "eof", "error", "eval", "expr", - "fblocked", "fconfigure", "flush", "for", "foreach", "format", - "gets", "global", - "history", - "if", "incr", "info", "interp", - "join", - "lappend", "lindex", "linsert", "list", "llength", "lower", "lrange", - "lreplace", "lsearch", "lsort", - "package", "pid", "proc", "puts", - "read", "regexp", "regsub", "rename", "return", - "scan", "seek", "set", "split", "string", "switch", - "tell", "trace", - "unset", "update", "uplevel", "upvar", - "vwait", - "while", - NULL}; -static int TclCommandsToKeepCt = - (sizeof (TclCommandsToKeep) / sizeof (char *)) -1 ; - -/* - *---------------------------------------------------------------------- - * - * TclPreventAliasLoop -- - * - * When defining an alias or renaming a command, prevent an alias - * loop from being formed. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * If TCL_ERROR is returned, the function also sets interp->result - * to an error message. - * - * NOTE: - * This function is public internal (instead of being static to - * this file) because it is also used from Tcl_RenameCmd. - * - *---------------------------------------------------------------------- - */ - -int -TclPreventAliasLoop( - Tcl_Interp *interp, /* Interp in which to report errors. */ - Tcl_Interp *cmdInterp, /* Interp in which the command is - * being defined. */ - char *cmdName, /* Name of Tcl command we are - * attempting to define. */ - Tcl_CmdProc *proc, /* The command procedure for the - * command being created. */ - ClientData clientData /* The client data associated with the - * command to be created. */ -) -{ - Alias *aliasPtr, *nextAliasPtr; - Tcl_CmdInfo cmdInfo; - - /* - * If we are not creating or renaming an alias, then it is - * always OK to create or rename the command. - */ - - if (proc != AliasCmd) { - return TCL_OK; - } - - /* - * OK, we are dealing with an alias, so traverse the chain of aliases. - * If we encounter the alias we are defining (or renaming to) any in - * the chain then we have a loop. - */ - - aliasPtr = (Alias *) clientData; - nextAliasPtr = aliasPtr; - while (1) { - - /* - * If the target of the next alias in the chain is the same as the - * source alias, we have a loop. - */ - - if ((strcmp(nextAliasPtr->targetName, cmdName) == 0) && - (nextAliasPtr->targetInterp == cmdInterp)) { - Tcl_AppendResult(interp, "cannot define or rename alias \"", - aliasPtr->aliasName, "\": would create a loop", - (char *) NULL); - return TCL_ERROR; - } - - /* - * Otherwise, follow the chain one step further. If the target - * command is undefined then there is no loop. - */ - - if (Tcl_GetCommandInfo(nextAliasPtr->targetInterp, - nextAliasPtr->targetName, &cmdInfo) == 0) { - return TCL_OK; - } - - /* - * See if the target command is an alias - if so, follow the - * loop to its target command. Otherwise we do not have a loop. - */ - - if (cmdInfo.proc != AliasCmd) { - return TCL_OK; - } - nextAliasPtr = (Alias *) cmdInfo.clientData; - } - - /* NOTREACHED */ -} - -/* - *---------------------------------------------------------------------- - * - * MakeSafe -- - * - * Makes its argument interpreter contain only functionality that is - * defined to be part of Safe Tcl. - * - * Results: - * None. - * - * Side effects: - * Removes commands from its argument interpreter. - * - *---------------------------------------------------------------------- - */ - -static int -MakeSafe( - Tcl_Interp *interp /* Interpreter to be made safe. */ -) -{ - char **argv; /* Args for Tcl_Eval. */ - int argc, keep, i, j; /* Loop indices. */ - char *cmdGetGlobalCmds = "info commands"; /* What command to run. */ - char *cmdNoEnv = "unset env"; /* How to get rid of env. */ - Master *masterPtr; /* Master record of interp - * to be made safe. */ - Tcl_Channel chan; /* Channel to remove from - * safe interpreter. */ - - /* - * Below, Tcl_Eval sets interp->result, so we do not. - */ - - Tcl_ResetResult(interp); - if ((Tcl_Eval(interp, cmdGetGlobalCmds) == TCL_ERROR) || - (Tcl_SplitList(interp, interp->result, &argc, &argv) != TCL_OK)) { - return TCL_ERROR; - } - for (i = 0; i < argc; i++) { - for (keep = 0, j = 0; j < TclCommandsToKeepCt; j++) { - if (strcmp(TclCommandsToKeep[j], argv[i]) == 0) { - keep = 1; - break; - } - } - if (keep == 0) { - (void) Tcl_DeleteCommand(interp, argv[i]); - } - } - ckfree((char *) argv); - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", - NULL); - if (masterPtr == (Master *) NULL) { - panic("MakeSafe: could not find master record"); - } - masterPtr->isSafe = 1; - if (Tcl_Eval(interp, cmdNoEnv) == TCL_ERROR) { - return TCL_ERROR; - } - - /* - * Remove the standard channels from the interpreter; safe interpreters - * do not ordinarily have access to stdin, stdout and stderr. - */ - - chan = Tcl_GetStdChannel(TCL_STDIN); - if (chan != (Tcl_Channel) NULL) { - Tcl_UnregisterChannel(interp, chan); - } - chan = Tcl_GetStdChannel(TCL_STDOUT); - if (chan != (Tcl_Channel) NULL) { - Tcl_UnregisterChannel(interp, chan); - } - chan = Tcl_GetStdChannel(TCL_STDERR); - if (chan != (Tcl_Channel) NULL) { - Tcl_UnregisterChannel(interp, chan); - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * GetInterp -- - * - * Helper function to find a slave interpreter given a pathname. - * - * Results: - * Returns the slave interpreter known by that name in the calling - * interpreter, or NULL if no interpreter known by that name exists. - * - * Side effects: - * Assigns to the pointer variable passed in, if not NULL. - * - *---------------------------------------------------------------------- - */ - -static Tcl_Interp * -GetInterp( - Tcl_Interp *interp, /* Interp. to start search from. */ - Master *masterPtr, /* Its master record. */ - char *path, /* The path (name) of interp. to be found. */ - Master **masterPtrPtr /* (Return) its master record. */ -) -{ - Tcl_HashEntry *hPtr; /* Search element. */ - Slave *slavePtr; /* Interim slave record. */ - char **argv; /* Split-up path (name) for interp to find. */ - int argc, i; /* Loop indices. */ - Tcl_Interp *searchInterp; /* Interim storage for interp. to find. */ - - if (masterPtrPtr != (Master **) NULL) *masterPtrPtr = masterPtr; - - if (Tcl_SplitList(interp, path, &argc, &argv) != TCL_OK) { - return (Tcl_Interp *) NULL; - } - - for (searchInterp = interp, i = 0; i < argc; i++) { - - hPtr = Tcl_FindHashEntry(&(masterPtr->slaveTable), argv[i]); - if (hPtr == (Tcl_HashEntry *) NULL) { - ckfree((char *) argv); - return (Tcl_Interp *) NULL; - } - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); - searchInterp = slavePtr->slaveInterp; - if (searchInterp == (Tcl_Interp *) NULL) { - ckfree((char *) argv); - return (Tcl_Interp *) NULL; - } - masterPtr = (Master *) Tcl_GetAssocData(searchInterp, - "tclMasterRecord", NULL); - if (masterPtrPtr != (Master **) NULL) *masterPtrPtr = masterPtr; - if (masterPtr == (Master *) NULL) { - ckfree((char *) argv); - return (Tcl_Interp *) NULL; - } - } - ckfree((char *) argv); - return searchInterp; -} - -/* - *---------------------------------------------------------------------- - * - * CreateSlave -- - * - * Helper function to do the actual work of creating a slave interp - * and new object command. Also optionally makes the new slave - * interpreter "safe". - * - * Results: - * Returns the new Tcl_Interp * if successful or NULL if not. If failed, - * the result of the invoking interpreter contains an error message. - * - * Side effects: - * Creates a new slave interpreter and a new object command. - * - *---------------------------------------------------------------------- - */ - -static Tcl_Interp * -CreateSlave( - Tcl_Interp *interp, /* Interp. to start search from. */ - char *slavePath, /* Path (name) of slave to create. */ - int safe /* Should we make it "safe"? */ -) -{ - Master *masterPtr; /* Master record. */ - Tcl_Interp *slaveInterp; /* Ptr to slave interpreter. */ - Tcl_Interp *masterInterp; /* Ptr to master interp for slave. */ - Slave *slavePtr; /* Slave record. */ - Tcl_HashEntry *hPtr; /* Entry into interp hashtable. */ - int new; /* Indicates whether new entry. */ - int argc; /* Count of elements in slavePath. */ - char **argv; /* Elements in slavePath. */ - char *masterPath; /* Path to its master. */ - - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", - NULL); - if (masterPtr == (Master *) NULL) { - panic("CreatSlave: could not find master record"); - } - - if (Tcl_SplitList(interp, slavePath, &argc, &argv) != TCL_OK) { - return (Tcl_Interp *) NULL; - } - - if (argc < 2) { - masterInterp = interp; - if (argc == 1) { - slavePath = argv[0]; - } - } else { - masterPath = Tcl_Merge(argc-1, argv); - masterInterp = GetInterp(interp, masterPtr, masterPath, &masterPtr); - if (masterInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter named \"", masterPath, - "\" not found", (char *) NULL); - ckfree((char *) argv); - ckfree((char *) masterPath); - return (Tcl_Interp *) NULL; - } - ckfree((char *) masterPath); - slavePath = argv[argc-1]; - if (!safe) { - safe = masterPtr->isSafe; - } - } - hPtr = Tcl_CreateHashEntry(&(masterPtr->slaveTable), slavePath, &new); - if (new == 0) { - Tcl_AppendResult(interp, "interpreter named \"", slavePath, - "\" already exists, cannot create", (char *) NULL); - ckfree((char *) argv); - return (Tcl_Interp *) NULL; - } - slaveInterp = Tcl_CreateInterp(); - if (slaveInterp == (Tcl_Interp *) NULL) { - panic("CreateSlave: out of memory while creating a new interpreter"); - } - slavePtr = (Slave *) ckalloc((unsigned) sizeof(Slave)); - slavePtr->masterInterp = masterInterp; - slavePtr->slaveEntry = hPtr; - slavePtr->slaveInterp = slaveInterp; - slavePtr->interpCmd = Tcl_CreateCommand(masterInterp, slavePath, - SlaveObjectCmd, (ClientData) slaveInterp, SlaveObjectDeleteProc); - Tcl_InitHashTable(&(slavePtr->aliasTable), TCL_STRING_KEYS); - (void) Tcl_SetAssocData(slaveInterp, "tclSlaveRecord", - SlaveRecordDeleteProc, (ClientData) slavePtr); - Tcl_SetHashValue(hPtr, (ClientData) slavePtr); - Tcl_SetVar(slaveInterp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); - - if (((safe) && (MakeSafe(slaveInterp) == TCL_ERROR)) || - ((!safe) && (Tcl_Init(slaveInterp) == TCL_ERROR))) { - Tcl_ResetResult(interp); - Tcl_AddErrorInfo(interp, Tcl_GetVar2(slaveInterp, "errorInfo", (char *) - NULL, TCL_GLOBAL_ONLY)); - Tcl_SetVar2(interp, "errorCode", (char *) NULL, - Tcl_GetVar2(slaveInterp, "errorCode", (char *) NULL, - TCL_GLOBAL_ONLY), - TCL_GLOBAL_ONLY); - if (slaveInterp->freeProc != NULL) { - interp->result = slaveInterp->result; - interp->freeProc = slaveInterp->freeProc; - slaveInterp->freeProc = 0; - } else { - Tcl_SetResult(interp, slaveInterp->result, TCL_VOLATILE); - } - Tcl_ResetResult(slaveInterp); - (void) Tcl_DeleteCommand(masterInterp, slavePath); - slaveInterp = (Tcl_Interp *) NULL; - } - ckfree((char *) argv); - return slaveInterp; -} - -/* - *---------------------------------------------------------------------- - * - * CreateInterpObject - - * - * Helper function to do the actual work of creating a new interpreter - * and an object command. - * - * Results: - * A Tcl result. - * - * Side effects: - * See user documentation for details. - * - *---------------------------------------------------------------------- - */ - -static int -CreateInterpObject( - Tcl_Interp *interp, /* Invoking interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int safe; /* Create a safe interpreter? */ - Master *masterPtr; /* Master record. */ - int moreFlags; /* Expecting more flag args? */ - char *slavePath; /* Name of slave. */ - char localSlaveName[200]; /* Local area for creating names. */ - int i; /* Loop counter. */ - size_t len; /* Length of option argument. */ - static int interpCounter = 0; /* Unique id for created names. */ - - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("CreateInterpObject: could not find master record"); - } - moreFlags = 1; - slavePath = NULL; - safe = masterPtr->isSafe; - - if (argc < 2 || argc > 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " create ?-safe? ?--? ?path?\"", (char *) NULL); - return TCL_ERROR; - } - for (i = 2; i < argc; i++) { - len = strlen(argv[i]); - if ((argv[i][0] == '-') && (moreFlags != 0)) { - if ((argv[i][1] == 's') && (strncmp(argv[i], "-safe", len) == 0) - && (len > 1)){ - safe = 1; - } else if ((strncmp(argv[i], "--", len) == 0) && (len > 1)) { - moreFlags = 0; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[i], - "\": should be -safe", (char *) NULL); - return TCL_ERROR; - } - } else { - slavePath = argv[i]; - } - } - if (slavePath == (char *) NULL) { - sprintf(localSlaveName, "interp%d", interpCounter); - interpCounter++; - slavePath = localSlaveName; - } - if (CreateSlave(interp, slavePath, safe) != NULL) { - Tcl_AppendResult(interp, slavePath, (char *) NULL); - return TCL_OK; - } else { - /* - * CreateSlave already set interp->result if there was an error, - * so we do not do it here. - */ - return TCL_ERROR; - } -} - -/* - *---------------------------------------------------------------------- - * - * DeleteOneInterpObject -- - * - * Helper function for DeleteInterpObject. It deals with deleting one - * interpreter at a time. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Deletes an interpreter and its interpreter object command. - * - *---------------------------------------------------------------------- - */ - -static int -DeleteOneInterpObject( - Tcl_Interp *interp, /* Interpreter for reporting errors. */ - char *path /* Path of interpreter to delete. */ -) -{ - Master *masterPtr; /* Interim storage for master record.*/ - Slave *slavePtr; /* Interim storage for slave record. */ - Tcl_Interp *masterInterp; /* Master of interp. to delete. */ - Tcl_HashEntry *hPtr; /* Search element. */ - int localArgc; /* Local copy of count of elements in - * path (name) of interp. to delete. */ - char **localArgv; /* Local copy of path. */ - char *slaveName; /* Last component in path. */ - char *masterPath; /* One-before-last component in path.*/ - - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("DeleteInterpObject: could not find master record"); - } - if (Tcl_SplitList(interp, path, &localArgc, &localArgv) != TCL_OK) { - Tcl_AppendResult(interp, "bad interpreter path \"", path, - "\"", (char *) NULL); - return TCL_ERROR; - } - if (localArgc < 2) { - masterInterp = interp; - if (localArgc == 0) { - slaveName = ""; - } else { - slaveName = localArgv[0]; - } - } else { - masterPath = Tcl_Merge(localArgc-1, localArgv); - masterInterp = GetInterp(interp, masterPtr, masterPath, &masterPtr); - if (masterInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter named \"", masterPath, - "\" not found", (char *) NULL); - ckfree((char *) localArgv); - ckfree((char *) masterPath); - return TCL_ERROR; - } - ckfree((char *) masterPath); - slaveName = localArgv[localArgc-1]; - } - hPtr = Tcl_FindHashEntry(&(masterPtr->slaveTable), slaveName); - if (hPtr == (Tcl_HashEntry *) NULL) { - ckfree((char *) localArgv); - Tcl_AppendResult(interp, "interpreter named \"", path, - "\" not found", (char *) NULL); - return TCL_ERROR; - } - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); - slaveName = Tcl_GetCommandName(masterInterp, slavePtr->interpCmd); - if (Tcl_DeleteCommand(masterInterp, slaveName) != 0) { - ckfree((char *) localArgv); - Tcl_AppendResult(interp, "interpreter named \"", path, - "\" not found", (char *) NULL); - return TCL_ERROR; - } - ckfree((char *) localArgv); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * DeleteInterpObject -- - * - * Helper function to do the work of deleting zero or more - * interpreters and their interpreter object commands. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Deletes interpreters and their interpreter object command. - * - *---------------------------------------------------------------------- - */ - -static int -DeleteInterpObject( - Tcl_Interp *interp, /* Interpreter start search from. */ - int argc, /* Number of arguments in vector. */ - char **argv /* Contains path to interps to - * delete. */ -) -{ - int i; - - for (i = 2; i < argc; i++) { - if (DeleteOneInterpObject(interp, argv[i]) != TCL_OK) { - return TCL_ERROR; - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * AliasHelper -- - * - * Helper function to do the work to actually create an alias or - * delete an alias. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * An alias command is created and entered into the alias table - * for the slave interpreter. - * - *---------------------------------------------------------------------- - */ - -static int -AliasHelper( - Tcl_Interp *curInterp, /* Interp that invoked this proc. */ - Tcl_Interp *slaveInterp, /* Interp where alias cmd will live - * or from which alias will be - * deleted. */ - Tcl_Interp *masterInterp, /* Interp where target cmd will be. */ - Master *masterPtr, /* Master record for target interp. */ - char *aliasName, /* Name of alias cmd. */ - char *targetName, /* Name of target cmd. */ - int argc, /* Additional arguments to store */ - char **argv /* with alias. */ -) -{ - Alias *aliasPtr; /* Storage for alias data. */ - Alias *tmpAliasPtr; /* Temp storage for alias to delete. */ - Tcl_HashEntry *hPtr; /* Entry into interp hashtable. */ - int i; /* Loop index. */ - int new; /* Is it a new hash entry? */ - Target *targetPtr; /* Maps from target command in master - * to source command in slave. */ - Slave *slavePtr; /* Maps from source command in slave - * to target command in master. */ - - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord", NULL); - - /* - * Fix it up if there is no slave record. This can happen if someone - * uses "" as the source for an alias. - */ - - if (slavePtr == (Slave *) NULL) { - slavePtr = (Slave *) ckalloc((unsigned) sizeof(Slave)); - slavePtr->masterInterp = (Tcl_Interp *) NULL; - slavePtr->slaveEntry = (Tcl_HashEntry *) NULL; - slavePtr->slaveInterp = slaveInterp; - slavePtr->interpCmd = (Tcl_Command) NULL; - Tcl_InitHashTable(&(slavePtr->aliasTable), TCL_STRING_KEYS); - (void) Tcl_SetAssocData(slaveInterp, "tclSlaveRecord", - SlaveRecordDeleteProc, (ClientData) slavePtr); - } - - if ((targetName == (char *) NULL) || (targetName[0] == '\0')) { - if (argc != 0) { - Tcl_AppendResult(curInterp, "malformed command: should be", - " \"alias ", aliasName, " {}\"", (char *) NULL); - return TCL_ERROR; - } - - return DeleteAlias(curInterp, slaveInterp, aliasName); - } - - aliasPtr = (Alias *) ckalloc((unsigned) sizeof(Alias)); - aliasPtr->aliasName = (char *) ckalloc((unsigned) strlen(aliasName)+1); - aliasPtr->targetName = (char *) ckalloc((unsigned) strlen(targetName)+1); - strcpy(aliasPtr->aliasName, aliasName); - strcpy(aliasPtr->targetName, targetName); - aliasPtr->targetInterp = masterInterp; - - aliasPtr->argv = (char **) NULL; - aliasPtr->argc = argc; - if (aliasPtr->argc > 0) { - aliasPtr->argv = (char **) ckalloc((unsigned) sizeof(char *) * - aliasPtr->argc); - for (i = 0; i < argc; i++) { - aliasPtr->argv[i] = (char *) ckalloc((unsigned) strlen(argv[i])+1); - strcpy(aliasPtr->argv[i], argv[i]); - } - } - - if (TclPreventAliasLoop(curInterp, slaveInterp, aliasName, AliasCmd, - (ClientData) aliasPtr) != TCL_OK) { - for (i = 0; i < argc; i++) { - ckfree(aliasPtr->argv[i]); - } - if (aliasPtr->argv != (char **) NULL) { - ckfree((char *) aliasPtr->argv); - } - ckfree(aliasPtr->aliasName); - ckfree(aliasPtr->targetName); - ckfree((char *) aliasPtr); - - return TCL_ERROR; - } - - aliasPtr->slaveCmd = Tcl_CreateCommand(slaveInterp, aliasName, AliasCmd, - (ClientData) aliasPtr, AliasCmdDeleteProc); - - /* - * Make an entry in the alias table. If it already exists delete - * the alias command. Then retry. - */ - - do { - hPtr = Tcl_CreateHashEntry(&(slavePtr->aliasTable), aliasName, &new); - if (new == 0) { - tmpAliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - (void) Tcl_DeleteCommand(slaveInterp, tmpAliasPtr->aliasName); - Tcl_DeleteHashEntry(hPtr); - } - } while (new == 0); - aliasPtr->aliasEntry = hPtr; - Tcl_SetHashValue(hPtr, (ClientData) aliasPtr); - - targetPtr = (Target *) ckalloc((unsigned) sizeof(Target)); - targetPtr->slaveCmd = aliasPtr->slaveCmd; - targetPtr->slaveInterp = slaveInterp; - - do { - hPtr = Tcl_CreateHashEntry(&(masterPtr->targetTable), - (char *) (intptr_t) aliasCounter, &new); - aliasCounter++; - } while (new == 0); - - Tcl_SetHashValue(hPtr, (ClientData) targetPtr); - - aliasPtr->targetEntry = hPtr; - - curInterp->result = aliasPtr->aliasName; - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * SlaveAliasHelper - - * - * Handles the different forms of the "interp alias" command: - * - interp alias slavePath aliasName - * Describes an alias. - * - interp alias slavePath aliasName {} - * Deletes an alias. - * - interp alias slavePath srcCmd masterPath targetCmd args... - * Creates an alias. - * - * Results: - * A Tcl result. - * - * Side effects: - * See user documentation for details. - * - *---------------------------------------------------------------------- - */ - -static int -SlaveAliasHelper( - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Master *masterPtr; /* Master record for current interp. */ - Tcl_Interp *slaveInterp, /* Interpreters used when */ - *masterInterp; /* creating an alias btn siblings. */ - Master *masterMasterPtr; /* Master record for master interp. */ - - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("SlaveAliasHelper: could not find master record"); - } - if (argc < 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " alias slavePath slaveCmd masterPath masterCmd ?args ..?\"", - (char *) NULL); - return TCL_ERROR; - } - slaveInterp = GetInterp(interp, masterPtr, argv[2], NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "could not find interpreter \"", - argv[2], "\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 4) { - return DescribeAlias(interp, slaveInterp, argv[3]); - } - if (argc == 5 && strcmp(argv[4], "") == 0) { - return DeleteAlias(interp, slaveInterp, argv[3]); - } - if (argc < 6) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " alias slavePath slaveCmd masterPath masterCmd ?args ..?\"", - (char *) NULL); - return TCL_ERROR; - } - masterInterp = GetInterp(interp, masterPtr, argv[4], &masterMasterPtr); - if (masterInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "could not find interpreter \"", - argv[4], "\"", (char *) NULL); - return TCL_ERROR; - } - return AliasHelper(interp, slaveInterp, masterInterp, masterMasterPtr, - argv[3], argv[5], argc-6, argv+6); -} - -/* - *---------------------------------------------------------------------- - * - * DescribeAlias -- - * - * Sets interp->result to a Tcl list describing the given alias in the - * given interpreter: its target command and the additional arguments - * to prepend to any invocation of the alias. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -DescribeAlias( - Tcl_Interp *interp, /* Interpreter for result and errors. */ - Tcl_Interp *slaveInterp, /* Interpreter defining alias. */ - char *aliasName /* Name of alias to describe. */ -) -{ - Slave *slavePtr; /* Slave record for slave interpreter. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - Alias *aliasPtr; /* Structure describing alias. */ - int i; /* Loop variable. */ - - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord", - NULL); - if (slavePtr == (Slave *) NULL) { - panic("DescribeAlias: could not find slave record"); - } - hPtr = Tcl_FindHashEntry(&(slavePtr->aliasTable), aliasName); - if (hPtr == (Tcl_HashEntry *) NULL) { - return TCL_OK; - } - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - Tcl_AppendResult(interp, aliasPtr->targetName, (char *) NULL); - for (i = 0; i < aliasPtr->argc; i++) { - Tcl_AppendElement(interp, aliasPtr->argv[i]); - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * DeleteAlias -- - * - * Deletes the given alias from the slave interpreter given. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Deletes the alias from the slave interpreter. - * - *---------------------------------------------------------------------- - */ - -static int -DeleteAlias( - Tcl_Interp *interp, /* Interpreter for result and errors. */ - Tcl_Interp *slaveInterp, /* Interpreter defining alias. */ - char *aliasName /* Name of alias to delete. */ -) -{ - Slave *slavePtr; /* Slave record for slave interpreter. */ - Tcl_HashEntry *hPtr; /* Search variable. */ - Alias *aliasPtr; /* Structure describing alias to delete. */ - - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord", - NULL); - if (slavePtr == (Slave *) NULL) { - panic("DeleteAlias: could not find slave record"); - } - - /* - * Get the alias from the alias table, determine the current - * true name of the alias (it may have been renamed!) and then - * delete the true command name. The deleteProc on the alias - * command will take care of removing the entry from the alias - * table. - */ - - hPtr = Tcl_FindHashEntry(&(slavePtr->aliasTable), aliasName); - if (hPtr == (Tcl_HashEntry *) NULL) { - Tcl_AppendResult(interp, "alias \"", aliasName, "\" not found", - (char *) NULL); - return TCL_ERROR; - } - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - aliasName = Tcl_GetCommandName(slaveInterp, aliasPtr->slaveCmd); - - /* - * NOTE: The deleteProc for this command will delete the - * alias from the hash table. The deleteProc will also - * delete the target information from the master interpreter - * target table. - */ - - if (Tcl_DeleteCommand(slaveInterp, aliasName) != 0) { - panic("DeleteAlias: did not find alias to be deleted"); - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetInterpPath -- - * - * Sets the result of the asking interpreter to a proper Tcl list - * containing the names of interpreters between the asking and - * target interpreters. The target interpreter must be either the - * same as the asking interpreter or one of its slaves (including - * recursively). - * - * Results: - * TCL_OK if the target interpreter is the same as, or a descendant - * of, the asking interpreter; TCL_ERROR else. This way one can - * distinguish between the case where the asking and target interps - * are the same (an empty list is the result, and TCL_OK is returned) - * and when the target is not a descendant of the asking interpreter - * (in which case the Tcl result is an error message and the function - * returns TCL_ERROR). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetInterpPath( - Tcl_Interp *askingInterp, /* Interpreter to start search from. */ - Tcl_Interp *targetInterp /* Interpreter to find. */ -) -{ - Master *masterPtr; /* Interim storage for Master record. */ - Slave *slavePtr; /* Interim storage for Slave record. */ - - if (targetInterp == askingInterp) { - return TCL_OK; - } - if (targetInterp == (Tcl_Interp *) NULL) { - return TCL_ERROR; - } - slavePtr = (Slave *) Tcl_GetAssocData(targetInterp, "tclSlaveRecord", - NULL); - if (slavePtr == (Slave *) NULL) { - return TCL_ERROR; - } - if (Tcl_GetInterpPath(askingInterp, slavePtr->masterInterp) == TCL_ERROR) { - /* - * AskingInterp->result was set by recursive call. - */ - return TCL_ERROR; - } - masterPtr = (Master *) Tcl_GetAssocData(slavePtr->masterInterp, - "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("Tcl_GetInterpPath: could not find master record"); - } - Tcl_AppendElement(askingInterp, Tcl_GetHashKey(&(masterPtr->slaveTable), - slavePtr->slaveEntry)); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * GetTarget -- - * - * Sets the result of the invoking interpreter to a path name for - * the target interpreter of an alias in one of the slaves. - * - * Results: - * TCL_OK if the target interpreter of the alias is a slave of the - * invoking interpreter, TCL_ERROR else. - * - * Side effects: - * Sets the result of the invoking interpreter. - * - *---------------------------------------------------------------------- - */ - -static int -GetTarget( - Tcl_Interp *askingInterp, /* Interpreter to start search from. */ - char *path, /* The path of the interp to find. */ - char *aliasName /* The target of this allias. */ -) -{ - Tcl_Interp *slaveInterp; /* Interim storage for slave. */ - Slave *slaveSlavePtr; /* Its Slave record. */ - Master *masterPtr; /* Interim storage for Master record. */ - Tcl_HashEntry *hPtr; /* Search element. */ - Alias *aliasPtr; /* Data describing the alias. */ - - Tcl_ResetResult(askingInterp); - - masterPtr = (Master *) Tcl_GetAssocData(askingInterp, "tclMasterRecord", - NULL); - if (masterPtr == (Master *) NULL) { - panic("GetTarget: could not find master record"); - } - slaveInterp = GetInterp(askingInterp, masterPtr, path, NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(askingInterp, "could not find interpreter \"", - path, "\"", (char *) NULL); - return TCL_ERROR; - } - slaveSlavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord", - NULL); - if (slaveSlavePtr == (Slave *) NULL) { - panic("GetTarget: could not find slave record"); - } - hPtr = Tcl_FindHashEntry(&(slaveSlavePtr->aliasTable), aliasName); - if (hPtr == (Tcl_HashEntry *) NULL) { - Tcl_AppendResult(askingInterp, "alias \"", aliasName, "\" in path \"", - path, "\" not found", (char *) NULL); - return TCL_ERROR; - } - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - if (aliasPtr == (Alias *) NULL) { - panic("GetTarget: could not find alias record"); - } - if (Tcl_GetInterpPath(askingInterp, aliasPtr->targetInterp) == TCL_ERROR) { - Tcl_ResetResult(askingInterp); - Tcl_AppendResult(askingInterp, "target interpreter for alias \"", - aliasName, "\" in path \"", path, "\" is not my descendant", - (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_InterpCmd -- - * - * This procedure is invoked to process the "interp" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - /* ARGSUSED */ -int -Tcl_InterpCmd( - ClientData clientData, /* Unused. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Interp *slaveInterp; /* A slave. */ - Tcl_Interp *masterInterp; /* A master. */ - Master *masterPtr; /* Master record for current interp. */ - Slave *slavePtr; /* Record for slave interp. */ - Tcl_HashEntry *hPtr; - Tcl_HashSearch hSearch; - size_t len; /* Length of command name. */ - int result; /* Result of eval. */ - char *cmdName; /* Name of sub command to do. */ - char *cmd; /* Command to eval. */ - Tcl_Channel chan; /* Channel to share or transfer. */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " cmd ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - cmdName = argv[1]; - - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("Tcl_InterpCmd: could not find master record"); - } - - len = strlen(cmdName); - - if (cmdName[0] == 'a') { - if ((strncmp(cmdName, "alias", len) == 0) && (len <= 5)) { - return SlaveAliasHelper(interp, argc, argv); - } - - if (strcmp(cmdName, "aliases") == 0) { - if (argc != 2 && argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " aliases ?path?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - slaveInterp = GetInterp(interp, masterPtr, argv[2], NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", - argv[2], "\" not found", (char *) NULL); - return TCL_ERROR; - } - } else { - slaveInterp = interp; - } - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, - "tclSlaveRecord", NULL); - if (slavePtr == (Slave *) NULL) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(&(slavePtr->aliasTable), &hSearch); - hPtr != NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - Tcl_AppendElement(interp, - Tcl_GetHashKey(&(slavePtr->aliasTable), hPtr)); - } - return TCL_OK; - } - } - - if ((cmdName[0] == 'c') && (strncmp(cmdName, "create", len) == 0)) { - return CreateInterpObject(interp, argc, argv); - } - - if ((cmdName[0] == 'd') && (strncmp(cmdName, "delete", len) == 0)) { - return DeleteInterpObject(interp, argc, argv); - } - - if (cmdName[0] == 'e') { - if ((strncmp(cmdName, "exists", len) == 0) && (len > 1)) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " exists ?path?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - if (GetInterp(interp, masterPtr, argv[2], NULL) == - (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "0", (char *) NULL); - } else { - Tcl_AppendResult(interp, "1", (char *) NULL); - } - } else { - Tcl_AppendResult(interp, "1", (char *) NULL); - } - return TCL_OK; - } - if ((strncmp(cmdName, "eval", len) == 0) && (len > 1)) { - if (argc < 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " eval path arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - slaveInterp = GetInterp(interp, masterPtr, argv[2], NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter named \"", argv[2], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - cmd = Tcl_Concat(argc-3, argv+3); - Tcl_Preserve((ClientData) slaveInterp); - result = Tcl_Eval(slaveInterp, cmd); - ckfree((char *) cmd); - - /* - * Now make the result and any error information accessible. We - * have to be careful because the slave interpreter and the current - * interpreter can be the same - do not destroy the result.. This - * can happen if an interpreter contains an alias which is directed - * at a target command in the same interpreter. - */ - - if (interp != slaveInterp) { - if (result == TCL_ERROR) { - - /* - * An error occurred, so transfer error information from - * the target interpreter back to our interpreter. Must - * clear interp's result before calling Tcl_AddErrorInfo, - * since Tcl_AddErrorInfo will store the interp's result in - * errorInfo before appending slaveInterp's $errorInfo; - * we've already got everything we need in the slave - * interpreter's $errorInfo. - */ - - Tcl_ResetResult(interp); - Tcl_AddErrorInfo(interp, Tcl_GetVar2(slaveInterp, - "errorInfo", (char *) NULL, TCL_GLOBAL_ONLY)); - Tcl_SetVar2(interp, "errorCode", (char *) NULL, - Tcl_GetVar2(slaveInterp, "errorCode", (char *) - NULL, TCL_GLOBAL_ONLY), - TCL_GLOBAL_ONLY); - } - if (slaveInterp->freeProc != NULL) { - interp->result = slaveInterp->result; - interp->freeProc = slaveInterp->freeProc; - slaveInterp->freeProc = 0; - } else { - Tcl_SetResult(interp, slaveInterp->result, TCL_VOLATILE); - } - Tcl_ResetResult(slaveInterp); - } - Tcl_Release((ClientData) slaveInterp); - return result; - } - } - - if ((cmdName[0] == 'i') && (strncmp(cmdName, "issafe", len) == 0)) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " issafe ?path?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - slaveInterp = GetInterp(interp, masterPtr, argv[2], &masterPtr); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[2], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - } - if (masterPtr->isSafe == 0) { - Tcl_AppendResult(interp, "0", (char *) NULL); - } else { - Tcl_AppendResult(interp, "1", (char *) NULL); - } - return TCL_OK; - } - - if (cmdName[0] == 's') { - if ((strncmp(cmdName, "slaves", len) == 0) && (len > 1)) { - if (argc != 2 && argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " slaves ?path?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - if (GetInterp(interp, masterPtr, argv[2], &masterPtr) == - (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[2], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - } - for (hPtr = Tcl_FirstHashEntry(&(masterPtr->slaveTable), &hSearch); - hPtr != NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - Tcl_AppendElement(interp, - Tcl_GetHashKey(&(masterPtr->slaveTable), hPtr)); - } - return TCL_OK; - } - if ((strncmp(cmdName, "share", len) == 0) && (len > 1)) { - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " share srcPath channelId destPath\"", (char *) NULL); - return TCL_ERROR; - } - masterInterp = GetInterp(interp, masterPtr, argv[2], NULL); - if (masterInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[2], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - slaveInterp = GetInterp(interp, masterPtr, argv[4], NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[4], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(masterInterp, argv[3], NULL); - if (chan == (Tcl_Channel) NULL) { - if (interp != masterInterp) { - Tcl_AppendResult(interp, masterInterp->result, - (char *) NULL); - Tcl_ResetResult(masterInterp); - } - return TCL_ERROR; - } - Tcl_RegisterChannel(slaveInterp, chan); - return TCL_OK; - } - } - - if ((cmdName[0] == 't') && (strncmp(cmdName, "target", len) == 0)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " target path alias\"", (char *) NULL); - return TCL_ERROR; - } - return GetTarget(interp, argv[2], argv[3]); - } - - if ((cmdName[0] == 't') && (strncmp(cmdName, "transfer", len) == 0)) { - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " transfer srcPath channelId destPath\"", (char *) NULL); - return TCL_ERROR; - } - masterInterp = GetInterp(interp, masterPtr, argv[2], NULL); - if (masterInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[2], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - slaveInterp = GetInterp(interp, masterPtr, argv[4], NULL); - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter \"", argv[4], - "\" not found", (char *) NULL); - return TCL_ERROR; - } - chan = Tcl_GetChannel(masterInterp, argv[3], NULL); - if (chan == (Tcl_Channel) NULL) { - if (interp != masterInterp) { - Tcl_AppendResult(interp, masterInterp->result, (char *) NULL); - Tcl_ResetResult(masterInterp); - } - return TCL_ERROR; - } - Tcl_RegisterChannel(slaveInterp, chan); - if (Tcl_UnregisterChannel(masterInterp, chan) != TCL_OK) { - if (interp != masterInterp) { - Tcl_AppendResult(interp, masterInterp->result, (char *) NULL); - Tcl_ResetResult(masterInterp); - } - return TCL_ERROR; - } - - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be alias, aliases, create, delete, exists, eval, ", - "issafe, share, slaves, target or transfer", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * SlaveObjectCmd -- - * - * Command to manipulate an interpreter, e.g. to send commands to it - * to be evaluated. One such command exists for each slave interpreter. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See user documentation for details. - * - *---------------------------------------------------------------------- - */ - -static int -SlaveObjectCmd( - ClientData clientData, /* Slave interpreter. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Master *masterPtr; /* Master record for slave interp. */ - Slave *slavePtr; /* Slave record. */ - Tcl_Interp *slaveInterp; /* Slave interpreter. */ - char *cmdName; /* Name of command to do. */ - char *cmd; /* Command to evaluate in slave - * interpreter. */ - Alias *aliasPtr; /* Alias information. */ - Tcl_HashEntry *hPtr; /* For local searches. */ - Tcl_HashSearch hSearch; /* For local searches. */ - int result; /* Loop counter, status return. */ - size_t len; /* Length of command name. */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " cmd ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - slaveInterp = (Tcl_Interp *) clientData; - if (slaveInterp == (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "interpreter ", argv[0], " has been deleted", - (char *) NULL); - return TCL_ERROR; - } - - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, - "tclSlaveRecord", NULL); - if (slavePtr == (Slave *) NULL) { - panic("SlaveObjectCmd: could not find slave record"); - } - - cmdName = argv[1]; - len = strlen(cmdName); - - if (cmdName[0] == 'a') { - if (strncmp(cmdName, "alias", len) == 0) { - switch (argc-2) { - case 0: - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " alias aliasName ?targetName? ?args..?", - (char *) NULL); - return TCL_ERROR; - - case 1: - - /* - * Return the name of the command in the current - * interpreter for which the argument is an alias in the - * slave interpreter, and the list of saved arguments - */ - - return DescribeAlias(interp, slaveInterp, argv[2]); - - default: - masterPtr = (Master *) Tcl_GetAssocData(interp, - "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("SlaveObjectCmd: could not find master record"); - } - return AliasHelper(interp, slaveInterp, interp, masterPtr, - argv[2], argv[3], argc-4, argv+4); - } - } - - if (strncmp(cmdName, "aliases", len) == 0) { - - /* - * Return the names of all the aliases created in the - * slave interpreter. - */ - - for (hPtr = Tcl_FirstHashEntry(&(slavePtr->aliasTable), - &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - Tcl_AppendElement(interp, aliasPtr->aliasName); - } - return TCL_OK; - } - } - - - if ((cmdName[0] == 'e') && (strncmp(cmdName, "eval", len) == 0)) { - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " eval arg ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - cmd = Tcl_Concat(argc-2, argv+2); - Tcl_Preserve((ClientData) slaveInterp); - result = Tcl_Eval(slaveInterp, cmd); - ckfree((char *) cmd); - - /* - * Now make the result and any error information accessible. We have - * to be careful because the slave interpreter and the current - * interpreter can be the same - do not destroy the result.. This - * can happen if an interpreter contains an alias which is directed - * at a target command in the same interpreter. - */ - - if (interp != slaveInterp) { - if (result == TCL_ERROR) { - - /* - * An error occurred, so transfer error information from the - * destination interpreter back to our interpreter. Must clear - * interp's result before calling Tcl_AddErrorInfo, since - * Tcl_AddErrorInfo will store the interp's result in errorInfo - * before appending slaveInterp's $errorInfo; - * we've already got everything we need in the slave - * interpreter's $errorInfo. - */ - - Tcl_ResetResult(interp); - Tcl_AddErrorInfo(interp, Tcl_GetVar2(slaveInterp, - "errorInfo", (char *) NULL, TCL_GLOBAL_ONLY)); - Tcl_SetVar2(interp, "errorCode", (char *) NULL, - Tcl_GetVar2(slaveInterp, "errorCode", (char *) NULL, - TCL_GLOBAL_ONLY), TCL_GLOBAL_ONLY); - } - if (slaveInterp->freeProc != NULL) { - interp->result = slaveInterp->result; - interp->freeProc = slaveInterp->freeProc; - slaveInterp->freeProc = 0; - } else { - Tcl_SetResult(interp, slaveInterp->result, TCL_VOLATILE); - } - Tcl_ResetResult(slaveInterp); - } - Tcl_Release((ClientData) slaveInterp); - return result; - } - - if ((cmdName[0] == 'i') && (strncmp(cmdName, "issafe", len) == 0)) { - if (argc > 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " issafe\"", (char *) NULL); - return TCL_ERROR; - } - masterPtr = (Master *) Tcl_GetAssocData(slaveInterp, - "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("SlaveObjectCmd: could not find master record"); - } - if (masterPtr->isSafe == 1) { - Tcl_AppendResult(interp, "1", (char *) NULL); - } else { - Tcl_AppendResult(interp, "0", (char *) NULL); - } - return TCL_OK; - } - - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be alias, aliases, eval or issafe", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * SlaveObjectDeleteProc -- - * - * Invoked when an object command for a slave interpreter is deleted; - * cleans up all state associated with the slave interpreter and destroys - * the slave interpreter. - * - * Results: - * None. - * - * Side effects: - * Cleans up all state associated with the slave interpreter and - * destroys the slave interpreter. - * - *---------------------------------------------------------------------- - */ - -static void -SlaveObjectDeleteProc( - ClientData clientData /* The SlaveRecord for the command. */ -) -{ - Slave *slavePtr; /* Interim storage for Slave record. */ - Tcl_Interp *slaveInterp; /* And for a slave interp. */ - - slaveInterp = (Tcl_Interp *) clientData; - slavePtr = (Slave *) Tcl_GetAssocData(slaveInterp, "tclSlaveRecord",NULL); - if (slavePtr == (Slave *) NULL) { - panic("SlaveObjectDeleteProc: could not find slave record"); - } - - /* - * Delete the entry in the slave table in the master interpreter now. - * This is to avoid an infinite loop in the Master hash table cleanup in - * the master interpreter. This can happen if this slave is being deleted - * because the master is being deleted and the slave deletion is deferred - * because it is still active. - */ - - Tcl_DeleteHashEntry(slavePtr->slaveEntry); - - /* - * Set to NULL so that when the slave record is cleaned up in the slave - * it does not try to delete the command causing all sorts of grief. - * See SlaveRecordDeleteProc(). - */ - - slavePtr->interpCmd = NULL; - - /* - * Destroy the interpreter - this will cause all the deleteProcs for - * all commands (including aliases) to run. - * - * NOTE: WE ASSUME THAT THE INTERPRETER HAS NOT BEEN DELETED YET!! - */ - - Tcl_DeleteInterp(slavePtr->slaveInterp); -} - -/* - *---------------------------------------------------------------------- - * - * AliasCmd -- - * - * This is the procedure that services invocations of aliases in a - * slave interpreter. One such command exists for each alias. When - * invoked, this procedure redirects the invocation to the target - * command in the master interpreter as designated by the Alias - * record associated with this command. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * Causes forwarding of the invocation; all possible side effects - * may occur as a result of invoking the command to which the - * invocation is forwarded. - * - *---------------------------------------------------------------------- - */ - -static int -AliasCmd( - ClientData clientData, /* Alias record. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Alias *aliasPtr; /* Describes the alias. */ - Tcl_CmdInfo cmdInfo; /* Info about target command. */ - int result; /* Result of execution. */ - int i, j, addArgc; /* Loop counters. */ - int localArgc; /* Local argument count. */ - char **localArgv; /* Local argument vector. */ - Interp *iPtr; /* The target interpreter. */ - - aliasPtr = (Alias *) clientData; - - result = Tcl_GetCommandInfo(aliasPtr->targetInterp, aliasPtr->targetName, - &cmdInfo); - if (result == 0) { - Tcl_AppendResult(interp, "aliased target \"", aliasPtr->targetName, - "\" for \"", argv[0], "\" not found", (char *) NULL); - return TCL_ERROR; - } - if (aliasPtr->argc <= 0) { - localArgv = argv; - localArgc = argc; - } else { - addArgc = aliasPtr->argc; - localArgc = argc + addArgc; - localArgv = (char **) ckalloc((unsigned) sizeof(char *) * localArgc); - localArgv[0] = argv[0]; - for (i = 0, j = 1; i < addArgc; i++, j++) { - localArgv[j] = aliasPtr->argv[i]; - } - for (i = 1; i < argc; i++, j++) { - localArgv[j] = argv[i]; - } - } - - /* - * Invoke the redirected command in the target interpreter. Note - * that we are not calling eval because of possible security holes with - * $ substitution and bracketed command evaluation. - * - * We duplicate some code here from Tcl_Eval to implement recursion - * level counting and correct deletion of the target interpreter if - * that was requested but delayed because of in-progress evaluations. - */ - - iPtr = (Interp *) aliasPtr->targetInterp; - iPtr->numLevels++; - Tcl_Preserve((ClientData) iPtr); - Tcl_ResetResult((Tcl_Interp *) iPtr); - result = (cmdInfo.proc)(cmdInfo.clientData, (Tcl_Interp *) iPtr, - localArgc, localArgv); - iPtr->numLevels--; - if (iPtr->numLevels == 0) { - if (result == TCL_RETURN) { - result = TclUpdateReturnInfo(iPtr); - } - if ((result != TCL_OK) && (result != TCL_ERROR)) { - Tcl_ResetResult((Tcl_Interp *) iPtr); - if (result == TCL_BREAK) { - iPtr->result = "invoked \"break\" outside of a loop"; - } else if (result == TCL_CONTINUE) { - iPtr->result = "invoked \"continue\" outside of a loop"; - } else { - iPtr->result = iPtr->resultSpace; - sprintf(iPtr->resultSpace, "command returned bad code: %d", - result); - } - result = TCL_ERROR; - } - } - - /* - * Clean up any locally allocated argument vector structure. - */ - - if (localArgv != argv) { - ckfree((char *) localArgv); - } - - /* - * - * NOTE: Need to be careful if the target interpreter and the current - * interpreter are the same - must not destroy result. This may happen - * if an alias is created which redirects to a command in the same - * interpreter as the one in which the source command will be defined. - * Also: We cannot use aliasPtr any more because the alias may have - * been deleted. - */ - - if (interp != (Tcl_Interp *) iPtr) { - if (result == TCL_ERROR) { - /* - * An error occurred, so transfer error information from the - * destination interpreter back to our interpreter. Some tricky - * points: - * 1. Must call Tcl_AddErrorInfo in destination interpreter to - * make sure that the errorInfo variable has been initialized - * (it's initialized lazily and might not have been initialized - * yet). - * 2. Must clear interp's result before calling Tcl_AddErrorInfo, - * since Tcl_AddErrorInfo will store the interp's result in - * errorInfo before appending aliasPtr->interp's $errorInfo; - * we've already got everything we need in the redirected - * interpreter's $errorInfo. - */ - - if (!(iPtr->flags & ERR_ALREADY_LOGGED)) { - Tcl_AddErrorInfo((Tcl_Interp *) iPtr, ""); - } - iPtr->flags &= ~ERR_ALREADY_LOGGED; - Tcl_ResetResult(interp); - Tcl_AddErrorInfo(interp, Tcl_GetVar2((Tcl_Interp *) iPtr, - "errorInfo", (char *) NULL, TCL_GLOBAL_ONLY)); - Tcl_SetVar2(interp, "errorCode", (char *) NULL, - Tcl_GetVar2((Tcl_Interp *) iPtr, "errorCode", - (char *) NULL, TCL_GLOBAL_ONLY), TCL_GLOBAL_ONLY); - } - if (iPtr->freeProc != NULL) { - interp->result = iPtr->result; - interp->freeProc = iPtr->freeProc; - iPtr->freeProc = 0; - } else { - Tcl_SetResult(interp, iPtr->result, TCL_VOLATILE); - } - Tcl_ResetResult((Tcl_Interp *) iPtr); - } - Tcl_Release((ClientData) iPtr); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * AliasCmdDeleteProc -- - * - * Is invoked when an alias command is deleted in a slave. Cleans up - * all storage associated with this alias. - * - * Results: - * None. - * - * Side effects: - * Deletes the alias record and its entry in the alias table for - * the interpreter. - * - *---------------------------------------------------------------------- - */ - -static void -AliasCmdDeleteProc( - ClientData clientData /* The alias record for this alias. */ -) -{ - Alias *aliasPtr; /* Alias record for alias to delete. */ - Target *targetPtr; /* Record for target of this alias. */ - int i; /* Loop counter. */ - - aliasPtr = (Alias *) clientData; - - targetPtr = (Target *) Tcl_GetHashValue(aliasPtr->targetEntry); - ckfree((char *) targetPtr); - Tcl_DeleteHashEntry(aliasPtr->targetEntry); - - ckfree((char *) aliasPtr->targetName); - ckfree((char *) aliasPtr->aliasName); - for (i = 0; i < aliasPtr->argc; i++) { - ckfree((char *) aliasPtr->argv[i]); - } - if (aliasPtr->argv != (char **) NULL) { - ckfree((char *) aliasPtr->argv); - } - - Tcl_DeleteHashEntry(aliasPtr->aliasEntry); - - ckfree((char *) aliasPtr); -} - -/* - *---------------------------------------------------------------------- - * - * MasterRecordDeleteProc - - * - * Is invoked when an interpreter (which is using the "interp" facility) - * is deleted, and it cleans up the storage associated with the - * "tclMasterRecord" assoc-data entry. - * - * Results: - * None. - * - * Side effects: - * Cleans up storage. - * - *---------------------------------------------------------------------- - */ - -static void -MasterRecordDeleteProc( - ClientData clientData, /* Master record for deleted interp. */ - Tcl_Interp *interp /* Interpreter being deleted. */ -) -{ - Target *targetPtr; /* Loop variable. */ - Tcl_HashEntry *hPtr; /* Search element. */ - Tcl_HashSearch hSearch; /* Search record (internal). */ - Slave *slavePtr; /* Loop variable. */ - char *cmdName; /* Name of command to delete. */ - Master *masterPtr; /* Interim storage. */ - - masterPtr = (Master *) clientData; - for (hPtr = Tcl_FirstHashEntry(&(masterPtr->slaveTable), &hSearch); - hPtr != NULL; - hPtr = Tcl_NextHashEntry(&hSearch)) { - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); - cmdName = Tcl_GetCommandName(interp, slavePtr->interpCmd); - (void) Tcl_DeleteCommand(interp, cmdName); - } - Tcl_DeleteHashTable(&(masterPtr->slaveTable)); - - for (hPtr = Tcl_FirstHashEntry(&(masterPtr->targetTable), &hSearch); - hPtr != NULL; - hPtr = Tcl_FirstHashEntry(&(masterPtr->targetTable), &hSearch)) { - targetPtr = (Target *) Tcl_GetHashValue(hPtr); - cmdName = Tcl_GetCommandName(targetPtr->slaveInterp, - targetPtr->slaveCmd); - (void) Tcl_DeleteCommand(targetPtr->slaveInterp, cmdName); - } - Tcl_DeleteHashTable(&(masterPtr->targetTable)); - - ckfree((char *) masterPtr); -} - -/* - *---------------------------------------------------------------------- - * - * SlaveRecordDeleteProc -- - * - * Is invoked when an interpreter (which is using the interp facility) - * is deleted, and it cleans up the storage associated with the - * tclSlaveRecord assoc-data entry. - * - * Results: - * None - * - * Side effects: - * Cleans up storage. - * - *---------------------------------------------------------------------- - */ - -static void -SlaveRecordDeleteProc( - ClientData clientData, /* Slave record for deleted interp. */ - Tcl_Interp *interp /* Interpreter being deleted. */ -) -{ - Slave *slavePtr; /* Interim storage. */ - Alias *aliasPtr; - Tcl_HashTable *hTblPtr; - Tcl_HashEntry *hPtr; - Tcl_HashSearch hSearch; - - slavePtr = (Slave *) clientData; - - /* - * In every case that we call SetAssocData on "tclSlaveRecord", - * slavePtr is not NULL. Otherwise we panic. - */ - - if (slavePtr == NULL) { - panic("SlaveRecordDeleteProc: NULL slavePtr"); - } - - if (slavePtr->interpCmd != (Tcl_Command) NULL) { - Command *cmdPtr = (Command *) slavePtr->interpCmd; - - /* - * The interpCmd has not been deleted in the master yet, since - * it's callback sets interpCmd to NULL. - * - * Probably Tcl_DeleteInterp() was called on this interpreter directly, - * rather than via "interp delete", or equivalent (deletion of the - * command in the master). - * - * Perform the cleanup done by SlaveObjectDeleteProc() directly, - * and turn off the callback now (since we are about to free slavePtr - * and this interpreter is going away, while the deletion of commands - * in the master may be deferred). - */ - - Tcl_DeleteHashEntry(slavePtr->slaveEntry); - cmdPtr->clientData = NULL; - cmdPtr->deleteProc = NULL; - cmdPtr->deleteData = NULL; - - /* - * Get the command name from the master interpreter instead of - * relying on the stored name; the command may have been renamed. - */ - - Tcl_DeleteCommand(slavePtr->masterInterp, - Tcl_GetCommandName(slavePtr->masterInterp, - slavePtr->interpCmd)); - } - - /* - * If there are any aliases, delete those now. This removes any - * dependency on the order of deletion between commands and the - * slave record. - */ - - hTblPtr = (Tcl_HashTable *) &(slavePtr->aliasTable); - for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); - hPtr != (Tcl_HashEntry *) NULL; - hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) { - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - - /* - * The call to Tcl_DeleteCommand will release the storage - * occuppied by the hash entry and the alias record. - * NOTE that we cannot use the alias name directly because its - * storage will be deleted in the command deletion callback. Hence - * we must use the name for the command as stored in the hash table. - */ - - Tcl_DeleteCommand(interp, - Tcl_GetCommandName(interp, aliasPtr->slaveCmd)); - } - - /* - * Finally dispose of the slave record itself. - */ - - ckfree((char *) slavePtr); -} - -/* - *---------------------------------------------------------------------- - * - * TclInterpInit -- - * - * Initializes the invoking interpreter for using the "interp" - * facility. This is called from inside Tcl_Init. - * - * Results: - * None. - * - * Side effects: - * Adds the "interp" command to an interpreter and initializes several - * records in the associated data of the invoking interpreter. - * - *---------------------------------------------------------------------- - */ - -int -TclInterpInit( - Tcl_Interp *interp /* Interpreter to initialize. */ -) -{ - Master *masterPtr; /* Its Master record. */ - - masterPtr = (Master *) ckalloc((unsigned) sizeof(Master)); - masterPtr->isSafe = 0; - Tcl_InitHashTable(&(masterPtr->slaveTable), TCL_STRING_KEYS); - Tcl_InitHashTable(&(masterPtr->targetTable), TCL_ONE_WORD_KEYS); - - (void) Tcl_SetAssocData(interp, "tclMasterRecord", MasterRecordDeleteProc, - (ClientData) masterPtr); - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_IsSafe -- - * - * Determines whether an interpreter is safe - * - * Results: - * 1 if it is safe, 0 if it is not. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_IsSafe( - Tcl_Interp *interp /* Is this interpreter "safe" ? */ -) -{ - Master *masterPtr; /* Its master record. */ - - if (interp == (Tcl_Interp *) NULL) { - return 0; - } - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("Tcl_IsSafe: could not find master record"); - } - return masterPtr->isSafe; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_MakeSafe -- - * - * Makes an interpreter safe. - * - * Results: - * TCL_OK if it succeeds, TCL_ERROR else. - * - * Side effects: - * Removes functionality from an interpreter. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_MakeSafe( - Tcl_Interp *interp /* Make this interpreter "safe". */ -) -{ - if (interp == (Tcl_Interp *) NULL) { - return TCL_ERROR; - } - return MakeSafe(interp); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateSlave -- - * - * Creates a slave interpreter. The slavePath argument denotes the - * name of the new slave relative to the current interpreter; the - * slave is a direct descendant of the one-before-last component of - * the path, e.g. it is a descendant of the current interpreter if - * the slavePath argument contains only one component. Optionally makes - * the slave interpreter safe. - * - * Results: - * Returns the interpreter structure created, or NULL if an error - * occurred. - * - * Side effects: - * Creates a new interpreter and a new interpreter object command in - * the interpreter indicated by the slavePath argument. - * - *---------------------------------------------------------------------- - */ - -Tcl_Interp * -Tcl_CreateSlave( - Tcl_Interp *interp, /* Interpreter to start search at. */ - char *slavePath, /* Name of slave to create. */ - int isSafe /* Should new slave be "safe" ? */ -) -{ - if ((interp == (Tcl_Interp *) NULL) || (slavePath == (char *) NULL)) { - return NULL; - } - return CreateSlave(interp, slavePath, isSafe); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetSlave -- - * - * Finds a slave interpreter by its path name. - * - * Results: - * Returns a Tcl_Interp * for the named interpreter or NULL if not - * found. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_Interp * -Tcl_GetSlave( - Tcl_Interp *interp, /* Interpreter to start search from. */ - char *slavePath /* Path of slave to find. */ -) -{ - Master *masterPtr; /* Interim storage for Master record. */ - - if ((interp == (Tcl_Interp *) NULL) || (slavePath == (char *) NULL)) { - return NULL; - } - masterPtr = (Master *) Tcl_GetAssocData(interp, "tclMasterRecord", NULL); - if (masterPtr == (Master *) NULL) { - panic("Tcl_GetSlave: could not find master record"); - } - return GetInterp(interp, masterPtr, slavePath, NULL); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetMaster -- - * - * Finds the master interpreter of a slave interpreter. - * - * Results: - * Returns a Tcl_Interp * for the master interpreter or NULL if none. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_Interp * -Tcl_GetMaster( - Tcl_Interp *interp /* Get the master of this interpreter. */ -) -{ - Slave *slavePtr; /* Slave record of this interpreter. */ - - if (interp == (Tcl_Interp *) NULL) { - return NULL; - } - slavePtr = (Slave *) Tcl_GetAssocData(interp, "tclSlaveRecord", NULL); - if (slavePtr == (Slave *) NULL) { - return NULL; - } - return slavePtr->masterInterp; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateAlias -- - * - * Creates an alias between two interpreters. - * - * Results: - * TCL_OK if successful, TCL_ERROR if failed. If TCL_ERROR is returned - * the result of slaveInterp will contain an error message. - * - * Side effects: - * Creates a new alias, manipulates the result field of slaveInterp. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_CreateAlias( - Tcl_Interp *slaveInterp, /* Interpreter for source command. */ - char *slaveCmd, /* Command to install in slave. */ - Tcl_Interp *targetInterp, /* Interpreter for target command. */ - char *targetCmd, /* Name of target command. */ - int argc, /* How many additional arguments? */ - char **argv /* These are the additional args. */ -) -{ - Master *masterPtr; /* Master record for target interp. */ - - if ((slaveInterp == (Tcl_Interp *) NULL) || - (targetInterp == (Tcl_Interp *) NULL) || - (slaveCmd == (char *) NULL) || - (targetCmd == (char *) NULL)) { - return TCL_ERROR; - } - masterPtr = (Master *) Tcl_GetAssocData(targetInterp, "tclMasterRecord", - NULL); - if (masterPtr == (Master *) NULL) { - panic("Tcl_CreateAlias: could not find master record"); - } - return AliasHelper(slaveInterp, slaveInterp, targetInterp, masterPtr, - slaveCmd, targetCmd, argc, argv); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetAlias -- - * - * Gets information about an alias. - * - * Results: - * TCL_OK if successful, TCL_ERROR else. If TCL_ERROR is returned, the - * result field of the interpreter given as argument will contain an - * error message. - * - * Side effects: - * Manipulates the result field of the interpreter given as argument. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetAlias( - Tcl_Interp *interp, /* Interp to start search from. */ - char *aliasName, /* Name of alias to find. */ - Tcl_Interp **targetInterpPtr, /* (Return) target interpreter. */ - char **targetNamePtr, /* (Return) name of target command. */ - int *argcPtr, /* (Return) count of addnl args. */ - char ***argvPtr /* (Return) additional arguments. */ -) -{ - Slave *slavePtr; /* Slave record for slave interp. */ - Tcl_HashEntry *hPtr; /* Search element. */ - Alias *aliasPtr; /* Storage for alias found. */ - - if ((interp == (Tcl_Interp *) NULL) || (aliasName == (char *) NULL)) { - return TCL_ERROR; - } - slavePtr = (Slave *) Tcl_GetAssocData(interp, "tclSlaveRecord", NULL); - if (slavePtr == (Slave *) NULL) { - panic("Tcl_GetAlias: could not find slave record"); - } - hPtr = Tcl_FindHashEntry(&(slavePtr->aliasTable), aliasName); - if (hPtr == (Tcl_HashEntry *) NULL) { - Tcl_AppendResult(interp, "alias \"", aliasName, "\" not found", - (char *) NULL); - return TCL_ERROR; - } - aliasPtr = (Alias *) Tcl_GetHashValue(hPtr); - if (targetInterpPtr != (Tcl_Interp **) NULL) { - *targetInterpPtr = aliasPtr->targetInterp; - } - if (targetNamePtr != (char **) NULL) { - *targetNamePtr = aliasPtr->targetName; - } - if (argcPtr != (int *) NULL) { - *argcPtr = aliasPtr->argc; - } - if (argvPtr != (char ***) NULL) { - *argvPtr = aliasPtr->argv; - } - return TCL_OK; -} diff --git a/cde/programs/dtdocbook/tcl/tclLink.c b/cde/programs/dtdocbook/tcl/tclLink.c deleted file mode 100644 index 15f0c33ee..000000000 --- a/cde/programs/dtdocbook/tcl/tclLink.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclLink.c /main/2 1996/08/08 14:45:07 cde-hp $ */ -/* - * tclLink.c -- - * - * This file implements linked variables (a C variable that is - * tied to a Tcl variable). The idea of linked variables was - * first suggested by Andreas Stolcke and this implementation is - * based heavily on a prototype implementation provided by - * him. - * - * Copyright (c) 1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclLink.c 1.12 96/02/15 11:50:26 - */ - -#include "tclInt.h" - -/* - * For each linked variable there is a data structure of the following - * type, which describes the link and is the clientData for the trace - * set on the Tcl variable. - */ - -typedef struct Link { - Tcl_Interp *interp; /* Interpreter containing Tcl variable. */ - char *varName; /* Name of variable (must be global). This - * is needed during trace callbacks, since - * the actual variable may be aliased at - * that time via upvar. */ - char *addr; /* Location of C variable. */ - int type; /* Type of link (TCL_LINK_INT, etc.). */ - int writable; /* Zero means Tcl variable is read-only. */ - union { - int i; - double d; - } lastValue; /* Last known value of C variable; used to - * avoid string conversions. */ -} Link; - -/* - * Forward references to procedures defined later in this file: - */ - -static char * LinkTraceProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); -static char * StringValue _ANSI_ARGS_((Link *linkPtr, - char *buffer)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_LinkVar -- - * - * Link a C variable to a Tcl variable so that changes to either - * one causes the other to change. - * - * Results: - * The return value is TCL_OK if everything went well or TCL_ERROR - * if an error occurred (interp->result is also set after errors). - * - * Side effects: - * The value at *addr is linked to the Tcl variable "varName", - * using "type" to convert between string values for Tcl and - * binary values for *addr. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_LinkVar( - Tcl_Interp *interp, /* Interpreter in which varName exists. */ - char *varName, /* Name of a global variable in interp. */ - char *addr, /* Address of a C variable to be linked - * to varName. */ - int type /* Type of C variable: TCL_LINK_INT, etc. - * Also may have TCL_LINK_READ_ONLY - * OR'ed in. */ -) -{ - Link *linkPtr; - char buffer[TCL_DOUBLE_SPACE]; - int code; - - linkPtr = (Link *) ckalloc(sizeof(Link)); - linkPtr->interp = interp; - linkPtr->varName = (char *) ckalloc((unsigned) (strlen(varName) + 1)); - strcpy(linkPtr->varName, varName); - linkPtr->addr = addr; - linkPtr->type = type & ~TCL_LINK_READ_ONLY; - linkPtr->writable = (type & TCL_LINK_READ_ONLY) == 0; - if (Tcl_SetVar(interp, varName, StringValue(linkPtr, buffer), - TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { - ckfree(linkPtr->varName); - ckfree((char *) linkPtr); - return TCL_ERROR; - } - code = Tcl_TraceVar(interp, varName, TCL_GLOBAL_ONLY|TCL_TRACE_READS - |TCL_TRACE_WRITES|TCL_TRACE_UNSETS, LinkTraceProc, - (ClientData) linkPtr); - if (code != TCL_OK) { - ckfree(linkPtr->varName); - ckfree((char *) linkPtr); - } - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UnlinkVar -- - * - * Destroy the link between a Tcl variable and a C variable. - * - * Results: - * None. - * - * Side effects: - * If "varName" was previously linked to a C variable, the link - * is broken to make the variable independent. If there was no - * previous link for "varName" then nothing happens. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_UnlinkVar( - Tcl_Interp *interp, /* Interpreter containing variable to unlink. */ - char *varName /* Global variable in interp to unlink. */ -) -{ - Link *linkPtr; - - linkPtr = (Link *) Tcl_VarTraceInfo(interp, varName, TCL_GLOBAL_ONLY, - LinkTraceProc, (ClientData) NULL); - if (linkPtr == NULL) { - return; - } - Tcl_UntraceVar(interp, varName, - TCL_GLOBAL_ONLY|TCL_TRACE_READS|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - LinkTraceProc, (ClientData) linkPtr); - ckfree(linkPtr->varName); - ckfree((char *) linkPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UpdateLinkedVar -- - * - * This procedure is invoked after a linked variable has been - * changed by C code. It updates the Tcl variable so that - * traces on the variable will trigger. - * - * Results: - * None. - * - * Side effects: - * The Tcl variable "varName" is updated from its C value, - * causing traces on the variable to trigger. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_UpdateLinkedVar( - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *varName /* Name of global variable that is linked. */ -) -{ - Link *linkPtr; - char buffer[TCL_DOUBLE_SPACE]; - - linkPtr = (Link *) Tcl_VarTraceInfo(interp, varName, TCL_GLOBAL_ONLY, - LinkTraceProc, (ClientData) NULL); - if (linkPtr == NULL) { - return; - } - Tcl_SetVar(interp, linkPtr->varName, StringValue(linkPtr, buffer), - TCL_GLOBAL_ONLY); -} - -/* - *---------------------------------------------------------------------- - * - * LinkTraceProc -- - * - * This procedure is invoked when a linked Tcl variable is read, - * written, or unset from Tcl. It's responsible for keeping the - * C variable in sync with the Tcl variable. - * - * Results: - * If all goes well, NULL is returned; otherwise an error message - * is returned. - * - * Side effects: - * The C variable may be updated to make it consistent with the - * Tcl variable, or the Tcl variable may be overwritten to reject - * a modification. - * - *---------------------------------------------------------------------- - */ - -static char * -LinkTraceProc( - ClientData clientData, /* Contains information about the link. */ - Tcl_Interp *interp, /* Interpreter containing Tcl variable. */ - char *name1, /* First part of variable name. */ - char *name2, /* Second part of variable name. */ - int flags /* Miscellaneous additional information. */ -) -{ - Link *linkPtr = (Link *) clientData; - int changed; - char buffer[TCL_DOUBLE_SPACE]; - char *value, **pp; - Tcl_DString savedResult; - - /* - * If the variable is being unset, then just re-create it (with a - * trace) unless the whole interpreter is going away. - */ - - if (flags & TCL_TRACE_UNSETS) { - if (flags & TCL_INTERP_DESTROYED) { - ckfree(linkPtr->varName); - ckfree((char *) linkPtr); - } else if (flags & TCL_TRACE_DESTROYED) { - Tcl_SetVar(interp, linkPtr->varName, StringValue(linkPtr, buffer), - TCL_GLOBAL_ONLY); - Tcl_TraceVar(interp, linkPtr->varName, TCL_GLOBAL_ONLY - |TCL_TRACE_READS|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - LinkTraceProc, (ClientData) linkPtr); - } - return NULL; - } - - /* - * For read accesses, update the Tcl variable if the C variable - * has changed since the last time we updated the Tcl variable. - */ - - if (flags & TCL_TRACE_READS) { - switch (linkPtr->type) { - case TCL_LINK_INT: - case TCL_LINK_BOOLEAN: - changed = *(int *)(linkPtr->addr) != linkPtr->lastValue.i; - break; - case TCL_LINK_DOUBLE: - changed = *(double *)(linkPtr->addr) != linkPtr->lastValue.d; - break; - case TCL_LINK_STRING: - changed = 1; - break; - default: - return "internal error: bad linked variable type"; - } - if (changed) { - Tcl_SetVar(interp, linkPtr->varName, StringValue(linkPtr, buffer), - TCL_GLOBAL_ONLY); - } - return NULL; - } - - /* - * For writes, first make sure that the variable is writable. Then - * convert the Tcl value to C if possible. If the variable isn't - * writable or can't be converted, then restore the variable's old - * value and return an error. Another tricky thing: we have to save - * and restore the interpreter's result, since the variable access - * could occur when the result has been partially set. - */ - - if (!linkPtr->writable) { - Tcl_SetVar(interp, linkPtr->varName, StringValue(linkPtr, buffer), - TCL_GLOBAL_ONLY); - return "linked variable is read-only"; - } - value = Tcl_GetVar(interp, linkPtr->varName, TCL_GLOBAL_ONLY); - if (value == NULL) { - /* - * This shouldn't ever happen. - */ - return "internal error: linked variable couldn't be read"; - } - Tcl_DStringInit(&savedResult); - Tcl_DStringAppend(&savedResult, interp->result, -1); - Tcl_ResetResult(interp); - switch (linkPtr->type) { - case TCL_LINK_INT: - if (Tcl_GetInt(interp, value, &linkPtr->lastValue.i) != TCL_OK) { - Tcl_DStringResult(interp, &savedResult); - Tcl_SetVar(interp, linkPtr->varName, - StringValue(linkPtr, buffer), TCL_GLOBAL_ONLY); - return "variable must have integer value"; - } - *(int *)(linkPtr->addr) = linkPtr->lastValue.i; - break; - case TCL_LINK_DOUBLE: - if (Tcl_GetDouble(interp, value, &linkPtr->lastValue.d) - != TCL_OK) { - Tcl_DStringResult(interp, &savedResult); - Tcl_SetVar(interp, linkPtr->varName, - StringValue(linkPtr, buffer), TCL_GLOBAL_ONLY); - return "variable must have real value"; - } - *(double *)(linkPtr->addr) = linkPtr->lastValue.d; - break; - case TCL_LINK_BOOLEAN: - if (Tcl_GetBoolean(interp, value, &linkPtr->lastValue.i) - != TCL_OK) { - Tcl_DStringResult(interp, &savedResult); - Tcl_SetVar(interp, linkPtr->varName, - StringValue(linkPtr, buffer), TCL_GLOBAL_ONLY); - return "variable must have boolean value"; - } - *(int *)(linkPtr->addr) = linkPtr->lastValue.i; - break; - case TCL_LINK_STRING: - pp = (char **)(linkPtr->addr); - if (*pp != NULL) { - ckfree(*pp); - } - *pp = (char *) ckalloc((unsigned) (strlen(value) + 1)); - strcpy(*pp, value); - break; - default: - return "internal error: bad linked variable type"; - } - Tcl_DStringResult(interp, &savedResult); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * StringValue -- - * - * Converts the value of a C variable to a string for use in a - * Tcl variable to which it is linked. - * - * Results: - * The return value is a pointer - to a string that represents - * the value of the C variable given by linkPtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -StringValue( - Link *linkPtr, /* Structure describing linked variable. */ - char *buffer /* Small buffer to use for converting - * values. Must have TCL_DOUBLE_SPACE - * bytes or more. */ -) -{ - char *p; - - switch (linkPtr->type) { - case TCL_LINK_INT: - linkPtr->lastValue.i = *(int *)(linkPtr->addr); - sprintf(buffer, "%d", linkPtr->lastValue.i); - return buffer; - case TCL_LINK_DOUBLE: - linkPtr->lastValue.d = *(double *)(linkPtr->addr); - Tcl_PrintDouble(linkPtr->interp, linkPtr->lastValue.d, buffer); - return buffer; - case TCL_LINK_BOOLEAN: - linkPtr->lastValue.i = *(int *)(linkPtr->addr); - if (linkPtr->lastValue.i != 0) { - return "1"; - } - return "0"; - case TCL_LINK_STRING: - p = *(char **)(linkPtr->addr); - if (p == NULL) { - return "NULL"; - } - return p; - } - - /* - * This code only gets executed if the link type is unknown - * (shouldn't ever happen). - */ - - return "??"; -} diff --git a/cde/programs/dtdocbook/tcl/tclLoad.c b/cde/programs/dtdocbook/tcl/tclLoad.c deleted file mode 100644 index 4a5d063f0..000000000 --- a/cde/programs/dtdocbook/tcl/tclLoad.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclLoad.c /main/2 1996/08/08 14:45:13 cde-hp $ */ -/* - * tclLoad.c -- - * - * This file provides the generic portion (those that are the same - * on all platforms) of Tcl's dynamic loading facilities. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclLoad.c 1.10 96/04/02 18:44:22 - */ - -#include "tclInt.h" - -/* - * The following structure describes a package that has been loaded - * either dynamically (with the "load" command) or statically (as - * indicated by a call to Tcl_PackageLoaded). All such packages - * are linked together into a single list for the process. Packages - * are never unloaded, so these structures are never freed. - */ - -typedef struct LoadedPackage { - char *fileName; /* Name of the file from which the - * package was loaded. An empty string - * means the package is loaded statically. - * Malloc-ed. */ - char *packageName; /* Name of package prefix for the package, - * properly capitalized (first letter UC, - * others LC), no "_", as in "Net". - * Malloc-ed. */ - Tcl_PackageInitProc *initProc; - /* Initialization procedure to call to - * incorporate this package into a trusted - * interpreter. */ - Tcl_PackageInitProc *safeInitProc; - /* Initialization procedure to call to - * incorporate this package into a safe - * interpreter (one that will execute - * untrusted scripts). NULL means the - * package can't be used in unsafe - * interpreters. */ - struct LoadedPackage *nextPtr; - /* Next in list of all packages loaded into - * this application process. NULL means - * end of list. */ -} LoadedPackage; - -static LoadedPackage *firstPackagePtr = NULL; - /* First in list of all packages loaded into - * this process. */ - -/* - * The following structure represents a particular package that has - * been incorporated into a particular interpreter (by calling its - * initialization procedure). There is a list of these structures for - * each interpreter, with an AssocData value (key "load") for the - * interpreter that points to the first package (if any). - */ - -typedef struct InterpPackage { - LoadedPackage *pkgPtr; /* Points to detailed information about - * package. */ - struct InterpPackage *nextPtr; - /* Next package in this interpreter, or - * NULL for end of list. */ -} InterpPackage; - -/* - * Prototypes for procedures that are private to this file: - */ - -static void LoadCleanupProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp)); -static void LoadExitProc _ANSI_ARGS_((ClientData clientData)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_LoadCmd -- - * - * This procedure is invoked to process the "load" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_LoadCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Interp *target; - LoadedPackage *pkgPtr; - Tcl_DString pkgName, initName, safeInitName, fileName; - Tcl_PackageInitProc *initProc, *safeInitProc; - InterpPackage *ipFirstPtr, *ipPtr; - int code, c, gotPkgName; - char *p, *fullFileName; - - if ((argc < 2) || (argc > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " fileName ?packageName? ?interp?\"", (char *) NULL); - return TCL_ERROR; - } - fullFileName = Tcl_TranslateFileName(interp, argv[1], &fileName); - if (fullFileName == NULL) { - return TCL_ERROR; - } - Tcl_DStringInit(&pkgName); - Tcl_DStringInit(&initName); - Tcl_DStringInit(&safeInitName); - if ((argc >= 3) && (argv[2][0] != 0)) { - gotPkgName = 1; - } else { - gotPkgName = 0; - } - if ((fullFileName[0] == 0) && !gotPkgName) { - interp->result = "must specify either file name or package name"; - code = TCL_ERROR; - goto done; - } - - /* - * Figure out which interpreter we're going to load the package into. - */ - - target = interp; - if (argc == 4) { - target = Tcl_GetSlave(interp, argv[3]); - if (target == NULL) { - Tcl_AppendResult(interp, "couldn't find slave interpreter named \"", - argv[3], "\"", (char *) NULL); - return TCL_ERROR; - } - } - - /* - * See if the desired file is already loaded. If so, its package - * name must agree with ours (if we have one). - */ - - for (pkgPtr = firstPackagePtr; pkgPtr != NULL; pkgPtr = pkgPtr->nextPtr) { - if (strcmp(pkgPtr->fileName, fullFileName) != 0) { - continue; - } - if (gotPkgName) { - char *p1, *p2; - for (p1 = argv[2], p2 = pkgPtr->packageName; ; p1++, p2++) { - if ((isupper(*p1) ? tolower(*p1) : *p1) - != (isupper(*p2) ? tolower(*p2) : *p2)) { - if (fullFileName[0] == 0) { - /* - * We're looking for a statically loaded package; - * the file name is basically irrelevant here, so - * don't get upset that there's some other package - * with the same (empty string) file name. Just - * skip this package and go on to the next. - */ - - goto nextPackage; - } - Tcl_AppendResult(interp, "file \"", fullFileName, - "\" is already loaded for package \"", - pkgPtr->packageName, "\"", (char *) NULL); - code = TCL_ERROR; - goto done; - } - if (*p1 == 0) { - goto gotPkg; - } - } - nextPackage: - continue; - } - break; - } - gotPkg: - - /* - * If the file is already loaded in the target interpreter then - * there's nothing for us to do. - */ - - ipFirstPtr = (InterpPackage *) Tcl_GetAssocData(target, "tclLoad", - (Tcl_InterpDeleteProc **) NULL); - if (pkgPtr != NULL) { - for (ipPtr = ipFirstPtr; ipPtr != NULL; ipPtr = ipPtr->nextPtr) { - if (ipPtr->pkgPtr == pkgPtr) { - code = TCL_OK; - goto done; - } - } - } - - if (pkgPtr == NULL) { - /* - * The desired file isn't currently loaded, so load it. It's an - * error if the desired package is a static one. - */ - - if (fullFileName[0] == 0) { - Tcl_AppendResult(interp, "package \"", argv[2], - "\" isn't loaded statically", (char *) NULL); - code = TCL_ERROR; - goto done; - } - - /* - * Figure out the module name if it wasn't provided explicitly. - */ - - if (gotPkgName) { - Tcl_DStringAppend(&pkgName, argv[2], -1); - } else { - if (!TclGuessPackageName(fullFileName, &pkgName)) { - int pargc; - char **pargv, *pkgGuess; - - /* - * The platform-specific code couldn't figure out the - * module name. Make a guess by taking the last element - * of the file name, stripping off any leading "lib", and - * then using all of the alphabetic characters that follow - * that. - */ - - Tcl_SplitPath(fullFileName, &pargc, &pargv); - pkgGuess = pargv[pargc-1]; - if ((pkgGuess[0] == 'l') && (pkgGuess[1] == 'i') - && (pkgGuess[2] == 'b')) { - pkgGuess += 3; - } - for (p = pkgGuess; isalpha(*p); p++) { - /* Empty loop body. */ - } - if (p == pkgGuess) { - ckfree((char *)pargv); - Tcl_AppendResult(interp, - "couldn't figure out package name for ", - fullFileName, (char *) NULL); - code = TCL_ERROR; - goto done; - } - Tcl_DStringAppend(&pkgName, pkgGuess, (p - pkgGuess)); - ckfree((char *)pargv); - } - } - - /* - * Fix the capitalization in the package name so that the first - * character is in caps but the others are all lower-case. - */ - - p = Tcl_DStringValue(&pkgName); - c = UCHAR(*p); - if (c != 0) { - if (islower(c)) { - *p = (char) toupper(c); - } - p++; - while (1) { - c = UCHAR(*p); - if (c == 0) { - break; - } - if (isupper(c)) { - *p = (char) tolower(c); - } - p++; - } - } - - /* - * Compute the names of the two initialization procedures, - * based on the package name. - */ - - Tcl_DStringAppend(&initName, Tcl_DStringValue(&pkgName), -1); - Tcl_DStringAppend(&initName, "_Init", 5); - Tcl_DStringAppend(&safeInitName, Tcl_DStringValue(&pkgName), -1); - Tcl_DStringAppend(&safeInitName, "_SafeInit", 9); - - /* - * Call platform-specific code to load the package and find the - * two initialization procedures. - */ - - code = TclLoadFile(interp, fullFileName, Tcl_DStringValue(&initName), - Tcl_DStringValue(&safeInitName), &initProc, &safeInitProc); - if (code != TCL_OK) { - goto done; - } - if (initProc == NULL) { - Tcl_AppendResult(interp, "couldn't find procedure ", - Tcl_DStringValue(&initName), (char *) NULL); - code = TCL_ERROR; - goto done; - } - - /* - * Create a new record to describe this package. - */ - - if (firstPackagePtr == NULL) { - Tcl_CreateExitHandler(LoadExitProc, (ClientData) NULL); - } - pkgPtr = (LoadedPackage *) ckalloc(sizeof(LoadedPackage)); - pkgPtr->fileName = (char *) ckalloc((unsigned) - (strlen(fullFileName) + 1)); - strcpy(pkgPtr->fileName, fullFileName); - pkgPtr->packageName = (char *) ckalloc((unsigned) - (Tcl_DStringLength(&pkgName) + 1)); - strcpy(pkgPtr->packageName, Tcl_DStringValue(&pkgName)); - pkgPtr->initProc = initProc; - pkgPtr->safeInitProc = safeInitProc; - pkgPtr->nextPtr = firstPackagePtr; - firstPackagePtr = pkgPtr; - } - - /* - * Invoke the package's initialization procedure (either the - * normal one or the safe one, depending on whether or not the - * interpreter is safe). - */ - - if (Tcl_IsSafe(target)) { - if (pkgPtr->safeInitProc != NULL) { - code = (*pkgPtr->safeInitProc)(target); - } else { - Tcl_AppendResult(interp, - "can't use package in a safe interpreter: ", - "no ", pkgPtr->packageName, "_SafeInit procedure", - (char *) NULL); - code = TCL_ERROR; - goto done; - } - } else { - code = (*pkgPtr->initProc)(target); - } - if ((code == TCL_ERROR) && (target != interp)) { - /* - * An error occurred, so transfer error information from the - * destination interpreter back to our interpreter. Must clear - * interp's result before calling Tcl_AddErrorInfo, since - * Tcl_AddErrorInfo will store the interp's result in errorInfo - * before appending target's $errorInfo; we've already got - * everything we need in target's $errorInfo. - */ - - Tcl_ResetResult(interp); - Tcl_AddErrorInfo(interp, Tcl_GetVar2(target, - "errorInfo", (char *) NULL, TCL_GLOBAL_ONLY)); - Tcl_SetVar2(interp, "errorCode", (char *) NULL, - Tcl_GetVar2(target, "errorCode", (char *) NULL, - TCL_GLOBAL_ONLY), TCL_GLOBAL_ONLY); - Tcl_SetResult(interp, target->result, TCL_VOLATILE); - } - - /* - * Record the fact that the package has been loaded in the - * target interpreter. - */ - - if (code == TCL_OK) { - ipPtr = (InterpPackage *) ckalloc(sizeof(InterpPackage)); - ipPtr->pkgPtr = pkgPtr; - ipPtr->nextPtr = ipFirstPtr; - Tcl_SetAssocData(target, "tclLoad", LoadCleanupProc, - (ClientData) ipPtr); - } - - done: - Tcl_DStringFree(&pkgName); - Tcl_DStringFree(&initName); - Tcl_DStringFree(&safeInitName); - Tcl_DStringFree(&fileName); - return code; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_StaticPackage -- - * - * This procedure is invoked to indicate that a particular - * package has been linked statically with an application. - * - * Results: - * None. - * - * Side effects: - * Once this procedure completes, the package becomes loadable - * via the "load" command with an empty file name. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_StaticPackage( - Tcl_Interp *interp, /* If not NULL, it means that the - * package has already been loaded - * into the given interpreter by - * calling the appropriate init proc. */ - char *pkgName, /* Name of package (must be properly - * capitalized: first letter upper - * case, others lower case). */ - Tcl_PackageInitProc *initProc, /* Procedure to call to incorporate - * this package into a trusted - * interpreter. */ - Tcl_PackageInitProc *safeInitProc /* Procedure to call to incorporate - * this package into a safe interpreter - * (one that will execute untrusted - * scripts). NULL means the package - * can't be used in safe - * interpreters. */ -) -{ - LoadedPackage *pkgPtr; - InterpPackage *ipPtr, *ipFirstPtr; - - if (firstPackagePtr == NULL) { - Tcl_CreateExitHandler(LoadExitProc, (ClientData) NULL); - } - pkgPtr = (LoadedPackage *) ckalloc(sizeof(LoadedPackage)); - pkgPtr->fileName = (char *) ckalloc((unsigned) 1); - pkgPtr->fileName[0] = 0; - pkgPtr->packageName = (char *) ckalloc((unsigned) - (strlen(pkgName) + 1)); - strcpy(pkgPtr->packageName, pkgName); - pkgPtr->initProc = initProc; - pkgPtr->safeInitProc = safeInitProc; - pkgPtr->nextPtr = firstPackagePtr; - firstPackagePtr = pkgPtr; - - if (interp != NULL) { - ipFirstPtr = (InterpPackage *) Tcl_GetAssocData(interp, "tclLoad", - (Tcl_InterpDeleteProc **) NULL); - ipPtr = (InterpPackage *) ckalloc(sizeof(InterpPackage)); - ipPtr->pkgPtr = pkgPtr; - ipPtr->nextPtr = ipFirstPtr; - Tcl_SetAssocData(interp, "tclLoad", LoadCleanupProc, - (ClientData) ipPtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * TclGetLoadedPackages -- - * - * This procedure returns information about all of the files - * that are loaded (either in a particular intepreter, or - * for all interpreters). - * - * Results: - * The return value is a standard Tcl completion code. If - * successful, a list of lists is placed in interp->result. - * Each sublist corresponds to one loaded file; its first - * element is the name of the file (or an empty string for - * something that's statically loaded) and the second element - * is the name of the package in that file. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGetLoadedPackages( - Tcl_Interp *interp, /* Interpreter in which to return - * information or error message. */ - char *targetName /* Name of target interpreter or NULL. - * If NULL, return info about all interps; - * otherwise, just return info about this - * interpreter. */ -) -{ - Tcl_Interp *target; - LoadedPackage *pkgPtr; - InterpPackage *ipPtr; - char *prefix; - - if (targetName == NULL) { - /* - * Return information about all of the available packages. - */ - - prefix = "{"; - for (pkgPtr = firstPackagePtr; pkgPtr != NULL; - pkgPtr = pkgPtr->nextPtr) { - Tcl_AppendResult(interp, prefix, (char *) NULL); - Tcl_AppendElement(interp, pkgPtr->fileName); - Tcl_AppendElement(interp, pkgPtr->packageName); - Tcl_AppendResult(interp, "}", (char *) NULL); - prefix = " {"; - } - return TCL_OK; - } - - /* - * Return information about only the packages that are loaded in - * a given interpreter. - */ - - target = Tcl_GetSlave(interp, targetName); - if (target == NULL) { - Tcl_AppendResult(interp, "couldn't find slave interpreter named \"", - targetName, "\"", (char *) NULL); - return TCL_ERROR; - } - ipPtr = (InterpPackage *) Tcl_GetAssocData(target, "tclLoad", - (Tcl_InterpDeleteProc **) NULL); - prefix = "{"; - for ( ; ipPtr != NULL; ipPtr = ipPtr->nextPtr) { - pkgPtr = ipPtr->pkgPtr; - Tcl_AppendResult(interp, prefix, (char *) NULL); - Tcl_AppendElement(interp, pkgPtr->fileName); - Tcl_AppendElement(interp, pkgPtr->packageName); - Tcl_AppendResult(interp, "}", (char *) NULL); - prefix = " {"; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * LoadCleanupProc -- - * - * This procedure is called to delete all of the InterpPackage - * structures for an interpreter when the interpreter is deleted. - * It gets invoked via the Tcl AssocData mechanism. - * - * Results: - * None. - * - * Side effects: - * Storage for all of the InterpPackage procedures for interp - * get deleted. - * - *---------------------------------------------------------------------- - */ - -static void -LoadCleanupProc( - ClientData clientData, /* Pointer to first InterpPackage structure - * for interp. */ - Tcl_Interp *interp /* Interpreter that is being deleted. */ -) -{ - InterpPackage *ipPtr, *nextPtr; - - ipPtr = (InterpPackage *) clientData; - while (ipPtr != NULL) { - nextPtr = ipPtr->nextPtr; - ckfree((char *) ipPtr); - ipPtr = nextPtr; - } -} - -/* - *---------------------------------------------------------------------- - * - * LoadExitProc -- - * - * This procedure is invoked just before the application exits. - * It frees all of the LoadedPackage structures. - * - * Results: - * None. - * - * Side effects: - * Memory is freed. - * - *---------------------------------------------------------------------- - */ - -static void -LoadExitProc( - ClientData clientData /* Not used. */ -) -{ - LoadedPackage *pkgPtr; - - while (firstPackagePtr != NULL) { - pkgPtr = firstPackagePtr; - firstPackagePtr = pkgPtr->nextPtr; - ckfree(pkgPtr->fileName); - ckfree(pkgPtr->packageName); - ckfree((char *) pkgPtr); - } -} diff --git a/cde/programs/dtdocbook/tcl/tclLoadNone.c b/cde/programs/dtdocbook/tcl/tclLoadNone.c deleted file mode 100644 index 408afd3f8..000000000 --- a/cde/programs/dtdocbook/tcl/tclLoadNone.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclLoadNone.c /main/2 1996/08/08 14:45:21 cde-hp $ */ -/* - * tclLoadNone.c -- - * - * This procedure provides a version of the TclLoadFile for use - * in systems that don't support dynamic loading; it just returns - * an error. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclLoadNone.c 1.5 96/02/15 11:43:01 - */ - -#include "tclInt.h" - -/* - *---------------------------------------------------------------------- - * - * TclLoadFile -- - * - * This procedure is called to carry out dynamic loading of binary - * code; it is intended for use only on systems that don't support - * dynamic loading (it returns an error). - * - * Results: - * The result is TCL_ERROR, and an error message is left in - * interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclLoadFile( - Tcl_Interp *interp, /* Used for error reporting. */ - char *fileName, /* Name of the file containing the desired - * code. */ - char *sym1, char *sym2, /* Names of two procedures to look up in - * the file's symbol table. */ - Tcl_PackageInitProc **proc1Ptr, Tcl_PackageInitProc **proc2Ptr - /* Where to return the addresses corresponding - * to sym1 and sym2. */ -) -{ - interp->result = - "dynamic loading is not currently available on this system"; - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * TclGuessPackageName -- - * - * If the "load" command is invoked without providing a package - * name, this procedure is invoked to try to figure it out. - * - * Results: - * Always returns 0 to indicate that we couldn't figure out a - * package name; generic code will then try to guess the package - * from the file name. A return value of 1 would have meant that - * we figured out the package name and put it in bufPtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGuessPackageName( - char *fileName, /* Name of file containing package (already - * translated to local form if needed). */ - Tcl_DString *bufPtr /* Initialized empty dstring. Append - * package name to this if possible. */ -) -{ - return 0; -} diff --git a/cde/programs/dtdocbook/tcl/tclMain.c b/cde/programs/dtdocbook/tcl/tclMain.c deleted file mode 100644 index e41354fc3..000000000 --- a/cde/programs/dtdocbook/tcl/tclMain.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclMain.c /main/2 1996/08/08 14:45:29 cde-hp $ */ -/* - * tclMain.c -- - * - * Main program for Tcl shells and other Tcl-based applications. - * - * Copyright (c) 1988-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclMain.c 1.50 96/04/10 16:40:57 - */ - -#include "tcl.h" -#include "tclInt.h" - -/* - * The following code ensures that tclLink.c is linked whenever - * Tcl is linked. Without this code there's no reference to the - * code in that file from anywhere in Tcl, so it may not be - * linked into the application. - */ - -EXTERN int Tcl_LinkVar(); -int (*tclDummyLinkVarPtr)() = Tcl_LinkVar; - -/* - * Declarations for various library procedures and variables (don't want - * to include tclPort.h here, because people might copy this file out of - * the Tcl source directory to make their own modified versions). - * Note: "exit" should really be declared here, but there's no way to - * declare it without causing conflicts with other definitions elsewher - * on some systems, so it's better just to leave it out. - */ - -extern int isatty _ANSI_ARGS_((int fd)); -extern char * strcpy _ANSI_ARGS_((char *dst, CONST char *src)); - -static Tcl_Interp *interp; /* Interpreter for application. */ -static Tcl_DString command; /* Used to buffer incomplete commands being - * read from stdin. */ -#ifdef TCL_MEM_DEBUG -static char dumpFile[100]; /* Records where to dump memory allocation - * information. */ -static int quitFlag = 0; /* 1 means the "checkmem" command was - * invoked, so the application should quit - * and dump memory allocation information. */ -#endif - -/* - * Forward references for procedures defined later in this file: - */ - -#ifdef TCL_MEM_DEBUG -static int CheckmemCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char *argv[])); -#endif - -/* - *---------------------------------------------------------------------- - * - * Tcl_Main -- - * - * Main program for tclsh and most other Tcl-based applications. - * - * Results: - * None. This procedure never returns (it exits the process when - * it's done. - * - * Side effects: - * This procedure initializes the Tk world and then starts - * interpreting commands; almost anything could happen, depending - * on the script being interpreted. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_Main( - int argc, /* Number of arguments. */ - char **argv, /* Array of argument strings. */ - Tcl_AppInitProc *appInitProc /* Application-specific initialization - * procedure to call after most - * initialization but before starting - * to execute commands. */ -) -{ - char buffer[1000], *cmd, *args, *fileName; - int code, gotPartial, tty, length; - int exitCode = 0; - Tcl_Channel inChannel, outChannel, errChannel; - Tcl_DString temp; - - Tcl_FindExecutable(argv[0]); - interp = Tcl_CreateInterp(); -#ifdef TCL_MEM_DEBUG - Tcl_InitMemory(interp); - Tcl_CreateCommand(interp, "checkmem", CheckmemCmd, (ClientData) 0, - (Tcl_CmdDeleteProc *) NULL); -#endif - - /* - * Make command-line arguments available in the Tcl variables "argc" - * and "argv". If the first argument doesn't start with a "-" then - * strip it off and use it as the name of a script file to process. - */ - - fileName = NULL; - if ((argc > 1) && (argv[1][0] != '-')) { - fileName = argv[1]; - argc--; - argv++; - } - args = Tcl_Merge(argc-1, argv+1); - Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY); - ckfree(args); - sprintf(buffer, "%d", argc-1); - Tcl_SetVar(interp, "argc", buffer, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "argv0", (fileName != NULL) ? fileName : argv[0], - TCL_GLOBAL_ONLY); - - /* - * Set the "tcl_interactive" variable. - */ - - tty = isatty(0); - Tcl_SetVar(interp, "tcl_interactive", - ((fileName == NULL) && tty) ? "1" : "0", TCL_GLOBAL_ONLY); - - /* - * Invoke application-specific initialization. - */ - - if ((*appInitProc)(interp) != TCL_OK) { - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (errChannel) { - Tcl_Write(errChannel, - "application-specific initialization failed: ", -1); - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", 1); - } - } - - /* - * If a script file was specified then just source that file - * and quit. - */ - - if (fileName != NULL) { - code = Tcl_EvalFile(interp, fileName); - if (code != TCL_OK) { - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (errChannel) { - /* - * The following statement guarantees that the errorInfo - * variable is set properly. - */ - - Tcl_AddErrorInfo(interp, ""); - Tcl_Write(errChannel, - Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY), -1); - Tcl_Write(errChannel, "\n", 1); - } - exitCode = 1; - } - goto done; - } - - /* - * We're running interactively. Source a user-specific startup - * file if the application specified one and if the file exists. - */ - - fileName = Tcl_GetVar(interp, "tcl_rcFileName", TCL_GLOBAL_ONLY); - - if (fileName != NULL) { - Tcl_Channel c; - char *fullName; - - Tcl_DStringInit(&temp); - fullName = Tcl_TranslateFileName(interp, fileName, &temp); - if (fullName == NULL) { - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (errChannel) { - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", 1); - } - } else { - - /* - * Test for the existence of the rc file before trying to read it. - */ - - c = Tcl_OpenFileChannel(NULL, fullName, "r", 0); - if (c != (Tcl_Channel) NULL) { - Tcl_Close(NULL, c); - if (Tcl_EvalFile(interp, fullName) != TCL_OK) { - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (errChannel) { - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", 1); - } - } - } - } - Tcl_DStringFree(&temp); - } - - /* - * Process commands from stdin until there's an end-of-file. Note - * that we need to fetch the standard channels again after every - * eval, since they may have been changed. - */ - - gotPartial = 0; - Tcl_DStringInit(&command); - inChannel = Tcl_GetStdChannel(TCL_STDIN); - outChannel = Tcl_GetStdChannel(TCL_STDOUT); - while (1) { - if (tty) { - char *promptCmd; - - promptCmd = Tcl_GetVar(interp, - gotPartial ? "tcl_prompt2" : "tcl_prompt1", TCL_GLOBAL_ONLY); - if (promptCmd == NULL) { -defaultPrompt: - if (!gotPartial && outChannel) { - Tcl_Write(outChannel, "% ", 2); - } - } else { - code = Tcl_Eval(interp, promptCmd); - inChannel = Tcl_GetStdChannel(TCL_STDIN); - outChannel = Tcl_GetStdChannel(TCL_STDOUT); - errChannel = Tcl_GetStdChannel(TCL_STDERR); - if (code != TCL_OK) { - if (errChannel) { - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", 1); - } - Tcl_AddErrorInfo(interp, - "\n (script that generates prompt)"); - goto defaultPrompt; - } - } - if (outChannel) { - Tcl_Flush(outChannel); - } - } - if (!inChannel) { - goto done; - } - length = Tcl_Gets(inChannel, &command); - if (length < 0) { - goto done; - } - if ((length == 0) && Tcl_Eof(inChannel) && (!gotPartial)) { - goto done; - } - - /* - * Add the newline removed by Tcl_Gets back to the string. - */ - - (void) Tcl_DStringAppend(&command, "\n", -1); - - cmd = Tcl_DStringValue(&command); - if (!Tcl_CommandComplete(cmd)) { - gotPartial = 1; - continue; - } - - gotPartial = 0; - code = Tcl_RecordAndEval(interp, cmd, 0); - inChannel = Tcl_GetStdChannel(TCL_STDIN); - outChannel = Tcl_GetStdChannel(TCL_STDOUT); - errChannel = Tcl_GetStdChannel(TCL_STDERR); - Tcl_DStringFree(&command); - if (code != TCL_OK) { - if (errChannel) { - Tcl_Write(errChannel, interp->result, -1); - Tcl_Write(errChannel, "\n", 1); - } - } else if (tty && (*interp->result != 0)) { - if (outChannel) { - Tcl_Write(outChannel, interp->result, -1); - Tcl_Write(outChannel, "\n", 1); - } - } -#ifdef TCL_MEM_DEBUG - if (quitFlag) { - Tcl_DeleteInterp(interp); - Tcl_Exit(0); - } -#endif - } - - /* - * Rather than calling exit, invoke the "exit" command so that - * users can replace "exit" with some other command to do additional - * cleanup on exit. The Tcl_Eval call should never return. - */ - -done: - sprintf(buffer, "exit %d", exitCode); - Tcl_Eval(interp, buffer); -} - -/* - *---------------------------------------------------------------------- - * - * CheckmemCmd -- - * - * This is the command procedure for the "checkmem" command, which - * causes the application to exit after printing information about - * memory usage to the file passed to this command as its first - * argument. - * - * Results: - * Returns a standard Tcl completion code. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -#ifdef TCL_MEM_DEBUG - - /* ARGSUSED */ -static int -CheckmemCmd( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter for evaluation. */ - int argc, /* Number of arguments. */ - char *argv[] /* String values of arguments. */ -) -{ - extern char *tclMemDumpFileName; - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " fileName\"", (char *) NULL); - return TCL_ERROR; - } - strcpy(dumpFile, argv[1]); - tclMemDumpFileName = dumpFile; - quitFlag = 1; - return TCL_OK; -} -#endif diff --git a/cde/programs/dtdocbook/tcl/tclMtherr.c b/cde/programs/dtdocbook/tcl/tclMtherr.c deleted file mode 100644 index b92b84c90..000000000 --- a/cde/programs/dtdocbook/tcl/tclMtherr.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclMtherr.c /main/2 1996/08/08 14:45:38 cde-hp $ */ -/* - * tclMatherr.c -- - * - * This function provides a default implementation of the - * "matherr" function, for SYS-V systems where it's needed. - * - * Copyright (c) 1993-1994 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclMtherr.c 1.11 96/02/15 11:58:36 - */ - -#include "tclInt.h" -#include <math.h> - -#ifndef TCL_GENERIC_ONLY -#include "tclPort.h" -#else -#define NO_ERRNO_H -#endif - -#ifdef NO_ERRNO_H -extern int errno; /* Use errno from tclExpr.c. */ -#define EDOM 33 -#define ERANGE 34 -#endif - -/* - * The following variable is secretly shared with Tcl so we can - * tell if expression evaluation is in progress. If not, matherr - * just emulates the default behavior, which includes printing - * a message. - */ - -extern int tcl_MathInProgress; - -/* - * The following definitions allow matherr to compile on systems - * that don't really support it. The compiled procedure is bogus, - * but it will never be executed on these systems anyway. - */ -#if defined(__linux__) && defined(__GLIBC__) -# include <features.h> -/* glibc removed matherr() support between 2.26 and 2.27 */ -# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 27) || __GLIBC__ >= 3 -# undef NEED_MATHERR -# endif -#endif /* linux */ - -#ifndef NEED_MATHERR -struct exception { - int type; -}; -#define DOMAIN 0 -#define SING 0 -#endif - -/* - *---------------------------------------------------------------------- - * - * matherr -- - * - * This procedure is invoked on Sys-V systems when certain - * errors occur in mathematical functions. Type "man matherr" - * for more information on how this function works. - * - * Results: - * Returns 1 to indicate that we've handled the error - * locally. - * - * Side effects: - * Sets errno based on what's in xPtr. - * - *---------------------------------------------------------------------- - */ - -int -matherr(xPtr) - struct exception *xPtr; /* Describes error that occurred. */ -{ - if (!tcl_MathInProgress) { - return 0; - } - if ((xPtr->type == DOMAIN) || (xPtr->type == SING)) { - errno = EDOM; - } else { - errno = ERANGE; - } - return 1; -} diff --git a/cde/programs/dtdocbook/tcl/tclNotify.c b/cde/programs/dtdocbook/tcl/tclNotify.c deleted file mode 100644 index 5fe36df55..000000000 --- a/cde/programs/dtdocbook/tcl/tclNotify.c +++ /dev/null @@ -1,608 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclNotify.c /main/2 1996/08/08 14:45:43 cde-hp $ */ -/* - * tclNotify.c -- - * - * This file provides the parts of the Tcl event notifier that are - * the same on all platforms, plus a few other parts that are used - * on more than one platform but not all. - * - * The notifier is the lowest-level part of the event system. It - * manages an event queue that holds Tcl_Event structures and a list - * of event sources that can add events to the queue. It also - * contains the procedure Tcl_DoOneEvent that invokes the event - * sources and blocks to wait for new events, but Tcl_DoOneEvent - * is in the platform-specific part of the notifier (in files like - * tclUnixNotify.c). - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclNotify.c 1.6 96/02/29 09:20:10 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The following variable records the address of the first event - * source in the list of all event sources for the application. - * This variable is accessed by the notifier to traverse the list - * and invoke each event source. - */ - -TclEventSource *tclFirstEventSourcePtr = NULL; - -/* - * The following variables indicate how long to block in the event - * notifier the next time it blocks (default: block forever). - */ - -static int blockTimeSet = 0; /* 0 means there is no maximum block - * time: block forever. */ -static Tcl_Time blockTime; /* If blockTimeSet is 1, gives the - * maximum elapsed time for the next block. */ - -/* - * The following variables keep track of the event queue. In addition - * to the first (next to be serviced) and last events in the queue, - * we keep track of a "marker" event. This provides a simple priority - * mechanism whereby events can be inserted at the front of the queue - * but behind all other high-priority events already in the queue (this - * is used for things like a sequence of Enter and Leave events generated - * during a grab in Tk). - */ - -static Tcl_Event *firstEventPtr = NULL; - /* First pending event, or NULL if none. */ -static Tcl_Event *lastEventPtr = NULL; - /* Last pending event, or NULL if none. */ -static Tcl_Event *markerEventPtr = NULL; - /* Last high-priority event in queue, or - * NULL if none. */ - -/* - * Prototypes for procedures used only in this file: - */ - -static int ServiceEvent _ANSI_ARGS_((int flags)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreateEventSource -- - * - * This procedure is invoked to create a new source of events. - * The source is identified by a procedure that gets invoked - * during Tcl_DoOneEvent to check for events on that source - * and queue them. - * - * - * Results: - * None. - * - * Side effects: - * SetupProc and checkProc will be invoked each time that Tcl_DoOneEvent - * runs out of things to do. SetupProc will be invoked before - * Tcl_DoOneEvent calls select or whatever else it uses to wait - * for events. SetupProc typically calls functions like Tcl_WatchFile - * or Tcl_SetMaxBlockTime to indicate what to wait for. - * - * CheckProc is called after select or whatever operation was actually - * used to wait. It figures out whether anything interesting actually - * happened (e.g. by calling Tcl_FileReady), and then calls - * Tcl_QueueEvent to queue any events that are ready. - * - * Each of these procedures is passed two arguments, e.g. - * (*checkProc)(ClientData clientData, int flags)); - * ClientData is the same as the clientData argument here, and flags - * is a combination of things like TCL_FILE_EVENTS that indicates - * what events are of interest: setupProc and checkProc use flags - * to figure out whether their events are relevant or not. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_CreateEventSource( - Tcl_EventSetupProc *setupProc, /* Procedure to invoke to figure out - * what to wait for. */ - Tcl_EventCheckProc *checkProc, /* Procedure to call after waiting - * to see what happened. */ - ClientData clientData /* One-word argument to pass to - * setupProc and checkProc. */ -) -{ - TclEventSource *sourcePtr; - - sourcePtr = (TclEventSource *) ckalloc(sizeof(TclEventSource)); - sourcePtr->setupProc = setupProc; - sourcePtr->checkProc = checkProc; - sourcePtr->clientData = clientData; - sourcePtr->nextPtr = tclFirstEventSourcePtr; - tclFirstEventSourcePtr = sourcePtr; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteEventSource -- - * - * This procedure is invoked to delete the source of events - * given by proc and clientData. - * - * Results: - * None. - * - * Side effects: - * The given event source is cancelled, so its procedure will - * never again be called. If no such source exists, nothing - * happens. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteEventSource( - Tcl_EventSetupProc *setupProc, /* Procedure to invoke to figure out - * what to wait for. */ - Tcl_EventCheckProc *checkProc, /* Procedure to call after waiting - * to see what happened. */ - ClientData clientData /* One-word argument to pass to - * setupProc and checkProc. */ -) -{ - TclEventSource *sourcePtr, *prevPtr; - - for (sourcePtr = tclFirstEventSourcePtr, prevPtr = NULL; - sourcePtr != NULL; - prevPtr = sourcePtr, sourcePtr = sourcePtr->nextPtr) { - if ((sourcePtr->setupProc != setupProc) - || (sourcePtr->checkProc != checkProc) - || (sourcePtr->clientData != clientData)) { - continue; - } - if (prevPtr == NULL) { - tclFirstEventSourcePtr = sourcePtr->nextPtr; - } else { - prevPtr->nextPtr = sourcePtr->nextPtr; - } - ckfree((char *) sourcePtr); - return; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_QueueEvent -- - * - * Insert an event into the Tk event queue at one of three - * positions: the head, the tail, or before a floating marker. - * Events inserted before the marker will be processed in - * first-in-first-out order, but before any events inserted at - * the tail of the queue. Events inserted at the head of the - * queue will be processed in last-in-first-out order. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_QueueEvent( - Tcl_Event* evPtr, /* Event to add to queue. The storage - * space must have been allocated the caller - * with malloc (ckalloc), and it becomes - * the property of the event queue. It - * will be freed after the event has been - * handled. */ - Tcl_QueuePosition position /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, - * TCL_QUEUE_MARK. */ -) -{ - if (position == TCL_QUEUE_TAIL) { - /* - * Append the event on the end of the queue. - */ - - evPtr->nextPtr = NULL; - if (firstEventPtr == NULL) { - firstEventPtr = evPtr; - } else { - lastEventPtr->nextPtr = evPtr; - } - lastEventPtr = evPtr; - } else if (position == TCL_QUEUE_HEAD) { - /* - * Push the event on the head of the queue. - */ - - evPtr->nextPtr = firstEventPtr; - if (firstEventPtr == NULL) { - lastEventPtr = evPtr; - } - firstEventPtr = evPtr; - } else if (position == TCL_QUEUE_MARK) { - /* - * Insert the event after the current marker event and advance - * the marker to the new event. - */ - - if (markerEventPtr == NULL) { - evPtr->nextPtr = firstEventPtr; - firstEventPtr = evPtr; - } else { - evPtr->nextPtr = markerEventPtr->nextPtr; - markerEventPtr->nextPtr = evPtr; - } - markerEventPtr = evPtr; - if (evPtr->nextPtr == NULL) { - lastEventPtr = evPtr; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DeleteEvents -- - * - * Calls a procedure for each event in the queue and deletes those - * for which the procedure returns 1. Events for which the - * procedure returns 0 are left in the queue. - * - * Results: - * None. - * - * Side effects: - * Potentially removes one or more events from the event queue. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DeleteEvents( - Tcl_EventDeleteProc *proc, /* The procedure to call. */ - ClientData clientData /* type-specific data. */ -) -{ - Tcl_Event *evPtr, *prevPtr, *hold; - - for (prevPtr = (Tcl_Event *) NULL, evPtr = firstEventPtr; - evPtr != (Tcl_Event *) NULL; - ) { - if ((*proc) (evPtr, clientData) == 1) { - if (firstEventPtr == evPtr) { - firstEventPtr = evPtr->nextPtr; - if (evPtr->nextPtr == (Tcl_Event *) NULL) { - lastEventPtr = (Tcl_Event *) NULL; - } - } else { - prevPtr->nextPtr = evPtr->nextPtr; - } - hold = evPtr; - evPtr = evPtr->nextPtr; - ckfree((char *) hold); - } else { - prevPtr = evPtr; - evPtr = evPtr->nextPtr; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * ServiceEvent -- - * - * Process one event from the event queue. This routine is called - * by the notifier whenever it wants Tk to process an event. - * - * Results: - * The return value is 1 if the procedure actually found an event - * to process. If no processing occurred, then 0 is returned. - * - * Side effects: - * Invokes all of the event handlers for the highest priority - * event in the event queue. May collapse some events into a - * single event or discard stale events. - * - *---------------------------------------------------------------------- - */ - -static int -ServiceEvent( - int flags /* Indicates what events should be processed. - * May be any combination of TCL_WINDOW_EVENTS - * TCL_FILE_EVENTS, TCL_TIMER_EVENTS, or other - * flags defined elsewhere. Events not - * matching this will be skipped for processing - * later. */ -) -{ - Tcl_Event *evPtr, *prevPtr; - Tcl_EventProc *proc; - - /* - * No event flags is equivalent to TCL_ALL_EVENTS. - */ - - if ((flags & TCL_ALL_EVENTS) == 0) { - flags |= TCL_ALL_EVENTS; - } - - /* - * Loop through all the events in the queue until we find one - * that can actually be handled. - */ - - for (evPtr = firstEventPtr; evPtr != NULL; evPtr = evPtr->nextPtr) { - /* - * Call the handler for the event. If it actually handles the - * event then free the storage for the event. There are two - * tricky things here, but stemming from the fact that the event - * code may be re-entered while servicing the event: - * - * 1. Set the "proc" field to NULL. This is a signal to ourselves - * that we shouldn't reexecute the handler if the event loop - * is re-entered. - * 2. When freeing the event, must search the queue again from the - * front to find it. This is because the event queue could - * change almost arbitrarily while handling the event, so we - * can't depend on pointers found now still being valid when - * the handler returns. - */ - - proc = evPtr->proc; - evPtr->proc = NULL; - if ((proc != NULL) && (*proc)(evPtr, flags)) { - if (firstEventPtr == evPtr) { - firstEventPtr = evPtr->nextPtr; - if (evPtr->nextPtr == NULL) { - lastEventPtr = NULL; - } - } else { - for (prevPtr = firstEventPtr; prevPtr->nextPtr != evPtr; - prevPtr = prevPtr->nextPtr) { - /* Empty loop body. */ - } - prevPtr->nextPtr = evPtr->nextPtr; - if (evPtr->nextPtr == NULL) { - lastEventPtr = prevPtr; - } - } - if (markerEventPtr == evPtr) { - markerEventPtr = NULL; - } - ckfree((char *) evPtr); - return 1; - } else { - /* - * The event wasn't actually handled, so we have to restore - * the proc field to allow the event to be attempted again. - */ - - evPtr->proc = proc; - } - - /* - * The handler for this event asked to defer it. Just go on to - * the next event. - */ - - continue; - } - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetMaxBlockTime -- - * - * This procedure is invoked by event sources to tell the notifier - * how long it may block the next time it blocks. The timePtr - * argument gives a maximum time; the actual time may be less if - * some other event source requested a smaller time. - * - * Results: - * None. - * - * Side effects: - * May reduce the length of the next sleep in the notifier. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetMaxBlockTime( - Tcl_Time *timePtr /* Specifies a maximum elapsed time for - * the next blocking operation in the - * event notifier. */ -) -{ - if (!blockTimeSet || (timePtr->sec < blockTime.sec) - || ((timePtr->sec == blockTime.sec) - && (timePtr->usec < blockTime.usec))) { - blockTime = *timePtr; - blockTimeSet = 1; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DoOneEvent -- - * - * Process a single event of some sort. If there's no work to - * do, wait for an event to occur, then process it. - * - * Results: - * The return value is 1 if the procedure actually found an event - * to process. If no processing occurred, then 0 is returned (this - * can happen if the TCL_DONT_WAIT flag is set or if there are no - * event handlers to wait for in the set specified by flags). - * - * Side effects: - * May delay execution of process while waiting for an event, - * unless TCL_DONT_WAIT is set in the flags argument. Event - * sources are invoked to check for and queue events. Event - * handlers may produce arbitrary side effects. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_DoOneEvent( - int flags /* Miscellaneous flag values: may be any - * combination of TCL_DONT_WAIT, - * TCL_WINDOW_EVENTS, TCL_FILE_EVENTS, - * TCL_TIMER_EVENTS, TCL_IDLE_EVENTS, or - * others defined by event sources. */ -) -{ - TclEventSource *sourcePtr; - Tcl_Time *timePtr; - - /* - * No event flags is equivalent to TCL_ALL_EVENTS. - */ - - if ((flags & TCL_ALL_EVENTS) == 0) { - flags |= TCL_ALL_EVENTS; - } - - /* - * The core of this procedure is an infinite loop, even though - * we only service one event. The reason for this is that we - * might think we have an event ready (e.g. the connection to - * the server becomes readable), but then we might discover that - * there's nothing interesting on that connection, so no event - * was serviced. Or, the select operation could return prematurely - * due to a signal. The easiest thing in both these cases is - * just to loop back and try again. - */ - - while (1) { - - /* - * The first thing we do is to service any asynchronous event - * handlers. - */ - - if (Tcl_AsyncReady()) { - (void) Tcl_AsyncInvoke((Tcl_Interp *) NULL, 0); - return 1; - } - - /* - * If idle events are the only things to service, skip the - * main part of the loop and go directly to handle idle - * events (i.e. don't wait even if TCL_DONT_WAIT isn't set. - */ - - if (flags == TCL_IDLE_EVENTS) { - flags = TCL_IDLE_EVENTS|TCL_DONT_WAIT; - goto idleEvents; - } - - /* - * Ask Tk to service a queued event, if there are any. - */ - - if (ServiceEvent(flags)) { - return 1; - } - - /* - * There are no events already queued. Invoke all of the - * event sources to give them a chance to setup for the wait. - */ - - blockTimeSet = 0; - for (sourcePtr = tclFirstEventSourcePtr; sourcePtr != NULL; - sourcePtr = sourcePtr->nextPtr) { - (*sourcePtr->setupProc)(sourcePtr->clientData, flags); - } - if ((flags & TCL_DONT_WAIT) || - ((flags & TCL_IDLE_EVENTS) && TclIdlePending())) { - /* - * Don't block: there are idle events waiting, or we don't - * care about idle events anyway, or the caller asked us not - * to block. - */ - - blockTime.sec = 0; - blockTime.usec = 0; - timePtr = &blockTime; - } else if (blockTimeSet) { - timePtr = &blockTime; - } else { - timePtr = NULL; - } - - /* - * Wait until an event occurs or the timer expires. - */ - - if (Tcl_WaitForEvent(timePtr) == TCL_ERROR) { - return 0; - } - - /* - * Give each of the event sources a chance to queue events, - * then call ServiceEvent and give it another chance to - * service events. - */ - - for (sourcePtr = tclFirstEventSourcePtr; sourcePtr != NULL; - sourcePtr = sourcePtr->nextPtr) { - (*sourcePtr->checkProc)(sourcePtr->clientData, flags); - } - if (ServiceEvent(flags)) { - return 1; - } - - /* - * We've tried everything at this point, but nobody had anything - * to do. Check for idle events. If none, either quit or go back - * to the top and try again. - */ - - idleEvents: - if ((flags & TCL_IDLE_EVENTS) && TclServiceIdle()) { - return 1; - } - if (flags & TCL_DONT_WAIT) { - return 0; - } - } -} diff --git a/cde/programs/dtdocbook/tcl/tclParse.c b/cde/programs/dtdocbook/tcl/tclParse.c deleted file mode 100644 index ac0c832f7..000000000 --- a/cde/programs/dtdocbook/tcl/tclParse.c +++ /dev/null @@ -1,1420 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclParse.c /main/2 1996/08/08 14:45:49 cde-hp $ */ -/* - * tclParse.c -- - * - * This file contains a collection of procedures that are used - * to parse Tcl commands or parts of commands (like quoted - * strings or nested sub-commands). - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclParse.c 1.50 96/03/02 14:46:55 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The following table assigns a type to each character. Only types - * meaningful to Tcl parsing are represented here. The table is - * designed to be referenced with either signed or unsigned characters, - * so it has 384 entries. The first 128 entries correspond to negative - * character values, the next 256 correspond to positive character - * values. The last 128 entries are identical to the first 128. The - * table is always indexed with a 128-byte offset (the 128th entry - * corresponds to a 0 character value). - */ - -char tclTypeTable[] = { - /* - * Negative character values, from -128 to -1: - */ - - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - - /* - * Positive character values, from 0-127: - */ - - TCL_COMMAND_END, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_SPACE, TCL_COMMAND_END, TCL_SPACE, - TCL_SPACE, TCL_SPACE, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_SPACE, TCL_NORMAL, TCL_QUOTE, TCL_NORMAL, - TCL_DOLLAR, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_COMMAND_END, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_OPEN_BRACKET, - TCL_BACKSLASH, TCL_COMMAND_END, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_OPEN_BRACE, - TCL_NORMAL, TCL_CLOSE_BRACE, TCL_NORMAL, TCL_NORMAL, - - /* - * Large unsigned character values, from 128-255: - */ - - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, - TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, -}; - -/* - * Function prototypes for procedures local to this file: - */ - -static char * QuoteEnd _ANSI_ARGS_((char *string, int term)); -static char * ScriptEnd _ANSI_ARGS_((char *p, int nested)); -static char * VarNameEnd _ANSI_ARGS_((char *string)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_Backslash -- - * - * Figure out how to handle a backslash sequence. - * - * Results: - * The return value is the character that should be substituted - * in place of the backslash sequence that starts at src. If - * readPtr isn't NULL then it is filled in with a count of the - * number of characters in the backslash sequence. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char -Tcl_Backslash( - char *src, /* Points to the backslash character of - * a backslash sequence. */ - int *readPtr /* Fill in with number of characters read - * from src, unless NULL. */ -) -{ - char *p = src+1; - char result; - int count; - - count = 2; - - switch (*p) { - case 'a': - result = 0x7; /* Don't say '\a' here, since some compilers */ - break; /* don't support it. */ - case 'b': - result = '\b'; - break; - case 'f': - result = '\f'; - break; - case 'n': - result = '\n'; - break; - case 'r': - result = '\r'; - break; - case 't': - result = '\t'; - break; - case 'v': - result = '\v'; - break; - case 'x': - if (isxdigit(UCHAR(p[1]))) { - char *end; - - result = (char) strtoul(p+1, &end, 16); - count = end - src; - } else { - count = 2; - result = 'x'; - } - break; - case '\n': - do { - p++; - } while ((*p == ' ') || (*p == '\t')); - result = ' '; - count = p - src; - break; - case 0: - result = '\\'; - count = 1; - break; - default: - if (isdigit(UCHAR(*p))) { - result = (char)(*p - '0'); - p++; - if (!isdigit(UCHAR(*p))) { - break; - } - count = 3; - result = (char)((result << 3) + (*p - '0')); - p++; - if (!isdigit(UCHAR(*p))) { - break; - } - count = 4; - result = (char)((result << 3) + (*p - '0')); - break; - } - result = *p; - count = 2; - break; - } - - if (readPtr != NULL) { - *readPtr = count; - } - return result; -} - -/* - *-------------------------------------------------------------- - * - * TclParseQuotes -- - * - * This procedure parses a double-quoted string such as a - * quoted Tcl command argument or a quoted value in a Tcl - * expression. This procedure is also used to parse array - * element names within parentheses, or anything else that - * needs all the substitutions that happen in quotes. - * - * Results: - * The return value is a standard Tcl result, which is - * TCL_OK unless there was an error while parsing the - * quoted string. If an error occurs then interp->result - * contains a standard error message. *TermPtr is filled - * in with the address of the character just after the - * last one successfully processed; this is usually the - * character just after the matching close-quote. The - * fully-substituted contents of the quotes are stored in - * standard fashion in *pvPtr, null-terminated with - * pvPtr->next pointing to the terminating null character. - * - * Side effects: - * The buffer space in pvPtr may be enlarged by calling its - * expandProc. - * - *-------------------------------------------------------------- - */ - -int -TclParseQuotes( - Tcl_Interp *interp, /* Interpreter to use for nested command - * evaluations and error messages. */ - char *string, /* Character just after opening double- - * quote. */ - int termChar, /* Character that terminates "quoted" string - * (usually double-quote, but sometimes - * right-paren or something else). */ - int flags, /* Flags to pass to nested Tcl_Eval calls. */ - char **termPtr, /* Store address of terminating character - * here. */ - ParseValue *pvPtr /* Information about where to place - * fully-substituted result of parse. */ -) -{ - char *src, *dst, c; - - src = string; - dst = pvPtr->next; - - while (1) { - if (dst == pvPtr->end) { - /* - * Target buffer space is about to run out. Make more space. - */ - - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, 1); - dst = pvPtr->next; - } - - c = *src; - src++; - if (c == termChar) { - *dst = '\0'; - pvPtr->next = dst; - *termPtr = src; - return TCL_OK; - } else if (CHAR_TYPE(c) == TCL_NORMAL) { - copy: - *dst = c; - dst++; - continue; - } else if (c == '$') { - int length; - char *value; - - value = Tcl_ParseVar(interp, src-1, termPtr); - if (value == NULL) { - return TCL_ERROR; - } - src = *termPtr; - length = strlen(value); - if ((pvPtr->end - dst) <= length) { - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, length); - dst = pvPtr->next; - } - strcpy(dst, value); - dst += length; - continue; - } else if (c == '[') { - int result; - - pvPtr->next = dst; - result = TclParseNestedCmd(interp, src, flags, termPtr, pvPtr); - if (result != TCL_OK) { - return result; - } - src = *termPtr; - dst = pvPtr->next; - continue; - } else if (c == '\\') { - int numRead; - - src--; - *dst = Tcl_Backslash(src, &numRead); - dst++; - src += numRead; - continue; - } else if (c == '\0') { - Tcl_ResetResult(interp); - sprintf(interp->result, "missing %c", termChar); - *termPtr = string-1; - return TCL_ERROR; - } else { - goto copy; - } - } -} - -/* - *-------------------------------------------------------------- - * - * TclParseNestedCmd -- - * - * This procedure parses a nested Tcl command between - * brackets, returning the result of the command. - * - * Results: - * The return value is a standard Tcl result, which is - * TCL_OK unless there was an error while executing the - * nested command. If an error occurs then interp->result - * contains a standard error message. *TermPtr is filled - * in with the address of the character just after the - * last one processed; this is usually the character just - * after the matching close-bracket, or the null character - * at the end of the string if the close-bracket was missing - * (a missing close bracket is an error). The result returned - * by the command is stored in standard fashion in *pvPtr, - * null-terminated, with pvPtr->next pointing to the null - * character. - * - * Side effects: - * The storage space at *pvPtr may be expanded. - * - *-------------------------------------------------------------- - */ - -int -TclParseNestedCmd( - Tcl_Interp *interp, /* Interpreter to use for nested command - * evaluations and error messages. */ - char *string, /* Character just after opening bracket. */ - int flags, /* Flags to pass to nested Tcl_Eval. */ - char **termPtr, /* Store address of terminating character - * here. */ - ParseValue *pvPtr /* Information about where to place - * result of command. */ -) -{ - int result, length, shortfall; - Interp *iPtr = (Interp *) interp; - - iPtr->evalFlags = flags | TCL_BRACKET_TERM; - result = Tcl_Eval(interp, string); - *termPtr = iPtr->termPtr; - if (result != TCL_OK) { - /* - * The increment below results in slightly cleaner message in - * the errorInfo variable (the close-bracket will appear). - */ - - if (**termPtr == ']') { - *termPtr += 1; - } - return result; - } - (*termPtr) += 1; - length = strlen(iPtr->result); - shortfall = length + 1 - (pvPtr->end - pvPtr->next); - if (shortfall > 0) { - (*pvPtr->expandProc)(pvPtr, shortfall); - } - strcpy(pvPtr->next, iPtr->result); - pvPtr->next += length; - Tcl_FreeResult(iPtr); - iPtr->result = iPtr->resultSpace; - iPtr->resultSpace[0] = '\0'; - return TCL_OK; -} - -/* - *-------------------------------------------------------------- - * - * TclParseBraces -- - * - * This procedure scans the information between matching - * curly braces. - * - * Results: - * The return value is a standard Tcl result, which is - * TCL_OK unless there was an error while parsing string. - * If an error occurs then interp->result contains a - * standard error message. *TermPtr is filled - * in with the address of the character just after the - * last one successfully processed; this is usually the - * character just after the matching close-brace. The - * information between curly braces is stored in standard - * fashion in *pvPtr, null-terminated with pvPtr->next - * pointing to the terminating null character. - * - * Side effects: - * The storage space at *pvPtr may be expanded. - * - *-------------------------------------------------------------- - */ - -int -TclParseBraces( - Tcl_Interp *interp, /* Interpreter to use for nested command - * evaluations and error messages. */ - char *string, /* Character just after opening bracket. */ - char **termPtr, /* Store address of terminating character - * here. */ - ParseValue *pvPtr /* Information about where to place - * result of command. */ -) -{ - int level; - char *src, *dst, *end; - char c; - - src = string; - dst = pvPtr->next; - end = pvPtr->end; - level = 1; - - /* - * Copy the characters one at a time to the result area, stopping - * when the matching close-brace is found. - */ - - while (1) { - c = *src; - src++; - if (dst == end) { - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, 20); - dst = pvPtr->next; - end = pvPtr->end; - } - *dst = c; - dst++; - if (CHAR_TYPE(c) == TCL_NORMAL) { - continue; - } else if (c == '{') { - level++; - } else if (c == '}') { - level--; - if (level == 0) { - dst--; /* Don't copy the last close brace. */ - break; - } - } else if (c == '\\') { - int count; - - /* - * Must always squish out backslash-newlines, even when in - * braces. This is needed so that this sequence can appear - * anywhere in a command, such as the middle of an expression. - */ - - if (*src == '\n') { - dst[-1] = Tcl_Backslash(src-1, &count); - src += count - 1; - } else { - (void) Tcl_Backslash(src-1, &count); - while (count > 1) { - if (dst == end) { - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, 20); - dst = pvPtr->next; - end = pvPtr->end; - } - *dst = *src; - dst++; - src++; - count--; - } - } - } else if (c == '\0') { - Tcl_SetResult(interp, "missing close-brace", TCL_STATIC); - *termPtr = string-1; - return TCL_ERROR; - } - } - - *dst = '\0'; - pvPtr->next = dst; - *termPtr = src; - return TCL_OK; -} - -/* - *-------------------------------------------------------------- - * - * TclParseWords -- - * - * This procedure parses one or more words from a command - * string and creates argv-style pointers to fully-substituted - * copies of those words. - * - * Results: - * The return value is a standard Tcl result. - * - * *argcPtr is modified to hold a count of the number of words - * successfully parsed, which may be 0. At most maxWords words - * will be parsed. If 0 <= *argcPtr < maxWords then it - * means that a command separator was seen. If *argcPtr - * is maxWords then it means that a command separator was - * not seen yet. - * - * *TermPtr is filled in with the address of the character - * just after the last one successfully processed in the - * last word. This is either the command terminator (if - * *argcPtr < maxWords), the character just after the last - * one in a word (if *argcPtr is maxWords), or the vicinity - * of an error (if the result is not TCL_OK). - * - * The pointers at *argv are filled in with pointers to the - * fully-substituted words, and the actual contents of the - * words are copied to the buffer at pvPtr. - * - * If an error occurrs then an error message is left in - * interp->result and the information at *argv, *argcPtr, - * and *pvPtr may be incomplete. - * - * Side effects: - * The buffer space in pvPtr may be enlarged by calling its - * expandProc. - * - *-------------------------------------------------------------- - */ - -int -TclParseWords( - Tcl_Interp *interp, /* Interpreter to use for nested command - * evaluations and error messages. */ - char *string, /* First character of word. */ - int flags, /* Flags to control parsing (same values as - * passed to Tcl_Eval). */ - int maxWords, /* Maximum number of words to parse. */ - char **termPtr, /* Store address of terminating character - * here. */ - int *argcPtr, /* Filled in with actual number of words - * parsed. */ - char **argv, /* Store addresses of individual words here. */ - ParseValue *pvPtr /* Information about where to place - * fully-substituted word. */ -) -{ - char *src, *dst; - char c; - int type, result, argc; - char *oldBuffer; /* Used to detect when pvPtr's buffer gets - * reallocated, so we can adjust all of the - * argv pointers. */ - - src = string; - oldBuffer = pvPtr->buffer; - dst = pvPtr->next; - for (argc = 0; argc < maxWords; argc++) { - argv[argc] = dst; - - /* - * Skip leading space. - */ - - skipSpace: - c = *src; - type = CHAR_TYPE(c); - while (type == TCL_SPACE) { - src++; - c = *src; - type = CHAR_TYPE(c); - } - - /* - * Handle the normal case (i.e. no leading double-quote or brace). - */ - - if (type == TCL_NORMAL) { - normalArg: - while (1) { - if (dst == pvPtr->end) { - /* - * Target buffer space is about to run out. Make - * more space. - */ - - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, 1); - dst = pvPtr->next; - } - - if (type == TCL_NORMAL) { - copy: - *dst = c; - dst++; - src++; - } else if (type == TCL_SPACE) { - goto wordEnd; - } else if (type == TCL_DOLLAR) { - int length; - char *value; - - value = Tcl_ParseVar(interp, src, termPtr); - if (value == NULL) { - return TCL_ERROR; - } - src = *termPtr; - length = strlen(value); - if ((pvPtr->end - dst) <= length) { - pvPtr->next = dst; - (*pvPtr->expandProc)(pvPtr, length); - dst = pvPtr->next; - } - strcpy(dst, value); - dst += length; - } else if (type == TCL_COMMAND_END) { - if ((c == ']') && !(flags & TCL_BRACKET_TERM)) { - goto copy; - } - - /* - * End of command; simulate a word-end first, so - * that the end-of-command can be processed as the - * first thing in a new word. - */ - - goto wordEnd; - } else if (type == TCL_OPEN_BRACKET) { - pvPtr->next = dst; - result = TclParseNestedCmd(interp, src+1, flags, termPtr, - pvPtr); - if (result != TCL_OK) { - return result; - } - src = *termPtr; - dst = pvPtr->next; - } else if (type == TCL_BACKSLASH) { - int numRead; - - *dst = Tcl_Backslash(src, &numRead); - - /* - * The following special check allows a backslash-newline - * to be treated as a word-separator, as if the backslash - * and newline had been collapsed before command parsing - * began. - */ - - if (src[1] == '\n') { - src += numRead; - goto wordEnd; - } - src += numRead; - dst++; - } else { - goto copy; - } - c = *src; - type = CHAR_TYPE(c); - } - } else { - - /* - * Check for the end of the command. - */ - - if (type == TCL_COMMAND_END) { - if (flags & TCL_BRACKET_TERM) { - if (c == '\0') { - Tcl_SetResult(interp, "missing close-bracket", - TCL_STATIC); - return TCL_ERROR; - } - } else { - if (c == ']') { - goto normalArg; - } - } - goto done; - } - - /* - * Now handle the special cases: open braces, double-quotes, - * and backslash-newline. - */ - - pvPtr->next = dst; - if (type == TCL_QUOTE) { - result = TclParseQuotes(interp, src+1, '"', flags, - termPtr, pvPtr); - } else if (type == TCL_OPEN_BRACE) { - result = TclParseBraces(interp, src+1, termPtr, pvPtr); - } else if ((type == TCL_BACKSLASH) && (src[1] == '\n')) { - /* - * This code is needed so that a backslash-newline at the - * very beginning of a word is treated as part of the white - * space between words and not as a space within the word. - */ - - src += 2; - goto skipSpace; - } else { - goto normalArg; - } - if (result != TCL_OK) { - return result; - } - - /* - * Back from quotes or braces; make sure that the terminating - * character was the end of the word. - */ - - c = **termPtr; - if ((c == '\\') && ((*termPtr)[1] == '\n')) { - /* - * Line is continued on next line; the backslash-newline - * sequence turns into space, which is OK. No need to do - * anything here. - */ - } else { - type = CHAR_TYPE(c); - if ((type != TCL_SPACE) && (type != TCL_COMMAND_END)) { - if (*src == '"') { - Tcl_SetResult(interp, - "extra characters after close-quote", - TCL_STATIC); - } else { - Tcl_SetResult(interp, - "extra characters after close-brace", - TCL_STATIC); - } - return TCL_ERROR; - } - } - src = *termPtr; - dst = pvPtr->next; - } - - /* - * We're at the end of a word, so add a null terminator. Then - * see if the buffer was re-allocated during this word. If so, - * update all of the argv pointers. - */ - - wordEnd: - *dst = '\0'; - dst++; - if (oldBuffer != pvPtr->buffer) { - int i; - - for (i = 0; i <= argc; i++) { - argv[i] = pvPtr->buffer + (argv[i] - oldBuffer); - } - oldBuffer = pvPtr->buffer; - } - } - - done: - pvPtr->next = dst; - *termPtr = src; - *argcPtr = argc; - return TCL_OK; -} - -/* - *-------------------------------------------------------------- - * - * TclExpandParseValue -- - * - * This procedure is commonly used as the value of the - * expandProc in a ParseValue. It uses malloc to allocate - * more space for the result of a parse. - * - * Results: - * The buffer space in *pvPtr is reallocated to something - * larger, and if pvPtr->clientData is non-zero the old - * buffer is freed. Information is copied from the old - * buffer to the new one. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -void -TclExpandParseValue( - ParseValue *pvPtr, /* Information about buffer that - * must be expanded. If the clientData - * in the structure is non-zero, it - * means that the current buffer is - * dynamically allocated. */ - int needed /* Minimum amount of additional space - * to allocate. */ -) -{ - int newSpace; - char *new; - - /* - * Either double the size of the buffer or add enough new space - * to meet the demand, whichever produces a larger new buffer. - */ - - newSpace = (pvPtr->end - pvPtr->buffer) + 1; - if (newSpace < needed) { - newSpace += needed; - } else { - newSpace += newSpace; - } - new = (char *) ckalloc((unsigned) newSpace); - - /* - * Copy from old buffer to new, free old buffer if needed, and - * mark new buffer as malloc-ed. - */ - - memcpy((VOID *) new, (VOID *) pvPtr->buffer, - (size_t) (pvPtr->next - pvPtr->buffer)); - pvPtr->next = new + (pvPtr->next - pvPtr->buffer); - if (pvPtr->clientData != 0) { - ckfree(pvPtr->buffer); - } - pvPtr->buffer = new; - pvPtr->end = new + newSpace - 1; - pvPtr->clientData = (ClientData) 1; -} - -/* - *---------------------------------------------------------------------- - * - * TclWordEnd -- - * - * Given a pointer into a Tcl command, find the end of the next - * word of the command. - * - * Results: - * The return value is a pointer to the last character that's part - * of the word pointed to by "start". If the word doesn't end - * properly within the string then the return value is the address - * of the null character at the end of the string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -TclWordEnd( - char *start, /* Beginning of a word of a Tcl command. */ - int nested, /* Zero means this is a top-level command. - * One means this is a nested command (close - * bracket is a word terminator). */ - int *semiPtr /* Set to 1 if word ends with a command- - * terminating semi-colon, zero otherwise. - * If NULL then ignored. */ -) -{ - char *p; - int count; - - if (semiPtr != NULL) { - *semiPtr = 0; - } - - /* - * Skip leading white space (backslash-newline must be treated like - * white-space, except that it better not be the last thing in the - * command). - */ - - for (p = start; ; p++) { - if (isspace(UCHAR(*p))) { - continue; - } - if ((p[0] == '\\') && (p[1] == '\n')) { - if (p[2] == 0) { - return p+2; - } - continue; - } - break; - } - - /* - * Handle words beginning with a double-quote or a brace. - */ - - if (*p == '"') { - p = QuoteEnd(p+1, '"'); - if (*p == 0) { - return p; - } - p++; - } else if (*p == '{') { - int braces = 1; - while (braces != 0) { - p++; - while (*p == '\\') { - (void) Tcl_Backslash(p, &count); - p += count; - } - if (*p == '}') { - braces--; - } else if (*p == '{') { - braces++; - } else if (*p == 0) { - return p; - } - } - p++; - } - - /* - * Handle words that don't start with a brace or double-quote. - * This code is also invoked if the word starts with a brace or - * double-quote and there is garbage after the closing brace or - * quote. This is an error as far as Tcl_Eval is concerned, but - * for here the garbage is treated as part of the word. - */ - - while (1) { - if (*p == '[') { - p = ScriptEnd(p+1, 1); - if (*p == 0) { - return p; - } - p++; - } else if (*p == '\\') { - if (p[1] == '\n') { - /* - * Backslash-newline: it maps to a space character - * that is a word separator, so the word ends just before - * the backslash. - */ - - return p-1; - } - (void) Tcl_Backslash(p, &count); - p += count; - } else if (*p == '$') { - p = VarNameEnd(p); - if (*p == 0) { - return p; - } - p++; - } else if (*p == ';') { - /* - * Include the semi-colon in the word that is returned. - */ - - if (semiPtr != NULL) { - *semiPtr = 1; - } - return p; - } else if (isspace(UCHAR(*p))) { - return p-1; - } else if ((*p == ']') && nested) { - return p-1; - } else if (*p == 0) { - if (nested) { - /* - * Nested commands can't end because of the end of the - * string. - */ - return p; - } - return p-1; - } else { - p++; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * QuoteEnd -- - * - * Given a pointer to a string that obeys the parsing conventions - * for quoted things in Tcl, find the end of that quoted thing. - * The actual thing may be a quoted argument or a parenthesized - * index name. - * - * Results: - * The return value is a pointer to the last character that is - * part of the quoted string (i.e the character that's equal to - * term). If the quoted string doesn't terminate properly then - * the return value is a pointer to the null character at the - * end of the string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -QuoteEnd( - char *string, /* Pointer to character just after opening - * "quote". */ - int term /* This character will terminate the - * quoted string (e.g. '"' or ')'). */ -) -{ - char *p = string; - int count; - - while (*p != term) { - if (*p == '\\') { - (void) Tcl_Backslash(p, &count); - p += count; - } else if (*p == '[') { - for (p++; *p != ']'; p++) { - p = TclWordEnd(p, 1, (int *) NULL); - if (*p == 0) { - return p; - } - } - p++; - } else if (*p == '$') { - p = VarNameEnd(p); - if (*p == 0) { - return p; - } - p++; - } else if (*p == 0) { - return p; - } else { - p++; - } - } - return p-1; -} - -/* - *---------------------------------------------------------------------- - * - * VarNameEnd -- - * - * Given a pointer to a variable reference using $-notation, find - * the end of the variable name spec. - * - * Results: - * The return value is a pointer to the last character that - * is part of the variable name. If the variable name doesn't - * terminate properly then the return value is a pointer to the - * null character at the end of the string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -VarNameEnd( - char *string /* Pointer to dollar-sign character. */ -) -{ - char *p = string+1; - - if (*p == '{') { - for (p++; (*p != '}') && (*p != 0); p++) { - /* Empty loop body. */ - } - return p; - } - while (isalnum(UCHAR(*p)) || (*p == '_')) { - p++; - } - if ((*p == '(') && (p != string+1)) { - return QuoteEnd(p+1, ')'); - } - return p-1; -} - - -/* - *---------------------------------------------------------------------- - * - * ScriptEnd -- - * - * Given a pointer to the beginning of a Tcl script, find the end of - * the script. - * - * Results: - * The return value is a pointer to the last character that's part - * of the script pointed to by "p". If the command doesn't end - * properly within the string then the return value is the address - * of the null character at the end of the string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static char * -ScriptEnd( - char *p, /* Script to check. */ - int nested /* Zero means this is a top-level command. - * One means this is a nested command (the - * last character of the script must be - * an unquoted ]). */ -) -{ - int commentOK = 1; - int length; - - while (1) { - while (isspace(UCHAR(*p))) { - if (*p == '\n') { - commentOK = 1; - } - p++; - } - if ((*p == '#') && commentOK) { - do { - if (*p == '\\') { - /* - * If the script ends with backslash-newline, then - * this command isn't complete. - */ - - if ((p[1] == '\n') && (p[2] == 0)) { - return p+2; - } - Tcl_Backslash(p, &length); - p += length; - } else { - p++; - } - } while ((*p != 0) && (*p != '\n')); - continue; - } - p = TclWordEnd(p, nested, &commentOK); - if (*p == 0) { - return p; - } - p++; - if (nested) { - if (*p == ']') { - return p; - } - } else { - if (*p == 0) { - return p-1; - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ParseVar -- - * - * Given a string starting with a $ sign, parse off a variable - * name and return its value. - * - * Results: - * The return value is the contents of the variable given by - * the leading characters of string. If termPtr isn't NULL, - * *termPtr gets filled in with the address of the character - * just after the last one in the variable specifier. If the - * variable doesn't exist, then the return value is NULL and - * an error message will be left in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_ParseVar( - Tcl_Interp *interp, /* Context for looking up variable. */ - char *string, /* String containing variable name. - * First character must be "$". */ - char **termPtr /* If non-NULL, points to word to fill - * in with character just after last - * one in the variable specifier. */ -) -{ - char *name1, *name1End, c, *result; - char *name2; -#define NUM_CHARS 200 - char copyStorage[NUM_CHARS]; - ParseValue pv; - - /* - * There are three cases: - * 1. The $ sign is followed by an open curly brace. Then the variable - * name is everything up to the next close curly brace, and the - * variable is a scalar variable. - * 2. The $ sign is not followed by an open curly brace. Then the - * variable name is everything up to the next character that isn't - * a letter, digit, or underscore. If the following character is an - * open parenthesis, then the information between parentheses is - * the array element name, which can include any of the substitutions - * permissible between quotes. - * 3. The $ sign is followed by something that isn't a letter, digit, - * or underscore: in this case, there is no variable name, and "$" - * is returned. - */ - - name2 = NULL; - string++; - if (*string == '{') { - string++; - name1 = string; - while (*string != '}') { - if (*string == 0) { - Tcl_SetResult(interp, "missing close-brace for variable name", - TCL_STATIC); - if (termPtr != 0) { - *termPtr = string; - } - return NULL; - } - string++; - } - name1End = string; - string++; - } else { - name1 = string; - while (isalnum(UCHAR(*string)) || (*string == '_')) { - string++; - } - if (string == name1) { - if (termPtr != 0) { - *termPtr = string; - } - return "$"; - } - name1End = string; - if (*string == '(') { - char *end; - - /* - * Perform substitutions on the array element name, just as - * is done for quotes. - */ - - pv.buffer = pv.next = copyStorage; - pv.end = copyStorage + NUM_CHARS - 1; - pv.expandProc = TclExpandParseValue; - pv.clientData = (ClientData) NULL; - if (TclParseQuotes(interp, string+1, ')', 0, &end, &pv) - != TCL_OK) { - char msg[200]; - int length; - - length = string-name1; - if (length > 100) { - length = 100; - } - sprintf(msg, "\n (parsing index for array \"%.*s\")", - length, name1); - Tcl_AddErrorInfo(interp, msg); - result = NULL; - name2 = pv.buffer; - if (termPtr != 0) { - *termPtr = end; - } - goto done; - } - Tcl_ResetResult(interp); - string = end; - name2 = pv.buffer; - } - } - if (termPtr != 0) { - *termPtr = string; - } - - if (((Interp *) interp)->noEval) { - return ""; - } - c = *name1End; - *name1End = 0; - result = Tcl_GetVar2(interp, name1, name2, TCL_LEAVE_ERR_MSG); - *name1End = c; - - done: - if ((name2 != NULL) && (pv.buffer != copyStorage)) { - ckfree(pv.buffer); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CommandComplete -- - * - * Given a partial or complete Tcl command, this procedure - * determines whether the command is complete in the sense - * of having matched braces and quotes and brackets. - * - * Results: - * 1 is returned if the command is complete, 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_CommandComplete( - char *cmd /* Command to check. */ -) -{ - char *p; - - if (*cmd == 0) { - return 1; - } - p = ScriptEnd(cmd, 0); - return (*p != 0); -} diff --git a/cde/programs/dtdocbook/tcl/tclPkg.c b/cde/programs/dtdocbook/tcl/tclPkg.c deleted file mode 100644 index d6fa47ac0..000000000 --- a/cde/programs/dtdocbook/tcl/tclPkg.c +++ /dev/null @@ -1,762 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclPkg.c /main/2 1996/08/08 14:45:54 cde-hp $ */ -/* - * tclPkg.c -- - * - * This file implements package and version control for Tcl via - * the "package" command and a few C APIs. - * - * Copyright (c) 1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclPkg.c 1.6 96/02/15 11:43:16 - */ - -#include "tclInt.h" - -/* - * Each invocation of the "package ifneeded" command creates a structure - * of the following type, which is used to load the package into the - * interpreter if it is requested with a "package require" command. - */ - -typedef struct PkgAvail { - char *version; /* Version string; malloc'ed. */ - char *script; /* Script to invoke to provide this version - * of the package. Malloc'ed and protected - * by Tcl_Preserve and Tcl_Release. */ - struct PkgAvail *nextPtr; /* Next in list of available versions of - * the same package. */ -} PkgAvail; - -/* - * For each package that is known in any way to an interpreter, there - * is one record of the following type. These records are stored in - * the "packageTable" hash table in the interpreter, keyed by - * package name such as "Tk" (no version number). - */ - -typedef struct Package { - char *version; /* Version that has been supplied in this - * interpreter via "package provide" - * (malloc'ed). NULL means the package doesn't - * exist in this interpreter yet. */ - PkgAvail *availPtr; /* First in list of all available versions - * of this package. */ -} Package; - -/* - * Prototypes for procedures defined in this file: - */ - -static int CheckVersion _ANSI_ARGS_((Tcl_Interp *interp, - char *string)); -static int ComparePkgVersions _ANSI_ARGS_((char *v1, char *v2, - int *satPtr)); -static Package * FindPackage _ANSI_ARGS_((Tcl_Interp *interp, - char *name)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_PkgProvide -- - * - * This procedure is invoked to declare that a particular version - * of a particular package is now present in an interpreter. There - * must not be any other version of this package already - * provided in the interpreter. - * - * Results: - * Normally returns TCL_OK; if there is already another version - * of the package loaded then TCL_ERROR is returned and an error - * message is left in interp->result. - * - * Side effects: - * The interpreter remembers that this package is available, - * so that no other version of the package may be provided for - * the interpreter. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_PkgProvide( - Tcl_Interp *interp, /* Interpreter in which package is now - * available. */ - char *name, /* Name of package. */ - char *version /* Version string for package. */ -) -{ - Package *pkgPtr; - - pkgPtr = FindPackage(interp, name); - if (pkgPtr->version == NULL) { - pkgPtr->version = ckalloc((unsigned) (strlen(version) + 1)); - strcpy(pkgPtr->version, version); - return TCL_OK; - } - if (ComparePkgVersions(pkgPtr->version, version, (int *) NULL) == 0) { - return TCL_OK; - } - Tcl_AppendResult(interp, "conflicting versions provided for package \"", - name, "\": ", pkgPtr->version, ", then ", version, (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PkgRequire -- - * - * This procedure is called by code that depends on a particular - * version of a particular package. If the package is not already - * provided in the interpreter, this procedure invokes a Tcl script - * to provide it. If the package is already provided, this - * procedure makes sure that the caller's needs don't conflict with - * the version that is present. - * - * Results: - * If successful, returns the version string for the currently - * provided version of the package, which may be different from - * the "version" argument. If the caller's requirements - * cannot be met (e.g. the version requested conflicts with - * a currently provided version, or the required version cannot - * be found, or the script to provide the required version - * generates an error), NULL is returned and an error - * message is left in interp->result. - * - * Side effects: - * The script from some previous "package ifneeded" command may - * be invoked to provide the package. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_PkgRequire( - Tcl_Interp *interp, /* Interpreter in which package is now - * available. */ - char *name, /* Name of desired package. */ - char *version, /* Version string for desired version; - * NULL means use the latest version - * available. */ - int exact /* Non-zero means that only the particular - * version given is acceptable. Zero means - * use the latest compatible version. */ -) -{ - Package *pkgPtr; - PkgAvail *availPtr, *bestPtr; - char *script; - int code, satisfies, result, pass; - Tcl_DString command; - - /* - * It can take up to three passes to find the package: one pass to - * run the "package unknown" script, one to run the "package ifneeded" - * script for a specific version, and a final pass to lookup the - * package loaded by the "package ifneeded" script. - */ - - for (pass = 1; ; pass++) { - pkgPtr = FindPackage(interp, name); - if (pkgPtr->version != NULL) { - break; - } - - /* - * The package isn't yet present. Search the list of available - * versions and invoke the script for the best available version. - */ - - bestPtr = NULL; - for (availPtr = pkgPtr->availPtr; availPtr != NULL; - availPtr = availPtr->nextPtr) { - if ((bestPtr != NULL) && (ComparePkgVersions(availPtr->version, - bestPtr->version, (int *) NULL) <= 0)) { - continue; - } - if (version != NULL) { - result = ComparePkgVersions(availPtr->version, version, - &satisfies); - if ((result != 0) && exact) { - continue; - } - if (!satisfies) { - continue; - } - } - bestPtr = availPtr; - } - if (bestPtr != NULL) { - /* - * We found an ifneeded script for the package. Be careful while - * executing it: this could cause reentrancy, so (a) protect the - * script itself from deletion and (b) don't assume that bestPtr - * will still exist when the script completes. - */ - - script = bestPtr->script; - Tcl_Preserve((ClientData) script); - code = Tcl_GlobalEval(interp, script); - Tcl_Release((ClientData) script); - if (code != TCL_OK) { - if (code == TCL_ERROR) { - Tcl_AddErrorInfo(interp, - "\n (\"package ifneeded\" script)"); - } - return NULL; - } - Tcl_ResetResult(interp); - pkgPtr = FindPackage(interp, name); - break; - } - - /* - * Package not in the database. If there is a "package unknown" - * command, invoke it (but only on the first pass; after that, - * we should not get here in the first place). - */ - - if (pass > 1) { - break; - } - script = ((Interp *) interp)->packageUnknown; - if (script != NULL) { - Tcl_DStringInit(&command); - Tcl_DStringAppend(&command, script, -1); - Tcl_DStringAppendElement(&command, name); - Tcl_DStringAppend(&command, " ", 1); - Tcl_DStringAppend(&command, (version != NULL) ? version : "{}", - -1); - if (exact) { - Tcl_DStringAppend(&command, " -exact", 7); - } - code = Tcl_GlobalEval(interp, Tcl_DStringValue(&command)); - Tcl_DStringFree(&command); - if (code != TCL_OK) { - if (code == TCL_ERROR) { - Tcl_AddErrorInfo(interp, - "\n (\"package unknown\" script)"); - } - return NULL; - } - Tcl_ResetResult(interp); - } - } - - if (pkgPtr->version == NULL) { - Tcl_AppendResult(interp, "can't find package ", name, - (char *) NULL); - if (version != NULL) { - Tcl_AppendResult(interp, " ", version, (char *) NULL); - } - return NULL; - } - - /* - * At this point we now that the package is present. Make sure that the - * provided version meets the current requirement. - */ - - if (version == NULL) { - return pkgPtr->version; - } - result = ComparePkgVersions(pkgPtr->version, version, &satisfies); - if ((satisfies && !exact) || (result == 0)) { - return pkgPtr->version; - } - Tcl_AppendResult(interp, "version conflict for package \"", - name, "\": have ", pkgPtr->version, ", need ", version, - (char *) NULL); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PackageCmd -- - * - * This procedure is invoked to process the "package" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_PackageCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - size_t length; - int c, exact, i, satisfies; - PkgAvail *availPtr, *prevPtr; - Package *pkgPtr; - Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - Tcl_HashTable *tablePtr; - char *version; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'f') && (strncmp(argv[1], "forget", length) == 0)) { - for (i = 2; i < argc; i++) { - hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv[i]); - if (hPtr == NULL) { - return TCL_OK; - } - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - Tcl_DeleteHashEntry(hPtr); - if (pkgPtr->version != NULL) { - ckfree(pkgPtr->version); - } - while (pkgPtr->availPtr != NULL) { - availPtr = pkgPtr->availPtr; - pkgPtr->availPtr = availPtr->nextPtr; - ckfree(availPtr->version); - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); - ckfree((char *) availPtr); - } - ckfree((char *) pkgPtr); - } - } else if ((c == 'i') && (strncmp(argv[1], "ifneeded", length) == 0)) { - if ((argc != 4) && (argc != 5)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ifneeded package version ?script?\"", (char *) NULL); - return TCL_ERROR; - } - if (CheckVersion(interp, argv[3]) != TCL_OK) { - return TCL_ERROR; - } - if (argc == 4) { - hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv[2]); - if (hPtr == NULL) { - return TCL_OK; - } - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - } else { - pkgPtr = FindPackage(interp, argv[2]); - } - for (availPtr = pkgPtr->availPtr, prevPtr = NULL; availPtr != NULL; - prevPtr = availPtr, availPtr = availPtr->nextPtr) { - if (ComparePkgVersions(availPtr->version, argv[3], (int *) NULL) - == 0) { - if (argc == 4) { - interp->result = availPtr->script; - return TCL_OK; - } - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); - break; - } - } - if (argc == 4) { - return TCL_OK; - } - if (availPtr == NULL) { - availPtr = (PkgAvail *) ckalloc(sizeof(PkgAvail)); - availPtr->version = ckalloc((unsigned) (strlen(argv[3]) + 1)); - strcpy(availPtr->version, argv[3]); - if (prevPtr == NULL) { - availPtr->nextPtr = pkgPtr->availPtr; - pkgPtr->availPtr = availPtr; - } else { - availPtr->nextPtr = prevPtr->nextPtr; - prevPtr->nextPtr = availPtr; - } - } - availPtr->script = ckalloc((unsigned) (strlen(argv[4]) + 1)); - strcpy(availPtr->script, argv[4]); - } else if ((c == 'n') && (strncmp(argv[1], "names", length) == 0)) { - if (argc != 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " names\"", (char *) NULL); - return TCL_ERROR; - } - tablePtr = &iPtr->packageTable; - for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; - hPtr = Tcl_NextHashEntry(&search)) { - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - if ((pkgPtr->version != NULL) || (pkgPtr->availPtr != NULL)) { - Tcl_AppendElement(interp, Tcl_GetHashKey(tablePtr, hPtr)); - } - } - } else if ((c == 'p') && (strncmp(argv[1], "provide", length) == 0)) { - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " provide package ?version?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv[2]); - if (hPtr != NULL) { - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - if (pkgPtr->version != NULL) { - interp->result = pkgPtr->version; - } - } - return TCL_OK; - } - if (CheckVersion(interp, argv[3]) != TCL_OK) { - return TCL_ERROR; - } - return Tcl_PkgProvide(interp, argv[2], argv[3]); - } else if ((c == 'r') && (strncmp(argv[1], "require", length) == 0)) { - if (argc < 3) { - requireSyntax: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " require ?-exact? package ?version?\"", (char *) NULL); - return TCL_ERROR; - } - if ((argv[2][0] == '-') && (strcmp(argv[2], "-exact") == 0)) { - exact = 1; - } else { - exact = 0; - } - version = NULL; - if (argc == (4+exact)) { - version = argv[3+exact]; - if (CheckVersion(interp, version) != TCL_OK) { - return TCL_ERROR; - } - } else if ((argc != 3) || exact) { - goto requireSyntax; - } - version = Tcl_PkgRequire(interp, argv[2+exact], version, exact); - if (version == NULL) { - return TCL_ERROR; - } - interp->result = version; - } else if ((c == 'u') && (strncmp(argv[1], "unknown", length) == 0)) { - if (argc == 2) { - if (iPtr->packageUnknown != NULL) { - iPtr->result = iPtr->packageUnknown; - } - } else if (argc == 3) { - if (iPtr->packageUnknown != NULL) { - ckfree(iPtr->packageUnknown); - } - if (argv[2][0] == 0) { - iPtr->packageUnknown = NULL; - } else { - iPtr->packageUnknown = (char *) ckalloc((unsigned) - (strlen(argv[2]) + 1)); - strcpy(iPtr->packageUnknown, argv[2]); - } - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " unknown ?command?\"", (char *) NULL); - return TCL_ERROR; - } - } else if ((c == 'v') && (strncmp(argv[1], "vcompare", length) == 0) - && (length >= 2)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " vcompare version1 version2\"", (char *) NULL); - return TCL_ERROR; - } - if ((CheckVersion(interp, argv[2]) != TCL_OK) - || (CheckVersion(interp, argv[3]) != TCL_OK)) { - return TCL_ERROR; - } - sprintf(interp->result, "%d", ComparePkgVersions(argv[2], argv[3], - (int *) NULL)); - } else if ((c == 'v') && (strncmp(argv[1], "versions", length) == 0) - && (length >= 2)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " versions package\"", (char *) NULL); - return TCL_ERROR; - } - hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv[2]); - if (hPtr != NULL) { - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - for (availPtr = pkgPtr->availPtr; availPtr != NULL; - availPtr = availPtr->nextPtr) { - Tcl_AppendElement(interp, availPtr->version); - } - } - } else if ((c == 'v') && (strncmp(argv[1], "vsatisfies", length) == 0) - && (length >= 2)) { - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " vsatisfies version1 version2\"", (char *) NULL); - return TCL_ERROR; - } - if ((CheckVersion(interp, argv[2]) != TCL_OK) - || (CheckVersion(interp, argv[3]) != TCL_OK)) { - return TCL_ERROR; - } - ComparePkgVersions(argv[2], argv[3], &satisfies); - sprintf(interp->result, "%d", satisfies); - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be forget, ifneeded, names, ", - "provide, require, unknown, vcompare, ", - "versions, or vsatisfies", (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * FindPackage -- - * - * This procedure finds the Package record for a particular package - * in a particular interpreter, creating a record if one doesn't - * already exist. - * - * Results: - * The return value is a pointer to the Package record for the - * package. - * - * Side effects: - * A new Package record may be created. - * - *---------------------------------------------------------------------- - */ - -static Package * -FindPackage( - Tcl_Interp *interp, /* Interpreter to use for package lookup. */ - char *name /* Name of package to fine. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashEntry *hPtr; - int new; - Package *pkgPtr; - - hPtr = Tcl_CreateHashEntry(&iPtr->packageTable, name, &new); - if (new) { - pkgPtr = (Package *) ckalloc(sizeof(Package)); - pkgPtr->version = NULL; - pkgPtr->availPtr = NULL; - Tcl_SetHashValue(hPtr, pkgPtr); - } else { - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - } - return pkgPtr; -} - -/* - *---------------------------------------------------------------------- - * - * TclFreePackageInfo -- - * - * This procedure is called during interpreter deletion to - * free all of the package-related information for the - * interpreter. - * - * Results: - * None. - * - * Side effects: - * Memory is freed. - * - *---------------------------------------------------------------------- - */ - -void -TclFreePackageInfo( - Interp *iPtr /* Interpereter that is being deleted. */ -) -{ - Package *pkgPtr; - Tcl_HashSearch search; - Tcl_HashEntry *hPtr; - PkgAvail *availPtr; - - for (hPtr = Tcl_FirstHashEntry(&iPtr->packageTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - pkgPtr = (Package *) Tcl_GetHashValue(hPtr); - if (pkgPtr->version != NULL) { - ckfree(pkgPtr->version); - } - while (pkgPtr->availPtr != NULL) { - availPtr = pkgPtr->availPtr; - pkgPtr->availPtr = availPtr->nextPtr; - ckfree(availPtr->version); - Tcl_EventuallyFree((ClientData)availPtr->script, TCL_DYNAMIC); - ckfree((char *) availPtr); - } - ckfree((char *) pkgPtr); - } - Tcl_DeleteHashTable(&iPtr->packageTable); - if (iPtr->packageUnknown != NULL) { - ckfree(iPtr->packageUnknown); - } -} - -/* - *---------------------------------------------------------------------- - * - * CheckVersion -- - * - * This procedure checks to see whether a version number has - * valid syntax. - * - * Results: - * If string is a properly formed version number the TCL_OK - * is returned. Otherwise TCL_ERROR is returned and an error - * message is left in interp->result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -CheckVersion( - Tcl_Interp *interp, /* Used for error reporting. */ - char *string /* Supposedly a version number, which is - * groups of decimal digits separated - * by dots. */ -) -{ - char *p = string; - - if (!isdigit(*p)) { - goto error; - } - for (p++; *p != 0; p++) { - if (!isdigit(*p) && (*p != '.')) { - goto error; - } - } - if (p[-1] != '.') { - return TCL_OK; - } - - error: - Tcl_AppendResult(interp, "expected version number but got \"", - string, "\"", (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * ComparePkgVersions -- - * - * This procedure compares two version numbers. - * - * Results: - * The return value is -1 if v1 is less than v2, 0 if the two - * version numbers are the same, and 1 if v1 is greater than v2. - * If *satPtr is non-NULL, the word it points to is filled in - * with 1 if v2 >= v1 and both numbers have the same major number - * or 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -ComparePkgVersions( - char *v1, char *v2, /* Versions strings, of form 2.1.3 (any - * number of version numbers). */ - int *satPtr /* If non-null, the word pointed to is - * filled in with a 0/1 value. 1 means - * v1 "satisfies" v2: v1 is greater than - * or equal to v2 and both version numbers - * have the same major number. */ -) -{ - int thisIsMajor, n1, n2; - - /* - * Each iteration of the following loop processes one number from - * each string, terminated by a ".". If those numbers don't match - * then the comparison is over; otherwise, we loop back for the - * next number. - */ - - thisIsMajor = 1; - while (1) { - /* - * Parse one decimal number from the front of each string. - */ - - n1 = n2 = 0; - while ((*v1 != 0) && (*v1 != '.')) { - n1 = 10*n1 + (*v1 - '0'); - v1++; - } - while ((*v2 != 0) && (*v2 != '.')) { - n2 = 10*n2 + (*v2 - '0'); - v2++; - } - - /* - * Compare and go on to the next version number if the - * current numbers match. - */ - - if (n1 != n2) { - break; - } - if (*v1 != 0) { - v1++; - } else if (*v2 == 0) { - break; - } - if (*v2 != 0) { - v2++; - } - thisIsMajor = 0; - } - if (satPtr != NULL) { - *satPtr = (n1 == n2) || ((n1 > n2) && !thisIsMajor); - } - if (n1 > n2) { - return 1; - } else if (n1 == n2) { - return 0; - } else { - return -1; - } -} diff --git a/cde/programs/dtdocbook/tcl/tclPort.h b/cde/programs/dtdocbook/tcl/tclPort.h deleted file mode 100644 index 7b830ff5c..000000000 --- a/cde/programs/dtdocbook/tcl/tclPort.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclPort.h /main/2 1996/08/08 14:46:02 cde-hp $ */ -/* - * tclPort.h -- - * - * This header file handles porting issues that occur because - * of differences between systems. It reads in platform specific - * portability files. - * - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclPort.h 1.15 96/02/07 17:24:21 - */ - -#ifndef _TCLPORT -#define _TCLPORT - -#if defined(__WIN32__) || defined(_WIN32) -# include "../win/tclWinPort.h" -#else -# if defined(MAC_TCL) -# include "tclMacPort.h" -# else -# include "tclUnixPort.h" -# endif -#endif - -#endif /* _TCLPORT */ diff --git a/cde/programs/dtdocbook/tcl/tclPosixStr.c b/cde/programs/dtdocbook/tcl/tclPosixStr.c deleted file mode 100644 index 47176b7c2..000000000 --- a/cde/programs/dtdocbook/tcl/tclPosixStr.c +++ /dev/null @@ -1,1200 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $TOG: tclPosixStr.c /main/3 1998/04/06 13:37:12 mgreess $ */ -/* - * tclPosixStr.c -- - * - * This file contains procedures that generate strings - * corresponding to various POSIX-related codes, such - * as errno and signals. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclPosixStr.c 1.30 96/02/08 16:33:34 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - *---------------------------------------------------------------------- - * - * Tcl_ErrnoId -- - * - * Return a textual identifier for the current errno value. - * - * Results: - * This procedure returns a machine-readable textual identifier - * that corresponds to the current errno value (e.g. "EPERM"). - * The identifier is the same as the #define name in errno.h. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_ErrnoId(void) -{ - switch (errno) { -#ifdef E2BIG - case E2BIG: return "E2BIG"; -#endif -#ifdef EACCES - case EACCES: return "EACCES"; -#endif -#ifdef EADDRINUSE - case EADDRINUSE: return "EADDRINUSE"; -#endif -#ifdef EADDRNOTAVAIL - case EADDRNOTAVAIL: return "EADDRNOTAVAIL"; -#endif -#ifdef EADV - case EADV: return "EADV"; -#endif -#ifdef EAFNOSUPPORT - case EAFNOSUPPORT: return "EAFNOSUPPORT"; -#endif -#ifdef EAGAIN - case EAGAIN: return "EAGAIN"; -#endif -#ifdef EALIGN - case EALIGN: return "EALIGN"; -#endif -#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY )) - case EALREADY: return "EALREADY"; -#endif -#ifdef EBADE - case EBADE: return "EBADE"; -#endif -#ifdef EBADF - case EBADF: return "EBADF"; -#endif -#ifdef EBADFD - case EBADFD: return "EBADFD"; -#endif -#ifdef EBADMSG - case EBADMSG: return "EBADMSG"; -#endif -#ifdef EBADR - case EBADR: return "EBADR"; -#endif -#ifdef EBADRPC - case EBADRPC: return "EBADRPC"; -#endif -#ifdef EBADRQC - case EBADRQC: return "EBADRQC"; -#endif -#ifdef EBADSLT - case EBADSLT: return "EBADSLT"; -#endif -#ifdef EBFONT - case EBFONT: return "EBFONT"; -#endif -#ifdef EBUSY - case EBUSY: return "EBUSY"; -#endif -#ifdef ECHILD - case ECHILD: return "ECHILD"; -#endif -#ifdef ECHRNG - case ECHRNG: return "ECHRNG"; -#endif -#ifdef ECOMM - case ECOMM: return "ECOMM"; -#endif -#ifdef ECONNABORTED - case ECONNABORTED: return "ECONNABORTED"; -#endif -#ifdef ECONNREFUSED - case ECONNREFUSED: return "ECONNREFUSED"; -#endif -#ifdef ECONNRESET - case ECONNRESET: return "ECONNRESET"; -#endif -#if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK)) - case EDEADLK: return "EDEADLK"; -#endif -#if defined(EDEADLOCK) && (EDEADLOCK != EDEADLK) - case EDEADLOCK: return "EDEADLOCK"; -#endif -#ifdef EDESTADDRREQ - case EDESTADDRREQ: return "EDESTADDRREQ"; -#endif -#ifdef EDIRTY - case EDIRTY: return "EDIRTY"; -#endif -#ifdef EDOM - case EDOM: return "EDOM"; -#endif -#ifdef EDOTDOT - case EDOTDOT: return "EDOTDOT"; -#endif -#ifdef EDQUOT - case EDQUOT: return "EDQUOT"; -#endif -#ifdef EDUPPKG - case EDUPPKG: return "EDUPPKG"; -#endif -#ifdef EEXIST - case EEXIST: return "EEXIST"; -#endif -#ifdef EFAULT - case EFAULT: return "EFAULT"; -#endif -#ifdef EFBIG - case EFBIG: return "EFBIG"; -#endif -#ifdef EHOSTDOWN - case EHOSTDOWN: return "EHOSTDOWN"; -#endif -#ifdef EHOSTUNREACH - case EHOSTUNREACH: return "EHOSTUNREACH"; -#endif -#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS)) - case EIDRM: return "EIDRM"; -#endif -#ifdef EINIT - case EINIT: return "EINIT"; -#endif -#ifdef EINPROGRESS - case EINPROGRESS: return "EINPROGRESS"; -#endif -#ifdef EINTR - case EINTR: return "EINTR"; -#endif -#ifdef EINVAL - case EINVAL: return "EINVAL"; -#endif -#ifdef EIO - case EIO: return "EIO"; -#endif -#ifdef EISCONN - case EISCONN: return "EISCONN"; -#endif -#ifdef EISDIR - case EISDIR: return "EISDIR"; -#endif -#ifdef EISNAME - case EISNAM: return "EISNAM"; -#endif -#ifdef ELBIN - case ELBIN: return "ELBIN"; -#endif -#ifdef EL2HLT - case EL2HLT: return "EL2HLT"; -#endif -#ifdef EL2NSYNC - case EL2NSYNC: return "EL2NSYNC"; -#endif -#ifdef EL3HLT - case EL3HLT: return "EL3HLT"; -#endif -#ifdef EL3RST - case EL3RST: return "EL3RST"; -#endif -#ifdef ELIBACC - case ELIBACC: return "ELIBACC"; -#endif -#ifdef ELIBBAD - case ELIBBAD: return "ELIBBAD"; -#endif -#ifdef ELIBEXEC - case ELIBEXEC: return "ELIBEXEC"; -#endif -#ifdef ELIBMAX - case ELIBMAX: return "ELIBMAX"; -#endif -#ifdef ELIBSCN - case ELIBSCN: return "ELIBSCN"; -#endif -#ifdef ELNRNG - case ELNRNG: return "ELNRNG"; -#endif -#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT)) - case ELOOP: return "ELOOP"; -#endif -#ifdef EMFILE - case EMFILE: return "EMFILE"; -#endif -#ifdef EMLINK - case EMLINK: return "EMLINK"; -#endif -#ifdef EMSGSIZE - case EMSGSIZE: return "EMSGSIZE"; -#endif -#ifdef EMULTIHOP - case EMULTIHOP: return "EMULTIHOP"; -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: return "ENAMETOOLONG"; -#endif -#ifdef ENAVAIL - case ENAVAIL: return "ENAVAIL"; -#endif -#ifdef ENET - case ENET: return "ENET"; -#endif -#ifdef ENETDOWN - case ENETDOWN: return "ENETDOWN"; -#endif -#ifdef ENETRESET - case ENETRESET: return "ENETRESET"; -#endif -#ifdef ENETUNREACH - case ENETUNREACH: return "ENETUNREACH"; -#endif -#ifdef ENFILE - case ENFILE: return "ENFILE"; -#endif -#ifdef ENOANO - case ENOANO: return "ENOANO"; -#endif -#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR)) - case ENOBUFS: return "ENOBUFS"; -#endif -#ifdef ENOCSI - case ENOCSI: return "ENOCSI"; -#endif -#if defined(ENODATA) && (!defined(ECONNREFUSED) || (ENODATA != ECONNREFUSED)) - case ENODATA: return "ENODATA"; -#endif -#ifdef ENODEV - case ENODEV: return "ENODEV"; -#endif -#ifdef ENOENT - case ENOENT: return "ENOENT"; -#endif -#ifdef ENOEXEC - case ENOEXEC: return "ENOEXEC"; -#endif -#ifdef ENOLCK - case ENOLCK: return "ENOLCK"; -#endif -#ifdef ENOLINK - case ENOLINK: return "ENOLINK"; -#endif -#ifdef ENOMEM - case ENOMEM: return "ENOMEM"; -#endif -#ifdef ENOMSG - case ENOMSG: return "ENOMSG"; -#endif -#ifdef ENONET - case ENONET: return "ENONET"; -#endif -#ifdef ENOPKG - case ENOPKG: return "ENOPKG"; -#endif -#ifdef ENOPROTOOPT - case ENOPROTOOPT: return "ENOPROTOOPT"; -#endif -#ifdef ENOSPC - case ENOSPC: return "ENOSPC"; -#endif -#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR)) - case ENOSR: return "ENOSR"; -#endif -#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR)) - case ENOSTR: return "ENOSTR"; -#endif -#ifdef ENOSYM - case ENOSYM: return "ENOSYM"; -#endif -#ifdef ENOSYS - case ENOSYS: return "ENOSYS"; -#endif -#ifdef ENOTBLK - case ENOTBLK: return "ENOTBLK"; -#endif -#ifdef ENOTCONN - case ENOTCONN: return "ENOTCONN"; -#endif -#ifdef ENOTDIR - case ENOTDIR: return "ENOTDIR"; -#endif -#if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST)) - case ENOTEMPTY: return "ENOTEMPTY"; -#endif -#ifdef ENOTNAM - case ENOTNAM: return "ENOTNAM"; -#endif -#ifdef ENOTSOCK - case ENOTSOCK: return "ENOTSOCK"; -#endif -#ifdef ENOTSUP - case ENOTSUP: return "ENOTSUP"; -#endif -#ifdef ENOTTY - case ENOTTY: return "ENOTTY"; -#endif -#ifdef ENOTUNIQ - case ENOTUNIQ: return "ENOTUNIQ"; -#endif -#ifdef ENXIO - case ENXIO: return "ENXIO"; -#endif -#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (EOPNOTSUPP != ENOTSUP)) - case EOPNOTSUPP: return "EOPNOTSUPP"; -#endif -#ifdef EPERM - case EPERM: return "EPERM"; -#endif -#if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT)) - case EPFNOSUPPORT: return "EPFNOSUPPORT"; -#endif -#ifdef EPIPE - case EPIPE: return "EPIPE"; -#endif -#ifdef EPROCLIM - case EPROCLIM: return "EPROCLIM"; -#endif -#ifdef EPROCUNAVAIL - case EPROCUNAVAIL: return "EPROCUNAVAIL"; -#endif -#ifdef EPROGMISMATCH - case EPROGMISMATCH: return "EPROGMISMATCH"; -#endif -#ifdef EPROGUNAVAIL - case EPROGUNAVAIL: return "EPROGUNAVAIL"; -#endif -#ifdef EPROTO - case EPROTO: return "EPROTO"; -#endif -#ifdef EPROTONOSUPPORT - case EPROTONOSUPPORT: return "EPROTONOSUPPORT"; -#endif -#ifdef EPROTOTYPE - case EPROTOTYPE: return "EPROTOTYPE"; -#endif -#ifdef ERANGE - case ERANGE: return "ERANGE"; -#endif -#if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED)) - case EREFUSED: return "EREFUSED"; -#endif -#ifdef EREMCHG - case EREMCHG: return "EREMCHG"; -#endif -#ifdef EREMDEV - case EREMDEV: return "EREMDEV"; -#endif -#ifdef EREMOTE - case EREMOTE: return "EREMOTE"; -#endif -#ifdef EREMOTEIO - case EREMOTEIO: return "EREMOTEIO"; -#endif -#ifdef EREMOTERELEASE - case EREMOTERELEASE: return "EREMOTERELEASE"; -#endif -#ifdef EROFS - case EROFS: return "EROFS"; -#endif -#ifdef ERPCMISMATCH - case ERPCMISMATCH: return "ERPCMISMATCH"; -#endif -#ifdef ERREMOTE - case ERREMOTE: return "ERREMOTE"; -#endif -#ifdef ESHUTDOWN - case ESHUTDOWN: return "ESHUTDOWN"; -#endif -#ifdef ESOCKTNOSUPPORT - case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT"; -#endif -#ifdef ESPIPE - case ESPIPE: return "ESPIPE"; -#endif -#ifdef ESRCH - case ESRCH: return "ESRCH"; -#endif -#ifdef ESRMNT - case ESRMNT: return "ESRMNT"; -#endif -#ifdef ESTALE - case ESTALE: return "ESTALE"; -#endif -#ifdef ESUCCESS - case ESUCCESS: return "ESUCCESS"; -#endif -#if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP)) - case ETIME: return "ETIME"; -#endif -#if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR)) - case ETIMEDOUT: return "ETIMEDOUT"; -#endif -#ifdef ETOOMANYREFS - case ETOOMANYREFS: return "ETOOMANYREFS"; -#endif -#ifdef ETXTBSY - case ETXTBSY: return "ETXTBSY"; -#endif -#ifdef EUCLEAN - case EUCLEAN: return "EUCLEAN"; -#endif -#ifdef EUNATCH - case EUNATCH: return "EUNATCH"; -#endif -#ifdef EUSERS - case EUSERS: return "EUSERS"; -#endif -#ifdef EVERSION - case EVERSION: return "EVERSION"; -#endif -#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN)) - case EWOULDBLOCK: return "EWOULDBLOCK"; -#endif -#ifdef EXDEV - case EXDEV: return "EXDEV"; -#endif -#ifdef EXFULL - case EXFULL: return "EXFULL"; -#endif - } - return "unknown error"; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ErrnoMsg -- - * - * Return a human-readable message corresponding to a given - * errno value. - * - * Results: - * The return value is the standard POSIX error message for - * errno. This procedure is used instead of strerror because - * strerror returns slightly different values on different - * machines (e.g. different capitalizations), which cause - * problems for things such as regression tests. This procedure - * provides messages for most standard errors, then it calls - * strerror for things it doesn't understand. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_ErrnoMsg( - int err /* Error number (such as in errno variable). */ -) -{ - switch (err) { -#ifdef E2BIG - case E2BIG: return "argument list too long"; -#endif -#ifdef EACCES - case EACCES: return "permission denied"; -#endif -#ifdef EADDRINUSE - case EADDRINUSE: return "address already in use"; -#endif -#ifdef EADDRNOTAVAIL - case EADDRNOTAVAIL: return "can't assign requested address"; -#endif -#ifdef EADV - case EADV: return "advertise error"; -#endif -#ifdef EAFNOSUPPORT - case EAFNOSUPPORT: return "address family not supported by protocol family"; -#endif -#ifdef EAGAIN - case EAGAIN: return "resource temporarily unavailable"; -#endif -#ifdef EALIGN - case EALIGN: return "EALIGN"; -#endif -#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY )) - case EALREADY: return "operation already in progress"; -#endif -#ifdef EBADE - case EBADE: return "bad exchange descriptor"; -#endif -#ifdef EBADF - case EBADF: return "bad file number"; -#endif -#ifdef EBADFD - case EBADFD: return "file descriptor in bad state"; -#endif -#ifdef EBADMSG - case EBADMSG: return "not a data message"; -#endif -#ifdef EBADR - case EBADR: return "bad request descriptor"; -#endif -#ifdef EBADRPC - case EBADRPC: return "RPC structure is bad"; -#endif -#ifdef EBADRQC - case EBADRQC: return "bad request code"; -#endif -#ifdef EBADSLT - case EBADSLT: return "invalid slot"; -#endif -#ifdef EBFONT - case EBFONT: return "bad font file format"; -#endif -#ifdef EBUSY - case EBUSY: return "mount device busy"; -#endif -#ifdef ECHILD - case ECHILD: return "no children"; -#endif -#ifdef ECHRNG - case ECHRNG: return "channel number out of range"; -#endif -#ifdef ECOMM - case ECOMM: return "communication error on send"; -#endif -#ifdef ECONNABORTED - case ECONNABORTED: return "software caused connection abort"; -#endif -#ifdef ECONNREFUSED - case ECONNREFUSED: return "connection refused"; -#endif -#ifdef ECONNRESET - case ECONNRESET: return "connection reset by peer"; -#endif -#if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK)) - case EDEADLK: return "resource deadlock avoided"; -#endif -#if defined(EDEADLOCK) && (EDEADLOCK != EDEADLK) - case EDEADLOCK: return "resource deadlock avoided"; -#endif -#ifdef EDESTADDRREQ - case EDESTADDRREQ: return "destination address required"; -#endif -#ifdef EDIRTY - case EDIRTY: return "mounting a dirty fs w/o force"; -#endif -#ifdef EDOM - case EDOM: return "math argument out of range"; -#endif -#ifdef EDOTDOT - case EDOTDOT: return "cross mount point"; -#endif -#ifdef EDQUOT - case EDQUOT: return "disk quota exceeded"; -#endif -#ifdef EDUPPKG - case EDUPPKG: return "duplicate package name"; -#endif -#ifdef EEXIST - case EEXIST: return "file already exists"; -#endif -#ifdef EFAULT - case EFAULT: return "bad address in system call argument"; -#endif -#ifdef EFBIG - case EFBIG: return "file too large"; -#endif -#ifdef EHOSTDOWN - case EHOSTDOWN: return "host is down"; -#endif -#ifdef EHOSTUNREACH - case EHOSTUNREACH: return "host is unreachable"; -#endif -#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS)) - case EIDRM: return "identifier removed"; -#endif -#ifdef EINIT - case EINIT: return "initialization error"; -#endif -#ifdef EINPROGRESS - case EINPROGRESS: return "operation now in progress"; -#endif -#ifdef EINTR - case EINTR: return "interrupted system call"; -#endif -#ifdef EINVAL - case EINVAL: return "invalid argument"; -#endif -#ifdef EIO - case EIO: return "I/O error"; -#endif -#ifdef EISCONN - case EISCONN: return "socket is already connected"; -#endif -#ifdef EISDIR - case EISDIR: return "illegal operation on a directory"; -#endif -#ifdef EISNAME - case EISNAM: return "is a name file"; -#endif -#ifdef ELBIN - case ELBIN: return "ELBIN"; -#endif -#ifdef EL2HLT - case EL2HLT: return "level 2 halted"; -#endif -#ifdef EL2NSYNC - case EL2NSYNC: return "level 2 not synchronized"; -#endif -#ifdef EL3HLT - case EL3HLT: return "level 3 halted"; -#endif -#ifdef EL3RST - case EL3RST: return "level 3 reset"; -#endif -#ifdef ELIBACC - case ELIBACC: return "can not access a needed shared library"; -#endif -#ifdef ELIBBAD - case ELIBBAD: return "accessing a corrupted shared library"; -#endif -#ifdef ELIBEXEC - case ELIBEXEC: return "can not exec a shared library directly"; -#endif -#ifdef ELIBMAX - case ELIBMAX: return - "attempting to link in more shared libraries than system limit"; -#endif -#ifdef ELIBSCN - case ELIBSCN: return ".lib section in a.out corrupted"; -#endif -#ifdef ELNRNG - case ELNRNG: return "link number out of range"; -#endif -#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT)) - case ELOOP: return "too many levels of symbolic links"; -#endif -#ifdef EMFILE - case EMFILE: return "too many open files"; -#endif -#ifdef EMLINK - case EMLINK: return "too many links"; -#endif -#ifdef EMSGSIZE - case EMSGSIZE: return "message too long"; -#endif -#ifdef EMULTIHOP - case EMULTIHOP: return "multihop attempted"; -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: return "file name too long"; -#endif -#ifdef ENAVAIL - case ENAVAIL: return "not available"; -#endif -#ifdef ENET - case ENET: return "ENET"; -#endif -#ifdef ENETDOWN - case ENETDOWN: return "network is down"; -#endif -#ifdef ENETRESET - case ENETRESET: return "network dropped connection on reset"; -#endif -#ifdef ENETUNREACH - case ENETUNREACH: return "network is unreachable"; -#endif -#ifdef ENFILE - case ENFILE: return "file table overflow"; -#endif -#ifdef ENOANO - case ENOANO: return "anode table overflow"; -#endif -#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR)) - case ENOBUFS: return "no buffer space available"; -#endif -#ifdef ENOCSI - case ENOCSI: return "no CSI structure available"; -#endif -#if defined(ENODATA) && (!defined(ECONNREFUSED) || (ENODATA != ECONNREFUSED)) - case ENODATA: return "no data available"; -#endif -#ifdef ENODEV - case ENODEV: return "no such device"; -#endif -#ifdef ENOENT - case ENOENT: return "no such file or directory"; -#endif -#ifdef ENOEXEC - case ENOEXEC: return "exec format error"; -#endif -#ifdef ENOLCK - case ENOLCK: return "no locks available"; -#endif -#ifdef ENOLINK - case ENOLINK: return "link has be severed"; -#endif -#ifdef ENOMEM - case ENOMEM: return "not enough memory"; -#endif -#ifdef ENOMSG - case ENOMSG: return "no message of desired type"; -#endif -#ifdef ENONET - case ENONET: return "machine is not on the network"; -#endif -#ifdef ENOPKG - case ENOPKG: return "package not installed"; -#endif -#ifdef ENOPROTOOPT - case ENOPROTOOPT: return "bad proocol option"; -#endif -#ifdef ENOSPC - case ENOSPC: return "no space left on device"; -#endif -#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR)) - case ENOSR: return "out of stream resources"; -#endif -#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR)) - case ENOSTR: return "not a stream device"; -#endif -#ifdef ENOSYM - case ENOSYM: return "unresolved symbol name"; -#endif -#ifdef ENOSYS - case ENOSYS: return "function not implemented"; -#endif -#ifdef ENOTBLK - case ENOTBLK: return "block device required"; -#endif -#ifdef ENOTCONN - case ENOTCONN: return "socket is not connected"; -#endif -#ifdef ENOTDIR - case ENOTDIR: return "not a directory"; -#endif -#if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST)) - case ENOTEMPTY: return "directory not empty"; -#endif -#ifdef ENOTNAM - case ENOTNAM: return "not a name file"; -#endif -#ifdef ENOTSOCK - case ENOTSOCK: return "socket operation on non-socket"; -#endif -#ifdef ENOTSUP - case ENOTSUP: return "operation not supported"; -#endif -#ifdef ENOTTY - case ENOTTY: return "inappropriate device for ioctl"; -#endif -#ifdef ENOTUNIQ - case ENOTUNIQ: return "name not unique on network"; -#endif -#ifdef ENXIO - case ENXIO: return "no such device or address"; -#endif -#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (EOPNOTSUPP != ENOTSUP)) - case EOPNOTSUPP: return "operation not supported on socket"; -#endif -#ifdef EPERM - case EPERM: return "not owner"; -#endif -#if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT)) - case EPFNOSUPPORT: return "protocol family not supported"; -#endif -#ifdef EPIPE - case EPIPE: return "broken pipe"; -#endif -#ifdef EPROCLIM - case EPROCLIM: return "too many processes"; -#endif -#ifdef EPROCUNAVAIL - case EPROCUNAVAIL: return "bad procedure for program"; -#endif -#ifdef EPROGMISMATCH - case EPROGMISMATCH: return "program version wrong"; -#endif -#ifdef EPROGUNAVAIL - case EPROGUNAVAIL: return "RPC program not available"; -#endif -#ifdef EPROTO - case EPROTO: return "protocol error"; -#endif -#ifdef EPROTONOSUPPORT - case EPROTONOSUPPORT: return "protocol not supported"; -#endif -#ifdef EPROTOTYPE - case EPROTOTYPE: return "protocol wrong type for socket"; -#endif -#ifdef ERANGE - case ERANGE: return "math result unrepresentable"; -#endif -#if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED)) - case EREFUSED: return "EREFUSED"; -#endif -#ifdef EREMCHG - case EREMCHG: return "remote address changed"; -#endif -#ifdef EREMDEV - case EREMDEV: return "remote device"; -#endif -#ifdef EREMOTE - case EREMOTE: return "pathname hit remote file system"; -#endif -#ifdef EREMOTEIO - case EREMOTEIO: return "remote i/o error"; -#endif -#ifdef EREMOTERELEASE - case EREMOTERELEASE: return "EREMOTERELEASE"; -#endif -#ifdef EROFS - case EROFS: return "read-only file system"; -#endif -#ifdef ERPCMISMATCH - case ERPCMISMATCH: return "RPC version is wrong"; -#endif -#ifdef ERREMOTE - case ERREMOTE: return "object is remote"; -#endif -#ifdef ESHUTDOWN - case ESHUTDOWN: return "can't send after socket shutdown"; -#endif -#ifdef ESOCKTNOSUPPORT - case ESOCKTNOSUPPORT: return "socket type not supported"; -#endif -#ifdef ESPIPE - case ESPIPE: return "invalid seek"; -#endif -#ifdef ESRCH - case ESRCH: return "no such process"; -#endif -#ifdef ESRMNT - case ESRMNT: return "srmount error"; -#endif -#ifdef ESTALE - case ESTALE: return "stale remote file handle"; -#endif -#ifdef ESUCCESS - case ESUCCESS: return "Error 0"; -#endif -#if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP)) - case ETIME: return "timer expired"; -#endif -#if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR)) - case ETIMEDOUT: return "connection timed out"; -#endif -#ifdef ETOOMANYREFS - case ETOOMANYREFS: return "too many references: can't splice"; -#endif -#ifdef ETXTBSY - case ETXTBSY: return "text file or pseudo-device busy"; -#endif -#ifdef EUCLEAN - case EUCLEAN: return "structure needs cleaning"; -#endif -#ifdef EUNATCH - case EUNATCH: return "protocol driver not attached"; -#endif -#ifdef EUSERS - case EUSERS: return "too many users"; -#endif -#ifdef EVERSION - case EVERSION: return "version mismatch"; -#endif -#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN)) - case EWOULDBLOCK: return "operation would block"; -#endif -#ifdef EXDEV - case EXDEV: return "cross-domain link"; -#endif -#ifdef EXFULL - case EXFULL: return "message tables full"; -#endif - default: -#ifdef NO_STRERROR - return "unknown POSIX error"; -#else - return strerror(errno); -#endif - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SignalId -- - * - * Return a textual identifier for a signal number. - * - * Results: - * This procedure returns a machine-readable textual identifier - * that corresponds to sig. The identifier is the same as the - * #define name in signal.h. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_SignalId( - int sig /* Number of signal. */ -) -{ - switch (sig) { -#ifdef SIGABRT - case SIGABRT: return "SIGABRT"; -#endif -#ifdef SIGALRM - case SIGALRM: return "SIGALRM"; -#endif -#ifdef SIGBUS - case SIGBUS: return "SIGBUS"; -#endif -#ifdef SIGCHLD - case SIGCHLD: return "SIGCHLD"; -#endif -#if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD)) - case SIGCLD: return "SIGCLD"; -#endif -#ifdef SIGCONT - case SIGCONT: return "SIGCONT"; -#endif -#if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU)) - case SIGEMT: return "SIGEMT"; -#endif -#ifdef SIGFPE - case SIGFPE: return "SIGFPE"; -#endif -#ifdef SIGHUP - case SIGHUP: return "SIGHUP"; -#endif -#ifdef SIGILL - case SIGILL: return "SIGILL"; -#endif -#ifdef SIGINT - case SIGINT: return "SIGINT"; -#endif -#ifdef SIGIO - case SIGIO: return "SIGIO"; -#endif -#if defined(SIGIOT) && (!defined(SIGABRT) || (SIGIOT != SIGABRT)) - case SIGIOT: return "SIGIOT"; -#endif -#ifdef SIGKILL - case SIGKILL: return "SIGKILL"; -#endif -#if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG)) && (!defined(SIGPROF) || (SIGLOST != SIGPROF)) - case SIGLOST: return "SIGLOST"; -#endif -#ifdef SIGPIPE - case SIGPIPE: return "SIGPIPE"; -#endif -#if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO)) - case SIGPOLL: return "SIGPOLL"; -#endif -#ifdef SIGPROF - case SIGPROF: return "SIGPROF"; -#endif -#if defined(SIGPWR) && (SIGPWR != SIGLOST) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ)) - case SIGPWR: return "SIGPWR"; -#endif -#ifdef SIGQUIT - case SIGQUIT: return "SIGQUIT"; -#endif -#ifdef SIGSEGV - case SIGSEGV: return "SIGSEGV"; -#endif -#ifdef SIGSTOP - case SIGSTOP: return "SIGSTOP"; -#endif -#ifdef SIGSYS - case SIGSYS: return "SIGSYS"; -#endif -#ifdef SIGTERM - case SIGTERM: return "SIGTERM"; -#endif -#ifdef SIGTRAP - case SIGTRAP: return "SIGTRAP"; -#endif -#ifdef SIGTSTP - case SIGTSTP: return "SIGTSTP"; -#endif -#ifdef SIGTTIN - case SIGTTIN: return "SIGTTIN"; -#endif -#ifdef SIGTTOU - case SIGTTOU: return "SIGTTOU"; -#endif -#if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO)) - case SIGURG: return "SIGURG"; -#endif -#if defined(SIGUSR1) && (!defined(SIGIO) || (SIGUSR1 != SIGIO)) - case SIGUSR1: return "SIGUSR1"; -#endif -#if defined(SIGUSR2) && (!defined(SIGURG) || (SIGUSR2 != SIGURG)) - case SIGUSR2: return "SIGUSR2"; -#endif -#ifdef SIGVTALRM - case SIGVTALRM: return "SIGVTALRM"; -#endif -#ifdef SIGWINCH - case SIGWINCH: return "SIGWINCH"; -#endif -#ifdef SIGXCPU - case SIGXCPU: return "SIGXCPU"; -#endif -#ifdef SIGXFSZ - case SIGXFSZ: return "SIGXFSZ"; -#endif - } - return "unknown signal"; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SignalMsg -- - * - * Return a human-readable message describing a signal. - * - * Results: - * This procedure returns a string describing sig that should - * make sense to a human. It may not be easy for a machine - * to parse. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_SignalMsg( - int sig /* Number of signal. */ -) -{ - switch (sig) { -#ifdef SIGABRT - case SIGABRT: return "SIGABRT"; -#endif -#ifdef SIGALRM - case SIGALRM: return "alarm clock"; -#endif -#ifdef SIGBUS - case SIGBUS: return "bus error"; -#endif -#ifdef SIGCHLD - case SIGCHLD: return "child status changed"; -#endif -#if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD)) - case SIGCLD: return "child status changed"; -#endif -#ifdef SIGCONT - case SIGCONT: return "continue after stop"; -#endif -#if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU)) - case SIGEMT: return "EMT instruction"; -#endif -#ifdef SIGFPE - case SIGFPE: return "floating-point exception"; -#endif -#ifdef SIGHUP - case SIGHUP: return "hangup"; -#endif -#ifdef SIGILL - case SIGILL: return "illegal instruction"; -#endif -#ifdef SIGINT - case SIGINT: return "interrupt"; -#endif -#ifdef SIGIO - case SIGIO: return "input/output possible on file"; -#endif -#if defined(SIGIOT) && (!defined(SIGABRT) || (SIGABRT != SIGIOT)) - case SIGIOT: return "IOT instruction"; -#endif -#ifdef SIGKILL - case SIGKILL: return "kill signal"; -#endif -#if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG)) - case SIGLOST: return "resource lost"; -#endif -#ifdef SIGPIPE - case SIGPIPE: return "write on pipe with no readers"; -#endif -#if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO)) - case SIGPOLL: return "input/output possible on file"; -#endif -#ifdef SIGPROF - case SIGPROF: return "profiling alarm"; -#endif -#if defined(SIGPWR) && (SIGPWR != SIGLOST) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ)) - case SIGPWR: return "power-fail restart"; -#endif -#ifdef SIGQUIT - case SIGQUIT: return "quit signal"; -#endif -#ifdef SIGSEGV - case SIGSEGV: return "segmentation violation"; -#endif -#ifdef SIGSTOP - case SIGSTOP: return "stop"; -#endif -#ifdef SIGSYS - case SIGSYS: return "bad argument to system call"; -#endif -#ifdef SIGTERM - case SIGTERM: return "software termination signal"; -#endif -#ifdef SIGTRAP - case SIGTRAP: return "trace trap"; -#endif -#ifdef SIGTSTP - case SIGTSTP: return "stop signal from tty"; -#endif -#ifdef SIGTTIN - case SIGTTIN: return "background tty read"; -#endif -#ifdef SIGTTOU - case SIGTTOU: return "background tty write"; -#endif -#if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO)) - case SIGURG: return "urgent I/O condition"; -#endif -#if defined(SIGUSR1) && (!defined(SIGIO) || (SIGUSR1 != SIGIO)) - case SIGUSR1: return "user-defined signal 1"; -#endif -#if defined(SIGUSR2) && (!defined(SIGURG) || (SIGUSR2 != SIGURG)) - case SIGUSR2: return "user-defined signal 2"; -#endif -#ifdef SIGVTALRM - case SIGVTALRM: return "virtual time alarm"; -#endif -#ifdef SIGWINCH - case SIGWINCH: return "window changed"; -#endif -#ifdef SIGXCPU - case SIGXCPU: return "exceeded CPU time limit"; -#endif -#ifdef SIGXFSZ - case SIGXFSZ: return "exceeded file size limit"; -#endif - } - return "unknown signal"; -} diff --git a/cde/programs/dtdocbook/tcl/tclPreserve.c b/cde/programs/dtdocbook/tcl/tclPreserve.c deleted file mode 100644 index 6604b673f..000000000 --- a/cde/programs/dtdocbook/tcl/tclPreserve.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclPreserve.c /main/2 1996/08/08 14:46:12 cde-hp $ */ -/* - * tclPreserve.c -- - * - * This file contains a collection of procedures that are used - * to make sure that widget records and other data structures - * aren't reallocated when there are nested procedures that - * depend on their existence. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclPreserve.c 1.14 96/03/20 08:24:37 - */ - -#include "tclInt.h" - -/* - * The following data structure is used to keep track of all the - * Tcl_Preserve calls that are still in effect. It grows as needed - * to accommodate any number of calls in effect. - */ - -typedef struct { - ClientData clientData; /* Address of preserved block. */ - int refCount; /* Number of Tcl_Preserve calls in effect - * for block. */ - int mustFree; /* Non-zero means Tcl_EventuallyFree was - * called while a Tcl_Preserve call was in - * effect, so the structure must be freed - * when refCount becomes zero. */ - Tcl_FreeProc *freeProc; /* Procedure to call to free. */ -} Reference; - -static Reference *refArray; /* First in array of references. */ -static int spaceAvl = 0; /* Total number of structures available - * at *firstRefPtr. */ -static int inUse = 0; /* Count of structures currently in use - * in refArray. */ -#define INITIAL_SIZE 2 - -/* - * Static routines in this file: - */ - -static void PreserveExitProc _ANSI_ARGS_((ClientData clientData)); - - -/* - *---------------------------------------------------------------------- - * - * PreserveExitProc -- - * - * Called during exit processing to clean up the reference array. - * - * Results: - * None. - * - * Side effects: - * Frees the storage of the reference array. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -PreserveExitProc( - ClientData clientData /* NULL -Unused. */ -) -{ - if (spaceAvl != 0) { - ckfree((char *) refArray); - refArray = (Reference *) NULL; - inUse = 0; - spaceAvl = 0; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Preserve -- - * - * This procedure is used by a procedure to declare its interest - * in a particular block of memory, so that the block will not be - * reallocated until a matching call to Tcl_Release has been made. - * - * Results: - * None. - * - * Side effects: - * Information is retained so that the block of memory will - * not be freed until at least the matching call to Tcl_Release. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_Preserve( - ClientData clientData /* Pointer to malloc'ed block of memory. */ -) -{ - Reference *refPtr; - int i; - - /* - * See if there is already a reference for this pointer. If so, - * just increment its reference count. - */ - - for (i = 0, refPtr = refArray; i < inUse; i++, refPtr++) { - if (refPtr->clientData == clientData) { - refPtr->refCount++; - return; - } - } - - /* - * Make a reference array if it doesn't already exist, or make it - * bigger if it is full. - */ - - if (inUse == spaceAvl) { - if (spaceAvl == 0) { - Tcl_CreateExitHandler((Tcl_ExitProc *) PreserveExitProc, - (ClientData) NULL); - refArray = (Reference *) ckalloc((unsigned) - (INITIAL_SIZE*sizeof(Reference))); - spaceAvl = INITIAL_SIZE; - } else { - Reference *new; - - new = (Reference *) ckalloc((unsigned) - (2*spaceAvl*sizeof(Reference))); - memcpy((VOID *) new, (VOID *) refArray, - spaceAvl*sizeof(Reference)); - ckfree((char *) refArray); - refArray = new; - spaceAvl *= 2; - } - } - - /* - * Make a new entry for the new reference. - */ - - refPtr = &refArray[inUse]; - refPtr->clientData = clientData; - refPtr->refCount = 1; - refPtr->mustFree = 0; - inUse += 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Release -- - * - * This procedure is called to cancel a previous call to - * Tcl_Preserve, thereby allowing a block of memory to be - * freed (if no one else cares about it). - * - * Results: - * None. - * - * Side effects: - * If Tcl_EventuallyFree has been called for clientData, and if - * no other call to Tcl_Preserve is still in effect, the block of - * memory is freed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_Release( - ClientData clientData /* Pointer to malloc'ed block of memory. */ -) -{ - Reference *refPtr; - int mustFree; - Tcl_FreeProc *freeProc; - int i; - - for (i = 0, refPtr = refArray; i < inUse; i++, refPtr++) { - if (refPtr->clientData != clientData) { - continue; - } - refPtr->refCount--; - if (refPtr->refCount == 0) { - - /* - * Must remove information from the slot before calling freeProc - * to avoid reentrancy problems if the freeProc calls Tcl_Preserve - * on the same clientData. Copy down the last reference in the - * array to overwrite the current slot. - */ - - freeProc = refPtr->freeProc; - mustFree = refPtr->mustFree; - inUse--; - if (i < inUse) { - refArray[i] = refArray[inUse]; - } - if (mustFree) { - if ((freeProc == TCL_DYNAMIC) || - (freeProc == (Tcl_FreeProc *) free)) { - ckfree((char *) clientData); - } else { - (*freeProc)((char *) clientData); - } - } - } - return; - } - - /* - * Reference not found. This is a bug in the caller. - */ - - panic("Tcl_Release couldn't find reference for 0x%x", clientData); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_EventuallyFree -- - * - * Free up a block of memory, unless a call to Tcl_Preserve is in - * effect for that block. In this case, defer the free until all - * calls to Tcl_Preserve have been undone by matching calls to - * Tcl_Release. - * - * Results: - * None. - * - * Side effects: - * Ptr may be released by calling free(). - * - *---------------------------------------------------------------------- - */ - -void -Tcl_EventuallyFree( - ClientData clientData, /* Pointer to malloc'ed block of memory. */ - Tcl_FreeProc *freeProc /* Procedure to actually do free. */ -) -{ - Reference *refPtr; - int i; - - /* - * See if there is a reference for this pointer. If so, set its - * "mustFree" flag (the flag had better not be set already!). - */ - - for (i = 0, refPtr = refArray; i < inUse; i++, refPtr++) { - if (refPtr->clientData != clientData) { - continue; - } - if (refPtr->mustFree) { - panic("Tcl_EventuallyFree called twice for 0x%x\n", clientData); - } - refPtr->mustFree = 1; - refPtr->freeProc = freeProc; - return; - } - - /* - * No reference for this block. Free it now. - */ - - if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { - ckfree((char *) clientData); - } else { - (*freeProc)((char *)clientData); - } -} diff --git a/cde/programs/dtdocbook/tcl/tclProc.c b/cde/programs/dtdocbook/tcl/tclProc.c deleted file mode 100644 index 85664b34a..000000000 --- a/cde/programs/dtdocbook/tcl/tclProc.c +++ /dev/null @@ -1,690 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclProc.c /main/2 1996/08/08 14:46:17 cde-hp $ */ -/* - * tclProc.c -- - * - * This file contains routines that implement Tcl procedures, - * including the "proc" and "uplevel" commands. - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclProc.c 1.72 96/02/15 11:42:48 - */ - -#include "tclInt.h" - -/* - * Forward references to procedures defined later in this file: - */ - -static void CleanupProc _ANSI_ARGS_((Proc *procPtr)); -static int InterpProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -static void ProcDeleteProc _ANSI_ARGS_((ClientData clientData)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_ProcCmd -- - * - * This procedure is invoked to process the "proc" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * A new procedure gets created. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ProcCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - Proc *procPtr; - int result, argCount, i; - char **argArray = NULL; - Arg *lastArgPtr; - Arg *argPtr = NULL; /* Initialization not needed, but - * prevents compiler warning. */ - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " name args body\"", (char *) NULL); - return TCL_ERROR; - } - - procPtr = (Proc *) ckalloc(sizeof(Proc)); - procPtr->iPtr = iPtr; - procPtr->refCount = 1; - procPtr->command = (char *) ckalloc((unsigned) strlen(argv[3]) + 1); - strcpy(procPtr->command, argv[3]); - procPtr->argPtr = NULL; - - /* - * Break up the argument list into argument specifiers, then process - * each argument specifier. - */ - - result = Tcl_SplitList(interp, argv[2], &argCount, &argArray); - if (result != TCL_OK) { - goto procError; - } - lastArgPtr = NULL; - for (i = 0; i < argCount; i++) { - int fieldCount, nameLength, valueLength; - char **fieldValues; - - /* - * Now divide the specifier up into name and default. - */ - - result = Tcl_SplitList(interp, argArray[i], &fieldCount, - &fieldValues); - if (result != TCL_OK) { - goto procError; - } - if (fieldCount > 2) { - ckfree((char *) fieldValues); - Tcl_AppendResult(interp, - "too many fields in argument specifier \"", - argArray[i], "\"", (char *) NULL); - result = TCL_ERROR; - goto procError; - } - if ((fieldCount == 0) || (*fieldValues[0] == 0)) { - ckfree((char *) fieldValues); - Tcl_AppendResult(interp, "procedure \"", argv[1], - "\" has argument with no name", (char *) NULL); - result = TCL_ERROR; - goto procError; - } - nameLength = strlen(fieldValues[0]) + 1; - if (fieldCount == 2) { - valueLength = strlen(fieldValues[1]) + 1; - } else { - valueLength = 0; - } - argPtr = (Arg *) ckalloc((unsigned) - (sizeof(Arg) - sizeof(argPtr->name) + nameLength - + valueLength)); - if (lastArgPtr == NULL) { - procPtr->argPtr = argPtr; - } else { - lastArgPtr->nextPtr = argPtr; - } - lastArgPtr = argPtr; - argPtr->nextPtr = NULL; - strcpy(argPtr->name, fieldValues[0]); - if (fieldCount == 2) { - argPtr->defValue = argPtr->name + nameLength; - strcpy(argPtr->defValue, fieldValues[1]); - } else { - argPtr->defValue = NULL; - } - ckfree((char *) fieldValues); - } - - Tcl_CreateCommand(interp, argv[1], InterpProc, (ClientData) procPtr, - ProcDeleteProc); - ckfree((char *) argArray); - return TCL_OK; - - procError: - ckfree(procPtr->command); - while (procPtr->argPtr != NULL) { - argPtr = procPtr->argPtr; - procPtr->argPtr = argPtr->nextPtr; - ckfree((char *) argPtr); - } - ckfree((char *) procPtr); - if (argArray != NULL) { - ckfree((char *) argArray); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetFrame -- - * - * Given a description of a procedure frame, such as the first - * argument to an "uplevel" or "upvar" command, locate the - * call frame for the appropriate level of procedure. - * - * Results: - * The return value is -1 if an error occurred in finding the - * frame (in this case an error message is left in interp->result). - * 1 is returned if string was either a number or a number preceded - * by "#" and it specified a valid frame. 0 is returned if string - * isn't one of the two things above (in this case, the lookup - * acts as if string were "1"). The variable pointed to by - * framePtrPtr is filled in with the address of the desired frame - * (unless an error occurs, in which case it isn't modified). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGetFrame( - Tcl_Interp *interp, /* Interpreter in which to find frame. */ - char *string, /* String describing frame. */ - CallFrame **framePtrPtr /* Store pointer to frame here (or NULL - * if global frame indicated). */ -) -{ - Interp *iPtr = (Interp *) interp; - int curLevel, level, result; - CallFrame *framePtr; - - /* - * Parse string to figure out which level number to go to. - */ - - result = 1; - curLevel = (iPtr->varFramePtr == NULL) ? 0 : iPtr->varFramePtr->level; - if (*string == '#') { - if (Tcl_GetInt(interp, string+1, &level) != TCL_OK) { - return -1; - } - if (level < 0) { - levelError: - Tcl_AppendResult(interp, "bad level \"", string, "\"", - (char *) NULL); - return -1; - } - } else if (isdigit(UCHAR(*string))) { - if (Tcl_GetInt(interp, string, &level) != TCL_OK) { - return -1; - } - level = curLevel - level; - } else { - level = curLevel - 1; - result = 0; - } - - /* - * Figure out which frame to use, and modify the interpreter so - * its variables come from that frame. - */ - - if (level == 0) { - framePtr = NULL; - } else { - for (framePtr = iPtr->varFramePtr; framePtr != NULL; - framePtr = framePtr->callerVarPtr) { - if (framePtr->level == level) { - break; - } - } - if (framePtr == NULL) { - goto levelError; - } - } - *framePtrPtr = framePtr; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UplevelCmd -- - * - * This procedure is invoked to process the "uplevel" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_UplevelCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - int result; - CallFrame *savedVarFramePtr, *framePtr; - - if (argc < 2) { - uplevelSyntax: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?level? command ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Find the level to use for executing the command. - */ - - result = TclGetFrame(interp, argv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - argc -= (result+1); - if (argc == 0) { - goto uplevelSyntax; - } - argv += (result+1); - - /* - * Modify the interpreter state to execute in the given frame. - */ - - savedVarFramePtr = iPtr->varFramePtr; - iPtr->varFramePtr = framePtr; - - /* - * Execute the residual arguments as a command. - */ - - if (argc == 1) { - result = Tcl_Eval(interp, argv[0]); - } else { - char *cmd; - - cmd = Tcl_Concat(argc, argv); - result = Tcl_Eval(interp, cmd); - ckfree(cmd); - } - if (result == TCL_ERROR) { - char msg[60]; - sprintf(msg, "\n (\"uplevel\" body line %d)", interp->errorLine); - Tcl_AddErrorInfo(interp, msg); - } - - /* - * Restore the variable frame, and return. - */ - - iPtr->varFramePtr = savedVarFramePtr; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * TclFindProc -- - * - * Given the name of a procedure, return a pointer to the - * record describing the procedure. - * - * Results: - * NULL is returned if the name doesn't correspond to any - * procedure. Otherwise the return value is a pointer to - * the procedure's record. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Proc * -TclFindProc( - Interp *iPtr, /* Interpreter in which to look. */ - char *procName /* Name of desired procedure. */ -) -{ - Tcl_HashEntry *hPtr; - Command *cmdPtr; - - hPtr = Tcl_FindHashEntry(&iPtr->commandTable, procName); - if (hPtr == NULL) { - return NULL; - } - cmdPtr = (Command *) Tcl_GetHashValue(hPtr); - if (cmdPtr->proc != InterpProc) { - return NULL; - } - return (Proc *) cmdPtr->clientData; -} - -/* - *---------------------------------------------------------------------- - * - * TclIsProc -- - * - * Tells whether a command is a Tcl procedure or not. - * - * Results: - * If the given command is actuall a Tcl procedure, the - * return value is the address of the record describing - * the procedure. Otherwise the return value is 0. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Proc * -TclIsProc( - Command *cmdPtr /* Command to test. */ -) -{ - if (cmdPtr->proc == InterpProc) { - return (Proc *) cmdPtr->clientData; - } - return (Proc *) 0; -} - -/* - *---------------------------------------------------------------------- - * - * InterpProc -- - * - * When a Tcl procedure gets invoked, this routine gets invoked - * to interpret the procedure. - * - * Results: - * A standard Tcl result value, usually TCL_OK. - * - * Side effects: - * Depends on the commands in the procedure. - * - *---------------------------------------------------------------------- - */ - -static int -InterpProc( - ClientData clientData, /* Record describing procedure to be - * interpreted. */ - Tcl_Interp *interp, /* Interpreter in which procedure was - * invoked. */ - int argc, /* Count of number of arguments to this - * procedure. */ - char **argv /* Argument values. */ -) -{ - Proc *procPtr = (Proc *) clientData; - Arg *argPtr; - Interp *iPtr; - char **args; - CallFrame frame; - char *value; - int result; - - /* - * Set up a call frame for the new procedure invocation. - */ - - iPtr = procPtr->iPtr; - Tcl_InitHashTable(&frame.varTable, TCL_STRING_KEYS); - if (iPtr->varFramePtr != NULL) { - frame.level = iPtr->varFramePtr->level + 1; - } else { - frame.level = 1; - } - frame.argc = argc; - frame.argv = argv; - frame.callerPtr = iPtr->framePtr; - frame.callerVarPtr = iPtr->varFramePtr; - iPtr->framePtr = &frame; - iPtr->varFramePtr = &frame; - iPtr->returnCode = TCL_OK; - - /* - * Match the actual arguments against the procedure's formal - * parameters to compute local variables. - */ - - for (argPtr = procPtr->argPtr, args = argv+1, argc -= 1; - argPtr != NULL; - argPtr = argPtr->nextPtr, args++, argc--) { - - /* - * Handle the special case of the last formal being "args". When - * it occurs, assign it a list consisting of all the remaining - * actual arguments. - */ - - if ((argPtr->nextPtr == NULL) - && (strcmp(argPtr->name, "args") == 0)) { - if (argc < 0) { - argc = 0; - } - value = Tcl_Merge(argc, args); - Tcl_SetVar(interp, argPtr->name, value, 0); - ckfree(value); - argc = 0; - break; - } else if (argc > 0) { - value = *args; - } else if (argPtr->defValue != NULL) { - value = argPtr->defValue; - } else { - Tcl_AppendResult(interp, "no value given for parameter \"", - argPtr->name, "\" to \"", argv[0], "\"", - (char *) NULL); - result = TCL_ERROR; - goto procDone; - } - Tcl_SetVar(interp, argPtr->name, value, 0); - } - if (argc > 0) { - Tcl_AppendResult(interp, "called \"", argv[0], - "\" with too many arguments", (char *) NULL); - result = TCL_ERROR; - goto procDone; - } - - /* - * Invoke the commands in the procedure's body. - */ - - procPtr->refCount++; - result = Tcl_Eval(interp, procPtr->command); - procPtr->refCount--; - if (procPtr->refCount <= 0) { - CleanupProc(procPtr); - } - if (result == TCL_RETURN) { - result = TclUpdateReturnInfo(iPtr); - } else if (result == TCL_ERROR) { - char msg[100]; - - /* - * Record information telling where the error occurred. - */ - - sprintf(msg, "\n (procedure \"%.50s\" line %d)", argv[0], - iPtr->errorLine); - Tcl_AddErrorInfo(interp, msg); - } else if (result == TCL_BREAK) { - iPtr->result = "invoked \"break\" outside of a loop"; - result = TCL_ERROR; - } else if (result == TCL_CONTINUE) { - iPtr->result = "invoked \"continue\" outside of a loop"; - result = TCL_ERROR; - } - - /* - * Delete the call frame for this procedure invocation (it's - * important to remove the call frame from the interpreter - * before deleting it, so that traces invoked during the - * deletion don't see the partially-deleted frame). - */ - - procDone: - iPtr->framePtr = frame.callerPtr; - iPtr->varFramePtr = frame.callerVarPtr; - - /* - * The check below is a hack. The problem is that there could be - * unset traces on the variables, which cause scripts to be evaluated. - * This will clear the ERR_IN_PROGRESS flag, losing stack trace - * information if the procedure was exiting with an error. The - * code below preserves the flag. Unfortunately, that isn't - * really enough: we really should preserve the errorInfo variable - * too (otherwise a nested error in the trace script will trash - * errorInfo). What's really needed is a general-purpose - * mechanism for saving and restoring interpreter state. - */ - - if (iPtr->flags & ERR_IN_PROGRESS) { - TclDeleteVars(iPtr, &frame.varTable); - iPtr->flags |= ERR_IN_PROGRESS; - } else { - TclDeleteVars(iPtr, &frame.varTable); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * ProcDeleteProc -- - * - * This procedure is invoked just before a command procedure is - * removed from an interpreter. Its job is to release all the - * resources allocated to the procedure. - * - * Results: - * None. - * - * Side effects: - * Memory gets freed, unless the procedure is actively being - * executed. In this case the cleanup is delayed until the - * last call to the current procedure completes. - * - *---------------------------------------------------------------------- - */ - -static void -ProcDeleteProc( - ClientData clientData /* Procedure to be deleted. */ -) -{ - Proc *procPtr = (Proc *) clientData; - - procPtr->refCount--; - if (procPtr->refCount <= 0) { - CleanupProc(procPtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * CleanupProc -- - * - * This procedure does all the real work of freeing up a Proc - * structure. It's called only when the structure's reference - * count becomes zero. - * - * Results: - * None. - * - * Side effects: - * Memory gets freed. - * - *---------------------------------------------------------------------- - */ - -static void -CleanupProc( - Proc *procPtr /* Procedure to be deleted. */ -) -{ - Arg *argPtr; - - ckfree((char *) procPtr->command); - for (argPtr = procPtr->argPtr; argPtr != NULL; ) { - Arg *nextPtr = argPtr->nextPtr; - - ckfree((char *) argPtr); - argPtr = nextPtr; - } - ckfree((char *) procPtr); -} - -/* - *---------------------------------------------------------------------- - * - * TclUpdateReturnInfo -- - * - * This procedure is called when procedures return, and at other - * points where the TCL_RETURN code is used. It examines fields - * such as iPtr->returnCode and iPtr->errorCode and modifies - * the real return status accordingly. - * - * Results: - * The return value is the true completion code to use for - * the procedure, instead of TCL_RETURN. - * - * Side effects: - * The errorInfo and errorCode variables may get modified. - * - *---------------------------------------------------------------------- - */ - -int -TclUpdateReturnInfo( - Interp *iPtr /* Interpreter for which TCL_RETURN - * exception is being processed. */ -) -{ - int code; - - code = iPtr->returnCode; - iPtr->returnCode = TCL_OK; - if (code == TCL_ERROR) { - Tcl_SetVar2((Tcl_Interp *) iPtr, "errorCode", (char *) NULL, - (iPtr->errorCode != NULL) ? iPtr->errorCode : "NONE", - TCL_GLOBAL_ONLY); - iPtr->flags |= ERROR_CODE_SET; - if (iPtr->errorInfo != NULL) { - Tcl_SetVar2((Tcl_Interp *) iPtr, "errorInfo", (char *) NULL, - iPtr->errorInfo, TCL_GLOBAL_ONLY); - iPtr->flags |= ERR_IN_PROGRESS; - } - } - return code; -} diff --git a/cde/programs/dtdocbook/tcl/tclRegexp.h b/cde/programs/dtdocbook/tcl/tclRegexp.h deleted file mode 100644 index ea0202597..000000000 --- a/cde/programs/dtdocbook/tcl/tclRegexp.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclRegexp.h /main/2 1996/08/08 14:46:22 cde-hp $ */ -/* - * Definitions etc. for regexp(3) routines. - * - * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], - * not the System V one. - * - * SCCS: @(#) tclRegexp.h 1.6 96/04/02 18:43:57 - */ - -#ifndef _REGEXP -#define _REGEXP 1 - -#ifndef _TCL -#include "tcl.h" -#endif - -/* - * NSUBEXP must be at least 10, and no greater than 117 or the parser - * will not work properly. - */ - -#define NSUBEXP 20 - -typedef struct regexp { - char *startp[NSUBEXP]; - char *endp[NSUBEXP]; - char regstart; /* Internal use only. */ - char reganch; /* Internal use only. */ - char *regmust; /* Internal use only. */ - int regmlen; /* Internal use only. */ - char program[1]; /* Unwarranted chumminess with compiler. */ -} regexp; - -EXTERN regexp *TclRegComp _ANSI_ARGS_((char *exp)); -EXTERN int TclRegExec _ANSI_ARGS_((regexp *prog, char *string, char *start)); -EXTERN void TclRegSub _ANSI_ARGS_((regexp *prog, char *source, char *dest)); -EXTERN void TclRegError _ANSI_ARGS_((char *msg)); -EXTERN char *TclGetRegError _ANSI_ARGS_((void)); - -#endif /* REGEXP */ diff --git a/cde/programs/dtdocbook/tcl/tclUnixChan.c b/cde/programs/dtdocbook/tcl/tclUnixChan.c deleted file mode 100644 index 6c3605180..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixChan.c +++ /dev/null @@ -1,1878 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixChan.c /main/3 1996/10/03 17:18:13 drk $ */ -/* - * tclUnixChan.c - * - * Common channel driver for Unix channels based on files, command - * pipes and TCP sockets. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixChan.c 1.161 96/04/18 08:28:54 - */ - -#include "tclInt.h" /* Internal definitions for Tcl. */ -#include "tclPort.h" /* Portability features for Tcl. */ - -/* - * This structure describes per-instance state of a pipe based channel. - */ - -typedef struct PipeState { - Tcl_File readFile; /* Output from pipe. */ - Tcl_File writeFile; /* Input to pipe. */ - Tcl_File errorFile; /* Error output from pipe. */ - int numPids; /* How many processes are attached to this pipe? */ - pid_t *pidPtr; /* The process IDs themselves. Allocated by - * the creator of the pipe. */ -} PipeState; - -/* - * This structure describes per-instance state of a tcp based channel. - */ - -typedef struct TcpState { - int flags; /* ORed combination of the - * bitfields defined below. */ - Tcl_File sock; /* The socket itself. */ - Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */ - ClientData acceptProcData; /* The data for the accept proc. */ -} TcpState; - -/* - * These bits may be ORed together into the "flags" field of a TcpState - * structure. - */ - -#define TCP_ASYNC_SOCKET (1<<0) /* Asynchronous socket. */ -#define TCP_ASYNC_CONNECT (1<<1) /* Async connect in progress. */ - -/* - * The following defines how much buffer space the kernel should maintain - * for a socket. - */ - -#define SOCKET_BUFSIZE 4096 - -/* - * Static routines for this file: - */ - -static int CommonBlockModeProc _ANSI_ARGS_(( - ClientData instanceData, Tcl_File inFile, - Tcl_File outFile, int mode)); -static TcpState * CreateSocket _ANSI_ARGS_((Tcl_Interp *interp, - int port, char *host, int server, - char *myaddr, int myport, int async)); -static int CreateSocketAddress _ANSI_ARGS_( - (struct sockaddr_in *sockaddrPtr, - char *host, int port)); -static int FileCloseProc _ANSI_ARGS_((ClientData instanceData, - Tcl_Interp *interp, Tcl_File inFile, - Tcl_File outFile)); -static int FilePipeInputProc _ANSI_ARGS_((ClientData instanceData, - Tcl_File inFile, char *buf, int toRead, - int *errorCode)); -static int FilePipeOutputProc _ANSI_ARGS_(( - ClientData instanceData, Tcl_File outFile, - char *buf, int toWrite, int *errorCode)); -static int FileSeekProc _ANSI_ARGS_((ClientData instanceData, - Tcl_File inFile, Tcl_File outFile, long offset, - int mode, int *errorCode)); -static int PipeCloseProc _ANSI_ARGS_((ClientData instanceData, - Tcl_Interp *interp, Tcl_File inFile, - Tcl_File outFile)); -static void TcpAccept _ANSI_ARGS_((ClientData data, int mask)); -static int TcpBlockModeProc _ANSI_ARGS_((ClientData data, - Tcl_File inFile, Tcl_File outFile, int mode)); -static int TcpCloseProc _ANSI_ARGS_((ClientData instanceData, - Tcl_Interp *interp, Tcl_File inFile, - Tcl_File outFile)); -static int TcpGetOptionProc _ANSI_ARGS_((ClientData instanceData, - char *optionName, Tcl_DString *dsPtr)); -static int TcpInputProc _ANSI_ARGS_((ClientData instanceData, - Tcl_File infile, char *buf, int toRead, - int *errorCode)); -static int TcpOutputProc _ANSI_ARGS_((ClientData instanceData, - Tcl_File outFile, char *buf, int toWrite, - int *errorCode)); -static int WaitForConnect _ANSI_ARGS_((TcpState *statePtr, - Tcl_File fileToWaitFor, int *errorCodePtr)); - -/* - * This structure describes the channel type structure for file based IO: - */ - -static Tcl_ChannelType fileChannelType = { - "file", /* Type name. */ - CommonBlockModeProc, /* Set blocking/nonblocking mode.*/ - FileCloseProc, /* Close proc. */ - FilePipeInputProc, /* Input proc. */ - FilePipeOutputProc, /* Output proc. */ - FileSeekProc, /* Seek proc. */ - NULL, /* Set option proc. */ - NULL, /* Get option proc. */ -}; - -/* - * This structure describes the channel type structure for command pipe - * based IO: - */ - -static Tcl_ChannelType pipeChannelType = { - "pipe", /* Type name. */ - CommonBlockModeProc, /* Set blocking/nonblocking mode.*/ - PipeCloseProc, /* Close proc. */ - FilePipeInputProc, /* Input proc. */ - FilePipeOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ - NULL, /* Set option proc. */ - NULL, /* Get option proc. */ -}; - -/* - * This structure describes the channel type structure for TCP socket - * based IO: - */ - -static Tcl_ChannelType tcpChannelType = { - "tcp", /* Type name. */ - TcpBlockModeProc, /* Set blocking/nonblocking mode.*/ - TcpCloseProc, /* Close proc. */ - TcpInputProc, /* Input proc. */ - TcpOutputProc, /* Output proc. */ - NULL, /* Seek proc. */ - NULL, /* Set option proc. */ - TcpGetOptionProc, /* Get option proc. */ -}; - -/* - *---------------------------------------------------------------------- - * - * CommonBlockModeProc -- - * - * Helper procedure to set blocking and nonblocking modes on a - * channel. Invoked either by generic IO level code or by other - * channel drivers after doing channel-type-specific inialization. - * - * Results: - * 0 if successful, errno when failed. - * - * Side effects: - * Sets the device into blocking or non-blocking mode. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -CommonBlockModeProc( - ClientData instanceData, /* Unused. */ - Tcl_File inFile, Tcl_File outFile, /* Input, output files for channel. */ - int mode /* The mode to set. Can be one of - * TCL_MODE_BLOCKING or - * TCL_MODE_NONBLOCKING. */ -) -{ - int curStatus; - int fd; - - if (inFile != NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - curStatus = fcntl(fd, F_GETFL); - if (mode == TCL_MODE_BLOCKING) { - curStatus &= (~(O_NONBLOCK)); - } else { - curStatus |= O_NONBLOCK; - } - if (fcntl(fd, F_SETFL, curStatus) < 0) { - return errno; - } - curStatus = fcntl(fd, F_GETFL); - } - if (outFile != NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - curStatus = fcntl(fd, F_GETFL); - if (mode == TCL_MODE_BLOCKING) { - curStatus &= (~(O_NONBLOCK)); - } else { - curStatus |= O_NONBLOCK; - } - if (fcntl(fd, F_SETFL, curStatus) < 0) { - return errno; - } - } - - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * FilePipeInputProc -- - * - * This procedure is invoked from the generic IO level to read - * input from a file or command pipeline channel. - * - * Results: - * The number of bytes read is returned or -1 on error. An output - * argument contains a POSIX error code if an error occurs, or zero. - * - * Side effects: - * Reads input from the input device of the channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -FilePipeInputProc( - ClientData instanceData, /* Unused. */ - Tcl_File inFile, /* Input device for channel. */ - char *buf, /* Where to store data read. */ - int toRead, /* How much space is available - * in the buffer? */ - int *errorCodePtr /* Where to store error code. */ -) -{ - int fd; /* The OS handle for reading. */ - int bytesRead; /* How many bytes were actually - * read from the input device? */ - - *errorCodePtr = 0; - fd = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - - /* - * Assume there is always enough input available. This will block - * appropriately, and read will unblock as soon as a short read is - * possible, if the channel is in blocking mode. If the channel is - * nonblocking, the read will never block. - */ - - bytesRead = read(fd, buf, (size_t) toRead); - if (bytesRead > -1) { - return bytesRead; - } - *errorCodePtr = errno; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * FilePipeOutputProc-- - * - * This procedure is invoked from the generic IO level to write - * output to a file or command pipeline channel. - * - * Results: - * The number of bytes written is returned or -1 on error. An - * output argument contains a POSIX error code if an error occurred, - * or zero. - * - * Side effects: - * Writes output on the output device of the channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -FilePipeOutputProc( - ClientData instanceData, /* Unused. */ - Tcl_File outFile, /* Output device for channel. */ - char *buf, /* The data buffer. */ - int toWrite, /* How many bytes to write? */ - int *errorCodePtr /* Where to store error code. */ -) -{ - int written; - int fd; - - *errorCodePtr = 0; - fd = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - written = write(fd, buf, (size_t) toWrite); - if (written > -1) { - return written; - } - *errorCodePtr = errno; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * FileCloseProc -- - * - * This procedure is called from the generic IO level to perform - * channel-type-specific cleanup when a file based channel is closed. - * - * Results: - * 0 if successful, errno if failed. - * - * Side effects: - * Closes the device of the channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -FileCloseProc( - ClientData instanceData, /* Unused. */ - Tcl_Interp *interp, /* For error reporting - unused. */ - Tcl_File inFile, /* Input file to close. */ - Tcl_File outFile /* Output file to close. */ -) -{ - int fd, errorCode = 0; - - if (inFile != NULL) { - - /* - * Check for read/write file so we only close it once. - */ - - if (inFile == outFile) { - outFile = NULL; - } - fd = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - Tcl_FreeFile(inFile); - - if (close(fd) < 0) { - errorCode = errno; - } - } - - if (outFile != NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - Tcl_FreeFile(outFile); - if ((close(fd) < 0) && (errorCode == 0)) { - errorCode = errno; - } - } - return errorCode; -} - -/* - *---------------------------------------------------------------------- - * - * FileSeekProc -- - * - * This procedure is called by the generic IO level to move the - * access point in a file based channel. - * - * Results: - * -1 if failed, the new position if successful. An output - * argument contains the POSIX error code if an error occurred, - * or zero. - * - * Side effects: - * Moves the location at which the channel will be accessed in - * future operations. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -FileSeekProc( - ClientData instanceData, /* Unused. */ - Tcl_File inFile, Tcl_File outFile, /* Input and output - * files for channel. */ - long offset, /* Offset to seek to. */ - int mode, /* Relative to where - * should we seek? Can be - * one of SEEK_START, - * SEEK_SET or SEEK_END. */ - int *errorCodePtr /* To store error code. */ -) -{ - int newLoc; - int fd; - - *errorCodePtr = 0; - if (inFile != (Tcl_File) NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - } else if (outFile != (Tcl_File) NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - } else { - *errorCodePtr = EFAULT; - return -1; - } - newLoc = lseek(fd, offset, mode); - if (newLoc > -1) { - return newLoc; - } - *errorCodePtr = errno; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetAndDetachPids -- - * - * This procedure is invoked in the generic implementation of a - * background "exec" (An exec when invoked with a terminating "&") - * to store a list of the PIDs for processes in a command pipeline - * in interp->result and to detach the processes. - * - * Results: - * None. - * - * Side effects: - * Modifies interp->result. Detaches processes. - * - *---------------------------------------------------------------------- - */ - -void -TclGetAndDetachPids( - Tcl_Interp *interp, - Tcl_Channel chan -) -{ - PipeState *pipePtr; - Tcl_ChannelType *chanTypePtr; - int i; - char buf[20]; - - /* - * Punt if the channel is not a command channel. - */ - - chanTypePtr = Tcl_GetChannelType(chan); - if (chanTypePtr != &pipeChannelType) { - return; - } - - pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan); - for (i = 0; i < pipePtr->numPids; i++) { - sprintf(buf, "%ld", (long)pipePtr->pidPtr[i]); - Tcl_AppendElement(interp, buf); - Tcl_DetachPids(1, &(pipePtr->pidPtr[i])); - } - if (pipePtr->numPids > 0) { - ckfree((char *) pipePtr->pidPtr); - pipePtr->numPids = 0; - } -} - -/* - *---------------------------------------------------------------------- - * - * PipeCloseProc -- - * - * This procedure is invoked by the generic IO level to perform - * channel-type-specific cleanup when a command pipeline channel - * is closed. - * - * Results: - * 0 on success, errno otherwise. - * - * Side effects: - * Closes the command pipeline channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -PipeCloseProc( - ClientData instanceData, /* The pipe to close. */ - Tcl_Interp *interp, /* For error reporting. */ - Tcl_File inFile, Tcl_File outFile /* Unused. */ -) -{ - PipeState *pipePtr; - Tcl_Channel errChan; - int fd, errorCode, result; - - errorCode = 0; - pipePtr = (PipeState *) instanceData; - if (pipePtr->readFile != NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(pipePtr->readFile, NULL); - Tcl_FreeFile(pipePtr->readFile); - if (close(fd) < 0) { - errorCode = errno; - } - } - if (pipePtr->writeFile != NULL) { - fd = (int) (intptr_t) Tcl_GetFileInfo(pipePtr->writeFile, NULL); - Tcl_FreeFile(pipePtr->writeFile); - if ((close(fd) < 0) && (errorCode == 0)) { - errorCode = errno; - } - } - - /* - * Wrap the error file into a channel and give it to the cleanup - * routine. - */ - - if (pipePtr->errorFile != NULL) { - errChan = Tcl_CreateChannel(&fileChannelType, "pipeError", - pipePtr->errorFile, NULL, NULL); - } else { - errChan = NULL; - } - result = TclCleanupChildren(interp, pipePtr->numPids, pipePtr->pidPtr, - errChan); - if (pipePtr->numPids != 0) { - ckfree((char *) pipePtr->pidPtr); - } - ckfree((char *) pipePtr); - if (errorCode == 0) { - return result; - } - return errorCode; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_OpenFileChannel -- - * - * Open an file based channel on Unix systems. - * - * Results: - * The new channel or NULL. If NULL, the output argument - * errorCodePtr is set to a POSIX error and an error message is - * left in interp->result if interp is not NULL. - * - * Side effects: - * May open the channel and may cause creation of a file on the - * file system. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_OpenFileChannel( - Tcl_Interp *interp, /* Interpreter for error reporting; - * can be NULL. */ - char *fileName, /* Name of file to open. */ - char *modeString, /* A list of POSIX open modes or - * a string such as "rw". */ - int permissions /* If the open involves creating a - * file, with what modes to create - * it? */ -) -{ - int fd, seekFlag, mode, channelPermissions; - Tcl_File file; - Tcl_Channel chan; - char *nativeName, channelName[20]; - Tcl_DString buffer; - - mode = TclGetOpenMode(interp, modeString, &seekFlag); - if (mode == -1) { - return NULL; - } - switch (mode & (O_RDONLY | O_WRONLY | O_RDWR)) { - case O_RDONLY: - channelPermissions = TCL_READABLE; - break; - case O_WRONLY: - channelPermissions = TCL_WRITABLE; - break; - case O_RDWR: - channelPermissions = (TCL_READABLE | TCL_WRITABLE); - break; - default: - /* - * This may occur if modeString was "", for example. - */ - panic("Tcl_OpenFileChannel: invalid mode value"); - return NULL; - } - - nativeName = Tcl_TranslateFileName(interp, fileName, &buffer); - if (nativeName == NULL) { - return NULL; - } - fd = open(nativeName, mode, permissions); - - /* - * If nativeName is not NULL, the buffer is valid and we must free - * the storage. - */ - - Tcl_DStringFree(&buffer); - - if (fd < 0) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ", - Tcl_PosixError(interp), (char *) NULL); - } - return NULL; - } - - sprintf(channelName, "file%d", fd); - file = Tcl_GetFile((ClientData) (intptr_t) fd, TCL_UNIX_FD); - - chan = Tcl_CreateChannel(&fileChannelType, channelName, - (channelPermissions & TCL_READABLE) ? file : NULL, - (channelPermissions & TCL_WRITABLE) ? file : NULL, - (ClientData) NULL); - - /* - * The channel may not be open now, for example if we tried to - * open a file with permissions that cannot be satisfied. - */ - - if (chan == (Tcl_Channel) NULL) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "couldn't create channel \"", - channelName, "\": ", Tcl_PosixError(interp), - (char *) NULL); - } - Tcl_FreeFile(file); - close(fd); - return NULL; - } - - if (seekFlag) { - if (Tcl_Seek(chan, 0, SEEK_END) < 0) { - if (interp != (Tcl_Interp *) NULL) { - Tcl_AppendResult(interp, "couldn't seek to end of file on \"", - channelName, "\": ", Tcl_PosixError(interp), - (char *) NULL); - } - Tcl_Close(NULL, chan); - return NULL; - } - } - return chan; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_MakeFileChannel -- - * - * Makes a Tcl_Channel from an existing OS level file handle. - * - * Results: - * The Tcl_Channel created around the preexisting OS level file handle. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_MakeFileChannel( - ClientData inFd, /* OS level handle used for input. */ - ClientData outFd, /* OS level handle used for output. */ - int mode /* ORed combination of TCL_READABLE and - * TCL_WRITABLE to indicate whether inFile - * and/or outFile are valid. */ -) -{ - Tcl_File inFile, outFile; - char channelName[20]; - - if (mode == 0) { - return (Tcl_Channel) NULL; - } - - inFile = (Tcl_File) NULL; - outFile = (Tcl_File) NULL; - - if (mode & TCL_READABLE) { - sprintf(channelName, "file%d", (int) (intptr_t) inFd); - inFile = Tcl_GetFile(inFd, TCL_UNIX_FD); - } - - if (mode & TCL_WRITABLE) { - sprintf(channelName, "file%d", (int) (intptr_t) outFd); - outFile = Tcl_GetFile(outFd, TCL_UNIX_FD); - } - - return Tcl_CreateChannel(&fileChannelType, channelName, inFile, outFile, - (ClientData) NULL); -} - -/* - *---------------------------------------------------------------------- - * - * TclCreateCommandChannel -- - * - * This function is called by the generic IO level to perform - * the platform specific channel initialization for a command - * channel. - * - * Results: - * Returns a new channel or NULL on failure. - * - * Side effects: - * Allocates a new channel. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -TclCreateCommandChannel( - Tcl_File readFile, /* If non-null, gives the file for reading. */ - Tcl_File writeFile, /* If non-null, gives the file for writing. */ - Tcl_File errorFile, /* If non-null, gives the file where errors - * can be read. */ - int numPids, /* The number of pids in the pid array. */ - pid_t *pidPtr /* An array of process identifiers. - * Allocated by the caller, freed when - * the channel is closed or the processes - * are detached (in a background exec). */ -) -{ - Tcl_Channel channel; - char channelName[20]; - int channelId; - PipeState *statePtr = (PipeState *) ckalloc((unsigned) sizeof(PipeState)); - - statePtr->readFile = readFile; - statePtr->writeFile = writeFile; - statePtr->errorFile = errorFile; - statePtr->numPids = numPids; - statePtr->pidPtr = pidPtr; - - /* - * Use one of the fds associated with the channel as the - * channel id. - */ - - if (readFile) { - channelId = (int) (intptr_t) Tcl_GetFileInfo(readFile, NULL); - } else if (writeFile) { - channelId = (int) (intptr_t) Tcl_GetFileInfo(writeFile, NULL); - } else if (errorFile) { - channelId = (int) (intptr_t) Tcl_GetFileInfo(errorFile, NULL); - } else { - channelId = 0; - } - - /* - * For backward compatibility with previous versions of Tcl, we - * use "file%d" as the base name for pipes even though it would - * be more natural to use "pipe%d". - */ - - sprintf(channelName, "file%d", channelId); - channel = Tcl_CreateChannel(&pipeChannelType, channelName, readFile, - writeFile, (ClientData) statePtr); - - if (channel == NULL) { - - /* - * pidPtr will be freed by the caller if the return value is NULL. - */ - - ckfree((char *)statePtr); - } - return channel; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PidCmd -- - * - * This procedure is invoked to process the "pid" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_PidCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Tcl_Channel chan; /* The channel to get pids for. */ - Tcl_ChannelType *chanTypePtr; /* The type of that channel. */ - PipeState *pipePtr; /* The pipe state. */ - int i; /* Loops over PIDs attached to the - * pipe. */ - char string[50]; /* Temp buffer for string rep. of - * PIDs attached to the pipe. */ - - if (argc > 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ?channelId?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 1) { - sprintf(interp->result, "%ld", (long) getpid()); - } else { - chan = Tcl_GetChannel(interp, argv[1], NULL); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - chanTypePtr = Tcl_GetChannelType(chan); - if (chanTypePtr != &pipeChannelType) { - return TCL_OK; - } - pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan); - for (i = 0; i < pipePtr->numPids; i++) { - sprintf(string, "%ld", (long)pipePtr->pidPtr[i]); - Tcl_AppendElement(interp, string); - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TcpBlockModeProc -- - * - * This procedure is invoked by the generic IO level to set blocking - * and nonblocking mode on a TCP socket based channel. - * - * Results: - * 0 if successful, errno when failed. - * - * Side effects: - * Sets the device into blocking or nonblocking mode. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -TcpBlockModeProc( - ClientData instanceData, /* Socket state. */ - Tcl_File inFile, Tcl_File outFile, /* Input, output files for channel. */ - int mode /* The mode to set. Can be one of - * TCL_MODE_BLOCKING or - * TCL_MODE_NONBLOCKING. */ -) -{ - TcpState *statePtr; - - statePtr = (TcpState *) instanceData; - if (mode == TCL_MODE_BLOCKING) { - statePtr->flags &= (~(TCP_ASYNC_SOCKET)); - } else { - statePtr->flags |= TCP_ASYNC_SOCKET; - } - return CommonBlockModeProc(instanceData, inFile, outFile, mode); -} - -/* - *---------------------------------------------------------------------- - * - * WaitForConnect -- - * - * Waits for a connection on an asynchronously opened socket to - * be completed. - * - * Results: - * None. - * - * Side effects: - * The socket is connected after this function returns. - * - *---------------------------------------------------------------------- - */ - -static int -WaitForConnect( - TcpState *statePtr, /* State of the socket. */ - Tcl_File fileToWaitFor, /* File to wait on to become connected. */ - int *errorCodePtr /* Where to store errors? */ -) -{ - int sock; /* The socket itself. */ - int timeOut; /* How long to wait. */ - int state; /* Of calling TclWaitForFile. */ - int flags; /* fcntl flags for the socket. */ - - /* - * If an asynchronous connect is in progress, attempt to wait for it - * to complete before reading. - */ - - if (statePtr->flags & TCP_ASYNC_CONNECT) { - if (statePtr->flags & TCP_ASYNC_SOCKET) { - timeOut = 0; - } else { - timeOut = -1; - } - errno = 0; - state = TclWaitForFile(fileToWaitFor, TCL_WRITABLE | TCL_EXCEPTION, - timeOut); - if (!(statePtr->flags & TCP_ASYNC_SOCKET)) { - sock = (int) (intptr_t) Tcl_GetFileInfo(statePtr->sock, NULL); - flags = fcntl(sock, F_GETFL); - flags &= (~(O_NONBLOCK)); - (void) fcntl(sock, F_SETFL, flags); - } - if (state & TCL_EXCEPTION) { - return -1; - } - if (state & TCL_WRITABLE) { - statePtr->flags &= (~(TCP_ASYNC_CONNECT)); - } else if (timeOut == 0) { - *errorCodePtr = errno = EWOULDBLOCK; - return -1; - } - } - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * TcpInputProc -- - * - * This procedure is invoked by the generic IO level to read input - * from a TCP socket based channel. - * - * NOTE: We cannot share code with FilePipeInputProc because here - * we must use recv to obtain the input from the channel, not read. - * - * Results: - * The number of bytes read is returned or -1 on error. An output - * argument contains the POSIX error code on error, or zero if no - * error occurred. - * - * Side effects: - * Reads input from the input device of the channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -TcpInputProc( - ClientData instanceData, /* Socket state. */ - Tcl_File inFile, /* Input device for channel. */ - char *buf, /* Where to store data read. */ - int bufSize, /* How much space is available - * in the buffer? */ - int *errorCodePtr /* Where to store error code. */ -) -{ - TcpState *statePtr; /* The state of the socket. */ - int sock; /* The OS handle. */ - int bytesRead; /* How many bytes were read? */ - int state; /* Of waiting for connection. */ - - *errorCodePtr = 0; - sock = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - statePtr = (TcpState *) instanceData; - - state = WaitForConnect(statePtr, inFile, errorCodePtr); - if (state != 0) { - return -1; - } - bytesRead = recv(sock, buf, bufSize, 0); - if (bytesRead > -1) { - return bytesRead; - } - if (errno == ECONNRESET) { - - /* - * Turn ECONNRESET into a soft EOF condition. - */ - - return 0; - } - *errorCodePtr = errno; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * TcpOutputProc -- - * - * This procedure is invoked by the generic IO level to write output - * to a TCP socket based channel. - * - * NOTE: We cannot share code with FilePipeOutputProc because here - * we must use send, not write, to get reliable error reporting. - * - * Results: - * The number of bytes written is returned. An output argument is - * set to a POSIX error code if an error occurred, or zero. - * - * Side effects: - * Writes output on the output device of the channel. - * - *---------------------------------------------------------------------- - */ - -static int -TcpOutputProc( - ClientData instanceData, /* Socket state. */ - Tcl_File outFile, /* Output device for channel. */ - char *buf, /* The data buffer. */ - int toWrite, /* How many bytes to write? */ - int *errorCodePtr /* Where to store error code. */ -) -{ - TcpState *statePtr; - int written; - int sock; /* OS level socket. */ - int state; /* Of waiting for connection. */ - - *errorCodePtr = 0; - sock = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - statePtr = (TcpState *) instanceData; - state = WaitForConnect(statePtr, outFile, errorCodePtr); - if (state != 0) { - return -1; - } - written = send(sock, buf, toWrite, 0); - if (written > -1) { - return written; - } - *errorCodePtr = errno; - return -1; -} - -/* - *---------------------------------------------------------------------- - * - * TcpCloseProc -- - * - * This procedure is invoked by the generic IO level to perform - * channel-type-specific cleanup when a TCP socket based channel - * is closed. - * - * Results: - * 0 if successful, the value of errno if failed. - * - * Side effects: - * Closes the socket of the channel. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static int -TcpCloseProc( - ClientData instanceData, /* The socket to close. */ - Tcl_Interp *interp, /* For error reporting - unused. */ - Tcl_File inFile, Tcl_File outFile /* Unused. */ -) -{ - TcpState *statePtr; - Tcl_File sockFile; - int sock; - int errorCode = 0; - - statePtr = (TcpState *) instanceData; - sockFile = statePtr->sock; - sock = (int) (intptr_t) Tcl_GetFileInfo(sockFile, NULL); - - /* - * Delete a file handler that may be active for this socket if this - * is a server socket - the file handler was created automatically - * by Tcl as part of the mechanism to accept new client connections. - * Channel handlers are already deleted in the generic IO channel - * closing code that called this function, so we do not have to - * delete them here. - */ - - Tcl_DeleteFileHandler(sockFile); - - ckfree((char *) statePtr); - - /* - * We assume that inFile==outFile==sockFile and so - * we only clean up sockFile. - */ - - Tcl_FreeFile(sockFile); - - if (close(sock) < 0) { - errorCode = errno; - } - - return errorCode; -} - -/* - *---------------------------------------------------------------------- - * - * TcpGetOptionProc -- - * - * Computes an option value for a TCP socket based channel, or a - * list of all options and their values. - * - * Note: This code is based on code contributed by John Haxby. - * - * Results: - * A standard Tcl result. The value of the specified option or a - * list of all options and their values is returned in the - * supplied DString. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static int -TcpGetOptionProc( - ClientData instanceData, /* Socket state. */ - char *optionName, /* Name of the option to - * retrieve the value for, or - * NULL to get all options and - * their values. */ - Tcl_DString *dsPtr /* Where to store the computed - * value; initialized by caller. */ -) -{ - TcpState *statePtr; - struct sockaddr_in sockname; - struct sockaddr_in peername; - struct hostent *hostEntPtr; - int sock; - int size = sizeof(struct sockaddr_in); - size_t len = 0; - char buf[128]; - - statePtr = (TcpState *) instanceData; - sock = (int) (intptr_t) Tcl_GetFileInfo(statePtr->sock, NULL); - if (optionName != (char *) NULL) { - len = strlen(optionName); - } - - if ((len == 0) || - ((len > 1) && (optionName[1] == 'p') && - (strncmp(optionName, "-peername", len) == 0))) { - if (getpeername(sock, (struct sockaddr *) &peername, &size) >= 0) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-peername"); - Tcl_DStringStartSublist(dsPtr); - } - Tcl_DStringAppendElement(dsPtr, inet_ntoa(peername.sin_addr)); - hostEntPtr = gethostbyaddr((char *) &(peername.sin_addr), - sizeof(peername.sin_addr), AF_INET); - if (hostEntPtr != (struct hostent *) NULL) { - Tcl_DStringAppendElement(dsPtr, hostEntPtr->h_name); - } else { - Tcl_DStringAppendElement(dsPtr, inet_ntoa(peername.sin_addr)); - } - sprintf(buf, "%d", ntohs(peername.sin_port)); - Tcl_DStringAppendElement(dsPtr, buf); - if (len == 0) { - Tcl_DStringEndSublist(dsPtr); - } else { - return TCL_OK; - } - } - } - - if ((len == 0) || - ((len > 1) && (optionName[1] == 's') && - (strncmp(optionName, "-sockname", len) == 0))) { - if (getsockname(sock, (struct sockaddr *) &sockname, &size) >= 0) { - if (len == 0) { - Tcl_DStringAppendElement(dsPtr, "-sockname"); - Tcl_DStringStartSublist(dsPtr); - } - Tcl_DStringAppendElement(dsPtr, inet_ntoa(sockname.sin_addr)); - hostEntPtr = gethostbyaddr((char *) &(sockname.sin_addr), - sizeof(peername.sin_addr), AF_INET); - if (hostEntPtr != (struct hostent *) NULL) { - Tcl_DStringAppendElement(dsPtr, hostEntPtr->h_name); - } else { - Tcl_DStringAppendElement(dsPtr, inet_ntoa(sockname.sin_addr)); - } - sprintf(buf, "%d", ntohs(sockname.sin_port)); - Tcl_DStringAppendElement(dsPtr, buf); - if (len == 0) { - Tcl_DStringEndSublist(dsPtr); - } else { - return TCL_OK; - } - } - } - - if (len > 0) { - Tcl_SetErrno(EINVAL); - return TCL_ERROR; - } - - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * CreateSocket -- - * - * This function opens a new socket in client or server mode - * and initializes the TcpState structure. - * - * Results: - * Returns a new TcpState, or NULL with an error in interp->result, - * if interp is not NULL. - * - * Side effects: - * Opens a socket. - * - *---------------------------------------------------------------------- - */ - -static TcpState * -CreateSocket( - Tcl_Interp *interp, /* For error reporting; can be NULL. */ - int port, /* Port number to open. */ - char *host, /* Name of host on which to open port. - * NULL implies INADDR_ANY */ - int server, /* 1 if socket should be a server socket, - * else 0 for a client socket. */ - char *myaddr, /* Optional client-side address */ - int myport, /* Optional client-side port */ - int async /* If nonzero and creating a client socket, - * attempt to do an async connect. Otherwise - * do a synchronous connect or bind. */ -) -{ - int status, sock, asyncConnect, curState, origState; - struct sockaddr_in sockaddr; /* socket address */ - struct sockaddr_in mysockaddr; /* Socket address for client */ - TcpState *statePtr; - - sock = -1; - origState = 0; - if (! CreateSocketAddress(&sockaddr, host, port)) { - goto addressError; - } - if ((myaddr != NULL || myport != 0) && - ! CreateSocketAddress(&mysockaddr, myaddr, myport)) { - goto addressError; - } - - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) { - goto addressError; - } - - /* - * Set kernel space buffering - */ - - TclSockMinimumBuffers(sock, SOCKET_BUFSIZE); - - asyncConnect = 0; - status = 0; - if (server) { - - /* - * Set up to reuse server addresses automatically and bind to the - * specified port. - */ - - status = 1; - (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &status, - sizeof(status)); - status = bind(sock, (struct sockaddr *) &sockaddr, - sizeof(struct sockaddr)); - if (status != -1) { - status = listen(sock, 5); - } - } else { - if (myaddr != NULL || myport != 0) { - status = 1; - (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &status, - sizeof(status)); - status = bind(sock, (struct sockaddr *) &mysockaddr, - sizeof(struct sockaddr)); - if (status < 0) { - goto bindError; - } - } - - /* - * Attempt to connect. The connect may fail at present with an - * EINPROGRESS but at a later time it will complete. The caller - * will set up a file handler on the socket if she is interested in - * being informed when the connect completes. - */ - - if (async) { - origState = fcntl(sock, F_GETFL); - curState = origState | O_NONBLOCK; - status = fcntl(sock, F_SETFL, curState); - } else { - status = 0; - } - if (status > -1) { - status = connect(sock, (struct sockaddr *) &sockaddr, - sizeof(sockaddr)); - if (status < 0) { - if (errno == EINPROGRESS) { - asyncConnect = 1; - status = 0; - } - } - } - } - -bindError: - if (status < 0) { - if (interp != NULL) { - Tcl_AppendResult(interp, "couldn't open socket: ", - Tcl_PosixError(interp), (char *) NULL); - } - if (sock != -1) { - close(sock); - } - return NULL; - } - - /* - * Allocate a new TcpState for this socket. - */ - - statePtr = (TcpState *) ckalloc((unsigned) sizeof(TcpState)); - statePtr->flags = 0; - if (asyncConnect) { - statePtr->flags = TCP_ASYNC_CONNECT; - } - statePtr->sock = Tcl_GetFile((ClientData) (intptr_t) sock, TCL_UNIX_FD); - - return statePtr; - -addressError: - if (sock != -1) { - close(sock); - } - if (interp != NULL) { - Tcl_AppendResult(interp, "couldn't open socket: ", - Tcl_PosixError(interp), (char *) NULL); - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * CreateSocketAddress -- - * - * This function initializes a sockaddr structure for a host and port. - * - * Results: - * 1 if the host was valid, 0 if the host could not be converted to - * an IP address. - * - * Side effects: - * Fills in the *sockaddrPtr structure. - * - *---------------------------------------------------------------------- - */ - -static int -CreateSocketAddress( - struct sockaddr_in *sockaddrPtr, /* Socket address */ - char *host, /* Host. NULL implies INADDR_ANY */ - int port /* Port number */ -) -{ - struct hostent *hostent; /* Host database entry */ - struct in_addr addr; /* For 64/32 bit madness */ - - (void) memset((VOID *) sockaddrPtr, '\0', sizeof(struct sockaddr_in)); - sockaddrPtr->sin_family = AF_INET; - sockaddrPtr->sin_port = htons((unsigned short) (port & 0xFFFF)); - if (host == NULL) { - addr.s_addr = INADDR_ANY; - } else { - addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { - hostent = gethostbyname(host); - if (hostent != NULL) { - memcpy((VOID *) &addr, - (VOID *) hostent->h_addr_list[0], - (size_t) hostent->h_length); - } else { -#ifdef EHOSTUNREACH - errno = EHOSTUNREACH; -#else -#ifdef ENXIO - errno = ENXIO; -#endif -#endif - return 0; /* error */ - } - } - } - - /* - * NOTE: On 64 bit machines the assignment below is rumored to not - * do the right thing. Please report errors related to this if you - * observe incorrect behavior on 64 bit machines such as DEC Alphas. - * Should we modify this code to do an explicit memcpy? - */ - - sockaddrPtr->sin_addr.s_addr = addr.s_addr; - return 1; /* Success. */ -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_OpenTcpClient -- - * - * Opens a TCP client socket and creates a channel around it. - * - * Results: - * The channel or NULL if failed. An error message is returned - * in the interpreter on failure. - * - * Side effects: - * Opens a client socket and creates a new channel. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_OpenTcpClient( - Tcl_Interp *interp, /* For error reporting; can be NULL. */ - int port, /* Port number to open. */ - char *host, /* Host on which to open port. */ - char *myaddr, /* Client-side address */ - int myport, /* Client-side port */ - int async /* If nonzero, attempt to do an - * asynchronous connect. Otherwise - * we do a blocking connect. */ -) -{ - Tcl_Channel chan; - TcpState *statePtr; - char channelName[20]; - - /* - * Create a new client socket and wrap it in a channel. - */ - - statePtr = CreateSocket(interp, port, host, 0, myaddr, myport, async); - if (statePtr == NULL) { - return NULL; - } - - statePtr->acceptProc = NULL; - statePtr->acceptProcData = (ClientData) NULL; - - sprintf(channelName, "sock%d", - (int) (intptr_t) Tcl_GetFileInfo(statePtr->sock, NULL)); - - chan = Tcl_CreateChannel(&tcpChannelType, channelName, statePtr->sock, - statePtr->sock, (ClientData) statePtr); - if (Tcl_SetChannelOption(interp, chan, "-translation", "auto crlf") == - TCL_ERROR) { - Tcl_Close((Tcl_Interp *) NULL, chan); - return NULL; - } - return chan; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_MakeTcpClientChannel -- - * - * Creates a Tcl_Channel from an existing client TCP socket. - * - * Results: - * The Tcl_Channel wrapped around the preexisting TCP socket. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_MakeTcpClientChannel( - ClientData sock /* The socket to wrap up into a channel. */ -) -{ - TcpState *statePtr; - Tcl_File sockFile; - char channelName[20]; - Tcl_Channel chan; - - sockFile = Tcl_GetFile(sock, TCL_UNIX_FD); - statePtr = (TcpState *) ckalloc((unsigned) sizeof(TcpState)); - statePtr->sock = sockFile; - statePtr->acceptProc = NULL; - statePtr->acceptProcData = (ClientData) NULL; - - sprintf(channelName, "sock%d", (int) (intptr_t) sock); - - chan = Tcl_CreateChannel(&tcpChannelType, channelName, sockFile, sockFile, - (ClientData) statePtr); - if (Tcl_SetChannelOption((Tcl_Interp *) NULL, chan, "-translation", - "auto crlf") == TCL_ERROR) { - Tcl_Close((Tcl_Interp *) NULL, chan); - return NULL; - } - return chan; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_OpenTcpServer -- - * - * Opens a TCP server socket and creates a channel around it. - * - * Results: - * The channel or NULL if failed. If an error occurred, an - * error message is left in interp->result if interp is - * not NULL. - * - * Side effects: - * Opens a server socket and creates a new channel. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -Tcl_OpenTcpServer( - Tcl_Interp *interp, /* For error reporting - may be - * NULL. */ - int port, /* Port number to open. */ - char *myHost, /* Name of local host. */ - Tcl_TcpAcceptProc *acceptProc, /* Callback for accepting connections - * from new clients. */ - ClientData acceptProcData /* Data for the callback. */ -) -{ - Tcl_Channel chan; - TcpState *statePtr; - char channelName[20]; - - /* - * Create a new client socket and wrap it in a channel. - */ - - statePtr = CreateSocket(interp, port, myHost, 1, NULL, 0, 0); - if (statePtr == NULL) { - return NULL; - } - - statePtr->acceptProc = acceptProc; - statePtr->acceptProcData = acceptProcData; - - /* - * Set up the callback mechanism for accepting connections - * from new clients. - */ - - Tcl_CreateFileHandler(statePtr->sock, TCL_READABLE, TcpAccept, - (ClientData) statePtr); - sprintf(channelName, "sock%d", - (int) (intptr_t) Tcl_GetFileInfo(statePtr->sock, NULL)); - chan = Tcl_CreateChannel(&tcpChannelType, channelName, NULL, NULL, - (ClientData) statePtr); - return chan; -} - -/* - *---------------------------------------------------------------------- - * - * TcpAccept -- - * Accept a TCP socket connection. This is called by the event loop. - * - * Results: - * None. - * - * Side effects: - * Creates a new connection socket. Calls the registered callback - * for the connection acceptance mechanism. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -TcpAccept( - ClientData data, /* Callback token. */ - int mask /* Not used. */ -) -{ - TcpState *sockState; /* Client data of server socket. */ - int newsock; /* The new client socket */ - Tcl_File newFile; /* Its file. */ - TcpState *newSockState; /* State for new socket. */ - struct sockaddr_in addr; /* The remote address */ - int len; /* For accept interface */ - Tcl_Channel chan; /* Channel instance created. */ - char channelName[20]; - - sockState = (TcpState *) data; - - len = sizeof(struct sockaddr_in); - newsock = accept((int) (intptr_t) Tcl_GetFileInfo(sockState->sock, NULL), - (struct sockaddr *)&addr, &len); - if (newsock < 0) { - return; - } - - newFile = Tcl_GetFile((ClientData) (intptr_t) newsock, TCL_UNIX_FD); - if (newFile) { - newSockState = (TcpState *) ckalloc((unsigned) sizeof(TcpState)); - - newSockState->flags = 0; - newSockState->sock = newFile; - newSockState->acceptProc = (Tcl_TcpAcceptProc *) NULL; - newSockState->acceptProcData = (ClientData) NULL; - - sprintf(channelName, "sock%d", (int) newsock); - chan = Tcl_CreateChannel(&tcpChannelType, channelName, newFile, - newFile, (ClientData) newSockState); - if (chan == (Tcl_Channel) NULL) { - ckfree((char *) newSockState); - close(newsock); - Tcl_FreeFile(newFile); - } else { - if (Tcl_SetChannelOption((Tcl_Interp *) NULL, chan, "-translation", - "auto crlf") == TCL_ERROR) { - Tcl_Close((Tcl_Interp *) NULL, chan); - } - if (sockState->acceptProc != (Tcl_TcpAcceptProc *) NULL) { - (sockState->acceptProc) (sockState->acceptProcData, chan, - inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)); - } - } - } -} - -/* - *---------------------------------------------------------------------- - * - * TclGetDefaultStdChannel -- - * - * Creates channels for standard input, standard output or standard - * error output if they do not already exist. - * - * Results: - * Returns the specified default standard channel, or NULL. - * - * Side effects: - * May cause the creation of a standard channel and the underlying - * file. - * - *---------------------------------------------------------------------- - */ - -Tcl_Channel -TclGetDefaultStdChannel( - int type /* One of TCL_STDIN, TCL_STDOUT, TCL_STDERR. */ -) -{ - Tcl_Channel channel = NULL; - int fd = 0; /* Initializations needed to prevent */ - int mode = 0; /* compiler warning (used before set). */ - char *bufMode = NULL; - - /* - * If the channels were not created yet, create them now and - * store them in the static variables. - */ - - switch (type) { - case TCL_STDIN: - fd = 0; - mode = TCL_READABLE; - bufMode = "line"; - break; - case TCL_STDOUT: - fd = 1; - mode = TCL_WRITABLE; - bufMode = "line"; - break; - case TCL_STDERR: - fd = 2; - mode = TCL_WRITABLE; - bufMode = "none"; - break; - default: - panic("TclGetDefaultStdChannel: Unexpected channel type"); - break; - } - - channel = Tcl_MakeFileChannel((ClientData) (intptr_t) fd, (ClientData) (intptr_t) fd, mode); - - /* - * Set up the normal channel options for stdio handles. - */ - - if (Tcl_SetChannelOption(NULL, channel, "-translation", "auto") == - TCL_ERROR) { - Tcl_Close((Tcl_Interp *) NULL, channel); - return NULL; - } - if (Tcl_SetChannelOption(NULL, channel, "-buffering", bufMode) == - TCL_ERROR) { - Tcl_Close((Tcl_Interp *) NULL, channel); - return NULL; - } - return channel; -} - -/* - *---------------------------------------------------------------------- - * - * TclClosePipeFile -- - * - * This function is a simple wrapper for close on a file or - * pipe handle. Called in the generic command pipeline cleanup - * code to do platform specific closing of the files associated - * with the command channel. - * - * Results: - * None. - * - * Side effects: - * Closes the fd and frees the Tcl_File. - * - *---------------------------------------------------------------------- - */ - -void -TclClosePipeFile( - Tcl_File file -) -{ - int fd = (int) (intptr_t) Tcl_GetFileInfo(file, NULL); - close(fd); - Tcl_FreeFile(file); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetOpenFile -- - * - * Given a name of a channel registered in the given interpreter, - * returns a FILE * for it. - * - * Results: - * A standard Tcl result. If the channel is registered in the given - * interpreter and it is managed by the "file" channel driver, and - * it is open for the requested mode, then the output parameter - * filePtr is set to a FILE * for the underlying file. On error, the - * filePtr is not set, TCL_ERROR is returned and an error message is - * left in interp->result. - * - * Side effects: - * May invoke fdopen to create the FILE * for the requested file. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_GetOpenFile( - Tcl_Interp *interp, /* Interpreter in which to find file. */ - char *string, /* String that identifies file. */ - int forWriting, /* 1 means the file is going to be used - * for writing, 0 means for reading. */ - int checkUsage, /* 1 means verify that the file was opened - * in a mode that allows the access specified - * by "forWriting". Ignored, we always - * check that the channel is open for the - * requested mode. */ - ClientData *filePtr /* Store pointer to FILE structure here. */ -) -{ - Tcl_Channel chan; - int chanMode; - Tcl_ChannelType *chanTypePtr; - Tcl_File tf; - int fd; - FILE *f; - - chan = Tcl_GetChannel(interp, string, &chanMode); - if (chan == (Tcl_Channel) NULL) { - return TCL_ERROR; - } - if ((forWriting) && ((chanMode & TCL_WRITABLE) == 0)) { - Tcl_AppendResult(interp, - "\"", string, "\" wasn't opened for writing", (char *) NULL); - return TCL_ERROR; - } else if ((!(forWriting)) && ((chanMode & TCL_READABLE) == 0)) { - Tcl_AppendResult(interp, - "\"", string, "\" wasn't opened for reading", (char *) NULL); - return TCL_ERROR; - } - - /* - * We allow creating a FILE * out of file based, pipe based and socket - * based channels. We currently do not allow any other channel types, - * because it is likely that stdio will not know what to do with them. - */ - - chanTypePtr = Tcl_GetChannelType(chan); - if ((chanTypePtr == &fileChannelType) || (chanTypePtr == &pipeChannelType) - || (chanTypePtr == &tcpChannelType)) { - tf = Tcl_GetChannelFile(chan, - (forWriting ? TCL_WRITABLE : TCL_READABLE)); - fd = (int) (intptr_t) Tcl_GetFileInfo(tf, NULL); - - /* - * The call to fdopen below is probably dangerous, since it will - * truncate an existing file if the file is being opened - * for writing.... - */ - - f = fdopen(fd, (forWriting ? "w" : "r")); - if (f == NULL) { - Tcl_AppendResult(interp, "cannot get a FILE * for \"", string, - "\"", (char *) NULL); - return TCL_ERROR; - } - *filePtr = (ClientData) f; - return TCL_OK; - } - - Tcl_AppendResult(interp, "\"", string, - "\" cannot be used to get a FILE * - unsupported type", - (char *) NULL); - return TCL_ERROR; -} diff --git a/cde/programs/dtdocbook/tcl/tclUnixFile.c b/cde/programs/dtdocbook/tcl/tclUnixFile.c deleted file mode 100644 index 37f8e4d8f..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixFile.c +++ /dev/null @@ -1,799 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixFile.c /main/3 1996/10/03 17:18:17 drk $ */ -/* - * tclUnixFile.c -- - * - * This file contains wrappers around UNIX file handling functions. - * These wrappers mask differences between Windows and UNIX. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixFile.c 1.38 96/04/18 08:43:51 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The variable below caches the name of the current working directory - * in order to avoid repeated calls to getcwd. The string is malloc-ed. - * NULL means the cache needs to be refreshed. - */ - -static char *currentDir = NULL; -static int currentDirExitHandlerSet = 0; - -/* - * The variable below is set if the exit routine for deleting the string - * containing the executable name has been registered. - */ - -static int executableNameExitHandlerSet = 0; - -extern pid_t waitpid _ANSI_ARGS_((pid_t pid, int *stat_loc, int options)); - -/* - * Static routines for this file: - */ - -static void FreeCurrentDir _ANSI_ARGS_((ClientData clientData)); -static void FreeExecutableName _ANSI_ARGS_((ClientData clientData)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_WaitPid -- - * - * Implements the waitpid system call on Unix systems. - * - * Results: - * Result of calling waitpid. - * - * Side effects: - * Waits for a process to terminate. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_WaitPid( - pid_t pid, - int *statPtr, - int options -) -{ - int result; - pid_t real_pid; - - real_pid = (pid_t) pid; - while (1) { - result = (int) waitpid(real_pid, statPtr, options); - if ((result != -1) || (errno != EINTR)) { - return result; - } - } -} - -/* - *---------------------------------------------------------------------- - * - * FreeCurrentDir -- - * - * Frees the string stored in the currentDir variable. This routine - * is registered as an exit handler and will be called during shutdown. - * - * Results: - * None. - * - * Side effects: - * Frees the memory occuppied by the currentDir value. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -FreeCurrentDir( - ClientData clientData /* Not used. */ -) -{ - if (currentDir != (char *) NULL) { - ckfree(currentDir); - currentDir = (char *) NULL; - } -} - -/* - *---------------------------------------------------------------------- - * - * FreeExecutableName -- - * - * Frees the string stored in the tclExecutableName variable. This - * routine is registered as an exit handler and will be called - * during shutdown. - * - * Results: - * None. - * - * Side effects: - * Frees the memory occuppied by the tclExecutableName value. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -static void -FreeExecutableName( - ClientData clientData /* Not used. */ -) -{ - if (tclExecutableName != (char *) NULL) { - ckfree(tclExecutableName); - tclExecutableName = (char *) NULL; - } -} - -/* - *---------------------------------------------------------------------- - * - * TclChdir -- - * - * Change the current working directory. - * - * Results: - * The result is a standard Tcl result. If an error occurs and - * interp isn't NULL, an error message is left in interp->result. - * - * Side effects: - * The working directory for this application is changed. Also - * the cache maintained used by TclGetCwd is deallocated and - * set to NULL. - * - *---------------------------------------------------------------------- - */ - -int -TclChdir( - Tcl_Interp *interp, /* If non NULL, used for error reporting. */ - char *dirName /* Path to new working directory. */ -) -{ - if (currentDir != NULL) { - ckfree(currentDir); - currentDir = NULL; - } - if (chdir(dirName) != 0) { - if (interp != NULL) { - Tcl_AppendResult(interp, "couldn't change working directory to \"", - dirName, "\": ", Tcl_PosixError(interp), (char *) NULL); - } - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetCwd -- - * - * Return the path name of the current working directory. - * - * Results: - * The result is the full path name of the current working - * directory, or NULL if an error occurred while figuring it out. - * The returned string is owned by the TclGetCwd routine and must - * not be freed by the caller. If an error occurs and interp - * isn't NULL, an error message is left in interp->result. - * - * Side effects: - * The path name is cached to avoid having to recompute it - * on future calls; if it is already cached, the cached - * value is returned. - * - *---------------------------------------------------------------------- - */ - -char * -TclGetCwd( - Tcl_Interp *interp /* If non NULL, used for error reporting. */ -) -{ - char buffer[MAXPATHLEN+1]; - - if (currentDir == NULL) { - if (!currentDirExitHandlerSet) { - currentDirExitHandlerSet = 1; - Tcl_CreateExitHandler(FreeCurrentDir, (ClientData) NULL); - } - if (getcwd(buffer, MAXPATHLEN+1) == NULL) { - if (interp != NULL) { - if (errno == ERANGE) { - interp->result = "working directory name is too long"; - } else { - Tcl_AppendResult(interp, - "error getting working directory name: ", - Tcl_PosixError(interp), (char *) NULL); - } - } - return NULL; - } - currentDir = (char *) ckalloc((unsigned) (strlen(buffer) + 1)); - strcpy(currentDir, buffer); - } - return currentDir; -} - -/* - *---------------------------------------------------------------------- - * - * TclOpenFile -- - * - * Implements a mechanism to open files on Unix systems. - * - * Results: - * The opened file. - * - * Side effects: - * May cause a file to be created on the file system. - * - *---------------------------------------------------------------------- - */ - -Tcl_File -TclOpenFile( - char *fname, /* The name of the file to open. */ - int mode /* In what mode to open the file? */ -) -{ - int fd; - - fd = open(fname, mode, 0600); - if (fd != -1) { - fcntl(fd, F_SETFD, FD_CLOEXEC); - return Tcl_GetFile((ClientData) (intptr_t) fd, TCL_UNIX_FD); - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * TclCloseFile -- - * - * Implements a mechanism to close a UNIX file. - * - * Results: - * Returns 0 on success, or -1 on error, setting errno. - * - * Side effects: - * The file is closed. - * - *---------------------------------------------------------------------- - */ - -int -TclCloseFile( - Tcl_File file /* The file to close. */ -) -{ - int type; - int fd; - int result; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - if (type != TCL_UNIX_FD) { - panic("Tcl_CloseFile: unexpected file type"); - } - - /* - * Refuse to close the fds for stdin, stdout and stderr. - */ - - if ((fd == 0) || (fd == 1) || (fd == 2)) { - return 0; - } - - result = close(fd); - Tcl_DeleteFileHandler(file); - Tcl_FreeFile(file); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * TclReadFile -- - * - * Implements a mechanism to read from files on Unix systems. Also - * simulates blocking behavior on non-blocking files when asked to. - * - * Results: - * The number of characters read from the specified file. - * - * Side effects: - * May consume characters from the file. - * - *---------------------------------------------------------------------- - */ - /* ARGSUSED */ -int -TclReadFile( - Tcl_File file, /* The file to read from. */ - int shouldBlock, /* Not used. */ - char *buf, /* The buffer to store input in. */ - int toRead /* Number of characters to read. */ -) -{ - int type, fd; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - if (type != TCL_UNIX_FD) { - panic("Tcl_ReadFile: unexpected file type"); - } - - return read(fd, buf, (size_t) toRead); -} - -/* - *---------------------------------------------------------------------- - * - * TclWriteFile -- - * - * Implements a mechanism to write to files on Unix systems. - * - * Results: - * The number of characters written to the specified file. - * - * Side effects: - * May produce characters on the file. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -TclWriteFile( - Tcl_File file, /* The file to write to. */ - int shouldBlock, /* Not used. */ - char *buf, /* Where output is stored. */ - int toWrite /* Number of characters to write. */ -) -{ - int type, fd; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - if (type != TCL_UNIX_FD) { - panic("Tcl_WriteFile: unexpected file type"); - } - return write(fd, buf, (size_t) toWrite); -} - -/* - *---------------------------------------------------------------------- - * - * TclSeekFile -- - * - * Sets the file pointer on the indicated UNIX file. - * - * Results: - * The new position at which the file will be accessed, or -1 on - * failure. - * - * Side effects: - * May change the position at which subsequent operations access the - * file designated by the file. - * - *---------------------------------------------------------------------- - */ - -int -TclSeekFile( - Tcl_File file, /* The file to seek on. */ - int offset, /* How far to seek? */ - int whence /* And from where to seek? */ -) -{ - int type, fd; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - if (type != TCL_UNIX_FD) { - panic("Tcl_SeekFile: unexpected file type"); - } - - return lseek(fd, offset, whence); -} - -/* - *---------------------------------------------------------------------- - * - * TclCreateTempFile -- - * - * This function creates a temporary file initialized with an - * optional string, and returns a file handle with the file pointer - * at the beginning of the file. - * - * Results: - * A handle to a file. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tcl_File -TclCreateTempFile( - char *contents /* String to write into temp file, or NULL. */ -) -{ - char fileName[L_tmpnam]; - Tcl_File file; - size_t length = (contents == NULL) ? 0 : strlen(contents); - - tmpnam(fileName); - file = TclOpenFile(fileName, O_RDWR|O_CREAT|O_TRUNC); - unlink(fileName); - - if ((file != NULL) && (length > 0)) { - int fd = (int) (intptr_t) Tcl_GetFileInfo(file, NULL); - while (1) { - if (write(fd, contents, length) != -1) { - break; - } else if (errno != EINTR) { - close(fd); - Tcl_FreeFile(file); - return NULL; - } - } - lseek(fd, 0, SEEK_SET); - } - return file; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FindExecutable -- - * - * This procedure computes the absolute path name of the current - * application, given its argv[0] value. - * - * Results: - * None. - * - * Side effects: - * The variable tclExecutableName gets filled in with the file - * name for the application, if we figured it out. If we couldn't - * figure it out, Tcl_FindExecutable is set to NULL. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_FindExecutable( - char *argv0 /* The value of the application's argv[0]. */ -) -{ - char *name, *p, *cwd; - Tcl_DString buffer; - int length; - - Tcl_DStringInit(&buffer); - if (tclExecutableName != NULL) { - ckfree(tclExecutableName); - tclExecutableName = NULL; - } - - name = argv0; - for (p = name; *p != 0; p++) { - if (*p == '/') { - /* - * The name contains a slash, so use the name directly - * without doing a path search. - */ - - goto gotName; - } - } - - p = getenv("PATH"); - if (p == NULL) { - /* - * There's no PATH environment variable; use the default that - * is used by sh. - */ - - p = ":/bin:/usr/bin"; - } - - /* - * Search through all the directories named in the PATH variable - * to see if argv[0] is in one of them. If so, use that file - * name. - */ - - while (*p != 0) { - while (isspace(UCHAR(*p))) { - p++; - } - name = p; - while ((*p != ':') && (*p != 0)) { - p++; - } - Tcl_DStringSetLength(&buffer, 0); - if (p != name) { - Tcl_DStringAppend(&buffer, name, p-name); - if (p[-1] != '/') { - Tcl_DStringAppend(&buffer, "/", 1); - } - } - Tcl_DStringAppend(&buffer, argv0, -1); - if (access(Tcl_DStringValue(&buffer), X_OK) == 0) { - name = Tcl_DStringValue(&buffer); - goto gotName; - } - p++; - } - goto done; - - /* - * If the name starts with "/" then just copy it to tclExecutableName. - */ - - gotName: - if (name[0] == '/') { - tclExecutableName = (char *) ckalloc((unsigned) (strlen(name) + 1)); - strcpy(tclExecutableName, name); - goto done; - } - - /* - * The name is relative to the current working directory. First - * strip off a leading "./", if any, then add the full path name of - * the current working directory. - */ - - if ((name[0] == '.') && (name[1] == '/')) { - name += 2; - } - cwd = TclGetCwd((Tcl_Interp *) NULL); - if (cwd == NULL) { - tclExecutableName = NULL; - goto done; - } - length = strlen(cwd); - tclExecutableName = (char *) ckalloc((unsigned) - (length + strlen(name) + 2)); - strcpy(tclExecutableName, cwd); - tclExecutableName[length] = '/'; - strcpy(tclExecutableName + length + 1, name); - - done: - Tcl_DStringFree(&buffer); - - if (!executableNameExitHandlerSet) { - executableNameExitHandlerSet = 1; - Tcl_CreateExitHandler(FreeExecutableName, (ClientData) NULL); - } -} - -/* - *---------------------------------------------------------------------- - * - * TclGetUserHome -- - * - * This function takes the passed in user name and finds the - * corresponding home directory specified in the password file. - * - * Results: - * The result is a pointer to a static string containing - * the new name. If there was an error in processing the - * user name then the return value is NULL. Otherwise the - * result is stored in bufferPtr, and the caller must call - * Tcl_DStringFree(bufferPtr) to free the result. - * - * Side effects: - * Information may be left in bufferPtr. - * - *---------------------------------------------------------------------- - */ - -char * -TclGetUserHome( - char *name, /* User name to use to find home directory. */ - Tcl_DString *bufferPtr /* May be used to hold result. Must not hold - * anything at the time of the call, and need - * not even be initialized. */ -) -{ - struct passwd *pwPtr; - - pwPtr = getpwnam(name); - if (pwPtr == NULL) { - endpwent(); - return NULL; - } - Tcl_DStringInit(bufferPtr); - Tcl_DStringAppend(bufferPtr, pwPtr->pw_dir, -1); - endpwent(); - return bufferPtr->string; -} - -/* - *---------------------------------------------------------------------- - * - * TclMatchFiles -- - * - * This routine is used by the globbing code to search a - * directory for all files which match a given pattern. - * - * Results: - * If the tail argument is NULL, then the matching files are - * added to the interp->result. Otherwise, TclDoGlob is called - * recursively for each matching subdirectory. The return value - * is a standard Tcl result indicating whether an error occurred - * in globbing. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- */ - -int -TclMatchFiles( - Tcl_Interp *interp, /* Interpreter to receive results. */ - char *separators, /* Path separators to pass to TclDoGlob. */ - Tcl_DString *dirPtr, /* Contains path to directory to search. */ - char *pattern, /* Pattern to match against. */ - char *tail /* Pointer to end of pattern. */ -) -{ - char *dirName, *patternEnd = tail; - char savedChar = 0; /* Initialization needed only to prevent - * compiler warning from gcc. */ - DIR *d; - struct stat statBuf; - struct dirent *entryPtr; - int matchHidden; - int result = TCL_OK; - int baseLength = Tcl_DStringLength(dirPtr); - - /* - * Make sure that the directory part of the name really is a - * directory. If the directory name is "", use the name "." - * instead, because some UNIX systems don't treat "" like "." - * automatically. Keep the "" for use in generating file names, - * otherwise "glob foo.c" would return "./foo.c". - */ - - if (dirPtr->string[0] == '\0') { - dirName = "."; - } else { - dirName = dirPtr->string; - } - if ((stat(dirName, &statBuf) != 0) || !S_ISDIR(statBuf.st_mode)) { - return TCL_OK; - } - - /* - * Check to see if the pattern needs to compare with hidden files. - */ - - if ((pattern[0] == '.') - || ((pattern[0] == '\\') && (pattern[1] == '.'))) { - matchHidden = 1; - } else { - matchHidden = 0; - } - - /* - * Now open the directory for reading and iterate over the contents. - */ - - d = opendir(dirName); - if (d == NULL) { - Tcl_ResetResult(interp); - - /* - * Strip off a trailing '/' if necessary, before reporting the error. - */ - - if (baseLength > 0) { - savedChar = dirPtr->string[baseLength-1]; - if (savedChar == '/') { - dirPtr->string[baseLength-1] = '\0'; - } - } - Tcl_AppendResult(interp, "couldn't read directory \"", - dirPtr->string, "\": ", Tcl_PosixError(interp), (char *) NULL); - if (baseLength > 0) { - dirPtr->string[baseLength-1] = savedChar; - } - return TCL_ERROR; - } - - /* - * Clean up the end of the pattern and the tail pointer. Leave - * the tail pointing to the first character after the path separator - * following the pattern, or NULL. Also, ensure that the pattern - * is null-terminated. - */ - - if (*tail == '\\') { - tail++; - } - if (*tail == '\0') { - tail = NULL; - } else { - tail++; - } - savedChar = *patternEnd; - *patternEnd = '\0'; - - while (1) { - entryPtr = readdir(d); - if (entryPtr == NULL) { - break; - } - - /* - * Don't match names starting with "." unless the "." is - * present in the pattern. - */ - - if (!matchHidden && (*entryPtr->d_name == '.')) { - continue; - } - - /* - * Now check to see if the file matches. If there are more - * characters to be processed, then ensure matching files are - * directories before calling TclDoGlob. Otherwise, just add - * the file to the result. - */ - - if (Tcl_StringMatch(entryPtr->d_name, pattern)) { - Tcl_DStringSetLength(dirPtr, baseLength); - Tcl_DStringAppend(dirPtr, entryPtr->d_name, -1); - if (tail == NULL) { - Tcl_AppendElement(interp, dirPtr->string); - } else if ((stat(dirPtr->string, &statBuf) == 0) - && S_ISDIR(statBuf.st_mode)) { - Tcl_DStringAppend(dirPtr, "/", 1); - result = TclDoGlob(interp, separators, dirPtr, tail); - if (result != TCL_OK) { - break; - } - } - } - } - *patternEnd = savedChar; - - closedir(d); - return result; -} diff --git a/cde/programs/dtdocbook/tcl/tclUnixInit.c b/cde/programs/dtdocbook/tcl/tclUnixInit.c deleted file mode 100644 index f32b05602..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixInit.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixInit.c /main/2 1996/08/08 14:46:42 cde-hp $ */ -/* - * tclUnixInit.c -- - * - * Contains the Unix-specific interpreter initialization functions. - * - * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixInit.c 1.10 96/03/12 09:05:59 - */ - -#include "tclInt.h" -#include "tclPort.h" -#ifndef NO_UNAME -# include <sys/utsname.h> -#endif -#if defined(__FreeBSD__) -#include <floatingpoint.h> -#endif - -/* - * Default directory in which to look for libraries: - */ - -static char defaultLibraryDir[200] = TCL_LIBRARY; - -/* - * The following string is the startup script executed in new - * interpreters. It looks on disk in several different directories - * for a script "init.tcl" that is compatible with this version - * of Tcl. The init.tcl script does all of the real work of - * initialization. - */ - -static char *initScript = -"proc init {} {\n\ - global tcl_library tcl_version tcl_patchLevel env\n\ - rename init {}\n\ - set dirs {}\n\ - if [info exists env(TCL_LIBRARY)] {\n\ - lappend dirs $env(TCL_LIBRARY)\n\ - }\n\ - lappend dirs [info library]\n\ - lappend dirs [file dirname [file dirname [info nameofexecutable]]]/lib/tcl$tcl_version\n\ - if [string match {*[ab]*} $tcl_patchLevel] {\n\ - set lib tcl$tcl_patchLevel\n\ - } else {\n\ - set lib tcl$tcl_version\n\ - }\n\ - lappend dirs [file dirname [file dirname [pwd]]]/$lib/library\n\ - lappend dirs [file dirname [pwd]]/library\n\ - foreach i $dirs {\n\ - set tcl_library $i\n\ - if ![catch {uplevel #0 source $i/init.tcl}] {\n\ - return\n\ - }\n\ - }\n\ - set msg \"Can't find a usable init.tcl in the following directories: \n\"\n\ - append msg \" $dirs\n\"\n\ - append msg \"This probably means that Tcl wasn't installed properly.\n\"\n\ - error $msg\n\ -}\n\ -init"; - -/* - *---------------------------------------------------------------------- - * - * TclPlatformInit -- - * - * Performs Unix-specific interpreter initialization related to the - * tcl_library and tcl_platform variables, and other platform- - * specific things. - * - * Results: - * None. - * - * Side effects: - * Sets "tcl_library" and "tcl_platform" Tcl variables. - * - *---------------------------------------------------------------------- - */ - -void -TclPlatformInit( - Tcl_Interp *interp -) -{ -#ifndef NO_UNAME - struct utsname name; -#endif - int unameOK; - static int initialized = 0; - - tclPlatform = TCL_PLATFORM_UNIX; - Tcl_SetVar(interp, "tcl_library", defaultLibraryDir, TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_platform", "platform", "unix", TCL_GLOBAL_ONLY); - unameOK = 0; -#ifndef NO_UNAME - if (uname(&name) >= 0) { - unameOK = 1; - Tcl_SetVar2(interp, "tcl_platform", "os", name.sysname, - TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_platform", "osVersion", name.release, - TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_platform", "machine", name.machine, - TCL_GLOBAL_ONLY); - } -#endif - if (!unameOK) { - Tcl_SetVar2(interp, "tcl_platform", "os", "", TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_platform", "osVersion", "", TCL_GLOBAL_ONLY); - Tcl_SetVar2(interp, "tcl_platform", "machine", "", TCL_GLOBAL_ONLY); - } - - if (!initialized) { - /* - * The code below causes SIGPIPE (broken pipe) errors to - * be ignored. This is needed so that Tcl processes don't - * die if they create child processes (e.g. using "exec" or - * "open") that terminate prematurely. The signal handler - * is only set up when the first interpreter is created; - * after this the application can override the handler with - * a different one of its own, if it wants. - */ - -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif /* SIGPIPE */ - -#ifdef __FreeBSD__ - fpsetround(FP_RN); - fpsetmask(0L); -#endif - initialized = 1; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Init -- - * - * This procedure is typically invoked by Tcl_AppInit procedures - * to perform additional initialization for a Tcl interpreter, - * such as sourcing the "init.tcl" script. - * - * Results: - * Returns a standard Tcl completion code and sets interp->result - * if there is an error. - * - * Side effects: - * Depends on what's in the init.tcl script. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_Init( - Tcl_Interp *interp /* Interpreter to initialize. */ -) -{ - return Tcl_Eval(interp, initScript); -} diff --git a/cde/programs/dtdocbook/tcl/tclUnixNotfy.c b/cde/programs/dtdocbook/tcl/tclUnixNotfy.c deleted file mode 100644 index d587c5733..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixNotfy.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $TOG: tclUnixNotfy.c /main/3 1998/04/06 13:37:34 mgreess $ */ -/* - * tclUnixNotify.c -- - * - * This file contains Unix-specific procedures for the notifier, - * which is the lowest-level part of the Tcl event loop. This file - * works together with ../generic/tclNotify.c. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixNotfy.c 1.30 96/03/22 12:45:31 - */ - -#include "tclInt.h" -#include "tclPort.h" -#include <signal.h> -#include <sys/time.h> - -/* - * The information below is used to provide read, write, and - * exception masks to select during calls to Tcl_DoOneEvent. - */ - -static fd_mask checkMasks[3*MASK_SIZE]; - /* This array is used to build up the masks - * to be used in the next call to select. - * Bits are set in response to calls to - * Tcl_WatchFile. */ -static fd_mask readyMasks[3*MASK_SIZE]; - /* This array reflects the readable/writable - * conditions that were found to exist by the - * last call to select. */ -static int numFdBits; /* Number of valid bits in checkMasks - * (one more than highest fd for which - * Tcl_WatchFile has been called). */ - -/* - * Static routines in this file: - */ - -static int MaskEmpty _ANSI_ARGS_((long *maskPtr)); - -/* - *---------------------------------------------------------------------- - * - * Tcl_WatchFile -- - * - * Arrange for Tcl_DoOneEvent to include this file in the masks - * for the next call to select. This procedure is invoked by - * event sources, which are in turn invoked by Tcl_DoOneEvent - * before it invokes select. - * - * Results: - * None. - * - * Side effects: - * - * The notifier will generate a file event when the I/O channel - * given by fd next becomes ready in the way indicated by mask. - * If fd is already registered then the old mask will be replaced - * with the new one. Once the event is sent, the notifier will - * not send any more events about the fd until the next call to - * Tcl_NotifyFile. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_WatchFile( - Tcl_File file, /* Generic file handle for a stream. */ - int mask /* OR'ed combination of TCL_READABLE, - * TCL_WRITABLE, and TCL_EXCEPTION: - * indicates conditions to wait for - * in select. */ -) -{ - int fd, type, index; - fd_mask bit; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - - if (type != TCL_UNIX_FD) { - panic("Tcl_WatchFile: unexpected file type"); - } - - if (fd >= FD_SETSIZE) { - panic("Tcl_WatchFile can't handle file id %d", fd); - } - - index = fd/(NBBY*sizeof(fd_mask)); - bit = 1 << (fd%(NBBY*sizeof(fd_mask))); - if (mask & TCL_READABLE) { - checkMasks[index] |= bit; - } - if (mask & TCL_WRITABLE) { - (checkMasks+MASK_SIZE)[index] |= bit; - } - if (mask & TCL_EXCEPTION) { - (checkMasks+2*(MASK_SIZE))[index] |= bit; - } - if (numFdBits <= fd) { - numFdBits = fd+1; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_FileReady -- - * - * Indicates what conditions (readable, writable, etc.) were - * present on a file the last time the notifier invoked select. - * This procedure is typically invoked by event sources to see - * if they should queue events. - * - * Results: - * The return value is 0 if none of the conditions specified by mask - * was true for fd the last time the system checked. If any of the - * conditions were true, then the return value is a mask of those - * that were true. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_FileReady( - Tcl_File file, /* Generic file handle for a stream. */ - int mask /* OR'ed combination of TCL_READABLE, - * TCL_WRITABLE, and TCL_EXCEPTION: - * indicates conditions caller cares about. */ -) -{ - int index, result, type, fd; - fd_mask bit; - - fd = (int) (intptr_t) Tcl_GetFileInfo(file, &type); - if (type != TCL_UNIX_FD) { - panic("Tcl_FileReady: unexpected file type"); - } - - index = fd/(NBBY*sizeof(fd_mask)); - bit = 1 << (fd%(NBBY*sizeof(fd_mask))); - result = 0; - if ((mask & TCL_READABLE) && (readyMasks[index] & bit)) { - result |= TCL_READABLE; - } - if ((mask & TCL_WRITABLE) && ((readyMasks+MASK_SIZE)[index] & bit)) { - result |= TCL_WRITABLE; - } - if ((mask & TCL_EXCEPTION) && ((readyMasks+(2*MASK_SIZE))[index] & bit)) { - result |= TCL_EXCEPTION; - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * MaskEmpty -- - * - * Returns nonzero if mask is empty (has no bits set). - * - * Results: - * Nonzero if the mask is empty, zero otherwise. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -static int -MaskEmpty( - long *maskPtr -) -{ - long *runPtr, *tailPtr; - int found, sz; - - sz = 3 * ((MASK_SIZE) / sizeof(long)) * sizeof(fd_mask); - for (runPtr = maskPtr, tailPtr = maskPtr + sz, found = 0; - runPtr < tailPtr; - runPtr++) { - if (*runPtr != 0) { - found = 1; - break; - } - } - return !found; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_WaitForEvent -- - * - * This procedure does the lowest level wait for events in a - * platform-specific manner. It uses information provided by - * previous calls to Tcl_WatchFile, plus the timePtr argument, - * to determine what to wait for and how long to wait. - * - * Results: - * The return value is normally TCL_OK. However, if there are - * no events to wait for (e.g. no files and no timers) so that - * the procedure would block forever, then it returns TCL_ERROR. - * - * Side effects: - * May put the process to sleep for a while, depending on timePtr. - * When this procedure returns, an event of interest to the application - * has probably, but not necessarily, occurred. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_WaitForEvent( - Tcl_Time *timePtr /* Specifies the maximum amount of time - * that this procedure should block before - * returning. The time is given as an - * interval, not an absolute wakeup time. - * NULL means block forever. */ -) -{ - struct timeval timeout, *timeoutPtr; - int numFound; - - memcpy((VOID *) readyMasks, (VOID *) checkMasks, - 3*MASK_SIZE*sizeof(fd_mask)); - if (timePtr == NULL) { - if ((numFdBits == 0) || (MaskEmpty((long *) readyMasks))) { - return TCL_ERROR; - } - timeoutPtr = NULL; - } else { - timeoutPtr = &timeout; - timeout.tv_sec = timePtr->sec; - timeout.tv_usec = timePtr->usec; - } - numFound = select(numFdBits, (SELECT_MASK *) &readyMasks[0], - (SELECT_MASK *) &readyMasks[MASK_SIZE], - (SELECT_MASK *) &readyMasks[2*MASK_SIZE], timeoutPtr); - - /* - * Some systems don't clear the masks after an error, so - * we have to do it here. - */ - - if (numFound == -1) { - memset((VOID *) readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask)); - } - - /* - * Reset the check masks in preparation for the next call to - * select. - */ - - numFdBits = 0; - memset((VOID *) checkMasks, 0, 3*MASK_SIZE*sizeof(fd_mask)); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Sleep -- - * - * Delay execution for the specified number of milliseconds. - * - * Results: - * None. - * - * Side effects: - * Time passes. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_Sleep( - int ms /* Number of milliseconds to sleep. */ -) -{ - static struct timeval delay; - Tcl_Time before, after; - - /* - * The only trick here is that select appears to return early - * under some conditions, so we have to check to make sure that - * the right amount of time really has elapsed. If it's too - * early, go back to sleep again. - */ - - TclGetTime(&before); - after = before; - after.sec += ms/1000; - after.usec += (ms%1000)*1000; - if (after.usec > 1000000) { - after.usec -= 1000000; - after.sec += 1; - } - while (1) { - delay.tv_sec = after.sec - before.sec; - delay.tv_usec = after.usec - before.usec; - if (delay.tv_usec < 0) { - delay.tv_usec += 1000000; - delay.tv_sec -= 1; - } - - /* - * Special note: must convert delay.tv_sec to int before comparing - * to zero, since delay.tv_usec is unsigned on some platforms. - */ - - if ((((int) delay.tv_sec) < 0) - || ((delay.tv_usec == 0) && (delay.tv_sec == 0))) { - break; - } - (void) select(0, (SELECT_MASK *) 0, (SELECT_MASK *) 0, - (SELECT_MASK *) 0, &delay); - TclGetTime(&before); - } -} - diff --git a/cde/programs/dtdocbook/tcl/tclUnixPipe.c b/cde/programs/dtdocbook/tcl/tclUnixPipe.c deleted file mode 100644 index f8fd9344c..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixPipe.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixPipe.c /main/3 1996/10/03 17:18:23 drk $ */ -/* - * tclUnixPipe.c -- This file implements the UNIX-specific exec pipeline - * functions. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixPipe.c 1.29 96/04/18 15:56:26 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * Declarations for local procedures defined in this file: - */ - -static void RestoreSignals _ANSI_ARGS_((void)); -static int SetupStdFile _ANSI_ARGS_((Tcl_File file, int type)); - -/* - *---------------------------------------------------------------------- - * - * RestoreSignals -- - * - * This procedure is invoked in a forked child process just before - * exec-ing a new program to restore all signals to their default - * settings. - * - * Results: - * None. - * - * Side effects: - * Signal settings get changed. - * - *---------------------------------------------------------------------- - */ - -static void -RestoreSignals(void) -{ -#ifdef SIGABRT - signal(SIGABRT, SIG_DFL); -#endif -#ifdef SIGALRM - signal(SIGALRM, SIG_DFL); -#endif -#ifdef SIGFPE - signal(SIGFPE, SIG_DFL); -#endif -#ifdef SIGHUP - signal(SIGHUP, SIG_DFL); -#endif -#ifdef SIGILL - signal(SIGILL, SIG_DFL); -#endif -#ifdef SIGINT - signal(SIGINT, SIG_DFL); -#endif -#ifdef SIGPIPE - signal(SIGPIPE, SIG_DFL); -#endif -#ifdef SIGQUIT - signal(SIGQUIT, SIG_DFL); -#endif -#ifdef SIGSEGV - signal(SIGSEGV, SIG_DFL); -#endif -#ifdef SIGTERM - signal(SIGTERM, SIG_DFL); -#endif -#ifdef SIGUSR1 - signal(SIGUSR1, SIG_DFL); -#endif -#ifdef SIGUSR2 - signal(SIGUSR2, SIG_DFL); -#endif -#ifdef SIGCHLD - signal(SIGCHLD, SIG_DFL); -#endif -#ifdef SIGCONT - signal(SIGCONT, SIG_DFL); -#endif -#ifdef SIGTSTP - signal(SIGTSTP, SIG_DFL); -#endif -#ifdef SIGTTIN - signal(SIGTTIN, SIG_DFL); -#endif -#ifdef SIGTTOU - signal(SIGTTOU, SIG_DFL); -#endif -} - -/* - *---------------------------------------------------------------------- - * - * SetupStdFile -- - * - * Set up stdio file handles for the child process, using the - * current standard channels if no other files are specified. - * If no standard channel is defined, or if no file is associated - * with the channel, then the corresponding standard fd is closed. - * - * Results: - * Returns 1 on success, or 0 on failure. - * - * Side effects: - * Replaces stdio fds. - * - *---------------------------------------------------------------------- - */ - -static int -SetupStdFile( - Tcl_File file, /* File to dup, or NULL. */ - int type /* One of TCL_STDIN, TCL_STDOUT, TCL_STDERR */ -) -{ - Tcl_Channel channel; - int fd; - int targetFd = 0; /* Initializations here needed only to */ - int direction = 0; /* prevent warnings about using uninitialized - * variables. */ - - switch (type) { - case TCL_STDIN: - targetFd = 0; - direction = TCL_READABLE; - break; - case TCL_STDOUT: - targetFd = 1; - direction = TCL_WRITABLE; - break; - case TCL_STDERR: - targetFd = 2; - direction = TCL_WRITABLE; - break; - } - - if (!file) { - channel = Tcl_GetStdChannel(type); - if (channel) { - file = Tcl_GetChannelFile(channel, direction); - } - } - if (file) { - fd = (int) (intptr_t) Tcl_GetFileInfo(file, NULL); - if (fd != targetFd) { - if (dup2(fd, targetFd) == -1) { - return 0; - } - - /* - * Must clear the close-on-exec flag for the target FD, since - * some systems (e.g. Ultrix) do not clear the CLOEXEC flag on - * the target FD. - */ - - fcntl(targetFd, F_SETFD, 0); - } else { - int result; - - /* - * Since we aren't dup'ing the file, we need to explicitly clear - * the close-on-exec flag. - */ - - result = fcntl(fd, F_SETFD, 0); - } - } else { - close(targetFd); - } - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * TclSpawnPipeline -- - * - * Given an argc/argv array, instantiate a pipeline of processes - * as described by the argv. - * - * Results: - * The return value is 1 on success, 0 on error - * - * Side effects: - * Processes and pipes are created. - * - *---------------------------------------------------------------------- - */ -int -TclSpawnPipeline( - Tcl_Interp *interp, /* Interpreter in which to process pipeline. */ - pid_t *pidPtr, /* Array of pids which are created. */ - int *numPids, /* Number of pids created. */ - int argc, /* Number of entries in argv. */ - char **argv, /* Array of strings describing commands in - * pipeline plus I/O redirection with <, - * <<, >, etc. argv[argc] must be NULL. */ - Tcl_File inputFile, /* If >=0, gives file id to use as input for - * first process in pipeline (specified via < - * or <@). */ - Tcl_File outputFile, /* Writable file id for output from last - * command in pipeline (could be file or - * pipe). NULL means use stdout. */ - Tcl_File errorFile, /* Writable file id for error output from all - * commands in the pipeline. NULL means use - * stderr */ - char *intIn, /* File name for initial input (for Win32s). */ - char *finalOut /* File name for final output (for Win32s). */ -) -{ - int firstArg, lastArg; - pid_t pid; - int count; - Tcl_DString buffer; - char *execName; - char errSpace[200]; - Tcl_File pipeIn, errPipeIn, errPipeOut; - int joinThisError; - Tcl_File curOutFile = NULL, curInFile; - - Tcl_DStringInit(&buffer); - pipeIn = errPipeIn = errPipeOut = NULL; - - curInFile = inputFile; - - for (firstArg = 0; firstArg < argc; firstArg = lastArg+1) { - - /* - * Convert the program name into native form. - */ - - Tcl_DStringFree(&buffer); - execName = Tcl_TranslateFileName(interp, argv[firstArg], &buffer); - if (execName == NULL) { - goto error; - } - - /* - * Find the end of the current segment of the pipeline. - */ - - joinThisError = 0; - for (lastArg = firstArg; lastArg < argc; lastArg++) { - if (argv[lastArg][0] == '|') { - if (argv[lastArg][1] == 0) { - break; - } - if ((argv[lastArg][1] == '&') && (argv[lastArg][2] == 0)) { - joinThisError = 1; - break; - } - } - } - argv[lastArg] = NULL; - - /* - * If this is the last segment, use the specified outputFile. - * Otherwise create an intermediate pipe. - */ - - if (lastArg == argc) { - curOutFile = outputFile; - } else { - if (TclCreatePipe(&pipeIn, &curOutFile) == 0) { - Tcl_AppendResult(interp, "couldn't create pipe: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - } - - /* - * Create a pipe that the child can use to return error - * information if anything goes wrong. - */ - - if (TclCreatePipe(&errPipeIn, &errPipeOut) == 0) { - Tcl_AppendResult(interp, "couldn't create pipe: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - - pid = vfork(); - if (pid == 0) { - - /* - * Set up stdio file handles for the child process. - */ - - if (!SetupStdFile(curInFile, TCL_STDIN) - || !SetupStdFile(curOutFile, TCL_STDOUT) - || (!joinThisError && !SetupStdFile(errorFile, TCL_STDERR)) - || (joinThisError && - ((dup2(1,2) == -1) || - (fcntl(2, F_SETFD, 0) != 0)))) { - sprintf(errSpace, - "%dforked process couldn't set up input/output: ", - errno); - TclWriteFile(errPipeOut, 1, errSpace, (int) strlen(errSpace)); - _exit(1); - } - - /* - * Close the input side of the error pipe. - */ - - RestoreSignals(); - execvp(execName, &argv[firstArg]); - sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno, - argv[firstArg]); - TclWriteFile(errPipeOut, 1, errSpace, (int) strlen(errSpace)); - _exit(1); - } - Tcl_DStringFree(&buffer); - if (pid == (pid_t)-1) { - Tcl_AppendResult(interp, "couldn't fork child process: ", - Tcl_PosixError(interp), (char *) NULL); - goto error; - } - - /* - * Add the child process to the list of those to be reaped. - * Note: must do it now, so that the process will be reaped even if - * an error occurs during its startup. - */ - - pidPtr[*numPids] = pid; - (*numPids)++; - - /* - * Read back from the error pipe to see if the child startup - * up OK. The info in the pipe (if any) consists of a decimal - * errno value followed by an error message. - */ - - TclCloseFile(errPipeOut); - errPipeOut = NULL; - - count = TclReadFile(errPipeIn, 1, errSpace, - (size_t) (sizeof(errSpace) - 1)); - if (count > 0) { - char *end; - errSpace[count] = 0; - errno = strtol(errSpace, &end, 10); - Tcl_AppendResult(interp, end, Tcl_PosixError(interp), - (char *) NULL); - goto error; - } - TclCloseFile(errPipeIn); - errPipeIn = NULL; - - /* - * Close off our copies of file descriptors that were set up for - * this child, then set up the input for the next child. - */ - - if (curInFile && (curInFile != inputFile)) { - TclCloseFile(curInFile); - } - curInFile = pipeIn; - pipeIn = NULL; - - if (curOutFile && (curOutFile != outputFile)) { - TclCloseFile(curOutFile); - } - curOutFile = NULL; - } - return 1; - - /* - * An error occurred, so we need to clean up any open pipes. - */ - -error: - Tcl_DStringFree(&buffer); - if (errPipeIn) { - TclCloseFile(errPipeIn); - } - if (errPipeOut) { - TclCloseFile(errPipeOut); - } - if (pipeIn) { - TclCloseFile(pipeIn); - } - if (curOutFile && (curOutFile != outputFile)) { - TclCloseFile(curOutFile); - } - if (curInFile && (curInFile != inputFile)) { - TclCloseFile(curInFile); - } - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * TclCreatePipe -- - * - * Creates a pipe - simply calls the pipe() function. - * - * Results: - * Returns 1 on success, 0 on failure. - * - * Side effects: - * Creates a pipe. - * - *---------------------------------------------------------------------- - */ -int -TclCreatePipe( - Tcl_File *readPipe, /* Location to store file handle for - * read side of pipe. */ - Tcl_File *writePipe /* Location to store file handle for - * write side of pipe. */ -) -{ - int pipeIds[2]; - - if (pipe(pipeIds) != 0) { - return 0; - } - - fcntl(pipeIds[0], F_SETFD, FD_CLOEXEC); - fcntl(pipeIds[1], F_SETFD, FD_CLOEXEC); - - *readPipe = Tcl_GetFile((ClientData) (intptr_t) pipeIds[0], TCL_UNIX_FD); - *writePipe = Tcl_GetFile((ClientData) (intptr_t) pipeIds[1], TCL_UNIX_FD); - return 1; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_CreatePipeline -- - * - * This function is a compatibility wrapper for TclCreatePipeline. - * It is only available under Unix, and may be removed from later - * versions. - * - * Results: - * Same as TclCreatePipeline. - * - * Side effects: - * Same as TclCreatePipeline. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_CreatePipeline( - Tcl_Interp *interp, - int argc, - char **argv, - pid_t **pidArrayPtr, - int *inPipePtr, - int *outPipePtr, - int *errFilePtr -) -{ - Tcl_File inFile, outFile, errFile; - int result; - - result = TclCreatePipeline(interp, argc, argv, pidArrayPtr, - (inPipePtr ? &inFile : NULL), - (outPipePtr ? &outFile : NULL), - (errFilePtr ? &errFile : NULL)); - - if (inPipePtr) { - if (inFile) { - *inPipePtr = (int) (intptr_t) Tcl_GetFileInfo(inFile, NULL); - Tcl_FreeFile(inFile); - } else { - *inPipePtr = -1; - } - } - if (outPipePtr) { - if (outFile) { - *outPipePtr = (int) (intptr_t) Tcl_GetFileInfo(outFile, NULL); - Tcl_FreeFile(outFile); - } else { - *outPipePtr = -1; - } - } - if (errFilePtr) { - if (errFile) { - *errFilePtr = (int) (intptr_t) Tcl_GetFileInfo(errFile, NULL); - Tcl_FreeFile(errFile); - } else { - *errFilePtr = -1; - } - } - return result; -} diff --git a/cde/programs/dtdocbook/tcl/tclUnixPort.h b/cde/programs/dtdocbook/tcl/tclUnixPort.h deleted file mode 100644 index 9405a9aff..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixPort.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixPort.h /main/2 1996/08/08 14:46:57 cde-hp $ */ -/* - * tclUnixPort.h -- - * - * This header file handles porting issues that occur because - * of differences between systems. It reads in UNIX-related - * header files and sets up UNIX-related macros for Tcl's UNIX - * core. It should be the only file that contains #ifdefs to - * handle different flavors of UNIX. This file sets up the - * union of all UNIX-related things needed by any of the Tcl - * core files. This file depends on configuration #defines such - * as NO_DIRENT_H that are set up by the "configure" script. - * - * Much of the material in this file was originally contributed - * by Karl Lehenbauer, Mark Diekhans and Peter da Silva. - * - * Copyright (c) 1991-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixPort.h 1.33 96/03/25 17:15:21 - */ - -#ifndef _TCLUNIXPORT -#define _TCLUNIXPORT - -#ifndef _TCLINT -# include "tclInt.h" -#endif -#include <errno.h> -#include <fcntl.h> -#ifdef HAVE_NET_ERRNO_H -# include <net/errno.h> -#endif -#include <pwd.h> -#include <signal.h> -#include <sys/param.h> -#include <sys/types.h> -#ifdef USE_DIRENT2_H -# include "../compat/dirent2.h" -#else -# ifdef NO_DIRENT_H -# include "../compat/dirent.h" -# else -# include <dirent.h> -# endif -#endif -#include <sys/file.h> -#ifdef HAVE_SYS_SELECT_H -# include <sys/select.h> -#endif -#include <sys/stat.h> -#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif -#ifndef NO_SYS_WAIT_H -# include <sys/wait.h> -#endif -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#else -# include "../compat/unistd.h" -#endif - -/* - * Socket support stuff: This likely needs more work to parameterize for - * each system. - */ - -#include <sys/socket.h> /* struct sockaddr, SOCK_STREAM, ... */ -#include <sys/utsname.h> /* uname system call. */ -#include <netinet/in.h> /* struct in_addr, struct sockaddr_in */ -#include <arpa/inet.h> /* inet_ntoa() */ -#include <netdb.h> /* gethostbyname() */ - -/* - * NeXT doesn't define O_NONBLOCK, so #define it here if necessary. - */ - -#ifndef O_NONBLOCK -# define O_NONBLOCK 0x80 -#endif - -/* - * HPUX needs the flag O_NONBLOCK to get the right non-blocking I/O - * semantics, while most other systems need O_NDELAY. Define the - * constant NBIO_FLAG to be one of these - */ - -#ifdef HPUX -# define NBIO_FLAG O_NONBLOCK -#else -# define NBIO_FLAG O_NDELAY -#endif - -/* - * The default platform eol translation on Unix is TCL_TRANSLATE_LF: - */ - -#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_LF - -/* - * Not all systems declare the errno variable in errno.h. so this - * file does it explicitly. The list of system error messages also - * isn't generally declared in a header file anywhere. - */ - -extern int errno; - -/* - * The type of the status returned by wait varies from UNIX system - * to UNIX system. The macro below defines it: - */ - -#ifdef _AIX -# define WAIT_STATUS_TYPE pid_t -#else -#ifndef NO_UNION_WAIT -# define WAIT_STATUS_TYPE union wait -#else -# define WAIT_STATUS_TYPE int -#endif -#endif - -/* - * Supply definitions for macros to query wait status, if not already - * defined in header files above. - */ - -#ifndef WIFEXITED -# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0) -#endif - -#ifndef WEXITSTATUS -# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff) -#endif - -#ifndef WIFSIGNALED -# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff))) -#endif - -#ifndef WTERMSIG -# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f) -#endif - -#ifndef WIFSTOPPED -# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177) -#endif - -#ifndef WSTOPSIG -# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff) -#endif - -/* - * Define constants for waitpid() system call if they aren't defined - * by a system header file. - */ - -#ifndef WNOHANG -# define WNOHANG 1 -#endif -#ifndef WUNTRACED -# define WUNTRACED 2 -#endif - -/* - * Supply macros for seek offsets, if they're not already provided by - * an include file. - */ - -#ifndef SEEK_SET -# define SEEK_SET 0 -#endif - -#ifndef SEEK_CUR -# define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -# define SEEK_END 2 -#endif - -/* - * The stuff below is needed by the "time" command. If this - * system has no gettimeofday call, then must use times and the - * CLK_TCK #define (from sys/param.h) to compute elapsed time. - * Unfortunately, some systems only have HZ and no CLK_TCK, and - * some might not even have HZ. - */ - -#ifdef NO_GETTOD -# include <sys/times.h> -# include <sys/param.h> -# ifndef CLK_TCK -# ifdef HZ -# define CLK_TCK HZ -# else -# define CLK_TCK 60 -# endif -# endif -#else -# ifdef HAVE_BSDGETTIMEOFDAY -# define gettimeofday BSDgettimeofday -# endif -#endif - -#ifdef GETTOD_NOT_DECLARED -EXTERN int gettimeofday _ANSI_ARGS_((struct timeval *tp, - struct timezone *tzp)); -#endif - -/* - * Define access mode constants if they aren't already defined. - */ - -#ifndef F_OK -# define F_OK 00 -#endif -#ifndef X_OK -# define X_OK 01 -#endif -#ifndef W_OK -# define W_OK 02 -#endif -#ifndef R_OK -# define R_OK 04 -#endif - -/* - * Define FD_CLOEEXEC (the close-on-exec flag bit) if it isn't - * already defined. - */ - -#ifndef FD_CLOEXEC -# define FD_CLOEXEC 1 -#endif - -/* - * On systems without symbolic links (i.e. S_IFLNK isn't defined) - * define "lstat" to use "stat" instead. - */ - -#ifndef S_IFLNK -# define lstat stat -#endif - -/* - * Define macros to query file type bits, if they're not already - * defined. - */ - -#ifndef S_ISREG -# ifdef S_IFREG -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -# else -# define S_ISREG(m) 0 -# endif -# endif -#ifndef S_ISDIR -# ifdef S_IFDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# else -# define S_ISDIR(m) 0 -# endif -# endif -#ifndef S_ISCHR -# ifdef S_IFCHR -# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -# else -# define S_ISCHR(m) 0 -# endif -# endif -#ifndef S_ISBLK -# ifdef S_IFBLK -# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -# else -# define S_ISBLK(m) 0 -# endif -# endif -#ifndef S_ISFIFO -# ifdef S_IFIFO -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -# else -# define S_ISFIFO(m) 0 -# endif -# endif -#ifndef S_ISLNK -# ifdef S_IFLNK -# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -# else -# define S_ISLNK(m) 0 -# endif -# endif -#ifndef S_ISSOCK -# ifdef S_IFSOCK -# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -# else -# define S_ISSOCK(m) 0 -# endif -# endif - -/* - * Make sure that MAXPATHLEN is defined. - */ - -#ifndef MAXPATHLEN -# ifdef PATH_MAX -# define MAXPATHLEN PATH_MAX -# else -# define MAXPATHLEN 2048 -# endif -#endif - -/* - * Make sure that L_tmpnam is defined. - */ - -#ifndef L_tmpnam -# define L_tmpnam 100 -#endif - -/* - * The following macro defines the type of the mask arguments to - * select: - */ - -#ifndef NO_FD_SET -# define SELECT_MASK fd_set -#else -# ifndef _AIX - typedef long fd_mask; -# endif -# if defined(_IBMR2) -# define SELECT_MASK void -# else -# define SELECT_MASK int -# endif -#endif - -/* - * Define "NBBY" (number of bits per byte) if it's not already defined. - */ - -#ifndef NBBY -# define NBBY 8 -#endif - -/* - * The following macro defines the number of fd_masks in an fd_set: - */ - -#ifndef FD_SETSIZE -# ifdef OPEN_MAX -# define FD_SETSIZE OPEN_MAX -# else -# define FD_SETSIZE 256 -# endif -#endif -#if !defined(howmany) -# define howmany(x, y) (((x)+((y)-1))/(y)) -#endif -#ifndef NFDBITS -# define NFDBITS NBBY*sizeof(fd_mask) -#endif -#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) - -/* - * The following function is declared in tclInt.h but doesn't do anything - * on Unix systems. - */ - -#define TclSetSystemEnv(a,b) - -/* - * The following implements the Unix method for exiting the process. - */ -#define TclPlatformExit(status) exit(status) - -/* - * The following functions always succeeds under Unix. - */ - -#define TclHasSockets(interp) (TCL_OK) -#define TclHasPipes() (1) - -/* - * Variables provided by the C library: - */ - -#if defined(_sgi) || defined(__sgi) -#define environ _environ -#endif -extern char **environ; - -/* - * At present (12/91) not all stdlib.h implementations declare strtod. - * The declaration below is here to ensure that it's declared, so that - * the compiler won't take the default approach of assuming it returns - * an int. There's no ANSI prototype for it because there would end - * up being too many conflicts with slightly-different prototypes. - */ - -extern double strtod(); - -#endif /* _TCLUNIXPORT */ diff --git a/cde/programs/dtdocbook/tcl/tclUnixSock.c b/cde/programs/dtdocbook/tcl/tclUnixSock.c deleted file mode 100644 index 606f1ca86..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixSock.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUnixSock.c /main/2 1996/08/08 14:47:01 cde-hp $ */ -/* - * tclUnixSock.c -- - * - * This file contains Unix-specific socket related code. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixSock.c 1.5 96/04/04 15:28:39 - */ - -#include "tcl.h" -#include "tclPort.h" - -/* - * The following variable holds the network name of this host. - */ - -#ifndef SYS_NMLN -# define SYS_NMLN 100 -#endif - -static char hostname[SYS_NMLN + 1]; -static int hostnameInited = 0; - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetHostName -- - * - * Get the network name for this machine, in a system dependent way. - * - * Results: - * A string containing the network name for this machine. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_GetHostName(void) -{ - struct utsname u; - struct hostent *hp; - - if (hostnameInited) { - return hostname; - } - - if (uname(&u) > -1) { - hp = gethostbyname(u.nodename); - if (hp != NULL) { - snprintf(hostname, sizeof(hostname), "%s", hp->h_name); - } else { - snprintf(hostname, sizeof(hostname), "%s", u.nodename); - } - hostnameInited = 1; - return hostname; - } - return (char *) NULL; -} diff --git a/cde/programs/dtdocbook/tcl/tclUnixTime.c b/cde/programs/dtdocbook/tcl/tclUnixTime.c deleted file mode 100644 index 76665d9d3..000000000 --- a/cde/programs/dtdocbook/tcl/tclUnixTime.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $TOG: tclUnixTime.c /main/3 1998/04/06 13:37:56 mgreess $ */ -/* - * tclUnixTime.c -- - * - * Contains Unix specific versions of Tcl functions that - * obtain time values from the operating system. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUnixTime.c 1.10 96/02/15 11:58:41 - */ - -#include <sys/time.h> -#include "tclInt.h" -#include "tclPort.h" - -/* - *----------------------------------------------------------------------------- - * - * TclGetSeconds -- - * - * This procedure returns the number of seconds from the epoch. On - * most Unix systems the epoch is Midnight Jan 1, 1970 GMT. - * - * Results: - * Number of seconds from the epoch. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -unsigned long -TclGetSeconds(void) -{ - return time((time_t *) NULL); -} - -/* - *----------------------------------------------------------------------------- - * - * TclGetClicks -- - * - * This procedure returns a value that represents the highest resolution - * clock available on the system. There are no garantees on what the - * resolution will be. In Tcl we will call this value a "click". The - * start time is also system dependant. - * - * Results: - * Number of clicks from some start time. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -unsigned long -TclGetClicks(void) -{ - unsigned long now; -#ifdef NO_GETTOD - struct tms dummy; -#else - struct timeval date; - struct timezone tz; -#endif - -#ifdef NO_GETTOD - now = (unsigned long) times(&dummy); -#else - gettimeofday(&date, &tz); - now = date.tv_sec*1000000 + date.tv_usec; -#endif - - return now; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetTimeZone -- - * - * Determines the current timezone. The method varies wildly - * between different platform implementations, so its hidden in - * this function. - * - * Results: - * Hours east of GMT. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGetTimeZone ( - unsigned long currentTime -) -{ - /* - * Determine how a timezone is obtained from "struct tm". If there is no - * time zone in this struct (very lame) then use the timezone variable. - * This is done in a way to make the timezone variable the method of last - * resort, as some systems have it in addition to a field in "struct tm". - * The gettimeofday system call can also be used to determine the time - * zone. - */ - -#if defined(HAVE_TM_TZADJ) -# define TCL_GOT_TIMEZONE - time_t curTime = (time_t) currentTime; - struct tm *timeDataPtr = localtime(&curTime); - int timeZone; - - timeZone = timeDataPtr->tm_tzadj / 60; - if (timeDataPtr->tm_isdst) { - timeZone += 60; - } - - return timeZone; -#endif - -#if defined(HAVE_TM_GMTOFF) && !defined (TCL_GOT_TIMEZONE) -# define TCL_GOT_TIMEZONE - time_t curTime = (time_t) currentTime; - struct tm *timeDataPtr = localtime(¤tTime); - int timeZone; - - timeZone = -(timeDataPtr->tm_gmtoff / 60); - if (timeDataPtr->tm_isdst) { - timeZone += 60; - } - - return timeZone; -#endif - - /* - * Must prefer timezone variable over gettimeofday, as gettimeofday does - * not return timezone information on many systems that have moved this - * information outside of the kernel. - */ - -#if defined(HAVE_TIMEZONE_VAR) && !defined (TCL_GOT_TIMEZONE) -# define TCL_GOT_TIMEZONE - static int setTZ = 0; - int timeZone; - - if (!setTZ) { - tzset(); - setTZ = 1; - } - - /* - * Note: this is not a typo in "timezone" below! See tzset - * documentation for details. - */ - - timeZone = timezone / 60; - - return timeZone; -#endif - -#if defined(HAVE_GETTIMEOFDAY) && !defined (TCL_GOT_TIMEZONE) -# define TCL_GOT_TIMEZONE - struct timeval tv; - struct timezone tz; - int timeZone; - - gettimeofday(&tv, &tz); - timeZone = tz.tz_minuteswest; - if (tz.tz_dsttime) { - timeZone += 60; - } - - return timeZone; -#endif - -#ifndef TCL_GOT_TIMEZONE - /* - * Cause compile error, we don't know how to get timezone. - */ - error: autoconf did not figure out how to determine the timezone. -#endif - -} - -/* - *---------------------------------------------------------------------- - * - * TclGetTime -- - * - * Gets the current system time in seconds and microseconds - * since the beginning of the epoch: 00:00 UCT, January 1, 1970. - * - * Results: - * Returns the current time in timePtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TclGetTime( - Tcl_Time *timePtr /* Location to store time information. */ -) -{ - struct timeval tv; - struct timezone tz; - - (void) gettimeofday(&tv, &tz); - timePtr->sec = tv.tv_sec; - timePtr->usec = tv.tv_usec; -} diff --git a/cde/programs/dtdocbook/tcl/tclUtil.c b/cde/programs/dtdocbook/tcl/tclUtil.c deleted file mode 100644 index 8b1401ae7..000000000 --- a/cde/programs/dtdocbook/tcl/tclUtil.c +++ /dev/null @@ -1,2186 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclUtil.c /main/5 1996/08/08 14:47:12 cde-hp $ */ -/* - * tclUtil.c -- - * - * This file contains utility procedures that are used by many Tcl - * commands. - * - * Copyright (c) 1987-1993 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclUtil.c 1.112 96/02/15 11:42:52 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The following values are used in the flags returned by Tcl_ScanElement - * and used by Tcl_ConvertElement. The value TCL_DONT_USE_BRACES is also - * defined in tcl.h; make sure its value doesn't overlap with any of the - * values below. - * - * TCL_DONT_USE_BRACES - 1 means the string mustn't be enclosed in - * braces (e.g. it contains unmatched braces, - * or ends in a backslash character, or user - * just doesn't want braces); handle all - * special characters by adding backslashes. - * USE_BRACES - 1 means the string contains a special - * character that can be handled simply by - * enclosing the entire argument in braces. - * BRACES_UNMATCHED - 1 means that braces aren't properly matched - * in the argument. - */ - -#define USE_BRACES 2 -#define BRACES_UNMATCHED 4 - -/* - * Function prototypes for local procedures in this file: - */ - -static void SetupAppendBuffer _ANSI_ARGS_((Interp *iPtr, - int newSpace)); - -/* - *---------------------------------------------------------------------- - * - * TclFindElement -- - * - * Given a pointer into a Tcl list, locate the first (or next) - * element in the list. - * - * Results: - * The return value is normally TCL_OK, which means that the - * element was successfully located. If TCL_ERROR is returned - * it means that list didn't have proper list structure; - * interp->result contains a more detailed error message. - * - * If TCL_OK is returned, then *elementPtr will be set to point - * to the first element of list, and *nextPtr will be set to point - * to the character just after any white space following the last - * character that's part of the element. If this is the last argument - * in the list, then *nextPtr will point to the NULL character at the - * end of list. If sizePtr is non-NULL, *sizePtr is filled in with - * the number of characters in the element. If the element is in - * braces, then *elementPtr will point to the character after the - * opening brace and *sizePtr will not include either of the braces. - * If there isn't an element in the list, *sizePtr will be zero, and - * both *elementPtr and *termPtr will refer to the null character at - * the end of list. Note: this procedure does NOT collapse backslash - * sequences. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclFindElement( - Tcl_Interp *interp, /* Interpreter to use for error reporting. - * If NULL, then no error message is left - * after errors. */ - char *list, /* String containing Tcl list with zero - * or more elements (possibly in braces). */ - char **elementPtr, /* Fill in with location of first significant - * character in first element of list. */ - char **nextPtr, /* Fill in with location of character just - * after all white space following end of - * argument (i.e. next argument or end of - * list). */ - int *sizePtr, /* If non-zero, fill in with size of - * element. */ - int *bracePtr /* If non-zero fill in with non-zero/zero - * to indicate that arg was/wasn't - * in braces. */ -) -{ - char *p; - int openBraces = 0; - int inQuotes = 0; - int size; - - /* - * Skim off leading white space and check for an opening brace or - * quote. Note: use of "isascii" below and elsewhere in this - * procedure is a temporary hack (7/27/90) because Mx uses characters - * with the high-order bit set for some things. This should probably - * be changed back eventually, or all of Tcl should call isascii. - */ - - while (isspace(UCHAR(*list))) { - list++; - } - if (*list == '{') { - openBraces = 1; - list++; - } else if (*list == '"') { - inQuotes = 1; - list++; - } - if (bracePtr != 0) { - *bracePtr = openBraces; - } - p = list; - - /* - * Find the end of the element (either a space or a close brace or - * the end of the string). - */ - - while (1) { - switch (*p) { - - /* - * Open brace: don't treat specially unless the element is - * in braces. In this case, keep a nesting count. - */ - - case '{': - if (openBraces != 0) { - openBraces++; - } - break; - - /* - * Close brace: if element is in braces, keep nesting - * count and quit when the last close brace is seen. - */ - - case '}': - if (openBraces == 1) { - char *p2; - - size = p - list; - p++; - if (isspace(UCHAR(*p)) || (*p == 0)) { - goto done; - } - for (p2 = p; (*p2 != 0) && (!isspace(UCHAR(*p2))) - && (p2 < p+20); p2++) { - /* null body */ - } - if (interp != NULL) { - Tcl_ResetResult(interp); - sprintf(interp->result, - "list element in braces followed by \"%.*s\" instead of space", - (int) (p2-p), p); - } - return TCL_ERROR; - } else if (openBraces != 0) { - openBraces--; - } - break; - - /* - * Backslash: skip over everything up to the end of the - * backslash sequence. - */ - - case '\\': { - int size; - - (void) Tcl_Backslash(p, &size); - p += size - 1; - break; - } - - /* - * Space: ignore if element is in braces or quotes; otherwise - * terminate element. - */ - - case ' ': - case '\f': - case '\n': - case '\r': - case '\t': - case '\v': - if ((openBraces == 0) && !inQuotes) { - size = p - list; - goto done; - } - break; - - /* - * Double-quote: if element is in quotes then terminate it. - */ - - case '"': - if (inQuotes) { - char *p2; - - size = p-list; - p++; - if (isspace(UCHAR(*p)) || (*p == 0)) { - goto done; - } - for (p2 = p; (*p2 != 0) && (!isspace(UCHAR(*p2))) - && (p2 < p+20); p2++) { - /* null body */ - } - if (interp != NULL) { - Tcl_ResetResult(interp); - sprintf(interp->result, - "list element in quotes followed by \"%.*s\" %s", (int) (p2-p), p, - "instead of space"); - } - return TCL_ERROR; - } - break; - - /* - * End of list: terminate element. - */ - - case 0: - if (openBraces != 0) { - if (interp != NULL) { - Tcl_SetResult(interp, "unmatched open brace in list", - TCL_STATIC); - } - return TCL_ERROR; - } else if (inQuotes) { - if (interp != NULL) { - Tcl_SetResult(interp, "unmatched open quote in list", - TCL_STATIC); - } - return TCL_ERROR; - } - size = p - list; - goto done; - - } - p++; - } - - done: - while (isspace(UCHAR(*p))) { - p++; - } - *elementPtr = list; - *nextPtr = p; - if (sizePtr != 0) { - *sizePtr = size; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclCopyAndCollapse -- - * - * Copy a string and eliminate any backslashes that aren't in braces. - * - * Results: - * There is no return value. Count chars. get copied from src - * to dst. Along the way, if backslash sequences are found outside - * braces, the backslashes are eliminated in the copy. - * After scanning count chars. from source, a null character is - * placed at the end of dst. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TclCopyAndCollapse( - int count, /* Total number of characters to copy - * from src. */ - char *src, /* Copy from here... */ - char *dst /* ... to here. */ -) -{ - char c; - int numRead; - - for (c = *src; count > 0; src++, c = *src, count--) { - if (c == '\\') { - *dst = Tcl_Backslash(src, &numRead); - dst++; - src += numRead-1; - count -= numRead-1; - } else { - *dst = c; - dst++; - } - } - *dst = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SplitList -- - * - * Splits a list up into its constituent fields. - * - * Results - * The return value is normally TCL_OK, which means that - * the list was successfully split up. If TCL_ERROR is - * returned, it means that "list" didn't have proper list - * structure; interp->result will contain a more detailed - * error message. - * - * *argvPtr will be filled in with the address of an array - * whose elements point to the elements of list, in order. - * *argcPtr will get filled in with the number of valid elements - * in the array. A single block of memory is dynamically allocated - * to hold both the argv array and a copy of the list (with - * backslashes and braces removed in the standard way). - * The caller must eventually free this memory by calling free() - * on *argvPtr. Note: *argvPtr and *argcPtr are only modified - * if the procedure returns normally. - * - * Side effects: - * Memory is allocated. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_SplitList( - Tcl_Interp *interp, /* Interpreter to use for error reporting. - * If NULL, then no error message is left. */ - char *list, /* Pointer to string with list structure. */ - int *argcPtr, /* Pointer to location to fill in with - * the number of elements in the list. */ - char ***argvPtr /* Pointer to place to store pointer to array - * of pointers to list elements. */ -) -{ - char **argv; - char *p; - int size, i, result, elSize, brace; - char *element; - - /* - * Figure out how much space to allocate. There must be enough - * space for both the array of pointers and also for a copy of - * the list. To estimate the number of pointers needed, count - * the number of space characters in the list. - */ - - for (size = 1, p = list; *p != 0; p++) { - if (isspace(UCHAR(*p))) { - size++; - } - } - size++; /* Leave space for final NULL pointer. */ - argv = (char **) ckalloc((unsigned) - ((size * sizeof(char *)) + (p - list) + 1)); - for (i = 0, p = ((char *) argv) + size*sizeof(char *); - *list != 0; i++) { - result = TclFindElement(interp, list, &element, &list, &elSize, &brace); - if (result != TCL_OK) { - ckfree((char *) argv); - return result; - } - if (*element == 0) { - break; - } - if (i >= size) { - ckfree((char *) argv); - if (interp != NULL) { - Tcl_SetResult(interp, "internal error in Tcl_SplitList", - TCL_STATIC); - } - return TCL_ERROR; - } - argv[i] = p; - if (brace) { - strncpy(p, element, (size_t) elSize); - p += elSize; - *p = 0; - p++; - } else { - TclCopyAndCollapse(elSize, element, p); - p += elSize+1; - } - } - - argv[i] = NULL; - *argvPtr = argv; - *argcPtr = i; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ScanElement -- - * - * This procedure is a companion procedure to Tcl_ConvertElement. - * It scans a string to see what needs to be done to it (e.g. - * add backslashes or enclosing braces) to make the string into - * a valid Tcl list element. - * - * Results: - * The return value is an overestimate of the number of characters - * that will be needed by Tcl_ConvertElement to produce a valid - * list element from string. The word at *flagPtr is filled in - * with a value needed by Tcl_ConvertElement when doing the actual - * conversion. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_ScanElement( - char *string, /* String to convert to Tcl list element. */ - int *flagPtr /* Where to store information to guide - * Tcl_ConvertElement. */ -) -{ - int flags, nestingLevel; - char *p; - - /* - * This procedure and Tcl_ConvertElement together do two things: - * - * 1. They produce a proper list, one that will yield back the - * argument strings when evaluated or when disassembled with - * Tcl_SplitList. This is the most important thing. - * - * 2. They try to produce legible output, which means minimizing the - * use of backslashes (using braces instead). However, there are - * some situations where backslashes must be used (e.g. an element - * like "{abc": the leading brace will have to be backslashed. For - * each element, one of three things must be done: - * - * (a) Use the element as-is (it doesn't contain anything special - * characters). This is the most desirable option. - * - * (b) Enclose the element in braces, but leave the contents alone. - * This happens if the element contains embedded space, or if it - * contains characters with special interpretation ($, [, ;, or \), - * or if it starts with a brace or double-quote, or if there are - * no characters in the element. - * - * (c) Don't enclose the element in braces, but add backslashes to - * prevent special interpretation of special characters. This is a - * last resort used when the argument would normally fall under case - * (b) but contains unmatched braces. It also occurs if the last - * character of the argument is a backslash or if the element contains - * a backslash followed by newline. - * - * The procedure figures out how many bytes will be needed to store - * the result (actually, it overestimates). It also collects information - * about the element in the form of a flags word. - */ - - nestingLevel = 0; - flags = 0; - if (string == NULL) { - string = ""; - } - p = string; - if ((*p == '{') || (*p == '"') || (*p == 0)) { - flags |= USE_BRACES; - } - for ( ; *p != 0; p++) { - switch (*p) { - case '{': - nestingLevel++; - break; - case '}': - nestingLevel--; - if (nestingLevel < 0) { - flags |= TCL_DONT_USE_BRACES|BRACES_UNMATCHED; - } - break; - case '[': - case '$': - case ';': - case ' ': - case '\f': - case '\n': - case '\r': - case '\t': - case '\v': - flags |= USE_BRACES; - break; - case '\\': - if ((p[1] == 0) || (p[1] == '\n')) { - flags = TCL_DONT_USE_BRACES; - } else { - int size; - - (void) Tcl_Backslash(p, &size); - p += size-1; - flags |= USE_BRACES; - } - break; - } - } - if (nestingLevel != 0) { - flags = TCL_DONT_USE_BRACES | BRACES_UNMATCHED; - } - *flagPtr = flags; - - /* - * Allow enough space to backslash every character plus leave - * two spaces for braces. - */ - - return 2*(p-string) + 2; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ConvertElement -- - * - * This is a companion procedure to Tcl_ScanElement. Given the - * information produced by Tcl_ScanElement, this procedure converts - * a string to a list element equal to that string. - * - * Results: - * Information is copied to *dst in the form of a list element - * identical to src (i.e. if Tcl_SplitList is applied to dst it - * will produce a string identical to src). The return value is - * a count of the number of characters copied (not including the - * terminating NULL character). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_ConvertElement( - char *src, /* Source information for list element. */ - char *dst, /* Place to put list-ified element. */ - int flags /* Flags produced by Tcl_ScanElement. */ -) -{ - char *p = dst; - - /* - * See the comment block at the beginning of the Tcl_ScanElement - * code for details of how this works. - */ - - if ((src == NULL) || (*src == 0)) { - p[0] = '{'; - p[1] = '}'; - p[2] = 0; - return 2; - } - if ((flags & USE_BRACES) && !(flags & TCL_DONT_USE_BRACES)) { - *p = '{'; - p++; - for ( ; *src != 0; src++, p++) { - *p = *src; - } - *p = '}'; - p++; - } else { - if (*src == '{') { - /* - * Can't have a leading brace unless the whole element is - * enclosed in braces. Add a backslash before the brace. - * Furthermore, this may destroy the balance between open - * and close braces, so set BRACES_UNMATCHED. - */ - - p[0] = '\\'; - p[1] = '{'; - p += 2; - src++; - flags |= BRACES_UNMATCHED; - } - for (; *src != 0 ; src++) { - switch (*src) { - case ']': - case '[': - case '$': - case ';': - case ' ': - case '\\': - case '"': - *p = '\\'; - p++; - break; - case '{': - case '}': - /* - * It may not seem necessary to backslash braces, but - * it is. The reason for this is that the resulting - * list element may actually be an element of a sub-list - * enclosed in braces (e.g. if Tcl_DStringStartSublist - * has been invoked), so there may be a brace mismatch - * if the braces aren't backslashed. - */ - - if (flags & BRACES_UNMATCHED) { - *p = '\\'; - p++; - } - break; - case '\f': - *p = '\\'; - p++; - *p = 'f'; - p++; - continue; - case '\n': - *p = '\\'; - p++; - *p = 'n'; - p++; - continue; - case '\r': - *p = '\\'; - p++; - *p = 'r'; - p++; - continue; - case '\t': - *p = '\\'; - p++; - *p = 't'; - p++; - continue; - case '\v': - *p = '\\'; - p++; - *p = 'v'; - p++; - continue; - } - *p = *src; - p++; - } - } - *p = '\0'; - return p-dst; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Merge -- - * - * Given a collection of strings, merge them together into a - * single string that has proper Tcl list structured (i.e. - * Tcl_SplitList may be used to retrieve strings equal to the - * original elements, and Tcl_Eval will parse the string back - * into its original elements). - * - * Results: - * The return value is the address of a dynamically-allocated - * string containing the merged list. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_Merge( - int argc, /* How many strings to merge. */ - char **argv /* Array of string values. */ -) -{ -# define LOCAL_SIZE 20 - int localFlags[LOCAL_SIZE], *flagPtr; - int numChars; - char *result; - char *dst; - int i; - - /* - * Pass 1: estimate space, gather flags. - */ - - if (argc <= LOCAL_SIZE) { - flagPtr = localFlags; - } else { - flagPtr = (int *) ckalloc((unsigned) argc*sizeof(int)); - } - numChars = 1; - for (i = 0; i < argc; i++) { - numChars += Tcl_ScanElement(argv[i], &flagPtr[i]) + 1; - } - - /* - * Pass two: copy into the result area. - */ - - result = (char *) ckalloc((unsigned) numChars); - dst = result; - for (i = 0; i < argc; i++) { - numChars = Tcl_ConvertElement(argv[i], dst, flagPtr[i]); - dst += numChars; - *dst = ' '; - dst++; - } - if (dst == result) { - *dst = 0; - } else { - dst[-1] = 0; - } - - if (flagPtr != localFlags) { - ckfree((char *) flagPtr); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_Concat -- - * - * Concatenate a set of strings into a single large string. - * - * Results: - * The return value is dynamically-allocated string containing - * a concatenation of all the strings in argv, with spaces between - * the original argv elements. - * - * Side effects: - * Memory is allocated for the result; the caller is responsible - * for freeing the memory. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_Concat( - int argc, /* Number of strings to concatenate. */ - char **argv /* Array of strings to concatenate. */ -) -{ - int totalSize, i; - char *p; - char *result; - - for (totalSize = 1, i = 0; i < argc; i++) { - totalSize += strlen(argv[i]) + 1; - } - result = (char *) ckalloc((unsigned) totalSize); - if (argc == 0) { - *result = '\0'; - return result; - } - for (p = result, i = 0; i < argc; i++) { - char *element; - int length; - - /* - * Clip white space off the front and back of the string - * to generate a neater result, and ignore any empty - * elements. - */ - - element = argv[i]; - while (isspace(UCHAR(*element))) { - element++; - } - for (length = strlen(element); - (length > 0) && (isspace(UCHAR(element[length-1]))); - length--) { - /* Null loop body. */ - } - if (length == 0) { - continue; - } - (void) strncpy(p, element, (size_t) length); - p += length; - *p = ' '; - p++; - } - if (p != result) { - p[-1] = 0; - } else { - *p = 0; - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_StringMatch -- - * - * See if a particular string matches a particular pattern. - * - * Results: - * The return value is 1 if string matches pattern, and - * 0 otherwise. The matching operation permits the following - * special characters in the pattern: *?\[] (see the manual - * entry for details on what these mean). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_StringMatch( - char *string, /* String. */ - char *pattern /* Pattern, which may contain something */ -) -{ - char c2; - - while (1) { - /* See if we're at the end of both the pattern and the string. - * If so, we succeeded. If we're at the end of the pattern - * but not at the end of the string, we failed. - */ - - if (*pattern == 0) { - if (*string == 0) { - return 1; - } else { - return 0; - } - } - if ((*string == 0) && (*pattern != '*')) { - return 0; - } - - /* Check for a "*" as the next pattern character. It matches - * any substring. We handle this by calling ourselves - * recursively for each postfix of string, until either we - * match or we reach the end of the string. - */ - - if (*pattern == '*') { - pattern += 1; - if (*pattern == 0) { - return 1; - } - while (1) { - if (Tcl_StringMatch(string, pattern)) { - return 1; - } - if (*string == 0) { - return 0; - } - string += 1; - } - } - - /* Check for a "?" as the next pattern character. It matches - * any single character. - */ - - if (*pattern == '?') { - goto thisCharOK; - } - - /* Check for a "[" as the next pattern character. It is followed - * by a list of characters that are acceptable, or by a range - * (two characters separated by "-"). - */ - - if (*pattern == '[') { - pattern += 1; - while (1) { - if ((*pattern == ']') || (*pattern == 0)) { - return 0; - } - if (*pattern == *string) { - break; - } - if (pattern[1] == '-') { - c2 = pattern[2]; - if (c2 == 0) { - return 0; - } - if ((*pattern <= *string) && (c2 >= *string)) { - break; - } - if ((*pattern >= *string) && (c2 <= *string)) { - break; - } - pattern += 2; - } - pattern += 1; - } - while (*pattern != ']') { - if (*pattern == 0) { - pattern--; - break; - } - pattern += 1; - } - goto thisCharOK; - } - - /* If the next pattern character is '/', just strip off the '/' - * so we do exact matching on the character that follows. - */ - - if (*pattern == '\\') { - pattern += 1; - if (*pattern == 0) { - return 0; - } - } - - /* There's no special character. Just make sure that the next - * characters of each string match. - */ - - if (*pattern != *string) { - return 0; - } - - thisCharOK: pattern += 1; - string += 1; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetResult -- - * - * Arrange for "string" to be the Tcl return value. - * - * Results: - * None. - * - * Side effects: - * interp->result is left pointing either to "string" (if "copy" is 0) - * or to a copy of string. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_SetResult( - Tcl_Interp *interp, /* Interpreter with which to associate the - * return value. */ - char *string, /* Value to be returned. If NULL, - * the result is set to an empty string. */ - Tcl_FreeProc *freeProc /* Gives information about the string: - * TCL_STATIC, TCL_VOLATILE, or the address - * of a Tcl_FreeProc such as free. */ -) -{ - Interp *iPtr = (Interp *) interp; - int length; - Tcl_FreeProc *oldFreeProc = iPtr->freeProc; - char *oldResult = iPtr->result; - - if (string == NULL) { - iPtr->resultSpace[0] = 0; - iPtr->result = iPtr->resultSpace; - iPtr->freeProc = 0; - } else if (freeProc == TCL_DYNAMIC) { - iPtr->result = string; - iPtr->freeProc = TCL_DYNAMIC; - } else if (freeProc == TCL_VOLATILE) { - length = strlen(string); - if (length > TCL_RESULT_SIZE) { - iPtr->result = (char *) ckalloc((unsigned) length+1); - iPtr->freeProc = TCL_DYNAMIC; - } else { - iPtr->result = iPtr->resultSpace; - iPtr->freeProc = 0; - } - strcpy(iPtr->result, string); - } else { - iPtr->result = string; - iPtr->freeProc = freeProc; - } - - /* - * If the old result was dynamically-allocated, free it up. Do it - * here, rather than at the beginning, in case the new result value - * was part of the old result value. - */ - - if (oldFreeProc != 0) { - if ((oldFreeProc == TCL_DYNAMIC) - || (oldFreeProc == (Tcl_FreeProc *) free)) { - ckfree(oldResult); - } else { - (*oldFreeProc)(oldResult); - } - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AppendResult -- - * - * Append a variable number of strings onto the result already - * present for an interpreter. - * - * Results: - * None. - * - * Side effects: - * The result in the interpreter given by the first argument - * is extended by the strings given by the second and following - * arguments (up to a terminating NULL argument). - * - *---------------------------------------------------------------------- - */ - - /* VARARGS2 */ -void -Tcl_AppendResult TCL_VARARGS_DEF(Tcl_Interp *,arg1) -{ - va_list argList; - Interp *iPtr; - char *string; - int newSpace; - - /* - * First, scan through all the arguments to see how much space is - * needed. - */ - - iPtr = (Interp *)arg1; - va_start(argList, arg1); - newSpace = 0; - while (1) { - string = va_arg(argList, char *); - if (string == NULL) { - break; - } - newSpace += strlen(string); - } - va_end(argList); - - /* - * If the append buffer isn't already setup and large enough - * to hold the new data, set it up. - */ - - if ((iPtr->result != iPtr->appendResult) - || (iPtr->appendResult[iPtr->appendUsed] != 0) - || ((newSpace + iPtr->appendUsed) >= iPtr->appendAvl)) { - SetupAppendBuffer(iPtr, newSpace); - } - - /* - * Final step: go through all the argument strings again, copying - * them into the buffer. - */ - - va_start(argList, arg1); - while (1) { - string = va_arg(argList, char *); - if (string == NULL) { - break; - } - strcpy(iPtr->appendResult + iPtr->appendUsed, string); - iPtr->appendUsed += strlen(string); - } - va_end(argList); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AppendElement -- - * - * Convert a string to a valid Tcl list element and append it - * to the current result (which is ostensibly a list). - * - * Results: - * None. - * - * Side effects: - * The result in the interpreter given by the first argument - * is extended with a list element converted from string. A - * separator space is added before the converted list element - * unless the current result is empty, contains the single - * character "{", or ends in " {". - * - *---------------------------------------------------------------------- - */ - -void -Tcl_AppendElement( - Tcl_Interp *interp, /* Interpreter whose result is to be - * extended. */ - char *string /* String to convert to list element and - * add to result. */ -) -{ - Interp *iPtr = (Interp *) interp; - int size, flags; - char *dst; - - /* - * See how much space is needed, and grow the append buffer if - * needed to accommodate the list element. - */ - - size = Tcl_ScanElement(string, &flags) + 1; - if ((iPtr->result != iPtr->appendResult) - || (iPtr->appendResult[iPtr->appendUsed] != 0) - || ((size + iPtr->appendUsed) >= iPtr->appendAvl)) { - SetupAppendBuffer(iPtr, size+iPtr->appendUsed); - } - - /* - * Convert the string into a list element and copy it to the - * buffer that's forming, with a space separator if needed. - */ - - dst = iPtr->appendResult + iPtr->appendUsed; - if (TclNeedSpace(iPtr->appendResult, dst)) { - iPtr->appendUsed++; - *dst = ' '; - dst++; - } - iPtr->appendUsed += Tcl_ConvertElement(string, dst, flags); -} - -/* - *---------------------------------------------------------------------- - * - * SetupAppendBuffer -- - * - * This procedure makes sure that there is an append buffer - * properly initialized for interp, and that it has at least - * enough room to accommodate newSpace new bytes of information. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static void -SetupAppendBuffer( - Interp *iPtr, /* Interpreter whose result is being set up. */ - int newSpace /* Make sure that at least this many bytes - * of new information may be added. */ -) -{ - int totalSpace; - - /* - * Make the append buffer larger, if that's necessary, then - * copy the current result into the append buffer and make the - * append buffer the official Tcl result. - */ - - if (iPtr->result != iPtr->appendResult) { - /* - * If an oversized buffer was used recently, then free it up - * so we go back to a smaller buffer. This avoids tying up - * memory forever after a large operation. - */ - - if (iPtr->appendAvl > 500) { - ckfree(iPtr->appendResult); - iPtr->appendResult = NULL; - iPtr->appendAvl = 0; - } - iPtr->appendUsed = strlen(iPtr->result); - } else if (iPtr->result[iPtr->appendUsed] != 0) { - /* - * Most likely someone has modified a result created by - * Tcl_AppendResult et al. so that it has a different size. - * Just recompute the size. - */ - - iPtr->appendUsed = strlen(iPtr->result); - } - totalSpace = newSpace + iPtr->appendUsed; - if (totalSpace >= iPtr->appendAvl) { - char *new; - - if (totalSpace < 100) { - totalSpace = 200; - } else { - totalSpace *= 2; - } - new = (char *) ckalloc((unsigned) totalSpace); - strcpy(new, iPtr->result); - if (iPtr->appendResult != NULL) { - ckfree(iPtr->appendResult); - } - iPtr->appendResult = new; - iPtr->appendAvl = totalSpace; - } else if (iPtr->result != iPtr->appendResult) { - strcpy(iPtr->appendResult, iPtr->result); - } - Tcl_FreeResult(iPtr); - iPtr->result = iPtr->appendResult; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ResetResult -- - * - * This procedure restores the result area for an interpreter - * to its default initialized state, freeing up any memory that - * may have been allocated for the result and clearing any - * error information for the interpreter. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_ResetResult( - Tcl_Interp *interp /* Interpreter for which to clear result. */ -) -{ - Interp *iPtr = (Interp *) interp; - - Tcl_FreeResult(iPtr); - iPtr->result = iPtr->resultSpace; - iPtr->resultSpace[0] = 0; - iPtr->flags &= - ~(ERR_ALREADY_LOGGED | ERR_IN_PROGRESS | ERROR_CODE_SET); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetErrorCode -- - * - * This procedure is called to record machine-readable information - * about an error that is about to be returned. - * - * Results: - * None. - * - * Side effects: - * The errorCode global variable is modified to hold all of the - * arguments to this procedure, in a list form with each argument - * becoming one element of the list. A flag is set internally - * to remember that errorCode has been set, so the variable doesn't - * get set automatically when the error is returned. - * - *---------------------------------------------------------------------- - */ - /* VARARGS2 */ -void -Tcl_SetErrorCode TCL_VARARGS_DEF(Tcl_Interp *,arg1) -{ - va_list argList; - char *string; - int flags; - Interp *iPtr; - - /* - * Scan through the arguments one at a time, appending them to - * $errorCode as list elements. - */ - - iPtr = (Interp *)arg1; - va_start(argList, arg1); - flags = TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT; - while (1) { - string = va_arg(argList, char *); - if (string == NULL) { - break; - } - (void) Tcl_SetVar2((Tcl_Interp *) iPtr, "errorCode", - (char *) NULL, string, flags); - flags |= TCL_APPEND_VALUE; - } - va_end(argList); - iPtr->flags |= ERROR_CODE_SET; -} - -/* - *---------------------------------------------------------------------- - * - * TclGetListIndex -- - * - * Parse a list index, which may be either an integer or the - * value "end". - * - * Results: - * The return value is either TCL_OK or TCL_ERROR. If it is - * TCL_OK, then the index corresponding to string is left in - * *indexPtr. If the return value is TCL_ERROR, then string - * was bogus; an error message is returned in interp->result. - * If a negative index is specified, it is rounded up to 0. - * The index value may be larger than the size of the list - * (this happens when "end" is specified). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGetListIndex( - Tcl_Interp *interp, /* Interpreter for error reporting. */ - char *string, /* String containing list index. */ - int *indexPtr /* Where to store index. */ -) -{ - if (isdigit(UCHAR(*string)) || (*string == '-')) { - if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) { - return TCL_ERROR; - } - if (*indexPtr < 0) { - *indexPtr = 0; - } - } else if (strncmp(string, "end", strlen(string)) == 0) { - *indexPtr = INT_MAX; - } else { - Tcl_AppendResult(interp, "bad index \"", string, - "\": must be integer or \"end\"", (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegExpCompile -- - * - * Compile a regular expression into a form suitable for fast - * matching. This procedure retains a small cache of pre-compiled - * regular expressions in the interpreter, in order to avoid - * compilation costs as much as possible. - * - * Results: - * The return value is a pointer to the compiled form of string, - * suitable for passing to Tcl_RegExpExec. This compiled form - * is only valid up until the next call to this procedure, so - * don't keep these around for a long time! If an error occurred - * while compiling the pattern, then NULL is returned and an error - * message is left in interp->result. - * - * Side effects: - * The cache of compiled regexp's in interp will be modified to - * hold information for string, if such information isn't already - * present in the cache. - * - *---------------------------------------------------------------------- - */ - -Tcl_RegExp -Tcl_RegExpCompile( - Tcl_Interp *interp, /* For use in error reporting. */ - char *string /* String for which to produce - * compiled regular expression. */ -) -{ - Interp *iPtr = (Interp *) interp; - int i, length; - regexp *result; - - length = strlen(string); - for (i = 0; i < NUM_REGEXPS; i++) { - if ((length == iPtr->patLengths[i]) - && (strcmp(string, iPtr->patterns[i]) == 0)) { - /* - * Move the matched pattern to the first slot in the - * cache and shift the other patterns down one position. - */ - - if (i != 0) { - int j; - char *cachedString; - - cachedString = iPtr->patterns[i]; - result = iPtr->regexps[i]; - for (j = i-1; j >= 0; j--) { - iPtr->patterns[j+1] = iPtr->patterns[j]; - iPtr->patLengths[j+1] = iPtr->patLengths[j]; - iPtr->regexps[j+1] = iPtr->regexps[j]; - } - iPtr->patterns[0] = cachedString; - iPtr->patLengths[0] = length; - iPtr->regexps[0] = result; - } - return (Tcl_RegExp) iPtr->regexps[0]; - } - } - - /* - * No match in the cache. Compile the string and add it to the - * cache. - */ - - TclRegError((char *) NULL); - result = TclRegComp(string); - if (TclGetRegError() != NULL) { - Tcl_AppendResult(interp, - "couldn't compile regular expression pattern: ", - TclGetRegError(), (char *) NULL); - return NULL; - } - if (iPtr->patterns[NUM_REGEXPS-1] != NULL) { - ckfree(iPtr->patterns[NUM_REGEXPS-1]); - ckfree((char *) iPtr->regexps[NUM_REGEXPS-1]); - } - for (i = NUM_REGEXPS - 2; i >= 0; i--) { - iPtr->patterns[i+1] = iPtr->patterns[i]; - iPtr->patLengths[i+1] = iPtr->patLengths[i]; - iPtr->regexps[i+1] = iPtr->regexps[i]; - } - iPtr->patterns[0] = (char *) ckalloc((unsigned) (length+1)); - strcpy(iPtr->patterns[0], string); - iPtr->patLengths[0] = length; - iPtr->regexps[0] = result; - return (Tcl_RegExp) result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegExpExec -- - * - * Execute the regular expression matcher using a compiled form - * of a regular expression and save information about any match - * that is found. - * - * Results: - * If an error occurs during the matching operation then -1 - * is returned and interp->result contains an error message. - * Otherwise the return value is 1 if a matching range is - * found and 0 if there is no matching range. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_RegExpExec( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - Tcl_RegExp re, /* Compiled regular expression; must have - * been returned by previous call to - * Tcl_RegExpCompile. */ - char *string, /* String against which to match re. */ - char *start /* If string is part of a larger string, - * this identifies beginning of larger - * string, so that "^" won't match. */ -) -{ - int match; - - regexp *regexpPtr = (regexp *) re; - TclRegError((char *) NULL); - match = TclRegExec(regexpPtr, string, start); - if (TclGetRegError() != NULL) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "error while matching regular expression: ", - TclGetRegError(), (char *) NULL); - return -1; - } - return match; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegExpRange -- - * - * Returns pointers describing the range of a regular expression match, - * or one of the subranges within the match. - * - * Results: - * The variables at *startPtr and *endPtr are modified to hold the - * addresses of the endpoints of the range given by index. If the - * specified range doesn't exist then NULLs are returned. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_RegExpRange( - Tcl_RegExp re, /* Compiled regular expression that has - * been passed to Tcl_RegExpExec. */ - int index, /* 0 means give the range of the entire - * match, > 0 means give the range of - * a matching subrange. Must be no greater - * than NSUBEXP. */ - char **startPtr, /* Store address of first character in - * (sub-) range here. */ - char **endPtr /* Store address of character just after last - * in (sub-) range here. */ -) -{ - regexp *regexpPtr = (regexp *) re; - - if (index >= NSUBEXP) { - *startPtr = *endPtr = NULL; - } else { - *startPtr = regexpPtr->startp[index]; - *endPtr = regexpPtr->endp[index]; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_RegExpMatch -- - * - * See if a string matches a regular expression. - * - * Results: - * If an error occurs during the matching operation then -1 - * is returned and interp->result contains an error message. - * Otherwise the return value is 1 if "string" matches "pattern" - * and 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_RegExpMatch( - Tcl_Interp *interp, /* Used for error reporting. */ - char *string, /* String. */ - char *pattern /* Regular expression to match against - * string. */ -) -{ - Tcl_RegExp re; - - re = Tcl_RegExpCompile(interp, pattern); - if (re == NULL) { - return -1; - } - return Tcl_RegExpExec(interp, re, string, string); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringInit -- - * - * Initializes a dynamic string, discarding any previous contents - * of the string (Tcl_DStringFree should have been called already - * if the dynamic string was previously in use). - * - * Results: - * None. - * - * Side effects: - * The dynamic string is initialized to be empty. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringInit( - Tcl_DString *dsPtr /* Pointer to structure for - * dynamic string. */ -) -{ - dsPtr->string = dsPtr->staticSpace; - dsPtr->length = 0; - dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE; - dsPtr->staticSpace[0] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringAppend -- - * - * Append more characters to the current value of a dynamic string. - * - * Results: - * The return value is a pointer to the dynamic string's new value. - * - * Side effects: - * Length bytes from string (or all of string if length is less - * than zero) are added to the current value of the string. Memory - * gets reallocated if needed to accommodate the string's new size. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_DStringAppend( - Tcl_DString *dsPtr, /* Structure describing dynamic - * string. */ - char *string, /* String to append. If length is - * -1 then this must be - * null-terminated. */ - int length /* Number of characters from string - * to append. If < 0, then append all - * of string, up to null at end. */ -) -{ - int newSize; - char *newString, *dst, *end; - - if (length < 0) { - length = strlen(string); - } - newSize = length + dsPtr->length; - - /* - * Allocate a larger buffer for the string if the current one isn't - * large enough. Allocate extra space in the new buffer so that there - * will be room to grow before we have to allocate again. - */ - - if (newSize >= dsPtr->spaceAvl) { - dsPtr->spaceAvl = newSize*2; - newString = (char *) ckalloc((unsigned) dsPtr->spaceAvl); - memcpy((VOID *)newString, (VOID *) dsPtr->string, - (size_t) dsPtr->length); - if (dsPtr->string != dsPtr->staticSpace) { - ckfree(dsPtr->string); - } - dsPtr->string = newString; - } - - /* - * Copy the new string into the buffer at the end of the old - * one. - */ - - for (dst = dsPtr->string + dsPtr->length, end = string+length; - string < end; string++, dst++) { - *dst = *string; - } - *dst = 0; - dsPtr->length += length; - return dsPtr->string; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringAppendElement -- - * - * Append a list element to the current value of a dynamic string. - * - * Results: - * The return value is a pointer to the dynamic string's new value. - * - * Side effects: - * String is reformatted as a list element and added to the current - * value of the string. Memory gets reallocated if needed to - * accommodate the string's new size. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_DStringAppendElement( - Tcl_DString *dsPtr, /* Structure describing dynamic - * string. */ - char *string /* String to append. Must be - * null-terminated. */ -) -{ - int newSize, flags; - char *dst, *newString; - - newSize = Tcl_ScanElement(string, &flags) + dsPtr->length + 1; - - /* - * Allocate a larger buffer for the string if the current one isn't - * large enough. Allocate extra space in the new buffer so that there - * will be room to grow before we have to allocate again. - * SPECIAL NOTE: must use memcpy, not strcpy, to copy the string - * to a larger buffer, since there may be embedded NULLs in the - * string in some cases. - */ - - if (newSize >= dsPtr->spaceAvl) { - dsPtr->spaceAvl = newSize*2; - newString = (char *) ckalloc((unsigned) dsPtr->spaceAvl); - memcpy((VOID *) newString, (VOID *) dsPtr->string, - (size_t) dsPtr->length); - if (dsPtr->string != dsPtr->staticSpace) { - ckfree(dsPtr->string); - } - dsPtr->string = newString; - } - - /* - * Convert the new string to a list element and copy it into the - * buffer at the end, with a space, if needed. - */ - - dst = dsPtr->string + dsPtr->length; - if (TclNeedSpace(dsPtr->string, dst)) { - *dst = ' '; - dst++; - dsPtr->length++; - } - dsPtr->length += Tcl_ConvertElement(string, dst, flags); - return dsPtr->string; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringSetLength -- - * - * Change the length of a dynamic string. This can cause the - * string to either grow or shrink, depending on the value of - * length. - * - * Results: - * None. - * - * Side effects: - * The length of dsPtr is changed to length and a null byte is - * stored at that position in the string. If length is larger - * than the space allocated for dsPtr, then a panic occurs. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringSetLength( - Tcl_DString *dsPtr, /* Structure describing dynamic - * string. */ - int length /* New length for dynamic string. */ -) -{ - if (length < 0) { - length = 0; - } - if (length >= dsPtr->spaceAvl) { - char *newString; - - dsPtr->spaceAvl = length+1; - newString = (char *) ckalloc((unsigned) dsPtr->spaceAvl); - - /* - * SPECIAL NOTE: must use memcpy, not strcpy, to copy the string - * to a larger buffer, since there may be embedded NULLs in the - * string in some cases. - */ - - memcpy((VOID *) newString, (VOID *) dsPtr->string, - (size_t) dsPtr->length); - if (dsPtr->string != dsPtr->staticSpace) { - ckfree(dsPtr->string); - } - dsPtr->string = newString; - } - dsPtr->length = length; - dsPtr->string[length] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringFree -- - * - * Frees up any memory allocated for the dynamic string and - * reinitializes the string to an empty state. - * - * Results: - * None. - * - * Side effects: - * The previous contents of the dynamic string are lost, and - * the new value is an empty string. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringFree( - Tcl_DString *dsPtr /* Structure describing dynamic - * string. */ -) -{ - if (dsPtr->string != dsPtr->staticSpace) { - ckfree(dsPtr->string); - } - dsPtr->string = dsPtr->staticSpace; - dsPtr->length = 0; - dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE; - dsPtr->staticSpace[0] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringResult -- - * - * This procedure moves the value of a dynamic string into an - * interpreter as its result. The string itself is reinitialized - * to an empty string. - * - * Results: - * None. - * - * Side effects: - * The string is "moved" to interp's result, and any existing - * result for interp is freed up. DsPtr is reinitialized to - * an empty string. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringResult( - Tcl_Interp *interp, /* Interpreter whose result is to be - * reset. */ - Tcl_DString *dsPtr /* Dynamic string that is to become - * the result of interp. */ -) -{ - Tcl_ResetResult(interp); - if (dsPtr->string != dsPtr->staticSpace) { - interp->result = dsPtr->string; - interp->freeProc = TCL_DYNAMIC; - } else if (dsPtr->length < TCL_RESULT_SIZE) { - interp->result = ((Interp *) interp)->resultSpace; - strcpy(interp->result, dsPtr->string); - } else { - Tcl_SetResult(interp, dsPtr->string, TCL_VOLATILE); - } - dsPtr->string = dsPtr->staticSpace; - dsPtr->length = 0; - dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE; - dsPtr->staticSpace[0] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringGetResult -- - * - * This procedure moves the result of an interpreter into a - * dynamic string. - * - * Results: - * None. - * - * Side effects: - * The interpreter's result is cleared, and the previous contents - * of dsPtr are freed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringGetResult( - Tcl_Interp *interp, /* Interpreter whose result is to be - * reset. */ - Tcl_DString *dsPtr /* Dynamic string that is to become - * the result of interp. */ -) -{ - Interp *iPtr = (Interp *) interp; - if (dsPtr->string != dsPtr->staticSpace) { - ckfree(dsPtr->string); - } - dsPtr->length = strlen(iPtr->result); - if (iPtr->freeProc != NULL) { - if ((iPtr->freeProc == TCL_DYNAMIC) - || (iPtr->freeProc == (Tcl_FreeProc *) free)) { - dsPtr->string = iPtr->result; - dsPtr->spaceAvl = dsPtr->length+1; - } else { - dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length+1)); - strcpy(dsPtr->string, iPtr->result); - (*iPtr->freeProc)(iPtr->result); - } - dsPtr->spaceAvl = dsPtr->length+1; - iPtr->freeProc = NULL; - } else { - if (dsPtr->length < TCL_DSTRING_STATIC_SIZE) { - dsPtr->string = dsPtr->staticSpace; - dsPtr->spaceAvl = TCL_DSTRING_STATIC_SIZE; - } else { - dsPtr->string = (char *) ckalloc((unsigned) (dsPtr->length + 1)); - dsPtr->spaceAvl = dsPtr->length + 1; - } - strcpy(dsPtr->string, iPtr->result); - } - iPtr->result = iPtr->resultSpace; - iPtr->resultSpace[0] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringStartSublist -- - * - * This procedure adds the necessary information to a dynamic - * string (e.g. " {" to start a sublist. Future element - * appends will be in the sublist rather than the main list. - * - * Results: - * None. - * - * Side effects: - * Characters get added to the dynamic string. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringStartSublist( - Tcl_DString *dsPtr /* Dynamic string. */ -) -{ - if (TclNeedSpace(dsPtr->string, dsPtr->string + dsPtr->length)) { - Tcl_DStringAppend(dsPtr, " {", -1); - } else { - Tcl_DStringAppend(dsPtr, "{", -1); - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_DStringEndSublist -- - * - * This procedure adds the necessary characters to a dynamic - * string to end a sublist (e.g. "}"). Future element appends - * will be in the enclosing (sub)list rather than the current - * sublist. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_DStringEndSublist( - Tcl_DString *dsPtr /* Dynamic string. */ -) -{ - Tcl_DStringAppend(dsPtr, "}", -1); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_PrintDouble -- - * - * Given a floating-point value, this procedure converts it to - * an ASCII string using. - * - * Results: - * The ASCII equivalent of "value" is written at "dst". It is - * written using the current precision, and it is guaranteed to - * contain a decimal point or exponent, so that it looks like - * a floating-point value and not an integer. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_PrintDouble( - Tcl_Interp *interp, /* Interpreter whose tcl_precision - * variable controls printing. */ - double value, /* Value to print as string. */ - char *dst /* Where to store converted value; - * must have at least TCL_DOUBLE_SPACE - * characters. */ -) -{ - char *p; - sprintf(dst, ((Interp *) interp)->pdFormat, value); - - /* - * If the ASCII result looks like an integer, add ".0" so that it - * doesn't look like an integer anymore. This prevents floating-point - * values from being converted to integers unintentionally. - */ - - for (p = dst; *p != 0; p++) { - if ((*p == '.') || (isalpha(UCHAR(*p)))) { - return; - } - } - p[0] = '.'; - p[1] = '0'; - p[2] = 0; -} - -/* - *---------------------------------------------------------------------- - * - * TclPrecTraceProc -- - * - * This procedure is invoked whenever the variable "tcl_precision" - * is written. - * - * Results: - * Returns NULL if all went well, or an error message if the - * new value for the variable doesn't make sense. - * - * Side effects: - * If the new value doesn't make sense then this procedure - * undoes the effect of the variable modification. Otherwise - * it modifies the format string that's used by Tcl_PrintDouble. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -char * -TclPrecTraceProc( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *name1, /* Name of variable. */ - char *name2, /* Second part of variable name. */ - int flags /* Information about what happened. */ -) -{ - Interp *iPtr = (Interp *) interp; - char *value, *end; - int prec; - - /* - * If the variable is unset, then recreate the trace and restore - * the default value of the format string. - */ - - if (flags & TCL_TRACE_UNSETS) { - if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) { - Tcl_TraceVar2(interp, name1, name2, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - TclPrecTraceProc, clientData); - } - strcpy(iPtr->pdFormat, DEFAULT_PD_FORMAT); - iPtr->pdPrec = DEFAULT_PD_PREC; - return (char *) NULL; - } - - value = Tcl_GetVar2(interp, name1, name2, flags & TCL_GLOBAL_ONLY); - if (value == NULL) { - value = ""; - } - prec = strtoul(value, &end, 10); - if ((prec <= 0) || (prec > TCL_MAX_PREC) || (prec > 100) || - (end == value) || (*end != 0)) { - char oldValue[10]; - - sprintf(oldValue, "%d", iPtr->pdPrec); - Tcl_SetVar2(interp, name1, name2, oldValue, flags & TCL_GLOBAL_ONLY); - return "improper value for precision"; - } - sprintf(iPtr->pdFormat, "%%.%dg", prec); - iPtr->pdPrec = prec; - return (char *) NULL; -} - -/* - *---------------------------------------------------------------------- - * - * TclNeedSpace -- - * - * This procedure checks to see whether it is appropriate to - * add a space before appending a new list element to an - * existing string. - * - * Results: - * The return value is 1 if a space is appropriate, 0 otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclNeedSpace( - char *start, /* First character in string. */ - char *end /* End of string (place where space will - * be added, if appropriate). */ -) -{ - /* - * A space is needed unless either - * (a) we're at the start of the string, or - * (b) the trailing characters of the string consist of one or more - * open curly braces preceded by a space or extending back to - * the beginning of the string. - * (c) the trailing characters of the string consist of a space - * preceded by a character other than backslash. - */ - - if (end == start) { - return 0; - } - end--; - if (*end != '{') { - if (isspace(UCHAR(*end)) && ((end == start) || (end[-1] != '\\'))) { - return 0; - } - return 1; - } - do { - if (end == start) { - return 0; - } - end--; - } while (*end == '{'); - if (isspace(UCHAR(*end))) { - return 0; - } - return 1; -} diff --git a/cde/programs/dtdocbook/tcl/tclVar.c b/cde/programs/dtdocbook/tcl/tclVar.c deleted file mode 100644 index eb2e3d5c9..000000000 --- a/cde/programs/dtdocbook/tcl/tclVar.c +++ /dev/null @@ -1,2628 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: tclVar.c /main/3 1996/10/03 16:42:27 drk $ */ -/* - * tclVar.c -- - * - * This file contains routines that implement Tcl variables - * (both scalars and arrays). - * - * The implementation of arrays is modelled after an initial - * implementation by Mark Diekhans and Karl Lehenbauer. - * - * Copyright (c) 1987-1994 The Regents of the University of California. - * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclVar.c 1.69 96/02/28 21:45:10 - */ - -#include "tclInt.h" -#include "tclPort.h" - -/* - * The strings below are used to indicate what went wrong when a - * variable access is denied. - */ - -static char *noSuchVar = "no such variable"; -static char *isArray = "variable is array"; -static char *needArray = "variable isn't array"; -static char *noSuchElement = "no such element in array"; -static char *danglingUpvar = "upvar refers to element in deleted array"; - -/* - * Creation flag values passed in to LookupVar: - * - * CRT_PART1 - 1 means create hash table entry for part 1 of - * name, if it doesn't already exist. 0 means - * return an error if it doesn't exist. - * CRT_PART2 - 1 means create hash table entry for part 2 of - * name, if it doesn't already exist. 0 means - * return an error if it doesn't exist. - */ - -#define CRT_PART1 1 -#define CRT_PART2 2 - -/* - * The following additional flag is used internally and passed through - * to LookupVar to indicate that a procedure like Tcl_GetVar was called - * instead of Tcl_GetVar2 and the single name value hasn't yet been - * parsed into an array name and index (if any). - */ - -#define PART1_NOT_PARSED 0x10000 - -/* - * Forward references to procedures defined later in this file: - */ - -static char * CallTraces _ANSI_ARGS_((Interp *iPtr, Var *arrayPtr, - Var *varPtr, char *part1, char *part2, - int flags)); -static void CleanupVar _ANSI_ARGS_((Var *varPtr, Var *arrayPtr)); -static void DeleteSearches _ANSI_ARGS_((Var *arrayVarPtr)); -static void DeleteArray _ANSI_ARGS_((Interp *iPtr, char *arrayName, - Var *varPtr, int flags)); -static Var * LookupVar _ANSI_ARGS_((Tcl_Interp *interp, char *part1, - char *part2, int flags, char *msg, int create, - Var **arrayPtrPtr)); -static int MakeUpvar _ANSI_ARGS_((Interp *iPtr, - CallFrame *framePtr, char *otherP1, - char *otherP2, char *myName, int flags)); -static Var * NewVar _ANSI_ARGS_((void)); -static ArraySearch * ParseSearchId _ANSI_ARGS_((Tcl_Interp *interp, - Var *varPtr, char *varName, char *string)); -static void VarErrMsg _ANSI_ARGS_((Tcl_Interp *interp, - char *part1, char *part2, char *operation, - char *reason)); - -/* - *---------------------------------------------------------------------- - * - * LookupVar -- - * - * This procedure is used by virtually all of the variable - * code to locate a variable given its name(s). - * - * Results: - * The return value is a pointer to the variable indicated by - * part1 and part2, or NULL if the variable couldn't be found. - * If the variable is found, *arrayPtrPtr is filled in with - * the address of the array that contains the variable (or NULL - * if the variable is a scalar). Note: it's possible that the - * variable returned may be VAR_UNDEFINED, even if CRT_PART1 and - * CRT_PART2 are specified (these only cause the hash table entry - * and/or array to be created). - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static Var * -LookupVar( - Tcl_Interp *interp, /* Interpreter to use for lookup. */ - char *part1, /* If part2 isn't NULL, this is the name - * of an array. Otherwise, if the - * PART1_NOT_PARSED flag bit is set this - * is a full variable name that could - * include a parenthesized array elemnt. - * If PART1_NOT_PARSED isn't present, then - * this is the name of a scalar variable. */ - char *part2, /* Name of an element within array, or NULL. */ - int flags, /* Only the TCL_GLOBAL_ONLY, TCL_LEAVE_ERR_MSG, - * and PART1_NOT_PARSED bits matter. */ - char *msg, /* Verb to use in error messages, e.g. - * "read" or "set". Only needed if - * TCL_LEAVE_ERR_MSG is set in flags. */ - int create, /* OR'ed combination of CRT_PART1 and - * CRT_PART2. Tells which entries to create - * if they don't already exist. */ - Var **arrayPtrPtr /* If the name refers to an element of an - * array, *arrayPtrPtr gets filled in with - * address of array variable. Otherwise - * this is set to NULL. */ -) -{ - Interp *iPtr = (Interp *) interp; - Tcl_HashTable *tablePtr; - Tcl_HashEntry *hPtr; - Var *varPtr; - int new; - char *openParen, *closeParen; /* If this procedure parses a name - * into array and index, these point - * to the parens around the index. - * Otherwise they are NULL. These - * are needed to restore the parens - * after parsing the name. */ - char *elName; /* Name of array element or NULL; - * may be same as part2, or may be - * openParen+1. */ - char *p; - - /* - * If the name hasn't been parsed into array name and index yet, - * do it now. - */ - - openParen = closeParen = NULL; - elName = part2; - if (flags & PART1_NOT_PARSED) { - for (p = part1; ; p++) { - if (*p == 0) { - elName = NULL; - break; - } - if (*p == '(') { - openParen = p; - do { - p++; - } while (*p != '\0'); - p--; - if (*p == ')') { - closeParen = p; - *openParen = 0; - elName = openParen+1; - } else { - openParen = NULL; - elName = NULL; - } - break; - } - } - } - - /* - * Lookup part1. - */ - - *arrayPtrPtr = NULL; - if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == NULL)) { - tablePtr = &iPtr->globalTable; - } else { - tablePtr = &iPtr->varFramePtr->varTable; - } - if (create & CRT_PART1) { - hPtr = Tcl_CreateHashEntry(tablePtr, part1, &new); - if (openParen != NULL) { - *openParen = '('; - } - if (new) { - varPtr = NewVar(); - Tcl_SetHashValue(hPtr, varPtr); - varPtr->hPtr = hPtr; - } - } else { - hPtr = Tcl_FindHashEntry(tablePtr, part1); - if (openParen != NULL) { - *openParen = '('; - } - if (hPtr == NULL) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, msg, noSuchVar); - } - return NULL; - } - } - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & VAR_UPVAR) { - varPtr = varPtr->value.upvarPtr; - } - - if (elName == NULL) { - return varPtr; - } - - /* - * We're dealing with an array element, so make sure the variable - * is an array and lookup the element (create it if desired). - */ - - if (varPtr->flags & VAR_UNDEFINED) { - if (!(create & CRT_PART1)) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, msg, noSuchVar); - } - return NULL; - } - varPtr->flags = VAR_ARRAY; - varPtr->value.tablePtr = (Tcl_HashTable *) - ckalloc(sizeof(Tcl_HashTable)); - Tcl_InitHashTable(varPtr->value.tablePtr, TCL_STRING_KEYS); - } else if (!(varPtr->flags & VAR_ARRAY)) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, msg, needArray); - } - return NULL; - } - *arrayPtrPtr = varPtr; - if (closeParen != NULL) { - *closeParen = 0; - } - if (create & CRT_PART2) { - hPtr = Tcl_CreateHashEntry(varPtr->value.tablePtr, elName, &new); - if (closeParen != NULL) { - *closeParen = ')'; - } - if (new) { - if (varPtr->searchPtr != NULL) { - DeleteSearches(varPtr); - } - varPtr = NewVar(); - Tcl_SetHashValue(hPtr, varPtr); - varPtr->hPtr = hPtr; - } - } else { - hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, elName); - if (closeParen != NULL) { - *closeParen = ')'; - } - if (hPtr == NULL) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, msg, noSuchElement); - } - return NULL; - } - } - return (Var *) Tcl_GetHashValue(hPtr); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetVar -- - * - * Return the value of a Tcl variable. - * - * Results: - * The return value points to the current value of varName. If - * the variable is not defined or can't be read because of a clash - * in array usage then a NULL pointer is returned and an error - * message is left in interp->result if the TCL_LEAVE_ERR_MSG - * flag is set. Note: the return value is only valid up until - * the next call to Tcl_SetVar or Tcl_SetVar2; if you depend on - * the value lasting longer than that, then make yourself a private - * copy. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_GetVar( - Tcl_Interp *interp, /* Command interpreter in which varName is - * to be looked up. */ - char *varName, /* Name of a variable in interp. */ - int flags /* OR-ed combination of TCL_GLOBAL_ONLY - * or TCL_LEAVE_ERR_MSG bits. */ -) -{ - return Tcl_GetVar2(interp, varName, (char *) NULL, - flags | PART1_NOT_PARSED); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GetVar2 -- - * - * Return the value of a Tcl variable, given a two-part name - * consisting of array name and element within array. - * - * Results: - * The return value points to the current value of the variable - * given by part1 and part2. If the specified variable doesn't - * exist, or if there is a clash in array usage, then NULL is - * returned and a message will be left in interp->result if the - * TCL_LEAVE_ERR_MSG flag is set. Note: the return value is - * only valid up until the next call to Tcl_SetVar or Tcl_SetVar2; - * if you depend on the value lasting longer than that, then make - * yourself a private copy. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_GetVar2( - Tcl_Interp *interp, /* Command interpreter in which variable is - * to be looked up. */ - char *part1, /* Name of array (if part2 is NULL) or - * name of variable. */ - char *part2, /* If non-null, gives name of element in - * array. */ - int flags /* OR-ed combination of TCL_GLOBAL_ONLY, - * TCL_LEAVE_ERR_MSG, and PART1_NOT_PARSED - * bits. */ -) -{ - Var *varPtr, *arrayPtr; - Interp *iPtr = (Interp *) interp; - - varPtr = LookupVar(interp, part1, part2, flags, "read", CRT_PART2, - &arrayPtr); - if (varPtr == NULL) { - return NULL; - } - - /* - * Invoke any traces that have been set for the variable. - */ - - if ((varPtr->tracePtr != NULL) - || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) { - char *msg; - - msg = CallTraces(iPtr, arrayPtr, varPtr, part1, part2, - (flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED)) | TCL_TRACE_READS); - if (msg != NULL) { - VarErrMsg(interp, part1, part2, "read", msg); - goto cleanup; - } - } - if (!(varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR|VAR_ARRAY))) { - return varPtr->value.string; - } - if (flags & TCL_LEAVE_ERR_MSG) { - char *msg; - - if ((varPtr->flags & VAR_UNDEFINED) && (arrayPtr != NULL) - && !(arrayPtr->flags & VAR_UNDEFINED)) { - msg = noSuchElement; - } else if (varPtr->flags & VAR_ARRAY) { - msg = isArray; - } else { - msg = noSuchVar; - } - VarErrMsg(interp, part1, part2, "read", msg); - } - - /* - * If the variable doesn't exist anymore and no-one's using it, - * then free up the relevant structures and hash table entries. - */ - - cleanup: - if (varPtr->flags & VAR_UNDEFINED) { - CleanupVar(varPtr, arrayPtr); - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetVar -- - * - * Change the value of a variable. - * - * Results: - * Returns a pointer to the malloc'ed string holding the new - * value of the variable. The caller should not modify this - * string. If the write operation was disallowed then NULL - * is returned; if the TCL_LEAVE_ERR_MSG flag is set, then - * an explanatory message will be left in interp->result. - * - * Side effects: - * If varName is defined as a local or global variable in interp, - * its value is changed to newValue. If varName isn't currently - * defined, then a new global variable by that name is created. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_SetVar( - Tcl_Interp *interp, /* Command interpreter in which varName is - * to be looked up. */ - char *varName, /* Name of a variable in interp. */ - char *newValue, /* New value for varName. */ - int flags /* Various flags that tell how to set value: - * any of TCL_GLOBAL_ONLY, TCL_APPEND_VALUE, - * TCL_LIST_ELEMENT, or TCL_LEAVE_ERR_MSG. */ -) -{ - return Tcl_SetVar2(interp, varName, (char *) NULL, newValue, - flags | PART1_NOT_PARSED); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetVar2 -- - * - * Given a two-part variable name, which may refer either to a - * scalar variable or an element of an array, change the value - * of the variable. If the named scalar or array or element - * doesn't exist then create one. - * - * Results: - * Returns a pointer to the malloc'ed string holding the new - * value of the variable. The caller should not modify this - * string. If the write operation was disallowed because an - * array was expected but not found (or vice versa), then NULL - * is returned; if the TCL_LEAVE_ERR_MSG flag is set, then - * an explanatory message will be left in interp->result. - * - * Side effects: - * The value of the given variable is set. If either the array - * or the entry didn't exist then a new one is created. - * - *---------------------------------------------------------------------- - */ - -char * -Tcl_SetVar2( - Tcl_Interp *interp, /* Command interpreter in which variable is - * to be looked up. */ - char *part1, /* If part2 is NULL, this is name of scalar - * variable. Otherwise it is name of array. */ - char *part2, /* Name of an element within array, or NULL. */ - char *newValue, /* New value for variable. */ - int flags /* Various flags that tell how to set value: - * any of TCL_GLOBAL_ONLY, TCL_APPEND_VALUE, - * TCL_LIST_ELEMENT, TCL_LEAVE_ERR_MSG, or - * PART1_NOT_PARSED. */ -) -{ - Var *varPtr; - Interp *iPtr = (Interp *) interp; - int length, listFlags; - Var *arrayPtr; - char *result; - - varPtr = LookupVar(interp, part1, part2, flags, "set", CRT_PART1|CRT_PART2, - &arrayPtr); - if (varPtr == NULL) { - return NULL; - } - - /* - * If the variable's hPtr field is NULL, it means that this is an - * upvar to an array element where the array was deleted, leaving - * the element dangling at the end of the upvar. Generate an error - * (allowing the variable to be reset would screw up our storage - * allocation and is meaningless anyway). - */ - - if (varPtr->hPtr == NULL) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, "set", danglingUpvar); - } - return NULL; - } - - /* - * Clear the variable's current value unless this is an - * append operation. - */ - - if (varPtr->flags & VAR_ARRAY) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, "set", isArray); - } - return NULL; - } - if (!(flags & TCL_APPEND_VALUE) || (varPtr->flags & VAR_UNDEFINED)) { - varPtr->valueLength = 0; - } - - /* - * Call read trace if variable is being appended to. - */ - - if ((flags & TCL_APPEND_VALUE) && ((varPtr->tracePtr != NULL) - || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL)))) { - char *msg; - msg = CallTraces(iPtr, arrayPtr, varPtr, part1, part2, - (flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED)) | TCL_TRACE_READS); - if (msg != NULL) { - VarErrMsg(interp, part1, part2, "read", msg); - result = NULL; - goto cleanup; - } - } - - /* - * Compute how many total bytes will be needed for the variable's - * new value (leave space for a separating space between list - * elements). Allocate new space for the value if needed. - */ - - if (flags & TCL_LIST_ELEMENT) { - length = Tcl_ScanElement(newValue, &listFlags) + 1; - } else { - length = strlen(newValue); - } - length += varPtr->valueLength; - if (length >= varPtr->valueSpace) { - char *newValue; - int newSize; - - newSize = 2*varPtr->valueSpace; - if (newSize <= length) { - newSize = length + 1; - } - if (newSize < 24) { - /* - * Don't waste time with teensy-tiny variables; we'll - * just end up expanding them later. - */ - - newSize = 24; - } - newValue = (char *) ckalloc((unsigned) newSize); - if (varPtr->valueSpace > 0) { - strcpy(newValue, varPtr->value.string); - ckfree(varPtr->value.string); - } - varPtr->valueSpace = newSize; - varPtr->value.string = newValue; - } - - /* - * Append the new value to the variable, either as a list - * element or as a string. - */ - - if (flags & TCL_LIST_ELEMENT) { - char *dst = varPtr->value.string + varPtr->valueLength; - - if (TclNeedSpace(varPtr->value.string, dst)) { - *dst = ' '; - dst++; - varPtr->valueLength++; - } - varPtr->valueLength += Tcl_ConvertElement(newValue, dst, listFlags); - } else { - strcpy(varPtr->value.string + varPtr->valueLength, newValue); - varPtr->valueLength = length; - } - varPtr->flags &= ~VAR_UNDEFINED; - - /* - * Invoke any write traces for the variable. - */ - - if ((varPtr->tracePtr != NULL) - || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) { - char *msg; - - msg = CallTraces(iPtr, arrayPtr, varPtr, part1, part2, - (flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED)) - | TCL_TRACE_WRITES); - if (msg != NULL) { - VarErrMsg(interp, part1, part2, "set", msg); - result = NULL; - goto cleanup; - } - } - - /* - * If the variable was changed in some gross way by a trace (e.g. - * it was unset and then recreated as an array) then just return - * an empty string; otherwise return the variable's current - * value. - */ - - if (!(varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR|VAR_ARRAY))) { - return varPtr->value.string; - } - result = ""; - - /* - * If the variable doesn't exist anymore and no-one's using it, - * then free up the relevant structures and hash table entries. - */ - - cleanup: - if (varPtr->flags & VAR_UNDEFINED) { - CleanupVar(varPtr, arrayPtr); - } - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UnsetVar -- - * - * Delete a variable, so that it may not be accessed anymore. - * - * Results: - * Returns TCL_OK if the variable was successfully deleted, TCL_ERROR - * if the variable can't be unset. In the event of an error, - * if the TCL_LEAVE_ERR_MSG flag is set then an error message - * is left in interp->result. - * - * Side effects: - * If varName is defined as a local or global variable in interp, - * it is deleted. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_UnsetVar( - Tcl_Interp *interp, /* Command interpreter in which varName is - * to be looked up. */ - char *varName, /* Name of a variable in interp. May be - * either a scalar name or an array name - * or an element in an array. */ - int flags /* OR-ed combination of any of - * TCL_GLOBAL_ONLY or TCL_LEAVE_ERR_MSG. */ -) -{ - return Tcl_UnsetVar2(interp, varName, (char *) NULL, - flags | PART1_NOT_PARSED); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UnsetVar2 -- - * - * Delete a variable, given a 2-part name. - * - * Results: - * Returns TCL_OK if the variable was successfully deleted, TCL_ERROR - * if the variable can't be unset. In the event of an error, - * if the TCL_LEAVE_ERR_MSG flag is set then an error message - * is left in interp->result. - * - * Side effects: - * If part1 and part2 indicate a local or global variable in interp, - * it is deleted. If part1 is an array name and part2 is NULL, then - * the whole array is deleted. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_UnsetVar2( - Tcl_Interp *interp, /* Command interpreter in which varName is - * to be looked up. */ - char *part1, /* Name of variable or array. */ - char *part2, /* Name of element within array or NULL. */ - int flags /* OR-ed combination of any of - * TCL_GLOBAL_ONLY, TCL_LEAVE_ERR_MSG, - * or PART1_NOT_PARSED. */ -) -{ - Var *varPtr, dummyVar; - Interp *iPtr = (Interp *) interp; - Var *arrayPtr; - ActiveVarTrace *activePtr; - int result; - - varPtr = LookupVar(interp, part1, part2, flags, "unset", 0, &arrayPtr); - if (varPtr == NULL) { - return TCL_ERROR; - } - result = (varPtr->flags & VAR_UNDEFINED) ? TCL_ERROR : TCL_OK; - - if ((arrayPtr != NULL) && (arrayPtr->searchPtr != NULL)) { - DeleteSearches(arrayPtr); - } - - /* - * The code below is tricky, because of the possibility that - * a trace procedure might try to access a variable being - * deleted. To handle this situation gracefully, do things - * in three steps: - * 1. Copy the contents of the variable to a dummy variable - * structure, and mark the original structure as undefined. - * 2. Invoke traces and clean up the variable, using the copy. - * 3. If at the end of this the original variable is still - * undefined and has no outstanding references, then delete - * it (but it could have gotten recreated by a trace). - */ - - dummyVar = *varPtr; - varPtr->valueSpace = 0; - varPtr->flags = VAR_UNDEFINED; - varPtr->tracePtr = NULL; - varPtr->searchPtr = NULL; - - /* - * Call trace procedures for the variable being deleted and delete - * its traces. Be sure to abort any other traces for the variable - * that are still pending. Special tricks: - * 1. Increment varPtr's refCount around this: CallTraces will - * use dummyVar so it won't increment varPtr's refCount. - * 2. Turn off the VAR_TRACE_ACTIVE flag in dummyVar: we want to - * call unset traces even if other traces are pending. - */ - - if ((dummyVar.tracePtr != NULL) - || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) { - varPtr->refCount++; - dummyVar.flags &= ~VAR_TRACE_ACTIVE; - (void) CallTraces(iPtr, arrayPtr, &dummyVar, part1, part2, - (flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED)) - | TCL_TRACE_UNSETS); - while (dummyVar.tracePtr != NULL) { - VarTrace *tracePtr = dummyVar.tracePtr; - dummyVar.tracePtr = tracePtr->nextPtr; - ckfree((char *) tracePtr); - } - for (activePtr = iPtr->activeTracePtr; activePtr != NULL; - activePtr = activePtr->nextPtr) { - if (activePtr->varPtr == varPtr) { - activePtr->nextTracePtr = NULL; - } - } - varPtr->refCount--; - } - - /* - * If the variable is an array, delete all of its elements. This - * must be done after calling the traces on the array, above (that's - * the way traces are defined). - */ - - if (dummyVar.flags & VAR_ARRAY) { - DeleteArray(iPtr, part1, &dummyVar, - (flags & TCL_GLOBAL_ONLY) | TCL_TRACE_UNSETS); - } - if (dummyVar.valueSpace > 0) { - ckfree(dummyVar.value.string); - } - if (result == TCL_ERROR) { - if (flags & TCL_LEAVE_ERR_MSG) { - VarErrMsg(interp, part1, part2, "unset", - (arrayPtr == NULL) ? noSuchVar : noSuchElement); - } - } - - /* - * Finally, if the variable is truly not in use then free up its - * record and remove it from the hash table. - */ - - CleanupVar(varPtr, arrayPtr); - return result; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TraceVar -- - * - * Arrange for reads and/or writes to a variable to cause a - * procedure to be invoked, which can monitor the operations - * and/or change their actions. - * - * Results: - * A standard Tcl return value. - * - * Side effects: - * A trace is set up on the variable given by varName, such that - * future references to the variable will be intermediated by - * proc. See the manual entry for complete details on the calling - * sequence for proc. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_TraceVar( - Tcl_Interp *interp, /* Interpreter in which variable is - * to be traced. */ - char *varName, /* Name of variable; may end with "(index)" - * to signify an array reference. */ - int flags, /* OR-ed collection of bits, including any - * of TCL_TRACE_READS, TCL_TRACE_WRITES, - * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ - Tcl_VarTraceProc *proc, /* Procedure to call when specified ops are - * invoked upon varName. */ - ClientData clientData /* Arbitrary argument to pass to proc. */ -) -{ - return Tcl_TraceVar2(interp, varName, (char *) NULL, - flags | PART1_NOT_PARSED, proc, clientData); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_TraceVar2 -- - * - * Arrange for reads and/or writes to a variable to cause a - * procedure to be invoked, which can monitor the operations - * and/or change their actions. - * - * Results: - * A standard Tcl return value. - * - * Side effects: - * A trace is set up on the variable given by part1 and part2, such - * that future references to the variable will be intermediated by - * proc. See the manual entry for complete details on the calling - * sequence for proc. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_TraceVar2( - Tcl_Interp *interp, /* Interpreter in which variable is - * to be traced. */ - char *part1, /* Name of scalar variable or array. */ - char *part2, /* Name of element within array; NULL means - * trace applies to scalar variable or array - * as-a-whole. */ - int flags, /* OR-ed collection of bits, including any - * of TCL_TRACE_READS, TCL_TRACE_WRITES, - * TCL_TRACE_UNSETS, TCL_GLOBAL_ONLY, and - * PART1_NOT_PARSED. */ - Tcl_VarTraceProc *proc, /* Procedure to call when specified ops are - * invoked upon varName. */ - ClientData clientData /* Arbitrary argument to pass to proc. */ -) -{ - Var *varPtr, *arrayPtr; - VarTrace *tracePtr; - - varPtr = LookupVar(interp, part1, part2, (flags | TCL_LEAVE_ERR_MSG), - "trace", CRT_PART1|CRT_PART2, &arrayPtr); - if (varPtr == NULL) { - return TCL_ERROR; - } - - /* - * Set up trace information. - */ - - tracePtr = (VarTrace *) ckalloc(sizeof(VarTrace)); - tracePtr->traceProc = proc; - tracePtr->clientData = clientData; - tracePtr->flags = flags & - (TCL_TRACE_READS|TCL_TRACE_WRITES|TCL_TRACE_UNSETS); - tracePtr->nextPtr = varPtr->tracePtr; - varPtr->tracePtr = tracePtr; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UntraceVar -- - * - * Remove a previously-created trace for a variable. - * - * Results: - * None. - * - * Side effects: - * If there exists a trace for the variable given by varName - * with the given flags, proc, and clientData, then that trace - * is removed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_UntraceVar( - Tcl_Interp *interp, /* Interpreter containing traced variable. */ - char *varName, /* Name of variable; may end with "(index)" - * to signify an array reference. */ - int flags, /* OR-ed collection of bits describing - * current trace, including any of - * TCL_TRACE_READS, TCL_TRACE_WRITES, - * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ - Tcl_VarTraceProc *proc, /* Procedure assocated with trace. */ - ClientData clientData /* Arbitrary argument to pass to proc. */ -) -{ - Tcl_UntraceVar2(interp, varName, (char *) NULL, flags | PART1_NOT_PARSED, - proc, clientData); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UntraceVar2 -- - * - * Remove a previously-created trace for a variable. - * - * Results: - * None. - * - * Side effects: - * If there exists a trace for the variable given by part1 - * and part2 with the given flags, proc, and clientData, then - * that trace is removed. - * - *---------------------------------------------------------------------- - */ - -void -Tcl_UntraceVar2( - Tcl_Interp *interp, /* Interpreter containing traced variable. */ - char *part1, /* Name of variable or array. */ - char *part2, /* Name of element within array; NULL means - * trace applies to scalar variable or array - * as-a-whole. */ - int flags, /* OR-ed collection of bits describing - * current trace, including any of - * TCL_TRACE_READS, TCL_TRACE_WRITES, - * TCL_TRACE_UNSETS, TCL_GLOBAL_ONLY, and - * PART1_NOT_PARSED. */ - Tcl_VarTraceProc *proc, /* Procedure assocated with trace. */ - ClientData clientData /* Arbitrary argument to pass to proc. */ -) -{ - VarTrace *tracePtr; - VarTrace *prevPtr; - Var *varPtr, *arrayPtr; - Interp *iPtr = (Interp *) interp; - ActiveVarTrace *activePtr; - - varPtr = LookupVar(interp, part1, part2, - flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED), (char *) NULL, 0, - &arrayPtr); - if (varPtr == NULL) { - return; - } - - flags &= (TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS); - for (tracePtr = varPtr->tracePtr, prevPtr = NULL; ; - prevPtr = tracePtr, tracePtr = tracePtr->nextPtr) { - if (tracePtr == NULL) { - return; - } - if ((tracePtr->traceProc == proc) && (tracePtr->flags == flags) - && (tracePtr->clientData == clientData)) { - break; - } - } - - /* - * The code below makes it possible to delete traces while traces - * are active: it makes sure that the deleted trace won't be - * processed by CallTraces. - */ - - for (activePtr = iPtr->activeTracePtr; activePtr != NULL; - activePtr = activePtr->nextPtr) { - if (activePtr->nextTracePtr == tracePtr) { - activePtr->nextTracePtr = tracePtr->nextPtr; - } - } - if (prevPtr == NULL) { - varPtr->tracePtr = tracePtr->nextPtr; - } else { - prevPtr->nextPtr = tracePtr->nextPtr; - } - ckfree((char *) tracePtr); - - /* - * If this is the last trace on the variable, and the variable is - * unset and unused, then free up the variable. - */ - - if (varPtr->flags & VAR_UNDEFINED) { - CleanupVar(varPtr, (Var *) NULL); - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_VarTraceInfo -- - * - * Return the clientData value associated with a trace on a - * variable. This procedure can also be used to step through - * all of the traces on a particular variable that have the - * same trace procedure. - * - * Results: - * The return value is the clientData value associated with - * a trace on the given variable. Information will only be - * returned for a trace with proc as trace procedure. If - * the clientData argument is NULL then the first such trace is - * returned; otherwise, the next relevant one after the one - * given by clientData will be returned. If the variable - * doesn't exist, or if there are no (more) traces for it, - * then NULL is returned. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_VarTraceInfo( - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *varName, /* Name of variable; may end with "(index)" - * to signify an array reference. */ - int flags, /* 0 or TCL_GLOBAL_ONLY. */ - Tcl_VarTraceProc *proc, /* Procedure assocated with trace. */ - ClientData prevClientData /* If non-NULL, gives last value returned - * by this procedure, so this call will - * return the next trace after that one. - * If NULL, this call will return the - * first trace. */ -) -{ - return Tcl_VarTraceInfo2(interp, varName, (char *) NULL, - flags | PART1_NOT_PARSED, proc, prevClientData); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_VarTraceInfo2 -- - * - * Same as Tcl_VarTraceInfo, except takes name in two pieces - * instead of one. - * - * Results: - * Same as Tcl_VarTraceInfo. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -ClientData -Tcl_VarTraceInfo2( - Tcl_Interp *interp, /* Interpreter containing variable. */ - char *part1, /* Name of variable or array. */ - char *part2, /* Name of element within array; NULL means - * trace applies to scalar variable or array - * as-a-whole. */ - int flags, /* OR-ed combination of TCL_GLOBAL_ONLY and - * PART1_NOT_PARSED. */ - Tcl_VarTraceProc *proc, /* Procedure assocated with trace. */ - ClientData prevClientData /* If non-NULL, gives last value returned - * by this procedure, so this call will - * return the next trace after that one. - * If NULL, this call will return the - * first trace. */ -) -{ - VarTrace *tracePtr; - Var *varPtr, *arrayPtr; - - varPtr = LookupVar(interp, part1, part2, - flags & (TCL_GLOBAL_ONLY|PART1_NOT_PARSED), (char *) NULL, 0, - &arrayPtr); - if (varPtr == NULL) { - return NULL; - } - - /* - * Find the relevant trace, if any, and return its clientData. - */ - - tracePtr = varPtr->tracePtr; - if (prevClientData != NULL) { - for ( ; tracePtr != NULL; tracePtr = tracePtr->nextPtr) { - if ((tracePtr->clientData == prevClientData) - && (tracePtr->traceProc == proc)) { - tracePtr = tracePtr->nextPtr; - break; - } - } - } - for ( ; tracePtr != NULL; tracePtr = tracePtr->nextPtr) { - if (tracePtr->traceProc == proc) { - return tracePtr->clientData; - } - } - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_SetCmd -- - * - * This procedure is invoked to process the "set" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * A variable's value may be changed. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_SetCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - if (argc == 2) { - char *value; - - value = Tcl_GetVar2(interp, argv[1], (char *) NULL, - TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED); - if (value == NULL) { - return TCL_ERROR; - } - interp->result = value; - return TCL_OK; - } else if (argc == 3) { - char *result; - - result = Tcl_SetVar2(interp, argv[1], (char *) NULL, argv[2], - TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED); - if (result == NULL) { - return TCL_ERROR; - } - interp->result = result; - return TCL_OK; - } else { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " varName ?newValue?\"", (char *) NULL); - return TCL_ERROR; - } -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UnsetCmd -- - * - * This procedure is invoked to process the "unset" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_UnsetCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " varName ?varName ...?\"", (char *) NULL); - return TCL_ERROR; - } - for (i = 1; i < argc; i++) { - if (Tcl_UnsetVar2(interp, argv[i], (char *) NULL, - TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED) != TCL_OK) { - return TCL_ERROR; - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_AppendCmd -- - * - * This procedure is invoked to process the "append" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * A variable's value may be changed. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_AppendCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i; - char *result = NULL; /* (Initialization only needed to keep - * the compiler from complaining) */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " varName ?value value ...?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 2) { - result = Tcl_GetVar2(interp, argv[1], (char *) NULL, - TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED); - if (result == NULL) { - return TCL_ERROR; - } - interp->result = result; - return TCL_OK; - } - - for (i = 2; i < argc; i++) { - result = Tcl_SetVar2(interp, argv[1], (char *) NULL, argv[i], - TCL_APPEND_VALUE|TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED); - if (result == NULL) { - return TCL_ERROR; - } - } - interp->result = result; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_LappendCmd -- - * - * This procedure is invoked to process the "lappend" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * A variable's value may be changed. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_LappendCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int i; - char *result = NULL; /* (Initialization only needed to keep - * the compiler from complaining) */ - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " varName ?value value ...?\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 2) { - result = Tcl_GetVar2(interp, argv[1], (char *) NULL, - TCL_LEAVE_ERR_MSG|PART1_NOT_PARSED); - if (result == NULL) { - return TCL_ERROR; - } - interp->result = result; - return TCL_OK; - } - - for (i = 2; i < argc; i++) { - result = Tcl_SetVar2(interp, argv[1], (char *) NULL, argv[i], - TCL_APPEND_VALUE|TCL_LIST_ELEMENT|TCL_LEAVE_ERR_MSG - |PART1_NOT_PARSED); - if (result == NULL) { - return TCL_ERROR; - } - } - interp->result = result; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_ArrayCmd -- - * - * This procedure is invoked to process the "array" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_ArrayCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - int c, notArray; - size_t length; - Var *varPtr = NULL; /* Initialization needed only to prevent - * compiler warning. */ - Tcl_HashEntry *hPtr; - Interp *iPtr = (Interp *) interp; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option arrayName ?arg ...?\"", (char *) NULL); - return TCL_ERROR; - } - - /* - * Locate the array variable (and it better be an array). - */ - - if (iPtr->varFramePtr == NULL) { - hPtr = Tcl_FindHashEntry(&iPtr->globalTable, argv[2]); - } else { - hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, argv[2]); - } - notArray = 0; - if (hPtr == NULL) { - notArray = 1; - } else { - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr->flags & VAR_UPVAR) { - varPtr = varPtr->value.upvarPtr; - } - if (!(varPtr->flags & VAR_ARRAY)) { - notArray = 1; - } - } - - /* - * Dispatch based on the option. - */ - - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'a') && (strncmp(argv[1], "anymore", length) == 0)) { - ArraySearch *searchPtr; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " anymore arrayName searchId\"", (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - goto error; - } - searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); - if (searchPtr == NULL) { - return TCL_ERROR; - } - while (1) { - Var *varPtr2; - - if (searchPtr->nextEntry != NULL) { - varPtr2 = (Var *) Tcl_GetHashValue(searchPtr->nextEntry); - if (!(varPtr2->flags & VAR_UNDEFINED)) { - break; - } - } - searchPtr->nextEntry = Tcl_NextHashEntry(&searchPtr->search); - if (searchPtr->nextEntry == NULL) { - interp->result = "0"; - return TCL_OK; - } - } - interp->result = "1"; - return TCL_OK; - } else if ((c == 'd') && (strncmp(argv[1], "donesearch", length) == 0)) { - ArraySearch *searchPtr, *prevPtr; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " donesearch arrayName searchId\"", (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - goto error; - } - searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); - if (searchPtr == NULL) { - return TCL_ERROR; - } - if (varPtr->searchPtr == searchPtr) { - varPtr->searchPtr = searchPtr->nextPtr; - } else { - for (prevPtr = varPtr->searchPtr; ; prevPtr = prevPtr->nextPtr) { - if (prevPtr->nextPtr == searchPtr) { - prevPtr->nextPtr = searchPtr->nextPtr; - break; - } - } - } - ckfree((char *) searchPtr); - } else if ((c == 'e') && (strncmp(argv[1], "exists", length) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " exists arrayName\"", (char *) NULL); - return TCL_ERROR; - } - interp->result = (notArray) ? "0" : "1"; - } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { - Tcl_HashSearch search; - Var *varPtr2; - char *name; - - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " get arrayName ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr2 = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr2->flags & VAR_UNDEFINED) { - continue; - } - name = Tcl_GetHashKey(varPtr->value.tablePtr, hPtr); - if ((argc == 4) && !Tcl_StringMatch(name, argv[3])) { - continue; - } - Tcl_AppendElement(interp, name); - Tcl_AppendElement(interp, varPtr2->value.string); - } - } else if ((c == 'n') && (strncmp(argv[1], "names", length) == 0) - && (length >= 2)) { - Tcl_HashSearch search; - Var *varPtr2; - char *name; - - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " names arrayName ?pattern?\"", (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - return TCL_OK; - } - for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr2 = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr2->flags & VAR_UNDEFINED) { - continue; - } - name = Tcl_GetHashKey(varPtr->value.tablePtr, hPtr); - if ((argc == 4) && !Tcl_StringMatch(name, argv[3])) { - continue; - } - Tcl_AppendElement(interp, name); - } - } else if ((c == 'n') && (strncmp(argv[1], "nextelement", length) == 0) - && (length >= 2)) { - ArraySearch *searchPtr; - Tcl_HashEntry *hPtr; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " nextelement arrayName searchId\"", - (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - goto error; - } - searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); - if (searchPtr == NULL) { - return TCL_ERROR; - } - while (1) { - Var *varPtr2; - - hPtr = searchPtr->nextEntry; - if (hPtr == NULL) { - hPtr = Tcl_NextHashEntry(&searchPtr->search); - if (hPtr == NULL) { - return TCL_OK; - } - } else { - searchPtr->nextEntry = NULL; - } - varPtr2 = (Var *) Tcl_GetHashValue(hPtr); - if (!(varPtr2->flags & VAR_UNDEFINED)) { - break; - } - } - interp->result = Tcl_GetHashKey(varPtr->value.tablePtr, hPtr); - } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0) - && (length >= 2)) { - char **valueArgv; - int valueArgc, i, result; - - if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " set arrayName list\"", (char *) NULL); - return TCL_ERROR; - } - if (Tcl_SplitList(interp, argv[3], &valueArgc, &valueArgv) != TCL_OK) { - return TCL_ERROR; - } - result = TCL_OK; - if (valueArgc & 1) { - interp->result = "list must have an even number of elements"; - result = TCL_ERROR; - goto setDone; - } - for (i = 0; i < valueArgc; i += 2) { - if (Tcl_SetVar2(interp, argv[2], valueArgv[i], valueArgv[i+1], - TCL_LEAVE_ERR_MSG) == NULL) { - result = TCL_ERROR; - break; - } - } - setDone: - ckfree((char *) valueArgv); - return result; - } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0) - && (length >= 2)) { - Tcl_HashSearch search; - Var *varPtr2; - int size; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " size arrayName\"", (char *) NULL); - return TCL_ERROR; - } - size = 0; - if (!notArray) { - for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - varPtr2 = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr2->flags & VAR_UNDEFINED) { - continue; - } - size++; - } - } - sprintf(interp->result, "%ld", (long)size); - } else if ((c == 's') && (strncmp(argv[1], "startsearch", length) == 0) - && (length >= 2)) { - ArraySearch *searchPtr; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " startsearch arrayName\"", (char *) NULL); - return TCL_ERROR; - } - if (notArray) { - goto error; - } - searchPtr = (ArraySearch *) ckalloc(sizeof(ArraySearch)); - if (varPtr->searchPtr == NULL) { - searchPtr->id = 1; - Tcl_AppendResult(interp, "s-1-", argv[2], (char *) NULL); - } else { - char string[20]; - - searchPtr->id = varPtr->searchPtr->id + 1; - sprintf(string, "%d", searchPtr->id); - Tcl_AppendResult(interp, "s-", string, "-", argv[2], - (char *) NULL); - } - searchPtr->varPtr = varPtr; - searchPtr->nextEntry = Tcl_FirstHashEntry(varPtr->value.tablePtr, - &searchPtr->search); - searchPtr->nextPtr = varPtr->searchPtr; - varPtr->searchPtr = searchPtr; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": should be anymore, donesearch, exists, ", - "get, names, nextelement, ", - "set, size, or startsearch", (char *) NULL); - return TCL_ERROR; - } - return TCL_OK; - - error: - Tcl_AppendResult(interp, "\"", argv[2], "\" isn't an array", - (char *) NULL); - return TCL_ERROR; -} - -/* - *---------------------------------------------------------------------- - * - * MakeUpvar -- - * - * This procedure does all of the work of the "global" and "upvar" - * commands. - * - * Results: - * A standard Tcl completion code. If an error occurs then an - * error message is left in iPtr->result. - * - * Side effects: - * The variable given by myName is linked to the variable in - * framePtr given by otherP1 and otherP2, so that references to - * myName are redirected to the other variable like a symbolic -* link. - * - *---------------------------------------------------------------------- - */ - -static int -MakeUpvar( - Interp *iPtr, /* Interpreter containing variables. Used - * for error messages, too. */ - CallFrame *framePtr, /* Call frame containing "other" variable. - * NULL means use global context. */ - char *otherP1, char *otherP2,/* Two-part name of variable in framePtr. */ - char *myName, /* Name of variable in local table, which - * will refer to otherP1/P2. Must be a - * scalar. */ - int flags /* 0 or TCL_GLOBAL_ONLY: indicates scope of - * myName. */ -) -{ - Tcl_HashEntry *hPtr; - Var *otherPtr, *varPtr, *arrayPtr; - CallFrame *savedFramePtr; - int new; - - /* - * In order to use LookupVar to find "other", temporarily replace - * the current frame pointer in the interpreter. - */ - - savedFramePtr = iPtr->varFramePtr; - iPtr->varFramePtr = framePtr; - otherPtr = LookupVar((Tcl_Interp *) iPtr, otherP1, otherP2, - TCL_LEAVE_ERR_MSG, "access", CRT_PART1|CRT_PART2, &arrayPtr); - iPtr->varFramePtr = savedFramePtr; - if (otherPtr == NULL) { - return TCL_ERROR; - } - if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == NULL)) { - hPtr = Tcl_CreateHashEntry(&iPtr->globalTable, myName, &new); - } else { - hPtr = Tcl_CreateHashEntry(&iPtr->varFramePtr->varTable, myName, &new); - } - if (new) { - varPtr = NewVar(); - Tcl_SetHashValue(hPtr, varPtr); - varPtr->hPtr = hPtr; - } else { - /* - * The variable already exists. Make sure that this variable - * isn't also "otherVar" (avoid circular links). Also, if it's - * not an upvar then it's an error. If it is an upvar, then - * just disconnect it from the thing it currently refers to. - */ - - varPtr = (Var *) Tcl_GetHashValue(hPtr); - if (varPtr == otherPtr) { - iPtr->result = "can't upvar from variable to itself"; - return TCL_ERROR; - } - if (varPtr->flags & VAR_UPVAR) { - Var *upvarPtr; - - upvarPtr = varPtr->value.upvarPtr; - if (upvarPtr == otherPtr) { - return TCL_OK; - } - upvarPtr->refCount--; - if (upvarPtr->flags & VAR_UNDEFINED) { - CleanupVar(upvarPtr, (Var *) NULL); - } - } else if (!(varPtr->flags & VAR_UNDEFINED)) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", myName, - "\" already exists", (char *) NULL); - return TCL_ERROR; - } else if (varPtr->tracePtr != NULL) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", myName, - "\" has traces: can't use for upvar", (char *) NULL); - return TCL_ERROR; - } - } - varPtr->flags = (varPtr->flags & ~VAR_UNDEFINED) | VAR_UPVAR; - varPtr->value.upvarPtr = otherPtr; - otherPtr->refCount++; - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UpVar -- - * - * Delete a variable, so that it may not be accessed anymore. - * - * Results: - * Returns TCL_OK if the variable was successfully deleted, TCL_ERROR - * if the variable can't be unset. In the event of an error, - * if the TCL_LEAVE_ERR_MSG flag is set then an error message - * is left in interp->result. - * - * Side effects: - * If varName is defined as a local or global variable in interp, - * it is deleted. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_UpVar( - Tcl_Interp *interp, /* Command interpreter in which varName is - * to be looked up. */ - char *frameName, /* Name of the frame containing the source - * variable, such as "1" or "#0". */ - char *varName, /* Name of a variable in interp. May be - * either a scalar name or an element - * in an array. */ - char *localName, /* Destination variable name. */ - int flags /* Either 0 or TCL_GLOBAL_ONLY; indicates - * whether localName is local or global. */ -) -{ - int result; - CallFrame *framePtr; - char *p; - - result = TclGetFrame(interp, frameName, &framePtr); - if (result == -1) { - return TCL_ERROR; - } - - /* - * Figure out whether this is an array reference, then call - * Tcl_UpVar2 to do all the real work. - */ - - for (p = varName; *p != '\0'; p++) { - if (*p == '(') { - char *openParen = p; - - do { - p++; - } while (*p != '\0'); - p--; - if (*p != ')') { - goto scalar; - } - *openParen = '\0'; - *p = '\0'; - result = MakeUpvar((Interp *) interp, framePtr, varName, - openParen+1, localName, flags); - *openParen = '('; - *p = ')'; - return result; - } - } - - scalar: - return MakeUpvar((Interp *) interp, framePtr, varName, (char *) NULL, - localName, flags); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UpVar2 -- - * - * This procedure links one variable to another, just like - * the "upvar" command. - * - * Results: - * A standard Tcl completion code. If an error occurs then - * an error message is left in interp->result. - * - * Side effects: - * The variable in frameName whose name is given by part1 and - * part2 becomes accessible under the name newName, so that - * references to newName are redirected to the other variable - * like a symbolic link. - * - *---------------------------------------------------------------------- - */ - -int -Tcl_UpVar2( - Tcl_Interp *interp, /* Interpreter containing variables. Used - * for error messages too. */ - char *frameName, /* Name of the frame containing the source - * variable, such as "1" or "#0". */ - char *part1, char *part2, /* Two parts of source variable name. */ - char *localName, /* Destination variable name. */ - int flags /* TCL_GLOBAL_ONLY or 0. */ -) -{ - int result; - CallFrame *framePtr; - - result = TclGetFrame(interp, frameName, &framePtr); - if (result == -1) { - return TCL_ERROR; - } - return MakeUpvar((Interp *) interp, framePtr, part1, part2, - localName, flags); -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_GlobalCmd -- - * - * This procedure is invoked to process the "global" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_GlobalCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - - if (argc < 2) { - Tcl_AppendResult((Tcl_Interp *) iPtr, "wrong # args: should be \"", - argv[0], " varName ?varName ...?\"", (char *) NULL); - return TCL_ERROR; - } - if (iPtr->varFramePtr == NULL) { - return TCL_OK; - } - - for (argc--, argv++; argc > 0; argc--, argv++) { - if (MakeUpvar(iPtr, (CallFrame *) NULL, *argv, (char *) NULL, *argv, 0) - != TCL_OK) { - return TCL_ERROR; - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * Tcl_UpvarCmd -- - * - * This procedure is invoked to process the "upvar" Tcl command. - * See the user documentation for details on what it does. - * - * Results: - * A standard Tcl result value. - * - * Side effects: - * See the user documentation. - * - *---------------------------------------------------------------------- - */ - - /* ARGSUSED */ -int -Tcl_UpvarCmd( - ClientData dummy, /* Not used. */ - Tcl_Interp *interp, /* Current interpreter. */ - int argc, /* Number of arguments. */ - char **argv /* Argument strings. */ -) -{ - Interp *iPtr = (Interp *) interp; - int result; - CallFrame *framePtr; - char *p; - - if (argc < 3) { - upvarSyntax: - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ?level? otherVar localVar ?otherVar localVar ...?\"", - (char *) NULL); - return TCL_ERROR; - } - - /* - * Find the hash table containing the variable being referenced. - */ - - result = TclGetFrame(interp, argv[1], &framePtr); - if (result == -1) { - return TCL_ERROR; - } - argc -= result+1; - if ((argc & 1) != 0) { - goto upvarSyntax; - } - argv += result+1; - - /* - * Iterate over all the pairs of (other variable, local variable) - * names. For each pair, divide the other variable name into two - * parts, then call MakeUpvar to do all the work of creating linking - * it to the local variable. - */ - - for ( ; argc > 0; argc -= 2, argv += 2) { - for (p = argv[0]; *p != 0; p++) { - if (*p == '(') { - char *openParen = p; - - do { - p++; - } while (*p != '\0'); - p--; - if (*p != ')') { - goto scalar; - } - *openParen = '\0'; - *p = '\0'; - result = MakeUpvar(iPtr, framePtr, argv[0], openParen+1, - argv[1], 0); - *openParen = '('; - *p = ')'; - goto checkResult; - } - } - scalar: - result = MakeUpvar(iPtr, framePtr, argv[0], (char *) NULL, argv[1], 0); - - checkResult: - if (result != TCL_OK) { - return TCL_ERROR; - } - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * CallTraces -- - * - * This procedure is invoked to find and invoke relevant - * trace procedures associated with a particular operation on - * a variable. This procedure invokes traces both on the - * variable and on its containing array (where relevant). - * - * Results: - * The return value is NULL if no trace procedures were invoked, or - * if all the invoked trace procedures returned successfully. - * The return value is non-zero if a trace procedure returned an - * error (in this case no more trace procedures were invoked after - * the error was returned). In this case the return value is a - * pointer to a static string describing the error. - * - * Side effects: - * Almost anything can happen, depending on trace; this procedure - * itself doesn't have any side effects. - * - *---------------------------------------------------------------------- - */ - -static char * -CallTraces( - Interp *iPtr, /* Interpreter containing variable. */ - Var *arrayPtr, /* Pointer to array variable that - * contains the variable, or NULL if - * the variable isn't an element of an - * array. */ - Var *varPtr, /* Variable whose traces are to be - * invoked. */ - char *part1, char *part2, /* Variable's two-part name. */ - int flags /* Flags to pass to trace procedures: - * indicates what's happening to - * variable, plus other stuff like - * TCL_GLOBAL_ONLY and - * TCL_INTERP_DESTROYED. May also - * contain PART1_NOT_PARSEd, which - * should not be passed through - * to callbacks. */ -) -{ - VarTrace *tracePtr; - ActiveVarTrace active; - char *result, *openParen, *p; - Tcl_DString nameCopy; - int copiedName; - - /* - * If there are already similar trace procedures active for the - * variable, don't call them again. - */ - - if (varPtr->flags & VAR_TRACE_ACTIVE) { - return NULL; - } - varPtr->flags |= VAR_TRACE_ACTIVE; - varPtr->refCount++; - - /* - * If the variable name hasn't been parsed into array name and - * element, do it here. If there really is an array element, - * make a copy of the original name so that NULLs can be - * inserted into it to separate the names (can't modify the name - * string in place, because the string might get used by the - * callbacks we invoke). - */ - - copiedName = 0; - if (flags & PART1_NOT_PARSED) { - for (p = part1; ; p++) { - if (*p == 0) { - break; - } - if (*p == '(') { - openParen = p; - do { - p++; - } while (*p != '\0'); - p--; - if (*p == ')') { - Tcl_DStringInit(&nameCopy); - Tcl_DStringAppend(&nameCopy, part1, (p-part1)); - part2 = Tcl_DStringValue(&nameCopy) - + (openParen + 1 - part1); - part2[-1] = 0; - part1 = Tcl_DStringValue(&nameCopy); - copiedName = 1; - } - break; - } - } - } - flags &= ~PART1_NOT_PARSED; - - /* - * Invoke traces on the array containing the variable, if relevant. - */ - - result = NULL; - active.nextPtr = iPtr->activeTracePtr; - iPtr->activeTracePtr = &active; - if (arrayPtr != NULL) { - arrayPtr->refCount++; - active.varPtr = arrayPtr; - for (tracePtr = arrayPtr->tracePtr; tracePtr != NULL; - tracePtr = active.nextTracePtr) { - active.nextTracePtr = tracePtr->nextPtr; - if (!(tracePtr->flags & flags)) { - continue; - } - result = (*tracePtr->traceProc)(tracePtr->clientData, - (Tcl_Interp *) iPtr, part1, part2, flags); - if (result != NULL) { - if (flags & TCL_TRACE_UNSETS) { - result = NULL; - } else { - goto done; - } - } - } - } - - /* - * Invoke traces on the variable itself. - */ - - if (flags & TCL_TRACE_UNSETS) { - flags |= TCL_TRACE_DESTROYED; - } - active.varPtr = varPtr; - for (tracePtr = varPtr->tracePtr; tracePtr != NULL; - tracePtr = active.nextTracePtr) { - active.nextTracePtr = tracePtr->nextPtr; - if (!(tracePtr->flags & flags)) { - continue; - } - result = (*tracePtr->traceProc)(tracePtr->clientData, - (Tcl_Interp *) iPtr, part1, part2, flags); - if (result != NULL) { - if (flags & TCL_TRACE_UNSETS) { - result = NULL; - } else { - goto done; - } - } - } - - /* - * Restore the variable's flags, remove the record of our active - * traces, and then return. - */ - - done: - if (arrayPtr != NULL) { - arrayPtr->refCount--; - } - if (copiedName) { - Tcl_DStringFree(&nameCopy); - } - varPtr->flags &= ~VAR_TRACE_ACTIVE; - varPtr->refCount--; - iPtr->activeTracePtr = active.nextPtr; - return result; -} - -/* - *---------------------------------------------------------------------- - * - * NewVar -- - * - * Create a new variable with a given amount of storage - * space. - * - * Results: - * The return value is a pointer to the new variable structure. - * The variable will not be part of any hash table yet. Its - * initial value is empty. - * - * Side effects: - * Storage gets allocated. - * - *---------------------------------------------------------------------- - */ - -static Var * -NewVar(void) -{ - Var *varPtr; - - varPtr = (Var *) ckalloc(sizeof(Var)); - varPtr->valueLength = 0; - varPtr->valueSpace = 0; - varPtr->value.string = NULL; - varPtr->hPtr = NULL; - varPtr->refCount = 0; - varPtr->tracePtr = NULL; - varPtr->searchPtr = NULL; - varPtr->flags = VAR_UNDEFINED; - return varPtr; -} - -/* - *---------------------------------------------------------------------- - * - * ParseSearchId -- - * - * This procedure translates from a string to a pointer to an - * active array search (if there is one that matches the string). - * - * Results: - * The return value is a pointer to the array search indicated - * by string, or NULL if there isn't one. If NULL is returned, - * interp->result contains an error message. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static ArraySearch * -ParseSearchId( - Tcl_Interp *interp, /* Interpreter containing variable. */ - Var *varPtr, /* Array variable search is for. */ - char *varName, /* Name of array variable that search is - * supposed to be for. */ - char *string /* String containing id of search. Must have - * form "search-num-var" where "num" is a - * decimal number and "var" is a variable - * name. */ -) -{ - char *end; - int id; - ArraySearch *searchPtr; - - /* - * Parse the id into the three parts separated by dashes. - */ - - if ((string[0] != 's') || (string[1] != '-')) { - syntax: - Tcl_AppendResult(interp, "illegal search identifier \"", string, - "\"", (char *) NULL); - return NULL; - } - id = strtoul(string+2, &end, 10); - if ((end == (string+2)) || (*end != '-')) { - goto syntax; - } - if (strcmp(end+1, varName) != 0) { - Tcl_AppendResult(interp, "search identifier \"", string, - "\" isn't for variable \"", varName, "\"", (char *) NULL); - return NULL; - } - - /* - * Search through the list of active searches on the interpreter - * to see if the desired one exists. - */ - - for (searchPtr = varPtr->searchPtr; searchPtr != NULL; - searchPtr = searchPtr->nextPtr) { - if (searchPtr->id == id) { - return searchPtr; - } - } - Tcl_AppendResult(interp, "couldn't find search \"", string, "\"", - (char *) NULL); - return NULL; -} - -/* - *---------------------------------------------------------------------- - * - * DeleteSearches -- - * - * This procedure is called to free up all of the searches - * associated with an array variable. - * - * Results: - * None. - * - * Side effects: - * Memory is released to the storage allocator. - * - *---------------------------------------------------------------------- - */ - -static void -DeleteSearches( - Var *arrayVarPtr /* Variable whose searches are - * to be deleted. */ -) -{ - ArraySearch *searchPtr; - - while (arrayVarPtr->searchPtr != NULL) { - searchPtr = arrayVarPtr->searchPtr; - arrayVarPtr->searchPtr = searchPtr->nextPtr; - ckfree((char *) searchPtr); - } -} - -/* - *---------------------------------------------------------------------- - * - * TclDeleteVars -- - * - * This procedure is called to recycle all the storage space - * associated with a table of variables. For this procedure - * to work correctly, it must not be possible for any of the - * variable in the table to be accessed from Tcl commands - * (e.g. from trace procedures). - * - * Results: - * None. - * - * Side effects: - * Variables are deleted and trace procedures are invoked, if - * any are declared. - * - *---------------------------------------------------------------------- - */ - -void -TclDeleteVars( - Interp *iPtr, /* Interpreter to which variables belong. */ - Tcl_HashTable *tablePtr /* Hash table containing variables to - * delete. */ -) -{ - Tcl_HashSearch search; - Tcl_HashEntry *hPtr; - Var *varPtr; - Var *upvarPtr; - int flags; - ActiveVarTrace *activePtr; - - flags = TCL_TRACE_UNSETS; - if (tablePtr == &iPtr->globalTable) { - flags |= TCL_INTERP_DESTROYED | TCL_GLOBAL_ONLY; - } - for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; - hPtr = Tcl_NextHashEntry(&search)) { - varPtr = (Var *) Tcl_GetHashValue(hPtr); - - /* - * For global/upvar variables referenced in procedures, decrement - * the reference count on the variable referred to, and free - * the referenced variable if it's no longer needed. Don't delete - * the hash entry for the other variable if it's in the same table - * as us: this will happen automatically later on. - */ - - if (varPtr->flags & VAR_UPVAR) { - upvarPtr = varPtr->value.upvarPtr; - upvarPtr->refCount--; - if ((upvarPtr->refCount == 0) && (upvarPtr->flags & VAR_UNDEFINED) - && (upvarPtr->tracePtr == NULL)) { - if (upvarPtr->hPtr == NULL) { - ckfree((char *) upvarPtr); - } else if (upvarPtr->hPtr->tablePtr != tablePtr) { - Tcl_DeleteHashEntry(upvarPtr->hPtr); - ckfree((char *) upvarPtr); - } - } - } - - /* - * Invoke traces on the variable that is being deleted, then - * free up the variable's space (no need to free the hash entry - * here, unless we're dealing with a global variable: the - * hash entries will be deleted automatically when the whole - * table is deleted). - */ - - if (varPtr->tracePtr != NULL) { - (void) CallTraces(iPtr, (Var *) NULL, varPtr, - Tcl_GetHashKey(tablePtr, hPtr), (char *) NULL, flags); - while (varPtr->tracePtr != NULL) { - VarTrace *tracePtr = varPtr->tracePtr; - varPtr->tracePtr = tracePtr->nextPtr; - ckfree((char *) tracePtr); - } - for (activePtr = iPtr->activeTracePtr; activePtr != NULL; - activePtr = activePtr->nextPtr) { - if (activePtr->varPtr == varPtr) { - activePtr->nextTracePtr = NULL; - } - } - } - if (varPtr->flags & VAR_ARRAY) { - DeleteArray(iPtr, Tcl_GetHashKey(tablePtr, hPtr), varPtr, flags); - } - if (varPtr->valueSpace > 0) { - /* - * SPECIAL TRICK: it's possible that the interpreter's result - * currently points to this variable (for example, a "set" or - * "lappend" command was the last command in a procedure that's - * being returned from). If this is the case, then just pass - * ownership of the value string to the Tcl interpreter. - */ - - if (iPtr->result == varPtr->value.string) { - iPtr->freeProc = TCL_DYNAMIC; - } else { - ckfree(varPtr->value.string); - } - varPtr->valueSpace = 0; - } - varPtr->hPtr = NULL; - varPtr->tracePtr = NULL; - varPtr->flags = VAR_UNDEFINED; - - /* - * Recycle the variable's memory space if there aren't any upvar's - * pointing to it. If there are upvars, then the variable will - * get freed when the last upvar goes away. - */ - - if (varPtr->refCount == 0) { - ckfree((char *) varPtr); - } - } - Tcl_DeleteHashTable(tablePtr); -} - -/* - *---------------------------------------------------------------------- - * - * DeleteArray -- - * - * This procedure is called to free up everything in an array - * variable. It's the caller's responsibility to make sure - * that the array is no longer accessible before this procedure - * is called. - * - * Results: - * None. - * - * Side effects: - * All storage associated with varPtr's array elements is deleted - * (including the hash table). Delete trace procedures for - * array elements are invoked. - * - *---------------------------------------------------------------------- - */ - -static void -DeleteArray( - Interp *iPtr, /* Interpreter containing array. */ - char *arrayName, /* Name of array (used for trace - * callbacks). */ - Var *varPtr, /* Pointer to variable structure. */ - int flags /* Flags to pass to CallTraces: - * TCL_TRACE_UNSETS and sometimes - * TCL_INTERP_DESTROYED and/or - * TCL_GLOBAL_ONLY. */ -) -{ - Tcl_HashSearch search; - Tcl_HashEntry *hPtr; - Var *elPtr; - ActiveVarTrace *activePtr; - - DeleteSearches(varPtr); - for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - elPtr = (Var *) Tcl_GetHashValue(hPtr); - if (elPtr->valueSpace != 0) { - /* - * SPECIAL TRICK: it's possible that the interpreter's result - * currently points to this element (for example, a "set" or - * "lappend" command was the last command in a procedure that's - * being returned from). If this is the case, then just pass - * ownership of the value string to the Tcl interpreter. - */ - - if (iPtr->result == elPtr->value.string) { - iPtr->freeProc = TCL_DYNAMIC; - } else { - ckfree(elPtr->value.string); - } - elPtr->valueSpace = 0; - } - elPtr->hPtr = NULL; - if (elPtr->tracePtr != NULL) { - elPtr->flags &= ~VAR_TRACE_ACTIVE; - (void) CallTraces(iPtr, (Var *) NULL, elPtr, arrayName, - Tcl_GetHashKey(varPtr->value.tablePtr, hPtr), flags); - while (elPtr->tracePtr != NULL) { - VarTrace *tracePtr = elPtr->tracePtr; - elPtr->tracePtr = tracePtr->nextPtr; - ckfree((char *) tracePtr); - } - for (activePtr = iPtr->activeTracePtr; activePtr != NULL; - activePtr = activePtr->nextPtr) { - if (activePtr->varPtr == elPtr) { - activePtr->nextTracePtr = NULL; - } - } - } - elPtr->flags = VAR_UNDEFINED; - if (elPtr->refCount == 0) { - ckfree((char *) elPtr); - } - } - Tcl_DeleteHashTable(varPtr->value.tablePtr); - ckfree((char *) varPtr->value.tablePtr); -} - -/* - *---------------------------------------------------------------------- - * - * CleanupVar -- - * - * This procedure is called when it looks like it may be OK - * to free up the variable's record and hash table entry, and - * those of its containing parent. It's called, for example, - * when a trace on a variable deletes the variable. - * - * Results: - * None. - * - * Side effects: - * If the variable (or its containing array) really is dead then - * its record, and possibly its hash table entry, gets freed up. - * - *---------------------------------------------------------------------- - */ - -static void -CleanupVar( - Var *varPtr, /* Pointer to variable that may be a - * candidate for being expunged. */ - Var *arrayPtr /* Array that contains the variable, or - * NULL if this variable isn't an array - * element. */ -) -{ - if ((varPtr->flags & VAR_UNDEFINED) && (varPtr->refCount == 0) - && (varPtr->tracePtr == NULL)) { - if (varPtr->hPtr != NULL) { - Tcl_DeleteHashEntry(varPtr->hPtr); - } - ckfree((char *) varPtr); - } - if (arrayPtr != NULL) { - if ((arrayPtr->flags & VAR_UNDEFINED) && (arrayPtr->refCount == 0) - && (arrayPtr->tracePtr == NULL)) { - if (arrayPtr->hPtr != NULL) { - Tcl_DeleteHashEntry(arrayPtr->hPtr); - } - ckfree((char *) arrayPtr); - } - } - return; -} - -/* - *---------------------------------------------------------------------- - * - * VarErrMsg -- - * - * Generate a reasonable error message describing why a variable - * operation failed. - * - * Results: - * None. - * - * Side effects: - * Interp->result is reset to hold a message identifying the - * variable given by part1 and part2 and describing why the - * variable operation failed. - * - *---------------------------------------------------------------------- - */ - -static void -VarErrMsg( - Tcl_Interp *interp, /* Interpreter in which to record message. */ - char *part1, char *part2, /* Variable's two-part name. */ - char *operation, /* String describing operation that failed, - * e.g. "read", "set", or "unset". */ - char *reason /* String describing why operation failed. */ -) -{ - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't ", operation, " \"", part1, (char *) NULL); - if (part2 != NULL) { - Tcl_AppendResult(interp, "(", part2, ")", (char *) NULL); - } - Tcl_AppendResult(interp, "\": ", reason, (char *) NULL); -} diff --git a/cde/programs/dtfile/Trash.c b/cde/programs/dtfile/Trash.c index d391cccdb..a62881933 100644 --- a/cde/programs/dtfile/Trash.c +++ b/cde/programs/dtfile/Trash.c @@ -46,7 +46,6 @@ * EraseDir * EraseObject * FileFromTrash - * FileSysType * InitializeTrash * MatchesSacredDirectory * MessageToFileList @@ -106,8 +105,13 @@ #include <sys/param.h> #include <sys/mount.h> #else +#if defined(__linux__) +#include <sys/vfs.h> +#include <linux/magic.h> +#else #include <ustat.h> #endif +#endif #include <Xm/RowColumn.h> #include <Xm/CascadeB.h> @@ -383,7 +387,6 @@ static void EmptyTrash( Tt_message msg) ; static int CheckDeletePermissionRecur( char *dir); -static int FileSysType(int dev); static void RestoreVerifyOk( Widget w, XtPointer client_data, @@ -4140,16 +4143,16 @@ CheckDeletePermission( char *parentdir, char *destinationPath) { -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) struct statfs statbuf; #elif defined(__NetBSD__) struct statvfs statbuf; #else struct stat statbuf; #endif - char fname[1024]; + char fname[PATH_MAX]; -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) if (statfs(parentdir,&statbuf) < 0) /* does not exist */ #elif defined(__NetBSD__) if (statvfs(parentdir,&statbuf) < 0) /* does not exist */ @@ -4164,8 +4167,10 @@ CheckDeletePermission( /* if NFS, need to check if server trusts root */ #if defined(CSRG_BASED) if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */ +#elif defined(__linux__) + if (statbuf.f_type == NFS_SUPER_MAGIC) #else - if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */ + /* nothing - always check if root */ #endif { int fd = -1; @@ -4196,7 +4201,7 @@ CheckDeletePermission( return -1; /* copy destinationPath to tmp buffer */ - strcpy(fname, destinationPath); + snprintf(fname, PATH_MAX, "%s", destinationPath); return CheckDeletePermissionRecur(fname); } @@ -4264,18 +4269,6 @@ CheckDeletePermissionRecur( return 0; } -#if !defined(CSRG_BASED) -static int -FileSysType( - int dev) -{ - struct ustat u1; - if(ustat(dev,&u1) < 0) - return -2; - return u1.f_tinode; -} -#endif - static int RestoreObject( Widget w, diff --git a/cde/programs/dtfile/dtcopy/sharedFuncs.c b/cde/programs/dtfile/dtcopy/sharedFuncs.c index b3a0e9518..eea1a601c 100644 --- a/cde/programs/dtfile/dtcopy/sharedFuncs.c +++ b/cde/programs/dtfile/dtcopy/sharedFuncs.c @@ -63,9 +63,13 @@ #include <sys/mount.h> #include <pwd.h> #include <fcntl.h> -#if !defined(CSRG_BASED) +#if !defined(CSRG_BASED) && !defined(__linux__) #include <ustat.h> #endif +#if defined(__linux__) +#include <sys/vfs.h> +#include <linux/magic.h> +#endif #include <dirent.h> @@ -358,18 +362,6 @@ ImageInitialize( Display *display ) return ; } /* end ImageInitialize */ -#if !defined(CSRG_BASED) -static int -CopyFileSysType( - int dev) -{ - struct ustat u1; - if(ustat(dev,&u1) < 0) - return -2; - return u1.f_tinode; -} -#endif - static int CopyCheckDeletePermissionRecur( char *destinationPath) @@ -440,7 +432,7 @@ CopyCheckDeletePermission( char *parentdir, char *destinationPath) { -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) struct statfs statbuf; #elif defined(__NetBSD__) struct statvfs statbuf; @@ -449,7 +441,7 @@ CopyCheckDeletePermission( #endif char fname[PATH_MAX]; -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) if (statfs(parentdir,&statbuf) < 0) /* does not exist */ #elif defined(__NetBSD__) if (statvfs(parentdir,&statbuf) < 0) /* does not exist */ @@ -464,8 +456,10 @@ CopyCheckDeletePermission( /* if NFS, need to check if server trusts root */ #if defined(CSRG_BASED) if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */ +#elif defined(__linux__) + if (statbuf.f_type == NFS_SUPER_MAGIC) #else - if (CopyFileSysType(statbuf.st_dev) < 0) /* Root user and nfs */ + /* nothing - always check if root */ #endif { char *tmpfile; diff --git a/cde/programs/dtksh/ksh93/ship/shipproto.c b/cde/programs/dtksh/ksh93/ship/shipproto.c index 0688e2454..d0eb637f7 100644 --- a/cde/programs/dtksh/ksh93/ship/shipproto.c +++ b/cde/programs/dtksh/ksh93/ship/shipproto.c @@ -108,14 +108,12 @@ # undef ctime -# ifndef _WIN32 # define remove(x) unlink(x) # define rename(x,y) ((link(x,y)||remove(x))?-1:0) -# endif - + @@ -138,7 +136,7 @@ replace __PARAM__((const char* newfile, const char* oldfile, int preserve), (new #line 1 "../../lib/libpp/ppproto.c" - + @@ -155,7 +153,7 @@ static const char id[] = "\n@(#)proto (AT&T Bell Laboratories) 05/09/95\000\n"; #line 1 "../../lib/libpp/ppfsm.c" - + diff --git a/cde/programs/dtksh/ksh93/src/cmd/ksh93/sh/path.c b/cde/programs/dtksh/ksh93/src/cmd/ksh93/sh/path.c index 22ddecd90..ae9be6c48 100644 --- a/cde/programs/dtksh/ksh93/src/cmd/ksh93/sh/path.c +++ b/cde/programs/dtksh/ksh93/src/cmd/ksh93/sh/path.c @@ -512,17 +512,6 @@ static int canexecute __PARAM__((char *path, int isfun), (path, isfun)) __OTORP_ } else if(stat(path,&statb) < 0) { -#ifdef _WIN32 - /* check for .exe suffix */ - if(errno==ENOENT) - { - stakputs(".exe"); - path = stakptr(PATH_OFFSET); - if(stat(path,&statb) < 0) - goto err; - } - else -#endif /* _WIN32 */ goto err; } errno = EPERM; diff --git a/cde/programs/dtksh/ksh93/src/lib/libast/include/ast_std.h b/cde/programs/dtksh/ksh93/src/lib/libast/include/ast_std.h index 3532078f5..6c011a98e 100644 --- a/cde/programs/dtksh/ksh93/src/lib/libast/include/ast_std.h +++ b/cde/programs/dtksh/ksh93/src/lib/libast/include/ast_std.h @@ -617,11 +617,7 @@ __STDPP__directive pragma pp:ignore "string.h" /* <unistd.h> */ -#ifdef _WIN32 -#include <unistd.h> -#else #include <ast_unistd.h> -#endif #include <ast_botch.h> #ifndef STDIN_FILENO @@ -696,8 +692,6 @@ extern __MANGLE__ char* ttyname __PROTO__((int)); extern __MANGLE__ int unlink __PROTO__((const char*)); extern __MANGLE__ ssize_t write __PROTO__((int, const __V_*, size_t)); -#ifndef _WIN32 - /* * yes, we don't trust anyone's interpretation but our own */ @@ -716,8 +710,6 @@ extern __MANGLE__ long fpathconf __PROTO__((int, int)); extern __MANGLE__ long pathconf __PROTO__((const char*, int)); extern __MANGLE__ long sysconf __PROTO__((int)); -#endif - #if defined(__STDPP__directive) && defined(__STDPP__ignore) __STDPP__directive pragma pp:ignore "unistd.h" diff --git a/cde/programs/dtopen/dtopen.src b/cde/programs/dtopen/dtopen.src index ff7476fb1..4f1d0c9a0 100755 --- a/cde/programs/dtopen/dtopen.src +++ b/cde/programs/dtopen/dtopen.src @@ -8,7 +8,7 @@ XCOMM ############################################################### XCOMM Init DTOPEN="dtopen" # Identity crisis -APPNAME="$(basename $0)" # the app to locate/run +APPNAME="$(basename "$0")" # the app to locate/run XCOMM apps to look for, given an action (based on APPNAME - see MAIN) @@ -53,7 +53,7 @@ FindProg() # FindProg "program" # - returns full path, or "" - whence $1 + whence "$1" return 0 } @@ -88,7 +88,7 @@ DoSimpleCmd() for i in $cmds do - thecmd="$(FindProg $i)" + thecmd="$(FindProg "$i")" if [ ! -z "$thecmd" ] then # it's there @@ -119,16 +119,16 @@ COMMANDS="dtopen_image dtopen_pdf dtopen_ps dtopen_video" case $APPNAME in dtopen_image) - DoSimpleCmd "$VIMAGE" $* + DoSimpleCmd "$VIMAGE" "$*" ;; dtopen_pdf) - DoSimpleCmd "$VPDF" $* + DoSimpleCmd "$VPDF" "$*" ;; dtopen_ps) - DoSimpleCmd "$VPS" $* + DoSimpleCmd "$VPS" "$*" ;; dtopen_video) - DoSimpleCmd "$VVIDEO" $* + DoSimpleCmd "$VVIDEO" "$*" ;; *) # Unknown diff --git a/cde/programs/dtprintegrate/dtlp.src b/cde/programs/dtprintegrate/dtlp.src index c930a0933..45895e1f0 100755 --- a/cde/programs/dtprintegrate/dtlp.src +++ b/cde/programs/dtprintegrate/dtlp.src @@ -65,7 +65,6 @@ XCOMM Exit/Return codes XCOMM CANCEL_EXIT=-1 SUCCESS=0 -NO_PRINT_MESSAGE=1 USAGE_EXIT=2 NO_FILE_ERR=3 NO_INIT_FILE_ERR=4 @@ -81,8 +80,6 @@ NOT_POS_INTEGER=12 XCOMM XCOMM For string processing XCOMM -DOUBLE_QUOTE=\" -SINGLE_QUOTE=\' MINUS_T="-t" XCOMM ################################################################# @@ -116,7 +113,6 @@ Initialize() other_options_flag=0 other_options="" - print_command_flag=0 print_command=lp print_cwd_flag=0 @@ -125,13 +121,11 @@ Initialize() HASH HASH Assume print file is stdin, unless told otherwise... HASH - print_file_flag=1 print_file="-" print_page_allowed=1 print_man_flag=0 - print_man="" printer_name_flag=0 printer_name="" @@ -145,7 +139,6 @@ Initialize() silent_flag=0 test_flag=0 - test_output_file="" verbose_flag=0 @@ -223,7 +216,6 @@ SetPreEnvironment() if (( ${#DTPRINTTESTOUTPUT} )) then - test_output_file=$DTPRINTTESTOUTPUT test_flag=1 fi @@ -243,7 +235,7 @@ ReconcileOptions() HASH HASH The RAW option takes precedence over all others. HASH - if (( $print_raw_flag )) + if (( print_raw_flag )) then format_flag=0 print_man_flag=0 @@ -252,7 +244,7 @@ ReconcileOptions() HASH HASH Next, this MAN option comes into play HASH - elif (( $print_man_flag )) + elif (( print_man_flag )) then format_flag=0 print_page_allowed=0 @@ -272,17 +264,17 @@ DoParameterCollectionSilent() HASH printer_name has to be set at this point so no need to check LPOPTIONS=-d${printer_name} - if (( $banner_title_flag )) + if (( banner_title_flag )) then LPOPTIONS=${LPOPTIONS}" "${MINUS_T}${SINGLE_QUOTE}${banner_title}${SINGLE_QUOTE} fi - if (( $copy_count_flag )) + if (( copy_count_flag )) then LPOPTIONS=${LPOPTIONS}" -n${copy_count}" fi - if (( $other_options_flag )) + if (( other_options_flag )) then LPOPTIONS=${LPOPTIONS}" ${other_options}" fi @@ -292,9 +284,9 @@ DoParameterCollectionSilent() LPOPTIONS=${LPOPTIONS}" -m" fi - if (( $verbose_flag )) + if (( verbose_flag )) then - echo Print Command is $print_command and Options are $LPOPTIONS + echo "Print Command is $print_command and Options are $LPOPTIONS" fi } @@ -310,45 +302,45 @@ XCOMM ## XCOMM ################################################################# EchoDtlpSetupOptions() { - if (( $remove_flag )) + if (( remove_flag )) then echo Remove file flag is SET. fi - if (( $print_man_flag )) + if (( print_man_flag )) then echo Manpage flag is SET. fi - if (( $print_raw_flag )) + if (( print_raw_flag )) then echo Raw print flag is SET. fi - if (( $print_cwd_flag )) + if (( print_cwd_flag )) then - echo Print working directory is $print_cwd. + echo "Print working directory is $print_cwd." fi - if (( $print_page_allowed )) + if (( print_page_allowed )) then echo Page printing is allowed. else echo Page printing is NOT allowed. fi - if (( $format_flag )) + if (( format_flag )) then echo Format flag is SET. fi - if (( $silent_flag )) + if (( silent_flag )) then echo Silent flag is SET. fi - if (( $user_filename_flag )) + if (( user_filename_flag )) then echo User-visible filename is \"$user_filename\". fi - if (( $verbose_flag )) + if (( verbose_flag )) then echo Verbose flag is SET. fi - if (( $other_options_flag )) + if (( other_options_flag )) then echo Other options include \"$other_options\". fi @@ -368,12 +360,12 @@ XCOMM ## If possible, log the results. XCOMM ################################################################# PrintIt() { - if (( $print_cwd_flag )) && [[ (-d "$print_cwd") && (-x "$print_cwd") ]] + if (( print_cwd_flag )) && [[ (-d "$print_cwd") && (-x "$print_cwd") ]] then - cd $print_cwd + cd "$print_cwd" || exit fi - if (( $test_flag )) + if (( test_flag )) then HASH then don't do any printing--instead log the results EchoDtlpSetupOptions @@ -384,19 +376,19 @@ PrintIt() INVOKER='eval' fi - if (( $print_raw_flag )) + if (( print_raw_flag )) then HASH Nothing special is required for raw mode on this platform. LPOPTIONS="${LPOPTIONS}" fi - if (( $format_flag )) + if (( format_flag )) then HASH set page header - if (( $banner_title_flag )) + if (( banner_title_flag )) then PAGEHEADER="$banner_title" - elif (( $user_filename_flag )) + elif (( user_filename_flag )) then PAGEHEADER="$user_filename" else @@ -404,7 +396,7 @@ PrintIt() fi $INVOKER "cat $print_file | pr -f -h '${PAGEHEADER}' | ${print_command} ${LPOPTIONS}" - elif (( $print_man_flag )) + elif (( print_man_flag )) then $INVOKER "cat $print_file | tbl | nroff -man | col | ${print_command} ${LPOPTIONS}" @@ -425,12 +417,12 @@ XCOMM ## End the show XCOMM ################################################################# CleanUp() { - if (( $remove_flag )) && [[ "$print_file" != "-" ]] + if (( remove_flag )) && [[ "$print_file" != "-" ]] then rm -f $print_file >/dev/null 2>&1 fi - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -475,7 +467,7 @@ XCOMM ## Returns true or false. XCOMM ################################################################# CheckValidPrinter() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" if [[ "$printer_name" = "" ]] then @@ -485,7 +477,7 @@ CheckValidPrinter() if [[ "$printer_name" = "$CAT_MESG_STRING" ]] then GetDefaultPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then printer_name=$default_printer else @@ -494,35 +486,33 @@ CheckValidPrinter() fi tmpfile=$DTLPDIR/$printer_name$$ - LANG=C lpstat -p$printer_name > $tmpfile 2>&1 - if [[ $? != $SUCCESS ]] + LANG=C lpstat -p"$printer_name" > "$tmpfile" 2>&1 + if [[ $? != "$SUCCESS" ]] then HASH printer does not exist failure_flag=$PRINTER_DOES_NOT_EXIST - rm -f $tmpfile + rm -f "$tmpfile" return $failure_flag else - grep disabled $tmpfile > /dev/null 2>&1 - if [ $? -eq 0 ] + if grep disabled "$tmpfile" > /dev/null 2>&1 then failure_flag=$PRINTER_NOT_ENABLED - rm -f $tmpfile + rm -f "$tmpfile" return $failure_flag else status=$DTLPDIR/status$$ - LANG=C lpstat -a > $tmpfile 2>&1 - grep $printer_name $tmpfile > $status 2>&1 - grep "not accepting" $status > /dev/null 2>&1 - if [ $? -eq 0 ] + LANG=C lpstat -a > "$tmpfile" 2>&1 + grep "$printer_name" "$tmpfile" > "$status" 2>&1 + if grep "not accepting" "$status" > /dev/null 2>&1 then failure_flag=$PRINTER_NOT_ACCEPT_REQ - rm -f $status + rm -f "$status" return $failure_flag fi - rm -f $status + rm -f "$status" fi fi - rm -f $tmpfile + rm -f "$tmpfile" failure_flag=$SUCCESS return $failure_flag @@ -554,16 +544,16 @@ GetDefaultPrinter() #if defined(_AIX) t1="`LANG=C lpstat -d | head -3 | tail -1`" #else - t1="`LANG=C lpstat -d`" + t1="$(LANG=C lpstat -d)" #endif - t2="`echo $t1 | cut -d' ' -f1`" + t2="$(echo "$t1" | cut -d' ' -f1)" HASH HASH "no system default destination" is expected if no default is defined; HASH otherwise, "system default destination: <printer_name>" is expected. HASH if [[ "$t2" != "no" ]] then - default_printer="`echo $t1 | cut -f$prfld -d"$flddelim"`" + default_printer="$(echo "$t1" | cut -f"$prfld" -d"$flddelim")" HASH remove leading space default_printer=${default_printer##+( )} fi @@ -621,9 +611,9 @@ XCOMM ## XCOMM ################################################################# GetErrorMessageString() { - catgets CAT_MESG_STRING $CAT_ID 1 130 "Sorry--Unable to print:" + catgets CAT_MESG_STRING "$CAT_ID" 1 130 "Sorry--Unable to print:" - if (( $user_filename_flag )) + if (( user_filename_flag )) then CAT_MESG_STRING=${CAT_MESG_STRING}" \"$user_filename\"." else @@ -632,35 +622,35 @@ GetErrorMessageString() case $failure_flag in $NO_REGULAR_FILE_ERR) - catgets TEMP_MESG_STRING $CAT_ID 1 210 "That file is either not printable or it does not exist." + catgets TEMP_MESG_STRING "$CAT_ID" 1 210 "That file is either not printable or it does not exist." ;; $NO_READABLE_FILE_ERR) - catgets TEMP_MESG_STRING $CAT_ID 1 134 "You don't have permission to read that file." + catgets TEMP_MESG_STRING "$CAT_ID" 1 134 "You don't have permission to read that file." ;; $NO_PRINTER_AVAILABLE) - catgets TEMP_MESG_STRING $CAT_ID 1 220 "There is either no printer defined for this system or no printer is enabled." + catgets TEMP_MESG_STRING "$CAT_ID" 1 220 "There is either no printer defined for this system or no printer is enabled." ;; $PRINTER_DOES_NOT_EXIST) - catgets TEMP_MESG_STRING $CAT_ID 1 230 "The printer does not exist." + catgets TEMP_MESG_STRING "$CAT_ID" 1 230 "The printer does not exist." ;; $PRINTER_NOT_ENABLED) - catgets TEMP_MESG_STRING $CAT_ID 1 240 "The printer is not enabled." + catgets TEMP_MESG_STRING "$CAT_ID" 1 240 "The printer is not enabled." ;; $NO_DEFAULT_PRINTER) - catgets TEMP_MESG_STRING $CAT_ID 1 250 "There is no default printer destination." + catgets TEMP_MESG_STRING "$CAT_ID" 1 250 "There is no default printer destination." ;; $PRINTER_NOT_ACCEPT_REQ) - catgets TEMP_MESG_STRING $CAT_ID 1 260 "The printer is currently not accepting requests." + catgets TEMP_MESG_STRING "$CAT_ID" 1 260 "The printer is currently not accepting requests." ;; $NOT_POS_INTEGER) - catgets TEMP_MESG_STRING $CAT_ID 1 270 "Number of copies must be a positive number." + catgets TEMP_MESG_STRING "$CAT_ID" 1 270 "Number of copies must be a positive number." ;; *) echo "" ;; esac - if (( $failure_flag == $NO_PRINTER_AVAILABLE )) + if (( failure_flag == NO_PRINTER_AVAILABLE )) then CAT_MESG_STRING="${TEMP_MESG_STRING}" else @@ -679,12 +669,12 @@ XCOMM ## XCOMM ################################################################# DisplayErrorMessage() { - catgets CAT_MESG_STRING $CAT_ID 1 130 "Sorry--Unable to print:" + catgets CAT_MESG_STRING "$CAT_ID" 1 130 "Sorry--Unable to print:" GetErrorMessageString print "" - print `date` + print "$(date)" print "${CAT_MESG_STRING}" print "" } @@ -698,7 +688,7 @@ XCOMM ## XCOMM ################################################################# PrintEndLog() { print "" - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then print "...successfully completed." else @@ -741,7 +731,7 @@ PrintUsage() { print " Specifies the title of the file to display to the user." print "" print " -a" - print " Formats the file with "man" before printing." + print " Formats the file with \"man\" before printing." print "" print " -e" print " Removes the file after printing." @@ -777,7 +767,7 @@ XCOMM ## XCOMM ################################################################# Exit() { - exit $1 + exit "$1" } XCOMM ################# GUI Callbacks #################### @@ -804,11 +794,11 @@ XCOMM ## XCOMM ################################################################# DoParameterCollection() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" GetCurrentPrinterName CheckValidPrinter - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then DisplayErrorMessageDialog return $failure_flag @@ -826,11 +816,11 @@ DoParameterCollection() HASH HASH We must make sure the value is a positive integer in this case. HASH - XtGetValues $COPIES_SB textField:COPIES_TF - XmTextFieldGetString copy_val $COPIES_TF + XtGetValues "$COPIES_SB" textField:COPIES_TF + XmTextFieldGetString copy_val "$COPIES_TF" - CheckIsPosInteger $copy_val - if (( $failure_flag == $NOT_POS_INTEGER )) + CheckIsPosInteger "$copy_val" + if (( failure_flag == NOT_POS_INTEGER )) then DisplayErrorMessageDialog return $failure_flag @@ -847,7 +837,7 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" -n$copy_count" fi - XmTextGetString banner_title $BANNER_TF + XmTextGetString banner_title "$BANNER_TF" HASH Strip any leading or trailing spaces banner_title=${banner_title##+( )} @@ -857,7 +847,7 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" "${MINUS_T}${SINGLE_QUOTE}${banner_title}${SINGLE_QUOTE} fi - XmTextGetString other_options $OPTIONS_TF + XmTextGetString other_options "$OPTIONS_TF" HASH Strip any leading or trailing spaces other_options=${other_options##+( )} @@ -867,14 +857,14 @@ DoParameterCollection() LPOPTIONS=${LPOPTIONS}" $other_options" fi - XtGetValues $SEND_MAIL_BTN set:send_mail_flag + XtGetValues "$SEND_MAIL_BTN" set:send_mail_flag if [[ "$send_mail_flag" == "true" ]] then LPOPTIONS=${LPOPTIONS}" -m" fi - if (( $verbose_flag )) + if (( verbose_flag )) then echo The LP options are \"${LPOPTIONS}\". fi @@ -893,9 +883,9 @@ DestroyDialogs() { if [[ "$SELECT_PRINTER_FORM" != "" ]] then - XtDestroyWidget $(XtParent "-" $SELECT_PRINTER_FORM) + XtDestroyWidget "$(XtParent "-" "$SELECT_PRINTER_FORM")" fi - XtDestroyWidget $(XtParent "-" $PDIALOG) + XtDestroyWidget "$(XtParent "-" "$PDIALOG")" } XCOMM ################################################################# @@ -907,7 +897,7 @@ XCOMM ## XCOMM ################################################################# PrintCB() { - XSync $DISPLAY True + XSync "$DISPLAY" True DoParameterCollection if [ $? != $SUCCESS ] @@ -944,14 +934,14 @@ XCOMM ################################################################# UpdatePrinterDescription() { CheckValidPrinter - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then - XtSetValues $PRINTER_DESC_LABEL labelString:"" + XtSetValues "$PRINTER_DESC_LABEL" labelString:"" return fi - GetPrinterInfo $printer_name - XtSetValues $PRINTER_DESC_LABEL labelString:"$printer_info" + GetPrinterInfo "$printer_name" + XtSetValues "$PRINTER_DESC_LABEL" labelString:"$printer_info" } XCOMM ################################################################# @@ -964,10 +954,10 @@ XCOMM ## XCOMM ################################################################# SelectPrinterCB() { - XtSetValues $PRINTER_TF value:$selected_printer + XtSetValues "$PRINTER_TF" value:"$selected_printer" printer_name=$selected_printer UpdatePrinterDescription - XtUnmanageChild $SELECT_PRINTER_FORM + XtUnmanageChild "$SELECT_PRINTER_FORM" } XCOMM ################################################################# @@ -992,8 +982,8 @@ XCOMM ## XCOMM ################################################################# ListSelectCB() { - GetPrinterInfo ${CB_CALL_DATA.ITEM} - XtSetValues $INFO_TEXT value:"$printer_info" + GetPrinterInfo "${CB_CALL_DATA.ITEM}" + XtSetValues "$INFO_TEXT" value:"$printer_info" selected_printer=${CB_CALL_DATA.ITEM} } @@ -1007,9 +997,9 @@ XCOMM ## XCOMM ################################################################# ListDblSelectCB() { - if [ ${CB_CALL_DATA.EVENT.TYPE} != KeyPress ] + if [ "${CB_CALL_DATA.EVENT.TYPE}" != KeyPress ] then - XtCallCallbacks $SELECT_PRINTER_BTN activateCallback + XtCallCallbacks "$SELECT_PRINTER_BTN" activateCallback fi } @@ -1022,7 +1012,7 @@ XCOMM ## XCOMM ################################################################# GetCurrentPrinterName() { - XmTextFieldGetString printer_name $PRINTER_TF + XmTextFieldGetString printer_name "$PRINTER_TF" HASH Strip any leading or trailing spaces printer_name=${printer_name##+( )} @@ -1052,19 +1042,19 @@ GetAvailPrinters() #else LANG=C lpstat -p | \ grep enabled | cut -f2 -d" " | \ - sort | uniq > $tmpfile 2>&1 + sort | uniq > "$tmpfile" 2>&1 #endif if [ -s "$tmpfile" ] then - for i in `cat $tmpfile` + while read -r "$tmpfile" do - printer_items=`echo $printer_items$comma$i` + printer_items=$printer_items$comma$i comma=',' ((num_printers=num_printers+1)) done fi - rm -f $tmpfile + rm -f "$tmpfile" } XCOMM ################################################################# @@ -1105,78 +1095,78 @@ SelectPrinterProc() GetCurrentPrinterName HASH get index of printer in the list - XmListItemPos index $PRINTER_LIST $printer_name + XmListItemPos index "$PRINTER_LIST" "$printer_name" HASH HASH If printer is in the list, select it and display info. on it; HASH otherwise, just re-manage the dialog. HASH - if [[ $index > 0 ]] + if [[ $index -gt 0 ]] then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" HASH HASH display printer information and select the printer specified in HASH the Printer Name textfield HASH - XmTextSetString $INFO_TEXT "$printer_info" - XmListSelectItem $PRINTER_LIST $printer_name true - XmListSetPos $PRINTER_LIST $index + XmTextSetString "$INFO_TEXT" "$printer_info" + XmListSelectItem "$PRINTER_LIST" "$printer_name" true + XmListSetPos "$PRINTER_LIST" "$index" fi - XtManageChild $SELECT_PRINTER_FORM + XtManageChild "$SELECT_PRINTER_FORM" return fi GetAvailPrinters - XmCreateFormDialog SELECT_PRINTER_FORM $TOPLEVEL form + XmCreateFormDialog SELECT_PRINTER_FORM "$TOPLEVEL" form - catgets CAT_MESG_STRING $CAT_ID 1 180 "Select Printer" + catgets CAT_MESG_STRING "$CAT_ID" 1 180 "Select Printer" - XmInternAtom DEL_ATOM $DISPLAY WM_DELETE_WINDOW false - XmAddWMProtocolCallback $(XtParent "-" $SELECT_PRINTER_FORM) \ - $DEL_ATOM SelectPrinterCancelCB + XmInternAtom DEL_ATOM "$DISPLAY" WM_DELETE_WINDOW false + XmAddWMProtocolCallback "$(XtParent "-" "$SELECT_PRINTER_FORM")" \ + "$DEL_ATOM" SelectPrinterCancelCB - XtSetValues $(XtParent "-" $SELECT_PRINTER_FORM) \ + XtSetValues "$(XtParent "-" "$SELECT_PRINTER_FORM")" \ title:"$CAT_MESG_STRING" \ allowShellResize:False \ deleteResponse:DO_NOTHING - XtSetValues $SELECT_PRINTER_FORM \ + XtSetValues "$SELECT_PRINTER_FORM" \ noResize:True \ autoUnmanage:False \ helpCallback:SelectPrinterHelpCB - XmCreateWorkArea WORK_AREA $SELECT_PRINTER_FORM work_area \ + XmCreateWorkArea WORK_AREA "$SELECT_PRINTER_FORM" work_area \ orientation:XmVERTICAL - XmCreateWorkArea LIST_RC $WORK_AREA list_rc orientation:XmHORIZONTAL + XmCreateWorkArea LIST_RC "$WORK_AREA" list_rc orientation:XmHORIZONTAL - catgets CAT_MESG_STRING $CAT_ID 1 190 "Available Printers:" + catgets CAT_MESG_STRING "$CAT_ID" 1 190 "Available Printers:" - XmCreateLabelGadget LIST_LABEL $LIST_RC list_label \ + XmCreateLabelGadget LIST_LABEL "$LIST_RC" list_label \ labelString:"$CAT_MESG_STRING" - XtManageChild $LIST_LABEL + XtManageChild "$LIST_LABEL" - XmCreateScrolledList PRINTER_LIST $LIST_RC printer_list \ + XmCreateScrolledList PRINTER_LIST "$LIST_RC" printer_list \ selectionPolicy:XmSINGLE_SELECT \ singleSelectionCallback:ListSelectCB \ defaultActionCallback:ListDblSelectCB \ itemCount:$num_printers \ - items:$printer_items \ + items:"$printer_items" \ visibleItemCount:5 - XtManageChild $PRINTER_LIST + XtManageChild "$PRINTER_LIST" - XmCreateWorkArea INFO_RC $WORK_AREA info_rc orientation:XmVERTICAL + XmCreateWorkArea INFO_RC "$WORK_AREA" info_rc orientation:XmVERTICAL - catgets CAT_MESG_STRING $CAT_ID 1 200 "Printer Information:" + catgets CAT_MESG_STRING "$CAT_ID" 1 200 "Printer Information:" - XmCreateLabelGadget INFO_LABEL $INFO_RC info_label \ + XmCreateLabelGadget INFO_LABEL "$INFO_RC" info_label \ labelString:"$CAT_MESG_STRING" - XtManageChild $INFO_LABEL + XtManageChild "$INFO_LABEL" printer_info="" - XmCreateScrolledText INFO_TEXT $INFO_RC info_text \ + XmCreateScrolledText INFO_TEXT "$INFO_RC" info_text \ editMode:XmMULTI_LINE_EDIT \ value:"$printer_info" \ rows:5 \ @@ -1184,82 +1174,82 @@ SelectPrinterProc() wordWrap:True \ editable:False - XmCreateSeparator BTN_SEP $SELECT_PRINTER_FORM sep \ + XmCreateSeparator BTN_SEP "$SELECT_PRINTER_FORM" sep \ separatorType:XmSHADOW_ETCHED_IN \ - $(DtkshUnder $WORK_AREA 4) \ - $(DtkshSpanWidth) + "$(DtkshUnder "$WORK_AREA" 4)" \ + "$(DtkshSpanWidth)" - catgets CAT_MESG_STRING $CAT_ID 1 180 "Select Printer" + catgets CAT_MESG_STRING "$CAT_ID" 1 180 "Select Printer" - XmCreatePushButtonGadget SELECT_PRINTER_BTN $SELECT_PRINTER_FORM \ + XmCreatePushButtonGadget SELECT_PRINTER_BTN "$SELECT_PRINTER_FORM" \ ok_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 10) \ - $(DtkshFloatRight 30) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 10)" \ + "$(DtkshFloatRight 30)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $SELECT_PRINTER_BTN activateCallback "SelectPrinterCB" + XtAddCallback "$SELECT_PRINTER_BTN" activateCallback "SelectPrinterCB" - catgets CAT_MESG_STRING $CAT_ID 1 110 "Cancel" + catgets CAT_MESG_STRING "$CAT_ID" 1 110 "Cancel" - XmCreatePushButtonGadget CANCEL_BTN $SELECT_PRINTER_FORM cancel_button \ + XmCreatePushButtonGadget CANCEL_BTN "$SELECT_PRINTER_FORM" cancel_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 40) \ - $(DtkshFloatRight 60) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 40)" \ + "$(DtkshFloatRight 60)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $CANCEL_BTN activateCallback "SelectPrinterCancelCB" + XtAddCallback "$CANCEL_BTN" activateCallback "SelectPrinterCancelCB" - catgets CAT_MESG_STRING $CAT_ID 1 120 "Help" + catgets CAT_MESG_STRING "$CAT_ID" 1 120 "Help" - XmCreatePushButtonGadget HELP_BTN $SELECT_PRINTER_FORM help_button \ + XmCreatePushButtonGadget HELP_BTN "$SELECT_PRINTER_FORM" help_button \ labelString:"$CAT_MESG_STRING" \ - $(DtkshUnder $BTN_SEP 5) \ - $(DtkshFloatLeft 70) \ - $(DtkshFloatRight 90) \ - $(DtkshAnchorBottom 5) + "$(DtkshUnder "$BTN_SEP" 5)" \ + "$(DtkshFloatLeft 70)" \ + "$(DtkshFloatRight 90)" \ + "$(DtkshAnchorBottom 5)" - XtAddCallback $HELP_BTN activateCallback "SelectPrinterHelpCB" + XtAddCallback "$HELP_BTN" activateCallback "SelectPrinterHelpCB" - XtSetValues $SELECT_PRINTER_FORM \ - initialFocus:$SELECT_PRINTER_BTN \ - defaultButton:$SELECT_PRINTER_BTN \ - cancelButton:$CANCEL_BTN \ + XtSetValues "$SELECT_PRINTER_FORM" \ + initialFocus:"$SELECT_PRINTER_BTN" \ + defaultButton:"$SELECT_PRINTER_BTN" \ + cancelButton:"$CANCEL_BTN" \ navigationType:EXCLUSIVE_TAB_GROUP - XtManageChild $BTN_SEP - XtManageChild $SELECT_PRINTER_BTN - XtManageChild $CANCEL_BTN - XtManageChild $HELP_BTN - XtManageChild $INFO_TEXT - XtManageChild $LIST_RC - XtManageChild $INFO_RC - XtManageChild $WORK_AREA - XtManageChild $SELECT_PRINTER_FORM + XtManageChild "$BTN_SEP" + XtManageChild "$SELECT_PRINTER_BTN" + XtManageChild "$CANCEL_BTN" + XtManageChild "$HELP_BTN" + XtManageChild "$INFO_TEXT" + XtManageChild "$LIST_RC" + XtManageChild "$INFO_RC" + XtManageChild "$WORK_AREA" + XtManageChild "$SELECT_PRINTER_FORM" - if (( $num_printers )) + if (( num_printers )) then GetCurrentPrinterName CheckValidPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" HASH HASH display printer information and select the printer specified in HASH the Printer Name textfield HASH - XmTextSetString $INFO_TEXT "$printer_info" - XmListSelectItem $PRINTER_LIST $printer_name true - XmListSetItem $PRINTER_LIST $printer_name + XmTextSetString "$INFO_TEXT" "$printer_info" + XmListSelectItem "$PRINTER_LIST" "$printer_name" true + XmListSetItem "$PRINTER_LIST" "$printer_name" fi else HASH HASH no available printer, desensitize Select Printer button in HASH the Select Printer dialog HASH - XtSetSensitive $SELECT_PRINTER_BTN false + XtSetSensitive "$SELECT_PRINTER_BTN" false failure_flag=$NO_PRINTER_AVAILABLE DisplayErrorMessageDialog fi @@ -1274,7 +1264,7 @@ XCOMM ## XCOMM ################################################################# SelectPrinterCancelCB() { - XtUnmanageChild $SELECT_PRINTER_FORM + XtUnmanageChild "$SELECT_PRINTER_FORM" } XCOMM ################################################################# @@ -1291,12 +1281,12 @@ PrinterNameFocusCB() HASH When it loses focus, compare the saved printer name with the new one HASH to determine if the user has changed it. If so, update the printer HASH description. - if [ ${CB_CALL_DATA.REASON} = CR_FOCUS ] + if [ "${CB_CALL_DATA.REASON}" = CR_FOCUS ] then GetCurrentPrinterName old_printer=$printer_name else - if [ ${CB_CALL_DATA.REASON} = CR_LOSING_FOCUS ] + if [ "${CB_CALL_DATA.REASON}" = CR_LOSING_FOCUS ] then GetCurrentPrinterName if [ "$old_printer" != "$printer_name" ] @@ -1315,14 +1305,14 @@ XCOMM ## XCOMM ################################################################# UseGui() { - catgets CAT_MESG_STRING $CAT_ID 1 10 "Default" + catgets CAT_MESG_STRING "$CAT_ID" 1 10 "Default" - if (( $printer_name_flag )) + if (( printer_name_flag )) then printer=$printer_name else GetDefaultPrinter - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then printer=$default_printer printer_name=$default_printer @@ -1333,12 +1323,12 @@ UseGui() if [[ "$printer_name" != "" ]] then - GetPrinterInfo $printer_name + GetPrinterInfo "$printer_name" else printer_info="" fi - DtCreatePrintSetupDialog PDIALOG $TOPLEVEL pdialog \ + DtCreatePrintSetupDialog PDIALOG "$TOPLEVEL" pdialog \ printCallback:PrintCB \ cancelCallback:PrintCancelCB \ helpCallback:PrintHelpCB \ @@ -1349,83 +1339,83 @@ UseGui() printerName:"$printer" \ description:"$printer_info" - catgets CAT_MESG_STRING $CAT_ID 1 20 "Print" + catgets CAT_MESG_STRING "$CAT_ID" 1 20 "Print" - XmInternAtom DEL_ATOM $DISPLAY WM_DELETE_WINDOW false - XmAddWMProtocolCallback $(XtParent "-" $PDIALOG) $DEL_ATOM PrintCancelCB + XmInternAtom DEL_ATOM "$DISPLAY" WM_DELETE_WINDOW false + XmAddWMProtocolCallback "$(XtParent "-" "$PDIALOG")" "$DEL_ATOM" PrintCancelCB - XtSetValues $(XtParent "-" $PDIALOG) \ + XtSetValues "$(XtParent "-" "$PDIALOG")" \ title:"$CAT_MESG_STRING" \ allowShellResize:False \ deleteResponse:DO_NOTHING - XtSetValues $PDIALOG autoUnmanage:False + XtSetValues "$PDIALOG" autoUnmanage:False - XmCreateWorkArea FILE_NAME_RC $PDIALOG file_name_rc \ + XmCreateWorkArea FILE_NAME_RC "$PDIALOG" file_name_rc \ marginWidth:0 \ marginHeight:0 \ orientation:XmHORIZONTAL - catgets CAT_MESG_STRING $CAT_ID 1 170 "File Name(s): " + catgets CAT_MESG_STRING "$CAT_ID" 1 170 "File Name(s): " - XmCreateLabel FILE_NAME_LABEL $FILE_NAME_RC file_name_label \ + XmCreateLabel FILE_NAME_LABEL "$FILE_NAME_RC" file_name_label \ labelString:"$CAT_MESG_STRING" - if (( $user_filename_flag )) + if (( user_filename_flag )) then LABEL_STRING="${user_filename}" else LABEL_STRING="${print_file}" fi - XmCreateLabel FILE_NAME $FILE_NAME_RC file_name \ + XmCreateLabel FILE_NAME "$FILE_NAME_RC" file_name \ labelString:"$LABEL_STRING" - XtManageChild $FILE_NAME_RC - XtManageChild $FILE_NAME_LABEL - XtManageChild $FILE_NAME + XtManageChild "$FILE_NAME_RC" + XtManageChild "$FILE_NAME_LABEL" + XtManageChild "$FILE_NAME" HASH HASH Unmanage unneeded widgets HASH - XtNameToWidget TOP_SEP $PDIALOG "TopWorkAreaSeparator" - XtUnmanageChild $TOP_SEP + XtNameToWidget TOP_SEP "$PDIALOG" "TopWorkAreaSeparator" + XtUnmanageChild "$TOP_SEP" - XtNameToWidget INFO_BTN $PDIALOG "Info" - XtUnmanageChild $INFO_BTN + XtNameToWidget INFO_BTN "$PDIALOG" "Info" + XtUnmanageChild "$INFO_BTN" - XtNameToWidget SELECT_FILE_BTN $PDIALOG "SelectFile" - XtUnmanageChild $SELECT_FILE_BTN + XtNameToWidget SELECT_FILE_BTN "$PDIALOG" "SelectFile" + XtUnmanageChild "$SELECT_FILE_BTN" - XtNameToWidget SETUP_BTN $PDIALOG "Setup" - XtUnmanageChild $SETUP_BTN + XtNameToWidget SETUP_BTN "$PDIALOG" "Setup" + XtUnmanageChild "$SETUP_BTN" - DtCreatePDMJobSetup JOB $PDIALOG + DtCreatePDMJobSetup JOB "$PDIALOG" HASH HASH Get widget handles HASH - XtNameToWidget PRINTER_COMBO $PDIALOG "Name" - XtNameToWidget PRINTER_TF $PRINTER_COMBO "Text" - XtNameToWidget PRINTER_DESC_LABEL $PDIALOG "Description" - XtNameToWidget COPIES_SB $PDIALOG "*Copies" - XtNameToWidget SEND_MAIL_CB $JOB "*SendMail" - XtNameToWidget BANNER_TF $JOB "*Banner" - XtNameToWidget OPTIONS_TF $JOB "*Options" - XtNameToWidget SEND_MAIL_BTN $SEND_MAIL_CB "button_0" - XtNameToWidget PRINT_BTN $PDIALOG "Print" - XtNameToWidget PRINT_CANCEL_BTN $PDIALOG "Cancel" + XtNameToWidget PRINTER_COMBO "$PDIALOG" "Name" + XtNameToWidget PRINTER_TF "$PRINTER_COMBO" "Text" + XtNameToWidget PRINTER_DESC_LABEL "$PDIALOG" "Description" + XtNameToWidget COPIES_SB "$PDIALOG" "*Copies" + XtNameToWidget SEND_MAIL_CB "$JOB" "*SendMail" + XtNameToWidget BANNER_TF "$JOB" "*Banner" + XtNameToWidget OPTIONS_TF "$JOB" "*Options" + XtNameToWidget SEND_MAIL_BTN "$SEND_MAIL_CB" "button_0" + XtNameToWidget PRINT_BTN "$PDIALOG" "Print" + XtNameToWidget PRINT_CANCEL_BTN "$PDIALOG" "Cancel" HASH HASH move cursor to end of printer name HASH - XtSetValues $PRINTER_TF cursorPosition:${#PRINTER} + XtSetValues "$PRINTER_TF" cursorPosition:${#PRINTER} HASH HASH set focus callbacks to track printer name changes HASH - XtAddCallback $PRINTER_TF focusCallback "PrinterNameFocusCB" - XtAddCallback $PRINTER_TF losingFocusCallback "PrinterNameFocusCB" + XtAddCallback "$PRINTER_TF" focusCallback "PrinterNameFocusCB" + XtAddCallback "$PRINTER_TF" losingFocusCallback "PrinterNameFocusCB" HASH HASH initialize SELECT_PRINTER_FORM to be used in SelectPrinterProc @@ -1433,32 +1423,32 @@ UseGui() HASH SELECT_PRINTER_FORM="" - if (( $banner_title_flag )) + if (( banner_title_flag )) then - XtSetValues $BANNER_TF value:"$banner_title" + XtSetValues "$BANNER_TF" value:"$banner_title" fi - if (( $other_options_flag )) + if (( other_options_flag )) then - XtSetValues $OPTIONS_TF value:"$other_options" + XtSetValues "$OPTIONS_TF" value:"$other_options" fi - XtManageChild $PDIALOG + XtManageChild "$PDIALOG" - if (( $copy_count_flag )) + if (( copy_count_flag )) then - XtSetValues $COPIES_SB position:$copy_count + XtSetValues "$COPIES_SB" position:"$copy_count" fi if [[ "$send_mail_flag" == "true" ]] then - XtSetValues $SEND_MAIL_BTN set:true + XtSetValues "$SEND_MAIL_BTN" set:true fi - XtGetValues $COPIES_SB textField:COPIES_TF + XtGetValues "$COPIES_SB" textField:COPIES_TF - DtkshSetReturnKeyControls $PRINTER_TF $COPIES_TF $PDIALOG $PRINT_BTN - DtkshSetReturnKeyControls $COPIES_TF $BANNER_TF $PDIALOG $PRINT_BTN - DtkshSetReturnKeyControls $BANNER_TF $OPTIONS_TF $PDIALOG $PRINT_BTN + DtkshSetReturnKeyControls "$PRINTER_TF" "$COPIES_TF" "$PDIALOG" "$PRINT_BTN" + DtkshSetReturnKeyControls "$COPIES_TF" "$BANNER_TF" "$PDIALOG" "$PRINT_BTN" + DtkshSetReturnKeyControls "$BANNER_TF" "$OPTIONS_TF" "$PDIALOG" "$PRINT_BTN" XtMainLoop @@ -1474,7 +1464,7 @@ XCOMM ## XCOMM ################################################################# BadFileCB() { - Exit $bad_file_flag + Exit "$bad_file_flag" } XCOMM ################################################################# @@ -1487,7 +1477,7 @@ XCOMM ## XCOMM ################################################################# ErrorDialogCB() { - XtDestroyWidget $INFORMATION + XtDestroyWidget "$INFORMATION" } XCOMM ################################################################# @@ -1501,17 +1491,17 @@ XCOMM ## XCOMM ################################################################# DisplayErrorMessageDialog() { - XmCreateErrorDialog INFORMATION $TOPLEVEL information + XmCreateErrorDialog INFORMATION "$TOPLEVEL" information - catgets CAT_MESG_STRING $CAT_ID 1 160 "Print Information" + catgets CAT_MESG_STRING "$CAT_ID" 1 160 "Print Information" - XtSetValues $(XtParent "-" $INFORMATION) title:"$CAT_MESG_STRING" + XtSetValues "$(XtParent "-" "$INFORMATION")" title:"$CAT_MESG_STRING" GetErrorMessageString - if (($failure_flag == $NO_FILE_ERR )) || - (( $failure_flag == $NO_REGULAR_FILE_ERR )) || - (( $failure_flag == $NO_READABLE_FILE_ERR )) + if ((failure_flag == NO_FILE_ERR )) || + (( failure_flag == NO_REGULAR_FILE_ERR )) || + (( failure_flag == NO_READABLE_FILE_ERR )) then bad_file_flag=$failure_flag cb="BadFileCB" @@ -1519,7 +1509,7 @@ DisplayErrorMessageDialog() cb="ErrorDialogCB" fi - XtSetValues $INFORMATION \ + XtSetValues "$INFORMATION" \ okCallback:$cb \ messageString:"${CAT_MESG_STRING}" \ noResize:True \ @@ -1527,13 +1517,13 @@ DisplayErrorMessageDialog() dialogStyle:DIALOG_FULL_APPLICATION_MODAL \ messageAlignment:ALIGNMENT_CENTER - XtUnmanageChild $(XmMessageBoxGetChild "-" $INFORMATION \ - DIALOG_CANCEL_BUTTON) + XtUnmanageChild "$(XmMessageBoxGetChild "-" "$INFORMATION" \ + DIALOG_CANCEL_BUTTON)" - XtUnmanageChild $(XmMessageBoxGetChild "-" $INFORMATION \ - DIALOG_HELP_BUTTON) + XtUnmanageChild "$(XmMessageBoxGetChild "-" "$INFORMATION" \ + DIALOG_HELP_BUTTON)" - XtManageChild $INFORMATION + XtManageChild "$INFORMATION" XtMainLoop } @@ -1568,7 +1558,6 @@ do i) send_mail_flag=true ;; m) print_command=$OPTARG - print_command_flag=1 ;; n) copy_count=$OPTARG copy_count_flag=1 @@ -1597,7 +1586,7 @@ done let npf=0 -if (( $shift_positions < $# )) +if (( shift_positions < $# )) then XCOMM XCOMM We have at least one remaining non-switch command line argument @@ -1608,11 +1597,10 @@ XCOMM HASH At some later point, may want to parse a list of filenames. HASH print_file="" - print_file_flag=1 while (($# > 0)) do - nw=`echo $1 | wc -w` + nw=$(echo "$1" | wc -w) if ((nw > 1)) then file="\"$1\"" @@ -1635,10 +1623,10 @@ fi XCOMM XCOMM make sure copy_count is a positive integer XCOMM -if (( $copy_count_flag )) +if (( copy_count_flag )) then - CheckIsPosInteger $copy_count - if (( $failure_flag != $SUCCESS )) + CheckIsPosInteger "$copy_count" + if (( failure_flag != SUCCESS )) then DisplayErrorMessage Exit $USAGE_EXIT @@ -1650,7 +1638,7 @@ XCOMM Make sure all these settings line up consistently. XCOMM ReconcileOptions -if (( $verbose_flag )) +if (( verbose_flag )) then PrintStartLog fi @@ -1668,7 +1656,7 @@ while ((i < npf)) do CheckValidFile "${files[$i]}" failure_flag=$? - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then print_file="\"${files[$i]}\"" break @@ -1676,13 +1664,13 @@ do let i=i+1 done -if (( $silent_flag )) +if (( silent_flag )) then - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then CheckValidPrinter failure_flag=$? - if (( $failure_flag != $SUCCESS )) + if (( failure_flag != SUCCESS )) then DisplayErrorMessage Exit $failure_flag @@ -1707,9 +1695,9 @@ else fi XtInitialize TOPLEVEL printerConfig Dtlp "${@:-}" - XtDisplay DISPLAY $TOPLEVEL + XtDisplay DISPLAY "$TOPLEVEL" - if (( $failure_flag == $SUCCESS )) + if (( failure_flag == SUCCESS )) then UseGui else diff --git a/cde/programs/dtprintegrate/dtlpsetup.src b/cde/programs/dtprintegrate/dtlpsetup.src index 538307826..a9537caff 100755 --- a/cde/programs/dtprintegrate/dtlpsetup.src +++ b/cde/programs/dtprintegrate/dtlpsetup.src @@ -20,10 +20,6 @@ XCOMM NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat:$NLSPATH export NLSPATH -XCOMM Return Codes -NO_VALID_FILE_ERR=7 -NO_READ_FILE_ERR=8 - usage="$0 [-b banner_title] [-d lpdest] [-f print_file] [-m print_command] [-n copy_count] [-o other_options] [-u user_filename] [-a] [-e] [-h] [-r] [-s] [-v] [-w]" @@ -31,7 +27,7 @@ usage="$0 [-b banner_title] [-d lpdest] [-f print_file] while [ $# -gt 0 ]; do case "$1" in -b) - if [ $2 ]; then + if [ "$2" ]; then banner_title="$1 $2" shift; shift; else @@ -40,11 +36,11 @@ while [ $# -gt 0 ]; do fi ;; -b*) - banner_title="-b `expr "$1" : '-b\(.*\)'`" + banner_title="-b $(expr "$1" : '-b\(.*\)')" shift ;; -d) - if [ $2 ]; then + if [ "$2" ]; then lpdest="$1 $2" shift; shift; else @@ -53,13 +49,13 @@ while [ $# -gt 0 ]; do fi ;; -d*) - lpdest="-d `expr "$1" : '-d\(.*\)'`" + lpdest="-d $(expr "$1" : '-d\(.*\)')" shift ;; -c) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -73,7 +69,7 @@ while [ $# -gt 0 ]; do -t) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -87,7 +83,7 @@ while [ $# -gt 0 ]; do -i) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -101,7 +97,7 @@ while [ $# -gt 0 ]; do -l) NOT_SUPPORTED=true ARGS="$ARGS $1" - if [ $2 ]; then + if [ "$2" ]; then shift; shift; else shift @@ -113,7 +109,7 @@ while [ $# -gt 0 ]; do shift ;; -f) - if [ $2 ]; then + if [ "$2" ]; then print_file=$2 shift; shift; else @@ -122,11 +118,11 @@ while [ $# -gt 0 ]; do fi ;; -f*) - print_file=`expr "$1" : '-f\(.*\)'` + print_file=$(expr "$1" : '-f\(.*\)') shift ;; -m) - if [ $2 ]; then + if [ "$2" ]; then print_command="$1 $2" shift; shift; else @@ -135,11 +131,11 @@ while [ $# -gt 0 ]; do fi ;; -m*) - print_command="-m `expr "$1" : '-m\(.*\)'`" + print_command="-m $(expr "$1" : '-m\(.*\)')" shift ;; -n) - if [ $2 ]; then + if [ "$2" ]; then copy_count="$1 $2" shift; shift; else @@ -148,11 +144,11 @@ while [ $# -gt 0 ]; do fi ;; -n*) - copy_count="-n `expr "$1" : '-n\(.*\)'`" + copy_count="-n $(expr "$1" : '-n\(.*\)')" shift ;; -o) - if [ $2 ]; then + if [ "$2" ]; then other_options="$1 $2" shift; shift; else @@ -161,11 +157,11 @@ while [ $# -gt 0 ]; do fi ;; -o*) - other_options="-o `expr "$1" : '-o\(.*\)'`" + other_options="-o $(expr "$1" : '-o\(.*\)')" shift ;; -u) - if [ $2 ]; then + if [ "$2" ]; then user_filename="$1 $2" shift; shift; else @@ -174,7 +170,7 @@ while [ $# -gt 0 ]; do fi ;; -u*) - user_filename="-u `expr "$1" : '-u\(.*\)'`" + user_filename="-u $(expr "$1" : '-u\(.*\)')" shift ;; -a) @@ -217,22 +213,22 @@ if [ $# -gt 0 ]; then fi if [ $NOT_SUPPORTED ]; then - dspmsg -s 1 dtmigrate 2 'dtlpsetup: dtlpsetup has been replaced with dtlp.\ + dspmsg -s 1 dtmigrate 2 "dtlpsetup: dtlpsetup has been replaced with dtlp.\ \tdtlp will be automatically called in its place. \ \tThe following flags and parameters on the dtlpsetup call \ \thave been ignored because dtlp does not support these flags: \ -\t%1$s \n' "$ARGS" +\t%1$s \n" "$ARGS" fi -/usr/dt/bin/dtlp $banner_title $lpdest $print_command $copy_count $other_options $user_filename $a $e $h $r $s $v $w $print_file +/usr/dt/bin/dtlp "$banner_title" "$lpdest" "$print_command" "$copy_count" "$other_options" "$user_filename" "$a" "$e" "$h" "$r" "$s" "$v" "$w" "$print_file" status=$? XCOMM dtlp return code of 5 maps to return code 7 of dtlpsetup -if [[ $status -eq 5 ]] +if [ $status -eq 5 ] then exit NO_VALID_FILE_ERR XCOMM dtlp return code of 6 maps to return code 8 of dtlpsetup -elif [[ $status -eq 6 ]] +elif [ $status -eq 6 ] then exit NO_READ_FILE_ERR else XCOMM all others are synonomous diff --git a/cde/programs/dtprintegrate/dtprintegrate.src b/cde/programs/dtprintegrate/dtprintegrate.src index b5215f4ff..7cd75b473 100755 --- a/cde/programs/dtprintegrate/dtprintegrate.src +++ b/cde/programs/dtprintegrate/dtprintegrate.src @@ -43,10 +43,8 @@ base_icon_name="Fpprnt" XCOMM XCOMM Return codes XCOMM -SUCCESS=0 USAGE_ERR=1 CREATE_ERR=2 -NO_WRITE_ERR=3 XCOMM ################################################################# XCOMM ## Initialize() @@ -56,13 +54,6 @@ XCOMM ## XCOMM ################################################################# Initialize() { - if (( ${#LANG} )) - then - if [[ $LANG != C ]] - then - non_default_lang=1 - fi - fi HASH HASH Location for Print action files... @@ -75,9 +66,9 @@ Initialize() DTPRINTERFOLDER="$DTUSERPRINTERFOLDER" fi - if [ ! -d $DTPRINTERFOLDER ] + if [ ! -d "$DTPRINTERFOLDER" ] then - mkdir -p $DTPRINTERFOLDER > /dev/null 2>/dev/null + mkdir -p "$DTPRINTERFOLDER" > /dev/null 2>/dev/null fi HASH @@ -86,9 +77,9 @@ Initialize() DEFAULT_FOLDER=/etc/dt/appconfig/types/C DTPRINTACTIONFOLDER=${DTPRINTACTIONFOLDER:-$DEFAULT_FOLDER} - if [ ! -d $DTPRINTACTIONFOLDER ] + if [ ! -d "$DTPRINTACTIONFOLDER" ] then - mkdir -p $DTPRINTACTIONFOLDER > /dev/null 2>/dev/null + mkdir -p "$DTPRINTACTIONFOLDER" > /dev/null 2>/dev/null fi HASH @@ -124,7 +115,7 @@ XCOMM ## XCOMM ################################################################# CheckOptions() { - if (( $printer_flag == "0" )) + if (( printer_flag == "0" )) HASH HASH We require a printer specification HASH @@ -149,21 +140,21 @@ AddHelpFileContents() print " \"$help_file\"." print "" failure_flag=1 - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi Exit $CREATE_ERR fi - echo " DESCRIPTION \\" >> $databasefile_path + echo " DESCRIPTION \\" >> "$databasefile_path" - exec 8< $help_file + exec 8< "$help_file" - while read -u8 this_line + while read -r -u8 this_line do - print $this_line " \\" >> $databasefile_path + print "$this_line" " \\" >> "$databasefile_path" done - print "**" >> $databasefile_path + print "**" >> "$databasefile_path" exec 8<&- } @@ -177,15 +168,15 @@ XCOMM ################################################################# MakeDatabaseFile() { - touch $databasefile_path > /dev/null 2>/dev/null + touch "$databasefile_path" > /dev/null 2>/dev/null - chmod +w $databasefile_path > /dev/null 2>/dev/null + chmod +w "$databasefile_path" > /dev/null 2>/dev/null if [[ ! -f $databasefile_path || ! -w $databasefile_path ]] then failure_flag=1 PrintCreateError "$DTPRINTACTIONFOLDER" "$database_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -204,11 +195,11 @@ MakeDatabaseFile() echo "# " echo "# This file created by the \"dtprintegrate\" utility." echo "# " - echo "# Date of integration: `date`. " + echo "# Date of integration: $(date). " echo "# " echo "################################################################" echo " " - ) > $databasefile_path + ) > "$databasefile_path" HASH HASH Now, create the Print action for the printer @@ -230,17 +221,17 @@ MakeDatabaseFile() fi echo " /usr/dt/bin/dtaction Print %(File)Arg_1%" - ) >> $databasefile_path + ) >> "$databasefile_path" - if (( $help_flag )) + if (( help_flag )) then - echo " DESCRIPTION $help_text" >> $databasefile_path - elif (( $helpfile_flag )) + echo " DESCRIPTION $help_text" >> "$databasefile_path" + elif (( helpfile_flag )) then - AddHelpFileContents $databasefile_path + AddHelpFileContents "$databasefile_path" fi - echo "}" >> $databasefile_path + echo "}" >> "$databasefile_path" HASH HASH Next, create the print manager action for the printer @@ -260,21 +251,20 @@ MakeDatabaseFile() fi echo " /usr/dt/bin/dtaction Dtqueueinfo" echo "}" - ) >> $databasefile_path + ) >> "$databasefile_path" } XCOMM ################################################################# XCOMM ## XCOMM ## TraversePath() XCOMM ## -XCOMM ## Parse a given search path, using comma (,) and colon (:) as +XCOMM ## Parse a given search path, using comma (,) and colon (:) as XCOMM ## delimiters. Pass each path element to another XCOMM ## function. XCOMM ## XCOMM ################################################################# TraversePath () { - gotahost=0 typeset -i path=0 IFSsave=$IFS search_path=$1 @@ -285,10 +275,10 @@ TraversePath () HASH look for colon and comma delimiters HASH IFS=':,' - set -A dir_array $search_path + set -A dir_array "$search_path" while ((path<=${#dir_array[*]}-1)) ;do - $dir_function ${dir_array[$path]} - path=path+1 + $dir_function "${dir_array[$path]}" + path=$((path+1)) done else return fi @@ -299,19 +289,19 @@ XCOMM ################################################################# XCOMM ## XCOMM ## GetIconBaseName() XCOMM ## -XCOMM ## Given a file name of the form "base.l.bm" where size +XCOMM ## Given a file name of the form "base.l.bm" where size XCOMM ## can be ".l", ".m", ".s.", or ".t" and visual type can be XCOMM ## ".bm" or ".pm", set $base_icon_name to just the base. XCOMM ## XCOMM ################################################################# GetIconBaseName() { - base_icon_name=`basename $1 .bm` - base_icon_name=`basename $base_icon_name .pm` - base_icon_name=`basename $base_icon_name .l` - base_icon_name=`basename $base_icon_name .m` - base_icon_name=`basename $base_icon_name .s` - base_icon_name=`basename $base_icon_name .t` + base_icon_name=$(basename "$1" .bm) + base_icon_name=$(basename "$base_icon_name" .pm) + base_icon_name=$(basename "$base_icon_name" .l) + base_icon_name=$(basename "$base_icon_name" .m) + base_icon_name=$(basename "$base_icon_name" .s) + base_icon_name=$(basename "$base_icon_name" .t) } XCOMM ################################################################# @@ -327,18 +317,18 @@ DoTheActualIconCopy() { for i in $1/${base_icon_name}.* do - if [ -f $i ] + if [ -f "$i" ] then simple_icon_name=${i##*/} - if [ -f $DTPRINTERICONFOLDER/$simple_icon_name ] + if [ -f "$DTPRINTERICONFOLDER/$simple_icon_name" ] then - mv -f $DTPRINTERICONFOLDER/$simple_icon_name $DTPRINTERICONFOLDER/#$simple_icon_name + mv -f "$DTPRINTERICONFOLDER/$simple_icon_name" "$DTPRINTERICONFOLDER/#$simple_icon_name" fi - cp $i $DTPRINTERICONFOLDER + cp "$i" "$DTPRINTERICONFOLDER" - if (( $verbose_flag )) + if (( verbose_flag )) then print " Copied icon file $i " print " to $DTPRINTERICONFOLDER." @@ -359,22 +349,22 @@ XCOMM ################################################################# CopyIconFiles() { -GetIconBaseName $icon_name +GetIconBaseName "$icon_name" -touch $DTPRINTERICONFOLDER/$icon_name.install > /dev/null 2>/dev/null +touch "$DTPRINTERICONFOLDER/$icon_name.install" > /dev/null 2>/dev/null if [[ ! -f $DTPRINTERICONFOLDER/$icon_name.install ]] then failure_flag=1 PrintCreateError "$DTPRINTERICONFOLDER" "$DTPRINTERICONFOLDER/$icon_name.*" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi Exit $CREATE_ERR fi -rm -f $DTPRINTERICONFOLDER/$icon_name.install +rm -f "$DTPRINTERICONFOLDER/$icon_name.install" TraversePath "$DTPRINTICONPATH" DoTheActualIconCopy @@ -392,15 +382,15 @@ XCOMM ################################################################# MakeActionFile() { - touch $action_path > /dev/null 2>/dev/null + touch "$action_path" > /dev/null 2>/dev/null - chmod +x $action_path > /dev/null 2>/dev/null + chmod +x "$action_path" > /dev/null 2>/dev/null if [[ ! -f $action_path || ! -x $action_path ]] then failure_flag=1 PrintCreateError "$DTPRINTERFOLDER" "$action_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -414,7 +404,7 @@ MakeActionFile() else failure_flag=1 PrintCreateError "$DTPRINTERFOLDER" "$action_file" - if (( $verbose_flag )) + if (( verbose_flag )) then PrintEndLog fi @@ -444,7 +434,7 @@ PrintEndLog() { print "" print " DTPRINTERFOLDER == $DTPRINTERFOLDER" print "" - if (( $failure_flag == 0 )) && (( $unintegrate_flag == 0)) + if (( failure_flag == 0 )) && (( unintegrate_flag == 0)) then print " Created one database file," print " \"$databasefile_path\"," @@ -452,7 +442,7 @@ PrintEndLog() { print " \"$action_path\"." print "" fi - if (( $failure_flag ==0 )) + if (( failure_flag ==0 )) then print "...successfully completed." else @@ -515,7 +505,7 @@ ReloadActions() { HASH HASH Shorten forms like "host.dom.com" to "host" HASH - session_host=`uname -n` + session_host=$(uname -n) session_host=${session_host%%.*} if (( reloadactions_flag )) @@ -557,7 +547,7 @@ UnintegratePrinter() { if [[ -f $action_path ]] then - rm -fr $action_path + rm -fr "$action_path" if (( verbose_flag )) then print " Removed one action file: " @@ -567,7 +557,7 @@ UnintegratePrinter() { if [[ -f $databasefile_path ]] then - rm -fr $databasefile_path + rm -fr "$databasefile_path" if (( verbose_flag )) then print " Removed one database file:" @@ -584,7 +574,7 @@ XCOMM ## XCOMM ## XCOMM ################################################################# Exit() { - exit $1 + exit "$1" } XCOMM ################################################################# @@ -599,7 +589,6 @@ printer_flag=0 help_flag=0 helpfile_flag=0 icon_flag=0 -language_flag=0 verbose_flag=0 unintegrate_flag=0 failure_flag=0 @@ -638,7 +627,7 @@ done ((shift_positions = OPTIND - 1)) -if (( $shift_positions < $# )) +if (( shift_positions < $# )) then XCOMM XCOMM We have at least one remaining non-switch command line argument @@ -658,21 +647,21 @@ XCOMM Time to get to work. XCOMM Initialize -if (( $verbose_flag )) +if (( verbose_flag )) then PrintStartLog fi CheckOptions -if (( $unintegrate_flag )) +if (( unintegrate_flag )) then UnintegratePrinter else - if (( $icon_flag )) + if (( icon_flag )) then CopyIconFiles HASH Doing so will set the $base_icon_name for inclusion in the @@ -687,7 +676,7 @@ else fi -if (( $verbose_flag )) +if (( verbose_flag )) then PrintEndLog fi diff --git a/cde/programs/dtudcexch/Imakefile b/cde/programs/dtudcexch/Imakefile new file mode 100644 index 000000000..93cf47431 --- /dev/null +++ b/cde/programs/dtudcexch/Imakefile @@ -0,0 +1,50 @@ +XCOMM $XConsortium: Imakefile /main/12 1996/10/17 01:48:11 cde-fuj $ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +FONTEDT_PATH1 = ../dtudcfonted +UDC_INC_PATH0 = -I./ +UDC_INC_PATH1 = -I$(FONTEDT_PATH1) +UDC_INC_PATH2 = -I$(FONTEDT_PATH1)/include +UDC_INC_PATH3 = -I$(FONTEDT_PATH1)/libfal +UDC_INC_PATH4 = -I$(FONTEDT_PATH1)/libfal/include +UDC_INC_PATH7 = -I$(FONTEDT_PATH1)/dtgpftobdf + + INCLUDES = \ + $(UDC_INC_PATH0)\ + $(UDC_INC_PATH1)\ + $(UDC_INC_PATH2)\ + $(UDC_INC_PATH3)\ + $(UDC_INC_PATH4)\ + $(UDC_INC_PATH7) + +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + +DEFINES = $(OPT2) + +DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) \ + $(DEPXLIB) \ + $(FONTEDT_PATH1)/libfuty/liboakfuty.a \ + $(FONTEDT_PATH1)/libfal/libfal.a + +LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) \ + $(FONTEDT_PATH1)/libfuty/liboakfuty.a \ + $(FONTEDT_PATH1)/libfal/libfal.a + +SYS_LIBRARIES = DtClientSysLibs + + SRCS = udcexc.c udcexp.c udcimp.c getbdffn.c excutil.c\ + selectx.c exportbdf.c importbdf.c + + OBJS = udcexc.o udcexp.o udcimp.o getbdffn.o excutil.o\ + selectx.o exportbdf.o importbdf.o + +ComplexProgramTarget(dtudcexch) diff --git a/cde/programs/dtudcexch/README b/cde/programs/dtudcexch/README new file mode 100644 index 000000000..07db09600 --- /dev/null +++ b/cde/programs/dtudcexch/README @@ -0,0 +1,31 @@ +$XConsortium: README /main/3 1996/10/17 01:48:23 cde-fuj $ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +UDC data exchange utility README + +Source code and directory structure +$(TOP)/cde/dtudcexch: + Imakefile + udcexc.c + udcexp.c + udcimp.c + getbdffn.c + excutil.c + excutil.h + selectx.c + exportbdf.c + importbdf.c + +The dtudcexch command uses following commands. + dtaddcpf dtbdftocpf dtcpftobdf dtcpftogpf + dtcpgpf dtfonteditor dtgpftobdf dtgpftocpf + dtlsgpf + +The dtudcexch command uses following libraries. + libfal.a + liboakfuty.a diff --git a/cde/programs/dtudcexch/dtudcexch.msg b/cde/programs/dtudcexch/dtudcexch.msg new file mode 100644 index 000000000..fabd16779 --- /dev/null +++ b/cde/programs/dtudcexch/dtudcexch.msg @@ -0,0 +1,127 @@ +$ $XConsortium: dtudcfonted.msg +$ *************************************<+>************************************* +$ ***************************************************************************** +$ ** +$ ** File: dtudcexch.msg +$ ** +$ ** Project: Fujitsu DT UDC Exchange +$ ** +$ ** Description: +$ ** ----------- +$ ** This file is the source for the message catalog for dtudcexch +$ ** +$ ** +$ ***************************************************************************** +$ ** +$ ** (c) Copyright 1996 Fujitsu Ltd. +$ ** + +$set 2 +$ ***************************************************************************** +$ ** _DtMessage set for getbdffn.c +$ ***************************************************************************** + +2 BDF file selection +4 The selected file exists. Overwrite? +6 Failed to open the selected file. + +$set 4 +$ ***************************************************************************** +$ ** _DtMessage set for selectx.c +$ ***************************************************************************** + +2 This font has no user defined characters. +4 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect. +6 The font file is in use by another UDC application. +8 There is no font +10 Open +12 Cancel +14 UDC data exchange utility +16 SelectItems +18 - Codeset: +20 - Style: +22 - Width: +24 - Height: + +$set 6 +$ ***************************************************************************** +$ ** _DtMessage set for selectxlfd.c +$ ***************************************************************************** + +2 Do you want to terminate UDC Exchange? +4 No UDCs exist in this font +6 XLFD name is not selected +8 Cannot open the font file +10 The font file is in use by another UDC application. + +$set 8 +$ ***************************************************************************** +$ ** _DtMessage set for udcexc.c +$ ***************************************************************************** + +2 UDC data exchange utility +4 Fatal error occurred. +6 Cannot open the font file. +8 Cannot read the font file. +10 There is no more memory. +12 Fatal error occurred. +14 The specified font file does not exist. +16 This font is not a pcf or snf font. +18 Cannot open the fonts.list file. +20 The format of the fonts.list file is incorrect. +22 The descriptions of the fonts.list file are incorrect. +24 The format of the fonts.list file is incorrect. +26 Cannot open the fonts.dir file. +28 Cannot read the fonts.dir file. +30 Cannot read the font properties. +32 Cannot get the FONT property. +34 Cannot get the FAMILY_NAME property. +36 This font file is already in use by another application. +38 Cannot lock the font file. +40 Cannot unlock the font file. +42 Cannot get lock information from the font file. +44 Cannot find the specified font file. +46 Cannot read the NLS database. +48 Cannot get charset names from the NLS database. +50 The charset name is not defined in the NLS database. +52 The specified font has not been opened. +54 A fatal error occurred. +56 XLFD name : +58 Original font (XLFD name) : +60 UDC code area : +62 Style : +64 Size (letter size) : +66 Open +68 Cancel +70 OK +72 cancel +74 Copy origin code(hex) : +76 Copy target code(hex) : +78 Copy +80 Overlay +82 export function +84 import function +86 Cancel + +$set 10 +$ ***************************************************************************** +$ ** _DtMessage set for udcexp.c +$ ***************************************************************************** + +2 Failed to create the BDF file +4 No indexes are selected +6 OK +8 Cancel +10 glyph indexes + +$set 12 +$ ***************************************************************************** +$ ** _DtMessage set for udcexp.c +$ ***************************************************************************** + +2 Glyph images in this BDF file cannot be added to the font. +4 Failed to open the selected BDF font. You do not have permission to access the font file, or the format of the file is incorrect. +6 One or more glyph images will be overwritten. Overwrite? +8 Failed to open the selected font. You do not have permission to access the font file, or the format of the file is incorrect. +10 Glyph images in this BDF file cannot be added to the font. +12 Registration of the font file failed. diff --git a/cde/programs/dtudcexch/excutil.c b/cde/programs/dtudcexch/excutil.c new file mode 100644 index 000000000..ff95ab6eb --- /dev/null +++ b/cde/programs/dtudcexch/excutil.c @@ -0,0 +1,336 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: excutil.c /main/3 1996/04/08 15:51:03 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "excutil.h" + +extern char *maintitle; + +Widget excCreatePushButton(Widget parent, String name, String label, + XtCallbackProc callback_func, + XtPointer client_data) +{ + Widget widget; + XmString xms; + Arg args[20]; + Cardinal n; + + n = 0; + xms = XmStringCreateLocalized(label); + XtSetArg(args[n], XmNlabelString, xms); n++; + widget = XmCreatePushButton(parent, name, args, n); + XmStringFree(xms); + XtAddCallback(widget, XmNactivateCallback, + (XtCallbackProc) callback_func, + (XtPointer) client_data); + XtManageChild(widget); + + return (widget); +} + +void excerror(Exc_data * ed, int excerrno, char * funcname, char * func) +{ + switch (excerrno) + { + case EXCERRMALLOC: + fprintf(stderr, "dtudcexch:memory allocation error\n"); + freeExcdata(ed); + exit (-1); + case EXCERRNOUDC: + fprintf(stderr, "dtudcexch:UDC is not defined in current locale\n"); + freeExcdata(ed); + exit (-1); + } +} + +void dialogokCB(Widget widget, int * ans, XtPointer call_data) +{ + /* ok button pushed */ + *ans = 1; +} + +void dialogcancelCB(Widget widget, int * ans, XtPointer call_data) +{ + /* cancel button pushed */ + *ans = 2; +} + +void AskUser(Widget parent, Exc_data * ed, char *msg, int *r, char * type) +/* If ok button pushed, *r = 1. */ +/* If cancel button pushed(if exists), *r = 2. */ +{ + XmString message; + Widget dialog; + int ans = 0; + Cardinal n; + Arg args[20]; + + n = 0; + message = XmStringCreateLocalized(msg); + XtSetArg(args[n], XmNmessageString, message); n++; + XtSetArg(args[n], XmNtitle, maintitle); n++; + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++; + if (strcmp(type, "warning") == 0) { + dialog = XmCreateWarningDialog(parent, type, args, n); + } else if (strcmp(type, "error") == 0) { + dialog = XmCreateErrorDialog(parent, type, args, n); + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON)); + } else if (strcmp(type, "information") == 0) { + dialog = XmCreateInformationDialog(parent, type, args, n); + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON)); + } else if (strcmp(type, "question") == 0) { + dialog = XmCreateQuestionDialog(parent, type, args, n); + } else { + fprintf(stderr, "error in AskUser\n"); + } + XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON)); + XmStringFree(message); + XtAddCallback(dialog, XmNokCallback, (XtCallbackProc) dialogokCB, + (XtPointer) &ans); + XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc) dialogcancelCB, + (XtPointer) &ans); + XtManageChild(dialog); + while (ans == 0) { + XtAppProcessEvent(ed->app, XtIMAll); + XSync(XtDisplay(dialog), 0); + } + *r = ans; + XSync(XtDisplay(dialog), 0); + XmUpdateDisplay(dialog); +} + +int beki(int n, int num) +{ + int a,i; + + a = 1; + for (i=0; i<num; i++) + a = a * n; + + return a; +} + +int c2h(char * num) +{ + int i,n; + char *c; + + if ((strlen(num)==6)&&(strncmp(num,"0x",2)==0)) + { + c = num; + c=c+2; + n=0; + for (i=3;i>=0;i--) + { + if (('0'<= *c)&&(*c <= '9')) + n = n + ((*c - '0')*beki(16,i)); + else if (('a' <= *c)&&(*c <= 'f')) + n = n + ((*c - 'a'+10)*beki(16,i)); + else + Ecs("error in c2h.here"); + c++; + } + } else + Ecs("error in c2h"); + + return n; +} +char * renge2num(char * renge) +{ + char * num; + + num = (char *) calloc(7, sizeof(char)); + + strncpy(num,renge,6); + + return num; +} + +void Ecs(char * string) +{ + fprintf(stderr,"%s\n",string); +} +void Ecd(int data) +{ + fprintf(stderr,"%d\n",data); +} + +void freecsrec(UDCcsREC *rec) +{ + if (rec->charset != NULL) + free(rec->charset); + if (rec->udcrenge != NULL) + free(rec->udcrenge); +} + +void freecslist(int n, UDCcsREC *rec) +{ + int i; + UDCcsREC *recp; + + recp = rec; + for (i = 0; i < n; i++) + { + if (recp != NULL) + { + freecsrec(recp); + recp++; + } else { + break; + } + } +} + +void freeExcdata(Exc_data *ed) +{ + if (ed == NULL) + return; + +/* Don't free ed->toplevel */ + + if (ed->locale != NULL) + free(ed->locale); + + if (ed->cslist != NULL) + free(ed->cslist); + + if (ed->xlfdname != NULL) + free(ed->xlfdname); + + if (ed->style != NULL) + free(ed->style); + + if (ed->size != NULL) + free(ed->size); + +/* Don't free ed->fontfile */ + + if (ed->bdffile != NULL) + XtFree(ed->bdffile); + + if (ed->udcrenge != NULL) + free(ed->udcrenge); + + if (ed->gpf_code_list != NULL) + free(ed->gpf_code_list); + + if (ed->bdf_code_list != NULL) + free(ed->bdf_code_list); + + if (ed->comment_list != NULL) + free(ed->comment_list); + + free(ed); +} + +void Ecss(char * s1, char * s2) +{ + fprintf(stderr,"%s is %s\n", s1, s2); +} +void Ecsd(char * s1, int i) +{ + fprintf(stderr,"%s = %d\n", s1, i); +} + +void checkdata(Exc_data *ed) +{ + if (ed == NULL) + return; + +/* Don't free ed->toplevel */ + + if (ed->locale != NULL) + Ecss("ed->locale", ed->locale); + + Ecsd("ed->csnum", ed->csnum); + + if (ed->xlfdname != NULL) + Ecss("ed->xlfdname",ed->xlfdname); + + if (ed->fontfile != NULL) + Ecss("ed->fontfile",ed->fontfile); + + if (ed->bdffile != NULL) + Ecss("ed->bdffile",ed->bdffile); + + if (ed->udcrenge != NULL) + Ecss("ed->udcrenge",ed->udcrenge); + + Ecsd("ed->code_num", ed->code_num); +} + +void excterminate(Exc_data * ed) +{ + freeExcdata(ed); + exit(0); +} + +void excexit(Exc_data * ed) +{ + excterminate(ed); +} + +void freeld(ListData *ld) +{ + int i; + char **cp; + + if (ld != NULL) { + if (ld->allcode != NULL) + free(ld->allcode); + if (ld->existcode != NULL) + free(ld->existcode); + if (ld->existcode_c != NULL) { + cp = ld->existcode_c; + for (i = 0; i < ld->existcode_num; i++) { + if (*cp != NULL) + free(*cp); + cp++; + } + free(ld->existcode_c); + } + free(ld); + } +} + +int bigger(int num1, int num2) +{ + if (num1 >= num2) + return (num1); + else + return (num2); +} + +int smaller(int num1, int num2) +{ + if (num1 < num2) + return (num1); + else + return (num2); +} diff --git a/cde/programs/dtudcexch/excutil.h b/cde/programs/dtudcexch/excutil.h new file mode 100644 index 000000000..83fdd9ec6 --- /dev/null +++ b/cde/programs/dtudcexch/excutil.h @@ -0,0 +1,129 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: excutil.h /main/6 1996/12/23 08:48:26 barstow $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include <stdio.h> +#include <stdlib.h> +#include <Xm/Xm.h> +#include <Xm/MessageB.h> +#include <Xm/PushB.h> +#define EXPORT 1 +#define IMPORT 2 +#define EXCERRMALLOC 101 +#define EXCERRNOUDC 102 + +void Ecs(); +void Ecd(); +/*void getpcffn();*/ +void getbdffn(); +void selcharcd(); +void getcharcd(); +void createbdf(); +int bigger(); +int smaller(); +int c2h(); +char *renge2num(); +void freeExcdata(); +void checkdata(); +void excexit(); +void excterminate(); +void freeld(); +void getexistcode(); +void AskUser(); +void excerror(); +Widget excCreatePushButton(); + +typedef struct { + char * charset; + char * udcrenge; +} UDCcsREC; + +typedef struct { + int function; + XtAppContext app; + Widget toplevel; + char *locale; + int csnum; + UDCcsREC *cslist; + char *xlfdname; + char *style; + char *size; + char *fontfile; + char *bdffile; + char bdfmode[2]; + char *udcrenge; + int code_num; + int *gpf_code_list; + int *bdf_code_list; + int comment_num; + char **comment_list; +} Exc_data; + +typedef struct { + Widget list; + int allcode_num; + int *allcode; + int existcode_num; + int *existcode; + char **existcode_c; + Exc_data *ed; +} ListData; + +#ifndef NO_MESSAGE_CATALOG +# define _CLIENT_CAT_NAME "dtudcexch" + +extern char *_DtGetMessage( + char *filename, + int set, + int n, + char *s ); + +#define GETMESSAGE(set, number, string) GetMessage(set, number, string) +static char * +GetMessage(int set, int number, char *string) +{ + char *tmp; + static char * point[100]; + static int first = True; + + if (first) { + memset(point, 0, sizeof(char *) * 100); + first = False; + } + if (point[number]) + return(point[number]); + tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string); + point[number] = (char *) malloc(strlen(tmp) + 1); + strcpy(point[number], tmp); + return (point[number]); +} +#else /* NO_MESSAGE_CATALOG */ +# define GETMESSAGE(set, number, string)\ + string +#endif /* NO_MESSAGE_CATALOG */ diff --git a/cde/programs/dtudcexch/exportbdf.c b/cde/programs/dtudcexch/exportbdf.c new file mode 100644 index 000000000..0f13c71cd --- /dev/null +++ b/cde/programs/dtudcexch/exportbdf.c @@ -0,0 +1,363 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: exportbdf.c /main/4 1996/04/10 13:49:20 ageorge $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Authors: Seiya Miyazaki FUJITSU LIMITED + * Hiroyuki Chiba FUJITSU LIMITED + */ +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <stdlib.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif +#include <memory.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <errno.h> + +#include "bdfgpf.h" + +static int writeBdfHeader(); +static int readBdfToMemory(); +static void sigint_out(); +static char buf[BUFSIZE]; +static struct ptobhead w_bdf ; + +static void +sigint_out() +{ + fclose(w_bdf.output) ; + fclose(w_bdf.input) ; /* stream */ + exit( 0 ); +} + +int +expCheckCode( unsigned int code, int code_num, int *code_list ) +{ + int i ; + + if( code < MIN_CODE || code > MAX_CODE ) return -1 ; + for( i=0; i<code_num; i++ ){ + if( code == code_list[i] ) return 0 ; + } + return -1 ; +} + +int +ExpGpftoBDF( + char *gpf_name, /* pointer to GPF file name area */ + char *bdf_name, /* pointer to BDF file name area */ + int code_num, /* number of GPF code */ + int *code_list, /* pointer to GPF code lists */ + int comment_num, /* number comments */ + char **comment_list, /* pointer to the list of comments */ + int make_all /* convert whole GPF fomat file to BDF */ +) +{ + struct stat statbuf ; + struct btophead r_gpf ; + int rtn, i, num_chars ; + + /* + * parameter check + */ + if( gpf_name == NULL || bdf_name == NULL ){ + fprintf(stderr, "GPF or BDF file name is not specified.\n" ) ; + return -1 ; + } + /* + * initiation + */ + memset( &w_bdf, 0, sizeof(struct ptobhead) ) ; + memset( &r_gpf, 0, sizeof(struct btophead) ) ; + + if ( stat( SNFTOBDF, &statbuf ) ) { + if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) { + fprintf( stderr, "There is not %s command.\n", SNFTOBDF_CMD ) ; + return -1 ; + } + }else{ + oakgtobdf = SNFTOBDF; + } + + /* + * export glyphs in BDF format + */ + w_bdf.snf_file = gpf_name ; + if( (w_bdf.output = fopen( bdf_name, "w" )) == NULL ){ + fprintf(stderr, "\"%s\" cannot open.\n", bdf_name ) ; + return -1 ; + } + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + if( (rtn = writeBdfHeader(&w_bdf, comment_num, comment_list)) ){ + fprintf(stderr, "\"%s\" cannot write header.\n", bdf_name ) ; + fclose(w_bdf.output) ; + fclose(w_bdf.input) ; /* stream */ + return rtn ; + } + + r_gpf.bdf_width = w_bdf.bdf_width ; + r_gpf.bdf_height = w_bdf.bdf_height ; + r_gpf.input = w_bdf.input ; + + num_chars = ((make_all) ? w_bdf.num_chars : code_num) ; + + if( (r_gpf.code = (int *)malloc( sizeof(int) * num_chars)) == NULL ) { + fclose(w_bdf.output) ; + fclose(w_bdf.input) ; + return(MALLOC_ERROR); + } + + if( (r_gpf.ptn = (char **)calloc( num_chars, sizeof(char *) )) == NULL ) { + fclose(w_bdf.output) ; + fclose(w_bdf.input) ; + return(MALLOC_ERROR); + } + + if( (rtn = readBdfToMemory(&r_gpf, buf, code_num, code_list, make_all)) ){ + fprintf(stderr, "\"%s\" cannot read glyph.\n", bdf_name ) ; + fclose(w_bdf.output) ; + fclose(w_bdf.input) ; + return rtn ; + } + fclose(w_bdf.input) ; + wait(0) ; + + w_bdf.zoomf = 0 ; + w_bdf.num_chars = r_gpf.num_chars ; + w_bdf.code = r_gpf.code ; + w_bdf.ptn = r_gpf.ptn ; + + if( (rtn = WritePtnToBdf( &w_bdf )) ){ + fprintf(stderr, "\"%s\" cannot write glyph.\n", bdf_name ) ; + fclose(w_bdf.output) ; + return rtn ; + } + fclose(w_bdf.output) ; + + signal( SIGHUP , SIG_IGN ); + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + /* + * free memories + */ + free( r_gpf.code ) ; + for(i=0; i<r_gpf.num_chars; i++){ + if(r_gpf.ptn[i]) free(r_gpf.ptn[i]) ; + } + free( r_gpf.ptn ) ; + + return 0 ; +} + +static int +writeBdfHeader(struct ptobhead *head, + int comment_num, /* number comments */ + char **comment_list /*pointer to the list of comments */ +) +{ + FILE *fp; + int fd[2]; + unsigned int getstat; + char buf[BUFSIZE], *p; + + int cnt ; + int comflg ; + pid_t chld_pid = 0; +#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__) + int chld_stat ; +#else + union wait chld_stat ; +#endif + + if (head->snf_file != NULL) { + if (pipe(fd) != 0) { + return PIPE_ERROR; + } + switch (chld_pid = fork()) { + case 0: + close(1); + if(dup(fd[1]) < 0) { + return(DUP_ERROR); + } + close(fd[0]); + close(fd[1]); + execl( oakgtobdf, oakgtobdf, head->snf_file, 0); + return EXEC_ERROR; + case -1: + return(FORK_ERROR); + default: + break; + } + close(fd[1]); + if((fp = (FILE *)fdopen(fd[0], "r")) == NULL) { + close( fd[0] ); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + return FDOPEN_ERROR; + } + } else { + return(BDF_OPEN_HEAD); + } + head->input = fp ; + getstat = 0; + comflg = 0 ; + + while ( 1 ) { + if (fgets(buf, BUFSIZE, fp) == NULL) { + fclose( fp ); + if (head->snf_file != NULL) { + close(fd[0]); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p); + + if (!strncmp(p, CHARS, CHARSsz)) { + if ((sscanf(p, "CHARS %d", &(head->num_chars))) != 1 ){ + return(BDF_INVAL); + } + getstat |= 0x04; + break; + } + /* + * write user comments + */ + if ( !strncmp(p, "FONT", strlen("FONT")) + && comment_list && !comflg + ) { + int i ; + for( i=0; i<comment_num; i++ ){ + char *ep ; + if( (ep = (char *)strchr( comment_list[i], '\n' )) != NULL ) + *ep = '\0' ; + if( !comment_list[i] ) continue ; + fprintf(head->output, "COMMENT %s\n", comment_list[i]); + } + fprintf(head->output, "COMMENT\n"); + comflg++ ; + } + + fprintf(head->output, "%s", buf); + + if (!strncmp(p, SIZE, SIZEsz)) { + if ((sscanf(p, "SIZE %f%d", + &(head->bdf_point), &(head->bdf_xdpi))) != 2) { + fclose(fp); + if (head->snf_file != NULL) { + close(fd[0]); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + getstat |= 0x01; + continue; + } + if (!strncmp(p, FONTBOUNDINGBOX, FONTBOUNDINGBOXsz)) { + if (( cnt = sscanf( p, "FONTBOUNDINGBOX %d%d%d%d", + &(head->bdf_width), &(head->bdf_height), + &(head->bdf_x), &(head->bdf_y))) != 4 + ) { + fclose(fp); + if (head->snf_file != NULL) { + close(fd[0]); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return BDF_INVAL; + } + getstat |= 0x02; + continue; + } + get_charset_registry(head, p) ; + } + + if (getstat != 0x07) { + return BDF_INVAL; + } + + return 0; +} + + +static int +readBdfToMemory(struct btophead *head, char *buf, +int code_num, /* number of GPF code */ +int *code_list, /* pointer to GPF code lists */ +int make_all /* convert whole GPF fomat file to BDF */ +) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + if ( !make_all ) { + if ( expCheckCode(code, code_num, code_list) ) { + continue; + } + } + + head->code[num_char] = code; + if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) { + return(MALLOC_ERROR); + } + + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} diff --git a/cde/programs/dtudcexch/getbdffn.c b/cde/programs/dtudcexch/getbdffn.c new file mode 100644 index 000000000..7415084f8 --- /dev/null +++ b/cde/programs/dtudcexch/getbdffn.c @@ -0,0 +1,180 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: getbdffn.c /main/5 1996/10/14 14:44:32 barstow $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "excutil.h" +#include <Xm/FileSB.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +/* + * There is no public header file for this function (only an + * internal header XmStringI.h). + */ +extern XtPointer _XmStringUngenerate (XmString string, + XmStringTag tag, + XmTextType tag_type, + XmTextType output_type); + +void filesbokCB(); +void filesbcancelCB(); + +extern char *maintitle; + +void getbdffn(Exc_data * ed) +{ + Widget filesb; + Arg args[20]; + Cardinal n; + char *selectlabel; + XmString xms; + + selectlabel = GETMESSAGE(2, 2, "BDF file selection"); + n = 0; + XtSetArg(args[n], XmNtitle, maintitle); n++; + xms = XmStringCreateLocalized(selectlabel); + XtSetArg(args[n], XmNselectionLabelString, xms); n++; + filesb = XmCreateFileSelectionDialog(ed->toplevel, "filesb", args, n); + XtAddCallback(filesb, XmNokCallback, + (XtCallbackProc) filesbokCB, + (XtPointer) ed); + XtAddCallback(filesb, XmNcancelCallback, + (XtCallbackProc) filesbcancelCB, + (XtPointer) ed); + XtUnmanageChild(XmFileSelectionBoxGetChild(filesb, XmDIALOG_HELP_BUTTON)); + XtManageChild(filesb); +} + +int fopencheck(char *file, char *dir, char *mode) +/* + * when mode = "r", if fopen can open the file with read only mode, return 0 + * when mode = "w", if fopen can open the file with write mode, return 0 + * but if the file exists, return 1 + * otherwise return -1 + */ +{ + struct stat buf; + + if (strcmp(mode, "r") == 0) { + if (stat(file, &buf) == 0) + if ((buf.st_mode & S_IFMT) == S_IFREG) + return 0; /* readable regular file */ + } else if (strcmp(mode, "w") == 0) { + if (stat(file, &buf) == 0) { + if (((buf.st_mode & S_IFMT) == S_IFREG) && + (access(file, W_OK) == 0)) + return 1; /* writable existing file */ + } else { + if (stat(dir, &buf) == 0) { + if (((buf.st_mode & S_IFMT) == S_IFDIR) && + (access(dir, W_OK) == 0)) { + return 0; /* writable new file */ + } + } + } + } else + fprintf(stderr, "Unanticipatable error occurred in fopencheck.\n"); + return -1; +} + +void filesbcancelCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ + excexit(ed); +} + +void freeStrings(char * dir, char * file) +{ + if (dir != NULL) + XtFree(dir); + if (file != NULL) + XtFree(file); +} + +void filesbokCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ + XmFileSelectionBoxCallbackStruct *ptr; + char *file = NULL, *dir = NULL, *tmpfile; + int r, ans = 0; + char *msg1; + char *msg2; + + msg1 = GETMESSAGE(2, 4, "The selected file exists. Overwrite?"); + msg2 = GETMESSAGE(2, 6, "Failed to open the selected file."); + + ptr = (XmFileSelectionBoxCallbackStruct *) call_data; + + file = (char *) _XmStringUngenerate((XmString) ptr->value, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (!file) { + return; + } + + dir = (char *) _XmStringUngenerate((XmString) ptr->dir, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (!dir) { + return; + } else { + if (*file != '/') { + if ((tmpfile = XtMalloc(strlen(dir) + 1 + strlen(file) + 1)) + == NULL) { + excerror(ed, EXCERRMALLOC, "filesbokCB", "exit"); + } + sprintf(tmpfile, "%s/%s", dir, file); + XtFree(file); + file = tmpfile; + } + } + + r = fopencheck(file, dir, ed->bdfmode); + if (r == 0) {/* no problem */ + /*fprintf(stderr, "%s will be opened\n", file);*/ + } else if (r == 1) { /* file exist at export function */ + AskUser(widget, ed, msg1, &ans, "warning"); + if (ans != 1) { /* overwrite cancel */ + freeStrings(dir, file); + return; + } + } else { /* file will not be opened */ + AskUser(widget, ed, msg2, &ans, "error"); + freeStrings(dir, file); + return; + } + ed->bdffile = (char *) malloc(strlen(file) + 1); + strcpy(ed->bdffile, file); + freeStrings(dir, file); + XtUnmanageChild(widget); + if (ed->function == EXPORT) + { + createbdf(ed); + } else if (ed->function == IMPORT) + { + PopupSelectXLFD(ed->toplevel); + } +} diff --git a/cde/programs/dtudcexch/importbdf.c b/cde/programs/dtudcexch/importbdf.c new file mode 100644 index 000000000..480c71f29 --- /dev/null +++ b/cde/programs/dtudcexch/importbdf.c @@ -0,0 +1,699 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: importbdf.c /main/5 1996/06/27 10:40:33 ageorge $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Authors: Seiya Miyazaki FUJITSU LIMITED + * Hiroyuki Chiba FUJITSU LIMITED + * + */ + + + +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif + +#include <unistd.h> + +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "bdfgpf.h" +#include "FaLib.h" + +#include <errno.h> + +#define UNLINK_TMPFILE( file ){ \ + if ( unlink( file ) != 0 ) { \ + exit(-1) ; \ + } \ +} + +static impFileConvInit(); +static impGetGpfInf(); +static impReadBdfHeaderAndPut(); +static impMergePtn(); +static impModifyPtn(); +static impInsertPtn(); +static impWriteSnf(); +static int impWritePtnToBdf(); +static int impPutDefaultChars(); +static int impReadBdfToMemory(); + +extern int expCheckCode(); + + +static struct ptobhead WriteGpf; + +static char *targ_file = NULL; /* UDC_file_name */ + + +static void +sigint_out(void) +{ + if (WriteGpf.out_file) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + exit( 0 ); +} + + + + +int +ImpBDFCodeList(char *bdf_name, int *code_num, int **code_list) +{ + int *glyph_list ; + FILE *bdfp ; + char *p ; + char buf[2048] ; + int cnt ; + + /* open BDF file */ + if( (bdfp = fopen( bdf_name, "r" )) == NULL ){ + return(-1); + } + + /* get number of characters in BDF file */ + while ( 1 ) { + if( fgets( buf, BUFSIZE, bdfp ) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP( p ) + if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) { + if ( ( sscanf( p, "CHARS %d", code_num ) ) != 1 ) { + return BDF_INVAL; + } + break ; + } + } + + /* alloc memory for codes */ + if( (glyph_list = (int *)calloc( *code_num, (unsigned int)sizeof(int) )) == NULL ){ + return(-1); + } + + /* get codes of BDF file */ + cnt = 0 ; + while( cnt < *code_num ) { + if (fgets(buf, BUFSIZE, bdfp ) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP( p ) + if (!strncmp(p, ENDFONT, (unsigned int)ENDFONTsz)) { + break; + }else if (!strncmp(p, ENCODING, (unsigned int)ENCODINGsz)) { + if ((sscanf(p, "ENCODING %d", &glyph_list[cnt] )) != 1) { + return(BDF_INVAL); + } + cnt ++ ; + } + } + if( cnt != *code_num ){ + return(-1) ; + } + + /* close BDF file */ + if( fclose( bdfp ) ){ + return(-1); + } + + *code_list = glyph_list ; + + return(0) ; +} + + + +int +ImpBDFCodeListFree(int **code_list) +{ + free( *code_list ) ; + return(0) ; +} + + + +int +ImpBDFCheck( +char *bdf_name, /* BDF file name */ +char *gpf_name /* GPF file name */ +) +{ + /* parameter check */ + if( bdf_name == NULL || gpf_name == NULL ){ + return(-1) ; + } + return(0) ; +} + + + + +int +ImpBDFtoGpf( +char *bdf_name, +char *gpf_name, +int bdf_codenum, +int *bdf_codelist +) +{ + int rtn ; + int exit_stat; + struct btophead ReadGpf; + struct btophead ReadUdc; + struct stat statbuf; + char buf[BUFSIZE]; + + int chk_fd; + + ReadGpf.in_file = ReadUdc.in_file = WriteGpf.out_file = NULL; + + if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) { + bdftopcf = BDFTOPCF; + } + if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) { + oakgtobdf = SNFTOBDF; + } + if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) { + bdftosnf = BDFTOSNF; + } + + /* + * set input/output file name + */ + + ReadUdc.in_file = bdf_name ; + ReadUdc.code_category = ALL_CODE ; + ReadUdc.start_code = MIN_CODE ; + ReadUdc.end_code = MAX_CODE ; + + ReadGpf.in_file = gpf_name ; + ReadGpf.code_category = ALL_CODE ; + ReadGpf.start_code = MIN_CODE ; + ReadGpf.end_code = MAX_CODE ; + + /* + * get real file name of GPF file + */ + if ((targ_file = GetRealFileName( ReadGpf.in_file )) == NULL){ + return(-1); + } + + /* + * WriteGpf.snf_file = ReadGpf.in_file + */ + WriteGpf.snf_file = targ_file; + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + /* + * impFileConvInit() + * + * SNFTOBDF, BDFTOSNF + * + * (ReadGpf.in_file) --> SNFTOBDF ==H + * H + * oakaddp <-- (ReadUdc.in_file) + * H + * (WriteGpf.out_file) <-- BDFTOSNF ==H + * + */ + + /* + * make a temporary file by BDF format corresponded to target GPF file + */ + if ( rtn = impFileConvInit( &ReadUdc, &ReadGpf, &WriteGpf ) ) { + if ( WriteGpf.out_file ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + return(-1) ; + } + + /* + * get informations from import file in BDF format + */ + if ( rtn = ReadBdfHeader( &ReadUdc, buf ) ) { + if ( WriteGpf.out_file ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + return(-1) ; + } + + /* + * get informations from target file in BDF format + */ + + if ( rtn = impGetGpfInf( &ReadGpf, &WriteGpf, buf, bdf_codenum ) ) { + if ( WriteGpf.out_file ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + return(-1) ; + } + + /* wait for dtgpftobdf */ + fclose( ReadGpf.input ); + wait( 0 ); + + /* + * merge the UDC glyphs into GPF file (in BDF format) + */ + if ( ( rtn = impMergePtn( &ReadUdc, &ReadGpf, buf, + bdf_codenum, bdf_codelist ) ) ) { + if ( WriteGpf.out_file ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + return(-1) ; + } + + /* + * write the UDC data into GPF output file (in BDF format) + */ + if ( ( rtn = impWriteSnf( &ReadGpf, &WriteGpf ) ) ) { + if ( WriteGpf.out_file ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + } + return(-1) ; + } + + /* + * convert temporary file into GPF format + */ + fclose( ReadUdc.input ); + fclose( WriteGpf.output ); + wait( &exit_stat ); +#if !defined( SVR4 ) && !defined( SYSV ) + if ( !WIFEXITED(exit_stat) ) { +#else + if ( ! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) { +#endif + UNLINK_TMPFILE( WriteGpf.out_file ); + return(-1) ; + } + signal( SIGHUP , SIG_IGN ); + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + sleep( 1 ); + if ( ( stat( WriteGpf.out_file, &statbuf ) ) || ( statbuf.st_size == 0 ) + ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + return(-1) ; + } + if ( stat( WriteGpf.snf_file, &statbuf ) ) { + UNLINK_TMPFILE( WriteGpf.out_file ); + return( -1 ); + } + /* + * convert the temporary file to target file + */ + return( Make_NewFefFile( WriteGpf.snf_file, WriteGpf.out_file, + FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, "ImpBDFtoGpf()" )); +} + + +/* +* sub functions +*/ + +static +impFileConvInit( +struct btophead *r_udc, +struct btophead *r_gpf, +struct ptobhead *w_gpf +) +{ + int fd[2], snf_fd, permission; + char buf[BUFSIZE]; + int pfd[2], ofd; + + FontInfoRec *finf; + char *optlist[5] = {0,0,0,0,0}; + char *ep ; + int i ; + struct stat statbuf ; + + + + if ( ( r_udc->input = fopen(r_udc->in_file, "r")) == NULL ) { + return GPF_OPEN_IN; + } + + /* + * case of SNF file + */ + if ( ChkPcfFontFile( w_gpf->snf_file ) ) { + /* snf */ + if ( ( snf_fd = open( w_gpf->snf_file, O_RDONLY ) ) >= 0 ) { + return BDF_OPEN_IN; + } + } + + if (pipe(fd) != 0) { + return PIPE_ERROR; + } + switch ( fork() ) { + case 0: + close( fd[0] ); + close( 1 ); + if ( dup( fd[1] ) < 0 ) { + return DUP_ERROR; + } + + close( fd[1] ); + + /* gpf -> bdf */ + execl( oakgtobdf, oakgtobdf, r_gpf->in_file, 0 ); + return EXEC_ERROR; + + case -1: + return FORK_ERROR; + + default: + break; + } + close( fd[1] ); + if ( ( r_gpf->input = (FILE *)fdopen( fd[0], "r" ) ) == NULL ) { + return FDOPEN_ERROR; + } + + if ( !( w_gpf->out_file = GetTmpPath( targ_file ) ) ) { + return MKTMP_ERROR; + } + + if ( pipe( pfd ) != 0 ) { + return PIPE_ERROR; + } + switch ( fork() ) { + case 0: + if ( ( ofd = open( w_gpf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) { + return BDF_OPEN_OUT; + } + close( 0 ); + if ( dup(pfd[0]) < 0 ) { + return DUP_ERROR; + } + close( pfd[0] ); + close( pfd[1] ); + close( 1 ); + if( dup( ofd ) < 0 ) { + return DUP_ERROR; + } + close( ofd ); + /* + * case of PCF file format + */ + if ( ChkPcfFontFile( w_gpf->snf_file ) == 0 ) { + execl( bdftopcf, bdftopcf, 0 ); + return EXEC_ERROR; + } + /* + * case of SNF file format + */ + COMM_SNF_EXECLBDFTOSNF( permission, buf, w_gpf->snf_file ) ; + return EXEC_ERROR; + + case -1: + return FORK_ERROR; + + default: + break; + } + close( pfd[0] ); + if ( ( w_gpf->output = (FILE *)fdopen( pfd[1], "w" ) ) == NULL ) { + return FDOPEN_ERROR; + } + return 0; +} + + + + + +static +impGetGpfInf( +struct btophead *r_gpf, +struct ptobhead *w_gpf, +char *buf, +int bdf_codenum +) +{ + int nchar, rtn; + + if ( ( rtn = impReadBdfHeaderAndPut( r_gpf, w_gpf, buf ) ) ) { + return rtn; + } + + nchar = r_gpf->num_chars + bdf_codenum ; + + if ( ( r_gpf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( r_gpf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + return ReadBdfToMemory( r_gpf, buf ) ; +} + + + +static +impReadBdfHeaderAndPut( +struct btophead *r_gpf, +struct ptobhead *w_gpf, +char *buf +) +{ + char *p; + unsigned int getstat = 0; + + while ( 1 ) { + if ( fgets( buf, BUFSIZE, r_gpf->input ) == NULL ) { + return BDF_INVAL; + } + p = buf; + SCAN_TO_NONSP( p ) + if ( !strncmp( p, SIZE, (unsigned int)strlen( SIZE ) ) ) { + if ( ( sscanf( p, "SIZE %f%d", + &(r_gpf->bdf_point), &(r_gpf->bdf_xdpi))) != 2 ) { + return BDF_INVAL; + } + fprintf( w_gpf->output, "%s", buf ); + getstat |= 0x01; + + } else if ( !strncmp( p, FONTBOUNDINGBOX, (unsigned int)strlen( FONTBOUNDINGBOX ) ) ) { + if ( ( sscanf( p, "FONTBOUNDINGBOX %d %d %d %d", + &(r_gpf->bdf_width), &(r_gpf->bdf_height), + &(r_gpf->bdf_x), &(r_gpf->bdf_y) ) ) != 4 ) { + return BDF_INVAL; + } + fprintf( w_gpf->output, "%s", buf ); + getstat |= 0x02; + + } else if ( !strncmp( p, CHARS, (unsigned int)strlen( CHARS ) ) ) { + if ( ( sscanf( p, "CHARS %d", &( r_gpf->num_chars ) ) ) != 1 ) { + return BDF_INVAL; + } + getstat |= 0x04; + break; + } else { + fprintf( w_gpf->output, "%s", buf ); + } + } + + if ( getstat != 0x07 ) { + return BDF_INVAL; + } + return 0; +} + + +static +impMergePtn( +struct btophead *r_udc, +struct btophead *r_gpf, +char *buf, +int bdf_codenum, +int *bdf_codelist +) +{ + int code, rtn, msize, i, j; + char *ptn; + + if ( ( r_udc->bdf_width != r_gpf->bdf_width ) + || ( r_udc->bdf_height != r_gpf->bdf_height ) + ) { + r_udc->zoomf = 1; + + msize = ( r_udc->bdf_width + 7 ) / 8 * r_udc->bdf_height; + + if ( ( ptn = (char *)malloc( msize ) ) == NULL ) { + return MALLOC_ERROR; + } + r_udc->ptn = &ptn; + + } else { + r_udc->zoomf = 0; + } + + for ( i = 0; i < r_udc->num_chars; i++ ) { + if ( ( rtn = GetBdfCode( r_udc, buf, &code ) ) < 0 ) { + return rtn; + } else if ( rtn == FILE_END ) { + break; + } + + if( expCheckCode( code, bdf_codenum, bdf_codelist ) ) { + continue ; + } + + for ( j = 0; j < r_gpf->num_chars; j++ ) { + if ( r_gpf->code[j] == code ) { + if ( ( rtn = impModifyPtn( r_udc, r_gpf, buf, j ) ) ) { + return rtn; + } + break; + } else if ( r_gpf->code[j] > code ) { + if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) { + return rtn; + } + break; + } + } + if ( j == r_gpf->num_chars ) { + if ( ( rtn = impInsertPtn( r_udc, r_gpf, buf, code, j ) ) ) { + return rtn; + } + } + } + return 0; +} + +static +impModifyPtn(struct btophead *r_udc, struct btophead *r_gpf, char *buf, int ix) +{ + int mwidth, msize, rtn; + + mwidth = ( r_udc->bdf_width + 7 ) / 8; + msize = mwidth * r_udc->bdf_height; + + if ( r_udc->zoomf ) { + if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) { + return rtn; + } + if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0], + r_udc->bdf_width, r_udc->bdf_height, + r_gpf->bdf_width, r_gpf->bdf_height ) ) ) { + return rtn; + } + } else { + if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) { + return rtn; + } + } + return 0; +} + +static +impInsertPtn( +struct btophead *r_udc, +struct btophead *r_gpf, +char *buf, +int code, +int ix +) +{ + int mwidth, msize, rtn, i; + + for ( i = r_gpf->num_chars; i > ix; i-- ) { + r_gpf->code[i] = r_gpf->code[i-1]; + r_gpf->ptn[i] = r_gpf->ptn[i-1]; + } + r_gpf->code[ix] = code; + + r_gpf->num_chars++; + + mwidth = (r_gpf->bdf_width + 7) / 8; + msize = mwidth * r_gpf->bdf_height; + + if ( ( r_gpf->ptn[ix] = (char *)malloc( msize ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( r_udc->zoomf ) { + mwidth = (r_udc->bdf_width + 7) / 8; + msize = mwidth * r_udc->bdf_height; + if ( ( rtn = GetBdfPtn( r_udc, buf, r_udc->ptn[0], mwidth, msize ) ) ) { + return rtn; + } + if ( ( rtn = PtnZoom( r_gpf->ptn[ix], r_udc->ptn[0], + r_udc->bdf_width, r_udc->bdf_height, + r_gpf->bdf_width, r_gpf->bdf_height ) ) ) { + return rtn; + } + } else { + if ( ( rtn = GetBdfPtn( r_udc, buf, r_gpf->ptn[ix], mwidth, msize ) ) ) { + return rtn; + } + } + return(0); +} + +static +impWriteSnf(struct btophead *r_gpf, struct ptobhead *w_gpf) +{ + w_gpf->zoomf = 0; + w_gpf->num_chars = r_gpf->num_chars; + w_gpf->code = r_gpf->code; + w_gpf->ptn = r_gpf->ptn; + w_gpf->bdf_width = r_gpf->bdf_width; + w_gpf->bdf_height = r_gpf->bdf_height; + w_gpf->bdf_x = r_gpf->bdf_x; + w_gpf->bdf_y = r_gpf->bdf_y; + w_gpf->bdf_point = r_gpf->bdf_point; + w_gpf->bdf_xdpi = r_gpf->bdf_xdpi; + + return WritePtnToBdf( w_gpf ); +} diff --git a/cde/programs/dtudcexch/selectx.c b/cde/programs/dtudcexch/selectx.c new file mode 100644 index 000000000..520da5e6f --- /dev/null +++ b/cde/programs/dtudcexch/selectx.c @@ -0,0 +1,1196 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* selectx.c 1.12 - Fujitsu source for CDEnext 96/03/01 09:34:52 */ +/* $TOG: selectx.c /main/5 1997/07/23 17:24:39 samborn $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <locale.h> /* dtex add */ +#include <math.h> /* dtex add */ +#include <nl_types.h> + +#include<X11/Xlib.h> +#include<X11/Xutil.h> +#include<X11/Xatom.h> + +#include <Xm/Xm.h> +#include <Xm/Form.h> +#include <Xm/PushB.h> +#include <Xm/Text.h> +#include <Xm/TextF.h> +#include <Xm/Label.h> +#include <Xm/SeparatoG.h> +#include <Xm/List.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> +#include <Xm/RowColumn.h> +#include <Xm/Frame.h> +#include <Xm/Label.h> + + +#include "xoakufont.h" +#include "selectxlfd.h" +#include "excutil.h" /* dtex add */ + +/* + * There is no public header file for this function (only an + * internal header XmStringI.h). + */ +extern XtPointer _XmStringUngenerate (XmString string, + XmStringTag tag, + XmTextType tag_type, + XmTextType output_type); + +/*extern Resource resource ; dtex del*/ +/* dtex add */ +extern Exc_data *ed; +extern ListData *ld; +FalGlyphRegion *gr; +int num_gr; +FalFontID fid; +extern char *maintitle; +extern char **errmsg_org; + +/* + * parameters + */ + +FalFontData fullFontData; + +void PopupSelectXLFD() ; +static Widget CreateSelectXLFD() ; + +/*extern void xlfdPopupDialog() ; dtex del*/ +extern int GetListsOfItems() ; + +/* extern void ReadCB(); dtex del */ + +Widget xlfdDialog; +static Widget xlfdWform; + +#define CS0 "Codeset 0" +#define CS1 "Codeset 1" +#define CS2 "Codeset 2" +#define CS3 "Codeset 3" + +#define ERROR_1 errmsg_org[fal_utyerrno & 0xff] +/*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/ +/*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/ + +static Widget pull1, pull2, pull3, pull4, scrolllist; +static int xlf_count = 0; +static XmString *xlf=NULL; +static int udc_count = 0; +static Boolean udc_flag = False; +static int *udc=NULL; +static int udc_val; +static int sty_count = 0; +static Boolean sty_flag = False; +static char **sty=NULL; +static char *sty_val=NULL; +static int wls_count = 0; +static Boolean wls_flag = False; +static int *wls=NULL; +static int wls_val; +static int hls_count = 0; +static Boolean hls_flag = False; +static int *hls=NULL; +static int hls_val; +static Widget *button1=NULL; +static Widget *button2=NULL; +static Widget *button3=NULL; +static Widget *button4=NULL; + +/* + * util dtex + */ + +void +xlfdPopupDialog(Widget w) +{ + if (! XtIsManaged(w)) + XtManageChild(w); + else + XRaiseWindow(XtDisplayOfObject(w), XtWindow(XtParent(w))); +} + +void +ForcePopdownDialog(Widget w) +{ + if (XtIsManaged(w)){ + XtUnmanageChild(w); + } +} + +int fontcheck(char *mode) +/* + * If fontfile can't be opend, return -1. + * If fontfile is editted by other UDC client, return 1. + * normary return 0. + */ +{ + int mask; + FalFontDataList *fulllist = NULL; + FalFontID fontid; + + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX | + FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET; + + if (strcmp(mode, "w") == 0) + mask |= FAL_FONT_MASK_UPDATE; + + fontid = FalOpenSysFont(&fullFontData, mask, &fulllist); + if (fontid == 0) { + if ((fal_utyerrno & 0xff) == 0x10)/*_FAL_ERR_LCKD*/ + return (1); + return (-1); + } + + FalCloseFont( fontid ); + return (0); +} + +void setallcode(ListData *ld) +{ + int i, code, codenum; + int *codep; + int code1, code2; + + codenum = 0; + for (i = 0; i < num_gr; i++) { + codenum += (abs(gr[i].end - gr[i].start) + 1); + } + + ld->allcode = (int *) calloc(codenum, sizeof(int)); + ld->allcode_num = codenum; + codep = ld->allcode; + for (i = 0; i < num_gr; i++) { + code1 = smaller(gr[i].start, gr[i].end); + code2 = bigger(gr[i].start, gr[i].end); + for (code = code1; code <= code2; code++) { + *codep = code; + codep++; + } + } +} + +FalFontID openfont() +{ + int mask; + FalFontDataList *fulllist = NULL; + FalFontID fontid; + char *fullpath=NULL; + + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX | + FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET; + fontid = FalOpenSysFont(&fullFontData, mask, &fulllist); + if (fontid == 0) { + return ( 0 ); + } + if (fullpath != NULL) + FalFree(fullpath); + if (FalFontIDToFileName(fontid, &fullpath) < 0){ + FalCloseFont(fontid); + fontid = NULL; + } + if ((ed->fontfile = strdup(fullpath)) == NULL) { + exit (-1); + } + return (fontid); +} + +void makelist(ListData *ld) +{ + char *pattern; + int code; + int *existcodep, *allcodep; + int existcode_num; + int i; + + ld->existcode = (int *) calloc(ld->allcode_num, sizeof(int)); + existcodep = ld->existcode ; + allcodep = ld->allcode; + existcode_num = 0; + for (i = 0; i < ld->allcode_num; i++) { + code = *allcodep; + pattern = FalReadFont(fid, code, 0, 0); + if (fal_utyexists == 0) { + *existcodep = *allcodep; + existcodep++; + existcode_num++; + } + allcodep++; + } + ld->existcode_num = existcode_num; +} + +void setexistcode(ListData *ld) +{ + fid = openfont(); + + makelist(ld); + +/* close font */ + if (fid != NULL) + FalCloseFont(fid); +} + + +char i2c(int num) +{ + char c; + + if ((0 <= num) && (num <= 9)) + c = '0' + num; + else if ((10 <= num) && (num <= 15)) + c = 'a' + (num - 10); + else + fprintf(stderr,"error in i2c\n"); + return c; +} + +char *i2s(int code) +{ + char buf[8]; + char *number; + char *cp; + int i; + int tmp; + int len; + + tmp = code; + for (i = 0; ; i++) { + if (tmp < 16) { + buf[i] = i2c(tmp); + buf[i+1] = 0; + break; + } + buf[i] = i2c(tmp % 16); + tmp = tmp / 16; + } + len = strlen(buf); + number = (char *) calloc(len+3, sizeof(char)); + cp = number; + memcpy(cp, "0x", 2); + cp += 2; + for (i = len - 1; i >= 0; i--) { + *cp = buf[i]; + cp++; + } + *cp = 0; + return (number); +} + +void setexistcode_c(ListData *ld) +{ + int i; + char **code_cp; + int *codep; + + if (ld->existcode_num == 0) { + return; + } + + ld->existcode_c = (char **) calloc(ld->existcode_num, sizeof(char *)); + code_cp = ld->existcode_c; + codep = ld->existcode; + for (i = 0; i < ld->existcode_num; i++) { + *code_cp = i2s(*codep); + code_cp++; + codep++; + } +} + +void getexistcode(ListData *ld) +{ + setallcode(ld); + setexistcode(ld); + setexistcode_c(ld); +} + +/**************************************************************** + * callbacks * + ***************************************************************/ + +void quit(w, client_data, call_data) /* dtex */ +Widget w; +caddr_t *client_data, *call_data; +{ + excterminate(ed); +} + +static char * +char_set(char *str) /* dtex */ +{ + int i, count; + char *p; + for (i=strlen(str),p=&(str[i]),count=0; i && count < 2; i--,p--) { + if (*p == '-') + count ++; + } + if (count == 2) + return(p + 2); + else + return(str); +} + +static char * +spc(char *str, char ch, int count) +{ + char *p; + p = str + strlen(str); + for(;count && (str < p);p--) { + if (*p == ch) + count --; + } + if (! count) + return(p+1); + else + return(NULL); +} + +static void OpenWindowCB() /* dtex change */ +{ + char *str, *p; + XmStringTable st; + /*dtex add */ + int r; + int ans; + char *msg; + char *msg2; + char *msg3; + char err[128]; + extern void selcharcd(); + char *locale; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED + | FAL_FONT_MASK_XLFDNAME; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + + msg = GETMESSAGE(4, 2, "This font has no user defined characters."); + msg2 = GETMESSAGE(4, 4, "Failed to open the selected font. You have no right to access for the font file, or the format of the file is not consistent."); + msg3 = GETMESSAGE(4, 6, "The font file is used by other UDC client."); + + XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL); + if( st == NULL ){ + return ; + } + str = (char *) _XmStringUngenerate((XmString) st[0], + NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if ( str == NULL ) { + return; + } + + p = spc(str, '-', 4); + p++; + + if (*p == 'p' || *p == 'P') { + str = NULL; + } + + fullFontData.xlfdname = str; + if ((ed->xlfdname = strdup(str)) == NULL) { + exit (-1); + } + if(udc_flag == True) + fullFontData.cd_set = udc_val; + else { /* dtex change */ + memset(&key, 0x00, sizeof(FalFontData)); + key.xlfdname = fullFontData.xlfdname; + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) + return; + if (fontlist->num != 1) + return; + f = fontlist->list; + /*fullFontData.cd_set = -1;*/ + fullFontData.cd_set = f->cd_set; + FalFreeFontList(fontlist); + } + + if (ld != NULL) { + freeld(ld); + } + + if ((ld = (ListData *) malloc(sizeof(ListData))) == NULL) { + excerror(ed, EXCERRMALLOC, "selcharcd", "exit"); + } + memset(ld, 0x00, sizeof(ListData)); + ld->ed = ed; + locale = getenv("LANG"); + if (locale == NULL) + locale = "C"; + if (FalGetUDCGIArea(locale, fullFontData.cd_set, + char_set(fullFontData.xlfdname), &gr, &num_gr) + == FAL_ERROR) { + fprintf(stderr, "error in FalGetUDCGIArea\n"); + sprintf(err, "%s", ERROR_1); + AskUser(ed->toplevel, ed, err, &ans, "error"); + return; + } + if (ed->function == EXPORT) { + r = fontcheck("r"); + if (r == -1) { /* file open error */ + AskUser(ld->ed->toplevel, ld->ed, msg2, &ans, "error"); + return; + } else if (r == 1) { /* file is being editted by other UDC client */ + AskUser(ld->ed->toplevel, ld->ed, msg3, &ans, "error"); + return; + } + /* get existing UDC code */ + getexistcode(ld); + if (ld->existcode_num == 0) { + AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error"); + return; + } + XtUnmanageChild(xlfdDialog); + selcharcd(ld->ed); + } else if (ed->function == IMPORT) { + r = fontcheck("w"); + if (r == -1) { /* file open error */ + AskUser(ld->ed->toplevel, ld->ed, msg2, &ans, "error"); + return; + } else if (r == 1) { /* file is being editted by other UDC client */ + AskUser(ld->ed->toplevel, ld->ed, msg3, &ans, "error"); + return; + } + /* get existing UDC code */ + getexistcode(ld); + + XtUnmanageChild(xlfdDialog); + getcharcd(ed); + } +} + +/** + ** contents : "Cancel" button callback + ** ------------------------ + ** + ** + **/ + +/*ARGSUSED*/ +static void +OpenCancelCB( Widget widget, caddr_t clientData, caddr_t callData ) +/* dtex change */ +{ +/* extern void ForcePopdownDialog(); + if ( !editPtnW ){ + exit( 0 ); + } dtex del */ + ForcePopdownDialog(xlfdDialog); +} + + +/* +* create selection window view +*/ +void +PopupSelectXLFD( Widget top ) +{ + + if( xlfdDialog == NULL ){ + if( (xlfdDialog = CreateSelectXLFD( top )) == NULL ){ + exit( -1 ) ; + } + } + /* pop up select window */ + xlfdPopupDialog( xlfdDialog ); +} + + +static void +create_xlfd() +{ + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + int i; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + xlf_count = 0; + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + return; + } + if (xlf) { + for (i=0; i < xlf_count; i++) { + XmStringFree(xlf[i]); + } + XtFree((char *)xlf); + } + xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname); + } + FalFreeFontList(fontlist); +} + +static void +udc_call(Widget w) +{ + XmString label; + char *moji; + + XtVaGetValues(w, XmNlabelString, &label, NULL); + + moji = (char *) _XmStringUngenerate((XmString) label, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (moji) { + if(strncmp(moji, "*", 1) == 0) { + udc_flag = False; + } else if(strcmp(moji, CS0) == 0) { + udc_val = FAL_FONT_CS0; + udc_flag = True; + } else if(strcmp(moji, CS1) == 0) { + udc_val = FAL_FONT_CS1; + udc_flag = True; + } else if(strcmp(moji, CS2) == 0) { + udc_val = FAL_FONT_CS2; + udc_flag = True; + } else if(strcmp(moji, CS3) == 0) { + udc_val = FAL_FONT_CS3; + udc_flag = True; + } else { + udc_flag = False; + } + XtFree(moji); + } else { + udc_flag = False; + } + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +sty_call(Widget w) +{ + XmString label; + char *moji; + if (sty_val) { + XtFree(sty_val); + sty_val = NULL; + } + XtVaGetValues(w, XmNlabelString, &label, NULL); + + moji = (char *) _XmStringUngenerate((XmString) label, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (moji) { + if(strncmp(moji, "*", 1) == 0) { + sty_flag = False; + } + else { + sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1)); + strcpy(sty_val, moji); + sty_flag = True; + } + XtFree(moji); + } + + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +wls_call(Widget w) +{ + XmString label; + char *moji; + + XtVaGetValues(w, XmNlabelString, &label, NULL); + + moji = (char *) _XmStringUngenerate((XmString) label, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (moji) { + if(strncmp(moji, "*", 1) == 0) { + wls_flag = False; + } + else { + wls_val = atoi(moji); + wls_flag = True; + } + XtFree(moji); + } + + XmStringFree(label); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +hls_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + + moji = (char *) _XmStringUngenerate((XmString) label, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (moji) { + if(strncmp(moji, "*", 1) == 0) { + hls_flag = False; + } + else { + hls_val = atoi(moji); + hls_flag = True; + } + XtFree(moji); + } + XmStringFree(label); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +button_set1() +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<udc_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(udc[j] == f->cd_set) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button1[j], False); + else + XtSetSensitive(button1[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set2() +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<sty_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(strcmp(sty[j], f->style.name) == 0) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button2[j], False); + else + XtSetSensitive(button2[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set3() +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<wls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(wls[j] == f->size.w) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button3[j], False); + else + XtSetSensitive(button3[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set4() +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<hls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(hls[j] == f->size.h) { + found = True; + break; + } + } + if (found == False) + XtSetSensitive(button4[j], False); + else + XtSetSensitive(button4[j], True); + } + FalFreeFontList(fontlist); +} + +void +data_sort(int *data, int count) +{ + int *p1, *p2, tmp, i; + + for (; count; count--) { + for (i=1, p1=data, p2=data+1; i < count; i++, p1++, p2++) { + if( *p1 > *p2) { + tmp = *p2; + *p2 = *p1; + *p1 = tmp; + } + } + } +} + + +static void +font_init() /* dtex change */ +{ + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + int i, j; + char tmp[16]; + char err[128]; + Widget button; + int ans; /* dtex add */ +/* extern void Error_message(); dtex del */ + char *p; + + p = GETMESSAGE(4, 8, "There is no font"); + xlf_count = udc_count = sty_count = wls_count = hls_count = 0; + if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) { + sprintf(err, "%s", ERROR_1); +/* Error_message((Widget)NULL, err); dtex del */ + AskUser(ed->toplevel, ed, err, &ans, "error"); + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); +/* strcpy(err, resource.mn_no_font); dtex change */ + strcpy(err, p); +/* Error_message((Widget)NULL, err); dtex del */ + AskUser(ed->toplevel, ed, err, &ans, "error"); + return; + } + udc = (int *)XtMalloc(sizeof(int) * fontlist->num); + sty = (char **)XtMalloc(sizeof(char *) * fontlist->num); + wls = (int *)XtMalloc(sizeof(int) * fontlist->num); + hls = (int *)XtMalloc(sizeof(int) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + for (j=0,found=False; j<udc_count; j++) { + if(udc[j] == f->cd_set) { + found=True; + break; + } + } + if (found == False) { + udc[udc_count++] = f->cd_set; + } + for (j=0,found=False; j<sty_count; j++) { + if(strcmp(sty[j], f->style.name) == 0) { + found=True; + break; + } + } + if (found == False) { + sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1)); + strcpy(sty[sty_count++], f->style.name); + } + if (f->size.w != -1) { + for (j=0,found=False; j<wls_count; j++) { + if(wls[j] == f->size.w) { + found=True; + break; + } + } + if (found == False) { + wls[wls_count++] = f->size.w; + } + } + for (j=0,found=False; j<hls_count; j++) { + if(hls[j] == f->size.h) { + found=True; + break; + } + } + if (found == False) { + hls[hls_count++] = f->size.h; + } + } + FalFreeFontList(fontlist); + + data_sort(udc, udc_count); + data_sort(wls, wls_count); + data_sort(hls, hls_count); + + if (udc_count > 0) { + button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count); + } + if (sty_count > 0) { + button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count); + } + if (wls_count > 0) { + button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count); + } + if (hls_count > 0) { + button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count); + } + + button = XmCreatePushButton(pull1, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + for (i=0; i < udc_count; i++) { + if(udc[i] == FAL_FONT_CS0) + sprintf(tmp, CS0); + else if(udc[i] == FAL_FONT_CS1) + sprintf(tmp, CS1); + else if(udc[i] == FAL_FONT_CS2) + sprintf(tmp, CS2); + else if(udc[i] == FAL_FONT_CS3) + sprintf(tmp, CS3); + else + sprintf(tmp, "Codeset %x?", udc[i]); + button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0); + XtManageChild(button1[i]); + XtAddCallback(button1[i], XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + } + + button = XmCreatePushButton(pull2, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + for (i=0; i < sty_count; i++) { + button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0); + XtManageChild(button2[i]); + XtAddCallback(button2[i], XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + } + + button = XmCreatePushButton(pull3, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + for (i=0; i < wls_count; i++) { + sprintf(tmp, "%d", wls[i]); + button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0); + XtManageChild(button3[i]); + XtAddCallback(button3[i], XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + } + + button = XmCreatePushButton(pull4, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + for (i=0; i < hls_count; i++) { + sprintf(tmp, "%d", hls[i]); + button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0); + XtManageChild(button4[i]); + XtAddCallback(button4[i], XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + } +} + + +static Widget +CreateSelectXLFD( Widget top ) /* dtex change */ +{ + + int n; + Arg args[16]; + XmString xms, xms1 ; + Widget editW ; + Widget frame, row1, label1, row2, cas1, cas2, cas3, cas4; + XmString str; + char *p; + udc_flag = sty_flag = wls_flag = hls_flag = False; + + /* + * create base window + */ + n = 0 ; + XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ; + XtSetArg( args[n], XmNtitle, maintitle ) ;n++ ; /* dtex add */ + XtSetArg( args[n], XmNnoResize, True ) ; n++ ; + XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ; +/* xms = XmStringCreateLocalized( resource.exec_label ) ; dtex change*/ + p = GETMESSAGE(4, 10, "Open"); + xms = XmStringCreateLocalized( p ) ; + XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ; +/* xms1 = XmStringCreateLocalized( resource.quit_label) ; dtex change*/ + p = GETMESSAGE(4, 12, "Cancel"); + xms1 = XmStringCreateLocalized( p ) ; + XtSetArg( args[n], XmNhelpLabelString, xms1 ) ; n++ ; +/* editW = XmCreateTemplateDialog( top, "dtfonteditor - Open", args, n ); dtex change*/ + p = GETMESSAGE(4, 14, "UDC data exchange utility"); + editW = XmCreateTemplateDialog( top, p, args, n ); + + XmStringFree( xms ) ; + XmStringFree( xms1 ) ; + + n = 0; + pull1 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull2 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull3 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull4 = XmCreatePulldownMenu(toplevel, "pull", args, n); + + n = 0 ; + xlfdWform = XmCreateRowColumn( editW, "BaseForm", args, n ); + XtManageChild( xlfdWform ); + + n = 0; + frame = XmCreateFrame( xlfdWform, "frame", args, n); + XtManageChild( frame ); + + n = 0 ; + row1 = XmCreateRowColumn( frame, "row", args, n ); + XtManageChild( row1 ); + + p = GETMESSAGE(4, 16, "SelectItems"); + n = 0; + label1 = XmCreateLabel( row1, p, args, n); + XtManageChild( label1 ); + + n = 0 ; + row2 = XmCreateRowColumn( row1, "row", args, n ); + XtManageChild( row2 ); + + n = 0 ; + /*str = XmStringCreateLocalized(resource.l_codeset) ; dtex change */ + p = GETMESSAGE(4, 18, "- Codeset:"); + str = XmStringCreateLocalized( p ); + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull1); n++; + cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n ); + XtManageChild( cas1 ); + XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback, + (XtCallbackProc)button_set1, NULL); + XmStringFree(str); + + n = 0 ; + /*str = XmStringCreateLocalized(resource.l_style) ; dtex change */ + p = GETMESSAGE(4, 20, "- Style:"); + str = XmStringCreateLocalized( p ); + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull2); n++; + cas2 = XmCreateOptionMenu( row2, "Style", args, n ); + XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback, + (XtCallbackProc)button_set2, NULL); + XtManageChild( cas2 ); + XmStringFree(str); + + n = 0 ; + /*str = XmStringCreateLocalized(resource.l_width) ; dtex change */ + p = GETMESSAGE(4, 22, "- Width:"); + str = XmStringCreateLocalized( p ); + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull3); n++; + cas3 = XmCreateOptionMenu( row2, "Width", args, n ); + XtManageChild( cas3 ); + XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback, + (XtCallbackProc)button_set3, NULL); + XmStringFree(str); + + n = 0 ; + /*str = XmStringCreateLocalized(resource.l_height) ; dtex change */ + p = GETMESSAGE(4, 24, "- Height:"); + str = XmStringCreateLocalized( p ); + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull4); n++; + cas4 = XmCreateOptionMenu( row2, "Height", args, n ); + XtManageChild( cas4 ); + XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback, + (XtCallbackProc)button_set4, NULL); + XmStringFree(str); + + font_init(); + create_xlfd(); + + n = 0; + XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ; + XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ; + XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ; + XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ; + XtSetArg(args[n], XmNitems, xlf) ; n++ ; + XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ; + scrolllist = XmCreateScrolledList(xlfdWform, "scrolllist", args, n); + XtManageChild(scrolllist); + + /* + * Error_Messege + */ + + XtAddCallback(editW, XmNokCallback, (XtCallbackProc)OpenWindowCB, NULL); +/* XtAddCallback(editW, XmNokCallback, (XtCallbackProc)ReadCB, NULL); dtex del */ + XtAddCallback(editW, XmNcancelCallback, (XtCallbackProc)quit, NULL); +/* XtAddCallback(editW, XmNhelpCallback, + (XtCallbackProc)OpenCancelCB, NULL); dtex del */ + XtAddCallback(editW, XmNhelpCallback, + (XtCallbackProc)quit, NULL); + + return( editW ) ; +} diff --git a/cde/programs/dtudcexch/selectxlfd.c b/cde/programs/dtudcexch/selectxlfd.c new file mode 100644 index 000000000..cfdfa9fd1 --- /dev/null +++ b/cde/programs/dtudcexch/selectxlfd.c @@ -0,0 +1,1009 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: selectxlfd.c /main/3 1996/10/14 14:45:17 barstow $ */ +/* + * All Rights Reserved, Copyright (c) FUJITSU LIMITED 1995 + */ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <nl_types.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include<X11/Xlib.h> +#include<X11/Xutil.h> +#include<X11/Xatom.h> + +#include <Xm/Xm.h> +#include <Xm/Form.h> +#include <Xm/PushB.h> +#include <Xm/Text.h> +#include <Xm/TextF.h> +#include <Xm/Label.h> +#include <Xm/SeparatoG.h> +#include <Xm/List.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> + +#include "FaLib.h" +#include "falxlfd.h" +#include "selectxlfd.h" +#include "excutil.h" + +char *shell_n[] = { "pop0", "pop1", "pop2", "pop3" } ; +char *list_n[] = { "list0", "list1", "list2", "list3" } ; + +#ifdef DEBUG +#undef Dprintf +#define Dprintf fprintf +#else +#define Dprintf +#endif /* DEBUG */ + +/* + * There is no public header file for this function (only an + * internal header XmStringI.h). + */ +extern XtPointer _XmStringUngenerate (XmString string, + XmStringTag tag, + XmTextType tag_type, + XmTextType output_type); + +extern Rsrc resource; +extern Exc_data *ed; +extern ListData *ld; +extern fal_utyerror; +extern fal_utyderror; +extern fal_utyexists; +extern char *maintitle; + +FalFontID fid; + + +/* + * parameters + */ + +char *fullPathName = NULL ; + +FalFontDataList *font_L ; +FalxCodeList *CodeList ; +FalxStyleList *StyleList ; +FalxSizeList *SizeList ; +FalxUdcArea *UdcArea ; +int SelectedOffset ; +int UdcAreaCount ; +int getmask ; + +FalxFontDataBuff KeyBuff ; + + +void PopupSelectXLFD() ; + +Widget xlfdDialog, xlfdWform, + slctBLabel[BUTTONITEMS],slctBText[BUTTONITEMS], slctButton[BUTTONITEMS], + listPop[BUTTONITEMS], listW[BUTTONITEMS], + separatorW, errorMD, msgBox ; +extern Widget cpyDialog ; + +extern Widget toplevel; + + +/* + * tmp + */ + +int fontcheck(char *fontfile, char *mode) +/* + * If fontfile can't be opend, return -1. + * If fontfile is editted by other UDC client, return 1. + * normary return 0. + */ +{ + int chk_fd; + + if (strcmp(mode, "r") == 0) { + if ((chk_fd = open(fontfile, O_RDONLY)) < 0) { + return (-1); + } + } else if (strcmp(mode, "w") == 0) { + if ((chk_fd = open(fontfile, O_RDWR)) < 0) { + return (-1); + } + } + if (isLock(chk_fd) == 1) { + close(chk_fd); + return(1); + } + close(chk_fd); + return (0); +} + +void setallcode(ListData *ld) +{ + int i, code, codenum; + int *codep; + int code1, code2; + + codenum = 0; + for (i = 0; i < UdcAreaCount; i++) { + codenum += (abs(UdcArea[i].udc_end - UdcArea[i].udc_start) + 1); + } + + ld->allcode = (int *) calloc(codenum, sizeof(int)); + ld->allcode_num = codenum; + codep = ld->allcode; + for (i = 0; i < UdcAreaCount; i++) { + code1 = smaller(UdcArea[i].udc_start, UdcArea[i].udc_end); + code2 = bigger(UdcArea[i].udc_start, UdcArea[i].udc_end); + for (code = code1; code <= code2; code++) { + *codep = code; + codep++; + } + } +} + +FalFontID openfont(void) +{ + int protect_key = FAL_FONT_DISPLAY; + int codeset; + FalFontID fontid; + + fontid = NULL; + codeset = font_L->list[0].cd_set; + if ((fontid = FalOpenFont(fullPathName, protect_key, codeset)) + == FAL_ERROR) { + fprintf(stderr, "FalOpenFont error\n"); + return ((FalFontID) NULL); + } + return (fontid); +} + +void makelist(ListData *ld) +{ + char *pattern; + int code; + int *existcodep, *allcodep; + int existcode_num; + int i; +/* FalFontinfo fontinfo;*/ + +/* FalQueryFont(fid, &fontinfo);*/ + + ld->existcode = (int *) calloc(ld->allcode_num, sizeof(int)); + existcodep = ld->existcode ; + allcodep = ld->allcode; + existcode_num = 0; + for (i = 0; i < ld->allcode_num; i++) { + code = *allcodep; + pattern = FalReadFont(fid, code, NULL, NULL); + if (fal_utyexists == 0) { + *existcodep = *allcodep; + existcodep++; + existcode_num++; + } + allcodep++; + } + ld->existcode_num = existcode_num; +} + +void setexistcode(ListData *ld) +{ + int *codep, *allcodep; + int i; + +/* open font */ + fid = openfont(); + + makelist(ld); + +/* close font */ + if (fid != NULL) + FalCloseFont(fid); +} + + +char i2c(int num) +{ + char c; + + if ((0 <= num) && (num <= 9)) + c = '0' + num; + else if ((10 <= num) && (num <= 15)) + c = 'a' + (num - 10); + else + fprintf(stderr,"error in i2c\n"); + return c; +} + +char *i2s(int code) +{ + char buf[8]; + char *number; + char *cp; + int i; + int tmp; + int len; + + tmp = code; + for (i = 0; ; i++) { + if (tmp < 16) { + buf[i] = i2c(tmp); + buf[i+1] = NULL; + break; + } + buf[i] = i2c(tmp % 16); + tmp = tmp / 16; + } + len = strlen(buf); + number = (char *) calloc(len+3, sizeof(char)); + cp = number; + memcpy(cp, "0x", 2); + cp += 2; + for (i = len - 1; i >= 0; i--) { + *cp = buf[i]; + cp++; + } + *cp = NULL; + return (number); +} + +void setexistcode_c(ListData *ld) +{ + int i; + char **code_cp; + int *codep; + + if (ld->existcode_num == 0) { + return; + } + + ld->existcode_c = (char **) calloc(ld->existcode_num, sizeof(char *)); + code_cp = ld->existcode_c; + codep = ld->existcode; + for (i = 0; i < ld->existcode_num; i++) { + *code_cp = i2s(*codep); + code_cp++; + codep++; + } +} + +void getexistcode(ListData *ld) +{ + setallcode(ld); + setexistcode(ld); + setexistcode_c(ld); +} + + + +/**************************************************************** + * common functions * + ***************************************************************/ + +/* + * pop up and down dialog box + */ + +void +xlfdPopupDialog(Widget w) +{ + if (! XtIsManaged(w)) + XtManageChild(w); + else + XRaiseWindow(XtDisplayOfObject(w), XtWindow(XtParent(w))); +} + +void +xlfdPopdownDialog(Widget w) +{ + if (XtIsManaged(w)){ + XtUnmanageChild(w); + } +} + + +/* +* get pixel width +*/ +Dimension +GetPixelWidth(Widget w, int columns, Dimension *width) +{ + Arg args[1] ; + XtSetArg( args[0], XmNwidth, width ) ; + XtGetValues( w , args, 1 ) ; + return( *width / (Dimension)columns ) ; +} + + +/**************************************************************** + * callbacks * + ***************************************************************/ + +void quit(Widget w, caddr_t *client_data, caddr_t *call_data) +{ + char *msg; + int ans; + + msg = GETMESSAGE(6, 2, "Do you want to terminate udcexchange?"); + + AskUser(ed->toplevel, ed, msg, &ans, "question"); + if (ans == 1) {/* terminate ok */ + FalxFreeCodeList( CodeList ) ; + FalxFreeStyleList( StyleList ) ; + FalxFreeSizeList( SizeList ) ; + FalxFreeFontList( font_L ) ; + excterminate(ed); + } +} + + +/* + * Unmanage widgets + */ +int +ClearText(int num, Widget *slctBText) +{ + int i ; + /* toggle button unset */ + for( i=0; i<BUTTONITEMS; i++ ){ + if( i>num ){ + XmTextSetString( slctBText[i], "" ); + } + } + return ; +} + +int +ClearButtons(int num, Widget *slctButton) +{ + int i, cnt ; + Boolean isSet ; + Arg args[5] ; + /* toggle button unset */ + for( i=0; i<BUTTONITEMS; i++ ){ + if( i != num ){ + cnt = 0; + XtSetArg( args[cnt], XmNset, &isSet ); cnt++; + XtGetValues( slctButton[i], args, cnt ); + if( isSet == True ){ + cnt = 0; + XtSetArg( args[cnt], XmNset, False ); cnt++; + XtSetValues( slctButton[i], args, cnt ); + } + } + } + return ; +} + + + +/* + * get text field position + */ +int +GetPositionOfLists( +int num, +Widget xlfdDialog, +Widget *listPop, +Widget *slctBText, +Position *x, +Position *y) +{ + int i ; + Position tbx, tby, tx, ty ; + Dimension theight ; + Arg args[10] ; + + i = 0; + XtSetArg(args[i], XmNx, &tbx ); i++; + XtSetArg(args[i], XmNy, &tby ); i++; + XtGetValues( xlfdDialog, args, i); + i = 0; + XtSetArg(args[i], XmNx, &tx ); i++; + XtSetArg(args[i], XmNy, &ty ); i++; + XtSetArg(args[i], XmNheight, &theight ); i++; + if( num==BUTTONITEMS-1 ) + XtGetValues( slctBText[num], args, i ) ; + else + XtGetValues( XtParent(slctBText[num]), args, i ) ; /* ScrolledText */ + /* determine the position of list */ + *x = tx + tbx + CX ; + if( num==BUTTONITEMS-1 ){ + *y = ty + tby + (Position)theight + 14 + CY ; + }else{ + *y = ty + tby + (Position)theight + CY ; + } + + for( i=0; i<BUTTONITEMS; i++ ){ + if( XtIsManaged( listPop[i] ) ) XtUnmanageChild( listPop[i] ); + } + if( !XtIsManaged( listPop[num] ) ) XtManageChild( listPop[num] ); + + return ; +} + + + + +void listEH(Widget w, int num, XButtonEvent *event) +{ + int i, j, ITEM_COUNT; + Arg args[10]; + XmString *xms ; + char *str ; + + int rtn ; + Position x, y ; + + /* + * get list items + */ + ITEM_COUNT = 0; + rtn = GetItemsToDisplay( num, &ITEM_COUNT, &xms ) ; + switch( rtn ){ + case FALX_TRY_NEXT : + fprintf( stderr, "There are no fonts that was required.\n" ) ; + XmTextSetString( slctBText[0], " " ); + ClearText( -1, slctBText ) ; + FalxFreeDataBuff( FALX_ALL, &KeyBuff ) ; + getmask = 0 ; + return ; + case 0 : + break ; + default : + fprintf( stderr, "GetItemsToDisplay() error.\n" ) ; + exit(-1) ; + } + + if( num == 0 && ITEM_COUNT == 1 ){ + + str = (char *) _XmStringUngenerate((XmString) xms[0], NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (str) + XmTextSetString(slctBText[num], str ); + return ; + } + if( ITEM_COUNT < 0 ){ + exit(-1) ; + } + + + /* + * get text field position + */ + GetPositionOfLists( num, xlfdDialog, listPop, slctBText, &x, &y ) ; + + i = 0; + XtSetArg(args[i], XmNx, x ) ; i++; + XtSetArg(args[i], XmNy, y ) ; i++; + XtSetValues(listPop[num], args, i ); + + /* + * set list items + */ + i = 0; + XtSetArg (args[i], XmNitems, xms ); i++; + XtSetArg (args[i], XmNitemCount, ITEM_COUNT ); i++; + XtSetValues(listW[num], args, i ); + + /* + * pop up list + */ + XtPopup( listPop[num], XtGrabNone ); + +} + + + + +void listPrintCB(Widget w, int num, XmListCallbackStruct *call_data) +{ + char *str ; + + /* clear text fields and unset buttons */ + ClearButtons( num, slctButton ) ; + + + str = (char *) _XmStringUngenerate((XmString) call_data->item, NULL, + XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if (str) { + XmTextSetString(slctBText[num], str); + } + +#if 0 + /* set key data */ + if( SetKeyBuff( num, str ) ){ + exit(-1) ; + } +#endif /* 0 */ + + if( XtIsManaged( listPop[num] ) ) XtUnmanageChild( listPop[num] ); + +} + + + + + +void OpenWindow(Widget w, caddr_t client_data, caddr_t *call_data) +{ + int r ; + int i ; + int ans; + char *msg; + char *msg1; + char *msg2; + char *msg3; + char *str, buff[512] ; + + msg = GETMESSAGE(6, 4, "No UDCs exist in this font"); + msg1 = GETMESSAGE(6, 6, "XLFD name isn't selected"); + msg2 = GETMESSAGE(6, 8, "Can't open the font file"); + msg3 = GETMESSAGE(6, 10, "The font file is used by other UDC client."); + + /* get font file name (str: XLFD name) */ + str = XmTextGetString( slctBText[0] ); + if (( str == NULL ) || (strcmp(str, "") == 0)) { + AskUser(w, ed, msg1, &ans, "error"); + return; + } + if( fullPathName != NULL ){ + free( fullPathName ) ; + } + SelectedOffset = FalxSearchFontFileName( str, font_L, buff ) ; + if( SelectedOffset < 0 ){ + exit(-1) ; + } + if( (fullPathName = strdup( buff )) == NULL ){ + exit(-1) ; + } + UdcAreaCount = FalxGetGlyphIndexInfo( str, font_L, &UdcArea ) ; + if( UdcAreaCount < 0 ){ + exit(-1) ; + } + + if( fullPathName != NULL ){ + Dprintf( stderr, "OpenWindow() : full path name = %s\n", fullPathName ); + } + for( i=0; i<UdcAreaCount; i++ ){ + Dprintf( stderr, "OpenWindow() : start(%d) = 0x%x\n", i, UdcArea[i].udc_start ); + Dprintf( stderr, "OpenWindow() : end (%d) = 0x%x\n", i, UdcArea[i].udc_end ); + } + if ((ed->xlfdname = strdup(str)) == NULL) { + exit (-1); + } + if ((ed->fontfile = strdup(fullPathName)) == NULL) { + exit (-1); + } +/* getxlfd(ed);*/ +/* initialize ld */ + if ((ld = (ListData *) malloc(sizeof(ListData))) == NULL) { + excerror(ed, EXCERRMALLOC, "selcharcd", "exit"); + } + memset(ld, 0x00, sizeof(ListData)); + ld->ed = ed; + + if (ed->function == EXPORT) { + r = fontcheck(ed->fontfile, "r"); + if (r == -1) { /* file open error */ + AskUser(ld->ed->toplevel, ld->ed, msg2, &ans, "error"); + return; + } else if (r == 1) { /* file is being editted by other UDC client */ + AskUser(ld->ed->toplevel, ld->ed, msg3, &ans, "error"); + return; + } + /* get existing UDC code */ + getexistcode(ld); + if (ld->existcode_num == 0) { + AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error"); + return; + } + XtUnmanageChild(xlfdDialog); + selcharcd(ed); + } else if (ed->function == IMPORT) { + r = fontcheck(ed->fontfile, "w"); + if (r == -1) { /* file open error */ + AskUser(ld->ed->toplevel, ld->ed, msg2, &ans, "error"); + return; + } else if (r == 1) { /* file is being editted by other UDC client */ + AskUser(ld->ed->toplevel, ld->ed, msg3, &ans, "error"); + return; + } + /* get existing UDC code */ + getexistcode(ld); + + XtUnmanageChild(xlfdDialog); + getcharcd(ed); + } +} + + + +/**************************************************************** + * functions for create window view +****************************************************************/ + +#define SetLabel( cnt ){ \ + switch( cnt ){ \ + case 0 : buf = resource.xlfd_label ; break ; \ + case 1 : buf = resource.code_label ; break ; \ + case 2 : buf = resource.style_label; break ; \ + case 3 : buf = resource.size_label ; break ; \ + } \ + xms = XmStringCreateLocalized( buf ); \ +} + + +int +CreateXLFDLabelAndText( +Widget owner, +Widget *slctBLabel, +Widget *slctBText, +Widget *slctButton) +{ + + Widget _slctBLabel ; + Widget _slctBText ; + Widget _slctButton ; + int i, j; + Arg args[16]; + char *buf ; + XmString xms ; + + /* + * create XLFD titles + */ + i = 0; + XtSetArg( args[i], XmNx, 20 ) ; i++ ; + XtSetArg( args[i], XmNheight, 20 ) ; i++ ; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_FORM ) ; i++ ; + XtSetArg( args[i], XmNtopOffset, 20 ) ; i++ ; +/* + _slctBLabel = XmCreateLabelGadget( owner , "xlfdlabel", args, i ); +*/ + _slctBLabel = XmCreateLabel( owner , "xlfdlabel", args, i ); + + XtManageChild( _slctBLabel ); + + /* + * create text fields to display XLFD font name + */ + i = 0; + XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM ) ; i++ ; + XtSetArg( args[i], XmNleftOffset, 20 ) ; i++ ; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_WIDGET ); i++ ; + XtSetArg( args[i], XmNtopOffset, 5 ) ; i++ ; + XtSetArg (args[i], XmNtopWidget, _slctBLabel ); i++; + XtSetArg( args[i], XmNcolumns, XLFD_COLUMNS ) ; i++ ; + XtSetArg( args[i], XmNspacing, 0 ) ; i++ ; + XtSetArg( args[i], XmNeditMode, XmSINGLE_LINE_EDIT ) ; i++ ; + XtSetArg( args[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED ) ; i++ ; + XtSetArg( args[i], XmNscrollingPolicy, XmAPPLICATION_DEFINED ) ; i++ ; +/* + XtSetArg( args[i], XmNscrollingPolicy, XmAUTOMATIC ) ; i++ ; + XtSetArg( args[i], XmNlistSizePolicy, XmCONSTANT ) ; i++ ; + + XtSetArg( args[i], XmNwidth, 600 ) ; i++ ; + XtSetArg( args[i], XmNfontList, fixed ) ; i++ ; + XtSetArg( args[i], XmNeditable, True ) ; i++ ; + XtSetArg( args[i], XmNlistSizePolicy, XmVARIABLE ) ; i++ ; +*/ + _slctBText = XmCreateScrolledText( owner , "xlfdtext", args, i ); + + XtManageChild( _slctBText ); + + /* + * create XLFD select buttons + */ + i = 0; + XtSetArg( args[i], XmNindicatorType, XmONE_OF_MANY ) ; i++ ; + XtSetArg (args[i], XmNtopWidget, _slctBText ); i++; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNtopOffset, 15 ) ; i++ ; + XtSetArg( args[i], XmNleftAttachment, XmATTACH_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNleftWidget, _slctBText ) ; i++ ; + XtSetArg( args[i], XmNleftOffset, 5 ) ; i++ ; /* WIDTH */ + XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM ) ; i++ ; + XtSetArg( args[i], XmNrightOffset, 5 ) ; i++ ; /* WIDTH */ + xms = XmStringCreateLocalized( "" ); + XtSetArg( args[i], XmNlabelString, xms ) ; i++ ; +/* + _slctButton = XmCreateToggleButtonGadget( owner , "xlfdbtn", args, i); +*/ + _slctButton = XmCreateToggleButton( owner , "xlfdbtn", args, i); + + XtManageChild( _slctButton ); + + *slctBLabel = _slctBLabel ; + *slctBText = _slctBText ; + *slctButton = _slctButton ; + +} + + + + +int +CreateOtherLabelAndText( +int num, +Widget owner, +Widget baseForm, +Widget *slctBLabel, +Widget topW, +Widget *slctBText, +Widget *slctButton) +{ + + Widget _slctBLabel ; + Widget _slctBText ; + Widget _slctButton ; + int i, j; + Arg args[16]; + char *buf ; + XmString xms ; + + + if( num < 1 ) return(0) ; + + /* + * create key titles + */ + i = 0; + XtSetArg ( args[i], XmNtopWidget, + (num==1) ? baseForm : topW ); i++; + XtSetArg( args[i], XmNx, 20 ) ; i++ ; + XtSetArg( args[i], XmNheight, 20 ) ; i++ ; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_WIDGET ) ; i++ ; +/* DEBUG + XtSetArg( args[i], XmNtopOffset, 20 ) ; i++ ; +*/ + XtSetArg( args[i], XmNtopOffset, 36 ) ; i++ ; + SetLabel(num) ; + XtSetArg( args[i], XmNlabelString, xms ) ; i++ ; +/* + _slctBLabel = XmCreateLabelGadget( owner , "label", args, i); +*/ + _slctBLabel = XmCreateLabel( owner , "label", args, i); + + XtManageChild( _slctBLabel ); + + /* + * create text fields to display selected keys + */ + i = 0; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNtopOffset, -5 ) ; i++ ; + XtSetArg (args[i], XmNtopWidget, _slctBLabel ); i++; + XtSetArg( args[i], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNrightOffset, 0 ) ; i++ ; + XtSetArg (args[i], XmNrightWidget, baseForm ); i++; + XtSetArg( args[i], XmNcolumns, KEY_COLUMNS ) ; i++ ; + XtSetArg( args[i], XmNspacing, 0 ) ; i++ ; + XtSetArg( args[i], XmNeditMode, XmSINGLE_LINE_EDIT ) ; i++ ; + XtSetArg( args[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED ) ; i++ ; + XtSetArg( args[i], XmNscrollingPolicy, XmAPPLICATION_DEFINED ) ; i++ ; + /* + XtSetArg( args[i], XmNscrollingPolicy, XmAUTOMATIC ) ; i++ ; + XtSetArg( args[i], XmNlistSizePolicy, XmCONSTANT ) ; i++ ; + + XtSetArg( args[i], XmNfontList, fixed ) ; i++ ; + XtSetArg( args[i], XmNlistSizePolicy, XmVARIABLE ) ; i++ ; + */ + if( num==BUTTONITEMS-1 ) + _slctBText = XmCreateText( owner , "text" , args, i ); + else + _slctBText = XmCreateScrolledText( owner , "text" , args, i ); + + XtManageChild( _slctBText ); + + /* + * create select buttons + */ + i = 0; + XtSetArg( args[i], XmNindicatorType, XmONE_OF_MANY ) ; i++ ; + XtSetArg( args[i], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNtopOffset, 5 ) ; i++ ; + XtSetArg (args[i], XmNtopWidget, _slctBLabel ); i++; + XtSetArg( args[i], XmNleftAttachment, XmATTACH_WIDGET ) ; i++ ; + XtSetArg( args[i], XmNleftWidget, _slctBText ) ; i++ ; + XtSetArg( args[i], XmNleftOffset, 5 ) ; i++ ; /* WIDTH */ + xms = XmStringCreateLocalized( "" ); + XtSetArg( args[i], XmNlabelString, xms ) ; i++ ; +/* + _slctButton = XmCreateToggleButtonGadget( owner , "button", args, i); +*/ + _slctButton = XmCreateToggleButton( owner , "button", args, i); + + XtManageChild( _slctButton ); + + *slctBLabel = _slctBLabel ; + *slctBText = _slctBText ; + *slctButton = _slctButton ; +} + + + +/* +* create pop up lists +*/ + + +Widget +xlfdCreateScrolledList (Widget owner, char *name, Arg *args, int n) +{ + Widget listW ; + + XtSetArg( args[n], XmNselectionPolicy, XmSINGLE_SELECT ) ;n++ ; + XtSetArg( args[n], XmNlistSpacing, 4 ) ; n++ ; + XtSetArg( args[n], XmNlistSizePolicy, XmCONSTANT ) ; n++ ; + XtSetArg( args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED ) ; n++ ; + listW = XmCreateScrolledList( owner, name, args, n ); + + XtManageChild( listW ); + + + return( listW ); +} + + + +/* +* create selection window view +*/ +void +PopupSelectXLFD(Widget top) +{ + + int n, i, j; + Arg args[16]; + char *buf ; + XmString xms ; + Dimension pix, xwidth, kwidth ; + + if( xlfdDialog == NULL ){ + /* + * create base window + */ + n = 0 ; + XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ; + XtSetArg( args[n], XmNtitle, maintitle ) ; n++ ; + XtSetArg( args[n], XmNnoResize, True ) ; n++ ; + xms = XmStringCreateLocalized( resource.exec_label ) ; + XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ; + xms = XmStringCreateLocalized( resource.quit_label) ; + XtSetArg( args[n], XmNhelpLabelString, xms ) ; n++ ; +Dprintf( stdout, "(PopupSelectXLFD)XmCreateTemplateDialog: start\n" ) ; + xlfdDialog = XmCreateTemplateDialog( top, "SelectDialog", args, n ); +Dprintf( stdout, "(PopupSelectXLFD)XmCreateTemplateDialog: end\n" ) ; + + n = 0 ; + xlfdWform = XmCreateForm( xlfdDialog, "BaseForm", args, n ); + XtManageChild( xlfdWform ); + + + /* + * create XLFD columns + */ +Dprintf( stdout, "(PopupSelectXLFD)CreateXLFDLabelAndText : start\n" ) ; + CreateXLFDLabelAndText( xlfdWform , + &slctBLabel[0], &slctBText[0], &slctButton[0] ) ; + n = 0 ; + SetLabel(0) ; + XtSetArg( args[n], XmNlabelString, xms ) ; n++ ; + XtSetValues( slctBLabel[0], args, n ) ; +Dprintf( stdout, "(PopupSelectXLFD)CreateXLFDLabelAndText : end\n" ) ; + + /* + * create other key columns + */ +Dprintf( stdout, "(PopupSelectXLFD)CreateOtherLabelAndText :start\n" ) ; + for( j=1; j<BUTTONITEMS; j++ ){ + CreateOtherLabelAndText( j, xlfdWform, slctBText[0], + &slctBLabel[j], slctBLabel[j-1], &slctBText[j], &slctButton[j] ) ; + } +Dprintf( stdout, "(PopupSelectXLFD)CreateOtherLabelAndText : end\n" ) ; + + /* set bottom offsets */ + n = 0 ; + XtSetArg( args[n], XmNbottomAttachment, XmATTACH_FORM ) ; n++ ; + XtSetArg( args[n], XmNbottomOffset, 36 ) ; n++ ; + XtSetValues( slctBLabel[BUTTONITEMS-1], args, n ) ; + + /* get pixel size */ + pix = GetPixelWidth( slctBText[0], XLFD_COLUMNS, &xwidth ) ; + /* xwidth += pix / 2 ; */ + kwidth = pix * KEY_COLUMNS + pix / 2 ; + + /* + * create popup shells + */ + for( j=0; j<BUTTONITEMS; j++ ) { + n = 0; + listPop[j] = XtCreatePopupShell( shell_n[j], overrideShellWidgetClass, + xlfdWform , args, n ); + } + + /* + * create popup lists + */ + for( j=0; j<BUTTONITEMS; j++ ) { + n = 0 ; + XtSetArg( args[n], XmNvisibleItemCount, (j==0)? 10 : 5 ) ; n++ ; + if( j==0 ){ + XtSetArg( args[n], XmNwidth, xwidth ) ; n++ ; + }else{ + XtSetArg( args[n], XmNwidth, kwidth ) ; n++ ; + XtSetArg( args[n], XmNlistMarginWidth, 0 ) ; n++ ; + } + listW[j] = xlfdCreateScrolledList( listPop[j], list_n[j], args, n ); + } + + /* + * Error_Messege + */ +#if 0 + n = 0 ; + XtSetArg( args[n], XmNokLabelString, "OK" ) ; n++ ; + XtSetArg( args[n], XmNcancelLabelString,"Cancel" ) ; n++ ; + errorMD = XmCreateMessageDialog(toplevel, "ed0", NULL, 0); + + msgBox = XmMessageBoxGetChild(errorMD, XmDIALOG_HELP_BUTTON); + XtUnmanageChild(msgBox); +#endif /* 0 */ + + /* + * add callbacks + */ + for( i=0; i<BUTTONITEMS; i++ ) + XtAddEventHandler( slctButton[i], ButtonReleaseMask, False, (XtEventHandler) listEH, (XtPointer) i ); + + for( i=0; i<BUTTONITEMS; i++ ) + XtAddCallback(listW[i], XmNsingleSelectionCallback, (XtCallbackProc) listPrintCB, (XtPointer) i ); + + XtAddCallback( xlfdDialog, XmNokCallback, (XtCallbackProc) OpenWindow, NULL ); + XtAddCallback( xlfdDialog, XmNhelpCallback,(XtCallbackProc) quit,NULL ); + +#if 0 + XtAddCallback( errorMD, XmNcancelCallback, (XtCallbackProc) quit, NULL); +#endif /* 0 */ + + } + /* + * pop up select window + */ +Dprintf( stdout, "(PopupSelectXLFD)xlfdPopupDialog : start\n" ) ; + xlfdPopupDialog( xlfdDialog ); +Dprintf( stdout, "(PopupSelectXLFD)xlfdPopupDialog : end\n" ) ; +Dprintf( stdout, " : end\n" ) ; + +} + + + +#undef SetLabel diff --git a/cde/programs/dtudcexch/udcexc.c b/cde/programs/dtudcexch/udcexc.c new file mode 100644 index 000000000..6c33620f6 --- /dev/null +++ b/cde/programs/dtudcexch/udcexc.c @@ -0,0 +1,236 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udcexc.c /main/4 1996/09/02 18:50:32 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "excutil.h" +#include "xoakufont.h" +#include "selectxlfd.h" +#include <locale.h> +#include <Xm/RowColumn.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> +#include <Xm/MainW.h> +void callexpCB(); +void callimpCB(); +void exitCB(); +void helpCB(); +void udcexp(); +void udcimp(); + +#define ERROR_1 errmsg_org[fal_utyerrno & 0xff] +/*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/ +/*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/ + +Widget toplevel, mainw; + +Exc_data *ed = NULL; +ListData *ld = NULL; +char *maintitle; +/*char *terminatemsg = "Do you want to terminate dtudcexch";*/ + +/* + * Error messages(by origin) + * fal_errmsg_org + */ +char *errmsg_org[0xff]; + +Rsrc resource ; + +#define Rchar(name, class, member,def){ \ + name, class, XtRString, sizeof(char *), \ + XtOffsetOf(Rsrc, member), XtRString, (XtPointer)def } + +Widget excCreateRadioButton(Widget parent, String name, String label, + XtCallbackProc callback_func, + XtPointer client_data) +{ + Widget widget; + XmString xms; + + widget = XtVaCreateManagedWidget(name, + xmToggleButtonWidgetClass, parent, + XmNindicatorType, XmONE_OF_MANY, + NULL); + XtAddCallback(widget, XmNvalueChangedCallback, + (XtCallbackProc) callback_func, + (XtPointer) client_data); + + xms = XmStringCreateLocalized(label); + XtVaSetValues(widget, + XmNlabelString, xms, + NULL); + + XmStringFree(xms); + + return (widget); +} + +int main(int argc, char * argv[]) +{ + XtAppContext app_context; + Widget row, expfunc, impfunc, exit/*, help*/; + Arg args[20]; + Cardinal n; + static char *explabel; + static char *implabel; + static char *exitlabel; +/* static char helplabel[] = "Help";*/ +/* char msg1[] = "Failed in the start of dtudcexch";*/ + char err[128]; + int ans; + + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + +/* appinitialize */ + XtSetLanguageProc(NULL,NULL,NULL); + _DtEnvControl(0); + n = 0; + toplevel = XtAppInitialize(&app_context, "UDCexchange", + (XrmOptionDescList) NULL, + 0, (int *) &argc, argv, (String *) NULL, + args, n); + + maintitle = GETMESSAGE(8, 2, "UDC data exchange utitlity"); + + errmsg_org[0] = GETMESSAGE(8, 4, "Fatal error occurred."); + errmsg_org[1] = GETMESSAGE(8, 6, "Cannot open the font file."); + errmsg_org[2] = GETMESSAGE(8, 8, "Cannot read the font file."); + errmsg_org[3] = GETMESSAGE(8, 10, "There is no more memory."); + errmsg_org[4] = GETMESSAGE(8, 12, "Fatal error occurred."); + errmsg_org[5] = GETMESSAGE(8, 14, "The specified font file does not exist."); + errmsg_org[6] = GETMESSAGE(8, 16, "This font is not a pcf or snf font."); + errmsg_org[7] = GETMESSAGE(8, 18, "Cannot open fonts.list file."); + errmsg_org[8] = GETMESSAGE(8, 20, "The format of fonts.list file is illegal."); + errmsg_org[9] = GETMESSAGE(8, 22, "The descriptions of the fonts.list file are incorrect."); + errmsg_org[10] = GETMESSAGE(8, 24, "The format of fonts.list file is illegal."); + errmsg_org[11] = GETMESSAGE(8, 26, "Cannot open fonts.dir file."); + errmsg_org[12] = GETMESSAGE(8, 28, "Cannot read fonts.dir file."); + errmsg_org[13] = GETMESSAGE(8, 30, "Cannot read font properties."); + errmsg_org[14] = GETMESSAGE(8, 32, "Cannot get FONT property."); + errmsg_org[15] = GETMESSAGE(8, 34, "Cannot get FAMILY_NAME property."); + errmsg_org[16] = GETMESSAGE(8, 36, "This font file is already opened by other application."); + errmsg_org[17] = GETMESSAGE(8, 38, "Cannot lock font file."); + errmsg_org[18] = GETMESSAGE(8, 40, "Cannot unlock font file."); + errmsg_org[19] = GETMESSAGE(8, 42, "Cannot get lock information from the font file."); + errmsg_org[20] = GETMESSAGE(8, 44, "Cannot find the specified font file."); + errmsg_org[21] = GETMESSAGE(8, 46, "Cannot read NLS database."); + errmsg_org[22] = GETMESSAGE(8, 48, "Cannot get charset names from NLS database."); + errmsg_org[23] = GETMESSAGE(8, 50, "Charset name not defined in NLS database."); + errmsg_org[24] = GETMESSAGE(8, 52, "The specified font has not been opened."); + errmsg_org[25] = GETMESSAGE(8, 54, "Fatal error occurred."); + + resource.xlfd_label = GETMESSAGE(8, 56, "XLFD name :" ), + resource.copy_xlfd_label = GETMESSAGE(8, 58, "Original font (XLFD name) :"); + resource.code_label = GETMESSAGE(8, 60, "UDC code area :"); + resource.style_label = GETMESSAGE(8, 62, "Style :"); + resource.size_label = GETMESSAGE(8, 64, "Size (letter size) :"); + resource.exec_label = GETMESSAGE(8, 66, "Open"); + resource.quit_label = GETMESSAGE(8, 68, "Cancel"); + resource.ok_label = GETMESSAGE(8, 70, "OK"); + resource.cancel_label = GETMESSAGE(8, 72, "cancel"); + resource.copy_orgin = GETMESSAGE(8, 74, "Copy orgin code(hex) :"); + resource.copy_target = GETMESSAGE(8, 76, "Copy target code(hex) :"); + resource.copy_label = GETMESSAGE(8, 78, "Copy"); + resource.overlay_label = GETMESSAGE(8, 80, "Overlay"); + + explabel = GETMESSAGE(8, 82, "export function"); + implabel = GETMESSAGE(8, 84, "import function"); + exitlabel = GETMESSAGE(8, 86, "Cancel"); + +/* initialize ed */ + if ((ed = (Exc_data *) malloc(sizeof(Exc_data))) == NULL) { + excerror(ed, EXCERRMALLOC, "main", "exit"); + } + memset(ed,0x00,sizeof(Exc_data)); + + ed->app = app_context; + ed->toplevel = toplevel; + + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + fprintf( stderr, "GetFontList Err\n" ); + sprintf(err, "%s", ERROR_1); + AskUser(ed->toplevel, ed, err, &ans, "error"); +/* AskUser(ed->toplevel, ed, msg1, &ans, "error");*/ + excexit(ed); + } + FalFreeFontList(fontlist); + + +/* make main window */ + n = 0; + XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ; + XtSetArg(args[n], XmNtitle, maintitle); n++; + mainw = XmCreateTemplateDialog(toplevel, "mainw", args, n); + + row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, mainw, + XmNradioBehavior, True, + XmNradioAlwaysOne, True, + NULL); + expfunc = excCreateRadioButton(row, "expfunc", explabel, + (XtCallbackProc) callexpCB, (XtPointer) ed); + + impfunc = excCreateRadioButton(row, "impfunc", implabel, + (XtCallbackProc) callimpCB, (XtPointer) ed); + + exit = excCreatePushButton(mainw, "exit", exitlabel, + (XtCallbackProc) exitCB, (XtPointer) ed); + +/* help = excCreatePushButton(mainw, "help", helplabel, + (XtCallbackProc) helpCB, (XtPointer) ed); +*/ + XtVaSetValues(mainw, + XmNmessageWindow, exit, + NULL); + + XtManageChild(mainw); + +/* XtRealizeWidget(toplevel);*/ + + XtAppMainLoop(app_context); +} + +void callexpCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ + XtUnmanageChild(mainw); + udcexp(ed); +} +void callimpCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ + XtUnmanageChild(mainw); + udcimp(ed); +} +void exitCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ + excexit(ed); +} +/*void helpCB(Widget widget, Exc_data * ed, XtPointer call_data) +{ +}*/ diff --git a/cde/programs/dtudcexch/udcexp.c b/cde/programs/dtudcexch/udcexp.c new file mode 100644 index 000000000..974447802 --- /dev/null +++ b/cde/programs/dtudcexch/udcexp.c @@ -0,0 +1,214 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udcexp.c /main/5 1996/10/14 14:45:34 barstow $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "excutil.h" +#include <Xm/MessageB.h> +#include <Xm/RowColumn.h> +#include <Xm/List.h> +#include <Xm/Form.h> +#include <Xm/Label.h> + +void setselectedcode(); + +extern char *maintitle; + +void udcexp(Exc_data * ed) +{ + ed->function = EXPORT; + strcpy(ed->bdfmode,"w"); + + PopupSelectXLFD(ed->toplevel); +} + +void createbdf(Exc_data * ed) +{ + int i = 0; + char *comment_list[] = {""}; + int comment_num = 0; + char *msg; + int ans; + + msg = GETMESSAGE(10, 2, "Failed to make the BDF file"); + + i = ExpGpftoBDF(ed->fontfile, ed->bdffile, + ed->code_num, ed->gpf_code_list, + comment_num, comment_list, 0); + if (i != 0) { + AskUser(ed->toplevel, ed, msg, &ans, "error"); + } + excterminate(ed); +} + +void selcharokCB(Widget widget, ListData * ld, XtPointer call_data) +{ + int num; + Exc_data *ed; + int ans; + char *msg; + + msg = GETMESSAGE(10, 4, "No indexes are selected"); + + XtVaGetValues(ld->list, XmNselectedItemCount, &num, NULL); + if (num == 0) { +/* AskUser(widget, ld->ed, msg, &ans, "error");*/ + return; + } else { + setselectedcode(ld); + XtUnmanageChild(XtParent(widget)); + ed = ld->ed; + freeld(ld); + getbdffn(ed); + } +} +void selcharcancelCB(Widget widget, ListData * ld, XtPointer call_data) +{ + Exc_data *ed; + + ed = ld->ed; + freeld(ld); + excterminate(ed); +} + +XmString * setxmslist(ListData * ld) +{ + char **cp; + XmString *xmslist, *xmsp; + int i; + + if ((xmslist = (XmString *) calloc(ld->existcode_num, sizeof(XmString *))) + == NULL) { + excerror(ld->ed, EXCERRMALLOC, "setxmslist", "exit"); + } + cp = ld->existcode_c; + xmsp = xmslist; + for (i = 0; i < ld->existcode_num; i++) { + *xmsp = XmStringCreateLocalized(*cp); + xmsp++; + cp++; + } + return (xmslist); +} + +void freexmslist(ListData * ld, XmString * xmslist) +{ + XmString *xmsp; + int i; + + if (xmslist != NULL) { + xmsp = xmslist; + for (i = 0; i < ld->existcode_num; i++) { + XmStringFree(*xmsp); + xmsp++; + } + free(xmslist); + } +} + +void selcharcd(Exc_data * ed) +{ + Widget mainw, selcd, ok, cancel; + Widget slctLabel, form; + Arg args[20]; + Cardinal n; + char *oklabel; + char *cancellabel; + XmString *xmslist; + extern ListData *ld; + char *p; + + oklabel = GETMESSAGE(10, 6, "OK"); + cancellabel = GETMESSAGE(10, 8, "Cancel"); + + n = 0; + XtSetArg(args[n], XmNautoUnmanage, False); n++; + XtSetArg(args[n], XmNtitle, maintitle); n++; + mainw = XmCreateTemplateDialog(ed->toplevel, "mainw", args, n); + + n = 0; + form = XmCreateForm( mainw, "form", args, n); + XtManageChild(form); + + p = GETMESSAGE(10, 10, "glyph indexes"); + n = 0; + XtSetArg( args[n], XmNx, 20 ) ; n++; + XtSetArg( args[n], XmNheight, 20 ) ; n++ ; + XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ) ; n++ ; + XtSetArg( args[n], XmNtopOffset, 10 ) ; n++ ; + slctLabel = XmCreateLabel( form, p, args, n); + XtManageChild(slctLabel); + + n = 0; + xmslist = setxmslist(ld); + XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ) ; n++ ; + XtSetArg( args[n], XmNleftOffset, 20 ) ; n++ ; + XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++ ; + XtSetArg( args[n], XmNtopOffset, 5 ) ; n++ ; + XtSetArg( args[n], XmNwidth, 200 ) ; n++ ; + XtSetArg (args[n], XmNtopWidget, slctLabel ); n++; + XtSetArg(args[n], XmNitems, xmslist); n++; + XtSetArg(args[n], XmNitemCount, ld->existcode_num); n++; + XtSetArg(args[n], XmNvisibleItemCount, 10); n++; + XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); n++; + XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++; + XtSetArg(args[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++; + selcd = XmCreateScrolledList(form, "Select codes", args, n); + freexmslist(ld, xmslist); + XtManageChild(selcd); + + ld->list = selcd; + + ok = excCreatePushButton(mainw, "ok", oklabel, + (XtCallbackProc) selcharokCB, (XtPointer) ld); + + cancel = excCreatePushButton(mainw, "cancel", cancellabel, + (XtCallbackProc) selcharcancelCB, + (XtPointer) ld); + + XtManageChild(mainw); +} + +void setselectedcode(ListData *ld) +{ + int *position_list; + int position_count; + int i; + int *codep; + + XmListGetSelectedPos(ld->list, &position_list, &position_count); + + ld->ed->code_num = position_count; + ld->ed->gpf_code_list = (int *) calloc(position_count, sizeof(int)); + codep = ld->ed->gpf_code_list; + + for (i = 0; i < position_count; i++) { + *codep = *((ld->existcode)+(position_list[i]-1)); + codep++; + } +} diff --git a/cde/programs/dtudcexch/udcimp.c b/cde/programs/dtudcexch/udcimp.c new file mode 100644 index 000000000..b68675980 --- /dev/null +++ b/cde/programs/dtudcexch/udcimp.c @@ -0,0 +1,210 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udcimp.c /main/4 1996/09/02 18:51:02 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "excutil.h" +#include "FaLib.h" +void addcharptn(); +void setcodelists(); + +extern ListData *ld; +extern int num_gr; +extern FalGlyphRegion *gr; +extern FalFontData fullFontData; + +void udcimp(Exc_data * ed) +{ + ed->function = IMPORT; + strcpy(ed->bdfmode,"r"); + getbdffn(ed); +} + +int checkcode(int code) +{ + int i, j; + int code1, code2; + + for (i = 0; i < num_gr; i++) { + code1 = smaller(gr[i].start, gr[i].end); + code2 = bigger(gr[i].start, gr[i].end); + if ((code >= code1) && (code <= code2)) { /*in udc area */ + for (j = 0; j < ld->existcode_num; j++) { + if (code == ld->existcode[j]) + return (1); /* the font has same glyph index */ + } + return (0); + } + } + return (-1); /* out of udc area */ +} + + +int checkcodes(int code_num, int * code_list) +{ + int *codep; + int i, ans; + int exist = 0; + + codep = code_list; + for (i = 0; i < code_num; i++) { + ans = checkcode(*codep); + if (ans == -1) { + return (-1); + } else if (ans == 1) { + exist = 1; + } + codep++; + } + return (exist); +} + +void getcharcd(Exc_data * ed) +{ + int code_num; + int *code_list; + int i; + char *msg; + char *msg2; + char *msg3; + int ans, ans2; + + msg = GETMESSAGE(12, 2, "Glyph images in this BDF file can't be added to the font."); + msg2 = GETMESSAGE(12, 4, "Failed to open the selected BDF font. You have no right to access for the font file, or the format of the file is not consistent."); + msg3 = GETMESSAGE(12, 6, "There are one or more glyph images being overwritten. Overwrite?"); + + i = ImpBDFCodeList(ed->bdffile, &code_num, &code_list); + + if (i != 0) { /* bad BDF format */ + AskUser(ed->toplevel, ed, msg2, &ans, "error"); + freeld(ld); + excterminate(ed); + } + + ans2 = checkcodes(code_num, code_list); + if (ans2 == -1) { /* out of UDC code exists */ + AskUser(ed->toplevel, ed, msg, &ans, "error"); + freeld(ld); + excterminate(ed); + } else if (ans2 == 1) { /* font file has same glyph index */ + AskUser(ed->toplevel, ed, msg3, &ans, "warning"); + if (ans != 1) { + freeld(ld); + excterminate(ed); + } + } + +/* set twe codelists */ + setcodelists(ld, code_num, code_list); + + if (ImpBDFCodeListFree(&code_list) != 0) { + fprintf(stderr,"error in ImpBDFCodeListFree\n"); + } + +/* add gryph images to font */ + addcharptn(ed); +} + +void addcharptn(Exc_data * ed) +{ + int i; + int ans; + char *msg; + char *msg2; + char *msg3; + + int mask; + FalFontDataList *fulllist = NULL; + FalFontID fontid; + + msg = GETMESSAGE(12, 8, "Failed to open the selected font. You have no right to access for the font file, or the format of the file is not consistent."); + msg2 = GETMESSAGE(12, 10, "Glyph images in this BDF file can't be added to the font."); + msg3 = GETMESSAGE(12, 12, "Failed in the registration of the font file."); + + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_GLYPH_INDEX | + FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UPDATE | + FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_CODE_SET; + + i = ImpBDFCheck(ed->bdffile, ed->fontfile); + if (i != 0) { + AskUser(ed->toplevel, ed, msg2, &ans, "error"); + excterminate(ed); + } + + fontid = FalOpenSysFont(&fullFontData, mask, &fulllist); + if (fontid == 0) { + AskUser(ld->ed->toplevel, ld->ed, msg, &ans, "error"); + excterminate(ed); + } + i = 0; + i = ImpBDFtoGpf(ed->bdffile, ed->fontfile, + ed->code_num, ed->bdf_code_list); + FalCloseFont( fontid ); + if (i != 0) { + AskUser(ed->toplevel, ed, msg3, &ans, "error"); + } + + excterminate(ed); +} + +void setcodelists(ListData *ld, int code_num, int *code_list) +{ + int *c1, *c2; + int i; + Exc_data *ed; + + ld->ed->code_num = code_num; + + if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) { + ed = ld->ed; + freeld(ld); + excerror(ed, EXCERRMALLOC, "setcodelists", "exit"); + } + ld->ed->bdf_code_list = c1; + c2 = code_list; + for (i = 0; i < code_num; i++) + { + *c1 = *c2; + c1++; + c2++; + } + + if ((c1 = (int *) calloc(code_num, sizeof(int))) == NULL) { + ed = ld->ed; + freeld(ld); + excerror(ed, EXCERRMALLOC, "setcodelists", "exit"); + } + ld->ed->gpf_code_list = c1; + c2 = code_list; + for (i = 0; i < code_num; i++) + { + *c1 = *c2; + c1++; + c2++; + } +} diff --git a/cde/programs/dtudcexch/xlfdutil.c b/cde/programs/dtudcexch/xlfdutil.c new file mode 100644 index 000000000..3c21a5657 --- /dev/null +++ b/cde/programs/dtudcexch/xlfdutil.c @@ -0,0 +1,332 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: xlfdutil.c /main/2 1996/10/14 14:45:50 barstow $ */ +/* + * All Rights Reserved, Copyright (c) FUJITSU LIMITED 1995 + * + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Authors: Seiya Miyazaki FUJITSU LIMITED + * Hiroyuki Chiba Fujitsu Basic Software Corporation + * + */ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <nl_types.h> + +#include <Xm/Xm.h> + +#include <Xm/Form.h> +#include <Xm/PushB.h> +#include <Xm/Text.h> +#include <Xm/TextF.h> +#include <Xm/Label.h> +#include <Xm/SeparatoG.h> +#include <Xm/List.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> + +#include "FaLib.h" +#include "falxlfd.h" + +#include "selectxlfd.h" + +#ifdef DEBUG +#undef Dprintf +#define Dprintf fprintf +#else +#define Dprintf +#endif /* DEBUG */ + +/* + * parameters + */ +static char* skipSpace() ; + +extern FalFontDataList *font_L ; +extern FalxFontDataBuff KeyBuff ; +extern FalxCodeList *CodeList ; +extern FalxStyleList *StyleList ; +extern FalxSizeList *SizeList ; +extern int SelectedOffset ; +extern int getmask ; + +extern char *fullPathName ; + + +extern Widget toplevel ; +extern Widget + xlfdWform, cpyWform, + slctBLabel[BUTTONITEMS],slctBText[BUTTONITEMS], slctButton[BUTTONITEMS], + listPop[BUTTONITEMS], listW[BUTTONITEMS], + errorMD, msgBox ; + + +/**************************************************************** + * functions for get font infomation +****************************************************************/ + +int +GetXLFDInfomations() +{ + Dprintf( stdout, "GetXLFDInfomations()\n" ) ; + + /* initialize */ + getmask = 0 ; + SelectedOffset = 0 ; + fullPathName = NULL ; + FalxInitDataBuff( &KeyBuff ) ; + + /* get UDC informations */ + if( FalxGetFontList( &font_L, XtDisplayOfObject( toplevel ) ) ){ + Dprintf( stderr, "GetXLFDInfomations() : FalxGetFontList() error.\n" ) ; + return(-1); + } + + /* create code area list */ + if( FalxCreateCodeList( &CodeList, font_L ) ){ + Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateCodeList() error.\n" ) ; + return(-1); + } + + /* create style list */ + if( FalxCreateStyleList( &StyleList, font_L ) ){ + Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateStyleList() error.\n" ) ; + return(-1); + } + + /* create size list */ + if( FalxCreateSizeList( &SizeList, font_L ) ){ + Dprintf( stderr, "\nGetXLFDInfomations() : FalxCreateSizeList() error.\n" ) ; + return(-1); + } + + return(0) ; +} + + + + + +int +GetItemsToDisplay( int num, int *itemcnt, XmString **xms_list ) +{ + int i, j, cnt ; + char *sp ,string[256], buf[256] ; + Arg args[1]; + int length, maxlength ; + FalxXlfdList *xlist ; + + int tmp_cnt ; + char **tmp_dlist, *str ; + XmString *xms ; + int rlen ; + int rtn ; + + + switch( num ){ + case 0 : /* XLFD */ + /* set key data */ + for( i=1; i<BUTTONITEMS; i++ ){ + if( (str = XmTextGetString( slctBText[i] )) == NULL ){ + exit(-1) ; + } + if( *str == ' ' || *str == NULL ) continue ; + if( SetKeyBuff( i, str ) ){ + exit(-1) ; + } + } + rtn = FalxGetXlfdList( &xlist, font_L, &KeyBuff, getmask ) ; + if( rtn ) return( rtn ) ; + tmp_cnt = xlist->num ; + tmp_dlist = xlist->list ; + break ; + case 1 : /* code area */ + tmp_cnt = CodeList->num ; + tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ; + if( tmp_dlist == NULL ) return(-1) ; + for( i=0; i<tmp_cnt; i++ ){ + sp = string ; + rlen = sprintf( sp, "CS:%d ", (CodeList->dlist[i]->fontset) ) ; + sp += rlen ; + for( j=0; j<CodeList->dlist[i]->code_area_num; j++ ){ + rlen = sprintf( sp, "%x - %x ", + CodeList->dlist[i]->alist[j]->udc_start, + CodeList->dlist[i]->alist[j]->udc_end ) ; + sp += rlen ; + } + if( (tmp_dlist[i] = strdup( string )) == NULL ){ + return(-1) ; + } + } + break ; + case 2 : /* style */ + tmp_cnt = StyleList->num ; + tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ; + for( i=0; i<tmp_cnt; i++ ){ + if( (tmp_dlist[i] = strdup( StyleList->list[i] )) == NULL ){ + return(-1) ; + } + } + break ; + case 3 : /* size */ + tmp_cnt = SizeList->num ; + tmp_dlist = (char **)malloc( sizeof(char *) * tmp_cnt ) ; + for( i=0; i<tmp_cnt; i++ ){ + sprintf( string, "%d ", SizeList->list[i] ) ; + if( (tmp_dlist[i] = strdup( string )) == NULL ){ + return(-1) ; + } + } + break ; + default : /* error */ + return(-1) ; + } + if( (xms = (XmString *)calloc( tmp_cnt, sizeof(XmString) )) == NULL ){ + return( -1 ) ; + } + + /* + * set list for display + */ + maxlength = 0 ; + for ( i=0; i<tmp_cnt; i++ ){ + xms[i] = XmStringCreateLocalized( tmp_dlist[i] ); + } + + /* + * free allocated memory + */ + + switch( num ){ + case 0 : /* XLFD */ + FalxFreeXlfdList( xlist ) ; + break ; + case 1 : /* code area */ + case 2 : /* style */ + case 3 : /* size */ + for( i=0; i<tmp_cnt; i++ ){ + free( tmp_dlist[i] ) ; + } + free( tmp_dlist ) ; + break ; + default : /* error */ + return(-1) ; + } + + + *itemcnt = tmp_cnt ; + *xms_list = xms ; + + return(0) ; + +} + + + + +static char* +skipSpace( char *str, int skipcnt ) +{ + int i, spacecnt ; + char *sp ; + int len ; + + if( *str == NULL ) return( NULL ) ; + len = strlen( str ) ; + sp = str ; + for( i=0,spacecnt=0; i<len-1; i++, sp++ ) { + if( *sp == NULL ) return( NULL ) ; + if( *sp == ' ' ) spacecnt++ ; + if( spacecnt == skipcnt ) break ; + } + sp++ ; + return( sp ) ; +} + + + + +int +SetKeyBuff( int num, char *str ) +{ + int i, j ; + int cdset, start, end ; + FalxUdcArea *tmp_list ; + char hyp, *sp ; + + switch( num ){ + case 0 : /* XLFD */ + KeyBuff.FontData.xlfdname = str ; + break ; + case 1 : /* code area */ + getmask |= FAL_FONT_MASK_CODE_SET ; + if( KeyBuff.FileData.list != NULL ){ + free( KeyBuff.FileData.list ) ; + } + KeyBuff.FileData.list = NULL ; + tmp_list = NULL ; + + sp = str ; + if( sscanf( sp, "CS:%d ", &cdset ) != 1 ){ + return(-1) ; + } + if( (sp = skipSpace( sp, 1 )) == NULL ) return( -1 ) ; + num = 0 ; + KeyBuff.FontData.cd_set = cdset ; + while( sscanf( sp, "%x %c %x ", &start, &hyp, &end ) == 3 ){ + if( hyp != '-' ) break ; + if( tmp_list == NULL ){ + tmp_list = (FalxUdcArea *)malloc( sizeof(FalxUdcArea) ) ; + }else{ + tmp_list = (FalxUdcArea *)realloc( KeyBuff.FileData.list, + sizeof(FalxUdcArea) * (num+1) ) ; + } + if( tmp_list == NULL ) return(-1) ; + tmp_list[num].udc_start = (int)start ; + tmp_list[num].udc_end = (int)end ; + num ++ ; + if( (sp = skipSpace( sp, 3 )) == NULL ) break ; + } + if( num == 0 ) return(-1) ; + KeyBuff.FileData.code_area_num = num ; + KeyBuff.FileData.list = tmp_list ; + break ; + case 2 : /* style */ + getmask |= FAL_FONT_MASK_STYLE_NAME ; + KeyBuff.FontData.style.name = str ; + break ; + case 3 : /* size */ + getmask |= FAL_FONT_MASK_LETTER_W ; + getmask |= FAL_FONT_MASK_LETTER_H ; + KeyBuff.FontData.letter.w = atoi( str ) ; + KeyBuff.FontData.letter.h = atoi( str ) ; + break ; + default : + return(-1) ; + } + return(0); +} diff --git a/cde/programs/dtudcfonted/Imakefile b/cde/programs/dtudcfonted/Imakefile new file mode 100644 index 000000000..8f90abc06 --- /dev/null +++ b/cde/programs/dtudcfonted/Imakefile @@ -0,0 +1,79 @@ +/* Imakefile 1.8 - Fujitsu source for CDEnext 96/06/10 13:34:37 */ +/* $TOG: Imakefile /main/20 1997/04/30 15:51:07 samborn $ */ + + LOCAL_XLIBPATH = + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + +UDC_INC_PATH1 = -I./ +UDC_INC_PATH2 = -I./include +UDC_INC_PATH3 = -I./libfal + +UDC_INC_PATH4 = -I$(DTSVCSRC)/DtXpm +UDC_INC_PATH5 = -I$(TOP)/../x11/xc + +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + +DEFINES = $(OPT2) + + INCLUDES = $(UDC_INC_PATH1)\ + $(UDC_INC_PATH2)\ + $(UDC_INC_PATH3)\ + $(UDC_INC_PATH4)\ + $(UDC_INC_PATH5) + + DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB) +LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB) ./libfuty/liboakfuty.a ./libfal/libfal.a + + + SRCS = comsub.c cpyw.c mtfgui.c ufont.c util.c\ + selectx.c cpyx.c xutil.c code.c + + OBJS = comsub.o ufont.o cpyw.o mtfgui.o util.o\ + cpyx.o xutil.o selectx.o code.o + +/* Sun needs the widechar library */ +#ifdef SunArchitecture +SYS_LIBRARIES = DtClientSysLibs -lw +#else +SYS_LIBRARIES = DtClientSysLibs +#endif + +#define IHaveSubdirs +#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' + +SUBDIRS = \ + libfal \ + libfuty \ + dtaddcpf \ + dtbdftocpf \ + dtcpftobdf \ + dtcpftogpf \ + dtcpgpf \ + dtgpftobdf \ + dtgpftocpf \ + dtlsgpf + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) + +ComplexProgramTarget(dtudcfonted) + +install:: + @if [ -d $(DESTDIR)/app-defaults/C ]; then set +x; \ + else (set -x; $(MKDIRHIER) $(DESTDIR)/app-defaults/C); fi ; \ + if [ -d $(DESTDIR)/app-defaults/ja_JP ]; then set +x; \ + else (set -x; $(MKDIRHIER) $(DESTDIR)/app-defaults/ja_JP); fi ; \ + if [ -f $(DESTDIR)/app-defaults/C/Dtudcfonted ]; then set +x; \ + else (set +x ; echo "installing" "in $(DESTDIR)/app-defaults/C" ; \ + $(CP) ./resource/Dtudcfonted $(DESTDIR)/app-defaults/C; \ + chmod 0444 $(DESTDIR)/app-defaults/C/Dtudcfonted); fi ; \ + if [ -f $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted ]; then set +x; \ + else (set +x ; echo "installing" "in $(DESTDIR)/app-defaults/ja_JP" ; \ + $(CP) ./resource/Dtudcfonted.ja_JP $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted; \ + chmod 0444 $(DESTDIR)/app-defaults/ja_JP/Dtudcfonted); fi diff --git a/cde/programs/dtudcfonted/README b/cde/programs/dtudcfonted/README new file mode 100644 index 000000000..67fb13959 --- /dev/null +++ b/cde/programs/dtudcfonted/README @@ -0,0 +1,30 @@ +$XConsortium: README /main/3 1996/07/04 02:23:02 cde-fuj $ +UDC font editor and UDC data exchange utility README + + +1) Environment + +1.1) XLOCALEDIR environment variable + + - If the NLS database ("XLC_LOCALE" files) locates + in different directory from where specified at building + time, set the full path name of the correct directory to + the XLOCALEDIR environment variable. + +1.2) Editable Fonts + + - Currently, only jisx0208 fonts in Japanese locale is + defined in NLS database to have UDC. So the dtudcfonted + will not show the edit view in other locales than Japanese. + + - If the "fonts.list" file exists in the directories showed + below, dtudcfonted and dtudcexch read and get directories + from this file to search fonts. + + /usr/dt/config/ + /usr/dt/config/$LANG + $DTUDCFONTS/ + $DTUDCFONTS/$LANG + + - If the system place fonts in different directories other + than listed in this file, you need to add them in it. diff --git a/cde/programs/dtudcfonted/code.c b/cde/programs/dtudcfonted/code.c new file mode 100644 index 000000000..8ecc1cd02 --- /dev/null +++ b/cde/programs/dtudcfonted/code.c @@ -0,0 +1,487 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* code.c 1.37 - Fujitsu source for CDEnext 96/10/30 13:13:47 */ +/* $XConsortium: code.c /main/6 1996/11/08 01:57:21 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ +#include <stdio.h> +#include <string.h> +#include <X11/keysym.h> +#include <Xm/Xm.h> +#include <Xm/Label.h> +#include <Xm/List.h> +#include <Xm/RowColumn.h> +#include <Xm/SeparatoG.h> +#include <Xm/Text.h> +#include <Xm/PushB.h> +#include <Xm/Frame.h> +#include <Xm/Form.h> +#include <Xm/MwmUtil.h> +#include <X11/Intrinsic.h> +#include "falfont.h" +#include "xoakufont.h" + +#define NUM 0x80 + +static Display *display=NULL; +static int screen; +static Boolean open_font; +static Widget toggle[NUM]; +static Widget text; +static Window BaseW; +static Widget set_widget; +static Widget code_w=0; +static int font_w, font_h; +static unsigned long fg, bg; +static unsigned char *ptn, *clr; +static Pixmap no_pix; +static int len, code1; +static char *FontName=NULL; +static FalFontID fid; + +extern FalFontID font_id; +extern int CodePoint; +extern Resource resource; + +static void +OpenFont(void) +{ + int mask; + FalFontData font_data; + static FalFontDataList *copylist; + extern FalFontData fullFontData; + + if(strcmp(FontName, fullFontData.xlfdname) == 0) { + fid = font_id; + return; + } + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED; + font_data.xlfdname = FontName; + if (! CodePoint) { + mask |= FAL_FONT_MASK_GLYPH_INDEX; + } + + fid = FalOpenSysFont(&font_data, mask, ©list); +} + +static void +CloseFont(void) +{ + if (fid != font_id) { + FalCloseFont(fid); + fid = 0; + } +} + +static void +DrawCode(Widget w, int low_code) +{ + int hi_code; + char *f = NULL; + XImage image; + GC gc = XDefaultGC(display, 0); + + hi_code = (code1 & 0xff) << 8; + image.width = font_w; + image.height = font_h; + image.xoffset = 0; + image.format = XYBitmap; + image.byte_order = LSBFirst; + image.bitmap_unit = 8; + image.bitmap_bit_order = MSBFirst; + image.bitmap_pad = 8; + image.depth = 1; + image.bytes_per_line = (font_w - 1) / 8 + 1; + XSetForeground(display, gc, fg); + XSetBackground(display, gc, bg); + + if (open_font) { + f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h); + if(f == NULL || f == (char *)FAL_ERROR) { + return; + } + if( EXISTS_FLAG == 0 ) { + memcpy(ptn, f, len); + image.data = (char *)ptn; + } else { + image.data = (char *)clr; + } + XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h); + } else { + if (ptnGet(hi_code | low_code, ptn) == 0) { + image.data = (char *)ptn; + } else { + image.data = (char *)clr; + } + XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h); + } +} + +static void +SetPixmap(start_code) +{ + int hi_code, low_code; + char *f = NULL; + XImage image; + GC gc = XDefaultGC(display, 0); + + hi_code = (start_code & 0xff) << 8; + image.width = font_w; + image.height = font_h; + image.xoffset = 0; + image.format = XYBitmap; + image.byte_order = LSBFirst; + image.bitmap_unit = 8; + image.bitmap_bit_order = MSBFirst; + image.bitmap_pad = 8; + image.depth = 1; + image.bytes_per_line = (font_w - 1) / 8 + 1; + XSetForeground(display, gc, fg); + XSetBackground(display, gc, bg); + + if (open_font) { + for (low_code=0; low_code < NUM; low_code++) { + f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h); + if(f == NULL || f == (char *)FAL_ERROR) { + return; + } + if( EXISTS_FLAG == 0 ) { + memcpy(ptn, f, len); + image.data = (char *)ptn; + } else { + image.data = (char *)clr; + } + XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h); + } + } else { + for (low_code=0; low_code < NUM; low_code++) { + if (ptnGet(hi_code | low_code, ptn) == 0) { + image.data = (char *)ptn; + } else { + image.data = (char *)clr; + } + XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h); + } + } +} + +static void +Code1Call(Widget w, int start_code, XmListCallbackStruct *data) +{ + code1 = start_code + data->item_position -1; + SetPixmap(code1); +} + +static void +Code2Call(Widget w, int code2, XmPushButtonCallbackStruct *data) +{ + char asc[16]; + sprintf(asc, "%2.2X%2.2X", code1, code2); + XtVaSetValues(text, XmNvalue, asc, NULL); + DrawCode(w, code2); +} + +static void +PrevPage(Widget w, Widget scroll) +{ + int *list; + int num; + if (XmListGetSelectedPos(scroll, &list, &num)) { + if(list[0] > 1) { + XmListSelectPos(scroll, list[0] - 1, True); + XmListSetPos(scroll, list[0] - 1); + } + } +} + +static void +NextPage(Widget w, Widget scroll) +{ + int *list; + int num, item; + XtVaGetValues(scroll, XmNitemCount, &item, NULL); + if (XmListGetSelectedPos(scroll, &list, &num)) { + if(list[0] < item) { + XmListSelectPos(scroll, list[0] + 1, True); + XmListSetBottomPos(scroll, list[0] + 1); + } + } +} + +static void +Cancel(void) +{ + XtUnmapWidget(XtParent(code_w)); +} + +static void +Apply(void) +{ + char *asc; + XtVaGetValues(text, XmNvalue, &asc, NULL); + XtVaSetValues(set_widget, XmNvalue, asc, NULL); + XtFree(asc); + Cancel(); +} + +static void +CreateItem(XmString *item, int *item_count, int *start_code) +{ + int count; + int start, end; + char str[5]; + FalFontinfo finfo; + extern int begin_code, last_code; + + if (open_font) { + if (FalQueryFont(fid, &finfo) == FAL_ERROR) { + *item_count = 0; + CloseFont(); + return; + } + font_w = finfo.width; + font_h = finfo.height; + start = (finfo.top & 0xff00) >> 8; + end = (finfo.bottom & 0xff00) >> 8; + } else { + font_w = edg.width; + font_h = edg.height; + start = (begin_code & 0xff00) >> 8; + end = (last_code & 0xff00) >> 8; + } + if (CodePoint) { + if (start < 0x80) + start = 80; + if (end < 0x80) + start = 80; + } else { + if (start > 0x7f) + start = 0x7f; + if (end > 0x7f) + end = 0x7f; + } + *start_code = start; + for (count=0;start <= end; start++, count++) { + sprintf(str, "%X", start); + item[count] = XmStringCreateLocalized(str); + } + *item_count = count; +} + +static Widget +CreateCodeWindow(Widget w) +{ + Widget top, base1, base2, base3, base4; + Widget frame, scroll, label, sep, form; + Widget push1, push2, push3, push4; + Arg args[16]; + int n, i; + XmString item[128]; + XmString xcs; + int item_count, start_code, add_c; + char add[9]; + + n = 0; + XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_CLOSE | + MWM_FUNC_RESIZE); n++; + XtSetArg(args[n], XmNmwmDecorations, MWM_DECOR_ALL); n++; + top = XmCreateFormDialog(w, "code", args, n); + + base1 = XtVaCreateManagedWidget("base1", xmRowColumnWidgetClass, top, + XmNorientation, XmVERTICAL, NULL); + + frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, base1, + NULL); + + base2 = XtVaCreateManagedWidget("base2", xmRowColumnWidgetClass, frame, + XmNorientation, XmHORIZONTAL, NULL); + + CreateItem(item, &item_count, &start_code); + code1 = start_code; + n = 0 ; + XtSetArg(args[n], XmNitems, item); n++; + XtSetArg(args[n], XmNitemCount, item_count); n++; + XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); n++; + scroll = XmCreateScrolledList(base2, "scroll", args, n); + XtManageChild(scroll); + XtAddCallback(scroll, XmNbrowseSelectionCallback, + (XtCallbackProc)Code1Call, (XtPointer) (intptr_t) start_code); + XtAddCallback(scroll, XmNdefaultActionCallback, + (XtCallbackProc)Code1Call, (XtPointer) (intptr_t) start_code); + XmListSelectPos(scroll, 1, False); + + base3 = XtVaCreateManagedWidget("base3", xmRowColumnWidgetClass, base2, + XmNorientation, XmHORIZONTAL, + XmNpacking, XmPACK_COLUMN, + XmNradioAlwaysOne, True, + XmNradioBehavior , True, + XmNmarginHeight, 0, + XmNmarginWidth, 0, + XmNspacing, 0, + XmNnumColumns, 9, NULL); + + + len = (font_w / 8 + 1) * font_h; + ptn = (unsigned char *) malloc(len); + clr = (unsigned char *) malloc(len); + memset(clr, 0, len); + XtVaGetValues(w, XmNforeground, &fg, XmNbackground, &bg, NULL); + no_pix = XCreatePixmapFromBitmapData(display, BaseW, (char *)clr, + font_w, font_h, fg, bg, DefaultDepth(display, screen)); + + XtVaCreateManagedWidget("", xmLabelWidgetClass, base3, NULL); + for (i=0; i < 16; i++) { + sprintf(add, "%2.1X", i); + XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL); + } + if (CodePoint) + add_c = 8; + else + add_c = 0; + for (i=0; i < NUM; i++) { + if ((i % 16) == 0) { + snprintf(add, sizeof(add), "%2.1X", add_c++); + XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL); + } + toggle[i] = XtVaCreateWidget("toggle", + xmPushButtonWidgetClass, base3, + XmNwidth, font_w, + XmNheight, font_h, + XmNlabelType, XmPIXMAP, + XmNlabelPixmap, no_pix, NULL); + XtAddCallback(toggle[i], XmNactivateCallback, + (XtCallbackProc)Code2Call, (XtPointer) (intptr_t) i); + XtAddCallback(toggle[i], XmNarmCallback, + (XtCallbackProc)DrawCode, (XtPointer) (intptr_t) i); + XtAddCallback(toggle[i], XmNdisarmCallback, + (XtCallbackProc)DrawCode, (XtPointer) (intptr_t) i); + XtAddEventHandler(toggle[i], ExposureMask, False, + (XtEventHandler)DrawCode, (XtPointer) (intptr_t) i); + } + XtManageChildren(toggle, NUM); + + base4 = XtVaCreateManagedWidget("base4", xmFormWidgetClass, base1, NULL); + + xcs = XmStringCreateLocalized(resource.l_code); + label = XtVaCreateManagedWidget("code", xmLabelWidgetClass, base4, + XmNlabelString, xcs, + XmNleftAttachment, XmATTACH_POSITION, + XmNleftPosition, 30, NULL); + + text = XtVaCreateManagedWidget("text", xmTextWidgetClass, base4, + XmNeditable, False, + XmNcursorPositionVisible, False, + XmNcolumns, 4, + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, label, NULL); + + sep = XtVaCreateManagedWidget("sep", xmSeparatorGadgetClass, base1, + XmNorientation, XmHORIZONTAL, NULL); + + form = XtVaCreateManagedWidget("sep", xmFormWidgetClass, base1, NULL); + + xcs = XmStringCreateLocalized(resource.previous); + push1 = XtVaCreateManagedWidget("PreviousPage", xmPushButtonWidgetClass, form, + XmNleftAttachment, XmATTACH_POSITION, + XmNlabelString, xcs, + XmNleftPosition, 10, NULL); + XtAddCallback(push1, XmNactivateCallback, + (XtCallbackProc)PrevPage, (XtPointer)scroll); + XmStringFree(xcs); + + xcs = XmStringCreateLocalized(resource.next); + push2 = XtVaCreateManagedWidget("NextPage", xmPushButtonWidgetClass, form, + XmNleftAttachment, XmATTACH_POSITION, + XmNlabelString, xcs, + XmNleftPosition, 35, NULL); + XtAddCallback(push2, XmNactivateCallback, + (XtCallbackProc)NextPage, (XtPointer)scroll); + XmStringFree(xcs); + + xcs = XmStringCreateLocalized(resource.apply); + push3 = XtVaCreateManagedWidget("Apply", xmPushButtonWidgetClass, form, + XmNleftAttachment, XmATTACH_POSITION, + XmNlabelString, xcs, + XmNleftPosition, 60, NULL); + XtAddCallback(push3, XmNactivateCallback, (XtCallbackProc)Apply, NULL); + XmStringFree(xcs); + + xcs = XmStringCreateLocalized(resource.l_cancel); + push4 = XtVaCreateManagedWidget("Cancel", xmPushButtonWidgetClass, form, + XmNleftAttachment, XmATTACH_POSITION, + XmNlabelString, xcs, + XmNleftPosition, 80, NULL); + XtAddCallback(push4, XmNactivateCallback, (XtCallbackProc)Cancel, NULL); + XmStringFree(xcs); + + return(top); +} + +void +CodeWindow(Widget widget, char *font_name, Boolean load_font) +{ + static Boolean old_load_font; + extern int CodePoint; + + set_widget = widget; + + BaseW = XtWindow(widget); + display = XtDisplay(widget); + screen = DefaultScreen(display); + if (FontName == NULL || strcmp(font_name, FontName) || + load_font != old_load_font) { + old_load_font = load_font; + if (code_w) { + XtDestroyWidget(code_w); + code_w = 0; + free(ptn); + free(clr); + if (fid != 0) { + CloseFont(); + } + } + if (FontName) + free(FontName); + FontName = (char *)malloc(strlen(font_name)+1); + strcpy(FontName, font_name); + + if (load_font) { + OpenFont(); + if (fid == 0) + return; + open_font = True; + } else { + open_font = False; + } + + code_w = CreateCodeWindow(widget); + XtManageChild(code_w); + } else { + XtMapWidget(XtParent(code_w)); + } +} diff --git a/cde/programs/dtudcfonted/comsub.c b/cde/programs/dtudcfonted/comsub.c new file mode 100644 index 000000000..6c10007de --- /dev/null +++ b/cde/programs/dtudcfonted/comsub.c @@ -0,0 +1,1563 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* comsub.c 1.36 - Fujitsu source for CDEnext 96/09/09 15:30:40 */ +/* $XConsortium: comsub.c /main/8 1996/09/19 19:36:37 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <math.h> +#include <locale.h> + +#include <X11/Intrinsic.h> +#include "fssxeg.h" +#include "falfont.h" +#include "ufontrsrc.h" + +static void writePtn(char *ptn, int width, int height, FILE *fp); +static void sig_receive(void); +char *get_cmd_path(char *path, char *cmd) ; + +extern Resource resource; + +/*********************************************************************** + manage the character patterns + **********************************************************************/ + +#define GUADDPTNN 100 /* number of charcters for memory allocation */ +/* this structure corresopnds to single font file */ +typedef struct { /* area to manage character patterns */ + char flag; /* invalid(=0)/valid(=1) */ + int width; /* pattern width */ + int height; /* pattern height */ + int nptn; /* number of characters in editting */ + int nmaxptn; /* maximum number of characters in editting */ + int ptnsize; /* size per byte of single pattern */ + unsigned int ptnmemsize; /* size of memory of whole patterns */ + unsigned short *ntoc; /* character list / relative code */ + unsigned short *ctop; /* relative code / bitmap area */ + char *ptn; /* pointer to the bimap area */ + int cptnnum; /* current pattern number */ +} PATTERN_MNG; + +static PATTERN_MNG pm; /* Pattern_Manage */ + +/* selection window for XLFD */ +extern FalFontData fullFontData; +extern FalFontData copyFontData; +extern int CodePoint; + +char *fullpath=NULL; +int begin_code=0, last_code=0; + +FalCodeRegion CodeArea[10]; +char AreaStr[160]; + +#define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)] + +FalFontID font_id; + +static char * +get_locale(void) +{ + char *loc; + + if ((loc = getenv("LANG")) != NULL) { + return(loc); + } else { + return("C"); + } +} + +/* contents : convert the sequential number in the editor into + * relative code in the system area + * values : -1 : terminated abnormally + * else : relative code + */ + +int +ptnSqToNo( int num /*sequential number */) +{ + if( (pm.flag == 0) || (num >= pm.nptn) ) + return( -1 ); + + return( pm.ntoc[num] ); +} + + + + +/* contents : convert the relative code in the system area into + * sequential number in the editor + * values : -1 : terminated abnormally + * else : sequential number + */ + +int +ptnNoToSq( int ncode /* relative code */) +{ + int sq; + + if( pm.flag == 0 ) + return( -1 ); + + for( sq=0 ; sq < pm.nptn ; sq++ ) { + if( pm.ntoc[sq] == ncode ) + return( sq ); + } + + return( -1 ); +} + + + + +/* + * contents : convert the character code into relative code + * values : relative code + * caution : There is no security against unusal character code. + */ + +int +codeToNo( int code /* character code */) +{ + return( code - begin_code); +} + + + + +/* + * contents : convert the relative code into character code + * values : character code + * caution : There is no security against unusal character code. + */ + +int +noToCode( int sno /* relative code */) +{ + return( sno + begin_code); +} + + +/* + * contents : judge the input code with the system defined character area + * values : 0 : in the system defined area + * -1 : not in the system defined area + */ + +int +codeCheck( int code ) +{ + if (code < begin_code || code > last_code) { + return( -1 ); + } + return( 0 ); +} + +/* + * contents : allocate memories for character patterns + * + * values : ID : sequential number of the area + * -1 : terminated abnormally + */ + +static int +ptnOpen( +int n, /* initial number of charcters */ +int maxc, +int width, /* pattern width */ +int height /* pattern height */ +) +{ + int i; + int fpsize; + + if( (n < 0) || (width <= 0) || (height <= 0) ) + return( -1 ); + + if( pm.flag != 0 ) { + return( -1 ); + } + + pm.width = width; + pm.height = height; + pm.nptn = 0; + pm.nmaxptn = n + GUADDPTNN; + pm.ptnsize = height * ((width+7)/8); + fpsize = pm.ptnsize + 1; + pm.ptnmemsize = (unsigned int) ( fpsize * pm.nmaxptn ) ; + + if(( pm.ntoc = (unsigned short *)calloc(maxc, sizeof(unsigned short)) ) == NULL) { + return( -1 ); + } + if(( pm.ctop = (unsigned short *)calloc(maxc, sizeof(unsigned short)) ) == NULL ) { + free( pm.ntoc ); + return( -1 ); + } + if(( pm.ptn = (char *)malloc(fpsize*pm.nmaxptn) ) == NULL ) { + free( pm.ctop ); + free( pm.ntoc ); + return( -1 ); + } + + for( i=0 ; i < maxc ; i++ ) { + pm.ntoc[i] = 0xFFFF; + pm.ctop[i] = 0xFFFF; + } + /* set null to each character pattern area */ + for( i=0 ; i < pm.nmaxptn ; i++ ) { + pm.ptn[fpsize * i] = 0; + } + pm.cptnnum = 0; + pm.flag = 1; + + return( 0 ); +} + + + + +/* + * contents : set free memories for character patterns + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +ptnClose(void) +{ + if( pm.flag == 0 ) { + return( -1 ); + } + pm.flag = 0; + free( pm.ntoc ); + free( pm.ctop ); + free( pm.ptn ); + + return( 0 ); +} + + + + +/* + * contents : add character pattern to the character management area + * + * values : 0 : same code was exists and replaced it + * 1 : add new pattern + * -1 : terminated abnormally + */ + +int +ptnAdd( +int code, /* code to be add */ +char *ptn) /* pointer to the pattern */ +{ + int fpsize; + int ncode; + unsigned short pno; + char *pf; + char *pp; + int i; + char *re_ptn; + unsigned int re_ptnmemsize; + int cpn; + + if( pm.flag == 0 ) + return( -1 ); + + fpsize = pm.ptnsize + 1; + ncode = codeToNo( code ); + + if( (pno = pm.ctop[ncode]) != 0xFFFF ) { + pf = pm.ptn + fpsize*pno; + pp = pf + 1; + for( i=0 ; i < pm.ptnsize ; i++ ) + pp[i] = ptn[i]; + return( 0 ); + } + + if( pm.nptn >= pm.nmaxptn ) { + re_ptnmemsize = pm.ptnmemsize + GUADDPTNN*fpsize; + if(pm.ptn == NULL) { + re_ptn = malloc( re_ptnmemsize ); + } else { + re_ptn = realloc(pm.ptn, re_ptnmemsize); + } + if (re_ptn == NULL) { + return( -1 ); + } + pm.ptnmemsize = re_ptnmemsize; + pm.ptn = re_ptn; + for( i=pm.nmaxptn ; i < pm.nmaxptn + GUADDPTNN ; i++ ) { + pm.ptn[fpsize * i] = 0; + } + pm.nmaxptn += GUADDPTNN; + } + + cpn = pm.cptnnum + 1; + for( i=0 ; i < pm.nmaxptn ; i++, cpn++ ) { + if( cpn >= pm.nmaxptn ) { + cpn = 0; + } + if( pm.ptn[fpsize * cpn] == 0 ) { + break; + } + } + pm.cptnnum = cpn; + + pm.ctop[ncode] = (unsigned short) cpn; + pf = pm.ptn + fpsize*cpn; + pp = pf + 1; + pf[0] = 1; + for( i=0 ; i < pm.ptnsize ; i++ ) + pp[i] = ptn[i]; + + for( i=pm.nptn ; i >=0 ; i-- ) { + if( ncode > (int)pm.ntoc[i] ) { + break; + } + pm.ntoc[i+1] = pm.ntoc[i]; + } + pm.ntoc[i+1] = (unsigned short) ncode; + pm.nptn += 1; + + return( 1 ); +} + + +/* + * contents : get a character pattern from the character management area + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +ptnGet( int code, char *ptn ) +{ + int ncode; + int fpsize; + unsigned short pno; + char *pf; + char *pp; + int i; + + if( (pm.flag == 0) || (codeCheck(code) == -1) ) + return( -1 ); + + ncode = codeToNo( code ); + fpsize = pm.ptnsize +1; + + if( (pno = pm.ctop[ncode]) == 0xFFFF ) + return( -1 ); + + pf = pm.ptn + pno*fpsize; + pp = pf +1; + + for( i=0 ; i < pm.ptnsize ; i++ ) + ptn[i] = pp[i]; + + return( 0 ); +} + + +/* + * contents : judge the character pattern exist or not + * values : 1 : exists + * 0 : not exists + * -1 : terminated abnormally + */ + +int +ptnSense( int code ) +{ + if( (pm.flag == 0) || (codeCheck(code) == -1) ) + return( -1 ); + + if( pm.ctop[ codeToNo(code) ] == 0xFFFF ) + return( 0 ); + else + return( 1 ); +} + + +/* + * contents : delete the character pattern + * values : 1 : deleted + * 0 : the pattern does not exist + * -1 : terminated abnormally + */ + +int +ptnDel( int code ) +{ + int ncode; + int fpsize; + unsigned short pno; + char *pf; + int i; + + if( (pm.flag == 0) || (codeCheck(code) == -1) ) + return( -1 ); + + ncode = codeToNo( code ); + fpsize = pm.ptnsize +1; + + if( (pno = pm.ctop[ncode]) == 0xFFFF ) { + return( 0 ); + } + + pf = pm.ptn + pno*fpsize; + + pf[0] = 0; + pm.ctop[ncode] = 0xFFFF; + + for( i=0 ; i < pm.nptn ; i++ ) { + if( (int)pm.ntoc[i] == ncode ) + break; + } + for( ; i < pm.nptn ; i++ ) + pm.ntoc[i] = pm.ntoc[i+1]; + + pm.nptn --; + return( 1 ); +} + + +/* + * contents : get the infomation of the character + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +ptnGetInfo( +int *n, /* the number of characters in editting */ +int *width, /* pattern width */ +int *height) /* pattern height */ +{ + if( pm.flag == 0 ) + return( -1 ); + + *n = pm.nptn; + *width = pm.width; + *height = pm.height; + + return( 0 ); +} + + +/******************************************************************** + * handle bit map file(1) * + ********************************************************************/ + +struct { /* infomation of character pattern */ + int width; /* pattern width */ + int height; /* pattern height */ + int xbytesize; +} bitInfo = { 16, 16 ,2 }; + + +/* + * contents : set infomation for handling bit-mapped files + */ + +static void +bitSetInfo( +int width, /* pattern width */ +int height) /* pattern height */ +{ + bitInfo.width = width; + bitInfo.height = height; + bitInfo.xbytesize = (width+7)/8; + + return; +} + + +/* + * contents : set the bit at specefied coordinate on + */ + +void +bitSet( char *ptn, int cx, int cy ) +{ + if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy)) + return; + ptn[ bitInfo.xbytesize*cy + cx/8 ] |= (char)( 0x80 >> (cx%8) ); +} + + +/* + * contents : set the bit at specefied coordinate off + */ + +void +bitReset( char *ptn, int cx, int cy ) +{ + if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy)) + return; + ptn[ bitInfo.xbytesize*cy + cx/8 ] &= ~(char)( 0x80 >> (cx%8) ); +} + + +/* + * contents : returns 1 ( bit on ) or 0 ( bit off ) + */ + +int +bitRead( char *ptn, int cx, int cy ) +{ + if((cx < 0) || (bitInfo.width <= cx) || (cy < 0) || (bitInfo.height <= cy)) + return( 0 ); + return( ptn[ bitInfo.xbytesize*cy + cx/8 ] + & + (char)( 0x80 >> (cx%8) ) ? 1 : 0 + ); +} + + +/* + * contents : clear the specefied bitmap file + */ + +void +bitPtnClear( char *ptn ) +{ + int i; + + for( i=0 ; i < bitInfo.height * bitInfo.xbytesize ; i++ ) + ptn[i] = 0; +} + + +/* + * contents : copy the bit-mapped file + */ + +void +bitPtnCopy( +char *d_ptn, /* pointer of the destination file */ +char *s_ptn) /* pointer of the source file */ +{ + int i; + + for( i=0 ; i < bitInfo.height * bitInfo.xbytesize ; i++ ) + d_ptn[i] = s_ptn[i]; +} + + + +/************************************************************************ + * handle bit map file(2) * + * caution : You must call bitSetInfo() before use these functions. * + * * + ************************************************************************/ + +/* + * contents : draw lines between desired two points + * values : 0 : terminated normally + * -1 : outside of the edtting pane + */ + +int +bitDrawLine( +char *ptn, /* pointer of the bit map file */ +int x1, +int y1, +int x2, +int y2, +int mode) /* 0: erase 1: draw */ +{ + float dx, dy; + float x, y; + float delta; + int i; + + if( (x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) || + (bitInfo.width <= x1) || (bitInfo.width <= x2) || + (bitInfo.height <= y1) || (bitInfo.height <= y2) ) + return( -1 ); + + dx = x2 - x1; + dy = y2 - y1; + x = x1 + 0.5; + y = y1 + 0.5; + + delta = abs((int)dx) > abs((int)dy) ? dx : dy; + if( delta < 0 ) + delta = -delta; + if( delta == 0) + delta = 0.75; + dx /= delta; + dy /= delta; + + for(i=0 ; i <= (int)delta ; i++ ) { + mode == 0 ? bitReset(ptn,(int)x,(int)y) : bitSet(ptn,(int)x,(int)y); + x += dx; + y += dy; + } + return( 0 ); +} + + +/* + * contents : draw circle + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawCircle( +char *ptn, +int x1, +int y1, +int x2, +int y2, +int mode) +{ + int dx, dy; + int i,x; + double rad, half; + + if( (x1 < 0) || (y1 < 0) || (x2 < 0.0) || ( y2 < 0.0) ) { + return( -1 ); + } + + dx = abs(x2 - x1); + dy = abs(y2 - y1); + rad = sqrt((double)(dx * dx + dy * dy)) + 0.5; + half = rad * sqrt(2.0)/2; + for (i = 0; i <= (int)half; i++) { + x = (int)sqrt(rad * rad - (double)(i*i)); + if( mode ) { + bitSet (ptn, x1 - x, y1 - i); + bitSet (ptn, x1 - x, y1 + i); + bitSet (ptn, x1 + x, y1 - i); + bitSet (ptn, x1 + x, y1 + i); + bitSet (ptn, x1 - i, y1 - x); + bitSet (ptn, x1 - i, y1 + x); + bitSet (ptn, x1 + i, y1 - x); + bitSet (ptn, x1 + i, y1 + x); + } else { + bitReset(ptn, x1 - x, y1 - i); + bitReset(ptn, x1 - x, y1 + i); + bitReset(ptn, x1 + x, y1 - i); + bitReset(ptn, x1 + x, y1 + i); + bitReset(ptn, x1 - i, y1 - x); + bitReset(ptn, x1 - i, y1 + x); + bitReset(ptn, x1 + i, y1 - x); + bitReset(ptn, x1 + i, y1 + x); + } + } + return( 0 ); +} + + +/* + * contents : draw rectangle + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawRect( +char *ptn, +int x, +int y, +int width, +int height, +int mode) +{ + int i; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( i=x ; i <= width+x ; i++ ) { + if( mode == 0 ) { + bitReset( ptn, i, y ); + bitReset( ptn, i, height+y ); + } + else { + bitSet( ptn, i, y ); + bitSet( ptn, i, height+y ); + } + } + for( i=y+1 ; i < height +y ; i++ ) { + if( mode == 0 ) { + bitReset( ptn, x, i ); + bitReset( ptn, x+width, i ); + } + else { + bitSet( ptn, x, i ); + bitSet( ptn, x +width, i ); + } + } + + return( 0 ); +} + + +/* + * contents : clear the inside of the specefied rectangle + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawCls( +char *ptn, +int x, +int y, +int width, +int height) +{ + int i, j; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( i=x ; i <= width +x ; i++ ) { + for( j=y ; j <= height +y ; j++ ) + bitReset( ptn, i, j ); + } + + return( 0 ); +} + + +/* + * contents : paint out the inside of the desired rectangle + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawSet( +char *ptn, +int x, +int y, +int width, +int height) +{ + int i, j; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( i=x ; i <= width +x ; i++ ) { + for( j=y ; j <= height +y ; j++ ) + bitSet( ptn, i, j ); + } + return(0); +} + + +/* + * contents : reverse the inside of the desired rectangle + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawRev( +char *ptn, +int x, +int y, +int width, +int height) +{ + int i, j; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( i=x ; i <= width +x ; i++ ) { + for( j=y ; j <= height +y ; j++ ) { + if( bitRead( ptn, i, j ) == 0 ) + bitSet ( ptn, i, j ); + else + bitReset( ptn, i, j ); + } + } + + return( 0 ); +} + + +static char cut_buffer[MAXPTNBYTE]; +static int cut_buffer_w=0; +static int cut_buffer_h=0; +/* + * contents : copy the specified rectangle area + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawCpy( +char *ptn, +int sx, +int sy, +int width, +int height, +int cut_flag) +{ + int i, j; + + if ((sx < 0) || (sy < 0) || (width < 2) || (height < 2) || + (bitInfo.width < width +sx) || (bitInfo.height < height +sy)) + return( -1 ); + + cut_buffer_w = width; + cut_buffer_h = height; + + for (i=0; i < width; i++) { + for (j=0; j < height; j++) { + if (bitRead(ptn, i + sx, j + sy) != 0) + bitSet(cut_buffer, i, j); + else + bitReset(cut_buffer, i, j); + if (cut_flag) + bitReset(ptn, i + sx, j + sy); + } + } + return( 0 ); +} + +int +bitDrawPaste(char *ptn, int dx, int dy) +{ + int i, j; + int width, height; + + if((dx < 0) || (dy < 0) || (cut_buffer == 0) || + (cut_buffer_w == 0) || (cut_buffer_h == 0)) + return( -1 ); + + width = (cut_buffer_w <= bitInfo.width - dx) + ? cut_buffer_w : bitInfo.width - dx; + height = (cut_buffer_h <= bitInfo.height - dy) + ? cut_buffer_h : bitInfo.height - dy; + + for (i=0; i < width; i++) { + for (j=0; j < height; j++) { + if( bitRead(cut_buffer, i, j) != 0 ) + bitSet (ptn, i + dx, j + dy); + else + bitReset(ptn, i + dx, j + dy); + } + } + return( 0 ); +} + + + +/* + * contents : rotate the inside of the area specified + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawRoll(char *ptn, int x, int y, int width, int height) +{ + char *point; + int xx, yy; + int count; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width < width +x) || (bitInfo.height < height +y) ) + return( -1 ); + + point = (char *)malloc((width * height) * sizeof(int)); + + for(count=0,yy=0; yy < height; yy++) { + for(xx=0; xx < width; xx++ ) { + point[count++] = bitRead(ptn, x + xx, y + yy); + bitReset(ptn, x + xx, y + yy); + } + } + + for(count=0,yy=0; yy < height; yy++) { + for(xx=0; xx < width; xx++ ) { + point[count++] == 0 ? bitReset(ptn, x + height - yy - 1, y + xx) + : bitSet(ptn, x + height - yy - 1, y + xx); + } + } + + free(point); + return( 0 ); +} + + +/* + * contents : reverse the top-bottom symmetry of the rectangle specified + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawSymV( char *ptn, int x, int y, int width, int height ) +{ + int k, j; + int d1, d2; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( k=0 ; k <= width ; k++ ) { + for( j=0 ; j <(height+1)/2 ; j++ ) { + d1 = bitRead( ptn, x +k, y +j ); + d2 = bitRead( ptn, x +k, y + height -j ); + + d1 == 0 ? bitReset( ptn, x +k, y +height -j ) + : bitSet( ptn, x +k, y +height -j ); + d2 == 0 ? bitReset( ptn, x +k, y +j ) + : bitSet( ptn, x +k, y +j ); + } + } + return( 0 ); +} + + +/* + * contents : reverse the left-right symmetry of the rectangle specified + * values : 0 : terminated normally + * -1 : terminated abnormally + */ + +int +bitDrawSymH( char *ptn, int x, int y, int width, int height ) +{ + int k, j; + int d1, d2; + + width --; + height --; + + if( (x < 0) || (y < 0) || (width < 0) || (height < 0) || + (bitInfo.width <= width +x) || (bitInfo.height <= height +y) ) + return( -1 ); + + for( k=0 ; k < (width+1)/2 ; k++ ) { + for( j=0 ; j <= height ; j++ ) { + d1 = bitRead( ptn, x +k, y +j ); + d2 = bitRead( ptn, x +width -k, y +j ); + + d1 == 0 ? bitReset( ptn, x +width -k, y +j ) + : bitSet( ptn, x +width -k, y +j ); + d2 == 0 ? bitReset( ptn, x +k, y +j ) + : bitSet( ptn, x +k, y +j ); + } + } + return( 0 ); +} + + +static char * +char_set(char *str) +{ + int i, count; + char *p; + for (i=strlen(str),p=&(str[i]),count=0; i && count < 2; i--,p--) { + if (*p == '-') + count ++; + } + if (count == 2) + return(p + 2); + else + return(str); +} + + +/**************************************************************** + * read and write SNF file * + * * + * * + ****************************************************************/ + +/* + * contents : read character patterns from specified SNF file + * values : number of the area that was allocated to manage font file + * -1 : terminated abnormally + * -2 : file is locked + */ +int +readSNF(FalFontData **fdata, int *width, int *height, char *err) +{ + FalFontinfo finfo; + int start, end; + int code; + int mask; + int i; + char *ptn; + static FalFontDataList *fulllist; + char *mes; + + FalGlyphRegion *gr, *gr_p; + int num_gr; + char tmp[16]; + unsigned int s, e; + + + if (fulllist) { + FalFreeFontList(fulllist); + fulllist = NULL; + } + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_UPDATE | + FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + if (fullFontData.cd_set != -1) { + mask |= FAL_FONT_MASK_CODE_SET; + } + if (! CodePoint) { + mask |= FAL_FONT_MASK_GLYPH_INDEX; + } + if (FalGetFontList(&fullFontData, mask, &fulllist) == FAL_ERROR) { + strcpy(err, FAL_ERROR_STR); + return(-1); + } + if(fulllist == NULL) { + strcpy(err, resource.mn_no_font); + return(-1); + } + if (fulllist->num != 1) { + FalFreeFontList(fulllist); + fulllist = NULL; + strcpy(err, resource.mn_plural_font); + return(-1); + } + *fdata = &(fulllist->list[0]); + font_id = FalOpenSysFont(&fullFontData, mask, &fulllist); + mes = 0; + if (font_id == 0 && (fal_utyerrno & 0xff) == FAL_ERR_FNT_OPN) { + mes = (char *) malloc(strlen(resource.mn_no_perm)+strlen(fal_err_file)+10); + if (mes == NULL) { + strcpy(err, resource.mn_no_mem); + FalFreeFontList(fulllist); + return( -1 ); + } + sprintf(mes, "%sfile: %s", resource.mn_no_perm, fal_err_file); + + mask &= ~FAL_FONT_MASK_UPDATE; + font_id = FalOpenSysFont(&fullFontData, mask, &fulllist); + if (font_id == 0) { + free(mes); + strcpy(err, FAL_ERROR_STR); + FalFreeFontList(fulllist); + return( -1 ); + } + } else if (font_id == 0) { + strcpy(err, FAL_ERROR_STR); + FalFreeFontList(fulllist); + return( -1 ); + } + if (fullpath != NULL) + FalFree(fullpath); + if (FalFontIDToFileName(font_id, &fullpath) == FAL_ERROR) { + strcpy(err, FAL_ERROR_STR); + if (mes) + free(mes); + return( -1 ); + } + + if( FalQueryFont( font_id, &finfo ) == FAL_ERROR ) { + strcpy(err, FAL_ERROR_STR); + FalCloseFont( font_id ); + if (mes) + free(mes); + return( -1 ); + } + *width = finfo.width; + *height = finfo.height; + + fullFontData.cd_set = (* fdata)->cd_set; + if (CodePoint) { + if (FalGetUDCCPArea(get_locale(),(* fdata)->cd_set, + char_set(( *fdata)->xlfdname), (FalCodeRegion **) &gr, &num_gr) == FAL_ERROR) { + strcpy(err, FAL_ERROR_STR); + FalCloseFont( font_id ); + if (mes) + free(mes); + return( -1 ); + } + } else { + if (FalGetUDCGIArea(get_locale(),(* fdata)->cd_set, + char_set(( *fdata)->xlfdname), &gr, &num_gr) == FAL_ERROR) { + strcpy(err, FAL_ERROR_STR); + FalCloseFont( font_id ); + if (mes) + free(mes); + return( -1 ); + } + } + if (! num_gr) { + FalCloseFont( font_id ); + strcpy(err, resource.mn_not_udc); + if (mes) + free(mes); + return( -1 ); + } + if (mes) { + Error_message2(NULL, mes); + free(mes); + fullFontData.prm = True; + } + start = gr->start; + end = gr->end; + for (i=0, gr_p=gr; i < num_gr; i++, gr_p++) { + CodeArea[i].start = gr_p->start; + CodeArea[i].end = gr_p->end; + s = (gr_p->start & 0xff00) >> 8; + e = (gr_p->end & 0xff00) >> 8; + if (i == 0) { + sprintf(tmp, "0x%x:0x%x", s, e); + strcpy(AreaStr, tmp); + } else { + sprintf(tmp, ",0x%x:0x%x", s, e); + strcat(AreaStr, tmp); + } + if (start > gr_p->start) + start = gr_p->start; + if (end < gr_p->end) + end = gr_p->end; + } + CodeArea[i].start = -1; + begin_code = start; + last_code = end; + + if (start > end) { + FalCloseFont( font_id ); + sprintf(err, "%s\nStart address = %x End address = %x\n", resource.mn_illegal_area, start, end); + return( -1 ); + } + + if( ptnOpen(1, end - start + 1, finfo.width, finfo.height) < 0 ) { + FalCloseFont( font_id ); + strcpy(err, resource.mn_no_mem); + return( -1 ); + } + bitSetInfo( finfo.width, finfo.height ); + + for (i=0, gr_p=gr; i < num_gr; i++, gr_p++) { + if (start > gr_p->start) + gr_p->start = start; + if (end < gr_p->end) + gr_p->end = end; + start = gr_p->end; + + if (! CodePoint) { + for (code=gr_p->start; code <= gr_p->end; code++) { + if (code & 0x80) { + code &= 0xff00; + code += 0x100; + continue; + } + + ptn = (char *)FalReadFont( font_id, code, finfo.width, finfo.height ); + if( ptn == (char *)FAL_ERROR ) { + strcpy(err, FAL_ERROR_STR); + FalFree(gr); + FalCloseFont( font_id ); + + ptnClose(); + return( -1 ); + } + if( EXISTS_FLAG == 0 ) { + if( ptnAdd( code, ptn ) != 1 ) { + FalFree(gr); + strcpy(err, resource.mn_no_read); + FalCloseFont( font_id ); + + ptnClose(); + return( -1 ); + } + } + } + } else { + for (code=gr_p->start; code <= gr_p->end; code++) { + if (! (code & 0x80)) { + code &= 0xff00; + code |= 0x80; + continue; + } + + ptn = (char *)FalReadFont( font_id, code, finfo.width, finfo.height ); + if( ptn == (char *)FAL_ERROR ) { + strcpy(err, FAL_ERROR_STR); + FalFree(gr); + FalCloseFont( font_id ); + + ptnClose(); + return( -1 ); + } + if( EXISTS_FLAG == 0 ) { + if( ptnAdd( code, ptn ) != 1 ) { + FalFree(gr); + strcpy(err, resource.mn_no_read); + FalCloseFont( font_id ); + + ptnClose(); + return( -1 ); + } + } + } + } + } + FalFree(gr); + *err = 0; + return( 0 ); +} + +static void +bicopy(char *s1, char *s2, int size) +{ + int i; + for(i=size; i; i--, s1++, s2++) + *s2 = *s1; +} + +int +copySNF(int start, int end, char ***ptn, int *num, char *err) +{ + FalFontID fid; + int mask; + char ** _ptn, **p; + int i; + static FalFontDataList *copylist; + int count; + char *point; + int size; + + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED; + if (copyFontData.cd_set != -1) { + mask |= FAL_FONT_MASK_CODE_SET; + } + if (! CodePoint) { + mask |= FAL_FONT_MASK_GLYPH_INDEX; + } + + fid = FalOpenSysFont(©FontData, mask, ©list); + if (fid == 0) { + strcpy(err, FAL_ERROR_STR); + FalFreeFontList(copylist); + return( -1 ); + } + + _ptn = (char **)malloc(sizeof(char *) * (end - start + 1)); + if (! CodePoint) { + for (i = start, count = 0, p = _ptn; i <= end; i++) { + if (i & 0x80) { + i &= 0xff00; + i += 0x100; + continue; + } + point = (char *)FalReadFont( fid, i, pm.width, pm.height ); + if( point == (char *)FAL_ERROR ) { + strcpy(err, FAL_ERROR_STR); + FalCloseFont( fid ); + return( -1 ); + } + if (EXISTS_FLAG != 0) + continue; + size = pm.height * ((pm.width+7)/8); + *p = (char *) XtMalloc(size); + bicopy(point, *p, size); + count++; p++; + } + } else { + for (i = start, count = 0, p = _ptn; i <= end; i++) { + if (! (i & 0x80)) { + i &= 0xff00; + i |= 0x80; + continue; + } + point = (char *)FalReadFont( fid, i, pm.width, pm.height ); + if( point == (char *)FAL_ERROR ) { + strcpy(err, FAL_ERROR_STR); + FalCloseFont( fid ); + return( -1 ); + } + if (EXISTS_FLAG != 0) + continue; + size = pm.height * ((pm.width+7)/8); + *p = (char *) XtMalloc(size); + bicopy(point, *p, size); + count++; p++; + } + } + *num = count; + *ptn = _ptn; + FalCloseFont( fid ); + if (count == 0) { + strcpy(err, resource.mg_non_code); + return( -1 ); + } + return( 0 ); +} + +void +freeSNF(char **addr, int count) +{ + char **p; + for (p=addr; count; count--, p++) + XtFree(*p); + XtFree((char *)addr); +} + +static int sig_flg = 0; /* flag for signal */ + +/* + * contents : write character patterns to the specified SNF file + * values : 0 : terminated normally + * -1 : terminated abnormally + * 1xxx : process is not completed ¡Êxxx:persents finished¡Ë + * + * + */ + +int +writeSNF( +int restart, /* ON:continue OFF:initial */ +int *err) /* errors : */ +{ + static int pfstdi[2]; + static FILE *fstdi; + static int nptn; + static int width, height; + static int n; + static int persents = 0; + char *argv[8]; + int code; + int endst; + int persents_; + + char ptn[MAXPTNBYTE]; + char code_set[2]; + + FalGIInf *gi; + int num_gi; + + char *command; + + /* get command path */ + if (!(command = (char *)get_cmd_path(getenv("PATH"), resource.l_ptog_cmd))){ + command = resource.l_ptog; + } + + if (fullFontData.cd_set == FAL_FONT_CS0) + sprintf(code_set, "0"); + else if (fullFontData.cd_set == FAL_FONT_CS1) + sprintf(code_set, "1"); + else if (fullFontData.cd_set == FAL_FONT_CS2) + sprintf(code_set, "2"); + else if (fullFontData.cd_set == FAL_FONT_CS3) + sprintf(code_set, "3"); + + /* signal set */ + signal( SIGPIPE, sig_receive ); + sig_flg = 0; + + if( restart == 0 ) { + + persents = 0; + + if( ptnGetInfo( &nptn, &width, &height ) != 0 ) { + *err = 100; + return( -1 ); + } + + if( pipe(pfstdi) !=0 ) { + *err = 101; + return( -1 ); + } + + switch( fork() ) { + case -1: + close( pfstdi[0] ); + close( pfstdi[1] ); + *err = 102; + return( -1 ); + case 0: + close( 0 ); /** 0 ... stdin **/ + + if( dup( pfstdi[0] ) == -1){ + return -1; + } else { + close( pfstdi[0] ); + close( pfstdi[1] ); + argv[0] = resource.l_ptog_cmd; + argv[1] = "-codeset"; + argv[2] = code_set; + argv[3] = "-xlfd"; + argv[4] = fullFontData.xlfdname; + argv[5] = "-init"; + argv[6] = "-f"; + argv[7] = NULL; + execv (command, argv ); + exit( 103 ); + } + } + + + close( pfstdi[0] ); + fstdi = (FILE *)fdopen( pfstdi[1], "w" ); + fprintf( fstdi, "numfonts:%d\n", nptn ); + fprintf( fstdi, "width:%d\n", width ); + fprintf( fstdi, "height:%d\n", height ); + + bitSetInfo( width, height ); + n = 0; + } + + while( (n < nptn) && ( sig_flg == 0) ) { + code = noToCode( ptnSqToNo(n) ); + if( ptnGet(code, ptn ) != 0 ) { + fclose( fstdi ); + close( pfstdi[1] ); + *err = 104; + return( -1 ); + } + + if (CodePoint) { + fal_code_to_glyph(get_locale(), code, &gi, &num_gi); + fprintf( fstdi, "code:0x%x\n", gi[0].glyph_index ); + FalFreeGI(gi, num_gi); + } else { + fprintf( fstdi, "code:0x%x\n", code ); + } + writePtn(ptn, width, height, fstdi); + + n++; + if ( sig_flg != 0 ) + break; + if( n == nptn ) { + persents = 0; + return( 1101 ); + } + if( (persents_ = (n*100)/nptn) != persents ) { + persents = persents_; + return( 1000 + persents ); + } + } + + if(sig_flg == 0 ) fprintf( fstdi, "enddata\n" ); + + fclose( fstdi ); + close( pfstdi[1] ); + + wait( &endst ); + + + if ( WIFEXITED(endst) && !WEXITSTATUS(endst) ) { + *err = 0; + return( 0 ); + } + else { + if ( WIFEXITED(endst) ) + *err = WEXITSTATUS(endst); + else{ + if ( WIFSTOPPED(endst) ) + *err = ( WTERMSIG(endst) << 8 ); + } + return( -1 ); + } +} + + +/* + * contents : set flag when dtudcfonted received signal + */ + +static void +sig_receive(void) +{ + sig_flg = 1; + return; +} + + +/* + * contents : convert bit map file into SNF file + */ + +static void +writePtn(char *ptn, int width, int height, FILE *fp) +{ + int i, j, k; + int nbyte; + int tw; + char p, *pbuf; + static char buf[ (MAXPTNSIZE+1)*MAXPTNSIZE+1 ]; + + nbyte = (width + 7) / 8; + + pbuf = buf; + for (i=0 ; i < height ; i++) { + for (j=0, tw=width ; j < nbyte ; j++ ) { + p = *ptn++; + for ( k=0 ; (k < 8) && (tw > 0) ; k++, tw--) { + if (p & 0x80) + *pbuf++ = '0'; + else + *pbuf++ = '-'; + p = p << 1; + } + } + *pbuf++ = '\n'; + } + *pbuf = '\0'; + fprintf(fp, "%s", buf); +} diff --git a/cde/programs/dtudcfonted/cpyw.c b/cde/programs/dtudcfonted/cpyw.c new file mode 100644 index 000000000..b028be32e --- /dev/null +++ b/cde/programs/dtudcfonted/cpyw.c @@ -0,0 +1,605 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* cpyw.c 1.9 - Fujitsu source for CDEnext 96/10/30 13:31:40 */ +/* $XConsortium: cpyw.c /main/7 1996/11/08 01:53:38 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + +#include <stdio.h> + +#include <X11/Intrinsic.h> + +#include "xoakufont.h" +#include "util.h" + + +extern Resource resource ; +extern Widget cpyDialog; + +/** + ** create and display the "User defined character ecitor :Copy" window + ** ================================================================== + **/ + +void PopdownCpyPtn(void); +void DoCpyProc(void); +void CpyPtnCB(void); +void CpyCB(Widget w, XtPointer cdata); + +/* static */ TextField SrcTf; +/* static */ TextField DestTf; + + +/** + ** contents : initialize the "Copy" window + ** -------------------- + ** + ** + **/ + +void +InitCpyPtn(void) +{ + /* initialize font infomation */ +} + + +/** + ** contents : create and pop up the "Copy" window + ** ---------------------------------- + ** + **/ + +void +CpyPtnCB(void) +{ + extern void CpyPtnXLFD(); + CpyPtnXLFD(); +} + + +/** + ** contents : pop down the "Copy" window + ** ---------------------- + **/ + +void +PopdownCpyPtn(void) +{ + ForcePopdownDialog(cpyDialog); +} + + +/** contents : + ** get the character strings of source code area from the input field + ** -------------------------------------- + **/ + +String +CpySrcCodeTfValue(void) +{ + return(GetTextFieldValue(&SrcTf)); +} + + +/** contents : + ** get the character strings of destination code area from input field + ** -------------------------------------- + **/ + +String +CpyDestCodeTfValue(void) +{ + return(GetTextFieldValue(&DestTf)); +} + + +/** + ** contents : pop up the copy confirmation window + ** -------------------------------- + **/ + +void +PopupCpyNotice( String message ) +{ + char bmsg[512] = ""; + + static NoticeButton buttons[] = { + NBTNARGS( DoCpyProc, NULL, NULL, True, False ), + NBTNARGS( NULL, NULL, NULL, True, False ), + }; + static NButton BTN = NBUTTONS( buttons ); + + snprintf(bmsg, sizeof(bmsg), "%s%s", resource.mn_cpy_lost, message); + SetItemLabel(&BTN, 0, resource.l_ok); + SetItemLabel(&BTN, 1, resource.l_cancel); + PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title); +} + + +/** + ** contents : "Copy" button callback + ** ------------------------ + ** execute the copy processing + **/ + +/*ARGSUSED*/ +void +CpyCB(Widget w, XtPointer cdata) +{ + extern Boolean BeforeCpyCheck(); + if (BeforeCpyCheck(cdata)){ + PopdownCpyPtn(); + DoCpyProc(); + } +} + + + +/** + ** "Add/Delete" window + ** =================================================================== + **/ + +/** + ** contents : pop down the "Add/Delete" window + ** ------------------------------ + **/ + +static void +PopdownMngPtn(void) +{ + PopdownDialog(mngPtnW); +} + +/** + ** contents : "Add" button callback + ** ------------------------ + **/ + +static void +AddCB(void) +{ + int s_code, e_code; + extern Boolean BeforeMngCheck(); + extern void DoAddProc(); + + if (BeforeMngCheck(&s_code, &e_code)){ + DoAddProc(s_code, e_code); + PopdownMngPtn(); + } +} + +/** + ** contents : "Delete" button callback + ** ------------------------ + **/ + +static void +DelCB(void) +{ + int s_code, e_code; + extern void DoDelProc(); + extern Boolean BeforeMngCheck(); + + if (BeforeMngCheck(&s_code, &e_code)){ + DoDelProc(s_code, e_code); + } +} + +static ButtonItems add_btn[] = { + BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) AddCB, NULL, NULL, True, True ), + BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelCB, NULL, NULL, True, False ), + BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) PopdownMngPtn, NULL, NULL, True, False ), +}; +static Button AddBTN = BUTTONS( add_btn ); + +static TextField MngCodeTf; + +/** + ** contents : create and pop up the "Add/Delete" window + ** ------------------------------------ + **/ + +void +MngPtnCB(void) +{ + if (! mngPtnW){ + Widget rowcol; + + SetItemLabel(&AddBTN, 0, resource.l_add); + SetItemLabel(&AddBTN, 1, resource.l_delete); + SetItemLabel(&AddBTN, 2, resource.l_cancel); + rowcol = + CreateDialogAndButtons( toplevel, resource.l_add_title, + + NULL, &AddBTN, XtNumber(add_btn), &mngPtnW); + + CreateTextField(rowcol, "wgkTxtF", + resource.l_manage_code, &MngCodeTf, 4); + } + PopupDialog(mngPtnW); +} + + + + +/** + ** contents : get the character strings of code for add or delete from the + ** input field + ** -------------------------------------------- + **/ + +String +MngCodeTfValue(void) +{ + return(GetTextFieldValue(&MngCodeTf)); +} + + + +/** + ** the delete confirmation window + ** =================================================================== + **/ + +static Widget CreateDelNotice(); +static void drawDelPtn(); +static void drawDelCode(); +static void CBdnOblB_del(); +static void EHdnBulB_disp(); +void EHStaT_disp(); /* add 1995.09.20 */ + +static Widget dnStaT_code[D_MAX], dnBulB_disp[D_MAX], dnPopW; + +/** + ** contents : pop up the delete confirmation window + ** -------------------------- + **/ + +void +PopupDelNotice( Widget owner ) +{ + int i; + Widget delNoticeW = NULL; + + delNoticeW = CreateDelNotice(owner); + XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, False, NULL); + XtManageChild(delNoticeW); + + for ( i=0 ; i < dn.disp_num ; i++ ) { + /* moved from paneDelNotice body */ + dl[i].disp_winID = XtWindow( dnBulB_disp[i] ); + + drawDelCode(i); + drawDelPtn(i); + } + XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, True, NULL); + + XBell(XtDisplayOfObject(delNoticeW), 0); +} + + +/** + ** contents : clear the image of deleted character + ** ---------------------------------------------- + **/ + +static void +dstrypaneDelNotice(void) +{ + int i; + + for ( i=0; i<dn.disp_num; i++ ){ + XFree((char *) dl[i].dispImage); + } +} + + +/** + ** contents : "OK" button callback + ** ---------------------------- + **/ + +static void +DelOkCB(void) +{ + CBdnOblB_del(); + PopdownMngPtn(); +} + + +/** + ** contents : callback of the delete list + ** ------------------------------------ + **/ + +static void +delScProc( int value ) +{ + int i; + extern int RelToAbsSq(); + + dn.sq_top = RelToAbsSq( dn.sq_start, value - dn.sq_start); + for ( i=0 ; i < dn.disp_num ; i++ ) { + drawDelCode(i); + drawDelPtn(i); + } +} + + +/** + ** contents : create the delete confirmation window + ** -------------------------- + **/ + +static Widget +CreateDelNotice(Widget owner) +{ + Widget form, listBase, itemform[D_MAX]; + char buf[64]; + int i, val, min, max; + int c ; + extern int AbsSqToRel(); + extern void AddDestroyProc(); + + static NoticeButton buttons[] = { + NBTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelOkCB, NULL, NULL, True, False ), + NBTNARGS( NULL, NULL, NULL, True, False ), + }; + static NButton BTN = NBUTTONS( buttons ); + c = AbsSqToRel( dn.sq_start, dn.sq_end) + 1; + if (c == 1) { + sprintf(buf, "%s(%d %s)", resource.mg_start_del_s, + c, resource.mg_start_del_cs ); + } else { + sprintf(buf, "%s(%d %s)", resource.mg_start_del_m, + c, resource.mg_start_del_cm ); + } + SetItemLabel(&BTN, 0, resource.l_ok); + SetItemLabel(&BTN, 1, resource.l_cancel); + form = CreateTemplateDialog( owner, buf, D_QUESTION, &BTN, + resource.l_question_title, &dnPopW); + AddDestroyProc(dnPopW, dstrypaneDelNotice); + + if ( dn.disp_num < (AbsSqToRel( dn.sq_start, dn.sq_end) + 1)) { + + val = AbsSqToRel( dn.sq_start, dn.sq_top) + dn.sq_start; + min = dn.sq_start; + max = AbsSqToRel( dn.sq_start, dn.sq_end) + dn.sq_start +1; + listBase = CreateScrollBase( form, "listBase", + min, max, val, dn.disp_num, delScProc ); + } + else{ + listBase = + CreateRowColumn( form, "listBase", L_VERTICAL, 4,2,2 ); + } + + for(i=0; i<dn.disp_num; i++) { + /* create form for the codes and fonts to be deleted */ + itemform[i] = CreateForm( listBase, "listBase" ); + + /* create widgets for the codes to be deleted in the list */ + dnStaT_code[i] = CreateLabel( itemform[i], "label", " " ); + AddTopAttachForm( dnStaT_code[i], 0 ); + AddLeftAttachForm( dnStaT_code[i], 0 ); + AddBottomAttachForm( dnStaT_code[i], 0 ); + + /* create widgets for the image of the codes to be deleted in the list */ + dnBulB_disp[i] = CreateDrawingArea( itemform[i], "image", + edg.width, edg.height, EHdnBulB_disp, i); + AddLeftAttachWidget( dnBulB_disp[i], dnStaT_code[i], 0 ); + + /* */ + dl[i].dispImage = XCreateImage( xl.display, + DefaultVisual( xl.display, DefaultScreen(xl.display) ), + 1, XYBitmap, 0, dl[i].ptn, dn.ptn_w, dn.ptn_h, 8, 0); + dl[i].dispImage->bitmap_bit_order = MSBFirst; + dl[i].dispImage->byte_order = MSBFirst; + + } + XtManageChildren( itemform, dn.disp_num ); + return(dnPopW); +} + + +/** + ** contents : delete characters from editor + ** ----------------------------------------- + ** + **/ + +static void +CBdnOblB_del(void) +{ + int code; /* code number for check */ + int ncode; /* sequential number in the codeset system area */ + int sq_now; /* sequential number in the editor */ + char mode; /* notify the modification of the edit list */ + extern void chgEdCode(); + + XtSetSensitive( dnPopW, FALSE ); + mode = OFF; + for( sq_now=dn.sq_end ; sq_now >= dn.sq_start ; sq_now-- ) { + ncode = ptnSqToNo(sq_now); + if ( codeCheck( noToCode(ncode))) + continue; + if (ptnSense( noToCode(ncode) ) == 1) { + ptnDel( noToCode(ncode) ); + edlist.nptn--; + edg.flag = ON; + mode = ON; + } + } + + /* update the current character */ + + sq_now++; + for ( ; sq_now < (edlist.sqstart + edlist.nptn); sq_now++) { + ncode = ptnSqToNo(sq_now); + if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0)) + break; + } + if(sq_now > (edlist.sqstart + edlist.nptn -1)) { + sq_now--; + for ( ; sq_now >= edlist.sqstart; sq_now--) { + ncode = ptnSqToNo(sq_now); + if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0)) + break; + } + } + + /* check the existence of the current character */ + if( (sq_now != -1) && ((ncode = ptnSqToNo(sq_now)) != -1) ){ + code = noToCode( ncode ); + } else { + /* There is no characters on the editor, dtudcfonted does not + * display any character on the editing pane and forbid users + * to input. + * It can realize to put 0 to the first parameter of chgEdCode(). + */ + code = 0; + } + if(codeCheck( code )) { + code = 0; + } + + /* */ + if( ptnSense( edg.code ) == 1 ) { + ptnAdd( edg.code, edg.ptn ); + } + + /* renew the current character */ + if (mode == ON) { + chgEdCode( code, mode ); + } + XtSetSensitive( dnPopW, TRUE ); +} + + +/** + ** contents : display the image of the character to be deleted + ** ------------------------ + ** + **/ + +static void +drawDelPtn( int i /* window number */) +{ + if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) { + ptnGet( noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))), + dl[i].ptn ); + XPutImage(xl.display, dl[i].disp_winID, xl.borderGC, + dl[i].dispImage, 0,0,0,0, dn.ptn_w, dn.ptn_h ); + } else { + return; + } +} + + +/** + ** contents : display the code of the character to be deleted + ** ---------------------- + ** + **/ + +static void +drawDelCode( int i /* window number */) +{ + char str[20]; + + if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) { + sprintf(str, "%4x ", noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i)))); + SetLabelString(dnStaT_code[i], str); + } else { + return; + } +} + + +/** + ** contents : re-display the code of the character to be deleted + ** -------------------------------------------------------------- + **/ + +/*ARGSUSED*/ +static void +EHdnBulB_disp( Widget widget, int i /* widget that have some ivent */ ) +{ + drawDelPtn( i ); +} + + + +/** + ** notify error message + ** =================================================================== + ** + **/ + +/** + ** contents : inner functions of DispMngErrorMessage() + ** ---------------------------------- + **/ + +static void +DispErrorMessage( Widget owner, String title, String msg ) +{ + static NoticeButton buttons[] = { + NBTNARGS( NULL, NULL, NULL, True, False ), + }; + static NButton BTN = NBUTTONS( buttons ); + + SetItemLabel(&BTN, 0, resource.l_ok); + PopupNotice( owner, msg, D_ERROR, &BTN, False, title ); +} + + +/** + ** contents : display "Add" or "Delete" error + ** -------------------------------- + **/ + +void +DispMngErrorMessage( String msg ) +{ + DispErrorMessage( mngPtnW, resource.l_error_title, msg ); +} + + +/** + ** contents : display "Copy" error + ** -------------------------- + **/ + +void +DispCpyErrorMessage( String msg ) +{ + DispErrorMessage( cpyPtnW, resource.l_error_title, msg ); +} diff --git a/cde/programs/dtudcfonted/cpyx.c b/cde/programs/dtudcfonted/cpyx.c new file mode 100644 index 000000000..0de53a710 --- /dev/null +++ b/cde/programs/dtudcfonted/cpyx.c @@ -0,0 +1,943 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* cpyx.c 1.29 - Fujitsu source for CDEnext 96/10/30 13:13:45 */ +/* $XConsortium: cpyx.c /main/8 1996/11/08 01:52:55 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <nl_types.h> + +#include<X11/Xlib.h> +#include<X11/Xutil.h> +#include<X11/Xatom.h> + +#include <Xm/XmAll.h> + +/* + * There is no public header file for this function (only an + * internal header XmStringI.h). + */ +extern XtPointer _XmStringUngenerate (XmString string, + XmStringTag tag, + XmTextType tag_type, + XmTextType output_type); + +#include "util.h" +#include "selectxlfd.h" +#include "xoakufont.h" + +#include "xpm.h" +#ifdef XPM +#define ReadXpm XpmCreatePixmapFromData +#else +#define ReadXpm _DtXpmCreatePixmapFromData +#endif +#include "pixmaps/arrow.pm" + +static Widget CreateCopyXLFD(Widget Top); +static void CpyXLFDCB(Widget w, caddr_t client_data, caddr_t *call_data); + +extern int CreateOtherLabelAndText(int num, + Widget owner, + Widget baseForm, + Widget *slctBLabel, + Widget topW, + Widget *slctBText, + Widget *slctButton); +extern Widget xlfdCreateScrolledList(Widget owner, + char *name, + Arg *args, + int n); +extern int GetItemsToDisplay(int num, int *itemcnt, XmString **xms_list); + +extern void xlfdPopupDialog(Widget w); + +extern void InitCpyPtn(void); +extern void _unmap(void); +extern void CpyCB(Widget w, XtPointer cdata); +extern void PopdownCpyPtn(void); +extern void AddPopupProc(Widget w, void(*popupcb)()); + +extern FalFontData fullFontData; + +/* + * parameters + */ + +FalFontData copyFontData; + +extern Widget toplevel ; +Widget cpyDialog=NULL; +static Widget codeLabel[COPYLABELS]; +static Widget codeText[COPYLABELS+1]; + +extern TextField SrcTf; +extern TextField DestTf; + +extern char AreaStr[160]; + +/* + * resource database + */ +extern Resource resource ; + +#define CS0 "Codeset 0" +#define CS1 "Codeset 1" +#define CS2 "Codeset 2" +#define CS3 "Codeset 3" + +#define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)] + +static Widget pull1, pull2, pull3, pull4, scrolllist; +static int xlf_count = 0; +static XmString *xlf=NULL; +static int udc_count = 0; +static Boolean udc_flag = False; +static int *udc=NULL; +static int udc_val; +static int sty_count = 0; +static Boolean sty_flag = False; +static char **sty=NULL; +static char *sty_val=NULL; +static int wls_count = 0; +static Boolean wls_flag = False; +static int *wls=NULL; +static int wls_val; +static int hls_count = 0; +static Boolean hls_flag = False; +static int *hls=NULL; +static int hls_val; +static Widget *button1=NULL; +static Widget *button2=NULL; +static Widget *button3=NULL; +static Widget *button4=NULL; +static Widget focus_widget=NULL; + +/**************************************************************** + * callbacks * + ***************************************************************/ + + +/*ARGSUSED*/ +static void +CpyXLFDCB(Widget w, caddr_t client_data, caddr_t *call_data) +{ + char *str; + XmStringTable st; + /* get font file name (str: XLFD name) */ + /* get font file name (str: XLFD name) */ + XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL); + if( st == NULL ){ + copyFontData.xlfdname = NULL; + return ; + } + str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + copyFontData.xlfdname = str; + if(udc_flag == True) + copyFontData.cd_set = udc_val; + else + copyFontData.cd_set = -1; +} + + +void +CpyPtnXLFD(void) +{ + if( cpyDialog == NULL ) + { + CreateCopyXLFD( toplevel ) ; + + /* + * add callbacks + */ + XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)_unmap, NULL); + XtAddCallback(cpyDialog, XmNokCallback, + (XtCallbackProc)CpyXLFDCB, NULL); + XtAddCallback(cpyDialog, XmNokCallback, (XtCallbackProc)CpyCB, NULL); + + XtAddCallback(cpyDialog, XmNcancelCallback, + (XtCallbackProc)_unmap, (XtPointer)1); + XtAddCallback(cpyDialog, XmNcancelCallback, + (XtCallbackProc)CpyXLFDCB, (XtPointer)1); + XtAddCallback(cpyDialog, XmNcancelCallback, + (XtCallbackProc)CpyCB, (XtPointer)1); + XtAddCallback(cpyDialog, XmNhelpCallback, (XtCallbackProc)_unmap, NULL); + XtAddCallback(cpyDialog, XmNhelpCallback, + (XtCallbackProc)PopdownCpyPtn, NULL); + + AddPopupProc( cpyDialog, InitCpyPtn ) ; + + SrcTf.w1 = codeText[0] ; + SrcTf.w2 = codeText[1] ; + DestTf.w1 = codeText[2] ; + DestTf.w2 = NULL; + + } + xlfdPopupDialog( cpyDialog ); +} + + +static void +create_xlfd(void) +{ + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + int i; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + xlf_count = 0; + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + return; + } + xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname); + } + FalFreeFontList(fontlist); +} + +static void +udc_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + udc_flag = False; + } else if(strcmp(moji, CS0) == 0) { + udc_val = FAL_FONT_CS0; + udc_flag = True; + } else if(strcmp(moji, CS1) == 0) { + udc_val = FAL_FONT_CS1; + udc_flag = True; + } else if(strcmp(moji, CS2) == 0) { + udc_val = FAL_FONT_CS2; + udc_flag = True; + } else if(strcmp(moji, CS3) == 0) { + udc_val = FAL_FONT_CS3; + udc_flag = True; + } else { + udc_flag = False; + } + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +sty_call(Widget w) +{ + XmString label; + char *moji; + if (sty_val) { + XtFree(sty_val); + sty_val = NULL; + } + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + sty_flag = False; + } + else { + sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1)); + strcpy(sty_val, moji); + sty_flag = True; + } + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +wls_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + wls_flag = False; + } + else { + wls_val = atoi(moji); + wls_flag = True; + } + XmStringFree(label); + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +hls_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + hls_flag = False; + } + else { + hls_val = atoi(moji); + hls_flag = True; + } + XmStringFree(label); + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +button_set1(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + return; + } + + for (j=0; j<udc_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(udc[j] == f->cd_set) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button1[j], False); + else + XtSetSensitive(button1[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set2(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<sty_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(strcmp(sty[j], f->style.name) == 0) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button2[j], False); + else + XtSetSensitive(button2[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set3(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<wls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(wls[j] == f->size.w) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button3[j], False); + else + XtSetSensitive(button3[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set4(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<hls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(hls[j] == f->size.h) { + found = True; + break; + } + } + if (found == False) + XtSetSensitive(button4[j], False); + else + XtSetSensitive(button4[j], True); + } + FalFreeFontList(fontlist); +} + + +static void +font_init(void) +{ + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + int i, j; + char tmp[16]; + char err[128]; + Widget button; + extern void data_sort(); + extern void Error_message(); + + xlf_count = udc_count = sty_count = wls_count = hls_count = 0; + if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) { + snprintf(err, sizeof(err), "%s", FAL_ERROR_STR); + Error_message((Widget)NULL, err); + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + snprintf(err, sizeof(err), "%s", resource.mn_no_font); + Error_message((Widget)NULL, err); + return; + } + xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num); + udc = (int *)XtMalloc(sizeof(int) * fontlist->num); + sty = (char **)XtMalloc(sizeof(char *) * fontlist->num); + wls = (int *)XtMalloc(sizeof(int) * fontlist->num); + hls = (int *)XtMalloc(sizeof(int) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname); + for (j=0,found=False; j<udc_count; j++) { + if(udc[j] == f->cd_set) { + found=True; + break; + } + } + if (found == False) { + udc[udc_count++] = f->cd_set; + } + for (j=0,found=False; j<sty_count; j++) { + if(strcmp(sty[j], f->style.name) == 0) { + found=True; + break; + } + } + if (found == False) { + sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1)); + strcpy(sty[sty_count++], f->style.name); + } + if (f->size.w != -1) { + for (j=0,found=False; j<wls_count; j++) { + if(wls[j] == f->size.w) { + found=True; + break; + } + } + if (found == False) { + wls[wls_count++] = f->size.w; + } + } + for (j=0,found=False; j<hls_count; j++) { + if(hls[j] == f->size.h) { + found=True; + break; + } + } + if (found == False) { + hls[hls_count++] = f->size.h; + } + } + FalFreeFontList(fontlist); + + data_sort(udc, udc_count); + data_sort(wls, wls_count); + data_sort(hls, hls_count); + + button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count); + button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count); + button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count); + button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count); + + button = XmCreatePushButton(pull1, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + for (i=0; i < udc_count; i++) { + if(udc[i] == FAL_FONT_CS0) + snprintf(tmp, sizeof(tmp), "%s", CS0); + else if(udc[i] == FAL_FONT_CS1) + snprintf(tmp, sizeof(tmp), "%s", CS1); + else if(udc[i] == FAL_FONT_CS2) + snprintf(tmp, sizeof(tmp), "%s", CS2); + else if(udc[i] == FAL_FONT_CS3) + snprintf(tmp, sizeof(tmp), "%s", CS3); + else + snprintf(tmp, sizeof(tmp), "Codeset %x?", udc[i]); + button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0); + XtManageChild(button1[i]); + XtAddCallback(button1[i], XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + } + + button = XmCreatePushButton(pull2, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + for (i=0; i < sty_count; i++) { + button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0); + XtManageChild(button2[i]); + XtAddCallback(button2[i], XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + } + + button = XmCreatePushButton(pull3, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + for (i=0; i < wls_count; i++) { + snprintf(tmp, sizeof(tmp), "%d", wls[i]); + button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0); + XtManageChild(button3[i]); + XtAddCallback(button3[i], XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + } + + button = XmCreatePushButton(pull4, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + for (i=0; i < hls_count; i++) { + snprintf(tmp, sizeof(tmp), "%d", hls[i]); + button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0); + XtManageChild(button4[i]); + XtAddCallback(button4[i], XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + } +} + +/*ARGSUSED*/ +static void +arrow_change(Widget w, Widget wid) +{ + if (XtIsSensitive(wid)) { + XtSetSensitive(wid, False); + } else { + XtSetSensitive(wid, True); + } +} + +static void +focus(Widget w) +{ + focus_widget = w; +} + +static void +code_input(void) +{ + char *str; + XmStringTable st; + extern void CodeWindow(); + XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL); + if( st == NULL ){ + return ; + } + str = _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + CodeWindow(focus_widget, str, True); +} + +static void +code_input2(void) +{ + extern void CodeWindow(); + CodeWindow(codeText[2], fullFontData.xlfdname, False); +} + +static Widget +CreateCopyXLFD( Widget top ) +{ + + int n; + Arg args[16]; + XmString xms, xms1, xms2 ; + Widget frame, row, label1, row1, row2, row3, row4, row5; + Widget sep, cas1, cas2, cas3, cas4; + Widget arrow, code; + XmString str; + extern Pixmap arrow_pix; + Display *disp; + Window root; + Pixmap mask; + XpmAttributes attr; + + udc_flag = sty_flag = wls_flag = hls_flag = False; + + /* + * create base window + */ + n = 0 ; + XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ; + xms = XmStringCreateLocalized( resource.l_copy ) ; + XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ; + xms1 = XmStringCreateLocalized( resource.l_overlay ) ; + XtSetArg( args[n], XmNcancelLabelString, xms1 ) ; n++ ; + xms2 = XmStringCreateLocalized( resource.quit_label) ; + XtSetArg( args[n], XmNhelpLabelString, xms2 ) ; n++ ; + XtSetArg( args[n], XmNnoResize, True ) ; n++ ; + XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ; + XtSetArg( args[n], XmNtitle, resource.l_copy_title) ; n++ ; + cpyDialog = XmCreateTemplateDialog( top, "copy_dialog", args, n ); + + XmStringFree( xms ) ; + XmStringFree( xms1 ) ; + XmStringFree( xms2 ) ; + + n = 0; + pull1 = XmCreatePulldownMenu(top, "pull", args, n); + pull2 = XmCreatePulldownMenu(top, "pull", args, n); + pull3 = XmCreatePulldownMenu(top, "pull", args, n); + pull4 = XmCreatePulldownMenu(top, "pull", args, n); + + n = 0 ; + row = XmCreateRowColumn( cpyDialog, "BaseForm", args, n ); + XtManageChild( row ); + + n = 0; + frame = XmCreateFrame( row, "frame", args, n); + XtManageChild( frame ); + + n = 0 ; + row1 = XmCreateRowColumn( frame, "row", args, n ); + XtManageChild( row1 ); + + n = 0; + str = XmStringCreateLocalized(resource.l_selectitem) ; + XtSetArg(args[n], XmNlabelString, str); n++; + label1 = XmCreateLabel( row1, "SelectItems", args, n); + XtManageChild( label1 ); + XmStringFree(str); + + n = 0 ; + row2 = XmCreateRowColumn( row1, "row", args, n ); + XtManageChild( row2 ); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_codeset) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull1); n++; + cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n ); + XtManageChild( cas1 ); + XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback, + (XtCallbackProc)button_set1, NULL); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_style) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull2); n++; + cas2 = XmCreateOptionMenu( row2, "Style", args, n ); + XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback, + (XtCallbackProc)button_set2, NULL); + XtManageChild( cas2 ); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_width) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull3); n++; + cas3 = XmCreateOptionMenu( row2, "Width", args, n ); + XtManageChild( cas3 ); + XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback, + (XtCallbackProc)button_set3, NULL); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_height) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull4); n++; + cas4 = XmCreateOptionMenu( row2, "Height", args, n ); + XtManageChild( cas4 ); + XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback, + (XtCallbackProc)button_set4, NULL); + XmStringFree(str); + + font_init(); + + n = 0; + XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ; + XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ; + XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ; + XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ; + XtSetArg(args[n], XmNitems, xlf) ; n++ ; + XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ; + scrolllist = XmCreateScrolledList(row, "scrolllist", args, n); + XtManageChild(scrolllist); + + n = 0; + sep = XmCreateSeparator(row, "sep", args, n); + XtManageChild(sep); + + n = 0 ; + row3 = XmCreateRowColumn( row, "row", args, n ); + XtManageChild( row3 ); + + if (! arrow_pix) { + disp = XtDisplay(row); + root = DefaultRootWindow(disp); + attr.valuemask = 0; + ReadXpm(disp, root, arrow_pm, &arrow_pix, &mask, &attr); + } + + n = 0 ; + XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ; n++ ; + row4 = XmCreateRowColumn( row3, "row", args, n ); + XtManageChild( row4 ); + + xms = XmStringCreateLocalized(resource.l_copy_src_code); + n = 0; + XtSetArg(args[n], XmNlabelString, xms); n++ ; + codeLabel[0] = XmCreateLabel(row4 , "copylabel", args, n); + XtManageChild(codeLabel[0]); + XmStringFree( xms ) ; + + n = 0; + XtSetArg(args[n], XmNcolumns, 4); n++; + XtSetArg(args[n], XmNmaxLength, 4); n++; + XtSetArg(args[n], XmNeditable, True); n++; + XtSetArg(args[n], XmNcursorPositionVisible, True); n++; + focus_widget = codeText[0] = XmCreateText(row4 , "copytext", + args, n); + XtManageChild(codeText[0]); + + XtAddCallback(codeText[0], XmNfocusCallback, (XtCallbackProc)focus, NULL); + + n = 0; + XtSetArg(args[n], XmNlabelPixmap, arrow_pix); n++; + XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; + XtSetArg(args[n], XmNindicatorOn, False); n++; + XtSetArg(args[n], XmNshadowThickness, 2); n++; + XtSetArg(args[n], XmNfillOnSelect, False); n++; + XtSetArg(args[n], XmNhighlightThickness, 0); n++; + arrow = XmCreateToggleButton(row4, "arrow", args, n); + XtManageChild(arrow); + + n = 0; + XtSetArg(args[n], XmNcolumns, 4); n++; + XtSetArg(args[n], XmNmaxLength, 4); n++; + XtSetArg(args[n], XmNeditable, True); n++; + XtSetArg(args[n], XmNcursorPositionVisible, True); n++; + codeText[1] = XmCreateText(row4 , "copytext", args, n); + XtManageChild(codeText[1]); + XtSetSensitive(codeText[1], False); + + XtAddCallback(codeText[1], XmNfocusCallback, (XtCallbackProc)focus, NULL); + + XtAddCallback(arrow, XmNvalueChangedCallback, + (XtCallbackProc)arrow_change, (XtPointer)codeText[1]); + + n = 0; + xms = XmStringCreateLocalized(resource.code) ; + XtSetArg(args[n], XmNlabelString, xms); n++; + XtSetArg(args[n], XmNhighlightThickness, 0); n++; + code = XmCreatePushButton(row4, "Code", args, n); + XtManageChild(code); + XmStringFree(xms); + + XtAddCallback(code, XmNactivateCallback, + (XtCallbackProc)code_input, (XtPointer)NULL); + + n = 0 ; + XtSetArg(args[n], XmNorientation, XmHORIZONTAL) ; n++ ; + row5 = XmCreateRowColumn( row3, "row", args, n ); + XtManageChild( row5 ); + + xms = XmStringCreateLocalized(resource.l_copy_dest_code); + + n = 0; + XtSetArg(args[n], XmNlabelString, xms); n++ ; + codeLabel[1] = XmCreateLabel(row5 , "copylabel", args, n); + XtManageChild(codeLabel[1]); + XmStringFree( xms ) ; + + n = 0; + XtSetArg(args[n], XmNcolumns, 4); n++; + XtSetArg(args[n], XmNmaxLength, 4); n++; + XtSetArg(args[n], XmNeditable, True); n++; + XtSetArg(args[n], XmNcursorPositionVisible, True); n++; + codeText[2] = XmCreateText(row5 , "copytext", args, n); + XtManageChild(codeText[2]); + + n = 0; + xms = XmStringCreateLocalized(resource.code) ; + XtSetArg(args[n], XmNlabelString, xms); n++; + XtSetArg(args[n], XmNhighlightThickness, 0); n++; + code = XmCreatePushButton(row5, "Code", args, n); + XtManageChild(code); + XmStringFree(xms); + + XtAddCallback(code, XmNactivateCallback, + (XtCallbackProc)code_input2, (XtPointer)NULL); + + return( cpyDialog ) ; +} diff --git a/cde/programs/dtudcfonted/dtaddcpf/Imakefile b/cde/programs/dtudcfonted/dtaddcpf/Imakefile new file mode 100644 index 000000000..444aa58b0 --- /dev/null +++ b/cde/programs/dtudcfonted/dtaddcpf/Imakefile @@ -0,0 +1,27 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:28 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../include -I../libfal/include + + LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + + SRCS = addcpf.c + + OBJS = addcpf.o + + SHLIBDIR = ../../../usr/bin + +ComplexProgramTarget(dtaddcpf) diff --git a/cde/programs/dtudcfonted/dtaddcpf/addcpf.c b/cde/programs/dtudcfonted/dtaddcpf/addcpf.c new file mode 100644 index 000000000..2504d992d --- /dev/null +++ b/cde/programs/dtudcfonted/dtaddcpf/addcpf.c @@ -0,0 +1,995 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: addcpf.c /main/9 1996/11/08 02:00:29 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <locale.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif + +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +#include "bdfgpf.h" + +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include <X11/fonts/fontstruct.h> + +#include "FaLib.h" +#include "snfstruct.h" +#include "udcutil.h" + +#include <errno.h> + + +static int rw_init(struct ptobhead *r_gpf, + struct btophead *r_snf, + struct ptobhead *w_snf, + int init_all); +static int readSnf(struct ptobhead *r_gpf, + struct btophead *r_snf, + struct ptobhead *w_snf, + char *buf); +static int readSnf_with_init(struct ptobhead *r_gpf, + struct btophead *r_snf, + struct ptobhead *w_snf, + int init, + char *buf, + int num_gr, + FalGlyphRegion *gr); +static int readSnfHeader(struct ptobhead *r_gpf, + struct btophead *r_snf, + struct ptobhead *w_snf, + char *buf) ; +static int readBdfHeaderAndPut(struct btophead *r_snf, + struct ptobhead *w_snf, + char *buf) ; +static int mergePtn(char *com, + struct ptobhead *r_gpf, + struct btophead *r_snf, + char *buf, + int code_area, + int modify, + char *prog_name, + int num_gr, + FalGlyphRegion *gr, + int code_no) ; +static int ModifyPtn(struct ptobhead *r_gpf, + struct btophead *r_snf, + char *buf, + int ix); +static int InsertPtn(struct ptobhead *r_gpf, + struct btophead *r_snf, + char *buf, + int code, + int ix); +static int writeSnf(struct btophead *r_snf, struct ptobhead *w_snf) ; +static void put_error_and_exit(struct ptobhead *ptob_in, + struct btophead *btop, + struct ptobhead *ptob_out, + int er_no, + char *prog_name); +static void put_help(char *prog_name); +static int readBdfToMemory_with_init(struct btophead *head, + int init, + char *buf, + int num_gr, + FalGlyphRegion *gr); + +extern int fal_glyph_to_code(char *locale, + char *charset_str, + int codeset, + unsigned long glyph_index, + unsigned long *codepoint); + +static struct ptobhead WriteSnf; + +static char *targ_file = NULL; /* UDC_file_name */ +static char *com = NULL; /* command_name */ +static char *spacing ; +static char *char_set ; +static char *util_locale ; + +static pid_t gtob_pid = 0; +static pid_t btop_pid = 0; +#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || \ + defined(__linux__) +static int chld_stat ; +#else +static union wait chld_stat ; +#endif + +static void +sigint_out(void) +{ + if (WriteSnf.out_file) { + Unlink_Tmpfile( WriteSnf.out_file, com ); + } + exit( 0 ); +} + +int main(int argc, char *argv[]) +{ + int code_area , init, modify, help, no_infile, no_style; + int fupd = 0 ; + int init_all, rtn, i; +#ifndef ROOT_ONLY + int exit_stat; +#endif + struct btophead ReadSnf; /* output file (GPF) */ + struct ptobhead ReadGpf; /* input file (CPF) */ + struct stat statbuf; + char snf_file[BUFSIZE] ; + char buf[BUFSIZE]; + char *style ; + char *xlfdname, *cbuf ; + int chk_fd; + FalGlyphRegion *gr ; + int num_gr ; + char *ep ; + + int code_no; + char *codeset = DEFAULT_CODESET; + + if( (util_locale = (char *)getenv( "LANG" )) == NULL ){ + util_locale = "C" ; + } + ReadSnf.in_file = ReadGpf.in_file = WriteSnf.out_file = NULL; + com = argv[0]; + COMM_SETDEFAULTSTYLE( style ) ; + cbuf = xlfdname = ep = '\0' ; + + gr = NULL ; + num_gr = 0 ; + spacing = char_set = NULL ; + + if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) { + bdftopcf = BDFTOPCF; + } + if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) { + oakgtobdf = SNFTOBDF; + } + if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) { + bdftosnf = BDFTOSNF; + } + + code_area = NORMAL; + init = modify = help = no_infile = no_style = init_all = 0; + + for ( i = 1; i < argc; i++ ) { + if ( !strcmp( argv[i], "-g" ) ) { + if ( ( i < argc-1) && (*argv[i+1] != '-' ) ) { + ReadSnf.in_file = argv[++i]; + } + } else if ( !strcmp( argv[i], "-p" ) ) { + if ( (i < argc-1) && (*argv[i+1] != '-') ){ + ReadGpf.in_file = argv[++i]; + } else { + no_infile = 1; + } + } else if ( !strcmp( argv[i], "-init" ) ) { + init = 1; + } else if ( !strcmp( argv[i], "-modify" ) ) { + modify = 1; + } else if ( !strcmp( argv[i], "-system" ) ) { + code_area |= SYSTM; + } else if ( !strcmp( argv[i], "-help" ) ) { + help = 1; + } else if ( !strcmp( argv[i], "-style" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){ + style = argv[++i]; + } else { + no_style = 1; + } + } else if ( !strcmp( argv[i], "-codeset" ) ) { + if ( ( i < argc - 1 ) && ( *argv[i+1] != '-' )){ + codeset = argv[++i]; + COMM_SET_CODESET( codeset, code_area ) ; + } + } else if ( !strcmp( argv[i], "-xlfd" ) ) { + if ( i < argc - 1 ){ + xlfdname = argv[++i]; + } + } else if ( COMM_SBOPT_STRCMP( argv, i ) ) { + COMM_SBOPT_SETSBOPT( code_area ) ; + } else if ( !strcmp( argv[i], "-f" ) ) { + fupd = 1; + } else { + put_help(argv[0]); + exit( 1 ); + } + } + + /* help_message */ + if ( help == 1 ) { + put_help( argv[0] ); + exit( 0 ); + } + COMM_SBOPT_CHECKSBOPT( argv[0], code_area ) ; + + if ( no_infile ) { + USAGE1("%s : The input file name following -p option cannot be omitted.\n", argv[0] ); + exit( 1 ); + } + + ep = (char *)strchr( codeset, '\0' ) ; + code_no = (int)strtol( codeset, &cbuf, 10 ) ; + if ( cbuf == codeset || cbuf != ep ) { + USAGE2("%s : The codeset number is not right.¡Ê %s ¡Ë\n", + argv[0], codeset ); + exit( 1 ); + } + + if ( no_style ) { + USAGE1("%s : The style is not specified.\n", argv[0] ) ; + exit( 1 ); + } + + if ( ReadSnf.in_file == NULL && xlfdname == NULL ) { + if ( code_area & SYSTM ) { + USAGE1("%s : The GPF output file name cannot be omitted.\n", argv[0] ); + } else { /* string of charcter size */ + USAGE1("%s : The character size specification cannot be omitted.\n", argv[0] ); + } + exit( 1 ); + } + + /* open GPF file */ + if ( !(code_area & SYSTM) ) { + if( xlfdname ) { + if ( GetUdcFileName( argv[0], code_no, xlfdname, snf_file ) ) { + USAGE1("%s : Failed to get font file. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + ReadSnf.in_file = snf_file ; + } else { + + + switch ( GetFileName( argv[0], ReadSnf.in_file, style, code_no, snf_file ) ) { + case 0: + ReadSnf.in_file = snf_file; + break; + case -1: + exit(1); + default: + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]); + exit(1); + } + } + if ( GetUdcRegion( argv[0], code_no, ReadSnf.in_file, &num_gr, &gr ) ) { + USAGE1("%s : This font cannot get UDC code region. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + } else { + num_gr = 1 ; + if( (gr = (FalGlyphRegion *)malloc( sizeof(FalGlyphRegion) * num_gr )) == NULL ) { + USAGE1("%s : malloc error. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + gr[0].start = MIN_CODE ; + gr[0].end = MAX_CODE ; + } + /* + * refuse proportional fonts + */ + if ( GetUdcFontName( ReadSnf.in_file, NULL, &xlfdname ) ) { + USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing ); + exit( 1 ); + } + GETCHARSETSTR( char_set, xlfdname ) ; + + /* get ReadSnf.in_file */ + if ((targ_file = GetRealFileName( ReadSnf.in_file )) == NULL){ + USAGE2("%s : It was not possible to refer to the substance of the font file. \"%s\"\n", argv[0], ReadSnf.in_file); + exit(1); + } + WriteSnf.snf_file = targ_file; + + if ( ( chk_fd = open( targ_file, O_RDWR ) ) < 0 ) { + USAGE2("%s : The font file of substance \"%s\" cannot be opened.\n", argv[0] , targ_file ); + exit( 1 ); + } + if( !fupd ){ + if ( isLock( chk_fd ) == 1 ) { + USAGE1("%s : Editing by other application. \n", argv[0] ); + close( chk_fd ); + exit( 1 ); + } + } + close( chk_fd ); + + /* We read whole characters from gpf file. */ + ReadSnf.start_code = MIN_CODE; + ReadSnf.end_code = MAX_CODE; + ReadSnf.code_category = ALL_CODE; + + switch ( code_area ) { + case SYSTM: + ReadGpf.start_code = MIN_CODE; + ReadGpf.end_code = MAX_CODE; + ReadGpf.code_category = ALL_CODE; + break; + case SYSTM | CDSET1 : + ReadGpf.start_code = MIN_CODE; + ReadGpf.end_code = MAX_CODE; + ReadGpf.code_category = ALL_CODE; + break; + default: + COMM_SBFNT_SETUDCAREA( argv[0], ReadGpf, char_set, code_area, num_gr, gr ) ; + } + + COMM_SBFNT_CONVCODETOGI( char_set, ReadSnf ) ; + COMM_SBFNT_CONVCODETOGI( char_set, ReadGpf ) ; + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + + /* + * rw_init() + * + * GPFTOBDF, BDFTOGPF + * + * (ReadSnf.in_file) --> GPFTOBDF ==H + * H + * dtaddcpf <-- (ReadGpf.in_file) + * H + * (WriteSnf.out_file) <-- BDFTOGPF ==H + * + */ + if ( rtn = rw_init( &ReadGpf, &ReadSnf, &WriteSnf, init_all ) ) { + if ( WriteSnf.out_file ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + } + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] ); + } + + if ( rtn = ReadGpfHeader( &ReadGpf, buf ) ) { + if ( WriteSnf.out_file ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + } + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] ); + } + + if ( init_all ) { + /* We read only header of gpf file. */ + rtn = readSnfHeader( &ReadGpf, &ReadSnf, &WriteSnf, buf ); + } else if ( init ) { + /* We read characters in UDC area from gpf file. */ + rtn = readSnf_with_init( &ReadGpf, &ReadSnf, &WriteSnf, + init, buf, num_gr, gr ); + } else { + /* We read whole characters from gpf file. */ + rtn = readSnf( &ReadGpf, &ReadSnf, &WriteSnf, buf ); + } + if ( rtn ) { + if ( WriteSnf.out_file ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + } + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] ); + } + + fclose( ReadSnf.input ); + WaitID( gtob_pid, chld_stat ) ; + + if ( ( rtn = mergePtn( argv[0], &ReadGpf, &ReadSnf, buf, code_area, modify, argv[0], num_gr, gr, code_no ) ) ) { + if ( WriteSnf.out_file ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + } + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] ); + } + + /* write SNF output file */ + if ( ( rtn = writeSnf( &ReadSnf, &WriteSnf ) ) ) { + if ( WriteSnf.out_file ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + } + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, rtn, argv[0] ); + } + +#ifdef ROOT_ONLY + if ( pclose( WriteSnf.output ) ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, PCLOSE_ERROR, argv[0] ); + } +#else + fclose( WriteSnf.output ); + WaitID( btop_pid, chld_stat ) ; +#if !defined( SVR4 ) && !defined( SYSV ) && !defined(__FreeBSD__) + if ( !WIFEXITED(chld_stat) ) { +#else + if ( ! ( WIFEXITED(chld_stat) && !WEXITSTATUS(chld_stat) ) ) { +#endif + USAGE4("%s: The error occurred by %s (%08x). Cannot write %s\n", + argv[0], bdftopcf, chld_stat, WriteSnf.out_file); + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, + FATAL_ERROR, argv[0] ); + } +#endif + signal( SIGHUP , SIG_IGN ); + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + if ( ( stat( WriteSnf.out_file, &statbuf ) ) || + ( statbuf.st_size == 0 ) + ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + put_error_and_exit( &ReadGpf, &ReadSnf, &WriteSnf, + BDF_WRITE, argv[0] ); + } + if ( stat( WriteSnf.snf_file, &statbuf ) ) { + Unlink_Tmpfile( WriteSnf.out_file, argv[0] ); + exit( 1 ); + } + exit( Make_NewFefFile( + WriteSnf.snf_file, WriteSnf.out_file, + FONT_FILE_PARM, + (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, + argv[0] )); +} + +static +rw_init( +struct ptobhead *r_gpf, +struct btophead *r_snf, +struct ptobhead *w_snf, +int init_all) +{ + FontInfoRec *finf; + int fd[2], snf_fd, permission; + char buf[BUFSIZE]; +#ifdef ROOT_ONLY + char command[BUFSIZE], *ep ; +#else + int pfd[2], ofd; +#endif + + if ( r_gpf->in_file == NULL ) { + r_gpf->input = stdin; + } else { + if ( ( r_gpf->input = fopen(r_gpf->in_file, "r")) == NULL ) { + return GPF_OPEN_IN; + } + } + + /* SNF format */ + if ( ChkPcfFontFile( w_snf->snf_file ) ) { + if( (snf_fd = open( w_snf->snf_file, O_RDONLY ) ) >= 0 ) { + return BDF_OPEN_IN; + } + } + if (pipe(fd) != 0) { + return PIPE_ERROR; + } + switch (gtob_pid = fork()) { + case 0: + close( fd[0] ); + close( 1 ); + if ( dup( fd[1] ) < 0 ) { + return DUP_ERROR; + } + + close( fd[1] ); + + /* SNFTOBDF */ + execl( oakgtobdf, oakgtobdf, r_snf->in_file, 0 ); + return EXEC_ERROR; + + case -1: + return FORK_ERROR; + + default: + break; + } + close( fd[1] ); + if ( ( r_snf->input = fdopen( fd[0], "r" ) ) == NULL ) { + return FDOPEN_ERROR; + } + + if ( !( w_snf->out_file = GetTmpPath( targ_file ) ) ) { + return MKTMP_ERROR; + } + +#ifdef ROOT_ONLY + if( ChkPcfFontFile( w_snf->snf_file ) == 0 ) { + sprintf(command, "%s > %s", bdftopcf, w_snf->out_file) ; + } else { + COMM_SNF_POPEN( permission, w_snf->snf_file, w_snf->out_file, ep, buf, command ) ; + } + if ((w_snf->output = popen(command, "w")) == NULL) { + return(POPEN_ERROR); + } +#else /* ROOT_ONLY */ + if ( pipe( pfd ) != 0 ) { + return PIPE_ERROR; + } + switch (btop_pid = fork()) { + case 0: + if ( ( ofd = open( w_snf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) { + return BDF_OPEN_OUT; + } + close( 0 ); + if ( dup(pfd[0]) < 0 ) { + return DUP_ERROR; + } + close( pfd[0] ); + close( pfd[1] ); + close( 1 ); + if( dup( ofd ) < 0 ) { + close( ofd ); + return DUP_ERROR; + } + close( ofd ); + if ( ChkPcfFontFile( w_snf->snf_file ) == 0 ) { + execl( bdftopcf, bdftopcf, 0 ); + return PCFFONTC_ERROR; + } + + COMM_SNF_EXECLBDFTOSNF( permission, buf, w_snf->snf_file ) ; + return SNFFONTC_ERROR; + + case -1: + return FORK_ERROR; + + default: + break; + } + close( pfd[0] ); + if ( ( w_snf->output = fdopen( pfd[1], "w" ) ) == NULL ) { + return FDOPEN_ERROR; + } +#endif /* ROOT_ONLY */ + return 0; +} + + +static +readSnf( +struct ptobhead *r_gpf, +struct btophead *r_snf, +struct ptobhead *w_snf, +char *buf) +{ + int nchar, rtn; + + if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) { + return rtn; + } + + nchar = r_snf->num_chars + r_gpf->num_chars; + + if ( ( r_snf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + return ReadBdfToMemory( r_snf, buf ) ; +} + +static +readSnf_with_init( +struct ptobhead *r_gpf, +struct btophead *r_snf, +struct ptobhead *w_snf, +int init, +char *buf, +int num_gr, +FalGlyphRegion *gr) +{ + int nchar, rtn; + + + if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) { + return rtn; + } + + nchar = r_snf->num_chars + r_gpf->num_chars; + + if ( ( r_snf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + return readBdfToMemory_with_init( r_snf, init, buf, num_gr, gr ) ; +} + + +static +readSnfHeader( +struct ptobhead *r_gpf, +struct btophead *r_snf, +struct ptobhead *w_snf, +char *buf) +{ + int rtn; + + if ( ( rtn = readBdfHeaderAndPut( r_snf, w_snf, buf ) ) ) { + return rtn; + } + + r_snf->num_chars = 0; + + if ( ( r_snf->code = (int *)malloc( sizeof(int) * r_gpf->num_chars ) ) == NULL ) { + return MALLOC_ERROR; + } + if ( ( r_snf->ptn = (char **)malloc( sizeof(char *) * r_gpf->num_chars ) ) == NULL ) { + return MALLOC_ERROR; + } + return 0; +} + +static +readBdfHeaderAndPut(struct btophead *r_snf, struct ptobhead *w_snf, char *buf) +{ + char *p; + int getstat = 0; + + while ( 1 ) { + if ( fgets( buf, BUFSIZE, r_snf->input ) == NULL ) { + return BDF_INVAL; + } + p = buf; + SCAN_TO_NONSP( p ) + if ( !strncmp( p, SIZE, strlen( SIZE ) ) ) { + if ( ( sscanf( p, "SIZE %f%d", + &(r_snf->bdf_point), &(r_snf->bdf_xdpi))) != 2 ) { + return BDF_INVAL; + } + fprintf( w_snf->output, "%s", buf ); + getstat |= 0x01; + + } else if ( !strncmp( p, FONTBOUNDINGBOX, strlen( FONTBOUNDINGBOX ) ) ) { + if ( ( sscanf( p, "FONTBOUNDINGBOX %d%d%d%d", + &(r_snf->bdf_width), &(r_snf->bdf_height), + &(r_snf->bdf_x), &(r_snf->bdf_y) )) != 4) { + return BDF_INVAL; + } + fprintf( w_snf->output, "%s", buf ); + getstat |= 0x02; + + } else if ( !strncmp( p, CHARS, strlen( CHARS ) ) ) { + if ( ( sscanf( p, "CHARS %d", &( r_snf->num_chars ) ) ) != 1 ) { + return BDF_INVAL; + } + getstat |= 0x04; + break; + } else { + fprintf( w_snf->output, "%s", buf ); + } + } + + if ( getstat != 0x07 ) { + return BDF_INVAL; + } + return 0; +} + +#define DispCodePoint( command, char_set, gidx, dspcode, code_no, locale ){\ + if( COMM_SBFNT_ISSBFNT( (char_set) ) ){\ + dspcode = DISPCODEPOINT( (char_set), (gidx) ) ;\ + }else{\ + if( fal_glyph_to_code( (locale), (char_set), FALGETFALCODESET((code_no)), (gidx), &(dspcode) ) ){\ + USAGE3("%s : Failed to convert glyph index into code point.(0x%x charset: %s)\n", (command), (gidx), (char_set) ) ;\ + return -1 ;\ + }\ + }\ +} + +static +mergePtn( +char *com, +struct ptobhead *r_gpf, +struct btophead *r_snf, +char *buf, +int code_area, +int modify, +char *prog_name, +int num_gr, +FalGlyphRegion *gr, +int code_no) +{ + int code, rtn, msize, i, j, dspcode; + char *ptn; + + if ( ( r_gpf->p_width != r_snf->bdf_width ) + || ( r_gpf->p_height != r_snf->bdf_height ) + ) { + r_gpf->zoomf = 1; + + msize = ( r_gpf->p_width + 7 ) / 8 * r_gpf->p_height; + + if ( ( ptn = (char *)malloc( msize ) ) == NULL ) { + return MALLOC_ERROR; + } + r_gpf->ptn = &ptn; + + } else { + r_gpf->zoomf = 0; + } + + for ( i = 0; i < r_gpf->num_chars; i++ ) { + if ( ( rtn = GetGpfCode( r_gpf, buf, &code ) ) < 0 ) { + return rtn; + } else if ( rtn == FILE_END ) { + break; + } + if( COMM_SBFNT_ISSBFNT( char_set ) ) CONVGLYPHINDEX( code ) ; + if ( + ( code < r_gpf->start_code) || ( code > r_gpf->end_code ) + ||( !IN_CODE( r_gpf->code_category, SHIFT_ON( code ) ) ) + ||( + (r_gpf->code_category == ALL_CODE) && + !( code_area & SYSTM ) && + IsInRegion( code, num_gr, gr ) + ) + ) { + DispCodePoint( com, char_set, code, dspcode, code_no, util_locale ) ; + USAGE2("%s : The font of a specified code cannot be added/changed \"0x%x\".\n", prog_name, dspcode ); + if( fgets(buf, BUFSIZE, r_gpf->input) == NULL){ + return -1; + } else { + continue; + } + } + + for ( j = 0; j < r_snf->num_chars; j++ ) { + if ( r_snf->code[j] == code ) { + if ( !modify ) { + DispCodePoint( com, char_set, code, dspcode, code_no, util_locale ) ; + USAGE2("%s : The font has already been registered in a specified code. \"0x%x\"\n", prog_name, dspcode ); + if(fgets( buf, BUFSIZE, r_gpf->input ) == NULL){ + return -1; + } else { + break; + } + } + if ( ( rtn = ModifyPtn( r_gpf, r_snf, buf, j ) ) ) { + return rtn; + } + break; + } else if ( r_snf->code[j] > code ) { + if ( ( rtn = InsertPtn( r_gpf, r_snf, buf, code, j ) ) ) { + return rtn; + } + break; + } + } + if ( j == r_snf->num_chars ) { + if ( ( rtn = InsertPtn( r_gpf, r_snf, buf, code, j ) ) ) { + return rtn; + } + } + } + return 0; +} + + +static +ModifyPtn( +struct ptobhead *r_gpf, +struct btophead *r_snf, +char *buf, +int ix) +{ + int mwidth, msize, rtn; + + mwidth = ( r_gpf->p_width + 7 ) / 8; + msize = mwidth * r_gpf->p_height; + + if ( r_gpf->zoomf ) { + if ( ( rtn = GetGpfPtn( r_gpf, buf, r_gpf->ptn[0], mwidth, msize ) ) ) { + return rtn; + } + if ( ( rtn = PtnZoom( r_snf->ptn[ix], r_gpf->ptn[0], + r_gpf->p_width, r_gpf->p_height, + r_snf->bdf_width, r_snf->bdf_height ) ) ) { + return rtn; + } + } else { + if ( ( rtn = GetGpfPtn( r_gpf, buf, r_snf->ptn[ix], mwidth, msize ) ) ) { + return rtn; + } + } + return 0; +} + +static +InsertPtn( +struct ptobhead *r_gpf, +struct btophead *r_snf, +char *buf, +int code, +int ix) +{ + int mwidth, msize, rtn, i; + + for ( i = r_snf->num_chars; i > ix; i-- ) { + r_snf->code[i] = r_snf->code[i-1]; + r_snf->ptn[i] = r_snf->ptn[i-1]; + } + r_snf->code[ix] = code; + + r_snf->num_chars++; + + mwidth = (r_snf->bdf_width + 7) / 8; + msize = mwidth * r_snf->bdf_height; + + if ( ( r_snf->ptn[ix] = (char *)malloc( msize ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( r_gpf->zoomf ) { + mwidth = (r_gpf->p_width + 7) / 8; + msize = mwidth * r_gpf->p_height; + if ( ( rtn = GetGpfPtn( r_gpf, buf, r_gpf->ptn[0], mwidth, msize ) ) ) { + return rtn; + } + if ( ( rtn = PtnZoom( r_snf->ptn[ix], r_gpf->ptn[0], + r_gpf->p_width, r_gpf->p_height, + r_snf->bdf_width, r_snf->bdf_height ) ) ) { + return rtn; + } + } else { + if ( ( rtn = GetGpfPtn( r_gpf, buf, r_snf->ptn[ix], mwidth, msize ) ) ) { + return rtn; + } + } + return(0); +} + +static +writeSnf(struct btophead *r_snf, struct ptobhead *w_snf) +{ + w_snf->zoomf = 0; + w_snf->num_chars = r_snf->num_chars; + w_snf->code = r_snf->code; + w_snf->ptn = r_snf->ptn; + w_snf->bdf_width = r_snf->bdf_width; + w_snf->bdf_height = r_snf->bdf_height; + + w_snf->bdf_x = r_snf->bdf_x; + w_snf->bdf_y = r_snf->bdf_y; + + w_snf->bdf_point = r_snf->bdf_point; + w_snf->bdf_xdpi = r_snf->bdf_xdpi; + + return WritePtnToBdf( w_snf ); +} + + + +static void +put_error_and_exit( +struct ptobhead *ptob_in, +struct btophead *btop, +struct ptobhead *ptob_out, +int er_no, +char *prog_name) +{ + ErrMsgTable_AndExit( er_no, ptob_in->in_file, ptob_out->out_file, + btop->in_file, NULL, + ptob_in->bdf_file, + prog_name + ); + return; +} + + + +static void +put_help(char *prog_name) +{ + USAGE1("Usage: %s -xlfd xlfd_name \n", prog_name); + USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n"); + USAGE("\t\t[-style style]"); + USAGE("\t\t[-init]\t(clear whole glyphs of gpf file that used for user defined characters)\n" ) ; + USAGE("\t\t[-modify]\t(permits the change of font)\n"); + COMM_HELP_MSG ; + USAGE1("%s can insert or modify glyphs in the following code area.\n", prog_name); + USAGE("codeset \t\tcode area\n"); + USAGE("----------------------------------------\n"); + DispUdcCpArea(stdout) ; + USAGE("The xlfd name and character size may be obtained using dtlsgpf command.\n"); + return; +} + + + +static int +readBdfToMemory_with_init( +struct btophead *head, +int init, +char *buf, +int num_gr, +FalGlyphRegion *gr) +{ + int code, mwidth, num_char, bsize, rtn ; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + rtn = IsInRegion( code, num_gr, gr ) ; + if ( + ( code < head->start_code) || ( code > head->end_code ) + ||( !IN_CODE( head->code_category, SHIFT_ON( code ) ) ) + ||( + (head->code_category == ALL_CODE) + && ( (init)? ((rtn)?0:1) : ((rtn)?1:0) ) + ||( COMM_ISDEFAULTCHAR( code ) ) + ) + ) { + continue; + } + head->code[num_char] = code; + if ((ptn = head->ptn[num_char++] = + (char *)malloc(bsize)) == NULL) { + return(MALLOC_ERROR); + } + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} diff --git a/cde/programs/dtudcfonted/dtbdftocpf/Imakefile b/cde/programs/dtudcfonted/dtbdftocpf/Imakefile new file mode 100644 index 000000000..8dd75cb90 --- /dev/null +++ b/cde/programs/dtudcfonted/dtbdftocpf/Imakefile @@ -0,0 +1,24 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:34 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../include -I../libfal/include + + LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + SRCS = bdftocpf.c + + OBJS = bdftocpf.o + +ComplexProgramTarget(dtbdftocpf) diff --git a/cde/programs/dtudcfonted/dtbdftocpf/bdftocpf.c b/cde/programs/dtudcfonted/dtbdftocpf/bdftocpf.c new file mode 100644 index 000000000..f93abd293 --- /dev/null +++ b/cde/programs/dtudcfonted/dtbdftocpf/bdftocpf.c @@ -0,0 +1,284 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: bdftocpf.c /main/6 1996/11/08 02:01:17 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include "bdfgpf.h" +#include "udcutil.h" + +static void put_error(struct btophead *head, int er_no, char *prog_name); +static void put_help(char *prog_name); +static void Usage(char *prog_name) ; +static void sigint_out(void) ; +static int CnvBDFtoGPF(struct btophead *head) ; + +static struct btophead Head; + +static void +sigint_out(void) +{ + if (Head.out_file) { + unlink(Head.out_file); + } + exit(0); +} + +int main(int argc, char *argv[]) +{ + int rtn, i; + char *GetTmpPath(); + struct stat st; + + for (i=1; i<argc; i++) { + if (!strcmp(argv[i], "-help")) { + put_help(argv[0]); + exit(0); + } + } + + if (!(argc % 2)) { + Usage(argv[0]); + } + + Head.in_file = Head.out_file = Head.text_file = NULL; + Head.p_width = Head.p_height = USE_ORG_SIZE; + + + Head.start_code = MIN_CODE ; + Head.end_code = MAX_CODE ; + Head.code_category = ALL_CODE; + + for (i=1; i<argc; i+=2) { + if (!strcmp(argv[i], "-p")) { + Head.out_file = argv[i+1]; + } else if (!strcmp(argv[i], "-bdf")) { + Head.in_file = argv[i+1]; + } else if (!strcmp(argv[i], "-width")) { + Head.p_width = atoi(argv[i+1]); + if ((Head.p_width > MAX_FONT_WIDTH) || + (Head.p_width < MIN_FONT_WIDTH)) { + USAGE2("%s: The specification of the character width is improper.\"%s\"\n", + argv[0], argv[i+1]); + exit(PARAM_ERROR * (-1)); + } + } else if (!strcmp(argv[i], "-height")) { + Head.p_height = atoi(argv[i+1]); + if ((Head.p_height > MAX_FONT_HEIGHT) || + (Head.p_height < MIN_FONT_HEIGHT)) { + USAGE2("%s: The specification of the character height is improper.\"%s\"\n", + argv[0], argv[i+1]); + exit(PARAM_ERROR * (-1)); + } + } else { + Usage(argv[0]); + } + } + + if (Head.in_file == NULL) { + Head.input = stdin; + } else { + char *spacing ; + char *xlfdname ; + spacing = xlfdname = NULL ; + /* refuse proportional fonts */ + if ( GetUdcFontName( NULL, Head.in_file, &xlfdname ) ) { + USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing ); + exit( 1 ); + } + if ((Head.input = fopen(Head.in_file, "r")) == NULL) { + USAGE2("%s: The BDF file cannot be opened.\"%s\"\n", + argv[0], Head.in_file); + exit(BDF_OPEN * (-1)); + } + } + + signal(SIGHUP, (void(*)())sigint_out); + signal(SIGINT, (void(*)())sigint_out); + signal(SIGQUIT, (void(*)())sigint_out); + signal(SIGTERM, (void(*)())sigint_out); + + if (Head.out_file == NULL) { + Head.output = stdout; + } else { + if (stat(Head.out_file, &st) != 0) { + if ((Head.output = fopen(Head.out_file, "w")) == NULL) { + USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", + argv[0], Head.out_file); + exit(GPF_OPEN *(-1)); + } + } else { + Head.text_file = Head.out_file; + if ((Head.out_file = GetTmpPath( Head.out_file )) == NULL) { + USAGE1("%s: Failed convert.\n", argv[0]); + exit(FATAL_ERROR * (-1)); + } + if ((Head.output = fopen(Head.out_file, "w")) == NULL) { + USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", + argv[0], Head.out_file); + exit(GPF_OPEN * (-1)); + } + } + } + + if ((rtn = CnvBDFtoGPF(&Head))) { + if (Head.in_file != NULL) { + fclose(Head.input); + } + if (Head.out_file != NULL) { + fclose(Head.output); + unlink(Head.out_file); + } + put_error(&Head, rtn, argv[0]); + exit(rtn * (-1)); + } + + if (Head.in_file != NULL) { + fclose(Head.input); + } + if (Head.out_file != NULL) { + fclose(Head.output); + signal(SIGHUP, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + if (Head.text_file != NULL) { + Link_NewFile(Head.out_file, Head.text_file); + unlink(Head.out_file); + } + } + exit(0); +} + +static +CnvBDFtoGPF( struct btophead *head) +{ + char bdfbuf[BUFSIZE]; + int rtn; + + if ((rtn = ReadBdfHeader(head, bdfbuf)) < 0) { + return(rtn); + } + + if (head->p_width == USE_ORG_SIZE) { + head->p_width = head->bdf_width; + } + if (head->p_height == USE_ORG_SIZE) { + head->p_height = head->bdf_height; + } + if ((head->p_width != head->bdf_width) || + (head->p_height != head->bdf_height)) { + head->zoomf = 1; + } else { + head->zoomf = 0; + } + + if ((head->code = (int *)malloc(sizeof(int)*head->num_chars)) == NULL) { + return(FATAL_ERROR); + } + + if ((head->ptn = (char **)malloc(sizeof(char *)*head->num_chars)) == NULL) { + return(FATAL_ERROR); + } + + if ((rtn = ReadBdfToMemory(head, bdfbuf))) { + return(rtn); + } + + WriteGpfHeader(head); + + if ((rtn = WritePtnToGpf(head))) { + return(rtn); + } + + return(0); +} + +static void +put_error(struct btophead *head, int er_no, char *prog_name) +{ + switch(er_no) { + case FATAL_ERROR : + USAGE1("%s: Failed convert.\n", prog_name); + break; + + case BDF_OPEN : + USAGE2("%s: The BDF file cannot be opened. \"%s\"\n", + prog_name, head->in_file); + break; + + case BDF_READ : + USAGE2("%s: The BDF file cannot be read. \"%s\"\n", + prog_name, head->in_file); + break; + + case BDF_INVAL : + USAGE2("%s: The format of the BDF file is illegal. \"%s\"\n", + prog_name, head->in_file); + break; + + case GPF_OPEN : + USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", + prog_name, head->out_file); + break; + + case GPF_WRITE : + USAGE2("%s: It is not possible to write to the character pattern file. \"%s\"\n", + prog_name, head->out_file); + break; + + default : + break; + } +} + +static void +put_help(char *prog_name) +{ + USAGE1("Usage: %s [-p character_pattern_file_name] [-bdf BDF_file_name]\n", prog_name); + USAGE("\t\t[-width character_width] [-height character_height] [-help]\n\n"); +} + +static void +Usage(char *prog_name) +{ + put_help(prog_name); + exit(PARAM_ERROR * (-1)); +} diff --git a/cde/programs/dtudcfonted/dtcpftobdf/Imakefile b/cde/programs/dtudcfonted/dtcpftobdf/Imakefile new file mode 100644 index 000000000..00d5a0abf --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpftobdf/Imakefile @@ -0,0 +1,24 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:37 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../include -I../libfal/include + + LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + SRCS = cpftobdf.c + + OBJS = cpftobdf.o + +ComplexProgramTarget(dtcpftobdf) diff --git a/cde/programs/dtudcfonted/dtcpftobdf/cpftobdf.c b/cde/programs/dtudcfonted/dtcpftobdf/cpftobdf.c new file mode 100644 index 000000000..ba837d0d3 --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpftobdf/cpftobdf.c @@ -0,0 +1,282 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: cpftobdf.c /main/6 1996/11/08 02:02:03 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <signal.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include "bdfgpf.h" +#include "udcutil.h" + +static void put_error(struct ptobhead *head, int er_no, char *prog_name); +static void put_help(char *prog_name); +static void Usage(char *prog_name); +static int CnvGPFtoBDF(struct ptobhead *head) ; +static void sigint_out(void) ; + +static struct ptobhead Head; + +static void +sigint_out(void) +{ + if ( Head.out_file ) { + unlink( Head.out_file ); + } + exit( 0 ); +} + +int main( int argc, char *argv[]) +{ + int rtn, i; + char *GetTmpPath(); + char *spacing ; + char *xlfdname ; + + for ( i = 1; i < argc; i++ ) { + if ( !strcmp( argv[i], "-help" ) ) { + put_help( argv[0] ); + exit( 0 ); + } + } + + if ( !( argc % 2 ) ) { + Usage(argv[0]); + } + + spacing = xlfdname = NULL ; + Head.in_file = Head.bdf_file = Head.snf_file = Head.out_file = NULL; + Head.start_code = MIN_CODE ; + Head.end_code = MAX_CODE ; + Head.code_category = ALL_CODE; + + if (!( bdftopcf = get_cmd_path( getenv( "PATH"), BDFTOPCF_CMD ))){ + bdftopcf = BDFTOPCF; + } + if (!( oakgtobdf = get_cmd_path( getenv( "PATH"), SNFTOBDF_CMD ))) { + oakgtobdf = SNFTOBDF; + } + + for ( i = 1; i < argc; i+=2 ) { + if ( !strcmp( argv[i], "-bdf" ) ) { + Head.bdf_file = argv[ i+1 ]; + } else if ( !strcmp( argv[i], "-p" ) ) { + Head.in_file = argv[i+1]; + } else if ( !strcmp( argv[i], "-g" ) ) { + Head.snf_file = argv[i+1]; + } else { + Usage( argv[0] ); + } + } + + if ( Head.in_file == NULL ) { + Head.input = stdin; + } else { + if ( ( Head.input = fopen( Head.in_file, "r" ) ) == NULL ) { + USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", argv[0], Head.in_file ); + exit( GPF_OPEN * (-1) ); + } + } + + signal( SIGHUP, (void(*)())sigint_out ); + signal( SIGINT, (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + if ( Head.bdf_file == NULL ) { + if ( Head.snf_file == NULL ) { + USAGE1("%s: If the output is stdout, the user defined font file name cannot be omitted.\n", argv[0]); + exit(PARAM_ERROR * (-1)); + } + Head.output = stdout; + } else { + if ( ! ( Head.out_file = GetTmpPath( Head.bdf_file ) ) ) { + exit( FATAL_ERROR * ( -1 ) ); + } + + if ( ( Head.output = fopen( Head.out_file, "w" ) ) == NULL ) { + USAGE2("%s: The work file for the output cannot be opened. \"%s\"\n", argv[0], Head.out_file ); + exit( BDF_OPEN * (-1) ); + } + } + /* refuse proportional fonts */ + if ( GetUdcFontName( Head.snf_file, Head.bdf_file, &xlfdname ) ) { + USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]); + if ( Head.in_file != NULL ) { + fclose( Head.input ); + } + if ( Head.out_file != NULL ) { + fclose( Head.output ); + unlink( Head.out_file ); + } + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing ); + if ( Head.in_file != NULL ) { + fclose( Head.input ); + } + if ( Head.out_file != NULL ) { + fclose( Head.output ); + unlink( Head.out_file ); + } + exit( 1 ); + } + + if ( ( rtn = CnvGPFtoBDF( &Head ) ) ) { + if ( Head.in_file != NULL ) { + fclose( Head.input ); + } + if ( Head.out_file != NULL ) { + fclose( Head.output ); + unlink( Head.out_file ); + } + put_error( &Head, rtn, argv[0] ); + exit( rtn * (-1) ); + } + + if ( Head.in_file != NULL ) { + fclose( Head.input ); + } + if ( Head.out_file != NULL ) { + fclose( Head.output ); + signal( SIGHUP, SIG_IGN ); + signal( SIGINT, SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + if ( Head.bdf_file != NULL ) { + Link_NewFile( Head.out_file, Head.bdf_file ); + unlink( Head.out_file ); + } + } + exit( 0 ); +} + +static +CnvGPFtoBDF(struct ptobhead *head) +{ + char textbuf[BUFSIZE] ; + int rtn ; + + if ( ( rtn = ReadGpfHeader( head, textbuf ) ) ) { + return rtn; + } + + if ( ( rtn = WriteBdfHeader( head ) ) ) { + return rtn; + } + + if ( ( head->p_width != head->bdf_width ) + || ( head->p_height != head->bdf_height ) + ) { + head->zoomf = 1; + } else { + head->zoomf = 0; + } + + if ( ( head->code = (int *)malloc( sizeof(int) * head->num_chars ) ) == NULL ) { + return FATAL_ERROR; + } + + if ( ( head->ptn = (char **)malloc( sizeof( char * ) * head->num_chars ) ) == NULL ) { + return FATAL_ERROR; + } + + if ( ( rtn = ReadGpfToMemory( head, textbuf ) ) ) { + return rtn; + } + + if ( ( rtn = WritePtnToBdf( head ) ) ) { + return rtn; + } + + return 0; +} + +static void +put_error(struct ptobhead *head, int er_no, char *prog_name) +{ + switch( er_no ) { + case FATAL_ERROR: + USAGE1("%s: Failed convert.\n", prog_name ); + break; + + case BDF_OPEN: + USAGE2("%s: The BDF file cannot be opened. \"%s\"\n", prog_name, head->bdf_file ); + break; + + case BDF_READ: + USAGE2("%s: The BDF file cannot be read. \"%s\"\n", prog_name, head->bdf_file ); + break; + + case BDF_WRITE: + USAGE2("%s: It is not possible to write to the BDF file. \"%s\"\n", prog_name, head->out_file ); + break; + + case BDF_INVAL: + if ( head->snf_file ) { + USAGE2("%s: The information from the font file cannot be obtained.\"%s\"\n", prog_name, head->snf_file ); + } else { + USAGE2("%s: The format of the BDF file is illegal. \"%s\"\n", prog_name, head->bdf_file ); + } + break; + + case GPF_OPEN: + USAGE2("%s: The character pattern file cannot be opened. \"%s\"\n", prog_name, head->in_file ); + break; + + case GPF_READ: + USAGE2("%s: The character pattern file cannot be read. \"%s\"\n", prog_name, head->in_file ); + break; + + case GPF_INVAL: + USAGE2("%s: The format of the character pattern file is illegal. \"%s\"\n", prog_name, head->in_file ); + break; + + default: + break; + } +} + +static void +put_help( char *prog_name) +{ + USAGE1("Usage: %s [-bdf BDF_file_name] [-p chracter_pattern_file_name]\n", prog_name); + USAGE("\t\t[-g user_defined_character_file_name] [-help]\n"); +} + +static void +Usage( char *prog_name) +{ + put_help( prog_name ); + exit( PARAM_ERROR * (-1) ); +} diff --git a/cde/programs/dtudcfonted/dtcpftogpf/Imakefile b/cde/programs/dtudcfonted/dtcpftogpf/Imakefile new file mode 100644 index 000000000..0fd45d15c --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpftogpf/Imakefile @@ -0,0 +1,24 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:41 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../include -I../libfal/include + +LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + SRCS = cpftogpf.c + + OBJS = cpftogpf.o + +ComplexProgramTarget(dtcpftogpf) diff --git a/cde/programs/dtudcfonted/dtcpftogpf/cpftogpf.c b/cde/programs/dtudcfonted/dtcpftogpf/cpftogpf.c new file mode 100644 index 000000000..c5b475d6e --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpftogpf/cpftogpf.c @@ -0,0 +1,455 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: cpftogpf.c /main/7 1996/11/08 02:02:48 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif +#include <sys/stat.h> +#include <string.h> + +#include <unistd.h> + +#include <X11/Xmd.h> +#include <X11/Xproto.h> + +#include "bdfgpf.h" + +#include "snfstruct.h" +#include <X11/fonts/fontstruct.h> + +#include "FaLib.h" +#include "udcutil.h" + +#include <errno.h> + + +static void sigint_out(void); +static void put_error_and_exit(struct ptobhead *ptob, + int er_no, + char *prog_name); +static void put_help(char *prog_name); +static int CnvGPFtoBDF(struct ptobhead *head); + +static struct ptobhead Head; + +static char *targ_file = NULL; /* UDC character filename */ +static char *com = NULL; /* command name */ +static char *spacing ; +static char *char_set ; + + +static void +sigint_out(void) +{ + if (Head.out_file) { + Unlink_Tmpfile(Head.out_file, com); + } + exit(0); +} + +int main(int argc, char *argv[]) +{ + FontInfoRec *finf; + int help, no_infile, style_err, rtn, i; + struct stat statbuf; + char snf_file[BUFSIZE], buf[BUFSIZE]; + int pfd[2], fd, snf_fd, permission; + int exit_stat; + char *style ; /* style */ + int chk_fd; + pid_t chld_pid = 0; +#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || \ + defined(__linux__) + int chld_stat ; +#else + union wait chld_stat ; +#endif + int code_no, code_area ; + FalFontData key ; + char *xlfdname, *cbuf, *ep ; + char *codeset = DEFAULT_CODESET ; + + /* format */ + Head.in_file = Head.bdf_file = Head.snf_file = Head.out_file = NULL; + help = no_infile = style_err = 0; + com = argv[0]; + COMM_SETDEFAULTSTYLE( style ) ; + memset( &key, '\0', sizeof(FalFontData) ) ; + xlfdname = cbuf = ep = '\0' ; + spacing = char_set = NULL ; + code_no = code_area = 0 ; + + if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) { + bdftopcf = BDFTOPCF; + } + if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) { + oakgtobdf = SNFTOBDF; + } + if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) { + bdftosnf = BDFTOSNF; + } + + Head.code_category = ALL_CODE; + Head.start_code = MIN_CODE; + Head.end_code = MAX_CODE; + + for (i=1; i<argc; i++) { + if ( !strcmp( argv[i], "-system" ) ) { + code_area |= SYSTM ; + } else if ( !strcmp( argv[i], "-help" ) ) { + help = 1; + } else if ( !strcmp( argv[i], "-g" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) { + Head.snf_file = argv[++i]; + } + } else if (!strcmp(argv[i], "-p")) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) { + Head.in_file = argv[++i]; + } else { + no_infile = 1; + } + } else if ( !strcmp(argv[i], "-style" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){ + style = argv[++i]; + } else { + style_err = 1; + } + + } else if ( !strcmp( argv[i], "-codeset" ) ) { + if ( + ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) && + ( strlen( argv[i + 1] ) == 1 ) + ) { + if ( *argv[i+1] == '1' ) code_area |= CDSET1 ; + codeset = argv[++i] ; + } else { + put_help( argv[0] ); + exit( 1 ); + } + } else if ( !strcmp( argv[i], "-xlfd" ) ) { + if ( i < argc-1 ) { + xlfdname = argv[++i] ; + } else { + put_help( argv[0] ); + exit( 1 ); + } + } else { + put_help( argv[0] ); + exit( 1 ); + } + } + + ep = (char *)strchr( codeset, '\0' ) ; + code_no = (int)strtol( codeset, &cbuf, 10 ) ; + if( cbuf == codeset || cbuf != ep ) { + USAGE1("%s : The code set number is not right.\n", argv[0] ) ; + exit(1) ; + } + + if ( help ) { + put_help( argv[0] ); + exit( 0 ); + } + + if ( no_infile ) { + USAGE1("%s : The input file name following -p option cannot be omitted.\n", argv[0] ); + exit( 1 ); + } + + if ( style_err ) { + USAGE1("%s : The style is not specified.\n", argv[0] ); + exit( 1 ); + } + + if ( Head.snf_file == NULL && xlfdname == NULL ) { + if ( code_area & SYSTM ) { + USAGE1("%s : The SNF output file name cannot be omitted.\n", argv[0] ); + } else { + USAGE1("%s : The character size specification cannot be omitted.\n", argv[0] ); + } + exit( 1 ); + } + + if ( !( code_area & SYSTM ) ) { + + + if( xlfdname ) { + if( GetUdcFileName( com, code_no, xlfdname, snf_file ) ) { + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", com ); + exit( 1 ); + } + Head.snf_file = snf_file; + } else { + switch ( GetFileName( argv[0], Head.snf_file, style, code_no, snf_file ) ) { + case 0: + Head.snf_file = snf_file; + break; + case -1: + /* output GetFileName() */ + exit( 1 ); + default: + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0] ); + exit( 1 ); + } + } + } + + /* + * refuse proportional fonts + */ + if ( GetUdcFontName( Head.snf_file, NULL, &xlfdname ) ) { + USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing ); + exit( 1 ); + } + GETCHARSETSTR( char_set, xlfdname ) ; + + COMM_SET_CODECATEGORY( char_set, code_area, Head) ; + + if ( ( targ_file = GetRealFileName( Head.snf_file ) ) == NULL ){ + USAGE2("%s : It was not possible to refer to the substance of the font file. \"%s\"\n", argv[0], Head.snf_file ); + exit( 1 ); + } + + + if ( ( chk_fd = open( targ_file, O_RDWR ) ) < 0 ) { + USAGE2("%s : The font file of substance \"%s\" cannot be opened.\n", argv[0] , targ_file ); + exit( 1 ); + } + if ( isLock( chk_fd ) == 1 ) { + USAGE1("%s : Editing by other application.\n", argv[0] ); + close( chk_fd ); + exit( 1 ); + } + close( chk_fd ); + + /* + * open input file(CPF) + */ + if ( Head.in_file == NULL ) { + Head.input = stdin; + } else { + if ( ( Head.input = fopen( Head.in_file, "r" ) ) == NULL ) { + put_error_and_exit( &Head, GPF_OPEN_IN, argv[0] ); + } + } + + /* + * get GPF filename + */ + if ( !( Head.out_file = GetTmpPath( targ_file ) ) ) { + put_error_and_exit( &Head, MKTMP_ERROR, argv[0] ); + } + + if ( ( snf_fd = open( Head.snf_file, O_RDONLY ) ) >= 0 ) { + if ( ChkPcfFontFile( Head.snf_file) ) { + /* pcf */ + close( snf_fd ); + } + + } else { + put_error_and_exit( &Head, BDF_OPEN_IN, argv[0] ); + } + + + if ( pipe( pfd ) != 0 ) { + put_error_and_exit( &Head, PIPE_ERROR, argv[0] ); + } + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + switch ( chld_pid = fork() ) { + case 0: + if ( ( fd = open( Head.out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) { + put_error_and_exit( &Head, BDF_OPEN_OUT, argv[0] ); + } + close(0); + if ( dup( pfd[0] ) < 0 ) { + put_error_and_exit( &Head, DUP_ERROR, argv[0] ); + } + close( pfd[0] ); + close( pfd[1] ); + close( 1 ); + if ( dup( fd ) < 0 ) { + put_error_and_exit( &Head, DUP_ERROR, argv[0] ); + } + + + if ( ChkPcfFontFile( Head.snf_file ) == 0 ) { + execl( bdftopcf, bdftopcf, 0 ); + /* exec error */ + put_error_and_exit( &Head, PCFFONTC_ERROR, argv[0] ); + } + + COMM_SNF_EXECLBDFTOSNF( permission, buf, Head.snf_file ) ; + /* exec error */ + put_error_and_exit( &Head, SNFFONTC_ERROR, argv[0] ); + + case -1: + /* fork() error */ + put_error_and_exit( &Head, FORK_ERROR, argv[0] ); + + default: + break; + } + + close( pfd[0] ); + if ( ( Head.output = fdopen( pfd[1], "w" ) ) == NULL ) { + close( pfd[1] ); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + put_error_and_exit( &Head, FDOPEN_ERROR, argv[0] ); + } + + if ( ( rtn = CnvGPFtoBDF( &Head ) ) ) { + fclose( Head.input ); + fclose( Head.output ); + close( pfd[1] ); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + Unlink_Tmpfile( Head.out_file, argv[0] ); + put_error_and_exit( &Head, rtn, argv[0] ); + } + fclose( Head.output ); + close( pfd[1] ); + wait( &exit_stat ); +#if !defined( SVR4 ) && !defined( SYSV ) && !defined(__FreeBSD__) + if ( !WIFEXITED(exit_stat) ) { +#else + if (! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) { +#endif + USAGE3("%s: The error occurred by %s (%08x).\n", argv[0], bdftopcf, exit_stat ); + Unlink_Tmpfile( Head.out_file, argv[0] ); + exit( 1 ); + } + fclose( Head.input ); + signal( SIGHUP , SIG_IGN ); + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + sleep(1) ; + if ( (stat( Head.out_file,&statbuf ) ) || + ( statbuf.st_size == 0 ) ) { + Unlink_Tmpfile( Head.out_file, argv[0] ); + put_error_and_exit( &Head, BDF_WRITE, argv[0] ); + } + if ( stat( targ_file, &statbuf ) ) { + Unlink_Tmpfile( Head.out_file, argv[0] ); + put_error_and_exit( &Head, BDF_WRITE, argv[0] ); + } + + exit ( Make_NewFefFile( targ_file, Head.out_file, + FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, argv[0]) ); +} + + +static +CnvGPFtoBDF(struct ptobhead *head) +{ + int rtn; + char textbuf[BUFSIZE]; + + if ( ( rtn = ReadGpfHeader( head, textbuf ) ) ) { + return rtn; + } + + if ( ( rtn = WriteBdfHeader( head ) ) ) { + return rtn; + } + + if ( ( head->p_width != head->bdf_width ) || + ( head->p_height != head->bdf_height ) + ) { + head->zoomf = 1; + } else { + head->zoomf = 0; + } + + if ( ( head->code = (int *)malloc( sizeof(int) * head->num_chars ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( head->ptn = (char **)malloc( sizeof(char *)*head->num_chars ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( rtn = ReadGpfToMemory(head, textbuf ) ) ) { + return rtn; + } + + if ( ( rtn = WritePtnToBdf( head ) ) ) { + return rtn; + } + + return 0; +} + + +static void +put_error_and_exit(struct ptobhead *ptob, int er_no, char *prog_name) +{ + ErrMsgTable_AndExit( er_no, ptob->snf_file, ptob->out_file, + ptob->in_file, NULL, + ptob->bdf_file, + prog_name + ); + return; +} + + +static void +put_help(char *prog_name) +{ + USAGE1("Usage: %s -xlfd xlfd_name\n", prog_name); + USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n" ); + USAGE("\t\t [-style style] \n"); + COMM_HELP_MSG ; + USAGE("The character size may be obtained using the dtlsgpf command.\n"); + USAGE("\n"); +} diff --git a/cde/programs/dtudcfonted/dtcpgpf/Imakefile b/cde/programs/dtudcfonted/dtcpgpf/Imakefile new file mode 100644 index 000000000..4b1dac895 --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpgpf/Imakefile @@ -0,0 +1,28 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:44 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + UDC_INC_PATH1 = -I../libfal/include + UDC_INC_PATH2 = -I../include + UDC_INC_PATH3 = -I./ + + INCLUDES = $(UDC_INC_PATH1) $(UDC_INC_PATH2) $(UDC_INC_PATH3) + +LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + SRCS = cpgpf.c + + OBJS = cpgpf.o + +ComplexProgramTarget(dtcpgpf) diff --git a/cde/programs/dtudcfonted/dtcpgpf/cpgpf.c b/cde/programs/dtudcfonted/dtcpgpf/cpgpf.c new file mode 100644 index 000000000..33b030eba --- /dev/null +++ b/cde/programs/dtudcfonted/dtcpgpf/cpgpf.c @@ -0,0 +1,1217 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: cpgpf.c /main/6 1996/11/08 02:03:36 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <locale.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif + +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +#include "bdfgpf.h" + +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include <X11/fonts/fontstruct.h> + +#include "FaLib.h" +#include "snfstruct.h" +#include "udcutil.h" + +#include <errno.h> + +#define START_CODE 0 +#define END_CODE 1 +#define INPUT_FONT 0 +#define OUTPUT_FONT 1 + +#define RESIZE_BY_RATE( a, r ) ((int)( (float)(a) * (r))) +#define DEF_RESOLUTION ((78 / 72.27) * 100) + +static void put_error_and_exit(struct btophead *ptob_in, + struct ptobhead *ptob_out, + int er_no, + char *prog_name); +static void put_help(char *prog_name); +static void sigint_out(void); +static void getDefaultCh(unsigned int cbuf); +static void MkFontProp(int font_height, char *font, char *output); + +static int CpyGpfInit(struct btophead *i_gpf, + struct btophead *o_gpf, + struct ptobhead *w_gpf, + int type); +static int writeGpf(struct btophead *i_gpf, + struct btophead *o_gpf, + struct ptobhead *w_gpf); +static int check_width(char *prog_name, char *len_str); +static int check_height(char *prog_name, char *len_str); +static int check_width_height(char *prog_name, char *len_str, int mode); +static int getGpfFileName(char *com, + struct btophead *gpfinf, + int code_area, + int code_no, + char *xlfdname, + char *snf_file, + char *style); +static int readGpf(struct btophead *i_gpf, + char *buf, + int startcode, + int endcode, + int num_gr, + FalGlyphRegion *gr); +static int readBdfHeaderAndPut(struct btophead *o_gpf, + struct ptobhead *w_gpf, + char *buf); +static int check_code(char *prog_name, + char *code_str, + int mode, + char *charset, + int num_gr, + FalGlyphRegion *gr); +static int readBdfToMemory(struct btophead *head, + char *buf, + int startcode, + int endcode, + int num_gr, + FalGlyphRegion *gr); +static int cpg_atoi(char *numstr); +static int is_in_udcregion(int start, + int end, + int num_gr, + FalGlyphRegion *gr); + +extern int fal_code_to_glyph(char *locale, + unsigned long codepoint, + FalGIInf **gi, + int *num_gi); + +static struct ptobhead WriteGpf; + +static char *targ_file = NULL; /* UDC_file_name */ +static char *com = NULL; /* command_name */ +static char create_font[BUFSIZE] ; +static int new_target = 0 ; +static unsigned int firstCol, lastCol, firstRow, lastRow ; +static char *locale ; +static char *spacing ; +static char *char_set ; +static char *xlfdname ; + + +static void +sigint_out(void) +{ + if (WriteGpf.out_file) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + } + exit( 0 ); +} + + +int main(int argc, char **argv) +{ + int code_area , help, no_infile, no_style, type ; + int rtn, i, exit_code ; +#ifndef ROOT_ONLY + int exit_stat; +#endif + struct btophead InputGpf; /* input file */ + struct btophead OutputGpf; /* output file */ + struct stat statbuf; + char isnf_file[BUFSIZE] ; + char osnf_file[BUFSIZE] ; + char readbuf[BUFSIZE]; + char *istyle, *ostyle ; + char *ixlfdname, *oxlfdname ; + int chk_fd; + FalGlyphRegion *gr ; + int num_gr ; + char *start_code, *end_code ; + int startcode, endcode ; + + int code_no; + char *codeset = DEFAULT_CODESET; + + /* + * initiation of parameters + */ + com = argv[0]; + *create_font = '\0' ; + if( (locale = (char *)getenv( "LANG" )) == NULL ){ + locale = "C" ; + } + + memset( &InputGpf, 0, sizeof(struct btophead) ) ; + memset( &OutputGpf, 0, sizeof(struct btophead) ) ; + memset( &WriteGpf, 0, sizeof(struct ptobhead) ) ; + + COMM_SETDEFAULTSTYLE( istyle ) ; + COMM_SETDEFAULTSTYLE( ostyle ) ; + + InputGpf.in_file = OutputGpf.in_file = WriteGpf.out_file = NULL; + ixlfdname = oxlfdname = '\0' ; + spacing = char_set = xlfdname = NULL ; + + gr = NULL ; + num_gr = 0 ; + firstCol = firstRow = 0xff ; + lastCol = lastRow = 0 ; + + start_code = end_code = '\0' ; + startcode = MIN_CODE ; + endcode = MAX_CODE ; + + /* get full path of font compilers */ + if (!( bdftopcf = get_cmd_path( getenv( "PATH" ), BDFTOPCF_CMD ))) { + bdftopcf = BDFTOPCF; + } + if (!( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ))) { + oakgtobdf = SNFTOBDF; + } + if (!( bdftosnf = get_cmd_path( getenv( "PATH" ), BDFTOSNF_CMD ))) { + bdftosnf = BDFTOSNF; + } + /***************************************************************** + * check options + *****************************************************************/ + code_area = NORMAL; + help = no_infile = no_style = type = 0; + + for ( i = 1; i < argc; i++ ) { + if ( *argv[i] != '-' ) { + if( !InputGpf.in_file ){ + InputGpf.in_file = argv[i] ; + }else if( !OutputGpf.in_file ){ + OutputGpf.in_file = argv[i] ; + } else { + put_help(com); + exit( 1 ); + } + }else if ( !strcmp( argv[i], "-ig" ) ) { + if ( ( i < argc-1) && (*argv[i+1] != '-' ) ) { + InputGpf.in_file = argv[++i]; + } else { + no_infile = 1; + } + } else if ( !strcmp( argv[i], "-og" ) ) { + if ( (i < argc-1) && (*argv[i+1] != '-') ){ + OutputGpf.in_file = argv[++i]; + } else { + no_infile = 2; + } + } else if ( !strcmp( argv[i], "-system" ) ) { + code_area |= SYSTM; + } else if ( !strcmp( argv[i], "-help" ) ) { + help = 1; + } else if ( !strcmp(argv[i], "-width") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + OutputGpf.p_width = check_width( com, argv[++i]); + if (OutputGpf.p_width == 0) { + exit(1); + } + } else { + USAGE1("%s : The character width is not specified.\n", com); + exit( 1 ); + } + } else if ( !strcmp(argv[i], "-height") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + OutputGpf.p_height = check_height( argv[0], argv[++i]); + if (OutputGpf.p_height == 0) { + exit(1); + } + } else { + USAGE1("%s : The character height is not specified.\n", com); + exit(1); + } + } else if ( !strcmp(argv[i], "-start") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + start_code = argv[++i] ; + } else { + USAGE1("%s : The extract start code is not specified.\n", com); + exit( 1 ); + } + } else if ( !strcmp(argv[i], "-end" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) { + end_code = argv[++i] ; + } else { + USAGE1("%s : The extract end code is not specified.\n", com); + exit( 1 ); + } + } else if ( !strcmp( argv[i], "-istyle" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){ + istyle = argv[++i]; + } else { + no_style = 1; + } + } else if ( !strcmp( argv[i], "-ostyle" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){ + ostyle = argv[++i]; + } else { + no_style = 2; + } + } else if ( !strcmp( argv[i], "-codeset" ) ) { + if ( ( i < argc - 1 ) && ( *argv[i+1] != '-' )){ + codeset = argv[++i]; + COMM_SET_CODESET( codeset, code_area ) ; + } + } else if ( !strcmp( argv[i], "-ixlfd" ) ) { + if ( i < argc - 1 ){ + ixlfdname = argv[++i]; + } + } else if ( !strcmp( argv[i], "-oxlfd" ) ) { + if ( i < argc - 1 ){ + oxlfdname = argv[++i]; + } + } else if ( COMM_SBOPT_STRCMP( argv, i ) ) { + COMM_SBOPT_SETSBOPT( code_area ) ; + } else if ( COMM_TYPE_STRCMP( argv, i ) ) { + COMM_TYPE_SETTYPE( argc, argv, i, type ) ; + } else { + put_help(com); + exit( 1 ); + } + } + + /* help_message */ + if ( help == 1 ) { + put_help( com ); + exit( 0 ); + } + COMM_SBOPT_CHECKSBOPT( com, code_area ) ; + + if ( no_infile ) { + if ( no_infile == 1 ) + USAGE1("%s : The font file name for input cannot be omitted.\n", com ); + else + USAGE1("%s : The font file name for output cannot be omitted.\n", com ); + exit( 1 ); + } + + if ( (code_no = cpg_atoi( codeset)) == -1 ) { + USAGE1("%s : The code set number is illegal.\n", com ); + exit( 1 ); + } + + if ( no_style ) { + if ( no_style == 1 ) + USAGE1("%s : The style for input cannot be omitted.\n", com ); + else + USAGE1("%s : The style for output cannot be omitted.\n", com ); + USAGE1("%s : The style is not specified.\n", com ) ; + exit( 1 ); + } + + /***************************************************************** + * get file name + *****************************************************************/ + /* copy origin */ + if ( getGpfFileName( com, &InputGpf, code_area, code_no, ixlfdname, isnf_file, istyle ) ) { + exit( 1 ); + } + + /* copy target */ + if ( getGpfFileName( com, &OutputGpf, code_area, code_no, oxlfdname, osnf_file, ostyle ) ) { + exit( 1 ); + } + + /* + * refuse proportional fonts + */ + if( ( !stat( OutputGpf.in_file, &statbuf ) )){ + if ( GetUdcFontName( OutputGpf.in_file, NULL, &xlfdname ) ) { + USAGE2("%s : This font cannot get XLFD(%s). Terminates abnormally.\n", com, OutputGpf.in_file ); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s : cannot edit proportional fonts.(SPACING \"%s\")\n", com, spacing ); + exit( 1 ); + } + }else{ + /* new file */ + if( !(code_area & SYSTM) ){ + USAGE2("%s : \"%s\" does not exists.\n", com, OutputGpf.in_file ); + exit( 1 ); + } + } + if( xlfdname ) free( xlfdname ) ; + if ( GetUdcFontName( InputGpf.in_file, NULL, &xlfdname ) ) { + USAGE2("%s : This font cannot get XLFD(%s). Terminates abnormally.\n", com, InputGpf.in_file ); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s : cannot edit proportional fonts.(SPACING \"%s\")\n", com, spacing ); + exit( 1 ); + } + GETCHARSETSTR( char_set, xlfdname ) ; + + /***************************************************************** + * get UDC code region + *****************************************************************/ + if ( !(code_area & SYSTM) ) { + if ( GetUdcRegion( com, code_no, InputGpf.in_file, &num_gr, &gr ) ) { + USAGE1("%s : This font cannot get UDC code region. Terminates abnormally.\n", com); + exit( 1 ); + } + } else { + num_gr = 1 ; + if( (gr = (FalGlyphRegion *)malloc( sizeof(FalGlyphRegion) * num_gr )) == NULL ) { + USAGE1("%s : malloc error. Terminates abnormally.\n", com); + exit( 1 ); + } + gr[0].start = MIN_CODE ; + gr[0].end = MAX_CODE ; + } + + /* + * check specified code region + */ + if( start_code && end_code ) { + if( (startcode = check_code(com, start_code, START_CODE, char_set, num_gr, gr )) < 0 ) { + exit( 1 ); + } + if( (endcode = check_code(com, end_code, END_CODE, char_set, num_gr, gr )) < 0 ) { + exit( 1 ); + } + + if ( startcode > endcode ) { + USAGE1("%s : The specification of extract start/end code is improper.\n", com); + exit( 1 ); + } + + if( is_in_udcregion( startcode, endcode, num_gr, gr ) ){ + USAGE3("%s : The specified code \"%s-%s\" is outside of the UDC code region.\n", com, start_code, end_code ); + USAGE("The UDC code region of specified font is showed below.\n" ); + for( i=0; i<num_gr; i++ ) + USAGE2("\t0x%x-0x%x\n", gr[i].start, gr[i].end ); + exit( 1 ); + } + } + + /***************************************************************** + * check status of font file + *****************************************************************/ + /* get InputGpf.in_file */ + if ((targ_file = GetRealFileName( OutputGpf.in_file )) == NULL){ + if( errno == ENOENT && (code_area & SYSTM) ){ + /* create new file */ + if ( ( chk_fd = open( OutputGpf.in_file, O_RDWR | O_CREAT, 0644 ) ) < 0 ) { + USAGE2("%s : The font file of substance \"%s\" cannot be create.\n", com , OutputGpf.in_file ); + exit( 1 ); + } + targ_file = OutputGpf.in_file ; + new_target = 1 ; + close( chk_fd ); + }else{ + USAGE2("%s : It is not possible to refer to the substance of the font file. \"%s\"\n", com, OutputGpf.in_file); + exit(1); + } + } + WriteGpf.snf_file = targ_file; + + if ( ( chk_fd = open( targ_file, O_RDWR ) ) < 0 ) { + USAGE2("%s : The font file of substance \"%s\" cannot be opened.\n", com , targ_file ); + exit( 1 ); + } + if ( isLock( chk_fd ) == 1 ) { + USAGE2("%s : \"%s\" is opened by other application. \n", WriteGpf.snf_file, com ); + close( chk_fd ); + exit( 1 ); + } + close( chk_fd ); + + /***************************************************************** + * set code category to inner structure + *****************************************************************/ + + WriteGpf.start_code = MIN_CODE; + WriteGpf.end_code = MAX_CODE; + WriteGpf.code_category = ALL_CODE; + + COMM_SBFNT_SETUDCAREA( argv[0], OutputGpf, char_set, code_area, num_gr, gr ) ; + + /* + * CpyGpfInit() + * + * GPFTOBDF, BDFTOGPF + * + * (InputGpf.in_file) --> GPFTOBDF ==H + * H + * (OutputGpf.in_file) --> GPFTOBDF ==H + * H + * dtcpgpf + * H + * (WriteGpf.out_file) <-- BDFTOGPF ==H + * + */ + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + if ( rtn = CpyGpfInit( &InputGpf, &OutputGpf, &WriteGpf, type ) ) { + if ( WriteGpf.out_file ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + } + put_error_and_exit( &InputGpf, &WriteGpf, rtn, com ); + } + + /* read copy origin */ + if ( (rtn = readGpf( &InputGpf, readbuf, startcode, endcode, num_gr, gr )) ){ + if ( WriteGpf.out_file ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + } + put_error_and_exit( &InputGpf, &WriteGpf, rtn, com ); + } + fclose( InputGpf.input ); + + /* read copy target */ + if( (rtn = readBdfHeaderAndPut(&OutputGpf, &WriteGpf, readbuf)) ) { + if ( WriteGpf.out_file ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + } + put_error_and_exit( &InputGpf, &WriteGpf, rtn, com ); + } + fclose( OutputGpf.input ); + wait( 0 ); + + /* + * write SNF output file + */ + if ( ( rtn = writeGpf( &InputGpf, &OutputGpf, &WriteGpf ) ) ) { + if ( WriteGpf.out_file ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + } + put_error_and_exit( &InputGpf, &WriteGpf, rtn, com ); + } + +#ifdef ROOT_ONLY + if ( pclose( WriteGpf.output ) ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + put_error_and_exit( &InputGpf, &WriteGpf, PCLOSE_ERROR, com ); + } +#else + fclose( WriteGpf.output ); + wait( &exit_stat ); +#if !defined( SVR4 ) && !defined( SYSV ) + if ( !WIFEXITED(exit_stat) ) { +#else + if ( ! ( WIFEXITED(exit_stat) && !WEXITSTATUS(exit_stat) ) ) { +#endif + USAGE3("%s: The error occurred by %s (%08x).\n", com, oakgtobdf, exit_stat); + Unlink_Tmpfile( WriteGpf.out_file, com ); + put_error_and_exit( &InputGpf, &WriteGpf, FATAL_ERROR, com ); + } +#endif + signal( SIGHUP , SIG_IGN ); + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + sleep( 1 ); + if ( ( stat( WriteGpf.out_file, &statbuf ) ) || ( statbuf.st_size == 0 ) + ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + put_error_and_exit( &InputGpf, &WriteGpf, BDF_WRITE, com ); + } + if ( stat( WriteGpf.snf_file, &statbuf ) ) { + Unlink_Tmpfile( WriteGpf.out_file, com ); + exit( 1 ); + } + exit_code = Make_NewFefFile( WriteGpf.snf_file, WriteGpf.out_file, + FONT_FILE_PARM, (uid_t)statbuf.st_uid, (gid_t)statbuf.st_gid, com ) ; + + if( !exit_code ){ + if( *create_font != '\0' && new_target ) + fprintf( stdout, "%s : New font <%s> is created.\n", com, create_font ); + } + exit( exit_code ); +} + + +static int +getGpfFileName( +char *com, +struct btophead *gpfinf, +int code_area, +int code_no, +char *xlfdname, +char *snf_file, +char *style) +{ + + + if ( gpfinf->in_file == NULL && xlfdname == NULL ) { + if ( code_area & SYSTM ) { + USAGE1("%s : The GPF output file name cannot be omitted.\n", com ); + } else { /* string of charcter size */ + USAGE1("%s : The character size specification cannot be omitted.\n", com ); + } + return -1 ; + } + + /* open GPF file */ + if ( !(code_area & SYSTM) ) { + if( xlfdname ) { + if ( GetUdcFileName( com, code_no, xlfdname, snf_file ) ) { + USAGE2("%s : Failed to get font file.( XLFD: %s ) Terminates abnormally.\n", com, xlfdname ); + return -1 ; + } + gpfinf->in_file = snf_file ; + } else { + + switch ( GetFileName( com, gpfinf->in_file, style, code_no, snf_file ) ) { + case 0: + gpfinf->in_file = snf_file; + break; + case -1: + return -1 ; + default: + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", com); + return -1 ; + } + } + } + + return 0 ; +} + + +static +CpyGpfInit( +struct btophead *i_gpf, +struct btophead *o_gpf, +struct ptobhead *w_gpf, +int type) +{ + FontInfoRec *finf; + int ifd[2], ofd[2], snf_fd, permission; + char buf[BUFSIZE]; +#ifdef ROOT_ONLY + char command[BUFSIZE], *ep ; +#else + int pfd[2], out_fd ; +#endif + + /* SNF format */ + if( !new_target ){ + if ( ChkPcfFontFile( w_gpf->snf_file ) ) { + if( (snf_fd = open( w_gpf->snf_file, O_RDONLY ) ) >= 0 ) { + return BDF_OPEN_IN; + } + } + }else{ + COMM_SNF_NEWTARGET( permission ) ; + } + + /* open pipe for copy origin gpf */ + if (pipe(ifd) != 0) { + return PIPE_ERROR; + } + switch ( fork() ) { + case 0: + close( ifd[0] ); + close( 1 ); + if ( dup( ifd[1] ) < 0 ) { + return DUP_ERROR; + } + close( ifd[1] ); + /* SNFTOBDF */ + execl( oakgtobdf, oakgtobdf, i_gpf->in_file, 0 ); + return EXEC_ERROR; + case -1: + return FORK_ERROR; + default: + break; + } + close( ifd[1] ); + if ( ( i_gpf->input = fdopen( ifd[0], "r" ) ) == NULL ) { + return FDOPEN_ERROR; + } + + /* open pipe for copy target gpf */ + if (pipe(ofd) != 0) { + return PIPE_ERROR; + } + switch ( fork() ) { + case 0: + close( ofd[0] ); + close( 1 ); + if ( dup( ofd[1] ) < 0 ) { + return DUP_ERROR; + } + close( ofd[1] ); + /* SNFTOBDF */ + if( !new_target ){ + execl( oakgtobdf, oakgtobdf, o_gpf->in_file, "-H", 0 ); + }else{ + execl( oakgtobdf, oakgtobdf, i_gpf->in_file, "-H", 0 ); + } + return EXEC_ERROR; + case -1: + return FORK_ERROR; + default: + break; + } + close( ofd[1] ); + if ( ( o_gpf->input = fdopen( ofd[0], "r" ) ) == NULL ) { + return FDOPEN_ERROR; + } + + /* open pipe for target gpf */ + if ( !( w_gpf->out_file = GetTmpPath( targ_file ) ) ) { + return MKTMP_ERROR; + } + +#ifdef ROOT_ONLY + if( ChkPcfFontFile( w_gpf->snf_file ) == 0 ) { + sprintf(command, "%s > %s", bdftopcf, w_gpf->out_file) ; + } else { + COMM_SNF_POPEN( permission, w_gpf->snf_file, w_gpf->out_file, ep, buf, command ) ; + } + if ((w_gpf->output = popen(command, "w")) == NULL) { + return(POPEN_ERROR); + } +#else /* ROOT_ONLY */ + if ( pipe( pfd ) != 0 ) { + return PIPE_ERROR; + } + switch ( fork() ) { + case 0: + if ( ( out_fd = open( w_gpf->out_file, O_WRONLY | O_CREAT, 0664 ) ) < 0 ) { + return BDF_OPEN_OUT; + } + close( 0 ); + if ( dup(pfd[0]) < 0 ) { + return DUP_ERROR; + } + close( pfd[0] ); + close( pfd[1] ); + close( 1 ); + if( dup( out_fd ) < 0 ) { + close( out_fd ); + return DUP_ERROR; + } + close( out_fd ); + /* pcf format */ + if ( ChkPcfFontFile( w_gpf->snf_file ) == 0 ) { + execl( bdftopcf, bdftopcf, 0 ); + return PCFFONTC_ERROR; + } + /* snf format */ + if( type ) permission = type ; + COMM_SNF_EXECLBDFTOSNF( permission, buf, w_gpf->snf_file ) ; + return SNFFONTC_ERROR; + + case -1: + return FORK_ERROR; + default: + break; + } + close( pfd[0] ); + if ( ( w_gpf->output = fdopen( pfd[1], "w" ) ) == NULL ) { + return FDOPEN_ERROR; + } +#endif /* ROOT_ONLY */ + return 0; +} + + + +static int +readGpf( +struct btophead *i_gpf, +char *buf, +int startcode, +int endcode, +int num_gr, +FalGlyphRegion *gr) +{ + int nchar, rtn; + + if ( ( rtn = ReadBdfHeader( i_gpf, buf ) ) ) { + return rtn; + } + + nchar = i_gpf->num_chars ; + + if ( ( i_gpf->code = (int *)malloc( sizeof(int) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + if ( ( i_gpf->ptn = (char **)malloc( sizeof(char *) * nchar ) ) == NULL ) { + return MALLOC_ERROR; + } + + return readBdfToMemory( i_gpf, buf, startcode, endcode, num_gr, gr ) ; +} + + + +static int +readBdfHeaderAndPut(struct btophead *o_gpf, struct ptobhead *w_gpf, char *buf) +{ + FILE *fp ; + char *p; + int getstat, zoom, property ; + + getstat = zoom = property = 0 ; + + if( o_gpf->p_width || o_gpf->p_height ){ + zoom = 1 ; + } + if ( (fp = fopen( w_gpf->out_file, "w" )) == NULL ) { + return BDF_OPEN_HEAD ; + } + + while ( 1 ) { + if ( fgets( buf, BUFSIZE, o_gpf->input ) == NULL ) { + fclose(fp) ; + return BDF_INVAL; + } + p = buf; + SCAN_TO_NONSP( p ) + if ( !strncmp( p, SIZE, strlen( SIZE ) ) ) { + if ( ( sscanf( p, "SIZE %f%d", + &(o_gpf->bdf_point), &(o_gpf->bdf_xdpi))) != 2 ) { + fclose(fp) ; + return BDF_INVAL; + } + fprintf( fp, "%s", buf ); + getstat |= 0x01; + + } else if ( !strncmp( p, FONTBOUNDINGBOX, strlen( FONTBOUNDINGBOX ) ) ) { + if ( ( sscanf( p, "FONTBOUNDINGBOX %d%d%d%d", + &(o_gpf->bdf_width), &(o_gpf->bdf_height), + &(o_gpf->bdf_x), &(o_gpf->bdf_y) )) != 4) { + fclose(fp) ; + return BDF_INVAL; + } + /* -width / -height */ + if( zoom ){ + /* -width / -height */ + if( o_gpf->p_width ) o_gpf->bdf_width = o_gpf->p_width ; + if( o_gpf->p_height ) o_gpf->bdf_height = o_gpf->p_height ; + fprintf( fp, "FONTBOUNDINGBOX %d %d %d %d\n", + o_gpf->bdf_width, o_gpf->bdf_height, + o_gpf->bdf_x, o_gpf->bdf_y ); + }else{ + fprintf( fp, "%s", buf ); + } + getstat |= 0x02; + + } else if ( !strncmp( p, "ENDPROPERTIES", strlen( "ENDPROPERTIES" ) ) ) { + fprintf( fp, "%s", buf ); + fclose(fp) ; + getstat |= 0x04; + break; + } else { + + if( zoom ){ + if ( !strncmp( p, "STARTPROPERTIES", strlen( "STARTPROPERTIES" ) ) ) { + property = 1 ; + fprintf( fp, "%s", buf ); + } else if ( !strncmp( p, "FONT ", strlen( "FONT " ) ) ) { + char font[BUFSIZE] ; + if( property ){ + if( (sscanf( buf, "FONT \"%s\"", font )) != 1 ){ + fclose(fp) ; + return BDF_INVAL; + } + MkFontProp( o_gpf->bdf_height, font, create_font ) ; + fprintf( fp, "FONT \"%s\"\n", create_font ) ; + }else{ + if( (sscanf( buf, "FONT %s", font )) != 1 ){ + fclose(fp) ; + return BDF_INVAL; + } + MkFontProp( o_gpf->p_height, font, create_font ) ; + fprintf( fp, "FONT %s\n", create_font ) ; + } + } else if ( !strncmp( p, "PIXEL_SIZE ", strlen( "PIXEL_SIZE " ) ) ) { + fprintf( fp, "PIXEL_SIZE %d\n", o_gpf->bdf_height ) ; + } else if ( !strncmp( p, "AVERAGE_WIDTH ", strlen( "AVERAGE_WIDTH " ) ) ) { + fprintf( fp, "AVERAGE_WIDTH %d\n", o_gpf->bdf_height*10 ) ; + } else if ( !strncmp( p, "POINT_SIZE ", strlen( "POINT_SIZE " ) ) ) { + fprintf( fp, "POINT_SIZE %d\n", o_gpf->bdf_height*10 ); + } else if ( !strncmp( p, "RESOLUTION ", strlen( "RESOLUTION " ) ) ) { + int resol ; + if( (sscanf( buf, "RESOLUTION %d\n", &resol )) != 1 ){ + fclose(fp) ; + return BDF_INVAL; + } + fprintf( fp, "RESOLUTION %d\n", (int)((resol<0)?DEF_RESOLUTION:resol) ); + } else if ( !strncmp( p, "X_HEIGHT ", strlen( "X_HEIGHT " ) ) ) { + fprintf( fp, "X_HEIGHT %d\n", o_gpf->bdf_height ); + } else if ( !strncmp( p, "QUAD_WIDTH ", strlen( "QUAD_WIDTH " ) ) ) { + fprintf( fp, "QUAD_WIDTH %d\n", o_gpf->bdf_width ); + } else if ( !strncmp( p, "FONT_ASCENT ", strlen( "FONT_ASCENT " ) ) ) { + fprintf( fp, "FONT_ASCENT %d\n", (o_gpf->bdf_height + o_gpf->bdf_y) ); + } else if ( !strncmp( p, "FONT_DESCENT ", strlen( "FONT_DESCENT " ) ) ) { + fprintf( fp, "FONT_DESCENT %d\n", -(o_gpf->bdf_y) ); + } else if ( !strncmp( p, "DEFAULT_CHAR ", strlen( "DEFAULT_CHAR " ) ) ) { + fprintf( fp, "DEFAULT_CHAR %d\n", ((firstRow << 8) + firstCol) ); + } else { + fprintf( fp, "%s", buf ); + } + } else { /* zoom */ + fprintf( fp, "%s", buf ); + } + } + + } /* while loop */ + fclose(fp) ; + if ( getstat != 0x07 ) { + return BDF_INVAL; + } + + return 0; +} + + +static +writeGpf(struct btophead *i_gpf, struct btophead *o_gpf, struct ptobhead *w_gpf) +{ + FILE *fp ; + char rdbuf[BUFSIZE] ; + + /* put BDF header from temporary file */ + if ( (fp = fopen( w_gpf->out_file, "r" )) == NULL ) { + return BDF_OPEN_HEAD ; + } + while( fgets( rdbuf, BUFSIZE, fp ) != (char *)NULL ){ + fprintf( w_gpf->output, "%s", rdbuf ) ; + } + if( feof(fp) != 0 ){ + fclose(fp) ; + }else{ + fclose(fp) ; + return BDF_READ_HEAD ; + } + + /* set specified width or height */ + w_gpf->bdf_width = o_gpf->bdf_width ; + w_gpf->bdf_height = o_gpf->bdf_height ; + w_gpf->bdf_x = o_gpf->bdf_x; + w_gpf->bdf_y = o_gpf->bdf_y; + w_gpf->bdf_point = o_gpf->bdf_point; + w_gpf->bdf_xdpi = o_gpf->bdf_xdpi; + + w_gpf->p_width = i_gpf->bdf_width; + w_gpf->p_height = i_gpf->bdf_height; + + if( w_gpf->bdf_width != w_gpf->p_width || + w_gpf->bdf_height != w_gpf->p_height ) { + w_gpf->zoomf = 1; + }else{ + w_gpf->zoomf = 0; + } + + w_gpf->num_chars = i_gpf->num_chars; + w_gpf->code = i_gpf->code; + w_gpf->ptn = i_gpf->ptn; + + return WritePtnToBdf( w_gpf ); +} + + + +static int +check_width(char *prog_name, char *len_str) +{ + return( check_width_height( prog_name, len_str, 0) ); +} + + +static int +check_height(char *prog_name, char *len_str) +{ + return( check_width_height( prog_name, len_str, 1) ); +} + +static int +check_width_height(char *prog_name, char *len_str, int mode) +/* width ... 0 , height ... 1 */ +{ + int ret; + char *tmp; + + ret = (int)strtol( len_str, &tmp, 10 ); /* <-- ret = atoi( len_str ) */ + if ((tmp == len_str) || (ret < MIN_FONT_WIDTH) || (ret > MAX_FONT_WIDTH)) { + switch( mode ) { + case 0: + USAGE2("%s : The specification of the character width is improper.\"%s\"¡¥\n", + prog_name, len_str); + break; + case 1: + USAGE2("%s : The specification of the character height is improper.\"%s\"¡¥\n", + prog_name, len_str); + break; + default: + break; + } + return(0); + } + return( ret ); +} + + + +static int +check_code( +char *prog_name, +char *code_str, +int mode, /* start_code ... 0, end_code ... 1 */ +char *charset, +int num_gr, +FalGlyphRegion *gr) +{ + int err_flg = 0; + int code_num; + char *tmp; + FalGIInf *gi ; + int num_gi ; + int i, code ; + + code = (int)strtol(code_str, &tmp, 16); + if ( tmp == code_str ) { + err_flg = 1; + } + + if( COMM_SBFNT_ISSBFNT( charset ) ) { + code_num = code ; + CONVGLYPHINDEX( code_num ) ; + } else { + if( fal_code_to_glyph( locale, code, &gi, &num_gi) ) { + USAGE2("%s : Failed to convert code point into glyph index.\"%s\" \n", prog_name, code_str ) ; + err_flg = 1; + } + if( num_gi==1 ){ + code_num = gi[0].glyph_index ; + err_flg = 0 ; + }else{ + for( i=0; i<num_gi; i++ ) { + if( !strcmp( gi[i].charset_str, char_set ) ) { + code_num = gi[i].glyph_index ; + err_flg = 0 ; + break ; + } else err_flg = 1 ; + } + } + } + if( !err_flg ) { + for( i=0; i<num_gr; i++ ) { + if( (code_num >= gr[i].start) && (code_num <= gr[i].end) ) + return( code_num ); + } + err_flg = 1 ; + } + if (err_flg) { + switch( mode ) { + case 0: + USAGE2("%s : The specification of the extract start code is improper.\"%s\"¡¥\n", + prog_name, code_str); + break; + case 1: + USAGE2("%s : The specification of the extract end code is improper.\"%s\"¡¥\n", + prog_name, code_str); + break; + default: + USAGE2("%s : The specification of the extract code is improper.\"%s\"¡¥\n", + prog_name, code_str); + } + return(-1); + } + return(-1); + +} + + + +static int +readBdfToMemory( +struct btophead *head, +char *buf, +int startcode, +int endcode, +int num_gr, +FalGlyphRegion *gr) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + if ( !IsInRegion( code, num_gr, gr ) && + ( startcode > code || endcode < code ) + ){ + continue; + } + getDefaultCh( (unsigned int)code ) ; + + head->code[num_char] = code; + if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) { + return(MALLOC_ERROR); + } + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} + + +static void +getDefaultCh(unsigned int cbuf) +{ + if( (cbuf & 0xff) < firstCol ) firstCol = cbuf & 0xff ; + if( (cbuf >> 8) < firstRow ) firstRow = cbuf >> 8 ; + if( (cbuf & 0xff) > lastCol ) lastCol = cbuf & 0xff ; + if( (cbuf >> 8) > lastRow ) lastRow = cbuf >> 8 ; +} + + +static int +cpg_atoi(char *numstr) +{ + int val ; + char *ep, *cbuf ; + + ep = (char *)strchr( numstr, '\0' ) ; + val = (int)strtol( numstr, &cbuf, 10 ) ; + if ( cbuf == numstr || cbuf != ep ) { + return -1 ; + } + return val ; +} + +static int +is_in_udcregion( int start, int end, int num_gr, FalGlyphRegion *gr ) +{ + int i ; + if( start < gr[0].start && end < gr[0].start ){ + return -1 ; + } + for( i=0; i<num_gr-1; i++ ){ + if( (start > gr[i].end && start < gr[i+1].start ) + && (end > gr[i].end && end < gr[i+1].start ) + ) + return -1 ; + } + if( start > gr[num_gr-1].end && end > gr[num_gr-1].end ){ + return -1 ; + } + return 0 ; +} + + +static void +MkFontProp(int font_height, char *font, char *output) +{ + char fbuf[BUFSIZE], split[BUFSIZE] ; + char *ep, *pix_sz, *point_sz, *rsl_x, *av_width, *char_set ; + + snprintf( fbuf, sizeof(fbuf), "%s", font ) ; + snprintf( split, sizeof(split), "%s", font ) ; + ep = fbuf ; + ep += strlen( fbuf ) ; + ep-- ; + if( *ep == '"' ) *ep = '\0' ; + POINTXLFDELM( pix_sz, fbuf, XLFD_ELM_PIXEL_SIZE ) ; + POINTXLFDELM( point_sz, split, XLFD_ELM_POINT_SIZE ) ; + POINTXLFDELM( rsl_x, split, XLFD_ELM_RESOLUTION_X ) ; + POINTXLFDELM( av_width, split, XLFD_ELM_AVERAGE_WIDTH ) ; + POINTXLFDELM( char_set, fbuf, XLFD_ELM_CHARSET_REGISTRY ) ; + *pix_sz = '\0' ; + *av_width = '\0' ; + + sprintf(output, "%s-%d-%s-%d%s", fbuf, + font_height, /* pixel size */ + rsl_x, + font_height*10, /* average width */ + char_set ); +} + + + +static void +put_error_and_exit( +struct btophead *ptob_in, +struct ptobhead *ptob_out, +int er_no, +char *prog_name) +{ + ErrMsgTable_AndExit( er_no, ptob_in->in_file, ptob_out->out_file, + NULL, NULL, NULL, prog_name ); + return; +} + + + +static void +put_help(char *prog_name) +{ + USAGE1("Usage: %s -ixlfd oxlfd -oxlfd oxlfd\n", prog_name); + USAGE("\t[in_character_size][out_character_size]\n"); + USAGE("\t[-start start_code][-end end_code]\n"); + USAGE("\t[-istyle ostyle][-ostyle ostyle]"); + COMM_HELP_MSG ; + USAGE1("%s can copy glyphs of gpf file in the following code area.\n", prog_name); + USAGE("codeset \t\tcode area\n"); + USAGE("----------------------------------------\n"); + DispUdcCpArea(stdout) ; + USAGE("If the -start and -end option is omitted, the start/end code of each extractive area is specified.\n"); + USAGE("The xlfd name and character size may be obtained using dtlsgpf command.\n"); + return; +} diff --git a/cde/programs/dtudcfonted/dtgpftobdf/Imakefile b/cde/programs/dtudcfonted/dtgpftobdf/Imakefile new file mode 100644 index 000000000..e4e5a80df --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftobdf/Imakefile @@ -0,0 +1,25 @@ +XCOMM $XConsortium: Imakefile /main/8 1996/09/09 11:19:48 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../libfal/include\ + -I../include + +LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) -lc + + SRCS = gpftobdf.c + + OBJS = gpftobdf.o + +ComplexProgramTarget(dtgpftobdf) diff --git a/cde/programs/dtudcfonted/dtgpftobdf/bdftosnf.h b/cde/programs/dtudcfonted/dtgpftobdf/bdftosnf.h new file mode 100644 index 000000000..4a7b6f713 --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftobdf/bdftosnf.h @@ -0,0 +1,124 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: bdftosnf.h /main/4 1996/06/25 20:13:29 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include<X11/Xfuncs.h> + +#ifndef MIN +#define MIN(a,b) ((a)>(b)?(b):(a)) +#endif +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + +typedef struct _GlyphMap { + char *bits; + int h; + int w; + int widthBytes; +} GlyphMap; + +/* + * a structure to hold all the pointers to make it easy to pass them all + * around. Much like the FONT structure in the server. + */ + +typedef struct _TempFont { + FontInfoPtr pFI; + CharInfoPtr pCI; + unsigned char *pGlyphs; + FontPropPtr pFP; + CharInfoPtr pInkCI; + CharInfoPtr pInkMin; + CharInfoPtr pInkMax; +} TempFont; /* not called font since collides with type in X.h */ + +#ifdef vax +# define DEFAULTGLPAD 1 /* default padding for glyphs */ +# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ + +#elif defined(sun) + +# if (sun386 || sun5) +# define DEFAULTGLPAD 4 /* default padding for glyphs */ +# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ +# else +# define DEFAULTGLPAD 4 /* default padding for glyphs */ +# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ +# endif + +#elif defined(ibm032) + +# define DEFAULTGLPAD 1 /* default padding for glyphs */ +# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ + +#elif defined(hpux) + +# define DEFAULTGLPAD 2 /* default padding for glyphs */ +# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ + +#elif defined(mips) +# ifdef MIPSEL + +# define DEFAULTGLPAD 4 /* default padding for glyphs */ +# define DEFAULTBITORDER LSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER LSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ + +# else +# define DEFAULTGLPAD 4 /* default padding for glyphs */ +# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ +# endif + +#else +# define DEFAULTGLPAD 1 /* default padding for glyphs */ +# define DEFAULTBITORDER MSBFirst /* default bitmap bit order */ +# define DEFAULTBYTEORDER MSBFirst /* default bitmap byte order */ +# define DEFAULTSCANUNIT 1 /* default bitmap scan unit */ +#endif + +#define GLWIDTHBYTESPADDED(bits,nbytes) \ + ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ + :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \ + :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \ + :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \ + : 0) diff --git a/cde/programs/dtudcfonted/dtgpftobdf/gpftobdf.c b/cde/programs/dtudcfonted/dtgpftobdf/gpftobdf.c new file mode 100644 index 000000000..41db3ad36 --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftobdf/gpftobdf.c @@ -0,0 +1,1545 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: gpftobdf.c /main/5 1996/11/08 02:04:24 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> +#include <X11/fonts/font.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include <X11/Xmd.h> +#include <X11/Intrinsic.h> +#include <ctype.h> +#include <errno.h> +#include <X11/fonts/fontstruct.h> +#include "snfstruct.h" +#include <time.h> +#include "bdftosnf.h" +#include <memory.h> +#if defined( SVR4 ) +#include <sys/mman.h> +#endif + +#include "udccom.h" +#include "udcutil.h" + +#define GLYPHPADOPTIONS 4 +#define SIZEOF_COMPRESSED_METRIC 5 + +#include "gtobdf.h" +#include "pcf.h" + +typedef struct pcf_tmp { + FontInfoRec info; + int ntables; + PCFTablePtr tables; + int nprops; + FontPropPtr props; + char *isStringProp; + int str_length; + char *string; + int nbitmaps; + CARD32 bmp_fmt; /* bitOrder ,byteOrder, glyph, scan */ + CARD32 *offsets; + int sizebitmaps; + char *bitmaps; + CARD32 enc_fmt; + CARD16 *encodingOffsets; + size_t pcf_bufsz; + caddr_t pcf_buffer; + + /* scale width */ + CARD32 swd_fmt ; + int swd_num ; + CARD32 *swidth ; + + /* glyph name */ + CARD32 glyph_fmt ; + unsigned int glyphs ; + int *glyph_offset ; + char *glyph_name ; + + /* metrics */ + int compress ; + CARD32 mtr_fmt ; + int mtr_num ; + xCharInfo *metrics; + +} PcfTmp; + +typedef struct prop_tmp { + char *font_name; + FontPropRec psize; + FontPropRec resolution; +} PropTmp; + + + +static char *readfontfile(char *fname); +static void Anafprop(FontInfoRec *fip, + FontPropRec *fpropPtr, + char *fpropvnPtr, + char **fontname, + FontPropRec **fplistPtr, + FontPropRec *ps, + FontPropRec *res, + unsigned int *fplistNum); +static void pSIZE(FontPropRec *ps, FontPropRec *res); +static void pPROPS(FontInfoRec *fip, + FontPropRec *fplistPtr, + unsigned int fplistNum); +static void pCHARS(FontInfoRec *fip, + CharInfoRec *cip, + char *glyphPtr, + unsigned int charNum, + unsigned int glyphPad); +static void pfixCHARS(FontInfoRec *fip, + CharInfoRec *cip, + char *glyphPtr, + unsigned int charNum, + unsigned int glyphPad); +static int getarg(int argc, + char *argv[], + char *fname, + int *bitorder, + int *byteorder, + int *scanunit, + int *glyphPad, + int *outLevel, + int *fix); + +static Bool seekToType(PCFTablePtr tables, + int ntables, + CARD32 type, + CARD32 *formatp, + CARD32 *sizep, + CARD32 *offsetp); +static void getMetric(caddr_t buf, CARD32 format, xCharInfo *metric) ; +static Bool getAccel(FontInfoPtr pFontInfo, + xCharInfo *maxink, + caddr_t buf_top, + PCFTablePtr tables, + int ntables, + CARD32 type); +static Bool getProperties(PcfTmp *pcf, + caddr_t buf_top, + PCFTablePtr tables, + int ntables); +static void putPtn(unsigned char *bits, int width, int height); +static void ByteSwap(char *p, int scan); +static void invertBits(char *src, + CARD32 format, + int width, + int height, + char *dest) ; + +static int getINT16(unsigned char *p, CARD32 format); +static int getINT32(unsigned char *p, CARD32 format); +static CARD32 getLSB32(unsigned char *p); +static char *make_toptn(int width, int height); +static void pSIZE_pcf(PropTmp *proptmp); +static PcfTmp *openPcfFont(char *fontname); +static void setProp(PcfTmp *pcf, PropTmp *proptmp); +static void pPROPS_pcf(PcfTmp *pcf); +static void pCHARS_pcf(PcfTmp *pcf, int fix); +static void BitOrderInvert(unsigned char *buf, int nbytes); +static char *bufp,buf[2048]; + +extern int ChkPcfFontFile(char *filename); + + +int main( int argc, char *argv[] ) +{ + int i,k; + + + char *fp; /* font */ + FontInfoRec *fip; /* font information */ + CharInfoRec *cip, *wkcip; /* character information */ + unsigned int glyphstotal; /* glyph */ + unsigned int charInfoNum ; /* character information's number */ + unsigned int charNum; /* define character number */ + char *glyphPtr; /* glyph */ + FontPropRec *fpropPtr,*fplistPtr; /* font property list */ + FontPropRec psprop; /* point size property */ + FontPropRec resprop; /* resolution property */ + char *fpropvnPtr; + + unsigned int fplistNum; /* font property number */ + char *fontname; /* fontname */ + time_t clock; + struct tm *tm; + char tmbuf[80] ; + + char fname[1024]; /* snf filename */ + int bitorder; /* bitorder */ + int byteorder; /* byteorder */ + int scanunit; /* scanunit */ + int glyphPad ; /* glyph */ + int outLevel; /* output information level */ + int fix; + + + int isPcf; + + PcfTmp *pcf; + PropTmp proptmp; + char *tmpfname; + extern char *GetRealFileName(); + + + if (getarg(argc,argv,fname,&bitorder,&byteorder,&scanunit,&glyphPad, + &outLevel,&fix) != 0) { + exit( -1 ); + } + + /* + * read to fontfile + */ + if ( ( tmpfname = GetRealFileName( fname ) ) == NULL ) { + USAGE("dtgpftobdf: cannot refer to substance file.\n" ); + exit( -1 ); + } + if ( strcmp( tmpfname, fname ) != 0 ){ + strcpy( fname, tmpfname ); + } + + if ( ChkPcfFontFile( fname ) == 0 ){ + /* pcf font */ + isPcf = 1; + if ( !( pcf = openPcfFont( fname ) ) ) { + USAGE("dtgpftobdf: cannot open font\n" ); + exit( -1 ); + } + } else { + /* snf font */ + isPcf = 0; + if ( ( fp = readfontfile( fname ) ) == (char *)-1 ) { + exit( -1 ); + } + } + + + if ( !isPcf ) { + /* SNF format */ + COMM_SNF_GETHEADER( fip, fp ) ; + + cip = (CharInfoRec *)((char *)fip + sizeof(FontInfoRec)); + + charInfoNum = (fip->lastCol - fip->firstCol + 1) + *(fip->lastRow - fip->firstRow + 1); + glyphPtr = ((char *)cip) + ( charInfoNum * sizeof(CharInfoRec) ); + + charNum = charInfoNum ; + wkcip = cip ; + + glyphPad = (((fip->maxbounds.rightSideBearing + - fip->maxbounds.leftSideBearing)+31)/32)*4; + + if ( fix == TRUE ) { + for ( i = 0; i < charInfoNum; i++ ) { + wkcip++; + } + } else { + glyphstotal = 0 ; + for ( i = 0; i < charInfoNum; i++ ) { + glyphstotal += (wkcip->metrics.ascent + + wkcip->metrics.descent) * glyphPad; + wkcip++; + } + } + + fpropPtr = (FontPropRec *)(glyphPtr + glyphstotal); + fpropvnPtr = ((char *)fpropPtr) + (fip->nprops) * sizeof(FontPropRec); + + } + + + if ( isPcf ) { + setProp( pcf, &proptmp ); + } else { + fontname = (char *)0; + Anafprop( + fip, fpropPtr, fpropvnPtr, + &fontname, &psprop, &resprop, + &fplistPtr, &fplistNum + ); + } + + /* + *¡¡output to BDF information + */ + bufp = buf; + memcpy(bufp,"STARTFONT 2.1\n",14); + bufp += 14; + memcpy(bufp,"COMMENT\n",8); + bufp += 8; + memcpy(bufp,"COMMENT This BDF was created by dtgpftobdf.\n",45 ); + bufp += 45 ; + memcpy(bufp,"COMMENT\n",8); + bufp += 8; + time(&clock); + tm = localtime(&clock); + + snprintf( tmbuf, sizeof(tmbuf), "%s", asctime(tm) ) ; + + k = sprintf(bufp,"COMMENT Created date : %s\n",tmbuf ); + bufp += k-1; + memcpy(bufp,"COMMENT\n",8); + bufp += 8; + + if ( isPcf ) { + k = sprintf(bufp,"FONT %s\n",proptmp.font_name); + bufp += k; + *bufp = '\0'; + fprintf( stdout,"%s",buf ); + pSIZE_pcf( &proptmp ); + fprintf( stdout,"FONTBOUNDINGBOX %d %d %d %d\n", + pcf->info.maxbounds.rightSideBearing + - pcf->info.maxbounds.leftSideBearing, + pcf->info.maxbounds.ascent + + pcf->info.maxbounds.descent, + pcf->info.maxbounds.leftSideBearing, + - ( pcf->info.maxbounds.descent ) + ); + pPROPS_pcf( pcf ); + if ( outLevel == FALSE ) { + pCHARS_pcf( pcf, fix ); + } + } else { + k = sprintf( bufp,"FONT %s\n",fontname ); + bufp += k; + *bufp = '\0'; + fprintf( stdout,"%s",buf ); + pSIZE( &psprop, &resprop ); + fprintf( stdout,"FONTBOUNDINGBOX %d %d %d %d\n", + cip->metrics.rightSideBearing + - cip->metrics.leftSideBearing, + cip->metrics.ascent + cip->metrics.descent, + cip->metrics.leftSideBearing, + -(cip->metrics.descent) + ); + pPROPS( fip,fplistPtr,fplistNum ); + if ( outLevel == FALSE ) { + if ( fix == TRUE ) { + pfixCHARS( fip,cip,glyphPtr,charNum, glyphPad ); + } else { + pCHARS(fip,cip,glyphPtr,charNum,glyphPad); + } + } + + } + + fprintf( stdout,"ENDFONT\n" ); + exit( 0 ); +} + +/* + * read to font file + */ +static char *readfontfile( char *fname ) +{ + int fd; + char *fp = NULL; + struct stat stat; + + fd = open( fname,O_RDONLY ); + if ( fd < 0 ) { + USAGE("dtgpftobdf: can't open file.\n" ); + return ( char * )-1; + } +#if defined( SVR4 ) + if ( fstat( fd,&stat ) == 0 ) { + fp = (char *)mmap( 0, stat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); + if ( fp == (char *)-1 ) { + if ( ( fp = ( char * )malloc( stat.st_size ) ) == NULL ) { + USAGE("dtgpftobdf: malloc error.\n" ); + close( fd ); + return ( char * )-1; + } +/* if ( read( fd, fp, stat.st_size ) < 0 ) {*/ + if ( read( fd, fp, stat.st_size ) != stat.st_size ) { + USAGE("dtgpftobdf: can't read file.\n" ); + close( fd ); + return ( char * )-1; + } + } + } else { + USAGE("dtgpftobdf: can't read file\n" ); + close( fd ); + return ( char * )-1; + } + close( fd ); +#else /* pfa */ + if ( fstat(fd,&stat) == 0 ) { + if ( ( fp = (char *)malloc(stat.st_size) ) == NULL ) { + USAGE("dtgpftobdf: malloc error.\n" ); + close( fd ); + return ( char * )-1; + } + if ( read( fd, fp, stat.st_size ) < 0 ) { + USAGE("dtgpftobdf: can't read file.\n" ); + close( fd ); + free(fp); + return ( char * )-1; + } + } else { + USAGE("dtgpftobdf: can't read file\n" ); + close( fd ); + return ( char * )-1; + } + close( fd ); +#endif /* pfa */ + return fp; +} + + +#define getINT8( p ) ( *p++ ) ; + +static CARD32 +getLSB32( unsigned char *p ) +{ + CARD32 c; + + c = *p++; + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p) << 24; + + return c; +} + + +static int +getINT32( unsigned char *p, CARD32 format ) +{ + CARD32 c; + + if ( PCF_BYTE_ORDER(format) == MSBFirst ) { + c = (CARD32)(*p++) << 24; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p); + } else { + c = (CARD32)(*p++); + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p) << 24; + } + + return ( int )c; +} + +static int +getINT16( unsigned char *p, CARD32 format ) +{ + CARD32 c; + + if ( PCF_BYTE_ORDER(format) == MSBFirst ) { + c = (CARD32)(*p++) << 8; + c |= (CARD32)(*p); + } else { + c = (CARD32)(*p++); + c |= (CARD32)(*p) << 8; + } + + return ( int )c; +} + +static Bool +seekToType( +PCFTablePtr tables, +int ntables, +CARD32 type, +CARD32 *formatp, +CARD32 *sizep, +CARD32 *offsetp) +{ + int i; + + for ( i = 0; i < ntables; i++ ) { + if ( getLSB32( (unsigned char *)&tables[i].type) == type) { + *formatp = getLSB32( (unsigned char *)&tables[i].format); + *sizep = getLSB32( (unsigned char *)&tables[i].size); + *offsetp = getLSB32( (unsigned char *)&tables[i].offset); + return TRUE; + } + } + return FALSE; +} + + +static void +getMetric( caddr_t buf, CARD32 format, xCharInfo *metric) +{ + metric->leftSideBearing = getINT16( (unsigned char *)buf, format); + buf += 2; + metric->rightSideBearing = getINT16( (unsigned char *)buf, format); + buf += 2; + metric->characterWidth = getINT16( (unsigned char *)buf, format); + buf += 2; + metric->ascent = getINT16( (unsigned char *)buf, format); + buf += 2; + metric->descent = getINT16( (unsigned char *)buf, format); + buf += 2; + metric->attributes = getINT16( (unsigned char *)buf, format); + buf += 2; +} + +static Bool +getAccel( +FontInfoPtr pFontInfo, +xCharInfo *maxink, +caddr_t buf_top, +PCFTablePtr tables, +int ntables, +CARD32 type) +{ + CARD32 format; + CARD32 size; + CARD32 offset; + caddr_t buffer; + + if ( !seekToType( tables, ntables, type, &format, &size, &offset)) { + return FALSE; + } + + buffer = buf_top + offset; + format = getLSB32( (unsigned char *)buffer); + buffer += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) + && !PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) + ) { + return FALSE; + } + pFontInfo->noOverlap = *buffer++; + pFontInfo->constantMetrics = *buffer++; + pFontInfo->terminalFont = *buffer++; + pFontInfo->constantWidth = *buffer++; + pFontInfo->inkInside = *buffer++; + pFontInfo->inkMetrics = *buffer++; + pFontInfo->drawDirection = *buffer++; + /* natural alignment */ + + buffer++; + + pFontInfo->fontAscent = getINT32( (unsigned char *)buffer, format); + buffer += 4; + + pFontInfo->fontDescent = getINT32((unsigned char *)buffer, format); + buffer +=4; + + buffer += 4; + + getMetric(buffer, format, &pFontInfo->minbounds); + buffer += 12; + + getMetric(buffer, format, &pFontInfo->maxbounds); + buffer += 12; + + if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ) { + buffer += 12; + getMetric( buffer, format, maxink); + } else { + *maxink = pFontInfo->maxbounds; + } + + return TRUE; +} + +static Bool +getProperties(PcfTmp *pcf, caddr_t buf_top, PCFTablePtr tables, int ntables) +{ + CARD32 format; + CARD32 size; + CARD32 offset; + caddr_t buffer; + int i; + + if ( !seekToType( tables, ntables, (CARD32)PCF_PROPERTIES, &format, &size, &offset ) ) { + return FALSE; + } + + buffer = buf_top + offset; + format = getLSB32( (unsigned char *)buffer ); + buffer += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + return FALSE; + } + pcf->nprops = getINT32((unsigned char *)buffer, format); + buffer += 4; + + if ( !( pcf->props = ( FontPropPtr )malloc( pcf->nprops * sizeof( FontPropRec ) ) ) ) { + return FALSE; + } + + if ( !( pcf->isStringProp = ( char * )malloc(pcf->nprops * sizeof( char ) ) ) ) { + return FALSE; + } + + for ( i = 0; i < pcf->nprops; i++ ) { + pcf->props[i].name = getINT32((unsigned char *)buffer, format); + buffer += 4; + pcf->isStringProp[i] = *buffer++; + pcf->props[i].value = getINT32((unsigned char *)buffer, format); + buffer += 4; + } + if ( pcf->nprops & 3 ) { + i = 4 - (pcf->nprops & 3); + buffer += i; + } + + pcf->str_length = getINT32((unsigned char *)buffer, format); + buffer += 4; + + pcf->string = (char *)buffer; + return TRUE; +} + + +static PcfTmp * +openPcfFont(char *fontname) +{ + PcfTmp *pcf_tmp; + + CARD32 format; + CARD32 size; + CARD32 offset; + CARD32 *bitmapSizes; + xCharInfo maxink; + caddr_t buffp; + struct stat st; + + pcf_tmp = ( PcfTmp * )calloc( 1, sizeof( PcfTmp ) ); + + while(1){ + + if ( !pcf_tmp ) { + USAGE("dtgpftobdf : calloc() error.\n" ) ; + break; + } + + if ( stat( fontname, &st ) ) { + break; + } + + if ( ( pcf_tmp->pcf_buffer = readfontfile( fontname)) == (char *)-1 ) { + break; + } + + pcf_tmp->pcf_bufsz = st.st_size; + + if ( (format = getLSB32( (unsigned char *)pcf_tmp->pcf_buffer )) != PCF_FILE_VERSION ) { + USAGE1("dtgpftobdf : pcf file version(0x%x) error.\n", format ) ; + break; + } + + pcf_tmp->ntables = getLSB32( (unsigned char *)(pcf_tmp->pcf_buffer + 4) ); + pcf_tmp->tables = (PCFTablePtr)(pcf_tmp->pcf_buffer + 8 ); + + if ( !getAccel( + &pcf_tmp->info, &maxink, pcf_tmp->pcf_buffer, + pcf_tmp->tables, pcf_tmp->ntables, (CARD32)PCF_BDF_ACCELERATORS + ) + ) { + if ( !getAccel( + &pcf_tmp->info, &maxink, pcf_tmp->pcf_buffer, + pcf_tmp->tables, pcf_tmp->ntables, (CARD32)PCF_ACCELERATORS + ) + ) { + USAGE("dtgpftobdf : Cannot get accelerators.\n" ) ; + break; + } + } + + if ( !getProperties( + pcf_tmp, pcf_tmp->pcf_buffer, + pcf_tmp->tables, pcf_tmp->ntables + ) + ) { + USAGE("dtgpftobdf : getProperties error.\n" ) ; + break; + } + if ( !seekToType( + pcf_tmp->tables, pcf_tmp->ntables, + (CARD32)PCF_BITMAPS, &format, &size, &offset + ) + ) { + USAGE("dtgpftobdf : PCF_BITMAPS error.\n" ) ; + break; + } + + buffp = pcf_tmp->pcf_buffer + offset; + + format = getLSB32( (unsigned char *)buffp); + buffp += 4; + + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + USAGE("dtgpftobdf : error.!PCF_FORMAT_MATCH(PCF_BITMAPS)\n" ) ; + break; + } + + pcf_tmp->nbitmaps = getINT32( (unsigned char *)buffp, format); + buffp += 4; + pcf_tmp->offsets = (CARD32 *)buffp; + buffp += sizeof( *pcf_tmp->offsets) * pcf_tmp->nbitmaps; + + + bitmapSizes = (CARD32 *)buffp; + pcf_tmp->sizebitmaps + = getINT32( (unsigned char *)&bitmapSizes[PCF_GLYPH_PAD_INDEX(format)], format); + pcf_tmp->bmp_fmt = format; + buffp += sizeof( *bitmapSizes) * GLYPHPADOPTIONS; + pcf_tmp->bitmaps = buffp; + buffp += pcf_tmp->sizebitmaps; + + if ( !seekToType( + pcf_tmp->tables, pcf_tmp->ntables, + (CARD32)PCF_BDF_ENCODINGS, &format, &size, &offset + ) + ) { + USAGE("dtgpftobdf : error.(PCF_BDF_ENCODINGS)\n" ) ; + break; + } + + buffp = pcf_tmp->pcf_buffer + offset; + format = getLSB32( (unsigned char *)buffp); + buffp += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + USAGE("dtgpftobdf : error.!PCF_FORMAT_MATCH(PCF_BDF_ENCODINGS)\n" ) ; + break; + } + + pcf_tmp->info.firstCol = getINT16( (unsigned char *)buffp, format); + buffp += 2; + pcf_tmp->info.lastCol = getINT16( (unsigned char *)buffp, format); + buffp += 2; + pcf_tmp->info.firstRow = getINT16( (unsigned char *)buffp, format); + buffp += 2; + pcf_tmp->info.lastRow = getINT16( (unsigned char *)buffp, format); + buffp += 2; + pcf_tmp->info.defaultCh = getINT16( (unsigned char *)buffp, format); + buffp += 2; + + pcf_tmp->info.allExist = FALSE; + pcf_tmp->enc_fmt = format; + pcf_tmp->encodingOffsets = (CARD16 *)buffp; + + /* + * get scale width infomations + */ + if ( !seekToType( + pcf_tmp->tables, pcf_tmp->ntables, + (CARD32)PCF_SWIDTHS, &format, &size, &offset + ) + ) { + break; + } + + buffp = pcf_tmp->pcf_buffer + offset; + format = getLSB32( (unsigned char*)buffp); + buffp += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + break; + } + pcf_tmp->swd_fmt = (CARD32)format ; + pcf_tmp->swd_num = getINT32( (unsigned char*)buffp, format ) ; + buffp += 4; + + pcf_tmp->swidth = (CARD32 *)buffp ; + + /* + * get glyph names + */ + if ( !seekToType( + pcf_tmp->tables, pcf_tmp->ntables, + (CARD32)PCF_GLYPH_NAMES, &format, &size, &offset + ) + ) { + break; + } + + buffp = pcf_tmp->pcf_buffer + offset; + format = getLSB32( (unsigned char*)buffp); + buffp += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + break; + } + pcf_tmp->glyphs = getINT32( (unsigned char*)buffp, format ) ; + buffp += 4; + pcf_tmp->glyph_offset = (int *)buffp ; + buffp += 4 * (pcf_tmp->glyphs + 1) ; + pcf_tmp->glyph_name = (char *)buffp ; + pcf_tmp->glyph_fmt = (CARD32)format ; + + /* + * get metrics + */ + if ( !seekToType( + pcf_tmp->tables, pcf_tmp->ntables, + (CARD32)PCF_METRICS, &format, &size, &offset + ) + ) { + break; + } + + buffp = pcf_tmp->pcf_buffer + offset; + format = getLSB32( (unsigned char*)buffp); + buffp += 4; + if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { + pcf_tmp->compress = 0 ; + pcf_tmp->mtr_num = getINT32( (unsigned char*)buffp, format ) ; + buffp += 4; + }else if ( PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ) { + pcf_tmp->compress = 1 ; + pcf_tmp->mtr_num = (int)getINT16( (unsigned char*)buffp, format ) ; + buffp += 2; + }else{ + break; + } + pcf_tmp->metrics = (xCharInfo *)buffp ; + pcf_tmp->mtr_fmt = (CARD32)format ; + + return pcf_tmp; + } + if ( pcf_tmp ) { + free( pcf_tmp ); + } + return NULL; +} + + +static void +Anafprop( +FontInfoRec *fip, +FontPropRec *fpropPtr, +char *fpropvnPtr, +char **fontname, +FontPropRec **fplistPtr, +FontPropRec *ps, +FontPropRec *res, +unsigned int *fplistNum) +{ + FontPropRec *wkp ,*wklp; + int i, fpnL; + char *fpnp; + + *fplistNum = fip->nprops - 1; + *fplistPtr = (FontPropRec *)malloc(*fplistNum * sizeof(FontPropRec)); + wkp = fpropPtr; + wklp = *fplistPtr; + for (i = 0; i < fip->nprops; i++) { + fpnp = fpropvnPtr + wkp->name; + fpnL = strlen(fpnp); + if ((fpnL == 4) && (strncmp(fpnp,"FONT",4) == 0)) { + *fontname = fpropvnPtr + wkp->value; + wkp++; + continue; + } + if (fpnL == 10) { + if (strncmp(fpnp,"POINT_SIZE",10) == 0) { + ps->value = wkp->value; + } + if (strncmp(fpnp,"RESOLUTION",10) == 0) { + res->value = wkp->value; + } + } + wklp->name = (CARD32) (intptr_t) fpropvnPtr + wkp->name; + wklp->value = wkp->value; + wkp++; + wklp++; + } +} + + + +static void +setProp( PcfTmp *pcf, PropTmp *proptmp ) +{ + int i, fpnL; + char *fpnp; + + for ( i = 0; i < pcf->nprops; i++ ) { + fpnp = pcf->string + pcf->props[i].name; + fpnL = strlen(fpnp); + if ( ( fpnL == 4 ) && ( strncmp( fpnp,"FONT", 4 ) == 0 ) ) { + proptmp->font_name = pcf->string + pcf->props[i].value; + continue; + } + if ( fpnL == 10 ) { + if ( strncmp( fpnp,"POINT_SIZE", 10 ) == 0 ) { + proptmp->psize.value = pcf->props[i].value; + } else if ( strncmp( fpnp, "RESOLUTION", 10 ) == 0 ) { + proptmp->resolution.value = pcf->props[i].value; + } + } + } +} + + + +/* + * output to SIZE (SIZE point resolutionX resolutionY) + * + */ +static void +pSIZE( FontPropRec *ps, FontPropRec *res ) +{ + int k; + float f; + char buf1[16], buf2[16]; + + f = ps->value / 10.0; + if ( ( ps->value % 10 ) != 0 ) { + sprintf( buf1, "%.1f", f ); + } else { + sprintf( buf1, "%.0f", f ); + } + k = ( ( res->value * 72.27 ) / 100.0 ) + 1; + sprintf( buf2, "%d %d", k, k ); + fprintf( stdout, "SIZE %s %s\n", buf1, buf2 ); + return; +} + + +/* output to SIZE of pcf font */ + +static void +pSIZE_pcf( PropTmp *proptmp ) +{ + int k; + float f; + char buf1[16],buf2[16]; + + f = proptmp->psize.value / 10.0; + if ( ( proptmp->psize.value % 10 ) != 0 ) { + snprintf( buf1, sizeof(buf1), "%.1f",f ); + } else { + snprintf( buf1, sizeof(buf1), "%.0f",f); + } + k = ( ( proptmp->resolution.value * 72.27 ) / 100.0 ) + 1; + snprintf( buf2, sizeof(buf2), "%d %d", k, k ); + fprintf( stdout,"SIZE %s %s\n", buf1, buf2 ); + return; +} + + + +static void +pPROPS( FontInfoRec *fip, FontPropRec *fplistPtr, unsigned int fplistNum ) +{ + FontPropRec *wkp; + int i, k; + + bufp = buf; + k = snprintf( bufp, sizeof(buf), "STARTPROPERTIES %d\n", fplistNum+3 ); + bufp += k; + k = snprintf( bufp, sizeof(buf) - (bufp - buf), "FONT_ASCENT %d\n", fip->fontAscent ); + bufp += k; + k = snprintf( bufp, sizeof(buf) - (bufp - buf), "FONT_DESCENT %d\n", fip->fontDescent ); + bufp += k; + k = snprintf( bufp, sizeof(buf) - (bufp - buf), "DEFAULT_CHAR %d\n", fip->defaultCh ); + bufp += k; + wkp = fplistPtr; + for ( i = 0; i < fplistNum; i++ ) { + k = snprintf( bufp, sizeof(buf) - (bufp - buf), "%s %d\n", (char *) (intptr_t) wkp->name, wkp->value ); + bufp += k; + wkp++; + } + k = snprintf( bufp, sizeof(buf) - (bufp - buf), "ENDPROPERTIES\n" ); + bufp += k; + *bufp = '\0'; + fprintf( stdout, "%s", buf ); + return; + +} + + +/* output to font property information of pcf fontpcf */ +static void +pPROPS_pcf(PcfTmp *pcf) +{ + FontPropPtr wkp; + int i, k; + + bufp = buf; + k = sprintf( bufp, "STARTPROPERTIES %d\n", pcf->nprops+3 ); + bufp += k; + k = sprintf( bufp, "FONT_ASCENT %d\n", + (pcf->info.fontAscent >= pcf->info.maxbounds.ascent) + ? pcf->info.fontAscent : pcf->info.maxbounds.ascent + ); + bufp += k; + k = sprintf( bufp, "FONT_DESCENT %d\n", + (pcf->info.fontDescent >= pcf->info.maxbounds.descent) + ? pcf->info.fontDescent : pcf->info.maxbounds.descent + ); + bufp += k; + k = sprintf( bufp, "DEFAULT_CHAR %d\n", pcf->info.defaultCh ); + bufp += k; + wkp = pcf->props; + for ( i = 0; i < pcf->nprops; i++ ) { + if ( pcf->isStringProp[i] ) { + k = sprintf(bufp,"%s \"%s\"\n", + pcf->string + wkp->name, pcf->string + wkp->value + ); + bufp += k; + } else { + k = sprintf(bufp,"%s %d\n", + pcf->string + wkp->name, wkp->value + ); + bufp += k; + } + wkp++; + } + k = sprintf( bufp, "ENDPROPERTIES\n" ); + bufp += k; + *bufp = '\0'; + fprintf( stdout,"%s",buf ); + return; + +} + + + +/* + * output to character information and patern + */ +static void +pCHARS( +FontInfoRec *fip, +CharInfoRec *cip, +char *glyphPtr, +unsigned int charNum, +unsigned int glyphPad) +{ + CharInfoRec *wkp; + int i, j; + unsigned int frow, lrow, row, fcol, lcol, col; + unsigned int bbw, bbh; + unsigned int bml; + char *glyph; + + fprintf( stdout, "CHARS %d\n", charNum ); + + frow = fip->firstRow; + lrow = fip->lastRow; + fcol = fip->firstCol; + lcol = fip->lastCol; + wkp = cip; + glyph = glyphPtr; + row = frow; + + for ( i = 0; i < 256; i++ ) { + cvtp[i] = &cvt[i]; + } + + for ( row = frow; row <= lrow; row++ ) { + for ( col = fcol; col <= lcol; col++ ) { + fprintf( stdout, "STARTCHAR %.2x%.2x\n", row,col ); + fprintf( stdout, "ENCODING %d\n", (row << 8) + col ); + fprintf( stdout, "SWIDTH 256 0\nDWIDTH %d %d\n", + wkp->metrics.characterWidth,0 ); + bbw = wkp->metrics.rightSideBearing + - wkp->metrics.leftSideBearing; + bbh = wkp->metrics.ascent + wkp->metrics.descent; + fprintf( stdout, "BBX %d %d %d %d\nBITMAP\n", bbw, bbh, + wkp->metrics.leftSideBearing, + - ( wkp->metrics.descent )); + bml = (bbw + 7) / 8; + for ( i = 0; i < bbh; i++ ) { + bufp = buf; + for ( j = 0; j < bml; j++ ) { + sprintf( bufp, "%s", (char *) cvtp[(unsigned char)glyph[j]] ); + bufp += 2; + } + fprintf( stdout, "%.*s\n", bml*2, buf ); + glyph += glyphPad; + } + fprintf( stdout,"ENDCHAR\n" ); + wkp++; + } + } + return; +} + + +/* + * output to character information and patern + */ +static void +pfixCHARS( +FontInfoRec *fip, +CharInfoRec *cip, +char *glyphPtr, +unsigned int charNum, +unsigned int glyphPad) +{ + CharInfoRec *wkp; + int i, j, k; + unsigned int frow,lrow,fcol,lcol; + int row, col; + unsigned int bbw, bbh, bbox, bboy; + unsigned int xd, yd; + unsigned int bml; + char *glyph; + char fixbuf[240], *fixbufp; + int fixdl; + + fprintf( stdout,"CHARS %d\n",charNum ); + + for ( i = 0; i < 256; i++ ) { + cvtp[i] = &cvt[i]; + } + + frow = fip->firstRow; + lrow = fip->lastRow; + fcol = fip->firstCol; + lcol = fip->lastCol; + xd = cip->metrics.characterWidth; + yd = 0; + bbw = cip->metrics.rightSideBearing - cip->metrics.leftSideBearing; + bbh = cip->metrics.ascent + cip->metrics.descent; + bbox = cip->metrics.leftSideBearing; + bboy = -(cip->metrics.descent); + + fixbufp = fixbuf; + fixdl = sprintf( fixbufp, "SWIDTH 256 0\nDWIDTH %d %d\n", xd, yd ); + fixbufp += fixdl; + k = sprintf(fixbufp,"BBX %d %d %d %d\nBITMAP\n", + bbw, bbh, bbox, bboy + ); + fixdl += k; + + bml = (bbw + 7) / 8; + wkp = cip; + glyph = glyphPtr; + for ( row = frow; row <= lrow; row++ ) { + for ( col = fcol; col <= lcol; col++ ) { + bufp = buf; + memcpy(bufp,"STARTCHAR ",10); + bufp += 10; + memcpy(bufp,cvtp[row],2); + bufp += 2; + memcpy(bufp,cvtp[col],3); + bufp += 3; + memcpy(bufp,"ENCODING ",9); + bufp += 9; + k = sprintf(bufp,"%d\n",(row << 8) + col); + bufp += k; + memcpy(bufp,fixbuf,fixdl); + bufp += fixdl; + for (i = 0; i < bbh; i++) { + for (j = 0; j < bml; j++) { + memcpy(bufp, cvtp[(unsigned char)glyph[j]],3); + bufp += 2; + } + bufp ++; + glyph += glyphPad; + } + memcpy( bufp, "ENDCHAR\n", 8 ); + bufp += 8; + *bufp = '\0'; + fprintf( stdout, "%s", buf ); + wkp++; + } + } + return; +} + + +static void +putPtn(unsigned char *bits, /* 1 byte boundary , no byte swap data */ + int width, + int height) +{ + int bytewidth; + int i, j; + + bytewidth = ( width + 7) / 8; + + for ( i = height; i-- > 0;) { + for ( j = bytewidth; j-- > 0; bits++) { + fprintf(stdout, "%.2x", *bits); + } + fprintf(stdout, "\n"); + } + +} + +static void +ByteSwap(char *p, int scan) +{ + char w; + + switch( scan) { + case 1: + break; + case 2: + w = *p; + *p = *(p + 1); + *(p + 1) = w; + break; + case 4: + w = *p; + *p = *(p + 3); + *(p + 3) = w; + w = *(p + 1); + *(p + 1) = *(p + 2); + *(p + 2) = w; + break; + } +} + +static unsigned char _reverse_byte[0x100] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +static void +BitOrderInvert(unsigned char *buf, int nbytes) +{ + unsigned char *rev = _reverse_byte; + + for (; --nbytes >= 0; buf++) + *buf = rev[*buf]; +} + +static void +invertBits(char *src, CARD32 format, int width, int height, char *dest) +{ + int bit, byte, glyph, scan; + int src_bytewidth, dest_bytewidth; + char work[8]; + int i, j; + + bit = PCF_BIT_ORDER( format); + byte = PCF_BYTE_ORDER( format); + glyph = PCF_GLYPH_PAD( format); + scan = PCF_SCAN_UNIT( format); + + src_bytewidth = (( width + ( 8 * glyph ) - 1)/( 8 * glyph)) * glyph; + dest_bytewidth = ( width + 7) /8; + + for ( i = 0; i < height; i++, src += src_bytewidth, + dest += dest_bytewidth) { + for ( j = 0; j < src_bytewidth; j += scan) { + memcpy( work, src + j, scan); + if ( bit == LSBFirst) + BitOrderInvert( (unsigned char *)work, scan); + if ( byte == LSBFirst) + ByteSwap( work, scan); + if (( j + scan) >= dest_bytewidth) { + memcpy( dest + j, work, dest_bytewidth - j); + break; + } + memcpy( dest + j, work, scan); + } + } + +} + +static void +pCHARS_pcf (PcfTmp *pcf, int fix) +{ + char *bmp_ptn = NULL; + char *bitmap = NULL; + int ptn_width = 0, ptn_height = 0; + int bmp_width = 0, bmp_height = 0; + int cpy_height = 0; + int row, col; + int row_width; + int encoding; + int encodingOffset; + int nencoding; + int bmp_adj = 0, ptn_adj = 0; + int adj_hi; + int width_bytes; + INT16 bl, br, ba, bd, bdw ; + unsigned char cl, cr, ca, cd, cdw ; + unsigned char *comp ; + int bbw, bbh, bbx, bby, dwidth ; + + fprintf(stdout,"CHARS %d\n",pcf->nbitmaps); + + row_width = pcf->info.lastCol - pcf->info.firstCol + 1; + nencoding = row_width * (pcf->info.lastRow - pcf->info.firstRow + 1); + + if( fix == TRUE ) { + bmp_width = pcf->info.maxbounds.leftSideBearing + + pcf->info.maxbounds.rightSideBearing ; + bmp_height = pcf->info.fontAscent + pcf->info.fontDescent ; + ptn_width = bmp_width ; + ptn_height = pcf->info.maxbounds.ascent + + pcf->info.maxbounds.descent; + + if (!(bmp_ptn = make_toptn( ptn_width, ptn_height))) + return; + + if ( ( adj_hi = pcf->info.fontAscent - pcf->info.maxbounds.ascent ) > 0) { + width_bytes = 8 * PCF_GLYPH_PAD( pcf->bmp_fmt); + width_bytes = (( width_bytes + bmp_width - 1)/width_bytes) * PCF_GLYPH_PAD( pcf->bmp_fmt); + bmp_adj = width_bytes * adj_hi; + ptn_adj = 0; + if (( cpy_height = bmp_height - adj_hi) > ptn_height) + cpy_height = ptn_height ; + } else if ( adj_hi < 0) { + adj_hi *= -1; + width_bytes = ( ptn_width + 7) / 8; + bmp_adj = 0; + ptn_adj = width_bytes * adj_hi; + if (( cpy_height = ptn_height - adj_hi) > bmp_height) + cpy_height = bmp_height ; + } else { + bmp_adj = 0; + ptn_adj = 0; + cpy_height = ptn_height ; + } + } + + + for ( encoding = 0; encoding < nencoding; encoding++) { + if(fix == TRUE) memset( bmp_ptn, '\0', (ptn_width + 7)/8 * ptn_height); + encodingOffset = getINT16( (unsigned char *)(pcf->encodingOffsets + encoding), pcf->enc_fmt); + if (encodingOffset == 0xFFFF) continue; + + row = pcf->info.firstRow + encoding / row_width; + col = pcf->info.firstCol + encoding % row_width; + + fprintf(stdout,"STARTCHAR %s\n",pcf->glyph_name + + getINT32( (unsigned char*)&pcf->glyph_offset[encodingOffset], + pcf->glyph_fmt) ); + fprintf(stdout,"ENCODING %d\n",(row << 8) + col); + + fprintf( stdout,"SWIDTH %d 0\n", getINT32( (unsigned char*)(pcf->swidth + encodingOffset), pcf->swd_fmt) ); + + if( pcf->compress ){ + comp = (unsigned char*)pcf->metrics + + encodingOffset * SIZEOF_COMPRESSED_METRIC ; + cl = getINT8( comp ) ; + cr = getINT8( comp ) ; + cdw = getINT8( comp ) ; + ca = getINT8( comp ) ; + cd = getINT8( comp ) ; + + dwidth = (int)(cdw - 0x80) ; + bbw = (int)((cr - 0x80) - (cl - 0x80)) ; + bbh = (int)((ca - 0x80) + (cd - 0x80)) ; + bbx = (int)(cl - 0x80) ; + bby = (int)( -(cd - 0x80) ) ; + }else{ + bl = getINT16( (unsigned char *)&pcf->metrics[encodingOffset].leftSideBearing, pcf->mtr_fmt ) ; + br = getINT16( (unsigned char *)&pcf->metrics[encodingOffset].rightSideBearing, pcf->mtr_fmt ) ; + bdw = getINT16( (unsigned char *)&pcf->metrics[encodingOffset].characterWidth, pcf->mtr_fmt ) ; + ba = getINT16( (unsigned char *)&pcf->metrics[encodingOffset].ascent, pcf->mtr_fmt ) ; + bd = getINT16( (unsigned char *)&pcf->metrics[encodingOffset].descent, pcf->mtr_fmt ) ; + dwidth = bdw ; + bbw = br-bl ; + bbh = ba+bd ; + bbx = bl ; + bby = -bd ; + } + fprintf( stdout,"DWIDTH %d 0\n", dwidth ) ; + fprintf( stdout,"BBX %d %d %d %d\nBITMAP\n", bbw, bbh, bbx, bby ) ; + + if( fix == FALSE ) { + bmp_width = pcf->info.maxbounds.leftSideBearing + + pcf->info.maxbounds.rightSideBearing ; + bmp_height = pcf->info.fontAscent + pcf->info.fontDescent ; + ptn_width = bbw ; + ptn_height = bbh ; + + if (!(bmp_ptn = make_toptn( ptn_width, ptn_height))) + return; + + if ( ( adj_hi = pcf->info.fontAscent - pcf->info.maxbounds.ascent ) > 0) { + width_bytes = 8 * PCF_GLYPH_PAD( pcf->bmp_fmt); + width_bytes = (( width_bytes + bmp_width - 1)/width_bytes) * PCF_GLYPH_PAD( pcf->bmp_fmt); + bmp_adj = width_bytes * adj_hi; + ptn_adj = 0; + if (( cpy_height = bmp_height - adj_hi) > ptn_height) + cpy_height = ptn_height ; + } else if ( adj_hi < 0) { + adj_hi *= -1; + width_bytes = ( ptn_width + 7) / 8; + bmp_adj = 0; + ptn_adj = width_bytes * adj_hi; + if (( cpy_height = ptn_height - adj_hi) > bmp_height) + cpy_height = bmp_height ; + } else { + bmp_adj = 0; + ptn_adj = 0; + cpy_height = ptn_height ; + } + memset( bmp_ptn, '\0', (ptn_width + 7)/8 * ptn_height); + } + + bitmap = pcf->bitmaps + getINT32( (unsigned char *)(pcf->offsets + encodingOffset), + pcf->bmp_fmt); + /* Only do this if non-NULL... */ + if (bmp_ptn) + { + invertBits( bitmap + bmp_adj, pcf->bmp_fmt, + ptn_width, cpy_height, bmp_ptn + ptn_adj); + putPtn( (unsigned char *)bmp_ptn, ptn_width, ptn_height ); + } + else + { + fprintf(stderr, "%s: bmp_ptn is NULL", __FUNCTION__); + } + + fprintf(stdout,"ENDCHAR\n"); + if( fix == FALSE ) free(bmp_ptn); + } + if( fix == TRUE ) free(bmp_ptn); + return; +} + +static char * +make_toptn(int width, int height) +{ + int byte_width; + + byte_width = (width + 7)/8; + + return (char *)malloc( byte_width * height); +} + + + + +static int +getarg( +int argc, +char *argv[], +char *fname, +int *bitorder, +int *byteorder, +int *scanunit, +int *glyphPad, +int *outLevel, +int *fix) +{ + int i; + int already; + char *arg; + char *usage="dtgpftobdf [-H] [-V] [-help] font_file_name"; + + *glyphPad = DEFAULTGLPAD; + *bitorder = DEFAULTBITORDER; + *scanunit = DEFAULTSCANUNIT; + *byteorder = DEFAULTBYTEORDER; + *outLevel = FALSE; + *fix = FALSE ; + already = 0 ; + + for (i = 1; i < argc; i++ ) { + arg = argv[i]; + if (*arg == '-') { + *arg++; + switch (*arg) { + case 'p' : + *glyphPad = atoi(arg+1) ; + if (*glyphPad != 1 && + *glyphPad != 2 && + *glyphPad != 4 && + *glyphPad != 8 ) { + USAGE("dtgpftobdf : illegal padding number (1/2/4/8)\n"); + return -1; + } + break; + case 'H' : + *outLevel = TRUE ; + break; + case 'h' : + USAGE1("usage: %s\n",usage); + return (-1); + case 'V' : + *fix = TRUE ; + break; + default : + USAGE1("dtgpftobdf : illegal option -- %s\n",arg); + USAGE1("usage: %s\n",usage); + return -1; + } + + } else { + if (already == FALSE) { + strcpy(fname,arg); + already = TRUE; + } else { + USAGE1("dtgpftobdf : extra parameter --- %s\n",arg); + USAGE1("usage: %s\n", usage ); + return -1; + } + } + } + if (already == FALSE) { + USAGE("dtgpftobdf : require file name\n"); + USAGE1("usage: %s\n",usage); + return -1; + } + return 0; +} diff --git a/cde/programs/dtudcfonted/dtgpftobdf/gtobdf.h b/cde/programs/dtudcfonted/dtgpftobdf/gtobdf.h new file mode 100644 index 000000000..22fe7eaf6 --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftobdf/gtobdf.h @@ -0,0 +1,84 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: gtobdf.h /main/3 1996/06/25 20:13:05 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +static +unsigned int + cvt[256]= +{0x30300a00,0x30310a00,0x30320a00,0x30330a00,0x30340a00,0x30350a00,0x30360a00, + 0x30370a00,0x30380a00,0x30390a00,0x30610a00,0x30620a00,0x30630a00,0x30640a00, + 0x30650a00,0x30660a00, + 0x31300a00,0x31310a00,0x31320a00,0x31330a00,0x31340a00,0x31350a00, + 0x31360a00,0x31370a00,0x31380a00,0x31390a00,0x31610a00,0x31620a00,0x31630a00, + 0x31640a00,0x31650a00,0x31660a00, + 0x32300a00,0x32310a00,0x32320a00,0x32330a00,0x32340a00,0x32350a00, + 0x32360a00,0x32370a00,0x32380a00,0x32390a00,0x32610a00,0x32620a00,0x32630a00, + 0x31640a00,0x32650a00,0x32660a00, + 0x33300a00,0x33310a00,0x33320a00,0x33330a00,0x33340a00,0x33350a00, + 0x33360a00,0x33370a00,0x33380a00,0x33390a00,0x33610a00,0x33620a00,0x33630a00, + 0x33640a00,0x33650a00,0x33660a00, + 0x34300a00,0x34310a00,0x34320a00,0x34330a00,0x34340a00,0x34350a00, + 0x34360a00,0x34370a00,0x34380a00,0x34390a00,0x34610a00,0x34620a00,0x34630a00, + 0x34640a00,0x34650a00,0x34660a00, + 0x35300a00,0x35310a00,0x35320a00,0x35330a00,0x35340a00,0x35350a00, + 0x35360a00,0x35370a00,0x35380a00,0x35390a00,0x35610a00,0x35620a00,0x35630a00, + 0x35640a00,0x35650a00,0x35660a00, + 0x36300a00,0x36310a00,0x36320a00,0x36330a00,0x36340a00,0x36350a00, + 0x36360a00,0x36370a00,0x36380a00,0x36390a00,0x36610a00,0x36620a00,0x36630a00, + 0x36640a00,0x36650a00,0x36660a00, + 0x37300a00,0x37310a00,0x37320a00,0x37330a00,0x37340a00,0x37350a00, + 0x37360a00,0x37370a00,0x37380a00,0x37390a00,0x37610a00,0x37620a00,0x37630a00, + 0x37640a00,0x37650a00,0x37660a00, + 0x38300a00,0x38310a00,0x38320a00,0x38330a00,0x38340a00,0x38350a00, + 0x38360a00,0x38370a00,0x38380a00,0x38390a00,0x38610a00,0x38620a00,0x38630a00, + 0x38640a00,0x38650a00,0x38660a00, + 0x39300a00,0x39310a00,0x39320a00,0x39330a00,0x39340a00,0x39350a00, + 0x39360a00,0x39370a00,0x39380a00,0x39390a00,0x39610a00,0x39620a00,0x39630a00, + 0x39640a00,0x39650a00,0x39660a00, + 0x61300a00,0x61310a00,0x61320a00,0x61330a00,0x61340a00,0x61350a00, + 0x61360a00,0x61370a00,0x61380a00,0x61390a00,0x61610a00,0x61620a00,0x61630a00, + 0x61640a00,0x61650a00,0x61660a00, + 0x62300a00,0x62310a00,0x62320a00,0x62330a00,0x62340a00,0x62350a00, + 0x62360a00,0x62370a00,0x62380a00,0x62390a00,0x62610a00,0x62620a00,0x62630a00, + 0x62640a00,0x62650a00,0x62660a00, + 0x63300a00,0x63310a00,0x63320a00,0x63330a00,0x63340a00,0x63350a00, + 0x63360a00,0x63370a00,0x63380a00,0x63390a00,0x63610a00,0x63620a00,0x63630a00, + 0x63640a00,0x63650a00,0x63660a00, + 0x64300a00,0x64310a00,0x64320a00,0x64330a00,0x64340a00,0x64350a00, + 0x64360a00,0x64370a00,0x64380a00,0x64390a00,0x64610a00,0x64620a00,0x64630a00, + 0x64640a00,0x64650a00,0x64660a00, + 0x65300a00,0x65310a00,0x65320a00,0x65330a00,0x65340a00,0x65350a00, + 0x65360a00,0x65370a00,0x65380a00,0x65390a00,0x65610a00,0x65620a00,0x65630a00, + 0x65640a00,0x65650a00,0x65660a00, + 0x66300a00,0x66310a00,0x66320a00,0x66330a00,0x66340a00,0x66350a00, + 0x66360a00,0x66370a00,0x66380a00,0x66390a00,0x66610a00,0x66620a00,0x66630a00, + 0x66640a00,0x66650a00,0x66660a00 }; +static +unsigned int *cvtp[256]; diff --git a/cde/programs/dtudcfonted/dtgpftocpf/Imakefile b/cde/programs/dtudcfonted/dtgpftocpf/Imakefile new file mode 100644 index 000000000..ef509928c --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftocpf/Imakefile @@ -0,0 +1,26 @@ +XCOMM $XConsortium: Imakefile /main/6 1996/09/09 11:19:51 drk $ + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) + + INCLUDES = -I../include -I../libfal/include + + DEPLIBS = ../libfuty/liboakfuty.a ../libfal/libfal.a $(DEPXLIB) +LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) + SYS_LIBRARIES = -lc + + SRCS = gpftocpf.c + + OBJS = gpftocpf.o + +ComplexProgramTarget(dtgpftocpf) diff --git a/cde/programs/dtudcfonted/dtgpftocpf/gpftocpf.c b/cde/programs/dtudcfonted/dtgpftocpf/gpftocpf.c new file mode 100644 index 000000000..bb94c0917 --- /dev/null +++ b/cde/programs/dtudcfonted/dtgpftocpf/gpftocpf.c @@ -0,0 +1,676 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: gpftocpf.c /main/6 1996/11/08 02:05:11 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include <stdio.h> +#include <fcntl.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#ifndef SVR4 +#if !defined ( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif +#include <errno.h> +#include <locale.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include "bdfgpf.h" + +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "snfstruct.h" +#include "FaLib.h" +#include "udcutil.h" + +#define START_CODE 0 +#define END_CODE 1 + +static int CnvBDFtoGPF(struct btophead *head, + int num_gr, + FalGlyphRegion *gr, + int code_area); +static int check_width(char *prog_name, char *len_str); +static int check_height(char *prog_name, char *len_str); +static int check_width_height(char *prog_name, char *len_str, int mode); +static int check_code(char *prog_name, + char *code_str, + int mode, + char *charset, + int num_gr, + FalGlyphRegion *gr); +static int readBdfToMemory(struct btophead *head, + char *buf, + int num_gr, + FalGlyphRegion *gr, + int code_area); +static void sigint_out(void); +static void put_error_and_exit(struct btophead *btop, + int er_no, + char *prog_name); +static void put_help(char *prog_name); +static void Usage(char *prog_name); + +extern int fal_code_to_glyph(char *locale, + unsigned long codepoint, + FalGIInf **gi, + int *num_gi); + +static struct btophead Head; +static char *locale; +static char *spacing; +static char *char_set; + + +static void +sigint_out(void) +{ + if ( Head.out_file ) { + unlink( Head.out_file ); + } + exit( 0 ); +} + +int main(int argc, char *argv[]) +{ + int help, code_area, fd[2], rtn, i; + struct stat st; + char snf_file[BUFSIZE]; + char *style ; + int code_no ; + int num_gr ; + FalGlyphRegion *gr ; + char *xlfdname, *cbuf, *ep ; + char *codeset = DEFAULT_CODESET ; + char *start_code, *end_code ; + + /* format */ + if( (locale = (char *)getenv( "LANG" )) == NULL ){ + locale = "C" ; + } + + Head.in_file = Head.out_file = Head.text_file = NULL; + Head.p_width = Head.p_height = USE_ORG_SIZE; + + Head.code_category = ALL_CODE ; + Head.start_code = MIN_CODE; + Head.end_code = MAX_CODE; + help = code_area = 0; + COMM_SETDEFAULTSTYLE( style ) ; + xlfdname = cbuf = start_code = end_code = ep = '\0' ; + spacing = char_set = NULL ; + gr = '\0' ; + num_gr = 0 ; + + if ( ! ( oakgtobdf = get_cmd_path( getenv( "PATH" ), SNFTOBDF_CMD ) ) ) { + oakgtobdf = SNFTOBDF; + } + /* + * check options + */ + for ( i = 1; i < argc; i++ ) { + if ( !strcmp(argv[i], "-help" ) ) { + help = 1; + } else if ( !strcmp(argv[i], "-system" ) ) { + code_area |= SYSTM; + } else if ( !strcmp( argv[i], "-codeset" ) ) { + if ( + ( (i+1) < argc ) && + ( strlen( argv[i+1] ) == 1 ) + ) { + if ( *argv[i+1] == '1' ) code_area |= CDSET1; + codeset = argv[++i] ; + } else { + put_help( argv[0] ); + exit( 1 ); + } + } else if ( COMM_SBOPT_STRCMP( argv, i ) ) { + COMM_SBOPT_SETSBOPT( code_area ) ; + } else { + continue ; + } + } + + if ( help ) { + put_help( argv[0] ); + exit( 0 ); + } + + ep = (char *)strchr( codeset, '\0' ) ; + code_no = (int)strtol( codeset, &cbuf, 10 ) ; + if( cbuf == codeset || cbuf != ep ) { + USAGE1("%s : The code set number is not right.\n", argv[0] ) ; + exit(1) ; + } + + COMM_SBOPT_CHECKSBOPT( argv[0], code_area ) ; + + /* + * get parameters + */ + for (i=1; i<argc; i++) { + if ( !strcmp(argv[i], "-g") ) { + if((i < argc-1) && (*argv[i+1] != '-')){ + Head.in_file = argv[++i]; + } + + } else if ( !strcmp(argv[i], "-p") ) { + if ((i < argc-1) && (*argv[i+1] != '-')){ + Head.out_file = argv[++i]; + } else { + USAGE1("%s : The output file name following -p option cannot be omitted.\n", + argv[0]); + exit(1); + } + + } else if ( !strcmp(argv[i], "-width") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + Head.p_width = check_width( argv[0], argv[++i]); + if (Head.p_width == 0) { + exit(1); + } + } + else { + USAGE1("%s : The character width is not specified.\n", argv[0]); + exit( 1 ); + } + + } else if ( !strcmp(argv[i], "-height") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + Head.p_height = check_height( argv[0], argv[++i]); + if (Head.p_height == 0) { + exit(1); + } + } + else { + USAGE1("%s : The character height is not specified.\n", argv[0]); + exit(1); + } + + } else if ( !strcmp(argv[i], "-start") ) { + if ((i < argc-1) && (*argv[i+1] != '-')) { + start_code = argv[++i] ; + } else { + USAGE1("%s : The extract start code is not specified.\n", + argv[0]); + exit( 1 ); + } + + } else if ( !strcmp(argv[i], "-end" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ) { + end_code = argv[++i] ; + } else { + USAGE1("%s : The extract end code is not specified.\n", + argv[0]); + exit( 1 ); + } + + } else if ( !strcmp(argv[i], "-style" ) ) { + if ( ( i < argc-1 ) && ( *argv[i+1] != '-' ) ){ + style = argv[++i]; + } else { + USAGE1("%s : The style is not specified.\n", argv[0]); + exit( 1 ); + } + } else if ( !strcmp(argv[i], "-xlfd" ) ) { + if ( i < argc-1 ){ + xlfdname = argv[++i]; + } else { + USAGE1("%s : The XLFD name is not specified.\n", argv[0]); + exit( 1 ); + } + } else if ( !strcmp(argv[i], "-help" ) + || !strcmp(argv[i], "-system") + || COMM_SBOPT_STRCMP( argv, i ) + ) { + continue; + + } else if ( !strcmp( argv[i], "-codeset" ) ) { + i++; + continue; + + } else { + Usage(argv[0]); + } + } + + if ( Head.in_file == NULL && xlfdname == NULL ) { + if ( code_area & SYSTM ) { + USAGE1("%s : The GPF output file name cannot be omitted.\n", argv[0] ); + } else { + USAGE1("%s : The specification of the character size cannot be omitted.\n", argv[0] ); + } + exit( 1 ); + } + + signal( SIGHUP , (void(*)())sigint_out ); + signal( SIGINT , (void(*)())sigint_out ); + signal( SIGQUIT, (void(*)())sigint_out ); + signal( SIGTERM, (void(*)())sigint_out ); + + if ( !(code_area & SYSTM ) ) { + + if( xlfdname ) { + if( GetUdcFileName( argv[0], code_no, xlfdname, snf_file ) ) { + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]); + exit(1) ; + } + Head.in_file = snf_file; + } else { + switch (GetFileName(argv[0], Head.in_file, style, code_no, snf_file)) { + case 0: + Head.in_file = snf_file; + break; + case -1: + exit(1); + default: + USAGE1("%s : The font file name cannot be obtained. Terminates abnormally.\n", argv[0]); + exit(1); + } + } + if( GetUdcRegion( argv[0], code_no, Head.in_file, &num_gr, &gr ) ) { + USAGE1("%s : The font file cannot get UDC code area.\n", argv[0]); + exit(1) ; + } + } else { + num_gr = 1 ; + if( (gr = (FalGlyphRegion *)malloc( sizeof(FalGlyphRegion) * num_gr )) == NULL ) { + USAGE1("%s : malloc error occurred. Terminates abnormally.\n", argv[0]); + exit(1) ; + } + gr[0].start = MIN_CODE ; + gr[0].end = MAX_CODE ; + } + /* + * refuse proportional fonts + */ + if ( GetUdcFontName( Head.in_file, NULL, &xlfdname ) ) { + USAGE1("%s : This font cannot get XLFD. Terminates abnormally.\n", argv[0]); + exit( 1 ); + } + GETSPACINGSTR( spacing, xlfdname ) ; + if ( !strcmp( "p", spacing ) || !strcmp( "P", spacing ) ) { + USAGE2("%s cannot edit proportional fonts.(SPACING \"%s\")\n", argv[0], spacing ); + exit( 1 ); + } + GETCHARSETSTR( char_set, xlfdname ) ; + + switch( code_area ) { + case SYSTM : + Head.code_category = ALL_CODE ; + Head.start_code = MIN_CODE ; + Head.end_code = MAX_CODE ; + break ; + case SYSTM | CDSET1 : + Head.code_category = ALL_CODE ; + Head.start_code = MIN_CODE ; + Head.end_code = MAX_CODE ; + break ; + default : + COMM_SBFNT_SETUDCAREA( argv[0], Head, char_set, code_area, num_gr, gr ) ; + break ; + } + + if( start_code && end_code ) { + Head.start_code = check_code(argv[0], start_code, START_CODE, char_set, num_gr, gr ); + if(Head.start_code < 0) { + exit( 1 ); + } + Head.end_code = check_code(argv[0], end_code, END_CODE, char_set, num_gr, gr ); + if(Head.end_code < 0) { + exit( 1 ); + } + } + + if ( Head.start_code > Head.end_code ) { + USAGE1("%s : The specification of extract start/end code is improper.\n", argv[0]); + exit( 1 ); + } + + COMM_SBFNT_CONVCODETOGI( char_set, Head ) ; + + /* open to output file */ + if ( Head.out_file == NULL ) { + Head.output = stdout; + } else { + if ( stat(Head.out_file, &st) != 0 ) { + if ((Head.output = fopen(Head.out_file, "w")) == NULL) { + put_error_and_exit( &Head, GPF_OPEN_OUT, argv[0] ); + } + } else { + Head.text_file = Head.out_file; + if ( ( Head.out_file = GetTmpPath( Head.out_file ) ) == NULL ) { + put_error_and_exit( &Head, MKTMP_ERROR, argv[0] ); + } + if ( ( Head.output = fopen( Head.out_file, "w" ) ) == NULL ) { + put_error_and_exit( &Head, GPF_OPEN_OUT, argv[0] ); + } + } + } + + if ( pipe( fd ) != 0 ) { + put_error_and_exit( &Head, PIPE_ERROR, argv[0] ); + } + + switch( fork() ) { + case 0: + close( fd[0] ); + close( 1 ); + if ( dup( fd[1] ) < 0 ) { + put_error_and_exit( &Head, DUP_ERROR, argv[0] ); + } + close( fd[1] ); + execl( oakgtobdf, oakgtobdf, Head.in_file, 0 ); + put_error_and_exit( &Head, EXEC_ERROR, argv[0] ); + + case -1: + /* fork fail */ + put_error_and_exit( &Head, FORK_ERROR, argv[0] ); + + default: + close( fd[1] ); + Head.input = fdopen( fd[0], "r" ); + } + + if ( rtn = CnvBDFtoGPF( &Head, num_gr, gr, code_area ) ) { + wait( 0 ); + fclose( Head.input ); + if ( Head.out_file ) { + unlink( Head.out_file ); + } + put_error_and_exit( &Head, rtn, argv[0] ); + } + wait(0); + fclose( Head.input ); + signal( SIGHUP, SIG_IGN ); + signal( SIGINT, SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + if ( Head.text_file ) { + fclose( Head.output ); + Link_NewFile( Head.out_file, Head.text_file ); + unlink( Head.out_file ); + } + exit( 0 ); +} + + +static int +CnvBDFtoGPF( +struct btophead *head, +int num_gr, +FalGlyphRegion *gr, +int code_area) +{ + int rtn; + char bdfbuf[BUFSIZE]; + + /* readto BDF head information */ + if ((rtn = ReadBdfHeader(head, bdfbuf))) { + return(rtn); + } + + if (head->p_width == USE_ORG_SIZE) { + head->p_width = head->bdf_width; + } + if (head->p_height == USE_ORG_SIZE) { + head->p_height = head->bdf_height; + } + + if ((head->p_width != head->bdf_width) || + (head->p_height != head->bdf_height)) { + head->zoomf = 1; + } else { + head->zoomf = 0; + } + + if ((head->code = (int *)malloc(sizeof(int)*head->num_chars)) == NULL) { + return(MALLOC_ERROR); + } + + if ((head->ptn = (char **)malloc(sizeof(char *)*head->num_chars)) == NULL) { + return(MALLOC_ERROR); + } + + if ((rtn = readBdfToMemory(head, bdfbuf, num_gr, gr, code_area))) { + return(rtn); + } + + WriteGpfHeader(head); + + if ((rtn = WritePtnToGpf(head))) { + return(rtn); + } + + return(0); +} + + +static void +put_error_and_exit(struct btophead *btop, int er_no, char *prog_name) +{ + ErrMsgTable_AndExit( er_no, btop->in_file, NULL, + NULL, btop->out_file, + NULL, + prog_name + ); + return; +} + + + + + +static void +put_help(char *prog_name) +{ + USAGE1("Usage : %s -xlfd xlfd_name\n", prog_name); + USAGE("\t\t[-g character_size][-p character_pattern_file_name]\n"); + USAGE("\t\t[-style style]\n"); + USAGE("\t\t[-start start_code] [-end end_code]\n"); + USAGE("\t\t[-width character_width] [-height character_height]\n"); + COMM_HELP_MSG ; + USAGE1("%s can extract glyphs in cpf file format in the following code area.\n", prog_name); + USAGE("codeset \t\tcode area\n"); + USAGE("----------------------------------------\n"); + DispUdcCpArea(stdout) ; + USAGE("If the -start and -end option is omitted, the start/end code of each extractive area is specified.\n"); + USAGE("The xlfd name and character size may be obtained using dtlsgpf command.\n"); + return; +} + +static void +Usage(char *prog_name) +{ + put_help( prog_name ); + exit(1); +} + + +static int +check_width(char *prog_name, char *len_str) +{ + return( check_width_height( prog_name, len_str, 0) ); +} + + +static int +check_height(char *prog_name, char *len_str) +{ + return( check_width_height( prog_name, len_str, 1) ); +} + +static int +check_width_height(char *prog_name, char *len_str, int mode) +/* width ... 0 , height ... 1 */ +{ + int ret; + char *tmp; + + ret = (int)strtol( len_str, &tmp, 10 ); /* <-- ret = atoi( len_str ) */ + if ((tmp == len_str) || (ret < MIN_FONT_WIDTH) || (ret > MAX_FONT_WIDTH)) { + switch( mode ) { + case 0: + USAGE2("%s : The specification of the character width is improper.\"%s\"¡¥\n", + prog_name, len_str); + break; + case 1: + USAGE2("%s : The specification of the character height is improper.\"%s\"¡¥\n", + prog_name, len_str); + break; + default: + break; + } + return(0); + } + return( ret ); +} + + + + + + +static int +check_code( +char *prog_name, +char *code_str, +int mode, /* start_code ... 0, end_code ... 1 */ +char *charset, +int num_gr, +FalGlyphRegion *gr) +{ + int err_flg = 0; + int code_num; + char *tmp; + FalGIInf *gi = NULL; + int num_gi ; + int i, code ; + + code = (int)strtol(code_str, &tmp, 16); + if ( tmp == code_str ) { + err_flg = 1; + } + + if( COMM_SBFNT_ISSBFNT( charset ) ) { + code_num = code ; + CONVGLYPHINDEX( code_num ) ; + } else { + if( fal_code_to_glyph( locale, code, &gi, &num_gi) ) { + USAGE2("%s : Failed to convert code point into glyph index.\"%s\" \n", prog_name, code_str ) ; + err_flg = 1; + } + if( num_gi==1 ){ + code_num = gi[0].glyph_index ; + err_flg = 0 ; + }else{ + for( i=0; i<num_gi; i++ ) { + if( !strcmp( gi[i].charset_str, char_set ) ) { + code_num = gi[i].glyph_index ; + err_flg = 0 ; + break ; + } else err_flg = 1 ; + } + } + } + + XFree(gi); + + if( !err_flg ) { + for( i=0; i<num_gr; i++ ) { + if( (code_num >= gr[i].start) && (code_num <= gr[i].end) ) + return( code_num ); + } + } + + switch( mode ) { + case 0: + USAGE2("%s : The specification of the extract start code is improper.\"%s\"¡¥\n", + prog_name, code_str); + break; + case 1: + USAGE2("%s : The specification of the extract end code is improper.\"%s\"¡¥\n", + prog_name, code_str); + break; + default: + USAGE2("%s : The specification of the extract code is improper.\"%s\"¡¥\n", + prog_name, code_str); + } + return(-1); +} + + +static int +readBdfToMemory( +struct btophead *head, +char *buf, +int num_gr, +FalGlyphRegion *gr, +int code_area) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + if ( + ( code < head->start_code) || ( code > head->end_code ) + ||( !IN_CODE( head->code_category, SHIFT_ON( code ) ) ) + ||( + (head->code_category == ALL_CODE) && + !( code_area & SYSTM ) && + IsInRegion( code, num_gr, gr ) + ) + ) { + continue; + } + + head->code[num_char] = code; + if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) { + return(MALLOC_ERROR); + } + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} diff --git a/cde/programs/dtudcfonted/dtlsgpf/Imakefile b/cde/programs/dtudcfonted/dtlsgpf/Imakefile new file mode 100644 index 000000000..5937b80a2 --- /dev/null +++ b/cde/programs/dtudcfonted/dtlsgpf/Imakefile @@ -0,0 +1,31 @@ +XCOMM $XConsortium: Imakefile /main/6 1996/09/09 11:19:55 drk $ + + + DESTDIR = $(CDE_INSTALLATION_TOP) + BINDIR = /bin + FONTLIST = /config + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + OPT4 = -DDTUDCFONTSLISTDIR='"'$(CDE_INSTALLATION_TOP)$(FONTLIST)'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) $(OPT4) + + INCLUDES = -I../include\ + -I../libfal\ + -I../libfal/include + + DEPLIBS = ../libfuty/liboakfuty.a ../libfal/libfal.a $(DEPXLIB) +LOCAL_LIBRARIES = ../libfuty/liboakfuty.a ../libfal/libfal.a $(XLIB) + SYS_LIBRARIES = -lc + + SRCS = lsgpf.c + + OBJS = lsgpf.o + +ComplexProgramTarget(dtlsgpf) diff --git a/cde/programs/dtudcfonted/dtlsgpf/lsgpf.c b/cde/programs/dtudcfonted/dtlsgpf/lsgpf.c new file mode 100644 index 000000000..9db4c3ddd --- /dev/null +++ b/cde/programs/dtudcfonted/dtlsgpf/lsgpf.c @@ -0,0 +1,926 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: lsgpf.c /main/7 1996/11/08 02:05:57 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <errno.h> +#include <locale.h> +#include <string.h> + +#include "FaLib.h" +#include "falfont.h" +#include "bdfgpf.h" +#include "udcutil.h" + +static char *utillocale; +static char *fontdir; +static char *command_name; + +typedef struct { + int num; + struct { + int start; + int end; + }entry[BUFSIZE]; +}MISS_ENTRY; + +/* request for sort */ +#define REQ_STYLE (1<<1) +#define REQ_CHARSIZE (1<<2) +#define REQ_LETTER (1<<3) +#define REQ_DELEQUAL (1<<16) + +/* error flag */ +#define NO_FONT (1<<1) +#define SAME_FONT (1<<2) +#define REDEFINED_FONT (1<<3) + +/* request flag */ +#define A_OPT (1<<1) +#define L_OPT (1<<2) +#define X_OPT (1<<3) +#define C_OPT (1<<4) + +static void dsp_info_list(char *com, + int dspopt, + FalFontDataList *lst, + MISS_ENTRY *unknown_file_lst, + int *errflg); +static void dsp_title(FILE *fp, int dspopt); +static void dspinfo_1line(FalFontData data, + FILE *fp, + MISS_ENTRY *unknown_file_lst, + int offset, + int *errflg, + int dspopt); +static void disp_no_fontslist(int dspopt); +static void sort_offset_list(FalFontDataList *flist, + int mask, + int **sort_list, + int *data_cnt); +static int sort_fontlist(FalFontDataList *lst); +static void dsp_error_title(char *com, int *errflg, int dspopt); +static int dsp_error_files(FalFontDataList *lst, MISS_ENTRY *unknown); + +static void put_help(char *prog_name); +static int search_fontfile_name(FalFontData data, + char *fname, + MISS_ENTRY *unknown_file_lst, + int offset, + int *errflg); +static int get_new_target(FalFontData *target, FalFontData *choose); + +int +main( int argc, char *argv[] ) +{ + FalFontDataList *lst_m; /* font information list struct */ + FalFontData key; /* font reference information creation struct */ + MISS_ENTRY unknown_m ; /* error */ + int i, j; + int code_sw; /* code set flag */ + + int mask; + int code_set ; + int errflg ; + int dsp_opt ; + + /* initialize */ + command_name = argv[0] ; + errflg = 0 ; + unknown_m.num = 0; + code_sw = 0; + dsp_opt = 0 ; + + /* get locale strings */ + if( (utillocale = (char *)getenv( "LANG" )) == NULL ){ + utillocale = "C" ; + } + + if( (fontdir = (char *)getenv( "DTUDCFONTS" )) == (char *)NULL ) { + fontdir = DTUDCFONTSLISTDIR ; + } + + /* + * dtlsgpf check on which options are required. + */ + for (i=1 ; i < argc ; i++) { + + if (!strcmp(argv[i], "-help")) { + put_help(argv[0]); + exit(0); + } + if (*argv[i] != '-') { + put_help(argv[0]); + exit(1); + } + + if ( !strcmp( argv[i], "-codeset" ) ) { + char *cbuf ; + if ( (i+1) >= argc ){ + put_help( argv[0] ); + exit( 1 ); + } + i++; + code_set = (int)strtol( argv[i], &cbuf, 10 ) ; + if( argv[i] == cbuf ) { + put_help( argv[0] ); + exit( 1 ); + } + code_sw = 1 ; + } + + for (j=1; argv[i][j] != '\0' ; j++) { + char req ; + req = argv[i][j] ; + if ( req == 'l') dsp_opt |= L_OPT ; + else if ( req == 'a') dsp_opt |= A_OPT ; + else if ( req == 'x') dsp_opt |= X_OPT ; + else if ( req == 'C') dsp_opt |= C_OPT ; + else { + put_help(argv[0]); + exit( 1 ); + } + } + } + + /* "-ax" -> "-a" */ + if( dsp_opt == ( A_OPT | X_OPT ) ) dsp_opt = A_OPT ; + + /* + * display information list of UDC code region + */ + if( dsp_opt & C_OPT ){ + fprintf(stdout ,"codeset\t\tcode area\n"); + fprintf(stdout ,"--------------------------------------------\n"); + if ( DispUdcCpArea( stdout ) == -1 ){ + ErrMsgTable_FalGetFontList( argv[0], fal_utyerror, fal_utyderror ); + exit( 1 ); + } + exit( 0 ); + } + + /* + * get an information list of UDC fonts + */ + mask = 0; + mask = FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_DEFINED ; + if( code_sw ) { + mask |= FAL_FONT_MASK_CODE_SET ; + key.cd_set = FALGETFALCODESET( code_set ) ; + } + + /* get font information list */ + if ( FalGetFontList( &key, mask, &lst_m ) == FAL_ERROR ){ + ErrMsgTable_FalGetFontList( argv[0], fal_utyerror, fal_utyderror ); + exit( 1 ); + } + + /* sort element of font infomation list */ + if( sort_fontlist( lst_m ) == FAL_ERROR ) { + FalFreeFontList( lst_m ); + return FAL_ERROR ; + } + + /* + * dtlsgpf shows UDC informations as user's request. + */ + dsp_title( stdout, dsp_opt ); + if ( lst_m->num == 0) { + disp_no_fontslist( dsp_opt ) ; + } else { + dsp_info_list( argv[0], dsp_opt, lst_m, &unknown_m, &errflg ); + if (unknown_m.num != 0) { + if( dsp_opt & L_OPT ) { + dsp_error_title(argv[0], &errflg, dsp_opt ); + if( dsp_error_files( lst_m, &unknown_m ) ) { + exit( 1 ); + } + } + } + } + + FalFreeFontList( lst_m ); + exit( 0 ); +} + + + + +static void +dsp_info_list( +char *com, +int dspopt, +FalFontDataList *lst, +MISS_ENTRY *unknown_file_lst, +int *errflg) +{ + FalFontDataList srt_lst; + int i, j ; + int entry, entry_end; + int ret; + char *filename; /* file base's name */ + char fname[BUFSIZE]; + char tmpfname[BUFSIZE]; + int srt_cnt, *sort_list, cnt, mask ; + + if( lst->num == 0 ){ + return ; + } + + srt_lst.num = lst->num ; + srt_lst.list = (FalFontData *)malloc( sizeof(FalFontData) * lst->num ) ; + if( srt_lst.list == NULL ) { + USAGE("dtlsgpf : malloc error.\n" ) ; + exit(1) ; + } + + for (i=0, srt_cnt=0 ; i < lst->num ; i++) { + int letter_cmp; + + entry = entry_end = i; + for (j=i ; + (j < lst->num) && + !strcmp(lst->list[j].style.name, lst->list[entry].style.name) && + (lst->list[j].size.h == lst->list[entry].size.h ) ; + j++) + { + if( (lst->list[j].letter.h == 0) || + (lst->list[j].letter.w == 0) ) break ; + entry_end = j; + } + + if ( entry == entry_end ) { + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( lst->list[entry], stdout, + unknown_file_lst, entry, + errflg, dspopt ); + else memmove( &(srt_lst.list[srt_cnt++]), + &(lst->list[entry]), + sizeof(FalFontData) ); + continue; + } + + letter_cmp = lst->list[entry].letter.h; + for (j=entry ; j <= entry_end ; j++) { + if (lst->list[j].letter.h != letter_cmp) { + break; + } + } + + if (j > entry_end) { + ret = GetDefaultFile( lst->list[entry].size.h, + lst->list[entry].style.name, fname); + if ( ret < 0 ) { + fname[0]='\0'; + for ( j = entry; j <= entry_end; j++ ) { + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( lst->list[j], stdout, + unknown_file_lst, j, + errflg, dspopt ); + else memmove( + &(srt_lst.list[srt_cnt++]), + &(lst->list[j]), + sizeof(FalFontData) ); + } + i = entry_end; + continue ; + } + for( j = entry; j <= entry_end; j++ ) { + ret = search_fontfile_name( + lst->list[j], tmpfname, + unknown_file_lst, j, errflg + ) ; + if( ret == -1 ) continue ; + else if( ret == -2 ) exit(1) ; + filename = falcom_get_base_name( tmpfname ) ; + if ( !strcmp( filename, fname ) ){ + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( lst->list[j], stdout, + unknown_file_lst, j, + errflg, dspopt ); + else memmove( + &(srt_lst.list[srt_cnt++]), + &(lst->list[j]), + sizeof(FalFontData) ); + break; + } + } + i = entry_end; + continue; + } + + + ret = GetDefaultFile( + lst->list[entry].size.h, + lst->list[entry].style.name, + fname + ); + if( ret ) { + switch ( ret ) { + case -1: + for ( j = entry; j <= entry_end; j++ ) { + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( + lst->list[j], stdout, + unknown_file_lst, j, + errflg, dspopt ); + else memmove( + &(srt_lst.list[srt_cnt++]), + &(lst->list[j]), + sizeof(FalFontData) ); + } + break ; + case -2: + unknown_file_lst->entry[ unknown_file_lst->num ].start = entry; + unknown_file_lst->entry[ unknown_file_lst->num ].end = entry_end; + unknown_file_lst->num++; + *errflg |= REDEFINED_FONT ; + break ; + case -3: + USAGE4("%s : The user defined character information file cannot be read.\"%s/%s/%s \"\n\n", + com, fontdir, utillocale, UDFLIST_DEF ); + exit(1) ; + case -4: + USAGE4("%s : The mistake is found in the description of the user defined character information file.\"%s/%s/%s \"\n\n", + com, utillocale, fontdir, UDFLIST_DEF ); + for ( j = entry; j <= entry_end; j++ ) { + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( lst->list[j], stdout, + unknown_file_lst, j, + errflg, dspopt ); + else memmove( + &(srt_lst.list[srt_cnt++]), + &(lst->list[j]), + sizeof(FalFontData) ); + } + break ; + } + i = entry_end; + continue; + } + + for ( j = entry; j <= entry_end; j++ ) { + ret = search_fontfile_name( + lst->list[j], tmpfname, + unknown_file_lst, j, errflg + ) ; + if( ret == -1 ) continue ; + else if( ret == -2 ) exit(1) ; + filename = falcom_get_base_name( tmpfname ) ; + if ( !strcmp( filename, fname ) ){ + if ( dspopt & L_OPT || dspopt & X_OPT ) + dspinfo_1line( lst->list[j], stdout, + unknown_file_lst, j, + errflg, dspopt ); + else memmove( + &(srt_lst.list[srt_cnt++]), + &(lst->list[j]), + sizeof(FalFontData) ); + break; + } + } + if ( j > entry_end ) { + unknown_file_lst->entry[ unknown_file_lst->num ].start = entry; + unknown_file_lst->entry[ unknown_file_lst->num ].end = entry_end; + unknown_file_lst->num++; + *errflg |= REDEFINED_FONT ; + } + i = entry_end; + } + + /* + * dtlsgpf displays the infomations of user defined characters. + */ + if ( !(dspopt & L_OPT) ) { /* display character size and style */ + srt_lst.num = srt_cnt ; + + if ( dspopt & A_OPT ) + mask = REQ_STYLE | REQ_CHARSIZE | REQ_LETTER | REQ_DELEQUAL ; + else + mask = REQ_CHARSIZE | REQ_DELEQUAL ; + + sort_offset_list( &srt_lst, mask, &sort_list, &cnt ) ; + + for (i=0 ; i<cnt; i++) + dspinfo_1line( srt_lst.list[sort_list[i]], stdout, + unknown_file_lst, sort_list[i], + errflg, dspopt ); + free( sort_list ) ; + free( srt_lst.list ) ; + } +} + + + + +static void +dsp_error_title(char *com, int *errflg, int dspopt) +{ + USAGE("\n\n" ); + if( dspopt & A_OPT ) { + if( *errflg & SAME_FONT ) + USAGE1("%s : There are fonts that are same character size and have same style, \ncode set and XLFD. It is not possible to select user defined character fonts uniquely.\n\n", com); + USAGE("Please inquire of the system manager.\n\n"); + } else { + if( *errflg & NO_FONT ) + USAGE1("\n%s : Mistake is found in the name of user defined character fonts \nfollowing character size and style.\n\n", com); + if( *errflg & REDEFINED_FONT ) + USAGE3(" Please describe the following file name in the user defined character \ninformation file(%s/%s/%s).\n\n", + fontdir, utillocale, UDFLIST_DEF ); + } +} + + + + + +static int +dsp_error_files( FalFontDataList *lst, MISS_ENTRY *unknown ) +{ + int i,j; + int entry_start, entry_end; + char *filename; + char tmp_fname[BUFSIZE]; + int ret ; + + if ( unknown->num == 0 ){ + return 0; + } + for (i=0 ; i<unknown->num ; i++) { + entry_start = unknown->entry[i].start; + entry_end = unknown->entry[i].end; + + USAGE1("\tcode set \t%d \n", + FALCODESETTONUM( lst->list[entry_start].cd_set ) ) ; + USAGE1("\tcharacter_size \t%d\n", + lst->list[entry_start].size.h ) ; + USAGE1("\tstyle \t\t%s \n", lst->list[entry_start].style.name ) ; + USAGE("\n" ); + for ( j = entry_start; j <= entry_end; j++ ) { + ret = search_fontfile_name( lst->list[j], tmp_fname, NULL, 0, 0 ) ; + if( ret == -1 ){ + USAGE("\t\tThere is no font file that is required." ); + USAGE1("\t%s\n", lst->list[j].xlfdname ); + continue ; + } else if( ret == -2 ){ + return -1 ; + } + filename = tmp_fname ; + USAGE1("\t\t%s", filename ); + USAGE1("\t%s\n", lst->list[j].xlfdname ); + } + USAGE("\n" ); + } + USAGE("\n" ); + return 0; +} + + + +#define SORTOFFSETNUM {\ + offset = size_offset_list[j] ;\ + size_offset_list[j] = size_offset_list[i] ;\ + size_offset_list[i] = offset ;\ +} + + +static void +sort_offset_list( +FalFontDataList *flist, +int mask, +int **sort_list, +int *data_cnt) +{ + int *size_offset_list ; + int cnt, i, j ; + int offset ; + int exist ; + + if( flist->num == 0 ){ + return ; + } + + if( (size_offset_list = (int *)malloc( flist->num * sizeof(int) )) == NULL ) + { + USAGE("dtlsgpf: malloc error.\n" ); + exit(1) ; + } + for( i=0 ; i < flist->num; i++ ) size_offset_list[i] = -1 ; + + for( i=0, cnt=0; i < flist->num; i++ ) { + if( mask & REQ_DELEQUAL ) { + exist = REQ_DELEQUAL ; + for( j=0; j<cnt; j++ ) { + if( size_offset_list[j] == -1 ) break ; + if( (mask & REQ_CHARSIZE) && + (flist->list[size_offset_list[j]].size.h == flist->list[i].size.h) + ) { + exist |= REQ_CHARSIZE ; + } + if( (mask & REQ_LETTER) && + (flist->list[size_offset_list[j]].letter.h == flist->list[i].letter.h) + ) { + exist |= REQ_LETTER ; + } + if( (mask & REQ_STYLE) && + !strcmp(flist->list[size_offset_list[j]].style.name, flist->list[i].style.name) + ) { + exist |= REQ_STYLE ; + } + if( exist == mask ) break ; + else exist = REQ_DELEQUAL ; + } /* size_offset_list */ + if( exist == mask ) continue ; + } /* REQ_DELEQUAL */ + size_offset_list[cnt++] = i ; + } /* flist */ + /* sort data */ + for( i=0; i<cnt-1; i++ ) { + for( j=i+1; j<cnt; j++ ) { + if( mask & REQ_LETTER ) { + if( flist->list[size_offset_list[i]].letter.h > + flist->list[size_offset_list[j]].letter.h) + { + SORTOFFSETNUM ; + } + } + if( mask & REQ_CHARSIZE ) { + if( flist->list[size_offset_list[i]].size.h > + flist->list[size_offset_list[j]].size.h) + { + SORTOFFSETNUM ; + } + } + if( mask & REQ_STYLE ) { + if( strcoll(flist->list[size_offset_list[i]].style.name, + flist->list[size_offset_list[j]].style.name) > 0 ) + { + SORTOFFSETNUM ; + } + } + } + } + *sort_list = size_offset_list ; + *data_cnt = cnt ; +} + + + +static void +dsp_title( FILE *fp, int dspopt ) +{ + if( dspopt & L_OPT || dspopt & X_OPT ) { + fprintf(fp, "\n" ) ; + + if( dspopt & X_OPT ) fprintf(fp, " code set" ); + if( dspopt & L_OPT ) fprintf(fp, "\tfilename\t" ); + if( (dspopt != X_OPT) && (dspopt != (L_OPT | X_OPT)) ) + fprintf(fp, "character size\t" ); + COMM_DSP_LETTER_T ; + if( dspopt & A_OPT ) fprintf(fp, "style \t" ); + COMM_DSP_PRM ; + if( dspopt != X_OPT ) fprintf(fp, "\n" ) ; + if( dspopt & X_OPT ) fprintf(fp, "\tXLFD\n" ); + fprintf(fp ,"-----------------------------------------------------------------------------\n"); + } +} + + + + + +static void +dspinfo_1line( +FalFontData data, +FILE *fp, +MISS_ENTRY *unknown_file_lst, +int offset, +int *errflg, +int dspopt) +{ + int dsp_on ; + char *namep; + char tmp_fname[BUFSIZE]; + int ret ; + + dsp_on = 0; + + /* get font informations */ + ret = search_fontfile_name( data, tmp_fname, unknown_file_lst, offset, errflg ) ; + if( ret == -1 ) return ; + else if( ret == -2 ) exit(1) ; + namep = tmp_fname ; + + /* display font informations */ + if( dspopt & X_OPT ) fprintf( fp, "%d \t", FALCODESETTONUM( data.cd_set ) ); + + if( dspopt & L_OPT ) fprintf( fp, "%s\t", namep ); + + if( (dspopt != X_OPT) && + (dspopt != (L_OPT | X_OPT)) + ) { + fprintf( fp, "%d", data.size.h ); + } + + if( dspopt & A_OPT ) { + if( data.letter.h ) { + if( !(dspopt & L_OPT) ) + fprintf( fp, ".%d", data.letter.h ); + else + fprintf( fp, "\t%4d", data.letter.h ); + } + fprintf( fp, "\t" ); + fprintf( fp, "%s", data.style.name ); + } + + if( dspopt & L_OPT ) { + fprintf( fp, "\t" ); + if( data.prm & FAL_FONT_DISPLAY ) { + fprintf( fp, "display"); + dsp_on = 1; + } + if( data.prm & FAL_FONT_PRINTER ) { + if( dsp_on ) { + fprintf( fp, " & "); + } + fprintf( fp, "printer"); + } + } + if( dspopt != X_OPT ){ + fprintf( fp, "\n"); + if( dspopt & X_OPT ) fprintf( fp, "\t" ); + } + if( dspopt & X_OPT ) fprintf( fp, "%s\n", data.xlfdname ); + if( dspopt != X_OPT ){ + if( dspopt & X_OPT ) fprintf( fp, "\n" ); + } +} + + + + + +static void +disp_no_fontslist( int dspopt ) +{ + fprintf( stdout, "\nThere are no fonts that are used for user defined character.\n" ) ; +} + + +static void +put_help( char *prog_name ) +{ + USAGE1("Usage : %s [-lax][-la][-lx][-C][-codeset number][-help]\n", prog_name); + USAGE("\t-l : display of file name and character size\n"); + USAGE("\t-a : display of style(FAMILY_NAME) information\n"); + USAGE("\t-x : display of XLFD information\n"); + USAGE("\t-C : display of code area informations\n"); + USAGE("\t-codeset : specification of the codeset\n"); + USAGE("\t-help : display of of the command parameter informations\n"); + + USAGE(" (If the option is not specified, only the character size are displayed.)\n"); +} + + + +static int +search_fontfile_name( +FalFontData data, +char *fname, +MISS_ENTRY *unknown_file_lst, +int offset, +int *errflg) +{ + FalFontID fid ; + FalFontDataList *flist ; + int mask ; + char *tmp_fname ; + + mask = + FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_XLFDNAME | + FAL_FONT_MASK_SIZE_H | + FAL_FONT_MASK_STYLE_NAME | FAL_FONT_MASK_CODE_SET + ; + + if( data.size.w >= 0 ) mask |= FAL_FONT_MASK_SIZE_W ; + if( data.letter.w ) mask |= FAL_FONT_MASK_LETTER_W ; + if( data.letter.h ) mask |= FAL_FONT_MASK_LETTER_H ; + if( data.letter.x ) mask |= FAL_FONT_MASK_LETTER_X ; + if( data.letter.y ) mask |= FAL_FONT_MASK_LETTER_Y ; + + if( data.style.def ) mask |= FAL_FONT_MASK_STYLE_DEF ; + if( data.shape.name ) mask |= FAL_FONT_MASK_SHAPE_NAME ; + if( data.shape.def ) mask |= FAL_FONT_MASK_SHAPE_DEF ; + COMM_SBCHR_SETFONTDATA( data, mask ) ; + if( data.prm ) mask |= FAL_FONT_MASK_PERMISSION ; + + fid = FalOpenSysFont( &data, mask, &flist ) ; + if( fid == 0 ) { + memset( fname, '\0', sizeof(fname) ) ; + if( flist ){ + FalFreeFontList( flist ) ; + if( unknown_file_lst ) { + unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ; + unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ; + unknown_file_lst->num++; + *errflg |= SAME_FONT ; + } + return(-1); + } else { + switch( fal_utyerror ) { + case _FAL_OPEN_ER : + case _FAL_READ_ER : + case _FAL_STAT_ER : + switch( fal_utyderror ) { + case EACCES : + case ENOENT : + if( unknown_file_lst ) { + unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ; + unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ; + unknown_file_lst->num++; + *errflg |= NO_FONT ; + } + return(-1) ; + default : + USAGE2("System call error occurred. fal_utyerror = %d fal_utyderror = %d\n", fal_utyerror, fal_utyderror ) ; + return(-2) ; + } + case _FAL_FONT_ER : + if( unknown_file_lst ) { + unknown_file_lst->entry[ unknown_file_lst->num ].start = offset ; + unknown_file_lst->entry[ unknown_file_lst->num ].end = offset ; + unknown_file_lst->num++; + *errflg |= NO_FONT ; + } + return(-1) ; + case _FAL_MALOC_ER : + USAGE("malloc error occurred.\n" ) ; + return(-2) ; + default : + USAGE1("%s : cannot get font information list.\n", command_name ) ; + return(-2) ; + } + } + } + if( FalFontIDToFileName( fid, &tmp_fname ) == FAL_ERROR ) { + USAGE1("%s : cannot get file name.\n", command_name ) ; + FalCloseFont( fid ) ; + return(-2) ; + } + strcpy( fname, tmp_fname ) ; + FalFree( tmp_fname ) ; + FalCloseFont( fid ) ; + return(0) ; +} + +static int +sort_fontlist( FalFontDataList *lst ) +{ + int i,j; + FalFontDataList srt; + FalFontData target; + int target_entry; + + if( lst->num == 0 ){ + return(0) ; + } + + srt.num = lst->num; + + if (( srt.list = (FalFontData *)malloc(sizeof(FalFontData) * srt.num)) == NULL) { + return FAL_ERROR; + } + memmove (srt.list, lst->list, sizeof(FalFontData) * srt.num); + /* start to sort */ + for ( i=0 ; i < srt.num -1 ; i++ ) { + + memmove( &target, &(srt.list[i]), sizeof(FalFontData)); + target_entry = i; + + for ( j=i+1 ; j < srt.num ; j++ ) { + if ( get_new_target( &target, &(srt.list[j]) ) ) { + memmove( &target, &(srt.list[j]), sizeof(FalFontData)); + target_entry = j; + } + } + if (target_entry != i) { + memmove( &target, &(srt.list[target_entry]), + sizeof(FalFontData) + ); + memmove( &(srt.list[i+1]), &(srt.list[i]), + sizeof(FalFontData)*(target_entry -i) + ); + memmove( &(srt.list[i]), &target, + sizeof(FalFontData) + ); + } + } + free(lst->list); + lst->list = srt.list; + return(0); +} + + +/* sort flag */ +/* return data ¡§ sort ... 1 */ +/* no sort ... 0 */ + +static int +get_new_target( FalFontData *target, FalFontData *choose ) +{ + FalFontData diff; + DEF_STR_CHK ; + DEF_STR_SET ; + + diff.style.def = choose->style.def - target->style.def; + str_chk.style = strcmp( choose->style.name, target->style.name ) ; + + NEW_TARGET_SET( diff, choose, target, str_chk ) ; + + diff.shape.def = choose->shape.def - target->shape.def; + if( (choose->shape.name != NULL) && (target->shape.name != NULL) ) { + str_chk.shape = strcmp( choose->shape.name, target->shape.name ) ; + } + + diff.cd_set = choose->cd_set - target->cd_set; + diff.size.h = choose->size.h - target->size.h; + diff.size.w = choose->size.w - target->size.w; + diff.letter.h = choose->letter.h - target->letter.h; + diff.letter.w = choose->letter.w - target->letter.w; + + /* codeset */ + if ( diff.cd_set < 0 ) return 1; + if ( diff.cd_set > 0 ) return 0; + + /* character size height */ + if ( diff.size.h < 0 ) return 1; + if ( diff.size.h > 0 ) return 0; + + /* letter size height */ + if ( diff.letter.h < 0 ) return 1; + if ( diff.letter.h > 0 ) return 0; + + /* character size wide */ + if ( diff.size.w < 0 ) return 1; + if ( diff.size.w > 0 ) return 0; + + /* letter size wide */ + if ( diff.letter.w < 0 ) return 1; + if ( diff.letter.w > 0 ) return 0; + + /* style */ + if ( target->style.def == FAL_FONT_UNKNOWN ) { + if ( choose->style.def > 0 ) return 1; + /* style is FAL_FONT_UNKNOWN both "target" and "choose" */ + if ( str_chk.style < 0 ) return 1; + if ( str_chk.style > 0) return 0; + } else if ( choose->style.def == FAL_FONT_UNKNOWN ) { + return 0; + } + /* target->style.def and choose->style.def is not FAL_FONT_UNKNOWN */ + if ( diff.style.def < 0 ) return 1; + if ( diff.style.def > 0 ) return 0; + + NEW_TARGET_CHK( diff, choose, target, str_chk ) ; + + /* character style */ + if ( target->shape.def == FAL_FONT_UNKNOWN ) { + if ( choose->shape.def > 0 ) return 1; + if ( str_chk.shape < 0 ) return 1; + if ( str_chk.shape > 0 ) return 0; + } else if (choose->shape.def == FAL_FONT_UNKNOWN ) { + return 0; + } + if ( diff.shape.def < 0 ) return 1; + if ( diff.shape.def > 0 ) return 0; + + return 0; +} diff --git a/cde/programs/dtudcfonted/dtudcfonted.1 b/cde/programs/dtudcfonted/dtudcfonted.1 new file mode 100644 index 000000000..42bf5760c --- /dev/null +++ b/cde/programs/dtudcfonted/dtudcfonted.1 @@ -0,0 +1,71 @@ +.\" $XConsortium: dtudcfonted.1 /main/2 1996/10/29 15:41:16 drk $ +.\"--- +.\" (c) Copyright 1996 FUJITSU Ltd. +.\"--- +.TH dtudcfonted 1X "20 Feb. 1996"" +.BH "20 Feb. 1996"" +.SH NAME +dtudcfonted - the User Defined Characters (UDCs) Font Editor +.SH SYNOPSIS +dtudcfonted [options] +.SH DESCRIPTION +The UDCs Editor provides the facilities that enable the user to edit +User Defined Characters font. +.P +The UDCs Editor uses lines and geometric shape drawing tools in order +to create new User Defined Character or modify existing ones. +It support PCF (Portable Compoled Formet) and SNF (Server Natural Format) +formats. +.sp .5 +.SS Key Supported Tasks +.RS +.P +- Modify size of window. +.P +- Modify location of window. +.P +- Iconify window. +.P +- Edit a User Defined Character or existing icon. +.P +- Save the current font. +.P +- Undo the last operation. +.P +- Cut, copy, and paste areas within the UDCs Editor editing area. +.P +- Rotate selected area. +.P +- Copy User Defined Character. +.RE +.SH OPTIONS +The following options are available from the command line: +.sp 1.5 +.BI \-pane_size " pane_size" +.sp .5 +This option takes a size of UDCs Editor editing area. +.sp 1.5 +.BI \-codepoint +.sp .5 +This option specifies code format. +If you do not set this optiton, UDCs editor uses Glyph Index code. +If you do set this optiton, UDCs editor uses Code point code. +.sp 1.5 +.SH RETURN VALUE + Exit values are: +.IP "\f30\fP" .5i +Successful completion. +.IP "\f3>0\fP" .5i +Error condition occurred. +.sp 1.5 +.SH EXAMPLES +.IP "dtudcfonted" .5i +Starts the UDCs Editor. +.sp 1.5 +.IP NOTE: .5i +UDCs Editor uses with root user. +.sp 1.5 +.SH FILES +Files used by this component. +.IP "/.../dt/app-defaults/C/Dtudcfonted App-defaults file. " .5i +.IP "/.../dt/app-defaults/ja_JP/Dtudcfonted App-defaults file. " .5i diff --git a/cde/programs/dtudcfonted/dtudcfonted.msg b/cde/programs/dtudcfonted/dtudcfonted.msg new file mode 100644 index 000000000..4d810bb99 --- /dev/null +++ b/cde/programs/dtudcfonted/dtudcfonted.msg @@ -0,0 +1,186 @@ +$ $XConsortium: dtudcfonted.msg +$ *************************************<+>************************************* +$ ***************************************************************************** +$ ** +$ ** File: dtudcfonted.msg +$ ** +$ ** Project: Fujitsu DT UDC Font Editor +$ ** +$ ** Description: +$ ** ----------- +$ ** This file is the source for the message catalog for dtudcfonted +$ ** +$ ** +$ ***************************************************************************** +$ ** +$ ** (c) Copyright 1996 Fujitsu Ltd. +$ ** +$set 2 +$ ***************************************************************************** +$ ** _DtMessage set for ufont.c +$ ***************************************************************************** + +$ This is footer message when registration of the character. +2 Registration processing inside. + +$ Message4-8 are error messages when registration of the character. +4 Failed in the registration of the character. +6 Illegal code. +8 Because the memory allocation cannot be done, it is not possible to add. + +$ Message10-16 are error messages when copying of the character. +10 There is no character of the specified code. +12 The mistake is found in the specified copy origin code. +14 The mistake is found in the specified copy target code. +16 There is no character in the specified area. + +$ This is footer message. +18 Please wait for a while. + +$ This is error message when copying of the character. +20 No copy origin code file is specified. + +$ Message22-24 are error message of user defined character +22 Informations of user defined character cannot collect.\nThere is no font specified. +24 Informations of user defined character cannot collect.\nThere are plural fonts specified. + +$ UDC is User Defined Character. +26 The specified font do not have any UDCs areas. + +28 There are no memories any more. +30 The information of UDCs area is illegal. +32 The font file cannot read.\nPattern area was broken. + +$ Dtudcfonted is name of this application. +34 Dtudcfonted cannot edit proportional character font. + +36 There are unsaved edits.\nDo you want to save them before opening? +38 There are unsaved edits.\nDo you want to save them before exiting? +40 When the copy processing is done, the glyph\nimage within the following ranges is changed.\nDo you want to do the copy processing?\n\n +42 No write permission for this font. You should change the file access mode before saving.\n + +$ There are user-visible labels in font-open dialog. +100 Select Items +102 - CodeSet: +104 - Style: +106 - Width: +108 - Height: +110 Open +112 Quit + +$ There are user-visible labels in menubar. +114 Font +116 Edit +118 Character +120 Information + +$ There are user-visible labels in File menu. +122 Open... +124 Save +126 Exit + +$ There are user-visible labels in Edit menu. +$ Message135 is copy of cut© +128 Clear +130 Set +132 Reverse +134 Cut +135 Copy +136 Paste +138 Rotate +140 Vertical Roll +142 Horizontal Roll +144 Undo + +$ There are user-visible labels in Character menu. +$ Message148 is copy of character +146 Add/Delete... +148 Copy... + +$ There are user-visible labels in Information menu. +150 XLFD name... +152 Code Area... + +$ There are user-visible labels in add/delete dialog. +154 Add +156 Delete +158 Cancel + +$ There are user-visible labels in copy dialog. +$ Message166 is label of execute button +160 Code(hex): +162 Copy origin code(hex): +164 Copy target code(hex): +166 Copy +168 Overlay +170 OK + +$ There are user-visible labels in unsaved edits. +172 Save +174 Do not Save +176 Save and Exit +178 Do not Save and Exit + +$ There are user-visible labels in delete notice dialog. +$ This format is `Message180 (?? Message182)' and `Message184 (?? Message186)'. +$ These Message180 and Message182 are used in only one character. +$ These Message184 and Message186 are used in plural characters. +180 The following character will be deleted. +182 character +184 The following characters will be deleted. +186 characters +188 Register completed +190 Code : +192 Code range : + +$ There are footer message label. +194 Message : + +$ There are user-visible labels in code dialog. +196 code... +198 Page up +200 Page down +202 Apply + +$ There are title. +204 dtudcfonted - Question +206 dtudcfonted - Warning +208 dtudcfonted - Error +210 dtudcfonted - Copy +212 dtudcfonted - Open +214 dtudcfonted - Add/Delete +216 dtudcfonted - XLFD +218 dtudcfonted - CodeArea + +$ There are information message. +230 File name +232 XLFD name +234 Code area + +$ There are error message of libfal. +300 Fatal error occurred. +301 Cannot open the font file. +302 Cannot read the font file. +303 There is no more memory. +304 Fatal error occurred. +305 The specified font file does not exist. +306 This font is not a pcf or snf font. +307 Cannot open fonts.list file. +308 The format of fonts.list file is illegal. +309 The descriptions of the fonts.list file are incorrect. +310 The format of fonts.list file is illegal. +311 Cannot open fonts.dir file. +312 Cannot read fonts.dir file. +313 Cannot read font properties. +314 Cannot get FONT property. +315 Cannot get FAMILY_NAME property. +316 This font file is already opened by other application. +317 Cannot lock font file. +318 Cannot unlock font file. +319 Cannot get lock information from the font file. +320 Cannot find the specified font file. +321 Cannot read NLS database. +322 Cannot get charset names from NLS database. +323 Charset name not defined in NLS database. +324 The specified font has not been opened. +325 Fatal error occurred. diff --git a/cde/programs/dtdocbook/sgmls/sgmlsasp.h b/cde/programs/dtudcfonted/fssxeg.h similarity index 59% rename from cde/programs/dtdocbook/sgmls/sgmlsasp.h rename to cde/programs/dtudcfonted/fssxeg.h index 86178c7a6..57abf7d51 100644 --- a/cde/programs/dtdocbook/sgmls/sgmlsasp.h +++ b/cde/programs/dtudcfonted/fssxeg.h @@ -20,30 +20,28 @@ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ -/* $XConsortium: sgmlsasp.h /main/3 1996/06/19 17:18:15 drk $ */ -/* sgmlsasp.h */ +/* fssxeg.h 1.5 - Fujitsu source for CDEnext 96/07/18 13:19:30 */ +/* $XConsortium: fssxeg.h /main/4 1996/07/19 20:32:54 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ -#include "config.h" -#include "std.h" -#ifdef USE_PROTOTYPES -#define P(parms) parms -#else -#define P(parms) () -#endif -#ifdef __GNUC__ -#define NO_RETURN volatile -#else -#define NO_RETURN /* as nothing */ -#endif +#include "udccom.h" /* 1995.10.09 */ +#include "FaLib.h" -#ifdef VARARGS -#define VP(parms) () -#else -#define VP(parms) P(parms) -#endif +#define ON 1 +#define OFF 0 -NO_RETURN void error VP((char *,...)); +#define MAXPTNSIZE 128 +#define MAXPTNBYTE MAXPTNSIZE*((MAXPTNSIZE+7)/8) -extern int fold_general_names; +#define ERROR_VAL fal_utyerror +#define EXISTS_FLAG fal_utyexists + +#define EDPANE_SIZE 400 +#define EDLIST_MAX 30 diff --git a/cde/programs/dtudcfonted/include/FaLib.h b/cde/programs/dtudcfonted/include/FaLib.h new file mode 100644 index 000000000..f2524b458 --- /dev/null +++ b/cde/programs/dtudcfonted/include/FaLib.h @@ -0,0 +1,388 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: FaLib.h /main/5 1996/06/25 20:08:31 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#ifndef _FALIB_H +#define _FALIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define FAL_ERROR -1 + +extern int fal_utyerror; /* library error information */ +extern int fal_utyderror; /* library error information */ +extern int fal_utyexists; /* existence's flag of font pattern */ + +extern unsigned long fal_utyerrno ; /* library error information */ +extern char fal_err_file[] ; + +/* + * + * structure of the font information + * + */ + +/* + * the equipment of output permission + */ +#define FAL_FONT_DISPLAY 1 +#define FAL_FONT_PRINTER 2 + + +#define FAL_FONT_GLYPH_INDEX -1 +/* + * codeset + */ +#define FAL_FONT_CS0 1 +#define FAL_FONT_CS1 2 +#define FAL_FONT_CS2 3 +#define FAL_FONT_CS3 4 + +#define FAL_FONT_CS4 5 +#define FAL_FONT_CS5 6 +#define FAL_FONT_CS6 7 +#define FAL_FONT_CS7 8 +#define FAL_FONT_CS8 9 + +/* + * font search mask + */ +#define FAL_FONT_MASK_XLFDNAME (1L<<1) +#define FAL_FONT_MASK_SIZE_W (1L<<2) +#define FAL_FONT_MASK_SIZE_H (1L<<3) +#define FAL_FONT_MASK_LETTER_W (1L<<4) +#define FAL_FONT_MASK_LETTER_H (1L<<5) +#define FAL_FONT_MASK_LETTER_X (1L<<6) +#define FAL_FONT_MASK_LETTER_Y (1L<<7) +#define FAL_FONT_MASK_STYLE_DEF (1L<<8) +#define FAL_FONT_MASK_STYLE_NAME (1L<<9) +#define FAL_FONT_MASK_SHAPE_DEF (1L<<10) +#define FAL_FONT_MASK_SHAPE_NAME (1L<<11) + + +#define FAL_FONT_MASK_CODE_SET (1L<<14) +#define FAL_FONT_MASK_PERMISSION (1L<<15) +#define FAL_FONT_MASK_DEL_EQUALDATA (1L<<16) +#define FAL_FONT_MASK_CHECK_ALL 0x1FFFF + +#define FAL_FONT_MASK_GLYPH_INDEX (1L<<17) +#define FAL_FONT_MASK_UPDATE (1L<<18) +#define FAL_FONT_MASK_DEFINED (1L<<19) +#define FAL_FONT_MASK_UNDEFINED (1L<<20) + + +/* + * undefined the character style,shape + */ +#define FAL_FONT_UNKNOWN 0 + +/* + * definition's data of character style + */ +#define FAL_FONT_MINCHO 1 +#define FAL_FONT_STR_MINCHO "mincho" +#define FAL_FONT_GOTHIC 2 +#define FAL_FONT_STR_GOTHIC "gothic" +#define FAL_FONT_MARU_GOTHIC 3 +#define FAL_FONT_STR_MARU_GOTHIC "maru_gothic" +#define FAL_FONT_TEXTBOOK 4 +#define FAL_FONT_STR_TEXTBOOK "textbook" +#define FAL_FONT_BRASH_GYOU 5 +#define FAL_FONT_STR_BRASH_GYOU "brash_gyou" +#define FAL_FONT_BRASH_KAI 6 +#define FAL_FONT_STR_BRASH_KAI "brash_kai" +#define FAL_FONT_HANDWRITING 7 +#define FAL_FONT_STR_HANDWRITING "handwriting" + +/* + * definition's data of character shape + */ +#define FAL_FONT_ZENKAKU 1 +#define FAL_FONT_STR_ZENKAKU "zenkaku" +#define FAL_FONT_HANKAKU 2 +#define FAL_FONT_STR_HANKAKU "hankaku" +#define FAL_FONT_QUARTER 3 +#define FAL_FONT_STR_QUARTER "1/4kaku" + +/* + * structures for font informations + */ +typedef struct { + int width; /* width */ + int height; /* height */ + int top; /* the head code */ + int bottom; /* the final code */ +} FalFontinfo ; + +typedef struct { + int num; + char **path; +} FalFontPath; + +typedef struct { + int def; /* definition data */ + char *name; /* the information of the character line */ +}FalFontDB; + + +/* + * structure of the font information + */ +typedef struct { + char *xlfdname; /* xlfd name */ + struct { + int w; /* the width of the character size */ + int h; /* the height of the character size */ + }size; + struct { + int w; /* the width of the letter size */ + int h; /* the height of the letter size */ + int x; /* position x of the letter size */ + int y; /* position y of the letter size */ + }letter; + FalFontDB style; /* character style */ + FalFontDB shape; /* character shape */ + FalFontDB reserve ; /* reserve */ + int cd_set; /* codeset */ + int prm; /* the equipment of output permission */ +}FalFontData; + +typedef struct { + int num; /* the number of font data*/ + FalFontData *list; /* the pointer to the array of + FalFontData structure */ +}FalFontDataList; + +/* + * UDC infomations + */ +typedef struct _FalCodeRegion { + int start ; /* first code */ + int end ; /* last code */ +} FalCodeRegion ; + +typedef struct _FalGlyphRegion { + int start ; /* first glyph index */ + int end ; /* last glyph index */ +} FalGlyphRegion ; + +typedef struct _FalGIInf { + char *charset_str; /* charcter set */ + int glyph_index; /* glyph index */ +} FalGIInf; + +/* + * structure of the font identifier + */ +#include <X11/Xos.h> +#include <X11/Xmd.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include <stdlib.h> +#include <dirent.h> + +#ifdef Bool +#undef Bool +#endif + +#include "snfstruct.h" +#include <X11/fonts/fontstruct.h> +#include "pcf.h" + +struct pcf_inf { + FontInfoRec info; + xCharInfo org_bounds; + PCFTablePtr tables; + int ntables; + CARD32 bmp_fmt; /* bitOrder ,byteOrder, glyph, scan */ + int nbitmaps; + CARD32 *offsets; + int sizebitmaps; + char *bitmaps; + CARD32 enc_fmt; + CARD16 *encodingOffsets; +}; + +typedef struct _Oak_Finf { + int ismmap; /* used mmap()? */ + int fsize; /* file size */ + int fd; /* file descripter */ + int isFef; + char *buf; /* font file allocated on memory */ + char *fname; /* name of font file */ +/* added by Rudie */ + int isPcf; + struct pcf_inf pcfinf; +/* added by Rudie */ + FontInfoPtr pFinf; + CharInfoPtr pCinf; + unsigned char *pGlyphs; + unsigned int width; + unsigned int height; + unsigned int start; + unsigned int end; + int sptnBufL; + char *sptnBuf; + int dptnBufL; + char *dptnBuf; + int dbufL; + char *dbuf; +} Oak_FontInf; + +typedef Oak_FontInf * FalFontID; /* font distinction */ + +/* + * function prototypes + */ +extern FalFontID FalOpenSysFont( + FalFontData* /* open_font_data */, + int /* font_data_mask */, + FalFontDataList** /* missing_font_list_return */ +) ; + +extern int FalGetFontList( + FalFontData* /* key_data */, + int /* mask */, + FalFontDataList** /* list_ret */ +) ; + +extern int FalFreeFontList( + FalFontDataList* /* list */ +) ; + +extern char * +FalReadFont( + FalFontID /* fid */ , + int /* code */ , + int /* width */ , + int /* height */ +) ; + +extern int FalQueryFont( + FalFontID /* fid */ , + FalFontinfo* /* fontinfo */ +) ; + +extern int FalFontOfFontID( + FalFontID /* fid */, + FalFontData* /* fontdata */ +) ; + +extern int FalCloseFont( + FalFontID /* fid */ +) ; + +extern int FalFontIDToFileName( + FalFontID /* fid */ , + char** /* file_name */ +) ; + +extern int FalFree( + void* /* list */ +) ; + +extern int FalGetUDCCPArea( + char* /* locale */ , + int /* code_set */ , + char* /* charset_str */ , + FalCodeRegion** /* cr */ , + int* /* num_cr */ +) ; + +extern int FalGetUDCGIArea( + char* /* locale */ , + int /* codeset */ , + char* /* charset_str */ , + FalGlyphRegion** /* gr */ , + int* /* num_gr */ +) ; + +extern FalFontID FalOpenFont() ; + +/* + * Code set + */ +#define FALGETFALCODESET( cd_set ) ( ((cd_set)==-1) ? FAL_FONT_GLYPH_INDEX : (cd_set)+1 ) + +#define FALCODESETTONUM( cd_set ) ( ((cd_set)==FAL_FONT_GLYPH_INDEX) ? -1 : (cd_set)-1 ) + +/* + * fal_utyerrno + */ +#define FAL_FUNCNUM_GFLST 0x0 +#define FAL_FUNCNUM_SRCHFNM 0x0 +#define FAL_FUNCNUM_OPNFNT 0x0 +#define FAL_FUNCNUM_FRFLST 0x0 +#define FAL_FUNCNUM_RDFNT 0x0 +#define FAL_FUNCNUM_QRY 0x0 +#define FAL_FUNCNUM_FID 0x0 +#define FAL_FUNCNUM_IDTOFNM 0x0 +#define FAL_FUNCNUM_CLSFNT 0x0 +#define FAL_FUNCNUM_CPA 0x0 +#define FAL_FUNCNUM_GIA 0x0 +#define FAL_FUNCNUM_FREE 0x0 + +#define FAL_ERR_NON 0x00 + +#define FAL_ERR_FNT_OPN 0x01 +#define FAL_ERR_FNT_RD 0x02 +#define FAL_ERR_MALLOC 0x03 +#define FAL_ERR_PARM 0x04 +#define FAL_ERR_STAT 0x05 +#define FAL_ERR_FONT 0x06 +#define FAL_ERR_FDATA_OPN 0x07 +#define FAL_ERR_FDATA_RD 0x08 +#define FAL_ERR_FDATA_DSC 0x09 +#define FAL_ERR_FPATH 0x0a + +#define FAL_ERR_FNTDIR_OPN 0x0b +#define FAL_ERR_FNTDIR_RD 0x0c +#define FAL_ERR_PROP_RD 0x0d +#define FAL_ERR_PROP_FONT 0x0e +#define FAL_ERR_PROP_FNAME 0x0f +#define FAL_ERR_LCKD 0x10 +#define FAL_ERR_FILELCK 0x11 +#define FAL_ERR_FILEUNLCK 0x12 +#define FAL_ERR_FILEGETLCK 0x13 +#define FAL_ERR_NOFONT 0x14 + +#define FAL_ERR_XLC_CRTDB 0x15 +#define FAL_ERR_XLC_GETCHARST 0x16 +#define FAL_ERR_XLC_NOCHARST 0x17 + +#define FAL_ERR_FID_RD 0x18 +#define FAL_ERR_FATAL 0x19 + + +#ifdef __cplusplus +} +#endif +#endif /* _FALIB_H */ diff --git a/cde/programs/dtudcfonted/include/bdfgpf.h b/cde/programs/dtudcfonted/include/bdfgpf.h new file mode 100644 index 000000000..6cf0e70df --- /dev/null +++ b/cde/programs/dtudcfonted/include/bdfgpf.h @@ -0,0 +1,519 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: bdfgpf.h /main/7 1996/06/25 20:08:09 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "udccom.h" +#include "FaLib.h" + +struct btophead { + char *in_file; + char *out_file; + char *text_file; + FILE *input; + FILE *output; + int num_chars; + int p_width; + int p_height; + int bdf_width; + int bdf_height; + + int bdf_x; + int bdf_y; + float bdf_point; + int bdf_xdpi; + int *code; + char **ptn; + int zoomf; + + int code_category; + int start_code; + int end_code; +}; + +struct ptobhead { + char *in_file; + char *out_file; + char *bdf_file; + char *snf_file; + FILE *input; + FILE *output; + int num_chars; + int p_width; + int p_height; + int bdf_width; + int bdf_height; + + int bdf_x; + int bdf_y; + float bdf_point; + int bdf_xdpi; + + int reserve ; + int *code; + char **ptn; + int zoomf; + + int code_category; + int start_code; + int end_code; + +}; + +#define MIN_CODE 0x0000 +#define MAX_CODE 0xFFFF + +#define ALL_CODE 0 + +extern char *oakgtobdf; +extern char *bdftosnf; +extern char *bdftopcf; + + + +#define TAB_CD 0x09 +#define USE_ORG_SIZE -1 +#define MAX_FONT_WIDTH 999 +#define MIN_FONT_WIDTH 2 +#define MAX_FONT_HEIGHT 999 +#define MIN_FONT_HEIGHT 2 + +#ifdef BUFSIZE +#undef BUFSIZE +#endif /* BUFSIZE */ +#define BUFSIZE 1024 + +/* KeyWord for BDF file */ + +#define STARTFONT "STARTFONT " +#define STARTFONTsz 10 +#define FONTBOUNDINGBOX "FONTBOUNDINGBOX " +#define FONTBOUNDINGBOXsz 16 +#define SIZE "SIZE " +#define SIZEsz 5 +#define CHARS "CHARS " +#define CHARSsz 6 +#define STARTCHAR "STARTCHAR " +#define STARTCHARsz 10 +#define ENCODING "ENCODING " +#define ENCODINGsz 9 +#define BITMAP "BITMAP" +#define BITMAPsz 6 +#define ENDCHAR "ENDCHAR" +#define ENDCHARsz 7 +#define ENDFONT "ENDFONT" +#define ENDFONTsz 7 + +#define CHARSET_REGISTRY "CHARSET_REGISTRY " +#define CHARSET_REGISTRYsz 17 + + +/* KeyWord for GPF file */ + +#define NUMFONTS "numfonts:" +#define NUMFONTSsz 9 +#define WIDTH "width:" +#define WIDTHsz 6 +#define HEIGHT "height:" +#define HEIGHTsz 7 +#define CODE "code:" +#define CODEsz 5 +#define ENDDATA "enddata" +#define ENDDATAsz 7 + +#define FILE_END 99 + +#define FATAL_ERROR -1 +#define BDF_OPEN -2 +#define BDF_OPEN_IN -2 +#define BDF_READ -3 +#define BDF_WRITE -4 +#define BDF_INVAL -5 +#define GPF_OPEN -6 +#define GPF_OPEN_IN -6 +#define GPF_READ -7 +#define GPF_WRITE -8 +#define GPF_INVAL -9 +#define PARAM_ERROR -10 + +#define BDF_OPEN_OUT -11 +#define GPF_OPEN_OUT -12 +#define BDF_OPEN_HEAD -13 +#define BDF_READ_HEAD -14 + +/* system_ call error */ +#define MALLOC_ERROR -15 +#define FORK_ERROR -16 +#define EXEC_ERROR -17 +#define PIPE_ERROR -18 +#define DUP_ERROR -19 +#define POPEN_ERROR -20 +#define PCLOSE_ERROR -21 +#define FDOPEN_ERROR -22 +#define STAT_ERROR -23 +#define MKTMP_ERROR -24 + +#define PCFFONTC_ERROR -25 +#define SNFFONTC_ERROR -26 + +#define SCAN_TO_NONSP(p) {\ + while (*(p) != 0) {\ + if ((*(p) == ' ') || (*(p) == TAB_CD) || (*(p) == 0xa1)) {\ + (p)++;\ + } else {\ + break;\ + }\ + }\ +} + +#define SCAN_TO_SP(p) {\ + while (*(p) != 0) {\ + if ((*(p) == ' ') || (*(p) == TAB_CD) || (*(p) == 0xa1)) {\ + break;\ + } else {\ + (p)++;\ + }\ + }\ +} + + +#if defined( SVR4 ) || defined( SYSV ) +#define WaitID( chld_pid, chld_stat ) waitpid( (chld_pid), &(chld_stat), WUNTRACED ) +#else +#define WaitID( chld_pid, chld_stat ) {\ + for(;;){\ + int rtn ;\ + rtn = wait3( &(chld_stat), WUNTRACED, NULL );\ + if( rtn == (chld_pid) ) break ;\ + if( rtn == -1 ){\ + if( errno == EINTR ) continue ;\ + else break ;\ + }\ + }\ +} +#endif + +#ifndef DEFAULT_CODESET +#define DEFAULT_CODESET "3" +#endif + +/* + * tempory file + */ +#define TempFileKey "XXXXXX" +#define TEMPFILEKEY TempFileKey +#ifndef DEFAULT_TMPPATH +#define DEFAULT_TMPPATH "/var/tmp/" +#endif /* DEFAULT_TMPPATH */ + +/* + * Function prototypes + */ +extern int falcom_atoi( + char* /* str */, + char /* ed_cod */, + int* /* val */ +); + +extern int GetDefaultFile( + int /* size */, + char* /* style */, + char* /* fname */ +); + +extern int get_default_file( + FILE* /* fp */, + int /* size */, + char* /* style */, + char* /* fname */ +); + +extern char *falcom_get_base_name( + char* /* str */ +); + +extern int GetFileName( + char* /* com */, + char* /* size_str */, + char* /* style */, + int /* codeset */, + char* /* ofile */ +); + +extern void ErrMsgTable_FalGetFontList( + char* /* com */, + int /* utyerr */, + int /* utyderr */ +); + +extern void fal_cut_tailslash( + char* /* name */ +); + +extern char *GetRealFileName( + char* /* name */ +); + +extern int IsInRegion( + int /* code */, + int /* num_gr */, + FalGlyphRegion* /* gr */ +); + +extern int GetUdcFileName( + char* /* com */, + int /* code_no */, + char* /* xlfdname */, + char* /* fname */ +); + +extern int GetUdcRegion( + char* /* com */, + int /* codeset */, + char* /* gpf_file */, + int* /* num_gr */, + FalGlyphRegion** /* gr */ +); + +extern int DispUdcCpArea( + FILE* /* fp */ +); + +extern int GetUdcFontName( + char* /* gpf_file */, + char* /* bdf_file */, + char** /* fontname */ +); + +extern int FileLock( + int /* fd */ +); + +extern int FileUnLock( + int /* fd */ +); + +extern int isLock( + int /* fd */ +); + +extern int ReadBdfHeader( + struct btophead* /* head */, + char* /* buf */ +); + +extern int ReadGpfHeader( + struct ptobhead* /* head */, + char* /* buf */ +); + +extern int WriteBdfHeader( + struct ptobhead* /* head */ +); + +extern void WriteGpfHeader( + struct btophead* /* head */ +); + +extern int WritePtnToBdf( + struct ptobhead* /* head */ +); + +extern int putDefaultChars( + struct ptobhead* /* head */ +); + +extern int WritePtnToGpf( + struct btophead* /* head */ +); + +extern int ReadBdfToMemory( + struct btophead* /* head */, + char* /* buf */ +); + +extern int ReadBdfToMemory_with_init( + struct btophead* /* head */, + int /* init_start */, + int /* init_end */, + char* /* buf */ +); + +extern int GetBdfCode( + struct btophead* /* head */, + char* /* buf */, + int* /* code */ +); + +extern int GetBdfPtn( + struct btophead* /* head */, + char* /* buf */, + char* /* ptn */, + int /* mwidth */, + int /* bsize */ +); + +extern int ReadGpfToMemory( + struct ptobhead* /* head */, + char* /* buf */ +); + +extern int GetGpfCode( + struct ptobhead* /* head */, + char* /* buf */, + int* /* code */ +); + +extern int GetGpfPtn( + struct ptobhead* /* head */, + char* /* buf */, + char* /* ptn */, + int /* mwidth */, + int /* bsize */ +); + +extern void GetBdfLinePtn( + char* /* mem */, + char* /* buf */, + int /* width */ +); + +extern void GetGpfLinePtn( + char* /* mem */, + char* /* buf */, + int /* width */ +); + +extern int PutBdfPtn( + unsigned char* /* ptn */, + int /* width */, + int /* height */, + FILE* /* fp */ +); + +extern int PutGpfPtn( + char* /* ptn */, + int /* width */, + int /* height */, + FILE* /* fp */ +); + +extern int PtnZoom( + char* /* dmem */, + char* /* smem */, + int /* sw */, + int /* sh */, + int /* dw */, + int /* dh */ +); + +extern char *GetTmpPath( + char* /* path */ +); + +extern int ChkNumString( + char* /* str */ +); + +extern void ErrMsgTable_AndExit( + int /* er_no */, + char* /* snf_in */, + char* /* snf_out */, + char* /* gpf_in */, + char* /* gpf_out */, + char* /* bdf_in */, + char* /* prog_name */ +); + +extern void fatal_err_msg( + int /* er_no */, + char* /* prog_name */ +); + +extern void ChatchSig() ; + +extern void Put_File_Create_Err_Msg( + int /* msg_level */, + char* /* org_name */, + char* /* tmp_name */, + char* /* save_name */, + char* /* com */ +); + +extern int Make_NewFefFile( + char* /* org_name */, + char* /* tmp_name */, + mode_t /* mode */, + uid_t /* owner */, + gid_t /* group */, + char* /* com */ +); + +extern int Unlink_Tmpfile( + char* /* file */, + char* /* com */ +); + +extern int Chmod_File ( + char* /* fname */, + mode_t /* mode */, + char* /* com */ +); + +extern int Chown_File ( + char* /* fname */, + uid_t /* owner */, + gid_t /* group */, + char* /* com */ +); + +extern int ChkPcfFontFile( + char* /* filename */ +); + +extern int ChkSnfFontFile( + char* /* filename */ +); + +extern char *get_cmd_path( + char* /* path */, + char* /* cmd */ +); + +extern int SetCmdPath( + char* /* com */, + char** /* path */, + char* /* dflt_path */, + char* /* cmd */ +); + +extern int +Link_NewFile( + char * /* rd_file */, + char * /* wr_file */ +); diff --git a/cde/programs/dtudcfonted/include/pcf.h b/cde/programs/dtudcfonted/include/pcf.h new file mode 100644 index 000000000..ad36b922e --- /dev/null +++ b/cde/programs/dtudcfonted/include/pcf.h @@ -0,0 +1,107 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: pcf.h /main/2 1996/02/10 16:25:46 cde-fuj $ */ +/* + * + * Copyright 1990 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. M.I.T. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + (c) Copyright 1995 FUJITSU LIMITED + This is source code modified by FUJITSU LIMITED under the Joint + Development Agreement for the CDEnext PST. + This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#ifndef _PCF_H_ +#define _PCF_H_ + +/* + * Information used to read/write PCF fonts + */ + +typedef struct _PCFTable { + CARD32 type; + CARD32 format; + CARD32 size; + CARD32 offset; +} PCFTableRec, *PCFTablePtr; + +#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1) +#define PCF_FORMAT_MASK 0xffffff00 + +#define PCF_DEFAULT_FORMAT 0x00000000 +#define PCF_INKBOUNDS 0x00000200 +#define PCF_ACCEL_W_INKBOUNDS 0x00000100 +#define PCF_COMPRESSED_METRICS 0x00000100 + +#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK)) + +#define PCF_GLYPH_PAD_MASK (3<<0) +#define PCF_BYTE_MASK (1<<2) +#define PCF_BIT_MASK (1<<3) +#define PCF_SCAN_UNIT_MASK (3<<4) + +#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst) +#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst) +#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK) +#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f)) +#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4) +#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f)) +#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK)) + +#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0) +#define PCF_INDEX_TO_SIZE(b) (1<<b) + +#define PCF_FORMAT(bit,byte,glyph,scan) (\ + (PCF_SIZE_TO_INDEX(scan) << 4) | \ + (((bit) == MSBFirst ? 1 : 0) << 3) | \ + (((byte) == MSBFirst ? 1 : 0) << 2) | \ + (PCF_SIZE_TO_INDEX(glyph) << 0)) + +#define PCF_PROPERTIES (1<<0) +#define PCF_ACCELERATORS (1<<1) +#define PCF_METRICS (1<<2) +#define PCF_BITMAPS (1<<3) +#define PCF_INK_METRICS (1<<4) +#define PCF_BDF_ENCODINGS (1<<5) +#define PCF_SWIDTHS (1<<6) +#define PCF_GLYPH_NAMES (1<<7) +#define PCF_BDF_ACCELERATORS (1<<8) + +#endif /* _PCF_H_ */ diff --git a/cde/programs/dtudcfonted/include/snfstruct.h b/cde/programs/dtudcfonted/include/snfstruct.h new file mode 100644 index 000000000..0bbf632a0 --- /dev/null +++ b/cde/programs/dtudcfonted/include/snfstruct.h @@ -0,0 +1,114 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: snfstruct.h /main/2 1996/02/10 16:25:06 cde-fuj $ */ +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +and the Massachusetts Institute of Technology, Cambridge, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Digital or MIT not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +(c) Copyright 1995 FUJITSU LIMITED +This is source code modified by FUJITSU LIMITED under the Joint +Development Agreement for the CDEnext PST. +This is unpublished proprietary source code of FUJITSU LIMITED + +******************************************************************/ +#ifndef SNFSTRUCT_H +#define SNFSTRUCT_H 1 +#include <X11/fonts/font.h> +#include <X11/Xlib.h> + +/* + * This file describes the Server Natural Font format. + * SNF fonts are both CPU-dependent and frame buffer bit order dependent. + * This file is used by: + * 1) the server, to hold font information read out of font files. + * 2) font converters + * + * Each font file contains the following + * data structures, with no padding in-between. + * + * 1) The XFONTINFO structure + * hand-padded to a two-short boundary. + * maxbounds.byteoffset is the total number of bytes in the + * glpyh array + * maxbounds.bitOffset is thetotal width of the unpadded font + * + * 2) The XCHARINFO array + * indexed directly with character codes, both on disk + * and in memory. + * + * 3) Character glyphs + * padded in the server-natural way, and + * ordered in the device-natural way. + * End of glyphs padded to 32-bit boundary. + * + * 4) nProps font properties + * + * 5) a sequence of null-terminated strings, for font properties + */ + +#define FONT_FILE_VERSION 4 + +/* + * the following macro definitions describe a font file image in memory + */ +#define ADDRCharInfoRec( pfi) \ + ((CharInfoRec *) &(pfi)[1]) + +#define ADDRCHARGLYPHS( pfi) \ + (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi)) + +/* + * pad out glyphs to a CARD32 boundary + */ +#define ADDRXFONTPROPS( pfi) \ + ((DIXFontProp *) (char *)ADDRCHARGLYPHS( pfi)) + +#define ADDRSTRINGTAB( pfi) \ + ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi)) + +#define BYTESOFFONTINFO(pfi) (sizeof(FontInfoRec)) +#define BYTESOFCHARINFO(pfi) (sizeof(CharInfoRec) * n2dChars(pfi)) +#define BYTESOFPROPINFO(pfi) (sizeof(FontPropRec) * (pfi)->nProps) +#define BYTESOFSTRINGINFO(pfi) ((pfi)->lenStrings) +#define BYTESOFINKINFO(pfi) (sizeof(CharInfoRec) * (2 + n2dChars(pfi))) + +#endif /* SNFSTRUCT_H */ + diff --git a/cde/programs/dtudcfonted/include/udccom.h b/cde/programs/dtudcfonted/include/udccom.h new file mode 100644 index 000000000..8e9dd4bb2 --- /dev/null +++ b/cde/programs/dtudcfonted/include/udccom.h @@ -0,0 +1,70 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udccom.h /main/5 1996/07/19 20:31:51 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include "udcopt.h" + +/* default path of dtaddcpf */ +#define DFLTPATH "/usr/dt/lib/dtudcfonted/dtaddcpf" +#define DFLTCMD "dtaddcpf" + +/* commands for exchange font format */ +#define SNFTOBDF_CMD "dtgpftobdf" +#define BDFTOPCF_CMD "bdftopcf" + +/* default path for commands */ +#define SNFTOBDF "/usr/dt/lib/dtudcfonted/dtgpftobdf" +#ifndef FONTC +#define BDFTOPCF "/usr/bin/X11/bdftopcf" +#else +#define BDFTOPCF FONTC +#endif +#define PCFTOBDF SNFTOBDF + +/* suffix of font file */ +#define BDFSUFFIX ".bdf" +#define PCFSUFFIX ".pcf" + +/* font information file */ +#define DTUDCFONTS "DTUDCFONTS" + +#ifndef DTUDCFONTSLISTDIR +#define DTUDCFONTSLISTDIR "/usr/dt/config" +#endif + +/* default font path */ +#ifndef DTUDCFONTPATH +#define DTUDCFONTPATH "/usr/lib/X11/fonts/misc" +#endif + +/* defines for UDC fonts */ +#define FONTS_LIST_FILE "fonts.list" +#define UDFLIST_DEF "udflist.def" + +#define FONTSDIR "fonts.dir" diff --git a/cde/programs/dtudcfonted/include/udcopt.h b/cde/programs/dtudcfonted/include/udcopt.h new file mode 100644 index 000000000..4827eadc3 --- /dev/null +++ b/cde/programs/dtudcfonted/include/udcopt.h @@ -0,0 +1,241 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udcopt.h /main/4 1996/11/08 01:59:43 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +/*********************************************************************** + * SNF format font + **********************************************************************/ +#define BDFTOSNF_CMD "bdftosnf" +#ifndef SNFFONTC +#define BDFTOSNF "/usr/bin/X11/bdftosnf" +#else +#define BDFTOSNF SNFFONTC +#endif +#define SNFSUFFIX ".snf" + +#define FONT_FILE_PARM 0 + +#define COMM_SNF_POPEN( permission, snf_file, out_file, ep, buf, command ) { \ + snprintf( (buf), sizeof((buf)), " -i " ) ; \ + snprintf( (command), sizeof((command)), "%s %s > %s", bdftosnf, (buf), (out_file) ); \ +} +#define COMM_SNF_NEWTARGET( permission ) (permission) = 0 +#define COMM_SNF_EXECLBDFTOSNF( permission, buf, snf_file ) { \ + execl( bdftosnf, bdftosnf, "-i", 0 ); \ +} +#define COMM_SNF_GETHEADER( fip, fp ) { \ + (fip) = (FontInfoRec *)(fp); \ +} + +#define FAL_FONT_PRM 0 +#define CHK_PROTECT_KEY( protect_key_data, openfontfile,\ + fal_utyerror, fal_utyderror ) +/* case of a snf former font */ +#define FAL_GET_SNF_HEADER( buf, protect_key_data, fal_utyerror, fal_utyderror, fd, finf, openfontfile ) { \ + (finf)->pFinf = ( FontInfoPtr )(buf); \ + (finf)->isFef = TRUE ; \ + (finf)->isPcf = FALSE; \ +} + +/* falReadGpfProp() */ +#define FAL_READ_SNF_HEADER( finf, protect_key_data, fal_utyerror, fal_utyderror ) { \ + (finf)->isFef = TRUE; \ + (finf)->isPcf = FALSE; \ + (finf)->pFinf = ( FontInfoPtr )(finf)->buf ; \ +} + +#define ISOPTFONT( file ) 1 + +/*********************************************************************** + * glyph index + **********************************************************************/ +#define SHIFTMASK 0x7F7F +#define SHIFT_OFF(co) (co) +#define SHIFT_ON(co) (co) +#define DEFAULTCHAR 0x2121 +#define CONVGLYPHINDEX( code ) (code) + +#define DISPCODEPOINT( char_set, code ) (code) + +#define FAL_OPT_CONVGITOCP( codeset, code ) +#define FAL_OPT_CONVCPTOGI( codeset, code ) + +/*********************************************************************** + * options for commands + **********************************************************************/ +#define NORMAL 0 +#define SYSTM 1 + +#define CDSET1 (1<<2) + +/* UDC code area */ +#define IN_CODE( cc, co ) (( cc ) ? 1 : 1 ) + +/* libfuty */ +#define COMM_SBOPT_CHECKSBOPT( com, code_area ) + +#define COMM_SBOPT_STRCMP( argv, cnt ) (((argv)[(cnt)] ? 0 : 0 )) +#define COMM_SBOPT_SETSBOPT( codearea ) + +#define COMM_TYPE_STRCMP( argv, cnt ) ( ((argv)[(cnt)] ? 0 : 0 )) +#define COMM_TYPE_SETTYPE( argc, argv, cnt, type ) + +/*********************************************************************** + * options for commands + **********************************************************************/ +#define COMM_SETDEFAULTSTYLE( style ) (style) = (char *)NULL + +#define COMM_SETSTYLE_TO_FONTDATA( style, key, mask ) { \ + if( style ) { \ + char stylebuf[ BUFSIZE ] ; \ + snprintf( stylebuf, sizeof(stylebuf), "%s", style ) ; \ + key.style.name = stylebuf ; \ + mask |= FAL_FONT_MASK_STYLE_NAME ; \ + } \ +} +#define COMM_ISDEFAULTCHAR( code ) 0 + +#define get_charset_registry(head, p) +#define put_default_chars(head, nchar, rtn) {\ + if ( !(nchar) ) \ + {\ + (nchar)++;\ + fprintf( (head)->output, "CHARS %d\n", (nchar) );\ + if ( ( (rtn) = putDefaultChars( (head) ) ) != 0 ) {\ + return (rtn);\ + }\ + } else {\ + fprintf( (head)->output, "CHARS %d\n", (nchar) );\ + }\ +} +#define put_default_encode( head ) {\ + fprintf((head)->output, "STARTCHAR %04x\n", DEFAULTCHAR );\ + fprintf((head)->output, "ENCODING %d\n", DEFAULTCHAR );\ +} +#define put_default_bitmap(head, bytew, posbit, i, j, ptnbuf, ptnbuf2, tmp) { \ + for ((i) = 0; (i) < (bytew); (i)++) \ + *((ptnbuf) + (i)) = (unsigned char)0x00;\ + for ((j) = 0; (j) < (head)->bdf_height; (j)++) {\ + for ((i) = 0; (i) < (bytew); (i)++) \ + fprintf((head)->output, "%.2x", *((ptnbuf) + (i)));\ + fprintf((head)->output, "\n");\ + }\ +} +#define COMM_SBFNT_ISSBFNT( p ) 0 +#define COMM_SBFNT_CONVCODETOGI( char_set, head ) +#define COMM_SBFNT_SETUDCAREA( com, head, char_set, code_area, num_gr, gr ) { \ + (head).code_category = ALL_CODE ; \ + (head).start_code = (gr)[0].start ; \ + (head).end_code = (gr)[(num_gr)-1].end ; \ +} +#define COMM_SET_CODESET( codeset, code_area ) +#define COMM_SET_CODECATEGORY( char_set, code_area, head ) + +/* + * help message + */ +#define COMM_HELP_MSG { \ + USAGE(" [-codeset number] [-help]\n"); \ + USAGE("\n"); \ +} +#define COMM_DSP_LETTER_T +#define COMM_DSP_PRM +#define COMM_HELP_MSG_STYLE USAGE("style (The default value is mincho style.)\n") + +/*********************************************************************** + * Options for libfal + **********************************************************************/ +#define COMM_SBCHR_SETFONTDATA( data, mask ) +#define COMM_SBCHR_STRDUP_P( data, odata ) + +#define FAL_DB_OPTION static FalFontDB *fal_db_opt +#define CHK_KEY_STR_OPTION( mask, key, flg ) +#define FAL_FREE_FONTLIST_OPTION( list ) +#define FAL_CLEAR_DATA_OPTION( tmp ) +#define SET_STRUCT_OPTION( dup_p, elm, tmp_data, fal_utyerror, fal_db_group ) +#define FAL_EQ_DATA_OPTION( flg, data, tmp_data ) +#define FAL_CMP_DATA_OPTION( mask, op1, key ) +#define DEF_STR_CHK struct { int style, shape; }str_chk +#define DEF_STR_SET { \ + str_chk.style = 0; \ + str_chk.shape = 0; \ +} + +#define NEW_TARGET_SET( diff, choose, target, str_chk ) +#define NEW_TARGET_CHK( diff, choose, target, str_chk ) + + +/*********************************************************************** + * udflist.def + **********************************************************************/ +#define COMM_GET_DEFAULTFILE_ERROR( buf, com, ret, height, style, list_d, list_c, list_l, statbuf ) {\ + buf[0] = '\0' ;\ +} +#define COMM_DISPERRORFILE( com, lst, style, i, size_str ) {\ + USAGE1("%s : Two or more corresponding user defined characters exist.\n", com);\ + USAGE("\tcode set\tXLFD\n" );\ + USAGE("\t--------------------------------------------------\n" );\ + for ( i = 0 ; i < lst->num; i++ ) {\ + USAGE2("\t%d\t%s\n", lst->list[i].cd_set-1, lst->list[i].xlfdname );\ + }\ +} + +/*********************************************************************** + * fonts.list + **********************************************************************/ +#define GETLISTFILEPATH( locale, srch_path, list_d, list_c, list_l, list_file ) { \ + if ( ( (locale) = getenv( "FAL_LANG" ) ) == NULL ) { \ + if( ((locale) = (char *)getenv( "LANG" )) == NULL ){\ + (locale) = "C" ;\ + }\ + } \ + if ( ( (srch_path) = getenv( DTUDCFONTS ) ) == NULL ) { \ + snprintf( (list_d), sizeof(list_d), "%s/%s", DTUDCFONTSLISTDIR, (list_file) ); \ + snprintf( (list_c), sizeof(list_c), "%s/C/%s", DTUDCFONTSLISTDIR, (list_file) ); \ + snprintf( (list_l), sizeof(list_l), "%s/%s/%s", DTUDCFONTSLISTDIR, (locale), (list_file) ); \ + } else { \ + snprintf( (list_d), sizeof(list_d), "%s/%s", (srch_path), (list_file) ); \ + snprintf( (list_c), sizeof(list_c), "%s/C/%s", (srch_path), (list_file) ); \ + snprintf( (list_l), sizeof(list_l), "%s/%s/%s", (srch_path), (locale), (list_file) ); \ + } \ +} + +#define SET_EXECDEFAULT( mask, def, undef ) { \ + if( !((mask) & FAL_FONT_MASK_DEFINED) && !((mask) & FAL_FONT_MASK_UNDEFINED) ){ \ + (def) = FALSE ; \ + (undef) = TRUE ; \ + }else{ \ + if( (mask) & FAL_FONT_MASK_DEFINED ) (def) = TRUE ; \ + else (def) = FALSE ; \ + if( (mask) & FAL_FONT_MASK_UNDEFINED ) (undef) = TRUE ; \ + else (undef) = FALSE ; \ + } \ +} + +/*************************< end of udcopt.h >**************************/ diff --git a/cde/programs/dtudcfonted/include/udcutil.h b/cde/programs/dtudcfonted/include/udcutil.h new file mode 100644 index 000000000..d9cb9df29 --- /dev/null +++ b/cde/programs/dtudcfonted/include/udcutil.h @@ -0,0 +1,147 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: udcutil.h /main/3 1996/11/08 01:58:55 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#ifndef PRINT_USAGE +#define USAGE(a) +#define USAGE1(a, b) +#define USAGE2(a, b, c) +#define USAGE3(a, b, c, d) +#define USAGE4(a, b, c, d, e) +#else +#define USAGE(a) fprintf(stderr, a) +#define USAGE1(a, b) fprintf(stderr, a, b) +#define USAGE2(a, b, c) fprintf(stderr, a, b, c) +#define USAGE3(a, b, c, d) fprintf(stderr, a, b, c, d) +#define USAGE4(a, b, c, d, e) fprintf(stderr, a, b, c, d, e) +#endif + +#define UDC_LINE_MAX 2048 + +/* macro for get character strings */ + +#define AllocString( str, orgstr, rtn ){ \ + (str) = (char *)malloc( sizeof(char) * (strlen((orgstr))+1) ) ;\ + if( !(str) ){\ + return( (rtn) ) ;\ + }\ + strcpy( (str), (orgstr) ) ;\ +} + +#define AddString( str, addstr, rtn ){ \ + (str) = (char *)realloc( (str), sizeof(char) * ( strlen((str)) + strlen((addstr)) + 1 ) ) ;\ + if( !(str) ){\ + return( (rtn) ) ;\ + }\ + strcat( (str), (addstr) ) ;\ +} + +#define ResizeString( str, rtn ){ \ + (str) = (char *)realloc( (str), sizeof(char) * ( strlen((str)) + 1 ) ) ;\ + if( !(str) ){\ + return( (rtn) ) ;\ + }\ +} + +#define FreeString( str ){ \ + if( (str) ) {\ + free( (str) ) ;\ + }\ + (str) = NULL ;\ +} + +/* access to "fonts.dir" */ + +#define XLFD_ELM_CNT 14 + +#define XLFD_ELM_FOUNDRY 1 +#define XLFD_ELM_FAMILY_NAME 2 +#define XLFD_ELM_WEIGHT_NAME 3 +#define XLFD_ELM_SLANT 4 +#define XLFD_ELM_SETWIDTH_NAME 5 +#define XLFD_ELM_ADD_STYLE_NAME 6 +#define XLFD_ELM_PIXEL_SIZE 7 +#define XLFD_ELM_POINT_SIZE 8 +#define XLFD_ELM_RESOLUTION_X 9 +#define XLFD_ELM_RESOLUTION_Y 10 +#define XLFD_ELM_SPACING 11 +#define XLFD_ELM_AVERAGE_WIDTH 12 +#define XLFD_ELM_CHARSET_REGISTRY 13 +#define XLFD_ELM_CHARSET_ENCODING 14 + + +static int udc_font_elm_cnt ; +static char udc_font_str_buffer[UDC_LINE_MAX] ; +static char *udc_font_sp ; + +#define POINTXLFDELM( sp, xlfdname, elm_num ) { \ + udc_font_sp = (xlfdname) ; \ + udc_font_elm_cnt = 0 ;\ + while(*udc_font_sp){\ + if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\ + if( udc_font_elm_cnt == (elm_num) ){\ + break ;\ + }\ + udc_font_sp++ ;\ + }\ + (sp) = udc_font_sp ;\ +} + +#define GETXLFDELMSTR( sp, xlfdname, elm_num ) { \ + snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \ + udc_font_sp = udc_font_str_buffer ; \ + udc_font_elm_cnt = 0 ;\ + while(*udc_font_sp){\ + if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\ + if( udc_font_elm_cnt == (elm_num) ){\ + udc_font_sp++ ;\ + break ;\ + }\ + udc_font_sp++ ;\ + }\ + (sp) = udc_font_sp ;\ + while(*udc_font_sp){\ + if(*udc_font_sp == '-') udc_font_elm_cnt++ ;\ + if( udc_font_elm_cnt == (elm_num)+1 ){\ + *udc_font_sp = '\0' ;\ + break ;\ + }\ + udc_font_sp++ ;\ + }\ +} + +#define GETCHARSETSTR( char_set, xlfdname ) { \ + snprintf( udc_font_str_buffer, sizeof(udc_font_str_buffer), "%s", (xlfdname) ) ; \ + POINTXLFDELM( (char_set), udc_font_str_buffer, XLFD_ELM_CHARSET_REGISTRY ) ; \ + (char_set)++ ; \ +} + +#define GETSPACINGSTR( spacing, xlfdname ) { \ + GETXLFDELMSTR( (spacing), (xlfdname), XLFD_ELM_SPACING ) ; \ +} diff --git a/cde/programs/dtudcfonted/libfal/Imakefile b/cde/programs/dtudcfonted/libfal/Imakefile new file mode 100644 index 000000000..c8bdcfb41 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/Imakefile @@ -0,0 +1,84 @@ +XCOMM $XConsortium: Imakefile /main/16 1996/09/09 11:45:13 drk $ +#define DoNormalLib YES +#define DoSharedLib NO +#define DoDebugLib NO +#define DoProfileLib NO +#define LibName fal +#define LibHeaders NO +#define LibInstall NO + + FALDESTDIR = $(CDE_INSTALLATION_TOP) + FONTLIST = config + XLOCALEDIR = $(XPROJECTROOT)/lib/X11/locale + XFONTDIR = $(XPROJECTROOT)/lib/X11/fonts + +UDCFONTPATH = $(XFONTDIR)/misc +FALOPT1 = -DDTUDCFONTPATH='"'$(XFONTDIR)/misc'"' +FALOPT2 = -DXLOCALEDIR='"'$(XLOCALEDIR)'"' +FALOPT3 = -DDTUDCFONTSLISTDIR='"'$(FALDESTDIR)/$(FONTLIST)'"' + +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + + DEPEND_DEFINES = $(DEPENDDEFINES) + DEFINES = $(FALOPT1) $(FALOPT2) $(OPT2) $(FALOPT3) + + UDC_INC_PATH1 = -I./include + UDC_INC_PATH2 = -I../include + UDC_INC_PATH3 = -I./ + + INCLUDES = \ + $(UDC_INC_PATH1)\ + $(UDC_INC_PATH2)\ + $(UDC_INC_PATH3) + +SRCS1 = falfont.c readpcf.c \ + syncx.c + +SRCS2 = _faludcInf.c \ + _fallcCT.c _fallcCharSet.c _fallcConv.c _fallcDB.c \ + _fallcDefConv.c _fallcDynamic.c _fallcEuc.c _fallcFile.c \ + _fallcGenConv.c _fallcGeneric.c _fallcInit.c _fallcPrTxt.c \ + _fallcPubWrap.c _fallcPublic.c _fallcRM.c _fallcSjis.c \ + _fallcStd.c _fallcTxtPr.c _fallcUTF.c _fallcUtil.c \ + _fallcWrap.c \ + _falomGeneric.c _falQuarks.c _falSetLocale.c _falrm.c + +SRCS3 = _falutilbitmap.c + +SRCS = $(SRCS1) $(SRCS2) $(SRCS3) + +OBJS = falfont.o readpcf.o \ + syncx.o \ + _faludcInf.o \ + _fallcCT.o _fallcCharSet.o _fallcConv.o _fallcDB.o \ + _fallcDefConv.o _fallcDynamic.o _fallcEuc.o _fallcFile.o \ + _fallcGenConv.o _fallcGeneric.o _fallcInit.o _fallcPrTxt.o \ + _fallcPubWrap.o _fallcPublic.o _fallcRM.o _fallcSjis.o \ + _fallcStd.o _fallcTxtPr.o _fallcUTF.o _fallcUtil.o \ + _fallcWrap.o _falomGeneric.o _falQuarks.o _falSetLocale.o \ + _falrm.o \ + _falutilbitmap.o + +all:: + $(RM) fonts.list;\ + $(CP) ./fonts.list.header ./fonts.list ;\ + chmod ug+w fonts.list;\ + key=`echo $(UDCFONTPATH) | sed -e 's/:/ /g'` ; \ + for dir in $$key ; \ + do \ + echo $$dir: >> ./fonts.list ;\ + done + +#include <Library.tmpl> + +install:: + if [ -d $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST) ]; then set +x; \ + else (set -x; $(MKDIRHIER) $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST)); fi ; \ + (set -x ; $(CP) ./fonts.list $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST) ; \ + chmod 0644 $(DESTDIR)/$(FALDESTDIR)/$(FONTLIST)/fonts.list ) + +DependTarget() diff --git a/cde/programs/dtudcfonted/libfal/_falQuarks.c b/cde/programs/dtudcfonted/libfal/_falQuarks.c new file mode 100644 index 000000000..97ebf9f46 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falQuarks.c @@ -0,0 +1,445 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Quarks.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:31:17 */ +/* $XConsortium: _falQuarks.c /main/2 1996/09/09 13:20:21 rswiston $ */ + +/*********************************************************** +Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard, + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* + +Copyright (c) 1987, 1988, 1990 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +#include "_fallibint.h" +#include <X11/Xresource.h> + +/* Not cost effective, at least for vanilla MIT clients */ +/* #define PERMQ */ + +typedef unsigned long Signature; +typedef unsigned long Entry; +#ifdef PERMQ +typedef unsigned char Bits; +#endif + +static XrmQuark nextQuark = 1; /* next available quark number */ +static unsigned long quarkMask = 0; +static Entry zero = 0; +static Entry *quarkTable = &zero; /* crock */ +static unsigned long quarkRehash; +static XrmString **stringTable = NULL; +#ifdef PERMQ +static Bits **permTable = NULL; +#endif +static XrmQuark nextUniq = -1; /* next quark from falrmUniqueQuark */ + +#define QUANTUMSHIFT 8 +#define QUANTUMMASK ((1 << QUANTUMSHIFT) - 1) +#define CHUNKPER 8 +#define CHUNKMASK ((CHUNKPER << QUANTUMSHIFT) - 1) + +#define LARGEQUARK ((Entry)0x80000000L) +#define QUARKSHIFT 18 +#define QUARKMASK ((LARGEQUARK - 1) >> QUARKSHIFT) +#define XSIGMASK ((1L << QUARKSHIFT) - 1) + +#define STRQUANTSIZE (sizeof(XrmString) * (QUANTUMMASK + 1)) +#ifdef PERMQ +#define QUANTSIZE (STRQUANTSIZE + \ + (sizeof(Bits) * ((QUANTUMMASK + 1) >> 3)) +#else +#define QUANTSIZE STRQUANTSIZE +#endif + +#define HASH(sig) ((sig) & quarkMask) +#define REHASHVAL(sig) ((((sig) % quarkRehash) + 2) | 1) +#define REHASH(idx,rehash) ((idx + rehash) & quarkMask) +#define NAME(q) stringTable[(q) >> QUANTUMSHIFT][(q) & QUANTUMMASK] +#ifdef PERMQ +#define BYTEREF(q) permTable[(q) >> QUANTUMSHIFT][((q) & QUANTUMMASK) >> 3] +#define ISPERM(q) (BYTEREF(q) & (1 << ((q) & 7))) +#define SETPERM(q) BYTEREF(q) |= (1 << ((q) & 7)) +#define CLEARPERM(q) BYTEREF(q) &= ~(1 << ((q) & 7)) +#endif + +/* Permanent memory allocation */ + +#define WALIGN sizeof(unsigned long) +#define DALIGN sizeof(double) + +#define NEVERFREETABLESIZE ((8192-12) & ~(DALIGN-1)) +static char *neverFreeTable = NULL; +static int neverFreeTableSize = 0; + +static char *permalloc(unsigned int length) +{ + char *ret; + + if (neverFreeTableSize < length) { + if (length >= NEVERFREETABLESIZE) + return Xmalloc(length); + if (! (ret = Xmalloc(NEVERFREETABLESIZE))) + return (char *) NULL; + neverFreeTableSize = NEVERFREETABLESIZE; + neverFreeTable = ret; + } + ret = neverFreeTable; + neverFreeTable += length; + neverFreeTableSize -= length; + return(ret); +} + +typedef struct {char a; double b;} TestType1; +typedef struct {char a; unsigned long b;} TestType2; + +#ifdef XTHREADS +static char *_falpermalloc(); + +char *falpermalloc(unsigned int length) +{ + char *p; + + _XLockMutex(_Xglobal_lock); + p = _falpermalloc(length); + _XUnlockMutex(_Xglobal_lock); + return p; +} +#define falpermalloc _falpermalloc + +static +#endif /* XTHREADS */ +char *falpermalloc(unsigned int length) +{ + int i; + + if (neverFreeTableSize && length < NEVERFREETABLESIZE) { + if ((sizeof(TestType1) != + (sizeof(TestType2) - sizeof(unsigned long) + sizeof(double))) && + !(length & (DALIGN-1)) && + (i = (NEVERFREETABLESIZE - neverFreeTableSize) & (DALIGN-1))) { + neverFreeTableSize -= DALIGN - i; + neverFreeTable += DALIGN - i; + } else + if (i = (NEVERFREETABLESIZE - neverFreeTableSize) & (WALIGN-1)) { + neverFreeTableSize -= WALIGN - i; + neverFreeTable += WALIGN - i; + } + } + return permalloc(length); +} + +static Bool +ExpandQuarkTable(void) +{ + unsigned long oldmask, newmask; + char c, *s; + Entry *oldentries, *entries; + Entry entry; + int oldidx, newidx, rehash; + Signature sig; + XrmQuark q; + + oldentries = quarkTable; + if (oldmask = quarkMask) + newmask = (oldmask << 1) + 1; + else { + if (!stringTable) { + stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) * + CHUNKPER); + if (!stringTable) + return False; + stringTable[0] = (XrmString *)NULL; + } +#ifdef PERMQ + if (!permTable) + permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER); + if (!permTable) + return False; +#endif + stringTable[0] = (XrmString *)falpermalloc(QUANTSIZE); + if (!stringTable[0]) + return False; +#ifdef PERMQ + permTable[0] = (Bits *)((char *)stringTable[0] + STRQUANTSIZE); +#endif + newmask = 0x1ff; + } + entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1)); + if (!entries) + return False; + bzero((char *)entries, sizeof(Entry) * (newmask + 1)); + quarkTable = entries; + quarkMask = newmask; + quarkRehash = quarkMask - 2; + for (oldidx = 0; oldidx <= oldmask; oldidx++) { + if (entry = oldentries[oldidx]) { + if (entry & LARGEQUARK) + q = entry & (LARGEQUARK-1); + else + q = (entry >> QUARKSHIFT) & QUARKMASK; + for (sig = 0, s = NAME(q); c = *s++; ) + sig = (sig << 1) + c; + newidx = HASH(sig); + if (entries[newidx]) { + rehash = REHASHVAL(sig); + do { + newidx = REHASH(newidx, rehash); + } while (entries[newidx]); + } + entries[newidx] = entry; + } + } + if (oldmask) + Xfree((char *)oldentries); + return True; +} + +XrmQuark _falrmInternalStringToQuark( + const char *name, int len, Signature sig, Bool permstring) +{ + XrmQuark q; + Entry entry; + int idx; + int rehash = 0; + int i; + char *s1, *s2; + char *new; + + idx = HASH(sig); + _XLockMutex(_Xglobal_lock); + while (entry = quarkTable[idx]) { + if (entry & LARGEQUARK) + q = entry & (LARGEQUARK-1); + else { + if ((entry - sig) & XSIGMASK){ + if (!rehash) + rehash = REHASHVAL(sig); + idx = REHASH(idx, rehash); + continue; + } + q = (entry >> QUARKSHIFT) & QUARKMASK; + } + for (i = len, s1 = (char *)name, s2 = NAME(q); --i >= 0; ) { + if (*s1++ != *s2++){ + if (!rehash) + rehash = REHASHVAL(sig); + idx = REHASH(idx, rehash); + continue; + } + } + if (*s2) { + if (!rehash) + rehash = REHASHVAL(sig); + idx = REHASH(idx, rehash); + continue; + } +#ifdef PERMQ + if (permstring && !ISPERM(q)) { + Xfree(NAME(q)); + NAME(q) = (char *)name; + SETPERM(q); + } +#endif + _XUnlockMutex(_Xglobal_lock); + return q; + } + if (nextUniq == nextQuark){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + if ((nextQuark + (nextQuark >> 2)) > quarkMask) { + if (!ExpandQuarkTable()){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + _XUnlockMutex(_Xglobal_lock); + return _falrmInternalStringToQuark(name, len, sig, permstring); + } + q = nextQuark; + if (!(q & QUANTUMMASK)) { + if (!(q & CHUNKMASK)) { + if (!(new = Xrealloc((char *)stringTable, + sizeof(XrmString *) * + ((q >> QUANTUMSHIFT) + CHUNKPER)))){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + stringTable = (XrmString **)new; +#ifdef PERMQ + if (!(new = Xrealloc((char *)permTable, + sizeof(Bits *) * + ((q >> QUANTUMSHIFT) + CHUNKPER)))){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + permTable = (Bits **)new; +#endif + } + new = falpermalloc(QUANTSIZE); + if (!new){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + stringTable[q >> QUANTUMSHIFT] = (XrmString *)new; +#ifdef PERMQ + permTable[q >> QUANTUMSHIFT] = (Bits *)(new + STRQUANTSIZE); +#endif + } + if (!permstring) { + s2 = (char *)name; +#ifdef PERMQ + name = Xmalloc(len+1); +#else + name = permalloc(len+1); +#endif + if (!name){ + _XUnlockMutex(_Xglobal_lock); + return NULLQUARK; + } + for (i = len, s1 = (char *)name; --i >= 0; ) + *s1++ = *s2++; + *s1++ = '\0'; +#ifdef PERMQ + CLEARPERM(q); + } + else { + SETPERM(q); +#endif + } + NAME(q) = (char *)name; + if (q <= QUARKMASK) + entry = (q << QUARKSHIFT) | (sig & XSIGMASK); + else + entry = q | LARGEQUARK; + quarkTable[idx] = entry; + nextQuark++; + _XUnlockMutex(_Xglobal_lock); + return q; +} + +XrmQuark falrmStringToQuark(const char *name) +{ + char c, *tname; + Signature sig = 0; + + if (!name) + return (NULLQUARK); + + for (tname = (char *)name; c = *tname++; ) + sig = (sig << 1) + c; + + return _falrmInternalStringToQuark(name, tname-(char *)name-1, sig, False); +} + +XrmQuark falrmPermStringToQuark( + const char *name) +{ + char c, *tname; + Signature sig = 0; + + if (!name) + return (NULLQUARK); + + for (tname = (char *)name; c = *tname++; ) + sig = (sig << 1) + c; + + return _falrmInternalStringToQuark(name, tname-(char *)name-1, sig, True); +} + +XrmQuark falrmUniqueQuark(void) +{ + XrmQuark q; + + _XLockMutex(_Xglobal_lock); + if (nextUniq == nextQuark) + q = NULLQUARK; + else + q = nextUniq--; + _XUnlockMutex(_Xglobal_lock); + return q; +} + +XrmString falrmQuarkToString(XrmQuark quark) +{ + XrmString s; + + _XLockMutex(_Xglobal_lock); + if (quark <= 0 || quark >= nextQuark) + s = NULLSTRING; + else { +#ifdef PERMQ + /* We have to mark the quark as permanent, since the caller might hold + * onto the string pointer forver. + */ + SETPERM(quark); +#endif + s = NAME(quark); + } + _XUnlockMutex(_Xglobal_lock); + return s; +} diff --git a/cde/programs/dtudcfonted/libfal/_falSetLocale.c b/cde/programs/dtudcfonted/libfal/_falSetLocale.c new file mode 100644 index 000000000..958b9d08e --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falSetLocale.c @@ -0,0 +1,203 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* SetLocale.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:31:29 */ +/* $XConsortium: _falSetLocale.c /main/1 1996/04/08 15:15:08 cde-fuj $ */ + +/* + * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation, + * and Nippon Telegraph and Telephone Corporation + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of OMRON, NTT Software, and NTT + * not be used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. OMRON, NTT Software, + * and NTT make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT, BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Li Yuhong OMRON Corporation + * Tetsuya Kato NTT Software Corporation + * Hiroshi Kuribayashi OMRON Corporation + * + */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +#include "_fallibint.h" +#include "_fallcint.h" +#include <X11/Xlocale.h> +#include <X11/Xos.h> + +#ifdef X_LOCALE + +#define MAXLOCALE 64 /* buffer size of locale name */ + +char * +_falsetlocale(int category, const char *name) +{ + static char *xsl_name; + char *old_name; + XrmMethods methods; + XPointer state; + + if (category != LC_CTYPE && category != LC_ALL) + return NULL; + if (!name) { + if (xsl_name) + return xsl_name; + return "C"; + } + if (!*name) + name = getenv("LC_CTYPE"); + if (!name || !*name) + name = getenv("LANG"); + if (!name || !*name) + name = "C"; + old_name = xsl_name; + xsl_name = (char *)name; + methods = _falrmInitParseInfo(&state); + xsl_name = old_name; + if (!methods) + return NULL; + name = (*methods->lcname)(state); + xsl_name = Xmalloc(strlen(name) + 1); + if (!xsl_name) { + xsl_name = old_name; + (*methods->destroy)(state); + return NULL; + } + strcpy(xsl_name, name); + if (old_name) + Xfree(old_name); + (*methods->destroy)(state); + return xsl_name; +} + +#else /* X_LOCALE */ + +/* + * _fallcMapOSLocaleName is an implementation dependent routine that derives + * the LC_CTYPE locale name as used in the sample implementation from that + * returned by setlocale. + * Should match the code in Xt ExtractLocaleName. + */ + +char * +_fallcMapOSLocaleName(char *osname, char *siname) +{ +#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) + +#ifdef hpux +#define SKIPCOUNT 2 +#define STARTCHAR ':' +#define ENDCHAR ';' +#elif !defined(sun) || defined(SVR4) +#define STARTCHAR '/' +#define ENDCHAR '/' +#endif + + char *start; + char *end; + int len; + + start = osname; +#ifdef SKIPCOUNT + int = n; + for (n = SKIPCOUNT; + --n >= 0 && start && (start = strchr (start, STARTCHAR)); + start++) + ; + if (!start) + start = osname; +#endif +#ifdef STARTCHAR + if (start && (start = strchr (start, STARTCHAR))) { + start++; +#endif + if (end = strchr (start, ENDCHAR)) { + len = end - start; + strncpy(siname, start, len); + *(siname + len) = '\0'; +#ifdef WHITEFILL + for (start = siname; start = strchr(start, ' '); ) + *start++ = '-'; +#endif + return siname; +#ifdef STARTCHAR + } +#endif + } +#ifdef WHITEFILL + if (strchr(osname, ' ')) { + strcpy(siname, osname); + for (start = siname; start = strchr(start, ' '); ) + *start++ = '-'; + return siname; + } +#endif +#undef STARTCHAR +#undef ENDCHAR +#undef WHITEFILL +#endif + return osname; +} + +#endif /* X_LOCALE */ diff --git a/cde/programs/dtudcfonted/libfal/_fallcCT.c b/cde/programs/dtudcfonted/libfal/_fallcCT.c new file mode 100644 index 000000000..2f7c342af --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcCT.c @@ -0,0 +1,868 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcCT.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:33 */ +/* $XConsortium: _fallcCT.c /main/1 1996/04/08 15:15:33 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" +#include <X11/Xos.h> +#include <stdio.h> + +typedef struct _StateRec { + XlcCharSet charset; + XlcCharSet GL_charset; + XlcCharSet GR_charset; + XlcCharSet ext_seg_charset; + int ext_seg_left; +} StateRec, *State; + +typedef struct _CTDataRec { + char *name; + char *encoding; /* Compound Text encoding */ +} CTDataRec, *CTData; + +typedef struct _CTInfoRec { + XlcCharSet charset; + int encoding_len; + char *encoding; /* Compound Text encoding */ + int ext_segment_len; + char *ext_segment; /* extended segment */ + struct _CTInfoRec *next; +} CTInfoRec, *CTInfo; + +static CTDataRec default_ct_data[] = +{ + { "ISO8859-1:GL", "\033(B" }, + { "ISO8859-1:GR", "\033-A" }, + { "ISO8859-2:GR", "\033-B" }, + { "ISO8859-3:GR", "\033-C" }, + { "ISO8859-4:GR", "\033-D" }, + { "ISO8859-7:GR", "\033-F" }, + { "ISO8859-6:GR", "\033-G" }, + { "ISO8859-8:GR", "\033-H" }, + { "ISO8859-5:GR", "\033-L" }, + { "ISO8859-9:GR", "\033-M" }, + { "JISX0201.1976-0:GL", "\033(J" }, + { "JISX0201.1976-0:GR", "\033)I" }, + + { "GB2312.1980-0:GL", "\033$(A" }, + { "GB2312.1980-0:GR", "\033$)A" }, + { "JISX0208.1983-0:GL", "\033$(B" }, + { "JISX0208.1983-0:GR", "\033$)B" }, + { "KSC5601.1987-0:GL", "\033$(C" }, + { "KSC5601.1987-0:GR", "\033$)C" }, +} ; + +#define XctC0 0x0000 +#define XctHT 0x0009 +#define XctNL 0x000a +#define XctESC 0x001b +#define XctGL 0x0020 +#define XctC1 0x0080 +#define XctCSI 0x009b +#define XctGR 0x00a0 + +#define XctCntrlFunc 0x0023 +#define XctMB 0x0024 +#define XctOtherCoding 0x0025 +#define XctGL94 0x0028 +#define XctGR94 0x0029 +#define XctGR96 0x002d +#define XctNonStandard 0x002f +#define XctIgnoreExt 0x0030 +#define XctNotIgnoreExt 0x0031 +#define XctLeftToRight 0x0031 +#define XctRightToLeft 0x0032 +#define XctDirection 0x005d +#define XctDirectionEnd 0x005d + +#define XctGL94MB 0x2428 +#define XctGR94MB 0x2429 +#define XctExtSeg 0x252f +#define XctOtherSeg 0x2f00 + +#define XctESCSeq 0x1b00 +#define XctCSISeq 0x9b00 + +#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++; +#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++; + +typedef struct { + XlcSide side; + int char_size; + int set_size; + int ext_seg_length; + int version; + CTInfo ct_info; +} CTParseRec, *CTParse; + +static CTInfo ct_list = NULL; + +static CTInfo +_XlcGetCTInfoFromEncoding(char *encoding, int length) +{ + CTInfo ct_info; + + for (ct_info = ct_list; ct_info; ct_info = ct_info->next) { + if (length >= ct_info->encoding_len) { + if (ct_info->ext_segment) { + if (!strncmp(ct_info->encoding, encoding, 4) && + !strncmp(ct_info->ext_segment, encoding + 6, + ct_info->ext_segment_len)) + return ct_info; + } else if (!strncmp(ct_info->encoding, encoding, + ct_info->encoding_len)) { + return ct_info; + } + } + } + + return (CTInfo) NULL; +} + +static unsigned int +_XlcParseCT(CTParse parse, char **text, int *length) +{ + unsigned int ret = 0; + unsigned char ch; + unsigned char *str = (unsigned char *) *text; + + bzero((char *) parse, sizeof(CTParseRec)); + + switch (ch = *str++) { + case XctESC: + if (*str == XctOtherCoding && *(str + 1) == XctNonStandard + && *(str + 2) >= 0x30 && *(str + 2) <= 0x3f && *length >= 6) { + + /* non-standard encodings */ + parse->side = XlcGLGR; + parse->set_size = 0; + str += 2; + if (*str <= 0x34) { + parse->char_size = *str - 0x30; + if (parse->char_size == 0) parse->char_size = 1; + ret = XctExtSeg; + parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length); + } else + ret = XctOtherSeg; + str++; + parse->ext_seg_length = (*str - 128) * 128 + *(str + 1) - 128; + str += 2; + + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } else if (*str == XctCntrlFunc && *length >= 4 && + *(str + 1) >= 0x20 && *(str + 1) <= 0x2f && + (*(str + 2) == XctIgnoreExt || + *(str + 2) == XctNotIgnoreExt)) { + + /* ignore extension or not */ + str++; + parse->version = *str++ - 0x20; + ret = *str++; + + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } + + if (*str == XctMB) { /* multiple-byte sets */ + parse->char_size = 2; + str++; + } else + parse->char_size = 1; + + switch (*str) { + case XctGL94: + parse->side = XlcGL; + parse->set_size = 94; + ret = (parse->char_size == 1) ? XctGL94 : XctGL94MB; + break; + case XctGR94: + parse->side = XlcGR; + parse->set_size = 94; + ret = (parse->char_size == 1) ? XctGR94 : XctGR94MB; + break; + case XctGR96: + if (parse->char_size == 1) { + parse->side = XlcGR; + parse->set_size = 96; + ret = XctGR96; + } + break; + } + if (ret) { + str++; + if (*str >= 0x24 && *str <= 0x2f) { /* non-standard */ + ret = 0; + str++; + } + } + + SKIP_I(str) + + if (ret && *str < 0x40) /* non-standard */ + ret = 0; + + if (*str < 0x30 || *str > 0x7e || (char *) str - *text >= *length) + break; + + if (ret == 0) + ret = XctESCSeq; + else { + if (parse->char_size == 2) { + if (*str >= 0x70) + parse->char_size = 4; + else if (*str >= 0x60) + parse->char_size = 3; + } + parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length); + } + str++; + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + case XctCSI: + /* direction */ + if (*str == XctLeftToRight && *(str + 1) == XctDirection) { + ret = XctLeftToRight; + str += 2; + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } else if (*str == XctRightToLeft && *(str + 1) == XctDirection) { + ret = XctRightToLeft; + str += 2; + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } else if (*str == XctDirectionEnd) { + ret = XctDirectionEnd; + str++; + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } + + SKIP_P(str) + SKIP_I(str) + + if (*str < 0x40 && *str > 0x7e) + break; + + ret = XctCSISeq; + str++; + *length -= (char *) str - *text; + *text = (char *) str; + return ret; + } + + if (ch & 0x80) { + if (ch < 0xa0) + ret = XctC1; + else + ret = XctGR; + } else { + if (ch == XctHT || ch == XctNL) + ret = ch; + else if (ch < 0x20) + ret = XctC0; + else + ret = XctGL; + } + + return ret; +} + +XlcCharSet +_fallcAddCT(char *name, char *encoding) +{ + CTInfo ct_info; + XlcCharSet charset; + CTParseRec parse; + char *ct_ptr = encoding; + int length; + unsigned int type; + + length = strlen(encoding); + + switch (type = _XlcParseCT(&parse, &ct_ptr, &length)) { + case XctExtSeg: + case XctGL94: + case XctGL94MB: + case XctGR94: + case XctGR94MB: + case XctGR96: + if (parse.ct_info) /* existed */ + return parse.ct_info->charset; + break; + default: + return (XlcCharSet) NULL; + } + + charset = _fallcCreateDefaultCharSet(name, encoding); + if (charset == NULL) + return (XlcCharSet) NULL; + _fallcAddCharSet(charset); + + ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec)); + if (ct_info == NULL) + return (XlcCharSet) NULL; + + ct_info->charset = charset; + ct_info->encoding = charset->ct_sequence; + ct_info->encoding_len = strlen(ct_info->encoding); + if (type == XctExtSeg) { + ct_info->ext_segment = ct_info->encoding + 6; + ct_info->ext_segment_len = strlen(ct_info->ext_segment); + } else { + ct_info->ext_segment = NULL; + ct_info->ext_segment_len = 0; + } + ct_info->next = ct_list; + ct_list = ct_info; + + return charset; +} + +static CTInfo +_XlcGetCTInfoFromCharSet(XlcCharSet charset) +{ + CTInfo ct_info; + + for (ct_info = ct_list; ct_info; ct_info = ct_info->next) + if (ct_info->charset == charset) + return ct_info; + + return (CTInfo) NULL; +} + +Bool +_fallcParseCharSet(XlcCharSet charset) +{ + CTParseRec parse; + char *ptr, buf[BUFSIZ]; + unsigned int type; + int length; + + if (charset->ct_sequence == NULL) + return False; + + ptr = charset->ct_sequence; + length = strlen(ptr); + + type = _XlcParseCT(&parse, &ptr, &length); + + if (charset->name) { + charset->xrm_name = falrmStringToQuark(charset->name); + + snprintf(buf, sizeof(buf), "%s", charset->name); + if (ptr = strchr(buf, ':')) + *ptr = '\0'; + charset->xrm_encoding_name = falrmStringToQuark(buf); + charset->encoding_name = falrmQuarkToString(charset->xrm_encoding_name); + } else { + charset->xrm_name = 0; + charset->encoding_name = NULL; + charset->xrm_encoding_name = 0; + } + + charset->side = parse.side; + charset->char_size = parse.char_size; + charset->set_size = parse.set_size; + + return True; +} + +static void init_converter(); + +Bool +_fallcInitCTInfo(void) +{ + XlcCharSet charset; + CTData ct_data; + int num; + + if (ct_list == NULL) { + num = sizeof(default_ct_data) / sizeof(CTDataRec); + for (ct_data = default_ct_data; num-- > 0; ct_data++) { + charset = _fallcAddCT(ct_data->name, ct_data->encoding); + if (charset == NULL) + continue; + } + init_converter(); + } + + return True; +} + + +static int +_XlcCheckCTSequence(State state, char **ctext, int *ctext_len) +{ + XlcCharSet charset; + CTParseRec parse; + CTInfo ct_info; + int length; + + _XlcParseCT(&parse, ctext, ctext_len); + + ct_info = parse.ct_info; + if (parse.ext_seg_length > 0) { /* XctExtSeg or XctOtherSeg */ + if (ct_info) { + length = ct_info->ext_segment_len; + *ctext += length; + *ctext_len -= length; + state->ext_seg_left = parse.ext_seg_length - length; + state->ext_seg_charset = ct_info->charset; + } else { + state->ext_seg_left = parse.ext_seg_length; + state->ext_seg_charset = NULL; + } + } else if (ct_info) { + if (charset = ct_info->charset) { + if (charset->side == XlcGL) + state->GL_charset = charset; + else if (charset->side == XlcGR) + state->GR_charset = charset; + } + } + + return 0; +} + + +static void +init_state(XlcConv conv) +{ + State state = (State) conv->state; + static XlcCharSet GL_charset = NULL; + static XlcCharSet GR_charset = NULL; + + if (GL_charset == NULL) { + GL_charset = _fallcGetCharSet("ISO8859-1:GL"); + GR_charset = _fallcGetCharSet("ISO8859-1:GR"); + } + + state->GL_charset = state->charset = GL_charset; + state->GR_charset = GR_charset; + state->ext_seg_charset = NULL; + state->ext_seg_left = 0; +} + +static int +cttocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + unsigned char ch; + int length; + XlcCharSet charset = NULL; + char *ctptr, *bufptr; + int ctext_len, buf_len; + + ctptr = *((char **) from); + bufptr = *((char **) to); + ctext_len = *from_left; + buf_len = *to_left; + + while (ctext_len > 0 && buf_len > 0) { + if (state->ext_seg_left > 0) { + length = min(state->ext_seg_left, ctext_len); + length = min(length, buf_len); + + ctext_len -= length; + state->ext_seg_left -= length; + + if (state->ext_seg_charset) { + charset = state->ext_seg_charset; + buf_len -= length; + if (charset->side == XlcGL) { + while (length-- > 0) + *bufptr++ = *ctptr++ & 0x7f; + } else if (charset->side == XlcGR) { + while (length-- > 0) + *bufptr++ = *ctptr++ | 0x80; + } else { + while (length-- > 0) + *bufptr++ = *ctptr++; + } + + if (state->ext_seg_left < 1) + state->ext_seg_charset = NULL; + } + break; + } + ch = *((unsigned char *) ctptr); + if (ch == 0x1b || ch == 0x9b) { + length = _XlcCheckCTSequence(state, &ctptr, &ctext_len); + if (length < 0) + return -1; + if (state->ext_seg_left > 0 && charset) + break; + } else { + if (charset) { + if (charset != (ch & 0x80 ? state->GR_charset : + state->GL_charset)) + break; + } else + charset = ch & 0x80 ? state->GR_charset : state->GL_charset; + + if ((ch < 0x20 && ch != '\0' && ch != '\n' && ch != '\t') || + (ch >= 0x80 && ch < 0xa0)) + return -1; + + *bufptr++ = *ctptr++; + ctext_len--; + buf_len--; + } + } + + if (charset) + state->charset = charset; + if (num_args > 0) + *((XlcCharSet *) args[0]) = state->charset; + + *from_left -= ctptr - *((char **) from); + *from = (XPointer) ctptr; + + *to_left -= bufptr - *((char **) to); + *to = (XPointer) bufptr; + + return 0; +} + +static int +cstoct( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XlcSide side; + unsigned char min_ch, max_ch, ch; + int length; + CTInfo ct_info; + XlcCharSet charset; + char *csptr, *ctptr; + int csstr_len, ct_len; + + if (num_args < 1) + return -1; + + csptr = *((char **) from); + ctptr = *((char **) to); + csstr_len = *from_left; + ct_len = *to_left; + + charset = (XlcCharSet) args[0]; + + ct_info = _XlcGetCTInfoFromCharSet(charset); + if (ct_info == NULL) + return -1; + + side = charset->side; + + if (ct_info->ext_segment) { + if (charset != state->ext_seg_charset && state->ext_seg_left < 1) { + length = ct_info->encoding_len; + if (ct_len < length) + return -1; + strcpy(ctptr, ct_info->encoding); + ctptr[4] = ((ct_info->ext_segment_len + csstr_len) / 128) | 0x80; + ctptr[5] = ((ct_info->ext_segment_len + csstr_len) % 128) | 0x80; + ctptr += length; + ct_len -= length; + state->ext_seg_left = csstr_len; + } + length = min(state->ext_seg_left, csstr_len); + state->ext_seg_left -= length; + + if (side == XlcGL) { + while (length-- > 0) + *ctptr++ = *csptr++ & 0x7f; + } else if (side == XlcGR) { + while (length-- > 0) + *ctptr++ = *csptr++ | 0x80; + } else { + while (length-- > 0) + *ctptr++ = *csptr++; + } + state->ext_seg_charset = (state->ext_seg_left > 0) ? charset : NULL; + } else { + if ((side == XlcGR && charset != state->GR_charset) || + (side == XlcGL && charset != state->GL_charset)) { + + ct_len -= ct_info->encoding_len; + if (ct_len < 0) + return -1; + strcpy(ctptr, ct_info->encoding); + ctptr += ct_info->encoding_len; + } + + min_ch = 0x20; + max_ch = 0x7f; + + if (charset->set_size == 94) { + max_ch--; + if (charset->char_size > 1 || side == XlcGR) + min_ch++; + } + + while (csstr_len > 0 && ct_len > 0) { + ch = *((unsigned char *) csptr++) & 0x7f; + if (ch < min_ch || ch > max_ch) + if (ch != 0x00 && ch != 0x09 && ch != 0x0a && ch != 0x1b) + continue; /* XXX */ + if (side == XlcGL) + *ctptr++ = ch & 0x7f; + else if (side == XlcGR) + *ctptr++ = ch | 0x80; + else + *ctptr++ = ch; + csstr_len--; + ct_len--; + } + if (side == XlcGR) + state->GR_charset = charset; + else if (side == XlcGL) + state->GL_charset = charset; + } + + *from_left -= csptr - *((char **) from); + *from = (XPointer) csptr; + + *to_left -= ctptr - *((char **) to); + *to = (XPointer) ctptr; + + return 0; +} + +static int +strtocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + char *src, *dst; + unsigned char side; + int length; + + src = (char *) *from; + dst = (char *) *to; + + length = min(*from_left, *to_left); + side = *((unsigned char *) src) & 0x80; + + while (side == (*((unsigned char *) src) & 0x80) && length-- > 0) + *dst++ = *src++; + + *from_left -= src - (char *) *from; + *from = (XPointer) src; + *to_left -= dst - (char *) *to; + *to = (XPointer) dst; + + if (num_args > 0) + *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset; + + return 0; +} + +static int +cstostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + char *csptr, *string_ptr; + int csstr_len, str_len; + unsigned char ch; + int unconv_num = 0; + + if (num_args < 1 || (state->GL_charset != (XlcCharSet) args[0] && + state->GR_charset != (XlcCharSet) args[0])) + return -1; + + csptr = *((char **) from); + string_ptr = *((char **) to); + csstr_len = *from_left; + str_len = *to_left; + + while (csstr_len-- > 0 && str_len > 0) { + ch = *((unsigned char *) csptr++); + if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a) || + ch == 0x7f || ((ch & 0x80) && ch < 0xa0)) { + unconv_num++; + continue; + } + *((unsigned char *) string_ptr++) = ch; + str_len--; + } + + *from_left -= csptr - *((char **) from); + *from = (XPointer) csptr; + + *to_left -= string_ptr - *((char **) to); + *to = (XPointer) string_ptr; + + return unconv_num; +} + + +static void +close_converter(XlcConv conv) +{ + if (conv->state) + Xfree((char *) conv->state); + + Xfree((char *) conv); +} + +static XlcConv +create_conv(XlcConvMethods methods) +{ + XlcConv conv; + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == NULL) + return (XlcConv) NULL; + + conv->state = (XPointer) Xmalloc(sizeof(StateRec)); + if (conv->state == NULL) { + close_converter(conv); + return (XlcConv) NULL; + } + + conv->methods = methods; + + init_state(conv); + + return conv; +} + +static XlcConvMethodsRec cttocs_methods = { + close_converter, + cttocs, + init_state +} ; + +static XlcConv +open_cttocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(&cttocs_methods); +} + +static XlcConvMethodsRec cstoct_methods = { + close_converter, + cstoct, + init_state +} ; + +static XlcConv +open_cstoct(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(&cstoct_methods); +} + +static XlcConvMethodsRec strtocs_methods = { + close_converter, + strtocs, + init_state +} ; + +static XlcConv +open_strtocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(&strtocs_methods); +} + +static XlcConvMethodsRec cstostr_methods = { + close_converter, + cstostr, + init_state +} ; + +static XlcConv +open_cstostr(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(&cstostr_methods); +} + +static void +init_converter(void) +{ + _fallcSetConverter((XLCd) NULL, XlcNCompoundText, (XLCd) NULL, XlcNCharSet, + open_cttocs); + _fallcSetConverter((XLCd) NULL, XlcNString, (XLCd) NULL, XlcNCharSet, + open_strtocs); + + _fallcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNCompoundText, + open_cstoct); + _fallcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNString, + open_cstostr); +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcCharSet.c b/cde/programs/dtudcfonted/libfal/_fallcCharSet.c new file mode 100644 index 000000000..d4f2fa761 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcCharSet.c @@ -0,0 +1,173 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcCharSet.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:33 */ +/* $XConsortium: _fallcCharSet.c /main/1 1996/04/08 15:15:44 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include <stdio.h> +#include "_fallibint.h" +#include "_fallcPublic.h" + +char * +_fallcGetCSValues(XlcCharSet charset, ...) +{ + va_list var; + XlcArgList args; + char *ret; + int num_args; + + Va_start(var, charset); + _fallcCountVaList(var, &num_args); + va_end(var); + + Va_start(var, charset); + _fallcVaToArgList(var, num_args, &args); + va_end(var); + + if (args == (XlcArgList) NULL) + return (char *) NULL; + + if (charset->get_values) + ret = (*charset->get_values)(charset, args, num_args); + else + ret = args->name; + + Xfree(args); + + return ret; +} + +typedef struct _XlcCharSetListRec { + XlcCharSet charset; + struct _XlcCharSetListRec *next; +} XlcCharSetListRec, *XlcCharSetList; + +static XlcCharSetList charset_list = NULL; + +XlcCharSet +_fallcGetCharSet(char *name) +{ + XlcCharSetList list; + XrmQuark xrm_name; + + xrm_name = falrmStringToQuark(name); + + for (list = charset_list; list; list = list->next) { + if (xrm_name == list->charset->xrm_name) + return (XlcCharSet) list->charset; + } + + return (XlcCharSet) NULL; +} + +Bool +_fallcAddCharSet(XlcCharSet charset) +{ + XlcCharSetList list; + + if (_fallcGetCharSet(charset->name)) + return False; + + list = (XlcCharSetList) Xmalloc(sizeof(XlcCharSetListRec)); + if (list == NULL) + return False; + + list->charset = charset; + list->next = charset_list; + charset_list = list; + + return True; +} + +static XlcResource resources[] = { + { XlcNName, NULLQUARK, sizeof(char *), + XOffsetOf(XlcCharSetRec, name), XlcGetMask }, + { XlcNEncodingName, NULLQUARK, sizeof(char *), + XOffsetOf(XlcCharSetRec, encoding_name), XlcGetMask }, + { XlcNSide, NULLQUARK, sizeof(XlcSide), + XOffsetOf(XlcCharSetRec, side), XlcGetMask }, + { XlcNCharSize, NULLQUARK, sizeof(int), + XOffsetOf(XlcCharSetRec, char_size), XlcGetMask }, + { XlcNSetSize, NULLQUARK, sizeof(int), + XOffsetOf(XlcCharSetRec, set_size), XlcGetMask }, + { XlcNControlSequence, NULLQUARK, sizeof(char *), + XOffsetOf(XlcCharSetRec, ct_sequence), XlcGetMask } +}; + +static char * +get_values(XlcCharSet charset, XlcArgList args, int num_args) +{ + if (resources[0].xrm_name == NULLQUARK) + _fallcCompileResourceList(resources, XlcNumber(resources)); + + return _fallcGetValues((XPointer) charset, resources, XlcNumber(resources), + args, num_args, XlcGetMask); +} + +XlcCharSet +_fallcCreateDefaultCharSet(char *name, char *ct_sequence) +{ + XlcCharSet charset; + + charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec)); + if (charset == NULL) + return (XlcCharSet) NULL; + bzero((char *) charset, sizeof(XlcCharSetRec)); + + charset->name = (char *) Xmalloc(strlen(name) + strlen(ct_sequence) + 2); + if (charset->name == NULL) { + Xfree((char *) charset); + return (XlcCharSet) NULL; + } + strcpy(charset->name, name); + charset->ct_sequence = charset->name + strlen(name) + 1; + strcpy(charset->ct_sequence, ct_sequence); + charset->get_values = get_values; + + _fallcParseCharSet(charset); + + return (XlcCharSet) charset; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcConv.c b/cde/programs/dtudcfonted/libfal/_fallcConv.c new file mode 100644 index 000000000..0afc9c18a --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcConv.c @@ -0,0 +1,344 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcConv.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:34 */ +/* $XConsortium: _fallcConv.c /main/1 1996/04/08 15:15:57 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" +#include <stdio.h> + +typedef XlcConv (*XlcConverter)(); + +typedef struct _fallcConverterListRec { + XLCd from_lcd; + char *from; + XrmQuark from_type; + XLCd to_lcd; + char *to; + XrmQuark to_type; + XlcConverter converter; + struct _fallcConverterListRec *next; +} XlcConverterListRec, *XlcConverterList; + +static XlcConverterList conv_list = NULL; + +static void +close_converter(XlcConv conv) +{ + (*conv->methods->close)(conv); +} + +static XlcConv +get_converter( + XLCd from_lcd, + XrmQuark from_type, + XLCd to_lcd, + XrmQuark to_type) +{ + XlcConverterList list, prev = NULL; + XlcConv conv; + + for (list = conv_list; list; list = list->next) { + if (list->from_lcd == from_lcd && list->to_lcd == to_lcd + && list->from_type == from_type && list->to_type == to_type) { + + if (prev && prev != conv_list) { /* XXX */ + prev->next = list->next; + list->next = conv_list; + conv_list = list; + } + + return (*list->converter)(from_lcd, list->from, to_lcd, list->to); + } + + prev = list; + } + + return (XlcConv) NULL; +} + +Bool +_fallcSetConverter( + XLCd from_lcd, + char *from, + XLCd to_lcd, + char *to, + XlcOpenConverterProc converter) +{ + XlcConverterList list; + XrmQuark from_type, to_type; + + from_type = falrmStringToQuark(from); + to_type = falrmStringToQuark(to); + + for (list = conv_list; list; list = list->next) { + if (list->from_lcd == from_lcd && list->to_lcd == to_lcd + && list->from_type == from_type && list->to_type == to_type) { + + list->converter = converter; + return True; + } + } + + list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec)); + if (list == NULL) + return False; + + list->from_lcd = from_lcd; + list->from = from; + list->from_type = from_type; + list->to_lcd = to_lcd; + list->to = to; + list->to_type = to_type; + list->converter = converter; + list->next = conv_list; + conv_list = list; + + return True; +} + +typedef struct _ConvRec { + XlcConv from_conv; + XlcConv to_conv; +} ConvRec, *Conv; + +static int +indirect_convert( + XlcConv lc_conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + Conv conv = (Conv) lc_conv->state; + XlcConv from_conv = conv->from_conv; + XlcConv to_conv = conv->to_conv; + XlcCharSet charset; + char buf[BUFSIZ], *cs; + XPointer tmp_args[1]; + int cs_left, ret, length, unconv_num = 0; + + if (from == NULL || *from == NULL) { + if (from_conv->methods->reset) + (*from_conv->methods->reset)(from_conv); + + if (to_conv->methods->reset) + (*to_conv->methods->reset)(to_conv); + + return 0; + } + + while (*from_left > 0) { + cs = buf; + cs_left = BUFSIZ; + tmp_args[0] = (XPointer) &charset; + + ret = (*from_conv->methods->convert)(from_conv, from, from_left, &cs, + &cs_left, tmp_args, 1); + if (ret < 0) + break; + + length = cs_left = cs - buf; + cs = buf; + + tmp_args[0] = (XPointer) charset; + + ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left, + tmp_args, 1); + if (ret < 0) { + unconv_num += length / charset->char_size; + continue; + } + + if (*to_left < 1) + break; + } + + return unconv_num; +} + +static void +close_indirect_converter(XlcConv lc_conv) +{ + Conv conv = (Conv) lc_conv->state; + + if (conv) { + if (conv->from_conv) + close_converter(conv->from_conv); + if (conv->to_conv) + close_converter(conv->to_conv); + + Xfree((char *) conv); + } + + Xfree((char *) lc_conv); +} + +static void +reset_indirect_converter(XlcConv lc_conv) +{ + Conv conv = (Conv) lc_conv->state; + + if (conv) { + if (conv->from_conv && conv->from_conv->methods->reset) + (*conv->from_conv->methods->reset)(conv->from_conv); + if (conv->to_conv && conv->to_conv->methods->reset) + (*conv->to_conv->methods->reset)(conv->to_conv); + } +} + +static XlcConvMethodsRec conv_methods = { + close_indirect_converter, + indirect_convert, + reset_indirect_converter +} ; + +static XlcConv +open_indirect_converter(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + XlcConv lc_conv, from_conv, to_conv; + Conv conv; + XrmQuark from_type, to_type; + static XrmQuark QChar, QCharSet, QCTCharSet = (XrmQuark) 0; + + if (QCTCharSet == (XrmQuark) 0) { + QCTCharSet = falrmStringToQuark(XlcNCTCharSet); + QCharSet = falrmStringToQuark(XlcNCharSet); + QChar = falrmStringToQuark(XlcNChar); + } + + from_type = falrmStringToQuark(from); + to_type = falrmStringToQuark(to); + + if (from_type == QCharSet || from_type == QChar || to_type == QCharSet || + to_type == QChar) + return (XlcConv) NULL; + + lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (lc_conv == NULL) + return (XlcConv) NULL; + + lc_conv->methods = &conv_methods; + + lc_conv->state = (XPointer) Xmalloc(sizeof(ConvRec)); + if (lc_conv->state == NULL){ + close_indirect_converter(lc_conv); + return (XlcConv) NULL; + } + + conv = (Conv) lc_conv->state; + + from_conv = get_converter(from_lcd, from_type, from_lcd, QCTCharSet); + if (from_conv == NULL) + from_conv = get_converter(from_lcd, from_type, from_lcd, QCharSet); + if (from_conv == NULL) + from_conv = get_converter((XLCd)NULL, from_type, (XLCd)NULL, QCharSet); + if (from_conv == NULL) + from_conv = get_converter(from_lcd, from_type, from_lcd, QChar); + if (from_conv == NULL){ + close_indirect_converter(lc_conv); + return (XlcConv) NULL; + } + conv->from_conv = from_conv; + + to_conv = get_converter(to_lcd, QCTCharSet, to_lcd, to_type); + if (to_conv == NULL) + to_conv = get_converter(to_lcd, QCharSet, to_lcd, to_type); + if (to_conv == NULL) + to_conv = get_converter((XLCd) NULL, QCharSet, (XLCd) NULL, to_type); + if (to_conv == NULL){ + close_indirect_converter(lc_conv); + return (XlcConv) NULL; + } + conv->to_conv = to_conv; + + return lc_conv; +} + +XlcConv +_fallcOpenConverter(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + XlcConv conv; + XrmQuark from_type, to_type; + + from_type = falrmStringToQuark(from); + to_type = falrmStringToQuark(to); + + if (conv = get_converter(from_lcd, from_type, to_lcd, to_type)) + return conv; + + return open_indirect_converter(from_lcd, from, to_lcd, to); +} + +void +_fallcCloseConverter(XlcConv conv) +{ + close_converter(conv); +} + +int +_fallcConvert( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + return (*conv->methods->convert)(conv, from, from_left, to, to_left, args, + num_args); +} + +void +_fallcResetConverter(XlcConv conv) +{ + if (conv->methods->reset) + (*conv->methods->reset)(conv); +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcDB.c b/cde/programs/dtudcfonted/libfal/_fallcDB.c new file mode 100644 index 000000000..864f95bcf --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcDB.c @@ -0,0 +1,1182 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcDB.c 1.3 - Fujitsu source for CDEnext 96/02/29 18:02:53 */ +/* $XConsortium: _fallcDB.c /main/1 1996/04/08 15:16:07 cde-fuj $ */ +/* + * + * Copyright IBM Corporation 1993 + * + * All Rights Reserved + * + * License to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#include "syncx.h" +#include <X11/Xresource.h> +#include "_fallibint.h" +#include "_fallcPubI.h" + +/* specifying NOT_X_ENV allows users to just use + the database parsing routine. */ +/* For UDC/VW */ +#ifndef BUFSIZE +#define BUFSIZE 2048 +#endif + +#ifdef COMMENT +#ifdef BUFSIZE +#undef BUFSIZE +#endif +#define BUFSIZE 6144 /* 2048*3 */ +#endif + +#include <stdio.h> + +typedef struct _DatabaseRec { + char *category; + char *name; + char **value; + int value_num; + struct _DatabaseRec *next; +} DatabaseRec, *Database; + +typedef enum { + S_NULL, /* outside category */ + S_CATEGORY, /* inside category */ + S_NAME, /* has name, expecting values */ + S_VALUE +} ParseState; + +typedef enum { + T_NEWLINE, + T_COMMENT, + T_SEMICOLON, + T_DOUBLE_QUOTE, + T_LEFT_BRACE, + T_RIGHT_BRACE, + T_SPACE, + T_TAB, + T_BACKSLASH, + T_NUMERIC_HEX, + T_NUMERIC_DEC, + T_NUMERIC_OCT, + T_DEFAULT +} Token; + +typedef struct { + Token token; /* token id */ + char *name; /* token sequence */ + int len; /* length of token sequence */ + int (*parse_proc)(); /* parsing procedure */ +} TokenTable; + +static int f_newline(); +static int f_comment(); +static int f_semicolon(); +static int f_double_quote(); +static int f_left_brace(); +static int f_right_brace(); +static int f_white(); +static int f_backslash(); +static int f_numeric(); +static int f_default(); + +static TokenTable token_tbl[] = { + { T_NEWLINE, "\n", 1, f_newline }, + { T_COMMENT, "#", 1, f_comment }, + { T_SEMICOLON, ";", 1, f_semicolon }, + { T_DOUBLE_QUOTE, "\"", 1, f_double_quote }, + { T_LEFT_BRACE, "{", 1, f_left_brace }, + { T_RIGHT_BRACE, "}", 1, f_right_brace }, + { T_SPACE, " ", 1, f_white }, + { T_TAB, "\t", 1, f_white }, + { T_BACKSLASH, "\\", 1, f_backslash }, + { T_NUMERIC_HEX, "\\x", 2, f_numeric }, + { T_NUMERIC_DEC, "\\d", 2, f_numeric }, + { T_NUMERIC_OCT, "\\o", 2, f_numeric }, + { T_DEFAULT, " ", 1, f_default }, /* any character */ + 0 +}; + +#define SYM_NEWLINE '\n' +#define SYM_COMMENT '#' +#define SYM_SEMICOLON ';' +#define SYM_DOUBLE_QUOTE '"' +#define SYM_LEFT_BRACE '{' +#define SYM_RIGHT_BRACE '}' +#define SYM_SPACE ' ' +#define SYM_TAB '\t' +#define SYM_BACKSLASH '\\' + +/************************************************************************/ + +#define MAX_NAME_NEST 64 + +typedef struct { + ParseState pre_state; + char *category; + char *name[MAX_NAME_NEST]; + int nest_depth; + char **value; + int value_len; + int value_num; + int bufsize; /* bufMaxSize >= bufsize >= 0 */ + int bufMaxSize; /* default : BUFSIZE */ + char *buf; +} DBParseInfo; + +static DBParseInfo parse_info; + +static void init_parse_info(void) +{ + static int first = 1; + char *ptr; + int size; + if(first == 1){ + bzero(&parse_info, sizeof(DBParseInfo)); + parse_info.buf = (char *)Xmalloc(BUFSIZE); + parse_info.bufMaxSize = BUFSIZE; + first = 0; + return ; + } + ptr = parse_info.buf; + size = parse_info.bufMaxSize; + bzero(&parse_info, sizeof(DBParseInfo)); + parse_info.buf = ptr; + parse_info.bufMaxSize = size; +} + +static void +clear_parse_info(void) +{ + int i; + char *ptr; + int size; + parse_info.pre_state = S_NULL; + if(parse_info.category != NULL){ + Xfree(parse_info.category); + } + for(i = 0; i <= parse_info.nest_depth; ++i){ + if(parse_info.name[i]){ + Xfree(parse_info.name[i]); + } + } + if(parse_info.value){ + if(*parse_info.value){ + Xfree(*parse_info.value); + } + Xfree((char *)parse_info.value); + } + ptr = parse_info.buf; + size = parse_info.bufMaxSize; + bzero(&parse_info, sizeof(DBParseInfo)); + parse_info.buf = ptr; + parse_info.bufMaxSize = size; +} + +static Bool +realloc_parse_info(int len) +{ + char *p; + + + parse_info.bufMaxSize = BUFSIZE * + ((parse_info.bufsize + len)/BUFSIZE + 1); + p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize); + if(p == NULL){ + return(False); + } + parse_info.buf = p; + + return(True); +} +/************************************************************************/ +typedef struct _Line { + char *str; + int cursize; + int maxsize; + int seq; +} Line; + +static void +free_line(Line *line) +{ + if(line->str != NULL){ + Xfree(line->str); + } + bzero(line, sizeof(Line)); +} + +static int +realloc_line(Line *line, int size) +{ + char *str = line->str; + + if(str != NULL){ + str = (char *)Xrealloc(str, size); + }else{ + str = (char *)Xmalloc(size); + } + if(str == NULL){ + /* malloc error */ + bzero(line, sizeof(Line)); + return 0; + } + line->str = str; + line->maxsize = size; + return 1; +} + +#define iswhite(ch) ((ch) == SYM_SPACE || (ch) == SYM_TAB) + +static void +zap_comment(char *str, int *quoted) +{ + char *p = str; + + while(*p){ + if(*p == SYM_DOUBLE_QUOTE){ + if(p == str || p[-1] != SYM_BACKSLASH){ + /* unescaped double quote changes quoted state. */ + *quoted = *quoted ? 0 : 1; + } + } + if(*p == SYM_COMMENT && !*quoted){ + int pos = p - str; + if(pos == 0 || + iswhite(p[-1]) && (pos == 1 || p[-2] != SYM_BACKSLASH)){ + int len = strlen(p); + if(len > 0 && p[len - 1] == SYM_NEWLINE){ + /* newline is the identifier for finding end of value. + therefore, it should not be removed. */ + *p++ = SYM_NEWLINE; + } + *p = '\0'; + break; + } + } + ++p; + } + +} + +static int +read_line(FILE *fd, Line *line) +{ + char buf[BUFSIZE], *p; + int len; + int quoted = 0; /* quoted by double quote? */ + char *str; + int cur; + + str = line->str; + cur = line->cursize = 0; + + while((p = fgets(buf, BUFSIZE, fd)) != NULL){ + ++line->seq; + zap_comment(p, "ed); /* remove comment line */ + len = strlen(p); + if(len == 0){ + if(cur > 0){ + break; + } + continue; + } + if(cur + len + 1 > line->maxsize){ + /* need to reallocate buffer. */ + if(! realloc_line(line, line->maxsize + BUFSIZE)){ + return -1; /* realloc error. */ + } + str = line->str; + } + strncpy(str + cur, p, len); + + cur += len; + str[cur] = '\0'; + if(!quoted){ + if(cur > 1 && str[cur - 2] == SYM_BACKSLASH && + str[cur - 1] == SYM_NEWLINE){ + /* the line is ended backslash followed by newline. + need to concatinate the next line. */ + cur -= 2; + str[cur] = '\0'; + }else{ + break; + } + } + } + if(quoted){ + /* error. still in quoted state. */ + return -1; + } + return line->cursize = cur; +} + +/************************************************************************/ + +static Token +get_token(char *str) +{ + switch(*str){ + case SYM_NEWLINE: return T_NEWLINE; + case SYM_COMMENT: return T_COMMENT; + case SYM_SEMICOLON: return T_SEMICOLON; + case SYM_DOUBLE_QUOTE: return T_DOUBLE_QUOTE; + case SYM_LEFT_BRACE: return T_LEFT_BRACE; + case SYM_RIGHT_BRACE: return T_RIGHT_BRACE; + case SYM_SPACE: return T_SPACE; + case SYM_TAB: return T_TAB; + case SYM_BACKSLASH: + switch(str[1]){ + case 'x': return T_NUMERIC_HEX; + case 'd': return T_NUMERIC_DEC; + case 'o': return T_NUMERIC_OCT; + } + return T_BACKSLASH; + default: + return T_DEFAULT; + } +} + +static int +get_word(char *str, char *word) +{ + char *p = str, *w = word; + Token token; + int token_len; + + while(*p != '\0'){ + token = get_token(p); + token_len = token_tbl[token].len; + if(token == T_BACKSLASH){ + p += token_len; + if(*p == '\0'){ + break; + } + token = get_token(p); + token_len = token_tbl[token].len; + }else if(token != T_COMMENT && + token != T_DEFAULT){ + break; + } + strncpy(w, p, token_len); + p += token_len; w += token_len; + } + *w = '\0'; + return p - str; /* return number of scanned chars */ +} + +static int +get_quoted_word(char *str, char *word) +{ + char *p = str, *w = word; + Token token; + int token_len; + + if(*p == SYM_DOUBLE_QUOTE){ + ++p; + } + while(*p != '\0'){ + token = get_token(p); + token_len = token_tbl[token].len; + if(token == T_DOUBLE_QUOTE){ + p += token_len; + *w = '\0'; + return p - str; + } + if(token == T_BACKSLASH){ + p += token_len; + if(*p == '\0'){ + break; + } + token = get_token(p); + token_len = token_tbl[token].len; + } + strncpy(w, p, token_len); + p += token_len; w += token_len; + } + /* error. cannot detect next double quote */ + return 0; +} + +/************************************************************************/ + +static int +append_value_list(void) +{ + char **value_list = parse_info.value; + char *value = NULL; + int value_num = parse_info.value_num; + int value_len = parse_info.value_len; + char *str = parse_info.buf; + int len = parse_info.bufsize; + char *p; + + if(len < 1){ + return 1; /* return with no error */ + } + + if(value_list == (char **)NULL){ + value_list = (char **)Xmalloc(sizeof(char *) * 2); + *value_list = NULL; + }else{ + value_list = (char **) + Xrealloc(value_list, sizeof(char *) * (value_num + 2)); + } + if(value_list == (char **)NULL){ + goto err; + } + + value = *value_list; + if(value == NULL){ + value = (char *)Xmalloc(value_len + len + 1); + }else{ + value = (char *)Xrealloc(value, value_len + len + 1); + } + if(value == NULL){ + goto err; + } + if(value != *value_list){ + int delta, i; + delta = value - *value_list; + *value_list = value; + for(i = 1; i < value_num; ++i){ + value_list[i] += delta; + } + } + + value_list[value_num] = p = &value[value_len]; + value_list[value_num + 1] = NULL; + strncpy(p, str, len); + p[len] = 0; + + parse_info.value = value_list; + parse_info.value_num = value_num + 1; + parse_info.value_len = value_len + len + 1; + parse_info.bufsize = 0; + return 1; + + err: + if(value_list){ + Xfree((char **)value_list); + } + + Xfree(value); + + parse_info.value = (char **)NULL; + parse_info.value_num = 0; + parse_info.value_len = 0; + parse_info.bufsize = 0; + return 0; +} + +static int +construct_name(char *name) +{ + int i, len = 0; + char *p = name; + + for(i = 0; i <= parse_info.nest_depth; ++i){ + len += strlen(parse_info.name[i]) + 1; + } + + strcpy(p, parse_info.name[0]); + p += strlen(parse_info.name[0]); + for(i = 1; i <= parse_info.nest_depth; ++i){ + *p++ = '.'; + strcpy(p, parse_info.name[i]); + p += strlen(parse_info.name[i]); + } + return *name != '\0'; +} + +static int +store_to_database(Database *db) +{ + Database new = (Database)NULL; + char name[BUFSIZE]; + + while(1){ + + if(parse_info.pre_state == S_VALUE){ + if(! append_value_list()){ + break; + } + } + + if(parse_info.name[parse_info.nest_depth] == NULL){ + break; + } + + new = (Database)Xmalloc(sizeof(DatabaseRec)); + if(new == (Database)NULL){ + break; + } + bzero(new, sizeof(DatabaseRec)); + + new->category = (char *)Xmalloc(strlen(parse_info.category) + 1); + if(new->category == NULL){ + break; + } + strcpy(new->category, parse_info.category); + + if(! construct_name(name)){ + break; + } + new->name = (char *)Xmalloc(strlen(name) + 1); + if(new->name == NULL){ + break; + } + strcpy(new->name, name); + new->next = *db; + new->value = parse_info.value; + new->value_num = parse_info.value_num; + *db = new; + + Xfree(parse_info.name[parse_info.nest_depth]); + parse_info.name[parse_info.nest_depth] = NULL; + + parse_info.value = (char **)NULL; + parse_info.value_num = 0; + parse_info.value_len = 0; + + return 1; + } + + if(new){ + if(new->category){ + Xfree(new->category); + } + if(new->name){ + Xfree(new->name); + } + Xfree(new); + } + if(parse_info.value){ + if(*parse_info.value){ + Xfree(*parse_info.value); + } + Xfree((char **)parse_info.value); + parse_info.value = (char **)NULL; + parse_info.value_num = 0; + parse_info.value_len = 0; + } + return 0; +} + +#define END_MARK "END" +#define END_MARK_LEN 3 /*strlen(END_MARK)*/ + +static int +check_category_end(char *str) +{ + char *p; + int len; + + p = str; + if(strncmp(p, END_MARK, END_MARK_LEN)){ + return 0; + } + p += END_MARK_LEN; + + while(iswhite(*p)){ + ++p; + } + len = strlen(parse_info.category); + if(strncmp(p, parse_info.category, len)){ + return 0; + } + p += len; + return p - str; +} + +/************************************************************************/ + +static int +f_newline(char *str, Token token, Database *db) +{ + switch(parse_info.pre_state){ + case S_NULL: + case S_CATEGORY: + break; + case S_NAME: + return 0; /* no value */ + case S_VALUE: + if(!store_to_database(db)){ + return 0; + } + parse_info.pre_state = S_CATEGORY; + break; + default: + return 0; + } + return token_tbl[token].len; +} + +static int +f_comment(char *str, Token token, Database *db) +{ + /* NOTE: comment is already handled in read_line(), + so this function is not necessary. */ + + char *p = str; + + while(*p != SYM_NEWLINE && *p != '\0'){ + ++p; /* zap to the end of line */ + } + return p - str; +} + +static int +f_white(char *str, Token token, Database *db) +{ + char *p = str; + + while(iswhite(*p)){ + ++p; + } + return p - str; +} + +static int +f_semicolon(char *str, Token token, Database *db) +{ + switch(parse_info.pre_state){ + case S_NULL: + case S_CATEGORY: + case S_NAME: + return 0; + case S_VALUE: + if(! append_value_list()){ + return 0; + } + parse_info.pre_state = S_VALUE; + break; + default: + return 0; + } + return token_tbl[token].len; +} + +static int +f_left_brace(char *str, Token token, Database *db) +{ + switch(parse_info.pre_state){ + case S_NULL: + case S_CATEGORY: + return 0; + case S_NAME: + if(parse_info.name[parse_info.nest_depth] == NULL || + parse_info.nest_depth + 1 > MAX_NAME_NEST){ + return 0; + } + ++parse_info.nest_depth; + parse_info.pre_state = S_CATEGORY; + break; + case S_VALUE: + default: + return 0; + } + return token_tbl[token].len; +} + +static int +f_right_brace(char *str, Token token, Database *db) +{ + if(parse_info.nest_depth < 1){ + return 0; + } + + switch(parse_info.pre_state){ + case S_NULL: + case S_NAME: + return 0; + case S_VALUE: + if(! store_to_database(db)){ + return 0; + } + /* fall into next case */ + case S_CATEGORY: + if(parse_info.name[parse_info.nest_depth] != NULL){ + Xfree(parse_info.name[parse_info.nest_depth]); + parse_info.name[parse_info.nest_depth] = NULL; + } + --parse_info.nest_depth; + parse_info.pre_state = S_CATEGORY; + break; + default: + return 0; + } + return token_tbl[token].len; +} + +static int +f_double_quote(char *str, Token token, Database *db) +{ + char word[BUFSIZE]; + int len = 0; + + switch(parse_info.pre_state){ + case S_NULL: + case S_CATEGORY: + return 0; + case S_NAME: + case S_VALUE: + len = get_quoted_word(str, word); + if(len < 1){ + return 0; + } + if( (parse_info.bufsize + (int)strlen(word) +1) + >= parse_info.bufMaxSize){ + if(realloc_parse_info(strlen(word) +1) == False){ + return 0; + } + } + strcpy(&parse_info.buf[parse_info.bufsize], word); + parse_info.bufsize += strlen(word); + parse_info.pre_state = S_VALUE; + break; + default: + return 0; + } + return len; /* including length of token */ +} + +static int +f_backslash(char *str, Token token, Database *db) +{ + return f_default(str, token, db); +} + +static int +f_numeric(char *str, Token token, Database *db) +{ + char word[BUFSIZE], *p; + int len; + int token_len; + + switch(parse_info.pre_state){ + case S_NULL: + case S_CATEGORY: + return 0; + case S_NAME: + case S_VALUE: + token_len = token_tbl[token].len; + p = str + token_len; + len = get_word(p, word); + if(len < 1){ + return 0; + } + if( (parse_info.bufsize + token_len + (int)strlen(word) +1) + >= parse_info.bufMaxSize){ + if(realloc_parse_info(token_len + strlen(word) +1) == False){ + return 0; + } + } + strncpy(&parse_info.buf[parse_info.bufsize], str, token_len); + strcpy(&parse_info.buf[parse_info.bufsize + token_len], word); + parse_info.bufsize += token_len + strlen(word); + parse_info.pre_state = S_VALUE; + break; + default: + return 0; + } + return len + token_len; +} + +static int +f_default(char *str, Token token, Database *db) +{ + char word[BUFSIZE], *p; + int len; + + len = get_word(str, word); + if(len < 1){ + return 0; + } + + switch(parse_info.pre_state){ + case S_NULL: + if(parse_info.category != NULL){ + return 0; + } + p = (char *)Xmalloc(strlen(word) + 1); + if(p == NULL){ + return 0; + } + strcpy(p, word); + parse_info.category = p; + parse_info.pre_state = S_CATEGORY; + break; + case S_CATEGORY: + if(parse_info.nest_depth == 0){ + if(check_category_end(str)){ + /* end of category is detected. + clear context and zap to end of this line */ + clear_parse_info(); + len = strlen(str); + break; + } + } + p = (char *)Xmalloc(strlen(word) + 1); + if(p == NULL){ + return 0; + } + strcpy(p, word); + if(parse_info.name[parse_info.nest_depth] != NULL){ + Xfree(parse_info.name[parse_info.nest_depth]); + } + parse_info.name[parse_info.nest_depth] = p; + parse_info.pre_state = S_NAME; + break; + case S_NAME: + case S_VALUE: + if( (parse_info.bufsize + (int)strlen(word) +1 ) + >= parse_info.bufMaxSize){ + if(realloc_parse_info(strlen(word) +1) == False){ + return 0; + } + } + strcpy(&parse_info.buf[parse_info.bufsize], word); + parse_info.bufsize += strlen(word); + parse_info.pre_state = S_VALUE; + break; + default: + return 0; + } + return len; +} + +/************************************************************************/ + +#ifdef DEBUG +static void +PrintDatabase(Database db) +{ + Database p = db; + int i = 0, j; + + printf("***\n*** BEGIN Database\n***\n"); + while(p){ + printf("%3d: ", i++); + printf("%s, %s, ", p->category, p->name); + printf("\t[%d: ", p->value_num); + for(j = 0; j < p->value_num; ++j){ + printf("%s, ", p->value[j]); + } + printf("]\n"); + p = p->next; + } + printf("***\n*** END Database\n***\n"); +} +#endif + +static void +DestroyDatabase(Database db) +{ + Database p = db; + + while(p){ + if(p->category != NULL){ + Xfree(p->category); + } + if(p->name != NULL){ + Xfree(p->name); + } + if(p->value != (char **)NULL){ + if(*p->value != NULL){ + Xfree(*p->value); + } + Xfree((char *)p->value); + } + db = p->next; + Xfree((char *)p); + p = db; + } +} + +static int +CountDatabase(Database db) +{ + Database p = db; + int cnt = 0; + + while(p){ + ++cnt; + p = p->next; + } + return cnt; +} + +static Database +CreateDatabase(char *dbfile) +{ + Database db = (Database)NULL; + FILE *fd; + Line line; + char *p; + Token token; + int token_len; + int len; + int error = 0; + + fd = fopen(dbfile, "r"); + if(fd == (FILE *)NULL){ + return NULL; + } + + bzero(&line, sizeof(Line)); + init_parse_info(); + + do { + int rc = read_line(fd, &line); + if(rc < 0){ + error = 1; + break; + }else if(rc == 0){ + break; + } + p = line.str; + while(*p){ + token = get_token(p); + len = (*token_tbl[token].parse_proc)(p, token, &db); + if(len < 1){ + error = 1; + break; + } + p += len; + } + } while (!error); + + if(parse_info.pre_state != S_NULL){ + clear_parse_info(); + error = 1; + } + if(error){ +#ifdef DEBUG + fprintf(stderr, "database format error at line %d.\n", line.seq); +#endif + DestroyDatabase(db); + db = (Database)NULL; + } + + fclose(fd); + free_line(&line); + +#ifdef DEBUG + PrintDatabase(db); +#endif + + return db; +} + +/************************************************************************/ + +/* locale framework functions */ + +typedef struct _XlcDatabaseRec { + XrmQuark category_q; + XrmQuark name_q; + Database db; + struct _XlcDatabaseRec *next; +} XlcDatabaseRec, *XlcDatabase; + +typedef struct _XlcDatabaseListRec { + XrmQuark name_q; + XlcDatabase lc_db; + Database database; + int ref_count; + struct _XlcDatabaseListRec *next; +} XlcDatabaseListRec, *XlcDatabaseList; + +/* database cache list (per file) */ +static XlcDatabaseList _db_list = (XlcDatabaseList)NULL; + +/************************************************************************/ +/* _fallcGetResource(lcd, category, class, value, count) */ +/*----------------------------------------------------------------------*/ +/* This function retrieves XLocale database information. */ +/************************************************************************/ +void +_fallcGetResource( + XLCd lcd, + char *category, + char *class, + char ***value, + int *count) +{ + XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd); + + (*methods->get_resource)(lcd, category, class, value, count); + return; +} + +/************************************************************************/ +/* _fallcGetLocaleDataBase(lcd, category, class, value, count) */ +/*----------------------------------------------------------------------*/ +/* This function retrieves XLocale database information. */ +/************************************************************************/ +void +_fallcGetLocaleDataBase( + XLCd lcd, + char *category, + char *name, + char ***value, + int *count) +{ + XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db); + XrmQuark category_q, name_q; + + category_q = falrmStringToQuark(category); + name_q = falrmStringToQuark(name); + for(; lc_db->db; ++lc_db){ + if(category_q == lc_db->category_q && name_q == lc_db->name_q){ + *value = lc_db->db->value; + *count = lc_db->db->value_num; + return; + } + } + *value = (char **)NULL; + *count = 0; +} + +/************************************************************************/ +/* _fallcDestroyLocaleDataBase(lcd) */ +/*----------------------------------------------------------------------*/ +/* This function destroy the XLocale Database that bound to the */ +/* specified lcd. If the XLocale Database is referred from some */ +/* other lcd, this function just decreases reference count of */ +/* the database. If no locale refers the database, this function */ +/* remove it from the cache list and free work area. */ +/************************************************************************/ +void +_fallcDestroyLocaleDataBase(XLCd lcd) +{ + XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db); + XlcDatabaseList p, prev; + + for(p = _db_list, prev = (XlcDatabaseList)NULL; p; + prev = p, p = p->next){ + if(p->lc_db == lc_db){ + if((-- p->ref_count) < 1){ + if(p->lc_db != (XlcDatabase)NULL){ + Xfree((char *)p->lc_db); + } + DestroyDatabase(p->database); + if(prev == (XlcDatabaseList)NULL){ + _db_list = p->next; + }else{ + prev->next = p->next; + } + Xfree((char*)p); + } + break; + } + } + XLC_PUBLIC(lcd, xlocale_db) = (XPointer)NULL; +} + +/************************************************************************/ +/* _fallcCreateLocaleDataBase(lcd) */ +/*----------------------------------------------------------------------*/ +/* This function create an XLocale database which correspond to */ +/* the specified XLCd. */ +/************************************************************************/ +XPointer +_fallcCreateLocaleDataBase(XLCd lcd) +{ + XlcDatabaseList list, new; + Database p, database = (Database)NULL; + XlcDatabase lc_db = (XlcDatabase)NULL; + XrmQuark name_q; + char pathname[256], *name; + int i, n; + + name = _fallcFileName(lcd, "locale"); + if(name == NULL){ + return (XPointer)NULL; + } + strcpy(pathname, name); + Xfree(name); + + name_q = falrmStringToQuark(pathname); + for(list = _db_list; list; list = list->next){ + if(name_q == list->name_q){ + list->ref_count++; + return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)list->lc_db; + } + } + + database = CreateDatabase(pathname); + if(database == (Database)NULL){ + return (XPointer)NULL; + } + n = CountDatabase(database); + lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1)); + if(lc_db == (XlcDatabase)NULL){ + DestroyDatabase(database); + if(lc_db != (XlcDatabase)NULL){ + Xfree((char *)lc_db); + } + return (XPointer)NULL; + } + bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1)); + for(p = database, i = 0; p && i < n; p = p->next, ++i){ + lc_db[i].category_q = falrmStringToQuark(p->category); + lc_db[i].name_q = falrmStringToQuark(p->name); + lc_db[i].db = p; + } + + new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec)); + if(new == (XlcDatabaseList)NULL){ + DestroyDatabase(database); + if(lc_db != (XlcDatabase)NULL){ + Xfree((char *)lc_db); + } + return (XPointer)NULL; + } + new->name_q = name_q; + new->lc_db = lc_db; + new->database = database; + new->ref_count = 1; + new->next = _db_list; + _db_list = new; + + return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)lc_db; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcDefConv.c b/cde/programs/dtudcfonted/libfal/_fallcDefConv.c new file mode 100644 index 000000000..ce3b9c92e --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcDefConv.c @@ -0,0 +1,365 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcDefConv.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:35 */ +/* $XConsortium: _fallcDefConv.c /main/1 1996/04/08 15:16:17 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" + +typedef struct _StateRec { + XlcCharSet charset; + XlcCharSet GL_charset; + XlcCharSet GR_charset; + XlcConv ct_conv; + int (*to_converter)(); +} StateRec, *State; + +static int +strtostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + char *src, *dst; + unsigned char side; + int length; + + if (from == NULL || *from == NULL) + return 0; + + src = (char *) *from; + dst = (char *) *to; + + length = min(*from_left, *to_left); + + if (num_args > 0) { + side = *((unsigned char *) src) & 0x80; + while (side == (*((unsigned char *) src) & 0x80) && length-- > 0) + *dst++ = *src++; + } else { + while (length-- > 0) + *dst++ = *src++; + } + + *from_left -= src - (char *) *from; + *from = (XPointer) src; + *to_left -= dst - (char *) *to; + *to = (XPointer) dst; + + if (num_args > 0) { + State state = (State) conv->state; + + *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset; + } + + return 0; +} + +static int +wcstostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + wchar_t *src, side; + char *dst; + int length; + + if (from == NULL || *from == NULL) + return 0; + + src = (wchar_t *) *from; + dst = (char *) *to; + + length = min(*from_left, *to_left); + + if (num_args > 0) { + side = *src & 0x80; + while (side == (*src & 0x80) && length-- > 0) + *dst++ = *src++; + } else { + while (length-- > 0) + *dst++ = *src++; + } + + *from_left -= src - (wchar_t *) *from; + *from = (XPointer) src; + *to_left -= dst - (char *) *to; + *to = (XPointer) dst; + + if (num_args > 0) { + State state = (State) conv->state; + + *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset; + } + + return 0; +} + +static int +cstostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + char *src, *dst; + unsigned char side; + int length; + + if (from == NULL || *from == NULL) + return 0; + + if (num_args > 0) { + State state = (State) conv->state; + XlcCharSet charset = (XlcCharSet) args[0]; + + if (charset != state->GL_charset && charset != state->GR_charset) + return -1; + } + + src = (char *) *from; + dst = (char *) *to; + + length = min(*from_left, *to_left); + + if (num_args > 0) { + side = *((unsigned char *) src) & 0x80; + while (side == (*((unsigned char *) src) & 0x80) && length-- > 0) + *dst++ = *src++; + } else { + while (length-- > 0) + *dst++ = *src++; + } + + *from_left -= src - (char *) *from; + *from = (XPointer) src; + *to_left -= dst - (char *) *to; + *to = (XPointer) dst; + + if (num_args > 0) { + State state = (State) conv->state; + + *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset; + } + + return 0; +} + +static int +strtowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + char *src; + wchar_t *dst; + int length; + + if (from == NULL || *from == NULL) + return 0; + + if (num_args > 0) { + State state = (State) conv->state; + XlcCharSet charset = (XlcCharSet) args[0]; + + if (charset != state->GL_charset && charset != state->GR_charset) + return -1; + } + + src = (char *) *from; + dst = (wchar_t *) *to; + + length = min(*from_left, *to_left); + + while (length-- > 0) + *dst++ = (wchar_t) *src++; + + *from_left -= src - (char *) *from; + *from = (XPointer) src; + *to_left -= dst - (wchar_t *) *to; + *to = (XPointer) dst; + + return 0; +} + + +static void +close_converter(XlcConv conv) +{ + if (conv->state) + Xfree((char *) conv->state); + + Xfree((char *) conv); +} + +static XlcConv +create_conv(XlcConvMethods methods) +{ + XlcConv conv; + State state; + static XlcCharSet GL_charset = NULL; + static XlcCharSet GR_charset = NULL; + + if (GL_charset == NULL) { + GL_charset = _fallcGetCharSet("ISO8859-1:GL"); + GR_charset = _fallcGetCharSet("ISO8859-1:GR"); + } + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == NULL) + return (XlcConv) NULL; + + conv->state = NULL; + + state = (State) Xmalloc(sizeof(StateRec)); + if (state == NULL){ + close_converter(conv); + return (XlcConv) NULL; + } + + state->GL_charset = state->charset = GL_charset; + state->GR_charset = GR_charset; + + conv->methods = methods; + conv->state = (XPointer) state; + + return conv; +} + +static XlcConvMethodsRec strtostr_methods = { + close_converter, + strtostr, + NULL +} ; + +static XlcConv +open_strtostr( XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type ) +{ + return create_conv(&strtostr_methods); +} + +static XlcConvMethodsRec wcstostr_methods = { + close_converter, + wcstostr, + NULL +} ; + +static XlcConv +open_wcstostr( XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type ) +{ + return create_conv(&wcstostr_methods); +} + +static XlcConvMethodsRec cstostr_methods = { + close_converter, + cstostr, + NULL +} ; + +static XlcConv +open_cstostr( XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type ) +{ + return create_conv(&cstostr_methods); +} + +static XlcConvMethodsRec strtowcs_methods = { + close_converter, + strtowcs, + NULL +} ; + +static XlcConv +open_strtowcs( XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type ) +{ + return create_conv(&strtowcs_methods); +} + +XLCd +_fallcDefaultLoader(char *name) +{ + XLCd lcd; + + if (strcmp(name, "C")) + return (XLCd) NULL; + + lcd = _fallcCreateLC(name, _fallcPublicMethods); + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_strtowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_strtostr); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_strtostr); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_strtostr); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_strtostr);/* XXX */ + + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstostr); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstostr); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstostr); + + _fallcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtostr); + _fallcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs); + + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstostr); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_strtowcs); + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcDynamic.c b/cde/programs/dtudcfonted/libfal/_fallcDynamic.c new file mode 100644 index 000000000..6736248d3 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcDynamic.c @@ -0,0 +1,72 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: _fallcDynamic.c /main/3 1996/05/08 19:00:37 drk $ */ +/* lcDynamic.c 1.1 - Fujitsu source for CDEnext 95/12/07 10:56:55 */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ +#include <stdio.h> +#include <string.h> +#include "_fallibint.h" +#ifdef USE_DYNAMIC_LOADER + +#ifndef XLOCALEDIR +#define XLOCALEDIR "/usr/lib/X11/locale" +#endif + +#define LCLIBNAME "xi18n.so" + +extern void *dlopen(); +extern void *dlsym(); +extern int dlclose(); +extern char *dlerror(); + +#define LAZY 1 +#define NOW 2 +#define GLOBAL 0x100 + +XLCd +_fallcDynamicLoader(char *name) +{ + char libpath[1024]; + XLCdMethods _fallcGenericMethods; + XLCd lcd; + void *nlshandler; + + sprintf(libpath,"%s/%s/%s", + XLOCALEDIR,name,LCLIBNAME); + nlshandler = dlopen(libpath,LAZY); + _fallcGenericMethods = (XLCdMethods)dlsym(nlshandler, + "genericMethods"); + lcd = _fallcCreateLC(name,_fallcGenericMethods); + + + return lcd; +} +#endif /* USE_DYNAMIC_LOADER */ diff --git a/cde/programs/dtudcfonted/libfal/_fallcEuc.c b/cde/programs/dtudcfonted/libfal/_fallcEuc.c new file mode 100644 index 000000000..377e2096b --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcEuc.c @@ -0,0 +1,1435 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcEuc.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:36 */ +/* $XConsortium: _fallcEuc.c /main/1 1996/04/08 15:16:38 cde-fuj $ */ +/****************************************************************** + + Copyright 1992, 1993 by FUJITSU LIMITED + Copyright 1993 by Fujitsu Open Systems Solutions, Inc. + +Permission to use, copy, modify, distribute and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED and +Fujitsu Open Systems Solutions, Inc. not be used in advertising or +publicity pertaining to distribution of the software without specific, +written prior permission. +FUJITSU LIMITED and Fujitsu Open Systems Solutions, Inc. makes no +representations about the suitability of this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED AND FUJITSU OPEN SYSTEMS SOLUTIONS, INC. DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU OPEN SYSTEMS +SOLUTIONS, INC. AND FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. + + Authors: Shigeru Yamada (yamada@ossi.com) + Jeffrey Bloomfield (jeffb@ossi.com) + Yoshiyuki Segawa (segawa@ossi.com) + +*****************************************************************/ + +#include "_fallibint.h" +#include "_fallcGeneric.h" + +#include <ctype.h> + +#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */ +#define CS1 codesets[1] /* Codeset 1 - Kanji */ +#define CS2 codesets[2] /* Codeset 2 - Half-Kana */ +#define CS3 codesets[3] /* Codeset 3 - User defined */ + +#define SS2 0x8e /* Single-shift char: CS2 */ +#define SS3 0x8f /* Single-shift char: CS3 */ + +#define ASCII_CODESET 0 +#define KANJI_CODESET 1 +#define KANA_CODESET 2 +#define USERDEF_CODESET 3 +#define MAX_CODESETS + +#define GR 0x80 /* begins right-side (non-ascii) region */ +#define GL 0x7f /* ends left-side (ascii) region */ + +#define isleftside(c) (((c) & GR) ? 0 : 1) +#define isrightside(c) (!isleftside(c)) + +#define BIT8OFF(c) ((c) & GL) +#define BIT8ON(c) ((c) | GR) + +typedef unsigned char Uchar; +typedef unsigned long Ulong; +typedef unsigned int Uint; + +static CodeSet GetCodeSetFromCharSet(); +static CodeSet wc_codeset(); + +#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \ + BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \ + BIT8OFF(c) != 0x1b) + +/* + * Notes: + * 1. Defining FORCE_INDIRECT_CONVERTER (see _fallcEucLoader()) + * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()). + * 2. Using direct converters (e.g. mbstowcs()) decreases conversion + * times by 20-40% (depends on specific converter used). + */ + +static int +euc_mbstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + + XLCd lcd = (XLCd)conv->state; + + Uchar ch; + int chr_len = 0; + int sshift = False; + int shift_mult = 0; + Uint chrcode; + + Uint wc_encode = 0; + Uint wc_tmp = 0; + + int cs0flg = False; + int cs1flg = False; + int length; + int num_conv; + int unconv_num = 0; + + Bool new_char; + + XPointer inbufptr = *from; + wchar_t *outbufptr = (wchar_t *) *to; + wchar_t *outbuf_base = outbufptr; + + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (new_char = True; *from_left > 0;) { + + ch = *inbufptr++; + + if (isleftside(ch)) { /* CS0 */ + if (ASCII_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + if( cs0flg == True) { + new_char = True; + cs0flg = False; + } + length = CS0->length; + *outbufptr++ = (wchar_t)ch; + (*from_left)--; + continue; + } + else if (ch == SS2) { /* CS2 */ + if (KANA_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + if (sshift == True || cs1flg == True) { + cs1flg = False; + unconv_num++; + continue; + } + length = CS2->length; + wc_encode = CS2->wc_encoding; + chrcode = 0; + sshift = True; + cs0flg = True; + (*from_left)--; + continue; + } + else if (ch == SS3) { /* CS3 */ + if (USERDEF_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + if (sshift == True || cs1flg == True) { + cs1flg = False; + unconv_num++; + continue; + } + length = CS3->length; + if (*from_left < 1 ) + unconv_num++; + wc_encode = CS3->wc_encoding; + chrcode = 0; + sshift = True; + cs0flg = True; + (*from_left)--; + continue; + + } else { /* CS1 */ + if (KANJI_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + if (sshift == False) { + length = CS1->length; + if (*from_left < 1) + unconv_num++; + wc_encode = CS1->wc_encoding; + } + chrcode = BIT8OFF(ch); + cs0flg = True; + cs1flg = True; + (*from_left)--; + } + + if (new_char) { /* begin new character */ + chr_len = length; + shift_mult = length - 1; + new_char = False; + } + + chrcode <<= (wc_shift * shift_mult); + shift_mult--; + wc_tmp |= chrcode; + + if (--chr_len == 0) { + wc_tmp |= wc_encode; + *outbufptr++ = wc_tmp; + + new_char = True; + sshift = False; + cs0flg = False; + cs1flg = False; + wc_tmp = (Uint)0; + } + + } /* end for */ + + *to = (XPointer)outbufptr; + + if (cs0flg == True || cs1flg == True) /* error check on last char */ + unconv_num++; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + *to_left = (*to_left) - num_conv; + + return unconv_num; +} + + +static int +euc_wcstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + XPointer outbuf_base = outbufptr; + wchar_t wch; + int length; + Uchar tmp; + int num_conv; + int unconv_num = 0; + + XLCd lcd = (XLCd)conv->state; + CodeSet codeset; + Ulong wc_encoding_mask = XLC_GENERIC(lcd, wc_encode_mask); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + Ulong wch_encode; + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (; *from_left > 0 ; (*from_left)-- ) { + + wch = *inbufptr++; + + if (!(codeset = wc_codeset(lcd, wch))) { + unconv_num++; + (*from_left)--; + continue; + } + + length = codeset->length; + wch ^= (wchar_t)codeset->wc_encoding; + + if (codeset->parse_info) /* put out SS2 or SS3 */ + *outbufptr++ = *codeset->parse_info->encoding; + + do { + length--; + tmp = (wch>>(wchar_t)(length * wc_shift)); + + if (codeset->side == XlcGR) + tmp = BIT8ON(tmp); + + *outbufptr++ = (Uchar)tmp; + } while (length); + } + + *to = (XPointer)outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + *to_left -= num_conv; + + return unconv_num; +} + + +static int +euc_mbtocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + XlcCharSet charset; + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + int length; + int unconv_num = 0; + int min_ch = 0; + char *src = *from, *dst = *to; + + + if (isleftside(*src)) { /* 7-bit (CS0) */ + if (ASCII_CODESET >= codeset_num) + return -1; + charset = *CS0->charset_list; + } + else if ((Uchar)*src == SS2) { /* half-kana (CS2) */ + if (KANA_CODESET >= codeset_num) + return -1; + charset = *CS2->charset_list; + src++; + (*from_left)--; + } + else if ((Uchar)*src == SS3) { /* user-def */ + if (USERDEF_CODESET >= codeset_num) + return -1; + charset = *CS3->charset_list; + src++; + (*from_left)--; + } + else { /* Kanji (CS1) */ + if (KANJI_CODESET >= codeset_num) + return -1; + charset = *CS1->charset_list; + } + + if(*from_left < charset->char_size || *to_left < charset->char_size) + return -1; + + min_ch = 0x20; + if (charset->set_size == 94) + if (charset->char_size > 1 || charset->side == XlcGR) + min_ch = 0x21; + + length = charset->char_size; + do { + if(BADCHAR(min_ch, *src)) { + unconv_num++; + break; + } + switch (charset->side) { + case XlcGL: + *dst++ = BIT8OFF(*src++); + break; + case XlcGR: + *dst++ = BIT8ON(*src++); + break; + default: + *dst++ = *src++; + break; + } + } while (--length); + + if (unconv_num) + src += charset->char_size - length; + + *to = dst; + *from = src; + *from_left -= charset->char_size; + *to_left -= charset->char_size; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return unconv_num; +} + + +static int +euc_mbstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + char *tmp_from, *tmp_to; + int tmp_from_left, tmp_to_left; + XlcCharSet charset, tmp_charset; + XPointer tmp_args[1]; + int unconv_num = 0, ret; + + +/* Determine the charset of the segment and convert one characater: */ + + tmp_args[0] = (XPointer) &charset; /* charset from euc_mbtocs() */ + while + ((ret = euc_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0) + unconv_num += ret; + if ( ret < 0 ) + return ret; + + tmp_from = *from; + tmp_from_left = *from_left; + tmp_to_left = *to_left; + tmp_to = *to; + + +/* Convert remainder of the segment: */ + + tmp_args[0] = (XPointer) &tmp_charset; + while( (ret = euc_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to, + &tmp_to_left, tmp_args, 1)) >= 0 ) { + + if (ret > 0) { + unconv_num += ret; + continue; + } + + if (tmp_charset != charset) /* quit on end of segment */ + break; + + *from = tmp_from; + *from_left = tmp_from_left; + *to = tmp_to; + *to_left = tmp_to_left; + } + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return unconv_num; +} + + +static int +euc_wcstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + wchar_t *wcptr = (wchar_t *) *from; + char *bufptr = (char *) *to; + wchar_t wch; + char *tmpptr; + int length; + CodeSet codeset; + Ulong wc_encoding; + int unconv_num = 0; + int wcstr_len = *from_left, buf_len = *to_left; + + + if (!(codeset = wc_codeset(lcd, *wcptr))) + return -1; + + wc_encoding = codeset->wc_encoding; + + if (wcstr_len < buf_len / codeset->length) + buf_len = wcstr_len * codeset->length; + + for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { + wch = *wcptr; + + if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding) + break; + + length = codeset->length; + + buf_len -= length; + bufptr += length; + tmpptr = bufptr - 1; + + while (length--) { + *tmpptr-- = codeset->length == 1 && codeset->side == XlcGR ? + BIT8ON(wch) : BIT8OFF(wch); + wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits); + } + } + + if (num_args > 0) + *((XlcCharSet *) args[0]) = *codeset->charset_list; + + *from_left -= wcptr - (wchar_t *) *from; + *from = (XPointer) wcptr; + + *to_left -= bufptr - *to; + *to = bufptr; + + return 0; +} + + +static int +euc_cstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + char *csptr = *from; + char *bufptr = *to; + int csstr_len = *from_left; + int buf_len = *to_left; + int length; + CodeSet codeset; + int cvt_length; + + + if (num_args < 1) + return -1; + + if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]))) + return -1; + + cvt_length = 0; + csstr_len /= codeset->length; + buf_len /= codeset->length; + + if (codeset->parse_info) + csstr_len *= 2; + + if (csstr_len < buf_len) + buf_len = csstr_len; + + cvt_length += buf_len * codeset->length; + + if (bufptr) { + while (buf_len--) { + if (codeset->parse_info) /* put out SS2 or SS3 */ + *bufptr++ = *codeset->parse_info->encoding; + + length = codeset->length; + while (length--) + *bufptr++ = codeset->side == XlcGR ? + BIT8ON(*csptr++) : BIT8OFF(*csptr++); + } + } + + *from_left -= csptr - *from; + *from = csptr; + if (bufptr) + *to += cvt_length; + *to_left -= cvt_length; + + return 0; +} + + +static int +euc_cstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + char *csptr = *from; + wchar_t *bufptr = (wchar_t *) *to; + wchar_t *toptr = (wchar_t *) *to; + int csstr_len = *from_left; + int buf_len = *to_left; + wchar_t wch; + int length; + Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits); + CodeSet codeset; + + + if (num_args < 1) + return -1; + + if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]))) + return -1; + + csstr_len /= codeset->length; + if (csstr_len < buf_len) + buf_len = csstr_len; + *to_left -= buf_len; + + if (bufptr) { + + toptr += buf_len; + *to = (XPointer) toptr; + + while (buf_len--) { + + wch = (wchar_t) BIT8OFF(*csptr); + csptr++; + + length = codeset->length - 1; + while (length--) { + wch = (wch << wc_shift_bits) | BIT8OFF(*csptr); + csptr++; + } + *bufptr++ = wch | codeset->wc_encoding; + } + } + *from_left -= csptr - *from; + *from = csptr; + + return 0; +} + + +static CodeSet +wc_codeset(XLCd lcd, wchar_t wch) +{ + + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int end = XLC_GENERIC(lcd, codeset_num); + Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask)); + + for (; --end >= 0; codesets++) + if ( widech == (*codesets)->wc_encoding ) + return *codesets; + + return NULL; +} + + +static CodeSet +GetCodeSetFromCharSet(XLCd lcd, XlcCharSet charset) +{ + CodeSet *codeset = XLC_GENERIC(lcd, codeset_list); + XlcCharSet *charset_list; + int codeset_num, num_charsets; + + codeset_num = XLC_GENERIC(lcd, codeset_num); + + for ( ; codeset_num-- > 0; codeset++) { + num_charsets = (*codeset)->num_charsets; + charset_list = (*codeset)->charset_list; + + for ( ; num_charsets-- > 0; charset_list++) + if (*charset_list == charset) + return *codeset; + } + + return (CodeSet) NULL; +} + + +static XlcConv +create_conv(XLCd lcd, XlcConvMethods methods) +{ + XlcConv conv; + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == NULL) + return (XlcConv) NULL; + + conv->methods = methods; + conv->state = (XPointer) lcd; + return conv; +} + + +/* + * Stripped down Direct CT converters for EUC + */ + +typedef struct _CTDataRec { + int side; + int length; + char *name; + Ulong wc_encoding; + char sshift; + char *ct_encoding; + int ct_encoding_len; + int set_size; + Uchar min_ch; + Uchar ct_type; +} CTDataRec, *CTData; + +typedef struct _StateRec { + CTData GL_charset; + CTData GR_charset; + CTData charset; +} StateRec, *State; + +static enum { CT_STD, CT_NSTD, CT_DIR, CT_EXT0, CT_EXT1, CT_EXT2, CT_VER } + ct_types; + +static CTDataRec ctdata[] = +{ + { XlcGL, 1, "ISO8859-1:GL", 0, 0, "\033(B" , 3, 0, 0, CT_STD }, + { XlcGR, 1, "ISO8859-1:GR", 0, 0, "\033-A" , 3, 0, 0, CT_STD }, + { XlcGL, 1, "JISX0201.1976-0:GL", 0, 0, "\033(J" , 3, 0, 0, CT_STD }, + { XlcGR, 1, "JISX0201.1976-0:GR", 0, 0, "\033)I" , 3, 0, 0, CT_STD }, + { XlcGL, 2, "JISX0208.1983-0:GL", 0, 0, "\033$(B" , 4, 0, 0, CT_STD }, + { XlcGR, 2, "JISX0208.1983-0:GR", 0, 0, "\033$)B" , 4, 0, 0, CT_STD }, + { XlcGL, 2, "JISX0212.1990-0:GL", 0, 0, "\033$(D" , 4, 0, 0, CT_STD }, + { XlcGR, 2, "JISX0212.1990-0:GR", 0, 0, "\033$)D" , 4, 0, 0, CT_STD }, + { XlcUnknown, 0, "Ignore-Ext-Status?", 0, 0, "\033#" , 2, 0, 0, CT_VER }, + { XlcUnknown, 0, "NonStd-?-OctetChar", 0, 0, "\033%/0" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 1, "NonStd-1-OctetChar", 0, 0, "\033%/1" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 2, "NonStd-2-OctetChar", 0, 0, "\033%/2" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 3, "NonStd-3-OctetChar", 0, 0, "\033%/3" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 4, "NonStd-4-OctetChar", 0, 0, "\033%/4" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 0, "Extension-2" , 0, 0, "\033%/" , 3, 0, 0, CT_EXT2 }, + { XlcUnknown, 0, "Extension-0" , 0, 0, "\033" , 1, 0, 0, CT_EXT0 }, + { XlcUnknown, 0, "Begin-L-to-R-Text", 0, 0, "\2331]" , 3, 0, 0, CT_DIR }, + { XlcUnknown, 0, "Begin-R-to-L-Text", 0, 0, "\2332]" , 3, 0, 0, CT_DIR }, + { XlcUnknown, 0, "End-Of-String", 0, 0, "\233]" , 2, 0, 0, CT_DIR }, + { XlcUnknown, 0, "Extension-1" , 0, 0, "\233" , 1, 0, 0, CT_EXT1 }, +}; + +/* Note on above table: euc_ctstombs() and euc_ctstowcs() parser depends on + * certain table entries occurring in decreasing string length-- + * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries. + * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries. + */ + +static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1; +static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)]; +static enum { Ascii, Kanji, Kana, Userdef } cs_nums; + + +/* + * initCTptr(): Set ctdptr[] to point at ctdata[], indexed by codeset_num. + */ +static void +initCTptr(XLCd lcd) +{ + int num_codesets = XLC_GENERIC(lcd, codeset_num); + int num_charsets; + int i, j; + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + CodeSet codeset; + XlcCharSet charset; + CTData ctdp = ctdata; + + ctdptr[Ascii] = &ctdata[0]; /* failsafe */ + + for (i = 0; i < num_codesets; i++) { + + codeset = codesets[i]; + num_charsets = codeset->num_charsets; + + for (j = 0; j < num_charsets; j++) { + + charset = codeset->charset_list[j]; + + for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++) + + if (! strcmp(ctdp->name, charset->name)) { + + ctdptr[codeset->cs_num] = ctdp; + + ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding; + + ctdptr[codeset->cs_num]->set_size = + charset->set_size; + + ctdptr[codeset->cs_num]->min_ch = + charset->set_size == 94 && + (ctdptr[codeset->cs_num]->length > 1 || + ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20; + + if (codeset->parse_info) { + ctdptr[codeset->cs_num]->sshift = + *codeset->parse_info->encoding; + } + + break; + } + } + } +} + + +#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++; +#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++; + +static int +euc_ctstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits); + XPointer inbufptr = *from; + XPointer inbuf_base; + wchar_t *outbufptr = (wchar_t *) *to; + wchar_t *outbuf_base = outbufptr; + int clen, length; + int num_conv; + int unconv_num = 0; + unsigned int ct_seglen = 0; + Uchar ct_type = 0; + int shift_mult; + wchar_t wc_tmp; + wchar_t wch; + Ulong wc_encoding; + CTData ctdp = ctdata; + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length) + { + ct_type = CT_STD; + if (*inbufptr == '\033' || *inbufptr == (char)'\233') { + for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { + + if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len)) + { + inbufptr += ctdp->ct_encoding_len; + (*from_left) -= ctdp->ct_encoding_len; + if (ctdp->length) { + length = ctdp->length; + if( *from_left < length ) { + *to = (XPointer)outbufptr; + *to_left -= outbufptr - outbuf_base; + return( unconv_num + *from_left ); + } + } + ct_type = ctdp->ct_type; + break; + } + } + if (ctdp > ctd_endp) /* failed to match CT sequence */ + unconv_num++; + } + +/* The following code insures that non-standard encodings, direction, extension, + * and version strings are ignored; subject to change in future. + */ + switch (ct_type) { + case CT_STD: + break; + case CT_EXT2: + inbufptr++; + (*from_left)--; + case CT_NSTD: + ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2; + inbufptr += ct_seglen; + (*from_left) -= ct_seglen; + continue; + case CT_EXT0: + inbuf_base = inbufptr; + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + *(from_left) -= ct_seglen; + continue; + case CT_EXT1: + inbuf_base = inbufptr; + SKIP_P(inbufptr); + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + *(from_left) -= ct_seglen; + continue; + case CT_DIR: + continue; + case CT_VER: + inbufptr += 2; + *(from_left) -= 2; + continue; + } + + wc_encoding = (ctdp == ctdptr[Kana] && isleftside(*inbufptr)) ? + ctdptr[Ascii]->wc_encoding: ctdp->wc_encoding; + + shift_mult = length - 1; + wch = (wchar_t)0; + clen = length; + + do { + wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult); + wch |= wc_tmp; + shift_mult--; + } while (--clen); + + *outbufptr++ = wch | wc_encoding; + } + + *to = (XPointer)outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; + +} + + +#define byte1 (length == codeset->length - 1) +#define byte2 (byte1 == 0) +#define kanji (codeset->cs_num == 1) +#define kana (codeset->cs_num == 2) +#define userdef (codeset->cs_num == 3) + +static int +euc_wcstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ct_len = *to_left; + wchar_t *inbufptr = (wchar_t *) *from; + char *ctptr = *to; + XPointer ct_base = ctptr; + wchar_t wch; + int length; + int unconv_num = 0; + Uchar tmp; + Uchar t1 = 0, t2; + int num_conv; + + StateRec ct_state; + XLCd lcd = (XLCd)conv->state; + CTData charset; + CodeSet codeset; + Ulong wc_encoding_mask = XLC_GENERIC(lcd, wc_encode_mask); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + + +/* Initial State: */ + ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */ + ct_state.GR_charset = NULL; + + if (*from_left > *to_left) + *from_left = *to_left; + + for (; *from_left > 0 ; (*from_left)-- ) { + + wch = *inbufptr++; + + if (!(codeset = wc_codeset(lcd, wch))) { + unconv_num++; + (*from_left)--; + continue; + } + + charset = ctdptr[codeset->cs_num]; + + length = codeset->length; + wch ^= (wchar_t)codeset->wc_encoding; + + if ( (charset->side == XlcGR && charset != ct_state.GR_charset) || + (charset->side == XlcGL && charset != ct_state.GL_charset) ) { + + ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len; + + if (ct_len < 0) { + unconv_num++; + break; + } + + if (ctptr) { + strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding); + ctptr += ctdptr[codeset->cs_num]->ct_encoding_len; + } + } + + if (charset->side == XlcGR) + ct_state.GR_charset = charset; + else if (charset->side == XlcGL) + ct_state.GL_charset = charset; + + do { + + length--; + tmp = wch>>(wchar_t)( (Ulong)length * wc_shift); + + if (kana) { + if (BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + *ctptr++ = (char)BIT8ON(tmp); + } + + else if (byte1 && (kanji || userdef)) + t1 = tmp; + + else if (byte2 && (kanji || userdef)) { + if (BADCHAR(charset->min_ch, (char)t1) || + BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + *ctptr++ = (char)t1; + *ctptr++ = (char)tmp; + } + + else { + if (BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + *ctptr++ = (char)tmp; + } + + + } while (length); + + } /* end for */ + + *to = (XPointer)ctptr; + + if ((num_conv = (int)(ctptr - ct_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; +} +#undef byte1 +#undef byte2 +#undef kana +#undef kanji +#undef userdef + + +#define byte1 (ctdp->length == clen) +#define kana (ctdp == ctdptr[Kana] && isrightside(*inbufptr)) +#define kanji (ctdp == ctdptr[Kanji]) +#define userdef (ctdp == ctdptr[Userdef]) + +static int +euc_ctstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XPointer inbufptr = *from; + XPointer outbufptr = *to; + XPointer inbuf_base; + XPointer outbuf_base = outbufptr; + int clen, length; + int unconv_num = 0; + int num_conv; + unsigned int ct_seglen = 0; + Uchar ct_type = 0; + CTData ctdp = &ctdata[0]; /* default */ + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length) + { + ct_type = CT_STD; + if (*inbufptr == '\033' || *inbufptr == (char)'\233') { + + for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { + + if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len)) + { + inbufptr += ctdp->ct_encoding_len; + (*from_left) -= ctdp->ct_encoding_len - 1; + if (ctdp->length) { + length = ctdp->length; + if( *from_left < length ) { + *to = (XPointer)outbufptr; + *to_left -= outbufptr - outbuf_base; + return( unconv_num + *from_left ); + } + } + ct_type = ctdp->ct_type; + break; + } + } + if (ctdp > ctd_endp) /* failed to match CT sequence */ + unconv_num++; + } + +/* The following code insures that non-standard encodings, direction, extension, + * and version strings are ignored; subject to change in future. + */ + switch (ct_type) { + case CT_STD: + break; + case CT_EXT2: + inbufptr++; + (*from_left)--; + case CT_NSTD: + ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2; + inbufptr += ct_seglen; + (*from_left) -= ct_seglen; + continue; + case CT_EXT0: + inbuf_base = inbufptr; + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + *(from_left) -= ct_seglen; + continue; + case CT_EXT1: + inbuf_base = inbufptr; + SKIP_P(inbufptr); + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + *(from_left) -= ct_seglen; + continue; + case CT_DIR: + continue; + case CT_VER: + inbufptr += 2; + *(from_left) -= 2; + continue; + } + + clen = length; + do { + + if (byte1) + if (kanji) { + *inbufptr = BIT8ON(*inbufptr); + *(inbufptr+1) = BIT8ON(*(inbufptr+1)); + } + else if (kana || userdef) + *outbufptr++ = ctdp->sshift; + + *outbufptr++ = *inbufptr++; + + } while (--clen); + } + + *to = outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; + +} +#undef byte1 +#undef kana +#undef kanji +#undef userdef + + +static int +euc_mbstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ct_len = *to_left; + int cs_num; + int clen, length; + int unconv_num = 0; + int num_conv; + XPointer inbufptr = *from; + char *ctptr = *to; + XPointer ct_base = ctptr; + + StateRec ct_state; + CTData charset; + XLCd lcd = (XLCd) conv->state; + int codeset_num = XLC_GENERIC(lcd, codeset_num); + + +/* Initial State: */ + ct_state.GL_charset = ctdptr[Ascii]; + ct_state.GR_charset = NULL; + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (;*from_left > 0; (*from_left) -= length) { + + if (isleftside(*inbufptr)) { /* 7-bit (CS0) */ + if (ASCII_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Ascii; + charset = ctdptr[Ascii]; + } + else if ((Uchar)*inbufptr == SS2) { /* Kana */ + if (KANA_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Kana; + charset = ctdptr[Kana]; + inbufptr++; + (*from_left)--; + } + else if ((Uchar)*inbufptr == SS3) { /* Userdef */ + if (USERDEF_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Userdef; + charset = ctdptr[Userdef]; + inbufptr++; + (*from_left)--; + } + else { + if (KANJI_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Kanji; + charset = ctdptr[Kanji]; + } + + length = charset->length; + + if (BADCHAR(charset->min_ch, *inbufptr)) + continue; + + if ( (charset->side == XlcGR && charset != ct_state.GR_charset) || + (charset->side == XlcGL && charset != ct_state.GL_charset) ) { + + ct_len -= ctdptr[cs_num]->ct_encoding_len; + if (ct_len < 0) { + unconv_num++; + break; + } + + if (ctptr) { + strcpy(ctptr, ctdptr[cs_num]->ct_encoding); + ctptr += ctdptr[cs_num]->ct_encoding_len; + } + } + + if (charset->side == XlcGR) + ct_state.GR_charset = charset; + else if (charset->side == XlcGL) + ct_state.GL_charset = charset; + + clen = length; + do { + *ctptr++ = charset == ct_state.GR_charset ? + BIT8ON(*inbufptr++) : BIT8OFF(*inbufptr++); + } while (--clen); + } + + *to = (XPointer)ctptr; + + if ((num_conv = (int)(ctptr - ct_base)) > 0) + (*to_left) -= num_conv; + return unconv_num; + +} + + +static void +close_converter(XlcConv conv) +{ + Xfree((char *) conv); +} + +enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS, + CTSTOWCS, CTSTOMBS, WCSTOCTS, MBSTOCTS }; + +static XlcConvMethodsRec conv_methods[] = { + {close_converter, euc_mbstocs, NULL }, + {close_converter, euc_wcstocs, NULL }, + {close_converter, euc_mbtocs, NULL }, + {close_converter, euc_cstombs, NULL }, + {close_converter, euc_cstowcs, NULL }, + {close_converter, euc_mbstowcs, NULL }, + {close_converter, euc_wcstombs, NULL }, + {close_converter, euc_ctstowcs, NULL }, + {close_converter, euc_ctstombs, NULL }, + {close_converter, euc_wcstocts, NULL }, + {close_converter, euc_mbstocts, NULL }, +}; + + +static XlcConv +open_mbstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOCS]); +} + +static XlcConv +open_wcstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOCS]); +} + +static XlcConv +open_mbtocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBTOCS]); +} + +static XlcConv +open_cstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CSTOMBS]); +} + +static XlcConv +open_cstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CSTOWCS]); +} + +static XlcConv +open_mbstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOWCS]); +} + +static XlcConv +open_wcstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOMBS]); +} + +static XlcConv +open_ctstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CTSTOWCS]); +} + +static XlcConv +open_ctstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CTSTOMBS]); +} + +static XlcConv +open_wcstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOCTS]); +} + +static XlcConv +open_mbstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOCTS]); +} + +XLCd +_fallcEucLoader(char *name) +{ + XLCd lcd; + + lcd = _fallcCreateLC(name, _fallcGenericMethods); + if (lcd == NULL) + return lcd; + + + if ((_fallcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "euc"))) { + _fallcDestroyLC(lcd); + return (XLCd) NULL; + } + + initCTptr(lcd); + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs); + +#ifndef FORCE_INDIRECT_CONVERTER + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs); + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs); +#endif + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcFile.c b/cde/programs/dtudcfonted/libfal/_fallcFile.c new file mode 100644 index 000000000..9bb125398 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcFile.c @@ -0,0 +1,357 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcFile.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:36 */ +/* $XConsortium: _fallcFile.c /main/1 1996/04/08 15:16:48 cde-fuj $ */ +/* + * + * Copyright IBM Corporation 1993 + * + * All Rights Reserved + * + * License to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ +#include <stdio.h> +#include <ctype.h> +#include "_fallibint.h" +#include "_fallcPubI.h" +#include <X11/Xos.h> + +/************************************************************************/ + +#define iscomment(ch) ((ch) == '#' || (ch) == '\0') +#define isreadable(f) ((access((f), R_OK) != -1) ? 1 : 0) +/* +#define isspace(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n') +*/ + +static int +parse_line(char *line, char **argv, int argsize) +{ + int argc = 0; + char *p = line; + + while(argc < argsize){ + while(isspace(*p)){ + ++p; + } + if(*p == '\0'){ + break; + } + argv[argc++] = p; + while(! isspace(*p) && *p != '\0'){ + ++p; + } + if(*p == '\0'){ + break; + } + *p++ = '\0'; + } + + return argc; +} + +#ifndef XLOCALEDIR +#define XLOCALEDIR "/usr/lib/X11/locale" +#endif + +static void +xlocaledir(char *path) +{ + char *dir, *p = path; + int len; + + dir = getenv("XLOCALEDIR"); + if(dir != NULL){ + len = strlen(dir); + strcpy(p, dir); + p[len++] = ':'; + p += len; + } + strcpy(p, XLOCALEDIR); +} + +static int +parse_path(char *path, char **argv, int argsize) +{ + char *p = path; + int i, n; + + while((p = strchr(p, ':')) != NULL){ + *p = ' '; /* place space on delimter */ + } + n = parse_line(path, argv, argsize); + if(n == 0){ + return 0; + } + for(i = 0; i < n; ++i){ + int len; + p = argv[i]; + len = strlen(p); + if(p[len - 1] == '/'){ + /* eliminate slash */ + p[len - 1] = '\0'; + } + } + return n; +} + +enum { LtoR, RtoL }; + +static char * +_XlcResolveName(char *lc_name, char *file_name, int direction)/*mapping direction*/ +{ + FILE *fp; + char buf[BUFSIZE], *name = NULL; + + fp = fopen(file_name, "r"); + if(fp == (FILE *)NULL){ + return NULL; + } + + while(fgets(buf, BUFSIZE, fp) != NULL){ + char *p = buf; + int n; + char *args[2], *from, *to; + while(isspace(*p)){ + ++p; + } + if(iscomment(*p)){ + continue; + } + n = parse_line(p, args, 2); /* get first 2 fields */ + if(n != 2){ + continue; + } + if(direction == LtoR){ + from = args[0], to = args[1]; /* left to right */ + }else{ + from = args[1], to = args[0]; /* right to left */ + } + if(! strcmp(from, lc_name)){ + name = Xmalloc(strlen(to) + 1); + if(name != NULL){ + strcpy(name, to); + } + break; + } + } + if(fp != (FILE *)NULL){ + fclose(fp); + } + return name; +} + +/* +#define isupper(ch) ('A' <= (ch) && (ch) <= 'Z') +#define tolower(ch) ((ch) - 'A' + 'a') +*/ +static char * +lowercase(char *dst, char *src) +{ + char *s, *t; + + for(s = src, t = dst; *s; ++s, ++t){ + *t = isupper(*s) ? tolower(*s) : *s; + } + *t = '\0'; + return dst; +} + +/************************************************************************/ +char * +_fallcFileName(XLCd lcd, char *category) +{ + char lc_name[BUFSIZE]; + char cat[BUFSIZE], dir[BUFSIZE]; + int i, n; + char *args[256]; + char *file_name = NULL; + + if(lcd == (XLCd)NULL){ + return NULL; + } + + if(! _fallcResolveLocaleName(XLC_PUBLIC(lcd, siname), lc_name, + NULL, NULL, NULL)){ + return NULL; + } + + lowercase(cat, category); + xlocaledir(dir); + n = parse_path(dir, args, 256); + for(i = 0; i < n; ++i){ + char buf[BUFSIZE], *name; + sprintf(buf, "%s/%s.dir", args[i], cat); + name = _XlcResolveName(lc_name, buf, RtoL); + if(name == NULL){ + continue; + } + if(*name == '/'){ + /* supposed to be absolute path name */ + file_name = name; + }else{ + sprintf(buf, "%s/%s", args[i], name); + Xfree(name); + file_name = Xmalloc(strlen(buf) + 1); + if(file_name == NULL){ + break; + } + strcpy(file_name, buf); + } + if(isreadable(file_name)){ + break; + } + Xfree(file_name); + file_name = NULL; + /* Then, try with next dir */ + } + return file_name; +} + +/************************************************************************/ +#ifndef LOCALE_ALIAS +#define LOCALE_ALIAS "locale.alias" +#endif + +int +_fallcResolveLocaleName( + char *lc_name, + char *full_name, + char *language, + char *territory, + char *codeset) +{ + char dir[BUFSIZE], buf[BUFSIZE], *name = NULL; + int i, n; + char *args[256]; + + xlocaledir(dir); + n = parse_path(dir, args, 256); + for(i = 0; i < n; ++i){ + sprintf(buf, "%s/%s", args[i], LOCALE_ALIAS); + name = _XlcResolveName(lc_name, buf, LtoR); + if(name != NULL){ + break; + } + } + + if(name != NULL){ + snprintf(buf, sizeof(buf), "%s", name); + Xfree(name); + }else{ + snprintf(buf, sizeof(buf), "%s", lc_name); + } + if(full_name != NULL){ + strcpy(full_name, buf); + } + + if(language || territory || codeset){ + char *ptr, *name_p; + /* + * Decompose locale name + */ + if(language) *language = '\0'; + if(territory) *territory = '\0'; + if(codeset) *codeset = '\0'; + + name_p = buf; + ptr = language; + while (1) { + if (*name_p == '_') { + if (ptr) + *ptr = '\0'; + ptr = territory; + } else if (*name_p == '.') { + if (ptr) + *ptr = '\0'; + ptr = codeset; + } else { + if (ptr) + *ptr++ = *name_p; + if (*name_p == '\0') + break; + } + name_p++; + } + } + + return (buf[0] != '\0') ? 1 : 0; +} + +/************************************************************************/ +#ifndef LOCALE_DIR +#define LOCALE_DIR "locale.dir" +#endif + +int +_fallcResolveDBName(char *lc_name, char *file_name) +{ + char dir[BUFSIZE], buf[BUFSIZE], *name = NULL; + int i, n; + char *args[256]; + + xlocaledir(dir); + n = parse_path(dir, args, 256); + for(i = 0; i < n; ++i){ + sprintf(buf, "%s/%s", args[i], LOCALE_DIR); + name = _XlcResolveName(lc_name, buf, RtoL); + if(name != NULL){ + break; + } + } + if(name == NULL){ + return 0; + } + strcpy(buf, name); + Xfree(name); + if(file_name != NULL){ + strcpy(file_name, buf); + } + return 1; +} + +/************************************************************************/ +int +_fallcResolveI18NPath(char *path_name) +{ + if(path_name != NULL){ + xlocaledir(path_name); + } + return 1; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcGenConv.c b/cde/programs/dtudcfonted/libfal/_fallcGenConv.c new file mode 100644 index 000000000..6e577c6a3 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcGenConv.c @@ -0,0 +1,2293 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcGenConv.c 1.5 - Fujitsu source for CDEnext 96/03/14 15:45:41 */ +/* $XConsortium: _fallcGenConv.c /main/1 1996/04/08 15:17:00 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Modifier: Masayoshi Shimamura FUJITSU LIMITED + * + */ + + +#include "_fallibint.h" +#include "_fallcGeneric.h" +#include <stdio.h> + +typedef struct _CTDataRec { + char *name; + char *encoding; /* Compound Text encoding */ +} CTDataRec, *CTData; + +static CTDataRec default_ct_data[] = +{ + { "ISO8859-1:GL", "\033(B" }, + { "ISO8859-1:GR", "\033-A" }, + { "ISO8859-2:GR", "\033-B" }, + { "ISO8859-3:GR", "\033-C" }, + { "ISO8859-4:GR", "\033-D" }, + { "ISO8859-7:GR", "\033-F" }, + { "ISO8859-6:GR", "\033-G" }, + { "ISO8859-8:GR", "\033-H" }, + { "ISO8859-5:GR", "\033-L" }, + { "ISO8859-9:GR", "\033-M" }, + { "JISX0201.1976-0:GL", "\033(J" }, + { "JISX0201.1976-0:GR", "\033)I" }, + + { "GB2312.1980-0:GL", "\033$(A" }, + { "GB2312.1980-0:GR", "\033$)A" }, + { "JISX0208.1983-0:GL", "\033$(B" }, + { "JISX0208.1983-0:GR", "\033$)B" }, + { "KSC5601.1987-0:GL", "\033$(C" }, + { "KSC5601.1987-0:GR", "\033$)C" }, +} ; + +static CTDataRec directionality_data[] = +{ + { "BEGIN_LEFT-TO-RIGHT_TEXT", "\2331]" }, + { "BEGIN_RIGHT-TO-LEFT_TEXT", "\2332]" }, + { "END_OF_STRING", "\233]" }, +}; + +typedef struct _StateRec { + XLCd lcd; + XlcCharSet charset; /* charset of current state */ + XlcCharSet GL_charset; /* charset of initial state in GL */ + XlcCharSet GR_charset; /* charset of initial state in GR */ +} StateRec, *State; + +#define GR 0x80 /* begins right-side (non-ascii) region */ +#define GL 0x7f /* ends left-side (ascii) region */ +#define ESC 0x1b +#define CSI 0x9b +#define STX 0x02 + +#define isleftside(c) (((c) & GR) ? 0 : 1) +#define isrightside(c) (!isleftside(c)) + +/* -------------------------------------------------------------------------- */ +/* Misc */ +/* -------------------------------------------------------------------------- */ + +static int +compare(char *src, char *encoding, int length) +{ + char *start = src; + + while (length-- > 0) { + if (*src++ != *encoding++) + return 0; + if (*encoding == '\0') + return src - start; + } + + return 0; +} + +static unsigned long +conv_to_dest(Conversion conv, unsigned long code) +{ + int i; + int conv_num = conv->conv_num; + FontScope convlist = conv->convlist; + + for (i = 0; i < conv_num; i++) { + if (convlist[i].start <= code && code <= convlist[i].end) { + switch (convlist[i].shift_direction) { + case '+': + return(code + convlist[i].shift); + case '-': + return(code - convlist[i].shift); + default: + return(code); + } + } + } + + return(code); +} + +static unsigned long +conv_to_source(Conversion conv, unsigned long code) +{ + int i; + int conv_num; + FontScope convlist; + unsigned long start_p; + unsigned long start_m; + unsigned long end_p; + unsigned long end_m; + + if (!conv) + return(code); + + conv_num = conv->conv_num; + convlist = conv->convlist; + + for (i = 0; i < conv_num; i++) { + start_p = convlist[i].start + convlist[i].shift; + start_m = convlist[i].start - convlist[i].shift; + end_p = convlist[i].end + convlist[i].shift; + end_m = convlist[i].end - convlist[i].shift; + + switch (convlist[i].shift_direction) { + case '+': + if (start_p <= code && code <= end_p) + return(code - convlist[i].shift); + break; + case '-': + if (start_m <= code && code <= end_m) + return(code + convlist[i].shift); + break; + default: + continue; + } + } + + return(code); +} + +static unsigned long +mb_to_gi(unsigned long mb, CodeSet codeset) +{ + int i; + unsigned long mb_tmp, mask = 0; + + if (codeset->mbconv) { + mb_tmp = conv_to_dest(codeset->mbconv, mb); + if (mb_tmp != mb) + return(mb_tmp); + } + + if (codeset->side == XlcC0 || codeset->side == XlcGL || + codeset->side == XlcC1 || codeset->side == XlcGR) { + + for (i = 0; i < codeset->length; i++) + mask = (mask << 8) | GL; + mb = mb & mask; + } + + return(mb); +} + +static unsigned long +gi_to_mb(unsigned long glyph_index, CodeSet codeset) +{ + int i; + unsigned long mask = 0; + + if (codeset->side == XlcC1 || codeset->side == XlcGR) { + for (i = 0; i < codeset->length; i++) + mask = (mask << 8) | GR; + glyph_index = glyph_index | mask; + } + + if (codeset->mbconv) + return( conv_to_source(codeset->mbconv, glyph_index) ); + + return(glyph_index); +} + +static Bool +gi_to_wc(XLCd lcd, unsigned long glyph_index, CodeSet codeset, wchar_t *wc) +{ + unsigned char mask = 0; + unsigned long wc_encoding = codeset->wc_encoding; + int i, length = codeset->length; + unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits); + + for (i = wc_shift_bits; i > 0; i--) + mask = (mask << 1) | 0x01; + + for (*wc = 0, length--; length >= 0; length--) + *wc = (*wc << wc_shift_bits) | ((glyph_index >> (length * 8 )) & mask); + + *wc = *wc | wc_encoding; + + return(True); +} + +static Bool +wc_to_gi(XLCd lcd, wchar_t wc, unsigned long *glyph_index, CodeSet *codeset) +{ + int i; + unsigned char mask = 0; + unsigned long wc_encoding; + unsigned long wc_encode_mask = XLC_GENERIC(lcd, wc_encode_mask); + unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + + wc_encoding = wc & wc_encode_mask; + for (*codeset = NULL, i = 0; i < codeset_num; i++) { + if (wc_encoding == codeset_list[i]->wc_encoding) { + *codeset = codeset_list[i]; + break; + } + } + if (*codeset == NULL) + return(False); + + for (i = wc_shift_bits; i > 0; i--) + mask = (mask << 1) | 0x01; + + wc = wc & ~wc_encode_mask; + for (*glyph_index = 0, i = (*codeset)->length - 1; i >= 0; i--) + *glyph_index = (*glyph_index << 8) | + ( ((unsigned long)wc >> (i * wc_shift_bits)) & mask ); + + return(True); +} + +static CodeSet +byteM_parse_codeset(XLCd lcd, XPointer inbufptr) +{ + unsigned char ch; + CodeSet codeset; + ByteInfoList byteM; + ByteInfoListRec byteM_rec; + ByteInfo byteinfo; + ByteInfoRec byteinfo_rec; + Bool hit; + int i, j, k; + + int codeset_num = XLC_GENERIC(lcd, codeset_num); + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + + for (i = 0; i < codeset_num; i++) { + codeset = codeset_list[i]; + byteM = codeset->byteM; + if (codeset->side != XlcNONE || byteM == NULL) + continue; + + for (j = 0; j < codeset->length; j++) { + ch = *((unsigned char *)(inbufptr + j)); + byteM_rec = byteM[j]; + byteinfo = byteM_rec.byteinfo; + + for (hit=False,k=0; k < byteM_rec.byteinfo_num; k++) { + byteinfo_rec = byteinfo[k]; + if (byteinfo_rec.start <= ch && ch <= byteinfo_rec.end) { + hit = True; + break; + } + } + + if (!hit) + break; + } + + if (hit) + return(codeset); + } + + return(NULL); +} + +static CodeSet +GLGR_parse_codeset(XLCd lcd, unsigned char ch) +{ + int i; + CodeSet initial_state_GL = XLC_GENERIC(lcd, initial_state_GL); + CodeSet initial_state_GR = XLC_GENERIC(lcd, initial_state_GR); + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + + XlcSide side = XlcGL; + CodeSet codeset = initial_state_GL; + + if (isrightside(ch)) { + side = XlcGR; + codeset = initial_state_GR; + } + + if (codeset) + return(codeset); + + for (i = 0; i < codeset_num; i++) { + codeset = codeset_list[i]; + if (codeset->side == side) + return(codeset); + } + + return(NULL); +} + +static XlcCharSet +gi_parse_charset(unsigned long glyph_index, CodeSet codeset) +{ + int i; + size_t table_size = sizeof(default_ct_data) / sizeof(default_ct_data[0]); + XlcCharSet *charset_list = codeset->charset_list; + int num_charsets = codeset->num_charsets; + ExtdSegment ctextseg = codeset->ctextseg; + XlcCharSet charset; + int area_num; + FontScope area; + + /* lockup ct sequence */ + for (i = 0; i < num_charsets; i++) { + charset = charset_list[i]; + if (*charset->ct_sequence != '\0') + break; + } + if (i >= num_charsets) + return(NULL); + + /* Standard Character Set Encoding ? */ + for (i = 0; i < table_size; i++){ + if (compare(charset->ct_sequence, + default_ct_data[i].encoding, strlen(charset->ct_sequence))){ + if (!ctextseg) + return(charset); + + area = ctextseg->area; + area_num = ctextseg->area_num; + + for (i = 0; i < area_num; i++) { + + if (area[i].start <= glyph_index && glyph_index <= area[i].end) { + + charset = ctextseg->charset; + + if (*charset->ct_sequence == '\0') + return(NULL); + + break; + } + } + } + } + return(charset); +} + +static Bool +ct_parse_csi(XPointer inbufptr, int *ctr_seq_len) +{ + int i; + int num = sizeof(directionality_data) / sizeof(directionality_data[0]); + + for (i = 0; i < num; i++) { + if ( !(*ctr_seq_len = strlen(directionality_data[i].encoding)) ) + continue; + + if ( strncmp(inbufptr, directionality_data[i].encoding, + *ctr_seq_len) == 0) + return(True); + } + + return(False); +} + +static int +cmp_esc_sequence(XPointer inbufptr, char *ct_sequence, char *encoding_name) +{ + size_t table_size = sizeof(default_ct_data) / sizeof(default_ct_data[0]); + int i, seq_len, name_len, total_len; + unsigned char byte_m, byte_l; + + /* check esc sequence */ + if ( !(seq_len = strlen(ct_sequence) ) ) + return(0); + if ( strncmp(inbufptr, ct_sequence, seq_len) != 0) + return(0); + + /* Standard Character Set Encoding ? */ + for (i = 0; i < table_size; i++) { + if (compare(ct_sequence, + default_ct_data[i].encoding, strlen(ct_sequence))) + return(seq_len); + } + + /* + * Non-Standard Character Set Encoding + * + * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ + * | esc sequence | M | L | encoding name | STX | + * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ + * 4bytes 1byte 1byte variable length 1byte + * | | + * +-----------------------------------------+ + * name length = ((M - 128) * 128) + (L - 128) + */ + + /* get length of encoding name */ + inbufptr += seq_len; + byte_m = *inbufptr++; + byte_l = *inbufptr++; + name_len = ((byte_m - 128) * 128) + (byte_l - 128); + total_len = seq_len + name_len; + + /* compare encoding names */ + if ( strncmp(inbufptr, encoding_name, name_len - 3) != 0 ) + return(0); + + /* check STX (Start of Text) */ + inbufptr = inbufptr + name_len - 3; + if ( *inbufptr != STX ) + return(0); + + return(total_len); +} + +static Bool +ct_parse_charset( + XLCd lcd, + XPointer inbufptr, + XlcCharSet *charset, + int *ctr_seq_len) +{ + int i, j; + ExtdSegment ctextseg; + int num_charsets; + XlcCharSet *charset_list; + CodeSet codeset; + int codeset_num = XLC_GENERIC(lcd, codeset_num); + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num); + SegConv segment_conv = XLC_GENERIC(lcd, segment_conv); + + + /* get charset from XLC_XLOCALE by escape sequence */ + + for (i = 0; i < codeset_num; i++) { + codeset = codeset_list[i]; + + num_charsets = codeset->num_charsets; + charset_list = codeset->charset_list; + ctextseg = codeset->ctextseg; + + for (j = 0; j < num_charsets; j++) { + *charset = charset_list[j]; + if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, + (*charset)->ct_sequence, (*charset)->encoding_name) ) + return(True); + } + + if (ctextseg) { + *charset = ctextseg->charset; + if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, + (*charset)->ct_sequence, (*charset)->encoding_name) ) + return(True); + } + } + + /* get charset from XLC_SEGMENTCONVERSION by escape sequence */ + + if (!segment_conv) + return(False); + + for (i = 0; i < segment_conv_num; i++) { + *charset = segment_conv[i].source; + if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, + (*charset)->ct_sequence, (*charset)->encoding_name) ) + return(True); + *charset = segment_conv[i].dest; + if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, + (*charset)->ct_sequence, (*charset)->encoding_name) ) + return(True); + } + + return(False); +} + +static Bool +segment_conversion(XLCd lcd, XlcCharSet *charset, unsigned long *glyph_index) +{ + int i; + int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num); + SegConv segment_conv = XLC_GENERIC(lcd, segment_conv); + FontScopeRec range; + ConversionRec conv_rec; + + if (!segment_conv) + return(True); + + for (i = 0; i < segment_conv_num; i++) { + if (segment_conv[i].source == *charset) + break; + } + + if (i >= segment_conv_num) + return(True); + + range = segment_conv[i].range; + if (*glyph_index < range.start || range.end < *glyph_index) + return(True); + + *charset = segment_conv[i].dest; + conv_rec.conv_num = segment_conv[i].conv_num; + conv_rec.convlist = segment_conv[i].conv; + *glyph_index = conv_to_dest(&conv_rec, *glyph_index); + + return(True); +} + +CodeSet +_fallcGetCodeSetFromName(XLCd lcd, char *name) +{ + int i, j; + XlcCharSet charset; + int num_charsets; + XlcCharSet *charset_list; + CodeSet codeset; + + int codeset_num = XLC_GENERIC(lcd, codeset_num); + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + + for (i = 0; i < codeset_num; i++) { + codeset = codeset_list[i]; + + num_charsets = codeset->num_charsets; + charset_list = codeset->charset_list; + + for (j = 0; j < num_charsets; j++) { + charset = charset_list[j]; + + if (!strlen(charset->name)) + continue; + if ( strcmp(charset->name, name) == 0) + return(codeset); + } + } + + return(NULL); +} + +static Bool +_XlcGetCodeSetFromCharSet( + XLCd lcd, + XlcCharSet charset, + CodeSet *codeset, + unsigned long *glyph_index) +{ + int i, j, num; + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + XlcCharSet *charset_list; + int codeset_num, num_charsets; + Conversion ctconv; + unsigned long glyph_index_tmp; + ExtdSegment ctextseg; + size_t table_size = sizeof(default_ct_data) / sizeof(default_ct_data[0]); + + codeset_num = XLC_GENERIC(lcd, codeset_num); + + for (num = 0 ; num < codeset_num; num++) { + *codeset = codeset_list[num]; + ctconv = (*codeset)->ctconv; + ctextseg = (*codeset)->ctextseg; + + num_charsets = (*codeset)->num_charsets; + charset_list = (*codeset)->charset_list; + + glyph_index_tmp = conv_to_source(ctconv, *glyph_index); + + /* Standard Character Set Encoding ? */ + for (i = 0; i < table_size; i++) { + if (compare(charset->ct_sequence, + default_ct_data[i].encoding, strlen(charset->ct_sequence))) + break; + } + + if (i < table_size) { + + /* Standard Character Set Encoding */ + if (glyph_index_tmp == *glyph_index) { + for (j = 0; j < num_charsets; j++) { + if (charset_list[j] == charset) { + goto end_loop; + } + } + } + + } else { + + /* Non-Standard Character Set Encoding */ + for (j = 0; j < num_charsets; j++) { + if (charset_list[j] == charset) { + goto end_loop; + } + } + + if (glyph_index_tmp != *glyph_index) { + if (ctextseg->charset == charset) { + goto end_loop; + } + } + + } + + } + +end_loop: + if (num < codeset_num) { + *glyph_index = glyph_index_tmp; + return(True); + } + + return(False); +} + +static Bool +check_string_encoding(CodeSet codeset) +{ + int i; + XlcCharSet charset; + XlcCharSet *charset_list = codeset->charset_list; + int num_charsets = codeset->num_charsets; + + for (i = 0; i < num_charsets; i++) { + charset = charset_list[i]; + if ( strcmp(charset->encoding_name, "ISO8859-1") == 0 || + charset->string_encoding) + return(True); + } + + return(False); +} + +/* -------------------------------------------------------------------------- */ +/* Init */ +/* -------------------------------------------------------------------------- */ + +static void +init_state(XlcConv conv) +{ + State state = (State) conv->state; + + /* for CT */ + state->charset = NULL; + state->GL_charset = _fallcGetCharSet("ISO8859-1:GL"); + state->GR_charset = _fallcGetCharSet("ISO8859-1:GR"); +} + +/* -------------------------------------------------------------------------- */ +/* Convert */ +/* -------------------------------------------------------------------------- */ + +static int +mbstowcs_org( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned char ch; + unsigned long mb = 0; + wchar_t wc; + + int length = 0, len_left = 0; + int unconv_num = 0; + int num; + Bool ss_flag = 0; + + CodeSet codeset = NULL; + ParseInfo parse_info; + + XPointer inbufptr = *from; + wchar_t *outbufptr = (wchar_t *) *to; + int from_size = *from_left; + + unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table); + ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list); + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + if (outbufptr) {*outbufptr++ = L'\0';} + (*to_left)--; + + /* error check */ + if (len_left) { + unconv_num += (length - len_left); + len_left = 0; + } + + continue; + } + + /* same mb char data */ + if (len_left){ + mb = (mb << 8) | ch; /* 1 byte left shift */ + len_left--; + + /* last of one mb char data */ + if (!len_left) { + gi_to_wc(lcd, mb_to_gi(mb, codeset), codeset, &wc); + if (outbufptr) {*outbufptr++ = wc;} + (*to_left)--; + } + } + + /* next mb char data for single shift ? */ + if (mb_parse_table) { + if ((num = mb_parse_table[ch]) > 0) { + parse_info = mb_parse_list[num - 1]; + + codeset = parse_info->codeset; + length = len_left = codeset->length; + mb = 0; + ss_flag = 1; + + continue; + } + } + + /* next mb char data for byteM ? */ + if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))) || + /* next mb char data for GL or GR side ? */ + (codeset = GLGR_parse_codeset(lcd, ch))){ + length = len_left = codeset->length; + mb = 0; + ss_flag = 0; + } + + /* can't find codeset for the ch */ + unconv_num++; + continue; + + } /* end of while */ + + /* error check on last char */ + if (len_left) { + inbufptr -= (length - len_left + ss_flag); + (*from_left) += (length - len_left + ss_flag); + unconv_num += (length - len_left + ss_flag); + } + + *from = *from + from_size; + *from_left = 0; + *to = (XPointer)outbufptr; + + return unconv_num; +} + +static int +wcstombs_org( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + char *encoding; + unsigned long mb, glyph_index; + wchar_t wc; + + int length; + int unconv_num = 0; + + CodeSet codeset; + + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + char *default_string = XLC_PUBLIC(lcd, default_string); + int defstr_len = strlen(default_string); + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + wc = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!wc) { + if (outbufptr) {*outbufptr++ = '\0';} + (*to_left)--; + + continue; + } + + /* convert */ + if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) { + + /* output default_string of falDefaultString() */ + if (*to_left < defstr_len) + break; + if (outbufptr) {strncpy((char *)outbufptr, default_string, defstr_len);} + + if (outbufptr) {outbufptr += defstr_len;} + (*to_left) -= defstr_len; + + unconv_num++; + + } else { + mb = gi_to_mb(glyph_index, codeset); + if (codeset->parse_info) { + + /* output shift sequence */ + encoding = codeset->parse_info->encoding; + length = strlen(encoding); + if (*to_left < length) + break; + if (outbufptr) {strncpy((char *)outbufptr, encoding, length);} + + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + } + + /* output characters */ + length = codeset->length; + if (*to_left < length) + break; + if (outbufptr) {strncpy((char *)outbufptr, ((char *)&mb)+sizeof(mb)-length, length);} + + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + } + + } /* end of while */ + + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + + return unconv_num; +} + +static int +wcstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + size_t table_size = sizeof(default_ct_data) / sizeof(default_ct_data[0]); + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned long glyph_index; + wchar_t wc; + + int i, total_len, seq_len, name_len; + int unconv_num = 0; + Bool first_flag = True, standard_flag; + XlcSide side; + + CodeSet codeset; + XlcCharSet charset, old_charset = NULL; + char *ct_sequence; + XPointer p; + + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + wc = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!wc) { + if (outbufptr) {*outbufptr++ = '\0';} + (*to_left)--; + + continue; + } + + /* convert */ + if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) { + unconv_num++; + continue; + } + + /* parse charset */ + if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) { + unconv_num++; + continue; + } + + /* Standard Character Set Encoding ? */ + standard_flag = False; + for (i = 0; i < table_size; i++) + if (compare(charset->ct_sequence, + default_ct_data[i].encoding, strlen(charset->ct_sequence))) + standard_flag = True; + + /* + * Non-Standard Character Set Encoding + * + * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ + * | esc sequence | M | L | encoding name | STX | + * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ + * 4bytes 1byte 1byte variable length 1byte + * | | + * +-----------------------------------------+ + * name length = ((M - 128) * 128) + (L - 128) + */ + + /* make encoding data */ + ct_sequence = charset->ct_sequence; + side = charset->side; + seq_len = strlen(charset->ct_sequence); + if (standard_flag) { + name_len = 0; + total_len = seq_len; + } else { + name_len = 2 + strlen(charset->encoding_name) + 1; + total_len = seq_len + name_len; + } + + /* output escape sequence of CT */ + if ( (charset != old_charset) && + !(first_flag && (strcmp(charset->encoding_name,"ISO8859-1")==0))) { + + if (*to_left < total_len + 1) { + unconv_num++; + break; + } + + if (outbufptr) { + strcpy((char *)outbufptr, charset->ct_sequence); + outbufptr += seq_len; + + if (!standard_flag) { + *outbufptr++ = name_len / 128 + 128; + *outbufptr++ = name_len % 128 + 128; + strcpy((char *)outbufptr, charset->encoding_name); + outbufptr = outbufptr + name_len - 2 - 1; + *outbufptr++ = STX; + } + } + + (*to_left) -= total_len; + + first_flag = False; + old_charset = charset; + } + + /* output glyph index */ + if (codeset->ctconv) + glyph_index = conv_to_dest(codeset->ctconv, glyph_index); + if (*to_left < charset->char_size) { + unconv_num++; + break; + } + + p = ((XPointer)&glyph_index) + sizeof(glyph_index) - charset->char_size; + for (i = 0; i < charset->char_size; i++) { + if (side == XlcC0 || side == XlcGL) { + if (outbufptr) {*outbufptr++ = *p++ & GL;} + } else if (side == XlcC1 || side == XlcGR) { + if (outbufptr) {*outbufptr++ = *p++ | GR;} + } else { + if (outbufptr) {*outbufptr++ = *p++;} + } + } + + (*to_left) -= charset->char_size; + + } /* end of while */ + + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + + return unconv_num; +} + +static int +ctstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned char ch; + unsigned long glyph_index = 0; + wchar_t wc; + + int ctr_seq_len = 0, gi_len_left = 0, gi_len = 0; + int unconv_num = 0; + + CodeSet codeset = NULL; + XlcCharSet charset_tmp; + + XPointer inbufptr = *from; + wchar_t *outbufptr = (wchar_t *) *to; + int from_size = *from_left; + + + init_state(conv); + + if (from == NULL || *from == NULL) { + init_state(conv); + return( 0 ); + } + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + if (outbufptr) {*outbufptr++ = L'\0';} + (*to_left)--; + + /* error check */ + if (gi_len_left) { + unconv_num += (gi_len - gi_len_left); + gi_len_left = 0; + } + + continue; + } + + /* same glyph_index data */ + if (gi_len_left){ + + if (state->charset->side == XlcC1 || state->charset->side == XlcGR) + glyph_index = (glyph_index << 8) | (ch & GL); + else + glyph_index = (glyph_index << 8) | ch; + + gi_len_left--; + + /* last of one glyph_index data */ + if (!gi_len_left) { + + /* segment conversion */ + charset_tmp = state->charset; + if ( !segment_conversion(lcd, &charset_tmp, &glyph_index) ) { + unconv_num += gi_len; + continue; + } + + /* get codeset */ + if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp, + &codeset, &glyph_index) ) { + unconv_num += gi_len; + continue; + } + + /* convert glyph index to wicd char */ + gi_to_wc(lcd, glyph_index, codeset, &wc); + if (outbufptr) {*outbufptr++ = wc;} + (*to_left)--; + } + + continue; + + } + + /* control sequence ? */ + if (ch == CSI) { + if ( !ct_parse_csi(inbufptr - 1, &ctr_seq_len) ) + goto skip_the_seg; + + if (*from_left < ctr_seq_len) { + inbufptr--; + (*from_left)++; + unconv_num += *from_left; + break; + } + + /* skip the control sequence */ + inbufptr += (ctr_seq_len - 1); + *from_left -= (ctr_seq_len - 1); + + continue; + } + + /* escape sequence ? */ + if (ch == ESC) { + if ( !ct_parse_charset(lcd, + inbufptr - 1, &state->charset, &ctr_seq_len) ) + goto skip_the_seg; + + if (*from_left < ctr_seq_len) { + inbufptr--; + (*from_left)++; + unconv_num += *from_left; + break; + } + + /* skip the escape sequence */ + inbufptr += (ctr_seq_len - 1); + *from_left -= (ctr_seq_len - 1); + + continue; + } + + /* check current state */ + if (state->charset) { + if (state->charset->side == XlcC0 || + state->charset->side == XlcGL) { + state->GL_charset = state->charset; + + } else if (state->charset->side == XlcC1 || + state->charset->side == XlcGR) { + state->GR_charset = state->charset; + } + } else { + if (isleftside(ch)) + state->charset = state->GL_charset; + else + state->charset = state->GR_charset; + } + + gi_len = gi_len_left = state->charset->char_size; + glyph_index = 0; + +skip_the_seg: + /* skip until next escape or control sequence */ + while ( *from_left ) { + ch = *inbufptr++; + (*from_left)--; + unconv_num++; + + if (ch == ESC || ch == CSI) { + inbufptr--; + (*from_left)++; + unconv_num--; + break; + } + } + + if ( !(*from_left) ) + break; + + } /* end of while */ + + /* error check on last char */ + if (gi_len_left) { + inbufptr -= (gi_len - gi_len_left); + (*from_left) += (gi_len - gi_len_left); + unconv_num += (gi_len - gi_len_left); + } + + *from = *from + from_size; + *from_left = 0; + *to = (XPointer)outbufptr; + + return unconv_num; +} + +static int +mbstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t)); + XPointer buf_ptr1 = buf; + int buf_left1 = (*from_left); + XPointer buf_ptr2 = buf_ptr1; + int buf_left2; + int unconv_num; + + unconv_num = mbstowcs_org(conv, + from, from_left, &buf_ptr1, &buf_left1, args, num_args); + if (unconv_num < 0){ + if (buf) + Xfree((char *)buf); + + return unconv_num; + } + + buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); + + unconv_num += wcstocts(conv, + &buf_ptr2, &buf_left2, to, to_left, args, num_args); + if (unconv_num < 0){ + if (buf) + Xfree((char *)buf); + + return unconv_num; + } +} + +static int +mbstostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned char ch; + unsigned long mb = 0; + + + int length = 0, len_left = 0; + int unconv_num = 0; + int num; + Bool ss_flag = 0; + + CodeSet codeset = NULL; + ParseInfo parse_info; + + XPointer inbufptr = *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table); + ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list); + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + if (outbufptr) {*outbufptr++ = '\0';} + (*to_left)--; + + /* error check */ + if (len_left) { + unconv_num += (length - len_left); + len_left = 0; + } + + continue; + } + + /* same mb char data */ + if (len_left){ + mb = (mb << 8) | ch; /* 1 byte left shift */ + len_left--; + + /* last of one mb char data */ + if (!len_left) { + if (check_string_encoding(codeset)) { + if (outbufptr) {*outbufptr++ = mb & 0xff;} + (*to_left)--; + } else { + unconv_num++; + } + } + } + + /* next mb char data for single shift ? */ + if (mb_parse_table) { + if ((num = mb_parse_table[ch]) > 0) { + parse_info = mb_parse_list[num - 1]; + + codeset = parse_info->codeset; + length = len_left = codeset->length; + mb = 0; + ss_flag = 1; + + continue; + } + } + + /* next char data : byteM ? */ + if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))) || + /* next char data : GL or GR side ? */ + (codeset = GLGR_parse_codeset(lcd, ch))){ + length = len_left = codeset->length; + mb = 0; + ss_flag = 0; + } + + /* can't find codeset for the ch */ + unconv_num++; + continue; + + } /* end of while */ + + /* error check on last char */ + if (len_left) { + inbufptr -= (length - len_left + ss_flag); + (*from_left) += (length - len_left + ss_flag); + unconv_num += (length - len_left + ss_flag); + } + + *from = *from + from_size; + *from_left = 0; + *to = (XPointer)outbufptr; + + return unconv_num; +} + +static int +mbtocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned char ch; + unsigned long mb = 0; + unsigned long glyph_index; + + int length = 0, len_left = 0, char_len; + int unconv_num = 0; + int i, num; + XlcSide side; + + CodeSet codeset = NULL; + XlcCharSet charset = NULL; + ParseInfo parse_info; + XPointer p; + + XPointer inbufptr = *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + + unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table); + ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list); + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + unconv_num = 1; + if (len_left) + unconv_num += (length - len_left); + break; + } + + /* same mb char data */ + if (len_left) + goto output; + + /* next mb char data for single shift ? */ + if (mb_parse_table) { + if ((num = mb_parse_table[ch]) > 0) { + parse_info = mb_parse_list[num - 1]; + + codeset = parse_info->codeset; + length = len_left = codeset->length; + mb = 0; + + continue; + } + } + + /* next mb char data for byteM ? */ + if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))) || + /* next mb char data for GL or GR side ? */ + (codeset = GLGR_parse_codeset(lcd, ch))){ + length = len_left = codeset->length; + mb = 0; + } + + /* can't find codeset for the ch */ + unconv_num = 1; + break; + +output: + mb = (mb << 8) | ch; /* 1 byte left shift */ + len_left--; + + /* last of one mb char data */ + if (!len_left) { + glyph_index = mb_to_gi(mb, codeset); + if (!(charset = gi_parse_charset(glyph_index, codeset))) { + unconv_num = length; + break; + } + char_len = charset->char_size; + side = charset->side; + + /* output glyph index */ + if (codeset->ctconv) + glyph_index = conv_to_dest(codeset->ctconv, glyph_index); + if (*to_left < char_len) { + unconv_num = length; + break; + } + + p = ((XPointer)&glyph_index) + sizeof(glyph_index) - char_len; + for (i = 0; i < char_len; i++) { + if (side == XlcC0 || side == XlcGL) { + if (outbufptr) {*outbufptr++ = *p++ & GL;} + } else if (side == XlcC1 || side == XlcGR) { + if (outbufptr) {*outbufptr++ = *p++ | GR;} + } else { + if (outbufptr) {*outbufptr++ = *p++;} + } + } + + (*to_left) -= char_len; + + break; + } + + } /* end of while */ + + /* error end */ + if (unconv_num) { + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + return -1; + } + + /* nomal end */ + *from = inbufptr; + *to = outbufptr; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return 0; +} + +static int +mbstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ret; + XlcCharSet charset_old, charset = NULL; + XPointer tmp_args[1]; + + XPointer inbufptr; + int in_left; + XPointer outbufptr; + int out_left; + tmp_args[0] = (XPointer) &charset; + + ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); + charset_old = charset; + inbufptr = *from; + in_left = *from_left; + outbufptr = *to; + out_left = *to_left; + + while ( ret == 0 && *from_left && *to_left && charset_old == charset ) { + charset_old = charset; + inbufptr = *from; + in_left = *from_left; + outbufptr = *to; + out_left = *to_left; + ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); + } + + *from = inbufptr; + *from_left = in_left; + *to = outbufptr; + *to_left = out_left; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset_old; + + /* error end */ + if (ret != 0) + return( -1 ); + + return(0); +} + +static int +wcstostr( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + char *encoding; + unsigned long mb, glyph_index; + wchar_t wc; + + int length; + int unconv_num = 0; + + CodeSet codeset; + + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + char *default_string = XLC_PUBLIC(lcd, default_string); + int defstr_len = strlen(default_string); + + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + wc = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!wc) { + if (outbufptr) {*outbufptr++ = '\0';} + (*to_left)--; + + continue; + } + + /* convert */ + if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) { + + /* output default_string of falDefaultString() */ + if (*to_left < defstr_len) + break; + if (outbufptr) {strncpy((char *)outbufptr, default_string, defstr_len);} + + if (outbufptr) {outbufptr += defstr_len;} + (*to_left) -= defstr_len; + + unconv_num++; + + } else { + mb = gi_to_mb(glyph_index, codeset); + if (codeset->parse_info) { + + /* output shift sequence */ + encoding = codeset->parse_info->encoding; + length = strlen(encoding); + if (*to_left < length) + break; + if (check_string_encoding(codeset)) { + if (outbufptr) {strncpy((char *)outbufptr, encoding, length);} + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + } + } + + /* output characters */ + length = codeset->length; + if (*to_left < length) + break; + if (check_string_encoding(codeset)) { + if (outbufptr) {strncpy((char *)outbufptr, + ((char *)&mb) + sizeof(mb) - length, length);} + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + } else { + unconv_num++; + } + } + + } /* end of while */ + + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + + return unconv_num; +} + +static int +wctocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + wchar_t wc; + unsigned long glyph_index; + + int i, char_len; + int unconv_num = 0; + XlcSide side; + + CodeSet codeset; + XlcCharSet charset; + XPointer p; + + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + + + if (*from_left > *to_left) + *from_left = *to_left; + + if (*from_left && *to_left) { + + wc = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!wc) { + unconv_num = 1; + goto end; + } + + /* convert */ + if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) { + unconv_num = 1; + goto end; + } + + if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) { + unconv_num = 1; + goto end; + } + char_len = charset->char_size; + side = charset->side; + + /* output glyph index */ + if (codeset->ctconv) + glyph_index = conv_to_dest(codeset->ctconv, glyph_index); + if (*to_left < char_len) { + unconv_num++; + goto end; + } + + p = ((XPointer)&glyph_index) + sizeof(glyph_index) - char_len; + for (i = 0; i < char_len; i++) { + if (side == XlcC0 || side == XlcGL) { + if (outbufptr) {*outbufptr++ = *p++ & GL;} + } else if (side == XlcC1 || side == XlcGR) { + if (outbufptr) {*outbufptr++ = *p++ | GR;} + } else { + if (outbufptr) {*outbufptr++ = *p++;} + } + } + + (*to_left) -= char_len; + + } + +end: + + /* error end */ + if (unconv_num) { + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + return -1; + } + + /* nomal end */ + *from = (XPointer)inbufptr; + *to = outbufptr; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return 0; +} + +static int +wcstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ret; + XlcCharSet charset_old, charset = NULL; + XPointer tmp_args[1]; + + wchar_t *inbufptr; + int in_left; + XPointer outbufptr; + int out_left; + tmp_args[0] = (XPointer) &charset; + + ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1); + charset_old = charset; + inbufptr = (wchar_t *)(*from); + in_left = *from_left; + outbufptr = *to; + out_left = *to_left; + + while ( ret == 0 && *from_left && *to_left && charset_old == charset ) { + charset_old = charset; + inbufptr = (wchar_t *)(*from); + in_left = *from_left; + outbufptr = *to; + out_left = *to_left; + ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1); + } + + *from = (XPointer)inbufptr; + *from_left = in_left; + *to = outbufptr; + *to_left = out_left; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset_old; + + /* error end */ + if (ret != 0) + return( -1 ); + + return(0); +} + +static int +ctstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t)); + XPointer buf_ptr1 = buf; + int buf_left1 = (*from_left); + XPointer buf_ptr2 = buf_ptr1; + int buf_left2; + int unconv_num; + + unconv_num = ctstowcs(conv, + from, from_left, &buf_ptr1, &buf_left1, args, num_args); + if (unconv_num < 0){ + if (buf) + Xfree((char *)buf); + return unconv_num; + } + + buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); + + unconv_num += wcstombs_org(conv, + &buf_ptr2, &buf_left2, to, to_left, args, num_args); + if (unconv_num < 0){ + if (buf) + Xfree((char *)buf); + + return unconv_num; + } +} + +static int +strtombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + char *encoding; + unsigned long mb, glyph_index; + unsigned char ch; + + int length; + int unconv_num = 0; + + CodeSet codeset; + + XPointer inbufptr = *from; + XPointer outbufptr = *to; + int from_size = *from_left; + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + if (outbufptr) {*outbufptr++ = '\0';} + (*to_left)--; + + continue; + } + + /* convert */ + if (isleftside(ch)) { + glyph_index = ch; + codeset = _fallcGetCodeSetFromName(lcd, "ISO8859-1:GL"); + } else { + glyph_index = ch & GL; + codeset = _fallcGetCodeSetFromName(lcd, "ISO8859-1:GR"); + } + + if (!codeset) { + unconv_num++; + continue; + } + + mb = gi_to_mb(glyph_index, codeset); + if (codeset->parse_info) { + + /* output shift sequence */ + encoding = codeset->parse_info->encoding; + length = strlen(encoding); + if (*to_left < length) + break; + if (outbufptr) {strncpy((char *)outbufptr, encoding, length);} + + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + } + + /* output characters */ + length = codeset->length; + if (*to_left < length) + break; + if (outbufptr) {strncpy((char *)outbufptr, ((char *)&mb)+sizeof(mb)-length, length);} + + if (outbufptr) {outbufptr += length;} + (*to_left) -= length; + + } /* end of while */ + + *from = *from + from_size; + *from_left = 0; + *to = outbufptr; + + return unconv_num; +} + +static int +strtowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + State state = (State) conv->state; + XLCd lcd = state->lcd; + + unsigned char ch; + unsigned long glyph_index; + wchar_t wc; + + int unconv_num = 0; + CodeSet codeset; + + XPointer inbufptr = *from; + wchar_t *outbufptr = (wchar_t *)*to; + int from_size = *from_left; + + if (*from_left > *to_left) + *from_left = *to_left; + + while (*from_left && *to_left) { + + ch = *inbufptr++; + (*from_left)--; + + /* null ? */ + if (!ch) { + if (outbufptr) {*outbufptr++ = L'\0';} + (*to_left)--; + + continue; + } + + /* convert */ + if (isleftside(ch)) { + glyph_index = ch; + codeset = _fallcGetCodeSetFromName(lcd, "ISO8859-1:GL"); + } else { + glyph_index = ch & GL; + codeset = _fallcGetCodeSetFromName(lcd, "ISO8859-1:GR"); + } + + if (!codeset) { + unconv_num++; + continue; + } + + gi_to_wc(lcd, glyph_index, codeset, &wc); + if (outbufptr) {*outbufptr++ = wc;} + (*to_left)--; + + } /* end of while */ + + *from = *from + from_size; + *from_left = 0; + *to = (XPointer)outbufptr; + + return unconv_num; +} + +/* -------------------------------------------------------------------------- */ +/* Close */ +/* -------------------------------------------------------------------------- */ + +static void +close_converter(XlcConv conv) +{ + if (conv->state) { + Xfree((char *) conv->state); + } + + if (conv->methods) { + Xfree((char *) conv->methods); + } + + Xfree((char *) conv); +} + +/* -------------------------------------------------------------------------- */ +/* Open */ +/* -------------------------------------------------------------------------- */ + +static XlcConv +create_conv(XLCd lcd, XlcConvMethods methods) +{ + XlcConv conv; + State state; + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == NULL) + return (XlcConv) NULL; + + conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec)); + if (conv->methods == NULL){ + close_converter(conv); + return (XlcConv) NULL; + } + *conv->methods = *methods; + if (XLC_PUBLIC(lcd, is_state_depend)) + conv->methods->reset = init_state; + + conv->state = (XPointer) Xmalloc(sizeof(StateRec)); + if (conv->state == NULL){ + close_converter(conv); + return (XlcConv) NULL; + } + bzero((char *) conv->state, sizeof(StateRec)); + + state = (State) conv->state; + state->lcd = lcd; + init_state(conv); + + return conv; +} + +static XlcConvMethodsRec mbstowcs_methods = { + close_converter, + mbstowcs_org, + NULL +} ; + +static XlcConv +open_mbstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &mbstowcs_methods); +} + +static XlcConvMethodsRec mbstocts_methods = { + close_converter, + mbstocts, + NULL +} ; + +static XlcConv +open_mbstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &mbstocts_methods); +} + +static XlcConvMethodsRec mbstostr_methods = { + close_converter, + mbstostr, + NULL +} ; + +static XlcConv +open_mbstostr(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &mbstostr_methods); +} + +static XlcConvMethodsRec mbstocs_methods = { + close_converter, + mbstocs, + NULL +} ; + +static XlcConv +open_mbstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &mbstocs_methods); +} + +static XlcConvMethodsRec mbtocs_methods = { + close_converter, + mbtocs, + NULL +} ; + +static XlcConv +open_mbtocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &mbtocs_methods); +} + +static XlcConvMethodsRec wcstombs_methods = { + close_converter, + wcstombs_org, + NULL +} ; + +static XlcConv +open_wcstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &wcstombs_methods); +} + +static XlcConvMethodsRec wcstocts_methods = { + close_converter, + wcstocts, + NULL +} ; + +static XlcConv +open_wcstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &wcstocts_methods); +} + +static XlcConvMethodsRec wcstostr_methods = { + close_converter, + wcstostr, + NULL +} ; + +static XlcConv +open_wcstostr(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &wcstostr_methods); +} + +static XlcConvMethodsRec wcstocs_methods = { + close_converter, + wcstocs, + NULL +} ; + +static XlcConv +open_wcstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &wcstocs_methods); +} + +static XlcConvMethodsRec wctocs_methods = { + close_converter, + wctocs, + NULL +} ; + +static XlcConv +open_wctocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &wctocs_methods); +} + +static XlcConvMethodsRec ctstombs_methods = { + close_converter, + ctstombs, + NULL +} ; + +static XlcConv +open_ctstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &ctstombs_methods); +} + +static XlcConvMethodsRec ctstowcs_methods = { + close_converter, + ctstowcs, + NULL +} ; + +static XlcConv +open_ctstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &ctstowcs_methods); +} + +static XlcConvMethodsRec strtombs_methods = { + close_converter, + strtombs, + NULL +} ; + +static XlcConv +open_strtombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &strtombs_methods); +} + +static XlcConvMethodsRec strtowcs_methods = { + close_converter, + strtowcs, + NULL +} ; + +static XlcConv +open_strtowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &strtowcs_methods); +} + +/* -------------------------------------------------------------------------- */ +/* Loader */ +/* -------------------------------------------------------------------------- */ + +XLCd +_fallcGenericLoader(char *name) +{ + XLCd lcd; + + lcd = _fallcCreateLC(name, _fallcGenericMethods); + if (lcd == NULL) + return lcd; + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_mbstostr); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs); + + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wctocs); + + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs); + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs); + + _fallcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs); + _fallcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs); + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcGeneric.c b/cde/programs/dtudcfonted/libfal/_fallcGeneric.c new file mode 100644 index 000000000..606eaab9a --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcGeneric.c @@ -0,0 +1,1172 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcGeneric.c 1.4 - Fujitsu source for CDEnext 96/02/29 18:02:54 */ +/* $XConsortium: _fallcGeneric.c /main/2 1996/09/27 19:03:31 drk $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + +#include <stdio.h> +#include "_fallibint.h" +#include "_fallcGeneric.h" + +static XLCd create(char *name, XLCdMethods methods); +static Bool initialize(XLCd lcd); +static void destroy(XLCd lcd); + +static XLCdPublicMethodsRec genericMethods = { + { NULL }, /* use default methods */ + { + NULL, + create, + initialize, + destroy, + NULL + } +}; + +XLCdMethods _fallcGenericMethods = (XLCdMethods) &genericMethods; + +static XLCd +create(char *name, XLCdMethods methods) +{ + XLCd lcd; + XLCdPublicMethods new; + + lcd = (XLCd) Xmalloc(sizeof(XLCdRec)); + if (lcd == NULL) + return (XLCd) NULL; + bzero((char *) lcd, sizeof(XLCdRec)); + + lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdGenericRec)); + if (lcd->core == NULL){ + Xfree(lcd); + return (XLCd) NULL; + } + bzero((char *) lcd->core, sizeof(XLCdGenericRec)); + + new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec)); + if (new == NULL){ + Xfree(lcd); + return (XLCd) NULL; + } + *new = *((XLCdPublicMethods) methods); + lcd->methods = (XLCdMethods) new; + + return lcd; +} + +static Bool +string_to_encoding(char *str, char *encoding) +{ + char *next; + long value; + int base; + + while (*str) { + if (*str == '\\') { + switch (*(str + 1)) { + case 'x': + case 'X': + base = 16; + break; + default: + base = 8; + break; + } + value = strtol(str + 2, &next, base); + if (str + 2 != next) { + *((unsigned char *) encoding++) = (unsigned char) value; + str = next; + continue; + } + } + *encoding++ = *str++; + } + + *encoding = '\0'; + + return True; +} + +static Bool +string_to_ulong(char *str, unsigned long *value) +{ + char *tmp1 = str; + int base; + + if(*tmp1++ != '\\'){ + tmp1--; + base = 10; + }else{ + switch(*tmp1++){ + case 'x': + base = 16; + break; + case 'o': + base = 8; + break; + case 'd': + base = 10; + break; + default: + return(False); + } + } + *value = (unsigned) strtol(tmp1, NULL, base); + return(True); +} + + +static Bool +add_charset(CodeSet codeset, XlcCharSet charset) +{ + XlcCharSet *new_list; + int num; + + if (num = codeset->num_charsets) + new_list = (XlcCharSet *) Xrealloc(codeset->charset_list, + (num + 1) * sizeof(XlcCharSet)); + else + new_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet)); + + if (new_list == NULL) + return False; + + new_list[num] = charset; + codeset->charset_list = new_list; + codeset->num_charsets = num + 1; + + return True; +} + +static CodeSet +add_codeset(XLCdGenericPart *gen) +{ + CodeSet new, *new_list; + int num; + + new = (CodeSet) Xmalloc(sizeof(CodeSetRec)); + if (new == NULL) + return NULL; + bzero((char *) new, sizeof(CodeSetRec)); + + if (num = gen->codeset_num) + new_list = (CodeSet *) Xrealloc(gen->codeset_list, + (num + 1) * sizeof(CodeSet)); + else + new_list = (CodeSet *) Xmalloc(sizeof(CodeSet)); + + if (new_list == NULL){ + Xfree(new); + return NULL; + } + + new_list[num] = new; + gen->codeset_list = new_list; + gen->codeset_num = num + 1; + + return new; +} + +static Bool +add_parse_list( + XLCdGenericPart *gen, + EncodingType type, + char *encoding, + CodeSet codeset) +{ + ParseInfo new, *new_list; + char *str; + unsigned char ch; + int num; + + str = (char *) Xmalloc(strlen(encoding) + 1); + if (str == NULL) + return False; + strcpy(str, encoding); + + new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec)); + if (new == NULL){ + Xfree(str); + if (new) + Xfree(new); + + return False; + } + bzero((char *) new, sizeof(ParseInfoRec)); + + if (gen->mb_parse_table == NULL) { + gen->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */ + if (gen->mb_parse_table == NULL){ + Xfree(str); + if (new) + Xfree(new); + + return False; + } + bzero((char *) gen->mb_parse_table, 256); + } + + if (num = gen->mb_parse_list_num) + new_list = (ParseInfo *) Xrealloc(gen->mb_parse_list, + (num + 2) * sizeof(ParseInfo)); + else { + new_list = (ParseInfo *) Xmalloc(2 * sizeof(ParseInfo)); + } + + if (new_list == NULL){ + Xfree(str); + if (new) + Xfree(new); + + return False; + } + + new_list[num] = new; + new_list[num + 1] = NULL; + gen->mb_parse_list = new_list; + gen->mb_parse_list_num = num + 1; + + ch = (unsigned char) *str; + if (gen->mb_parse_table[ch] == 0) + gen->mb_parse_table[ch] = num + 1; + + new->type = type; + new->encoding = str; + new->codeset = codeset; + + if (codeset->parse_info == NULL) + codeset->parse_info = new; + + return True; +} + +static void +free_charset(XLCd lcd) +{ + XLCdGenericPart *gen = XLC_GENERIC_PART(lcd); + CodeSet *codeset; + ParseInfo *parse_info; + int num; + + if (gen->mb_parse_table) + Xfree(gen->mb_parse_table); + if (num = gen->mb_parse_list_num) { + for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) { + if ((*parse_info)->encoding) + Xfree((*parse_info)->encoding); + Xfree(*parse_info); + } + Xfree(gen->mb_parse_list); + } + + if (num = gen->codeset_num) + Xfree(gen->codeset_list); +} +/* For VW/UDC */ + +#define FORWARD (unsigned long)'+' +#define BACKWARD (unsigned long)'-' + +static char *getscope(char *str, FontScope scp) +{ + char buff[256],*next; + unsigned long start=0,end=0,dest=0,shift=0,direction=0; + sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end, &dest); + if( dest ){ + if(dest >= start ){ + shift = dest - start; + direction = FORWARD ; + } else { + shift = start - dest; + direction = BACKWARD; + } + } + scp->start = start ; + scp->end = end ; + scp->shift = shift ; + scp->shift_direction + = direction ; + /* .......... */ + while(*str){ + if(*str == ',' && *(str+1) == '['){ + break; + } + str++; + } + next = str+1 ; + return(next); +} +static int count_scopemap(char *str) +{ + char *ptr; + int num=0; + for(ptr=str;*ptr;ptr++){ + if(*ptr == ']'){ + num ++; + } + } + return(num); +} +FontScope falparse_scopemaps(char *str, int *size) +{ + int num=0,i; + FontScope scope,sc_ptr; + char *str_sc; + num = count_scopemap(str); + scope = (FontScope )Xmalloc(num * sizeof(FontScopeRec)); + if(scope == NULL) { + return (NULL); + } + for (i=0,str_sc=str,sc_ptr=scope; + i < num; i++,sc_ptr++){ + str_sc = getscope(str_sc,sc_ptr); + } + *size = num; + return (scope); +} + +void +dbg_printValue(char *str, char **value, int num) +{ +#ifdef DEBUG + int i; + for(i=0;i<num;i++){ + fprintf(stderr,"%s value[%d] = %s\n",str,i,value[i]); + } +#endif +} + +void +dmpscope(char *name, FontScope sc, int num) +{ +/* should this be protected by ifdef DEBUG? + int i; + fprintf(stderr,"dmpscope %s\n",name); + for(i=0;i<num;i++){ + fprintf(stderr,"%x %x %x %x \n", + sc[i].start, + sc[i].end, + sc[i].shift, + sc[i].shift_direction); + } + fprintf(stderr,"dmpscope end\n"); +*/ +} + +static XlcCharSet srch_charset_define(char *name, int *new) +{ + XlcCharSet charset = NULL; + *new = 0; + charset = _fallcGetCharSet(name); + if (charset == NULL && + (charset = _fallcCreateDefaultCharSet(name, ""))) { + _fallcAddCharSet(charset); + *new = 1; + } + return(charset); +} + +static int +read_charset_define(XLCd lcd, XLCdGenericPart *gen) +{ + int i=0; + char csd[16],cset_name[256]; + char name[BUFSIZ]; + XlcCharSet charsetd; + char **value; + int num,new,side=0; + char *tmp; + + for(i=0;;i++){ /* loop start */ + charsetd = 0; + sprintf(csd, "csd%d", i); + + /* charset_name */ + sprintf(name, "%s.%s", csd , "charset_name"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + dbg_printValue(name,value,num); + if (num > 0) { + snprintf(cset_name, sizeof(cset_name), "%s", value[0]); + snprintf(name, sizeof(name), "%s.%s", csd , "side"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + if( !_fallcNCompareISOLatin1(value[0], "none", 4) ){ + side = XlcNONE ; + strcat(cset_name,":none"); + } else + if( !_fallcNCompareISOLatin1(value[0], "GL", 2) ){ + side = XlcGL ; + strcat(cset_name,":GL"); + } else { + side = XlcGR ; + strcat(cset_name,":GR"); + } + if (charsetd == NULL && + (charsetd = srch_charset_define(cset_name,&new)) == NULL) + return 0; + } + } else { + if(i == 0){ + continue ; + } else { + break ; + } + } + if(new){ + tmp = (char *)Xmalloc(strlen(cset_name)+1); + if(tmp == NULL){ + return 0; + } + strcpy(tmp,cset_name); + charsetd->name = tmp; + } + /* side */ + charsetd->side = side ; + /* length */ + snprintf(name, sizeof(name), "%s.%s", csd , "length"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + charsetd->char_size = atoi(value[0]); + } + /* gc_number */ + snprintf(name, sizeof(name), "%s.%s", csd , "gc_number"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + charsetd->set_size = atoi(value[0]); + } + /* string_encoding */ + snprintf(name, sizeof(name), "%s.%s", csd , "string_encoding"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + if(!strcmp("False",value[0])){ + charsetd->string_encoding = False; + } else { + charsetd->string_encoding = True; + } + } + /* sequence */ + snprintf(name, sizeof(name), "%s.%s", csd , "sequence"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); +/* + if(charsetd->ct_sequence){ + Xfree(charsetd->ct_sequence); + } +*/ + tmp = (char *)Xmalloc(strlen(value[0])+1); + if(tmp == NULL){ + return 0; + } + charsetd->ct_sequence = tmp; + string_to_encoding(value[0],tmp); + } + /* encoding_name */ + snprintf(name, sizeof(name), "%s.%s", csd , "encoding_name"); + _fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); +/* + if(charsetd->encoding_name){ + Xfree(charsetd->encoding_name); + } +*/ + tmp = (char *)Xmalloc(strlen(value[0]) + 1); + strcpy(tmp,value[0]); + charsetd->encoding_name = tmp; + charsetd->xrm_encoding_name = + falrmStringToQuark(tmp); + } + } + return 1; +} + +SegConv +faladd_conversion(XLCdGenericPart *gen) +{ + SegConv new_list; + int num; + + if (num = gen->segment_conv_num){ + new_list = (SegConv) Xrealloc(gen->segment_conv, + (num + 1) * sizeof(SegConvRec)); + } else { + new_list = (SegConv) Xmalloc(sizeof(SegConvRec)); + } + + if (new_list == NULL) + return False; + + gen->segment_conv = new_list; + gen->segment_conv_num = num + 1; + + return (&new_list[num]); + +} +static int +read_segmentconversion(XLCd lcd, XLCdGenericPart *gen) +{ + int i=0; + char conv[16]; + char name[BUFSIZ]; + char **value; + int num,new; + SegConv conversion; + for(i=0 ; ; i++){ /* loop start */ + conversion = 0; + sprintf(conv, "conv%d", i); + + /* length */ + sprintf(name, "%s.%s", conv , "length"); + _fallcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); + if (num > 0) { + char *tmp; + if (conversion == NULL && + (conversion = faladd_conversion(gen)) == NULL) { + return 0; + } + dbg_printValue(name,value,num); + } else { + if(i == 0){ + continue; + } else { + break ; + } + } + conversion->length = atoi(value[0]); + + /* source_encoding */ + sprintf(name, "%s.%s", conv , "source_encoding"); + _fallcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); + if (num > 0) { + char *tmp; + dbg_printValue(name,value,num); + tmp = (char *)Xmalloc(strlen(value[0])+1); + if(tmp == NULL){ + return 0; + } + strcpy(tmp,value[0]); + conversion->source_encoding = tmp; + conversion->source = srch_charset_define(tmp,&new); + if(new){ + tmp = (char *)Xmalloc(strlen(conversion->source_encoding)+1); + if(tmp == NULL){ + return 0; + } + strcpy(tmp,conversion->source_encoding); + conversion->source->name = tmp; + } + } + /* destination_encoding */ + sprintf(name, "%s.%s", conv , "destination_encoding"); + _fallcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); + if (num > 0) { + char *tmp; + dbg_printValue(name,value,num); + tmp = (char *)Xmalloc(strlen(value[0])+1); + if(tmp == NULL){ + return 0; + } + strcpy(tmp,value[0]); + conversion->destination_encoding = tmp; + conversion->dest = srch_charset_define(tmp,&new); + if(new){ + tmp = (char *)Xmalloc( + strlen(conversion->destination_encoding)+1); + if(tmp == NULL){ + return 0; + } + strcpy(tmp,conversion->destination_encoding); + conversion->dest->name = tmp; + } + } + /* range */ + sprintf(name, "%s.%s", conv , "range"); + _fallcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); + if (num > 0) { + char *tmp; + dbg_printValue(name,value,num); + sscanf(value[0],"\\x%lx,\\x%lx", + &(conversion->range.start), + &(conversion->range.end)); + } + /* conversion */ + sprintf(name, "%s.%s", conv , "conversion"); + _fallcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num); + if (num > 0) { + char *tmp; + dbg_printValue(name,value,num); + conversion->conv = + falparse_scopemaps(value[0],&conversion->conv_num); + } + } /* loop end */ + + return 1; +} + +static ExtdSegment create_ctextseg(char **value, int num) +{ + ExtdSegment ret; + char side_str[128],*ptr; + char cset_name[128],*tmp; + int i,new; + FontScope scope; + ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec)); + if(ret == NULL){ + return (0); + } + if(strchr(value[0],':')){ + ret->name = (char *)Xmalloc(strlen(value[0])+1); + if(ret->name == NULL){ + XFree(ret); + return(NULL); + } + strcpy(ret->name,value[0]); + ptr = strchr(ret->name,':'); + *ptr = 0; + ptr++; + if( !_fallcNCompareISOLatin1(ptr, "none", 4) ){ + ret->side = XlcNONE ; + snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"none"); + } else + if( !_fallcNCompareISOLatin1(ptr, "GL", 2) ){ + ret->side = XlcGL ; + snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"GL"); + } else { + ret->side = XlcGR ; + snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"GR"); + } + } else { + ret->name = (char *)Xmalloc(strlen(value[0])+1); + if(ret->name == NULL){ + XFree(ret); + return(NULL); + } + strcpy(ret->name,value[0]); + } + ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec)); + if(ret->area == NULL){ + XFree(ret->name); + XFree(ret); + return(NULL); + } + ret->area_num = num - 1; + scope = ret->area ; + for(i=1;i<num;i++){ + sscanf(value[i],"\\x%lx,\\x%lx", &scope[i-1].start, &scope[i-1].end); + } + ret->charset = srch_charset_define(cset_name,&new); + if(new){ + tmp = (char *)Xmalloc(strlen(cset_name)+1); + if(tmp == NULL){ + XFree(ret->area); + XFree(ret->name); + XFree(ret); + return NULL; + } + strcpy(tmp,cset_name); + ret->charset->name = tmp; + } + return(ret); +} +/* For VW/UDC end */ + +static Bool +load_generic(XLCd lcd) +{ + XLCdGenericPart *gen = XLC_GENERIC_PART(lcd); + char **value; + int num; + unsigned long l; + int i; + int M,ii; + + gen->codeset_num = 0; + + /***** wc_encoding_mask *****/ + _fallcGetResource(lcd, "XLC_XLOCALE", "wc_encoding_mask", &value, &num); + if (num > 0) { + if (string_to_ulong(value[0], &l) == False){ + free_charset(lcd); + return False; + } + gen->wc_encode_mask = l; + } + /***** wc_shift_bits *****/ + _fallcGetResource(lcd, "XLC_XLOCALE", "wc_shift_bits", &value, &num); + if (num > 0) + gen->wc_shift_bits = atoi(value[0]); + if (gen->wc_shift_bits < 1) + gen->wc_shift_bits = 8; +#ifndef X_NOT_STDC_ENV + /***** use_stdc_env *****/ + _fallcGetResource(lcd, "XLC_XLOCALE", "use_stdc_env", &value, &num); + if (num > 0 && !_fallcCompareISOLatin1(value[0], "True")) + gen->use_stdc_env = True; + else + gen->use_stdc_env = False; + /***** force_convert_to_mb *****/ + _fallcGetResource(lcd, "XLC_XLOCALE", "force_convert_to_mb", &value, &num); + if (num > 0 && !_fallcCompareISOLatin1(value[0], "True")) + gen->force_convert_to_mb = True; + else + gen->force_convert_to_mb = False; +#endif + + for (i = 0; ; i++) { + CodeSetRec *codeset = NULL; + char cs[16]; + char name[BUFSIZ]; + + sprintf(cs, "cs%d", i); + + /***** codeset.side *****/ + sprintf(name, "%s.%s", cs , "side"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + char *tmp; + + if (codeset == NULL && (codeset = add_codeset(gen)) == NULL){ + free_charset(lcd); + return False; + } + + /* 3.4.1 side */ + if( !_fallcNCompareISOLatin1(value[0], "none", 4) ){ + codeset->side = XlcNONE ; + } else + if( !_fallcNCompareISOLatin1(value[0], "GL", 2) ){ + codeset->side = XlcGL ; + } else { + codeset->side = XlcGR ; + } + + tmp = strrchr(value[0], ':'); + if (tmp != NULL && !_fallcCompareISOLatin1(tmp + 1, "Default")) { + if (codeset->side == XlcGR) + gen->initial_state_GR = codeset; + else + gen->initial_state_GL = codeset; + } + } + + /***** codeset.length *****/ + sprintf(name, "%s.%s", cs , "length"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + if (codeset == NULL && (codeset = add_codeset(gen)) == NULL){ + free_charset(lcd); + return False; + } + codeset->length = atoi(value[0]); + if (codeset->length < 1) + codeset->length = 1; + } + + /***** codeset.mb_encoding *****/ + sprintf(name, "%s.%s", cs, "mb_encoding"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + static struct { + char *str; + int type; + } shifts[] = { + {"<SS>", E_SS}, + {"<LSL>", E_LSL}, + {"<LSR>", E_LSR}, + 0 + }; + int j; + + if (codeset == NULL && (codeset = add_codeset(gen)) == NULL){ + free_charset(lcd); + return False; + } + for ( ; num-- > 0; value++) { + char encoding[256]; + char *tmp = *value; + int type = E_SS; /* for BC */ + for (j = 0; shifts[j].str; j++) { + if (!_fallcNCompareISOLatin1(tmp, shifts[j].str, + strlen(shifts[j].str))) { + type = shifts[j].type; + tmp += strlen(shifts[j].str); + break; + } + } + if (string_to_encoding(tmp, encoding) == False){ + free_charset(lcd); + return False; + } + add_parse_list(gen, type, encoding, codeset); + } + } + + /***** codeset.wc_encoding *****/ + sprintf(name, "%s.%s", cs, "wc_encoding"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + if ((codeset == NULL && (codeset = add_codeset(gen)) == NULL) || \ + (string_to_ulong(value[0], &l) == False)){ + free_charset(lcd); + return False; + } + codeset->wc_encoding = l; + } + + /***** codeset.ct_encoding *****/ + sprintf(name, "%s.%s", cs, "ct_encoding"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + XlcCharSet charset; + char *encoding; + + if (codeset == NULL && (codeset = add_codeset(gen)) == NULL){ + free_charset(lcd); + return False; + } + for ( ; num-- > 0; value++) { + string_to_encoding(*value, name); + charset = NULL; + if ((encoding = strchr(name, ':')) && + (encoding = strchr(encoding + 1, ':'))) { + *encoding++ = '\0'; + charset = _fallcAddCT(name, encoding); + } + if (charset == NULL) { + charset = _fallcGetCharSet(name); + if (charset == NULL && + (charset = _fallcCreateDefaultCharSet(name, ""))) { + charset->side = codeset->side; + charset->char_size = codeset->length; + _fallcAddCharSet(charset); + } + } + if (charset) { + if (add_charset(codeset, charset) == False){ + free_charset(lcd); + return False; + } + } + } + } + + if (codeset == NULL) + break; + codeset->cs_num = i; + /* For VW/UDC */ + /***** 3.4.2 byteM (1 <= M <= length)*****/ + for(M=1; M-1 < codeset->length; M++){ + long start,end; + ByteInfo tmpb; + + sprintf(name,"%s.%s%d",cs,"byte",M); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + + if( M == 1){ + if(num < 1) { + codeset->byteM = NULL ; + break ; + } + codeset->byteM = + (ByteInfoListRec *)Xmalloc( + (codeset->length)*sizeof(ByteInfoListRec)); + if(codeset->byteM == NULL){ + free_charset(lcd); + return False; + } + } + + if(num > 0){ + dbg_printValue(name,value,num); + (codeset->byteM)[M-1].M = M; + (codeset->byteM)[M-1].byteinfo_num = num; + (codeset->byteM)[M-1].byteinfo = + (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec)); + for(ii = 0 ; ii < num ; ii++){ + char tmp[128]; + tmpb = (codeset->byteM)[M-1].byteinfo ; + /* default 0x00 - 0xff */ + sscanf(value[ii], "\\x%lx,\\x%lx", (long unsigned *) &start, (long unsigned *) &end); + tmpb[ii].start = (unsigned char)start; + tmpb[ii].end = (unsigned char)end; + } + } + /* .... */ + } + + + /***** codeset.mb_conversion *****/ + sprintf(name, "%s.%s", cs, "mb_conversion"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + codeset->mbconv = Xmalloc(sizeof(ConversionRec)); + codeset->mbconv->convlist = + falparse_scopemaps(value[0],&(codeset->mbconv->conv_num)); + dmpscope("mb_conv",codeset->mbconv->convlist, + codeset->mbconv->conv_num); + /* [\x%x,\x%x]->\x%x,... */ + } + /***** codeset.ct_conversion *****/ + sprintf(name, "%s.%s", cs, "ct_conversion"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + codeset->ctconv = Xmalloc(sizeof(ConversionRec)); + codeset->ctconv->convlist = + falparse_scopemaps(value[0],&(codeset->ctconv->conv_num)); + dmpscope("ctconv",codeset->ctconv->convlist, + codeset->ctconv->conv_num); + /* [\x%x,\x%x]->\x%x,... */ + } + /***** codeset.ct_conversion_file *****/ + sprintf(name, "%s.%s", cs, "ct_conversion_file"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + /* [\x%x,\x%x]->\x%x,... */ + } + /***** codeset.ct_extended_segment *****/ + sprintf(name, "%s.%s", cs, "ct_extended_segment"); + _fallcGetResource(lcd, "XLC_XLOCALE", name, &value, &num); + if (num > 0) { + dbg_printValue(name,value,num); + codeset->ctextseg = create_ctextseg(value,num); + /* [\x%x,\x%x]->\x%x,... */ + } + /* For VW/UDC end */ + + } + + read_charset_define(lcd,gen); /* For VW/UDC */ + read_segmentconversion(lcd,gen); /* For VW/UDC */ + + return True; +} + +static Bool +initialize(XLCd lcd) +{ + XLCdPublicMethods superclass = (XLCdPublicMethods) _fallcPublicMethods; + + XLC_PUBLIC_METHODS(lcd)->superclass = superclass; + + if (superclass->pub.initialize) { + if ((*superclass->pub.initialize)(lcd) == False) + return False; + } + + if(load_generic(lcd) == False) + return False; + + return True; +} +/* VW/UDC start 95.01.08 */ +static void +freeByteM(CodeSet codeset) +{ + int i; + ByteInfoList blst; + if(codeset->byteM == NULL) { + return ; + } + blst = codeset->byteM; + for(i=0;i<codeset->length;i++){ + if(blst[i].byteinfo){ + Xfree(blst[i].byteinfo); + blst[i].byteinfo = NULL; + } + } + Xfree(codeset->byteM); + codeset->byteM = NULL; +} +static void +freeConversion(CodeSet codeset) +{ + int i; + Conversion mbconv,ctconv; + if( codeset->mbconv ) { + mbconv = codeset->mbconv; + /* ... */ + if(mbconv->convlist){ + Xfree(mbconv->convlist); + mbconv->convlist = NULL; + } + Xfree(mbconv); + codeset->mbconv = NULL; + } + if( codeset->ctconv ) { + ctconv = codeset->ctconv; + /* ... */ + if(ctconv->convlist){ + Xfree(ctconv->convlist); + ctconv->convlist = NULL; + } + Xfree(ctconv); + codeset->ctconv = NULL; + } +} +static void +freeExtdSegment(CodeSet codeset) +{ + int i; + ExtdSegment ctextseg; + if(codeset->ctextseg == NULL) { + return ; + } + ctextseg = codeset->ctextseg; + if(ctextseg->name){ + Xfree(ctextseg->name); + ctextseg->name = NULL; + } + if(ctextseg->area){ + Xfree(ctextseg->area); + ctextseg->area = NULL; + } + Xfree(codeset->ctextseg); + codeset->ctextseg = NULL; +} +static void +freeParseInfo(CodeSet codeset) +{ + int i; + ParseInfo parse_info; + if(codeset->parse_info == NULL) { + return ; + } + parse_info = codeset->parse_info; + if(parse_info->encoding){ + Xfree(parse_info->encoding); + parse_info->encoding = NULL; + } + Xfree(codeset->parse_info); + codeset->parse_info = NULL; +} +static void +destroy_CodeSetList(XLCdGenericPart *gen) +{ + CodeSet *codeset = gen->codeset_list; + int i; + if(gen->codeset_num == 0) { + return; + } + for(i=0;i<gen->codeset_num;i++){ + freeByteM(codeset[i]); + freeConversion(codeset[i]); + freeExtdSegment(codeset[i]); + freeParseInfo(codeset[i]); + if(codeset[i]->charset_list){ + Xfree(codeset[i]->charset_list); + codeset[i]->charset_list = NULL; + } + Xfree(codeset[i]); codeset[i]=NULL; + } + Xfree(codeset); gen->codeset_list = NULL; +} + +static void +destroy_SegConv(XLCdGenericPart *gen) +{ + SegConv seg = gen->segment_conv; + int i; + if(gen->segment_conv_num == 0) { + return; + } + for(i=0;i<gen->segment_conv_num;i++){ + if(seg[i].source_encoding){ + Xfree(seg[i].source_encoding); + seg[i].source_encoding = NULL; + } + if(seg[i].destination_encoding){ + Xfree(seg[i].destination_encoding); + seg[i].destination_encoding = NULL; + } + if(seg[i].conv){ + Xfree(seg[i].conv); seg[i].conv = NULL; + } + } + Xfree(seg); gen->segment_conv = NULL; +} + +static void +destroy_gen(XLCd lcd) +{ + XLCdGenericPart *gen = XLC_GENERIC_PART(lcd); + destroy_SegConv(gen); + destroy_CodeSetList(gen); + if(gen->mb_parse_table){ + Xfree(gen->mb_parse_table); + gen->mb_parse_table = NULL; + } + if(gen->mb_parse_list){ + Xfree(gen->mb_parse_list); + gen->mb_parse_list = NULL; + } +} +/* VW/UDC end 95.01.08 */ +static void +destroy(XLCd lcd) +{ + XLCdPublicMethods superclass = XLC_PUBLIC_METHODS(lcd)->superclass; + + destroy_gen(lcd); /* ADD 1996.01.08 */ + if (superclass && superclass->pub.destroy) + (*superclass->pub.destroy)(lcd); +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcGeneric.h b/cde/programs/dtudcfonted/libfal/_fallcGeneric.h new file mode 100644 index 000000000..b9eb08f99 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcGeneric.h @@ -0,0 +1,168 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XlcGeneric.h 1.3 - Fujitsu source for CDEnext 95/12/07 10:53:07 */ +/* $XConsortium: _fallcGeneric.h /main/1 1996/04/08 15:17:24 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + +#ifndef _XLCGENERIC_H_ +#define _XLCGENERIC_H_ + +#include "_fallcPubI.h" + +typedef struct _ByteInfo { + unsigned char start,end; +} ByteInfoRec, *ByteInfo; + +typedef struct _ByteInfoList { + int M; /* 1 <= M <= length */ + int byteinfo_num; + ByteInfo byteinfo; +} ByteInfoListRec, *ByteInfoList; + +/* conversion_type values */ +#define LOCALCONV 1 +#define FILECONV 2 +#define FUNCTIONCONV 4 + +typedef struct _Conversion { + unsigned long conversion_type; + int conv_num; + FontScope convlist; + char *cnv_file; + XlcConv cnvfunc; +} ConversionRec, *Conversion; + +typedef struct _ExtdSegment { + char *name; + XlcSide side; + FontScope area; + int area_num; + XlcCharSet charset; +} ExtdSegmentRec, *ExtdSegment; + +typedef struct _SegConvRec { + int length; + char *source_encoding; + XlcCharSet source; + char *destination_encoding; + XlcCharSet dest; + FontScopeRec range; + int conv_num; + FontScope conv; +} SegConvRec, *SegConv; + +typedef struct _ParseInfoRec *ParseInfo; + +typedef struct _CodeSetRec { + XlcCharSet *charset_list; + int num_charsets; + int cs_num; + XlcSide side; + int length; + ByteInfoList byteM; + Conversion mbconv; + Conversion ctconv; + ExtdSegment ctextseg; + ParseInfo parse_info; + unsigned long wc_encoding; +} CodeSetRec, *CodeSet; + +typedef enum { + E_GL, /* GL encoding */ + E_GR, /* GR encoding */ + E_SS, /* single shift */ + E_LSL, /* locking shift left */ + E_LSR, /* locking shift right */ + E_LAST +} EncodingType; + +typedef struct _ParseInfoRec { + EncodingType type; + char *encoding; + CodeSet codeset; +} ParseInfoRec; + +/* + * XLCd private data + */ + +#define XLC_GENERIC(lcd, x) (((XLCdGeneric) lcd->core)->gen.x) +#define XLC_GENERIC_PART(lcd) (&(((XLCdGeneric) lcd->core)->gen)) + +typedef struct _XLCdGenericPart { + int codeset_num; + CodeSet *codeset_list; + unsigned char *mb_parse_table; + int mb_parse_list_num; + ParseInfo *mb_parse_list; + unsigned long wc_encode_mask; + unsigned long wc_shift_bits; + CodeSet initial_state_GL; + CodeSet initial_state_GR; + int segment_conv_num; /* UDC */ + SegConv segment_conv; /* UDC */ + Bool use_stdc_env; + Bool force_convert_to_mb; +} XLCdGenericPart; + +typedef struct _XLCdGenericRec { + XLCdCoreRec core; + XLCdPublicPart pub; + XLCdGenericPart gen; +} XLCdGenericRec, *XLCdGeneric; + +extern XLCdMethods _fallcGenericMethods; + +#endif /* _XLCGENERIC_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_fallcInit.c b/cde/programs/dtudcfonted/libfal/_fallcInit.c new file mode 100644 index 000000000..3f1db9bd0 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcInit.c @@ -0,0 +1,158 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcInit.c 1.4 - Fujitsu source for CDEnext 96/03/11 17:13:15 */ +/* $XConsortium: _fallcInit.c /main/1 1996/04/08 15:17:36 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Modifier: Masayoshi Shimamura FUJITSU LIMITED + * + */ + +#include "_fallibint.h" +#include "_fallcint.h" + +#define USE_GENERIC_LOADER +#define USE_DEFAULT_LOADER +/*** #define USE_EUC_LOADER ***/ +/*** #define USE_SJIS_LOADER ***/ +/*** #define USE_JIS_LOADER ***/ +/*** #define USE_UTF_LOADER ***/ + +extern XLCd _fallcDefaultLoader( + char* +); + +#ifdef DYNAMIC_LOAD +#ifdef sun +extern XLCd _falsunOsDynamicLoad( + char* +); +#endif /* sun */ +#endif /* DYNAMIC_LOAD */ + +#ifdef USE_GENERIC_LOADER +extern XLCd _fallcGenericLoader( + char* +); +#endif + +#ifdef USE_UTF_LOADER +extern XLCd _fallcUtfLoader( + char* +); +#endif + +#ifdef USE_EUC_LOADER +extern XLCd _fallcEucLoader( + char* +); +#endif + +#ifdef USE_SJIS_LOADER +extern XLCd _fallcSjisLoader( + char* +); +#endif + +#ifdef USE_JIS_LOADER +extern XLCd _XlcJisLoader( + char* +); +#endif + +#ifdef USE_DYNAMIC_LOADER +extern XLCd _fallcDynamicLoader( + char* +); +#endif + +/* + * The _fallcInitLoader function initializes the locale object loader list + * with vendor specific manner. + */ + +void +_fallcInitLoader(void) +{ +#ifdef USE_GENERIC_LOADER + _fallcAddLoader(_fallcGenericLoader, XlcHead); +#endif + +#ifdef USE_DEFAULT_LOADER + _fallcAddLoader(_fallcDefaultLoader, XlcHead); +#endif + +#ifdef USE_EUC_LOADER + _fallcAddLoader(_fallcEucLoader, XlcHead); +#endif + +#ifdef USE_SJIS_LOADER + _fallcAddLoader(_fallcSjisLoader, XlcHead); +#endif + +#ifdef USE_JIS_LOADER + _fallcAddLoader(_XlcJisLoader, XlcHead); +#endif + +#ifdef USE_UTF_LOADER + _fallcAddLoader(_fallcUtfLoader, XlcHead); +#endif + +#ifdef DYNAMIC_LOAD +#ifdef sun + _fallcAddLoader(_falsunOsDynamicLoad, XlcHead); +#endif /* sun */ +#endif /* DYNAMIC_LOAD */ + +#ifdef USE_DYNAMIC_LOADER + _fallcAddLoader(_fallcDynamicLoader, XlcHead); +#endif +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcPrTxt.c b/cde/programs/dtudcfonted/libfal/_fallcPrTxt.c new file mode 100644 index 000000000..a8b871606 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcPrTxt.c @@ -0,0 +1,258 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcPrTxt.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:38 */ +/* $XConsortium: _fallcPrTxt.c /main/1 1996/04/08 15:17:49 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" +#include "_falutil.h" +#include <X11/Xatom.h> + +static XPointer * +alloc_list(Bool is_wide_char, int count, int nitems) +{ + if (is_wide_char) { + wchar_t **wstr_list; + + wstr_list = (wchar_t **) Xmalloc(count * sizeof(wchar_t *)); + if (wstr_list == NULL) + return (XPointer *) NULL; + + *wstr_list = (wchar_t *) Xmalloc(nitems * sizeof(wchar_t)); + if (*wstr_list == NULL) { + Xfree(wstr_list); + return (XPointer *) NULL; + } + + return (XPointer *) wstr_list; + } else { + char **str_list; + + str_list = (char **) Xmalloc(count * sizeof(char *)); + if (str_list == NULL) + return (XPointer *) NULL; + + *str_list = (char *) Xmalloc(nitems); + if (*str_list == NULL) { + Xfree(str_list); + return (XPointer *) NULL; + } + + return (XPointer *) str_list; + } +} + +static void +copy_list(Bool is_wide_char, XPointer text, XPointer *list, int count) +{ + int length; + + if (is_wide_char) { + wchar_t *wc_text, *wstr, **wstr_list; + + wc_text = (wchar_t *) text; + wstr_list = (wchar_t **) list; + + for (wstr = *wstr_list; count > 0; count--, wstr_list++) { + _falwcscpy(wstr, wc_text); + *wstr_list = wstr; + length = _falwcslen(wstr) + 1; + wstr += length; + wc_text += length; + } + } else { + char *mb_text, *str, **str_list; + + mb_text = (char *) text; + str_list = (char **) list; + + for (str = *str_list; count > 0; count--, str_list++) { + strcpy(str, mb_text); + *str_list = str; + length = strlen(str) + 1; + str += length; + mb_text += length; + } + } +} + +static int +_XTextPropertyToTextList( + XLCd lcd, + Display *dpy, + XTextProperty *text_prop, + char *to_type, + XPointer **list_ret, + int *count_ret) +{ + XlcConv conv; + char *from_type; + XPointer from, to, buf; + char *str_ptr, *last_ptr; + Atom encoding; + int from_left, to_left, buf_len, ret; + int unconv_num, nitems = text_prop->nitems; + Bool is_wide_char = False; + + if (strcmp(XlcNWideChar, to_type) == 0) + is_wide_char = True; + + if (nitems <= 0) { + *list_ret = NULL; + *count_ret = 0; + return Success; + } + + if (text_prop->format != 8) + return XConverterNotFound; + + encoding = text_prop->encoding; + if (encoding == XA_STRING) + from_type = XlcNString; + else if (encoding == falInternAtom(dpy, "COMPOUND_TEXT", False)) + from_type = XlcNCompoundText; + else if (encoding == falInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False)) + from_type = XlcNMultiByte; + else + return XConverterNotFound; + + if (is_wide_char) { + buf_len = text_prop->nitems + 1; + buf = (XPointer) Xmalloc(buf_len * sizeof(wchar_t)); + } else { + buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1; + buf = (XPointer) Xmalloc(buf_len); + } + if (buf == NULL) + return XNoMemory; + to = buf; + to_left = buf_len; + + conv = _fallcOpenConverter(lcd, from_type, lcd, to_type); + if (conv == NULL) { + Xfree(buf); + return XConverterNotFound; + } + + last_ptr = str_ptr = (char *) text_prop->value; + unconv_num = *count_ret = 0; + + while (1) { + if (nitems == 0 || *str_ptr == 0) { + if (nitems) + str_ptr++; + from = (XPointer) last_ptr; + from_left = str_ptr - last_ptr; + last_ptr = str_ptr; + + ret = _fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0); + + if (ret < 0) + continue; + + unconv_num += ret; + (*count_ret)++; + + if (nitems == 0) + break; + _fallcResetConverter(conv); + } else + str_ptr++; + + nitems--; + } + + _fallcCloseConverter(conv); + + if (is_wide_char) + *((wchar_t *) to) = (wchar_t) 0; + else + *((char *) to) = '\0'; + to_left--; + + *list_ret = alloc_list(is_wide_char, *count_ret, buf_len - to_left); + if (*list_ret) + copy_list(is_wide_char, buf, *list_ret, *count_ret); + + Xfree(buf); + + return unconv_num; +} + +int +_falmbTextPropertyToTextList( + XLCd lcd, + Display *dpy, + XTextProperty *text_prop, + char ***list_ret, + int *count_ret) +{ + return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNMultiByte, + (XPointer **) list_ret, count_ret); +} + +int +_falwcTextPropertyToTextList( + XLCd lcd, + Display *dpy, + XTextProperty *text_prop, + wchar_t ***list_ret, + int *count_ret) +{ + return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNWideChar, + (XPointer **) list_ret, count_ret); +} + +void +_falwcFreeStringList(XLCd lcd, wchar_t **list) +{ + if (list) { + if (*list) + Xfree(*list); + Xfree(list); + } +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcPubI.h b/cde/programs/dtudcfonted/libfal/_fallcPubI.h new file mode 100644 index 000000000..e86b50f88 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcPubI.h @@ -0,0 +1,233 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XlcPubI.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:05 */ +/* $XConsortium: _fallcPubI.h /main/1 1996/04/08 15:17:59 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#ifndef _XLCPUBLICI_H_ +#define _XLCPUBLICI_H_ + +#include "_fallcPublic.h" + +#define XLC_PUBLIC(lcd, x) (((XLCdPublic) lcd->core)->pub.x) +#define XLC_PUBLIC_PART(lcd) (&(((XLCdPublic) lcd->core)->pub)) +#define XLC_PUBLIC_METHODS(lcd) (&(((XLCdPublicMethods) lcd->methods)->pub)) + +/* + * XLCd public methods + */ + +typedef struct _XLCdPublicMethodsRec *XLCdPublicMethods; + +typedef XLCd (*XlcPubCreateProc)( + char* /* name */, + XLCdMethods /* methods */ +); + +typedef Bool (*XlcPubInitializeProc)( + XLCd /* lcd */ +); + +typedef void (*XlcPubDestroyProc)( + XLCd /* lcd */ +); + +typedef char* (*XlcPubGetValuesProc)( + XLCd /* lcd */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef void (*XlcPubGetResourceProc)( + XLCd /* lcd */, + char* /* category */, + char* /* class */, + char*** /* value */, + int* /* count */ +); + +typedef struct _XLCdPublicMethodsPart { + XLCdPublicMethods superclass; + XlcPubCreateProc create; + XlcPubInitializeProc initialize; + XlcPubDestroyProc destroy; + XlcPubGetValuesProc get_values; + XlcPubGetResourceProc get_resource; +} XLCdPublicMethodsPart; + +typedef struct _XLCdPublicMethodsRec { + XLCdMethodsRec core; + XLCdPublicMethodsPart pub; +} XLCdPublicMethodsRec; + +/* + * XLCd public data + */ + +typedef struct _XLCdPublicPart { + char *siname; /* for _fallcMapOSLocaleName() */ + char *language; /* language part of locale name */ + char *territory; /* territory part of locale name */ + char *codeset; /* codeset part of locale name */ + char *encoding_name; /* encoding name */ + int mb_cur_max; /* ANSI C MB_CUR_MAX */ + Bool is_state_depend; /* state-depend encoding */ + char *default_string; /* for falDefaultString() */ + XPointer xlocale_db; +} XLCdPublicPart; + +typedef struct _XLCdPublicRec { + XLCdCoreRec core; + XLCdPublicPart pub; +} XLCdPublicRec, *XLCdPublic; + +extern XLCdMethods _fallcPublicMethods; + +_XFUNCPROTOBEGIN + +extern XLCd _fallcCreateLC( + char* /* name */, + XLCdMethods /* methods */ +); + +extern void _fallcDestroyLC( + XLCd /* lcd */ +); + +extern Bool _fallcParseCharSet( + XlcCharSet /* charset */ +); + +extern XlcCharSet _fallcCreateDefaultCharSet( + char* /* name */, + char* /* control_sequence */ +); + +extern XlcCharSet _fallcAddCT( + char* /* name */, + char* /* control_sequence */ +); + +extern XrmMethods _falrmDefaultInitParseInfo( + XLCd /* lcd */, + XPointer* /* state */ +); + +extern int _falmbTextPropertyToTextList( + XLCd /* lcd */, + Display* /* dpy */, + XTextProperty* /* text_prop */, + char*** /* list_ret */, + int* /* count_ret */ +); + +extern int _falwcTextPropertyToTextList( + XLCd /* lcd */, + Display* /* dpy */, + XTextProperty* /* text_prop */, + wchar_t*** /* list_ret */, + int* /* count_ret */ +); + +extern int _falmbTextListToTextProperty( + XLCd /* lcd */, + Display* /* dpy */, + char** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop */ +); + +extern int _falwcTextListToTextProperty( + XLCd /* lcd */, + Display* /* dpy */, + wchar_t** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop */ +); + +extern void _falwcFreeStringList( + XLCd /* lcd */, + wchar_t** /* list */ +); + +extern int _fallcResolveLocaleName( + char* /* lc_name */, + char* /* full_name */, + char* /* language */, + char* /* territory */, + char* /* codeset */ +); + +extern int _fallcResolveDBName( + char* /* lc_name */, + char* /* file_name */ +); + +extern int _fallcResolveI18NPath( + char* /* path_name */ +); + +extern XPointer _fallcCreateLocaleDataBase( + XLCd /* lcd */ +); + +extern void _fallcDestroyLocaleDataBase( + XLCd /* lcd */ +); + +extern void _fallcGetLocaleDataBase( + XLCd /* lcd */, + char* /* category */, + char* /* name */, + char*** /* value */, + int* /* count */ +); + +_XFUNCPROTOEND + +#endif /* _XLCPUBLICI_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_fallcPubWrap.c b/cde/programs/dtudcfonted/libfal/_fallcPubWrap.c new file mode 100644 index 000000000..532c83958 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcPubWrap.c @@ -0,0 +1,117 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcPubWrap.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:39 */ +/* $XConsortium: _fallcPubWrap.c /main/1 1996/04/08 15:18:09 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" + +char * +_falGetLCValues(XLCd lcd, ...) +{ + va_list var; + XlcArgList args; + char *ret; + int num_args; + XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd); + + Va_start(var, lcd); + _fallcCountVaList(var, &num_args); + va_end(var); + + Va_start(var, lcd); + _fallcVaToArgList(var, num_args, &args); + va_end(var); + + if (args == (XlcArgList) NULL) + return (char *) NULL; + + ret = (*methods->get_values)(lcd, args, num_args); + + Xfree(args); + + return ret; +} + +void +_fallcDestroyLC(XLCd lcd) +{ + XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods; + + (*methods->pub.destroy)(lcd); +} + +XLCd +_fallcCreateLC(char *name, XLCdMethods methods) +{ + XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods; + XLCd lcd; + + lcd = (*pub_methods->pub.create)(name, methods); + if (lcd == NULL) + return (XLCd) NULL; + + if (lcd->core->name == NULL) { + lcd->core->name = (char*) Xmalloc(strlen(name) + 1); + if (lcd->core->name == NULL) { + _fallcDestroyLC(lcd); + return (XLCd) NULL; + } + + strcpy(lcd->core->name, name); + } + + if (lcd->methods == NULL) + lcd->methods = methods; + + if ((*pub_methods->pub.initialize)(lcd) == False) { + _fallcDestroyLC(lcd); + return (XLCd) NULL; + } + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcPublic.c b/cde/programs/dtudcfonted/libfal/_fallcPublic.c new file mode 100644 index 000000000..af3972936 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcPublic.c @@ -0,0 +1,314 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcPublic.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:39 */ +/* $XConsortium: _fallcPublic.c /main/1 1996/04/08 15:18:20 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include <stdio.h> +#include "_fallibint.h" +#include "_fallcPubI.h" + +static char *default_string(); + +static XLCd create(); +static Bool initialize(); +static void destroy(); +static char *get_values(); + +static XLCdPublicMethodsRec publicMethods = { + { + destroy, + _fallcDefaultMapModifiers, + NULL, + NULL, + _falrmDefaultInitParseInfo, + _falmbTextPropertyToTextList, + _falwcTextPropertyToTextList, + _falmbTextListToTextProperty, + _falwcTextListToTextProperty, + _falwcFreeStringList, + default_string, + NULL, + NULL + }, + { + NULL, + create, + initialize, + destroy, + get_values, + _fallcGetLocaleDataBase + } +}; + +XLCdMethods _fallcPublicMethods = (XLCdMethods) &publicMethods; + +static char * +default_string(XLCd lcd) +{ + return XLC_PUBLIC(lcd, default_string); +} + +static XLCd +create(char *name, XLCdMethods methods) +{ + XLCd lcd; + XLCdPublicMethods new; + + lcd = (XLCd) Xmalloc(sizeof(XLCdRec)); + if (lcd == NULL) + return (XLCd) NULL; + bzero((char *) lcd, sizeof(XLCdRec)); + + lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec)); + if (lcd->core == NULL){ + Xfree(lcd); + return (XLCd) NULL; + } + bzero((char *) lcd->core, sizeof(XLCdPublicRec)); + + new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec)); + if (new == NULL){ + Xfree(lcd); + return (XLCd) NULL; + } + *new = *((XLCdPublicMethods) methods); + lcd->methods = (XLCdMethods) new; + + return lcd; +} + +static Bool +load_public(XLCd lcd) +{ + XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd); + char **values, *str; + int num; + + if(_fallcCreateLocaleDataBase(lcd) == NULL) + return False; + + _fallcGetResource(lcd, "XLC_XLOCALE", "mb_cur_max", &values, &num); + if (num > 0) { + pub->mb_cur_max = atoi(values[0]); + if (pub->mb_cur_max < 1) + pub->mb_cur_max = 1; + } else + pub->mb_cur_max = 1; + + _fallcGetResource(lcd, "XLC_XLOCALE", "state_dependent", &values, &num); + if (num > 0 && !_fallcCompareISOLatin1(values[0], "True")) + pub->is_state_depend = True; + else + pub->is_state_depend = False; + + _fallcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num); + str = (num > 0) ? values[0] : "STRING"; + pub->encoding_name = (char*) Xmalloc(strlen(str) + 1); + if (pub->encoding_name == NULL) + return False; + strcpy(pub->encoding_name, str); + + return True; +} + +static Bool +initialize_core(XLCd lcd) +{ + XLCdMethods methods = lcd->methods; + XLCdMethods core = &publicMethods.core; + + if (methods->close == NULL) + methods->close = core->close; + + if (methods->map_modifiers == NULL) + methods->map_modifiers = core->map_modifiers; + + if (methods->open_om == NULL) + _falInitOM(lcd); + + if (methods->init_parse_info == NULL) + methods->init_parse_info = core->init_parse_info; + + if (methods->mb_text_prop_to_list == NULL) + methods->mb_text_prop_to_list = core->mb_text_prop_to_list; + + if (methods->wc_text_prop_to_list == NULL) + methods->wc_text_prop_to_list = core->wc_text_prop_to_list; + + if (methods->mb_text_list_to_prop == NULL) + methods->mb_text_list_to_prop = core->mb_text_list_to_prop; + + if (methods->wc_text_list_to_prop == NULL) + methods->wc_text_list_to_prop = core->wc_text_list_to_prop; + + if (methods->wc_free_string_list == NULL) + methods->wc_free_string_list = core->wc_free_string_list; + + if (methods->default_string == NULL) + methods->default_string = core->default_string; + + return True; +} + +extern Bool _fallcInitCTInfo(); + +static Bool +initialize(XLCd lcd) +{ + XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd); + XLCdPublicMethodsPart *pub_methods = &publicMethods.pub; + XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd); + char lang[128], terr[128], code[128], *str; + char *name; +#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) + char siname[256]; + char *_fallcMapOSLocaleName(); +#endif + + _fallcInitCTInfo(); + + if (initialize_core(lcd) == False) + return False; + + name = lcd->core->name; +#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) + name = _fallcMapOSLocaleName(name, siname); +#endif + + if (_fallcResolveLocaleName(name, NULL, lang, terr, code) == 0) + return False; + + str = (char*) Xmalloc(strlen(name) + strlen(lang) + strlen(terr) + + strlen(code) + 4); + if (str == NULL) + return False; + + strcpy(str, name); + pub->siname = str; + str += strlen(str) + 1; + + strcpy(str, lang); + pub->language = str; + str += strlen(str) + 1; + + strcpy(str, terr); + pub->territory = str; + str += strlen(str) + 1; + + strcpy(str, code); + pub->codeset = str; + + if (pub->default_string == NULL) + pub->default_string = ""; + + if (methods->get_values == NULL) + methods->get_values = pub_methods->get_values; + + if (methods->get_resource == NULL) + methods->get_resource = pub_methods->get_resource; + + return load_public(lcd); +} + +static void +destroy_core(XLCd lcd) +{ + if (lcd->core) { + if (lcd->core->name) + Xfree(lcd->core->name); + Xfree(lcd->core); + } + + if (lcd->methods) + Xfree(lcd->methods); + + Xfree(lcd); +} + +static void +destroy(XLCd lcd) +{ + XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd); + + _fallcDestroyLocaleDataBase(lcd); + + if (pub->siname) + Xfree(pub->siname); + if (pub->encoding_name) + Xfree(pub->encoding_name); + + destroy_core(lcd); +} + +static XlcResource resources[] = { + { XlcNCodeset, NULLQUARK, sizeof(char *), + XOffsetOf(XLCdPublicRec, pub.codeset), XlcGetMask }, + { XlcNDefaultString, NULLQUARK, sizeof(char *), + XOffsetOf(XLCdPublicRec, pub.default_string), XlcGetMask }, + { XlcNEncodingName, NULLQUARK, sizeof(char *), + XOffsetOf(XLCdPublicRec, pub.encoding_name), XlcGetMask }, + { XlcNLanguage, NULLQUARK, sizeof(char *), + XOffsetOf(XLCdPublicRec, pub.language), XlcGetMask }, + { XlcNMbCurMax, NULLQUARK, sizeof(int), + XOffsetOf(XLCdPublicRec, pub.mb_cur_max), XlcGetMask }, + { XlcNStateDependentEncoding, NULLQUARK, sizeof(Bool), + XOffsetOf(XLCdPublicRec, pub.is_state_depend), XlcGetMask }, + { XlcNTerritory, NULLQUARK, sizeof(char *), + XOffsetOf(XLCdPublicRec, pub.territory), XlcGetMask } +}; + +static char * +get_values(XLCd lcd, XlcArgList args, int num_args) +{ + XLCdPublic pub = (XLCdPublic) lcd->core; + + if (resources[0].xrm_name == NULLQUARK) + _fallcCompileResourceList(resources, XlcNumber(resources)); + + return _fallcGetValues((XPointer) pub, resources, XlcNumber(resources), args, + num_args, XlcGetMask); +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcPublic.h b/cde/programs/dtudcfonted/libfal/_fallcPublic.h new file mode 100644 index 000000000..9bb73fec3 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcPublic.h @@ -0,0 +1,267 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XlcPublic.h 1.3 - Fujitsu source for CDEnext 95/12/07 10:53:08 */ +/* $XConsortium: _fallcPublic.h /main/1 1996/04/08 15:18:31 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + +#ifndef _XLCPUBLIC_H_ +#define _XLCPUBLIC_H_ + +#include "_fallcint.h" + +#define XlcNCharSize "charSize" +#define XlcNCodeset "codeset" +#define XlcNControlSequence "controlSequence" +#define XlcNDefaultString "defaultString" +#define XlcNEncodingName "encodingName" +#define XlcNLanguage "language" +#define XlcNMbCurMax "mbCurMax" +#define XlcNName "name" +#define XlcNSetSize "setSize" +#define XlcNSide "side" +#define XlcNStateDependentEncoding "stateDependentEncoding" +#define XlcNTerritory "territory" + +typedef enum { + XlcUnknown, XlcC0, XlcGL, XlcC1, XlcGR, XlcGLGR, XlcOther, XlcNONE +} XlcSide; + +typedef struct _FonScope { + unsigned long start; + unsigned long end; + unsigned long shift; + unsigned long shift_direction; +} FontScopeRec, *FontScope; + +typedef struct _UDCArea { + unsigned long start,end; +} UDCAreaRec, *UDCArea; + +typedef struct _XlcCharSetRec *XlcCharSet; + +typedef char* (*XlcGetCSValuesProc)( + XlcCharSet /* charset */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef struct _XlcCharSetRec { + char *name; /* character set name */ + XrmQuark xrm_name; + char *encoding_name; /* XLFD encoding name */ + XrmQuark xrm_encoding_name; + XlcSide side; /* GL, GR or others */ + int char_size; /* number of bytes per character */ + int set_size; /* graphic character sets */ + char *ct_sequence; /* control sequence of CT */ + XlcGetCSValuesProc get_values; + /* UDC */ + Bool string_encoding; + UDCArea udc_area; + int udc_area_num; +} XlcCharSetRec; + +/* + * conversion methods + */ + +typedef struct _XlcConvRec *XlcConv; + +typedef XlcConv (*XlcOpenConverterProc)( + XLCd /* from_lcd */, + char* /* from_type */, + XLCd /* to_lcd */, + char* /* to_type */ +); + +typedef void (*XlcCloseConverterProc)( + XlcConv /* conv */ +); + +typedef int (*XlcConvertProc)( + XlcConv /* conv */, + XPointer* /* from */, + int* /* from_left */, + XPointer* /* to */, + int* /* to_left */, + XPointer* /* args */, + int /* num_args */ +); + +typedef void (*XlcResetConverterProc)( + XlcConv /* conv */ +); + +typedef struct _XlcConvMethodsRec{ + XlcCloseConverterProc close; + XlcConvertProc convert; + XlcResetConverterProc reset; +} XlcConvMethodsRec, *XlcConvMethods; + +/* + * conversion data + */ + +#define XlcNMultiByte "multiByte" +#define XlcNWideChar "wideChar" +#define XlcNCompoundText "compoundText" +#define XlcNString "string" +#define XlcNCharSet "charSet" +#define XlcNCTCharSet "CTcharSet" +#define XlcNChar "char" + +typedef struct _XlcConvRec { + XlcConvMethods methods; + XPointer state; +} XlcConvRec; + + +_XFUNCPROTOBEGIN + +extern Bool _falInitOM( + XLCd /* lcd */ +); + +extern Bool _XInitIM( + XLCd /* lcd */ +); + +extern char *_falGetLCValues( + XLCd /* lcd */, + ... +); + +extern XlcCharSet _fallcGetCharSet( + char* /* name */ +); + +extern Bool _fallcAddCharSet( + XlcCharSet /* charset */ +); + +extern char *_fallcGetCSValues( + XlcCharSet /* charset */, + ... +); + +extern XlcConv _fallcOpenConverter( + XLCd /* from_lcd */, + char* /* from_type */, + XLCd /* to_lcd */, + char* /* to_type */ +); + +extern void _fallcCloseConverter( + XlcConv /* conv */ +); + +extern int _fallcConvert( + XlcConv /* conv */, + XPointer* /* from */, + int* /* from_left */, + XPointer* /* to */, + int* /* to_left */, + XPointer* /* args */, + int /* num_args */ +); + +extern void _fallcResetConverter( + XlcConv /* conv */ +); + +extern Bool _fallcSetConverter( + XLCd /* from_lcd */, + char* /* from_type */, + XLCd /* to_lcd */, + char* /* to_type */, + XlcOpenConverterProc /* open_converter */ +); + +extern void _fallcGetResource( + XLCd /* lcd */, + char* /* category */, + char* /* class */, + char*** /* value */, + int* /* count */ +); + +extern char *_fallcFileName( + XLCd /* lcd */, + char* /* category */ +); + +extern int _falwcslen( + wchar_t* /* wstr */ +); + +extern wchar_t *_falwcscpy( + wchar_t* /* wstr1 */, + wchar_t* /* wstr2 */ +); + +extern int _fallcCompareISOLatin1( + char* /* str1 */, + char* /* str2 */ +); + +extern int _fallcNCompareISOLatin1( + char* /* str1 */, + char* /* str2 */, + int /* len */ +); + +_XFUNCPROTOEND + +#endif /* _XLCPUBLIC_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_fallcRM.c b/cde/programs/dtudcfonted/libfal/_fallcRM.c new file mode 100644 index 000000000..478a28351 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcRM.c @@ -0,0 +1,136 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcRM.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:40 */ +/* $XConsortium: _fallcRM.c /main/1 1996/04/08 15:18:41 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" +#include <stdio.h> + +typedef struct _StateRec { + XLCd lcd; + XlcConv conv; +} StateRec, *State; + +static void +mbinit(XPointer state) +{ + _fallcResetConverter(((State) state)->conv); +} + +static char +mbchar(XPointer state, char *str, char *lenp) +{ + XlcConv conv = ((State) state)->conv; + XlcCharSet charset; + char *from, *to, buf[BUFSIZ]; + int from_left, to_left; + XPointer args[1]; + + from = str; + *lenp = from_left = XLC_PUBLIC(((State) state)->lcd, mb_cur_max); + to = buf; + to_left = BUFSIZ; + args[0] = (XPointer) &charset; + + _fallcConvert(conv, (XPointer *) &from, &from_left, (XPointer *) &to, + &to_left, args, 1); + + *lenp -= from_left; + + /* XXX */ + return buf[0]; +} + +static void +mbfinish(XPointer state) +{ +} + +static char * +lcname(XPointer state) +{ + return ((State) state)->lcd->core->name; +} + +static void +destroy(XPointer state) +{ + _fallcCloseConverter(((State) state)->conv); + _falCloseLC(((State) state)->lcd); + Xfree((char *) state); +} + +static XrmMethodsRec rm_methods = { + mbinit, + mbchar, + mbfinish, + lcname, + destroy +} ; + +XrmMethods +_falrmDefaultInitParseInfo(XLCd lcd, XPointer *rm_state) +{ + State state; + + state = (State) Xmalloc(sizeof(StateRec)); + if (state == NULL) + return (XrmMethods) NULL; + + state->lcd = lcd; + state->conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNChar); + if (state->conv == NULL) { + Xfree((char *) state); + + return (XrmMethods) NULL; + } + + *rm_state = (XPointer) state; + + return &rm_methods; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcSjis.c b/cde/programs/dtudcfonted/libfal/_fallcSjis.c new file mode 100644 index 000000000..5a2b72d88 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcSjis.c @@ -0,0 +1,1475 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcSjis.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:40 */ +/* $XConsortium: _fallcSjis.c /main/1 1996/04/08 15:18:51 cde-fuj $ */ +/**************************************************************** + + Copyright 1992, 1993 by FUJITSU LIMITED + Copyright 1993 by Fujitsu Open Systems Solutions, Inc. + Copyright 1994 by Sony Corporation + +Permission to use, copy, modify, distribute and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED, +Fujitsu Open Systems Solutions, Inc. and Sony Corporation not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. +FUJITSU LIMITED, Fujitsu Open Systems Solutions, Inc. and +Sony Corporation make no representations about the suitability of +this software for any purpose. It is provided "as is" without +express or implied warranty. + +FUJITSU LIMITED, FUJITSU OPEN SYSTEMS SOLUTIONS, INC. AND SONY +CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL FUJITSU OPEN SYSTEMS SOLUTIONS, INC., FUJITSU LIMITED +AND SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. + + Authors: Jeffrey Bloomfield (jeffb@ossi.com) + Shigeru Yamada (yamada@ossi.com) + Yoshiyuki Segawa (segawa@ossi.com) + Modifier:Makoto Wakamatsu Sony Corporation + makoto@sm.sony.co.jp + +*****************************************************************/ + +#include "_fallibint.h" +#include "_fallcGeneric.h" + +#include <ctype.h> + +#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */ +#define CS1 codesets[1] /* Codeset 1 - Kanji */ +#define CS2 codesets[2] /* Codeset 2 - Half-Kana */ +#define CS3 codesets[3] /* Codeset 3 - User defined */ + +#define ascii (codeset->cs_num == 0) +#define kanji (codeset->cs_num == 1) +#define kana (codeset->cs_num == 2) +#define userdef (codeset->cs_num == 3) + +#define ASCII_CODESET 0 +#define KANJI_CODESET 1 +#define KANA_CODESET 2 +#define USERDEF_CODESET 3 +#define MAX_CODESETS 4 + +#define GR 0x80 /* begins right-side (non-ascii) region */ +#define GL 0x7f /* ends left-side (ascii) region */ + +#define isleftside(c) (((c) & GR) ? 0 : 1) +#define isrightside(c) (!isleftside(c)) + +typedef unsigned char Uchar; +typedef unsigned long Ulong; +typedef unsigned int Uint; + +/* Acceptable range for 2nd byte of SJIS multibyte char */ +#define VALID_MULTIBYTE(c) \ + ((0x40<=((Uchar)c) && ((Uchar)c)<=0x7e) \ + || (0x80<=((Uchar)c) && ((Uchar)c)<=0xfc)) + +#ifndef iskanji +#define iskanji(c) ((0x81<=((Uchar)c) && ((Uchar)c)<=0x9f) \ + || (0xe0<=((Uchar)c) && ((Uchar)c)<=0xef)) +#endif /* !iskanji */ + +#ifndef iskana +#define iskana(c) (0xa1<=((Uchar)c) && ((Uchar)c)<=0xdf) +#endif /* !iskana */ + +#define isuserdef(c) (0xf0<=((Uchar)c) && ((Uchar)c)<=0xfc) + +#define BIT8OFF(c) ((c) & GL) +#define BIT8ON(c) ((c) | GR) + + +static void jis_to_sjis(); +static void sjis_to_jis(); +static CodeSet wc_codeset(); + + +/* + * Notes: + * 1. 16-bit widechar format is limited to 14 data bits. Since the 2nd byte + * of SJIS multibyte chars are in the ranges of 0x40 - 7E and 0x80 - 0xFC, + * SJIS cannot map directly into 16 bit widechar format within the confines + * of a single codeset. Therefore, for SJIS widechar conversion, SJIS Kanji + * is mapped into the JIS codeset. (The algorithms used in jis_to_sjis() + * and sjis_to_jis() are from Ken Lunde (lunde@mv.us.adobe.com) and are in + * the public domain.) + * 2. Defining FORCE_INDIRECT_CONVERTER (see _fallcEucLoader()) + * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()). + * 3. Using direct converters (e.g. mbstowcs()) decreases conversion + * times by 20-40% (depends on specific converter used). + */ + + +static int +sjis_mbstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + + XLCd lcd = (XLCd)conv->state; + + int chr_len = 0; + int outbuf = 0; + int shift_mult = 0; + Uint chrcode = 0; + + Uchar ch, ch2; + Uint wc_encode = 0; + Uint wc_tmp = 0; + + Bool new_char; + + int firstbyte; + int length; + int num_conv; + int unconv_num = 0; + + XPointer inbufptr = *from; + wchar_t *outbufptr = (wchar_t *) *to; + wchar_t *outbuf_base = outbufptr; + + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (new_char = True, firstbyte = True; *from_left > 0; (*from_left)--) { + + ch = *inbufptr++; + + if (firstbyte) { + if (ASCII_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + if (isascii(ch)) { + length = CS0->length; + *outbufptr++ = (wchar_t)ch; + continue; + } + else if (iskanji(ch)) { + if (KANJI_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + firstbyte = False; + length = CS1->length; + if (*from_left < length || *to_left < length) + return -1; + wc_encode = CS1->wc_encoding; + ch2 = *inbufptr; + sjis_to_jis(&ch, &ch2); + chrcode = ch; + } + else if (iskana(ch)) { + if (KANA_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + length = CS2->length; + wc_encode = CS2->wc_encoding; + chrcode = BIT8OFF(ch); + } + else if (isuserdef(ch)) { + if (USERDEF_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + firstbyte = False; + length = CS3->length; + if (*from_left < length || *to_left < length) + return -1; + wc_encode = CS3->wc_encoding; + ch2 = *inbufptr; + sjis_to_jis(&ch, &ch2); + chrcode = ch; + } + else /* unknown */ { + unconv_num++; + (*from_left)--; + continue; + } + } else { /* 2nd byte of multibyte char */ + if (!VALID_MULTIBYTE((Uchar) *(inbufptr-1))) { + unconv_num++; + firstbyte = True; + } + chrcode = ch2; + } + + if (new_char) { + chr_len = length; + shift_mult = length - 1; + new_char = False; + } + + chrcode <<= (wc_shift * shift_mult); + shift_mult--; + wc_tmp |= chrcode; + if (--chr_len == 0) { + wc_tmp |= wc_encode; + *outbufptr++ = wc_tmp; + + firstbyte = True; + new_char = True; + wc_tmp = (Uint)0; + } + + } /* end for */ + + *to = (XPointer)outbufptr; + + if ((num_conv = outbufptr - outbuf_base) > 0) + (*to_left) -= num_conv; + + return unconv_num; +} + + +#define byte1 (length == codeset->length - 1) +#define byte2 (byte1 == 0) + +static int +sjis_wcstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + wchar_t *inbufptr = (wchar_t *) *from; + XPointer outbufptr = *to; + XPointer outbuf_base = outbufptr; + wchar_t wch; + int length; + Uchar tmp; + Uchar t1, t2; + int num_conv; + int unconv_num = 0; + + XLCd lcd = (XLCd)conv->state; + CodeSet codeset; + Ulong wc_encoding_mask = XLC_GENERIC(lcd, wc_encode_mask); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (; *from_left > 0 ; (*from_left)-- ) { + + wch = *inbufptr++; + + if (!(codeset = wc_codeset(lcd, wch))) { + unconv_num++; + (*from_left)--; + continue; + } + + length = codeset->length; + wch ^= (wchar_t)codeset->wc_encoding; + + do { + length--; + tmp = wch>>(wchar_t)( (Ulong)length * wc_shift); + + if (kana) + tmp = BIT8ON(tmp); + + else if (byte1 && (kanji || userdef)) { + t1 = BIT8OFF(tmp); + continue; + } + + else if (byte2 && (kanji || userdef)) { + t2 = BIT8OFF(tmp); + jis_to_sjis(&t1, &t2); + *outbufptr++ = (char)t1; + tmp = t2; + } + + *outbufptr++ = (char)tmp; + } while (length); + + } /* end for */ + + *to = (XPointer)outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; +} +#undef byte1 +#undef byte2 + +/* + * sjis<->jis conversion for widechar kanji (See Note at top of file) + */ +static void +sjis_to_jis(Uchar *p1, Uchar *p2) +{ + Uchar c1 = *p1; + Uchar c2 = *p2; + Uchar adjust = c2 < 0x9f; + Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0; + Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e; + + *p1 = ((c1 - rowOffset) << 1) - adjust; + *p2 -= cellOffset; +} + +static void +jis_to_sjis(Uchar *p1, Uchar *p2) +{ + Uchar c1 = *p1; + Uchar c2 = *p2; + Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0; + Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e; + + *p1 = ((Uchar)(c1 + 1) >> 1) + rowOffset; + *p2 = c2 + cellOffset; +} + +static CodeSet +wc_codeset(XLCd lcd, wchar_t wch) +{ + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int end = XLC_GENERIC(lcd, codeset_num); + Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask)); + + for (; --end >= 0; codesets++) + if ( widech == (*codesets)->wc_encoding ) + return *codesets; + + return NULL; +} + + +static int +sjis_mbtocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + XlcCharSet charset = NULL; + int char_size = 0; + int unconv_num = 0; + char *src = *from, *dst = *to; + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + + + if (iskanji(*src)) { + if (KANJI_CODESET >= codeset_num) + return -1; + charset = *CS1->charset_list; + char_size = charset->char_size; + + if (*from_left >= char_size && *to_left >= char_size) { + *dst++ = *src++; + *dst++ = *src++; + if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */ + unconv_num++; + sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1)); + } else + return -1; + } + else if (isuserdef(*src)) { + if (USERDEF_CODESET >= codeset_num) + return -1; + charset = *CS3->charset_list; + char_size = charset->char_size; + + if (*from_left >= char_size && *to_left >= char_size) { + *dst++ = *src++; + *dst++ = *src++; + if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */ + unconv_num++; + sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1)); + } else + return -1; + } + else if (isascii(*src)) { + if (ASCII_CODESET >= codeset_num) + return -1; + charset = *CS0->charset_list; + char_size = charset->char_size; + + if (*from_left >= char_size && *to_left >= char_size) + *dst++ = *src++; + else + return -1; + } + else if (iskana(*src)) { + if (KANA_CODESET >= codeset_num) + return -1; + charset = *CS2->charset_list; + char_size = charset->char_size; + + if (*from_left >= char_size && *to_left >= char_size) + *dst++ = *src++; + else + return -1; + } + else /* unknown */ + return -1; + + *from_left -= char_size; + *to_left -= char_size; + + *to = dst; + *from = src; + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return unconv_num; +} + + +static int +sjis_mbstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd) conv->state; + char *tmp_from, *tmp_to; + int tmp_from_left, tmp_to_left; + XlcCharSet charset, tmp_charset; + XPointer tmp_args[1]; + int unconv_num = 0, ret; + + + +/* Determine the charset of the segment and convert one characater: */ + + tmp_args[0] = (XPointer) &charset; /* charset from sjis_mbtocs() */ + while + ((ret = sjis_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0) + unconv_num += ret; + if ( ret < 0 ) + return ret; + + tmp_from = *from; + tmp_from_left = *from_left; + tmp_to_left = *to_left; + tmp_to = *to; + +/* Convert remainder of the segment: */ + + tmp_args[0] = (XPointer) &tmp_charset; + while( (ret = sjis_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to, + &tmp_to_left, tmp_args, 1)) >= 0 ) { + + if (ret > 0) { + unconv_num += ret; + continue; + } + + if (tmp_charset != charset) /* quit on end of segment */ + break; + + *from = tmp_from; + *from_left = tmp_from_left; + *to = tmp_to; + *to_left = tmp_to_left; + } + + if (num_args > 0) + *((XlcCharSet *) args[0]) = charset; + + return unconv_num; +} + +static int +sjis_wcstocs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd) conv->state; + wchar_t *wcptr = *((wchar_t **)from); + char *bufptr = *((char **) to); + wchar_t wch; + char *tmpptr; + int length; + CodeSet codeset; + Ulong wc_encoding; + int buf_len = *to_left; + int unconv_num = 0; + int wcstr_len = *from_left; + + + if (!(codeset = wc_codeset(lcd, *wcptr))) + return -1; + + if (wcstr_len < buf_len / codeset->length) + buf_len = wcstr_len * codeset->length; + + wc_encoding = codeset->wc_encoding; + + for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { + wch = *wcptr; + + if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding) + break; + + length = codeset->length; + + buf_len -= length; + bufptr += length; + tmpptr = bufptr - 1; + + while (length--) { + *tmpptr-- = kana ? BIT8ON(wch) : BIT8OFF(wch); + wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits); + } + } + + if (num_args > 0) + *((XlcCharSet *) args[0]) = *codeset->charset_list; + + *from_left -= wcptr - (wchar_t *) *from; + *from = (XPointer) wcptr; + + *to_left -= bufptr - *to; + *to = bufptr; + + return 0; +} + +static CodeSet +GetCodeSetFromCharSet(XLCd lcd, XlcCharSet charset) +{ + CodeSet *codeset = XLC_GENERIC(lcd, codeset_list); + XlcCharSet *charset_list; + int codeset_num, num_charsets; + + codeset_num = XLC_GENERIC(lcd, codeset_num); + + for ( ; codeset_num-- > 0; codeset++) { + num_charsets = (*codeset)->num_charsets; + charset_list = (*codeset)->charset_list; + + for ( ; num_charsets-- > 0; charset_list++) + if (*charset_list == charset) + return *codeset; + } + + return (CodeSet) NULL; +} + + +static int +sjis_cstombs( + XlcConv conv, + char **from, + int *from_left, + char **to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd) conv->state; + char *csptr = *from; + char *bufptr = *to; + int csstr_len = *from_left; + int buf_len = *to_left; + int length; + CodeSet codeset; + EncodingType type; + int cvt_length = 0; + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + + + if (num_args < 1) + return -1; + + if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]))) + return -1; + + csstr_len /= codeset->length; + buf_len /= codeset->length; + if (csstr_len < buf_len) + buf_len = csstr_len; + + cvt_length += buf_len * codeset->length; + + if (bufptr) { + while (buf_len--) { + length = codeset->length; + while (length--) + *bufptr++ = codeset->length == 1 && codeset->side == XlcGR ? + BIT8ON(*csptr++) : BIT8OFF(*csptr++); + + if (codeset->length == 2) + jis_to_sjis((Uchar *)(bufptr-2), (Uchar *)(bufptr-1)); + } + } + + *from_left -= csptr - *from; + *from = csptr; + + if (bufptr) + *to += cvt_length; + *to_left -= cvt_length; + + + return 0; +} + +static int +sjis_cstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd) conv->state; + char *csptr = (char *) *from; + wchar_t *bufptr = (wchar_t *) *to; + wchar_t *toptr = (wchar_t *) *to; + int csstr_len = *from_left; + int buf_len = *to_left; + wchar_t wch; + int length; + Ulong wc_shift_bits = (int)XLC_GENERIC(lcd, wc_shift_bits); + CodeSet codeset; + + + if (num_args < 1) + return -1; + + if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]))) + return -1; + + csstr_len /= codeset->length; + if (csstr_len < buf_len) + buf_len = csstr_len; + + *to_left -= buf_len; + + if (bufptr) { + + toptr += buf_len; + *to = (XPointer) toptr; + + while (buf_len--) { + wch = (wchar_t) BIT8OFF(*csptr); + csptr++; + + length = codeset->length - 1; + while (length--) { + wch = (wch << wc_shift_bits) | BIT8OFF(*csptr); + csptr++; + } + *bufptr++ = wch | codeset->wc_encoding; + } + } + + *from_left -= csptr - *from; + *from = csptr; + + return 0; +} + + +/* + * Stripped down Direct CT converters for SJIS + */ + +#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \ + BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \ + BIT8OFF(c) != 0x1b) + +typedef struct _CTDataRec { + int side; + int length; + char *name; + Ulong wc_encoding; + char *ct_encoding; + int ct_encoding_len; + int set_size; + Uchar min_ch; + Uchar ct_type; +} CTDataRec, *CTData; + +typedef struct _StateRec { + CTData GL_charset; + CTData GR_charset; + CTData charset; +} StateRec, *State; + +static enum { CT_STD, CT_NSTD, CT_DIR, CT_EXT0, CT_EXT1, CT_EXT2, CT_VER } + ct_types; + +static CTDataRec ctdata[] = +{ + { XlcGL, 1, "ISO8859-1:GL", 0, "\033(B" , 3, 0, 0, CT_STD }, + { XlcGR, 1, "ISO8859-1:GR", 0, "\033-A" , 3, 0, 0, CT_STD }, + { XlcGL, 1, "JISX0201.1976-0:GL", 0, "\033(J" , 3, 0, 0, CT_STD }, + { XlcGR, 1, "JISX0201.1976-0:GR", 0, "\033)I" , 3, 0, 0, CT_STD }, + { XlcGL, 2, "JISX0208.1983-0:GL", 0, "\033$(B" , 4, 0, 0, CT_STD }, + { XlcGR, 2, "JISX0208.1983-0:GR", 0, "\033$)B" , 4, 0, 0, CT_STD }, + { XlcGL, 2, "JISX0212.1990-0:GL", 0, "\033$(D" , 4, 0, 0, CT_STD }, + { XlcGR, 2, "JISX0212.1990-0:GR", 0, "\033$)D" , 4, 0, 0, CT_STD }, + { XlcUnknown, 0, "Ignore-Ext-Status?", 0, "\033#" , 2, 0, 0, CT_VER }, + { XlcUnknown, 0, "NonStd-?-OctetChar", 0, "\033%/0" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 1, "NonStd-1-OctetChar", 0, "\033%/1" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 2, "NonStd-2-OctetChar", 0, "\033%/2" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 3, "NonStd-3-OctetChar", 0, "\033%/3" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 4, "NonStd-4-OctetChar", 0, "\033%/4" , 4, 0, 0, CT_NSTD }, + { XlcUnknown, 0, "Extension-2" , 0, "\033%/" , 3, 0, 0, CT_EXT2 }, + { XlcUnknown, 0, "Extension-0" , 0, "\033" , 1, 0, 0, CT_EXT0 }, + { XlcUnknown, 0, "Begin-L-to-R-Text", 0, "\2331]" , 3, 0, 0, CT_DIR }, + { XlcUnknown, 0, "Begin-R-to-L-Text", 0, "\2332]" , 3, 0, 0, CT_DIR }, + { XlcUnknown, 0, "End-Of-String", 0, "\233]" , 2, 0, 0, CT_DIR }, + { XlcUnknown, 0, "Extension-1" , 0, "\233" , 1, 0, 0, CT_EXT1 }, +}; + +/* Note on above table: sjis_ctstombs() and sjis_ctstowcs() parser depends on + * certain table entries occurring in decreasing string length-- + * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries. + * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries. + */ + +static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)]; +static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1; +static enum { Ascii, Kanji, Kana, Userdef } cs_nums; + + +/* + * initCTptr(): Set ctptr[] to point at ctdata[], indexed by codeset_num. + */ +static void +initCTptr(XLCd lcd) +{ + int num_codesets = XLC_GENERIC(lcd, codeset_num); + int num_charsets; + int i, j; + CodeSet *codesets = XLC_GENERIC(lcd, codeset_list); + CodeSet codeset; + XlcCharSet charset; + CTData ctdp = ctdata; + + ctdptr[Ascii] = &ctdata[0]; /* failsafe */ + + for (i = 0; i < num_codesets; i++) { + + codeset = codesets[i]; + num_charsets = codeset->num_charsets; + + for (j = 0; j < num_charsets; j++) { + + charset = codeset->charset_list[j]; + + for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++) + + if (! strcmp(ctdp->name, charset->name)) { + + ctdptr[codeset->cs_num] = ctdp; + + ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding; + + ctdptr[codeset->cs_num]->set_size = + charset->set_size; + + ctdptr[codeset->cs_num]->min_ch = + charset->set_size == 94 && + (ctdptr[codeset->cs_num]->length > 1 || + ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20; + + break; + } + } + } +} + + +static int +sjis_mbstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ct_len = *to_left; + int cs_num; + int clen; + int unconv_num = 0; + int num_conv; + XPointer inbufptr = *from; + char *ctptr = *to; + XPointer ct_base = ctptr; + + StateRec ct_state; + CTData charset; + XLCd lcd = (XLCd) conv->state; + int codeset_num = XLC_GENERIC(lcd, codeset_num); + + +/* Initial State: */ + + ct_state.GL_charset = ctdptr[Ascii]; + ct_state.GR_charset = NULL; + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (;*from_left > 0; (*from_left) -= charset->length) { + + if (iskanji(*inbufptr)) { + if (KANJI_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Kanji; + charset = ctdptr[Kanji]; + if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1))) + unconv_num++; + } + else if (isuserdef(*inbufptr)) { + if (USERDEF_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Userdef; + charset = ctdptr[Userdef]; + if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1))) + unconv_num++; + } + else if (isascii(*inbufptr)) { + if (ASCII_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Ascii; + charset = ctdptr[Ascii]; + } + else if (iskana(*inbufptr)) { + if (KANA_CODESET >= codeset_num) { + unconv_num++; + (*from_left)--; + continue; + } + cs_num = Kana; + charset = ctdptr[Kana]; + } + else { /* unknown */ + unconv_num++; + (*from_left)--; + continue; + } + + if ( (charset->side == XlcGR && charset != ct_state.GR_charset) || + (charset->side == XlcGL && charset != ct_state.GL_charset) ) { + + ct_len -= ctdptr[cs_num]->ct_encoding_len; + if (ct_len < 0) { + unconv_num++; + break; + } + + if (ctptr) { + strcpy(ctptr, ctdptr[cs_num]->ct_encoding); + ctptr += ctdptr[cs_num]->ct_encoding_len; + } + } + + clen = charset->length; + do { + *ctptr++ = *inbufptr++; + } while (--clen); + + if (charset->length >= 2) { + sjis_to_jis((Uchar *)(ctptr-2), (Uchar *)(ctptr-1)); + if (BADCHAR(charset->min_ch, *(ctptr-2)) || + BADCHAR(charset->min_ch, *(ctptr-1))) { + unconv_num++; + continue; + } + } + else + if (BADCHAR(charset->min_ch, *(ctptr-1))) { + unconv_num++; + continue; + } + + if (charset->side == XlcGR) + ct_state.GR_charset = charset; + else if (charset->side == XlcGL) + ct_state.GL_charset = charset; + } + + *to = (XPointer)ctptr; + + if ((num_conv = (int)(ctptr - ct_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; + +} + + +#define byte1 (length == codeset->length - 1) +#define byte2 (byte1 == 0) + +static int +sjis_wcstocts( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + int ct_len = *to_left; + wchar_t *inbufptr = (wchar_t *) *from; + char *ctptr = *to; + XPointer ct_base = ctptr; + wchar_t wch; + int length; + Uchar tmp; + Uchar t1 = 0, t2; + int num_conv; + + StateRec ct_state; + XLCd lcd = (XLCd)conv->state; + CTData charset; + CodeSet codeset; + int unconv_num = 0; + Ulong wc_encoding_mask = XLC_GENERIC(lcd, wc_encode_mask); + Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits); + + +/* Initial State: */ + ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */ + ct_state.GR_charset = NULL; + + if (*from_left > *to_left) + *from_left = *to_left; + + for (; *from_left > 0 ; (*from_left)-- ) { + + wch = *inbufptr++; + + if (!(codeset = wc_codeset(lcd, wch))) { + unconv_num++; + (*from_left)--; + continue; + } + + charset = ctdptr[codeset->cs_num]; + + length = codeset->length; + wch ^= (wchar_t)codeset->wc_encoding; + + if ( (charset->side == XlcGR && charset != ct_state.GR_charset) || + (charset->side == XlcGL && charset != ct_state.GL_charset) ) { + + ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len; + if (ct_len < 0) { + unconv_num++; + break; + } + + if (ctptr) { + strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding); + ctptr += ctdptr[codeset->cs_num]->ct_encoding_len; + } + + } + + if (charset->side == XlcGR) + ct_state.GR_charset = charset; + else if (charset->side == XlcGL) + ct_state.GL_charset = charset; + + do { + length--; + tmp = wch>>(wchar_t)( (Ulong)length * wc_shift); + + if (kana) { + if (BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + *ctptr++ = (char)BIT8ON(tmp); + } + + else if (byte1 && (kanji || userdef)) { + t1 = tmp; + } + + else if (byte2 && (kanji || userdef)) { + if (BADCHAR(charset->min_ch, (char)t1) || + BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + + *ctptr++ = (char)BIT8OFF(t1); + *ctptr++ = (char)BIT8OFF(tmp); + } + + else { + if (BADCHAR(charset->min_ch, (char)tmp)) { + unconv_num++; + break; + } + *ctptr++ = (char)tmp; + } + } while (length); + + } /* end for */ + + *to = (XPointer)ctptr; + + if ((num_conv = (int)(ctptr - ct_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; +} +#undef byte1 +#undef byte2 + +#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++; +#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++; + +static int +sjis_ctstombs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XPointer inbufptr = *from; + XPointer outbufptr = *to; + XPointer inbuf_base; + XPointer outbuf_base = outbufptr; + int clen, length; + int unconv_num = 0; + int num_conv; + unsigned int ct_seglen = 0; + Uchar ct_type; + CTData ctdp = ctdata; /* default */ + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length) + { + ct_type = CT_STD; + if (*inbufptr == '\033' || *inbufptr == (char)'\233') { + + for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { + + if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len)) + { + inbufptr += ctdp->ct_encoding_len; + (*from_left) -= ctdp->ct_encoding_len; + if( ctdp->length ) { + length = ctdp->length; + if( *from_left < length ) { + *to = (XPointer)outbufptr; + *to_left -= outbufptr - outbuf_base; + return( unconv_num + *from_left ); + } + } + ct_type = ctdp->ct_type; + break; + } + } + if (ctdp > ctd_endp) /* failed to match CT sequence */ + unconv_num++; + } + +/* The following code insures that non-standard encodings, direction, extension, + * and version strings are ignored; subject to change in future. + */ + switch (ct_type) { + case CT_STD: + break; + case CT_EXT2: + inbufptr++; + (*from_left)--; + case CT_NSTD: + ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2; + inbufptr += ct_seglen; + (*from_left) -= ct_seglen; + continue; + case CT_EXT0: + inbuf_base = inbufptr; + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + (*from_left) -= ct_seglen; + continue; + case CT_EXT1: + inbuf_base = inbufptr; + SKIP_P(inbufptr); + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + (*from_left) -= ct_seglen; + continue; + case CT_DIR: + continue; + case CT_VER: + inbufptr += 2; + (*from_left) -= 2; + continue; + } + + clen = length; + do { + *outbufptr++ = *inbufptr++; + } while (--clen); + + if (length >= 2) + jis_to_sjis((Uchar *)(outbufptr-2), (Uchar *)(outbufptr-1)); + } + + *to = (XPointer)outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + (*to_left) -= num_conv; + + return unconv_num; +} + + +static int +sjis_ctstowcs( + XlcConv conv, + XPointer *from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XLCd lcd = (XLCd)conv->state; + Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits); + XPointer inbufptr = *from; + XPointer inbuf_base; + wchar_t *outbufptr = (wchar_t *) *to; + wchar_t *outbuf_base = outbufptr; + int clen, length; + int num_conv; + int unconv_num = 0; + unsigned int ct_seglen = 0; + Uchar ct_type = 0; + int shift_mult; + wchar_t wc_tmp; + wchar_t wch; + Ulong wc_encoding; + CTData ctdp = ctdata; + + + if (*from_left > *to_left) + *from_left = *to_left; + + for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length ) + { + ct_type = CT_STD; + if (*inbufptr == '\033' || *inbufptr == (char)'\233') { + for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) { + + if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len)) + { + inbufptr += ctdp->ct_encoding_len; + (*from_left) -= ctdp->ct_encoding_len; + if( ctdp->length ) { + length = ctdp->length; + if( *from_left < length ) { + *to = (XPointer)outbufptr; + *to_left -= outbufptr - outbuf_base; + return( unconv_num + *from_left ); + } + } + ct_type = ctdp->ct_type; + break; + } + } + if (ctdp > ctd_endp) /* failed to match CT sequence */ + unconv_num++; + } + +/* The following block of code insures that non-standard encodings, direction, + * extension, and version strings are ignored; subject to change in future. + */ + switch (ct_type) { + case CT_STD: + break; + case CT_EXT2: + inbufptr++; + (*from_left)--; + case CT_NSTD: + ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2; + inbufptr += ct_seglen; + (*from_left) -= ct_seglen; + continue; + case CT_EXT0: + inbuf_base = inbufptr; + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + (*from_left) -= ct_seglen; + continue; + case CT_EXT1: + inbuf_base = inbufptr; + SKIP_P(inbufptr); + SKIP_I(inbufptr); + inbufptr++; + ct_seglen = (unsigned)(inbufptr - inbuf_base); + (*from_left) -= ct_seglen; + continue; + case CT_DIR: + continue; + case CT_VER: + inbufptr += 2; + (*from_left) -= 2; + continue; + } + wc_encoding = (ctdp == ctdptr[Kana] && isleftside(*inbufptr)) ? + ctdptr[Ascii]->wc_encoding : ctdp->wc_encoding; + + shift_mult = length - 1; + wch = (wchar_t)0; + clen = length; + + do { + wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult); + wch |= wc_tmp; + shift_mult--; + } while (--clen); + *outbufptr++ = wch | wc_encoding; + } + *to = (XPointer)outbufptr; + + if ((num_conv = (int)(outbufptr - outbuf_base)) > 0) + (*to_left) -= num_conv ; + + return unconv_num; + +} +#undef BADCHAR + +static void +close_converter(XlcConv conv) +{ + Xfree((char *) conv); +} + + +static XlcConv +create_conv(XLCd lcd, XlcConvMethods methods) +{ + XlcConv conv; + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == NULL) + return (XlcConv) NULL; + + conv->methods = methods; + conv->state = (XPointer) lcd; + return conv; +} + + +enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS, + WCSTOCTS, MBSTOCTS, CTSTOMBS, CTSTOWCS }; + +static XlcConvMethodsRec conv_methods[] = { + {close_converter, sjis_mbstocs, NULL }, + {close_converter, sjis_wcstocs, NULL }, + {close_converter, sjis_mbtocs, NULL }, + {close_converter, sjis_cstombs, NULL }, + {close_converter, sjis_cstowcs, NULL }, + {close_converter, sjis_mbstowcs, NULL }, + {close_converter, sjis_wcstombs, NULL }, + {close_converter, sjis_wcstocts, NULL }, + {close_converter, sjis_mbstocts, NULL }, + {close_converter, sjis_ctstombs, NULL }, + {close_converter, sjis_ctstowcs, NULL }, +}; + + +static XlcConv +open_mbstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOCS]); +} + +static XlcConv +open_wcstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOCS]); +} + +static XlcConv +open_mbtocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBTOCS]); +} + +static XlcConv +open_cstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CSTOMBS]); +} + +static XlcConv +open_cstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CSTOWCS]); +} + +static XlcConv +open_mbstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOWCS]); +} + +static XlcConv +open_wcstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOMBS]); +} + +static XlcConv +open_wcstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[WCSTOCTS]); +} + +static XlcConv +open_mbstocts(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[MBSTOCTS]); +} + +static XlcConv +open_ctstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CTSTOMBS]); +} + +static XlcConv +open_ctstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type) +{ + return create_conv(from_lcd, &conv_methods[CTSTOWCS]); +} + +XLCd +_fallcSjisLoader(char *name) +{ + XLCd lcd; + CodeSet *codeset_list; + + lcd = _fallcCreateLC(name, _fallcGenericMethods); + if (lcd == NULL) + return lcd; + + if ((_fallcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "sjis"))) { + _fallcDestroyLC(lcd); + return (XLCd) NULL; + } + + initCTptr(lcd); + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs); + +#ifndef FORCE_INDIRECT_CONVERTER + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs); + _fallcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts); + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs); +#endif + + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcStd.c b/cde/programs/dtudcfonted/libfal/_fallcStd.c new file mode 100644 index 000000000..a7404ae52 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcStd.c @@ -0,0 +1,293 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcStd.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:41 */ +/* $XConsortium: _fallcStd.c /main/1 1996/04/08 15:19:02 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" + +int +_fallcmbtowc(XLCd lcd, wchar_t *wstr, char *str, int len) +{ + static XLCd last_lcd = NULL; + static XlcConv conv = NULL; + XPointer from, to; + int from_left, to_left; + wchar_t tmp_wc; + + if (lcd == NULL) { + lcd = _fallcCurrentLC(); + if (lcd == NULL) + return -1; + } + if (str == NULL) + return XLC_PUBLIC(lcd, is_state_depend); + + if (conv && lcd != last_lcd) { + _fallcCloseConverter(conv); + conv = NULL; + } + + last_lcd = lcd; + + if (conv == NULL) { + conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar); + if (conv == NULL) + return -1; + } + + from = (XPointer) str; + from_left = len; + to = (XPointer) (wstr ? wstr : &tmp_wc); + to_left = 1; + + if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) + return -1; + + return (len - from_left); +} + +int +_fallcwctomb(XLCd lcd, char *str, wchar_t wc) +{ + static XLCd last_lcd = NULL; + static XlcConv conv = NULL; + XPointer from, to; + int from_left, to_left, length; + + if (lcd == NULL) { + lcd = _fallcCurrentLC(); + if (lcd == NULL) + return -1; + } + if (str == NULL) + return XLC_PUBLIC(lcd, is_state_depend); + + if (conv && lcd != last_lcd) { + _fallcCloseConverter(conv); + conv = NULL; + } + + last_lcd = lcd; + + if (conv == NULL) { + conv = _fallcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); + if (conv == NULL) + return -1; + } + + from = (XPointer) &wc; + from_left = 1; + to = (XPointer) str; + length = to_left = XLC_PUBLIC(lcd, mb_cur_max); + + if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) + return -1; + + return (length - to_left); +} + +int +_fallcmbstowcs(XLCd lcd, wchar_t *wstr, char *str, int len) +{ + XlcConv conv; + XPointer from, to; + int from_left, to_left, ret; + + if (lcd == NULL) { + lcd = _fallcCurrentLC(); + if (lcd == NULL) + return -1; + } + + conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar); + if (conv == NULL) + return -1; + + from = (XPointer) str; + from_left = strlen(str); + to = (XPointer) wstr; + to_left = len; + + if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) + ret = -1; + else { + ret = len - to_left; + if (wstr && to_left > 0) + wstr[ret] = (wchar_t) 0; + } + + _fallcCloseConverter(conv); + + return ret; +} + +int +_fallcwcstombs(XLCd lcd, char *str, wchar_t *wstr, int len) +{ + XlcConv conv; + XPointer from, to; + int from_left, to_left, ret; + + if (lcd == NULL) { + lcd = _fallcCurrentLC(); + if (lcd == NULL) + return -1; + } + + conv = _fallcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); + if (conv == NULL) + return -1; + + from = (XPointer) wstr; + from_left = _falwcslen(wstr); + to = (XPointer) str; + to_left = len; + + if (_fallcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) + ret = -1; + else { + ret = len - to_left; + if (str && to_left > 0) + str[ret] = '\0'; + } + + _fallcCloseConverter(conv); + + return ret; +} + + +int +_falmbtowc(wchar_t *wstr, char *str, int len) +{ + return _fallcmbtowc((XLCd) NULL, wstr, str, len); +} + +int +_falmblen(char *str, int len) +{ + return _falmbtowc((wchar_t *) NULL, str, len); +} + +int +_falwctomb(char *str, wchar_t wc) +{ + return _fallcwctomb((XLCd) NULL, str, wc); +} + +int +_falmbstowcs(wchar_t *wstr, char *str, int len) +{ + return _fallcmbstowcs((XLCd) NULL, wstr, str, len); +} + +int +_falwcstombs(char *str, wchar_t *wstr, int len) +{ + return _fallcwcstombs((XLCd) NULL, str, wstr, len); +} + +wchar_t * +_falwcscpy(wchar_t *wstr1, wchar_t *wstr2) +{ + wchar_t *wstr_tmp = wstr1; + + while (*wstr1++ = *wstr2++) + ; + + return wstr_tmp; +} + +wchar_t * +_falwcsncpy(wchar_t *wstr1, wchar_t *wstr2, int len) +{ + wchar_t *wstr_tmp = wstr1; + + while (len-- > 0) + if (!(*wstr1++ = *wstr2++)) + break; + + while (len-- > 0) + *wstr1++ = (wchar_t) 0; + + return wstr_tmp; +} + +int +_falwcslen(wchar_t *wstr) +{ + wchar_t *wstr_ptr = wstr; + + while (*wstr_ptr) + wstr_ptr++; + + return wstr_ptr - wstr; +} + +int +_falwcscmp(wchar_t *wstr1, wchar_t *wstr2) +{ + for ( ; *wstr1 && *wstr2; wstr1++, wstr2++) + if (*wstr1 != *wstr2) + break; + + return *wstr1 - *wstr2; +} + +int +_falwcsncmp(wchar_t *wstr1, wchar_t *wstr2, int len) +{ + for ( ; *wstr1 && *wstr2 && len > 0; wstr1++, wstr2++, len--) + if (*wstr1 != *wstr2) + break; + + if (len <= 0) + return 0; + + return *wstr1 - *wstr2; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcTxtPr.c b/cde/programs/dtudcfonted/libfal/_fallcTxtPr.c new file mode 100644 index 000000000..708543d82 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcTxtPr.c @@ -0,0 +1,256 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcTxtPr.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:41 */ +/* $XConsortium: _fallcTxtPr.c /main/1 1996/04/08 15:19:12 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include "_fallibint.h" +#include "_fallcPubI.h" +#include "_falutil.h" +#include <X11/Xatom.h> +#include <stdio.h> + +static int +get_buf_size(Bool is_wide_char, XPointer list, int count) +{ + int length = 0; + char **mb_list; + wchar_t **wc_list; + + if (list == NULL) + return 0; + + if (is_wide_char) { + wc_list = (wchar_t **) list; + for ( ; count-- > 0; wc_list++) { + if (*wc_list) + length += _falwcslen(*wc_list) + 1; + } + length *= 5; /* XXX */ + } else { + mb_list = (char **) list; + for ( ; count-- > 0; mb_list++) { + if (*mb_list) + length += strlen(*mb_list) + 1; + } + length *= 3; /* XXX */ + } + length = (length / BUFSIZ + 1) * BUFSIZ; /* XXX */ + + return length; +} + +static int +_XTextListToTextProperty( + XLCd lcd, + Display *dpy, + char *from_type, + XPointer list, + int count, + XICCEncodingStyle style, + XTextProperty *text_prop) +{ + Atom encoding; + XlcConv conv; + char *to_type; + char **mb_list; + wchar_t **wc_list; + XPointer from; + char *to, *buf, *value; + int from_left, to_left, buf_len, nitems, unconv_num, ret, i, retry, done =0; + Bool is_wide_char = False; + + if (strcmp(XlcNWideChar, from_type) == 0) + is_wide_char = True; + + buf_len = get_buf_size(is_wide_char, list, count); + if ((buf = (char *) Xmalloc(buf_len)) == NULL) + return XNoMemory; + + switch (style) { + case XStringStyle: + case XStdICCTextStyle: + encoding = XA_STRING; + to_type = XlcNString; + break; + case XCompoundTextStyle: + encoding = falInternAtom(dpy, "COMPOUND_TEXT", False); + to_type = XlcNCompoundText; + break; + case XTextStyle: + encoding = falInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False); + to_type = XlcNMultiByte; + if (is_wide_char == False) { + nitems = 0; + mb_list = (char **) list; + to = buf; + for (i = 0; i < count; i++) { + strcpy(to, *mb_list); + from_left = strlen(*mb_list) + 1; + nitems += from_left; + to += from_left; + mb_list++; + } + unconv_num = 0; + done++; + } + break; + default: + Xfree(buf); + return XConverterNotFound; + } + + if (count < 1) { + nitems = 0; + done++; + } + + if(done == 1){ + if (nitems <= 0) + nitems = 1; + value = (char *) Xmalloc(nitems); + if (value == NULL) { + Xfree(buf); + return XNoMemory; + } + if (nitems == 1) + *value = 0; + else + memcpy(value, buf, nitems); + nitems--; + Xfree(buf); + + text_prop->value = (unsigned char *) value; + text_prop->encoding = encoding; + text_prop->format = 8; + text_prop->nitems = nitems; + + return unconv_num; + } + + do{ + retry = 0; + conv = _fallcOpenConverter(lcd, from_type, lcd, to_type); + if (conv == NULL) { + Xfree(buf); + return XConverterNotFound; + } + + if (is_wide_char) + wc_list = (wchar_t **) list; + else + mb_list = (char **) list; + + to = buf; + to_left = buf_len; + + unconv_num = 0; + + for (i = 1; to_left > 0; i++) { + if (is_wide_char) { + from = (XPointer) *wc_list; + from_left = _falwcslen(*wc_list); + wc_list++; + } else { + from = (XPointer) *mb_list; + from_left = strlen(*mb_list); + mb_list++; + } + + ret = _fallcConvert(conv, &from, &from_left, (XPointer *) &to, &to_left, + NULL, 0); + + if (ret < 0) + continue; + + if (ret > 0 && style == XStdICCTextStyle && encoding == XA_STRING) { + _fallcCloseConverter(conv); + encoding = falInternAtom(dpy, "COMPOUND_TEXT", False); + to_type = XlcNCompoundText; + retry++; + } + + unconv_num += ret; + *to++ = '\0'; + to_left--; + + if (i >= count) + break; + + _fallcResetConverter(conv); + } + + _fallcCloseConverter(conv); + + nitems = to - buf; + }while (retry == 1); +} + +int +_falmbTextListToTextProperty( + XLCd lcd, + Display *dpy, + char **list, + int count, + XICCEncodingStyle style, + XTextProperty *text_prop) +{ + return _XTextListToTextProperty(lcd, dpy, XlcNMultiByte, (XPointer) list, + count, style, text_prop); +} + +int +_falwcTextListToTextProperty( + XLCd lcd, + Display *dpy, + wchar_t **list, + int count, + XICCEncodingStyle style, + XTextProperty *text_prop) +{ + return _XTextListToTextProperty(lcd, dpy, XlcNWideChar, (XPointer) list, + count, style, text_prop); +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcUTF.c b/cde/programs/dtudcfonted/libfal/_fallcUTF.c new file mode 100644 index 000000000..3154dc512 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcUTF.c @@ -0,0 +1,1445 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcUTF.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:41 */ +/* $XConsortium: _fallcUTF.c /main/2 1996/09/27 19:03:38 drk $ */ +/****************************************************************** + + Copyright 1993 by SunSoft, Inc. + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of SunSoft, Inc. +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +SunSoft, Inc. makes no representations about the suitability of +this software for any purpose. It is provided "as is" without +express or implied warranty. + +SunSoft Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL SunSoft, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. + + Author: Hiromu Inukai (inukai@Japan.Sun.COM) SunSoft, inc. + +******************************************************************/ +#include "_fallcUTF.h" +#include <stdlib.h> + +static long getutfrune(char **read_from, int *from_len); +static void our_wctomb( + unsigned short r, + char **bufptr, + int *buf_len +); +static int our_mbtowc( + unsigned long *p, + char *s, + size_t n +); +static void latin2rune( + unsigned char c, + Rune *r +); +static void jis02012rune( + unsigned char c, + Rune *r +); +static void jis02082rune( + unsigned char c, + Rune *r +); +static void ksc2rune( + unsigned char c, + Rune *r +); +static void gb2rune( + unsigned char c, + Rune *r +); +static void init_latin1tab(long *tbl, long fb_default); +static void init_latin2tab(long *tbl, long fb_default); +static void init_latin3tab(long *tbl, long fb_default); +static void init_latin4tab(long *tbl, long fb_default); +static void init_latin5tab(long *tbl, long fb_default); +static void init_latin6tab(long *tbl, long fb_default); +static void init_latin7tab(long *tbl, long fb_default); +static void init_latin8tab(long *tbl, long fb_default); +static void init_latin9tab(long *tbl, long fb_default); +static void init_jis0201tab(long *tbl, long fb_default); +static void init_jis0208tab(long *tbl, long fb_default); +static void init_ksc5601tab(long *tbl, long fb_default); +static void init_gb2312tab(long *tbl, long fb_default); + + +static char *int_locale = NULL; +static long *tabkuten = NULL; +static long *tabksc5601 = NULL; +static long *tabgb = NULL; + +static UtfData utfdata_list = (UtfData)NULL; + +static XlcUTFDataRec default_utf_data[] = +{ + {"ISO8859-1", XlcGL, init_latin1tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin1tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin2tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin2tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin3tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin3tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin4tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin4tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin5tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin5tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin6tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin6tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin7tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin7tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin8tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin8tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGL, init_latin9tab, latin2rune, N11n_none, 0x20}, + {"ISO8859-1", XlcGR, init_latin9tab, latin2rune, N11n_none, 0x20}, + {"JISX0201.1976-0", XlcGL, init_jis0201tab, jis02012rune, N11n_none, 0x20}, + {"JISX0201.1976-0", XlcGR, init_jis0201tab, jis02012rune, N11n_none, 0x20}, + {"JISX0208.1983-0", XlcGL, init_jis0208tab, jis02082rune, N11n_ja, 0x2222}, + {"JISX0208.1983-0", XlcGR, init_jis0208tab, jis02082rune, N11n_ja, 0x2222}, + {"KSC5601.1987-0", XlcGL, init_ksc5601tab, ksc2rune, N11n_ko, 0x2160}, + {"KSC5601.1987-0", XlcGR, init_ksc5601tab, ksc2rune, N11n_ko, 0x2160}, + {"GB2312.1980-0", XlcGL, init_gb2312tab, gb2rune, N11n_zh, 0x2175}, + {"GB2312.1980-0", XlcGR, init_gb2312tab, gb2rune, N11n_zh, 0x2175}, +}; + + +static void +set_latin_nop(long *table, long default_val) +{ + int i; + for(i = 0; i < 0x1fff; i++) + table[i] = default_val; + return; +} + +static void +set_latin_tab(FILE *fptr, long *table, long fb_default) +{ + int i = 0; + int j = 0; + int rv = 0; + long value; + + for(i = 0; i < NRUNE; i++) + table[i] = -1; + while((rv = fscanf(fptr, "%lx", (long unsigned *) &value)) != EOF) { + if(rv != 0 && value >= 0) { + table[value] = j++; + } else { + set_latin_nop(table, fb_default); + return; + } + } +} + +extern int _fallcResolveI18NPath(); +#define TBL_DATA_DIR "tbl_data" + +static void +init_latin1tab(long *tbl, long fb_default) +{ + FILE *fp = NULL; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_1); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin2tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_2); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin3tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_3); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin4tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_4); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin5tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_5); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin6tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_6); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin7tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_7); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin8tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_8); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_latin9tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, tab8859_9); + fp = fopen(filename, "r"); + if(fp) { + set_latin_tab(fp, tbl, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_latin_nop(tbl, fb_default); + } +} + +static void +init_jis0201tab(long *tbl, long fb_default) +{ + int i; + for(i = 0; i < NRUNE; i++) + tbl[i] = -1; +} + +static void +set_cjk_nop(long **to_tbl, int to_max, long default_val) +{ + int i; + for(i = 0; i < to_max; i++) + (*to_tbl)[i] = default_val; + return; +} + +static void +set_table( +FILE *fptr, +long **to_tbl, +long *from_tbl, +int to_max, +long fb_default) +{ + int i = 0; + int j = 0; + int rv = 0; + long value; + + for(i = 0; i < NRUNE; i++) + from_tbl[i] = -1; + while((rv = fscanf(fptr, "%lx", (long unsigned *) &value)) != EOF) { + if(rv != 0) { + (*to_tbl)[j++] = value; + } else { + set_cjk_nop(to_tbl, to_max, fb_default); + break; + } + } + for(i = 0; i < to_max; i++) { + if((value = (*to_tbl)[i]) != -1){ + from_tbl[abs(value)] = i; + } + } +} + + + +static void +init_jis0208tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + if((tabkuten = (long *)Xmalloc(KUTENMAX * sizeof(long))) == NULL) { + return; + } + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, jis0208); + fp = fopen(filename, "r"); + if(fp) { + set_table(fp, &tabkuten, tbl, KUTENMAX, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_cjk_nop(&tabkuten, KUTENMAX, fb_default); + } +} + +static void +init_ksc5601tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + if((tabksc5601 = (long *)Xmalloc(KSCMAX * sizeof(long))) == NULL) { + return; + } + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, ksc5601); + fp = fopen(filename, "r"); + if(fp) { + set_table(fp, &tabksc5601, tbl, KSCMAX, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_cjk_nop(&tabksc5601, KSCMAX, fb_default); + } +} + +static void +init_gb2312tab(long *tbl, long fb_default) +{ + FILE *fp; + char dirname[BUFSIZE]; + char filename[BUFSIZE]; + char *p, *q; + + if((tabgb = (long *)Xmalloc(GBMAX * sizeof(long))) == NULL) { + return; + } + _fallcResolveI18NPath(dirname); + p = dirname; + while(p) { + q = strchr(p, ':'); + if(q) { + *q = '\0'; + } + sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, gb2312); + fp = fopen(filename, "r"); + if(fp) { + set_table(fp, &tabgb, tbl, GBMAX, fb_default); + fclose(fp); + return; + } + if(q) { + p = q + 1; + } else { + p = q; + } + } + if(!fp) { + set_cjk_nop(&tabgb, GBMAX, fb_default); + } +} + +static UtfData +make_entry(void) +{ + UtfData tmp = (UtfData)Xmalloc(sizeof(UtfDataRec)); + bzero(tmp, sizeof(UtfDataRec)); + return tmp; +} + +static int once = 0; +static int +_XlcInitUTFInfo(XLCd lcd) +{ + if(!once) { + int i; + CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list); + int codeset_num = XLC_GENERIC(lcd, codeset_num); + UtfData pdata; + + if(!utfdata_list) { + utfdata_list = make_entry(); + } + pdata = utfdata_list; + for(i=0; i < codeset_num; i++) { + XlcCharSet charset = *codeset_list[i]->charset_list; + while(pdata->next) { + if(charset == pdata->charset) { + break; + } + pdata = pdata->next; + } + if(pdata->next) { + continue; + } else { + int j; + for(j = 0; j < MAX_UTF_CHARSET; j++) { + if(_fallcCompareISOLatin1(charset->encoding_name, default_utf_data[j].name) || + charset->side != default_utf_data[j].side) { + continue; + } else { + pdata->initialize = default_utf_data[j].initialize; + pdata->fromtbl = (long *)Xmalloc(NRUNE * sizeof(long)); + (*pdata->initialize)(pdata->fromtbl, default_utf_data[j].fallback_value); + pdata->already_init = True; + pdata->charset = charset; + pdata->cstorune = default_utf_data[j].cstorune; + pdata->type = default_utf_data[j].type; + pdata->next = make_entry(); + break; + } + } + } + } + once = 1; + } + return 1; +} + +static int +utftocs( + XlcConv conv, + char **from, + int *from_left, + char **to, + int *to_left, + XPointer *args, + int num_args) +{ + char *utfptr; + char *bufptr; + int utf_len, buf_len; + long l; + XlcCharSet tmpcharset = (XlcCharSet)NULL; + UtfData pdata = utfdata_list; + + if (from == NULL || *from == NULL) + return 0; + + utfptr = *from; + bufptr = *to; + utf_len = *from_left; + buf_len = *to_left; + + while(utf_len > 0 && buf_len > 0) { + char *p = utfptr; + if((l = getutfrune(&p, &utf_len)) == -2) { + return -1; + } else { + while(pdata->next) { + long r; + long *tbl; + + tbl = pdata->fromtbl; + tbl += l; + if((r = *tbl) == -1) { + if(tmpcharset) { + if((num_args > 0) && tmpcharset) + *((XlcCharSet *) args[0]) = tmpcharset; + + *from_left -= utfptr - *from; + *from = utfptr; + + *to_left -= bufptr - *to; + *to = bufptr; + + return 0; + + } else { + pdata = pdata->next; + continue; + } + } else { + utfptr = p; + if(!tmpcharset) tmpcharset = pdata->charset; + } + if(r < 128) { + *bufptr++ = r; + buf_len--; + } else { + switch(pdata->type) { + case N11n_ja: + *bufptr++ = (r/100 + ' '); + *bufptr++ = (r%100 + ' '); + break; + case N11n_ko: + *bufptr++ = (r/94 + 0x21); + *bufptr++ = (r%94 + 0x21); + break; + case N11n_zh: + *bufptr++ = 0x20 + (r/100); + *bufptr++ = 0x20 + (r%100); + break; + default: + break; + } + buf_len -= 2; + } + break; + } + if(!tmpcharset) return (-1); /* Unknown Codepoint */ + } + } +} + +static int +utf1tocs( + XlcConv conv, + char **from, + int *from_left, + char **to, + int *to_left, + XPointer *args, + int num_args) +{ + char **ptr = NULL; + char char_ptr[UTFmax]; + int i = 0; + unsigned long dummy = (unsigned long)0; + + if (from == NULL || *from == NULL) + return utftocs(conv, from, from_left, to, to_left, args, num_args); + + ptr = from; + for(i = 0; i < UTFmax; char_ptr[i++] = *(*ptr)++); + i=0; + while(our_mbtowc(&dummy, (char*)&char_ptr[0], i) <= 0) + i++; + utftocs(conv, from, &i, to, to_left, args, num_args); +} + +static int +ucstocs( + XlcConv conv, + XPointer *from, + int *from_left, + char **to, + int *to_left, + XPointer *args, + int num_args) +{ + wchar_t *ucsptr; + char *bufptr; + int ucs_len, buf_len; + XlcCharSet tmpcharset = (XlcCharSet)NULL; + UtfData pdata = utfdata_list; + + if (from == NULL || *from == NULL) + return 0; + + ucsptr = (wchar_t *)*from; + bufptr = *to; + ucs_len = *from_left; + buf_len = *to_left; + + while(ucs_len > 0 && buf_len > 0) { + while(pdata->next) { + long r; + long *tbl; + + tbl = pdata->fromtbl; + tbl += *ucsptr; + if((r = *tbl) == -1) { + if(tmpcharset) { + if((num_args > 0) && tmpcharset) + *((XlcCharSet *) args[0]) = tmpcharset; + + *from_left -= ucsptr - (wchar_t *)*from; + *from = (XPointer)ucsptr; + + *to_left -= bufptr - *to; + *to = bufptr; + + return 0; + + } else { + pdata = pdata->next; + continue; + } + } else { + if(!tmpcharset) tmpcharset = pdata->charset; + } + ucsptr++; + if(r < 128) { + *bufptr++ = r; + ucs_len--; + buf_len--; + } else { + switch(pdata->type) { + case N11n_ja: + *bufptr++ = (r/100 + ' '); + *bufptr++ = (r%100 + ' '); + break; + case N11n_ko: + *bufptr++ = (r/94 + 0x21); + *bufptr++ = (r%94 + 0x21); + break; + case N11n_zh: + *bufptr++ = 0x20 + (r/100); + *bufptr++ = 0x20 + (r%100); + break; + default: + break; + } + ucs_len--; + buf_len -= 2; + } + break; + } + if(!tmpcharset) return (-1); /* Unknown Codepoint */ + } +} + +static long +getutfrune(char **read_from, int *from_len) +{ + int c, i; + char str[UTFmax]; /* MB_LEN_MAX really */ + unsigned long l; + int n; + + str[0] = '\0'; + for(i = 0; i <= UTFmax;) { + c = **read_from; + (*read_from)++; + str[i++] = c; + n = our_mbtowc(&l, str, i); + if(n == -1) + return(-2); + if(n > 0) { + *from_len -= n; + return(l); + } + } + return(-2); +} + +static +cstoutf( + XlcConv conv, + char **from, + int *from_left, + char **to, + int *to_left, + XPointer *args, + int num_args) +{ + XlcCharSet charset; + char *csptr, *utfptr; + int csstr_len, utf_len; + int cmp_len = 0; + void (*putrune)( + unsigned char c, + Rune *r + ) = NULL; + Rune r = (Rune)0; + UtfData pdata = utfdata_list; + + if (from == NULL || *from == NULL) + return 0; + + if (num_args < 1) + return -1; + + csptr = *from; + utfptr = *to; + csstr_len = *from_left; + utf_len = *to_left; + + charset = (XlcCharSet)args[0]; + cmp_len = strchr(charset->name, ':') - charset->name; + while(pdata->next) { + if(!_fallcNCompareISOLatin1(charset->name, pdata->charset->name, cmp_len)) { + putrune = pdata->cstorune; + break; + } else { + pdata = pdata->next; + } + } + if(!putrune) + return -1; + + while(csstr_len-- > 0 && utf_len > 0) { + (*putrune)(*csptr++, &r); + if(!r) { + continue; + } + our_wctomb(r, &utfptr, &utf_len); + r = 0; + } + + *from_left -= csptr - *from; + *from = csptr; + + *to_left -= utfptr - *to; + *to = utfptr; + + return 0; +} + +static +cstoucs( + XlcConv conv, + char **from, + int *from_left, + XPointer *to, + int *to_left, + XPointer *args, + int num_args) +{ + XlcCharSet charset; + char *csptr; + wchar_t *ucsptr; + int csstr_len, ucs_len; + int cmp_len = 0; + void (*putrune)( + unsigned char c, + Rune *r + ) = NULL; + Rune r = (Rune)0; + UtfData pdata = utfdata_list; + + if (from == NULL || *from == NULL) + return 0; + + if (num_args < 1) + return -1; + + csptr = *from; + ucsptr = (wchar_t *)*to; + csstr_len = *from_left; + ucs_len = *to_left; + charset = (XlcCharSet)args[0]; + cmp_len = strchr(charset->name, ':') - charset->name; + + while(pdata->next) { + if(!_fallcNCompareISOLatin1(charset->name, pdata->charset->name, cmp_len)) { + putrune = pdata->cstorune; + break; + } else { + pdata = pdata->next; + } + } + if(!putrune) + return -1; + + while(csstr_len-- > 0 && ucs_len > 0) { + (*putrune)(*csptr++, &r); + if(!r) { + continue; + } + *ucsptr = (long)r; + ucsptr++; + ucs_len--; + r = 0; + } + + *from_left -= csptr - *from; + *from = csptr; + + *to_left -= ucsptr - (wchar_t *)*to; + *to = (XPointer)ucsptr; + + return 0; +} + +static void +our_wctomb(Rune r, char **utfptr, int *utf_len) +{ + long l = (long)r; + + if(!utfptr || !*utfptr) + return; /* no shift states */ + if(l & ~Wchar2) { + if(l & ~Wchar4) { + if(l & ~Wchar5) { + /* 6 bytes */ + *(*utfptr)++ = T6 | ((l >> 5*Bitx) & Mask6); + *(*utfptr)++ = Tx | ((l >> 4*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 3*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 2*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 1*Bitx) & Maskx); + *(*utfptr)++ = Tx | (l & Maskx); + *utf_len -= 6; + return; + } + /* 5 bytes */ + *(*utfptr)++ = T5 | (l >> 4*Bitx); + *(*utfptr)++ = Tx | ((l >> 3*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 2*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 1*Bitx) & Maskx); + *(*utfptr)++ = Tx | (l & Maskx); + *utf_len -= 5; + return; + } + if(l & ~Wchar3) { + /* 4 bytes */ + *(*utfptr)++ = T4 | (l >> 3*Bitx); + *(*utfptr)++ = Tx | ((l >> 2*Bitx) & Maskx); + *(*utfptr)++ = Tx | ((l >> 1*Bitx) & Maskx); + *(*utfptr)++ = Tx | (l & Maskx); + *utf_len -= 4; + return; + } + /* 3 bytes */ + *(*utfptr)++ = T3 | (l >> 2*Bitx); + *(*utfptr)++ = Tx | ((l >> 1*Bitx) & Maskx); + *(*utfptr)++ = Tx | (l & Maskx); + *utf_len -= 3; + return; + } + if(l & ~Wchar1) { + /* 2 bytes */ + *(*utfptr)++ = T2 | (l >> 1*Bitx); + *(*utfptr)++ = Tx | (l & Maskx); + *utf_len -= 2; + return; + } + /* 1 byte */ + *(*utfptr)++ = T1 | l; + *utf_len -= 1; + return; +} + +static void +latin2rune(unsigned char c, Rune *r) +{ + *r = (Rune)c; + return; +} + +static void +ksc2rune(unsigned char c, Rune *r) +{ + static enum { init, cs1last} state = init; + static int korean646 = 1; /* fixed to 1 for now. */ + static int lastc; + unsigned char ch = (c|0x80); /* XXX */ + int n; + long l; + + switch(state) + { + case init: + if (ch < 128){ + if(korean646 && (ch=='\\')){ + emit(0x20A9); + } else { + emit(ch); + } + }else{ + lastc = ch; + state = cs1last; + } + return; + + case cs1last: /* 2nd byte of codeset 1 (KSC 5601) */ + n = ((lastc&0x7f)-33)*94 + (ch&0x7f)-33; + if((l = tabksc5601[n]) == 0){ + emit(BADMAP); + } else { + emit(l); + } + state = init; + return; + } +} + +static void +jis02012rune(unsigned char c, Rune *r) +{ +/* To Be Implemented */ +} + +static void +gb2rune(unsigned char c, Rune *r) +{ + static enum { state0, state1 } state = state0; + static int lastc; + long n, ch; + unsigned char ch1 = (c|0x80); /* XXX */ + + switch(state) + { + case state0: /* idle state */ + if(ch1 >= 0xA1){ + lastc = ch1; + state = state1; + return; + } + emit(ch1); + return; + + case state1: /* seen a font spec */ + if(ch1 >= 0xA1) + n = (lastc-0xA0)*100 + (ch1-0xA0); + else { + emit(BADMAP); + state = state0; + return; + } + ch = tabgb[n]; + if(ch < 0){ + emit(BADMAP); + } else + emit(ch); + state = state0; + } +} + +static void +jis02082rune(unsigned char c, Rune *r) +{ + static enum { state0, state1} state = state0; + static int lastc; + unsigned char ch = (c|0x80); /* XXX */ + int n, again; + long l; + +do { + again = 0; + switch(state) + { + case state0: /* idle state */ + lastc = ch; + state = state1; + return; + + case state1: /* two part char */ + if((lastc&0x80) != (ch&0x80)){ + emit(lastc); + state = state0; + again += 1; + } + if(CANS2J(lastc, ch)){ + int h = lastc, l = ch; + S2J(h, l); + n = h*100 + l - 3232; + } else + n = (lastc&0x7F)*100 + (ch&0x7f) - 3232; /* kuten */ + if((l = tabkuten[n]) == -1){ + emit(BADMAP); + } else { + if(l < 0){ + l = -l; + } + emit(l); + } + state = state0; + } + } while (again == 1); +} + +static int +our_mbtowc(unsigned long *p, char *s, size_t n) +{ + unsigned char *us; + int c0, c1, c2, c3, c4, c5; + unsigned long wc; + + if(s == 0) + return 0; /* no shift states */ + + if(n < 1) + return -2; /* bad length */ + us = (unsigned char*)s; + c0 = us[0]; + if(c0 >= T3) { + if(n < 3) + return -2; + c1 = us[1] ^ Tx; + c2 = us[2] ^ Tx; + if((c1|c2) & T2) { + errno = EILSEQ; + return -1; + } + if(c0 >= T5) { + if(n < 5) + return -2; + c3 = us[3] ^ Tx; + c4 = us[4] ^ Tx; + if((c3|c4) & T2) { + errno = EILSEQ; + return -1; + } + if(c0 >= T6) { + /* 6 bytes */ + if(n < 6) + return -2; + c5 = us[5] ^ Tx; + if(c5 & T2) { + errno = EILSEQ; + return -1; + } + wc = ((((((((((c0 & Mask6) << Bitx) | + c1) << Bitx) | c2) << Bitx) | + c3) << Bitx) | c4) << Bitx) | c5; + if(wc <= Wchar5) { + errno = EILSEQ; + return -1; + } + *p = wc; + return 6; + } + /* 5 bytes */ + wc = ((((((((c0 & Mask5) << Bitx) | + c1) << Bitx) | c2) << Bitx) | + c3) << Bitx) | c4; + if(wc <= Wchar4) { + errno = EILSEQ; + return -1; + } + *p = wc; + return 5; + } + if(c0 >= T4) { + /* 4 bytes */ + if(n < 4) + return -2; + c3 = us[3] ^ Tx; + if(c3 & T2) { + errno = EILSEQ; + return -1; + } + wc = ((((((c0 & Mask4) << Bitx) | + c1) << Bitx) | c2) << Bitx) | + c3; + if(wc <= Wchar3) { + errno = EILSEQ; + return -1; + } + *p = wc; + return 4; + } + /* 3 bytes */ + wc = ((((c0 & Mask3) << Bitx) | + c1) << Bitx) | c2; + if(wc <= Wchar2) { + errno = EILSEQ; + return -1; + } + *p = wc; + return 3; + } + if(c0 >= T2) { + /* 2 bytes */ + if(n < 2) + return -2; + c1 = us[1] ^ Tx; + if(c1 & T2) { + errno = EILSEQ; + return -1; + } + wc = ((c0 & Mask2) << Bitx) | + c1; + if(wc <= Wchar1) { + errno = EILSEQ; + return -1; + } + *p = wc; + return 2; + } + /* 1 byte */ + if(c0 >= Tx) { + errno = EILSEQ; + return -1; + } + *p = c0; + return 1; +} + +static void +close_converter(XlcConv conv) +{ + Xfree((char *) conv); +} + +static XlcConv +create_conv(XLCd lcd, XlcConvMethods methods) +{ + XlcConv conv; + + conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + if (conv == (XlcConv) NULL) + return (XlcConv) NULL; + + conv->methods = methods; + + conv->state = NULL; + _XlcInitUTFInfo(lcd); + + return conv; + +/* if an error occurs somewhere + close_converter(conv); + return (XlcConv) NULL; +*/ +} + +static XlcConvMethodsRec mbtocs_methods = { + close_converter, + utf1tocs, + NULL +}; + +static XlcConv +open_mbtocs(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + return create_conv(from_lcd, &mbtocs_methods); +} + +static XlcConvMethodsRec mbstocs_methods = { + close_converter, + utftocs, + NULL +}; + +static XlcConv +open_mbstocs(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + return create_conv(from_lcd, &mbstocs_methods); +} + +static XlcConvMethodsRec wcstocs_methods = { + close_converter, + ucstocs, + NULL +}; + +static XlcConv +open_wcstocs(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + return create_conv(from_lcd, &wcstocs_methods); +} + +static XlcConvMethodsRec cstombs_methods = { + close_converter, + cstoutf, + NULL +}; + +static XlcConv +open_cstombs(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + return create_conv(from_lcd, &cstombs_methods); +} + +static XlcConvMethodsRec cstowcs_methods = { + close_converter, + cstoucs, + NULL +}; + +static XlcConv +open_cstowcs(XLCd from_lcd, char *from, XLCd to_lcd, char *to) +{ + return create_conv(from_lcd, &cstowcs_methods); +} + + +XLCd +_fallcUtfLoader(char *name) +{ + XLCd lcd; + + lcd = _fallcCreateLC(name, _fallcGenericMethods); + if (lcd == (XLCd) NULL) + return lcd; + + if ((_fallcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "utf"))) { + _fallcDestroyLC(lcd); + return (XLCd) NULL; + } + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs); + _fallcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs); + + _fallcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs); + + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs); + _fallcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs); + + return lcd; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcUTF.h b/cde/programs/dtudcfonted/libfal/_fallcUTF.h new file mode 100644 index 000000000..825b455e1 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcUTF.h @@ -0,0 +1,189 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XlcUTF.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:06 */ +/* $XConsortium: _fallcUTF.h /main/1 1996/04/08 15:19:33 cde-fuj $ */ +/****************************************************************** + + Copyright 1993 by SunSoft, Inc. + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of SunSoft, Inc. +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +SunSoft, Inc. makes no representations about the suitability of +this software for any purpose. It is provided "as is" without +express or implied warranty. + +SunSoft Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL SunSoft, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. + + Author: Hiromu Inukai (inukai@Japan.Sun.COM) SunSoft, inc. + +******************************************************************/ +#include "_fallibint.h" +#include "_fallcGeneric.h" +#include <X11/Xos.h> +#include <stdio.h> + +typedef unsigned short Rune; /* 16 bits */ +#define Runeerror 0x80 /* decoding error in UTF */ +#define Runeself 0x80 /* rune and UTF sequences are the same (<) */ +#define UTFmax 3 /* maximum bytes per rune */ + +#define BADMAP (0xFFFD) +#define ESC 033 +#define NRUNE 65536 +#define NLATIN 0x6ff +#define LATINMAX 256 +#define KUTENMAX 8407 +#define KSCMAX 8743 +#define GBMAX 8795 +#define tab8859_1 "tab8859_1" +#define tab8859_2 "tab8859_2" +#define tab8859_3 "tab8859_3" +#define tab8859_4 "tab8859_4" +#define tab8859_5 "tab8859_5" +#define tab8859_6 "tab8859_6" +#define tab8859_7 "tab8859_7" +#define tab8859_8 "tab8859_8" +#define tab8859_9 "tab8859_9" +#define jis0208 "jis0208" +#define ksc5601 "ksc5601" +#define gb2312 "gb2312" + +#define emit(x) *r = (Rune)x; + +typedef enum { + N11n_none, /* No need to normalize (1byte) */ + N11n_ja, /* Normalize for ja */ + N11n_ko, /* Normalize for ko */ + N11n_zh /* Normalize for zh */ +} NormalizeType; + +typedef struct _UtfDataRec { + XlcCharSet charset; + void (*initialize)( /* Table Initializer */ + long *tbl, + long fallback + ); + long *fromtbl; /* UTF -> CharSet */ + NormalizeType type; /* Normalize type */ + void (*cstorune)( /* CharSet -> UTF */ + unsigned char c, + Rune *r + ); + Bool already_init; + struct _UtfDataRec *next; /* next entry */ +} UtfDataRec, *UtfData; + +typedef struct _XlcUTFDataRec { + char *name; + XlcSide side; + void (*initialize)(); + void (*cstorune)( + unsigned char c, + Rune *r + ); + NormalizeType type; + long fallback_value; +} XlcUTFDataRec, *XlcUTFData; + +typedef struct _StateRec { + XlcCharSet charset; + XlcCharSet GL_charset; + XlcCharSet GR_charset; +} StateRec, *State; + +#define MAX_UTF_CHARSET (sizeof(default_utf_data)/sizeof(XlcUTFDataRec)) + +#define Char1 Runeself +#define Rune1 Runeself +#define Char21 0xA1 +#define Rune21 0x0100 +#define Char22 0xF6 +#define Rune22 0x4016 +#define Char3 0xFC +#define Rune3 0x10000 /* really 0x38E2E */ +#define Esc 0xBE +#define Bad Runeerror + +#define T1 0x00 +#define Tx 0x80 +#define T2 0xC0 +#define T3 0xE0 +#define T4 0xF0 +#define T5 0xF8 +#define T6 0xFC + +#define Bit1 7 +#define Bitx 6 +#define Bit2 5 +#define Bit3 4 +#define Bit4 3 +#define Bit5 2 +#define Bit6 2 + +#define Mask1 (1<<Bit1)-1 +#define Maskx (1<<Bitx)-1 +#define Mask2 (1<<Bit2)-1 +#define Mask3 (1<<Bit3)-1 +#define Mask4 (1<<Bit4)-1 +#define Mask5 (1<<Bit5)-1 +#define Mask6 (1<<Bit6)-1 + +#define Wchar1 (1<<Bit1)-1 +#define Wchar2 (1<<(Bit2+Bitx))-1 +#define Wchar3 (1<<(Bit3+2*Bitx))-1 +#define Wchar4 (1<<(Bit4+3*Bitx))-1 +#define Wchar5 (1<<(Bit5+4*Bitx))-1 + +#ifndef EILSEQ +#define EILSEQ 123 +#endif + +#define J2S(_h, _l) { \ + /* lower: 21-7e >> 40-9d,9e-fb >> 40-7e,(skip 7f),80-fc */ \ + if (((_l) += (((_h)-- % 2) ? 0x1f : 0x7d)) > 0x7e) (_l)++; \ + /* upper: 21-7e >> 81-af >> 81-9f,(skip a0-df),e0-ef */ \ + if (((_h) = ((_h) / 2 + 0x71)) > 0x9f) (_h) += 0x40; \ +} +#define S2J(_h, _l) { \ + /* lower: 40-7e,80-fc >> 21-5f,61-dd >> 21-7e,7f-dc */ \ + if (((_l) -= 0x1f) > 0x60) (_l)--; \ + /* upper: 81-9f,e0-ef >> 00-1e,5f-6e >> 00-2e >> 21-7d */ \ + if (((_h) -= 0x81) > 0x5e) (_h) -= 0x40; (_h) *= 2, (_h) += 0x21; \ + /* upper: ,21-7d >> ,22-7e ; lower: ,7f-dc >> ,21-7e */ \ + if ((_l) > 0x7e) (_h)++, (_l) -= 0x5e; \ +} +#define ISJKANA(_b) (0xa0 <= (_b) && (_b) < 0xe0) +#define CANS2JH(_h) ((0x81 <= (_h) && (_h) < 0xf0) && !ISJKANA(_h)) +#define CANS2JL(_l) (0x40 <= (_l) && (_l) < 0xfd && (_l) != 0x7f) +#define CANS2J(_h, _l) (CANS2JH(_h) && CANS2JL(_l)) diff --git a/cde/programs/dtudcfonted/libfal/_fallcUtil.c b/cde/programs/dtudcfonted/libfal/_fallcUtil.c new file mode 100644 index 000000000..3de03e542 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcUtil.c @@ -0,0 +1,98 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcUtil.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:42 */ +/* $XConsortium: _fallcUtil.c /main/1 1996/04/08 15:19:43 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ + +#include <stdio.h> +#include <ctype.h> +#include <X11/Xos.h> +#include "_fallibint.h" + +#ifdef X_NOT_STDC_ENV +#ifndef toupper +#define toupper(c) ((int)(c) - 'a' + 'A') +#endif +#endif + +int +_fallcCompareISOLatin1(char *str1, char *str2) +{ + char ch1, ch2; + + for ( ; (ch1 = *str1) && (ch2 = *str2); str1++, str2++) { + if (islower(ch1)) + ch1 = toupper(ch1); + if (islower(ch2)) + ch2 = toupper(ch2); + + if (ch1 != ch2) + break; + } + + return *str1 - *str2; +} + +int +_fallcNCompareISOLatin1(char *str1, char *str2, int len) +{ + char ch1, ch2; + + for ( ; (ch1 = *str1) && (ch2 = *str2) && len; str1++, str2++, len--) { + if (islower(ch1)) + ch1 = toupper(ch1); + if (islower(ch2)) + ch2 = toupper(ch2); + + if (ch1 != ch2) + break; + } + + if (len == 0) + return 0; + + return *str1 - *str2; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcWrap.c b/cde/programs/dtudcfonted/libfal/_fallcWrap.c new file mode 100644 index 000000000..d6ac19206 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcWrap.c @@ -0,0 +1,569 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* lcWrap.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:42 */ +/* $XConsortium: _fallcWrap.c /main/1 1996/04/08 15:19:54 cde-fuj $ */ +/* + +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* + * Copyright 1991 by the Open Software Foundation + * Copyright 1993 by the TOSHIBA Corp. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Open Software Foundation and TOSHIBA + * not be used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. Open Software + * Foundation and TOSHIBA make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OPEN SOFTWARE FOUNDATION AND TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN OR TOSHIBA BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * M. Collins OSF + * + * Katsuhisa Yano TOSHIBA Corp. + */ + +#include <stdint.h> +#include "_fallibint.h" +#include "_fallcint.h" +#if defined(__linux__) +#include <locale.h> +#else +#include <X11/Xlocale.h> +#endif +#include <X11/Xos.h> +#include "_falutil.h" + +extern void _fallcInitLoader( + void +); + +#ifdef XTHREADS +LockInfoPtr _Xi18n_lock; +#endif + +char * +falSetLocaleModifiers(const char *modifiers) +{ + XLCd lcd = _fallcCurrentLC(); + char *user_mods; + + if (!lcd) + return (char *) NULL; + if (!modifiers) + return lcd->core->modifiers; + user_mods = getenv("XMODIFIERS"); + modifiers = (*lcd->methods->map_modifiers) (lcd, + user_mods, (char *)modifiers); + if (modifiers) { + if (lcd->core->modifiers) + Xfree(lcd->core->modifiers); + lcd->core->modifiers = (char *)modifiers; + } + return (char *)modifiers; +} + +Bool +falSupportsLocale(void) +{ + return _fallcCurrentLC() != (XLCd)NULL; +} + +Bool _fallcValidModSyntax(char *mods, char **valid_mods) +{ + int i; + char **ptr; + + while (mods && (*mods == '@')) { + mods++; + if (*mods == '@') + break; + for (ptr = valid_mods; *ptr; ptr++) { + i = strlen(*ptr); + if (strncmp(mods, *ptr, i) || ((mods[i] != '='))) + continue; + mods = strchr(mods+i+1, '@'); + break; + } + } + return !mods || !*mods; +} + +static const char *im_valid[] = {"im", (char *)NULL}; + +/*ARGSUSED*/ +char * +_fallcDefaultMapModifiers (XLCd lcd, char *user_mods, char *prog_mods) +{ + int i; + char *mods; + + if (!_fallcValidModSyntax(prog_mods, (char **)im_valid)) + return (char *)NULL; + if (!_fallcValidModSyntax(user_mods, (char **)im_valid)) + return (char *)NULL; + i = strlen(prog_mods) + 1; + if (user_mods) + i += strlen(user_mods); + mods = Xmalloc(i); + if (mods) { + strcpy(mods, prog_mods); + if (user_mods) + strcat(mods, user_mods); + } + return mods; +} + +typedef struct _XLCdListRec { + struct _XLCdListRec *next; + XLCd lcd; + int ref_count; +} XLCdListRec, *XLCdList; + +static XLCdList lcd_list = NULL; + +typedef struct _XlcLoaderListRec { + struct _XlcLoaderListRec *next; + XLCdLoadProc proc; +} XlcLoaderListRec, *XlcLoaderList; + +static XlcLoaderList loader_list = NULL; + +void +_fallcRemoveLoader(XLCdLoadProc proc) +{ + XlcLoaderList loader, prev; + + if (loader_list == NULL) + return; + + prev = loader = loader_list; + if (loader->proc == proc) { + loader_list = loader->next; + Xfree(loader); + return; + } + + while (loader = loader->next) { + if (loader->proc == proc) { + prev->next = loader->next; + Xfree(loader); + return; + } + prev = loader; + } + + return; +} + +Bool +_fallcAddLoader(XLCdLoadProc proc, XlcPosition position) +{ + XlcLoaderList loader, last; + + _fallcRemoveLoader(proc); /* remove old loader, if exist */ + + loader = (XlcLoaderList) Xmalloc(sizeof(XlcLoaderListRec)); + if (loader == NULL) + return False; + + loader->proc = proc; + + if (loader_list == NULL) + position = XlcHead; + + if (position == XlcHead) { + loader->next = loader_list; + loader_list = loader; + } else { + last = loader_list; + while (last->next) + last = last->next; + + loader->next = NULL; + last->next = loader; + } + + return True; +} + +XLCd +_falOpenLC(char *name) +{ + XLCd lcd; + XlcLoaderList loader; + XLCdList cur; +#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) + char siname[256]; + char *_fallcMapOSLocaleName(); +#endif + + if (name == NULL) { + name = setlocale (LC_CTYPE, (char *)NULL); +#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) + name = _fallcMapOSLocaleName (name, siname); +#endif + } + + _XLockMutex(_Xi18n_lock); + + /* + * search for needed lcd, if found return it + */ + for (cur = lcd_list; cur; cur = cur->next) { + if (!strcmp (cur->lcd->core->name, name)) { + lcd = cur->lcd; + cur->ref_count++; + _XUnlockMutex(_Xi18n_lock); + return lcd; + } + } + + if (!loader_list) + _fallcInitLoader(); + + /* + * not there, so try to get and add to list + */ + for (loader = loader_list; loader; loader = loader->next) { + lcd = (*loader->proc)(name); + if (lcd) { + cur = (XLCdList) Xmalloc (sizeof(XLCdListRec)); + if (cur) { + cur->lcd = lcd; + cur->ref_count = 1; + cur->next = lcd_list; + lcd_list = cur; + } else { + (*lcd->methods->close)(lcd); + lcd = (XLCd) NULL; + } + break; + } + } +} + +void +_falCloseLC(XLCd lcd) +{ + XLCdList cur, *prev; + + for (prev = &lcd_list; cur = *prev; prev = &cur->next) { + if (cur->lcd == lcd) { + if (--cur->ref_count < 1) { + (*lcd->methods->close)(lcd); + *prev = cur->next; + Xfree(cur); + } + break; + } + } +} + +/* + * Get the XLCd for the current locale + */ + +XLCd +_fallcCurrentLC(void) +{ + XLCd lcd; + static XLCd last_lcd = NULL; + + lcd = _falOpenLC((char *) NULL); + + if (last_lcd) + _falCloseLC(last_lcd); + + last_lcd = lcd; + + return lcd; +} + +XrmMethods +_falrmInitParseInfo(XPointer *state) +{ + XLCd lcd = _falOpenLC((char *) NULL); + + if (lcd == (XLCd) NULL) + return (XrmMethods) NULL; + + return (*lcd->methods->init_parse_info)(lcd, state); +} + +int +falmbTextPropertyToTextList( + Display *dpy, + XTextProperty *text_prop, + char ***list_ret, + int *count_ret) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return XLocaleNotSupported; + + return (*lcd->methods->mb_text_prop_to_list)(lcd, dpy, text_prop, list_ret, + count_ret); +} + +int +falwcTextPropertyToTextList( + Display *dpy, + XTextProperty *text_prop, + wchar_t ***list_ret, + int *count_ret) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return XLocaleNotSupported; + + return (*lcd->methods->wc_text_prop_to_list)(lcd, dpy, text_prop, list_ret, + count_ret); +} + +int +falmbTextListToTextProperty( + Display *dpy, + char **list, + int count, + XICCEncodingStyle style, + XTextProperty *text_prop) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return XLocaleNotSupported; + + return (*lcd->methods->mb_text_list_to_prop)(lcd, dpy, list, count, style, + text_prop); +} + +int +falwcTextListToTextProperty( + Display *dpy, + wchar_t **list, + int count, + XICCEncodingStyle style, + XTextProperty *text_prop) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return XLocaleNotSupported; + + return (*lcd->methods->wc_text_list_to_prop)(lcd, dpy, list, count, style, + text_prop); +} + +void +falwcFreeStringList(wchar_t **list) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return; + + (*lcd->methods->wc_free_string_list)(lcd, list); +} + +char * +falDefaultString(void) +{ + XLCd lcd = _fallcCurrentLC(); + + if (lcd == NULL) + return (char *) NULL; + + return (*lcd->methods->default_string)(lcd); +} + +void +_fallcCopyFromArg(char *src, char *dst, int size) +{ + if (size == sizeof(long)) + *((long *) dst) = (long) src; +#ifdef LONG64 + else if (size == sizeof(int)) + *((int *) dst) = (int) (intptr_t) src; +#endif + else if (size == sizeof(short)) + *((short *) dst) = (short) (intptr_t) src; + else if (size == sizeof(char)) + *((char *) dst) = (char) (intptr_t) src; + else if (size == sizeof(XPointer)) + *((XPointer *) dst) = (XPointer) src; + else if (size > sizeof(XPointer)) + memcpy(dst, (char *) src, size); + else + memcpy(dst, (char *) &src, size); +} + +void +_fallcCopyToArg(char *src, char **dst, int size) +{ + if (size == sizeof(long)) + *((long *) *dst) = *((long *) src); + else if (size == sizeof(short)) + *((short *) *dst) = *((short *) src); + else if (size == sizeof(char)) + *((char *) *dst) = *((char *) src); + else if (size == sizeof(XPointer)) + *((XPointer *) *dst) = *((XPointer *) src); + else + memcpy(*dst, src, size); +} + +void +_fallcCountVaList(va_list var, int *count_ret) +{ + int count; + + for (count = 0; va_arg(var, char *); count++) + va_arg(var, XPointer); + + *count_ret = count; +} + +void +_fallcVaToArgList(va_list var, int count, XlcArgList *args_ret) +{ + XlcArgList args; + + *args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count); + if (args == (XlcArgList) NULL) + return; + + for ( ; count-- > 0; args++) { + args->name = va_arg(var, char *); + args->value = va_arg(var, XPointer); + } +} + +void +_fallcCompileResourceList(XlcResourceList resources, int num_resources) +{ + for ( ; num_resources-- > 0; resources++) + resources->xrm_name = falrmPermStringToQuark(resources->name); +} + +char * +_fallcGetValues( + XPointer base, + XlcResourceList resources, + int num_resources, + XlcArgList args, + int num_args, + unsigned long mask) +{ + XlcResourceList res; + XrmQuark xrm_name; + int count; + + for ( ; num_args-- > 0; args++) { + res = resources; + count = num_resources; + xrm_name = falrmPermStringToQuark(args->name); + + for ( ; count-- > 0; res++) { + if (xrm_name == res->xrm_name && (mask & res->mask)) { + _fallcCopyToArg(base + res->offset, &args->value, res->size); + break; + } + } + + if (count < 0) + return args->name; + } + + return NULL; +} + +char * +_fallcSetValues( + XPointer base, + XlcResourceList resources, + int num_resources, + XlcArgList args, + int num_args, + unsigned long mask) +{ + XlcResourceList res; + XrmQuark xrm_name; + int count; + + for ( ; num_args-- > 0; args++) { + res = resources; + count = num_resources; + xrm_name = falrmPermStringToQuark(args->name); + + for ( ; count-- > 0; res++) { + if (xrm_name == res->xrm_name && (mask & res->mask)) { + _fallcCopyFromArg(args->value, base + res->offset, res->size); + break; + } + } + + if (count < 0) + return args->name; + } + + return NULL; +} diff --git a/cde/programs/dtudcfonted/libfal/_fallcint.h b/cde/programs/dtudcfonted/libfal/_fallcint.h new file mode 100644 index 000000000..4ae07e32e --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallcint.h @@ -0,0 +1,875 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Xlcint.h 1.4 - Fujitsu source for CDEnext 95/12/07 10:53:09 */ +/* $XConsortium: _fallcint.h /main/1 1996/04/08 15:20:05 cde-fuj $ */ +/* + +Copyright (c) 1991 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +/* + * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation, + * and Nippon Telegraph and Telephone Corporation + * Copyright 1991 by the Open Software Foundation + * Copyright 1993 by the TOSHIBA Corp. + * Copyright 1993, 1994 by Sony Corporation + * Copyright 1993, 1994 by the FUJITSU LIMITED + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of OMRON, NTT Software, NTT, Open + * Software Foundation, and Sony Corporation not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. OMRON, NTT Software, NTT, Open Software + * Foundation, and Sony Corporation make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, AND SONY + * CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT + * SHALL OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, OR SONY + * CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Li Yuhong OMRON Corporation + * Tatsuya Kato NTT Software Corporation + * Hiroshi Kuribayashi OMRON Coproration + * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co. + * + * M. Collins OSF + * Katsuhisa Yano TOSHIBA Corp. + * Makoto Wakamatsu Sony Corporation + * Takashi Fujiwara FUJITSU LIMITED + */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#ifndef _XLCINT_H_ +#define _XLCINT_H_ + +#include <X11/Xresource.h> +#include "_falutil.h" +#include "_falvarargs.h" + +typedef Bool (*XFilterEventProc)( + Display* /* display */, + Window /* window */, + XEvent* /* event */, + XPointer /* client_data */ +); + +typedef struct _XIMFilter { + struct _XIMFilter *next; + Window window; + unsigned long event_mask; + int start_type, end_type; + XFilterEventProc filter; + XPointer client_data; +} XFilterEventRec, *XFilterEventList; + +typedef struct { + char *name; + XPointer value; +} XIMArg; + +#ifdef offsetof +#define XOffsetOf(s_type,field) offsetof(s_type,field) +#else +#define XOffsetOf(s_type,field) ((unsigned int)&(((s_type*)NULL)->field)) +#endif + +#define XIMNumber(arr) ((unsigned int) (sizeof(arr) / sizeof(arr[0]))) + +/* + * define secondary data structs which are part of Input Methods + * and Input Context + */ +typedef struct { + char *resource_name; /* Resource string */ + XrmQuark xrm_name; /* Resource name quark */ + int resource_size; /* Size in bytes of data */ + long resource_offset; /* Offset from base */ + unsigned short mode; /* Read Write Permission */ + unsigned short id; /* Input Method Protocol */ +} XIMResource, *XIMResourceList; + +/* + * data block describing the visual attributes associated with + * an input context + */ +typedef struct { + XRectangle area; + XRectangle area_needed; + XPoint spot_location; + Colormap colormap; + Atom std_colormap; + unsigned long foreground; + unsigned long background; + Pixmap background_pixmap; + XFontSet fontset; + int line_spacing; + Cursor cursor; + XIMCallback start_callback; + XIMCallback done_callback; + XIMCallback draw_callback; + XIMCallback caret_callback; + XIMPreeditState preedit_state; + XIMCallback state_notify_callback; +} ICPreeditAttributes, *ICPreeditAttributesPtr; + +typedef struct { + XRectangle area; + XRectangle area_needed; + Colormap colormap; + Atom std_colormap; + unsigned long foreground; + unsigned long background; + Pixmap background_pixmap; + XFontSet fontset; + int line_spacing; + Cursor cursor; + XIMCallback start_callback; + XIMCallback done_callback; + XIMCallback draw_callback; +} ICStatusAttributes, *ICStatusAttributesPtr; + +/* + * Methods for Xrm parsing + */ + +typedef void (*XmbInitProc)( + XPointer /* state */ +); + +typedef char (*XmbCharProc)( + XPointer /* state */, + char* /* str */, + int* /* lenp */ +); + +typedef void (*XmbFinishProc)( + XPointer /* state */ +); + +typedef char* (*XlcNameProc)( + XPointer /* state */ +); + +typedef void (*XrmDestroyProc)( + XPointer /* state */ +); + +typedef struct { + XmbInitProc mbinit; + XmbCharProc mbchar; + XmbFinishProc mbfinish; + XlcNameProc lcname; + XrmDestroyProc destroy; +} XrmMethodsRec, *XrmMethods; + +typedef struct _XLCd *XLCd; /* need forward reference */ + +/* + * define an LC, it's methods, and data. + */ + +typedef void (*XCloseLCProc)( + XLCd /* lcd */ +); + +typedef char* (*XlcMapModifiersProc)( + XLCd /* lcd */, + char* /* user_mods */, + char* /* prog_mods */ +); + +typedef XOM (*XOpenOMProc)( + XLCd /* lcd */, + Display* /* display */, + XrmDatabase /* rdb */, + const char* /* res_name */, + const char* /* res_class */ +); + +typedef XIM (*XOpenIMProc)( + XLCd /* lcd */, + Display* /* display */, + XrmDatabase /* rdb */, + char* /* res_name */, + char* /* res_class */ +); + +typedef Bool (*XRegisterIMInstantiateCBProc)( + XLCd /* lcd */, + Display* /* display */, + XrmDatabase /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIMProc /* callback */, + XPointer* /* client_data */ +); + +typedef Bool (*XUnregisterIMInstantiateCBProc)( + XLCd /* lcd */, + Display* /* display */, + XrmDatabase /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIMProc /* callback */, + XPointer* /* client_data */ +); + +typedef XrmMethods (*XrmInitParseInfoProc)( + XLCd /* lcd */, + XPointer* /* state */ +); + +typedef int (*falmbTextPropertyToTextListProc)( + XLCd /* lcd */, + Display* /* display */, + XTextProperty* /* text_prop */, + char*** /* list_return */, + int* /* count_return */ +); + +typedef int (*falwcTextPropertyToTextListProc)( + XLCd /* lcd */, + Display* /* display */, + XTextProperty* /* text_prop */, + wchar_t*** /* list_return */, + int* /* count_return */ +); + +typedef int (*falmbTextListToTextPropertyProc)( + XLCd /* lcd */, + Display* /* display */, + char** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop_return */ +); + +typedef int (*falwcTextListToTextPropertyProc)( + XLCd /* lcd */, + Display* /* display */, + wchar_t** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop_return */ +); + +typedef void (*falwcFreeStringListProc)( + XLCd /* lcd */, + wchar_t** /* list */ +); + +typedef char* (*falDefaultStringProc)( + XLCd /* lcd */ +); + +typedef struct { + XCloseLCProc close; + XlcMapModifiersProc map_modifiers; + XOpenOMProc open_om; + XOpenIMProc open_im; + XrmInitParseInfoProc init_parse_info; + falmbTextPropertyToTextListProc mb_text_prop_to_list; + falwcTextPropertyToTextListProc wc_text_prop_to_list; + falmbTextListToTextPropertyProc mb_text_list_to_prop; + falwcTextListToTextPropertyProc wc_text_list_to_prop; + falwcFreeStringListProc wc_free_string_list; + falDefaultStringProc default_string; + XRegisterIMInstantiateCBProc register_callback; + XUnregisterIMInstantiateCBProc unregister_callback; +} XLCdMethodsRec, *XLCdMethods; + + +typedef struct { + char* name; /* name of this LC */ + char* modifiers; /* modifiers of locale */ +} XLCdCoreRec, *XLCdCore; + + +typedef struct _XLCd { + XLCdMethods methods; /* methods of this LC */ + XLCdCore core; /* data of this LC */ + XPointer opaque; /* LDX specific data */ +} XLCdRec; + +typedef int XlcPosition; + +#define XlcHead 0 +#define XlcTail -1 + +typedef struct { + char *name; + XPointer value; +} XlcArg, *XlcArgList; + +typedef struct _XlcResource { + char *name; + XrmQuark xrm_name; + int size; + int offset; + unsigned long mask; +} XlcResource, *XlcResourceList; + +#define XlcCreateMask (1L<<0) +#define XlcDefaultMask (1L<<1) +#define XlcGetMask (1L<<2) +#define XlcSetMask (1L<<3) +#define XlcIgnoreMask (1L<<4) + +#define XlcNumber(arr) (sizeof(arr) / sizeof(arr[0])) + +typedef Status (*XCloseOMProc)( + XOM /* om */ +); + +typedef char* (*XSetOMValuesProc)( + XOM /* om */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef char* (*XGetOMValuesProc)( + XOM /* om */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef XOC (*XCreateOCProc)( + XOM /* om */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef struct _XOMMethodsRec { + XCloseOMProc close; + XSetOMValuesProc set_values; + XGetOMValuesProc get_values; + XCreateOCProc create_oc; +} XOMMethodsRec, *XOMMethods; + +typedef struct _XOMCoreRec { + XLCd lcd; /* lcd */ + Display *display; /* display */ + XrmDatabase rdb; /* database */ + char *res_name; /* resource name */ + char *res_class; /* resource class */ + XOC oc_list; /* xoc list */ + XlcResourceList resources; /* xom resources */ + int num_resources; /* number of xom resources */ + XOMCharSetList required_charset; /* required charset list */ + XOMOrientation orientation_list; /* orientation list */ + Bool directional_dependent; /* directional-dependent */ + Bool contextual_drawing; /* contextual drawing */ + Bool context_dependent; /* context-dependent drawing */ +} XOMCoreRec, *XOMCore; + +typedef struct _XOM { + XOMMethods methods; + XOMCoreRec core; +} XOMRec; + +typedef void (*XDestroyOCProc)( + XOC /* oc */ +); + +typedef char* (*XSetOCValuesProc)( + XOC /* oc */, + XlcArgList /* args */, + int /* num_args */ +); + +typedef char* (*XGetOCValuesProc)( + XOC /* oc */, + XlcArgList /* args */, + int /* num_args */ +); + +/* + * X Font Sets are an instantiable object, so we define it, the + * object itself, a method list and data + */ + +/* + * XFontSet object method list + */ + +typedef int (*XmbTextEscapementProc)( + XFontSet /* font_set */, + const char* /* text */, + int /* text_len */ +); + +typedef int (*XmbTextExtentsProc)( + XFontSet /* font_set */, + const char* /* text */, + int /* text_len */, + XRectangle* /* overall_ink_extents */, + XRectangle* /* overall_logical_extents */ +); + +typedef Status (*XmbTextPerCharExtentsProc)( + XFontSet /* font_set */, + const char* /* text */, + int /* text_len */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* max_ink_extents */, + XRectangle* /* max_logical_extents */ +); + +typedef int (*XmbDrawStringProc)( + Display* /* display */, + Drawable /* drawable */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + const char* /* text */, + int /* text_len */ +); + +typedef void (*XmbDrawImageStringProc)( + Display* /* display */, + Drawable /* drawable */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + const char* /* text */, + int /* text_len */ +); + +typedef int (*XwcTextEscapementProc)( + XFontSet /* font_set */, + const wchar_t* /* text */, + int /* text_len */ +); + +typedef int (*XwcTextExtentsProc)( + XFontSet /* font_set */, + const wchar_t* /* text */, + int /* text_len */, + XRectangle* /* overall_ink_extents */, + XRectangle* /* overall_logical_extents */ +); + +typedef Status (*XwcTextPerCharExtentsProc)( + XFontSet /* font_set */, + const wchar_t* /* text */, + int /* text_len */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* max_ink_extents */, + XRectangle* /* max_logical_extents */ +); + +typedef int (*XwcDrawStringProc)( + Display* /* display */, + Drawable /* drawable */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + const wchar_t* /* text */, + int /* text_len */ +); + +typedef void (*XwcDrawImageStringProc)( + Display* /* display */, + Drawable /* drawable */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + const wchar_t* /* text */, + int /* text_len */ +); + +typedef struct { + XDestroyOCProc destroy; + XSetOCValuesProc set_values; + XGetOCValuesProc get_values; + + /* multi-byte text drawing methods */ + + XmbTextEscapementProc mb_escapement; + XmbTextExtentsProc mb_extents; + XmbTextPerCharExtentsProc mb_extents_per_char; + XmbDrawStringProc mb_draw_string; + XmbDrawImageStringProc mb_draw_image_string; + + /* wide character text drawing methods */ + + XwcTextEscapementProc wc_escapement; + XwcTextExtentsProc wc_extents; + XwcTextPerCharExtentsProc wc_extents_per_char; + XwcDrawStringProc wc_draw_string; + XwcDrawImageStringProc wc_draw_image_string; +} XOCMethodsRec, *XOCMethods; + + +/* + * XOC independent data + */ + +typedef struct { + XOM om; /* XOM */ + XOC next; /* next XOC */ + XlcResourceList resources; /* xoc resources */ + int num_resources; /* number of xoc resources */ + char *base_name_list; /* base font name list */ + Bool om_automatic; /* OM Automatic */ + XOMFontInfo font_info; /* font info */ + XFontSetExtents font_set_extents; /* font set extents */ + char *default_string; /* default string */ + XOMCharSetList missing_list; /* missing charset list */ + XOrientation orientation; /* orientation */ + char *res_name; /* resource name */ + char *res_class; /* resource class */ +} XOCCoreRec, *XOCCore; + +typedef struct _XOC { + XOCMethods methods; + XOCCoreRec core; +} XOCRec; + + +/* + * X Input Managers are an instantiable object, so we define it, the + * object itself, a method list and data. + */ + +/* + * an Input Manager object method list + */ +typedef struct { + Status (*close)( + XIM + ); + char* (*set_values)( + XIM, XIMArg* + ); + char* (*get_values)( + XIM, XIMArg* + ); + XIC (*create_ic)( + XIM, XIMArg* + ); + int (*ctstombs)( + XIM, char*, int, char*, int, Status * + ); + int (*ctstowcs)( + XIM, char*, int, wchar_t*, int, Status * + ); +} XIMMethodsRec, *XIMMethods; + +/* + * Input Manager LC independent data + */ +typedef struct { + XLCd lcd; /* LC of this input method */ + XIC ic_chain; /* list of ICs for this IM */ + + Display * display; /* display */ + XrmDatabase rdb; + char * res_name; + char * res_class; + + XIMValuesList *im_values_list; + XIMValuesList *ic_values_list; + XIMStyles *styles; + XIMCallback destroy_callback; + char * im_name; /* XIMMODIFIER name */ + XIMResourceList im_resources; /* compiled IM resource list */ + unsigned int im_num_resources; + XIMResourceList ic_resources; /* compiled IC resource list */ + unsigned int ic_num_resources; + Bool visible_position; +} XIMCoreRec, *XIMCore; + + + +/* + * An X Input Manager (IM). Implementations may need to extend this data + * structure to accommodate additional data, state information etc. + */ +typedef struct _XIM { + XIMMethods methods; /* method list of this IM */ + XIMCoreRec core; /* data of this IM */ +} XIMRec; + + + +/* + * X Input Contexts (IC) are an instantiable object, so we define it, the + * object itself, a method list and data for this object + */ + +/* + * Input Context method list + */ +typedef struct { + void (*destroy)( + XIC + ); + void (*set_focus)( + XIC + ); + void (*unset_focus)( + XIC + ); + char* (*set_values)( + XIC, XIMArg* + ); + char* (*get_values)( + XIC, XIMArg* + ); + char* (*mb_reset)( + XIC + ); + wchar_t* (*wc_reset)( + XIC + ); + int (*mb_lookup_string)( + XIC, XKeyEvent*, char*, int, KeySym*, Status* + ); + int (*wc_lookup_string)( + XIC, XKeyEvent*, wchar_t*, int, KeySym*, Status* + ); +} XICMethodsRec, *XICMethods; + + +/* + * Input Context LC independent data + */ +typedef struct { + XIM im; /* XIM this IC belongs too */ + XIC next; /* linked list of ICs for IM */ + + Window client_window; /* window IM can use for */ + /* display or subwindows */ + XIMStyle input_style; /* IM's input style */ + Window focus_window; /* where key events go */ + unsigned long filter_events; /* event mask from IM */ + XIMCallback geometry_callback; /* client callback */ + char * res_name; + char * res_class; + + XIMCallback destroy_callback; + XIMCallback string_conversion_callback; + XIMStringConversionText string_conversion; + XIMResetState reset_state; + XIMHotKeyTriggers *hotkey; + XIMHotKeyState hotkey_state; + + ICPreeditAttributes preedit_attr; /* visuals of preedit area */ + ICStatusAttributes status_attr; /* visuals of status area */ +} XICCoreRec, *XICCore; + + +/* + * an Input Context. Implementations may need to extend this data + * structure to accommodate additional data, state information etc. + */ +typedef struct _XIC { + XICMethods methods; /* method list of this IC */ + XICCoreRec core; /* data of this IC */ +} XICRec; + +typedef XLCd (*XLCdLoadProc)( + char* +); + +_XFUNCPROTOBEGIN + +extern XLCd _falOpenLC( + char* /* name */ +); + +extern void _falCloseLC( + XLCd /* lcd */ +); + +extern XLCd _fallcCurrentLC( + void +); + +extern Bool _fallcValidModSyntax( + char* /* mods */, + char** /* valid */ +); + +extern char *_fallcDefaultMapModifiers( + XLCd /* lcd */, + char* /* user_mods */, + char* /* prog_mods */ +); + +extern void _XIMCompileResourceList( + XIMResourceList /* res */, + unsigned int /* num_res */ +); + +extern void _XCopyToArg( + XPointer /* src */, + XPointer* /* dst */, + unsigned int /* size */ +); + +extern char ** _falParseBaseFontNameList( + char* /* str */, + int* /* num */ +); + +extern XrmMethods _falrmInitParseInfo( + XPointer* /* statep */ +); + +extern void _XRegisterFilterByMask( + Display* /* dpy */, + Window /* window */, + unsigned long /* event_mask */, + Bool (*)( + Display* /* display */, + Window /* window */, + XEvent* /* event */, + XPointer /* client_data */ + ) /* filter */, + XPointer /* client_data */ +); + +extern void _XRegisterFilterByType( + Display* /* dpy */, + Window /* window */, + int /* start_type */, + int /* end_type */, + Bool (*)( + Display* /* display */, + Window /* window */, + XEvent* /* event */, + XPointer /* client_data */ + ) /* filter */, + XPointer /* client_data */ +); + +extern void _XUnregisterFilter( + Display* /* dpy */, + Window /* window */, + Bool (*)( + Display* /* display */, + Window /* window */, + XEvent* /* event */, + XPointer /* client_data */ + ) /* filter */, + XPointer /* client_data */ +); + +extern void _fallcCountVaList( + va_list /* var */, + int* /* count_return */ +); + +extern void _fallcVaToArgList( + va_list /* var */, + int /* count */, + XlcArgList* /* args_return */ +); + +extern void _fallcCompileResourceList( + XlcResourceList /* resources */, + int /* num_resources */ +); + +extern char *_fallcGetValues( + XPointer /* base */, + XlcResourceList /* resources */, + int /* num_resources */, + XlcArgList /* args */, + int /* num_args */, + unsigned long /* mask */ +); + +extern char *_fallcSetValues( + XPointer /* base */, + XlcResourceList /* resources */, + int /* num_resources */, + XlcArgList /* args */, + int /* num_args */, + unsigned long /* mask */ +); + +extern Bool _fallcAddLoader( + XLCdLoadProc /* proc */, + XlcPosition /* position */ +); + +extern void _fallcRemoveLoader( + XLCdLoadProc /* proc */ +); + +_XFUNCPROTOEND + +#endif /* _XLCINT_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_fallibint.h b/cde/programs/dtudcfonted/libfal/_fallibint.h new file mode 100644 index 000000000..a02722a94 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallibint.h @@ -0,0 +1,1035 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Xlibint.h 1.2 - Fujitsu source for CDEnext 95/12/07 10:53:12 */ +/* $XConsortium: _fallibint.h /main/1 1996/04/08 15:21:22 cde-fuj $ */ + +/* + +Copyright (c) 1984, 1985, 1987, 1989 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +/* + * Xlibint.h - Header definition and support file for the internal + * support routines used by the C subroutine interface + * library (Xlib) to the X Window System. + * + * Warning, there be dragons here.... + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + + +#if !defined(NEED_EVENTS) && !NeedFunctionPrototypes +#define _XEVENT_ +#endif + +#include "syncx.h" + +struct _XGC +{ + XExtData *ext_data; /* hook for extension to hang data */ + GContext gid; /* protocol ID for graphics context */ + Bool rects; /* boolean: TRUE if clipmask is list of rectangles */ + Bool dashes; /* boolean: TRUE if dash-list is really a list */ + unsigned long dirty;/* cache dirty bits */ + XGCValues values; /* shadow structure of values */ +}; + +struct _XDisplay +{ + XExtData *ext_data; /* hook for extension to hang data */ + struct _XFreeFuncs *free_funcs; /* internal free functions */ + int fd; /* Network socket. */ + int conn_checker; /* ugly thing used by _XEventsQueued */ + int proto_major_version;/* maj. version of server's X protocol */ + int proto_minor_version;/* minor version of server's X protocol */ + char *vendor; /* vendor of the server hardware */ + XID resource_base; /* resource ID base */ + XID resource_mask; /* resource ID mask bits */ + XID resource_id; /* allocator current ID */ + int resource_shift; /* allocator shift to correct bits */ + XID (*resource_alloc)(); /* allocator function */ + int byte_order; /* screen byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* padding and data requirements */ + int bitmap_pad; /* padding requirements on bitmaps */ + int bitmap_bit_order; /* LeastSignificant or MostSignificant */ + int nformats; /* number of pixmap formats in list */ + ScreenFormat *pixmap_format; /* pixmap format list */ + int vnumber; /* Xlib's X protocol version number. */ + int release; /* release of the server */ + struct _XSQEvent *head, *tail; /* Input event queue. */ + int qlen; /* Length of input event queue */ + unsigned long last_request_read; /* seq number of last event read */ + unsigned long request; /* sequence number of last request. */ + char *last_req; /* beginning of last request, or dummy */ + char *buffer; /* Output buffer starting address. */ + char *bufptr; /* Output buffer index pointer. */ + char *bufmax; /* Output buffer maximum+1 address. */ + unsigned max_request_size; /* maximum number 32 bit words in request*/ + struct _XrmHashBucketRec *db; + int (*synchandler)(); /* Synchronization handler */ + char *display_name; /* "host:display" string used on this connect*/ + int default_screen; /* default screen for operations */ + int nscreens; /* number of screens on this server*/ + Screen *screens; /* pointer to list of screens */ + unsigned long motion_buffer; /* size of motion buffer */ + unsigned long flags; /* internal connection flags */ + int min_keycode; /* minimum defined keycode */ + int max_keycode; /* maximum defined keycode */ + KeySym *keysyms; /* This server's keysyms */ + XModifierKeymap *modifiermap; /* This server's modifier keymap */ + int keysyms_per_keycode;/* number of rows */ + char *xdefaults; /* contents of defaults from server */ + char *scratch_buffer; /* place to hang scratch buffer */ + unsigned long scratch_length; /* length of scratch buffer */ + int ext_number; /* extension number on this display */ + struct _XExten *ext_procs; /* extensions initialized on this display */ + /* + * the following can be fixed size, as the protocol defines how + * much address space is available. + * While this could be done using the extension vector, there + * may be MANY events processed, so a search through the extension + * list to find the right procedure for each event might be + * expensive if many extensions are being used. + */ + Bool (*event_vec[128])(); /* vector for wire to event */ + Status (*wire_vec[128])(); /* vector for event to wire */ + KeySym lock_meaning; /* for XLookupString */ + struct _XLockInfo *lock; /* multi-thread state, display lock */ + struct _XInternalAsync *async_handlers; /* for internal async */ + unsigned long bigreq_size; /* max size of big requests */ + struct _XLockPtrs *lock_fns; /* pointers to threads functions */ + void (*idlist_alloc)(); /* XID list allocator function */ + /* things above this line should not move, for binary compatibility */ + struct _XKeytrans *key_bindings; /* for XLookupString */ + Font cursor_font; /* for XCreateFontCursor */ + struct _XDisplayAtoms *atoms; /* for falInternAtom */ + unsigned int mode_switch; /* keyboard group modifiers */ + unsigned int num_lock; /* keyboard numlock modifiers */ + struct _XContextDB *context_db; /* context database */ + Bool (**error_vec)(); /* vector for wire to error */ + /* + * Xcms information + */ + struct { + XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */ + XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */ + XPointer perVisualIntensityMaps; + /* linked list of XcmsIntensityMap */ + } cms; + struct _XIMFilter *im_filters; + struct _XSQEvent *qfree; /* unallocated event queue elements */ + unsigned long next_event_serial_num; /* inserted into next queue elt */ + struct _XExten *flushes; /* Flush hooks */ + struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */ + int im_fd_length; /* number of im_fd_info */ + struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */ + int watcher_count; /* number of conn_watchers */ + XPointer filedes; /* struct pollfd cache for _XWaitForReadable */ + int (*savedsynchandler)(); /* user synchandler when Xlib usurps */ + XID resource_max; /* allocator max ID */ + int xcmisc_opcode; /* major opcode for XC-MISC */ + struct _XkbInfoRec *xkb_info; /* XKB info */ + struct _XtransConnInfo *trans_conn; /* transport connection object */ +}; + +#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n) + +/* + * define DataRoutineIsProcedure if you want the Data macro to be a procedure + * instead + */ + +#ifndef _XEVENT_ +/* + * _QEvent datatype for use in input queueing. + */ +typedef struct _XSQEvent +{ + struct _XSQEvent *next; + XEvent event; + unsigned long qserial_num; /* so multi-threaded code can find new ones */ +} _XQEvent; +#endif + +#ifdef XTHREADS /* for xReply */ +#define NEED_REPLIES +#endif + +#define NEED_EVENTS +#define NEED_REPLIES +#include <X11/Xproto.h> +#include <errno.h> +#define _XBCOPYFUNC _Xbcopy +#include <X11/Xfuncs.h> +#include <X11/Xosdefs.h> + +#ifndef X_NOT_STDC_ENV +#include <stdlib.h> +#include <string.h> +#else +char *malloc(), *realloc(), *calloc(); +void exit(); +#ifdef SYSV +#include <string.h> +#else +#include <strings.h> +#endif +#endif + +/* + * The following definitions can be used for locking requests in multi-threaded + * address spaces. + */ +#ifdef XTHREADS +/* Author: Stephen Gildea, MIT X Consortium + * + * declarations for C Threads locking + */ + +#include <X11/Xfuncproto.h> + +struct _XLockPtrs { + /* used by all, including extensions; do not move */ + void (*lock_display)(); + void (*unlock_display)(); +}; + +typedef struct _LockInfoRec *LockInfoPtr; + +/* in XlibInt.c */ +extern void (*_XCreateMutex_fn)( + LockInfoPtr /* lock */ +); +extern void (*_XFreeMutex_fn)( + LockInfoPtr /* lock */ +); +extern void (*_XLockMutex_fn)( + LockInfoPtr /* lock */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char * /* file */ + , int /* line */ +#endif +); +extern void (*_XUnlockMutex_fn)( + LockInfoPtr /* lock */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char * /* file */ + , int /* line */ +#endif +); + +extern LockInfoPtr _Xglobal_lock; + +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) +#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__) +#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__) +#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__) +#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__) +#else +/* used everywhere, so must be fast if not using threads */ +#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d) +#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d) +#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock) +#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock) +#endif +#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock); +#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock); + +#else /* XTHREADS */ +#define LockDisplay(dis) +#define _XLockMutex(lock) +#define _XUnlockMutex(lock) +#define UnlockDisplay(dis) +#define _XCreateMutex(lock) +#define _XFreeMutex(lock) +#endif + +#define Xfree(ptr) free((ptr)) + +/* + * Note that some machines do not return a valid pointer for malloc(0), in + * which case we provide an alternate under the control of the + * define MALLOC_0_RETURNS_NULL. This is necessary because some + * Xlib code expects malloc(0) to return a valid pointer to storage. + */ +#ifdef MALLOC_0_RETURNS_NULL + +# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size))) +# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size))) +# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize)) + +#else + +# define Xmalloc(size) malloc((size)) +# define Xrealloc(ptr, size) realloc((ptr), (size)) +# define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) + +#endif + +#define LOCKED 1 +#define UNLOCKED 0 + +#ifdef X_NOT_STDC_ENV +extern int errno; /* Internal system error number. */ +#endif + +#ifndef BUFSIZE +#define BUFSIZE 2048 /* X output buffer size. */ +#endif +#ifndef PTSPERBATCH +#define PTSPERBATCH 1024 /* point batching */ +#endif +#ifndef WLNSPERBATCH +#define WLNSPERBATCH 50 /* wide line batching */ +#endif +#ifndef ZLNSPERBATCH +#define ZLNSPERBATCH 1024 /* thin line batching */ +#endif +#ifndef WRCTSPERBATCH +#define WRCTSPERBATCH 10 /* wide line rectangle batching */ +#endif +#ifndef ZRCTSPERBATCH +#define ZRCTSPERBATCH 256 /* thin line rectangle batching */ +#endif +#ifndef FRCTSPERBATCH +#define FRCTSPERBATCH 256 /* filled rectangle batching */ +#endif +#ifndef FARCSPERBATCH +#define FARCSPERBATCH 256 /* filled arc batching */ +#endif +#ifndef CURSORFONT +#define CURSORFONT "cursor" /* standard cursor fonts */ +#endif + +/* + * Display flags + */ +#define XlibDisplayIOError (1L << 0) +#define XlibDisplayClosing (1L << 1) +#define XlibDisplayNoXkb (1L << 2) +#define XlibDisplayPrivSync (1L << 3) +#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */ +#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */ +#define XlibDisplayReply (1L << 5) /* in _XReply */ +#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */ + +/* + * X Protocol packetizing macros. + */ + +#define WORD64ALIGN + +/* + * GetReq - Get the next available X request packet in the buffer and + * return it. + * + * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc. + * "req" is the name of the request pointer. + * + */ + +#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) +#define GetReq(name, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ + req->reqType = X_##name;\ + req->length = (SIZEOF(x##name##Req))>>2;\ + dpy->bufptr += SIZEOF(x##name##Req);\ + dpy->request++ + +#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ +#define GetReq(name, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ + req->reqType = X_/**/name;\ + req->length = (SIZEOF(x/**/name/**/Req))>>2;\ + dpy->bufptr += SIZEOF(x/**/name/**/Req);\ + dpy->request++ +#endif + +/* GetReqExtra is the same as GetReq, but allocates "n" additional + bytes after the request. "n" must be a multiple of 4! */ + +#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) +#define GetReqExtra(name, n, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ + req->reqType = X_##name;\ + req->length = (SIZEOF(x##name##Req) + n)>>2;\ + dpy->bufptr += SIZEOF(x##name##Req) + n;\ + dpy->request++ +#else +#define GetReqExtra(name, n, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ + req->reqType = X_/**/name;\ + req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\ + dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\ + dpy->request++ +#endif + + +/* + * GetResReq is for those requests that have a resource ID + * (Window, Pixmap, GContext, etc.) as their single argument. + * "rid" is the name of the resource. + */ + +#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) +#define GetResReq(name, rid, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ + req->reqType = X_##name;\ + req->length = 2;\ + req->id = (rid);\ + dpy->bufptr += SIZEOF(xResourceReq);\ + dpy->request++ +#else +#define GetResReq(name, rid, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ + req->reqType = X_/**/name;\ + req->length = 2;\ + req->id = (rid);\ + dpy->bufptr += SIZEOF(xResourceReq);\ + dpy->request++ +#endif + +/* + * GetEmptyReq is for those requests that have no arguments + * at all. + */ +#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) +#define GetEmptyReq(name, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (xReq *) (dpy->last_req = dpy->bufptr);\ + req->reqType = X_##name;\ + req->length = 1;\ + dpy->bufptr += SIZEOF(xReq);\ + dpy->request++ +#else +#define GetEmptyReq(name, req) \ + WORD64ALIGN\ + if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (xReq *) (dpy->last_req = dpy->bufptr);\ + req->reqType = X_/**/name;\ + req->length = 1;\ + dpy->bufptr += SIZEOF(xReq);\ + dpy->request++ +#endif + +#define MakeBigReq(req,n) \ + { \ + long _BRdat; \ + unsigned long _BRlen = req->length - 1; \ + req->length = 0; \ + _BRdat = ((long *)req)[_BRlen]; \ + memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ + ((unsigned long *)req)[1] = _BRlen + n + 2; \ + Data32(dpy, &_BRdat, 4); \ + } + +#define SetReqLen(req,n,badlen) \ + if ((req->length + n) > (unsigned)65535) { \ + if (dpy->bigreq_size) { \ + MakeBigReq(req,n) \ + } else { \ + n = badlen; \ + req->length += n; \ + } \ + } else \ + req->length += n + +#define SyncHandle() \ + if (dpy->synchandler) (*dpy->synchandler)(dpy) + +#define FlushGC(dpy, gc) \ + if ((gc)->dirty) _XFlushGCCache((dpy), (gc)) +/* + * Data - Place data in the buffer and pad the end to provide + * 32 bit word alignment. Transmit if the buffer fills. + * + * "dpy" is a pointer to a Display. + * "data" is a pinter to a data buffer. + * "len" is the length of the data buffer. + */ +#ifndef DataRoutineIsProcedure +#define Data(dpy, data, len) \ + if (dpy->bufptr + (len) <= dpy->bufmax) {\ + memcpy(dpy->bufptr, data, (int)len);\ + dpy->bufptr += ((len) + 3) & ~3;\ + } else\ + _XSend(dpy, data, len) +#endif /* DataRoutineIsProcedure */ + + +/* Allocate bytes from the buffer. No padding is done, so if + * the length is not a multiple of 4, the caller must be + * careful to leave the buffer aligned after sending the + * current request. + * + * "type" is the type of the pointer being assigned to. + * "ptr" is the pointer being assigned to. + * "n" is the number of bytes to allocate. + * + * Example: + * xTextElt *elt; + * BufAlloc (xTextElt *, elt, nbytes) + */ + +#define BufAlloc(type, ptr, n) \ + if (dpy->bufptr + (n) > dpy->bufmax) \ + _XFlush (dpy); \ + ptr = (type) dpy->bufptr; \ + dpy->bufptr += (n); + +#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) +#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len)) +#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len)) +#ifdef LONG64 +#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) +#else +#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) +#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len)) +#endif + +#define PackData16(dpy,data,len) Data16 (dpy, data, len) +#define PackData32(dpy,data,len) Data32 (dpy, data, len) + +/* Xlib manual is bogus */ +#define PackData(dpy,data,len) PackData16 (dpy, data, len) + +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define max(a,b) (((a) > (b)) ? (a) : (b)) + +#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ + (((cs)->rbearing|(cs)->lbearing| \ + (cs)->ascent|(cs)->descent) == 0)) + +/* + * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit + * character. If the character is in the column and exists, then return the + * appropriate metrics (note that fonts with common per-character metrics will + * return min_bounds). If none of these hold true, try again with the default + * char. + */ +#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ +{ \ + cs = def; \ + if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ + if (fs->per_char == NULL) { \ + cs = &fs->min_bounds; \ + } else { \ + cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ + if (CI_NONEXISTCHAR(cs)) cs = def; \ + } \ + } \ +} + +#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ + CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) + + + +/* + * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and + * column. This is used for fonts that have more than row zero. + */ +#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ +{ \ + cs = def; \ + if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ + col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ + if (fs->per_char == NULL) { \ + cs = &fs->min_bounds; \ + } else { \ + cs = &fs->per_char[((row - fs->min_byte1) * \ + (fs->max_char_or_byte2 - \ + fs->min_char_or_byte2 + 1)) + \ + (col - fs->min_char_or_byte2)]; \ + if (CI_NONEXISTCHAR(cs)) cs = def; \ + } \ + } \ +} + +#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ +{ \ + unsigned int r = (fs->default_char >> 8); \ + unsigned int c = (fs->default_char & 0xff); \ + CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ +} + + +#ifdef MUSTCOPY + +/* for when 32-bit alignment is not good enough */ +#define OneDataCard32(dpy,dstaddr,srcvar) \ + { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); } + +#else + +/* srcvar must be a variable for large architecture version */ +#define OneDataCard32(dpy,dstaddr,srcvar) \ + { *(CARD32 *)(dstaddr) = (srcvar); } + +#endif /* MUSTCOPY */ + +typedef struct _XInternalAsync { + struct _XInternalAsync *next; + Bool (*handler)(); + XPointer data; +} _XAsyncHandler; + +typedef struct _XAsyncEState { + unsigned long min_sequence_number; + unsigned long max_sequence_number; + unsigned char error_code; + unsigned char major_opcode; + unsigned short minor_opcode; + unsigned char last_error_received; + int error_count; +} _XAsyncErrorState; + +#define DeqAsyncHandler(dpy,handler) { \ + if (dpy->async_handlers == (handler)) \ + dpy->async_handlers = (handler)->next; \ + else \ + _XDeqAsyncHandler(dpy, handler); \ + } + +/* + * This structure is private to the library. + */ +typedef struct _XFreeFuncs { + void (*atoms)(); /* _XFreeAtomTable */ + int (*modifiermap)(); /* XFreeModifierMap */ + void (*key_bindings)(); /* _XFreeKeyBindings */ + void (*context_db)(); /* _XFreeContextDB */ + void (*defaultCCCs)(); /* _XcmsFreeDefaultCCCs */ + void (*clientCmaps)(); /* _XcmsFreeClientCmaps */ + void (*intensityMaps)(); /* _XcmsFreeIntensityMaps */ + void (*im_filters)(); /* _XFreeIMFilters */ + void (*xkb)(); /* _XkbFreeInfo */ +} _XFreeFuncRec; + +/* + * This structure is private to the library. + */ +typedef struct _XExten { /* private to extension mechanism */ + struct _XExten *next; /* next in list */ + XExtCodes codes; /* public information, all extension told */ + int (*create_GC)(); /* routine to call when GC created */ + int (*copy_GC)(); /* routine to call when GC copied */ + int (*flush_GC)(); /* routine to call when GC flushed */ + int (*free_GC)(); /* routine to call when GC freed */ + int (*create_Font)(); /* routine to call when Font created */ + int (*free_Font)(); /* routine to call when Font freed */ + int (*close_display)(); /* routine to call when connection closed */ + int (*error)(); /* who to call when an error occurs */ + char *(*error_string)(); /* routine to supply error string */ + char *name; /* name of this extension */ + void (*error_values)(); /* routine to supply error values */ + void (*before_flush)(); /* routine to call when sending data */ + struct _XExten *next_flush; /* next in list of those with flushes */ +} _XExtension; + +/* extension hooks */ + +_XFUNCPROTOBEGIN + +#ifdef DataRoutineIsProcedure +extern void Data(); +#endif +extern int _XError( + Display* /* dpy */, + xError* /* rep */ +); +extern int _XIOError( + Display* /* dpy */ +); +extern int (*_XIOErrorFunction)( + Display* /* dpy */ +); +extern int (*_XErrorFunction)( + Display* /* dpy */, + XErrorEvent* /* error_event */ +); +extern void _XEatData( + Display* /* dpy */, + unsigned long /* n */ +); +extern char *_XAllocScratch( + Display* /* dpy */, + unsigned long /* nbytes */ +); +extern char *_XAllocTemp( + Display* /* dpy */, + unsigned long /* nbytes */ +); +extern void _XFreeTemp( + Display* /* dpy */, + char* /* buf */, + unsigned long /* nbytes */ +); +extern Visual *_XVIDtoVisual( + Display* /* dpy */, + VisualID /* id */ +); +extern unsigned long _XSetLastRequestRead( + Display* /* dpy */, + xGenericReply* /* rep */ +); +extern int _XGetHostname( + char* /* buf */, + int /* maxlen */ +); +extern Screen *_XScreenOfWindow( + Display* /* dpy */, + Window /* w */ +); +extern Bool _XAsyncErrorHandler( + Display* /* dpy */, + xReply* /* rep */, + char* /* buf */, + int /* len */, + XPointer /* data */ +); +extern char *_XGetAsyncReply( + Display* /* dpy */, + char* /* replbuf */, + xReply* /* rep */, + char* /* buf */, + int /* len */, + int /* extra */, + Bool /* discard */ +); +extern _XFlush( + Display* /* dpy */ +); +extern int _XEventsQueued( + Display* /* dpy */, + int /* mode */ +); +extern _XReadEvents( + Display* /* dpy */ +); +extern _XRead( + Display* /* dpy */, + char* /* data */, + long /* size */ +); +extern _XReadPad( + Display* /* dpy */, + char* /* data */, + long /* size */ +); +extern _XSend( + Display* /* dpy */, + const char* /* data */, + long /* size */ +); +extern Status _XReply( + Display* /* dpy */, + xReply* /* rep */, + int /* extra */, + Bool /* discard */ +); +extern _XEnq( + Display* /* dpy */, + xEvent* /* event */ +); +extern _XDeq( + Display* /* dpy */, + _XQEvent* /* prev */, + _XQEvent* /* qelt */ +); + +extern int (*XESetCreateGC( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + GC /* gc */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, GC, XExtCodes* +); + +extern int (*XESetCopyGC( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + GC /* gc */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, GC, XExtCodes* +); + +extern int (*XESetFlushGC( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + GC /* gc */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, GC, XExtCodes* +); + +extern int (*XESetFreeGC( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + GC /* gc */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, GC, XExtCodes* +); + +extern int (*XESetCreateFont( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + XFontStruct* /* fs */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, XFontStruct*, XExtCodes* +); + +extern int (*XESetFreeFont( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + XFontStruct* /* fs */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, XFontStruct*, XExtCodes* +); + +extern int (*XESetCloseDisplay( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + XExtCodes* /* codes */ + ) /* proc */ +))( + Display*, XExtCodes* +); + +extern int (*XESetError( + Display* /* display */, + int /* extension */, + int (*) ( + Display* /* display */, + xError* /* err */, + XExtCodes* /* codes */, + int* /* ret_code */ + ) /* proc */ +))( + Display*, xError*, XExtCodes*, int* +); + +extern char* (*XESetErrorString( + Display* /* display */, + int /* extension */, + char* (*) ( + Display* /* display */, + int /* code */, + XExtCodes* /* codes */, + char* /* buffer */, + int /* nbytes */ + ) /* proc */ +))( + Display*, int, XExtCodes*, char*, int +); + +extern void (*XESetPrintErrorValues ( + Display* /* display */, + int /* extension */, + void (*)( + Display* /* display */, + XErrorEvent* /* ev */, + void* /* fp */ + ) /* proc */ +))( + Display*, XErrorEvent*, void* +); + +extern Bool (*XESetWireToEvent( + Display* /* display */, + int /* event_number */, + Bool (*) ( + Display* /* display */, + XEvent* /* re */, + xEvent* /* event */ + ) /* proc */ +))( + Display*, XEvent*, xEvent* +); + +extern Status (*XESetEventToWire( + Display* /* display */, + int /* event_number */, + Status (*) ( + Display* /* display */, + XEvent* /* re */, + xEvent* /* event */ + ) /* proc */ +))( + Display*, XEvent*, xEvent* +); + +extern Bool (*XESetWireToError( + Display* /* display */, + int /* error_number */, + Bool (*) ( + Display* /* display */, + XErrorEvent* /* he */, + xError* /* we */ + ) /* proc */ +))( + Display*, XErrorEvent*, xError* +); + +extern void (*XESetBeforeFlush( + Display* /* display */, + int /* error_number */, + void (*) ( + Display* /* display */, + XExtCodes* /* codes */, + char* /* data */, + long /* len */ + ) /* proc */ +))( + Display*, XExtCodes*, char*, long +); + +/* internal connections for IMs */ + +typedef void (*_XInternalConnectionProc)( + Display* /* dpy */, + int /* fd */, + XPointer /* call_data */ +); + + +extern Status _XRegisterInternalConnection( + Display* /* dpy */, + int /* fd */, + _XInternalConnectionProc /* callback */, + XPointer /* call_data */ +); + +extern void _XUnregisterInternalConnection( + Display* /* dpy */, + int /* fd */ +); + +/* Display structure has pointers to these */ + +struct _XConnectionInfo { /* info from _XRegisterInternalConnection */ + int fd; + _XInternalConnectionProc read_callback; + XPointer call_data; + XPointer *watch_data; /* set/used by XConnectionWatchProc */ + struct _XConnectionInfo *next; +}; + +struct _XConnWatchInfo { /* info from XAddConnectionWatch */ + XConnectionWatchProc fn; + XPointer client_data; + struct _XConnWatchInfo *next; +}; + +extern int XTextHeight( + XFontStruct* /* font_struct */, + const char* /* string */, + int /* count */ +); + +extern int XTextHeight16( + XFontStruct* /* font_struct */, + const XChar2b* /* string */, + int /* count */ +); + +_XFUNCPROTOEND diff --git a/cde/programs/dtudcfonted/libfal/_fallocking.h b/cde/programs/dtudcfonted/libfal/_fallocking.h new file mode 100644 index 000000000..384437f99 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_fallocking.h @@ -0,0 +1,175 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* locking.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:43 */ +/* $XConsortium: _fallocking.h /main/1 1996/04/08 15:21:32 cde-fuj $ */ +/* + +Copyright (c) 1992 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +*/ + +/* + * Author: Stephen Gildea, MIT X Consortium + * + * locking.h - data types for C Threads locking. + * Used by XlibInt.c, locking.c, LockDis.c + */ + +#ifndef _X_locking_H_ +#define _X_locking_H_ + +#define xmalloc(s) Xmalloc(s) +#define xfree(s) Xfree(s) +#include <X11/Xthreads.h> + +struct _XCVList { + xcondition_t cv; + xReply *buf; + struct _XCVList *next; +}; + +extern xthread_t (*_Xthread_self_fn)( /* in XlibInt.c */ + void +); + +/* Display->lock is a pointer to one of these */ + +struct _XLockInfo { + xmutex_t mutex; /* mutex for critical sections */ + int reply_bytes_left; /* nbytes of the reply still to read */ + Bool reply_was_read; /* _XReadEvents read a reply for _XReply */ + struct _XCVList *reply_awaiters; /* list of CVs for _XReply */ + struct _XCVList **reply_awaiters_tail; + struct _XCVList *event_awaiters; /* list of CVs for _XReadEvents */ + struct _XCVList **event_awaiters_tail; + Bool reply_first; /* who may read, reply queue or event queue */ + /* for XLockDisplay */ + int locking_level; /* how many times into XLockDisplay we are */ + xthread_t locking_thread; /* thread that did XLockDisplay */ + xcondition_t cv; /* wait if another thread has XLockDisplay */ + xthread_t reading_thread; /* cache */ + xthread_t conni_thread; /* thread in XProcessInternalConnection */ + xcondition_t writers; /* wait for writable */ + int num_free_cvls; + struct _XCVList *free_cvls; + /* used only in XlibInt.c */ + void (*pop_reader)( + Display* /* dpy */, + struct _XCVList** /* list */, + struct _XCVList*** /* tail */ + ); + struct _XCVList *(*push_reader)( + Display * /* dpy */, + struct _XCVList*** /* tail */ + ); + void (*condition_wait)( + xcondition_t /* cv */, + xmutex_t /* mutex */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char* /* file */, + int /* line */ +#endif + ); + void (*internal_lock_display)( + Display* /* dpy */, + Bool /* wskip */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char* /* file */, + int /* line */ +#endif + ); + /* used in XlibInt.c and locking.c */ + void (*condition_signal)( + xcondition_t /* cv */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char* /* file */, + int /* line */ +#endif + ); + void (*condition_broadcast)( + xcondition_t /* cv */ +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) + , char* /* file */, + int /* line */ +#endif + ); + /* used in XlibInt.c and XLockDis.c */ + void (*lock_wait)( + Display* /* dpy */ + ); + void (*user_lock_display)( + Display* /* dpy */ + ); + void (*user_unlock_display)( + Display* /* dpy */ + ); + struct _XCVList *(*create_cvl)( + Display * /* dpy */ + ); +}; + +#define UnlockNextEventReader(d) if ((d)->lock) \ + (*(d)->lock->pop_reader)((d),&(d)->lock->event_awaiters,&(d)->lock->event_awaiters_tail) + +#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) +#define ConditionWait(d,c) if ((d)->lock) \ + (*(d)->lock->condition_wait)(c, (d)->lock->mutex,__FILE__,__LINE__) +#define ConditionSignal(d,c) if ((d)->lock) \ + (*(d)->lock->condition_signal)(c,__FILE__,__LINE__) +#define ConditionBroadcast(d,c) if ((d)->lock) \ + (*(d)->lock->condition_broadcast)(c,__FILE__,__LINE__) +#else +#define ConditionWait(d,c) if ((d)->lock) \ + (*(d)->lock->condition_wait)(c, (d)->lock->mutex) +#define ConditionSignal(d,c) if ((d)->lock) \ + (*(d)->lock->condition_signal)(c) +#define ConditionBroadcast(d,c) if ((d)->lock) \ + (*(d)->lock->condition_broadcast)(c) +#endif + +typedef struct _LockInfoRec { + xmutex_t lock; +} LockInfoRec; + +#endif /* _X_locking_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_falomGeneric.c b/cde/programs/dtudcfonted/libfal/_falomGeneric.c new file mode 100644 index 000000000..2caeaa761 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falomGeneric.c @@ -0,0 +1,1880 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* omGeneric.c 1.9 - Fujitsu source for CDEnext 96/04/26 11:20:11 */ +/* $XConsortium: _falomGeneric.c /main/4 1996/09/27 19:03:50 drk $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + +#include "_fallibint.h" +#include "_falomGeneric.h" +#include <X11/Xos.h> +#include <X11/Xatom.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#define MAXFONTS 100 +#define PIXEL_SIZE_FIELD 7 +#define POINT_SIZE_FIELD 8 +#define CHARSET_ENCODING_FIELD 14 + +extern int _falmbDefaultTextEscapement(), _falwcDefaultTextEscapement(); +extern int _falmbDefaultTextExtents(), _falwcDefaultTextExtents(); +extern Status _falmbDefaultTextPerCharExtents(), _falwcDefaultTextPerCharExtents(); +extern int _falmbDefaultDrawString(), _falwcDefaultDrawString(); +extern void _falmbDefaultDrawImageString(), _falwcDefaultDrawImageString(); + +extern int _falmbGenericTextEscapement(), _falwcGenericTextEscapement(); +extern int _falmbGenericTextExtents(), _falwcGenericTextExtents(); +extern Status _falmbGenericTextPerCharExtents(), _falwcGenericTextPerCharExtents(); +extern int _falmbGenericDrawString(), _falwcGenericDrawString(); +extern void _falmbGenericDrawImageString(), _falwcGenericDrawImageString(); + +extern void dbg_printValue(char *str, char **value, int num); + +/* For VW/UDC start */ + +static FontData +init_fontdata(FontData font_data, int font_data_count) +{ + FontData fd; + int i; + + fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count); + if(fd == (FontData) NULL) + return False; + + memset(fd, 0x00, sizeof(FontData) * font_data_count); + for(i = 0 ; i < font_data_count ; i++) + fd[i] = font_data[i]; + + return fd; +} + +static VRotate +init_vrotate( + FontData font_data, + int font_data_count, + int type, + CodeRange code_range, + int code_range_num) +{ + VRotate vrotate; + int i; + + if(type == VROTATE_NONE) + return (VRotate)NULL; + + vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count); + if(vrotate == (VRotate) NULL) + return False; + + memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count); + for(i = 0 ; i < font_data_count ; i++) { + vrotate[i].charset_name = font_data[i].name; + vrotate[i].side = font_data[i].side; + if(type == VROTATE_PART) { + vrotate[i].num_cr = code_range_num; + vrotate[i].code_range = code_range; + } + } + + return vrotate; +} + +static Bool +init_fontset(XOC oc) +{ + XOCGenericPart *gen; + FontSet font_set; + OMData data; + int count; + int err = 0; + + count = XOM_GENERIC(oc->core.om)->data_num; + data = XOM_GENERIC(oc->core.om)->data; + + font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count); + if (font_set == NULL) + return False; + memset((char *) font_set, 0x00, sizeof(FontSetRec) * count); + + gen = XOC_GENERIC(oc); + gen->font_set_num = count; + gen->font_set = font_set; + + for ( ; count-- > 0; data++, font_set++) { + font_set->charset_count = data->charset_count; + font_set->charset_list = data->charset_list; + + if((font_set->font_data = init_fontdata(data->font_data, + data->font_data_count)) == NULL){ + err += 1; + break; + } + font_set->font_data_count = data->font_data_count; + if((font_set->substitute = init_fontdata(data->substitute, + data->substitute_num)) == NULL){ + err += 1; + break; + } + font_set->substitute_num = data->substitute_num; + if((font_set->vmap = init_fontdata(data->vmap, + data->vmap_num)) == NULL){ + err += 1; + break; + } + font_set->vmap_num = data->vmap_num; + + if(data->vrotate_type != VROTATE_NONE) { + /* A vrotate member is specified primary font data */ + /* as initial value. */ + if((font_set->vrotate = init_vrotate(data->font_data, + data->font_data_count, + data->vrotate_type, + data->vrotate, + data->vrotate_num)) == NULL){ + err += 1; + break; + } + font_set->vrotate_num = data->font_data_count; + } + } + + if (err == 1){ + if(font_set->font_data) + Xfree(font_set->font_data); + if(font_set->substitute) + Xfree(font_set->substitute); + if(font_set->vmap) + Xfree(font_set->vmap); + if(font_set->vrotate) + Xfree(font_set->vrotate); + if(font_set) + Xfree(font_set); + gen->font_set = (FontSet) NULL; + gen->font_set_num = 0; + return False; + } else { + return True; + } +} + +/* For VW/UDC end */ + +static char * +get_prop_name(Display *dpy, XFontStruct *fs) +{ + unsigned long fp; + + if (falGetFontProperty(fs, XA_FONT, &fp)) + return falGetAtomName(dpy, fp); + + return (char *) NULL; +} + +static FontData +check_charset(FontSet font_set, char *font_name) +{ + FontData font_data; + char *last; + int count, length, name_len; + + name_len = strlen(font_name); + last = font_name + name_len; + + count = font_set->font_data_count; + font_data = font_set->font_data; + for ( ; count-- > 0; font_data++) { + length = strlen(font_data->name); + if (length > name_len) + continue; + + if (_fallcCompareISOLatin1(last - length, font_data->name) == 0) + return font_data; + } + + return (FontData) NULL; +} + +static int +check_fontname(XOC oc, char *name, int found_num) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontData data; + FontSet font_set; + XFontStruct *fs_list; + char **fn_list, *fname, *prop_fname = NULL; + int list_num, font_set_num, i; + int list2_num; + char **fn2_list = NULL; + + fn_list = falListFonts(dpy, name, MAXFONTS, &list_num); + if (fn_list == NULL) + return found_num; + + for (i = 0; i < list_num; i++) { + fname = fn_list[i]; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->font_name) + continue; + + if ((data = check_charset(font_set, fname)) == NULL) { + if ((fn2_list = falListFontsWithInfo(dpy, name, MAXFONTS, + &list2_num, &fs_list)) + && (prop_fname = get_prop_name(dpy, fs_list)) + && (data = check_charset(font_set, prop_fname))) + fname = prop_fname; + } + if (data) { + font_set->side = data->side; + font_set->font_name = (char *) Xmalloc(strlen(fname) + 1); + if (font_set->font_name) { + strcpy(font_set->font_name, fname); + found_num++; + } + } + if (fn2_list) { + falFreeFontInfo(fn2_list, fs_list, list2_num); + fn2_list = NULL; + if (prop_fname) { + Xfree(prop_fname); + prop_fname = NULL; + } + } + if (found_num == gen->font_set_num) + break; + } + } + falFreeFontNames(fn_list); + return found_num; +} + + +/* For VW/UDC start */ + +static Bool +load_fontdata(XOC oc, FontData font_data, int font_data_num) +{ + Display *dpy = oc->core.om->core.display; + FontData fd = font_data; + + for( ; font_data_num-- ; fd++) { + if(fd->xlfd_name != (char *) NULL && fd->font == NULL) { + fd->font = falLoadQueryFont(dpy, fd->xlfd_name); + if (fd->font == NULL) + return False; + } + } + return True; +} + +static Bool +load_font(XOC oc) +{ + int i; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + int num = gen->font_set_num; + + for ( ; num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + if(load_fontdata(oc, font_set->font_data, + font_set->font_data_count) != True) + return False; + + if(load_fontdata(oc, font_set->substitute, + font_set->substitute_num) != True) + return False; + + if(font_set->font_data_count > 0 && font_set->font_data->font) { + font_set->font = font_set->font_data->font; + } else if(font_set->substitute_num > 0 ) { + for(i=0;i<font_set->substitute_num;i++){ + if(font_set->substitute[i].font != NULL){ + font_set->font = font_set->substitute[i].font; + } + } + } + + load_fontdata(oc, font_set->vmap, font_set->vmap_num); + load_fontdata(oc, (FontData) font_set->vrotate, + font_set->vrotate_num); + + if (font_set->font->min_byte1 || font_set->font->max_byte1) + font_set->is_xchar2b = True; + else + font_set->is_xchar2b = False; + } + + return True; +} + +/* For VW/UDC end */ + +static Bool +load_font_info(XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + char **fn_list; + int fn_num, num = gen->font_set_num; + + for ( ; num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + if (font_set->info == NULL) { + fn_list = falListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num, + &font_set->info); + if (font_set->info == NULL) + return False; + + falFreeFontNames(fn_list); + } + } + + return True; +} + +/* For Vertical Writing start */ + +static void +check_fontset_extents( + XCharStruct *overall, + int *logical_ascent, + int *logical_descent, + XFontStruct *font) +{ + overall->lbearing = min(overall->lbearing, font->min_bounds.lbearing); + overall->rbearing = max(overall->rbearing, font->max_bounds.rbearing); + overall->ascent = max(overall->ascent, font->max_bounds.ascent); + overall->descent = max(overall->descent, font->max_bounds.descent); + overall->width = max(overall->width, font->max_bounds.width); + *logical_ascent = max(*logical_ascent, font->ascent); + *logical_descent = max(*logical_descent, font->descent); +} + +/* For Vertical Writing end */ + +static void +set_fontset_extents(XOC oc) +{ + XRectangle *ink = &oc->core.font_set_extents.max_ink_extent; + XRectangle *logical = &oc->core.font_set_extents.max_logical_extent; + XFontStruct **font_list, *font; + XCharStruct overall; + int logical_ascent, logical_descent; + int num = oc->core.font_info.num_font; + + font_list = oc->core.font_info.font_struct_list; + font = *font_list++; + overall = font->max_bounds; + overall.lbearing = font->min_bounds.lbearing; + logical_ascent = font->ascent; + logical_descent = font->descent; + + /* For Vertical Writing start */ + + while (--num > 0) { + font = *font_list++; + check_fontset_extents(&overall, &logical_ascent, &logical_descent, + font); + } + + { + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + FontData font_data; + int font_set_num = gen->font_set_num; + int font_data_count; + + for( ; font_set_num-- ; font_set++) { + if(font_set->vmap_num > 0) { + font_data = font_set->vmap; + font_data_count = font_set->vmap_num; + for( ; font_data_count-- ; font_data++) { + if(font_data->font != NULL) { + check_fontset_extents(&overall, &logical_ascent, + &logical_descent, + font_data->font); + } + } + } + +#ifndef COMMENT + if(font_set->vrotate_num > 0) { + font_data = (FontData) font_set->vrotate; + font_data_count = font_set->vrotate_num; + for( ; font_data_count-- ; font_data++) { + if(font_data->font != NULL) { + check_fontset_extents(&overall, &logical_ascent, + &logical_descent, + font_data->font); + } + } + } +#endif /* COMMENT */ + } + } + + /* For Vertical Writing start */ + + ink->x = overall.lbearing; + ink->y = -(overall.ascent); + ink->width = overall.rbearing - overall.lbearing; + ink->height = overall.ascent + overall.descent; + + logical->x = 0; + logical->y = -(logical_ascent); + logical->width = overall.width; + logical->height = logical_ascent + logical_descent; +} + +static Bool +init_core_part(XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + int font_set_num; + XFontStruct **font_struct_list; + char **font_name_list, *font_name_buf; + int count, length; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + count = length = 0; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + length += strlen(font_set->font_name) + 1; + count++; + } + if (count == 0) + return False; + + font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count); + if (font_struct_list == NULL) + return False; + + font_name_list = (char **) Xmalloc(sizeof(char *) * count); + if (font_name_list == NULL){ + if (font_name_list) + Xfree(font_name_list); + Xfree(font_struct_list); + return False; + } + + font_name_buf = (char *) Xmalloc(length); + if (font_name_buf == NULL){ + if (font_name_list) + Xfree(font_name_list); + Xfree(font_struct_list); + return False; + } + + oc->core.font_info.num_font = count; + oc->core.font_info.font_name_list = font_name_list; + oc->core.font_info.font_struct_list = font_struct_list; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for (count = 0; font_set_num-- > 0; font_set++, count++) { + if (font_set->font_name == NULL) + continue; + + font_set->id = count; + if (font_set->font) + *font_struct_list++ = font_set->font; + else + *font_struct_list++ = font_set->info; + strcpy(font_name_buf, font_set->font_name); + Xfree(font_set->font_name); + *font_name_list++ = font_set->font_name = font_name_buf; + font_name_buf += strlen(font_name_buf) + 1; + } + + set_fontset_extents(oc); + + return True; +} + +static char * +get_font_name(XOC oc, char *pattern) +{ + char **list, *name; + int count = 0; + + list = falListFonts(oc->core.om->core.display, pattern, 1, &count); + if (list == NULL) + return NULL; + + name = (char *) Xmalloc(strlen(*list) + 1); + if (name) + strcpy(name, *list); + + falFreeFontNames(list); + + return name; +} + +/* For VW/UDC start*/ + +static char +*get_rotate_fontname(char *font_name) +{ + char *pattern = NULL, *ptr = NULL; + char *fields[CHARSET_ENCODING_FIELD]; + char str_pixel[32], str_point[4]; + char rotate_font[256]; + char *rotate_font_ptr = NULL; + int pixel_size = 0; + int field_num = 0, len = 0; + + if(font_name == (char *) NULL || (len = strlen(font_name)) <= 0) + return NULL; + + pattern = (char *)Xmalloc(len + 1); + if(!pattern) + return NULL; + strcpy(pattern, font_name); + + memset(fields, 0, sizeof(char *) * 14); + ptr = pattern; + while(isspace(*ptr)) { + ptr++; + } + if(*ptr == '-') + ptr++; + + for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && ptr && *ptr ; + ptr++, field_num++) { + fields[field_num] = ptr; + + if(ptr = strchr(ptr, '-')) { + *ptr = '\0'; + } + } + + if(field_num < CHARSET_ENCODING_FIELD) { + Xfree(pattern); + return NULL; + } + + /* Pixel Size field : fields[6] */ + for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) { + if(!isdigit(*ptr)) { + Xfree(pattern); + return NULL; + } + } + pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]); + snprintf(str_pixel, sizeof(str_pixel), "[ 0 ~%d %d 0 ]", pixel_size, pixel_size); + fields[6] = str_pixel; + + /* Point Size field : fields[7] */ + strcpy(str_point, "*"); + fields[POINT_SIZE_FIELD - 1] = str_point; + + rotate_font[0] = '\0'; + for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && + fields[field_num] ; field_num++) { + snprintf(rotate_font, sizeof(rotate_font), "%s-%s", rotate_font, fields[field_num]); + } + + if(pattern) + Xfree(pattern); + + rotate_font_ptr = (char *)Xmalloc(strlen(rotate_font) + 1); + if(!rotate_font_ptr) + return NULL; + strcpy(rotate_font_ptr, rotate_font); + + return rotate_font_ptr; +} + +static Bool +is_match_charset(FontData font_data, char *font_name) +{ + char *last; + int length, name_len; + + name_len = strlen(font_name); + last = font_name + name_len; + + length = strlen(font_data->name); + if (length > name_len) + return False; + + if (_fallcCompareISOLatin1(last - length, font_data->name) == 0) + return True; + + return False; +} + +static int +parse_all_name(XOC oc, FontData font_data, char *pattern) +{ + + if(is_match_charset(font_data, pattern) != True) + return False; + + font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1); + if(font_data->xlfd_name == NULL) + return (-1); + + strcpy(font_data->xlfd_name, pattern); + return True; +} + +static int +parse_omit_name(XOC oc, FontData font_data, char *pattern) +{ + char *font_name = (char *) NULL; + char *last = (char *) NULL; + char buf[BUFSIZE]; + int length = 0; + + if(is_match_charset(font_data, pattern) == True) { + strcpy(buf, pattern); + if (font_name = get_font_name(oc, buf)) { + font_data->xlfd_name = (char *)Xmalloc(strlen(font_name) + 1); + if(font_data->xlfd_name == NULL) { + Xfree(font_name); + return (-1); + } + strcpy(font_data->xlfd_name, font_name); + Xfree(font_name); + return True; + } + } + + snprintf(buf, sizeof(buf), "%s", pattern); + length = strlen(pattern); + last = buf + length - 1; + if (length > 1 && *last == '*' && *(last - 1) == '-') { + if (length > 3 && *(last - 2) == '*' && *(last - 3) == '-') + last -= 2; + } else { + ++last; + *last++ = '-'; + } + + strcpy(last, font_data->name); + if (font_name = get_font_name(oc, buf)) { + font_data->xlfd_name = (char *)Xmalloc(strlen(font_name) + 1); + if(font_data->xlfd_name == NULL) { + Xfree(font_name); + return (-1); + } + strcpy(font_data->xlfd_name, font_name); + Xfree(font_name); + return True; + } + + *last = '*'; + *(last + 1) = '-'; + strcpy(last + 2, font_data->name); + if (font_name = get_font_name(oc, buf)) { + font_data->xlfd_name = (char *)Xmalloc(strlen(font_name) + 1); + if(font_data->xlfd_name == NULL) { + Xfree(font_name); + return (-1); + } + strcpy(font_data->xlfd_name, font_name); + Xfree(font_name); + return True; + } + + return False; +} + + +typedef enum{C_PRIMARY, C_SUBSTITUTE, C_VMAP, C_VROTATE } ClassType; + +static int +parse_fontdata( + XOC oc, + FontData font_data, + int font_data_count, + char **name_list, + int name_list_count, + ClassType class) +{ + char **cur_name_list = name_list; + char *font_name = (char *) NULL; + char *pattern = (char *) NULL; + int found_num = 0, ret = 0; + int fd_count = font_data_count; + int count = name_list_count; + Bool is_found = False; + + if(name_list == NULL || count <= 0) { + return False; + } + + if(font_data == NULL || font_data_count <= 0) { + return False; + } + + for ( ; font_data_count-- > 0; font_data++) { + is_found = False; + font_name = (char *) NULL; + count = name_list_count; + cur_name_list = name_list; + while (count-- > 0) { + pattern = *cur_name_list++; + if (pattern == NULL || *pattern == '\0') + continue; + + /* When the font name is specified a full name. */ + if (strchr(pattern, '*') == NULL && + (font_name = get_font_name(oc, pattern))) { + ret = parse_all_name(oc, font_data, font_name); + Xfree(font_name); + if(ret == -1) + return ret; + else if (ret == True) { + found_num++; + is_found = True; + break; + } else + continue; + } + + /* When the font name is specified a omited name. */ + ret = parse_omit_name(oc, font_data, pattern); + if(ret == -1) + return ret; + else if (ret == True) { + found_num++; + is_found = True; + break; + } else + continue; + } + + switch(class) { + case C_PRIMARY: + if(is_found != True) + return False; + break; + case C_SUBSTITUTE: + case C_VMAP: + if(is_found == True) + return True; + break; + case C_VROTATE: + if(is_found == True) { + char *rotate_name; + + if((rotate_name = get_rotate_fontname(font_data->xlfd_name)) != + NULL) { + Xfree(font_data->xlfd_name); + font_data->xlfd_name = rotate_name; + return True; + } + Xfree(font_data->xlfd_name); + return False; + } + } + } + + if(class == C_PRIMARY && found_num == fd_count) + return True; + + return False; +} + + +static int +parse_vw(XOC oc, FontSet font_set, char **name_list, int count) +{ + FontData vmap = font_set->vmap; + VRotate vrotate = font_set->vrotate; + int vmap_num = font_set->vmap_num; + int vrotate_num = font_set->vrotate_num; + int ret = 0, i = 0; + + if(vmap_num > 0) { + if(parse_fontdata(oc, vmap, vmap_num, name_list, count, C_VMAP) == -1) + return (-1); + } + + if(vrotate_num > 0) { + ret = parse_fontdata(oc, (FontData) vrotate, vrotate_num, + name_list, count, C_VROTATE); + if(ret == -1) { + return (-1); + } else if(ret == False) { + CodeRange code_range; + int num_cr; + int sub_num = font_set->substitute_num; + + code_range = vrotate[i].code_range; + num_cr = vrotate[i].num_cr; + for(i = 0 ; i < vrotate_num ; i++) { + if(vrotate[i].xlfd_name) + Xfree(vrotate[i].xlfd_name); + } + Xfree(vrotate); + + if(sub_num > 0) { + vrotate = font_set->vrotate = (VRotate)Xmalloc + (sizeof(VRotateRec) * sub_num); + if(font_set->vrotate == (VRotate)NULL) + return (-1); + + for(i = 0 ; i < sub_num ; i++) { + vrotate[i].charset_name = font_set->substitute[i].name; + vrotate[i].side = font_set->substitute[i].side; + vrotate[i].code_range = code_range; + vrotate[i].num_cr = num_cr; + } + vrotate_num = font_set->vrotate_num = sub_num; + } else { + font_set->vrotate = (VRotate)NULL; + } + + ret = parse_fontdata(oc, (FontData) vrotate, vrotate_num, + name_list, count, C_VROTATE); + if(ret == -1) + return (-1); + } + } + + return True; +} + +static int +parse_fontname(XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + char *base_name, **name_list; + int font_set_num = 0; + int found_num = 0; + int count = 0; + int ret; + int i; + + name_list = _falParseBaseFontNameList(oc->core.base_name_list, &count); + if (name_list == NULL) + return -1; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for( ; font_set_num-- > 0 ; font_set++) { + if(font_set->font_name) + continue; + + if(font_set->font_data_count > 0) { + ret = parse_fontdata(oc, font_set->font_data, + font_set->font_data_count, + name_list, count, C_PRIMARY); + if(ret == -1) { + falFreeStringList(name_list); + return -1; + } else if(ret == True) { + font_set->font_name = (char *)Xmalloc + (strlen(font_set->font_data->xlfd_name) + 1); + if(font_set->font_name == (char *) NULL){ + falFreeStringList(name_list); + return -1; + } + strcpy(font_set->font_name, font_set->font_data->xlfd_name); + font_set->side = font_set->font_data->side; + + if(parse_vw(oc, font_set, name_list, count) == -1){ + falFreeStringList(name_list); + return -1; + } + found_num++; + + /* The substitute font is serched, when the primary fonts */ + /* is not found. */ + } else { + /* The primary information is free from FontSet structure */ + font_set->font_data_count = 0; + if(font_set->font_data) { + Xfree(font_set->font_data); + font_set->font_data = (FontData) NULL; + } + + /* A vrotate member is replaced to substitute information */ + /* from primary information. */ + font_set->vrotate_num = 0; + if(font_set->vrotate) { + Xfree(font_set->vrotate); + font_set->vrotate = (VRotate) NULL; + } + + ret = parse_fontdata(oc, font_set->substitute, + font_set->substitute_num, + name_list, count, C_SUBSTITUTE); + if(ret == -1) { + falFreeStringList(name_list); + return -1; + } else if(ret == True) { + for(i=0;i<font_set->substitute_num;i++){ + if(font_set->substitute[i].xlfd_name != NULL){ + break; + } + } + font_set->font_name = (char *)Xmalloc + (strlen(font_set->substitute[i].xlfd_name) + 1); + if(font_set->font_name == (char *) NULL){ + falFreeStringList(name_list); + return -1; + } + strcpy(font_set->font_name,font_set->substitute[i].xlfd_name); + font_set->side = font_set->substitute[i].side; + if(parse_vw(oc, font_set, name_list, count) == -1){ + falFreeStringList(name_list); + return -1; + } + found_num++; + } + } + } else if(font_set->substitute_num > 0) { + ret = parse_fontdata(oc, font_set->substitute, + font_set->substitute_num, + name_list, count, C_SUBSTITUTE); + if(ret == -1) { + falFreeStringList(name_list); + return -1; + } else if(ret == True) { + for(i=0;i<font_set->substitute_num;i++){ + if(font_set->substitute[i].xlfd_name != NULL){ + break; + } + } + font_set->font_name = (char *)Xmalloc + (strlen(font_set->substitute[i].xlfd_name) + 1); + if(font_set->font_name == (char *) NULL){ + falFreeStringList(name_list); + return -1; + } + + strcpy(font_set->font_name,font_set->substitute[i].xlfd_name); + font_set->side = font_set->substitute[i].side; + if(parse_vw(oc, font_set, name_list, count) == -1){ + falFreeStringList(name_list); + return -1; + } + + found_num++; + } + } + } + + base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); + if (base_name == NULL){ + falFreeStringList(name_list); + return -1; + } + + strcpy(base_name, oc->core.base_name_list); + oc->core.base_name_list = base_name; + + falFreeStringList(name_list); + + return found_num; +} + +/* For VW/UDC end*/ + +static Bool +set_missing_list(XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + char **charset_list, *charset_buf; + int count, length, font_set_num; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + count = length = 0; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->info || font_set->font) + continue; + + /* Change 1996.01.23 start */ + if(font_set->font_data_count <= 0 || + font_set->font_data == (FontData)NULL) { + if(font_set->substitute_num <= 0 || + font_set->substitute == (FontData)NULL) + if(font_set->charset_list != NULL){ + length += + strlen(font_set->charset_list[0]->encoding_name) + 1; + } else { + length += 1; + } + else + length += strlen(font_set->substitute->name) + 1; + } else { + length += strlen(font_set->font_data->name) + 1; + } + /* Change 1996.01.23 end */ + count++; + } + + if (count < 1) + return True; + + charset_list = (char **) Xmalloc(sizeof(char *) * count); + if (charset_list == NULL) + return False; + + charset_buf = (char *) Xmalloc(length); + if (charset_buf == NULL) { + Xfree(charset_list); + return False; + } + + oc->core.missing_list.charset_list = charset_list; + oc->core.missing_list.charset_count = count; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->info || font_set->font) + continue; + + /* Change 1996.01.23 start */ + if(font_set->font_data_count <= 0 || + font_set->font_data == (FontData)NULL) { + if(font_set->substitute_num <= 0 || + font_set->substitute == (FontData)NULL) + if(font_set->charset_list != NULL){ + strcpy(charset_buf, + font_set->charset_list[0]->encoding_name); + } else { + strcpy(charset_buf, ""); + } + else + strcpy(charset_buf, font_set->substitute->name); + } else { + strcpy(charset_buf, font_set->font_data->name); + } + /* Change 1996.01.23 end */ + *charset_list++ = charset_buf; + charset_buf += strlen(charset_buf) + 1; + } + + return True; +} + +static Bool +create_fontset(XOC oc) +{ + XOMGenericPart *gen = XOM_GENERIC(oc->core.om); + int found_num; + + if (init_fontset(oc) == False) + return False; + + found_num = parse_fontname(oc); + if (found_num <= 0) { + if (found_num == 0) + set_missing_list(oc); + return False; + } + + if (gen->on_demand_loading == True) { + if (load_font_info(oc) == False) + return False; + } else { + if (load_font(oc) == False) + return False; + } + + if (init_core_part(oc) == False) + return False; + + if (set_missing_list(oc) == False) + return False; + + return True; +} + +/* For VW/UDC start */ +static void +free_fontdataOC(Display *dpy, FontData font_data, int font_data_count) +{ + for( ; font_data_count-- ; font_data++) { + if(font_data->xlfd_name){ + Xfree(font_data->xlfd_name); + font_data->xlfd_name = NULL; + } + if(font_data->font){ /* ADD 1996.01.7 */ + if(font_data->font->fid) /* Add 1996.01.23 */ + falFreeFont(dpy,font_data->font); /* ADD 1996.01.7 */ + else /* Add 1996.01.23 */ + falFreeFontInfo(NULL, font_data->font, 1);/* Add 1996.01.23 */ + font_data->font = NULL; + } +/* XOM to kyoutuu shite shiyou sushiteiru ryouiki + kokoha free_fontdataOM() de free sareru + + if(font_data->scopes){ + Xfree(font_data->scopes); + font_data->scopes = NULL; + } + if(font_data->name){ + Xfree(font_data->name); + font_data->name = NULL; + } +*/ + } +} + +static void +destroy_fontdata(XOCGenericPart *gen, Display *dpy) +{ + FontSet font_set = (FontSet) NULL; + int font_set_num = 0; + + if (gen->font_set) { + font_set = gen->font_set; + font_set_num = gen->font_set_num; + for( ; font_set_num-- ; font_set++) { + if(font_set->font_data) { + free_fontdataOC(dpy, + font_set->font_data, font_set->font_data_count); + Xfree(font_set->font_data); + font_set->font_data = NULL; + } + if(font_set->substitute) { + free_fontdataOC(dpy, + font_set->substitute, font_set->substitute_num); + Xfree(font_set->substitute); + font_set->substitute = NULL; + } + if(font_set->vmap) { + free_fontdataOC(dpy, + font_set->vmap, font_set->vmap_num); + Xfree(font_set->vmap); + font_set->vmap = NULL; + } + if(font_set->vrotate) { + free_fontdataOC(dpy, + (FontData)font_set->vrotate, + font_set->vrotate_num); + Xfree(font_set->vrotate); + font_set->vrotate = NULL; + } + } + Xfree(gen->font_set); + gen->font_set = NULL; + } +} +/* For VW/UDC end */ + +static void +destroy_oc(XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + XFontStruct **font_list, *font; + FontSet font_set = (FontSet) NULL; + int font_set_num = 0; + int count = 0; + + if (gen->mbs_to_cs) + _fallcCloseConverter(gen->mbs_to_cs); + + if (gen->wcs_to_cs) + _fallcCloseConverter(gen->wcs_to_cs); + +/* For VW/UDC start */ /* Change 1996.01.8 */ + destroy_fontdata(gen,dpy); +/* +*/ +/* For VW/UDC end */ + + if (oc->core.base_name_list) + Xfree(oc->core.base_name_list); + + if (oc->core.font_info.font_name_list) + falFreeStringList(oc->core.font_info.font_name_list); + + if (font_list = oc->core.font_info.font_struct_list) { + Xfree(oc->core.font_info.font_struct_list); + } + + if (oc->core.missing_list.charset_list) + falFreeStringList(oc->core.missing_list.charset_list); + + Xfree(oc); +} + +static char * +set_oc_values(XOC oc, XlcArgList args, int num_args) +{ + if (oc->core.resources == NULL) + return NULL; + + return _fallcSetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcSetMask); +} + +static char * +get_oc_values(XOC oc, XlcArgList args, int num_args) +{ + if (oc->core.resources == NULL) + return NULL; + + return _fallcGetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcGetMask); +} + +static XOCMethodsRec oc_default_methods = { + destroy_oc, + set_oc_values, + get_oc_values, + _falmbDefaultTextEscapement, + _falmbDefaultTextExtents, + _falmbDefaultTextPerCharExtents, + _falmbDefaultDrawString, + _falmbDefaultDrawImageString, + _falwcDefaultTextEscapement, + _falwcDefaultTextExtents, + _falwcDefaultTextPerCharExtents, + _falwcDefaultDrawString, + _falwcDefaultDrawImageString +}; + +static XOCMethodsRec oc_generic_methods = { + destroy_oc, + set_oc_values, + get_oc_values, + _falmbGenericTextEscapement, + _falmbGenericTextExtents, + _falmbGenericTextPerCharExtents, + _falmbGenericDrawString, + _falmbGenericDrawImageString, + _falwcGenericTextEscapement, + _falwcGenericTextExtents, + _falwcGenericTextPerCharExtents, + _falwcGenericDrawString, + _falwcGenericDrawImageString +}; + +typedef struct _XOCMethodsListRec { + char *name; + XOCMethods methods; +} XOCMethodsListRec, *XOCMethodsList; + +static XOCMethodsListRec oc_methods_list[] = { + { "default", &oc_default_methods }, + { "generic", &oc_generic_methods } +}; + +static XlcResource oc_resources[] = { + { XNBaseFontName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask }, + { XNOMAutomatic, NULLQUARK, sizeof(Bool), + XOffsetOf(XOCRec, core.om_automatic), XlcGetMask }, + { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOCRec, core.missing_list), XlcGetMask }, + { XNDefaultString, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.default_string), XlcGetMask }, + { XNOrientation, NULLQUARK, sizeof(XOrientation), + XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask }, + { XNResourceName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask }, + { XNResourceClass, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask }, + { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo), + XOffsetOf(XOCRec, core.font_info), XlcGetMask } +}; + +static XOC +create_oc(XOM om, XlcArgList args, int num_args) +{ + XOC oc; + XOMGenericPart *gen = XOM_GENERIC(om); + XOCMethodsList methods_list = oc_methods_list; + int count; + + oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); + if (oc == NULL) + return (XOC) NULL; + bzero((char *) oc, sizeof(XOCGenericRec)); + + oc->core.om = om; + + if (oc_resources[0].xrm_name == NULLQUARK) + _fallcCompileResourceList(oc_resources, XlcNumber(oc_resources)); + + if (_fallcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources), + args, num_args, XlcCreateMask | XlcDefaultMask)){ + destroy_oc(oc); + return (XOC) NULL; + } + if (oc->core.base_name_list == NULL){ + destroy_oc(oc); + return (XOC) NULL; + } + oc->core.resources = oc_resources; + oc->core.num_resources = XlcNumber(oc_resources); + + if (create_fontset(oc) == False){ + destroy_oc(oc); + return (XOC) NULL; + } + oc->methods = &oc_generic_methods; + + if (gen->object_name) { + count = XlcNumber(oc_methods_list); + + for ( ; count-- > 0; methods_list++) { + if (!_fallcCompareISOLatin1(gen->object_name, methods_list->name)) { + oc->methods = methods_list->methods; + break; + } + } + } + + return oc; +} + +static void +free_fontdataOM(FontData font_data, int font_data_count) +{ + for( ; font_data_count-- ; font_data++) { + if(font_data->name){ + Xfree(font_data->name); + font_data->name = NULL; + } + if(font_data->scopes){ + Xfree(font_data->scopes); + font_data->scopes = NULL; + } + } +} + +static Status +close_om(XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + int count; + + if (data = gen->data) { + for (count = gen->data_num; count-- > 0; data++) { + if (data->charset_list){ + Xfree(data->charset_list); + data->charset_list = NULL; + } + /* free font_data for om */ + if (data->font_data) { + free_fontdataOM(data->font_data,data->font_data_count); + Xfree(data->font_data); + data->font_data = NULL; + } + /* free substitute for om */ + if (data->substitute) { + free_fontdataOM(data->substitute,data->substitute_num); + Xfree(data->substitute); + data->substitute = NULL; + } + /* free vmap for om */ + if (data->vmap) { + free_fontdataOM(data->vmap,data->vmap_num); + Xfree(data->vmap); + data->vmap = NULL; + } + /* free vrotate for om */ + if (data->vrotate) { +#ifdef COMMENT + free_fontdataOM(data->vrotate,data->vrotate_num); +#endif /* COMMENT */ + Xfree(data->vrotate); + data->vrotate = NULL; + } + } + Xfree(gen->data); + gen->data = NULL; + } + + if (gen->object_name){ + Xfree(gen->object_name); + gen->object_name = NULL; + } + + if (om->core.res_name){ + Xfree(om->core.res_name); + om->core.res_name = NULL; + } + if (om->core.res_class){ + Xfree(om->core.res_class); + om->core.res_class = NULL; + } + if (om->core.required_charset.charset_list && + om->core.required_charset.charset_count > 0){ + falFreeStringList(om->core.required_charset.charset_list); + om->core.required_charset.charset_list = NULL; + } else { + Xfree((char*)om->core.required_charset.charset_list); + om->core.required_charset.charset_list = NULL; + } + if (om->core.orientation_list.orientation){ + Xfree(om->core.orientation_list.orientation); + om->core.orientation_list.orientation = NULL; + } + + Xfree(om); + + return 0; +} + +static char * +set_om_values(XOM om, XlcArgList args, int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _fallcSetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcSetMask); +} + +static char * +get_om_values(XOM om, XlcArgList args, int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _fallcGetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcGetMask); +} + +static XOMMethodsRec methods = { + close_om, + set_om_values, + get_om_values, + create_oc +}; + +static XlcResource om_resources[] = { + { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOMRec, core.required_charset), XlcGetMask }, + { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation), + XOffsetOf(XOMRec, core.orientation_list), XlcGetMask }, + { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask }, + { XNContextualDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask } +}; + +static XOM +create_om( + XLCd lcd, + Display *dpy, + XrmDatabase rdb, + char *res_name, + char *res_class) +{ + XOM om; + + om = (XOM) Xmalloc(sizeof(XOMGenericRec)); + if (om == NULL) + return (XOM) NULL; + bzero((char *) om, sizeof(XOMGenericRec)); + + om->methods = &methods; + om->core.lcd = lcd; + om->core.display = dpy; + om->core.rdb = rdb; + if (res_name) { + om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1); + if (om->core.res_name == NULL){ + close_om(om); + return (XOM) NULL; + } + strcpy(om->core.res_name, res_name); + } + if (res_class) { + om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1); + if (om->core.res_class == NULL){ + close_om(om); + return (XOM) NULL; + } + strcpy(om->core.res_class, res_class); + } + + if (om_resources[0].xrm_name == NULLQUARK) + _fallcCompileResourceList(om_resources, XlcNumber(om_resources)); + + om->core.resources = om_resources; + om->core.num_resources = XlcNumber(om_resources); + + return om; +} + +static OMData +add_data(XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData new; + int num; + + if (num = gen->data_num) + new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec)); + else + new = (OMData) Xmalloc(sizeof(OMDataRec)); + + if (new == NULL) + return NULL; + + gen->data_num = num + 1; + gen->data = new; + + new += num; + bzero((char *) new, sizeof(OMDataRec)); + + return new; +} + +/* For VW/UDC */ +FontData +falread_EncodingInfo(int count, char **value) +{ + FontData font_data,ret; + char *buf, *bufptr,*scp; + FontScope scope; + int len; + extern FontScope falparse_scopemaps(); + font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); + if (font_data == NULL) + return NULL; + bzero((char *) font_data, sizeof(FontDataRec) * count); + + ret = font_data; + for ( ; count-- > 0; font_data++) { +/* + strcpy(buf, *value++); +*/ + buf = *value; value++; + if (bufptr = strchr(buf, ':')){ + len = (int)(bufptr - buf); + bufptr++ ; + } + font_data->name = (char *) Xmalloc(len + 1); + if (font_data->name == NULL) { + XFree(font_data); + return NULL; + } + strncpy(font_data->name, buf,len); + font_data->name[len] = 0; + if (bufptr && _fallcCompareISOLatin1(bufptr, "GL") == 0) + font_data->side = XlcGL; + else if (bufptr && _fallcCompareISOLatin1(bufptr, "GR") == 0) + font_data->side = XlcGR; + else + font_data->side = XlcGLGR; + + if (bufptr && (scp = strchr(bufptr, '['))){ + font_data->scopes = falparse_scopemaps(scp,&(font_data->scopes_num)); + } + } + return(ret); +} + +static CodeRange read_vrotate( +int count, +char **value, +int *type, +int *vrotate_num) +{ + FontData font_data,ret; + char *buf, *bufptr,*scp; + CodeRange range; + extern FontScope falparse_scopemaps(); + if(!strcmp(value[0],"all")){ + *type = VROTATE_ALL ; + *vrotate_num = 0 ; + return (NULL); + } else if(*(value[0]) == '['){ + *type = VROTATE_PART ; + range = (CodeRange)falparse_scopemaps(value[0],vrotate_num); + return (range); + } else { + *type = VROTATE_NONE ; + *vrotate_num = 0 ; + return (NULL); + } +} + +static void +read_vw(XLCd lcd, OMData font_set, int num) +{ + char **value, buf[BUFSIZ], *bufptr; + int count,i; + + snprintf(buf, sizeof(buf), "fs%d.font.vertical_map", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + dbg_printValue(buf,value,count); + font_set->vmap_num = count; + font_set->vmap = falread_EncodingInfo(count,value); + } + + snprintf(buf, sizeof(buf), "fs%d.font.vertical_rotate", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + dbg_printValue(buf,value,count); + font_set->vrotate = read_vrotate(count,value,&(font_set->vrotate_type), + &(font_set->vrotate_num)); + } +} +/* VW/UDC end */ +static Bool +init_om(XOM om) +{ + XLCd lcd = om->core.lcd; + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + XlcCharSet *charset_list; + FontData font_data; + char **required_list; + XOrientation *orientation; + char **value, buf[BUFSIZ], *bufptr; + int count = 0, num = 0, length = 0; + + _fallcGetResource(lcd, "XLC_FONTSET", "on_demand_loading", &value, &count); + if (count > 0 && _fallcCompareISOLatin1(*value, "True") == 0) + gen->on_demand_loading = True; + + _fallcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count); + if (count > 0) { + gen->object_name = (char *) Xmalloc(strlen(*value) + 1); + if (gen->object_name == NULL) + return False; + strcpy(gen->object_name, *value); + } + + for (num = 0; ; num++) { + + snprintf(buf, sizeof(buf), "fs%d.charset.name", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + + if( count < 1){ + snprintf(buf, sizeof(buf), "fs%d.charset", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) + break; + } + + data = add_data(om); + if (data == NULL) + return False; + + charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count); + if (charset_list == NULL) + return False; + data->charset_list = charset_list; + data->charset_count = count; + + while (count-- > 0){ + *charset_list++ = _fallcGetCharSet(*value++); + } + snprintf(buf, sizeof(buf), "fs%d.charset.udc_area", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if( count > 0){ + UDCArea udc; + int i,flag = 0; + udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec)); + if (udc == NULL) + return False; + for(i=0;i<count;i++){ + sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end)); + } + for(i=0;i<data->charset_count;i++){ + if(data->charset_list[i]->udc_area == NULL){ + data->charset_list[i]->udc_area = udc; + data->charset_list[i]->udc_area_num = count; + flag = 1; + } + } + if(flag == 0){ + Xfree(udc); + } + } + + snprintf(buf, sizeof(buf), "fs%d.font.primary", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1){ + snprintf(buf, sizeof(buf), "fs%d.font", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) + return False; + } + + font_data = falread_EncodingInfo(count,value); + if (font_data == NULL) + return False; + + data->font_data = font_data; + data->font_data_count = count; + + snprintf(buf, sizeof(buf), "fs%d.font.substitute", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + font_data = falread_EncodingInfo(count,value); + if (font_data == NULL) + return False; + data->substitute = font_data; + data->substitute_num = count; + } else { + snprintf(buf, sizeof(buf), "fs%d.font", num); + _fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) { + data->substitute = NULL; + data->substitute_num = 0; + } else { + font_data = falread_EncodingInfo(count,value); + data->substitute = font_data; + data->substitute_num = count; + } + } + read_vw(lcd,data,num); + length += strlen(data->font_data->name) + 1; + } + + /* required charset list */ + required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num); + if (required_list == NULL) + return False; + + bufptr = (char *) Xmalloc(length); + if (bufptr == NULL) { + Xfree(required_list); + return False; + } + + om->core.required_charset.charset_list = required_list; + om->core.required_charset.charset_count = gen->data_num; + + count = gen->data_num; + data = gen->data; + + for ( ; count-- > 0; data++) { + strcpy(bufptr, data->font_data->name); + *required_list++ = bufptr; + bufptr += strlen(bufptr) + 1; + } + + /* orientation list */ + orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2); + if (orientation == NULL) + return False; + + orientation[0] = XOMOrientation_LTR_TTB; + orientation[1] = XOMOrientation_TTB_RTL; + om->core.orientation_list.orientation = orientation; + om->core.orientation_list.num_orientation = 2; + + /* directional dependent drawing */ + om->core.directional_dependent = False; + + /* contexual drawing */ + om->core.contextual_drawing = False; + + /* context dependent */ + om->core.context_dependent = False; + + return True; +} + +XOM +_falomGenericOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, + char *res_name, char *res_class) +{ + XOM om; + + om = create_om(lcd, dpy, rdb, res_name, res_class); + if (om == NULL) + return (XOM) NULL; + + if (init_om(om) == False){ + close_om(om); + return (XOM) NULL; + } + + return om; +} + +Bool +_falInitOM(XLCd lcd) +{ + lcd->methods->open_om = _falomGenericOpenOM; + + return True; +} diff --git a/cde/programs/dtudcfonted/libfal/_falomGeneric.h b/cde/programs/dtudcfonted/libfal/_falomGeneric.h new file mode 100644 index 000000000..71fa4984c --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falomGeneric.h @@ -0,0 +1,198 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XomGeneric.h 1.6 - Fujitsu source for CDEnext 96/02/29 18:02:52 */ +/* $XConsortium: _falomGeneric.h /main/1 1996/04/08 15:20:29 cde-fuj $ */ +/* + * Copyright 1992, 1993 by TOSHIBA Corp. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of TOSHIBA not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. TOSHIBA make no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Author: Katsuhisa Yano TOSHIBA Corp. + * mopi@osa.ilab.toshiba.co.jp + */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ + +#ifndef _XOMGENERIC_H_ +#define _XOMGENERIC_H_ + +#include "_fallcPublic.h" + +#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen) +#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen) + +/* For VW/UDC */ +typedef struct _CodeRangeRec { + unsigned long start; + unsigned long end; + unsigned long dmy1; + unsigned long dmy2; +} CodeRangeRec, *CodeRange; + +typedef struct _VRotateRec { + char *charset_name; /* Charset name */ + XlcSide side; /* Encoding side */ + int num_cr; + CodeRange code_range; + char *xlfd_name; + XFontStruct *font; +} VRotateRec, *VRotate; + +typedef enum { + XOMMultiByte, + XOMWideChar +} XOMTextType; + +typedef struct _FontDataRec { + char *name; + XlcSide side; + /* For VW/UDC */ + int scopes_num; + FontScope scopes; + char *xlfd_name; + XFontStruct *font; +} FontDataRec, *FontData; + +#define VROTATE_NONE 0 +#define VROTATE_PART 1 +#define VROTATE_ALL 2 + +typedef struct _OMDataRec { + int charset_count; + XlcCharSet *charset_list; + int font_data_count; + FontData font_data; + /* For VW/UDC */ + int substitute_num; + FontData substitute; + /* Vertical Writing */ + int vmap_num; + FontData vmap; + int vrotate_type; + int vrotate_num; + CodeRange vrotate; +} OMDataRec, *OMData; + +typedef struct _XOMGenericPart { + int data_num; + OMData data; + Bool on_demand_loading; + char *object_name; +} XOMGenericPart; + +typedef struct _XOMGenericRec { + XOMMethods methods; + XOMCoreRec core; + XOMGenericPart gen; +} XOMGenericRec, *XOMGeneric; + +/* + * XOC dependent data + */ + +typedef struct _FontSetRec { + int id; + int charset_count; + XlcCharSet *charset_list; + int font_data_count; + FontData font_data; + char *font_name; + XFontStruct *info; + XFontStruct *font; + XlcSide side; + Bool is_xchar2b; + /* For VW/UDC */ + int substitute_num; + FontData substitute; + /* Vertical Writing */ + int vmap_num; + FontData vmap; + int vrotate_num; + VRotate vrotate; +} FontSetRec, *FontSet; + +typedef struct _XOCGenericPart { + XlcConv mbs_to_cs; + XlcConv wcs_to_cs; + int font_set_num; + FontSet font_set; +} XOCGenericPart; + +typedef struct _XOCGenericRec { + XOCMethods methods; + XOCCoreRec core; + XOCGenericPart gen; +} XOCGenericRec, *XOCGeneric; + +_XFUNCPROTOBEGIN + +extern XOM _falomGenericOpenOM( + XLCd /* lcd */, + Display* /* dpy */, + XrmDatabase /* rdb */, + char* /* res_name */, + char* /* res_class */ +); + +extern XlcConv _XomInitConverter( + XOC /* oc */, + XOMTextType /* type */ +); + +extern int _XomConvert( + XOC /* oc */, + XlcConv /* conv */, + XPointer* /* from */, + int* /* from_left */, + XPointer* /* to */, + int* /* to_left */, + XPointer* /* args */, + int /* num_args */ +); + +_XFUNCPROTOEND + +#endif /* _XOMGENERIC_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_falrm.c b/cde/programs/dtudcfonted/libfal/_falrm.c new file mode 100644 index 000000000..82e43c1ab --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falrm.c @@ -0,0 +1,2497 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Xrm.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:11 */ +/* $XConsortium: _falrm.c /main/1 1996/04/08 15:21:43 cde-fuj $ */ + +/*********************************************************** +Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* + +Copyright (c) 1987, 1988, 1990 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +#include <stdio.h> +#include <ctype.h> +#include "_fallibint.h" +#include <X11/Xresource.h> +#include "_fallcint.h" +#ifdef XTHREADS +#include "_falloking.h" +#endif +#include "_falrmI.h" +#include <X11/Xos.h> + +/* + +These Xrm routines allow very fast lookup of resources in the resource +database. Several usage patterns are exploited: + +(1) Widgets get a lot of resources at one time. Rather than look up each from +scratch, we can precompute the prioritized list of database levels once, then +search for each resource starting at the beginning of the list. + +(2) Many database levels don't contain any leaf resource nodes. There is no +point in looking for resources on a level that doesn't contain any. This +information is kept on a per-level basis. + +(3) Sometimes the widget instance tree is structured such that you get the same +class name repeated on the fully qualified widget name. This can result in the +same database level occurring multiple times on the search list. The code below +only checks to see if you get two identical search lists in a row, rather than +look back through all database levels, but in practice this removes all +duplicates I've ever observed. + +Joel McCormack + +*/ + +/* + +The Xrm representation has been completely redesigned to substantially reduce +memory and hopefully improve performance. + +The database is structured into two kinds of tables: LTables that contain +only values, and NTables that contain only other tables. + +Some invariants: + +The next pointer of the top-level node table points to the top-level leaf +table, if any. + +Within an LTable, for a given name, the tight value always precedes the +loose value, and if both are present the loose value is always right after +the tight value. + +Within an NTable, all of the entries for a given name are contiguous, +in the order tight NTable, loose NTable, tight LTable, loose LTable. + +Bob Scheifler + +*/ + +typedef unsigned long Signature; + +static XrmQuark XrmQString, XrmQANY; + +typedef Bool (*DBEnumProc)( +/* this is Nested on purpose, to match Xlib.h */ + XrmDatabase* /* db */, + XrmBindingList /* bindings */, + XrmQuarkList /* quarks */, + XrmRepresentation* /* type */, + XrmValue* /* value */, + XPointer /* closure */ +); + +typedef struct _VEntry { + struct _VEntry *next; /* next in chain */ + XrmQuark name; /* name of this entry */ + unsigned int tight:1; /* 1 if it is a tight binding */ + unsigned int string:1; /* 1 if type is String */ + unsigned int size:30; /* size of value */ +} VEntryRec, *VEntry; + + +typedef struct _DEntry { + VEntryRec entry; /* entry */ + XrmRepresentation type; /* representation type */ +} DEntryRec, *DEntry; + +/* the value is right after the structure */ +#define StringValue(ve) (XPointer)((ve) + 1) +#define RepType(ve) ((DEntry)(ve))->type +/* the value is right after the structure */ +#define DataValue(ve) (XPointer)(((DEntry)(ve)) + 1) +#define RawValue(ve) (char *)((ve)->string ? StringValue(ve) : DataValue(ve)) + +typedef struct _NTable { + struct _NTable *next; /* next in chain */ + XrmQuark name; /* name of this entry */ + unsigned int tight:1; /* 1 if it is a tight binding */ + unsigned int leaf:1; /* 1 if children are values */ + unsigned int hasloose:1; /* 1 if has loose children */ + unsigned int hasany:1; /* 1 if has ANY entry */ + unsigned int pad:4; /* unused */ + unsigned int mask:8; /* hash size - 1 */ + unsigned int entries:16; /* number of children */ +} NTableRec, *NTable; + +/* the buckets are right after the structure */ +#define NodeBuckets(ne) ((NTable *)((ne) + 1)) +#define NodeHash(ne,q) NodeBuckets(ne)[(q) & (ne)->mask] + +/* leaf tables have an extra level of indirection for the buckets, + * so that resizing can be done without invalidating a search list. + * This is completely ugly, and wastes some memory, but the Xlib + * spec doesn't really specify whether invalidation is OK, and the + * old implementation did not invalidate. + */ +typedef struct _LTable { + NTableRec table; + VEntry *buckets; +} LTableRec, *LTable; + +#define LeafHash(le,q) (le)->buckets[(q) & (le)->table.mask] + +/* An XrmDatabase just holds a pointer to the first top-level table. + * The type name is no longer descriptive, but better to not change + * the Xresource.h header file. This type also gets used to define + * XrmSearchList, which is a complete crock, but we'll just leave it + * and caste types as required. + */ +typedef struct _XrmHashBucketRec { + NTable table; + XPointer mbstate; + XrmMethods methods; +#ifdef XTHREADS + LockInfoRec linfo; +#endif +} XrmHashBucketRec; + +/* closure used in get/put resource */ +typedef struct _VClosure { + XrmRepresentation *type; /* type of value */ + XrmValuePtr value; /* value itself */ +} VClosureRec, *VClosure; + +/* closure used in get search list */ +typedef struct _SClosure { + LTable *list; /* search list */ + int idx; /* index of last filled element */ + int limit; /* maximum index */ +} SClosureRec, *SClosure; + +/* placed in XrmSearchList to indicate next table is loose only */ +#define LOOSESEARCH ((LTable)1) + +/* closure used in enumerate database */ +typedef struct _EClosure { + XrmDatabase db; /* the database */ + DBEnumProc proc; /* the user proc */ + XPointer closure; /* the user closure */ + XrmBindingList bindings; /* binding list */ + XrmQuarkList quarks; /* quark list */ + int mode; /* XrmEnum<kind> */ +} EClosureRec, *EClosure; + +/* predicate to determine when to resize a hash table */ +#define GrowthPred(n,m) ((unsigned)(n) > (((m) + 1) << 2)) + +#define GROW(prev) \ + if (GrowthPred((*prev)->entries, (*prev)->mask)) \ + GrowTable(prev) + +/* pick a reasonable value for maximum depth of resource database */ +#define MAXDBDEPTH 100 + +/* macro used in get/search functions */ + +/* find an entry named ename, with leafness given by leaf */ +#define NFIND(ename) \ + q = ename; \ + entry = NodeHash(table, q); \ + while (entry && entry->name != q) \ + entry = entry->next; \ + if (leaf && entry && !entry->leaf) { \ + entry = entry->next; \ + if (entry && !entry->leaf) \ + entry = entry->next; \ + if (entry && entry->name != q) \ + entry = (NTable)NULL; \ + } + +/* resourceQuarks keeps track of what quarks have been associated with values + * in all LTables. If a quark has never been used in an LTable, we don't need + * to bother looking for it. + */ + +static unsigned char *resourceQuarks = (unsigned char *)NULL; +static XrmQuark maxResourceQuark = -1; + +/* determines if a quark has been used for a value in any database */ +#define IsResourceQuark(q) ((q) > 0 && (q) <= maxResourceQuark && \ + resourceQuarks[(q) >> 3] & (1 << ((q) & 7))) + +typedef unsigned char XrmBits; + +#define BSLASH ((XrmBits) (1 << 5)) +#define NORMAL ((XrmBits) (1 << 4)) +#define EOQ ((XrmBits) (1 << 3)) +#define SEP ((XrmBits) (1 << 2)) +#define ENDOF ((XrmBits) (1 << 1)) +#define SPACE (NORMAL|EOQ|SEP|(XrmBits)0) +#define RSEP (NORMAL|EOQ|SEP|(XrmBits)1) +#define EOS (EOQ|SEP|ENDOF|(XrmBits)0) +#define EOL (EOQ|SEP|ENDOF|(XrmBits)1) +#define BINDING (NORMAL|EOQ) +#define ODIGIT (NORMAL|(XrmBits)1) + +#define next_char(ch,str) xrmtypes[(unsigned char)((ch) = *(++(str)))] +#define next_mbchar(ch,len,str) xrmtypes[(unsigned char)(ch = (*db->methods->mbchar)(db->mbstate, str, &len), str += len, ch)] + +#define is_space(bits) ((bits) == SPACE) +#define is_EOQ(bits) ((bits) & EOQ) +#define is_EOF(bits) ((bits) == EOS) +#define is_EOL(bits) ((bits) & ENDOF) +#define is_binding(bits) ((bits) == BINDING) +#define is_odigit(bits) ((bits) == ODIGIT) +#define is_separator(bits) ((bits) & SEP) +#define is_nonpcs(bits) (!(bits)) +#define is_normal(bits) ((bits) & NORMAL) +#define is_simple(bits) ((bits) & (NORMAL|BSLASH)) +#define is_special(bits) ((bits) & (ENDOF|BSLASH)) + +/* parsing types */ +static XrmBits const xrmtypes[256] = { + EOS,0,0,0,0,0,0,0, + 0,SPACE,EOL,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + SPACE,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,BINDING,NORMAL,NORMAL,NORMAL,BINDING,NORMAL, + ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT, + NORMAL,NORMAL,RSEP,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,BSLASH,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL, + NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,0 + /* The rest will be automatically initialized to zero. */ +}; + +void falrmInitialize(void) +{ + XrmQString = falrmPermStringToQuark("String"); + XrmQANY = falrmPermStringToQuark("?"); +} + +XrmDatabase falrmGetDatabase(display) + Display *display; +{ + XrmDatabase retval; + LockDisplay(display); + retval = display->db; + UnlockDisplay(display); + return retval; +} + +void falrmSetDatabase(Display *display, XrmDatabase database) +{ + LockDisplay(display); + display->db = database; + UnlockDisplay(display); +} + +void falrmStringToQuarkList(const char *name, XrmQuarkList quarks)/*RETURN*/ +{ + XrmBits bits; + Signature sig = 0; + char ch, *tname; + int i = 0; + + if (tname = (char *)name) { + tname--; + while (!is_EOF(bits = next_char(ch, tname))) { + if (is_binding (bits)) { + if (i) { + /* Found a complete name */ + *quarks++ = _falrmInternalStringToQuark(name,tname - name, + sig, False); + i = 0; + sig = 0; + } + name = tname+1; + } + else { + sig = (sig << 1) + ch; /* Compute the signature. */ + i++; + } + } + *quarks++ = _falrmInternalStringToQuark(name, tname - name, sig, False); + } + *quarks = NULLQUARK; +} + +void falrmStringToBindingQuarkList( + const char *name, + XrmBindingList bindings, /* RETURN */ + XrmQuarkList quarks) /* RETURN */ +{ + XrmBits bits; + Signature sig = 0; + char ch, *tname; + XrmBinding binding; + int i = 0; + + if (tname = (char *)name) { + tname--; + binding = XrmBindTightly; + while (!is_EOF(bits = next_char(ch, tname))) { + if (is_binding (bits)) { + if (i) { + /* Found a complete name */ + *bindings++ = binding; + *quarks++ = _falrmInternalStringToQuark(name, tname - name, + sig, False); + + i = 0; + sig = 0; + binding = XrmBindTightly; + } + name = tname+1; + + if (ch == '*') + binding = XrmBindLoosely; + } + else { + sig = (sig << 1) + ch; /* Compute the signature. */ + i++; + } + } + *bindings = binding; + *quarks++ = _falrmInternalStringToQuark(name, tname - name, sig, False); + } + *quarks = NULLQUARK; +} + +#ifdef DEBUG + +static void PrintQuarkList(XrmQuarkList quarks, FILE *stream) +{ + Bool firstNameSeen; + + for (firstNameSeen = False; *quarks; quarks++) { + if (firstNameSeen) { + (void) fprintf(stream, "."); + } + firstNameSeen = True; + (void) fputs(falrmQuarkToString(*quarks), stream); + } +} /* PrintQuarkList */ + +#endif /* DEBUG */ + +/*ARGSUSED*/ +static void mbnoop(XPointer state) +{ +} + +/*ARGSUSED*/ +static char mbchar(XPointer state, char *str, int *lenp) +{ + *lenp = 1; + return *str; +} + +/*ARGSUSED*/ +static char *lcname(XPointer state) +{ + return "C"; +} + +static const XrmMethodsRec mb_methods = { + mbnoop, + mbchar, + mbnoop, + lcname, + mbnoop +}; + +static XrmDatabase NewDatabase(void) +{ + XrmDatabase db; + + db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec)); + if (db) { + _XCreateMutex(&db->linfo); + db->table = (NTable)NULL; + db->methods = _falrmInitParseInfo(&db->mbstate); + if (!db->methods) + db->methods = (XrmMethods)&mb_methods; + } + return db; +} + +/* move all values from ftable to ttable, and free ftable's buckets. + * ttable is guaranteed empty to start with. + */ +static void MoveValues(LTable ftable, LTable ttable) +{ + VEntry fentry, nfentry; + VEntry *prev; + VEntry *bucket; + VEntry tentry; + int i; + + for (i = ftable->table.mask, bucket = ftable->buckets; i >= 0; i--) { + for (fentry = *bucket++; fentry; fentry = nfentry) { + prev = &LeafHash(ttable, fentry->name); + tentry = *prev; + *prev = fentry; + /* chain on all with same name, to preserve invariant order */ + while ((nfentry = fentry->next) && nfentry->name == fentry->name) + fentry = nfentry; + fentry->next = tentry; + } + } + Xfree((char *)ftable->buckets); +} + +/* move all tables from ftable to ttable, and free ftable. + * ttable is quaranteed empty to start with. + */ +static void MoveTables(NTable ftable, NTable ttable) +{ + NTable fentry, nfentry; + NTable *prev; + NTable *bucket; + NTable tentry; + int i; + + for (i = ftable->mask, bucket = NodeBuckets(ftable); i >= 0; i--) { + for (fentry = *bucket++; fentry; fentry = nfentry) { + prev = &NodeHash(ttable, fentry->name); + tentry = *prev; + *prev = fentry; + /* chain on all with same name, to preserve invariant order */ + while ((nfentry = fentry->next) && nfentry->name == fentry->name) + fentry = nfentry; + fentry->next = tentry; + } + } + Xfree((char *)ftable); +} + +/* grow the table, based on current number of entries */ +static void GrowTable(NTable *prev) +{ + NTable table; + int i; + + table = *prev; + i = table->mask; + if (i == 255) /* biggest it gets */ + return; + while (i < 255 && GrowthPred(table->entries, i)) + i = (i << 1) + 1; + i++; /* i is now the new size */ + if (table->leaf) { + LTable ltable; + LTableRec otable; + + ltable = (LTable)table; + /* cons up a copy to make MoveValues look symmetric */ + otable = *ltable; + ltable->buckets = (VEntry *)Xmalloc(i * sizeof(VEntry)); + if (!ltable->buckets) { + ltable->buckets = otable.buckets; + return; + } + ltable->table.mask = i - 1; + bzero((char *)ltable->buckets, i * sizeof(VEntry)); + MoveValues(&otable, ltable); + } else { + NTable ntable; + + ntable = (NTable)Xmalloc(sizeof(NTableRec) + i * sizeof(NTable)); + if (!ntable) + return; + *ntable = *table; + ntable->mask = i - 1; + bzero((char *)NodeBuckets(ntable), i * sizeof(NTable)); + *prev = ntable; + MoveTables(table, ntable); + } +} + +/* merge values from ftable into *pprev, destroy ftable in the process */ +static void MergeValues(LTable ftable, NTable *pprev, Bool override) +{ + VEntry fentry, tentry; + VEntry *prev; + LTable ttable; + VEntry *bucket; + int i; + XrmQuark q; + + ttable = (LTable)*pprev; + if (ftable->table.hasloose) + ttable->table.hasloose = 1; + for (i = ftable->table.mask, bucket = ftable->buckets; + i >= 0; + i--, bucket++) { + for (fentry = *bucket; fentry; ) { + q = fentry->name; + prev = &LeafHash(ttable, q); + tentry = *prev; + while (tentry && tentry->name != q) + tentry = *(prev = &tentry->next); + /* note: test intentionally uses fentry->name instead of q */ + /* permits serendipitous inserts */ + while (tentry && tentry->name == fentry->name) { + /* if tentry is earlier, skip it */ + if (!fentry->tight && tentry->tight) { + tentry = *(prev = &tentry->next); + continue; + } + if (fentry->tight != tentry->tight) { + /* no match, chain in fentry */ + *prev = fentry; + prev = &fentry->next; + fentry = *prev; + *prev = tentry; + ttable->table.entries++; + } else if (override) { + /* match, chain in fentry, splice out and free tentry */ + *prev = fentry; + prev = &fentry->next; + fentry = *prev; + *prev = tentry->next; + /* free the overridden entry */ + Xfree((char *)tentry); + /* get next tentry */ + tentry = *prev; + } else { + /* match, discard fentry */ + prev = &tentry->next; + tentry = fentry; /* use as a temp var */ + fentry = fentry->next; + /* free the overpowered entry */ + Xfree((char *)tentry); + /* get next tentry */ + tentry = *prev; + } + if (!fentry) + break; + } + /* at this point, tentry cannot match any fentry named q */ + /* chain in all bindings together, preserve invariant order */ + while (fentry && fentry->name == q) { + *prev = fentry; + prev = &fentry->next; + fentry = *prev; + *prev = tentry; + ttable->table.entries++; + } + } + } + Xfree((char *)ftable->buckets); + Xfree((char *)ftable); + /* resize if necessary, now that we're all done */ + GROW(pprev); +} + +/* merge tables from ftable into *pprev, destroy ftable in the process */ +static void MergeTables(NTable ftable, NTable *pprev, Bool override) +{ + NTable fentry, tentry; + NTable nfentry; + NTable *prev; + NTable ttable; + NTable *bucket; + int i; + XrmQuark q; + + ttable = *pprev; + if (ftable->hasloose) + ttable->hasloose = 1; + if (ftable->hasany) + ttable->hasany = 1; + for (i = ftable->mask, bucket = NodeBuckets(ftable); + i >= 0; + i--, bucket++) { + for (fentry = *bucket; fentry; ) { + q = fentry->name; + prev = &NodeHash(ttable, q); + tentry = *prev; + while (tentry && tentry->name != q) + tentry = *(prev = &tentry->next); + /* note: test intentionally uses fentry->name instead of q */ + /* permits serendipitous inserts */ + while (tentry && tentry->name == fentry->name) { + /* if tentry is earlier, skip it */ + if ((fentry->leaf && !tentry->leaf) || + (!fentry->tight && tentry->tight && + (fentry->leaf || !tentry->leaf))) { + tentry = *(prev = &tentry->next); + continue; + } + nfentry = fentry->next; + if (fentry->leaf != tentry->leaf || + fentry->tight != tentry->tight) { + /* no match, just chain in */ + *prev = fentry; + *(prev = &fentry->next) = tentry; + ttable->entries++; + } else { + if (fentry->leaf) + MergeValues((LTable)fentry, prev, override); + else + MergeTables(fentry, prev, override); + /* bump to next tentry */ + tentry = *(prev = &(*prev)->next); + } + /* bump to next fentry */ + fentry = nfentry; + if (!fentry) + break; + } + /* at this point, tentry cannot match any fentry named q */ + /* chain in all bindings together, preserve invariant order */ + while (fentry && fentry->name == q) { + *prev = fentry; + prev = &fentry->next; + fentry = *prev; + *prev = tentry; + ttable->entries++; + } + } + } + Xfree((char *)ftable); + /* resize if necessary, now that we're all done */ + GROW(pprev); +} + +void falrmCombineDatabase(XrmDatabase from, XrmDatabase *into, Bool override) +{ + NTable *prev; + NTable ftable, ttable, nftable; + + if (!*into) { + *into = from; + } else if (from) { + _XLockMutex(&from->linfo); + _XLockMutex(&(*into)->linfo); + if (ftable = from->table) { + prev = &(*into)->table; + ttable = *prev; + if (!ftable->leaf) { + nftable = ftable->next; + if (ttable && !ttable->leaf) { + /* both have node tables, merge them */ + MergeTables(ftable, prev, override); + /* bump to into's leaf table, if any */ + ttable = *(prev = &(*prev)->next); + } else { + /* into has no node table, link from's in */ + *prev = ftable; + *(prev = &ftable->next) = ttable; + } + /* bump to from's leaf table, if any */ + ftable = nftable; + } else { + /* bump to into's leaf table, if any */ + if (ttable && !ttable->leaf) + ttable = *(prev = &ttable->next); + } + if (ftable) { + /* if into has a leaf, merge, else insert */ + if (ttable) + MergeValues((LTable)ftable, prev, override); + else + *prev = ftable; + } + } + (from->methods->destroy)(from->mbstate); + _XFreeMutex(&from->linfo); + Xfree((char *)from); + _XUnlockMutex(&(*into)->linfo); + } +} + +void falrmMergeDatabases(XrmDatabase from, XrmDatabase *into) +{ + falrmCombineDatabase(from, into, True); +} + +/* store a value in the database, overriding any existing entry */ +static void PutEntry( + XrmDatabase db, + XrmBindingList bindings, + XrmQuarkList quarks, + XrmRepresentation type, + XrmValuePtr value) +{ + NTable *pprev, *prev; + NTable table; + XrmQuark q; + VEntry *vprev; + VEntry entry; + NTable *nprev, *firstpprev; + +#define NEWTABLE(q,i) \ + table = (NTable)Xmalloc(sizeof(LTableRec)); \ + if (!table) \ + return; \ + table->name = q; \ + table->hasloose = 0; \ + table->hasany = 0; \ + table->mask = 0; \ + table->entries = 0; \ + if (quarks[i]) { \ + table->leaf = 0; \ + nprev = NodeBuckets(table); \ + } else { \ + table->leaf = 1; \ + if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \ + return; \ + ((LTable)table)->buckets = (VEntry *)nprev; \ + } \ + *nprev = (NTable)NULL; \ + table->next = *prev; \ + *prev = table + + if (!db || !*quarks) + return; + table = *(prev = &db->table); + /* if already at leaf, bump to the leaf table */ + if (!quarks[1] && table && !table->leaf) + table = *(prev = &table->next); + pprev = prev; + if (!table || (quarks[1] && table->leaf)) { + /* no top-level node table, create one and chain it in */ + NEWTABLE(NULLQUARK,1); + table->tight = 1; /* arbitrary */ + prev = nprev; + } else { + /* search along until we need a value */ + while (quarks[1]) { + q = *quarks; + table = *(prev = &NodeHash(table, q)); + while (table && table->name != q) + table = *(prev = &table->next); + if (!table) + break; /* not found */ + if (quarks[2]) { + if (table->leaf) + break; /* not found */ + } else { + if (!table->leaf) { + /* bump to leaf table, if any */ + table = *(prev = &table->next); + if (!table || table->name != q) + break; /* not found */ + if (!table->leaf) { + /* bump to leaf table, if any */ + table = *(prev = &table->next); + if (!table || table->name != q) + break; /* not found */ + } + } + } + if (*bindings == XrmBindTightly) { + if (!table->tight) + break; /* not found */ + } else { + if (table->tight) { + /* bump to loose table, if any */ + table = *(prev = &table->next); + if (!table || table->name != q || + !quarks[2] != table->leaf) + break; /* not found */ + } + } + /* found that one, bump to next quark */ + pprev = prev; + quarks++; + bindings++; + } + if (!quarks[1]) { + /* found all the way to a leaf */ + q = *quarks; + entry = *(vprev = &LeafHash((LTable)table, q)); + while (entry && entry->name != q) + entry = *(vprev = &entry->next); + /* if want loose and have tight, bump to next entry */ + if (entry && *bindings == XrmBindLoosely && entry->tight) + entry = *(vprev = &entry->next); + if (entry && entry->name == q && + (*bindings == XrmBindTightly) == entry->tight) { + /* match, need to override */ + if ((type == XrmQString) == entry->string && + entry->size == value->size) { + /* update type if not String, can be different */ + if (!entry->string) + RepType(entry) = type; + /* identical size, just overwrite value */ + memcpy(RawValue(entry), (char *)value->addr, value->size); + return; + } + /* splice out and free old entry */ + *vprev = entry->next; + Xfree((char *)entry); + (*pprev)->entries--; + } + /* this is where to insert */ + prev = (NTable *)vprev; + } + } + /* keep the top table, because we may have to grow it */ + firstpprev = pprev; + /* iterate until we get to the leaf */ + while (quarks[1]) { + /* build a new table and chain it in */ + NEWTABLE(*quarks,2); + if (*quarks++ == XrmQANY) + (*pprev)->hasany = 1; + if (*bindings++ == XrmBindTightly) { + table->tight = 1; + } else { + table->tight = 0; + (*pprev)->hasloose = 1; + } + (*pprev)->entries++; + pprev = prev; + prev = nprev; + } + /* now allocate the value entry */ + entry = (VEntry)Xmalloc(((type == XrmQString) ? + sizeof(VEntryRec) : sizeof(DEntryRec)) + + value->size); + if (!entry) + return; + entry->name = q = *quarks; + if (*bindings == XrmBindTightly) { + entry->tight = 1; + } else { + entry->tight = 0; + (*pprev)->hasloose = 1; + } + /* chain it in, with a bit of type cast ugliness */ + entry->next = *((VEntry *)prev); + *((VEntry *)prev) = entry; + entry->size = value->size; + if (type == XrmQString) { + entry->string = 1; + } else { + entry->string = 0; + RepType(entry) = type; + } + /* save a copy of the value */ + memcpy(RawValue(entry), (char *)value->addr, value->size); + (*pprev)->entries++; + /* this is a new leaf, need to remember it for search lists */ + if (q > maxResourceQuark) { + unsigned oldsize = (maxResourceQuark + 1) >> 3; + unsigned size = ((q | 0x7f) + 1) >> 3; /* reallocate in chunks */ + if (resourceQuarks) + resourceQuarks = (unsigned char *)Xrealloc((char *)resourceQuarks, + size); + else + resourceQuarks = (unsigned char *)Xmalloc(size); + if (resourceQuarks) { + bzero((char *)&resourceQuarks[oldsize], size - oldsize); + maxResourceQuark = (size << 3) - 1; + } else { + maxResourceQuark = -1; + } + } + if (q > 0 && resourceQuarks) + resourceQuarks[q >> 3] |= 1 << (q & 0x7); + GROW(firstpprev); + +#undef NEWTABLE +} + +void falrmQPutResource( + XrmDatabase *pdb, + XrmBindingList bindings, + XrmQuarkList quarks, + XrmRepresentation type, + XrmValuePtr value) +{ + if (!*pdb) *pdb = NewDatabase(); + _XLockMutex(&(*pdb)->linfo); + PutEntry(*pdb, bindings, quarks, type, value); + _XUnlockMutex(&(*pdb)->linfo); +} + +void falrmPutResource( + XrmDatabase *pdb, + const char *specifier, + const char *type, + XrmValuePtr value) +{ + XrmBinding bindings[MAXDBDEPTH+1]; + XrmQuark quarks[MAXDBDEPTH+1]; + + if (!*pdb) *pdb = NewDatabase(); + _XLockMutex(&(*pdb)->linfo); + falrmStringToBindingQuarkList(specifier, bindings, quarks); + PutEntry(*pdb, bindings, quarks, falrmStringToQuark(type), value); + _XUnlockMutex(&(*pdb)->linfo); +} + +void falrmQPutStringResource( + XrmDatabase *pdb, + XrmBindingList bindings, + XrmQuarkList quarks, + const char *str) +{ + XrmValue value; + + if (!*pdb) *pdb = NewDatabase(); + value.addr = (XPointer) str; + value.size = strlen(str)+1; + _XLockMutex(&(*pdb)->linfo); + PutEntry(*pdb, bindings, quarks, XrmQString, &value); + _XUnlockMutex(&(*pdb)->linfo); +} + +/* Function Name: GetDatabase + * Description: Parses a string and stores it as a database. + * Arguments: db - the database. + * str - a pointer to the string containing the database. + * filename - source filename, if any. + * doall - whether to do all lines or just one + */ + +/* + * This function is highly optimized to inline as much as possible. + * Be very careful with modifications, or simplifications, as they + * may adversely affect the performance. + * + * Chris Peterson, MIT X Consortium 5/17/90. + */ + +#define LIST_SIZE 101 +#define BUFFER_SIZE 100 + +static void GetIncludeFile(); + +static void GetDatabase( + XrmDatabase db, + char *str, + char *filename, + Bool doall) +{ + char *ptr; + XrmBits bits = 0; + char c; + int len; + Signature sig; + char *ptr_max; + XrmQuarkList t_quarks; + XrmBindingList t_bindings; + + int alloc_chars = BUFSIZ; + char buffer[BUFSIZ], *value_str; + XrmQuark quarks[LIST_SIZE]; + XrmBinding bindings[LIST_SIZE]; + XrmValue value; + Bool only_pcs; + Bool dolines; + + if (!db) + return; + + if (!(value_str = Xmalloc(sizeof(char) * alloc_chars))) + return; + + (*db->methods->mbinit)(db->mbstate); + str--; + dolines = True; + while (!is_EOF(bits) && dolines) { + dolines = doall; + + /* + * First: Remove extra whitespace. + */ + + do { + bits = next_char(c, str); + } while is_space(bits); + + /* + * Ignore empty lines. + */ + + if (is_EOL(bits)) + continue; /* start a new line. */ + + /* + * Second: check the first character in a line to see if it is + * "!" signifying a comment, or "#" signifying a directive. + */ + + if (c == '!') { /* Comment, spin to next newline */ + while (is_simple(bits = next_char(c, str))) {} + if (is_EOL(bits)) + continue; + while (!is_EOL(bits = next_mbchar(c, len, str))) {} + str--; + continue; /* start a new line. */ + } + + if (c == '#') { /* Directive */ + /* remove extra whitespace */ + only_pcs = True; + while (is_space(bits = next_char(c, str))) {}; + /* only "include" directive is currently defined */ + if (!strncmp(str, "include", 7)) { + str += (7-1); + /* remove extra whitespace */ + while (is_space(bits = next_char(c, str))) {}; + /* must have a starting " */ + if (c == '"') { + char *fname = str+1; + len = 0; + do { + if (only_pcs) { + bits = next_char(c, str); + if (is_nonpcs(bits)) + only_pcs = False; + } + if (!only_pcs) + bits = next_mbchar(c, len, str); + } while (c != '"' && !is_EOL(bits)); + /* must have an ending " */ + if (c == '"') + GetIncludeFile(db, filename, fname, str - len - fname); + } + } + /* spin to next newline */ + if (only_pcs) { + while (is_simple(bits)) + bits = next_char(c, str); + if (is_EOL(bits)) + continue; + } + while (!is_EOL(bits)) + bits = next_mbchar(c, len, str); + str--; + continue; /* start a new line. */ + } + + /* + * Third: loop through the LHS of the resource specification + * storing characters and converting this to a Quark. + * + * If the number of quarks is greater than LIST_SIZE - 1. This + * function will trash your memory. + * + * If the length of any quark is larger than BUFSIZ this function + * will also trash memory. + */ + + t_bindings = bindings; + t_quarks = quarks; + + sig = 0; + ptr = buffer; + *t_bindings = XrmBindTightly; + for(;;) { + if (!is_binding(bits)) { + while (!is_EOQ(bits)) { + *ptr++ = c; + sig = (sig << 1) + c; /* Compute the signature. */ + bits = next_char(c, str); + } + + *t_quarks++ = _falrmInternalStringToQuark(buffer, ptr - buffer, + sig, False); + + if (is_separator(bits)) { + if (!is_space(bits)) + break; + + /* Remove white space */ + do { + *ptr++ = c; + sig = (sig << 1) + c; /* Compute the signature. */ + } while (is_space(bits = next_char(c, str))); + + /* + * The spec doesn't permit it, but support spaces + * internal to resource name/class + */ + + if (is_separator(bits)) + break; + t_quarks--; + continue; + } + + if (c == '.') + *(++t_bindings) = XrmBindTightly; + else + *(++t_bindings) = XrmBindLoosely; + + sig = 0; + ptr = buffer; + } + else { + /* + * Magic unspecified feature #254. + * + * If two separators appear with no Text between them then + * ignore them. + * + * If anyone of those separators is a '*' then the binding + * will be loose, otherwise it will be tight. + */ + + if (c == '*') + *t_bindings = XrmBindLoosely; + } + + bits = next_char(c, str); + } + + *t_quarks = NULLQUARK; + + /* + * Make sure that there is a ':' in this line. + */ + + if (c != ':') { + char oldc; + + /* + * A parsing error has occurred, toss everything on the line + * a new_line can still be escaped with a '\'. + */ + + while (is_normal(bits)) + bits = next_char(c, str); + if (is_EOL(bits)) + continue; + bits = next_mbchar(c, len, str); + do { + oldc = c; + bits = next_mbchar(c, len, str); + } while (c && (c != '\n' || oldc == '\\')); + str--; + continue; + } + + /* + * I now have a quark and binding list for the entire left hand + * side. "c" currently points to the ":" separating the left hand + * side for the right hand side. It is time to begin processing + * the right hand side. + */ + + /* + * Fourth: Remove more whitespace + */ + + for(;;) { + if (is_space(bits = next_char(c, str))) + continue; + if (c != '\\') + break; + bits = next_char(c, str); + if (c == '\n') + continue; + str--; + bits = BSLASH; + c = '\\'; + break; + } + + /* + * Fifth: Process the right hand side. + */ + + ptr = value_str; + ptr_max = ptr + alloc_chars - 4; + only_pcs = True; + len = 1; + + for(;;) { + + /* + * Tight loop for the normal case: Non backslash, non-end of value + * character that will fit into the allocated buffer. + */ + + if (only_pcs) { + while (is_normal(bits) && ptr < ptr_max) { + *ptr++ = c; + bits = next_char(c, str); + } + if (is_EOL(bits)) + break; + if (is_nonpcs(bits)) { + only_pcs = False; + bits = next_mbchar(c, len, str); + } + } + while (!is_special(bits) && ptr + len <= ptr_max) { + len = -len; + while (len) + *ptr++ = str[len++]; + bits = next_mbchar(c, len, str); + } + + if (is_EOL(bits)) { + str--; + break; + } + + if (c == '\\') { + /* + * We need to do some magic after a backslash. + */ + Bool read_next = True; + + if (only_pcs) { + bits = next_char(c, str); + if (is_nonpcs(bits)) + only_pcs = False; + } + if (!only_pcs) + bits = next_mbchar(c, len, str); + + if (is_EOL(bits)) { + if (is_EOF(bits)) + continue; + } else if (c == 'n') { + /* + * "\n" means insert a newline. + */ + *ptr++ = '\n'; + } else if (c == '\\') { + /* + * "\\" completes to just one backslash. + */ + *ptr++ = '\\'; + } else { + /* + * pick up to three octal digits after the '\'. + */ + char temp[3]; + int count = 0; + while (is_odigit(bits) && count < 3) { + temp[count++] = c; + if (only_pcs) { + bits = next_char(c, str); + if (is_nonpcs(bits)) + only_pcs = False; + } + if (!only_pcs) + bits = next_mbchar(c, len, str); + } + + /* + * If we found three digits then insert that octal code + * into the value string as a character. + */ + + if (count == 3) { + *ptr++ = (unsigned char) ((temp[0] - '0') * 0100 + + (temp[1] - '0') * 010 + + (temp[2] - '0')); + } + else { + int tcount; + + /* + * Otherwise just insert those characters into the + * string, since no special processing is needed on + * numerics we can skip the special processing. + */ + + for (tcount = 0; tcount < count; tcount++) { + *ptr++ = temp[tcount]; /* print them in + the correct order */ + } + } + read_next = False; + } + if (read_next) { + if (only_pcs) { + bits = next_char(c, str); + if (is_nonpcs(bits)) + only_pcs = False; + } + if (!only_pcs) + bits = next_mbchar(c, len, str); + } + } + + /* + * It is important to make sure that there is room for at least + * four more characters in the buffer, since I can add that + * many characters into the buffer after a backslash has occurred. + */ + + if (ptr + len > ptr_max) { + char * temp_str; + + alloc_chars += BUFSIZ/10; + temp_str = Xrealloc(value_str, sizeof(char) * alloc_chars); + + if (!temp_str) { + Xfree(value_str); + (*db->methods->mbfinish)(db->mbstate); + return; + } + + ptr = temp_str + (ptr - value_str); /* reset pointer. */ + value_str = temp_str; + ptr_max = value_str + alloc_chars - 4; + } + } + + /* + * Lastly: Terminate the value string, and store this entry + * into the database. + */ + + *ptr++ = '\0'; + + /* Store it in database */ + value.size = ptr - value_str; + value.addr = (XPointer) value_str; + + PutEntry(db, bindings, quarks, XrmQString, &value); + } + + Xfree(value_str); + (*db->methods->mbfinish)(db->mbstate); +} + +void falrmPutStringResource( + XrmDatabase *pdb, + const char*specifier, + const char*str) +{ + XrmValue value; + XrmBinding bindings[MAXDBDEPTH+1]; + XrmQuark quarks[MAXDBDEPTH+1]; + + if (!*pdb) *pdb = NewDatabase(); + falrmStringToBindingQuarkList(specifier, bindings, quarks); + value.addr = (XPointer) str; + value.size = strlen(str)+1; + _XLockMutex(&(*pdb)->linfo); + PutEntry(*pdb, bindings, quarks, XrmQString, &value); + _XUnlockMutex(&(*pdb)->linfo); +} + + +void falrmPutLineResource(XrmDatabase *pdb, char *line) +{ + if (!*pdb) *pdb = NewDatabase(); + _XLockMutex(&(*pdb)->linfo); + GetDatabase(*pdb, line, (char *)NULL, False); + _XUnlockMutex(&(*pdb)->linfo); +} + +XrmDatabase falrmGetStringDatabase(char *data) +{ + XrmDatabase db; + + db = NewDatabase(); + _XLockMutex(&db->linfo); + GetDatabase(db, data, (char *)NULL, True); + _XUnlockMutex(&db->linfo); + return db; +} + +/* Function Name: ReadInFile + * Description: Reads the file into a buffer. + * Arguments: filename - the name of the file. + * Returns: An allocated string containing the contents of the file. + */ + +static char * +ReadInFile(char *filename) +{ + int fd, size; + char * filebuf; + + if ( (fd = OpenFile(filename)) == -1 ) + return (char *)NULL; + + GetSizeOfFile(filename, size); + + if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */ + close(fd); + return (char *)NULL; + } + + size = ReadFile(fd, filebuf, size); + if (size < 0) { + CloseFile(fd); + Xfree(filebuf); + return (char *)NULL; + } + CloseFile(fd); + + filebuf[size] = '\0'; /* NULL terminate it. */ + return filebuf; +} + +static void +GetIncludeFile( + XrmDatabase db, + char *base, + char *fname, + int fnamelen) +{ + int len; + char *str; + char realfname[BUFSIZ]; + + if (fnamelen <= 0 || fnamelen >= BUFSIZ) + return; + if (*fname != '/' && base && (str = strrchr(base, '/'))) { + len = str - base + 1; + if (len + fnamelen >= BUFSIZ) + return; + strncpy(realfname, base, len); + strncpy(realfname + len, fname, fnamelen); + realfname[len + fnamelen] = '\0'; + } else { + strncpy(realfname, fname, fnamelen); + realfname[fnamelen] = '\0'; + } + if (!(str = ReadInFile(realfname))) + return; + GetDatabase(db, str, realfname, True); + Xfree(str); +} + +XrmDatabase falrmGetFileDatabase(char *filename) +{ + XrmDatabase db; + char *str; + + if (!(str = ReadInFile(filename))) + return (XrmDatabase)NULL; + + db = NewDatabase(); + _XLockMutex(&db->linfo); + GetDatabase(db, str, filename, True); + _XUnlockMutex(&db->linfo); + Xfree(str); + return db; +} + +Status falrmCombineFileDatabase( + char *filename, + XrmDatabase *target, + Bool override) +{ + XrmDatabase db; + char *str; + + if (!(str = ReadInFile(filename))) + return 0; + if (override) { + db = *target; + if (!db) + *target = db = NewDatabase(); + } else + db = NewDatabase(); + _XLockMutex(&db->linfo); + GetDatabase(db, str, filename, True); + _XUnlockMutex(&db->linfo); + Xfree(str); + if (!override) + falrmCombineDatabase(db, target, False); + return 1; +} + +/* call the user proc for every value in the table, arbitrary order. + * stop if user proc returns True. level is current depth in database. + */ +/*ARGSUSED*/ +static Bool EnumLTable( + LTable table, + XrmNameList names, + XrmClassList classes, + int level, + EClosure closure) +{ + VEntry *bucket; + int i; + VEntry entry; + XrmValue value; + XrmRepresentation type; + Bool tightOk; + + closure->bindings[level] = (table->table.tight ? + XrmBindTightly : XrmBindLoosely); + closure->quarks[level] = table->table.name; + level++; + tightOk = !*names; + closure->quarks[level + 1] = NULLQUARK; + for (i = table->table.mask, bucket = table->buckets; + i >= 0; + i--, bucket++) { + for (entry = *bucket; entry; entry = entry->next) { + if (entry->tight && !tightOk) + continue; + closure->bindings[level] = (entry->tight ? + XrmBindTightly : XrmBindLoosely); + closure->quarks[level] = entry->name; + value.size = entry->size; + if (entry->string) { + type = XrmQString; + value.addr = StringValue(entry); + } else { + type = RepType(entry); + value.addr = DataValue(entry); + } + if ((*closure->proc)(&closure->db, closure->bindings+1, + closure->quarks+1, &type, &value, + closure->closure)) + return True; + } + } + return False; +} + +static Bool EnumAllNTable(NTable table, int level, EClosure closure) +{ + NTable *bucket; + int i; + NTable entry; + XrmQuark empty = NULLQUARK; + + if (level >= MAXDBDEPTH) + return False; + for (i = table->mask, bucket = NodeBuckets(table); + i >= 0; + i--, bucket++) { + for (entry = *bucket; entry; entry = entry->next) { + if (entry->leaf) { + if (EnumLTable((LTable)entry, &empty, &empty, level, closure)) + return True; + } else { + closure->bindings[level] = (entry->tight ? + XrmBindTightly : XrmBindLoosely); + closure->quarks[level] = entry->name; + if (EnumAllNTable(entry, level+1, closure)) + return True; + } + } + } + return False; +} + +/* recurse on every table in the table, arbitrary order. + * stop if user proc returns True. level is current depth in database. + */ +static Bool EnumNTable( + NTable table, + XrmNameList names, + XrmClassList classes, + int level, + EClosure closure) +{ + NTable entry; + XrmQuark q; + unsigned int leaf; + Bool (*get)(); + Bool bilevel; + +/* find entries named ename, leafness leaf, tight or loose, and call get */ +#define ITIGHTLOOSE(ename) \ + NFIND(ename); \ + if (entry) { \ + if (leaf == entry->leaf) { \ + if (!leaf && !entry->tight && entry->next && \ + entry->next->name == q && entry->next->tight && \ + (bilevel || entry->next->hasloose) && \ + EnumLTable((LTable)entry->next, names+1, classes+1, \ + level, closure)) \ + return True; \ + if ((*get)(entry, names+1, classes+1, level, closure)) \ + return True; \ + if (entry->tight && (entry = entry->next) && \ + entry->name == q && leaf == entry->leaf && \ + (*get)(entry, names+1, classes+1, level, closure)) \ + return True; \ + } else if (entry->leaf) { \ + if ((bilevel || entry->hasloose) && \ + EnumLTable((LTable)entry, names+1, classes+1, level, closure))\ + return True; \ + if (entry->tight && (entry = entry->next) && \ + entry->name == q && (bilevel || entry->hasloose) && \ + EnumLTable((LTable)entry, names+1, classes+1, level, closure))\ + return True; \ + } \ + } + +/* find entries named ename, leafness leaf, loose only, and call get */ +#define ILOOSE(ename) \ + NFIND(ename); \ + if (entry && entry->tight && (entry = entry->next) && entry->name != q) \ + entry = (NTable)NULL; \ + if (entry) { \ + if (leaf == entry->leaf) { \ + if ((*get)(entry, names+1, classes+1, level, closure)) \ + return True; \ + } else if (entry->leaf && (bilevel || entry->hasloose)) { \ + if (EnumLTable((LTable)entry, names+1, classes+1, level, closure))\ + return True; \ + } \ + } + + if (level >= MAXDBDEPTH) + return False; + closure->bindings[level] = (table->tight ? + XrmBindTightly : XrmBindLoosely); + closure->quarks[level] = table->name; + level++; + if (!*names) { + if (EnumAllNTable(table, level, closure)) + return True; + } else { + if (names[1] || closure->mode == XrmEnumAllLevels) { + get = EnumNTable; /* recurse */ + leaf = 0; + bilevel = !names[1]; + } else { + get = EnumLTable; /* bottom of recursion */ + leaf = 1; + bilevel = False; + } + if (table->hasloose && closure->mode == XrmEnumAllLevels) { + NTable *bucket; + int i; + XrmQuark empty = NULLQUARK; + + for (i = table->mask, bucket = NodeBuckets(table); + i >= 0; + i--, bucket++) { + q = NULLQUARK; + for (entry = *bucket; entry; entry = entry->next) { + if (!entry->tight && entry->name != q && + entry->name != *names && entry->name != *classes) { + q = entry->name; + if (entry->leaf) { + if (EnumLTable((LTable)entry, &empty, &empty, + level, closure)) + return True; + } else { + if (EnumNTable(entry, &empty, &empty, + level, closure)) + return True; + } + } + } + } + } + + ITIGHTLOOSE(*names); /* do name, tight and loose */ + ITIGHTLOOSE(*classes); /* do class, tight and loose */ + if (table->hasany) { + ITIGHTLOOSE(XrmQANY); /* do ANY, tight and loose */ + } + if (table->hasloose) { + while (1) { + names++; + classes++; + if (!*names) + break; + if (!names[1] && closure->mode != XrmEnumAllLevels) { + get = EnumLTable; /* bottom of recursion */ + leaf = 1; + } + ILOOSE(*names); /* loose names */ + ILOOSE(*classes); /* loose classes */ + if (table->hasany) { + ILOOSE(XrmQANY); /* loose ANY */ + } + } + names--; + classes--; + } + } + /* now look for matching leaf nodes */ + entry = table->next; + if (!entry) + return False; + if (entry->leaf) { + if (entry->tight && !table->tight) + entry = entry->next; + } else { + entry = entry->next; + if (!entry || !entry->tight) + return False; + } + if (!entry || entry->name != table->name) + return False; + /* found one */ + level--; + if ((!*names || entry->hasloose) && + EnumLTable((LTable)entry, names, classes, level, closure)) + return True; + if (entry->tight && entry == table->next && (entry = entry->next) && + entry->name == table->name && (!*names || entry->hasloose)) + return EnumLTable((LTable)entry, names, classes, level, closure); + return False; + +#undef ITIGHTLOOSE +#undef ILOOSE +} + +/* call the proc for every value in the database, arbitrary order. + * stop if the proc returns True. + */ +Bool falrmEnumerateDatabase( + XrmDatabase db, + XrmNameList names, + XrmClassList classes, + int mode, + DBEnumProc proc, + XPointer closure) +{ + XrmBinding bindings[MAXDBDEPTH+2]; + XrmQuark quarks[MAXDBDEPTH+2]; + NTable table; + EClosureRec eclosure; + Bool retval = False; + + if (!db) + return False; + _XLockMutex(&db->linfo); + eclosure.db = db; + eclosure.proc = proc; + eclosure.closure = closure; + eclosure.bindings = bindings; + eclosure.quarks = quarks; + eclosure.mode = mode; + table = db->table; + if (table && !table->leaf && !*names && mode == XrmEnumOneLevel) + table = table->next; + if (table) { + if (!table->leaf) + retval = EnumNTable(table, names, classes, 0, &eclosure); + else + retval = EnumLTable((LTable)table, names, classes, 0, &eclosure); + } + _XUnlockMutex(&db->linfo); + return retval; +} + +static void PrintBindingQuarkList( + XrmBindingList bindings, + XrmQuarkList quarks, + FILE *stream) +{ + Bool firstNameSeen; + + for (firstNameSeen = False; *quarks; bindings++, quarks++) { + if (*bindings == XrmBindLoosely) { + (void) fprintf(stream, "*"); + } else if (firstNameSeen) { + (void) fprintf(stream, "."); + } + firstNameSeen = True; + (void) fputs(falrmQuarkToString(*quarks), stream); + } +} + +/* output out the entry in correct file syntax */ +/*ARGSUSED*/ +static Bool DumpEntry( + XrmDatabase *db, + XrmBindingList bindings, + XrmQuarkList quarks, + XrmRepresentation *type, + XrmValuePtr value, + XPointer data) +{ + FILE *stream = (FILE *)data; + unsigned int i; + char *s; + char c; + + if (*type != XrmQString) + (void) putc('!', stream); + PrintBindingQuarkList(bindings, quarks, stream); + s = value->addr; + i = value->size; + if (*type == XrmQString) { + (void) fputs(":\t", stream); + if (i) + i--; + } + else + (void) fprintf(stream, "=%s:\t", XrmRepresentationToString(*type)); + if (i && (*s == ' ' || *s == '\t')) + (void) putc('\\', stream); /* preserve leading whitespace */ + while (i--) { + c = *s++; + if (c == '\n') { + if (i) + (void) fputs("\\n\\\n", stream); + else + (void) fputs("\\n", stream); + } else if (c == '\\') + (void) fputs("\\\\", stream); + else if ((c < ' ' && c != '\t') || + ((unsigned char)c >= 0x7f && (unsigned char)c < 0xa0)) + (void) fprintf(stream, "\\%03o", (unsigned char)c); + else + (void) putc(c, stream); + } + (void) putc('\n', stream); + return ferror(stream) != 0; +} + +#ifdef DEBUG + +void falPrintTable(NTable table, FILE *file) +{ + XrmBinding bindings[MAXDBDEPTH+1]; + XrmQuark quarks[MAXDBDEPTH+1]; + EClosureRec closure; + XrmQuark empty = NULLQUARK; + + closure.db = (XrmDatabase)NULL; + closure.proc = DumpEntry; + closure.closure = (XPointer)file; + closure.bindings = bindings; + closure.quarks = quarks; + closure.mode = XrmEnumAllLevels; + if (table->leaf) + EnumLTable((LTable)table, &empty, &empty, 0, &closure); + else + EnumNTable(table, &empty, &empty, 0, &closure); +} + +#endif /* DEBUG */ + +void falrmPutFileDatabase(XrmDatabase db, const char *fileName) +{ + FILE *file; + XrmQuark empty = NULLQUARK; + + if (!db) return; + if (!(file = fopen(fileName, "w"))) return; + if (falrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels, + DumpEntry, (XPointer) file)) + unlink((char *)fileName); + fclose(file); +} + +/* macros used in get/search functions */ + +/* find entries named ename, leafness leaf, tight or loose, and call get */ +#define GTIGHTLOOSE(ename,looseleaf) \ + NFIND(ename); \ + if (entry) { \ + if (leaf == entry->leaf) { \ + if (!leaf && !entry->tight && entry->next && \ + entry->next->name == q && entry->next->tight && \ + entry->next->hasloose && \ + looseleaf((LTable)entry->next, names+1, classes+1, closure)) \ + return True; \ + if ((*get)(entry, names+1, classes+1, closure)) \ + return True; \ + if (entry->tight && (entry = entry->next) && \ + entry->name == q && leaf == entry->leaf && \ + (*get)(entry, names+1, classes+1, closure)) \ + return True; \ + } else if (entry->leaf) { \ + if (entry->hasloose && \ + looseleaf((LTable)entry, names+1, classes+1, closure)) \ + return True; \ + if (entry->tight && (entry = entry->next) && \ + entry->name == q && entry->hasloose && \ + looseleaf((LTable)entry, names+1, classes+1, closure)) \ + return True; \ + } \ + } + +/* find entries named ename, leafness leaf, loose only, and call get */ +#define GLOOSE(ename,looseleaf) \ + NFIND(ename); \ + if (entry && entry->tight && (entry = entry->next) && entry->name != q) \ + entry = (NTable)NULL; \ + if (entry) { \ + if (leaf == entry->leaf) { \ + if ((*get)(entry, names+1, classes+1, closure)) \ + return True; \ + } else if (entry->leaf && entry->hasloose) { \ + if (looseleaf((LTable)entry, names+1, classes+1, closure)) \ + return True; \ + } \ + } + +/* add tight/loose entry to the search list, return True if list is full */ +/*ARGSUSED*/ +static Bool AppendLEntry( + LTable table, + XrmNameList names, + XrmClassList classes, + SClosure closure) +{ + /* check for duplicate */ + if (closure->idx >= 0 && closure->list[closure->idx] == table) + return False; + if (closure->idx == closure->limit) + return True; + /* append it */ + closure->idx++; + closure->list[closure->idx] = table; + return False; +} + +/* add loose entry to the search list, return True if list is full */ +/*ARGSUSED*/ +static Bool AppendLooseLEntry( + LTable table, + XrmNameList names, + XrmClassList classes, + SClosure closure) +{ + /* check for duplicate */ + if (closure->idx >= 0 && closure->list[closure->idx] == table) + return False; + if (closure->idx >= closure->limit - 1) + return True; + /* append it */ + closure->idx++; + closure->list[closure->idx] = LOOSESEARCH; + closure->idx++; + closure->list[closure->idx] = table; + return False; +} + +/* search for a leaf table */ +static Bool SearchNEntry( + NTable table, + XrmNameList names, + XrmClassList classes, + SClosure closure) +{ + NTable entry; + XrmQuark q; + unsigned int leaf; + Bool (*get)(); + + if (names[1]) { + get = SearchNEntry; /* recurse */ + leaf = 0; + } else { + get = AppendLEntry; /* bottom of recursion */ + leaf = 1; + } + GTIGHTLOOSE(*names, AppendLooseLEntry); /* do name, tight and loose */ + GTIGHTLOOSE(*classes, AppendLooseLEntry); /* do class, tight and loose */ + if (table->hasany) { + GTIGHTLOOSE(XrmQANY, AppendLooseLEntry); /* do ANY, tight and loose */ + } + if (table->hasloose) { + while (1) { + names++; + classes++; + if (!*names) + break; + if (!names[1]) { + get = AppendLEntry; /* bottom of recursion */ + leaf = 1; + } + GLOOSE(*names, AppendLooseLEntry); /* loose names */ + GLOOSE(*classes, AppendLooseLEntry); /* loose classes */ + if (table->hasany) { + GLOOSE(XrmQANY, AppendLooseLEntry); /* loose ANY */ + } + } + } + /* now look for matching leaf nodes */ + entry = table->next; + if (!entry) + return False; + if (entry->leaf) { + if (entry->tight && !table->tight) + entry = entry->next; + } else { + entry = entry->next; + if (!entry || !entry->tight) + return False; + } + if (!entry || entry->name != table->name) + return False; + /* found one */ + if (entry->hasloose && + AppendLooseLEntry((LTable)entry, names, classes, closure)) + return True; + if (entry->tight && entry == table->next && (entry = entry->next) && + entry->name == table->name && entry->hasloose) + return AppendLooseLEntry((LTable)entry, names, classes, closure); + return False; +} + +Bool falrmQGetSearchList( + XrmDatabase db, + XrmNameList names, + XrmClassList classes, + XrmSearchList searchList, /* RETURN */ + int listLength) +{ + NTable table; + SClosureRec closure; + + if (listLength <= 0) + return False; + closure.list = (LTable *)searchList; + closure.idx = -1; + closure.limit = listLength - 2; + if (db) { + _XLockMutex(&db->linfo); + table = db->table; + if (*names) { + if (table && !table->leaf) { + if (SearchNEntry(table, names, classes, &closure)) { + _XUnlockMutex(&db->linfo); + return False; + } + } else if (table && table->hasloose && + AppendLooseLEntry((LTable)table, names, classes, + &closure)) { + _XUnlockMutex(&db->linfo); + return False; + } + } else { + if (table && !table->leaf) + table = table->next; + if (table && + AppendLEntry((LTable)table, names, classes, &closure)) { + _XUnlockMutex(&db->linfo); + return False; + } + } + _XUnlockMutex(&db->linfo); + } + closure.list[closure.idx + 1] = (LTable)NULL; + return True; +} + +Bool falrmQGetSearchResource( + XrmSearchList searchList, + XrmName name, + XrmClass class, + XrmRepresentation *pType, /* RETURN */ + XrmValue *pValue) /* RETURN */ +{ + LTable *list; + LTable table; + VEntry entry; + int flags; + +/* find tight or loose entry */ +#define VTIGHTLOOSE(q) \ + entry = LeafHash(table, q); \ + while (entry && entry->name != q) \ + entry = entry->next; \ + if (entry) \ + break + +/* find loose entry */ +#define VLOOSE(q) \ + entry = LeafHash(table, q); \ + while (entry && entry->name != q) \ + entry = entry->next; \ + if (entry) { \ + if (!entry->tight) \ + break; \ + if ((entry = entry->next) && entry->name == q) \ + break; \ + } + + list = (LTable *)searchList; + /* figure out which combination of name and class we need to search for */ + flags = 0; + if (IsResourceQuark(name)) + flags = 2; + if (IsResourceQuark(class)) + flags |= 1; + if (!flags) { + /* neither name nor class has ever been used to name a resource */ + table = (LTable)NULL; + } else if (flags == 3) { + /* both name and class */ + while (table = *list++) { + if (table != LOOSESEARCH) { + VTIGHTLOOSE(name); /* do name, tight and loose */ + VTIGHTLOOSE(class); /* do class, tight and loose */ + } else { + table = *list++; + VLOOSE(name); /* do name, loose only */ + VLOOSE(class); /* do class, loose only */ + } + } + } else { + /* just one of name or class */ + if (flags == 1) + name = class; + while (table = *list++) { + if (table != LOOSESEARCH) { + VTIGHTLOOSE(name); /* tight and loose */ + } else { + table = *list++; + VLOOSE(name); /* loose only */ + } + } + } + if (table) { + /* found a match */ + if (entry->string) { + *pType = XrmQString; + pValue->addr = StringValue(entry); + } else { + *pType = RepType(entry); + pValue->addr = DataValue(entry); + } + pValue->size = entry->size; + return True; + } + *pType = NULLQUARK; + pValue->addr = (XPointer)NULL; + pValue->size = 0; + return False; + +#undef VTIGHTLOOSE +#undef VLOOSE +} + +/* look for a tight/loose value */ +static Bool GetVEntry( + LTable table, + XrmNameList names, + XrmClassList classes, + VClosure closure) +{ + VEntry entry; + XrmQuark q; + + /* try name first */ + q = *names; + entry = LeafHash(table, q); + while (entry && entry->name != q) + entry = entry->next; + if (!entry) { + /* not found, try class */ + q = *classes; + entry = LeafHash(table, q); + while (entry && entry->name != q) + entry = entry->next; + if (!entry) + return False; + } + if (entry->string) { + *closure->type = XrmQString; + closure->value->addr = StringValue(entry); + } else { + *closure->type = RepType(entry); + closure->value->addr = DataValue(entry); + } + closure->value->size = entry->size; + return True; +} + +/* look for a loose value */ +static Bool GetLooseVEntry( + LTable table, + XrmNameList names, + XrmClassList classes, + VClosure closure) +{ + VEntry entry; + XrmQuark q; + +#define VLOOSE(ename) \ + q = ename; \ + entry = LeafHash(table, q); \ + while (entry && entry->name != q) \ + entry = entry->next; \ + if (entry && entry->tight && (entry = entry->next) && entry->name != q) \ + entry = (VEntry)NULL; + + /* bump to last component */ + while (names[1]) { + names++; + classes++; + } + VLOOSE(*names); /* do name, loose only */ + if (!entry) { + VLOOSE(*classes); /* do class, loose only */ + if (!entry) + return False; + } + if (entry->string) { + *closure->type = XrmQString; + closure->value->addr = StringValue(entry); + } else { + *closure->type = RepType(entry); + closure->value->addr = DataValue(entry); + } + closure->value->size = entry->size; + return True; + +#undef VLOOSE +} + +/* recursive search for a value */ +static Bool GetNEntry( + NTable table, + XrmNameList names, + XrmClassList classes, + VClosure closure) +{ + NTable entry; + XrmQuark q; + unsigned int leaf; + Bool (*get)(); + NTable otable; + + if (names[2]) { + get = GetNEntry; /* recurse */ + leaf = 0; + } else { + get = GetVEntry; /* bottom of recursion */ + leaf = 1; + } + GTIGHTLOOSE(*names, GetLooseVEntry); /* do name, tight and loose */ + GTIGHTLOOSE(*classes, GetLooseVEntry); /* do class, tight and loose */ + if (table->hasany) { + GTIGHTLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, tight and loose */ + } + if (table->hasloose) { + while (1) { + names++; + classes++; + if (!names[1]) + break; + if (!names[2]) { + get = GetVEntry; /* bottom of recursion */ + leaf = 1; + } + GLOOSE(*names, GetLooseVEntry); /* do name, loose only */ + GLOOSE(*classes, GetLooseVEntry); /* do class, loose only */ + if (table->hasany) { + GLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, loose only */ + } + } + } + /* look for matching leaf tables */ + otable = table; + table = table->next; + if (!table) + return False; + if (table->leaf) { + if (table->tight && !otable->tight) + table = table->next; + } else { + table = table->next; + if (!table || !table->tight) + return False; + } + if (!table || table->name != otable->name) + return False; + /* found one */ + if (table->hasloose && + GetLooseVEntry((LTable)table, names, classes, closure)) + return True; + if (table->tight && table == otable->next) { + table = table->next; + if (table && table->name == otable->name && table->hasloose) + return GetLooseVEntry((LTable)table, names, classes, closure); + } + return False; +} + +Bool falrmQGetResource( + XrmDatabase db, + XrmNameList names, + XrmClassList classes, + XrmRepresentation *pType, /* RETURN */ + XrmValuePtr pValue) /* RETURN */ +{ + NTable table; + VClosureRec closure; + + if (db && *names) { + _XLockMutex(&db->linfo); + closure.type = pType; + closure.value = pValue; + table = db->table; + if (names[1]) { + if (table && !table->leaf) { + if (GetNEntry(table, names, classes, &closure)) { + _XUnlockMutex(&db->linfo); + return True; + } + } else if (table && table->hasloose && + GetLooseVEntry((LTable)table, names, classes, &closure)) { + _XUnlockMutex (&db->linfo); + return True; + } + } else { + if (table && !table->leaf) + table = table->next; + if (table && GetVEntry((LTable)table, names, classes, &closure)) { + _XUnlockMutex(&db->linfo); + return True; + } + } + _XUnlockMutex(&db->linfo); + } + *pType = NULLQUARK; + pValue->addr = (XPointer)NULL; + pValue->size = 0; + return False; +} + +Bool falrmGetResource( + XrmDatabase db, + const char *name_str, + const char *class_str, + XrmString *pType_str, /* RETURN */ + XrmValuePtr pValue) /* RETURN */ +{ + XrmName names[MAXDBDEPTH+1]; + XrmClass classes[MAXDBDEPTH+1]; + XrmRepresentation fromType; + Bool result; + + XrmStringToNameList(name_str, names); + XrmStringToClassList(class_str, classes); + result = falrmQGetResource(db, names, classes, &fromType, pValue); + (*pType_str) = falrmQuarkToString(fromType); + return result; +} + +/* destroy all values, plus table itself */ +static void DestroyLTable(LTable table) +{ + int i; + VEntry *buckets; + VEntry entry, next; + + buckets = table->buckets; + for (i = table->table.mask; i >= 0; i--, buckets++) { + for (next = *buckets; entry = next; ) { + next = entry->next; + Xfree((char *)entry); + } + } + Xfree((char *)table->buckets); + Xfree((char *)table); +} + +/* destroy all contained tables, plus table itself */ +static void DestroyNTable(NTable table) +{ + int i; + NTable *buckets; + NTable entry, next; + + buckets = NodeBuckets(table); + for (i = table->mask; i >= 0; i--, buckets++) { + for (next = *buckets; entry = next; ) { + next = entry->next; + if (entry->leaf) + DestroyLTable((LTable)entry); + else + DestroyNTable(entry); + } + } + Xfree((char *)table); +} + +char *falrmLocaleOfDatabase(XrmDatabase db) +{ + char* retval; + _XLockMutex(&db->linfo); + retval = (*db->methods->lcname)(db->mbstate); + _XUnlockMutex(&db->linfo); + return retval; +} + +void falrmDestroyDatabase(XrmDatabase db) +{ + NTable table, next; + + if (db) { + _XLockMutex(&db->linfo); + for (next = db->table; table = next; ) { + next = table->next; + if (table->leaf) + DestroyLTable((LTable)table); + else + DestroyNTable(table); + } + _XFreeMutex(&db->linfo); + (*db->methods->destroy)(db->mbstate); + Xfree((char *)db); + } +} diff --git a/cde/programs/dtudcfonted/libfal/_falrmI.h b/cde/programs/dtudcfonted/libfal/_falrmI.h new file mode 100644 index 000000000..0a8561168 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falrmI.h @@ -0,0 +1,75 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* XrmI.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:12 */ +/* $XConsortium: _falrmI.h /main/1 1996/04/08 15:22:08 cde-fuj $ */ +/* + +Copyright (c) 1990 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + + +/* + * Macros to abstract out reading the file, and getting its size. + * + * You may need to redefine these for various other operating systems. + */ + +#include <X11/Xos.h> +#include <sys/stat.h> + +#define OpenFile(name) open((name), O_RDONLY) +#define CloseFile(fd) close((fd)) +#define ReadFile(fd,buf,size) read((fd), (buf), (size)) +#define GetSizeOfFile(name,size) \ +{ \ + struct stat status_buffer; \ + if ( (stat((name), &status_buffer)) == -1 ) \ + size = -1; \ + else \ + size = status_buffer.st_size; \ +} diff --git a/cde/programs/dtudcfonted/libfal/_faludcInf.c b/cde/programs/dtudcfonted/libfal/_faludcInf.c new file mode 100644 index 000000000..9c03ab32a --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_faludcInf.c @@ -0,0 +1,679 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: _faludcInf.c /main/4 1996/10/15 10:28:13 drk $ */ +/* udcInf.c 1.4 - Fujitsu source for CDEnext 96/03/19 13:41:00 */ +/* + * Copyright 1995 by FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietry source code of FUJITSU LIMITED + * + * Modifier: Takanori Tateno FUJITSU LIMITED + * + */ +#include <stdio.h> +#include <stdint.h> +#include <locale.h> +#include "syncx.h" +#include "_fallibint.h" +#include "_fallcint.h" +#include "_fallcPubI.h" +#include "_fallcGeneric.h" +#include "_falomGeneric.h" + +/* + external symbols +*/ +extern FontData falread_EncodingInfo(); +extern int fal_get_codeset(); + +extern int fal_utyderror ; +extern int fal_utyerror ; + +extern unsigned long fal_utyerrno ; + +#define FAL_ERROR -1 + + +/* + UDC structure define +*/ +typedef struct _FalGlyphRegion { + unsigned long start; + unsigned long end; +} FalGlyphRegion ; + +/* + * "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu. + */ +static unsigned char getbyte(unsigned long code, int i) +{ + unsigned long byteL; + unsigned char byte; + byteL = code >> (8*(3-i)); + byte = (unsigned char)(0x000000ff & byteL); + return(byte); +} +/* + get codeset which described by charset_str and locale. + for examples ... + locale : ja_JP + charset_str : JISX0208.1983-0 +*/ + +fal_get_codeset( +char *locale, +char *charset_str, +int **codeset, +int *num_codeset) +{ + XLCdRec lcdrec; + XLCd lcd; + XLCdPublicRec xlcdp; + XPointer rdb; + int num = 0,count,num_ret=0,i,*ret; + char **value,buf[128],*ptr; + + + fal_utyderror = 0; + fal_utyerror = 0; + + if((locale == NULL) || (charset_str == NULL)){ + fal_utyerror = 5; + fal_utyderror = 1; + fal_utyerrno = 0x04 ; + return(FAL_ERROR); + } + if(codeset == NULL){ + fal_utyerror = 5; + fal_utyderror = 2; + fal_utyerrno = 0x04 ; + return(FAL_ERROR); + } + + /* create XLCd */ + xlcdp.pub.siname = locale; + lcdrec.core = (XLCdCore)&xlcdp; + lcd = &lcdrec; + /* create X RDB (X NLS DB) */ + rdb = _fallcCreateLocaleDataBase(lcd); + if(rdb == NULL){ + fal_utyerror = 1; + fal_utyerrno = 0x15 ; + return(FAL_ERROR); + } + + for(num=0;;num++){ + /* XLC_FONTSET */ + sprintf(buf, "fs%d.font.primary", num); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count < 1){ + break ; + } + for(i=0;i<count;i++){ + strcpy(buf,value[i]); + ptr = (char *)strchr(buf,(int)':'); + *ptr = 0; + if(!_fallcCompareISOLatin1(charset_str,buf)){ + num_ret += 1; + if(num_ret == 1){ + ret = (int *)Xmalloc(sizeof(int)); + } else { + ret = + (int *)Xrealloc(ret,num_ret*sizeof(int)); + } + if(ret == NULL){ + fal_utyerrno = 0x03 ; + return(FAL_ERROR); + } + ret[num_ret-1]=num; + break ; + } + } + } + if(num_ret == 0){ + *num_codeset = 0; + *codeset = NULL; + return (0xff); + } + + *num_codeset = num_ret; + *codeset = ret; + return 0; +} + +static Bool gi_to_vgi(unsigned long gi, unsigned long *vgi, FontScope scope) +{ + if(scope->shift_direction == (unsigned long)'+'){ + gi -= scope->shift; + } else { + gi += scope->shift; + } + if(gi >= scope->start && gi <= scope->end){ + *vgi = gi; + return(True); + } + return(False); +} + +static void shift_area(FalGlyphRegion *udc, FontScope scope) +{ + if(scope->shift_direction == (unsigned long)'+'){ + udc->start += scope->shift; + udc->end += scope->shift; + } else { + udc->start -= scope->shift; + udc->end -= scope->shift; + } +} + +/* + get UDC area with glyph index. + for examples ... + locale : ja_JP + charset_str : JISX0208.1983-0 +*/ +FalGetUDCGIArea( +char *locale, +int codeset, +char *charset_str, +FalGlyphRegion **gr, +int *num_gr) +{ + XLCdRec lcdrec; + XLCd lcd; + XLCdPublicRec xlcdp; + XPointer rdb; + FalGlyphRegion *udc; + int num = 0,count,num_ret=0; + int i,j,k; + char **value,buf[128],ptr; + FontData font_data; + + + fal_utyderror = 0; + fal_utyerror = 0; + fal_utyerrno = 0x00 ; + + if((locale == NULL) || (charset_str == NULL)){ + fal_utyerror = 5; + fal_utyderror = 1; + fal_utyerrno = 0x04; + fal_utyerrno |= (0x0b<<8) ; + return(FAL_ERROR); + } + if(gr == NULL){ + fal_utyerror = 5; + fal_utyderror = 1; + fal_utyerrno = 0x04; + fal_utyerrno |= (0x0b<<8) ; + return(FAL_ERROR); + } + if(num_gr == NULL){ + fal_utyerror = 5; + fal_utyderror = 2; + fal_utyerrno = 0x04; + fal_utyerrno |= (0x0b<<8) ; + return(FAL_ERROR); + } + + /* create XLCd */ + xlcdp.pub.siname = locale; + lcdrec.core = (XLCdCore)&xlcdp; + lcd = &lcdrec; + /* create X RDB (X NLS DB) */ + rdb = _fallcCreateLocaleDataBase(lcd); + if(rdb == NULL){ + fal_utyerror = 1; + fal_utyerrno = 0x15 ; + fal_utyerrno |= (0x0b<<8) ; + return(FAL_ERROR); + } + udc = NULL; + + /* XLC_FONTSET */ + sprintf(buf, "fs%d.charset.udc_area", codeset-1); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + udc = (FalGlyphRegion *)Xmalloc(count * sizeof(FalGlyphRegion)); + if(udc == NULL){ + fal_utyerrno = 0x03 ; + fal_utyerrno |= (0x0b<<8) ; + return(FAL_ERROR); + } + for(i=0;i<count;i++){ + sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end)); + } + } + + *num_gr = count; + + sprintf(buf, "fs%d.font.primary", codeset-1); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + font_data = falread_EncodingInfo(count,value); + for(i=0;i<count;i++){ + if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){ + for(j=0;j<(*num_gr);j++){ + for(k=0;k<font_data[i].scopes_num;k++){ + if(udc[j].start == font_data[i].scopes[k].start + && font_data[i].scopes[k].shift){ + shift_area(&udc[j],&(font_data[i].scopes[k])); + } + } + } + } + } + } + + *gr = udc; + return 0; +} + +/* + * Code convert wo tomonau UDC area no kakutoku + * GetUDCCPArea() / glyph_to_code() + * + */ + +int fal_gi_to_vgi( +XLCd lcd, +char *locale, +char *charset_str, +int codeset, +unsigned long gi, +unsigned long *vgi, +char *charsetname) +{ + FalGlyphRegion *udc; + int num = 0,count,num_ret=0; + int i,j,k; + char **value,buf[128],ptr; + FontData font_data = NULL; + + + sprintf(buf, "fs%d.charset.name", codeset-1); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + strcpy(charsetname,value[0]); + } + sprintf(buf, "fs%d.font.primary", codeset-1); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + font_data = falread_EncodingInfo(count,value); + for(i=0;i<count;i++){ + if( !_fallcCompareISOLatin1(font_data[i].name,charset_str)){ + for(k=0;k<font_data[i].scopes_num;k++){ + if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){ + XFree(font_data); + return(True); + } + } + } + } + } +/* + free_fontdata(font_data); +*/ + *vgi = gi; + XFree(font_data); + return(True); +} + +Bool falnon_standard(XLCd lcd, XlcCharSet charset) +{ + char buf[256]; + int count,i; + char **value; + if(charset->ct_sequence == NULL){ + return(False); + } + for(i=0;;i++){ + sprintf(buf, "csd%d.charset_name", i); + _fallcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count); + if(count > 0){ + if(!_fallcNCompareISOLatin1(value[0], + charset->name,strlen(value[0])) ){ + return(True); + } + } else { + return(False); + } + } +} + +void +falmake_none_standard(char *from, XlcCharSet charset, char *src) +{ + int name_len,seq_len,i; + name_len = 2 + strlen(charset->encoding_name) + 1; + seq_len = strlen(charset->ct_sequence); + strcpy(from,charset->ct_sequence); + from[seq_len] = name_len / 128 + 128; + from[seq_len+1] = name_len % 128 + 128; + strcpy(&from[seq_len + 2],charset->encoding_name); + from[seq_len+name_len-1] = 0x02; /* STX */ + strcpy(&from[seq_len + name_len],src); +} +int +fal_glyph_to_code( +char *locale, +char *charset_str, +int codeset, +unsigned long glyph_index, +unsigned long *codepoint) +{ + XLCd lcd; + unsigned char *from; int from_left; + unsigned char *to ; int to_left = 10; + unsigned char *dst; + unsigned char byte; + unsigned long from32[25]; + unsigned long to32[25]; + int i,j; + char tmp[256],charsetname[256],src[10]; + XlcConv conv; + XlcCharSet charset; + XPointer args[2]; + + from = (unsigned char *)from32; + to = (unsigned char *)to32; + dst = (unsigned char *)to32; + + memset(dst,0,25); + + lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale); + + fal_gi_to_vgi(lcd,locale,charset_str,codeset, + glyph_index,&glyph_index,charsetname); + + for(i=0,j=0;i<4;i++){ + byte = getbyte(glyph_index,i); + if(byte){ + src[j] = byte; + j ++; + } + } + src[j] = 0; + + + /* get charset */ +/* + sprintf(tmp,"%s%s",charset_str,":GL"); + charset_name = strdup(tmp); +*/ + charset = _fallcGetCharSet(charsetname); + if(charset == NULL){ + fal_utyerrno = 0x16 ; + return(FAL_ERROR); + } + /* make ct */ + if( falnon_standard(lcd,charset)) { + falmake_none_standard(from,charset,src); + } else if(charset->ct_sequence){ + snprintf((char *)from, sizeof(from32), "%s%s", charset->ct_sequence,src); + } else { + snprintf((char *)from, sizeof(from32), "%s", src); + } + /* compound text -> multi byte */ + conv = _fallcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte); + from_left = strlen((char *)from); + _fallcConvert(conv,(XPointer *)&from,&from_left, + (XPointer *)&to, &to_left,args,0); + _fallcCloseConverter(conv); + _fallcDestroyLC(lcd); + + *codepoint = 0; + for(i=0;dst[i];i++){ + *codepoint = ((*codepoint << 8) | dst[i]) ; + } + return(0); +} + +typedef struct _FalCodeRegion { + unsigned long start,end; +} FalCodeRegion ; + +int +FalGetUDCCPArea( +char *locale, +int codeset, +char *charset_str, +FalCodeRegion **cr, +int *num_cr) +{ + int i,num_gr,ret; + FalGlyphRegion *gr; + FalCodeRegion *crr; + + fal_utyerror = 0; + fal_utyderror = 0; + + if(cr == NULL){ + fal_utyerror = 5; + fal_utyderror = 1; + fal_utyerrno = 0x04 ; + fal_utyerrno |= (0x0a<<8) ; + return(FAL_ERROR); + } + if(num_cr == NULL){ + fal_utyerror = 5; + fal_utyderror = 2; + fal_utyerrno = 0x04 ; + fal_utyerrno |= (0x0a<<8) ; + return(FAL_ERROR); + } + + ret = FalGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr); + if(ret == FAL_ERROR){ + fal_utyerrno &= 0xff ; + fal_utyerrno |= (0x0a<<8) ; + return(ret); + } + + crr = (FalCodeRegion *)Xmalloc(num_gr*sizeof(FalCodeRegion)); + if(crr == NULL){ + Xfree(gr); + fal_utyerrno = 0x03 ; + fal_utyerrno |= (0x0a<<8) ; + return(FAL_ERROR); + } + + for(i=0;i<num_gr;i++){ + ret = fal_glyph_to_code(locale,charset_str,codeset, + gr[i].start, &(crr[i].start)); + if(ret == FAL_ERROR){ + fal_utyerrno |= (0x0a<<8) ; + Xfree(gr); + Xfree(crr); + return(ret); + } + ret = fal_glyph_to_code(locale,charset_str,codeset, + gr[i].end, &(crr[i].end)); + if(ret == FAL_ERROR){ + fal_utyerrno |= (0x0a<<8) ; + Xfree(gr); + Xfree(crr); + return(ret); + } + } + Xfree(gr); + *cr = crr; + *num_cr = num_gr; + return(0); +} + +/* + * code_to_glyph() + * + */ +typedef struct _FalGIInf { + char *charset_str; + unsigned long glyph_index; +} FalGIInf ; + +/* + * + * + */ +static Bool vgi_to_gi(unsigned long *gi, unsigned long vgi, FontScope scope) +{ + if(vgi >= scope->start && vgi <= scope->end){ + if(scope->shift_direction == (unsigned long)'+'){ + *gi = vgi + scope->shift; + } else { + *gi = vgi - scope->shift; + } + return(True); + } + return(False); +} +/* + * + * + */ +static Bool +fal_vgi_to_gi( +XLCd lcd, +char *locale, +unsigned long vglyph, +unsigned long *glyph, +XlcCharSet charset, +char *charsetname) +{ + int num = 0,count,num_ret=0; + int i,j,k; + char **value,buf[128],ptr; + FontData font_data = NULL; + CodeSet cs; + + + for(i=0;;i++){ + sprintf(buf, "fs%d.charset.name",i); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + if(!_fallcNCompareISOLatin1(charset->name,value[0], + strlen(charset->name))){ + break; + } + } else { + fal_utyerrno = 0x17 ; + return(False); + } + } +/* + sprintf(buf, "fs%d.charset.name", codeset-1); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + strcpy(charsetname,value[0]); + } +*/ + sprintf(buf, "fs%d.font.primary", i); + _fallcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count); + if(count > 0){ + font_data = falread_EncodingInfo(count,value); + for(i=0;i<count;i++){ + for(k=0;k<font_data[i].scopes_num;k++){ + if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){ + strcpy(charsetname,font_data[i].name); + XFree(font_data); + return(True); + } + } + } + } + *glyph = vglyph; + XFree(font_data); + return(True); +} +int +fal_code_to_glyph( +char *locale, +unsigned long codepoint, +FalGIInf **gi, +int *num_gi) +{ + XLCd lcd; + unsigned char *from; int from_left; + unsigned char *to ; int to_left = 10; + unsigned char *dst; + unsigned char byte; + unsigned int from32[25]; + unsigned int to32[25]; + int i,j; + char tmp[256],charsetname[256],src[10]; + XlcConv conv; + XlcCharSet charset; + XPointer args[2]; + unsigned long glyph,vglyph; + + from = (unsigned char *)from32; + to = (unsigned char *)to32; + dst = (unsigned char *)to32; + memset(dst,0,25); + + lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale); + + for(i=0,j=0;i<4;i++){ + byte = getbyte(codepoint,i); + if(byte){ + src[j] = byte; + j ++; + } + } + src[j] = 0; + snprintf((char *)from, sizeof(from32), "%s", src); + /* multi byte -> vgi */ + conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet); + from_left = strlen((char *)from); + args[0] = (XPointer) &charset; + _fallcConvert(conv,(XPointer *)&from,&from_left, + (XPointer *)&to, &to_left,args,1); + + /* vgi -> gi */ + vglyph = 0; + for(i=0;dst[i];i++){ + vglyph = ((vglyph << 8) | dst[i]) ; + } + if(fal_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname)==False){ + _fallcCloseConverter(conv); + _fallcDestroyLC(lcd); + *num_gi = 0; + return(0); + } + + _fallcCloseConverter(conv); + _fallcDestroyLC(lcd); + + *gi = (FalGIInf *)Xmalloc(sizeof(FalGIInf)); + if(*gi == NULL){ + fal_utyerrno = 0x03 ; + return(FAL_ERROR); + } + (*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1); + strcpy((*gi)->charset_str,charsetname); + (*gi)->glyph_index = glyph; + + *num_gi = 1; + return(0); +} diff --git a/cde/programs/dtudcfonted/libfal/_falutil.h b/cde/programs/dtudcfonted/libfal/_falutil.h new file mode 100644 index 000000000..e8e68a99a --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falutil.h @@ -0,0 +1,794 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Xutil.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:12 */ +/* $XConsortium: _falutil.h /main/1 1996/04/08 15:20:39 cde-fuj $ */ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef _XUTIL_H_ +#define _XUTIL_H_ + +/* You must include "syncx.h" before including this file */ + +/* + * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding + * value (x, y, width, height) was found in the parsed string. + */ +#define NoValue 0x0000 +#define XValue 0x0001 +#define YValue 0x0002 +#define WidthValue 0x0004 +#define HeightValue 0x0008 +#define AllValues 0x000F +#define XNegative 0x0010 +#define YNegative 0x0020 + +/* + * new version containing base_width, base_height, and win_gravity fields; + * used with WM_NORMAL_HINTS. + */ +typedef struct { + long flags; /* marks which fields in this structure are defined */ + int x, y; /* obsolete for new window mgrs, but clients */ + int width, height; /* should set so old wm's don't mess up */ + int min_width, min_height; + int max_width, max_height; + int width_inc, height_inc; + struct { + int x; /* numerator */ + int y; /* denominator */ + } min_aspect, max_aspect; + int base_width, base_height; /* added by ICCCM version 1 */ + int win_gravity; /* added by ICCCM version 1 */ +} XSizeHints; + +/* + * The next block of definitions are for window manager properties that + * clients and applications use for communication. + */ + +/* flags argument in size hints */ +#define USPosition (1L << 0) /* user specified x, y */ +#define USSize (1L << 1) /* user specified width, height */ + +#define PPosition (1L << 2) /* program specified position */ +#define PSize (1L << 3) /* program specified size */ +#define PMinSize (1L << 4) /* program specified minimum size */ +#define PMaxSize (1L << 5) /* program specified maximum size */ +#define PResizeInc (1L << 6) /* program specified resize increments */ +#define PAspect (1L << 7) /* program specified min and max aspect ratios */ +#define PBaseSize (1L << 8) /* program specified base for incrementing */ +#define PWinGravity (1L << 9) /* program specified window gravity */ + +/* obsolete */ +#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect) + + + +typedef struct { + long flags; /* marks which fields in this structure are defined */ + Bool input; /* does this application rely on the window manager to + get keyboard input? */ + int initial_state; /* see below */ + Pixmap icon_pixmap; /* pixmap to be used as icon */ + Window icon_window; /* window to be used as icon */ + int icon_x, icon_y; /* initial position of icon */ + Pixmap icon_mask; /* icon mask bitmap */ + XID window_group; /* id of related window group */ + /* this structure may be extended in the future */ +} XWMHints; + +/* definition for flags of XWMHints */ + +#define InputHint (1L << 0) +#define StateHint (1L << 1) +#define IconPixmapHint (1L << 2) +#define IconWindowHint (1L << 3) +#define IconPositionHint (1L << 4) +#define IconMaskHint (1L << 5) +#define WindowGroupHint (1L << 6) +#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \ +IconPositionHint|IconMaskHint|WindowGroupHint) +#define XUrgencyHint (1L << 8) + +/* definitions for initial window state */ +#define WithdrawnState 0 /* for windows that are not mapped */ +#define NormalState 1 /* most applications want to start this way */ +#define IconicState 3 /* application wants to start as an icon */ + +/* + * Obsolete states no longer defined by ICCCM + */ +#define DontCareState 0 /* don't know or care */ +#define ZoomState 2 /* application wants to start zoomed */ +#define InactiveState 4 /* application believes it is seldom used; */ + /* some wm's may put it on inactive menu */ + + +/* + * new structure for manipulating TEXT properties; used with WM_NAME, + * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND. + */ +typedef struct { + unsigned char *value; /* same as Property routines */ + Atom encoding; /* prop type */ + int format; /* prop data format: 8, 16, or 32 */ + unsigned long nitems; /* number of data items in value */ +} XTextProperty; + +#define XNoMemory -1 +#define XLocaleNotSupported -2 +#define XConverterNotFound -3 + +typedef enum { + XStringStyle, /* STRING */ + XCompoundTextStyle, /* COMPOUND_TEXT */ + XTextStyle, /* text in owner's encoding (current locale)*/ + XStdICCTextStyle /* STRING, else COMPOUND_TEXT */ +} XICCEncodingStyle; + +typedef struct { + int min_width, min_height; + int max_width, max_height; + int width_inc, height_inc; +} XIconSize; + +typedef struct { + char *res_name; + char *res_class; +} XClassHint; + +/* + * These macros are used to give some sugar to the image routines so that + * naive people are more comfortable with them. + */ +#define XDestroyImage(ximage) \ + ((*((ximage)->f.destroy_image))((ximage))) +#define XGetPixel(ximage, x, y) \ + ((*((ximage)->f.get_pixel))((ximage), (x), (y))) +#define XPutPixel(ximage, x, y, pixel) \ + ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel))) +#define XSubImage(ximage, x, y, width, height) \ + ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height))) +#define XAddPixel(ximage, value) \ + ((*((ximage)->f.add_pixel))((ximage), (value))) + +/* + * Compose sequence status structure, used in calling XLookupString. + */ +typedef struct _XComposeStatus { + XPointer compose_ptr; /* state table pointer */ + int chars_matched; /* match state */ +} XComposeStatus; + +/* + * Keysym macros, used on Keysyms to test for classes of symbols + */ +#define IsKeypadKey(keysym) \ + (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal)) + +#define IsPrivateKeypadKey(keysym) \ + (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) + +#define IsCursorKey(keysym) \ + (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select)) + +#define IsPFKey(keysym) \ + (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4)) + +#define IsFunctionKey(keysym) \ + (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35)) + +#define IsMiscFunctionKey(keysym) \ + (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break)) + +#define IsModifierKey(keysym) \ + ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \ + || ((KeySym)(keysym) == XK_Mode_switch) \ + || ((KeySym)(keysym) == XK_Num_Lock)) +/* + * opaque reference to Region data type + */ +typedef struct _XRegion *Region; + +/* Return values from XRectInRegion() */ + +#define RectangleOut 0 +#define RectangleIn 1 +#define RectanglePart 2 + + +/* + * Information used by the visual utility routines to find desired visual + * type from the many visuals a display may support. + */ + +typedef struct { + Visual *visual; + VisualID visualid; + int screen; + int depth; +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ */ +#else + int class; +#endif + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + int colormap_size; + int bits_per_rgb; +} XVisualInfo; + +#define VisualNoMask 0x0 +#define VisualIDMask 0x1 +#define VisualScreenMask 0x2 +#define VisualDepthMask 0x4 +#define VisualClassMask 0x8 +#define VisualRedMaskMask 0x10 +#define VisualGreenMaskMask 0x20 +#define VisualBlueMaskMask 0x40 +#define VisualColormapSizeMask 0x80 +#define VisualBitsPerRGBMask 0x100 +#define VisualAllMask 0x1FF + +/* + * This defines a window manager property that clients may use to + * share standard color maps of type RGB_COLOR_MAP: + */ +typedef struct { + Colormap colormap; + unsigned long red_max; + unsigned long red_mult; + unsigned long green_max; + unsigned long green_mult; + unsigned long blue_max; + unsigned long blue_mult; + unsigned long base_pixel; + VisualID visualid; /* added by ICCCM version 1 */ + XID killid; /* added by ICCCM version 1 */ +} XStandardColormap; + +#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */ + + +/* + * return codes for XReadBitmapFile and XWriteBitmapFile + */ +#define BitmapSuccess 0 +#define BitmapOpenFailed 1 +#define BitmapFileInvalid 2 +#define BitmapNoMemory 3 + +/**************************************************************** + * + * Context Management + * + ****************************************************************/ + + +/* Associative lookup table return codes */ + +#define XCSUCCESS 0 /* No error. */ +#define XCNOMEM 1 /* Out of memory */ +#define XCNOENT 2 /* No entry in table */ + +typedef int XContext; + +#define XUniqueContext() ((XContext) falrmUniqueQuark()) +#define XStringToContext(string) ((XContext) falrmStringToQuark(string)) + +_XFUNCPROTOBEGIN + +/* The following declarations are alphabetized. */ + +extern XClassHint *XAllocClassHint ( + void +); + +extern XIconSize *XAllocIconSize ( + void +); + +extern XSizeHints *XAllocSizeHints ( + void +); + +extern XStandardColormap *XAllocStandardColormap ( + void +); + +extern XWMHints *XAllocWMHints ( + void +); + +extern XClipBox( + Region /* r */, + XRectangle* /* rect_return */ +); + +extern Region XCreateRegion( + void +); + +extern char *falDefaultString( + void +); + +extern int XDeleteContext( + Display* /* display */, + XID /* rid */, + XContext /* context */ +); + +extern XDestroyRegion( + Region /* r */ +); + +extern XEmptyRegion( + Region /* r */ +); + +extern XEqualRegion( + Region /* r1 */, + Region /* r2 */ +); + +extern int XFindContext( + Display* /* display */, + XID /* rid */, + XContext /* context */, + XPointer* /* data_return */ +); + +extern Status XGetClassHint( + Display* /* display */, + Window /* w */, + XClassHint* /* class_hints_return */ +); + +extern Status XGetIconSizes( + Display* /* display */, + Window /* w */, + XIconSize** /* size_list_return */, + int* /* count_return */ +); + +extern Status XGetNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */ +); + +extern Status XGetRGBColormaps( + Display* /* display */, + Window /* w */, + XStandardColormap** /* stdcmap_return */, + int* /* count_return */, + Atom /* property */ +); + +extern Status XGetSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + Atom /* property */ +); + +extern Status XGetStandardColormap( + Display* /* display */, + Window /* w */, + XStandardColormap* /* colormap_return */, + Atom /* property */ +); + +extern Status XGetTextProperty( + Display* /* display */, + Window /* window */, + XTextProperty* /* text_prop_return */, + Atom /* property */ +); + +extern XVisualInfo *XGetVisualInfo( + Display* /* display */, + long /* vinfo_mask */, + XVisualInfo* /* vinfo_template */, + int* /* nitems_return */ +); + +extern Status XGetWMClientMachine( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern XWMHints *XGetWMHints( + Display* /* display */, + Window /* w */ +); + +extern Status XGetWMIconName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern Status XGetWMName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern Status XGetWMNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + long* /* supplied_return */ +); + +extern Status XGetWMSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + long* /* supplied_return */, + Atom /* property */ +); + +extern Status XGetZoomHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* zhints_return */ +); + +extern XIntersectRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern void XConvertCase( + KeySym /* sym */, + KeySym* /* lower */, + KeySym* /* upper */ +); + +extern int XLookupString( + XKeyEvent* /* event_struct */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + XComposeStatus* /* status_in_out */ +); + +extern Status XMatchVisualInfo( + Display* /* display */, + int /* screen */, + int /* depth */, + int /* class */, + XVisualInfo* /* vinfo_return */ +); + +extern XOffsetRegion( + Region /* r */, + int /* dx */, + int /* dy */ +); + +extern Bool XPointInRegion( + Region /* r */, + int /* x */, + int /* y */ +); + +extern Region XPolygonRegion( + XPoint* /* points */, + int /* n */, + int /* fill_rule */ +); + +extern int XRectInRegion( + Region /* r */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XSaveContext( + Display* /* display */, + XID /* rid */, + XContext /* context */, + const char* /* data */ +); + +extern XSetClassHint( + Display* /* display */, + Window /* w */, + XClassHint* /* class_hints */ +); + +extern XSetIconSizes( + Display* /* display */, + Window /* w */, + XIconSize* /* size_list */, + int /* count */ +); + +extern XSetNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */ +); + +extern void XSetRGBColormaps( + Display* /* display */, + Window /* w */, + XStandardColormap* /* stdcmaps */, + int /* count */, + Atom /* property */ +); + +extern XSetSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */, + Atom /* property */ +); + +extern XSetStandardProperties( + Display* /* display */, + Window /* w */, + const char* /* window_name */, + const char* /* icon_name */, + Pixmap /* icon_pixmap */, + char** /* argv */, + int /* argc */, + XSizeHints* /* hints */ +); + +extern void XSetTextProperty( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */, + Atom /* property */ +); + +extern void XSetWMClientMachine( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern XSetWMHints( + Display* /* display */, + Window /* w */, + XWMHints* /* wm_hints */ +); + +extern void XSetWMIconName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern void XSetWMName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern void XSetWMNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */ +); + +extern void XSetWMProperties( + Display* /* display */, + Window /* w */, + XTextProperty* /* window_name */, + XTextProperty* /* icon_name */, + char** /* argv */, + int /* argc */, + XSizeHints* /* normal_hints */, + XWMHints* /* wm_hints */, + XClassHint* /* class_hints */ +); + +extern void XmbSetWMProperties( + Display* /* display */, + Window /* w */, + const char* /* window_name */, + const char* /* icon_name */, + char** /* argv */, + int /* argc */, + XSizeHints* /* normal_hints */, + XWMHints* /* wm_hints */, + XClassHint* /* class_hints */ +); + +extern void XSetWMSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */, + Atom /* property */ +); + +extern XSetRegion( + Display* /* display */, + GC /* gc */, + Region /* r */ +); + +extern void XSetStandardColormap( + Display* /* display */, + Window /* w */, + XStandardColormap* /* colormap */, + Atom /* property */ +); + +extern XSetZoomHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* zhints */ +); + +extern XShrinkRegion( + Region /* r */, + int /* dx */, + int /* dy */ +); + +extern Status XStringListToTextProperty( + char** /* list */, + int /* count */, + XTextProperty* /* text_prop_return */ +); + +extern XSubtractRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern int falmbTextListToTextProperty( + Display* /* display */, + char** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop_return */ +); + +extern int falwcTextListToTextProperty( + Display* /* display */, + wchar_t** /* list */, + int /* count */, + XICCEncodingStyle /* style */, + XTextProperty* /* text_prop_return */ +); + +extern void falwcFreeStringList( + wchar_t** /* list */ +); + +extern Status XTextPropertyToStringList( + XTextProperty* /* text_prop */, + char*** /* list_return */, + int* /* count_return */ +); + +extern int falmbTextPropertyToTextList( + Display* /* display */, + XTextProperty* /* text_prop */, + char*** /* list_return */, + int* /* count_return */ +); + +extern int falwcTextPropertyToTextList( + Display* /* display */, + XTextProperty* /* text_prop */, + wchar_t*** /* list_return */, + int* /* count_return */ +); + +extern XUnionRectWithRegion( + XRectangle* /* rectangle */, + Region /* src_region */, + Region /* dest_region_return */ +); + +extern XUnionRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern int XWMGeometry( + Display* /* display */, + int /* screen_number */, + const char* /* user_geometry */, + const char* /* default_geometry */, + unsigned int /* border_width */, + XSizeHints* /* hints */, + int* /* x_return */, + int* /* y_return */, + int* /* width_return */, + int* /* height_return */, + int* /* gravity_return */ +); + +extern XXorRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +_XFUNCPROTOEND + +#endif /* _XUTIL_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/_falutilbitmap.c b/cde/programs/dtudcfonted/libfal/_falutilbitmap.c new file mode 100644 index 000000000..cd5066170 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falutilbitmap.c @@ -0,0 +1,207 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: _falutilbitmap.c /main/1 1996/04/08 15:22:19 cde-fuj $ */ + +/* + +Copyright (c) 1990, 1994 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +*/ + +/* + * Author: Keith Packard, MIT X Consortium + */ + +/* Utility functions for reformating font bitmaps */ + +static unsigned char _reverse_byte[0x100] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +/* + * Invert bit order within each BYTE of an array. + */ +void +BitOrderInvert(unsigned char *buf, int nbytes) +{ + unsigned char *rev = _reverse_byte; + + for (; --nbytes >= 0; buf++) + *buf = rev[*buf]; +} + +/* + * Invert byte order within each 16-bits of an array. + */ +void +TwoByteSwap(unsigned char *buf, int nbytes) +{ + unsigned char c; + + for (; nbytes > 0; nbytes -= 2, buf += 2) + { + c = buf[0]; + buf[0] = buf[1]; + buf[1] = c; + } +} + +/* + * Invert byte order within each 32-bits of an array. + */ +void +FourByteSwap(unsigned char *buf, int nbytes) +{ + unsigned char c; + + for (; nbytes > 0; nbytes -= 4, buf += 4) + { + c = buf[0]; + buf[0] = buf[3]; + buf[3] = c; + c = buf[1]; + buf[1] = buf[2]; + buf[2] = c; + } +} + +/* + * Repad a bitmap + */ + +int +RepadBitmap ( + char *pSrc, + char *pDst, + unsigned srcPad, + unsigned dstPad, + int width, + int height) +{ + int srcWidthBytes,dstWidthBytes; + int row,col; + char *pTmpSrc,*pTmpDst; + + switch (srcPad) { + case 1: + srcWidthBytes = (width+7)>>3; + break; + case 2: + srcWidthBytes = ((width+15)>>4)<<1; + break; + case 4: + srcWidthBytes = ((width+31)>>5)<<2; + break; + case 8: + srcWidthBytes = ((width+63)>>6)<<3; + break; + default: + return 0; + } + switch (dstPad) { + case 1: + dstWidthBytes = (width+7)>>3; + break; + case 2: + dstWidthBytes = ((width+15)>>4)<<1; + break; + case 4: + dstWidthBytes = ((width+31)>>5)<<2; + break; + case 8: + dstWidthBytes = ((width+63)>>6)<<3; + break; + default: + return 0; + } + + width = srcWidthBytes; + if (width > dstWidthBytes) + width = dstWidthBytes; + pTmpSrc= pSrc; + pTmpDst= pDst; + for (row = 0; row < height; row++) + { + for (col = 0; col < width; col++) + *pTmpDst++ = *pTmpSrc++; + while (col < dstWidthBytes) + { + *pTmpDst++ = '\0'; + col++; + } + pTmpSrc += srcWidthBytes - width; + } + return dstWidthBytes * height; +} diff --git a/cde/programs/dtudcfonted/libfal/_falvarargs.h b/cde/programs/dtudcfonted/libfal/_falvarargs.h new file mode 100644 index 000000000..5b05b47a6 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/_falvarargs.h @@ -0,0 +1,90 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* Xvarargs.h 1.1 - Fujitsu source for CDEnext 95/11/06 20:32:13 */ +/* $XConsortium: _falvarargs.h /main/1 1996/04/08 15:22:42 cde-fuj $ */ +/* + +Copyright (c) 1985, 1986, 1987, 1988, 1989 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +#ifndef _XVARARGS_H_ +#define _XVARARGS_H_ + +#ifdef __HIGHC__ +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *va_list; + +/* Amount of space required in an argument list for an arg of type TYPE. + TYPE may alternatively be an expression whose type is used. */ + +#define __va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#define va_start(AP, LASTARG) \ + (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) + +#define va_end(AP) + +#define va_arg(AP, TYPE) \ + (AP += __va_rounded_size (TYPE), \ + *((TYPE *) (AP - __va_rounded_size (TYPE)))) + +#endif /* _STDARG_H */ + +#define Va_start(a,b) va_start(a,b) + +#else /* !__HIGHC__ */ + +# include <stdarg.h> +# define Va_start(a,b) va_start(a,b) + +#endif /* __HIGHC__ */ + +#endif /* _XVARARGS_H_ */ diff --git a/cde/programs/dtudcfonted/libfal/falfont.c b/cde/programs/dtudcfonted/libfal/falfont.c new file mode 100644 index 000000000..74501fae4 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/falfont.c @@ -0,0 +1,3082 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: falfont.c /main/8 1996/07/04 02:35:37 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <signal.h> +#include <locale.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <sys/mman.h> +#include <errno.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <X11/Intrinsic.h> + +#include "FaLib.h" +#include "falfont.h" +#include "udcutil.h" + +#define MKFONTLIST (1<<1) +#define SRCHFNAME (1<<2) +#define FONTOFID (1<<3) + +typedef struct _FontIDInfo { + FalFontID fid ; + int cd_set ; + int dspcode ; + int islock ; +} FontIDInfo ; + +typedef struct _MngFontID { + int num ; + FontIDInfo **finf ; +} MngFontID ; + +/*** structures for UDC fontpath ***/ +static FalFontPath orgn = { 0, NULL }; /* for libfal */ +static FalFontPath copy = { 0, NULL }; /* report to the user */ +static FalFontPath wpath = { 0, NULL }; /* for libfal */ + +/***** Variables for notice kind of error *****/ +int fal_utyerror; +int fal_utyderror; +int fal_utyexists; +unsigned long fal_utyerrno ; +char fal_err_file[ FAL_LINE_MAX+1 ] ; + +char fal_err_file_buf[ sizeof(fal_err_file) ] ; + +#define fal_seterrcode( uty, der, errno, func ) { \ + fal_utyerror = (uty); \ + fal_utyderror = (der) ; \ + fal_utyerrno = (errno) ; \ + fal_utyerrno |= ((func)<<8) ; \ +} + +/***** flags *****/ +static int execDefined ; +static int execUndefined ; +static int IsDefaultPath = FALSE ; +static MngFontID mngfid = { 0, NULL } ; +static int tmp_codeset = 0 ; +static char *fal_locale = NULL ; +static char *charset_str_buf = NULL ; +static int *codeset_list_sav = NULL ; +static int codeset_list_num = 0 ; + +/* declaration of inner functions */ +char *fal_get_base_name(); + +static FILE *open_fonts_list() ; +static int falGetGlyph() ; +static int falGetCharIndex() ; +static int falZoom() ; +static int exline() ; +static char falGetMask() ; +static int chk_key_str() ; +static int fal_make_fontlist() ; +static int fal_sort_fontlist() ; +static int set_default_path() ; +static int cpy_default_path() ; +static int comp_default_path() ; +static int fal_clear_font_path() ; +static int set_font_pathlist() ; + +static int fal_split_data() ; +static int fal_clear_data() ; +static int CR_to_NULL() ; +static int fal_cmp_data() ; +static int new_target() ; + +int set_struct() ; +int fal_eq_data() ; + +void set_errfile_str() ; + +static int fal_init() ; +static int fal_add_fidinf() ; +static int fal_read_fidinf() ; +static int fal_del_fidinf() ; +static int fal_conv_code_to_glyph() ; +static int fal_conv_glyph_to_code() ; +static int falReadFontInfoLists() ; +static int fal_get_def_fontdata() ; +static int falgetfontlist() ; +static int fal_get_undef_fontdata() ; +static void clear_charset_info() ; +static int make_default_path() ; +static int file_lock() ; +static int file_unlock() ; +static int is_lock() ; + +extern int falReadFontProp() ; +extern int falReadGpfProp() ; +extern int falInitReadPcfProp() ; +extern int fal_get_codeset() ; +extern int falInitReadPcf() ; +extern void falGetPcfGSize() ; +extern int falPcfGlyph() ; +extern int fal_code_to_glyph() ; +extern int fal_glyph_to_code() ; + + + +static int +fal_init(void) +{ + memset( fal_err_file, '\0', sizeof(fal_err_file) ) ; + memset( fal_err_file_buf, '\0', sizeof(fal_err_file_buf) ) ; + + if ( !fal_locale ){ + char *lcl ; + if( (lcl = (char *)getenv( "LANG" )) == NULL ){ + lcl = "C" ; + } + if( (fal_locale = (char *)strdup( lcl )) == NULL ){ + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + } + return 0 ; +} + +void +set_errfile_str(char *obuf, char *ibuf) +{ + char *sp ; + + if( (strlen(ibuf)+1) > sizeof(fal_err_file) ){ + sp = ibuf ; + sp += ((strlen(ibuf)+1) - sizeof(fal_err_file)) ; + strcpy( obuf, sp ) ; + }else{ + strcpy( obuf, ibuf ) ; + } +} + +/* + * open a fontfile by "RDONLY" + */ +FalFontID +FalOpenFont(char *file, int protect_key_data, int codeset) +{ + FalFontID __FalOpenFont(); + + return __FalOpenFont( file, protect_key_data, codeset, 0 ); +} + +/* + * open a fontfile by "RDWR" + * + * + * lock flag + * 1: ON --- open mode "RDWR" + * 0: OFF -- for "FalOpenFont()" + */ +FalFontID +__FalOpenFont(char *file, int protect_key_data, int codeset, int lockflag) +{ + int fd ; + char *buf; + char *openfontfile; + struct stat st; + Oak_FontInf *finf; + + while(1){ + + if ( !(openfontfile = (char *)malloc( strlen( file ) + 1 )) ) { + fal_seterrcode( _FAL_MALOC_ER, 0, + FAL_ERR_MALLOC , FAL_FUNCNUM_OPNFNT ) ; + return (FalFontID)FAL_ERROR; + } + strcpy( openfontfile, file ); + + /* read a condition of a fontfile */ + if ( stat( openfontfile, &st ) < 0 ) { + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_STAT_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_STAT ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return (FalFontID)FAL_ERROR; + } + + CHK_PROTECT_KEY( protect_key_data, openfontfile, fal_utyerror, fal_utyderror ) ; + + if ( st.st_size < sizeof( FontInfoRec ) ) { + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_FONT ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return (FalFontID)FAL_ERROR; + } + + /* open a fontfile */ + if ( lockflag == 1 ) { + int ret ; + if ( (fd = open( openfontfile, O_RDWR )) < 0 ) { + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_OPN ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return (FalFontID)FAL_ERROR; + } + ret = is_lock( fd ) ; + if( ret != 0 ){ + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + close( fd ); + return (FalFontID)FAL_ERROR; + } + } else { + if ( (fd = open( openfontfile, O_RDONLY)) < 0 ) { + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_OPN ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return (FalFontID)FAL_ERROR; + } + } + + /* read a fontfile */ + if ( !(finf = ( Oak_FontInf * )malloc(sizeof( Oak_FontInf ) )) ) { + free( openfontfile ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + close( fd ); + return (FalFontID)FAL_ERROR; + } + + +#if defined( SVR4 ) + /* use "mmap()" */ + buf = (char *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + if ( buf != (char *)-1 ) { + /* if "mmap" is normal end */ + if ( lockflag == 0 ) { + close( fd ); + } + finf->ismmap = TRUE; + finf->fsize = st.st_size; + } else { +#endif + /* if "mmap" is abnormal end , try "read()" */ + finf->ismmap = FALSE; + if ( !(buf = (char *)malloc(st.st_size)) ) { + free( openfontfile ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + free( finf ); + close( fd ); + return (FalFontID)FAL_ERROR; + } + if ( read(fd, buf, st.st_size) != st.st_size ) { + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + fal_utyerror = _FAL_READ_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_RD ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + free( finf ); + free( buf ); + close( fd ); + return (FalFontID)FAL_ERROR; + } +#if defined( SVR4 ) + } +#endif + + if ( !(finf->fname = (char *)strdup( openfontfile )) ) { + fal_seterrcode( _FAL_MALOC_ER, 0, + FAL_ERR_MALLOC , FAL_FUNCNUM_OPNFNT ) ; + free( openfontfile ); + free( finf ); + free( buf ); + close( fd ); + return (FalFontID)FAL_ERROR; + } + + /* case of a pcf font */ + if ( strcmp( FILE_SUFFIX( openfontfile ), PCFSUFFIX ) == 0 ) { + if ( falInitReadPcf( &finf->pcfinf, buf ) ) { + fal_utyerror = _FAL_PKEY_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_FONT ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + break; + } + finf->isFef = FALSE; + finf->isPcf = TRUE; + finf->pFinf = &finf->pcfinf.info; + } else { + FAL_GET_SNF_HEADER( buf, protect_key_data, fal_utyerror, fal_utyderror, fd, finf, openfontfile ) ; + } + finf->buf = buf; + + if ( finf->isFef ){ + finf->pCinf + = (CharInfoPtr)( (char *)finf->pFinf + + sizeof( FontInfoRec ) ); + finf->pGlyphs + = (unsigned char *)((char *)finf->pCinf + + (sizeof(CharInfoRec) * GETNUMCHARS(finf->pFinf))); + finf->width + = finf->pFinf->maxbounds.rightSideBearing + - finf->pFinf->maxbounds.leftSideBearing; + finf->height + = finf->pFinf->maxbounds.ascent + + finf->pFinf->maxbounds.descent; + } else if ( finf->isPcf ) { + finf->pCinf = NULL; + finf->pGlyphs = NULL; + falGetPcfGSize( &finf->pcfinf, &finf->width, &finf->height); + } else { + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_FONT ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + break; + } + + finf->start = (finf->pFinf->firstRow << 8) | finf->pFinf->firstCol; + finf->end = (finf->pFinf->lastRow << 8) | finf->pFinf->lastCol; + + finf->fd = fd; + finf->sptnBufL = 0; + finf->sptnBuf = (char *)0; + finf->dptnBufL = 0; + finf->dptnBuf = (char *)0; + finf->dbufL = 0; + finf->dbuf = (char *)0; + + finf->sptnBufL = ((finf->width + 7) / 8) * (finf->height); + finf->sptnBuf = (char *)malloc(finf->sptnBufL); + if ( finf->sptnBuf == NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + break; + } + + /* Save font information */ + if( fal_add_fidinf( (FalFontID)finf, codeset, + ((tmp_codeset)?tmp_codeset:codeset), + lockflag ) == FAL_ERROR ) + { + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + break; + } + + /* Lock the font file */ + if ( lockflag == 1 ) { + if ( file_lock( finf->fd ) == FAL_ERROR ) { + set_errfile_str( fal_err_file, openfontfile ) ; + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + break; + } + } + free( openfontfile ); + + return( ( FalFontID ) finf ); + + } + +#if defined( SVR4 ) + if ( finf->ismmap == TRUE ) { + munmap( buf, finf->fsize ); + } else { + free( buf ); + close( fd ); + } +#else + free( buf ); + close( fd ); +#endif + set_errfile_str( fal_err_file, openfontfile ) ; + free( openfontfile ); + free( finf->fname ); + finf->fname = NULL; + free(finf); + + return (FalFontID)FAL_ERROR; +} + + + +FalCloseFont(FalFontID fid) +{ + int __FalCloseFont(); + FontIDInfo fontid_inf ; + + if( fal_read_fidinf( fid, &fontid_inf ) == FAL_ERROR ) { + fal_utyerrno |= (FAL_FUNCNUM_CLSFNT<<8) ; + return FAL_ERROR; + } + + return __FalCloseFont( fid, fontid_inf.islock ); +} + + +/* + * close a fontfile + * + * + * lock flag + * 1: ON --- open a font by "RDWR" mode + * 0: OFF -- for "FalOpenFont()" + */ +__FalCloseFont(FalFontID fid, int lockflag) +{ + Oak_FontInf *finf; + + finf = ( Oak_FontInf * )fid; + + if ( finf == NULL ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_CLSFNT<<8) ; + return FAL_ERROR; + } + + set_errfile_str( fal_err_file_buf, finf->fname ) ; + free( finf->fname ); + if ( finf->buf != NULL ) { +#if defined( SVR4 ) + if ( finf->ismmap == TRUE ) { + munmap( finf->buf, finf->fsize ); + if ( lockflag == 1 ) { + close( finf->fd ); + } + } else { + free( finf->buf ); + close( finf->fd ); + } +#else + free( finf->buf ); + close( finf->fd ); +#endif + + free( finf->sptnBuf ); + free( finf->dptnBuf ); + free( finf->dbuf ); + + free ( finf ); + } + if ( lockflag == 1 ) { + if ( file_unlock( finf->fd ) == FAL_ERROR ) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerrno |= (FAL_FUNCNUM_CLSFNT<<8) ; + return FAL_ERROR; + } + } + + if ( fal_del_fidinf( fid ) == FAL_ERROR ) { + fal_utyerrno |= (FAL_FUNCNUM_CLSFNT<<8) ; + return FAL_ERROR; + } + + return _FAL_OK; +} + +FalQueryFont(FalFontID fid, FalFontinfo *fontinfo) +{ + Oak_FontInf *finf; + unsigned int inner_start, inner_end ; + FontIDInfo fontid_inf ; + + if( fal_read_fidinf( fid, &fontid_inf ) == FAL_ERROR ){ + fal_utyerrno |= (FAL_FUNCNUM_QRY<<8) ; + return FAL_ERROR; + } + finf = ( Oak_FontInf * )fid; + if ( finf == NULL || fontinfo == NULL ) { + fal_utyerror = _FAL_PARM_ER; + if (finf == NULL) { + fal_utyderror = _FAL_Q_P_FINF_DER; + } else { + fal_utyderror = _FAL_Q_P_FONT_DER; + } + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_QRY<<8) ; + return FAL_ERROR; + } + + fontinfo->width = (int)finf->width; + fontinfo->height = (int)finf->height; + + if( (fal_conv_glyph_to_code( finf, fontid_inf.dspcode, + fontid_inf.cd_set, finf->start, &inner_start ) == FAL_ERROR ) || + (fal_conv_glyph_to_code( finf, fontid_inf.dspcode, + fontid_inf.cd_set, finf->end, &inner_end ) == FAL_ERROR )) + { + fal_utyerrno |= (FAL_FUNCNUM_QRY<<8) ; + return FAL_ERROR; + } + + fontinfo->top = inner_start ; + fontinfo->bottom = inner_end ; + + return _FAL_OK; +} + +char * +FalReadFont( + FalFontID fid, + int code, + int width, + int height ) +{ + Oak_FontInf *finf; + int zoom_on ; + char *toglyph; + int ptnBsize; + unsigned int inner_code; /* an inside code of a file */ + + finf = ( Oak_FontInf * )fid; + + if ( finf == NULL ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = _FAL_R_P_FINF_DER; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)FAL_ERROR; + } + if (width < 0) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = _FAL_R_P_W_DER; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)FAL_ERROR; + } + if (height < 0) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = _FAL_R_P_H_DER; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)FAL_ERROR; + } + + if (width == 0) { + width = finf->width; + } + if (height == 0) { + height = finf->height; + } + if ( (width != finf->width) || (height != finf->height) ) { + zoom_on = TRUE; + } else { + zoom_on = FALSE; + } + + memset(finf->sptnBuf, 0, finf->sptnBufL); + + if( fal_conv_code_to_glyph( fid, code, &inner_code ) == FAL_ERROR ) { + fal_utyexists = 1; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)0; + } + + if ( finf->isPcf) { + /* case of a pcf font */ + falPcfGlyph( finf->sptnBuf, finf, inner_code ); + } else { + /* case of a snf font */ + falGetGlyph( finf->sptnBuf, finf, inner_code ); + } + if ( zoom_on == TRUE ) { + ptnBsize = ((width + 7)/8)*height; + if ( ptnBsize > finf->dptnBufL ) { + if ( finf->dptnBuf == NULL ) { + toglyph = (char *)malloc( ptnBsize ); + } else { + toglyph = (char *)realloc( finf->dptnBuf, ptnBsize ); + } + if ( toglyph == NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)FAL_ERROR; + } + finf->dptnBufL = ptnBsize; + finf->dptnBuf = toglyph; + } + ptnBsize = (width + 7) / 8; + if ( ptnBsize > finf->dbufL ) { + if ( finf->dbuf == NULL ) { + toglyph = (char *)malloc( ptnBsize ); + } else { + toglyph = (char *)realloc( finf->dbuf, ptnBsize ); + } + if ( toglyph == NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_RDFNT<<8) ; + return (char *)FAL_ERROR; + } + finf->dbufL = ptnBsize; + finf->dbuf = toglyph; + } + falZoom( + finf->dptnBuf, finf->sptnBuf, + finf->width, finf->height, width, height, finf->dbuf + ); + return( finf->dptnBuf ); + } else { + return finf->sptnBuf; + } +} + +static +falGetGlyph(char *glyph, Oak_FontInf *finf, int code) +{ + int in_dwidth, out_dwidth, ix, i, j; + char *glyph_p, *inp, p_mask, falGetMask(); + CharInfoPtr CharInfP; + int codeRow, codeCol; + unsigned int inner_code; /* an inside code of a file */ + + inner_code = code; + codeCol = inner_code & 0xff; /* a lower byte of an inside code */ + codeRow = (inner_code >> 8) & 0xff; /* a upper byte of a code */ + + /* code check */ + if ( + ((code < finf->start) || (code > finf->end)) || + ((codeCol < finf->pFinf->firstCol) || + (codeCol > finf->pFinf->lastCol)) || + ((codeRow < finf->pFinf->firstRow) || + (codeRow > finf->pFinf->lastRow)) + ) { + fal_utyexists = 1; + return 0; + } + + in_dwidth + = (finf->width + SNF_BOUND - 1) + / SNF_BOUND * (SNF_BOUND / 8); + out_dwidth = (finf->width + 7) / 8; + + p_mask = falGetMask( finf->width ); + + glyph_p = (char *)finf->pGlyphs; + for ( i = 0; i < finf->height; i++ ) { + inp = glyph_p + ( in_dwidth * i ); + for ( j = 0; j < out_dwidth-1; j++ ) { + *glyph++ = *inp++; + } + *glyph++ = *inp++ & p_mask; + } + return 0; +} + +static +falGetCharIndex(Oak_FontInf *finf, int code) /* an inside code of a file */ +{ + int nColperRow, nRow, nCol; + + nColperRow = finf->pFinf->lastCol - finf->pFinf->firstCol + 1; + nRow = ((code >> 8) & 0xff) - finf->pFinf->firstRow; + nCol = (code & 0xff) - finf->pFinf->firstCol; + + return ( nRow * nColperRow + nCol ); +} + +static +falZoom(char *dmem, char *smem, int sw, int sh, int dw, int dh, char *dbuf) +{ + int swidth = (sw + 7) / 8; + int dwidth = (dw + 7) / 8; + int i, lcnt = 0; + char *sp, *dp; + + sp = smem; + dp = dmem; + for ( i=0; i < sh; i++ ) { + lcnt += dh; + if ( lcnt >= sh ) { + exline( sp, dbuf, sw, dw ); + sp += swidth; + lcnt -= sh; + memcpy( dp, dbuf, dwidth ); + dp += dwidth; + for ( ; lcnt >= sh; lcnt -= sh ) { + memcpy( dp, dbuf, dwidth ); + dp += dwidth; + } + } else { + sp += swidth; + } + } + return 0; +} + +static +exline(char *sp, char *dbuf, int sw, int dw) +{ + int i, bit, sval, dval, dcnt, bcnt; + + bcnt = dval = 0; + dcnt = 8; + + for ( i = 0; i < sw; i++ ) { + if ( i % 8 == 0 ) { + sval = *sp++; + } + bit = ( (sval & 0x80) ? 1 : 0 ); + sval <<= 1; + for ( bcnt += dw; bcnt >= sw; bcnt -= sw ) { + dval = ( dval << 1 ) | bit; + if ( --dcnt == 0 ) { + *dbuf++ = (char)dval; + dval = 0; + dcnt = 8; + } + } + } + if ( dcnt != 8 ) { + dval <<= dcnt; + *dbuf = (char)dval; + } + return 0; +} + +static unsigned char _Fal_Mask_Tab[8] = { + 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe +}; + +static char +falGetMask(int width) +{ + int ix = width % 8; + return _Fal_Mask_Tab[ix]; +} + + +/* a difinition of a style */ +static FalFontDB fal_db_style[] = { + { FAL_FONT_MINCHO, FAL_FONT_STR_MINCHO }, + { FAL_FONT_GOTHIC, FAL_FONT_STR_GOTHIC }, + { FAL_FONT_MARU_GOTHIC, FAL_FONT_STR_MARU_GOTHIC }, + { FAL_FONT_TEXTBOOK, FAL_FONT_STR_TEXTBOOK }, + { FAL_FONT_BRASH_GYOU, FAL_FONT_STR_BRASH_GYOU }, + { FAL_FONT_BRASH_KAI, FAL_FONT_STR_BRASH_KAI }, + { FAL_FONT_HANDWRITING, FAL_FONT_STR_HANDWRITING }, + { FAL_FONT_UNKNOWN, ""} +}; + +/* a difinition of a shape */ +static FalFontDB fal_db_shape[] = { + { FAL_FONT_ZENKAKU, FAL_FONT_STR_ZENKAKU }, + { FAL_FONT_HANKAKU, FAL_FONT_STR_HANKAKU }, + { FAL_FONT_QUARTER, FAL_FONT_STR_QUARTER }, + { FAL_FONT_UNKNOWN, ""} +}; + +FAL_DB_OPTION ; + +/*********************************************************/ +/* make a font information list and carry to user */ +/*********************************************************/ + +int +FalGetFontList( + FalFontData *key_data, /* a structure of a searching information */ + int mask, /* a mask */ + FalFontDataList **list_ret ) /* maked a address of a structure */ +{ + + FalFontDataList *fls; /* a pointer of a structure of "FalFontDataList()" */ + + /* clear an error's data */ + fal_utyerror = 0; + fal_utyderror = 0; + fal_utyerrno = 0 ; + + /* change mode */ + SET_EXECDEFAULT( mask, execDefined, execUndefined ) ; + + /* interface check */ + if ( list_ret == NULL ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = _FAL_L_P_LST_DER; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR ; + } + + /* character check */ + if ( chk_key_str( key_data, mask ) == FAL_ERROR ) { + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR; + } + + /* error check */ + if ( orgn.path == NULL ) { + if ( set_default_path() == FAL_ERROR ) { + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR ; + } + } + + /* make an structure of "FalFontDataList()" */ + if ((fls = (FalFontDataList *)malloc( sizeof( FalFontDataList ))) == NULL){ + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR ; + } + + /* inital set for search */ + fls->num = 0; + fls->list = NULL; + + /* make font infomation list */ + if ( fal_make_fontlist( fls, key_data, mask ) == FAL_ERROR) { + switch( fal_utyerror ) { + case _FAL_FLST_ER : + case _FAL_DATA_OPEN_ER : + fal_utyderror = 1; + } + FalFreeFontList( fls ); + fal_utyerrno &= 0xff; + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR; + } + /* sort element of font infomation list */ + if( fal_sort_fontlist( fls ) == FAL_ERROR ) { + FalFreeFontList( fls ); + fal_utyerrno &= 0xff; + fal_utyerrno |= (FAL_FUNCNUM_GFLST<<8) ; + return FAL_ERROR ; + } + + *list_ret = fls; + return 0; +} + + + +/***********************************************************************/ +/* search a character "key" of a structure */ +/***********************************************************************/ + +static int +chk_key_str( +FalFontData *key, /* a structure of saerching information */ +int mask) /* a mask */ +{ + int flg = 0; + + if( key == NULL ) { + return 0 ; + } + + /* check a character of setting a mask */ + /* xlfd name */ + if ((mask & FAL_FONT_MASK_XLFDNAME) && (key->xlfdname == NULL)) { + flg++; + } + /* style */ + if ((mask & FAL_FONT_MASK_STYLE_NAME) && (key->style.name == NULL)) { + flg++; + } + /* shape */ + if ((mask & FAL_FONT_MASK_SHAPE_NAME) && (key->shape.name == NULL)) { + flg++; + } + CHK_KEY_STR_OPTION( mask, key, flg ) ; + /* error check */ + if ( flg ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyderror = _FAL_L_P_KEY_DER; + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR ; + } + return 0 ; +} + + +/***************************************************************/ +/* read a font information and add a list or make a list */ +/***************************************************************/ + + +static int +fal_make_fontlist( +FalFontDataList *fls, /* a pointer of a structure of a font information list */ +FalFontData *key, /* a structure of searching information */ +int mask) /* a mask for a saerch */ +{ + return falReadFontInfoLists(MKFONTLIST, + key, mask, fls, + NULL, NULL, + NULL, NULL) ; +} + + +/**************************************************/ +/* free a structure of "FalFontDataList()" */ +/**************************************************/ + +int +FalFreeFontList(FalFontDataList *list) +{ + int i; + + /* parametter check */ + if ( list == NULL ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_FRFLST<<8) ; + return FAL_ERROR; + } + /* free a structure's array of "FalFontData()" */ + if ( list->list != NULL ) { + for ( i = 0; i < list->num; i++ ) { + /* free a structure's character of "FalFontData()" */ + free( list->list[i].xlfdname ); + free( list->list[i].style.name ); + free( list->list[i].shape.name ); + FAL_FREE_FONTLIST_OPTION( list ) ; + } + /* free a structure's array of "FalFontData()" */ + free( list->list ); + } + list->num = 0 ; + list->list = NULL ; + + /* free a structure of " FalFontDataList()" */ + free( list ); + return 0; +} + + +/***********************************************************************/ +/* split string for "FalFontData()" */ +/***********************************************************************/ + +static int +fal_split_data(char *buf, int elm_num, char *elm[]) +{ + int cnt; + int strtop_flg; + + /* check a comment */ + if ((*buf == '#') || (*buf == '\0')) { + return _FAL_TRY_NEXT; + } + /* check a pathname */ + if ( *buf == '/' ) { + return _FAL_TRY_NEXT; + } + /* divide a data */ + for ( cnt = 0, strtop_flg = 1 ; *buf != '\0'; buf++ ){ + if ( strtop_flg ) { + elm[cnt] = buf; + cnt++; + strtop_flg = 0; + } + if ( *buf == ':' ) { + *buf = '\0'; + strtop_flg++; + } + } + if ( cnt != elm_num ) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_FLST_ER; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return FAL_ERROR; + } + return 0; +} + +/***********************************************************************/ +/* clear a structure of "FalFontData()" */ +/***********************************************************************/ + +static int +fal_clear_data(FalFontData *tmp) +{ + /* search a character */ + free(tmp->xlfdname); + free(tmp->style.name); + free(tmp->shape.name); + FAL_CLEAR_DATA_OPTION( tmp ) ; + memset(tmp, 0, sizeof(*tmp)); + return 0 ; +} + +static int +fal_check_already_exist(FalFontData *data, FalFontDataList *lst) +{ + int i; + int mask ; + + mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_STYLE_NAME + | FAL_FONT_MASK_SIZE_H | FAL_FONT_MASK_CODE_SET ; + + for ( i=0 ; i < lst->num ; i++ ){ + switch ( fal_cmp_data( &(lst->list[i]), data, mask ) ) { + case 0: + return(i); + default: + continue; + } + } + return(-1); +} + + + +static int +fal_sort_fontlist(FalFontDataList *lst) +{ + int i,j; + FalFontDataList srt; + FalFontData target; + int target_entry; + + if( lst->num == 0 ){ + return 0 ; + } + + srt.num = lst->num; + + if (( srt.list = malloc(sizeof(FalFontData) * srt.num)) == NULL) { + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + memmove (srt.list, lst->list, sizeof(FalFontData) * srt.num); + /* start to sort */ + for ( i=0 ; i < srt.num -1 ; i++ ) { + + memmove( &target, &(srt.list[i]), sizeof(FalFontData)); + target_entry = i; + + for ( j=i+1 ; j < srt.num ; j++ ) { + if ( new_target( &target, &(srt.list[j]) ) ) { + memmove( &target, &(srt.list[j]), sizeof(FalFontData)); + target_entry = j; + } + } + if (target_entry != i) { + memmove( &target, &(srt.list[target_entry]), + sizeof(FalFontData) + ); + memmove( &(srt.list[i+1]), &(srt.list[i]), + sizeof(FalFontData)*(target_entry -i) + ); + memmove( &(srt.list[i]), &target, + sizeof(FalFontData) + ); + } + } + free(lst->list); + lst->list = srt.list; + return 0 ; +} + + + +/***************************************/ +/* change a character for a number */ +/***************************************/ + +static int +fal_atoi(char *str, int *val) +{ + char *ptr; + char *str_end; + int tmp; + + str_end = strchr( str, '\0' ); + + tmp = (int)strtol(str, &ptr, 10); + + /* error check */ + if ((ptr == str) || (ptr != str_end)) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_FLST_ER; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return(FAL_ERROR); + } + *val = tmp; + return 0 ; +} + +/*******************************/ +/* get a codeset */ +/*******************************/ + +static int +fal_set_cs(char *str, int *cs) +{ + if (!strcmp(str, "CS0")) { + *cs = FAL_FONT_CS0; + } else if (!strcmp(str, "CS1")) { + *cs = FAL_FONT_CS1; + } else if (!strcmp(str, "CS2")) { + *cs = FAL_FONT_CS2; + } else if (!strcmp(str, "CS3")) { + *cs = FAL_FONT_CS3; + } else { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_FLST_ER; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return(FAL_ERROR); + } + return(0); +} + + +/******************************************/ +/* get a equipment of an output permission*/ +/******************************************/ + + +static int +fal_set_prm(char *str, int *prm) +{ + int tmp = 0; + for ( ; *str != '\0' ; str++) { + if( *str == 'P' ) { + tmp |= FAL_FONT_PRINTER; + } else if( *str == 'D' ) { + tmp |= FAL_FONT_DISPLAY; + } else { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_FLST_ER; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return FAL_ERROR ; + } + } + *prm = tmp; + return 0 ; +} + +static int fal_read_db(char *str, FalFontDB *db) +{ + int i; + + for(i=0 ; db[i].def != FAL_FONT_UNKNOWN ; i++) { + if (!strcmp(str, db[i].name)) { + return(db[i].def); + } + } + return FAL_FONT_UNKNOWN ; +} + + +/***************************************/ +/* make a structure of "FalFontPath()" */ +/***************************************/ + +int +FalGetFontPath(FalFontPath **dlist_ret) +{ + + /* clear an error data */ + fal_utyerror = 0; + fal_utyderror = 0; + fal_utyerrno = 0 ; + + /* get current locale */ + if( fal_init() ) return FAL_ERROR ; + + /* parametter check */ + if ( dlist_ret == NULL ) { + fal_utyerror = _FAL_PARM_ER; + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR; + } + if ( orgn.path == NULL ) { + if ( set_default_path() == FAL_ERROR ) { + return FAL_ERROR; + } + if ( cpy_default_path( © ) == FAL_ERROR ){ + return FAL_ERROR; + } + } else if ( copy.path == NULL ) { + if ( cpy_default_path(©) == FAL_ERROR ){ + return FAL_ERROR; + } + } else { + + if ( comp_default_path( © ) == FAL_ERROR ) { + fal_clear_font_path( © ); + if ( cpy_default_path(©) == FAL_ERROR ){ + return FAL_ERROR; + } + } + } + *dlist_ret = © + return 0; +} + +static int +set_default_path(void) +{ + return set_font_pathlist(&orgn, 0) ; +} + +static int +cpy_default_path(FalFontPath *p) +{ + int i; + FalFontPath tmp; + + if ((orgn.num == 0) || (orgn.path == NULL)) { + p->num = 0; + p->path = NULL; + return 0; + } + + if ( + (tmp.path = (char **)malloc(sizeof(char *) * (orgn.num) )) + == NULL + ){ + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + tmp.num = 0; + for ( i = 0 ; i< orgn.num ; i++ ) { + char *tmp_str; + /* malloc & copy in strdup */ + if ((tmp_str = (char *)strdup((orgn.path)[i])) == NULL) { + fal_clear_font_path( &tmp ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + tmp.path[i] = tmp_str; + tmp.num++; + } + p->num = tmp.num; + p->path = tmp.path; + return 0; +} + +static int +comp_default_path(FalFontPath *p) +{ + int i; + + if ( p->num != orgn.num ) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerrno = FAL_ERR_FPATH ; + return FAL_ERROR; + } + for ( i = 0; i < p->num; i++ ) { + if( strcmp( p->path[i], orgn.path[i] ) ) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerrno = FAL_ERR_FPATH ; + return FAL_ERROR; + } + } + return 0; +} + + +static int +fal_clear_font_path(FalFontPath *ls) +{ + int i; + + if (ls->path != NULL) { + /* free a fontpath character */ + for (i=0 ; i < ls->num ; i++) { + if ((ls->path[i] != NULL) && (ls->path[i] == orgn.path[i])) { + free(ls->path[i]); + } + } + /* free a character pointer array */ + free( ls->path ); + ls->path = NULL; + } + ls->num = 0; + + return 0; +} + + +/* access number */ +#define FAL_FONT_ELM_FILENAME 0 +#define FAL_FONT_ELM_SIZE_W 1 +#define FAL_FONT_ELM_SIZE_H 2 +#define FAL_FONT_ELM_LETTER_W 3 +#define FAL_FONT_ELM_LETTER_H 4 +#define FAL_FONT_ELM_LETTER_X 5 +#define FAL_FONT_ELM_LETTER_Y 6 +#define FAL_FONT_ELM_STYLE_NAME 7 +#define FAL_FONT_ELM_SHAPE_NAME 8 + +#define FAL_FONT_ELM_CODE_SET 10 +#define FAL_FONT_ELM_PERMISSION 11 +#define FAL_FONT_ELM_XLFDNAME 12 + +int +set_struct(FalFontData *tmp_data, char *elm[]) +{ + char *dup_p; + + /* data information */ + while(1){ + /* a width of a character size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_SIZE_W], &(tmp_data->size.w ) + ) == FAL_ERROR + ) { + break; + } + /* a height of a character size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_SIZE_H], &(tmp_data->size.h ) + ) == FAL_ERROR + ) { + break; + } + /* a width of a letter size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_LETTER_W], &(tmp_data->letter.w ) + ) == FAL_ERROR + ) { + break; + } + /* a height of a letter size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_LETTER_H], &(tmp_data->letter.h ) + ) == FAL_ERROR + ) { + break; + } + /* position x of a letter size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_LETTER_X], &(tmp_data->letter.x ) + ) == FAL_ERROR + ) { + break; + } + /* position y of a letter size */ + if ( fal_atoi( + elm[FAL_FONT_ELM_LETTER_Y], &(tmp_data->letter.y ) + ) == FAL_ERROR + ) { + break; + } + /* codeset */ + if ( fal_set_cs( + elm[FAL_FONT_ELM_CODE_SET], &(tmp_data->cd_set ) + ) == FAL_ERROR + ) { + break; + } + /* a equipment of an output permission */ + if ( fal_set_prm( + elm[FAL_FONT_ELM_PERMISSION], &(tmp_data->prm ) + ) == FAL_ERROR + ) { + break; + } + + /* character information */ + + /* xlfd name */ + if ( ( dup_p = (char *)strdup( elm[FAL_FONT_ELM_XLFDNAME] ) ) == NULL ) { + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + tmp_data->xlfdname = dup_p; + + /* character style (character) */ + if ( ( dup_p = (char *)strdup( elm[FAL_FONT_ELM_STYLE_NAME] ) ) == NULL) { + free( tmp_data->xlfdname ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + tmp_data->style.name = dup_p; + + /* character style (numerical) */ + tmp_data->style.def + = fal_read_db( tmp_data->style.name, (FalFontDB *)&fal_db_style ); + + /* character shape (character) */ + if ( ( dup_p = (char *)strdup( elm[FAL_FONT_ELM_SHAPE_NAME] ) ) == NULL ) { + free( tmp_data->style.name ); + free( tmp_data->xlfdname ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR; + } + tmp_data->shape.name = dup_p; + + /* character shape (numerical) */ + tmp_data->shape.def + = fal_read_db( tmp_data->shape.name, (FalFontDB *)&fal_db_shape ); + + SET_STRUCT_OPTION( dup_p, elm, tmp_data, fal_utyerror, fal_db_group ) ; + return 0; + + } + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return FAL_ERROR; +} + +/* get a full path name */ +int searchFontFileName(FalFontData data, char *fullPathName) +{ + int rtn ; + rtn = falReadFontInfoLists(SRCHFNAME, + NULL, NULL, NULL, + data, fullPathName, + NULL, NULL) ; + if( fal_utyerrno != 0 ){ + fal_utyerrno |= (FAL_FUNCNUM_SRCHFNM<<8) ; + } + return rtn ; +} + + +int fal_eq_data(FalFontData data, FalFontData tmp_data) +{ + int flg = 0; + + /* xlfd name */ + if ( strcmp( data.xlfdname, tmp_data.xlfdname ) != 0 ) { + flg++; + } + + /* a width of a character size */ + if ( ( flg == 0 ) && ( data.size.h != tmp_data.size.h ) ) { + flg++; + } + + /* a height of a character size */ + if ( ( flg == 0 ) && ( data.size.w != tmp_data.size.w ) ) { + flg++; + } + /* a height of a letter size */ + if ( ( flg == 0 ) && ( data.letter.h != tmp_data.letter.h ) ) { + flg++; + } + + /* a width of a letter size */ + if ( ( flg == 0 ) && ( data.letter.w != tmp_data.letter.w ) ) { + flg++; + } + + /* position x of a letter size */ + if ( ( flg == 0 ) && ( data.letter.x != tmp_data.letter.x ) ) { + flg++; + } + + /* position y of a letter size */ + if ( ( flg == 0 ) && ( data.letter.y != tmp_data.letter.y ) ) { + flg++; + } + + /* a definition data of a character style */ + if ( ( flg == 0 ) && ( data.style.def != tmp_data.style.def ) ) { + flg++; + } + + /* character style */ + if ( (data.style.name != NULL) && (tmp_data.style.name != NULL) ) { + if ( ( flg == 0 ) && ( strcmp( data.style.name, tmp_data.style.name ) != 0 ) ) { + flg++; + } + } + + /* a definition data of a character shape */ + if ( ( flg == 0 ) && ( data.shape.def != tmp_data.shape.def ) ) { + flg++; + } + + /* character shape */ + if ( (data.shape.name != NULL) && (tmp_data.shape.name != NULL) ) { + if ( ( flg == 0 ) && ( strcmp( data.shape.name, tmp_data.shape.name ) != 0 ) ) { + flg++; + } + } + + FAL_EQ_DATA_OPTION( flg, data, tmp_data ) ; + + /* code set */ + if ( ( flg == 0 ) && ( data.cd_set != tmp_data.cd_set ) ) { + flg++; + } + + /* an equipment of an output permission */ + if ( ( flg == 0 ) && ( data.prm != tmp_data.prm ) ) { + flg++; + } + + if ( flg == 0 ) { + return 0; + } else if ( flg != 0 ) { + return _FAL_TRY_NEXT; + } else { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerrno = FAL_ERR_FDATA_DSC ; + return FAL_ERROR; + } +} + + +static int +CR_to_NULL(char *buf) +{ + for( ; *buf != '\0'; buf++ ) { + if (*buf == '\n') { + *buf = '\0'; + break; + } + } + return 0 ; +} + +char *fal_get_base_name(char *str) +{ + char *str_slash; + + str_slash = strrchr( str, '/'); + if ( str_slash == NULL ) { + return( str ); + } + return( ++str_slash ); +} + + +static int +fal_cmp_data(FalFontData *op1, FalFontData *key, int mask) +{ + if ( mask == 0 ) { + return(0); + } + + if ( key == NULL ) { + return(0); + } + + if ( + ( mask & FAL_FONT_MASK_XLFDNAME ) + && strcmp( op1->xlfdname, key->xlfdname ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_SIZE_W ) + && (op1->size.w != key->size.w ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_SIZE_H ) + && (op1->size.h != key->size.h ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_LETTER_W ) + && ( op1->letter.w != key->letter.w ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_LETTER_H ) + && ( op1->letter.h != key->letter.h ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_LETTER_X ) + && ( op1->letter.x != key->letter.x ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_LETTER_Y ) + && ( op1->letter.y != key->letter.y ) + ) { + return _FAL_TRY_NEXT; + } + if ( + ( mask & FAL_FONT_MASK_STYLE_DEF ) + && ( op1->style.def != key->style.def ) + ) { + return _FAL_TRY_NEXT; + } + if( (op1->style.name != NULL) && (key->style.name != NULL) ) { + if ( + ( mask & FAL_FONT_MASK_STYLE_NAME ) + && strcmp( op1->style.name, key->style.name ) + ) { + return _FAL_TRY_NEXT; + } + } + if ( + ( mask & FAL_FONT_MASK_SHAPE_DEF ) + && ( op1->shape.def != key->shape.def ) + ) { + return _FAL_TRY_NEXT; + } + if( (op1->shape.name != NULL) && (key->shape.name != NULL) ) { + if ( + ( mask & FAL_FONT_MASK_SHAPE_NAME ) + && strcmp( op1->shape.name, key->shape.name ) + ) { + return _FAL_TRY_NEXT; + } + } + FAL_CMP_DATA_OPTION( mask, op1, key ) ; + if ( + ( mask & FAL_FONT_MASK_CODE_SET ) + && ( op1->cd_set != key->cd_set ) + ) { + return _FAL_TRY_NEXT; + } + if ( mask & FAL_FONT_MASK_PERMISSION ) { + int cmp_prm; + cmp_prm = key->prm & (FAL_FONT_DISPLAY | FAL_FONT_PRINTER); + if ( ( op1->prm & cmp_prm ) != cmp_prm ) { + return _FAL_TRY_NEXT; + } + } + return 0; +} + + +/* sort flag */ +/* return data ¡§ sort ... 1 */ +/* no sort ... 0 */ + +static int +new_target(FalFontData *target, FalFontData *choose) +{ + FalFontData diff; + DEF_STR_CHK ; + + DEF_STR_SET ; + + diff.style.def = choose->style.def - target->style.def; + if( (choose->style.name != NULL) && (target->style.name != NULL) ) { + str_chk.style = strcmp( choose->style.name, target->style.name ) ; + } + + NEW_TARGET_SET( diff, choose, target, str_chk ) ; + + diff.shape.def = choose->shape.def - target->shape.def; + if( (choose->shape.name != NULL) && (target->shape.name != NULL) ) { + str_chk.shape = strcmp( choose->shape.name, target->shape.name ) ; + } + + diff.cd_set = choose->cd_set - target->cd_set; + diff.size.h = choose->size.h - target->size.h; + diff.size.w = choose->size.w - target->size.w; + diff.letter.h = choose->letter.h - target->letter.h; + diff.letter.w = choose->letter.w - target->letter.w; + + /* style */ + if ( target->style.def == FAL_FONT_UNKNOWN ) { + if ( choose->style.def > 0 ) { + return 1; + } + /* style is FAL_FONT_UNKNOWN both "target" and "choose" */ + if ( str_chk.style < 0 ) { + return 1; + } + if ( str_chk.style > 0) { + return 0; + } + } else if ( choose->style.def == FAL_FONT_UNKNOWN ) { + return 0; + } + /* target->style.def and choose->style.def is not FAL_FONT_UNKNOWN */ + if (diff.style.def < 0) { + return 1; + } + if ( diff.style.def > 0) { + return 0; + } + + NEW_TARGET_CHK( diff, choose, target, str_chk ) ; + + /* character shape */ + if ( target->shape.def == FAL_FONT_UNKNOWN ) { + if ( choose->shape.def > 0 ) { + return 1; + } + if ( str_chk.shape < 0 ) { + return 1; + } + if ( str_chk.shape > 0 ) { + return 0; + } + } else if (choose->shape.def == FAL_FONT_UNKNOWN ) { + return 0; + } + if ( diff.shape.def < 0 ) { + return 1; + } + if ( diff.shape.def > 0 ) { + return 0; + } + + /* codeset */ + if ( diff.cd_set < 0 ) { + return 1; + } + if (diff.cd_set > 0) { + return 0; + } + + /* character size height */ + if ( diff.size.h < 0 ) { + return 1; + } + if ( diff.size.h > 0 ) { + return 0; + } + + /* letter size height */ + if ( diff.letter.h < 0 ) { + return 1; + } + if ( diff.letter.h > 0 ) { + return 0; + } + + /* character size wide */ + if ( diff.size.w < 0 ) { + return 1; + } + if ( diff.size.w > 0 ) { + return 0; + } + + /* letter size wide */ + if ( diff.letter.w < 0 ) { + return 1; + } + if ( diff.letter.w > 0 ) { + return 0; + } + + return 0; +} + +int FalFontOfFontID( + FalFontID fid, + FalFontData *fontdata ) +{ + int rtn ; + rtn = falReadFontInfoLists(FONTOFID, + NULL, NULL, NULL, + NULL, NULL, + fid, fontdata) ; + if( fal_utyerrno != 0 ){ + fal_utyerrno |= (FAL_FUNCNUM_FID<<8) ; + } + return rtn ; +} + +FalFontID +FalOpenSysFont( + FalFontData *open_font_data, + int font_data_mask, + FalFontDataList **missing_font_list_return ) +{ + int retFL; /* return a data of FontList */ + FalFontID retOF; /* return a data of OpenFont */ + char fname[FAL_LINE_MAX]; + + /* follow "font_data_mask" and call "FalGetFontList()" */ + retFL = FalGetFontList( + open_font_data, font_data_mask, missing_font_list_return + ); + /* case of an abnormal end */ + if ( retFL != 0 ) { + *missing_font_list_return = NULL; + return 0; + } + + if ( (*missing_font_list_return)->num > 1 ) { + return 0; + } else if ( (*missing_font_list_return)->num == 1 ) { + /* investigator an font file name */ + int slct_cdset, prm, islock, dspcode ; + if ( + searchFontFileName( + (*missing_font_list_return)->list[0], fname + ) == FAL_ERROR + ){ + FalFreeFontList( *missing_font_list_return ); + fal_utyerrno &= 0xff ; + fal_utyerrno |= (FAL_FUNCNUM_SRCHFNM<<8) ; + *missing_font_list_return = NULL; + return 0; + } + /* open a font by "__FalOpenFont()" */ + slct_cdset = (*missing_font_list_return)->list[0].cd_set ; + dspcode = ( font_data_mask & FAL_FONT_MASK_GLYPH_INDEX )? + FAL_FONT_GLYPH_INDEX : slct_cdset ; + prm = ((*missing_font_list_return)->list[0].prm ) ? + (*missing_font_list_return)->list[0].prm : + FAL_FONT_DISPLAY | FAL_FONT_PRINTER ; + islock = (( font_data_mask & FAL_FONT_MASK_UPDATE )? 1 : 0 ); + retOF = __FalOpenFont( fname, prm, dspcode, islock ); + + if ( retOF == (FalFontID)FAL_ERROR ) { + /* abnomal end */ + FalFreeFontList( *missing_font_list_return ); + fal_utyerrno &= 0xff ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + *missing_font_list_return = NULL; + return 0; + } else { + /* normal end ( return retOF ) */ + *missing_font_list_return = NULL; + FalFreeFontList( *missing_font_list_return ); + if( fal_add_fidinf( retOF, + dspcode, slct_cdset, islock ) == FAL_ERROR ){ + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return 0 ; + } + return retOF; + } + } else if ( (*missing_font_list_return)->num == 0 ) { + /* + * set NULL in "missing_font_list_return" + */ + FalFreeFontList( *missing_font_list_return ); + *missing_font_list_return = NULL; + return 0; + } else { + /* case abnormal */ + *missing_font_list_return = NULL; + fal_utyerrno = FAL_ERR_FATAL ; + fal_utyerrno |= (FAL_FUNCNUM_OPNFNT<<8) ; + return 0; + } +} + + +/******************************************************** +* function to access fonts.list +********************************************************/ +static +FILE *open_fonts_list(void) +{ + + FILE *fp; + char *locale = NULL ; + char *fal_search_path = NULL ; + char flist_d[FAL_LINE_MAX] ; + char flist_c[FAL_LINE_MAX] ; + char flist_l[FAL_LINE_MAX] ; + + GETLISTFILEPATH( locale, fal_search_path, flist_d, flist_c, flist_l, FONTS_LIST_FILE ) ; + + if ( ( fp = fopen( flist_l, "r" ) ) == NULL ) { + if( (fp = fopen( flist_c, "r" )) == NULL ) { + if( (fp = fopen( flist_d, "r" )) == NULL ) { + set_errfile_str( fal_err_file, flist_d ) ; + set_errfile_str( fal_err_file_buf, flist_d ) ; + fal_utyerror = _FAL_DATA_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FDATA_OPN ; + }else{ + /* Save full path of fonts.list. */ + set_errfile_str( fal_err_file_buf, flist_d ) ; + if( IsDefaultPath == TRUE ) IsDefaultPath = FALSE ; + } + }else{ + /* Save full path of fonts.list. */ + set_errfile_str( fal_err_file_buf, flist_c ) ; + if( IsDefaultPath == TRUE ) IsDefaultPath = FALSE ; + } + }else{ + /* Save full path of fonts.list. */ + set_errfile_str( fal_err_file_buf, flist_l ) ; + if( IsDefaultPath == TRUE ) IsDefaultPath = FALSE ; + } + + return( fp ) ; +} + + + +/* + * functions to read "fonts.dir" files + */ + +/***************************************************************/ +/* read a font information and add a list or make a list */ +/***************************************************************/ + + +static int +set_font_pathlist(FalFontPath *pathlist, int nodef) +{ + FILE *fp; + char buf[FAL_LINE_MAX]; + char *font_path = NULL ; + char **tmp_list ; + int num; + + errno = 0; + /* open a font directory information file */ + if ((fp = open_fonts_list()) == NULL) { + /* Make default path list */ + if( errno == ENOENT || errno == EACCES || errno == EISDIR ){ + if ( make_default_path(pathlist) ) { + return FAL_ERROR ; + } + return 0 ; + } + return FAL_ERROR ; + } + memset( buf, '\0', sizeof(buf) ) ; + + while ( fgets( buf, FAL_LINE_MAX, fp ) != (char *)NULL ){ + struct stat statbuf ; + char *ep ; + + CR_to_NULL(buf); + + if( buf[0] == '#' ){ /* comments */ + continue ; + }else if( buf[0] == '/' ){ /* font path */ + + /* add font_path to pathlist */ + if( font_path ){ + num = pathlist->num; + if (pathlist->path == NULL) { + tmp_list = (char **)malloc(sizeof(char *)*(num +1)); + } else { + tmp_list = (char **)realloc(pathlist->path, sizeof(char *)*(num+1)); + } + if (tmp_list == NULL) { + fclose( fp ); + free( font_path ); + fal_clear_font_path( pathlist ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + pathlist->path = tmp_list; + pathlist->path[num] = font_path; + pathlist->num++; + } + + /* get font_path */ + if ((font_path = (char *)strdup(buf)) == NULL) { + fclose( fp ); + fal_clear_font_path( pathlist ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + ep = font_path + strlen( font_path ) - 1 ; + *ep = '/'; /* ':' -> '/' */ + if( *(ep-1) == '/' ) *ep = '\0'; + + if( stat( font_path, &statbuf ) ) { + free( font_path ) ; + font_path = NULL ; + continue; + } + if( !(statbuf.st_mode & S_IFDIR) ) { + free( font_path ) ; + font_path = NULL ; + continue; + } + + }else{ /* font file */ + if( nodef ){ + if( font_path ){ + free( font_path ) ; + font_path = NULL ; + } + } + continue ; + } + + } + /* add font_path to pathlist */ + if( font_path ){ + num = pathlist->num; + if (pathlist->path == NULL) { + tmp_list = (char **)malloc(sizeof(char *)*(num +1)); + } else { + tmp_list = (char **)realloc(pathlist->path, sizeof(char *)*(num+1)); + } + if (tmp_list == NULL) { + fclose( fp ); + free( font_path ); + fal_clear_font_path( pathlist ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + pathlist->path = tmp_list; + pathlist->path[num] = font_path; + pathlist->num++; + } + + if ( feof(fp) != 0 ){ + fclose(fp); + return 0 ; + } + fclose(fp); + fal_clear_font_path( pathlist ); + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_READ_PATH_ER; + fal_utyerrno = FAL_ERR_FPATH ; + return FAL_ERROR; +} + + + +static int +make_default_path(FalFontPath *pathlist) +{ + struct stat statbuf ; + char pbuf[FAL_LINE_MAX], *dir, *p ; + char *path, **plist ; + char *sp, *ep ; + int len, num; + + memset( pbuf, '\0', sizeof(pbuf) ) ; + + p = pbuf ; + if( (dir = getenv( "DTUDCFONTPATH" )) != NULL ) { + len = strlen( dir ) ; + strcpy( p, dir ) ; + p[len++] = ':' ; + p += len ; + } + strcpy( p, DTUDCFONTPATH ) ; + strcat( p, ":" ) ; + + sp = pbuf ; + while ( (ep = strchr( sp, ':' )) != (char *)NULL ){ + + /* get path */ + *ep = '\0' ; + if ((path = (char *)malloc(sizeof(char) * (strlen(sp)+2))) == NULL) { + fal_clear_font_path( pathlist ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + strcpy( path, sp ) ; + len = strlen( sp ) ; + path[len++] = '/' ; + path[len] = '\0' ; + if( path[len-2] == '/' ) path[len-1] = '\0'; + + if( stat(path, &statbuf) ) { + free( path ) ; + sp = ep + 1 ; + continue; + } + if( !(statbuf.st_mode & S_IFDIR) ) { + free( path ) ; + sp = ep + 1 ; + continue; + } + + /* add path to pathlist */ + num = pathlist->num; + if (pathlist->path == NULL) { + plist = (char **)malloc(sizeof(char *)*(num +1)); + } else { + plist = (char **)realloc(pathlist->path, sizeof(char *)*(num+1)); + } + if (plist == NULL) { + fal_clear_font_path( pathlist ); + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + free(path); + return FAL_ERROR ; + } + pathlist->path = plist; + pathlist->path[num] = path; + pathlist->num++; + sp = ep + 1 ; + } + if( execDefined == TRUE ) execDefined = FALSE ; + if( IsDefaultPath == FALSE ) IsDefaultPath = TRUE ; + fal_utyerror = 0 ; + fal_utyderror = 0 ; + fal_utyerrno = 0 ; + return 0 ; +} + + + + +static int +falReadFontInfoLists( +int func, + /* parameters for FalGetFontList */ +FalFontData *lstkey, +int mask, +FalFontDataList *fls, + /* parameters for searchFontFileName */ +FalFontData fnkey, +char *fullpath, + /* parameters for FalFontOfFontID */ +FalFontID fid, +FalFontData *fdata) +{ + FILE *fp; + char pname[ FAL_LINE_MAX ] ; + Oak_FontInf *finf; + + FalFontData tmp_data; + FontIDInfo fontid_inf; + char *elm[FAL_DATA_ELM * 3]; + char buf[FAL_LINE_MAX * 3]; + + struct stat statbuf ; + char *keyfname, *fontFileName, *fonts_list_file ; + int i, j ; + int fontnum ; + int codeset_num, *codeset_list ; + + keyfname = fontFileName = fonts_list_file = NULL ; + codeset_num = 0 ; + codeset_list = NULL ; + if( func & FONTOFID ){ + finf = (Oak_FontInf *)fid ; + keyfname = finf->fname ; + } + + /* get current locale */ + if( fal_init() ) return FAL_ERROR ; + + /* get font path list */ + if( wpath.path==NULL ) { + if( set_font_pathlist( &wpath, 1 ) ) { + return FAL_ERROR ; + } + } + /* + * If execDefined is true, this function read detail informations + * of the fonts descripted in fonts.list. + */ + if( execDefined == TRUE && IsDefaultPath == FALSE ) { + /* open an information file */ + if ((fp = open_fonts_list()) == NULL) { + return FAL_ERROR ; + } + memset( pname, 0, sizeof( pname ) ); + + while ( fgets( buf, FAL_LINE_MAX, fp ) != ( char * ) NULL ) { + int eq; + + /* clear an area */ + memset( elm, 0, sizeof( elm ) ); + memset( &tmp_data, 0, sizeof( tmp_data ) ); + CR_to_NULL( buf ); + + /* + * get font information of a font + */ + switch( fal_get_def_fontdata(func, pname, buf, elm, &tmp_data, keyfname ) ) { + case _FAL_TRY_NEXT: + if( buf[0] == '/' ) { + buf[strlen( buf ) -1] = '/' ; + strcpy( pname, buf ) ; + } + continue; + case 0: + break; + case FAL_ERROR: + default: + goto FalError ; + } + + switch( func ) { + case MKFONTLIST : /* FalGetFontList */ + switch( falgetfontlist(&tmp_data, lstkey, mask, fls, 1) ){ + case _FAL_TRY_NEXT : + continue ; + case 0: + break; + case FAL_ERROR: + default: + goto FalError ; + } + break ; + case SRCHFNAME : /* searchFontFileName */ + eq = fal_eq_data( fnkey, tmp_data ) ; + switch ( eq ) { + case 0 : + sprintf( fullpath, "%s%s", pname, elm[ FAL_FONT_ELM_FILENAME ] ); + fal_clear_data( &tmp_data ) ; + fclose(fp) ; + return 0 ; + case _FAL_TRY_NEXT : + fal_clear_data( &tmp_data ) ; + break ; + default : /* FAL_ERROR */ + goto FalError ; + } + break ; + case FONTOFID : /* FalFontOfFontID */ + memmove( fdata, &tmp_data, sizeof(FalFontData) ) ; + fclose(fp) ; + return 0 ; + default : + fal_utyerrno = FAL_ERR_PARM ; + goto FalError ; + } + + } /* end of while loop */ + /* EOF */ + if ( feof( fp ) != 0 ) { + fclose( fp ); + }else{ + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_DATA_READ_ER; + fal_utyerrno = FAL_ERR_FDATA_RD ; + fclose( fp ); + return FAL_ERROR ; + } + + if( (func & SRCHFNAME) && (execUndefined == FALSE) ){ + fal_utyerrno = FAL_ERR_NOFONT ; + return FAL_ERROR ; + } + + } /* execDefined */ + + /* + * If execUnefined is true, this function read list of font path, + * and get the name of font file from fonts.dir. + */ + if( execUndefined == TRUE ) { + + /* + * search font path + */ + for( i=0; i<wpath.num; i++ ) { + FalFontData *p_bak ; + + fonts_list_file = (char *)malloc( sizeof(char) * ( strlen(wpath.path[i]) + strlen(FONTSDIR) + 1 ) ) ; + if( fonts_list_file == (char *)NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + sprintf( fonts_list_file, "%s%s", wpath.path[i], FONTSDIR ) ; + + if( stat( fonts_list_file, &statbuf ) ) { + FreeString( fonts_list_file ) ; + continue ; + } + if( !(statbuf.st_mode & S_IFREG) ) { + FreeString( fonts_list_file ) ; + continue ; + } + errno = 0 ; + /* open "fonts.dir" */ + if ((fp = fopen( fonts_list_file, "r" )) == NULL) { + if( errno == EACCES ) { + FreeString( fonts_list_file ) ; + continue ; + }else{ + set_errfile_str( fal_err_file, fonts_list_file ) ; + FreeString( fonts_list_file ) ; + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno ; + fal_utyerrno = FAL_ERR_FNTDIR_OPN ; + return FAL_ERROR ; + } + } + /* Save full path of fonts.dir */ + set_errfile_str( fal_err_file_buf, fonts_list_file ) ; + FreeString( fonts_list_file ) ; + + /* Get number of fonts in current path */ + if( fgets( buf, FAL_LINE_MAX, fp ) == (char *)NULL ) { + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_DATA_READ_ER; + fal_utyerrno = FAL_ERR_FNTDIR_RD ; + fclose(fp); + return FAL_ERROR; + } + fontnum = atoi( buf ); + + /* Get list of font informations */ + if( func & MKFONTLIST){ + if ( fls->list == NULL ) { + p_bak = (FalFontData *)malloc(sizeof(FalFontData) * (fls->num + fontnum)); + } else { + p_bak = (FalFontData *)realloc(fls->list, sizeof(FalFontData)*(fls->num + fontnum)); + } + if ( p_bak == NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + fls->list = p_bak ; + } + + memset( buf, 0, sizeof(buf)); + + while( fgets( buf, FAL_LINE_MAX, fp ) != (char *)NULL ) { + int tmp_num, eq ; + char *ep, *xlfd ; + + /* set FalFontData */ + CR_to_NULL(buf); /* '\n' -> '\0' */ + memset( &tmp_data, 0, sizeof(FalFontData)); + + /* parse string of font file */ + if( (ep = strchr( buf, ' ' )) == (char *)NULL ) continue ; + else *ep = 0 ; + /* refuse font file (not gpf) */ + if( + ( strcmp( FILE_SUFFIX(buf), PCFSUFFIX ) != 0 ) && + ( strcmp( FILE_SUFFIX(buf), SNFSUFFIX ) != 0 ) && + ( ISOPTFONT(buf) != 0 ) + ){ + continue ; + } + + /* get string of font file */ + if( (func & SRCHFNAME) || (func & FONTOFID) ){ + fontFileName = (char *)malloc( sizeof(char) * ( strlen(wpath.path[i]) + strlen(buf) + 1 ) ) ; + if( fontFileName == (char *)NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + sprintf( fontFileName, "%s%s", wpath.path[i], buf ) ; + } + + /* read font file and get properties */ + xlfd = ++ep ; + switch( fal_get_undef_fontdata(func, fontFileName, xlfd, &tmp_data, keyfname, &codeset_num, &codeset_list) ) + { + case _FAL_TRY_NEXT : + if( (func & SRCHFNAME) || (func & FONTOFID) ) FreeString( fontFileName ) ; + fal_clear_data( &tmp_data ); + memset( buf, 0, sizeof(buf)); + continue ; + case 0: + if( (func & FONTOFID) ) FreeString( fontFileName ) ; + break; + case FAL_ERROR: + default: + if( (func & SRCHFNAME) || (func & FONTOFID) ) FreeString( fontFileName ) ; + goto FalError ; + } + + if( !(func & FONTOFID) && (codeset_num == 0) ){ + if( (func & SRCHFNAME) ) FreeString( fontFileName ) ; + fal_clear_data( &tmp_data ); + memset( buf, 0, sizeof(buf)); + continue ; + } + + switch( func ) { + case MKFONTLIST : /* FalGetFontList */ + tmp_num = fls->num ; + case SRCHFNAME : /* searchFontFileName */ + /* set font data */ + for( j=0; j<codeset_num; j++ ) { + tmp_data.cd_set = FALGETFALCODESET( codeset_list[j] ) ; + + if( func & MKFONTLIST ){ /* FalGetFontList */ + /* Ignore fonts already exists. */ + if ( fal_check_already_exist(&tmp_data, fls) >= 0 ) { + continue; + } + + switch( falgetfontlist(&tmp_data, lstkey, mask, fls, 1) ){ + case _FAL_TRY_NEXT : + continue ; + case 0: + break; + case FAL_ERROR: + default: + goto FalError ; + } + } + if( func & SRCHFNAME ){ /* searchFontFileName */ + eq = fal_eq_data( fnkey, tmp_data ) ; + switch ( eq ) { + case 0 : + strcpy( fullpath, fontFileName ); + fal_clear_data( &tmp_data ) ; + FreeString( fontFileName ) ; + tmp_codeset = tmp_data.cd_set ; + fclose(fp) ; + /* clear code set informations */ + clear_charset_info() ; + return 0 ; + case _FAL_TRY_NEXT : + break ; + default : /* FAL_ERROR */ + FreeString( fontFileName ) ; + goto FalError ; + } + } + } /* for loop */ + if( func & MKFONTLIST ){ /* FalGetFontList */ + if( fls->num == tmp_num ) fal_clear_data( &tmp_data ) ; + } + if( func & SRCHFNAME ){ /* searchFontFileName */ + fal_clear_data( &tmp_data ) ; + FreeString( fontFileName ) ; /* _FAL_TRY_NEXT */ + } + break ; + + case FONTOFID : /* FalFontOfFontID */ + memmove( fdata, &tmp_data, sizeof(FalFontData) ) ; + if( fal_read_fidinf( fid, &fontid_inf ) != FAL_ERROR ) + fdata->cd_set = fontid_inf.cd_set ; + else { + fdata->cd_set = 0 ; + goto FalError ; + } + fclose(fp) ; + return 0 ; + + default : + goto FalError ; + } + + memset(buf, 0, sizeof(buf)); + } /* while loop */ + + if ( feof(fp) != 0 ) { + fclose(fp); + }else{ + set_errfile_str( fal_err_file, fal_err_file_buf ) ; + fal_utyerror = _FAL_DATA_READ_ER; + fal_utyerrno = FAL_ERR_FNTDIR_RD ; + fclose(fp); + return FAL_ERROR; + } + + } /* for loop */ + + /* clear code set informations */ + clear_charset_info() ; + + if( (func & SRCHFNAME) || (func & FONTOFID) ){ + fal_utyerrno = FAL_ERR_NOFONT ; + return FAL_ERROR ; + } + + } /* execUndefined */ + + return 0 ; + +FalError: + + clear_charset_info() ; + fal_clear_data( &tmp_data ) ; + fclose(fp) ; + return FAL_ERROR ; + +} + + +/* clear code set informations */ +static void +clear_charset_info(void) +{ + if( charset_str_buf ) free( charset_str_buf ) ; + charset_str_buf = NULL ; + if( codeset_list_sav ) free( codeset_list_sav ) ; + codeset_list_sav = NULL ; + codeset_list_num = 0 ; +} + + +static int +fal_get_def_fontdata( +int func, +char *pname, /* font path */ +char *buf, /* buffer for fgets() */ +char **elm, +FalFontData *tmp_data, +char *key_fname) +{ + int rtn ; + char tmp_fname[FAL_LINE_MAX] ; + + if( (rtn = fal_split_data( buf, FAL_DATA_ELM, elm )) ) { + return rtn ; + } + + if( func & FONTOFID ){ + sprintf( tmp_fname, "%s%s", pname, elm[ FAL_FONT_ELM_FILENAME ] ); + if( strcmp( tmp_fname, key_fname ) ) return _FAL_TRY_NEXT ; + } + + /* set informations to structrue */ + if ( set_struct( tmp_data, elm ) == FAL_ERROR ) { + return FAL_ERROR; + } + return 0 ; +} + + + +static int +falgetfontlist( +FalFontData *tmp_data, +FalFontData *key, +int mask, +FalFontDataList *fls, +int fontnum) +{ + FalFontData *p_bak ; + + if( fontnum == 0 ){ + return _FAL_TRY_NEXT ; + } + + /* compare with key data */ + if ( fal_cmp_data(tmp_data, key, mask) == _FAL_TRY_NEXT ) { + return _FAL_TRY_NEXT ; + } + + if ( fls->list == NULL ) { + p_bak = malloc(sizeof(FalFontData) * (fls->num + fontnum)); + } else { + p_bak = realloc(fls->list, sizeof(FalFontData)*(fls->num + fontnum)); + } + if ( p_bak == NULL ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + fls->list = p_bak; + memmove(&(fls->list[fls->num]), tmp_data, sizeof(FalFontData)); + fls->num++; /* update number of fonts */ + + return 0 ; +} + + + +static int +fal_get_undef_fontdata( +int func, +char *full_path, +char *xlfd, +FalFontData *tmp_data, +char *key_fname, +int *codeset_num, +int **codeset_list) +{ + int rtn, pix ; + char *char_set ; + char xlfdname[ FAL_LINE_MAX ], *family, *pixsize ; + char *cbuf, *ep ; + + /* FalFontOfFontID() */ + if( func & FONTOFID ){ + if( strcmp( full_path, key_fname ) ) return _FAL_TRY_NEXT ; + } + + /* + * parse XLFD and get font informations + */ + cbuf = ep = family = pixsize = NULL ; + /* XLFD */ + strcpy( xlfdname, xlfd ) ; + /* pixel size */ + GETXLFDELMSTR( pixsize, xlfd, XLFD_ELM_PIXEL_SIZE ) ; + ep = (char *)strchr( pixsize, '\0' ) ; + pix = (int)strtol( pixsize, &cbuf, 10 ) ; + if( cbuf == pixsize || cbuf != ep ){ + return _FAL_TRY_NEXT ; + } + /* family name */ + GETXLFDELMSTR( family, xlfd, XLFD_ELM_FAMILY_NAME ) ; + + /* set font data */ + if( (tmp_data->style.name = (char *)strdup( family )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + if( (tmp_data->xlfdname = (char *)strdup( xlfdname )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + tmp_data->size.h = pix ; + tmp_data->size.w = -1 ; + + /* FalGetFontList() and searchFontFilename() */ + if( (func & MKFONTLIST) || (func & SRCHFNAME) ){ + GETCHARSETSTR( char_set, tmp_data->xlfdname ) ; + /* code set infomations exist */ + if( charset_str_buf && !strcmp( charset_str_buf, char_set ) ) { + *codeset_num = codeset_list_num ; + *codeset_list = codeset_list_sav ; + }else{ + /* clear code set infomations */ + clear_charset_info() ; + /* get code set infomations */ + if( (rtn = fal_get_codeset( fal_locale, char_set, codeset_list, codeset_num )) ){ + return rtn ; + } + /* save code set infomations */ + if( (charset_str_buf = (char *)strdup( char_set )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + codeset_list_num = *codeset_num ; + codeset_list_sav = *codeset_list ; + } + } + return 0 ; +} + + + +/* + * get file name of fonts + */ + +int +FalFontIDToFileName( + FalFontID fid, + char **file_name ) +{ + char *fname ; + Oak_FontInf *finf ; + if( fid == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyderror = _FAL_R_P_FINF_DER ; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_IDTOFNM<<8) ; + return FAL_ERROR ; + } + if( file_name == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyderror = _FAL_R_P_W_DER ; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_IDTOFNM<<8) ; + return FAL_ERROR ; + } + finf = (Oak_FontInf *)fid ; + if( (fname = (char *)strdup( finf->fname )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + fal_utyerrno |= (FAL_FUNCNUM_IDTOFNM<<8) ; + return FAL_ERROR ; + } + *file_name = fname ; + return 0 ; +} + + +int +FalFree(void *list) +{ + if( list == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyerrno = FAL_ERR_PARM ; + fal_utyerrno |= (FAL_FUNCNUM_FREE<<8) ; + return FAL_ERROR ; + } + free( list ) ; + return 0 ; +} + + + +int +FalFreeGI(FalGIInf *ginf, int num) +{ + int i ; + if( ginf == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR ; + } + for( i=0; i<num; i++ ) { + if( ginf[i].charset_str != NULL ) + free( ginf[i].charset_str ) ; + } + free( ginf ) ; + return 0 ; +} + + +/* + * This functions manage the relation of FontID + * between code set number. + */ + +static int +fal_add_fidinf(FalFontID fid, int dspcode, int cd_set, int islock) +{ + int exist, i, cnt ; + FontIDInfo **flist ; + if( fid == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR ; + } + exist = 0 ; + for( i=0; i<mngfid.num; i++ ) { + if( fid == mngfid.finf[i]->fid ) { + exist++ ; + mngfid.finf[i]->dspcode = dspcode ; + mngfid.finf[i]->cd_set = cd_set ; + mngfid.finf[i]->islock = islock ; + break ; + } + } + /* add new data */ + if( !exist ) { + if( mngfid.finf == NULL ) { + cnt = 0 ; + if( (flist = (FontIDInfo **)malloc( sizeof(FontIDInfo *) )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + } else { + cnt = mngfid.num ; + if( (flist = (FontIDInfo **)realloc( + mngfid.finf, sizeof(FontIDInfo *) * (cnt + 1) )) == NULL ) + { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + } + if( (flist[cnt] = (FontIDInfo *)malloc( sizeof(FontIDInfo) )) == NULL ) { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + free(flist); + return FAL_ERROR ; + } + flist[cnt]->fid = fid ; + flist[cnt]->cd_set = cd_set ; + flist[cnt]->dspcode = dspcode ; + flist[cnt]->islock = islock ; + + mngfid.num = cnt + 1 ; + mngfid.finf = flist ; + } + + return 0 ; +} + +static int +fal_read_fidinf(FalFontID fid, FontIDInfo *fontid_inf) +{ + int i ; + if( fid == NULL ) { + fal_utyerror = _FAL_PARM_ER ; + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR ; + } + for( i=0; i<mngfid.num; i++ ) { + if( mngfid.finf[i]->fid == fid ) { + fontid_inf->fid = fid ; + fontid_inf->cd_set = mngfid.finf[i]->cd_set ; + fontid_inf->dspcode = mngfid.finf[i]->dspcode ; + fontid_inf->islock = mngfid.finf[i]->islock ; + return 0 ; + } + } + fal_utyerror = _FAL_PARM_ER ; + fal_utyerrno = FAL_ERR_FID_RD ; + return FAL_ERROR ; +} + + +static int +fal_del_fidinf(FalFontID fid) +{ + int i, cnt, target ; + FontIDInfo **flist ; + + for( i=0; i<mngfid.num; i++ ) { + if( mngfid.finf[i]->fid == fid ) { + target = i ; + break ; + } + } + cnt = mngfid.num - 1 ; + free( mngfid.finf[target] ) ; + for( i=target; i<mngfid.num; i++ ) { + mngfid.finf[i] = mngfid.finf[i+1] ; + } + if( cnt > 0 ) { + if( (flist = (FontIDInfo **)realloc( + mngfid.finf, sizeof(FontIDInfo *) * cnt )) == NULL ) + { + fal_utyerror = _FAL_MALOC_ER ; + fal_utyerrno = FAL_ERR_MALLOC ; + return FAL_ERROR ; + } + mngfid.num = cnt ; + mngfid.finf = flist ; + } else { + free( mngfid.finf ) ; + mngfid.num = 0 ; + mngfid.finf = NULL ; + } + return 0 ; +} + +/* + * convert codepoint into glyph index + */ + +static int +fal_conv_code_to_glyph(FalFontID fid, unsigned int code, unsigned int *glidx) +{ + Oak_FontInf *finf ; + FalFontData tmp_data ; + FalGIInf *gi ; + FontIDInfo fontid_inf ; + int gnum ; + int i ; + int inner_code = 0 ; + char *char_set ; + static FalFontID cmpfid = 0 ; + static char charset_name[FAL_LINE_MAX] ; + + finf = (Oak_FontInf *)fid ; + /* + * get code set number + */ + if( fal_read_fidinf( fid, &fontid_inf ) == FAL_ERROR ) { + return FAL_ERROR; + } + + if( fontid_inf.dspcode != FAL_FONT_GLYPH_INDEX ){ + /* + * get string of "CHARSET_REGISTRY" + */ + memset( &tmp_data, 0, sizeof(FalFontData) ) ; + + if( cmpfid != fid ){ + if( falReadGpfProp( FAL_READ_FONTINFO, finf, FAL_FONT_PRM, &tmp_data ) ) { + fal_clear_data( &tmp_data ) ; + return FAL_ERROR; + } + GETCHARSETSTR( char_set, tmp_data.xlfdname ) ; + snprintf( charset_name, sizeof(charset_name), "%s", char_set ) ; + } + + /* + * convert codepoint into glyph index + */ + if( COMM_SBFNT_ISSBFNT( charset_name ) ) { + inner_code = code ; + FAL_OPT_CONVCPTOGI( fontid_inf.dspcode, inner_code ) ; + } else { + if( fal_code_to_glyph( fal_locale, code, &gi, &gnum ) ) { + fal_clear_data( &tmp_data ) ; + return FAL_ERROR; + } + if( gnum==1 ){ + inner_code = gi[0].glyph_index ; + }else{ + for( i=0; i<gnum; i++ ) { + if( !strcmp( gi[i].charset_str, char_set ) ) { + inner_code = gi[i].glyph_index ; + break ; + } + } + } + FalFreeGI( gi, gnum ) ; + } + fal_clear_data( &tmp_data ) ; + }else{ + inner_code = code; /* glyph index */ + } + *glidx = inner_code ; + + return 0 ; +} + + +/* + * convert codepoint into glyph index + */ + +static int +fal_conv_glyph_to_code( +Oak_FontInf *finf, +int dspcode, +int cd_set, +unsigned int glidx, +unsigned int *code) +{ + FalFontData tmp_data ; + int inner_code ; + char *char_set ; + + /* + * get code set number + */ + if( dspcode != FAL_FONT_GLYPH_INDEX ){ + /* + * get string of "CHARSET_REGISTRY" + */ + memset( &tmp_data, 0, sizeof(tmp_data) ) ; + if( falReadGpfProp( FAL_READ_FONTINFO, finf, FAL_FONT_PRM, &tmp_data ) ) { + fal_clear_data( &tmp_data ) ; + return FAL_ERROR; + } + GETCHARSETSTR( char_set, tmp_data.xlfdname ) ; + + /* + * convert glyph index into codepoint + */ + if( COMM_SBFNT_ISSBFNT( char_set ) ) { + inner_code = glidx ; + FAL_OPT_CONVGITOCP( dspcode, inner_code ) ; + } else { + if( fal_glyph_to_code( fal_locale, char_set, cd_set, glidx, &inner_code ) ) { + fal_clear_data( &tmp_data ) ; + return FAL_ERROR; + } + } + fal_clear_data( &tmp_data ) ; + }else{ + inner_code = glidx ; /* glyph index */ + } + *code = inner_code ; + + return 0 ; +} + + +static int +file_lock(int fd) /* a file descripter */ +{ + struct flock flpar; + + flpar.l_type = F_RDLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_SETLK, &flpar ) == -1 ) { + fal_utyerrno = FAL_ERR_FILELCK ; + return FAL_ERROR ; + } + + return 0; +} + +static int +file_unlock(int fd) /* a file descripter */ +{ + struct flock flpar; + + flpar.l_type = F_UNLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_SETLK, &flpar ) == -1 ){ + fal_utyerrno = FAL_ERR_FILEUNLCK ; + return FAL_ERROR ; + } + return 0; +} + +static int +is_lock(int fd) /* file descripter */ +{ + struct flock flpar; + + flpar.l_type = F_WRLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_GETLK, &flpar ) == -1 ) { + fal_utyerrno = FAL_ERR_FILEGETLCK ; + return FAL_ERROR ; + } + + if ( flpar.l_type == F_UNLCK ){ + return 0 ; + } else { + fal_utyerrno = FAL_ERR_LCKD ; + return 1 ; + } +} + +/********************< end of falfont.c >*********************************/ diff --git a/cde/programs/dtudcfonted/libfal/falfont.h b/cde/programs/dtudcfonted/libfal/falfont.h new file mode 100644 index 000000000..439478911 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/falfont.h @@ -0,0 +1,88 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: falfont.h /main/5 1996/06/25 20:05:39 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#define GETNUMCHARS(pFinf) \ + (((pFinf)->lastCol - (pFinf)->firstCol + 1) * \ + ((pFinf)->lastRow - (pFinf)->firstRow + 1)) + +#define GETHIGHT(pCinf) \ + ((pCinf)->metrics.ascent + (pCinf)->metrics.descent) + +#define _FAL_OK 1 +/* fal_utyerror */ +#define _FAL_OPEN_ER 1 +#define _FAL_DIR_NOACCSS 1 +#define _FAL_READ_ER 2 +#define _FAL_READ_PATH_ER 2 +#define _FAL_MALOC_ER 3 +#define _FAL_PKEY_ER 4 +#define _FAL_PARM_ER 5 +#define _FAL_STAT_ER 6 +#define _FAL_FONT_ER 7 +#define _FAL_FLST_ER 7 +#define _FAL_DATA_OPEN_ER 8 +#define _FAL_DATA_READ_ER 9 + +/* fal_utyderror */ +/* FalOpenFont */ +#define _FAL_O_P_PKEY_DER 1 +#define _FAL_O_P_CS_DER 2 +/* FalQueryFont */ +#define _FAL_Q_P_FINF_DER 1 +#define _FAL_Q_P_FONT_DER 2 +/* FalReadFont */ +#define _FAL_R_P_FINF_DER 1 +#define _FAL_R_P_W_DER 2 +#define _FAL_R_P_H_DER 3 + +/* FalGetFontList */ +#define _FAL_L_P_LST_DER 1 +#define _FAL_L_P_KEY_DER 2 + +#define _FAL_TRY_NEXT 0xFF + +#include "udccom.h" + +#define SNF_BOUND 32 + + +#define FILE_SUFFIX( file ) \ + ( strrchr( file, '.' ) ? strrchr( file, '.' ) : "" ) + + +#define FAL_DATA_ELM 13 +#define FAL_LINE_MAX 1024 + +/* update _Oak_Finf */ +#define FAL_UPDATE_FONTINFO 1 +#define FAL_READ_FONTINFO 0 + +/* Buffer of file name */ +extern char fal_err_file_buf[] ; diff --git a/cde/programs/dtudcfonted/libfal/fonts.list.header b/cde/programs/dtudcfonted/libfal/fonts.list.header new file mode 100644 index 000000000..9e194cefe --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/fonts.list.header @@ -0,0 +1,26 @@ +############################################################################# +##### ##### +##### fonts.list ##### +##### ##### +##### All Rights Reserved, Copyright (C) FUJITSU LIMITED 1995 ##### +##### ##### +############################################################################# +# +# This file is referenced by : +# +# dtudcfonted +# dtudcexch +# dtaddcpf +# dtcpgpf +# dtgpftocpf +# dtcpftogpf +# dtgpftobdf +# dtbdftocpf +# dtcpftobdf +# and dtlsgpf. +# +# font path ==> path1: +# path2: +# : +# pathN: +# diff --git a/cde/programs/dtudcfonted/libfal/readpcf.c b/cde/programs/dtudcfonted/libfal/readpcf.c new file mode 100644 index 000000000..4dc9eed8b --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/readpcf.c @@ -0,0 +1,866 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: readpcf.c /main/5 1996/06/05 16:42:29 ageorge $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <X11/Intrinsic.h> +#include "FaLib.h" +#include "falfont.h" + +#ifndef GLYPHPADOPTIONS +#define GLYPHPADOPTIONS 4 +#endif + +static CARD32 getLSB32(); +static int getINT32(); +static int getINT16(); +static Bool seekToType(); +static void getMetric(); +static Bool getAccel(); +int falInitReadPcf(); +static void ByteSwap(); +static void repadBits(); +int falPcfGlyph(); +void falGetPcfGSize(); +int falInitReadPcfProp() ; +int falInitReadSnfProp() ; +int falReadGpfProp() ; + +extern void BitOrderInvert() ; +extern void set_errfile_str() ; + +static CARD32 +getLSB32(unsigned char *p) +{ + CARD32 c; + + c = *p++; + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p) << 24; + + return c; +} + +static int +getINT32(unsigned char *p, CARD32 format) +{ + CARD32 c; + + if (PCF_BYTE_ORDER(format) == MSBFirst) { + c = (CARD32)(*p++) << 24; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p); + } else { + c = (CARD32)(*p++); + c |= (CARD32)(*p++) << 8; + c |= (CARD32)(*p++) << 16; + c |= (CARD32)(*p) << 24; + } + + return (int)c; +} + +static int +getINT16(unsigned char *p, CARD32 format) +{ + CARD32 c; + + if (PCF_BYTE_ORDER(format) == MSBFirst) { + c = (CARD32)(*p++) << 8; + c |= (CARD32)(*p); + } else { + c = (CARD32)(*p++); + c |= (CARD32)(*p) << 8; + } + + return (int)c; +} + +static Bool +seekToType( +PCFTablePtr tables, +int ntables, +CARD32 type, +CARD32 *formatp, +CARD32 *sizep, +CARD32 *offsetp) +{ + int i; + + for ( i = 0; i < ntables; i++) { + if ( getLSB32( (unsigned char *)&tables[i].type ) == type) { + if ( formatp) + *formatp = getLSB32( (unsigned char *)&tables[i].format); + if ( sizep) + *sizep = getLSB32( (unsigned char *)&tables[i].size); + if ( offsetp) + *offsetp = getLSB32( (unsigned char *)&tables[i].offset); + return(TRUE); + } + } + return(FALSE); +} + + + +static void +getMetric(caddr_t buf, CARD32 format, xCharInfo *metric) +{ + metric->leftSideBearing = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; + metric->rightSideBearing = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; + metric->characterWidth = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; + metric->ascent = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; + metric->descent = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; + metric->attributes = getINT16( (unsigned char *)buf, (CARD32)format); + buf += 2; +} + +static Bool +getAccel( +FontInfoPtr pFontInfo, +xCharInfo *maxink, +caddr_t buf_top, +PCFTablePtr tables, +int ntables, +CARD32 type) +{ + CARD32 format; + CARD32 offset; + caddr_t buffer; + + if ( !seekToType( tables, ntables, (CARD32)type, &format, (CARD32 *)NULL, &offset)) + return FALSE; + + buffer = buf_top + offset; + format = getLSB32( (unsigned char *)buffer ); + buffer += 4; + if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) && + !PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) { + return FALSE; + } + pFontInfo->noOverlap = *buffer++; + pFontInfo->constantMetrics = *buffer++; + pFontInfo->terminalFont = *buffer++; + pFontInfo->constantWidth = *buffer++; + pFontInfo->inkInside = *buffer++; + pFontInfo->inkMetrics = *buffer++; + pFontInfo->drawDirection = *buffer++; + /* pFontInfo->anamorphic = FALSE; */ + /* natural alignment */ buffer++; + pFontInfo->fontAscent = getINT32( (unsigned char *)buffer, (CARD32)format); + buffer += 4; + pFontInfo->fontDescent = getINT32( (unsigned char *)buffer, (CARD32)format); + buffer +=4; + + /* pFontInfo->maxOverlap = getINT32( (unsigned char *)buffer, (CARD32)format); */ buffer += 4; + getMetric(buffer, format, &pFontInfo->minbounds); + buffer += 12; + getMetric(buffer, format, &pFontInfo->maxbounds); + buffer += 12; + if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) { + buffer += 12; + getMetric( buffer, format, maxink); + } else { + *maxink = pFontInfo->maxbounds; + } + return TRUE; +} + +int +falInitReadPcf(struct pcf_inf *pcfinf, caddr_t buftop) +{ + CARD32 format; + CARD32 offset; + CARD32 *bitmapSizes; + xCharInfo maxink; + caddr_t buffp; + + if ( getLSB32( (unsigned char *)buftop ) != PCF_FILE_VERSION) + return -1; + + pcfinf->ntables = getLSB32( (unsigned char *)(buftop + 4) ); + + pcfinf->tables = (PCFTablePtr)(buftop + 8); + + if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, pcfinf->ntables, + (CARD32)PCF_BDF_ACCELERATORS)) + if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, pcfinf->ntables, + (CARD32)PCF_ACCELERATORS)) + return -1; + + pcfinf->org_bounds = pcfinf->info.maxbounds; + + if ( !seekToType( pcfinf->tables, pcfinf->ntables, (CARD32)PCF_BITMAPS, + &format, (CARD32 *)NULL, &offset)) + return -1; + + buffp = buftop + offset; + + format = getLSB32( (unsigned char *)buffp ); + buffp += 4; + if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) + return -1; + + pcfinf->nbitmaps = getINT32( (unsigned char *)buffp, (CARD32)format); + buffp += 4; + pcfinf->offsets = (CARD32 *)buffp; + buffp += sizeof( *pcfinf->offsets) * pcfinf->nbitmaps; + + bitmapSizes = (CARD32 *)buffp; + pcfinf->sizebitmaps = getINT32( (unsigned char *)&bitmapSizes[PCF_GLYPH_PAD_INDEX(format)], (CARD32)format); + pcfinf->bmp_fmt = format; + buffp += sizeof( *bitmapSizes) * GLYPHPADOPTIONS; + pcfinf->bitmaps = buffp; + buffp += pcfinf->sizebitmaps; + + if ( !seekToType( pcfinf->tables, pcfinf->ntables, (CARD32)PCF_BDF_ENCODINGS, + &format, (CARD32 *)NULL, &offset)) + return -1; + + buffp = buftop + offset; + format = getLSB32( (unsigned char *)buffp ); + buffp += 4; + if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) + return -1; + + pcfinf->info.firstCol = getINT16( (unsigned char *)buffp, (CARD32)format); + buffp += 2; + pcfinf->info.lastCol = getINT16( (unsigned char *)buffp, (CARD32)format); + buffp += 2; + pcfinf->info.firstRow = getINT16( (unsigned char *)buffp, (CARD32)format); + buffp += 2; + pcfinf->info.lastRow = getINT16( (unsigned char *)buffp, (CARD32)format); + buffp += 2; + /* + pcfinf->info.defaultCh = getINT16( (unsigned char *)buffp, (CARD32)format); buffp += 2; + */ + pcfinf->info.defaultCh = getINT16( (unsigned char *)buffp, (CARD32)format); + buffp += 2; + + pcfinf->info.allExist = FALSE; + pcfinf->enc_fmt = format; + pcfinf->encodingOffsets = (CARD16 *)buffp; + + return 0; +} + +static void +ByteSwap(char *p, int scan) +{ + char w; + + switch( scan) { + case 1: + break; + case 2: + w = *p; + *p = *(p + 1); + *(p + 1) = w; + break; + case 4: + w = *p; + *p = *(p + 3); + *(p + 3) = w; + w = *(p + 1); + *(p + 1) = *(p + 2); + *(p + 2) = w; + break; + } +} +static void +repadBits(char *src, CARD32 format, int width, int height, char *dest) +{ + int bit, byte, glyph, scan; + int src_bytewidth, dest_bytewidth; + char work[8]; + int i, j; + + bit = PCF_BIT_ORDER( format); + byte = PCF_BYTE_ORDER( format); + glyph = PCF_GLYPH_PAD( format); + scan = PCF_SCAN_UNIT( format); + + src_bytewidth = (( width + ( 8 * glyph ) - 1)/( 8 * glyph)) * glyph; + dest_bytewidth = ( width + 7) /8; + + for ( i = 0; i < height; i++, src += src_bytewidth, + dest += dest_bytewidth) { + for ( j = 0; j < src_bytewidth; j += scan) { + memcpy( work, src + j, scan); + if ( bit == LSBFirst) + BitOrderInvert( work, scan ); + if ( byte == LSBFirst) + ByteSwap( work, scan); + if (( j + scan) >= dest_bytewidth) { + memcpy( dest + j, work, dest_bytewidth - j); + break; + } + memcpy( dest + j, work, scan); + } + } +} + +int +falPcfGlyph(char *glyph, Oak_FontInf *finf, int code) +{ + int encode; + int inner_code; + char *bitmap; + int encodingOffset; + int codeRow, codeCol; + int bytewidth; + int bmp_adj, ptn_adj; + int adj_hi; + int cpy_height; + int bmp_height; + + if ( !glyph){ + fal_utyerrno = FAL_ERR_PARM ; + return FAL_ERROR ; + } + + inner_code = code; + codeCol = inner_code & 0xff; + codeRow = (inner_code >> 8) & 0xff; + + /* code check */ + if ( + ((code < finf->start) || (code > finf->end))|| + ((codeCol < finf->pFinf->firstCol)||(codeCol > finf->pFinf->lastCol))|| + ((codeRow < finf->pFinf->firstRow)||(codeRow > finf->pFinf->lastRow)) + ) { + fal_utyexists = 1; + return(-1); + } + + encode = (codeRow - finf->pFinf->firstRow) * ( finf->pFinf->lastCol - finf->pFinf->firstCol + 1); + encode += codeCol - finf->pFinf->firstCol; + encodingOffset = getINT16( (unsigned char *)(finf->pcfinf.encodingOffsets + encode), finf->pcfinf.enc_fmt); + + if (encodingOffset == 0xFFFF) { + fal_utyexists = 1; + return(-1); + } + fal_utyexists = 0; + + bitmap = finf->pcfinf.bitmaps + getINT32( (unsigned char *)(finf->pcfinf.offsets + encodingOffset), finf->pcfinf.bmp_fmt); + + bmp_height = finf->pFinf->maxbounds.ascent + + finf->pFinf->maxbounds.descent; + if (( adj_hi = finf->pFinf->maxbounds.ascent + - finf->pcfinf.org_bounds.ascent) > 0) { + bytewidth = 8 * PCF_GLYPH_PAD( finf->pcfinf.bmp_fmt); + bytewidth = (( finf->width + bytewidth - 1)/ bytewidth ) * PCF_GLYPH_PAD( finf->pcfinf.bmp_fmt); + bmp_adj = bytewidth * adj_hi; + ptn_adj = 0; + if (( cpy_height = bmp_height - adj_hi) > finf->height) + cpy_height = finf->height; + } else if ( adj_hi < 0) { + adj_hi *= -1; + bytewidth = ( finf->width + 7) / 8; + bmp_adj = 0; + ptn_adj = bytewidth * adj_hi; + if (( cpy_height = finf->height - adj_hi) > bmp_height) + cpy_height = bmp_height; + } else { + bmp_adj = 0; + ptn_adj = 0; + cpy_height = finf->height; + } + + repadBits( bitmap + bmp_adj , finf->pcfinf.bmp_fmt, finf->width, cpy_height, glyph + ptn_adj); + return(0); +} + +void +falGetPcfGSize( +struct pcf_inf *pcfinf, +unsigned int *widthp, +unsigned int *heightp) +{ + unsigned int w, h; + + w = pcfinf->org_bounds.rightSideBearing + - pcfinf->org_bounds.leftSideBearing; + h = pcfinf->org_bounds.ascent + pcfinf->org_bounds.descent; + + *widthp = w; + *heightp = h; +} + + + + +/******************************************************** + * + * functions for collect GPF file properties + * + *******************************************************/ + +#include <X11/fonts/fontstruct.h> + +static char *getPcfFontProp(); +static char *getSnfFontProp(); +/* +* read properties and get font style and +* letter size +*/ + +int +falReadFontProp( +char *file, /* name of font file */ +int protect_key_data, +FalFontData *databuff, +int islock) +{ + Oak_FontInf finf; + int fd ; + char *buf; + char *openfontfile; + struct stat st; + int rtn ; + + /* initialezation */ + openfontfile = file ; + + /* read a condition of a fontfile */ + if ( stat( openfontfile, &st ) < 0 ) { + set_errfile_str( fal_err_file, openfontfile ) ; + fal_utyerror = _FAL_STAT_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_STAT ; + return FAL_ERROR; + } + + if ( st.st_size < sizeof( FontInfoRec ) ) { + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_FONT ; + return FAL_ERROR; + } + + /* open a fontfile */ + if ( (fd = open( openfontfile, ((islock)? O_RDONLY : O_RDWR) )) < 0 ) { + switch( errno ) { + case EACCES : + return _FAL_TRY_NEXT ; + default : + set_errfile_str( fal_err_file, openfontfile ) ; + fal_utyerror = _FAL_OPEN_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_OPN ; + return FAL_ERROR; + } + } + +#if defined( SVR4 ) + buf = (char *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + if ( buf != (char *)-1 ) { + /* if "mmap" is normal end */ + close( fd ); + finf.ismmap = TRUE; + finf.fsize = st.st_size; + } else { + /* if "mmap" is abnormal end , try "read()" */ + finf.ismmap = FALSE; + if ( !(buf = (char *)malloc(st.st_size)) ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + close( fd ); + return FAL_ERROR; + } + if ( read(fd, buf, st.st_size) != st.st_size ) { + set_errfile_str( fal_err_file, openfontfile ) ; + fal_utyerror = _FAL_READ_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_RD ; + free( buf ); + close( fd ); + return FAL_ERROR; + } + } +#else + finf.ismmap = FALSE; + if ( !(buf = (char *)malloc( st.st_size )) ) { + fal_utyerror = _FAL_MALOC_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_MALLOC ; + close( fd ); + return FAL_ERROR; + } + if ( read(fd, buf, st.st_size) != st.st_size ) { + set_errfile_str( fal_err_file, openfontfile ) ; + fal_utyerror = _FAL_READ_ER; + fal_utyderror = errno; + fal_utyerrno = FAL_ERR_FNT_RD ; + free( buf ); + close( fd ); + return FAL_ERROR; + } +#endif + + finf.fname = openfontfile ; + finf.buf = buf ; + + /* + * open GPF font file + */ + rtn = falReadGpfProp( FAL_UPDATE_FONTINFO, &finf, protect_key_data, databuff ) ; +#if defined( SVR4 ) + if ( finf.ismmap == TRUE ) { + munmap( buf, finf.fsize ); + } else { + free(buf); + close(fd); + } +#else + free( buf ); + close( fd ); +#endif + + return( rtn ) ; +} + + +/* +* get properties of GPF format file +*/ +int +falReadGpfProp( +int updflg, +Oak_FontInf *finf, +int protect_key_data, +FalFontData *databuff) +{ + char *openfontfile; + int rtn ; + + /* initialize */ + openfontfile = finf->fname ; + + if( updflg == FAL_UPDATE_FONTINFO ) { + /* case of a PCF format font */ + if ( strcmp( FILE_SUFFIX( openfontfile ), PCFSUFFIX ) == 0 ) { + + finf->isFef = FALSE; + finf->isPcf = TRUE; + + } + else /* case of a SNF format font */ + { + FAL_READ_SNF_HEADER( finf, protect_key_data, fal_utyerror, fal_utyderror ) ; + } + } /* updflg */ + + /* + * get font properties + */ + if ( finf->isFef ){ + /* read SNF format property */ + if ( rtn = falInitReadSnfProp( finf, (caddr_t)finf->pFinf, databuff ) ) { + if( rtn == _FAL_TRY_NEXT ){ + return( rtn ) ; + } + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + return FAL_ERROR; + } + } else if ( finf->isPcf ) { + /* read PCF format property */ + if ( rtn = falInitReadPcfProp( updflg, finf, databuff ) ) { + if( rtn == _FAL_TRY_NEXT ){ + return( rtn ) ; + } + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + return FAL_ERROR; + } + + if( updflg == FAL_UPDATE_FONTINFO ) { + finf->pFinf = &finf->pcfinf.info; + finf->pCinf = NULL; + finf->pGlyphs = NULL; + } + } else { + fal_utyerror = _FAL_FONT_ER; + fal_utyderror = 0; + fal_utyerrno = FAL_ERR_FONT ; + return FAL_ERROR; + } + + return(0); +} + + +/* +* get properties of PCF format file +*/ +int +falInitReadPcfProp(int updflg, Oak_FontInf *finf, FalFontData *databuff) +{ + struct pcf_inf *pcfinf; + caddr_t buftop; + xCharInfo maxink; + caddr_t buffp; + int lb, rb, as, ds ; + + + + pcfinf = &finf->pcfinf ; + buftop = finf->buf ; + + if ( getLSB32( (unsigned char *)buftop ) != PCF_FILE_VERSION) + return _FAL_TRY_NEXT ; + + if( updflg == FAL_UPDATE_FONTINFO ) { + pcfinf->ntables = getLSB32( (unsigned char *)(buftop + 4) ); + + pcfinf->tables = (PCFTablePtr)(buftop + 8); + + if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, + pcfinf->ntables, (CARD32)PCF_BDF_ACCELERATORS)) { + if ( !getAccel( &pcfinf->info, &maxink, buftop, pcfinf->tables, + pcfinf->ntables, (CARD32)PCF_ACCELERATORS)) { + fal_utyerrno = FAL_ERR_FONT ; + return -1; + } + } + + } + + /* + * read property + */ + + if( updflg == FAL_UPDATE_FONTINFO ) { + pcfinf->org_bounds = pcfinf->info.maxbounds; + } + + lb = pcfinf->org_bounds.leftSideBearing ; + rb = pcfinf->org_bounds.rightSideBearing ; + as = pcfinf->org_bounds.ascent ; + ds = pcfinf->org_bounds.descent ; + + databuff->size.w = rb - lb ; + databuff->size.h = as + ds ; + + /* + * read property "FONT" + */ + if ( buffp = getPcfFontProp( buftop, pcfinf->tables, + pcfinf->ntables, "FONT" )) { + if( (databuff->xlfdname = (char *)strdup( buffp )) == (char *)NULL ){ + fal_utyerrno = FAL_ERR_MALLOC ; + return -1; + } + }else{ + set_errfile_str( fal_err_file, finf->fname ) ; + fal_utyerrno = FAL_ERR_PROP_FONT ; + return( _FAL_TRY_NEXT ) ; + } + + /* + * read property "FAMILY_NAME" + */ + if ( buffp = getPcfFontProp( buftop, pcfinf->tables, + pcfinf->ntables, "FAMILY_NAME")) { + if( (databuff->style.name = (char *)strdup( buffp )) == NULL ){ + fal_utyerrno = FAL_ERR_MALLOC ; + return -1; + } + }else{ + set_errfile_str( fal_err_file, finf->fname ) ; + fal_utyerrno = FAL_ERR_PROP_FNAME ; + return( _FAL_TRY_NEXT ) ; + } + + return 0; + +} + + + +static char * +getPcfFontProp(caddr_t buftop, PCFTablePtr tables, int ntables, char *propname) +{ + caddr_t buffer; + int name_ofs; + int i ; + int nprops; + char *propstr ; + CARD32 format, offset; + + if ( !seekToType( tables, ntables, (CARD32)PCF_PROPERTIES, &format, (CARD32 *)NULL, &offset)) + return NULL; + + buffer = buftop + offset; + format = getLSB32( (unsigned char *)buffer ); + buffer += 4; + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT)) + return NULL; + + nprops = getINT32( (unsigned char *)buffer, (CARD32)format); + buffer += 4; + propstr = buffer + (4 * ((nprops * 9 + 3) / 4)) + 4; + + for ( i=0; i < nprops ; i++ ) { + name_ofs = getINT32( (unsigned char *)buffer, (CARD32)format ) ; + buffer += 4 ; /* name */ + if ( strcmp( propstr + name_ofs, propname) == 0) { + if ( *buffer) { /* isStringProp */ + return( propstr + getINT32( (unsigned char *)(buffer + 1), (CARD32)format) ); + }else{ + return((char *)(intptr_t)getINT32( (unsigned char *)(buffer + 1), (CARD32)format) ); + } + } + buffer += 5 ; /* isStringProp + value */ + } + + return( NULL); +} + + +/* +* get properties of SNF format file +*/ +int +falInitReadSnfProp( +Oak_FontInf *finf, /* pointer to the infomation structure */ +caddr_t buftop, /* font file */ +FalFontData *databuff) +{ + caddr_t stprop ; + int lb, rb, as, ds ; + char *propptr ; + char *fnt = NULL, *fam ; + int nprops, bitmapSize, num_chars ; + + + /* initialize pointer */ + nprops = finf->pFinf->nprops ; + num_chars = ( finf->pFinf->lastRow - finf->pFinf->firstRow + 1 ) * + ( finf->pFinf->lastCol - finf->pFinf->firstCol + 1 ) ; + + stprop = buftop ; + stprop += sizeof(FontInfoRec) ; + stprop += num_chars * sizeof(CharInfoRec) ; + + /* + * read property "FONTBOUNDINGBOX" + */ + lb = finf->pFinf->maxbounds.leftSideBearing ; + rb = finf->pFinf->maxbounds.rightSideBearing ; + as = finf->pFinf->maxbounds.ascent ; + ds = finf->pFinf->maxbounds.descent ; + + /* + * read property "FONT" + */ + if ( propptr = getSnfFontProp( stprop, nprops, "FONT" )) { + if( (fnt = (char *)strdup( propptr )) == NULL ){ + fal_utyerrno = FAL_ERR_MALLOC ; + free(fnt); + return -1; + } + }else{ + set_errfile_str( fal_err_file, finf->fname ) ; + fal_utyerrno = FAL_ERR_PROP_FONT ; + return( _FAL_TRY_NEXT ) ; + } + + /* + * read property "FAMILY_NAME" + */ + if ( propptr = getSnfFontProp( stprop, nprops, "FAMILY_NAME")) { + if( (fam = (char *)strdup( propptr )) == NULL ){ + fal_utyerrno = FAL_ERR_MALLOC ; + free(fnt); + return -1; + } + }else{ + set_errfile_str( fal_err_file, finf->fname ) ; + fal_utyerrno = FAL_ERR_PROP_FNAME ; + free(fnt); + return( _FAL_TRY_NEXT ) ; + } + + /* + * set data buffer + */ + + databuff->size.w = rb - lb ; + databuff->size.h = as + ds ; + + databuff->xlfdname = fnt ; + databuff->style.name = fam ; + + return 0; +} + + + +static char * +getSnfFontProp(caddr_t buftop, int nprops, char *propname) +{ + caddr_t buffer; + int name_ofs; + int i ; + char *propstr ; + FontPropRec *ProcRec ; + + ProcRec = (FontPropRec *)buftop ; + buffer = (char *)buftop ; + propstr = buffer + nprops * sizeof(FontPropRec) ; + + for ( i=0; i < nprops ; i++, ProcRec++ ) { + name_ofs = ProcRec->name ; + if( strcmp( propstr + name_ofs, propname ) == 0 ){ + return( (char *) (intptr_t) ProcRec->value ) ; + } + } + + return( NULL); +} + +/***********************< end of readpcf.c >********************/ diff --git a/cde/programs/dtudcfonted/libfal/syncx.c b/cde/programs/dtudcfonted/libfal/syncx.c new file mode 100644 index 000000000..40aa14a10 --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/syncx.c @@ -0,0 +1,75 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: syncx.c /main/3 1996/07/04 02:32:52 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ +#include <stdio.h> + +/* "fal" -> "X" */ +/* GetFProp.c falGetFontProperty() : Xlib.h */ +/* omDefault.c _falwcDefaultTextPerCharExtents(): omGeneric.c */ +/* IntAtom.c falInternAtom() : Xlib.h */ +/* Font.c falFreeFont() : Xlib.h */ +/* FontInfo.c falFreeFontInfo() : Xlib.h */ +/* TextToStr.c falFreeStringList() : Xlib.h */ +/* FontNames.c falFreeFontNames() : Xlib.h */ + +/* Bool */ falGetFontProperty() { return 0 ; } +/* Status */ _falwcDefaultTextPerCharExtents(){ return 0 ; } +void _falmbDefaultDrawImageString() { return ; } +/* Atom */ falInternAtom() { return 0 ; } +int _falwcGenericDrawString() { return 0 ; } +char **_falParseBaseFontNameList() { return NULL ; } +/* XFontStruct * */ falLoadQueryFont() { return 0 ; } +falFreeFont() { return 0 ; } +falFreeFontInfo() { return 0 ; } +/* char ** */ falListFonts() { return 0 ; } +void _falmbGenericDrawImageString() { return ; } +void _falwcDefaultDrawImageString() { return ; } +int _falmbDefaultDrawString() { return 0 ; } +int _falmbGenericTextEscapement() { return 0 ; } +void falFreeStringList() { return ; } +/* falrmStringToQuark() { return 0 ; } */ +/* falrmPermStringToQuark() { return 0 ; } */ +int _falwcDefaultDrawString() { return 0 ; } +/* char * */ falGetAtomName() { return 0 ; } +int _falwcGenericTextExtents() { return 0 ; } +int _falmbGenericTextExtents() { return 0 ; } +void _falwcGenericDrawImageString() { return ; } +falFreeFontNames() { return 0 ; } +/* falrmQuarkToString() { return 0 ; } */ +int _falwcDefaultTextExtents() { return 0 ; } +/* Status */ _falmbGenericTextPerCharExtents(){ return 0 ; } +int _falmbDefaultTextEscapement() { return 0 ; } +int _falwcGenericTextEscapement() { return 0 ; } +int _falmbDefaultTextExtents() { return 0 ; } +/* char ** */ falListFontsWithInfo() { return 0 ; } +int _falwcDefaultTextEscapement() { return 0 ; } +/* Status */ _falwcGenericTextPerCharExtents(){ return 0 ; } +/* _fallcMapOSLocaleName() { return 0 ; } */ +int _falmbGenericDrawString() { return 0 ; } +/* Status */ _falmbDefaultTextPerCharExtents(){ return 0 ; } diff --git a/cde/programs/dtudcfonted/libfal/syncx.h b/cde/programs/dtudcfonted/libfal/syncx.h new file mode 100644 index 000000000..1814dfc6d --- /dev/null +++ b/cde/programs/dtudcfonted/libfal/syncx.h @@ -0,0 +1,66 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: syncx.h /main/2 1996/06/25 20:04:52 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ +#include <stdio.h> +#include <X11/Xlib.h> +#include <X11/Xresource.h> +#include "_falutil.h" + +extern XrmQuark falrmStringToQuark( + const char* /* string */ +); +extern XrmString falrmQuarkToString( + XrmQuark /* quark */ +); + +extern char *falGetAtomName( + Display* /* display */, + Atom /* atom */ +); + +extern char **falListFonts( + Display* /* display */, + const char* /* pattern */, + int /* maxnames */, + int* /* actual_count_return */ +); + +extern char **falListFontsWithInfo( + Display* /* display */, + const char* /* pattern */, + int /* maxnames */, + int* /* count_return */, + XFontStruct** /* info_return */ +); + +extern XFontStruct *falLoadQueryFont( + Display* /* display */, + const char* /* name */ +); + diff --git a/cde/programs/dtudcfonted/libfuty/Imakefile b/cde/programs/dtudcfonted/libfuty/Imakefile new file mode 100644 index 000000000..a55ac3ac6 --- /dev/null +++ b/cde/programs/dtudcfonted/libfuty/Imakefile @@ -0,0 +1,32 @@ +XCOMM $XConsortium: Imakefile /main/5 1996/09/09 11:20:01 drk $ +#define DoNormalLib YES +#define DoSharedLib NO +#define DoDebugLib NO +#define DoProfileLib NO +#define LibName oakfuty +#define LibHeaders NO +#define LibInstall NO + + FONTLIST = /config + + OPT1 = -DDEFAULT_CODESET='"'3'"' +#ifdef X11ProjectRoot + OPT2 = -DFONTC='"'$(XPROJECTROOT)/bin/bdftopcf'"' +#else + OPT2 = -DFONTC='"'$(BINDIR)/bdftopcf'"' +#endif + OPT3 = -DSNFFONTC='"'$(SNFFONTC)'"' + OPT4 = -DDTUDCFONTSLISTDIR='"'$(CDE_INSTALLATION_TOP)$(FONTLIST)'"' + OPT5 = -DDEFAULT_TMPPATH='"'/var/tmp/'"' + + DEFINES = $(OPT1) $(OPT2) $(OPT3) $(OPT4) $(OPT5) + + INCLUDES = -I../include -I../libfal/include -I../libfal + + SRCS = oakfuty.c getfname.c lock.c + + OBJS = oakfuty.o getfname.o lock.o + +#include <Library.tmpl> + +DependTarget() diff --git a/cde/programs/dtudcfonted/libfuty/getfname.c b/cde/programs/dtudcfonted/libfuty/getfname.c new file mode 100644 index 000000000..167a3135b --- /dev/null +++ b/cde/programs/dtudcfonted/libfuty/getfname.c @@ -0,0 +1,1067 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: getfname.c /main/9 1996/11/08 02:06:43 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <sys/types.h> +#include <sys/stat.h> +#include <locale.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +#include "FaLib.h" +#include "falfont.h" +#include "udcutil.h" + +#include <string.h> + +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <wait.h> +#endif /* SVR4 */ +#include <signal.h> + +#include "bdfgpf.h" + +static void ErrMsgTable_GetDefaultFile(char *com, + int ret, + int size, + char *style, + char *fname); +static int falcom_split_data(char *buf, + int entry_num, + char *elm[]); +static void dsp_font_list(FalFontDataList *flist); +static int search_Font_File_Name(FalFontData data, char *fname); + +extern int searchFontFileName(FalFontData data, char *fullPathName); +extern int falReadFontProp(char *file, + int protect_key_data, + FalFontData *databuff, + int islock); + +/* + * get "character size" and "letter size" from a character of an interface + * + * return code¡§ + * 1... get "character size" + * 2... get "character size" and "letter size" + * -1... NG + */ + +#define BODY_ONLY 1 +#define BODY_AND_LETTER 2 + +static int +GetSize( +char *size_str, /* a character of a size */ +int *body, /* set "character size" (output) */ +int *letter) /* set "letter size" (output) */ +{ + char *str_dot; + /* char *str_end; */ + int bdy, ltr; + + str_dot = strchr( size_str, '.'); + /* str_end = strchr( size_str, '\0'); */ + + if ( str_dot == NULL) { + /* change a size of "character size"*/ + if (falcom_atoi( size_str, '\0', &bdy ) ==-1) { + return -1; + } + *body = bdy; + return BODY_ONLY; + } + + /* change a size of "character size"*/ + if (falcom_atoi( size_str, '.', &bdy ) ==-1) { + return -1; + } + + /* change a size of "letter size"*/ + str_dot++; + if (falcom_atoi( str_dot, '\0', <r ) ==-1) { + return -1; + } + *body = bdy; + *letter = ltr; + return BODY_AND_LETTER; +} + + +/* + * + * change numerical character for numarical data + * + */ + +int +falcom_atoi( + char *str, /* numerical character */ + char ed_code,/* an end code in numerical character */ + int *val) /* set numarical data */ +{ + char *ptr; + char *str_end; + int tmp; + + /* get an end index */ + str_end = strchr( str, ed_code ); + + /* change numarical data */ + tmp = (int)strtol(str, &ptr, 10); + + /* error check */ + if ((ptr == str) || (ptr != str_end)) { + return(-1); + } + *val = tmp; + return 0; +} + + +static int +falcom_cr_to_null(char *buf) +{ + buf = strchr( buf, '\n'); + if (buf != NULL) { + *buf = '\0'; + } + return 0; +} + + + +#define FALCOM_DATA_ELM 3 + +#define FALCOM_ELM_SIZE 0 +#define FALCOM_ELM_STYLE 1 +#define FALCOM_ELM_FNAME 2 + + +int +GetDefaultFile( + int size, /* character size */ + char *style, /* character style */ + char *fname) /* buffer */ +{ + FILE *fp; + int ret; + + + char *locale; + char *fal_search_path; + char uflist_d[BUFSIZE]; + char uflist_c[ BUFSIZE ]; + char uflist_l[ BUFSIZE ]; + + GETLISTFILEPATH( locale, fal_search_path, uflist_d, uflist_c, uflist_l, UDFLIST_DEF ) ; + + if ( ( fp = fopen( uflist_l, "r" ) ) == NULL ) { + if ( ( fp = fopen( uflist_c, "r" ) ) == NULL ) { + if ( ( fp = fopen( uflist_d, "r" ) ) == NULL ) { + return FAL_ERROR; + } + } + } + + ret = get_default_file( fp, size, style, fname ); + fclose( fp ); + return ret; +} + + +int +get_default_file( + FILE *fp, + int size, /* character size */ + char *style, /* character style */ + char *fname) /* buffer */ +{ + char buf[BUFSIZE]; /* buffer */ + int size_tmp; /* size (read file) */ + int ret; + char *elm[FALCOM_DATA_ELM]; + + ret = 0; + + /* read from a file */ + while( fgets(buf, BUFSIZE, fp) != (char *)NULL ) { + + falcom_cr_to_null( buf ); + if ((buf[0] == '#') || (buf[0] == '\0')) { + continue; + } + if (falcom_split_data( buf, FALCOM_DATA_ELM, &elm ) == -1) { + ret = -4; + continue; + } + if (falcom_atoi( elm[FALCOM_ELM_SIZE], '\0', &size_tmp ) == -1) { + ret = -4; + continue; + } + if ( style ) { + if ((size_tmp == size) && !strcmp(elm[FALCOM_ELM_STYLE], style)) { + strcpy( fname, elm[FALCOM_ELM_FNAME] ); + fclose( fp ); + return 0; + } + } + } + if (ret != 0) { + return ret; + } + + if ( feof(fp) != 0 ) { + return -2; + } + return -3; +} + +/**************************************************************/ +/* read from a file and divide a data that read from file */ +/**************************************************************/ + +static int +falcom_split_data( +char *buf, /* read a font information character array from a file */ +int entry_num, +char *elm[]) +{ + int cnt; /* counter */ + int strtop_flg; /* flag of a head of a character array */ + + /* divide a data */ + strtop_flg = 1; + for (cnt=0 ; *buf != '\0' && cnt < entry_num ; buf++){ + /* skip a separate character */ + if ((*buf == '\t') || (*buf == ' ')) { + /* change NULL */ + *buf = '\0'; + /* skip a separate character */ + do { + buf++; + } while((*buf == '\t') || (*buf == ' ')); + strtop_flg = 1; + } + if (strtop_flg) { + elm[cnt] = buf; + cnt++; + strtop_flg = 0; + } + } + /* check a data's number */ + if (cnt != entry_num ) { + return -1; + } + return 0; +} + + +char * +falcom_get_base_name( char *str /* a full path character of a file name */ ) +{ + char *str_slash; + + str_slash = strrchr( str, '/'); + if ( str_slash == NULL ) { + return str; + } + return ++str_slash; +} + + +static int +is_letter_size_not_only_one( FalFontDataList *lst /* a font list */ ) +{ + int i, letter_cmp; + + letter_cmp = lst->list[0].letter.h; + for (i=0 ; i < lst->num ; i++) { + if (lst->list[i].letter.h != letter_cmp){ + return 1; + } + } + return 0; +} + + +/* + * get a real file name from a character of "size" and "style" + * + * return code¡§ + * 0 ... OK + * -1 ... NG + * + */ +int +GetFileName( + char *com, /* a character of a command name(case error) */ + char *size_str, /* a character of "size" */ + char *style, /* a character of "style" */ + int codeset, /* a codeset */ + char *ofile) /* set a target file name (output) */ +{ + int body, letter; + int size_sw; /* a size flag */ + char buf[BUFSIZE] ; /* an area for a file name */ + char *filename; /* a pointer for a file name */ + char fname[BUFSIZE]; /* a pointer for a file name */ + FalFontDataList *lst; /* a font list */ + FalFontData key; /* search an information of a font */ + unsigned int mask; /* search a mask of a font */ + int i, ret; + struct stat statbuf ; + char *locale; + + char *fal_search_path; + char uflist_d[ BUFSIZE ]; + char uflist_c[ BUFSIZE ]; + char uflist_l[ BUFSIZE ]; + + GETLISTFILEPATH( locale, fal_search_path, uflist_d, uflist_c, uflist_l, UDFLIST_DEF ) ; + + /* change a character of a size */ + if ((size_sw = GetSize(size_str, &body, &letter)) == -1) { + USAGE2("%s : The specification of the character size is improper.\"%s\"\n", + com, size_str); + return -1; + } + + mask = 0; + mask |= FAL_FONT_MASK_UNDEFINED ; + mask |= FAL_FONT_MASK_DEFINED ; + memset( &key, '\0', sizeof(FalFontData) ) ; + /* set information to search fonts */ + + key.cd_set = FALGETFALCODESET( codeset ) ; + mask |= FAL_FONT_MASK_CODE_SET ; + + switch( size_sw ) { + case BODY_AND_LETTER: + key.letter.h = letter; + mask |= FAL_FONT_MASK_LETTER_H; + case BODY_ONLY: + key.size.h = body; + mask |= FAL_FONT_MASK_SIZE_H; + } + + /* aet and check an information of a style */ + COMM_SETSTYLE_TO_FONTDATA( style, key, mask ) ; + + /* get a font information */ + if (FalGetFontList( &key, mask, &lst ) == FAL_ERROR ) { + ErrMsgTable_FalGetFontList( com, fal_utyerror, fal_utyderror ); + return -1; + } + + if ( lst->num == 0 ) { + USAGE3("%s : The user defined character of the specified size and style does not exist.\"%s , %s\"\n", + com, size_str, (style)?style:" "); + FalFreeFontList( lst ); + return -1; + } + + memset( fname, '\0', sizeof(fname) ) ; + switch( size_sw ) { + case BODY_ONLY: + + if ( is_letter_size_not_only_one(lst) ) { + ret = GetDefaultFile( key.size.h, style, buf) ; + if ( ret < 0 ) { + COMM_GET_DEFAULTFILE_ERROR( buf, com, ret, key.size.h, style, uflist_d, uflist_c, uflist_l, statbuf ) ; + } + for ( i = 0 ; i < lst->num; i++ ) { + ret = search_Font_File_Name( lst->list[i], fname ); + if ( ret == FAL_ERROR ) { + FalFreeFontList( lst ); + return -1; + } + filename = falcom_get_base_name( fname ); + if ( (buf[0] != '\0' && fname[0] != '\0') + && !strcmp( buf, filename ) ) { + strcpy( ofile, fname ); + FalFreeFontList( lst ); + return 0; + } + } + COMM_DISPERRORFILE( com, lst, style, i, size_str ) ; + FalFreeFontList( lst ); + return -1; + } + + case BODY_AND_LETTER: + switch( lst->num ) { + case 1: + ret = search_Font_File_Name( lst->list[0], fname ); + if ( ret == FAL_ERROR ) { + FalFreeFontList( lst ); + return -1; + } + strcpy( ofile, fname ); + FalFreeFontList( lst ); + return 0; + default: + ret = GetDefaultFile( key.size.h, style, buf); + if ( ret < 0 ) { + buf[0]='\0'; + } + for( i = 0 ; i < lst->num; i++ ) { + ret = search_Font_File_Name( lst->list[0], fname ); + if ( ret == FAL_ERROR ) { + FalFreeFontList( lst ); + return -1; + } + filename = falcom_get_base_name( fname ); + if ( (buf[0] != '\0' && fname[0] != '\0') + && !strcmp( buf, filename ) ) { + strcpy( ofile, fname ); + FalFreeFontList( lst ); + return 0; + } + } + USAGE1("%s : Two or more corresponding user defined characters exist.\n", com); + for ( i = 0 ; i < lst->num; i++ ) { + ret = search_Font_File_Name( lst->list[i], fname ); + if ( ret == FAL_ERROR ) { + FalFreeFontList( lst ); + return -1; + } + fprintf( stdout, "\t%s\n", fname ); + } + FalFreeFontList( lst ); + return -1; + } /* <--- switch( lst->num ) { */ + } /* <--- switch( size_sw ) { */ + return -1 ; +} + + +/* take out an error message of "FalGetFontList()" */ + +/* + * Error messages(by origin) + */ +char *fal_errmsg_org[0xff] = { +/* 0x00 */ + " ", + "Cannot open the font file.", + "Cannot read the font file.", + "There is no more memory .", + "Fatal error occurred.", + "The specified font file does not exist.", + "This font is not a pcf or snf format.", + "Cannot open fonts.list file.", + "The format of fonts.list file is illegal.", + "The descriptions of the fonts.list file are incorrect.", + "The format of fonts.list file is illegal.", + "Cannot open fonts.dir file.", + "Cannot read fonts.dir file.", + "Cannot read font properties.", + "Cannot get \"FONT\" property.", + "Cannot get \"FAMILY_NAME\" property.", +/* 0x10 */ + "This font file is already opened by other application.", + "Cannot lock font file.", + "Cannot unlock font file.", + "Cannot get lock information from the font file.", + "Cannot find the specified font file.", + "Cannot read NLS database.", + "Cannot get charset names from NLS database.", + "Charset name not defined in NLS database.", + "The specified font has not been opened.", + "Fatal error occurred.", + " "," "," "," "," "," ", +/* 0x20 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x30 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x40 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x50 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x60 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x70 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x80 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0x90 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xa0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xb0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xc0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xd0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xe0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ", +/* 0xf0 */ + " "," "," "," "," "," "," "," "," "," "," "," "," "," "," " +} ; + + +void +ErrMsgTable_FalGetFontList( + char *com, /* command name */ + int utyerr, /* fal_utyerror */ + int utyderr) /* fal_utyderror */ +{ + char *fontsdir, *locale ; + + if( (locale = (char *)getenv( "LANG" )) == NULL ){ + locale = "C" ; + } + + if( (fontsdir = (char *)getenv( "DTUDCFONTS" )) == NULL ) { + fontsdir = DTUDCFONTSLISTDIR ; + } + switch( utyerr ) { + case 1: + if( fal_utyerrno ) { + USAGE2("%s : %s\n", com, fal_errmsg_org[ fal_utyerrno & 0xff ] ) ; + return ; + } + USAGE4("%s : The font directory information file(%s/%s/%s) cannot be opened.\n", + com, fontsdir, locale, FONTS_LIST_FILE ) ; + break; + case 2: + USAGE4("%s : Information cannot be read from the font directory information file(%s/%s/%s).\n", com, fontsdir, locale, FONTS_LIST_FILE ); + break; + case 3: + USAGE1("%s : The work area cannot be secured.\n", com ); + break; + case 7: + USAGE4("%s : Abnormality is found in the content of the font directory information file((%s/%s/%s).\n", + com , fontsdir, locale, FONTS_LIST_FILE); + break; + case 8: + USAGE4("%s : The font directory information file(%s/%s/%s) cannot be opened.\n", + com , fontsdir, locale, FONTS_LIST_FILE); + break; + case 9: + USAGE4("%s : Information cannot be read from the font directory information file(%s/%s/%s).\n", + com , fontsdir, locale, FONTS_LIST_FILE); + default: + if( fal_utyerrno ) { + USAGE2("%s : %s\n", com, fal_errmsg_org[ fal_utyerrno & 0xff ] ) ; + return ; + } + USAGE1("%s : Terminates abnormally.\n", com ); + } +} + +/* take out an error message of "GetDefaultFile()" */ + +static void +ErrMsgTable_GetDefaultFile( +char *com, /* a command name */ +int ret, /* return code */ +int size, /* a character size */ +char *style, /* a character style */ +char *fname) /* user defined character information file name */ +{ + switch (ret) { + case -1: + USAGE2("%s : The user defined character information file cannot be opened. \"%s \"\n", + com, fname); + break; + case -2: + USAGE4("%s : The representative user defined character of the character size (%d) and style (%s) is not defined.\"%s\"\n", + com, size, (style)?style:" ", fname); + break; + case -3: + USAGE2("%s : Information cannot be read from the user defined character information file.\"%s\"\n", com, fname); + break; + case -4: + USAGE2("%s : The mistake is found in the description of the user defined character information file. \"%s\"\n", com, fname); + break; + } +} + + +/* + * if an end character of a file name is "/",it is cleared + * + * return code¡§none + * none + */ + +void +fal_cut_tailslash( char *name ) +{ + char *p; + + p = strrchr( name, '\0'); + if (p == NULL) { + return; + } + for (p-- ; (p>=name) && (*p == '/') ; p--) { + *p = '\0'; + } +} + + +/* + * get a real file name from a link file name + * + * return code¡§ + * OK¡¡¡¥¡¥a pointer of a file name + * NG¡¡¡¥¡¥NULL + * + */ + +char * +GetRealFileName( char *name ) +{ + static char *ret_name ; + char link_name[BUFSIZE]; + int len; + + struct stat st; + + AllocString( ret_name, name, NULL ) ; + /* strcpy( ret_name, name ) ; */ + fal_cut_tailslash( ret_name ); /* for example /tmp/aa/ --> /tmp/aa */ + + while ( 1 ) { + if ( lstat( ret_name, &st ) == -1) { + FreeString( ret_name ) ; + return NULL; + } + errno = 0; + if ( ( len = readlink( ret_name, link_name, BUFSIZE ) ) == -1 ) { + if ( errno == EINVAL ) { + return( ret_name ) ; + /* return( strdup( ret_name ) ) ; */ + } else { + FreeString( ret_name ) ; + return NULL; + } + } + link_name[len-1] = 0; + if ( link_name[0] == '/' ) { + /* strcpy( ret_name, link_name ) ; */ + FreeString( ret_name ) ; + AllocString( ret_name, link_name, NULL ) ; + } else { + char *slash; + + slash = strrchr( ret_name, '/' ); + if (slash != NULL) { + *slash = '\0'; + fal_cut_tailslash( ret_name ); + ResizeString( ret_name, NULL ); + AddString(ret_name, "/", NULL); + } else { + /* ret_name[0] = '\0' ; */ + FreeString( ret_name ) ; + AllocString(ret_name, "/", NULL); + } + /* strcat( ret_name, "/" ) ; + strcat( ret_name, link_name ) ; */ + AddString( ret_name, link_name, NULL ) ; + } + } +} + + + +/* + * funtctions for search fonts by XLFD and NLS database + */ + +int +IsInRegion( + int code , + int num_gr , + FalGlyphRegion *gr) +{ + int i ; + if( code < MIN_CODE || code > MAX_CODE ) return -1 ; + for( i=0; i<num_gr; i++ ) { + if( gr[i].start < MIN_CODE || gr[i].end > MAX_CODE ) continue ; + if( gr[i].start <= code && gr[i].end >= code ) + return 0 ; + } + return -1 ; +} + + + + +static int +search_Font_File_Name( FalFontData data, char *fname ) +{ + FalFontID fid ; + FalFontDataList *flist ; + int mask ; + char *tmp_fname ; + + mask = FAL_FONT_MASK_UNDEFINED | FAL_FONT_MASK_DEFINED ; + + if( data.xlfdname ) mask |= FAL_FONT_MASK_XLFDNAME ; + if( data.size.h ) mask |= FAL_FONT_MASK_SIZE_H ; + if( data.size.w >= 0 ) mask |= FAL_FONT_MASK_SIZE_W ; + if( data.style.name ) mask |= FAL_FONT_MASK_STYLE_NAME ; + if( data.cd_set ) mask |= FAL_FONT_MASK_CODE_SET ; + + if( data.letter.w ) mask |= FAL_FONT_MASK_LETTER_W ; + if( data.letter.h ) mask |= FAL_FONT_MASK_LETTER_H ; + if( data.letter.x ) mask |= FAL_FONT_MASK_LETTER_X ; + if( data.letter.y ) mask |= FAL_FONT_MASK_LETTER_Y ; + + if( data.style.def ) mask |= FAL_FONT_MASK_STYLE_DEF ; + if( data.shape.name ) mask |= FAL_FONT_MASK_SHAPE_NAME ; + if( data.shape.def ) mask |= FAL_FONT_MASK_SHAPE_DEF ; + COMM_SBCHR_SETFONTDATA( data, mask ) ; + if( data.prm ) mask |= FAL_FONT_MASK_PERMISSION ; + + fid = FalOpenSysFont( &data, mask, &flist ) ; + if( fid == 0 ) { + memset( fname, '\0', sizeof(fname) ) ; + if( flist ){ + dsp_font_list( flist ) ; + FalFreeFontList( flist ) ; + return(-1); + } else { + switch( fal_utyerror ) { + case _FAL_OPEN_ER : + case _FAL_READ_ER : + case _FAL_STAT_ER : + switch( fal_utyderror ) { + case EACCES : + case ENOENT : + return(0) ; + default : + USAGE3("There is no font file correspond to specified font.\n(%s)\n fal_utyerror = %d fal_utyderror = %d\n", + ((data.xlfdname)?data.xlfdname:"null font name"), fal_utyerror, fal_utyderror ) ; + return(-2) ; + } + case _FAL_MALOC_ER : + USAGE("System call error occurred.\n" ) ; + return(-2) ; + default : + USAGE3("There is no font file correspond to specified font.\n(%s)\n fal_utyerror = %d fal_utyderror = %d\n", + ((data.xlfdname)?data.xlfdname:"null font name"), fal_utyerror, fal_utyderror ) ; + return(-2) ; + } + } + } + if( FalFontIDToFileName( fid, &tmp_fname ) == FAL_ERROR ) { + USAGE3("There is no font file correspond to specified font.\n(%s)\n fal_utyerror = %d fal_utyderror = %d\n", + ((data.xlfdname)?data.xlfdname:"null font name"), fal_utyerror, fal_utyderror ) ; + FalCloseFont( fid ) ; + return(-1) ; + } + strcpy( fname, tmp_fname ) ; + FalFree( tmp_fname ) ; + FalCloseFont( fid ) ; + + return(0) ; +} + + +int +GetUdcFileName( + char *com, + int code_no, + char *xlfdname, + char *fname) +{ + FalFontData data ; + + if( !xlfdname || !fname ) { + USAGE1("%s: null parameter\n", com ) ; + return(-1) ; + } + memset( &data, '\0', sizeof(FalFontData) ) ; + data.size.w = -1 ; + data.xlfdname = xlfdname ; + data.cd_set = FALGETFALCODESET( code_no ) ; + return( search_Font_File_Name( data, fname ) ) ; +} + + +static void +dsp_font_list( FalFontDataList *flist ) +{ + int i ; + + USAGE(" code set / size / style / xlfd\n" ) ; + USAGE("-------------------------------------------------------\n" ) ; + for( i=0; i<flist->num; i++ ) { + USAGE4("\t%d\t%d\t%s\t%s\n", + FALCODESETTONUM( flist->list[i].cd_set ), + flist->list[i].size.h, + flist->list[i].style.name, + flist->list[i].xlfdname + ) ; + } +} + + +int +GetUdcRegion( + char *com, + int codeset, + char *gpf_file, + int *num_gr, + FalGlyphRegion **gr) +{ + FalFontData fdata ; + char *locale, *char_set, *tmp_gpf ; + + if( (locale = (char *)getenv( "LANG" )) == NULL ){ + locale = "C" ; + } + /* parameter check */ + if( gpf_file == NULL || gr == NULL ) { + USAGE1("%s : null parameters.\n", com); + return( -1 ) ; + } + + /* get font properties */ + tmp_gpf = (char *)GetRealFileName( gpf_file ) ; + if( tmp_gpf == NULL ){ + return -1 ; + } + if( falReadFontProp( tmp_gpf, FAL_FONT_PRM, &fdata, 1 ) ) { + USAGE1("%s : Failed to get font properties.\n", com ) ; + return -1 ; + } + + GETCHARSETSTR( char_set, fdata.xlfdname ) ; + if( FalGetUDCGIArea( locale, FALGETFALCODESET(codeset), char_set, gr, num_gr ) == FAL_ERROR ) + { + USAGE3("%s : Failed to get UDC code region. ( code set %d charset %s )\n", + com, codeset, char_set ) ; + return( -1 ); + } + + if( *num_gr == 0 ) { + USAGE3("%s : Failed to get UDC code region. ( code set %d charset %s )\n", + com, codeset, char_set ) ; + return -1 ; + } + + return(0) ; +} + + + +#define MAX_CODESET 8 + +int +DispUdcCpArea( FILE *fp ) +{ + int cd_set, j ; + FalFontDataList *fls ; + FalFontData fdata ; + int mask ; + FalCodeRegion *cr ; + int num_cr ; + char *locale ; + + if( (locale = (char *)getenv( "LANG" )) == NULL ){ + locale = "C" ; + } + memset( &fdata, 0, sizeof(FalFontData) ) ; + mask = 0 ; + mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED | + FAL_FONT_MASK_CODE_SET ; + + for( cd_set=0; cd_set<MAX_CODESET; cd_set++ ){ + char *char_set ; + fdata.cd_set = FALGETFALCODESET(cd_set) ; + if( FalGetFontList(&fdata, mask, &fls) == FAL_ERROR ){ + return -1 ; + } + if( fls->num == 0 ){ + continue ; + } + GETCHARSETSTR( char_set, fls->list[0].xlfdname ) ; + if( FalGetUDCCPArea( locale, + fls->list[0].cd_set, char_set, &cr, &num_cr ) == FAL_ERROR ){ + return -1 ; + } + if( num_cr == 0 ){ + continue ; + } + /* display UDC code region */ + USAGE1(" %d", cd_set ) ; + for( j=0; j<num_cr; j++ ){ + USAGE2("\t\t0x%x - 0x%x\n", cr[j].start, cr[j].end ) ; + } + if( FalFreeFontList( fls ) == FAL_ERROR ){ + return -1 ; + } + } + return 0 ; +} + + + +int +GetUdcFontName( + char *gpf_file , + char *bdf_file , + char **fontname) +{ + FILE *fp ; + pid_t chld_pid = 0; +#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__) + int chld_stat ; +#else + union wait chld_stat ; +#endif + struct ptobhead head ; + char *p, *tmp_font ; + char readbuf[BUFSIZE], fntbuf[BUFSIZE] ; + unsigned int getstat; + int fd[2]; + + p = tmp_font = NULL ; + /* + * get temorary file + */ + memset( &head, 0, sizeof(struct ptobhead) ) ; + if( gpf_file ){ + head.snf_file = GetRealFileName( gpf_file ) ; + if( head.snf_file == NULL ) return STAT_ERROR ; + }else if( bdf_file ){ + head.bdf_file = GetRealFileName( bdf_file ) ; + if( head.bdf_file == NULL ) return STAT_ERROR ; + }else{ + return STAT_ERROR ; + } + + /* + * write BDF header into FIFO + */ + if (head.snf_file != NULL) { + if (pipe(fd) != 0) { + return PIPE_ERROR; + } + switch (chld_pid = fork()) { + case 0: + close(1); + if(dup(fd[1]) < 0) { + return(DUP_ERROR); + } + close(fd[0]); + close(fd[1]); + execl( oakgtobdf, oakgtobdf, head.snf_file, "-H", 0); + USAGE1("Cannot execute %s\n", oakgtobdf ) ; + return EXEC_ERROR; + case -1: + return(FORK_ERROR); + default: + break; + } + close(fd[1]); + if((fp = (FILE *)fdopen(fd[0], "r")) == NULL) { + close( fd[0] ); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + return FDOPEN_ERROR; + } + } else { + if ((fp = fopen(head.bdf_file, "r")) == NULL) { + return(BDF_OPEN_HEAD); + } + } + + /* + * read BDF header + */ + getstat = 0 ; + while ( 1 ) { + if (fgets(readbuf, BUFSIZE, fp) == NULL) { + fclose( fp ); + if (head.snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + p = readbuf; + SCAN_TO_NONSP(p); + + if (!strncmp( p, "ENDPROPERTIES", strlen("ENDPROPERTIES") )) { + fclose( fp ); + if (head.snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + if (!strncmp( p, "FONT ", strlen("FONT ") )) { + char *sp, *ep ; + sp = ep = p ; + SCAN_TO_NONSP(sp); + sp++ ; + while( *ep != '\n' ){ + ep++ ; + } + *ep = '\0' ; + snprintf(fntbuf, sizeof(fntbuf), "%s", sp) ; + getstat |= 0x01 ; + fclose( fp ); + if (head.snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + break; + } + } + + if( getstat != 0x01 ){ + return BDF_INVAL ; + } + + /* + * dup font name + */ + if( (tmp_font = (char *)strdup( fntbuf )) == NULL ){ + return MALLOC_ERROR ; + } + *fontname = tmp_font ; + + return 0 ; +} diff --git a/cde/programs/dtudcfonted/libfuty/lock.c b/cde/programs/dtudcfonted/libfuty/lock.c new file mode 100644 index 000000000..b6fddf3bc --- /dev/null +++ b/cde/programs/dtudcfonted/libfuty/lock.c @@ -0,0 +1,128 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: lock.c /main/5 1996/11/08 02:07:28 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <errno.h> +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include "udcutil.h" + +/* + * FileLock( fd ) + * fd: file descripter + * + * lock a file by a writing mode + * + * normal end : 0 + * abnormal end : -1 + * + */ + +int +FileLock( int fd ) +{ + + struct flock flpar; + + + flpar.l_type = F_RDLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_SETLK, &flpar ) == -1 ) { + USAGE("Write lock not success \n" ); + return -1; + } + + return 0; +} + + +/* + * FileUnLock( fd ) + * + * free a file by a writing mode + * + * normal end : 0 + * abnormal end : -1 + */ + +int +FileUnLock( int fd ) +{ + struct flock flpar; + + + flpar.l_type = F_UNLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_SETLK, &flpar ) == -1 ){ + USAGE("File unlock not success \n" ); + return -1; + } + return 0; +} + +/* + * isLock( fd ) + * + * search whether file is locked by a writing mode + * + * 1 : file is locked by a writing mode + * 0 : file isn't locked by a writing mode + */ + +int +isLock( int fd ) +{ + struct flock flpar; + + + flpar.l_type = F_WRLCK; + flpar.l_start = 0; + flpar.l_len = 0; + flpar.l_whence = 0; + + if ( fcntl( fd, F_GETLK, &flpar ) == -1 ) { + USAGE("Inquiry of file lock not sucess \n" ); + return -1; + } + + if ( flpar.l_type == F_UNLCK ){ + return 0 ; + } else { + return 1 ; + } +} diff --git a/cde/programs/dtudcfonted/libfuty/oakfuty.c b/cde/programs/dtudcfonted/libfuty/oakfuty.c new file mode 100644 index 000000000..b1ad17c8b --- /dev/null +++ b/cde/programs/dtudcfonted/libfuty/oakfuty.c @@ -0,0 +1,1419 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* $XConsortium: oakfuty.c /main/12 1996/11/11 10:55:57 drk $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#ifndef SVR4 +#if !defined( SYSV ) +#include <sys/resource.h> +#endif +#include <sys/wait.h> +#else +#include <sys/mman.h> +#include <wait.h> +#endif + +#include <unistd.h> +#include <sys/stat.h> +#include <signal.h> +#include <fcntl.h> + +#include "bdfgpf.h" +#include "udcutil.h" + +static void exline(char *sp, char *dbuf, int sw, int dw); + +char *oakgtobdf; +char *bdftosnf = BDFTOSNF; +char *bdftopcf; + +static int put_file_create_err_msg = 0; + +#define DEVICE_FAIL 2 +#define WRITE_FAIL 3 +#define OPEN_FAIL 4 +#define READ_FAIL 5 + +int +ReadBdfHeader(struct btophead *head, char *buf) +{ + char *p; + unsigned int getstat = 0; + + if (NULL == fgets(buf, BUFSIZE, head->input)) { + return(BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p) + + if (strncmp(p, STARTFONT, STARTFONTsz)) { + return(BDF_INVAL); + } + + while( 1 ) { + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p) + if (!strncmp(p, SIZE, SIZEsz)) { + if ((sscanf(p, "SIZE %f%d", + &(head->bdf_point), &(head->bdf_xdpi))) != 2) { + return(BDF_INVAL); + } + getstat |= 0x01; + } else if (!strncmp(p, FONTBOUNDINGBOX, FONTBOUNDINGBOXsz)) { + if (sscanf(p, "FONTBOUNDINGBOX %d%d%d%d", + &(head->bdf_width), &(head->bdf_height), + &(head->bdf_x), &(head->bdf_y)) != 4) { + return BDF_INVAL; + } + getstat |= 0x02; + + } else if (!strncmp(p, CHARS, CHARSsz)) { + if ((sscanf(p, "CHARS %d", &(head->num_chars))) != 1) { + return(BDF_INVAL); + } + getstat |= 0x04; + } else if (!strncmp(p, STARTCHAR, STARTCHARsz)) { + break; + } + } + + if (getstat != 0x07) { + return(BDF_INVAL); + } + return 0; +} + + +int +ReadGpfHeader(struct ptobhead *head, char *buf) +{ + char *p; + unsigned int getstat = 0; + + while(1) { + if (getstat == 0x07) break; + + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return GPF_INVAL; + } + p = buf; + SCAN_TO_NONSP(p) + + if (!strncmp(p, NUMFONTS, NUMFONTSsz)) { + if (sscanf(p, "numfonts:%d", &(head->num_chars)) != 1) { + return(GPF_INVAL); + } + getstat |= 0x01; + } else if (!strncmp(p, WIDTH, WIDTHsz)) { + if (sscanf(p, "width:%d", &(head->p_width)) != 1) { + return(GPF_INVAL); + } + getstat |= 0x02; + } else if (!strncmp(p, HEIGHT, HEIGHTsz)) { + if (sscanf(p, "height:%d", &(head->p_height)) != 1) { + return(GPF_INVAL); + } + getstat |= 0x04; + } + } + return 0; +} + + +int +WriteBdfHeader( struct ptobhead *head ) +{ + FILE *fp; + int fd[2]; + unsigned int getstat; + char buf[BUFSIZE], *p; + + pid_t chld_pid = 0; +#if defined( SVR4 ) || defined( SYSV ) || defined(CSRG_BASED) || defined(__linux__) + int chld_stat ; +#else + union wait chld_stat ; +#endif + + + if (head->snf_file != NULL) { + if (pipe(fd) != 0) { + return PIPE_ERROR; + } + switch (chld_pid = fork()) { + case 0: + close(1); + if(dup(fd[1]) < 0) { + return(DUP_ERROR); + } + close(fd[0]); + close(fd[1]); + execl( oakgtobdf, oakgtobdf, head->snf_file, 0); + + return EXEC_ERROR; + + case -1: + return(FORK_ERROR); + + default: + break; + } + close(fd[1]); + if((fp = (FILE *)fdopen(fd[0], "r")) == NULL) { + close( fd[0] ); + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + return FDOPEN_ERROR; + } + } else { + if ((fp = fopen(head->bdf_file, "r")) == NULL) { + return(BDF_OPEN_HEAD); + } + } + + getstat = 0; + + while ( 1 ) { + if (fgets(buf, BUFSIZE, fp) == NULL) { + fclose( fp ); + if (head->snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p); + + if (!strncmp(p, CHARS, CHARSsz)) { + fclose( fp ); + if (head->snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + break; + } + + fprintf(head->output, "%s", buf); + + if (!strncmp(p, SIZE, SIZEsz)) { + if ((sscanf(p, "SIZE %f%d", + &(head->bdf_point), &(head->bdf_xdpi))) != 2) { + fclose(fp); + if (head->snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return(BDF_INVAL); + } + getstat |= 0x01; + continue; + } + if (!strncmp(p, FONTBOUNDINGBOX, FONTBOUNDINGBOXsz)) { + if ( sscanf( p, "FONTBOUNDINGBOX %d%d%d%d", + &(head->bdf_width), + &(head->bdf_height), + &(head->bdf_x), + &(head->bdf_y)) != 4 + ) { + fclose(fp); + if (head->snf_file != NULL) { + kill( chld_pid, SIGKILL ); + WaitID( chld_pid, chld_stat ) ; + } + return BDF_INVAL; + } + getstat |= 0x02; + continue; + } + get_charset_registry(head, p) ; + } + + + if (getstat != 0x03) { + return BDF_INVAL; + } + + return 0; +} + + +void +WriteGpfHeader( struct btophead *head ) +{ + fprintf(head->output, "numfonts:%d\n", head->num_chars); + fprintf(head->output, "width:%d\n", head->p_width ); + fprintf(head->output, "height:%d\n", head->p_height ); +} + + + + +int +WritePtnToBdf( struct ptobhead *head ) +{ + int msize, swidth, rtn, i, nchar; + char *zoomptn; + int bbw, bbh, bbx, bby, dw ; + char glyph_name[BUFSIZE] ; + + nchar = head->num_chars; + put_default_chars(head, nchar, rtn) ; + + if (head->zoomf) { + msize = ((head->bdf_width + 7) / 8) * head->bdf_height; + if ((zoomptn = (char *)malloc(msize)) == NULL) { + return(MALLOC_ERROR); + } + } + + for (i=0; i<head->num_chars; i++) { + sprintf( glyph_name, "%x", head->code[i]); + swidth = (head->bdf_width * 72270)/((int)(head->bdf_point * (float)head->bdf_xdpi)); + dw = head->bdf_width ; + bbw = head->bdf_width ; + bbh = head->bdf_height ; + bbx = head->bdf_x ; + bby = head->bdf_y ; + + fprintf(head->output, "STARTCHAR %s\n", glyph_name ); + fprintf(head->output, "ENCODING %d\n", head->code[i]); + fprintf(head->output, "SWIDTH %d 0\n", swidth ); + fprintf(head->output, "DWIDTH %d 0\n", dw ); + fprintf(head->output, "BBX %d %d %d %d\n", bbw, bbh, bbx, bby ); + fprintf(head->output, "BITMAP\n"); + + if (head->zoomf) { + if ((rtn = PtnZoom(zoomptn, head->ptn[i], head->p_width, + head->p_height, head->bdf_width, head->bdf_height))) { + return(rtn); + } + if( (rtn = PutBdfPtn(zoomptn, head->bdf_width, + head->bdf_height, head->output))) { + return(rtn); + } + } else { + if( (rtn = PutBdfPtn(head->ptn[i], + head->bdf_width, head->bdf_height, head->output))) { + return(rtn); + } + } + fprintf(head->output, "ENDCHAR\n"); + free(head->ptn[i]); + } + fprintf(head->output, "ENDFONT\n"); + return(0); +} + + + + +int +putDefaultChars( struct ptobhead *head ) +{ + int swidth, bytew, i, j; + unsigned int posbit ; + unsigned char *ptnbuf, *ptnbuf2 ; + unsigned char tmp; + + put_default_encode( head ) ; + swidth = (head->bdf_width * 72270)/((int)(head->bdf_point * (float)head->bdf_xdpi)); + fprintf(head->output, "SWIDTH %d 0\n", swidth); + fprintf(head->output, "DWIDTH %d 0\n", head->bdf_width); + fprintf( head->output, "BBX %d %d %d %d\n", head->bdf_width, head->bdf_height, head->bdf_x, head->bdf_y ); + fprintf(head->output, "BITMAP\n"); + + bytew = (head->bdf_width + 7) / 8; + if ((ptnbuf = (unsigned char *)malloc(bytew * 2)) == NULL) { + return(MALLOC_ERROR); + } + put_default_bitmap(head, bytew, posbit, i, j, ptnbuf, ptnbuf2, tmp) ; + + fprintf(head->output, "ENDCHAR\n"); + free(ptnbuf); + return 0; +} + + +int +WritePtnToGpf( struct btophead *head ) +{ + int msize, rtn, i; + char *zoomptn; + + + if (head->zoomf) { + msize = ((head->p_width + 7) / 8) * head->p_height; + if ((zoomptn = (char *)malloc(msize)) == NULL) { + return(MALLOC_ERROR); + } + } + + for (i=0; i<head->num_chars; i++) { + + if ( head->code[i] > 0xff ) { + fprintf(head->output, "code:0x%x\n", SHIFT_ON(head->code[i]) ); + } else { + fprintf(head->output, "code:0x%x\n", head->code[i]); + } + if (head->zoomf) { + if ((rtn = PtnZoom(zoomptn, head->ptn[i], head->bdf_width, + head->bdf_height, head->p_width, head->p_height))) { + return(rtn); + } + if ((rtn = PutGpfPtn(zoomptn, head->p_width, + head->p_height, head->output))) { + return(rtn); + } + } else { + if ((rtn = PutGpfPtn(head->ptn[i], + head->bdf_width, head->bdf_height, head->output))) { + return(rtn); + } + } + free(head->ptn[i]); + } + fprintf(head->output, "enddata\n"); + return(0); +} + + +int +ReadBdfToMemory(struct btophead *head, char *buf) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + + if ( ( code > head->end_code ) + || ( code < head->start_code ) + || ( !IN_CODE( head->code_category, SHIFT_ON( code ) ) ) + || COMM_ISDEFAULTCHAR( code ) + ) { + continue; + } + head->code[num_char] = code; + if ( ( ptn = head->ptn[num_char++] = (char *)malloc( bsize ) ) == NULL ) { + return(MALLOC_ERROR); + } + + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} + + +int +ReadBdfToMemory_with_init( + struct btophead *head, + int init_start, + int init_end, + char *buf) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->bdf_width + 7) / 8; + bsize = mwidth * head->bdf_height; + while(1) { + if ((rtn = GetBdfCode(head, buf, &code)) < 0) { + return(rtn); /* contain BDF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + + if ( ( code > head->end_code ) + || ( code < head->start_code ) + || ( !IN_CODE( head->code_category, SHIFT_ON( code ) ) ) + || ( ( code >= init_start ) && ( code <= init_end ) ) + || COMM_ISDEFAULTCHAR( code ) + ) { + continue; + } + + head->code[num_char] = code; + if ((ptn = head->ptn[num_char++] = + (char *)malloc(bsize)) == NULL) { + return(MALLOC_ERROR); + } + + if ((rtn = GetBdfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} + + +int +GetBdfCode( + struct btophead *head, + char *buf, + int *code +) +{ + char *p; + + while(1) { + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p) + if (!strncmp(p, ENDFONT, ENDFONTsz)) { + return(FILE_END); + } + + if (!strncmp(p, ENCODING, ENCODINGsz)) { + if ((sscanf(p, "ENCODING %d", code)) != 1) { + return(BDF_INVAL); + } + break; + } + } + return(0); +} + +int +GetBdfPtn( + struct btophead *head, + char *buf, + char *ptn, + int mwidth, + int bsize) +{ + int skip, i, j; + char *p; + + while(1) { + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p) + if (!strncmp(p, BITMAP, BITMAPsz)) { + break; + } + } + + ptn[bsize - 1] = 0; + + for (i=0, skip=0; i<head->bdf_height; i++) { + if (skip) { + for(j=0; j<mwidth; j++) { + ptn[j] = 0; + } + ptn += mwidth; + continue; + } + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (BDF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p); + if (!strncmp(p, ENDCHAR, ENDCHARsz)) { + skip = 1; + for(j=0; j<mwidth; j++) { + ptn[j] = 0; + } + ptn += mwidth; + continue; + } + GetBdfLinePtn(ptn, buf, head->bdf_width); + ptn += mwidth; + } + return(0); +} + + +int +ReadGpfToMemory(struct ptobhead *head, char *buf) +{ + int code, mwidth, num_char, bsize, rtn; + char *ptn; + + num_char = 0; + mwidth = (head->p_width + 7) / 8; + bsize = mwidth * head->p_height; + while(1) { + if ((rtn = GetGpfCode(head, buf, &code)) < 0) { + return(rtn); /* contain GPF_INVAL */ + } else if (rtn == FILE_END) { + head->num_chars = num_char; + break; + } + if ( ( code > head->end_code ) + || (code < head->start_code ) + || ( !IN_CODE( head->code_category, SHIFT_ON( code ) ) ) + || COMM_ISDEFAULTCHAR( code ) + ) { + continue; + } + head->code[num_char] = code; + if ((ptn = head->ptn[num_char++] = + (char *)malloc(bsize)) == NULL) { + return(MALLOC_ERROR); + } + + if ((rtn = GetGpfPtn(head, buf, ptn, mwidth, bsize)) != 0) { + return(rtn); + } + } + return(0); +} + + +int +GetGpfCode(struct ptobhead *head, char *buf, int *code) +{ + char *p; + + while(1) { + p = buf; + SCAN_TO_NONSP(p) + + if (!strncmp(p, ENDDATA, ENDDATAsz)) { + return(FILE_END); + } + if (!strncmp(p, CODE, CODEsz)) { + *code = (int)strtol(buf+CODEsz, NULL, 0); + CONVGLYPHINDEX( *code ) ; + break; + } + + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (GPF_INVAL); + } + } + return(0); +} + +int +GetGpfPtn( + struct ptobhead *head, + char *buf, + char *ptn, + int mwidth, + int bsize +) +{ + int skip, i, j; + char *p; + + for (i=0, skip=0; i<head->p_height; i++) { + if (skip) { + for (j=0; j<mwidth; j++) { + ptn[j] = 0; + } + ptn += mwidth; + continue; + } + if (fgets(buf, BUFSIZE, head->input) == NULL) { + return (GPF_INVAL); + } + p = buf; + SCAN_TO_NONSP(p); + if ((!strncmp(p, CODE, CODEsz)) || + (!strncmp(p, ENDDATA, ENDDATAsz))) { + skip = 1; + for (j=0; j<mwidth; j++) { + ptn[j] = 0; + } + ptn += mwidth; + continue; + } + + GetGpfLinePtn(ptn, buf, head->p_width); + ptn += mwidth; + } + return(0); +} + + +void +GetBdfLinePtn(char *mem, char *buf, int width) +{ + int i, iend, len; + char *p, str[3]; + + str[2] = 0; + + SCAN_TO_NONSP(buf); + + iend = (width + 3) / 4; + + if ((len = strlen(buf)) < iend) { + p = buf+len; + for (i=0; i<(iend-len); i++) { + *p++ = '0'; + } + *p ='\0'; + } + + for (i=0; i<iend/2; i++) { + str[0] = *buf++; + str[1] = *buf++; + *mem++ = (char)strtol(str, NULL, 16); + } + if (iend%2) { + str[0] = *buf; + str[1] = 0; + *mem = (char)strtol(str, NULL, 16) << 4; + } +} + +void +GetGpfLinePtn(char *mem, char *buf, int width) +{ + unsigned int skip, i, iend, j; + unsigned char ptn; + + SCAN_TO_NONSP(buf); + + iend = (width + 7) / 8; + + for (i=0, skip=0; i<iend; i++) { + if (skip) { + *mem++ = 0; + continue; + } + for (j=0, ptn = 0; j<8; j++) { + if ((*buf == '\n') || (*buf == 0)) { + skip = 1; + ptn <<= (8-j); + break; + } + if (j) ptn <<= 1; + if (*buf == '0') { + ptn |= 1; + } + buf++; + } + *mem++ = ptn; + } +} + + + + +int +PutBdfPtn(unsigned char *ptn, int width, int height, FILE *fp) +{ + int i, j, nbyte ; + unsigned char *pbuf, x, c; + static unsigned char *buf=NULL; + + if (buf==NULL) { + buf = (unsigned char *)malloc(width*height+2); + if ( buf == NULL) { + return(MALLOC_ERROR); + } + } + nbyte = (width + 7) / 8; + + pbuf=buf; + for(i=0; i<height; i++) { + for (j=0 ; j<nbyte; j++) { + x = *ptn >> 4; + c = (x>=10)? 'a'-0xa : '0'; + *pbuf++ = c + x; + x = *ptn++ & 0x0f; + c = (x>=10)? 'a'-0xa : '0'; + *pbuf++ = c + x; + } + *pbuf++ = '\n'; + } + *pbuf = '\0'; + fprintf(fp, "%s", buf); + return(0); +} + +int +PutGpfPtn(char *ptn, int width, int height, FILE *fp) +{ + int i, j, k, nbyte, tw; + unsigned char p, *pbuf; + static unsigned char *buf=NULL; + + if (buf==NULL) { + buf = (unsigned char *)malloc(((width+1)*height)+1); + if ( buf == NULL) { + return(MALLOC_ERROR); + } + } + + nbyte = (width + 7) / 8; + + pbuf=buf; + for(i=0; i<height; i++) { + for (j=0, tw=width; j<nbyte; j++) { + p = *ptn++; + for (k=0; k<8 && tw>0; k++, tw--) { + if (p & 0x80) { + *pbuf++ = '0'; + } else { + *pbuf++ = '-'; + } + p = p << 1; + } + } + *pbuf++ = '\n'; + } + *pbuf = '\0'; + fprintf(fp, "%s", buf); + return(0); +} + + +int +PtnZoom(char *dmem, char *smem, int sw, int sh, int dw, int dh) +{ + int swidth; + int dwidth; + int i, lcnt; + char *dbuf, *sp, *dp; + + swidth = (sw + 7) / 8; + dwidth = (dw + 7) / 8; + + if ((dbuf = (char *)malloc(dwidth)) == NULL) { + return(MALLOC_ERROR); + } + + lcnt = 0; + sp = smem; + dp = dmem; + + for(i=0; i < sh; i++) { + lcnt += dh; + if (lcnt >= sh) { + exline(sp, dbuf, sw, dw); + sp += swidth; + lcnt -= sh; + memcpy(dp, dbuf, dwidth); + dp += dwidth; + for (; lcnt >= sh; lcnt -= sh) { + memcpy(dp, dbuf, dwidth); + dp += dwidth; + } + } else { + sp += swidth; + } + } + free(dbuf); + return(0); +} + + +static void +exline(char *sp, char *dbuf, int sw, int dw) +{ + unsigned int i, bit, sval, dval, dcnt, bcnt; + + bcnt = dval = 0; + dcnt = 8; + + for(i=0; i<sw; i++) { + if (i % 8 == 0) { + sval = *sp++; + } + bit = ((sval & 0x80) ? 1 : 0); + sval <<= 1; + for (bcnt += dw; bcnt >= sw; bcnt -= sw) { + dval = (dval << 1) | bit; + if (--dcnt == 0) { + *dbuf++ = (char)dval; + dval = 0; + dcnt = 8; + } + } + } + if (dcnt != 8) { + dval <<= dcnt; + *dbuf = (char)dval; + } +} + + +char * +GetTmpPath( char *path ) +{ + char *p=NULL, *sp, *buf ; + int len ; + struct stat statbuf ; + + /* Get directory of temporary file */ + if( !(p = (char *)getenv( "TMPDIR" )) ){ + p = DEFAULT_TMPPATH ; + } + /* Get memory for temporary file name */ + sp = p ; + len = strlen(p) ; + if( *(sp + len -1) == '/' ){ + len += (strlen( TEMPFILEKEY ) + 1) ; + }else{ + len += (strlen( TEMPFILEKEY ) +1 + 1) ; + } + if ((buf = (char *)malloc( len )) == NULL) { + return NULL; + } + /* Get temporary file path */ + strcpy( buf, p ) ; + sp = buf + strlen(buf) -1 ; + if( *sp == '/' ) *sp-- = '\0' ; + sprintf( sp+1, "/%s", TEMPFILEKEY ) ; + /* Get temporary file name */ + return mkstemp( buf ); +} + + +int +Link_NewFile( char *rd_file, char *wr_file ) +{ + FILE *rfp, *wfp ; + int i, c ; + int rfd, wfd ; + struct stat statbuf ; + unsigned char bufc ; + char *buf ; + int ismmap = 0 ; + + if( stat( wr_file, &statbuf ) == -1 ){ + if( (wfd = open( wr_file, O_CREAT | O_WRONLY, 0644 )) == -1 ){ + return -1 ; + } + }else{ + if( (wfd = open( wr_file, O_WRONLY | O_TRUNC )) == -1 ){ + return -1 ; + } + } + if( stat( rd_file, &statbuf ) == -1 ){ + close(wfd) ; + return -1 ; + } + if( (rfd = open( rd_file, O_RDONLY )) == -1 ){ + close(wfd) ; + return -1 ; + } + +#if defined( SVR4 ) + if( (buf = (char *)mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, rfd, 0)) == (char *)-1 ){ +#endif /* SVR4 */ + if( !(buf = (char *)malloc(statbuf.st_size)) ){ + close(wfd) ; + close(rfd) ; + return -1 ; + } + if( read(rfd, buf, statbuf.st_size) != statbuf.st_size ){ + close(wfd) ; + close(rfd) ; + free(buf) ; + return -1 ; + } +#if defined( SVR4 ) + }else{ + ismmap = 1 ; + } +#endif /* SVR4 */ + + close(rfd) ; + + if( write(wfd, buf, statbuf.st_size) != statbuf.st_size ){ +#if defined( SVR4 ) + if( ismmap ){ + munmap(buf, statbuf.st_size) ; + }else{ +#endif /* SVR4 */ + free(buf) ; +#if defined( SVR4 ) + } +#endif /* SVR4 */ + close(wfd) ; + return (DEVICE_FAIL); + } +#if defined( SVR4 ) + if( ismmap ){ + munmap(buf, statbuf.st_size) ; + }else{ +#endif /* SVR4 */ + free(buf) ; +#if defined( SVR4 ) + } +#endif /* SVR4 */ + close(wfd) ; + + return 0 ; +} + + +int +ChkNumString( char *str ) +{ + char *tmp; + int num; + + num = (int)strtol( str, &tmp, 10 ); + if ((num == 0)&&(tmp == str)) { + return(-1); + } + if ((size_t)(tmp - str) != strlen(str)){ + return(-1); + } + return( 0 ); +} + + +void +ErrMsgTable_AndExit( + int er_no, + char *snf_in, + char *snf_out, + char *gpf_in, + char *gpf_out, + char *bdf_in, + char *prog_name +) +{ + int rtn = 0 ; + switch(er_no) { + case 0: + break; + case BDF_OPEN_IN : + USAGE2("%s : The input font file cannot be opened.\"%s\"\A1\A5\n", prog_name, (snf_in != NULL)? snf_in : "\0" ); + rtn = OPEN_FAIL ; + break; + + case BDF_OPEN_OUT : + USAGE2("%s : The output font file cannot be opened.\"%s\"\A1\A5\n", prog_name, (snf_out != NULL)? snf_out : "\0" ); + rtn = OPEN_FAIL ; + break; + + + case BDF_READ : + USAGE2("%s : Information from the font file cannot be extracted.\"%s\"\A1\A5 \n", prog_name, (snf_in != NULL) ? snf_in : "\0" ); + rtn = READ_FAIL ; + break; + + case BDF_WRITE : + USAGE2("%s : It is not possible to write to the font file.\"%s\"\A1\A5\n", prog_name, (snf_out != NULL) ? snf_out : "\0" ); + rtn = DEVICE_FAIL ; + break; + + case BDF_INVAL : + USAGE2("%s : The format of the font file is illegal.\"%s\"\A1\A5 \n", prog_name, (snf_in != NULL) ? snf_in : "\0" ); + rtn = 1 ; + break; + + case BDF_OPEN_HEAD : + USAGE2("%s : The BDF file cannot be opened.\"%s\"\A1\A5\n", prog_name, (bdf_in != NULL)? bdf_in : "\0" ); + rtn = OPEN_FAIL ; + break; + + case BDF_READ_HEAD : + USAGE2("%s : Information of the BDF file cannot be extracted.\"%s\"\A1\A5 \n", prog_name, (bdf_in != NULL) ? bdf_in : "\0" ); + rtn = READ_FAIL ; + break; + + case GPF_OPEN_IN : + USAGE2("%s : The input character pattern file cannot be opened.\"%s\"\A1\A5\n", prog_name, (gpf_in != NULL) ? gpf_in : "\0" ); + rtn = OPEN_FAIL ; + break; + + case GPF_OPEN_OUT : + USAGE2("%s : The output character pattern file cannot be opened.\"%s\"\A1\A5\n", prog_name, (gpf_out != NULL) ? gpf_out : "\0" ); + rtn = OPEN_FAIL ; + break; + + case GPF_READ : + USAGE2("%s : The character pattern file cannot be read.\"%s\"\A1\A5\n", prog_name, (gpf_in != NULL) ? gpf_in : "\0" ); + rtn = READ_FAIL ; + break; + + case GPF_WRITE : + USAGE2("%s : It is not possible to write to the character pattern file.\"%s\"\A1\A5\n", prog_name, (gpf_out != NULL) ? gpf_out : "\0" ); + rtn = DEVICE_FAIL ; + break; + + case GPF_INVAL : + USAGE2("%s : The format of the character pattern file is illegal.\"%s\"\A1\A5\n", prog_name, (gpf_in != NULL) ? gpf_in : "\0" ); + rtn = 1 ; + break; + + default : + fatal_err_msg( er_no, prog_name ); + rtn = 1 ; + break; + } + exit(rtn); +} + + +void +fatal_err_msg(int er_no, char *prog_name) +{ + USAGE1("%s : The font file failed to be converted. ", prog_name); + switch( er_no ) { + case MALLOC_ERROR: + USAGE("There is no memory any more.\n"); + break; + case FORK_ERROR: + USAGE("The child process cannot be created.\n" ); + break; + case EXEC_ERROR: + USAGE("Cannot execute dtgpftobdf.\n" ); + break; + case PIPE_ERROR: + USAGE("The pipe buffer cannot be open.\n" ); + break; + case DUP_ERROR: + USAGE("The file descripter cannot be duplicated.\n" ); + break; + case POPEN_ERROR: + USAGE("The X font compiler cannot be executed.\n" ); + break; + case PCLOSE_ERROR: + USAGE("The pipe buffer cannot be close.\n" ); + break; + case FDOPEN_ERROR: + USAGE("The file descripter cannot be got.\n" ); + break; + case STAT_ERROR: + USAGE("The status of font cannot be got.\n" ); + break; + case MKTMP_ERROR: + USAGE("The temporally file cannot be got.\n" ); + break; + case PCFFONTC_ERROR: + USAGE("Cannot execute bdftopcf.\n" ); + break; + case SNFFONTC_ERROR: + USAGE("Cannot execute bdftosnf.\n" ); + break; + default: + USAGE1("Terminates abnormally. ( err_code(%d) )\n", er_no); + break; + } + return; +} + + + +static int sig_flg=0; + +#define GPF_BUCK_UP_FAIL 1 +#define GPF_MODIFY_FAIL 2 +#define RESTORE_FAIL 3 +#define CATCH_SIGNAL 10 + +void +ChatchSig(void) +{ + sig_flg = 1; +} + +void +Put_File_Create_Err_Msg( + int msg_level, + char *org_name, + char *tmp_name, + char *save_name, + char *com +) +{ + switch( msg_level ) { + case GPF_BUCK_UP_FAIL: + USAGE1("%s : Failed to write temporary file. Terminates abnormally.\n", com ); + put_file_create_err_msg = DEVICE_FAIL ; + break; + + case GPF_MODIFY_FAIL: + USAGE1("%s : Failed in the renewal of the font file. Terminates abnormally.\n", com ); + put_file_create_err_msg = WRITE_FAIL ; + break; + + case RESTORE_FAIL: + USAGE3("%s : The file before updating cannot be changed to former file name.\tPlease execute the following command after the inquiry the system manager.\n\t mv %s %s\n", + com, save_name, org_name); + put_file_create_err_msg = WRITE_FAIL ; + break; + + case CATCH_SIGNAL: + USAGE1("%s : The signal was received. Terminates abnormally.\n", com); + put_file_create_err_msg = 1 ; + break; + } +} + +int +Make_NewFefFile( + char *org_name, + char *tmp_name, + mode_t mode, + uid_t owner, + gid_t group, + char *com +) +{ + struct stat statbuf; + char *save_name = NULL; + int ret_val; + int msg_level; + int rtn ; + +#ifndef SVR4 + signal( SIGHUP , (void(*)())ChatchSig); + signal( SIGINT , (void(*)())ChatchSig); + signal( SIGQUIT, (void(*)())ChatchSig); + signal( SIGTERM, (void(*)())ChatchSig); +#else + sigset( SIGHUP , (void(*)())ChatchSig); + sigset( SIGINT , (void(*)())ChatchSig); + sigset( SIGQUIT, (void(*)())ChatchSig); + sigset( SIGTERM, (void(*)())ChatchSig); +#endif + + errno = 0; + if (sig_flg || ((save_name = GetTmpPath( org_name )) == NULL)) { + msg_level = (sig_flg) ? CATCH_SIGNAL : GPF_BUCK_UP_FAIL; + Put_File_Create_Err_Msg( msg_level, org_name, tmp_name, + (char *)NULL, com ); + Unlink_Tmpfile ( tmp_name, com ); + return(put_file_create_err_msg); + } + + if (sig_flg || ((rtn=Link_NewFile( org_name, save_name )) != 0)) { + msg_level = (sig_flg) ? CATCH_SIGNAL : GPF_BUCK_UP_FAIL; + Put_File_Create_Err_Msg( msg_level, org_name, tmp_name, + save_name, com ); + Unlink_Tmpfile ( save_name, com ); + Unlink_Tmpfile ( tmp_name, com ); + free(save_name); + return( (put_file_create_err_msg == DEVICE_FAIL)? + put_file_create_err_msg : rtn ); + } + + if (sig_flg || ((rtn=Link_NewFile( tmp_name, org_name )) != 0)) { + msg_level = (sig_flg) ? CATCH_SIGNAL : GPF_MODIFY_FAIL; + Put_File_Create_Err_Msg( msg_level, org_name, tmp_name, + save_name, com ); + if ( (rtn=Link_NewFile( save_name, org_name )) != 0 ) { + Put_File_Create_Err_Msg( RESTORE_FAIL, org_name, + tmp_name, save_name, com ); + Unlink_Tmpfile ( tmp_name, com ); + } else { + Unlink_Tmpfile ( tmp_name, com ); + Unlink_Tmpfile ( save_name, com ); + } + free(save_name); + return( (put_file_create_err_msg == DEVICE_FAIL)? + put_file_create_err_msg : rtn ); + } + + ret_val = 0; + ret_val += Unlink_Tmpfile ( tmp_name, com ); + ret_val += Unlink_Tmpfile ( save_name, com ); + + free(save_name); + return( (ret_val)? 1 : 0 ); +} + + +int +Unlink_Tmpfile(char *file,char *com) +{ + errno = 0; + if ( unlink( file ) != 0 ) { + USAGE2("%s : The work file cannot be deleted. Please unlink the following files\tafter the inquiry the system manager.\"%s\" \n", com, file ); + return(1); + } + return(0); +} + + +int +Chmod_File (char *fname, mode_t mode, char *com) +{ + errno = 0; + if ( mode == 0 ) return( 0 ) ; + if ( chmod (fname, mode) != 0) { + USAGE3("%s : Failed in the mode change of the following files. Please change the mode to %o\tafter the inquiry the system manager.\"%s\" \n", com, (int)mode, fname ); + return( 1 ); + } + return( 0 ); +} + + +int +Chown_File (char *fname, uid_t owner, gid_t group, char *com) +{ + errno = 0; + if ( chown (fname, owner, group) != 0) { + USAGE2("%s : Failed in setteing of the owner and the group of the following files. \tPlease change to the file of the owner and the group of following ID \tafter the inquiry the system manager.\"%s\"\n", com, fname ); + USAGE1("\t\t Owner ID \A1\A7%d\n", (int)owner); + USAGE1("\t\t Group ID \A1\A7%d\n", (int)group); + return( 1 ); + } + return( 0 ); +} + + + + +int +ChkPcfFontFile( char *filename ) +{ + char *suffix; + + if ( !filename ) { + return -1; + } + suffix = ( char * )strrchr( filename, '.' ); + if ( !suffix ) { + return -1; + } + + return strcmp( PCFSUFFIX, suffix ); +} + + +int +ChkSnfFontFile( char *filename ) +{ + char *suffix; + + if ( !filename ) { + return -1; + } + suffix = ( char * )strrchr( filename, '.' ); + if ( !suffix ) { + return -1; + } + + return strcmp( SNFSUFFIX, suffix ); +} + + +char * +get_cmd_path(char *path, char *cmd) +{ + char *cmd_path = NULL; + struct stat st; + char *end; + char chr_sv; + + if ( !path || !cmd ) { + return NULL; + } + + for ( ; end = ( char * )strchr( path, ':' ); path = end + 1 ) { + chr_sv = *end; + *end = 0; + AllocString( cmd_path, path, NULL ) ; + *end = chr_sv; + + AddString( cmd_path, "/", NULL ) ; + AddString( cmd_path, cmd, NULL ) ; + + if ( stat( cmd_path, &st ) == 0 ) { + if( st.st_mode & S_IFREG ) { + cmd_path = realloc( cmd_path, strlen( cmd_path ) + 1 ); + return cmd_path; + } + } + FreeString( cmd_path ) ; + } + free(cmd_path); + AllocString( cmd_path, path, NULL ) ; + AddString( cmd_path, "/", NULL ) ; + AddString( cmd_path, cmd, NULL ) ; + if ( stat( cmd_path, &st ) == 0 ) { + if( st.st_mode & S_IFREG ) { + cmd_path = realloc( cmd_path, strlen( cmd_path ) + 1 ); + return cmd_path; + } + } + free( cmd_path ); + return NULL; +} + +int +SetCmdPath(char *com, char **path, char *dflt_path, char *cmd) +{ + struct stat statbuf ; + char *pbuf ; + + if( stat( dflt_path, &statbuf ) ){ + if( !( pbuf = (char *)get_cmd_path( getenv( "PATH" ), cmd )) ){ + USAGE2("%s: There is not \"%s\" command in \"PATH\".\n", com, cmd ) ; + return -1 ; + } + if( stat( pbuf, &statbuf ) ){ + USAGE2("%s: There is not \"%s\" command.\n", com, cmd ) ; + free(pbuf); + return STAT_ERROR ; + } + if( !(statbuf.st_mode & S_IXUSR) ){ + USAGE2("%s: \"%s\" command don't have permission to execute.\n", com, cmd ) ; + free(pbuf); + return STAT_ERROR ; + } + }else{ + if( !(statbuf.st_mode & S_IXUSR) ){ + USAGE2("%s: \"%s\" command don't have permission to execute.\n", com, cmd ) ; + return STAT_ERROR ; + } + pbuf = dflt_path ; + } + *path = pbuf ; + return 0 ; +} + +/*****************************< end of oakfuty.c >************************/ diff --git a/cde/programs/dtudcfonted/mtfgui.c b/cde/programs/dtudcfonted/mtfgui.c new file mode 100644 index 000000000..b9066713b --- /dev/null +++ b/cde/programs/dtudcfonted/mtfgui.c @@ -0,0 +1,674 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* mtfgui.c 1.21 - Fujitsu source for CDEnext 96/10/30 13:13:46 */ +/* $XConsortium: mtfgui.c /main/11 1996/11/08 01:55:01 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + +#include <stdio.h> +#include <locale.h> +#include <X11/Intrinsic.h> +#include <Xm/MessageB.h> + +#include "xoakufont.h" +#include "util.h" + +void CBeOblB_aEnd(Widget widget, caddr_t clientData, caddr_t callData); +void EHeStaT_list(Widget widget, int select, XEvent *e); +void CBeScro(Widget widget, caddr_t clientData, caddr_t callData); +void EHeBulB_eMEv(Widget widget, caddr_t clientData, XEvent *e); +void EHeBulB_eExp(Widget widget, caddr_t clientData, XEvent *e); +void EHeBulB_dExp(Widget widget, caddr_t clientData); +static void EHStaT_disp(Widget widget, int i); + +extern Resource resource; + +extern int efctPtnNum(void); +extern char *char_set(char *str); + +extern char *fullpath; +extern FalFontData fullFontData; + +extern FalCodeRegion CodeArea[16]; + +/******************************************************************** + structure of widgets + ********************************************************************/ +extern Widget toplevel; + Widget editPopW, + wgeScro, + wgeBulB_edit; +static Widget wgeStaT_form[EDLIST_MAX], + wgeStaT_disp[EDLIST_MAX], + wgeStaT_list[EDLIST_MAX], + wgeBulB_disp; + +/********************************************************************** + display windows + **********************************************************************/ + +/* + * contents : displays the "User Defined Charactrer editor" window + */ + +static Widget CreateEditPtn(Widget owner); +void OpenCB(Widget w, XtPointer client_data, XtPointer call_data); +void MngPtnCB(void); +void CpyPtnCB(void); +void CBeRecB_obj(Widget widget, int obj, XmToggleButtonCallbackStruct *call); +void CBeOblB_aAdd(void); +void CBeOblB_rCmd(Widget widget, int proc, caddr_t callData); +void CBeOblB_rCmdp(Widget widget, int proc, caddr_t callData); +void CBeOblB_rCan(Widget widget, caddr_t clientData, caddr_t callData); + + +/** + ** contents : manage the codes list + ** =================================================================== + **/ + +static void +XlfdCB(void) +{ + Widget dialog; + Arg args[5]; + char mess[1024]; + int n = 0; + XmString cs, cs1, cs2; + + sprintf(mess, "%s : %s", resource.file_name, fullpath); + cs = XmStringCreateLocalized(mess); + cs1 = XmStringSeparatorCreate(); + cs2 = XmStringConcat(cs, cs1); + XmStringFree(cs); + XmStringFree(cs1); + sprintf(mess, "%s : %s", resource.xlfd_name, fullFontData.xlfdname); + cs1 = XmStringCreateLocalized(mess); + cs = XmStringConcat(cs2, cs1); + XmStringFree(cs1); + XmStringFree(cs2); + XtSetArg (args[n], XmNtitle, resource.l_xlfd_title); n++; + XtSetArg (args[n], XmNmessageString, cs); n++; + XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++; + dialog = XmCreateInformationDialog (toplevel, "Xlfd_name", args, n); + XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON)); + XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON)); + XtManageChild (dialog); + XmStringFree(cs); +} + +static void +CodeAreaCB(void) +{ + char mess[256]; + char tmp[16]; + Widget dialog; + Arg args[5]; + int n; + XmString cs; + + sprintf(mess, "%s : ", resource.codearea); + switch (fullFontData.cd_set) { + case FAL_FONT_CS0: + strcat(mess, "CS0:"); + break; + case FAL_FONT_CS1: + strcat(mess, "CS1:"); + break; + case FAL_FONT_CS2: + strcat(mess, "CS2:"); + break; + case FAL_FONT_CS3: + strcat(mess, "CS3:"); + break; + } + + for (n=0; CodeArea[n].start != -1; n++) { + sprintf(tmp, " %X - %X ", CodeArea[n].start, CodeArea[n].end); + strcat(mess, tmp); + } + cs = XmStringCreateLocalized(mess); + n = 0; + XtSetArg (args[n], XmNtitle, resource.l_codearea_title); n++; + XtSetArg (args[n], XmNmessageString, cs); n++; + XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++; + XtSetArg (args[n], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); n++; + dialog = XmCreateInformationDialog (toplevel, "UDCarea", args, n); + XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON)); + XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON)); + XtManageChild (dialog); + XmStringFree(cs); +} + +void +ListSetLabelStr(int i, String str) +{ + SetLabelString( wgeStaT_list[i], str ); +} + +void +ListSelectItem(int i) +{ + XtVaSetValues( wgeStaT_list[i], + XmNbackground, (XtArgVal) resource.foreground, + XmNforeground, (XtArgVal) resource.background, + NULL); + xl.list_winID = XtWindow( wgeStaT_disp[i] ) ; +} + +void +ListUnselectItem(int i) +{ + XtVaSetValues( wgeStaT_list[i], + XmNbackground, (XtArgVal) resource.background, + XmNforeground, (XtArgVal) resource.foreground, + NULL); + xl.list_winID = 0 ; +} + +void +ListSetGlyphImage( int i ) +{ + int code ; + + dl_glyph[i].disp_winID = XtWindow(wgeStaT_disp[i]); + code = noToCode(ptnSqToNo(sq_disp[i])); + if (codeCheck(code)) { + XClearWindow(xl.display, dl_glyph[i].disp_winID); + return; + } + if (code == edg.code && xl.dispImage != NULL) { + XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC, + xl.dispImage, 0,0,0,0, edg.width, edg.height ); + } else { + if (dl_glyph[i].dispImage) + XFree((char *)dl_glyph[i].dispImage); + if (ptnGet(code, dl_glyph[i].ptn)) + return ; + dl_glyph[i].dispImage = XCreateImage( xl.display, + DefaultVisual(xl.display, DefaultScreen(xl.display)), 1, + XYBitmap, 0, dl_glyph[i].ptn, edg.width, edg.height, 8, 0); + dl_glyph[i].dispImage->bitmap_bit_order = MSBFirst; + dl_glyph[i].dispImage->byte_order = MSBFirst; + + XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC, + dl_glyph[i].dispImage, 0,0,0,0, edg.width, edg.height); + } +} + +/*ARGSUSED*/ +static void +EHStaT_disp( Widget widget, int i /* widget that have some ivent */ ) +{ + ListSetGlyphImage( i ); +} + +/** + ** contents : create the icon + ** =================================================================== + **/ + + +/** + ** contents : set callback functions for UDC editor window + ** =================================================================== + **/ + +static void _create_editptn_after(); + +static Widget FooterMessage; +static Widget codeLabel; + +static menuButtonItems menu_btn[] = { + MENUBTNARGS( 'F' ), + MENUBTNARGS( 'E' ), + MENUBTNARGS( 'C' ), + MENUBTNARGS( 'I' ), +}; +static MButton MenuBTN = MBUTTONS( menu_btn ); + +static ButtonItems file_btn[] = { + BTNARGS( OpenCB, NULL, 'O', True, False), + BTNARGS( CBeOblB_aAdd, NULL, 'S', True, False), + BTNARGS( NULL, NULL, NULL, NULL, NULL), + BTNARGS( CBeOblB_aEnd, NULL, 'E', True, False), +}; +static Button FileBTN = BUTTONS( file_btn ); + +static ButtonItems edit_btn[] = { + BTNARGS( CBeOblB_rCmd, PROC_CLS, 'C', True, False), + BTNARGS( CBeOblB_rCmd, PROC_SET, 'S', True, False), + BTNARGS( CBeOblB_rCmd, PROC_REV, 'R', True, False), + BTNARGS( CBeOblB_rCmdp, PROC_CUT, 'U', True, False), + BTNARGS( CBeOblB_rCmdp, PROC_CPY, 'O', True, False), + BTNARGS( CBeOblB_rCmdp, PROC_PASTE,'P', True, False), + BTNARGS( CBeOblB_rCmd, PROC_ROLL, 'A', True, False), + BTNARGS( CBeOblB_rCmd, PROC_SYMV, 'V', True, False), + BTNARGS( CBeOblB_rCmd, PROC_SYMH, 'H', True, False), + BTNARGS( CBeOblB_rCan, NULL, 'N', True, False), +}; +static Button EditBTN = BUTTONS( edit_btn ); + +static ButtonItems char_btn[] = { + BTNARGS( MngPtnCB, NULL, 'A', True, False ), + BTNARGS( CpyPtnCB, NULL, 'C', True, False ), +}; +static Button CharBTN = BUTTONS( char_btn ); + +static ButtonItems info_btn[] = { + BTNARGS( XlfdCB, NULL, 'X', True, False ), + BTNARGS( CodeAreaCB, NULL, 'C', True, False ), +}; +static Button InfoBTN = BUTTONS( info_btn ); + +static ExclusiveItems draw_ex[] = { + EXARGS( PROC_POINT, "pencil", True, CBeRecB_obj, True ), + EXARGS( PROC_LINE, "line", True, CBeRecB_obj, False ), + EXARGS( PROC_RECT, "rectangle", True, CBeRecB_obj, False ), + EXARGS( PROC_CIRCLE, "circle", True, CBeRecB_obj, False ), + EXARGS( PROC_ERASE, "erase", True, CBeRecB_obj, False ), + EXARGS( PROC_SELECT, "select", True, CBeRecB_obj, False ), +}; +static Exclusive DrawEX = EXCLUSIVE( draw_ex ); + +static void +Unset(void) +{ + XtSetSensitive(EditBTN.w[0], False); + XtSetSensitive(EditBTN.w[1], False); + XtSetSensitive(EditBTN.w[2], False); + XtSetSensitive(EditBTN.w[3], False); + XtSetSensitive(EditBTN.w[4], False); + XtSetSensitive(EditBTN.w[5], False); + XtSetSensitive(EditBTN.w[6], False); + XtSetSensitive(EditBTN.w[7], False); + XtSetSensitive(EditBTN.w[8], False); + XtSetSensitive(EditBTN.w[9], False); +} + +void +SelectSet(void) +{ + XtSetSensitive(EditBTN.w[0], True); + XtSetSensitive(EditBTN.w[1], True); + XtSetSensitive(EditBTN.w[2], True); + XtSetSensitive(EditBTN.w[3], True); + XtSetSensitive(EditBTN.w[4], True); + XtSetSensitive(EditBTN.w[6], True); + XtSetSensitive(EditBTN.w[7], True); + XtSetSensitive(EditBTN.w[8], True); +} + +void +SelectUnset(void) +{ + XtSetSensitive(EditBTN.w[0], False); + XtSetSensitive(EditBTN.w[1], False); + XtSetSensitive(EditBTN.w[2], False); + XtSetSensitive(EditBTN.w[3], False); + XtSetSensitive(EditBTN.w[4], False); + XtSetSensitive(EditBTN.w[6], False); + XtSetSensitive(EditBTN.w[7], False); + XtSetSensitive(EditBTN.w[8], False); +} + +void +CopySet(void) +{ + XtSetSensitive(EditBTN.w[5], True); +} + +void +UndoSet(void) +{ + XtSetSensitive(EditBTN.w[9], True); +} + +void +UndoUnset(void) +{ + XtSetSensitive(EditBTN.w[9], False); +} + +/** + ** contents : create the UDC editor window + ** -------------------------------- + **/ + +void +PopupEditPtn(Widget owner) +{ + if (! editPtnW){ + editPtnW = CreateEditPtn(owner); + _create_editptn_after(); + } + XtPopup(editPtnW, XtGrabNone); +} + +static Widget +CreateEditPtn(Widget owner) +{ + int slimax; + int i; + Widget baseForm, pop, font_menu, edit_menu, char_menu, info_menu; + Widget listBase, listFrame, rc, editFrame, figure_w; + Widget imageFrame, imageForm, editPane, image; + extern Widget CreateFrame(); + extern Widget CreatePixButton(); + + Arg arg[1]; + + + SetItemLabel(&MenuBTN, 0, resource.l_font); + SetItemLabel(&MenuBTN, 1, resource.l_edit); + SetItemLabel(&MenuBTN, 2, resource.l_manage); + SetItemLabel(&MenuBTN, 3, resource.l_info); + baseForm = (Widget) + CreateMenuBarAndFooterMessageForm( owner, "dtudcfonted", + &MenuBTN, XtNumber(menu_btn), &pop, &FooterMessage ); + + editPopW = pop; + + AddDeleteProc(pop, CBeOblB_aEnd); + + font_menu = GetMenuWidget( &MenuBTN, 0 ); + edit_menu = GetMenuWidget( &MenuBTN, 1 ); + char_menu = GetMenuWidget( &MenuBTN, 2 ); + info_menu = GetMenuWidget( &MenuBTN, 3 ); + + SetItemLabel(&FileBTN, 0, resource.l_open_w); + SetItemLabel(&FileBTN, 1, resource.l_save); + SetItemLabel(&FileBTN, 3, resource.l_exit); + + SetItemLabel(&EditBTN, 0, resource.l_clear); + SetItemLabel(&EditBTN, 1, resource.l_set); + SetItemLabel(&EditBTN, 2, resource.l_reverse); + SetItemLabel(&EditBTN, 3, resource.l_cut); + SetItemLabel(&EditBTN, 4, resource.l_Copy); + SetItemLabel(&EditBTN, 5, resource.l_paste); + SetItemLabel(&EditBTN, 6, resource.l_roll); + SetItemLabel(&EditBTN, 7, resource.l_updown_roll); + SetItemLabel(&EditBTN, 8, resource.l_leftright_roll); + SetItemLabel(&EditBTN, 9, resource.l_undo); + + SetItemLabel(&CharBTN, 0, resource.l_manage_w); + SetItemLabel(&CharBTN, 1, resource.l_copy_w); + + SetItemLabel(&InfoBTN, 0, resource.l_xlfd); + SetItemLabel(&InfoBTN, 1, resource.l_codearea); + + CreateMenuButtons( font_menu, &FileBTN, XtNumber(file_btn)); + CreateMenuButtons( edit_menu, &EditBTN, XtNumber(edit_btn)); + Unset(); + CreateMenuButtons( char_menu, &CharBTN, XtNumber(char_btn)); + CreateMenuButtons( info_menu, &InfoBTN, XtNumber(info_btn)); + + /* create "Character list" */ + + listFrame = + CreateFrame( baseForm, "listFrame", XmSHADOW_IN, 2); + AddTopAttachForm(listFrame, resource.ed_wge_topoff); + AddLeftAttachForm(listFrame, resource.ed_wge_lftoff); + AddBottomAttachForm(listFrame, resource.ed_wge_btmoff); + + listBase = + CreateRowColumn( listFrame, "listFrame", L_VERTICAL, 4, 2, 2); + + for( i=0 ; i < edlist.nlist ; i++ ) { + wgeStaT_form[i] = CreateForm( listBase, "listform" ); + wgeStaT_list[i] = + CreateLabel( wgeStaT_form[i], "label", "0000" ); + wgeStaT_disp[i] = CreateDrawingArea( wgeStaT_form[i], "image", + edg.width, edg.height, EHStaT_disp, i ) ; + AddLeftAttachWidget( wgeStaT_disp[i], wgeStaT_list[i], 0 ) ; + XtAddEventHandler( wgeStaT_list[i], + ButtonPressMask|ButtonReleaseMask, + False, EHeStaT_list, (XtPointer) (intptr_t) i ); + XtAddEventHandler( wgeStaT_disp[i], + ButtonPressMask|ButtonReleaseMask, + False, EHeStaT_list, (XtPointer) (intptr_t) i ); + + if (i==0){ + XtVaGetValues(wgeStaT_disp[i], + XmNheight, &(edlist.elem_h), + XmNwidth, &(edlist.elem_w), NULL); + + edlist.back = resource.pane_background; + edlist.border = resource.pane_foreground; + + dn.elem_h = edlist.elem_h; + dn.elem_w = edlist.elem_w; + + /* + */ + edpane.pix_w = edpane.width / edg.width; + edpane.pix_h = edpane.height / edg.height; + if(edpane.pix_w > edpane.pix_h) + edpane.pix_w = edpane.pix_h; + else + edpane.pix_h = edpane.pix_w; + /* */ + edpane.pix_w = ( edpane.pix_w < 8 ) ? 8 : edpane.pix_w; + edpane.pix_h = ( edpane.pix_h < 8 ) ? 8 : edpane.pix_h; + /* + */ + edpane.width = edpane.pix_w * edg.width - 1; + edpane.height = edpane.pix_h * edg.height - 1; + + edlist.nlist = (edpane.height +2)/(int)(edlist.elem_h +8); + edlist.nlist = + (edlist.nlist<EDLIST_MAX)?edlist.nlist:EDLIST_MAX; + } + } + + XtManageChildren( wgeStaT_form, edlist.nlist ); + for( i=0 ; i < edlist.nlist ; i++ ) { + XtManageChild( wgeStaT_list[i] ); + XtManageChild( wgeStaT_disp[i] ); + } + + /* create the scroll bar for Charcter list */ + XtVaGetValues( listBase, XmNheight, &(edlist.list_h), NULL); + + if (( slimax = efctPtnNum()) < edlist.nlist) + slimax = edlist.nlist; + wgeScro = CreateScrollBar( baseForm, "scrollBar", (edpane.height+2), + edlist.nlist, 0, slimax, CBeScro); + AddLeftAttachWidget( wgeScro, listFrame, 4 ); + AddTopAttachForm( wgeScro, resource.ed_wge_topoff ); + AddBottomAttachForm( wgeScro, resource.ed_wge_btmoff ); + + rc = + CreateForm( baseForm, "rc" ); + AddTopAttachForm( rc, resource.ed_wge_topoff ); + AddRightAttachForm( rc, resource.ed_wge_rghoff ); + AddBottomAttachForm( rc, resource.ed_wge_btmoff ); + + editFrame = + CreateFrame( baseForm, "editFrame", XmSHADOW_IN, 2); + AddTopAttachForm(editFrame, resource.ed_wge_topoff); + AddLeftAttachWidget(editFrame, wgeScro, 4); + AddRightAttachWidget(editFrame, rc, 10); + + figure_w = + CreatePixButton(rc, "Draw", &DrawEX); + AddTopAttachForm(figure_w, 0); + AddLeftAttachForm(figure_w, 0); + AddRightAttachForm(figure_w, 0); + + imageFrame = + CreateCaptionFrame( rc, "Frame", " ", XmSHADOW_IN, 1); + AddTopAttachWidget(XtParent(imageFrame), figure_w, 4); + AddLeftAttachForm(XtParent(imageFrame), 0); + AddRightAttachForm(XtParent(imageFrame), 0); + AddBottomAttachForm(XtParent(imageFrame), 0); + + imageForm = + CreateForm( imageFrame, "separator" ); + + /* create the Editing pane */ + wgeBulB_edit = editPane = + CreateDrawingArea( editFrame, "editPane", + edpane.width, edpane.height, EHeBulB_eExp, 0); + + XtAddEventHandler( editPane, + ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, + False, EHeBulB_eMEv, NULL ); + AddTopAttachForm( editPane, 2 ); + AddLeftAttachForm( editPane, 2 ); + + /* create character image */ + codeLabel = CreateLabel( imageForm, "codeLabel", "0000" ); + AddTopAttachForm( codeLabel, 3 ); + AddLeftAttachForm( codeLabel, 3 ); + + wgeBulB_disp = image = CreateDrawingArea( imageForm, "image", edg.width, + edg.height, EHeBulB_dExp, 0); + AddTopAttachWidget( image, codeLabel, 3 ); + AddLeftAttachForm( image, 6 ); + + XtRealizeWidget( editPopW ); + + return(editPopW); +} + + + + +void +SetCodeString(int code) +{ + char str[8]; + + if (! code){ + str[0] = '\0'; + } + else{ + sprintf( str, "%4x:", code ); + } + SetLabelString(codeLabel, str); +} + + + +static void +_create_editptn_after(void) +{ + int slctloc; + static char dashPtn[] = {1,1}; /* Editing pane's border pattern */ + extern void chgEdList(); + + + /* + * set X-library interface + */ + xl.display = XtDisplayOfObject( editPopW ); + xl.root_winID = RootWindow( xl.display, DefaultScreen(xl.display) ); + xl.edit_winID = XtWindow( wgeBulB_edit ); + xl.disp_winID = XtWindow( wgeBulB_disp ); + xl.list_winID = XtWindow( wgeStaT_disp[0] ); + + /* + * Graphic Context ( Pixel clear ) + */ + xl.backGC = XCreateGC( xl.display, xl.root_winID, 0, 0 ); + XSetForeground( xl.display, xl.backGC, edpane.back ); + XSetBackground( xl.display, xl.backGC, edpane.border ); + + /* + * Graphic Context ( Pixel set ) + */ + xl.borderGC = XCreateGC( xl.display, xl.root_winID, 0, 0 ); + XSetForeground( xl.display, xl.borderGC, edpane.border ); + XSetBackground( xl.display, xl.borderGC, edpane.back ); + + /* + * Graphic Context ( rubber band ) + */ + xl.rubGC = XCreateGC( xl.display, xl.root_winID, 0, 0 ); + XSetForeground(xl.display, xl.rubGC, edpane.border ^ edpane.back); + + XSetFunction ( xl.display, xl.rubGC, GXxor ); + + /* + * Graphc Context ( lattice of Editing pane ) + */ + xl.dashGC = XCreateGC( xl.display, xl.root_winID, 0, 0 ); + XSetForeground( xl.display, xl.dashGC, edpane.border ); + XSetBackground( xl.display, xl.dashGC, edpane.back ); + + XSetLineAttributes( xl.display, xl.dashGC, 0, + LineDoubleDash, CapButt, JoinMiter ); + XSetDashes ( xl.display, xl.dashGC, 0, dashPtn, 2 ); + + /* + * display Editing pane + */ + xl.dispImage = XCreateImage( xl.display, + DefaultVisual( xl.display, DefaultScreen(xl.display) ), + 1, XYBitmap, 0, edg.ptn, edg.width, edg.height, 8, 0 ); + xl.dispImage->bitmap_bit_order = MSBFirst; + xl.dispImage->byte_order = MSBFirst; + + /* + * initialize + */ + edpane.color = ON; + edpane.obj = PROC_POINT; + em.proc = PROC_POINT; + + if(efctPtnNum() > 0){ + slctloc = 0; + SetCodeString(edg.code); + } + else{ + slctloc = -1; + } + chgEdList( 0, slctloc, ON ); + +} + +void +UpdateMessage(String str) +{ + static Boolean nomsg = False; + + if (! str || ! *str){ + if (nomsg){ + return; + } + else{ + nomsg = True; + } + } + else{ + nomsg = False; + } + SetFooterString(FooterMessage, str); +} diff --git a/cde/programs/dtudcfonted/pixmaps/Circle.pm b/cde/programs/dtudcfonted/pixmaps/Circle.pm new file mode 100755 index 000000000..06bc46f7c --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/Circle.pm @@ -0,0 +1,52 @@ +/* XPM */ +/* $XConsortium: Circle.pm /main/4 1996/07/23 11:49:20 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * Circle [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 2 1 -1 -1", +/* colors */ +" s background m black c #949494949494", +". s foreground m white c white", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ....... ", +" ... ... ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" ... ... ", +" ....... ", +" ", +" ", +" ", +" "}; diff --git a/cde/programs/dtudcfonted/pixmaps/Eraser.pm b/cde/programs/dtudcfonted/pixmaps/Eraser.pm new file mode 100755 index 000000000..253df8fea --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/Eraser.pm @@ -0,0 +1,58 @@ +/* XPM */ +/* $XConsortium: Eraser.pm /main/4 1996/07/23 11:49:43 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * Eraser [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 8 1 0 0", +/* colors */ +" s iconColor6 m white c yellow", +". s iconColor2 m white c white", +"X s background m black c #949494949494", +"o s iconGray5 m black c #737373737373", +"O s iconGray1 m white c #dededededede", +"+ s iconGray3 m white c #adadadadadad", +"@ s iconColor3 m black c red", +"# s iconColor1 m black c black", +/* pixels */ +" . . XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"o . . XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +" o . . XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"o o . . XXXXXXXXXXXXXXXXXXXXXXXXXXXX", +" o o . . XXXXXXXXXXXXXXXXXXXXXXXXXXX", +"o o o . . XXXXXXXXXXXXXXXXXXXXXXXXXX", +"Xo o o . . XXXXXXXXXXXXXXXXXXXXXXXXX", +"XXo o o . . XXXXXXXXXXXXXXXXXXXXXXXX", +"XXXo o o . . XXXXXXXXXXXXXXXXXXXXXXX", +"XXXXo o o . . XXXXXXXXXXXXXXXXXXXXXX", +"XXXXXo o o . . XXXXXXXXXXXXXXXXXXXXX", +"XXXXXXo o o . . XXXXXXXXXXXXXXXXXXXX", +"XXXXXXXo o o . . XXXXXXXXXXXXXXXXXXX", +"XXXXXXXXo o o ...OXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXo o o+...OXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXo oo++...OXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXo+oo++...OXXXXXXXXXXXXXXX", +"XXXXXXXXXXXX++oo++..ooXXXXXXXXXXXXXX", +"XXXXXXXXXXXXX++oo++o@.@XXXXXXXXXXXXX", +"XXXXXXXXXXXXXX++ooo@.@O@XXXXXXXXXXXX", +"XXXXXXXXXXXXXXX+oo@+@O@O@XXXXXXXXXXX", +"XXXXXXXXXXXXXXXXo@o@o@O@O@XXXXXXXXXX", +"XXXXXXXXXXXXXXXXXo@o@o@O@O@#########", +"XXXXXXXXXXXXXXXXXXo@o@o@O@##########", +"XXXXXXXXXXXXXXXXXXXo@o@o@###########", +"XXXXXXXXXXXXXXXXXXXXo@o@############", +"XXXXXXXXXXXXXXXXXXXXXo@#############", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}; diff --git a/cde/programs/dtudcfonted/pixmaps/Line.pm b/cde/programs/dtudcfonted/pixmaps/Line.pm new file mode 100755 index 000000000..aa8ae113d --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/Line.pm @@ -0,0 +1,52 @@ +/* XPM */ +/* $XConsortium: Line.pm /main/4 1996/07/23 11:50:13 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * Line [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 2 1 -1 -1", +/* colors */ +" s background m black c #949494949494", +". s foreground m white c white", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" ", +" ", +" ", +" ", +" "}; diff --git a/cde/programs/dtudcfonted/pixmaps/Pencil.pm b/cde/programs/dtudcfonted/pixmaps/Pencil.pm new file mode 100644 index 000000000..8a1c1c4d9 --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/Pencil.pm @@ -0,0 +1,58 @@ +/* XPM */ +/* $XConsortium: Pencil.pm /main/4 1996/07/23 11:50:33 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * Pencil [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 8 1 0 0", +/* colors */ +" s background m black c #949494949494", +". s iconColor6 m white c yellow", +"X s iconColor2 m white c white", +"o s iconGray5 m black c #737373737373", +"O s foreground m white c white", +"+ s iconGray3 m white c #adadadadadad", +"@ s iconGray1 m white c #dededededede", +"# s iconGray7 m black c #424242424242", +/* pixels */ +" ", +" ", +" .", +" .X", +" .X.", +" .X.X", +" .X.X.", +" .X.X.o", +" .X.X.o.", +" .X.X.o.o", +" OOOOO .X.X.o.o.", +" OOO .X.X.o.o.o", +" O .X.X.o.o.o ", +" O .X.X.o.o.o ", +" O .X.X.o.o.o ", +" O .X.X.o.o.o ", +" O .X.X.o.o.o ", +" O +@XX.o.o.o ", +" O +XX@o.o.o ", +" OO +XX@ooo.o ", +" OOO +X@ooo.o ", +" O +X@ooooo ", +" O +@ooooo ", +" O +#ooooo ", +" O ###oo ", +" O ##o ", +" OO ## ", +" O## ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/cde/programs/dtudcfonted/pixmaps/Rectangle.pm b/cde/programs/dtudcfonted/pixmaps/Rectangle.pm new file mode 100755 index 000000000..7d7df1400 --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/Rectangle.pm @@ -0,0 +1,52 @@ +/* XPM */ +/* $XConsortium: Rectangle.pm /main/4 1996/07/23 11:50:54 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * Rectangle [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 2 1 -1 -1", +/* colors */ +" s background m black c #949494949494", +". s foreground m white c white", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" .............................. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .............................. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/cde/programs/dtudcfonted/pixmaps/SelectArea.pm b/cde/programs/dtudcfonted/pixmaps/SelectArea.pm new file mode 100755 index 000000000..01e9a623c --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/SelectArea.pm @@ -0,0 +1,53 @@ +/* XPM */ +/* $XConsortium: SelectArea.pm /main/4 1996/07/23 11:51:18 drk $ */ +/********************************************************************* +* (c) Copyright 1993, 1994 Hewlett-Packard Company +* (c) Copyright 1993, 1994 International Business Machines Corp. +* (c) Copyright 1993, 1994 Sun Microsystems, Inc. +* (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of +* Novell, Inc. +**********************************************************************/ +static char * SelectArea [] = { +/* width height ncolors cpp [x_hot y_hot] */ +"36 36 3 1 -1 -1", +/* colors */ +" s background m black c #949494949494", +". s iconColor1 m black c black", +"X s iconColor2 m white c white", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" .... .. .. .. .. .... ", +" .... .. .. .. .. .... ", +" ..XXX XX XX XX XX X..X ", +" ..XXXX XX XX XX XX ..XX ", +" XX XX ", +" X X ", +" .. .. ", +" ..X ..X ", +" XX XX ", +" X X ", +" .. .. ", +" ..X ..X ", +" XX XX ", +" X X ", +" .. .. ", +" ..X ..X ", +" XX XX ", +" X X ", +" .. .. ", +" ..X ..X ", +" .... .. .. .. .. ....XX ", +" .... .. .. .. .. ....XX ", +" XXXX XX XX XX XX XXXXX ", +" XXXX XX XX XX XX XXXX ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/cde/programs/dtudcfonted/pixmaps/arrow.pm b/cde/programs/dtudcfonted/pixmaps/arrow.pm new file mode 100755 index 000000000..40f81d205 --- /dev/null +++ b/cde/programs/dtudcfonted/pixmaps/arrow.pm @@ -0,0 +1,21 @@ +/* XPM */ +/* $XConsortium: arrow.pm /main/4 1996/07/23 11:51:52 drk $ */ +static char * arrow_pm[] = { +"14 14 3 1", +" c #C2C2C2C2C2C2", +". c #727272727272", +"X c #E8E8E8E8E8E8", +" . ", +" .. ", +" ... ", +"......... . ", +"......... . ", +".. . ", +".. X", +".. X", +".. XX", +".XXXXXXX XX ", +" X XX ", +" X XX ", +" XXX ", +" XX "}; diff --git a/cde/programs/dtudcfonted/resource/Dtudcfonted b/cde/programs/dtudcfonted/resource/Dtudcfonted new file mode 100644 index 000000000..233e94c37 --- /dev/null +++ b/cde/programs/dtudcfonted/resource/Dtudcfonted @@ -0,0 +1,10 @@ +! (c) Copyright 1995 FUJITSU LIMITED +! This is source code modified by FUJITSU LIMITED under the Joint +! Development Agreement for the CDEnext PST. +! This is unpublished proprietary source code of FUJITSU LIMITED + +*Lptog: /usr/dt/lib/dtudcfonted/dtaddcpf +*LptogCmd: dtaddcpf + +*PaneForeground : black +*PaneBackground : white diff --git a/cde/programs/dtudcfonted/selectx.c b/cde/programs/dtudcfonted/selectx.c new file mode 100644 index 000000000..cd86af2f8 --- /dev/null +++ b/cde/programs/dtudcfonted/selectx.c @@ -0,0 +1,813 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* selectx.c 1.23 - Fujitsu source for CDEnext 96/10/30 13:13:45 */ +/* $XConsortium: selectx.c /main/7 1996/11/08 01:54:18 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <nl_types.h> + +#include<X11/Xlib.h> +#include<X11/Xutil.h> +#include<X11/Xatom.h> + +#include <Xm/Xm.h> +#include <Xm/Form.h> +#include <Xm/PushB.h> +#include <Xm/Text.h> +#include <Xm/TextF.h> +#include <Xm/Label.h> +#include <Xm/SeparatoG.h> +#include <Xm/List.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> +#include <Xm/RowColumn.h> +#include <Xm/Frame.h> +#include <Xm/Label.h> + +/* + * There is no public header file for this function (only an + * internal header XmStringI.h). + */ +extern XtPointer _XmStringUngenerate (XmString string, + XmStringTag tag, + XmTextType tag_type, + XmTextType output_type); + + +#include "xoakufont.h" +#include "selectxlfd.h" + +extern Resource resource ; + +/* + * parameters + */ + +FalFontData fullFontData; + +void PopupSelectXLFD(Widget top) ; +static Widget CreateSelectXLFD(Widget top) ; + +extern void xlfdPopupDialog(Widget w); + +extern void ReadCB(Widget w, XtPointer client_data, XtPointer call_data); + + +Widget xlfdDialog; +static Widget xlfdWform; + +#define CS0 "Codeset 0" +#define CS1 "Codeset 1" +#define CS2 "Codeset 2" +#define CS3 "Codeset 3" + +#define FAL_ERROR_STR resource.falerrmsg[((fal_utyerrno & 0xff) > 25) ? 0 : (fal_utyerrno & 0xff)] + +static Widget pull1, pull2, pull3, pull4, scrolllist; +static int xlf_count = 0; +static XmString *xlf=NULL; +static int udc_count = 0; +static Boolean udc_flag = False; +static int *udc=NULL; +static int udc_val; +static int sty_count = 0; +static Boolean sty_flag = False; +static char **sty=NULL; +static char *sty_val=NULL; +static int wls_count = 0; +static Boolean wls_flag = False; +static int *wls=NULL; +static int wls_val; +static int hls_count = 0; +static Boolean hls_flag = False; +static int *hls=NULL; +static int hls_val; +static Widget *button1=NULL; +static Widget *button2=NULL; +static Widget *button3=NULL; +static Widget *button4=NULL; + +/**************************************************************** + * callbacks * + ***************************************************************/ + +static char * +spc(char *str, char ch, int count) +{ + char *p; + p = str + strlen(str); + for(;count && (str < p);p--) { + if (*p == ch) + count --; + } + if (! count) + return(p+1); + else + return(NULL); +} + +static void OpenWindowCB(void) +{ + char *str, *p; + XmStringTable st; + + XtVaGetValues(scrolllist, XmNselectedItems, &st, NULL); + if( st == NULL ){ + fullFontData.xlfdname = NULL; + return ; + } + str = (char *) _XmStringUngenerate(st[0], NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + + p = spc(str, '-', 4); + p++; + + if (*p == 'p' || *p == 'P') { + fullFontData.xlfdname = (char *)-1; + return ; + } + + fullFontData.xlfdname = str; + if(udc_flag == True) + fullFontData.cd_set = udc_val; + else + fullFontData.cd_set = -1; +} + +/** + ** contents : "Cancel" button callback + ** ------------------------ + ** + ** + **/ + +/*ARGSUSED*/ +static void +OpenCancelCB(Widget widget, caddr_t clientData, caddr_t callData) +{ + extern void ForcePopdownDialog(); + if ( !editPtnW ){ + exit( 0 ); + } + ForcePopdownDialog(xlfdDialog); +} + + +/* +* create selection window view +*/ +void +PopupSelectXLFD(Widget top) +{ + + if( xlfdDialog == NULL ){ + if( (xlfdDialog = CreateSelectXLFD( top )) == NULL ){ + exit( -1 ) ; + } + } + /* pop up select window */ + xlfdPopupDialog( xlfdDialog ); +} + + +static void +create_xlfd(void) +{ + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + int i; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + xlf_count = 0; + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + return; + } + if (xlf) { + for (i=0; i < xlf_count; i++) { + XmStringFree(xlf[i]); + } + XtFree((char *)xlf); + } + xlf = (XmString *)XtMalloc(sizeof(XmString) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + xlf[xlf_count++] = XmStringCreateLocalized(f->xlfdname); + } + FalFreeFontList(fontlist); +} + +static void +udc_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + udc_flag = False; + } else if(strcmp(moji, CS0) == 0) { + udc_val = FAL_FONT_CS0; + udc_flag = True; + } else if(strcmp(moji, CS1) == 0) { + udc_val = FAL_FONT_CS1; + udc_flag = True; + } else if(strcmp(moji, CS2) == 0) { + udc_val = FAL_FONT_CS2; + udc_flag = True; + } else if(strcmp(moji, CS3) == 0) { + udc_val = FAL_FONT_CS3; + udc_flag = True; + } else { + udc_flag = False; + } + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +sty_call(Widget w) +{ + XmString label; + char *moji; + if (sty_val) { + XtFree(sty_val); + sty_val = NULL; + } + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + sty_flag = False; + } + else { + sty_val = XtMalloc(sizeof(char) * (strlen(moji) + 1)); + strcpy(sty_val, moji); + sty_flag = True; + } + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +wls_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + wls_flag = False; + } + else { + wls_val = atoi(moji); + wls_flag = True; + } + XmStringFree(label); + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +hls_call(Widget w) +{ + XmString label; + char *moji; + XtVaGetValues(w, XmNlabelString, &label, NULL); + moji = (char *) _XmStringUngenerate(label, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); + if(strncmp(moji, "*", 1) == 0) { + hls_flag = False; + } + else { + hls_val = atoi(moji); + hls_flag = True; + } + XmStringFree(label); + XtFree(moji); + create_xlfd(); + XtVaSetValues(scrolllist, XmNitems, xlf, XmNitemCount, xlf_count, NULL); +} + +static void +button_set1(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<udc_count; j++) + XtSetSensitive(button1[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<udc_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(udc[j] == f->cd_set) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button1[j], False); + else + XtSetSensitive(button1[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set2(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<sty_count; j++) + XtSetSensitive(button2[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<sty_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(strcmp(sty[j], f->style.name) == 0) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button2[j], False); + else + XtSetSensitive(button2[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set3(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (hls_flag == True) { + key.size.h = hls_val; + mask |= FAL_FONT_MASK_SIZE_H; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<wls_count; j++) + XtSetSensitive(button3[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<wls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(wls[j] == f->size.w) { + found = True; + break; + } + } + if(found == False) + XtSetSensitive(button3[j], False); + else + XtSetSensitive(button3[j], True); + } + FalFreeFontList(fontlist); +} + +static void +button_set4(void) +{ + int i, j; + int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED; + FalFontData key; + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + + if (udc_flag == True) { + key.cd_set = udc_val; + mask |= FAL_FONT_MASK_CODE_SET; + } + if (sty_flag == True) { + key.style.name = sty_val; + mask |= FAL_FONT_MASK_STYLE_NAME; + } + if (wls_flag == True) { + key.size.w = wls_val; + mask |= FAL_FONT_MASK_SIZE_W; + } + if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + return; + } + if(fontlist->num == 0) { + for (j=0; j<hls_count; j++) + XtSetSensitive(button4[j], False); + FalFreeFontList(fontlist); + return; + } + + for (j=0; j<hls_count; j++) { + for (i=0, f=fontlist->list, found=False; i < fontlist->num; i++, f++) { + if(hls[j] == f->size.h) { + found = True; + break; + } + } + if (found == False) + XtSetSensitive(button4[j], False); + else + XtSetSensitive(button4[j], True); + } + FalFreeFontList(fontlist); +} + +void +data_sort(int *data, int count) +{ + int *p1, *p2, tmp, i; + + for (; count; count--) { + for (i=1, p1=data, p2=data+1; i < count; i++, p1++, p2++) { + if( *p1 > *p2) { + tmp = *p2; + *p2 = *p1; + *p1 = tmp; + } + } + } +} + + +static void +font_init(void) +{ + FalFontDataList *fontlist; + FalFontData *f; + Boolean found; + int i, j; + char tmp[16]; + char err[128]; + Widget button; + extern void Error_message(); + + xlf_count = udc_count = sty_count = wls_count = hls_count = 0; + if (FalGetFontList(NULL, FAL_FONT_MASK_DEFINED | + FAL_FONT_MASK_UNDEFINED, &fontlist) == FAL_ERROR) { + strcpy(err, FAL_ERROR_STR); + Error_message((Widget)NULL, err); + return; + } + if(fontlist->num == 0) { + FalFreeFontList(fontlist); + strcpy(err, resource.mn_no_font); + Error_message((Widget)NULL, err); + return; + } + udc = (int *)XtMalloc(sizeof(int) * fontlist->num); + sty = (char **)XtMalloc(sizeof(char *) * fontlist->num); + wls = (int *)XtMalloc(sizeof(int) * fontlist->num); + hls = (int *)XtMalloc(sizeof(int) * fontlist->num); + for (i=0, f=fontlist->list; i < fontlist->num; i++, f++) { + for (j=0,found=False; j<udc_count; j++) { + if(udc[j] == f->cd_set) { + found=True; + break; + } + } + if (found == False) { + udc[udc_count++] = f->cd_set; + } + for (j=0,found=False; j<sty_count; j++) { + if(strcmp(sty[j], f->style.name) == 0) { + found=True; + break; + } + } + if (found == False) { + sty[sty_count] = XtMalloc(sizeof(char) * (strlen(f->style.name) + 1)); + strcpy(sty[sty_count++], f->style.name); + } + if (f->size.w != -1) { + for (j=0,found=False; j<wls_count; j++) { + if(wls[j] == f->size.w) { + found=True; + break; + } + } + if (found == False) { + wls[wls_count++] = f->size.w; + } + } + for (j=0,found=False; j<hls_count; j++) { + if(hls[j] == f->size.h) { + found=True; + break; + } + } + if (found == False) { + hls[hls_count++] = f->size.h; + } + } + FalFreeFontList(fontlist); + + data_sort(udc, udc_count); + data_sort(wls, wls_count); + data_sort(hls, hls_count); + + button1 = (Widget *) XtMalloc(sizeof(Widget) * udc_count); + button2 = (Widget *) XtMalloc(sizeof(Widget) * sty_count); + button3 = (Widget *) XtMalloc(sizeof(Widget) * wls_count); + button4 = (Widget *) XtMalloc(sizeof(Widget) * hls_count); + + button = XmCreatePushButton(pull1, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + for (i=0; i < udc_count; i++) { + if(udc[i] == FAL_FONT_CS0) + sprintf(tmp, CS0); + else if(udc[i] == FAL_FONT_CS1) + sprintf(tmp, CS1); + else if(udc[i] == FAL_FONT_CS2) + sprintf(tmp, CS2); + else if(udc[i] == FAL_FONT_CS3) + sprintf(tmp, CS3); + else + sprintf(tmp, "Codeset %x?", udc[i]); + button1[i] = XmCreatePushButton(pull1, tmp, NULL, 0); + XtManageChild(button1[i]); + XtAddCallback(button1[i], XmNactivateCallback, + (XtCallbackProc)udc_call, NULL); + } + + button = XmCreatePushButton(pull2, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + for (i=0; i < sty_count; i++) { + button2[i] = XmCreatePushButton(pull2, sty[i], NULL, 0); + XtManageChild(button2[i]); + XtAddCallback(button2[i], XmNactivateCallback, + (XtCallbackProc)sty_call, NULL); + } + + button = XmCreatePushButton(pull3, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + for (i=0; i < wls_count; i++) { + sprintf(tmp, "%d", wls[i]); + button3[i] = XmCreatePushButton(pull3, tmp, NULL, 0); + XtManageChild(button3[i]); + XtAddCallback(button3[i], XmNactivateCallback, + (XtCallbackProc)wls_call, NULL); + } + + button = XmCreatePushButton(pull4, "*", NULL, 0); + XtManageChild(button); + XtAddCallback(button, XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + for (i=0; i < hls_count; i++) { + sprintf(tmp, "%d", hls[i]); + button4[i] = XmCreatePushButton(pull4, tmp, NULL, 0); + XtManageChild(button4[i]); + XtAddCallback(button4[i], XmNactivateCallback, + (XtCallbackProc)hls_call, NULL); + } +} + + +static Widget +CreateSelectXLFD(Widget top) +{ + + int n; + Arg args[16]; + XmString xms, xms1 ; + Widget editW ; + Widget frame, row1, label1, row2, cas1, cas2, cas3, cas4; + XmString str; + udc_flag = sty_flag = wls_flag = hls_flag = False; + + /* + * create base window + */ + n = 0 ; + XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ; + XtSetArg( args[n], XmNnoResize, True ) ; n++ ; + XtSetArg( args[n], XmNminimizeButtons, True ) ; n++ ; + xms = XmStringCreateLocalized( resource.exec_label ) ; + XtSetArg( args[n], XmNokLabelString, xms ) ; n++ ; + xms1 = XmStringCreateLocalized( resource.quit_label) ; + XtSetArg( args[n], XmNhelpLabelString, xms1 ) ; n++ ; + XtSetArg( args[n], XmNtitle, resource.l_open_title ) ; n++ ; + editW = XmCreateTemplateDialog( top, "open_dialog", args, n ); + + XmStringFree( xms ) ; + XmStringFree( xms1 ) ; + + n = 0; + pull1 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull2 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull3 = XmCreatePulldownMenu(toplevel, "pull", args, n); + pull4 = XmCreatePulldownMenu(toplevel, "pull", args, n); + + n = 0 ; + xlfdWform = XmCreateRowColumn( editW, "BaseForm", args, n ); + XtManageChild( xlfdWform ); + + n = 0; + frame = XmCreateFrame( xlfdWform, "frame", args, n); + XtManageChild( frame ); + + n = 0 ; + row1 = XmCreateRowColumn( frame, "row", args, n ); + XtManageChild( row1 ); + + n = 0; + str = XmStringCreateLocalized(resource.l_selectitem) ; + XtSetArg(args[n], XmNlabelString, str); n++; + label1 = XmCreateLabel( row1, "SelectItems", args, n); + XtManageChild( label1 ); + XmStringFree(str); + + n = 0 ; + row2 = XmCreateRowColumn( row1, "row", args, n ); + XtManageChild( row2 ); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_codeset) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull1); n++; + cas1 = XmCreateOptionMenu( row2, "CodeSet", args, n ); + XtManageChild( cas1 ); + XtAddCallback(XmOptionButtonGadget(cas1), XmNcascadingCallback, + (XtCallbackProc)button_set1, NULL); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_style) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull2); n++; + cas2 = XmCreateOptionMenu( row2, "Style", args, n ); + XtAddCallback(XmOptionButtonGadget(cas2), XmNcascadingCallback, + (XtCallbackProc)button_set2, NULL); + XtManageChild( cas2 ); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_width) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull3); n++; + cas3 = XmCreateOptionMenu( row2, "Width", args, n ); + XtManageChild( cas3 ); + XtAddCallback(XmOptionButtonGadget(cas3), XmNcascadingCallback, + (XtCallbackProc)button_set3, NULL); + XmStringFree(str); + + n = 0 ; + str = XmStringCreateLocalized(resource.l_height) ; + XtSetArg(args[n], XmNlabelString, str); n++; + XtSetArg(args[n], XmNsubMenuId, pull4); n++; + cas4 = XmCreateOptionMenu( row2, "Height", args, n ); + XtManageChild( cas4 ); + XtAddCallback(XmOptionButtonGadget(cas4), XmNcascadingCallback, + (XtCallbackProc)button_set4, NULL); + XmStringFree(str); + + font_init(); + create_xlfd(); + + n = 0; + XtSetArg(args[n], XmNvisibleItemCount, 10) ; n++ ; + XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT) ; n++ ; + XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC) ; n++ ; + XtSetArg(args[n], XmNselectionPolicy, XmSINGLE_SELECT) ; n++ ; + XtSetArg(args[n], XmNitems, xlf) ; n++ ; + XtSetArg(args[n], XmNitemCount, xlf_count) ; n++ ; + scrolllist = XmCreateScrolledList(xlfdWform, "scrolllist", args, n); + XtManageChild(scrolllist); + + /* + * Error_Messege + */ + + XtAddCallback(editW, XmNokCallback, (XtCallbackProc)OpenWindowCB, NULL); + XtAddCallback(editW, XmNokCallback, (XtCallbackProc)ReadCB, NULL); + XtAddCallback(editW, XmNhelpCallback, + (XtCallbackProc)OpenCancelCB, NULL); + + return( editW ) ; +} diff --git a/cde/programs/dtudcfonted/selectxlfd.h b/cde/programs/dtudcfonted/selectxlfd.h new file mode 100644 index 000000000..916c645d6 --- /dev/null +++ b/cde/programs/dtudcfonted/selectxlfd.h @@ -0,0 +1,62 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* selectxlfd.h 1.1 - Fujitsu source for CDEnext 96/01/06 16:57:23 */ +/* $XConsortium: selectxlfd.h /main/3 1996/04/08 16:02:27 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + +#define BUTTONITEMS 4 +#define PUSHBUTTONS 2 +#define COPYLABELS 2 + +#define CX 12 +#define CY -4 + +#define XLFD_COLUMNS 38 +#define KEY_COLUMNS 15 + +/* + * put data from resource database + */ +typedef struct _Rsrc { + char * xlfd_label ; + char * copy_xlfd_label ; + char * code_label ; + char * style_label ; + char * size_label ; + char * exec_label ; + char * quit_label ; + char * ok_label ; + char * cancel_label ; + char * copy_orgin ; + char * copy_target ; + char * copy_label ; + char * overlay_label ; +} Rsrc ; +/***************< end of selectxlfd.h >***************/ diff --git a/cde/programs/dtudcfonted/ufont.c b/cde/programs/dtudcfonted/ufont.c new file mode 100644 index 000000000..1372e945c --- /dev/null +++ b/cde/programs/dtudcfonted/ufont.c @@ -0,0 +1,2490 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* ufont.c 1.45 - Fujitsu source for CDEnext 96/12/03 18:34:11 */ +/* $XConsortium: ufont.c /main/14 1996/12/17 19:30:16 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +#include <X11/Intrinsic.h> + +#include "xoakufont.h" +#include "util.h" + +#define _CLIENT_CAT_NAME "dtudcfonted" +extern char *_DtGetMessage(char *filename, int set, int n, char *s); +#define GETMESSAGE(set, number, string) GetMessage(set, number, string) +static char * +GetMessage(int set, int number, char *string) +{ + char *tmp, *ret; + tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string); + ret = malloc(strlen(tmp) + 1); + strcpy(ret, tmp); + return (ret); +} + +/**************************************************************** + * Widgets * + ***************************************************************/ +Widget toplevel; +static Widget dnPopW; +Widget wgeScro, editPopW; + +static int select_x, select_y, select_w, select_h; +static int r1_x, r1_y, r2_x, r2_y, cut_w, cut_h; + +extern Widget xlfdDialog, cpyDialog; + +extern FalFontID font_id; + +Pixmap arrow_pix=0; + + +static XtAppContext app; /* application context */ +static int edpane_size=0; + +static void OtherFontSelect(void); +void drawDelCode(int i); +void drawDelPtn(int i); +static void xeg_init(void); + + +static void dstrypaneEditPtn(void); +void chgEdCode(int code, char mode); +void chgEdList(int statloc, int slctloc, char mode); +static void chgEdPtn(int code); +static void DrawRectEdPn(int x1, int y1, int x2, int y2); +static void DrawBorderEdPn(int x1, int y1, int x2, int y2); +static void DrawPointEdPn(int x, int y, int mode); +static void DrawDpPn(void); +static void DrawPointDpPn(int x, int y, int mode); +static void musPoint(int evtype, int px, int py); +static void musLine(int evtype, int px, int py); +static void musCircle(int evtype, int px, int py); +static void musRect(int proc, int evtype, int px, int py); +static void musRegionProc(int proc, int evtype, int px, int py); +static void musPasteProc(Widget w, XtPointer client_data, XEvent *event); +static void rubLine(int x1, int y1, int x2, int y2); +static void rubBand(int x1, int y1, int x2, int y2); +static void rubCircle(int ox, int oy, int rx, int ry); +static void resetEditMode(unsigned int flag); +static void copyPatterns(FalFontData *fdata, + int s1_code, + int s2_code, + int d1_code, + int proc); +extern String MngCodeTfValue(void); +extern String CpySrcCodeTfValue(void); +extern String CpyDestCodeTfValue(void); +char *get_cmd_path(char *path, char *cmd); +extern FalFontData fullFontData; +extern FalFontData copyFontData; + +extern void PopupSelectXLFD(Widget top); +extern void UpdateMessage(String str); +extern void DispMngErrorMessage(String msg); +extern void DispCpyErrorMessage(String msg); +static int setRealDelArea(int *s_ncode, + int *e_ncode, + int *sq_start, + int *sq_end); + +/**************************************************************** + * parameters * + ***************************************************************/ +static Arg arg[30]; +static int n; + +Resource resource; + +/**************************************************************** + * callback routines * + ***************************************************************/ + +static void CancelCB(void); + +static void +ExitCB(void) +{ + exit(0); +} + +int +efctPtnNum(void) +{ + int no; + int sq; + int cnt; + + for ( cnt = 0, sq = edlist.sqstart; + sq < (edlist.sqstart + edlist.nptn); sq++) { + no = ptnSqToNo(sq); + if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) + cnt++; + } + return( cnt); +} + +void +Error_message(Widget widget, char *message) +{ + static NoticeButton is_lock[] = { + NBTNARGS( ExitCB, NULL, 'E', True, False ), + NBTNARGS( CancelCB, NULL, 'C', True, True ) + }; + static NButton LockBTN = NBUTTONS( is_lock ); + + SetItemLabel(&LockBTN, 0, resource.l_exit); + SetItemLabel(&LockBTN, 1, resource.l_cancel); + PopupNotice( (widget), message, + D_ERROR, + &LockBTN, + True, + resource.l_question_title); +} + +void +Error_message2(Widget widget, char *message) +{ + static NoticeButton is_lock[] = { + NBTNARGS( CancelCB, NULL, 'C', True, True ) + }; + static NButton LockBTN = NBUTTONS( is_lock ); + + if (widget == NULL) + widget = toplevel; + + SetItemLabel(&LockBTN, 0, resource.l_ok); + PopupNotice( (widget), message, + D_ERROR, + &LockBTN, + True, + resource.l_question_title); +} + +/* + * contents : read a character pattern from SNF file + */ +/*ARGSUSED*/ +static void +CBmOblB_edit( Widget widget, caddr_t clientData, caddr_t callData ) +{ + int ptn_n; + int ptn_w; + int ptn_h; + int code; + int i; + int ret; + char err[128]; + extern int begin_code; + + extern int ptnGetInfo(); + extern void PopupEditPtn(); + + /* open font file and get informations of character to be edited */ + + ret = readSNF( &(edg.fdata), &(edg.width), &(edg.height), err); + + if( ret == -1 ) { + Error_message(widget, err); + return; + } + dn.ptn_w = (Dimension) edg.width; + dn.ptn_h = (Dimension) edg.height; + + + if( xlfdDialog != NULL ) + PopdownDialog(xlfdDialog); + + ptnGetInfo( &ptn_n, &ptn_w, &ptn_h ); + for( i=0 ; i<ptn_n ; i++ ) { + code = noToCode( ptnSqToNo(i) ); + if( begin_code > code){ + edlist.sqstart = i+1; + } else { + edlist.nptn++; + } + } + if( efctPtnNum() > 0) { + for ( i=edlist.sqstart; i<(edlist.sqstart+edlist.nptn); i++){ + if ( codeCheck( noToCode( ptnSqToNo(i))) == 0) + break; + } + edg.ncode = ptnSqToNo( i ); + edg.code = noToCode( edg.ncode ); + ptnGet( edg.code, edg.ptn ); + } + PopupEditPtn(toplevel); +} + + + +void CBeOblB_aAdd(void); + +static Boolean do_read = False; +static Boolean do_end = False; + +static void CancelCB(void) { } + +static void ContReadCB(Widget w) +{ + FalCloseFont(font_id); + editPtnW = NULL; + OtherFontSelect(); + PopupSelectXLFD(toplevel); +} + +static void SaveReadCB(void) +{ + CBeOblB_aAdd(); + do_read = True; + PopupSelectXLFD(toplevel); +} + + +static void ContEndCB(void) +{ + FalCloseFont(font_id); + exit(0); +} + +static void SaveEndCB(void) +{ + CBeOblB_aAdd(); + do_end = True; +} + + +/* + * contents : quit editting + */ + + +/*ARGSUSED*/ +static int +QuitEditPtn( Widget widget, caddr_t clientData, caddr_t callData ) +{ + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + if( edg.code != 0 ){ + ptnAdd( edg.code, edg.ptn ); + } + if( edg.flag == ON ){ + return(0); + } + return(1); +} + + + +void +OpenCB(Widget w, XtPointer client_data, XtPointer call_data) +{ + static NoticeButton is_save_read_btn1[] = { + NBTNARGS( SaveReadCB, NULL, 'S', True, False ), + NBTNARGS( ContReadCB, NULL, 'O', True, False ), + NBTNARGS( CancelCB, NULL, 'C', True, True ), + }; + static NoticeButton is_save_read_btn2[] = { + NBTNARGS( ContReadCB, NULL, 'O', True, False ), + NBTNARGS( CancelCB, NULL, 'C', True, True ), + }; + static NButton SaveReadBTN1 = NBUTTONS( is_save_read_btn1 ); + static NButton SaveReadBTN2 = NBUTTONS( is_save_read_btn2 ); + + if (QuitEditPtn((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL)){ + FalCloseFont(font_id); + editPtnW = NULL; + OtherFontSelect(); + PopupSelectXLFD(toplevel); + } + else{ + if (! fullFontData.prm) { + SetItemLabel(&SaveReadBTN1, 0, resource.l_do_save_exit); + SetItemLabel(&SaveReadBTN1, 1, resource.l_dont_save_exit); + SetItemLabel(&SaveReadBTN1, 2, resource.l_cancel); + PopupNotice( (w), resource.mn_saved_open , + D_QUESTION, + &SaveReadBTN1, + True, + resource.l_question_title); + } else { + SetItemLabel(&SaveReadBTN2, 0, resource.l_dont_save_exit); + SetItemLabel(&SaveReadBTN2, 1, resource.l_cancel); + PopupNotice( (w), resource.mn_saved_open , + D_QUESTION, + &SaveReadBTN2, + True, + resource.l_question_title); + } + } +} + + +void +ReadCB(Widget w, XtPointer client_data, XtPointer call_data) +{ + if (fullFontData.xlfdname == NULL) { + return; + } + if (fullFontData.xlfdname == (char *) -1) { + Error_message(w, resource.mn_prop_font); + return; + } + CBmOblB_edit( w, client_data, call_data ); +} + +/**************************************************************** + * callback routines and event handler * + ***************************************************************/ + +/* + * contents : write character patterns to SNF file +*/ + +static Boolean +WPwriteSNF( int restart ) +{ + int rc, err; + char str[MG_MAXSIZE]; + + switch( rc = writeSNF( restart, &err ) ) { + case -1: + if (dnPopW) + XtSetSensitive( dnPopW, TRUE ); + switch( err ) { + case 001: + sprintf(str, "%s(permission denied)", resource.me_write_snf); + break; + case 002: + sprintf(str, "%s(disk full)", resource.me_write_snf); + break; + case 101: + sprintf(str, "%s(pipe error)", resource.me_write_snf); + break; + case 102: + sprintf(str, "%s(fork error)", resource.me_write_snf); + break; + case 103: + sprintf(str, "%s(execv error)", resource.me_write_snf); + break; + case 104: + sprintf(str, "%s(data error)", resource.me_write_snf); + break; + default: + sprintf(str, "%s", resource.me_write_snf); + } + UpdateMessage( str ); + return( TRUE ); + case 0: + edg.flag = 0; + UpdateMessage( resource.mg_register ); + sleep(1); + UpdateMessage(""); + + if (do_read){ + do_read = False; + ContReadCB((Widget)NULL); + } + if (do_end){ + do_read = False; + ContEndCB(); + } + return(TRUE); + default: + if( rc == 1101 ) + sprintf( str, "%s", resource.me_wait ); + else + sprintf( str, "%s(%3d%%)", resource.mg_write_snf , rc-1000 ); + + UpdateMessage( str ); + XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)ON ); + if( rc == 1101 ){ + XSync( xl.display,0 ); + } + return( TRUE ); + } +} + + + +/* + * contents : write character patterns to SNF file + */ + +void +CBeOblB_aAdd(void) +{ + char str[MG_MAXSIZE]; + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + UpdateMessage( resource.mg_write_snf ); + + if( edg.code != 0 ) + ptnAdd( edg.code, edg.ptn ); + + if( edg.flag == ON ) { + sprintf( str, "%s", resource.mg_write_snf ); + if (dnPopW) + XtSetSensitive( dnPopW, FALSE ); + + XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)OFF ); + return; + } + else{ + UpdateMessage( "" ); + } +} + + + +/* + * contents : destroy the editor window + */ + +static void +OtherFontSelect(void) +{ + dstrypaneEditPtn(); + xeg_init(); +} + + + +/* + * contents : close dtudcfonted + */ + +/*ARGSUSED*/ +void +CBeOblB_aEnd( Widget widget, caddr_t clientData, caddr_t callData ) +{ + static NoticeButton is_save_exit_btn[] = { + NBTNARGS( SaveEndCB, NULL, 'S', True, False ), + NBTNARGS( ContEndCB, NULL, 'E', True, False ), + NBTNARGS( CancelCB, NULL, 'C', True, True ), + }; + static NButton SaveEndBTN = NBUTTONS( is_save_exit_btn ); + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + if( edg.code != 0 ) + ptnAdd( edg.code, edg.ptn ); + if( edg.flag == ON ) { + + SetItemLabel(&SaveEndBTN, 0, resource.l_do_save); + SetItemLabel(&SaveEndBTN, 1, resource.l_dont_save); + SetItemLabel(&SaveEndBTN, 2, resource.l_cancel); + PopupNotice( widget, resource.mn_saved_exit, D_QUESTION, + &SaveEndBTN, True, resource.l_question_title); + return; + } else { + FalCloseFont(font_id); + } + + exit(0); +} + + + +/*ARGSUSED*/ +void +CBeOblB_rCmd( Widget widget, int proc, caddr_t callData ) +{ + extern void SelectUnset(); + extern void UndoSet(); + if (!select_x && !select_y && !select_w && !select_h) + return; + em.rsv_f = ON; + bitPtnCopy( em.rsv_ptn, edg.ptn ); + rubBand( r1_x, r1_y, r2_x, r2_y ); + switch( proc ) { + case PROC_CLS: + bitDrawCls (edg.ptn, select_x, select_y, select_w, select_h ); + break; + case PROC_SET: + bitDrawSet (edg.ptn, select_x, select_y, select_w, select_h ); + break; + case PROC_REV: + bitDrawRev (edg.ptn, select_x, select_y, select_w, select_h ); + break; + case PROC_ROLL: + bitDrawRoll(edg.ptn, select_x, select_y, select_w, select_h); + break; + case PROC_SYMV: + bitDrawSymV(edg.ptn, select_x, select_y, select_w, select_h ); + break; + case PROC_SYMH: + bitDrawSymH(edg.ptn, select_x, select_y, select_w, select_h ); + break; + } + edg.flag = ON; + DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + DrawDpPn(); + select_x = select_y = select_w = select_h = 0; + SelectUnset(); + UndoSet(); +} + +/*ARGSUSED*/ +void +CBeOblB_rCmdp( Widget widget, int proc, caddr_t callData ) +{ + extern Widget wgeBulB_edit; + extern void CopySet(); + extern void UndoSet(); + extern void SelectUnset(); + + switch( proc ) { + case PROC_CPY: + if (!select_x && !select_y && !select_w && !select_h) + return; + rubBand( r1_x, r1_y, r2_x, r2_y ); + bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, False); + cut_w = select_w; + cut_h = select_h; + select_x = select_y = select_w = select_h = 0; + CopySet(); + SelectUnset(); + break; + case PROC_CUT: + if (!select_x && !select_y && !select_w && !select_h) + return; + em.rsv_f = ON; + rubBand( r1_x, r1_y, r2_x, r2_y ); + bitPtnCopy( em.rsv_ptn, edg.ptn ); + bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, True); + cut_w = select_w; + cut_h = select_h; + edg.flag = ON; + DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + DrawDpPn(); + select_x = select_y = select_w = select_h = 0; + CopySet(); + UndoSet(); + SelectUnset(); + break; + case PROC_PASTE: + XtAddEventHandler(wgeBulB_edit, + ButtonReleaseMask|PointerMotionMask, + False, musPasteProc, NULL ); + } +} + + + + +/* + * contents : cancel all editting + */ + +/*ARGSUSED*/ +void +CBeOblB_rCan( Widget widget, caddr_t clientData, caddr_t callData ) +{ + extern void UndoUnset(); + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT ); + + if( em.rsv_f == ON ) { + bitPtnCopy( edg.ptn, em.rsv_ptn ); + em.rsv_f = OFF; + + DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + DrawDpPn(); + UndoUnset(); + } +} + + + + +/* + * + * contents : get a sequential number of the editor + */ +int +RelToAbsSq( int from, int cnt) +{ + int i; + int no; + + if ( cnt >= 0) { + for ( i = -1; from < (edlist.sqstart + edlist.nptn) ; from++) { + no = ptnSqToNo(from); + if (( no >= 0) && ( noToCode( no) >= 0) ) { + i++; + if ( i >= cnt) + return( from); + } + } + } else { + cnt *= -1; + for ( i = -1; from >= edlist.sqstart; from--) { + no = ptnSqToNo(from); + if (( no >= 0) && ( noToCode( no) >= 0) ) { + i++; + if ( i >= cnt) + return(from); + } + } + } + return( -1); +} + +/* + * contents : get a relative number of the system area + */ +int +AbsSqToRel( int from, int to) +{ + int sq; + int cnt; + int sign = 1; + int no; + + if ( from > to) { + sq = from; + from = to; + to = sq; + sign = -1; + } + + for ( cnt = -1, sq = from; sq <= to; sq++) { + no = ptnSqToNo(sq); + if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) + cnt++; + } + + if ( cnt < 0) + cnt = 0; + + cnt *= sign; + return( cnt); +} + + +/* + * contents : be the character list selected + */ + +/*ARGSUSED*/ +void +EHeStaT_list( Widget widget, int select, XEvent *e ) +{ + int sq, no; + int code; + + resetEditMode( RES_MSG|RES_PROC|RES_SLCT|RES_RSV ); + + if( (e->xbutton.button != 1) || (e->type != ButtonRelease) || + (e->xbutton.x < 0) || ((int)edlist.elem_w < e->xbutton.x) || + (e->xbutton.y < 0) || ((int)edlist.elem_h < e->xbutton.y) + ) + return; + + if( edlist.slctloc == select ) + return; + + sq = RelToAbsSq( edlist.sqstart + edlist.statloc, select); + + if( (no = ptnSqToNo(sq)) == -1 ) + return; + + code = noToCode( no ); + if( codeCheck( code ) == -1 ) + return; + + if( ptnSense( code) == 0 ) + return ; + + chgEdList( edlist.statloc, select, OFF ); + if( ptnSense(edg.code) == 1 ) + ptnAdd(edg.code, edg.ptn ); + chgEdPtn( code ); +} + + + + +/* + * contents : update the character list + */ + +/*ARGSUSED*/ +void +CBeScro( Widget widget, caddr_t clientData, caddr_t callData ) +{ + int newl; + int new_statloc; + int new_slct; + + n = 0; + XtSetArg( arg[n], XmNvalue, (XtArgVal)&newl ); n++; + XtGetValues( wgeScro , arg, n ); + + if (( new_statloc = RelToAbsSq( edlist.sqstart, newl)) < 0) { + new_statloc = 0; + } else { + new_statloc -= edlist.sqstart; + } + /* + */ + new_slct = edlist.slctloc + - AbsSqToRel( edlist.sqstart + edlist.statloc, + edlist.sqstart + new_statloc); + chgEdList( new_statloc, new_slct, OFF); +} + + + + +/* + * contents : select the edit items by mouse + */ + +/*ARGSUSED*/ +void +EHeBulB_eMEv( Widget widget, caddr_t clientData, XEvent *e ) +{ + int px, py; + int downbutton; + + if (edpane.pix_w * edpane.pix_h == 0 ) { + return; + } + + if( e->type == ButtonPress ){ + em.drag_f = ON; + } + if( (edg.code == 0) || (em.drag_f == OFF) ) + return; + if( e->type == ButtonRelease ){ + em.drag_f = OFF; + } + + px = e->xbutton.x / edpane.pix_w; + py = e->xbutton.y / edpane.pix_h; + + if (( e->type == ButtonPress) || (e->type == ButtonRelease)){ + downbutton = e->xbutton.button; + }else if ( e->type == MotionNotify ){ + if ( e->xmotion.state & Button1Mask ){ + downbutton = 1; /* select button */ + }else if ( e->xmotion.state & Button2Mask ){ + downbutton = 2; /* adjust button */ + } else { + downbutton = 0; + } + } + + switch( downbutton ) { + case 1: + switch( em.proc ) { + case PROC_POINT: + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + musPoint( e->type, px, py ); + break; + case PROC_LINE: + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + musLine( e->type, px, py ); + break; + case PROC_CIRCLE: + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + musCircle( e->type, px, py ); + break; + case PROC_RECT: + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + musRect( em.proc, e->type, px, py ); + break; + case PROC_ERASE: + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + musPoint( e->type, px, py ); + break; + case PROC_SELECT: + musRegionProc( em.proc, e->type, px, py ); + break; + default: + break; + } + break; + + case 2: + if( (0 <= px) && (px < edg.width) && (0 <= py) && (py < edg.height) ) { + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + switch( e->type ) { + case MotionNotify: + if( (em.adj_px == px) && (em.adj_py == py) ) + return; + break; + case ButtonPress: + em.adj_px = px; + em.adj_py = py; + if( bitRead(edg.ptn, px, py) == 0 ) { + bitSet( edg.ptn, px, py ); + DrawPointEdPn( px,py, 1 ); + DrawPointDpPn( px,py, 1 ); + } + else { + bitReset( edg.ptn, px, py ); + DrawPointEdPn( px,py, 0 ); + DrawPointDpPn( px,py, 0 ); + } + edg.flag = ON; + break; + default: + return; + } + } + default: + break; + } +} + + + + +/* + * contents : restore the editting pane + */ + +/*ARGSUSED*/ +void +EHeBulB_eExp( Widget widget, caddr_t clientData, XEvent *e ) +{ + int x1, y1; + int x2, y2; + + if (edpane.pix_w * edpane.pix_h == 0 ) { + return; + } + + x1 = e->xexpose.x / edpane.pix_w; + y1 = e->xexpose.y / edpane.pix_h; + x2 = (e->xexpose.x + e->xexpose.width - 1) / edpane.pix_w; + y2 = (e->xexpose.y + e->xexpose.height - 1) / edpane.pix_h; + + DrawRectEdPn( x1, y1, x2, y2 ); + DrawBorderEdPn( x1, y1, x2, y2 ); +} + + + + +/* + * contents : specifies the drawing operation (Pont/Line/Rectangle/Circle) + */ + +/*ARGSUSED*/ +void +CBeRecB_obj( Widget widget, int obj, XmToggleButtonCallbackStruct *call) +{ + extern void SelectUnset(); + + if (call->set == False) + return; + + resetEditMode( RES_MSG | RES_RSV | RES_SLCT ); + + if (obj == PROC_ERASE) + edpane.color = OFF; + else + edpane.color = ON; + edpane.obj = obj; + em.proc = obj; + if (obj != PROC_SELECT) { + if (select_x || select_y || select_w || select_h) { + rubBand( r1_x, r1_y, r2_x, r2_y ); + select_x = select_y = select_w = select_h = 0; + SelectUnset(); + } + } +} + + + + +/* + * contents : restore the displaying pane + */ + +/*ARGSUSED*/ +void +EHeBulB_dExp( Widget widget, caddr_t clientData ) +{ + if (xl.display == NULL ){ + return; + } + + DrawDpPn(); +} + +/* + * contents : set the range to be add or deleted + */ + +static int +codeAreaSet(int *s_code, int *e_code) +{ + char *str; + char delm; + + str = MngCodeTfValue(); + delm = '\0'; + *s_code = 0; + *e_code = 0; + if (!str || !*str){ + return(-1); + } + sscanf( str, "%x %c %x", s_code, &delm, e_code ); + if (str) free( str ); + switch( delm ) { + case '\0': + *e_code = *s_code; + break; + case '-': + break; + default: + return(-1); + } + if( codeCheck(*s_code) || codeCheck(*e_code) || + (*s_code > *e_code) ) { + return(-1); + } + return(0); +} + + +/**************************************************************** + * callback routines (character management window) * + ***************************************************************/ + +Boolean +BeforeMngCheck(int *s_code, int *e_code) +{ + if(codeAreaSet(s_code, e_code) == -1) { + DispMngErrorMessage( resource.me_illegal_code ); + return(False); + } + return(True); +} + +void +DoAddProc(int s_code, int e_code) +{ + int code; + + int s_ncode; + int e_ncode; + char ptn[MAXPTNBYTE]; + char mode; + int i; + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + s_ncode = codeToNo( s_code ); + e_ncode = codeToNo( e_code ); + mode = OFF; + bitPtnClear( ptn ); + for( i=s_ncode ; i <= e_ncode ; i++ ) { + code = noToCode(i); + if ( codeCheck( code)) + continue; + if (ptnSense(code) == 0) { + if(ptnAdd(code, ptn) != 1) { + UpdateMessage( resource.me_non_memory ); + return; + } + edg.flag = ON; + mode = ON; + edlist.nptn++; + } + } + + if( ptnSense( edg.code ) == 1 ) { + ptnAdd( edg.code, edg.ptn ); + } + + if(mode == ON) { + chgEdCode( s_code, mode ); + } + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); +} + + + +void PopupDelNotice(); +Widget CreateDelNotice(); + + +void +DoDelProc( int s_code, int e_code ) +{ + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + if( ptnSense( edg.code) == 1 ) + ptnAdd( edg.code, edg.ptn ); + + dn.s_ncode = codeToNo( s_code ); + dn.e_ncode = codeToNo( e_code ); + + if (setRealDelArea(&dn.s_ncode, &dn.e_ncode, &dn.sq_start, &dn.sq_end) == -1) { + DispMngErrorMessage( resource.me_nodelete_code ); + return; + } + dn.sq_top = dn.sq_start; + dn.disp_num = AbsSqToRel( dn.sq_start, dn.sq_end) + 1; + dn.disp_num = (dn.disp_num <= D_MAX) ? dn.disp_num : D_MAX; + + PopupDelNotice( mngPtnW ); + +} + + + + +/* + * contents : get the real range to be add or delete + */ + + +static int +setRealDelArea(int *s_ncode, int *e_ncode, int *sq_start, int *sq_end ) +{ + int ncode; + int flg; + int sq; + int i; + + /* first code */ + flg = 0; + ncode = *e_ncode; + for( i=*s_ncode ; i <= ncode ; i++ ) { + if (((sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i)) == 0)) { + flg = 1; + break; + } + } + if (flg == 1) { + *s_ncode = ptnSqToNo( sq ); + *sq_start = sq; + } else { + return(-1); + } + + /* last code */ + flg = 0; + ncode = *s_ncode; + for( i=*e_ncode ; i >= ncode ; i-- ) { + if ((( sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i) ) == 0)) { + flg = 1; + break; + } + } + *e_ncode = ptnSqToNo( sq ); + *sq_end = sq; + return(0); +} + + + + + + +/**************************************************************** + * callback routines (Copy) * + ****************************************************************/ + +static int +CpySrcCodeCheck(void) +{ + char *str; + char delm; + + str = CpySrcCodeTfValue(); + if (!str) + return(-1); + if (!*str) { + free(str); + return(-1); + } + delm = '\0'; + cpm.s1_code = 0; + cpm.s2_code = 0; + sscanf( str, "%x %c %x", &cpm.s1_code,&delm, &cpm.s2_code ); + free( str ); + switch( delm ) { + case '\0': + cpm.s2_code = cpm.s1_code; + break; + case '-': + break; + default: + return(-1); + } + if (cpm.s1_code > cpm.s2_code) + return(-1); + return(0); +} + +static int +CpyDestCodeCheck(void) +{ + char *str; + + str = CpyDestCodeTfValue(); + if (!str) + return(-1); + if (!*str){ + free(str); + return(-1); + } + cpm.d1_code = 0; + sscanf( str, "%x", &cpm.d1_code ); + free( str ); + + if( codeCheck(cpm.d1_code) ) { + return(-1); + } + return(0); +} + +Boolean +BeforeCpyCheck( int proc ) +{ + int s_ncode, e_ncode; + int r1_code, r2_code; + int no; + int i; + char rstr[30]; + extern void PopupCpyNotice(); + + if (copyFontData.xlfdname == NULL) { + DispCpyErrorMessage(resource.me_non_srcfile); + return(False); + } + + if (CpySrcCodeCheck() == -1){ + DispCpyErrorMessage( resource.me_illegal_srccode ); + return(False); + } + + if (CpyDestCodeCheck() == -1){ + DispCpyErrorMessage( resource.me_illegal_destcode ); + return(False); + } + + s_ncode = codeToNo( cpm.d1_code ); + e_ncode = codeToNo( cpm.d1_code + cpm.s2_code - cpm.s1_code); + r1_code = r2_code = 0; + for( i=s_ncode ; i <= e_ncode ; i++ ) { + no = ptnSqToNo(i); + if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) { + if(r1_code == 0) + r1_code = noToCode(i); + r2_code = noToCode(i); + } + } + + cpm.proc = proc; + + if( r1_code != 0 ) { + if( r1_code == r2_code ) { + sprintf( rstr, "%s %x¡¡", resource.l_code, r1_code ); + } else if ( codeCheck(r1_code) && codeCheck(r2_code)){ + sprintf( rstr, " %x - %x", r1_code, r2_code ); + } else { + sprintf( rstr, "%s %x - %x ", resource.l_code_range, r1_code, r2_code ); + } + PopupCpyNotice(rstr); + + return(False); + } + return(True); +} + +void +DoCpyProc(void) +{ + extern void PopdownCpyPtn(); + + PopdownCpyPtn(); + + resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV ); + + copyPatterns( cpm.fdata, cpm.s1_code, cpm.s2_code, cpm.d1_code, cpm.proc ); +} + +/**************************************************************** + * main routine * + ****************************************************************/ +#define R(name, class, member,def) { \ + name, \ + class, \ + XtRString, \ + sizeof(char *), \ + XtOffsetOf(Resource, member), \ + XtRString, \ + (XtPointer)def } + +#define RBoolean(name, class, member,def) \ + { name, class, XtRBoolean, sizeof(XtRBoolean), \ + XtOffsetOf(Resource, member), XtRString, (XtPointer)def } + +#define RDimension(name, class, member,def) \ + { name, class, XtRDimension, sizeof(XtRDimension), \ + XtOffsetOf(Resource, member), XtRString, (XtPointer)def } + +#define Rint(name, class, member,def) \ + { name, class, XtRInt, sizeof(XtRInt), \ + XtOffsetOf(Resource, member), XtRString, (XtPointer)def } + +#define RPixel(name, class, member,def) \ + { name, class, XtRPixel, sizeof(XtRPixel), \ + XtOffsetOf(Resource, member), XtRString, (XtPointer)def } + +static XtResource app_resources[] = { +RBoolean("Codepoint", "codepoint", codepoint, "False"), + +R( "lptog", "Lptog", l_ptog, DFLTPATH ), +R( "lptogCmd", "LptogCmd", l_ptog_cmd, DFLTCMD ), + +/* CreateCaptionFrame() */ +RBoolean( "captResize", "CaptResize", capt_resize, "True" ) , +Rint( "captLftoff", "CaptLftoff", capt_lftoff, "2" ) , +Rint( "captTopoff", "CaptTopoff", capt_topoff, "2" ) , +Rint( "captRghoff", "CaptRghoff", capt_rghoff, "2" ) , + +RPixel( "paneBackground", "paneBackground", pane_background, "white" ), +RPixel( "paneForeground", "PaneForeground", pane_foreground, "black" ), +RPixel( "background", "Background", background, "white" ), +RPixel( "foreground", "Foreground", foreground, "black" ), + +/* CreateMenuButtons() */ +RDimension( "menuMargin", "MenuMargin", menu_margin, "0" ) , + +/* CreateDialogAndButtons() */ +RBoolean( "diaTmAutomng", "DiaTmAutomng", dia_tm_automng, "False" ) , +RDimension( "diaTmWidth", "DiaTmWidth", dia_tm_width, "4" ) , +RDimension( "diaTmHeight", "DiaTmHeight", dia_tm_height, "4" ) , +RBoolean( "diaTmResize", "DiaTmResize", dia_tm_resize, "True" ) , +RBoolean( "diaTmMinimize", "DiaTmMinimize", dia_tm_minimize, "True" ) , + +RDimension( "diaRwWidth", "DiaRwWidth", dia_rw_width, "6" ) , +RDimension( "diaRwHeight", "DiaRwHeight", dia_rw_height, "6" ) , +RDimension( "diaRwSpacing", "DiaRwSpacing", dia_rw_spacing, "4" ) , + +/* CreateDrawingArea() */ +RDimension( "drawBorder", "DrawBorder", draw_border, "1" ) , +Rint( "drawTopoff", "DrawTopoff", draw_topoff, "2" ) , +Rint( "drawLftoff", "DrawLftoff", draw_lftoff, "2" ) , + +/* PopupNotice() */ +RBoolean( "popResize", "PopResize", pop_resize , "True" ) , +RBoolean( "popMinimize", "PopMinimize", pop_minimize , "True" ) , + +/* CreateTemplateDialog() */ +RBoolean( "tempResize", "TempResize", temp_resize, "True" ) , +RBoolean( "tempMinimize", "TempMinimize", temp_minimize, "True" ) , + +RDimension( "tempWidth", "TempWidth", temp_width, "1" ) , +RDimension( "tempHeight", "TempHeight", temp_height, "1" ) , + +/* CreateMenuBarAndFooterMessageForm() */ +Rint( "edBarTopoff", "EdBarTopoff", ed_bar_topoff, "1" ) , +Rint( "edBarLftoff", "EdBarLftoff", ed_bar_lftoff, "1" ) , +Rint( "edBarRghoff", "EdBarRghoff", ed_bar_rghoff, "1" ) , + +Rint( "edFrmBtmoff", "EdFrmBtmoff", ed_frm_btmoff, "3" ) , +Rint( "edFrmLftoff", "EdFrmLftoff", ed_frm_lftoff, "3" ) , +Rint( "edFrmRghoff", "EdFrmRghoff", ed_frm_rghoff, "3" ) , + +RDimension( "edMsgMargintop", "EdMsgMargintop", ed_msg_margintop, "3" ) , +RDimension( "edMsgMarginbtm", "EdMsgMarginbtm", ed_msg_marginbtm, "3" ) , + +RDimension( "edMesgMargintop", "EdMesgMargintop", ed_mesg_margintop, "3" ) , +RDimension( "edMesgMarginbtm", "EdMesgMarginbtm", ed_mesg_marginbtm, "3" ) , + +Rint( "edSepBtmoff", "EdSepBtmoff", ed_sep_btmoff, "3" ) , +Rint( "edSepLftoff", "EdSepLftoff", ed_sep_lftoff, "0" ) , +Rint( "edSepRghoff", "EdSepRghoff", ed_sep_rghoff, "0" ) , +RDimension( "edSepMargin", "EdSepMargin", ed_sep_margin, "0" ) , + +Rint( "edWgeTopoff", "EdWgeTopoff", ed_wge_topoff, "10" ) , +Rint( "edWgeLftoff", "EdWgeLftoff", ed_wge_lftoff, "10" ) , +Rint( "edWgeRghoff", "EdWgeRghoff", ed_wge_rghoff, "10" ) , +Rint( "edWgeBtmoff", "EdWgeBtmoff", ed_wge_btmoff, "10" ) , + +/* CreateFrame() */ +RBoolean( "frameResize", "FrameResize", frame_resize, "False" ) , + +/* CreateScrollBase() */ +RDimension( "scllFrWidth", "ScllFrWidth", scll_fr_width, "500" ) , + +RDimension( "scllFrThick", "ScllFrThick", scll_fr_thick, "2" ) , + +Rint( "scllBarLftoff", "ScllBarLftoff", scll_bar_lftoff, "4" ) , +}; +#undef R +#undef RBoolean +#undef RDimension +#undef Rint +#undef RPixel + +int CodePoint = False; + +/*ARGSUSED*/ +static void +xerror(Display *d, XErrorEvent *ev) +{ + fprintf (stderr, "dtudcfonted: warning, error event receieved.\n"); + exit(-1); +} + +int +main(int argc, char *argv[]) +{ + static char class_name[] = "Dtudcfonted"; + int i; + + /* initialize GUI */ + toplevel = GuiInitialize(&app, class_name, &argc, argv); + + /* get application's resources */ + XtGetApplicationResources( toplevel, &resource, + app_resources, XtNumber(app_resources), NULL, 0); + + if (resource.codepoint) + CodePoint = True; + /* initialize the code range */ + for( i=1 ; i < argc ; i++ ) { + if( !strcmp(argv[i],"-pane_size") ) { + i++; + edpane_size = atoi( argv[i] ); + } else if( !strcmp(argv[i],"-codepoint") ) { + CodePoint = True; + } + } + + resource.mg_write_snf = GETMESSAGE(2, 2, "Registration processing inside."); + resource.me_write_snf = GETMESSAGE(2, 4, "Failed in the registration of the character."); + resource.me_illegal_code = GETMESSAGE(2, 6, "Illegal code."); + resource.me_non_memory = GETMESSAGE(2, 8, "Because the memory allocation cannot be done, it is not possible to add."); + resource.mg_non_code = GETMESSAGE(2, 10, "There is no character of the specified code."); + resource.me_illegal_srccode = GETMESSAGE(2, 12, "The mistake is found in the specified copy origin code."); + resource.me_illegal_destcode = GETMESSAGE(2, 14, "The mistake is found in the specified copy target code."); + resource.me_nodelete_code = GETMESSAGE(2, 16, "There is no character in the specified area."); + resource.me_wait = GETMESSAGE(2, 18, "Please wait for a while."); + resource.me_non_srcfile = GETMESSAGE(2, 20, "No copy origin code file is specified."); + resource.mn_no_font = GETMESSAGE(2, 22, "Informations of user defined character cannot collect.\nThere is no font specified."); + resource.mn_plural_font = GETMESSAGE(2, 24, "Informations of user defined character cannot collect.\nThere are plural fonts specified."); + resource.mn_not_udc = GETMESSAGE(2, 26, "The specified font do not have any UDCs areas."); + resource.mn_no_mem = GETMESSAGE(2, 28, "There are no memories any more."); + resource.mn_illegal_area = GETMESSAGE(2, 30, "The information of UDCs area is illegal."); + resource.mn_no_read = GETMESSAGE(2, 32, "The font file cannot read.\nPattern area was broken."); + resource.mn_prop_font = GETMESSAGE(2, 34, "Dtudcfonted cannot edit proportional character font."); + resource.mn_saved_open = GETMESSAGE(2, 36, "There are unsaved edits.\nDo you want to save them before opening?"); + resource.mn_saved_exit = GETMESSAGE(2, 38, "There are unsaved edits.\nDo you want to save them before exiting?"); + resource.mn_cpy_lost = GETMESSAGE(2, 40, "When the copy processing is done, the glyph\nimage within the following ranges is changed.\nDo you want to do the copy processing?\n\n"); + resource.mn_no_perm = GETMESSAGE(2, 42, "No write permission for this font. You should change the file access mode before saving.\n"); + + resource.l_selectitem = GETMESSAGE(2, 100, "Select Items"); /* font open */ + resource.l_codeset = GETMESSAGE(2, 102, " CodeSet:"); + resource.l_style = GETMESSAGE(2, 104, " Style:"); + resource.l_width = GETMESSAGE(2, 106, " Width:"); + resource.l_height = GETMESSAGE(2, 108, " Height:"); + resource.exec_label = GETMESSAGE(2, 110, "Open"); + resource.quit_label = GETMESSAGE(2, 112, "Quit"); + + resource.l_font = GETMESSAGE(2, 114, "Font"); /* menu bar */ + resource.l_edit = GETMESSAGE(2, 116, "Edit"); + resource.l_manage = GETMESSAGE(2, 118, "Character"); + resource.l_info = GETMESSAGE(2, 120, "Information"); + + resource.l_open_w = GETMESSAGE(2, 122, "Open"); /* font menu */ + resource.l_save = GETMESSAGE(2, 124, "Save"); + resource.l_exit = GETMESSAGE(2, 126, "Exit"); + + resource.l_clear = GETMESSAGE(2, 128, "Clear"); /* edit menu */ + resource.l_set = GETMESSAGE(2, 130, "Set"); + resource.l_reverse = GETMESSAGE(2, 132, "Reverse"); + resource.l_cut = GETMESSAGE(2, 134, "Cut"); + resource.l_Copy = GETMESSAGE(2, 135, "Copy"); + resource.l_paste = GETMESSAGE(2, 136, "Paste"); + resource.l_roll = GETMESSAGE(2, 138, "Rotate"); + resource.l_updown_roll = GETMESSAGE(2, 140, "Vertical Roll"); + resource.l_leftright_roll = GETMESSAGE(2, 142, "Horizontal Roll"); + resource.l_undo = GETMESSAGE(2, 144, "Undo"); + + resource.l_manage_w = GETMESSAGE(2, 146, "Add/Delete..."); /* character menu */ + resource.l_copy_w = GETMESSAGE(2, 148, "Copy..."); + + resource.l_xlfd = GETMESSAGE(2, 150, "XLFD name..."); /* information menu */ + resource.l_codearea = GETMESSAGE(2, 152, "Code Area..."); + + resource.l_add = GETMESSAGE(2, 154, "Add"); /* add/delete dialog */ + resource.l_delete = GETMESSAGE(2, 156, "Delete"); + resource.l_cancel = GETMESSAGE(2, 158, "Cancel"); + + resource.l_manage_code = GETMESSAGE(2, 160, "Code(hex):"); /* copy dialog */ + resource.l_copy_src_code = GETMESSAGE(2, 162, " Copy origin code(hex):"); + resource.l_copy_dest_code = GETMESSAGE(2, 164, "Copy target code(hex):"); + resource.l_copy = GETMESSAGE(2, 166, "Copy"); + resource.l_overlay = GETMESSAGE(2, 168, "Overlay"); + resource.l_ok = GETMESSAGE(2, 170, "OK"); + + resource.l_do_save = GETMESSAGE(2, 172, "Save"); /* unsaved edits */ + resource.l_dont_save = GETMESSAGE(2, 174, "Do not Save"); + resource.l_do_save_exit = GETMESSAGE(2, 176, "Save and Exit"); + resource.l_dont_save_exit = GETMESSAGE(2, 178, "Do not Save and Exit"); + + resource.mg_start_del_s = GETMESSAGE(2, 180, "The following character will be deleted."); /* delete notice dialog */ + resource.mg_start_del_cs = GETMESSAGE(2, 182, "character"); + resource.mg_start_del_m = GETMESSAGE(2, 184, "The following characters will be deleted."); + resource.mg_start_del_cm = GETMESSAGE(2, 186, "characters"); + resource.mg_register = GETMESSAGE(2, 188, "Register completed"); + resource.l_code = GETMESSAGE(2, 190, " Code : "); + resource.l_code_range = GETMESSAGE(2, 192, " Code range : "); + + resource.message = GETMESSAGE(2, 194, "Message : "); + + resource.code = GETMESSAGE(2, 196, "code..."); /* code dialog */ + resource.previous = GETMESSAGE(2, 198, "Page up"); + resource.next = GETMESSAGE(2, 200, "Page down"); + resource.apply = GETMESSAGE(2, 202, "Apply"); + + resource.l_question_title = GETMESSAGE(2, 204, "dtudcfonted - Question"); + resource.l_warning_title = GETMESSAGE(2, 206, "dtudcfonted - Warning"); + resource.l_error_title = GETMESSAGE(2, 208, "dtudcfonted - Error"); + resource.l_copy_title = GETMESSAGE(2, 210, "dtudcfonted - Copy"); + resource.l_open_title = GETMESSAGE(2, 212, "dtudcfonted - Open"); + resource.l_add_title = GETMESSAGE(2, 214, "dtudcfonted - Add/Delete"); + resource.l_xlfd_title = GETMESSAGE(2, 216, "dtudcfonted - XLFD"); + resource.l_codearea_title = GETMESSAGE(2, 218, "dtudcfonted - CodeArea"); + + resource.file_name = GETMESSAGE(2, 230, "File name"); + resource.xlfd_name = GETMESSAGE(2, 232, "XLFD name"); + resource.codearea = GETMESSAGE(2, 234, "Code area"); + + resource.falerrmsg[0] = GETMESSAGE(2, 300, "Fatal error occurred."); + resource.falerrmsg[1] = GETMESSAGE(2, 301, "Cannot open the font file."); + resource.falerrmsg[2] = GETMESSAGE(2, 302, "Cannot read the font file."); + resource.falerrmsg[3] = GETMESSAGE(2, 303, "There is no more memory."); + resource.falerrmsg[4] = GETMESSAGE(2, 304, "Fatal error occurred."); + resource.falerrmsg[5] = GETMESSAGE(2, 305, "The specified font file does not exist."); + resource.falerrmsg[6] = GETMESSAGE(2, 306, "This font is not a pcf or snf font."); + resource.falerrmsg[7] = GETMESSAGE(2, 307, "Cannot open fonts.list file."); + resource.falerrmsg[8] = GETMESSAGE(2, 308, "The format of fonts.list file is illegal."); + resource.falerrmsg[9] = GETMESSAGE(2, 309, "The descriptions of the fonts.list file are incorrect."); + resource.falerrmsg[10] = GETMESSAGE(2, 310, "The format of fonts.list file is illegal."); + resource.falerrmsg[11] = GETMESSAGE(2, 311, "Cannot open fonts.dir file."); + resource.falerrmsg[12] = GETMESSAGE(2, 312, "Cannot read fonts.dir file."); + resource.falerrmsg[13] = GETMESSAGE(2, 313, "Cannot read font properties."); + resource.falerrmsg[14] = GETMESSAGE(2, 314, "Cannot get FONT property."); + resource.falerrmsg[15] = GETMESSAGE(2, 315, "Cannot get FAMILY_NAME property."); + resource.falerrmsg[16] = GETMESSAGE(2, 316, "This font file is already opened by other application."); + resource.falerrmsg[17] = GETMESSAGE(2, 317, "Cannot lock font file."); + resource.falerrmsg[18] = GETMESSAGE(2, 318, "Cannot unlock font file."); + resource.falerrmsg[19] = GETMESSAGE(2, 319, "Cannot get lock information from the font file."); + resource.falerrmsg[20] = GETMESSAGE(2, 320, "Cannot find the specified font file."); + resource.falerrmsg[21] = GETMESSAGE(2, 321, "Cannot read NLS database."); + resource.falerrmsg[22] = GETMESSAGE(2, 322, "Cannot get charset names from NLS database."); + resource.falerrmsg[23] = GETMESSAGE(2, 323, "Charset name not defined in NLS database."); + resource.falerrmsg[24] = GETMESSAGE(2, 324, "The specified font has not been opened."); + resource.falerrmsg[25] = GETMESSAGE(2, 325, "Fatal error occurred."); + + xlfdDialog = NULL ; + cpyDialog = NULL ; + + /* initialize the global values and allocate the memories */ + xeg_init(); + + + /* displays the selection window */ + PopupSelectXLFD(toplevel); + + XSetErrorHandler((XErrorHandler)xerror); + XSetIOErrorHandler((XIOErrorHandler)xerror); + + /* main loop */ + XtAppMainLoop(app); + + return(-1); +} + + +/* + * contents : initialize the global values + */ + +static void +xeg_init(void) +{ + int i; + + edg.code = edg.ncode = 0; + bitPtnClear( edg.ptn ); + edg.flag = (char)0; + + edlist.nlist = EDLIST_MAX; + edlist.statloc = edlist.slctloc = 0; + edlist.nptn = 0; + edlist.sqstart = 0; + edlist.list_h = edlist.elem_w = edlist.elem_h = (Dimension)0; + edlist.back = resource.pane_background; + edlist.border = resource.pane_foreground; + + if ( edpane_size ){ + edpane.width = edpane_size; + edpane.height = edpane_size; + } else { + edpane.width = EDPANE_SIZE; + edpane.height = EDPANE_SIZE; + } + edpane.pix_w = edpane.pix_h = 0; + edpane.color = 0; + edpane.obj = 0; + edpane.back = resource.pane_background; + edpane.border = resource.pane_foreground; + + xl.display = NULL; + xl.root_winID = xl.edit_winID = xl.disp_winID = xl.list_winID = + (Window)NULL; + xl.borderGC = xl.backGC = xl.rubGC = xl.dashGC = (GC)NULL; + xl.dispImage = NULL; + + dn.elem_w = dn.elem_h = (Dimension)0; + dn.ptn_w = dn.ptn_h = (Dimension)0; + dn.list_h = (Dimension)0; + dn.s_ncode = dn.e_ncode = 0; + dn.sq_top = dn.sq_start = dn.sq_end = 0; + dn.disp_num = 0; + + for ( i=0 ; i<D_MAX ; i++ ) { + dl[i].disp_winID = (Window)NULL; + dl[i].dispImage = NULL; + bitPtnClear( dl[i].ptn ); + } + for ( i=0 ; i<EDLIST_MAX ; i++ ) { + dl_glyph[i].disp_winID = (Window)NULL; + dl_glyph[i].dispImage = NULL; + bitPtnClear( dl_glyph[i].ptn ); + sq_disp[i] = 0 ; + } + em.drag_f = OFF; + em.adj_px = em.adj_py = 0; + em.proc = em.slct_f = 0; + em.src1_px = em.src1_py = 0; + em.src2_px = em.src2_py = 0; + em.dest_px = em.dest_py = 0; + em.rsv_f = (char)0; + bitPtnClear( em.rsv_ptn ); + + cpm.s1_code = cpm.s2_code = cpm.d1_code = 0; + cpm.proc = 0; + + return; +} + + + +/**************************************************************** + * distroy the "User defined character editor" window * + ****************************************************************/ + +/* + * contents : destroy the editting window + */ + +static void +dstrypaneEditPtn(void) +{ + int i ; + + ptnClose(); + + XFree( (char *)xl.dispImage ); + XFreeGC( xl.display, xl.borderGC ); + XFreeGC( xl.display, xl.backGC ); + XFreeGC( xl.display, xl.rubGC ); + XFreeGC( xl.display, xl.dashGC ); + + for( i=0; i<EDLIST_MAX; i++ ){ + if( dl_glyph[i].dispImage ){ + XFree( (char *)dl_glyph[i].dispImage ); + dl_glyph[i].dispImage = NULL ; + } + } + + XtPopdown( editPopW ); + XtDestroyWidget( editPopW ); + + return; +} + + +/**************************************************************** + * update character list * + ***************************************************************/ + +/* + * contents : add the specified code to the character list + */ + +void +chgEdCode( int code, char mode ) +{ + int ncode; + int esq; + int statloc; + int slctloc; + int slimax; + + if( code == 0 ) { + esq = -1; + } else { + ncode = codeToNo( code ); + esq = ptnNoToSq( ncode ) - edlist.sqstart; + } + if( esq < 0 ) { + slctloc = -1; + statloc = 0; + } else if (efctPtnNum() <= edlist.nlist) { + statloc = 0; + slctloc = AbsSqToRel(edlist.sqstart, ptnNoToSq( ncode)); + } else { + if ((esq >= edlist.statloc) + && (esq <= (RelToAbsSq( edlist.sqstart + edlist.statloc, + edlist.nlist - 1) - edlist.sqstart))){ + statloc = edlist.statloc; + slctloc = AbsSqToRel(edlist.sqstart+statloc, + edlist.sqstart + esq); + } else { + statloc = esq; + slctloc = 0; + } + while( RelToAbsSq(edlist.sqstart+statloc, edlist.nlist - 1) < 0) + statloc = RelToAbsSq( edlist.sqstart + statloc, -1) + - edlist.sqstart; + slctloc = AbsSqToRel( edlist.sqstart + statloc, edlist.sqstart + esq); + } + + n = 0; + if (( slimax = efctPtnNum()) < edlist.nlist) + slimax = edlist.nlist; + XtSetArg( arg[n], XmNmaximum, (XtArgVal)slimax ); n++; + XtSetArg( arg[n], XmNvalue, (XtArgVal)AbsSqToRel( edlist.sqstart, edlist.sqstart + statloc) ); n++; + XtSetValues( wgeScro , arg, n ); + + chgEdList( statloc, slctloc, mode ); + chgEdPtn( code ); +} + + +/* + * contents : rewrite the character list + */ + +void +chgEdList( int statloc, int slctloc, char mode ) +{ + int sq; + int i; + char str[6]; + int no; + int code; + extern void ListSetLabelStr(); + extern void ListSetGlyphImage(); + extern void ListUnselectItem(); + extern void ListSelectItem(); + + if((mode == ON) || (edlist.statloc != statloc)){ + for (i=0, sq=edlist.sqstart+statloc; i < edlist.nlist; sq++){ + no = ptnSqToNo(sq); + sq_disp[i] = sq ; + + if ((no >= 0) && (code = noToCode(no)) >= 0 ){ + sprintf(str, "%4x", code); + ListSetLabelStr(i, str); + ListSetGlyphImage(i) ; + if (i == 0) + edlist.statloc = sq - edlist.sqstart; + i++; + } else if (sq > ( edlist.sqstart + edlist.nptn - 1)){ + strcpy(str, " "); + ListSetLabelStr(i, str); + ListSetGlyphImage(i) ; + i++; + } + } + } + + if( (mode == ON) || (edlist.slctloc != slctloc) ) { + if((0 <= edlist.slctloc) && (edlist.slctloc < edlist.nlist)){ + ListUnselectItem(edlist.slctloc); + } + if((0 <= slctloc) && (slctloc < edlist.nlist)){ + ListSelectItem(slctloc); + } + edlist.slctloc = slctloc; + } +} + + +/* + * contents : rewrite the editting pane + */ + +static void +chgEdPtn( int code ) +{ + extern void SetCodeString(); + + if (xl.display == NULL ){ + return; + } + + if( code == 0 ) { + XClearWindow( xl.display, xl.edit_winID ); + DrawBorderEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + XClearWindow( xl.display, xl.disp_winID ); + XClearWindow( xl.display, xl.list_winID ); + bitPtnClear( edg.ptn ); + edg.code = 0; + edg.ncode = 0; + SetCodeString(0); + } + + if( ptnGet( code, edg.ptn) == 0 ) { + edg.code = code; + edg.ncode = codeToNo( code ); + DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + + SetCodeString(code); + DrawDpPn(); + } +} + + + + + +/**************************************************************** + * draw patterns to the editting pane * + ***************************************************************/ + +/* + * contents : draw a rectangle + * + */ + +static void +DrawRectEdPn( int x1, int y1, int x2, int y2 ) +{ + int i, j, wk; + short cx1, cy1, cx2, cy2; + XRectangle recOn[MAXPTNSIZE*MAXPTNSIZE]; + XRectangle recOff[MAXPTNSIZE*MAXPTNSIZE]; + int nron, nroff; + + if (xl.display == NULL ){ + return; + } + + if( x2 < x1 ) { + wk = x2; + x2 = x1; + x1 = wk; + } + if( y2 < y1 ) { + wk = y2; + y2 = y1; + y1 = wk; + } + + nron = nroff = 0; + for( j=y1 ; j <= y2 ; j++ ) { + for( i=x1 ; i <= x2 ; i++ ) { + cx1 = (short)(edpane.pix_w * i); + cy1 = (short)(edpane.pix_h * j); + cx2 = (short)(cx1 + edpane.pix_w - 1); + cy2 = (short)(cy1 + edpane.pix_h - 1); + + if( bitRead( edg.ptn, i, j ) != 0 ) { + recOn[nron].x = cx1; + recOn[nron].y = cy1; + recOn[nron].width = (unsigned short)(cx2 - cx1); + recOn[nron].height = (unsigned short)(cy2 - cy1); + nron++; + } + else { + recOff[nroff].x = cx1; + recOff[nroff].y = cy1; + recOff[nroff].width = (unsigned short)(cx2 - cx1); + recOff[nroff].height = (unsigned short)(cy2 - cy1); + nroff++; + } + } + } + if( nron ) + XFillRectangles( xl.display, xl.edit_winID, xl.borderGC, recOn, nron ); + if( nroff ) + XFillRectangles( xl.display, xl.edit_winID, xl.backGC, recOff, nroff ); +} + + +/* + * contents : draw a lattice inside of the editting pane + */ + +static void +DrawBorderEdPn( int x1, int y1, int x2, int y2 ) +{ + short cx1, cy1; + short cx2, cy2; + int ndseg; + int wk, i; + XSegment dseg[MAXPTNSIZE*2]; + + if (xl.display == NULL ){ + return; + } + + if( x2 < x1 ) { + wk = x2; + x2 = x1; + x1 = wk; + } + if( y2 < y1 ) { + wk = y2; + y2 = y1; + y1 = wk; + } + + ndseg = 0; + + cx1 = (short)(edpane.pix_w * x1); + cx2 = (short)(edpane.pix_w * x2 + edpane.pix_w - 1); + for( i=y1 ; i <= y2 ; i++ ) { + cy1 = (short)(edpane.pix_h * i + edpane.pix_h - 1); + dseg[ndseg].x1 = cx1; + dseg[ndseg].y1 = cy1; + dseg[ndseg].x2 = cx2; + dseg[ndseg].y2 = cy1; + ndseg++; + } + cy1 = (short)(edpane.pix_h * y1); + cy2 = (short)(edpane.pix_h * y2 + edpane.pix_h - 1); + for( i=x1 ; i <= x2 ; i++ ) { + cx1 = (short)(edpane.pix_w * i + edpane.pix_w - 1); + dseg[ndseg].x1 = cx1; + dseg[ndseg].y1 = cy1; + dseg[ndseg].x2 = cx1; + dseg[ndseg].y2 = cy2; + ndseg++; + } + + if( ndseg ) { + XDrawSegments( xl.display, xl.edit_winID, xl.dashGC, dseg, ndseg); + } +} + + +/* + * contents : draw a dot + */ + +static void +DrawPointEdPn( int x, int y, int mode ) +{ + int x1, y1; + int x2, y2; + + if (xl.display == NULL ){ + return; + } + + x1 = edpane.pix_w * x; + y1 = edpane.pix_h * y; + x2 = x1 + edpane.pix_w - 1; + y2 = y1 + edpane.pix_h - 1; + + if( mode != 0 ) { + XFillRectangle( xl.display, xl.edit_winID, xl.borderGC, + x1, y1, x2-x1, y2-y1 ); + } else { + XFillRectangle( xl.display, xl.edit_winID, xl.backGC, + x1, y1, x2-x1, y2-y1 ); + } +} + + + +/* + * contents : draw a current character pattern to the display pane + */ + +static void +DrawDpPn(void) +{ + if (xl.display == NULL ){ + return; + } + + XPutImage( xl.display, xl.disp_winID, xl.borderGC, xl.dispImage, + 0, 0, 0, 0, edg.width, edg.height ); + if( xl.list_winID ) { + XPutImage( xl.display, xl.list_winID, xl.borderGC, + xl.dispImage, 0, 0, 0, 0, edg.width, edg.height ); + } +} + + + +/* + * contents : draw a dot + */ + +static void +DrawPointDpPn( int x, int y, int mode ) +{ + + if (xl.display == NULL ){ + return; + } + if( mode != 0 ){ + XDrawPoint( xl.display, xl.disp_winID, xl.borderGC, x, y ); + if (xl.list_winID) + XDrawPoint( xl.display, xl.list_winID, xl.borderGC, x, y ); + } else { + XDrawPoint( xl.display, xl.disp_winID, xl.backGC, x, y ); + if (xl.list_winID) + XDrawPoint( xl.display, xl.list_winID, xl.backGC, x, y ); + } +} + + + +/**************************************************************** + * draw patterns by mouse * + ****************************************************************/ + + +/* + * contents : draw a dot + */ + +static void +musPoint( int evtype, int px, int py ) +{ + switch( evtype ) { + case MotionNotify: + if( (em.src1_px == px) && (em.src1_py == py) ) + return; + break; + case ButtonPress: + em.src1_px = px; + em.src1_py = py; + break; + default: + return; + } + + if( edpane.color == ON ) + bitSet( edg.ptn, px, py ); + else + bitReset( edg.ptn, px, py ); + edg.flag = ON; + DrawPointEdPn( px, py, edpane.color ); + DrawPointDpPn( px, py, edpane.color ); +} + + +/* + * contents : draw a line + */ + +static void +musLine( int evtype, int px, int py ) +{ + int r1_x, r1_y; + int r2_x, r2_y; + int rx, ry; + int harf_pix_w; + int harf_pix_h; + + harf_pix_w = edpane.pix_w / 2; + harf_pix_h = edpane.pix_h / 2; + r1_x = em.src1_px * edpane.pix_w + harf_pix_w; + r1_y = em.src1_py * edpane.pix_h + harf_pix_h; + r2_x = em.src2_px * edpane.pix_w + harf_pix_w; + r2_y = em.src2_py * edpane.pix_h + harf_pix_h; + rx = px * edpane.pix_w + harf_pix_w; + ry = py * edpane.pix_h + harf_pix_h; + + switch( evtype ) { + case MotionNotify: + if( (em.src2_px == px) && (em.src2_py == py) ) + return; + rubLine( r1_x, r1_y, r2_x, r2_y ); + rubLine( r1_x, r1_y, rx, ry ); + em.src2_px = px; + em.src2_py = py; + return; + case ButtonPress: + em.src1_px = em.src2_px = px; + em.src1_py = em.src2_py = py; + return; + default: + if( (r1_x == r2_x) && (r1_y == r2_y) ) + return; + rubLine( r1_x, r1_y, r2_x, r2_y ); + + if ((em.src2_px < 0) || (em.src2_py < 0) || + (edg.width <= em.src2_px) || (edg.height <= em.src2_py)) + return; + + bitDrawLine( edg.ptn, em.src1_px, em.src1_py, + em.src2_px, em.src2_py, edpane.color ); + edg.flag = ON; + DrawRectEdPn( em.src1_px, em.src1_py, em.src2_px, em.src2_py ); + DrawDpPn(); + } +} + + + +/* + * contents : draw a circle + */ + +static void +musCircle( int evtype, int px, int py ) +{ + int r1_x, r1_y; + int r2_x, r2_y; + int rx, ry; + int harf_pix_w; + int harf_pix_h; + extern int bitDrawCircle(); + + harf_pix_w = edpane.pix_w / 2; + harf_pix_h = edpane.pix_h / 2; + + r1_x = em.src1_px * edpane.pix_w + harf_pix_w; + r1_y = em.src1_py * edpane.pix_h + harf_pix_h; + r2_x = em.src2_px * edpane.pix_w + harf_pix_w; + r2_y = em.src2_py * edpane.pix_h + harf_pix_h; + rx = px * edpane.pix_w + harf_pix_w; + ry = py * edpane.pix_h + harf_pix_h; + + switch( evtype ) { + case MotionNotify: + if( (em.src2_px == px) && (em.src2_py == py) ) { + return; + } + rubCircle( r1_x, r1_y, r2_x, r2_y ); + rubCircle( r1_x, r1_y, rx, ry ); + em.src2_px = px; + em.src2_py = py; + return; + case ButtonPress: + em.src1_px = em.src2_px = px; + em.src1_py = em.src2_py = py; + return; + default: + if( (em.src1_px == px) && (em.src1_py == py) ) { + return; + } + rubCircle( r1_x, r1_y, r2_x, r2_y ); + + if( (px < 0) || (py < 0) || (edg.width <= px) || (edg.height <= py) ) { + return; + } + bitDrawCircle( edg.ptn, em.src1_px, em.src1_py, px, py, edpane.color); + + edg.flag = ON; + DrawRectEdPn( 0, 0, edg.width -1, edg.height -1 ); + DrawDpPn(); + } +} + + +/* + * contents : draw a rectangle + */ + +static void +musRect( int proc, int evtype, int px, int py ) +{ + int r1_x, r1_y; + int r2_x, r2_y; + int rx, ry; + int lux, luy; + int width, height; + int dpx, dpy, dp; + + if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) { + dpx = px - em.src1_px; + dpy = py - em.src1_py; + dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy); + + if( dpx != 0 ) + px = em.src1_px + dpx/abs(dpx) * dp; + if( dpy != 0 ) + py = em.src1_py + dpy/abs(dpy) * dp; + } + + r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2; + r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2; + r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2; + r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2; + rx = px * edpane.pix_w + edpane.pix_w / 2; + ry = py * edpane.pix_h + edpane.pix_h / 2; + + switch( evtype ) { + case MotionNotify: + if( (em.src2_px == px) && (em.src2_py == py) ) + return; + rubBand( r1_x, r1_y, r2_x, r2_y ); + rubBand( r1_x, r1_y, rx, ry ); + em.src2_px = px; + em.src2_py = py; + return; + case ButtonPress: + resetEditMode( RES_SLCT ); + em.src1_px = em.src2_px = px; + em.src1_py = em.src2_py = py; + return; + default: + resetEditMode( RES_MSG | RES_PROC ); + rubBand( r1_x, r1_y, r2_x, r2_y ); + if( (r1_x == r2_x) || (r1_y == r2_y) ) + return; + if( (em.src2_px < 0) || (em.src2_py < 0) || + (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) + return; + + lux = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px; + luy = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py; + width = abs( em.src1_px - em.src2_px ) + 1; + height = abs( em.src1_py - em.src2_py ) + 1; + + bitDrawRect(edg.ptn, lux, luy, width, height, edpane.color); + + edg.flag = ON; + DrawRectEdPn( em.src1_px, em.src1_py, px, py ); + DrawDpPn(); + } +} + + +/* + * contents : edit inside of the specified area (clear, reverse, rotate,etc.) + */ + +static void +musRegionProc( int proc, int evtype, int px, int py ) +{ + int rx, ry; + int dpx, dpy, dp; + extern void SelectSet(); + + if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) { + dpx = px - em.src1_px; + dpy = py - em.src1_py; + dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy); + + if( dpx != 0 ) + px = em.src1_px + dpx/abs(dpx) * dp; + if( dpy != 0 ) + py = em.src1_py + dpy/abs(dpy) * dp; + } + + r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2; + r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2; + r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2; + r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2; + rx = px * edpane.pix_w + edpane.pix_w / 2; + ry = py * edpane.pix_h + edpane.pix_h / 2; + + switch( evtype ) { + case MotionNotify: + if( (em.src2_px == px) && (em.src2_py == py) ) + return; + rubBand( r1_x, r1_y, r2_x, r2_y ); + rubBand( r1_x, r1_y, rx, ry ); + em.src2_px = px; + em.src2_py = py; + return; + case ButtonPress: + if (select_x || select_y || select_w || select_h) { + rubBand( r1_x, r1_y, r2_x, r2_y ); + } + resetEditMode( RES_SLCT ); + em.src1_px = em.src2_px = px; + em.src1_py = em.src2_py = py; + return; + default: + resetEditMode( RES_MSG | RES_PROC ); + select_x = select_y = select_w = select_h = 0; + if( (r1_x == r2_x) || (r1_y == r2_y) ) { + rubBand( r1_x, r1_y, r2_x, r2_y ); + return; + } + if( (em.src2_px < 0) || (em.src2_py < 0) || + (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) { + rubBand( r1_x, r1_y, r2_x, r2_y ); + return; + } + + select_x = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px; + select_y = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py; + select_w = abs( em.src1_px - em.src2_px ) + 1; + select_h = abs( em.src1_py - em.src2_py ) + 1; + SelectSet(); + } +} + + +/*ARGSUSED*/ +static void +musPasteProc(Widget w, XtPointer client_data, XEvent *event) +{ + static int ox=0, oy=0; + int rc, tx, ty; + extern void UndoSet(); + extern Widget wgeBulB_edit; + extern int bitDrawPaste(); + + switch(event->type) { + case MotionNotify: + tx = (event->xmotion.x / edpane.pix_w) * edpane.pix_w + edpane.pix_w / 2; + ty = (event->xmotion.y / edpane.pix_h) * edpane.pix_h + edpane.pix_h / 2; + if (tx == ox && ty == oy) + return; + if(ox) { + rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h); + } + ox = tx; + oy = ty; + rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h); + break; + case ButtonRelease: + XtRemoveEventHandler(wgeBulB_edit, + ButtonReleaseMask|PointerMotionMask, + False, (XtEventHandler)musPasteProc, NULL ); + rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h); + ox = 0; + oy = 0; + bitPtnCopy( em.rsv_ptn, edg.ptn ); + + tx = event->xbutton.x / edpane.pix_w; + ty = event->xbutton.y / edpane.pix_h; + rc = bitDrawPaste(edg.ptn, tx, ty); + if( rc == -1 ) + return; + edg.flag = ON; + em.rsv_f = ON; + DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 ); + DrawDpPn(); + UndoSet(); + break; + } +} + + + +static void +rubLine( int x1, int y1, int x2, int y2 ) +{ + if( x1==x2 && y1==y2 ) return; + + XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1,y1, x2,y2 ); +} + + + +static void +rubBand( int x1, int y1, int x2, int y2 ) +{ + if( x1==x2 && y1==y2 ) + return; + + XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x2, y1 ); + XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x1, y2 ); + XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x2, y1, x2, y2 ); + XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y2, x2, y2 ); +} + + + +static void +rubCircle( int ox, int oy, int rx, int ry ) +{ + unsigned int r; + int x, y; + + if( ox==rx && oy==ry ) return; + + x = rx - ox; + y = ry - oy; + r = (unsigned int)sqrt( (double)(x*x + y*y) ); + if ( r == 0 ) return; + + x = ox - (int)r; + y = oy - (int)r; + XDrawArc( xl.display, xl.edit_winID, xl.rubGC, + x, y, 2*r-1, 2*r-1, + 0, 360*64 + ); +} + + + +static void +resetEditMode( unsigned int flag ) +{ + int r1_x, r1_y; + int r2_x, r2_y; + + if( flag & RES_MSG ) + UpdateMessage( "" ); + + if( flag & RES_PROC ) + em.proc = edpane.obj; + + if( (flag & RES_SLCT) && (em.slct_f) ) { + r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2; + r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2; + r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2; + r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2; + rubBand( r1_x, r1_y, r2_x, r2_y ); + em.slct_f = OFF; + } + + if( flag & RES_RSV ) + em.rsv_f = OFF; +} + + +/**************************************************************** + * copy character pattern * + ***************************************************************/ + +/* + * contents : copy or overlay the new character pattern to the current pattern + */ + +/*ARGSUSED*/ +static void +copyPatterns( + FalFontData *fdata, + int s1_code, + int s2_code, + int d1_code, + int proc) +{ + int ret; + int d1_ncode, d2_ncode; + int code_d; + int code_disp; + char err[128]; + int i_s, i_d; + int i; + char grc_d; + char **ptn; + char ptn2[MAXPTNBYTE]; + int num; + extern int last_code; + + ret = copySNF(s1_code, s2_code, &ptn, &num, err); + if( ret == -1 ) { + Error_message2((Widget)NULL, err); + return; + } + + if (last_code < (d1_code + num)) + last_code = d1_code + num; + + if( ptnSense(edg.code) == 1 ) + ptnAdd( edg.code, edg.ptn ); + + d1_ncode = codeToNo( d1_code ); + + for (i_d=d1_ncode, i_s=0; i_s < num; i_d++) { + if ( codeCheck( noToCode( i_d))) + continue; + bitPtnClear( ptn2 ); + code_d = noToCode( i_d ); + grc_d = ptnGet( code_d, ptn2 ); + + if (grc_d == 0) { + if( proc == CPY_OVERLAY ) { + for( i=0 ; i < edg.height*((edg.width+7)/8) ; i++ ) { + ptn[i_s][i] |= ptn2[i]; + } + } + ptnAdd( code_d, ptn[i_s] ); + edg.flag = ON; + } else { + if( ptnAdd( code_d, ptn[i_s] ) != 1 ) { + UpdateMessage( resource.me_non_memory ); + break; + } + edlist.nptn++; + edg.flag = ON; + } + i_s ++; + } + d2_ncode = i_d - 1; + + code_disp = 0; + for( i=d1_ncode ; i <= d2_ncode; i++ ) { + if ( codeCheck( noToCode(i) ) ) + continue; + if( ptnSense( noToCode( i ) ) == 1 ) { + code_disp = noToCode( i ); + break; + } + } + freeSNF(ptn, num); + + if( (code_disp == 0) && (efctPtnNum() > 0)) + code_disp = noToCode( ptnSqToNo(edlist.sqstart) ); + + chgEdCode( code_disp, ON ); + + resetEditMode( (unsigned int) (RES_MSG | RES_PROC | RES_SLCT | RES_RSV) ); +} diff --git a/cde/programs/dtudcfonted/ufontrsrc.h b/cde/programs/dtudcfonted/ufontrsrc.h new file mode 100644 index 000000000..cd9b56333 --- /dev/null +++ b/cde/programs/dtudcfonted/ufontrsrc.h @@ -0,0 +1,223 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* ufontrsrc.h 1.18 - Fujitsu source for CDEnext 96/10/30 13:13:44 */ +/* $XConsortium: ufontrsrc.h /main/9 1996/11/08 01:52:14 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + +typedef struct _Resource { + char *mg_write_snf; + char *me_write_snf; + char *me_illegal_code; + char *me_non_memory; + char *mg_non_code; + char *me_illegal_srccode; + char *me_illegal_destcode; + char *me_nodelete_code; + char *me_wait; + char *me_non_srcfile; + + char *mn_no_font; + char *mn_plural_font; + char *mn_not_udc; + char *mn_no_mem; + char *mn_illegal_area; + char *mn_no_read; + char *mn_prop_font; + char *mn_saved_open; + char *mn_saved_exit; + char *mn_cpy_lost; + char *mn_no_perm; + + Boolean codepoint; + + char *l_font; + char *l_edit; + char *l_manage; + char *l_info; + char *l_open; + char *l_selectitem; + char *l_codeset; + char *l_style; + char *l_width; + char *l_height; + char *l_cancel; + char *l_copy; + char *l_overlay; + char *l_add; + char *l_delete; + char *l_open_w; + char *l_save; + char *l_exit; + char *l_manage_w; + char *l_xlfd; + char *l_codearea; + char *l_copy_w; + char *l_clear; + char *l_set; + char *l_reverse; + char *l_cut; + char *l_Copy; + char *l_paste; + char *l_roll; + char *l_updown_roll; + char *l_leftright_roll; + char *l_undo; + + char *l_manage_code; + char *l_copy_src_code; + char *l_copy_dest_code; + + char *l_ok; + + char *l_question_title; + char *l_warning_title; + char *l_error_title; + char *l_copy_title; + char *l_open_title; + char *l_add_title; + char *l_xlfd_title; + char *l_codearea_title; + + char *file_name; + char *xlfd_name; + char *codearea; + + char *l_do_save; + char *l_dont_save; + char *l_do_save_exit; + char *l_dont_save_exit; + + char *l_ptog; + char *l_ptog_cmd; + + char *mg_start_del_s; + char *mg_start_del_cs; + char *mg_start_del_m; + char *mg_start_del_cm; + + char *mg_register; + + char *l_code; + char *l_code_range; + + +/* CreateCaptionFrame() */ + Boolean capt_resize ; /* resizable: */ + int capt_lftoff ; /* leftOffset: */ + int capt_topoff ; /* topOffset: */ + int capt_rghoff ; /* RightOffset: */ + + Pixel pane_background; + Pixel pane_foreground; + Pixel background; + Pixel foreground; + +/* CreateMenuButtons() */ + Dimension menu_margin ; /* margin: */ + +/* CreateDialogAndButtons() */ + Boolean dia_tm_automng ; /* autoUnmanage: */ + Dimension dia_tm_width ; /* marginWidth: */ + Dimension dia_tm_height ; /* marginHeight: */ + Boolean dia_tm_resize ; /* noResize: */ + Boolean dia_tm_minimize ; /* minimizeButtons: */ + + Dimension dia_rw_width ; /* marginWidth: */ + Dimension dia_rw_height ; /* marginHeight: */ + Dimension dia_rw_spacing ; /* spacing: */ + +/* CreateDrawingArea() */ + Dimension draw_border ; /* borderWidth: */ + int draw_topoff ; /* topOffset: */ + int draw_lftoff ; /* leftOffset: */ + +/* PopupNotice() */ + Boolean pop_resize ; /* noResize: */ + Boolean pop_minimize ; /* minimizeButtons: */ + +/* CreateTemplateDialog() */ + Boolean temp_resize ; /* noResize: */ + Boolean temp_minimize ; /* minimizeButtons: */ + + Dimension temp_width ; /* width: */ + Dimension temp_height ; /* height: */ + +/* CreateMenuBarAndFooterMessageForm() */ + + int ed_bar_topoff ; /* topOffset: */ + int ed_bar_lftoff ; /* leftOffset: */ + int ed_bar_rghoff ; /* rightOffset: */ + + int ed_frm_btmoff ; /* bottomOffset: */ + int ed_frm_lftoff ; /* leftOffset: */ + int ed_frm_rghoff ; /* rightOffset: */ + + Dimension ed_msg_margintop ; /* marginTop: */ + Dimension ed_msg_marginbtm ; /* marginBottom: */ + + Dimension ed_mesg_margintop ; /* marginTop: */ + Dimension ed_mesg_marginbtm ; /* marginBottom: */ + + int ed_sep_btmoff ; /* bottomOffset: */ + int ed_sep_lftoff ; /* leftOffset: */ + int ed_sep_rghoff ; /* rightOffset: */ + Dimension ed_sep_margin ; /* margin: */ + + int ed_wge_topoff ; /* topOffset: */ + int ed_wge_lftoff ; /* leftOffset: */ + int ed_wge_rghoff ; /* rightOffset: */ + int ed_wge_btmoff ; /* bottomOffset: */ + +/* CreateFrame() */ + Boolean frame_resize ; /* resizable: */ + +/* CreateScrollBase() */ + Dimension scll_fr_width ; /* width: */ + + Dimension scll_fr_thick ; /* shadowThickness: */ + + int scll_bar_lftoff ; /* leftOffset: */ + + /* put data from resource database */ + char * exec_label ; + char * quit_label ; + + char * message ; + + char * code ; + char * previous ; + char * next ; + char * apply ; + + char * falerrmsg[26]; +} Resource; + + +/**********/ diff --git a/cde/programs/dtudcfonted/util.c b/cde/programs/dtudcfonted/util.c new file mode 100644 index 000000000..d9d4eac70 --- /dev/null +++ b/cde/programs/dtudcfonted/util.c @@ -0,0 +1,1092 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* util.c 1.22 - Fujitsu source for CDEnext 96/10/30 13:31:41 */ +/* $XConsortium: util.c /main/13 1996/11/08 01:56:34 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + + +#include <stdlib.h> +#include <wchar.h> +#include <Xm/XmAll.h> +#include <Xm/RowColumn.h> +#include <Xm/MainW.h> + +#include "util.h" +#include "ufontrsrc.h" +#include "FaLib.h" + +extern Widget toplevel; +static void _destroy(Widget w); +void _unmap(void); + +extern Resource resource ; + +#include "xpm.h" +#include "pixmaps/Pencil.pm" +#include "pixmaps/Line.pm" +#include "pixmaps/Rectangle.pm" +#include "pixmaps/Circle.pm" +#include "pixmaps/Eraser.pm" +#include "pixmaps/SelectArea.pm" + +#ifdef XPM +#define ReadXpm XpmCreatePixmapFromData +#else +#define ReadXpm _DtXpmCreatePixmapFromData +#endif +#define NUMPIX 6 + +#include "pixmaps/arrow.pm" + +/*ARGSUSED*/ +Widget +CreateCaptionFrame( +Widget owner, +String name, +String labelstr, +int type, +int thickness) +{ + Widget top, label, frame; + Arg args[20]; + int n = 0; + XmString xmstr; + + top = XmCreateForm(owner, "form", args, n); + if (labelstr && *labelstr){ + xmstr = XmStringCreateLocalized(labelstr); + n = 0; + XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNlabelString, xmstr); n++; + label = XmCreateLabelGadget(top, "label", args, n); + XtManageChild(label); + XmStringFree(xmstr); + + n = 0; + XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; + XtSetArg(args[n], XmNtopWidget, label); n++; + } + else{ + n = 0; + XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; + } + XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; + XtSetArg(args[n], XmNresizable, resource.capt_resize ); n++; + XtSetArg(args[n], XmNshadowType, type); n++; + XtSetArg(args[n], XmNshadowThickness , thickness); n++; + XtSetArg(args[n], XmNleftOffset, resource.capt_lftoff ); n++; + XtSetArg(args[n], XmNtopOffset, resource.capt_topoff ); n++; + XtSetArg(args[n], XmNrightOffset, resource.capt_rghoff ); n++; + frame = XmCreateFrame(top, "frame", args, n); + XtManageChild(frame); + XtManageChild(top); + return(frame); +} + +/* + * + * create pix button + * + */ + +Widget +CreatePixButton( +Widget owner, +String name, +RadioButt *data) +{ + Arg args[20]; + int i, n = 0; + Pixmap mask; + XpmAttributes attr; + Pixmap pix[NUMPIX]; + Widget top; + Display *disp; + Window root = DefaultRootWindow(disp); + + disp = XtDisplay(owner); + + XtSetArg(args[n], XmNborderWidth, 1); n++; + XtSetArg(args[n], XmNradioAlwaysOne, TRUE); n++; + XtSetArg(args[n], XmNradioBehavior, TRUE); n++; + top = XmCreateRowColumn(owner, name, args, n); + + attr.valuemask = 0; + + ReadXpm(disp, root, Pencil, &pix[0], &mask, &attr); + ReadXpm(disp, root, Line, &pix[1], &mask, &attr); + ReadXpm(disp, root, Rectangle, &pix[2], &mask, &attr); + ReadXpm(disp, root, Circle, &pix[3], &mask, &attr); + ReadXpm(disp, root, Eraser, &pix[4], &mask, &attr); + ReadXpm(disp, root, SelectArea, &pix[5], &mask, &attr); + + for (i=0; i < NUMPIX; i++) { + n = 0; + XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; + XtSetArg(args[n], XmNlabelPixmap, pix[i]); n++; + XtSetArg(args[n], XmNindicatorOn, False); n++; + XtSetArg(args[n], XmNshadowThickness, 2); n++; + XtSetArg(args[n], XmNfillOnSelect, False); n++; + XtSetArg(args[n], XmNset, data->items[i].set); n++; + XtSetArg(args[n], XmNwidth, 36); n++; + XtSetArg(args[n], XmNheight, 36); n++; + data->items[i].w = XmCreateToggleButton(top, data->items[i].name, args, n); + XtManageChild(data->items[i].w); + XtAddCallback(data->items[i].w, XmNvalueChangedCallback, + data->items[i].cb, data->items[i].clientdata); + } + XtManageChild(top); + return(top); +} + + +/* + * + * returns the value what the text field has + * + */ + +#ifdef _HPUX_SOURCE +String +#else +XtPointer +#endif +GetTextFieldValue(TextField *textf) +{ + char *s1, *s2, *s3; + if (textf->w2 == NULL) { + XtVaGetValues(textf->w1, XmNvalue, &s1, NULL); + return(s1); + } else { + if (XtIsSensitive(textf->w2)) { + XtVaGetValues(textf->w1, XmNvalue, &s1, NULL); + XtVaGetValues(textf->w2, XmNvalue, &s2, NULL); + s3 = (char *) XtMalloc(strlen(s1) + strlen(s2) + 2); + strcpy(s3, s1); + strcat(s3, "-"); + strcat(s3, s2); + XtFree(s1); + XtFree(s2); + return(s3); + } else { + XtVaGetValues(textf->w1, XmNvalue, &s1, NULL); + return(s1); + } + } +} + +/*ARGSUSED*/ +static void +arrow_change(int w, TextField *data) +{ + if (XtIsSensitive(data->w2)) { + XtSetSensitive(data->w2, False); + } else { + XtSetSensitive(data->w2, True); + } +} + +static Widget focus_widget=NULL; +extern char AreaStr[160]; +extern FalFontData fullFontData; + +static void +focus(Widget w) +{ + focus_widget = w; +} + +static void +code_input(void) +{ + extern void CodeWindow(); + CodeWindow(focus_widget, fullFontData.xlfdname, False); +} + +/*ARGSUSED*/ +void +CreateTextField( +Widget owner, +String name, +String labelstr, +TextField *data, +int maxlength) +{ + Widget row, label, arrow, textfield, code; + Arg args[20]; + int n = 0; + Display *disp; + Window root; + Pixmap mask; + XpmAttributes attr; + XmString xms; + extern Pixmap arrow_pix; + + XtSetArg(args[n], XmNorientation, (XtArgVal)XmHORIZONTAL); n++; + row = XmCreateRowColumn(owner, "row", args, n); + XtManageChild(row); + + n = 0; + xms = XmStringCreateLocalized(labelstr); + XtSetArg(args[n], XmNlabelString, xms); n++; + label = XmCreateLabelGadget(row, "label", args, n); + XtManageChild(label); + XmStringFree(xms); + + n = 0; + XtSetArg(args[n], XmNcolumns, maxlength); n++; + XtSetArg(args[n], XmNmaxLength, maxlength); n++; + data->w1 = focus_widget = textfield = + XmCreateText(row, "textField", args, n); + XtManageChild(textfield); + XtAddCallback(textfield, XmNfocusCallback, (XtCallbackProc)focus, NULL); + + if (! arrow_pix) { + disp = XtDisplay(row); + root = DefaultRootWindow(disp); + attr.valuemask = 0; + ReadXpm(disp, root, arrow_pm, &arrow_pix, &mask, &attr); + } + + n = 0; + XtSetArg(args[n], XmNlabelPixmap, arrow_pix); n++; + XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++; + XtSetArg(args[n], XmNindicatorOn, False); n++; + XtSetArg(args[n], XmNshadowThickness, 2); n++; + XtSetArg(args[n], XmNfillOnSelect, False); n++; + XtSetArg(args[n], XmNhighlightThickness, 0); n++; + arrow = XmCreateToggleButton(row, "arrow", args, n); + XtManageChild(arrow); + XtAddCallback(arrow, XmNvalueChangedCallback, + (XtCallbackProc)arrow_change, (XtPointer)data); + + n = 0; + XtSetArg(args[n], XmNcolumns, maxlength ); n++; + XtSetArg(args[n], XmNmaxLength, maxlength); n++; + data->w2 = textfield = XmCreateText(row, "textField", args, n); + XtManageChild(textfield); + XtSetSensitive(textfield, False); + XtAddCallback(textfield, XmNfocusCallback, (XtCallbackProc)focus, NULL); + + n = 0; + xms = XmStringCreateLocalized(resource.code) ; + XtSetArg(args[n], XmNlabelString, xms); n++; + XtSetArg(args[n], XmNhighlightThickness, 0); n++; + code = XmCreatePushButton(row, "Code", args, n); + XtManageChild(code); + XmStringFree(xms); + + XtAddCallback(code, XmNactivateCallback, + (XtCallbackProc)code_input, (XtPointer)textfield); +} + + +void +CreateMenuButtons( Widget owner, Button *buttons, int buttons_cnt ) +{ + Arg args[4]; + char buf[64]; + XmString xms; + int i, n; + +#define LABEL(x) (buttons->items[(x)].label) +#define NMNIC(x) (buttons->items[(x)].mnemonic) +#define SENS(x) (buttons->items[(x)].sensitive) + + buttons->w = (Widget *) malloc(sizeof(Widget)*buttons_cnt); + + if (buttons->w) { + for (i=0; i<buttons_cnt; i++) { + if (LABEL(i) && *((char *) LABEL(i))){ + n=0; + if (strchr(LABEL(i), NMNIC(i))){ + sprintf(buf, "%s", LABEL(i)); + }else{ + sprintf(buf, "%s(%ld)", LABEL(i), NMNIC(i)); + } + xms = XmStringCreateLocalized(buf); + XtSetArg(args[n],XmNlabelString, xms); n++; + XtSetArg(args[n],XmNmnemonic, NMNIC(i)); n++; + XtSetArg(args[n],XmNsensitive, SENS(i)); n++; + buttons->w[i] = + XmCreatePushButtonGadget(owner, "button", args, n); + if (buttons->items[i].cb){ + XtAddCallback(buttons->w[i], XmNactivateCallback, + buttons->items[i].cb, buttons->items[i].clientdata); + } + XmStringFree(xms); + } else{ + n = 0; + XtSetArg(args[n], XmNseparatorType, XmSHADOW_ETCHED_IN); n++; + XtSetArg(args[n], XmNmargin, resource.menu_margin ); n++; + buttons->w[i] = XmCreateSeparatorGadget(owner, + "separater", args, n); + } + XtManageChild(buttons->w[i]); + } + } +#undef LABEL +#undef NMNIC +#undef SENS +} + +static Atom +DeleteWindowAtom(void) +{ + static Atom delatom = 0; + if (! delatom){ + delatom = XInternAtom(XtDisplayOfObject(toplevel), + "WM_DELETE_WINDOW", False); + } + return(delatom); +} + +/*ARGSUSED*/ +Widget +CreateDialogAndButtons( +Widget owner, +String name, +void (*delcb)(), +Button *btns, +int btns_cnt, +Widget *pop) +{ + int n = 0; + Arg args[32]; + Arg arg[8]; + Widget rowcol; + XmString cs1, cs2, cs3; + + XtSetArg( args[n], XmNautoUnmanage, resource. dia_tm_automng ); n++; + XtSetArg( args[n], XmNmarginWidth, resource.dia_tm_width ); n++; + XtSetArg( args[n], XmNmarginHeight, resource.dia_tm_height ); n++; + if (btns->itemcnt > 0){ + cs1 = XmStringCreateLocalized(btns->items[0].label); + XtSetArg(args[n], XmNokLabelString, cs1); n++; + } + if (btns->itemcnt > 1){ + cs2 = XmStringCreateLocalized(btns->items[1].label); + XtSetArg(args[n], XmNcancelLabelString, cs2); n++; + } + if (btns->itemcnt > 2){ + cs3 = XmStringCreateLocalized(btns->items[2].label); + XtSetArg(args[n], XmNhelpLabelString, cs3); n++; + } + XtSetArg(args[n], XmNnoResize, resource.dia_tm_resize ); n++; + XtSetArg(args[n], XmNminimizeButtons, resource.dia_tm_minimize ); n++; + XtSetArg(args[n], XmNtitle, name ); n++; + *pop = XmCreateTemplateDialog(toplevel, "dialog", args, n); + if (delcb) + XmAddWMProtocolCallback(XtParent(*pop), + DeleteWindowAtom(), delcb, 0); + n = 0; + XtSetArg( arg[n], XmNmarginWidth, resource.dia_rw_width ); n++; + XtSetArg( arg[n], XmNmarginHeight, resource.dia_rw_height ); n++; + XtSetArg( arg[n], XmNspacing, resource.dia_rw_spacing ); n++; + XtSetArg( arg[n], XmNorientation, XmVERTICAL); n++; + rowcol = XmCreateRowColumn( *pop, "RowCol", arg, n); + XtManageChild(rowcol); + if (btns->itemcnt > 0){ + if (! btns->items[0].cb) + XtAddCallback(*pop, XmNokCallback, _unmap, 0); + XtAddCallback(*pop, XmNokCallback, btns->items[0].cb, + (btns->items[0].clientdata != NULL) ? btns->items[0].clientdata : 0); + } + if (btns->itemcnt > 1){ + if (! btns->items[1].cb) + XtAddCallback(*pop, XmNcancelCallback, _unmap, 0); + XtAddCallback(*pop, XmNcancelCallback, btns->items[1].cb, + (btns->items[1].clientdata != NULL) ? btns->items[1].clientdata : 0); + } + if (btns->itemcnt > 2){ + if (! btns->items[2].cb) + XtAddCallback(*pop, XmNhelpCallback, _unmap, 0); + XtAddCallback(*pop, XmNhelpCallback, btns->items[2].cb, + (btns->items[2].clientdata != NULL) ? btns->items[2].clientdata : 0); + } + n = 0; + XtSetValues(*pop, args, n); + if (btns->itemcnt == 1){ + XmStringFree(cs1); + } + else if (btns->itemcnt == 2){ + XmStringFree(cs1); + XmStringFree(cs2); + } + else if (btns->itemcnt == 3){ + XmStringFree(cs1); + XmStringFree(cs2); + XmStringFree(cs3); + } + return(rowcol); +} + + +/* Initialize GUI */ + +Widget +GuiInitialize(XtAppContext *app, String class_name, int *ac, String av[]) +{ + Widget top; + + XtSetLanguageProc(NULL, NULL, NULL); + _DtEnvControl(0); + + top = XtAppInitialize(app, class_name, NULL,0, ac,av, NULL,NULL,0); + + return(top); +} + +Widget +CreateDrawingArea( +Widget owner, +String name, +int width, +int height, +void (*proc)(), +int val) +{ + int n = 0; + Arg arg[16]; + Widget drawarea; + + XtSetArg(arg[n], XmNwidth, width); n++; + XtSetArg(arg[n], XmNheight, height); n++; + XtSetArg(arg[n], XmNresizePolicy, XmRESIZE_NONE); n++; + XtSetArg(arg[n], XmNborderWidth, resource.draw_border); n++; + XtSetArg(arg[n], XmNbackground, resource.pane_background); n++; + XtSetArg(arg[n], XmNtopAttachment, (XtArgVal)XmATTACH_FORM); n++; + XtSetArg(arg[n], XmNleftAttachment, (XtArgVal)XmATTACH_FORM); n++; + XtSetArg(arg[n], XmNtopOffset, (XtArgVal)resource.draw_topoff); n++; + XtSetArg(arg[n], XmNleftOffset, (XtArgVal)resource.draw_lftoff); n++; + drawarea = XmCreateDrawingArea(owner, name, arg, n); + XtManageChild( drawarea ); + XtAddEventHandler(drawarea, ExposureMask, FALSE, proc, (XtPointer) (intptr_t) val); + return(drawarea); +} + + +#ifndef USE_MACRO + +void +AddLeftAttachWidget( Widget w, Widget ref, int offset) +{ + XtVaSetValues( w, + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, ref, + XmNleftOffset, offset, + NULL); +} + +void +AddLeftAttachForm( Widget w, int offset ) +{ + XtVaSetValues( w, + XmNleftAttachment, XmATTACH_FORM, + XmNleftOffset, offset, + NULL); +} + +void +AddTopAttachWidget( Widget w, Widget ref, int offset ) +{ + XtVaSetValues( w, + XmNtopAttachment, XmATTACH_WIDGET, + XmNtopWidget, ref, + XmNtopOffset, offset, + NULL); +} + +void +AddTopAttachForm( Widget w, int offset ) +{ + XtVaSetValues( w, + XmNtopAttachment, XmATTACH_FORM, + XmNtopOffset, offset, + NULL); +} + +void +AddRightAttachWidget( Widget w, Widget ref, int offset ) +{ + XtVaSetValues( w, + XmNrightAttachment, XmATTACH_WIDGET, + XmNrightWidget, ref, + XmNrightOffset, offset, + NULL); +} + +void +AddRightAttachForm( Widget w, int offset ) +{ + XtVaSetValues( w, + XmNrightAttachment, XmATTACH_FORM, + XmNrightOffset, offset, + NULL); +} + +void +AddBottomAttachForm( Widget w, int offset ) +{ + XtVaSetValues( w, + XmNbottomAttachment, XmATTACH_FORM, + XmNbottomOffset, offset, + NULL); +} +#endif /* not USE_MACRO */ + +void +PopupDialog(Widget w) +{ + if (! XtIsManaged(w)) + XtManageChild(w); + else + XRaiseWindow(XtDisplayOfObject(w), XtWindow(XtParent(w))); +} + +void +PopdownDialog(Widget w) +{ + if (XtIsManaged(w)){ + XtUnmanageChild(w); + } +} + +void +ForcePopdownDialog(Widget w) +{ + if (XtIsManaged(w)){ + XtUnmanageChild(w); + } +} + +void +SetLabelString(Widget w, String str) +{ + XmString cs = XmStringCreateLocalized(str); + XtVaSetValues( w, XmNlabelString, cs, NULL); + XmStringFree( cs ); +} + +void +SetFooterString(Widget w, String str) +{ + XmString cs = XmStringCreateLocalized(str); + XtVaSetValues( w, XmNlabelString, cs, NULL); + XmStringFree( cs ); + XmUpdateDisplay(w); +} + + +/*********************************************************************** + create and pop up the confirmaiton window + **********************************************************************/ + +static Widget notice=NULL; + +static void +format_str(Widget st, int charcnt , char *str) +{ + int i ; + char *s, *p; + static char buf[512]; + int lw; + int len ; + wchar_t wc ; + XmString cs; + + if (! str || ! *str) return; + + for( p=str, s=buf, lw=0; *p != 0; ){ + + if ( (*p == '\n') || (charcnt <= lw) ){ + *s = '\n'; /* new line */ + lw = 0; + s++; + } + if( (len = mbtowc( &wc, p, MB_CUR_MAX )) <= 0 ) break; + for( i=0; i<len ; i++, s++, p++ ) *s = *p ; + + lw += wcwidth( wc ); + } + *s = 0; + + cs = XmStringCreateLocalized(buf); + XtVaSetValues(st, XmNlabelString, (XtArgVal)cs, (String)0 ); + XmStringFree(cs); +} + +void _unmap(void) +{ + if (notice && XtIsManaged(notice)){ + XtUnmanageChild(notice); + } +} + +static void _destroy(Widget w) +{ + if (w){ + XtDestroyWidget(w); + } + if (w == notice){ + notice = NULL; + } +} + + +/*ARGSUSED*/ +void +PopupNotice( +Widget owner, +char *message, +unsigned char type, +NButton *button, +Boolean do_format, +String title) +{ + Widget label, help, cancel; + int n = 0; + Arg args[32]; + XmString cs1, cs2, cs3; + + XtSetArg(args[n], XmNtitle, title ); n++; + XtSetArg(args[n], XmNnoResize, resource.pop_resize ); n++; + XtSetArg(args[n], XmNminimizeButtons, resource.pop_minimize ); n++; + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++; + XtSetArg(args[n], XmNdialogType, type); n++; + notice = XmCreateMessageDialog( toplevel , "PopupNotice", args, n); + n = 0; + if (button->itemcnt > 0){ + cs1 = XmStringCreateLocalized(button->items[0].label); + XtSetArg(args[n], XmNokLabelString, cs1); n++; + if (button->items[0].cb) + XtAddCallback(notice, XmNokCallback, button->items[0].cb, NULL); + cancel = XmMessageBoxGetChild(notice, XmDIALOG_CANCEL_BUTTON); + help = XmMessageBoxGetChild(notice, XmDIALOG_HELP_BUTTON); + } + if (button->itemcnt > 1){ + cs2 = XmStringCreateLocalized(button->items[1].label); + XtSetArg(args[n], XmNcancelLabelString, cs2); n++; + if (button->items[1].cb) + XtAddCallback(notice, XmNcancelCallback, button->items[1].cb, NULL); + } + if (button->itemcnt > 2){ + cs3 = XmStringCreateLocalized(button->items[2].label); + XtSetArg(args[n], XmNhelpLabelString, cs3); n++; + if (button->items[2].cb) + XtAddCallback(notice, XmNhelpCallback, button->items[2].cb, NULL); + XtAddCallback(help, XmNactivateCallback, (XtCallbackProc)_unmap, NULL); + } + XtSetValues(notice, args, n); + XtAddCallback(notice, XmNunmapCallback, (XtCallbackProc)_destroy, NULL); + if (button->itemcnt == 1){ + XmStringFree(cs1); + XtUnmanageChild(cancel); + XtUnmanageChild(help); + } + else if (button->itemcnt == 2){ + XmStringFree(cs1); + XmStringFree(cs2); + XtUnmanageChild(help); + } + else if (button->itemcnt == 3){ + XmStringFree(cs1); + XmStringFree(cs2); + XmStringFree(cs3); + } + + label = XmMessageBoxGetChild(notice, XmDIALOG_MESSAGE_LABEL); + + if (do_format) + format_str(label, 52, message); + else{ + cs1 = XmStringCreateLocalized(message); + XtVaSetValues(notice, + XmNmessageString, (XtArgVal) cs1, (String) 0); + XtVaSetValues(notice, + XmNmessageAlignment, XmALIGNMENT_CENTER, (String) 0); + XmStringFree(cs1); + } + XtManageChild(notice); + XBell(XtDisplayOfObject( toplevel ), 0); +} + + +/*ARGSUSED*/ +static void +_layout_centerEH(Widget w, XtPointer clientdata) +{ + Widget *child; + int num; + Dimension bbw, mw, sw, cw; + + + XtVaGetValues(w, XmNchildren, &child, XmNnumChildren, &num, NULL); + XtVaGetValues(XtParent(w), + XmNwidth, &bbw, + XmNmarginWidth, &mw, + XmNshadowThickness, &sw, + NULL); + XtVaGetValues(child[0], XmNwidth, &cw, NULL); + XtVaSetValues(w, XmNwidth, ((int)bbw-2*((int)mw+(int)sw)), NULL); + XtVaSetValues(child[0], XmNx, + ((((int)bbw-2*((int)mw+(int)sw))-(int)cw)/2), NULL); +} + +/*ARGSUSED*/ +Widget +CreateTemplateDialog( +Widget w, +char *message, +unsigned char type, +NButton *button, +String title, +Widget *pop) +{ + int n = 0; + Arg args[32]; + XmString cs, cs1=NULL, cs2=NULL, cs3=NULL; + Widget brtnb; + + cs = XmStringCreateLocalized(message); + XtSetArg(args[n], XmNnoResize, resource.temp_resize ); n++; + XtSetArg(args[n], XmNminimizeButtons, resource.temp_minimize ); n++; + XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++; + XtSetArg(args[n], XmNmessageString, cs); n++; + XtSetArg(args[n], XmNmessageAlignment, XmALIGNMENT_CENTER); n++; + XtSetArg(args[n], XmNtitle, title ); n++; + + if (button->itemcnt > 0){ + cs1 = XmStringCreateLocalized(button->items[0].label); + XtSetArg(args[n], XmNokLabelString, cs1); n++; + } + if (button->itemcnt > 1){ + cs2 = XmStringCreateLocalized(button->items[1].label); + XtSetArg(args[n], XmNcancelLabelString, cs2); n++; + } + if (button->itemcnt > 2){ + cs3 = XmStringCreateLocalized(button->items[2].label); + XtSetArg(args[n], XmNhelpLabelString, cs3); n++; + } + *pop = XmCreateTemplateDialog(w, "TemplateDialog", args, n); + if (button->itemcnt > 0 && button->items[0].cb) + XtAddCallback(*pop, XmNokCallback, button->items[0].cb, NULL); + if (button->itemcnt > 1 && button->items[1].cb) + XtAddCallback(*pop, XmNcancelCallback, button->items[1].cb, NULL); + if (button->itemcnt > 2 && button->items[2].cb) + XtAddCallback(*pop, XmNhelpCallback, button->items[2].cb, NULL); + + XmStringFree(cs); + if (cs1) XmStringFree(cs1); + if (cs2) XmStringFree(cs2); + if (cs3) XmStringFree(cs3); + + XtAddCallback(*pop, XmNunmapCallback, (XtCallbackProc)_destroy, NULL); + n = 0; + XtSetArg(args[n], XmNwidth, resource.temp_width ); n++; + XtSetArg(args[n], XmNheight, resource.temp_height ); n++; + brtnb = XmCreateBulletinBoard(*pop, "BulletinBo", args, n); + XtManageChild(brtnb); + XtAddEventHandler(brtnb, + StructureNotifyMask, True, (XtEventHandler)_layout_centerEH, NULL); + return(brtnb); +} + + + + +void +AddDeleteProc(Widget w, void (*delcb)()) +{ + Atom del = DeleteWindowAtom(); + XmAddWMProtocols( w, &del, 1); + XmAddWMProtocolCallback( w, del, delcb, NULL ); +} + +void +AddPopupProc(Widget w, void (*popupcb)()) +{ + XtAddCallback(XtParent(w), XmNpopupCallback, popupcb, 0); +} + +void +AddDestroyProc(Widget w, void (*destroycb)()) +{ + XtAddCallback(XtParent(w), XmNdestroyCallback, destroycb, 0); +} + +Widget +CreateMenuBarAndFooterMessageForm( +Widget owner, +String name, +MButton *buttons, +int bcnt, +Widget *pop, +Widget *footer) +{ + Widget menuBar, form; + Widget footerFrame, footerForm, footerLabel, sep, casBtn, baseForm; + XmString cs; + char buf[64]; + Arg arg[20]; + int i, n = 0; + + XtSetArg( arg[n], XmNiconName, name ); n++; + XtSetArg( arg[n], XmNdeleteResponse, XmUNMAP ); n++; + XtSetArg( arg[n], XmNmwmFunctions, + (MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_CLOSE)); n++; + *pop = XtCreatePopupShell(name, applicationShellWidgetClass, owner, arg, n); + + n = 0; + XtSetArg( arg[n], XmNshowSeparator, True ); n++; + form = XmCreateMainWindow( *pop, "MainW", arg, n); + XtManageChild(form); + + n = 0; + menuBar = XmCreateMenuBar( form, "menuBar", arg, n); + XtManageChild(menuBar); + + n = 0; + baseForm = XmCreateForm( form, "wgeForm", arg, n); + XtManageChild(baseForm); + + for (i=0; i<bcnt; i++){ + n = 0; + XtSetArg(arg[n], XmNtearOffModel, XmTEAR_OFF_ENABLED); n++; + buttons->items[i].menu = + XmCreatePulldownMenu(menuBar, "menu", arg, n); + n = 0; + if (strchr(buttons->items[i].label, buttons->items[i].mnemonic)){ + sprintf(buf, "%s", buttons->items[i].label); + }else{ + snprintf(buf, sizeof(buf), "%s(%s)", buttons->items[i].label, &(buttons->items[i].mnemonic)); + } + cs = XmStringCreateLocalized(buf); + XtSetArg(arg[n],XmNmnemonic, buttons->items[i].mnemonic ); n++; + XtSetArg(arg[n],XmNlabelString, cs ); n++; + XtSetArg(arg[n],XmNsubMenuId, buttons->items[i].menu ); n++; + casBtn = XmCreateCascadeButton( menuBar, "casBtnA", arg, n); + XtManageChild(casBtn); + XmStringFree(cs); + } + + n = 0; + XtSetArg( arg[n], XmNshadowType, XmSHADOW_IN ); n++; + footerFrame = XmCreateFrame( form, "footerFrame", arg, n); + XtManageChild(footerFrame); + XtVaSetValues(form, XmNmessageWindow, footerFrame, NULL); + + n = 0; + XtSetArg( arg[n], XmNtopAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNbottomAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNleftAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNrightAttachment, XmATTACH_FORM); n++; + footerForm = XmCreateForm( footerFrame, "footerForm", arg, n); + XtManageChild(footerForm); + + n = 0; + cs = XmStringCreateLocalized(resource.message); + XtSetArg( arg[n], XmNlabelString, cs); n++; + XtSetArg( arg[n], XmNtopAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNbottomAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNleftAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNmarginTop, resource.ed_msg_margintop ); n++; + XtSetArg( arg[n], XmNmarginBottom, resource.ed_msg_marginbtm ); n++; + footerLabel = XmCreateLabel(footerForm, "Message", arg,n); + XtManageChild(footerLabel); + XmStringFree(cs); + + n = 0; + cs = XmStringCreateLocalized(""); + XtSetArg( arg[n], XmNtopAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNbottomAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNrightAttachment, XmATTACH_FORM); n++; + XtSetArg( arg[n], XmNleftAttachment, XmATTACH_WIDGET); n++; + XtSetArg( arg[n], XmNleftWidget, footerLabel); n++; + XtSetArg( arg[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; + XtSetArg( arg[n], XmNmarginTop, resource.ed_mesg_margintop ); n++; + XtSetArg( arg[n], XmNmarginBottom, resource.ed_mesg_marginbtm ); n++; + XtSetArg( arg[n], XmNlabelString, cs); n++; + *footer = XmCreateLabelGadget(footerForm, "MessageG", arg, n); + XtManageChild(*footer); + XmStringFree(cs); + + return(baseForm); +} + +Widget +GetMenuWidget( MButton *buttons, int buttons_num ) +{ + return(buttons->items[buttons_num].menu); +} + +Widget +CreateForm( Widget owner, String name ) +{ + Widget form; + int n = 0; + Arg arg[8]; + + form = XmCreateForm( owner, name, arg, n ); + XtManageChild(form); + return(form); +} + +/*ARGSUSED*/ +Widget +CreateLabel( Widget owner, String name, String str ) +{ + Widget label; + Arg arg[2]; + int n = 0; + XmString cs = XmStringCreateLocalized(str); + XtSetArg( arg[n], XmNlabelString, cs); n++; + label = XmCreateLabel( owner, "label", arg, n); + XtManageChild(label); + return(label); +} + + +/*ARGSUSED*/ +Widget +CreateFrame(Widget owner, String name, XtPointer type, XtPointer thickness) +{ + Widget frame; + Arg args[20]; + int n = 0; + XtSetArg(args[n], XmNresizable, resource.frame_resize ); n++; + XtSetArg(args[n], XmNshadowType, type); n++; + XtSetArg(args[n], XmNshadowThickness , thickness); n++; + frame = XmCreateFrame(owner, "frame", args, n); + XtManageChild(frame); + return(frame); +} + +/*ARGSUSED*/ +Widget +CreateRowColumn( +Widget owner, +String name, +int layout, +int space, +int marginw, +int marginh) +{ + Widget rc; + Arg args[20]; + int n = 0; + XtSetArg(args[n], XmNorientation, layout); n++; + XtSetArg(args[n], XmNspacing, space); n++; + XtSetArg(args[n], XmNmarginWidth, marginw); n++; + XtSetArg(args[n], XmNmarginHeight, marginh); n++; + rc = XmCreateRowColumn(owner, "rowColumn", args, n); + XtManageChild(rc); + return(rc); +} + +/*ARGSUSED*/ +Widget +CreateScrollBar( +Widget owner, +String name, +int height, +int val, +int min, +int max, +void (*proc)()) +{ + Widget sc; + int n = 0; + Arg arg[16]; + + XtSetArg( arg[n], XmNsliderSize, (XtArgVal)val ); n++; + XtSetArg( arg[n], XmNpageIncrement, (XtArgVal)val ); n++; + XtSetArg( arg[n], XmNmaximum, (XtArgVal)max ); n++; + + sc = XmCreateScrollBar(owner, "wgeScro", arg, n); + XtManageChild( sc ); + XtAddCallback( sc, XmNvalueChangedCallback, proc, NULL ); + return(sc); +} + + +/*ARGSUSED*/ +static void +_scbase_cb( Widget w, void (*proc)(), XmScrollBarCallbackStruct *calldata ) +{ + (*proc)(calldata->value); +} + +Widget +CreateScrollBase( +Widget owner, +String name, +int min, +int max, +int val, +int vcnt, +void (*sbproc)()) +{ + int n = 0; + Arg arg[16]; + Widget base, frame, rwclm, sc; + + XtSetArg( arg[n], XmNwidth, resource.scll_fr_width ); n++; + base = XmCreateForm( owner, name, arg, n ); + XtManageChild( base ); + n=0; + XtSetArg( arg[n], XmNshadowType, XmSHADOW_IN ); n++; + XtSetArg( arg[n], XmNshadowThickness, resource.scll_fr_thick ); n++; + XtSetArg( arg[n], XmNbottomAttachment, XmATTACH_FORM ); n++; + frame = XmCreateFrame( base, name, arg, n ); + XtManageChild( frame ); + n=0; + rwclm = XmCreateRowColumn( frame, name, arg, n ); + XtManageChild( rwclm ); + if (vcnt < (max-min)){ + n=0; + XtSetArg( arg[n], XmNsliderSize, vcnt ); n++; + XtSetArg( arg[n], XmNminimum, min ); n++; + XtSetArg( arg[n], XmNmaximum, max ); n++; + XtSetArg( arg[n], XmNvalue, val ); n++; + XtSetArg( arg[n], XmNleftAttachment, XmATTACH_WIDGET ); n++; + XtSetArg( arg[n], XmNleftWidget, rwclm ); n++; + XtSetArg( arg[n], XmNleftOffset, resource.scll_bar_lftoff ); n++; + XtSetArg( arg[n], XmNtopAttachment, XmATTACH_FORM ); n++; + XtSetArg( arg[n], XmNbottomAttachment, XmATTACH_FORM ); n++; + sc = XmCreateScrollBar( base, name, arg, n ); + XtManageChild( sc ); + XtAddCallback( sc, XmNvalueChangedCallback, + (XtCallbackProc)_scbase_cb, (XtPointer)sbproc); + } + return( rwclm ); +} diff --git a/cde/programs/dtudcfonted/util.h b/cde/programs/dtudcfonted/util.h new file mode 100644 index 000000000..057a4acc9 --- /dev/null +++ b/cde/programs/dtudcfonted/util.h @@ -0,0 +1,334 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* util.h 1.5 - Fujitsu source for CDEnext 96/09/18 13:59:22 */ +/* $XConsortium: util.h /main/5 1996/09/19 19:42:11 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + +#include <Xm/Xm.h> +#include <Xm/XmStrDefs.h> + +#define MarginWidth 4 +#define RowMarginWidth 11 +#define MarginHeight 11 +#define HeightSpace 4 +#define MinimumSpace 4 + +/***** Exclusive Set *****/ + +typedef struct _ToggleButt { + Widget w; + char * label; + XtPointer clientdata; + String name; + XtArgVal sensitive; + XtCallbackProc cb; + XtArgVal set; +} ToggleButt; + +#define EXARGS( clientdata, name, sensitive, cb, set ){ \ + NULL, \ + (char *) "", \ + (XtPointer) clientdata, \ + name, \ + (XtArgVal) sensitive, \ + (XtCallbackProc) cb, \ + (XtArgVal) set \ +} + +typedef struct _RadioButt { + String label; + ToggleButt *items; + int items_cnt; + String name; + Widget w; + XtPointer udata; +} RadioButt; + + +#define EXCLUSIVE(a) { 0, a, XtNumber(a), 0, 0, 0 } + +#define ExclusiveItems ToggleButt +#define Exclusive RadioButt + +#define SetItemLabel(b,n,l) (b)->items[(n)].label = (l) + +/***** PushButton Set *****/ + +typedef struct _ButtonItems { + char * label; + XtCallbackProc cb; + XtPointer clientdata; + XtArgVal mnemonic; + XtArgVal sensitive; + XtArgVal deflt; +} ButtonItems; + +#define BTNARGS( cb, clientdata, mnumonic, sensitive, deflt ) { \ + (char *) "", \ + (XtCallbackProc) cb, \ + (XtPointer) clientdata, \ + (XtArgVal) mnumonic, \ + (XtArgVal) sensitive, \ + (XtArgVal) deflt \ +} + +typedef struct _Button { + Widget *w; + ButtonItems *items; + int itemcnt; +} Button; + +#define BUTTONS( items ) { 0, items, XtNumber(items) } + +/***** MenuButton Set *****/ + +typedef struct _menuButtonItems { + char *label; + char mnemonic; + Widget menu; +} menuButtonItems; + +#define MENUBTNARGS( mnumonic ) { \ + "", \ + mnumonic, \ + NULL, \ +} + +typedef struct _MButton { + menuButtonItems *items; + int itemcnt; +} MButton; + +#define MBUTTONS(items) {items,XtNumber((items))} + + +/***** NoticeButton Set *****/ + +typedef struct _NoticeButton { + char *label; + void (*cb)(); +} NoticeButton; + +#define NBTNARGS( cb, clientdata, mnumonic, sensitive, deflt) { \ + "", \ + cb, \ +} + +typedef struct _NButton { + NoticeButton *items; + int itemcnt; +} NButton; + +#define NBUTTONS(items) {items,XtNumber((items))} + + +/***** TextField Set *****/ + +typedef struct _TextField { + Widget w1; + Widget w2; + String label; +} TextField; + + +/***** Function Type *****/ + +#define D_WARNING XmDIALOG_WARNING +#define D_QUESTION XmDIALOG_QUESTION +#define D_ERROR XmDIALOG_ERROR +#define D_TEMPLATE XmDIALOG_TEMPLATE +#define L_VERTICAL XmVERTICAL +#define L_HORIZONTAL XmHORIZONTAL + + +#ifdef USE_MACRO +#define AddLeftAttachWidget( w, ref, offset ) XtVaSetValues( w, \ + XmNleftAttachment, XmATTACH_WIDGET, \ + XmNleftWidget, ref, \ + XmNleftOffset, offset, \ + 0) + +#define AddLeftAttachForm( w, offset ) XtVaSetValues( w, \ + XmNleftAttachment, XmATTACH_FORM, \ + XmNleftOffset, offset, \ + 0) + +#define AddTopAttachWidget( w, ref, offset ) XtVaSetValues( w, \ + XmNtopAttachment, XmATTACH_WIDGET, \ + XmNtopWidget, ref, \ + XmNtopOffset, offset, \ + 0) + +#define AddTopAttachForm( w, offset ) XtVaSetValues( w, \ + XmNtopAttachment, XmATTACH_FORM, \ + XmNtopOffset, offset, \ + 0) + +#define AddRightAttachWidget( w, ref, offset ) XtVaSetValues( w, \ + XmNrightAttachment, XmATTACH_WIDGET, \ + XmNrightWidget, ref, \ + XmNrightOffset, offset, \ + 0) + +#define AddRightAttachForm( w, offset ) XtVaSetValues( w, \ + XmNrightAttachment, XmATTACH_FORM, \ + XmNrightOffset, offset, \ + 0) + +#define AddBottomAttachForm( w, offset ) XtVaSetValues( w, \ + XmNbottomAttachment, XmATTACH_FORM, \ + XmNbottomOffset, offset, \ + 0) + +extern Widget GetMenuWidget(MButton *buttons, int buttons_num); +extern Widget CreateFrame(Widget owner, + String name, + XtPointer type, + XtPointer thickness); +extern Widget CreateScrollBar(Widget owner, + String name, + int height, + int val, + int min, + int max, + void (*proc)()); +extern Widget CreateDrawingArea(Widget owner, + String name, + int width, + int height, + void (*proc)(), + int val); +extern Widget CreateLabel(Widget owner, String name, String str); +extern Widget CreateDialogAndButtons(Widget owner, + String name, + void (*delcb)(), + Button *btns, + int btns_cnt, + Widget *pop); +extern +#ifdef _HPUX_SOURCE +String +#else +XtPointer +#endif +GetTextFieldValue(TextField *textf); +extern Widget CreateTemplateDialog(Widget w, + char *message, + unsigned char type, + NButton *button, + String title, + Widget *pop); +extern Widget CreateScrollBase(Widget owner, + String name, + int min, + int max, + int val, + int vcnt, + void (*sbproc)()); +extern Widget CreateForm(Widget owner, String name); + +Widget CreateCaptionFrame(Widget owner, + String name, + String labelstr, + int type, + int thickness); +#ifdef _HPUX_SOURCE +String +#else +XtPointer +#endif +GetTextFieldValue(TextField *textf); +void CreateTextField(Widget owner, + String name, + String labelstr, + TextField *data, + int maxlength); +void CreateMenuButtons(Widget owner, Button *buttons, int buttons_cnt); +Widget CreateDialogAndButtons(Widget owner, + String name, + void (*delcb)(), + Button *btns, + int btns_cnt, + Widget *pop); +Widget GuiInitialize(XtAppContext *app, + String class_name, + int *ac, + String av[]); +Widget CreateDrawingArea(Widget owner, + String name, + int width, + int height, + void (*proc)(), + int val); +void AddLeftAttachWidget(Widget w, Widget ref, int offset); +void AddLeftAttachForm(Widget w, int offset); +void AddTopAttachWidget(Widget w, Widget ref, int offset); +void AddTopAttachForm(Widget w, int offset); +void AddRightAttachWidget(Widget w, Widget ref, int offset); +void AddRightAttachForm(Widget w, int offset); +void AddBottomAttachForm(Widget w, int offset); +void PopupDialog(Widget w); +void PopdownDialog(Widget w); +void ForcePopdownDialog(Widget w); +void SetLabelString(Widget w, String str); +void SetFooterString(Widget w, String str); +void PopupNotice(Widget owner, + char *message, + unsigned char type, + NButton *button, + Boolean do_format, + String title); +void AddDeleteProc(Widget w, void (*delcb)()); +Widget CreateMenuBarAndFooterMessageForm(Widget owner, + String name, + MButton *buttons, + int bcnt, + Widget *pop, + Widget *footer); +Widget GetMenuWidget(MButton *buttons, int buttons_num); +Widget CreateForm(Widget owner, String name); +Widget CreateLabel(Widget owner, String name, String str); +Widget CreateFrame(Widget owner, + String name, + XtPointer type, + XtPointer thickness); +Widget CreateRowColumn(Widget owner, + String name, + int layout, + int space, + int marginw, + int marginh); +Widget CreateScrollBar(Widget owner, + String name, + int height, + int val, + int min, + int max, + void (*proc)()); + +#endif /* USE_MACRO */ diff --git a/cde/programs/dtudcfonted/xoakufont.h b/cde/programs/dtudcfonted/xoakufont.h new file mode 100644 index 000000000..6d1261522 --- /dev/null +++ b/cde/programs/dtudcfonted/xoakufont.h @@ -0,0 +1,283 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* xoakufont.h 1.4 - Fujitsu source for CDEnext 96/05/30 11:20:56 */ +/* $XConsortium: xoakufont.h /main/4 1996/06/25 20:17:03 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + +#include "fssxeg.h" + +extern Widget CreateLabel(Widget owner, String name, String str); + +extern int readSNF(FalFontData **fdata, + int *width, + int *height, + char *err); +extern int writeSNF(int restart, int *err); +extern int ptnClose(void); +extern int ptnAdd(int code, char *ptn); +extern int ptnGet(int code, char *ptn); +extern int ptnSense(int code); +extern int ptnDel(int code); +extern int ptnSqToNo(int num); +extern int ptnNoToSq(int ncode); +extern int noToCode(int sno); +extern int codeToNo(int code); +extern int codeCheck(int code); +extern void bitSetInfo(int width, int height); +extern void bitSet(char *ptn, int cx, int cy); +extern void bitReset(char *ptn, int cx, int cy); +extern int bitRead(char *ptn, int cx, int cy); +extern void bitPtnClear(char *ptn); +extern void bitPtnCopy(char *d_ptn, char *s_ptn); +extern int bitDrawLine(char *ptn, + int x1, + int y1, + int x2, + int y2, + int mode); +extern int bitDrawRect(char *ptn, + int x, + int y, + int width, + int height, + int mode); +extern int bitDrawCls(char *ptn, + int x, + int y, + int width, + int height); +extern int bitDrawSet(char *ptn, + int x, + int y, + int width, + int height); +extern int bitDrawRev(char *ptn, + int x, + int y, + int width, + int height); +extern int bitDrawCpy(char *ptn, + int sx, + int sy, + int width, + int height, + int cut_flag); +extern int bitDrawRoll(char *ptn, int x, int y, int width, int height); +extern int bitDrawSymV(char *ptn, int x, int y, int width, int height); +extern int bitDrawSymH(char *ptn, int x, int y, int width, int height); + +#define D_MAX 10 + +#define PROC_POINT 0 +#define PROC_LINE 1 +#define PROC_RECT 2 +#define PROC_CLS 3 +#define PROC_SET 4 +#define PROC_REV 5 +#define PROC_CUT 6 +#define PROC_CPY 7 +#define PROC_PASTE 8 +#define PROC_ROLL 9 +#define PROC_SYMV 10 +#define PROC_SYMH 11 +#define PROC_CIRCLE 12 +#define PROC_ERASE 13 +#define PROC_SELECT 14 + +#define RES_MSG (1L<<0) +#define RES_PROC (1L<<1) +#define RES_SLCT (1L<<2) +#define RES_RSV (1L<<3) + + +#define CPY_COPY 0 +#define CPY_OVERLAY 1 + + +#define CODE_ADD 0 +#define CODE_DEL 1 + +#define SET_CDSET1 0 +#define SET_CDSET3 1 + + +#define SET_NORMAL_U90_G1 0 +#define SET_NORMAL_G1 1 +#define SET_SYSTEM_G1 2 +#define SET_NORMAL 3 +#define SET_JEF 4 +#define SET_SYSTEM 5 + + +#define MG_MAXSIZE 100 + + +/********************************************************************** + structure + **********************************************************************/ + +/* editting character */ +typedef struct _EditChar { + FalFontData *fdata; + int width; + int height; + int code; + int ncode; + char ptn[MAXPTNBYTE]; + char flag; + +} EditChar; + +/* character list */ +typedef struct _EditList { + int nlist; + int statloc; + int slctloc; + int nptn; + int sqstart; + Dimension list_h; + Dimension elem_w; + Dimension elem_h; + Pixel back; + Pixel border; +} EditList; + +/* editting pane */ +typedef struct _EditPane { + int width; + int height; + int pix_w; + int pix_h; + int color; + int obj; + Pixel back; + Pixel border; +} EditPane; + +/* X library */ +typedef struct _XlibInf { + Display *display; + Window root_winID; + Window edit_winID; + Window disp_winID; + Window list_winID; /* 1995.10.02 */ + GC borderGC; + GC backGC; + GC rubGC; + GC dashGC; + XImage *dispImage; +} XlibInf; + + +typedef struct _DelInf { + Dimension elem_w; + Dimension elem_h; + Dimension ptn_w; + Dimension ptn_h; + Dimension list_h; + int s_ncode; + int e_ncode; + int sq_top; + int sq_start; + int sq_end; + int disp_num; +} DelInf; + +/* X library */ +typedef struct _DelPtnInf { + Window disp_winID; + XImage *dispImage; + char ptn[MAXPTNBYTE]; +} DelPtnInf; + +/* editting pattern */ +typedef struct _EditPtnInf { + char drag_f; + int adj_px; + int adj_py; + int proc; + char slct_f; + int src1_px; + int src1_py; + int src2_px; + int src2_py; + int dest_px; + int dest_py; + char rsv_f; + char rsv_ptn[MAXPTNBYTE]; +} EditPtnInf; + +/* copy patterns */ +typedef struct _CopyPtnInf { +/* int size;*/ + FalFontData *fdata; + int s1_code; + int s2_code; + int d1_code; + int proc; +} CopyPtnInf; + +/* fonts */ +typedef struct _FontInf { + int num; + FalFontDataList *lp; + Widget *RecB; +} FontInf; + +/********************************************************************** + + + **********************************************************************/ + +Widget toplevel; + +Widget editPtnW; +Widget cpyPtnW; +Widget mngPtnW; + +EditChar edg; +EditList edlist; +EditPane edpane; +XlibInf xl; +DelInf dn; +DelPtnInf dl[D_MAX] ; +DelPtnInf dl_glyph[EDLIST_MAX]; /* add dl_disp 1995.09.20 */ +int sq_disp[EDLIST_MAX]; /* add sq_disp 1995.09.20 */ + +EditPtnInf em; +CopyPtnInf cpm; + + +/* + * resources for font editor + */ + +#include"ufontrsrc.h" /* 1995.06.28 H.Chiba */ + +/**********/ diff --git a/cde/programs/dtudcfonted/xutil.c b/cde/programs/dtudcfonted/xutil.c new file mode 100644 index 000000000..b4e2e28e5 --- /dev/null +++ b/cde/programs/dtudcfonted/xutil.c @@ -0,0 +1,82 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ +/* xutil.c 1.2 - Fujitsu source for CDEnext 96/02/29 17:30:54 */ +/* $XConsortium: xutil.c /main/2 1996/04/08 16:03:37 cde-fuj $ */ +/* + * (c) Copyright 1995 FUJITSU LIMITED + * This is source code modified by FUJITSU LIMITED under the Joint + * Development Agreement for the CDEnext PST. + * This is unpublished proprietary source code of FUJITSU LIMITED + */ + + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <nl_types.h> + +#include <Xm/Xm.h> + +#include <Xm/Form.h> +#include <Xm/PushB.h> +#include <Xm/Text.h> +#include <Xm/TextF.h> +#include <Xm/Label.h> +#include <Xm/SeparatoG.h> +#include <Xm/List.h> +#include <Xm/ToggleB.h> +#include <Xm/MessageB.h> + +#include "selectxlfd.h" +#include "xoakufont.h" + +/* + * parameters + */ +void xlfdPopupDialog(Widget w); + +extern int getmask ; + +extern Widget toplevel ; +extern Widget slctBLabel[BUTTONITEMS], + slctBText[BUTTONITEMS], slctButton[BUTTONITEMS], + listPop[BUTTONITEMS], listW[BUTTONITEMS], errorMD, msgBox ; + +/**************************************************************** + * common functions +****************************************************************/ + + +/* + * pop up and down dialog box + */ + +void +xlfdPopupDialog(Widget w) +{ + if (! XtIsManaged(w)) + XtManageChild(w); + else + XRaiseWindow(XtDisplayOfObject(w), XtWindow(XtParent(w))); +} diff --git a/cde/programs/localized/templates/app-defaults.tmpl b/cde/programs/localized/templates/app-defaults.tmpl index 57e46d58c..6b03d380e 100644 --- a/cde/programs/localized/templates/app-defaults.tmpl +++ b/cde/programs/localized/templates/app-defaults.tmpl @@ -28,6 +28,7 @@ OBJS = \ Dtmail \ Dtbuilder \ Dtinfo \ + Dtudcfonted \ Dt all:: $(OBJS) @@ -50,6 +51,7 @@ LinkFile(Dtterm.nls,$(CDESRC)/dtterm/Dtterm.ad) LinkFile(Dtmail.nls,$(CDESRC)/dtmail/dtmail/Dtmail) LinkFile(Dtbuilder.nls,$(CDESRC)/dtappbuilder/src/ab/Dtbuilder.ad) LinkFile(Dtinfo.nls,$(CDESRC)/dtinfo/dtinfo/src/Dtinfo) +LinkFile(Dtudcfonted.nls,$(CDESRC)/dtudcfonted/resource/Dtudcfonted) LinkFile(Dt.nls,$(DTSVCSRC)/DtUtil2/Dt.ad) DtstyleDescRule(Dthelpview,Dthelpview) @@ -70,6 +72,7 @@ DtstyleDescRule(Dtterm,Dtterm) DtstyleDescRule(Dtmail,Dtmail) DtstyleDescRule(Dtbuilder,Dtbuilder) DtstyleDescRule(Dtinfo,Dtinfo) +DtstyleDescRule(Dtudcfonted,Dtudcfonted) DtstyleDescRule(Dt,Dt) depend:: diff --git a/cde/programs/localized/templates/msg.C.tmpl b/cde/programs/localized/templates/msg.C.tmpl index 1eda38092..453cf1957 100644 --- a/cde/programs/localized/templates/msg.C.tmpl +++ b/cde/programs/localized/templates/msg.C.tmpl @@ -52,6 +52,8 @@ OBJS= \ dtterm.cat \ dttypes.cat \ dtwm.cat \ + dtudcexch.cat \ + dtudcfonted.cat \ libdtcm.cat \ libDtMail.cat @@ -103,6 +105,8 @@ LinkFile(dtstyle.msg,$(CDESRC)/dtstyle/dtstyle.msg) LinkFile(dtterm.msg,$(CDESRC)/dtterm/dtterm.msg) LinkFile(dttypes.msg,$(CDESRC)/util/dttypes/dttypes.msg) LinkFile(dtwm.msg,$(CDESRC)/dtwm/dtwm.msg) +LinkFile(dtudcexch.msg,$(CDESRC)/dtudcexch/dtudcexch.msg) +LinkFile(dtudcfonted.msg,$(CDESRC)/dtudcfonted/dtudcfonted.msg) LinkFile(libABil.msg,$(CDESRC)/dtappbuilder/src/libABil/libABil.msg) LinkFile(libABobjXm.msg,$(CDESRC)/dtappbuilder/src/libABobjXm/libABobjXm.msg) LinkFile(libAButil.msg,$(CDESRC)/dtappbuilder/src/libAButil/libAButil.msg) diff --git a/cde/programs/localized/templates/msg.el_GR.UTF-8.tmpl b/cde/programs/localized/templates/msg.el_GR.UTF-8.tmpl index 42260bcee..72c3700c3 100644 --- a/cde/programs/localized/templates/msg.el_GR.UTF-8.tmpl +++ b/cde/programs/localized/templates/msg.el_GR.UTF-8.tmpl @@ -58,6 +58,8 @@ OBJS= \ dtterm.cat \ dttypes.cat \ dtwm.cat \ + dtudcexch.cat \ + dtudcfonted.cat \ libdtcm.cat \ libDtMail.cat @@ -112,6 +114,8 @@ LinkFile(dtstyle.msg,$(CDESRC)/dtstyle/dtstyle.msg) LinkFile(dtterm.msg,$(CDESRC)/dtterm/dtterm.msg) LinkFile(dttypes.msg,$(CDESRC)/util/dttypes/dttypes.msg) LinkFile(dtwm.msg,$(CDESRC)/dtwm/dtwm.msg) +LinkFile(dtudcexch.msg,$(CDESRC)/dtudcexch/dtudcexch.msg) +LinkFile(dtudcfonted.msg,$(CDESRC)/dtudcfonted/dtudcfonted.msg) LinkFile(libABil.msg,$(CDESRC)/dtappbuilder/src/libABil/libABil.msg) LinkFile(libABobjXm.msg,$(CDESRC)/dtappbuilder/src/libABobjXm/libABobjXm.msg) LinkFile(libAButil.msg,$(CDESRC)/dtappbuilder/src/libAButil/libAButil.msg)