From: Adam Dickmeiss Date: Thu, 20 May 1999 12:57:18 +0000 (+0000) Subject: Implemented TCL filter. Updated recctrl system. X-Git-Tag: ZEBRA.1.0~114 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=4415da5dbbba04e50d4524347486d60113ed569c Implemented TCL filter. Updated recctrl system. --- diff --git a/CHANGELOG b/CHANGELOG index 9038b54..a47e0d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Implemented new Tcl record filter - use grs.tcl. to enable it. +Zebra's configure script automatically attempts to locate Tcl. For +manual Tcl configuration use option --with-tclconfig= to specify +where Tcl's library files are located. + Implemented "compression" of Dictionary and ISAM system. Dictionary format HAS changed. diff --git a/Makefile.in b/Makefile.in index d218d9b..47cb541 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ # Copyright (C) 1994-1999, Index Data # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.3 1999-02-18 12:49:32 adam Exp $ +# $Id: Makefile.in,v 1.4 1999-05-20 12:57:18 adam Exp $ SHELL=/bin/sh MAKE=make @@ -20,6 +20,8 @@ YAZINC=-I../../yaz/z39.50 -I../../yaz/include # Some systems have seperate socket libraries LIBS=@LIBS@ +prefix=@prefix@ + SUBDIR=util bfile dfa dict isamc isam rset recctrl index all: diff --git a/TODO b/TODO index 120027b..32cd3c8 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ -Zebra TODO $Id: TODO,v 1.6 1998-03-05 08:45:11 adam Exp $ - -Make regx-filter thread safe. +Zebra TODO $Id: TODO,v 1.7 1999-05-20 12:57:18 adam Exp $ Size of sort entries should be configurable. @@ -15,9 +13,6 @@ Configurable default search attributes. Better ranking in searches. Admin should be able specify initial weight to certain fields. -Explain support - including d1 to grs (d1_grs.c) in YAZ; Zebra - to auto-generate explain information depending on data1 system. - ISAMC optimization: indirect block with pointers to all blocks in chain. The initial block should include the count as well. diff --git a/configure b/configure index 7cb4b3b..23e0db8 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -11,6 +11,8 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --with-tclconfig Path for tclConfig.sh" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -49,6 +51,7 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -332,7 +335,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -502,9 +505,11 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -519,18 +524,22 @@ fi + + + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:526: checking for $ac_word" >&5 +echo "configure:534: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -551,16 +560,17 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:555: checking for $ac_word" >&5 +echo "configure:564: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -595,25 +605,61 @@ else echo "$ac_t""no" 1>&6 fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:615: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:603: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:647: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 658 "configure" #include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -627,18 +673,24 @@ else ac_cv_prog_cc_works=no fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:637: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:689: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:642: checking whether we are using GNU C" >&5 +echo "configure:694: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -647,7 +699,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:703: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -658,11 +710,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:666: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:722: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -677,20 +733,24 @@ rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else - CFLAGS="-O2" + CFLAGS="-g" fi else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:694: checking how to run the C preprocessor" >&5 +echo "configure:754: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -705,14 +765,14 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:715: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -722,14 +782,31 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:792: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -742,6 +819,8 @@ fi rm -f conftest* fi rm -f conftest* +fi +rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" @@ -776,28 +855,30 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:784: checking for a BSD compatible install" >&5 +echo "configure:864: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -827,20 +908,23 @@ echo "$ac_t""$INSTALL" 1>&6 # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:836: checking for $ac_word" >&5 +echo "configure:919: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" @@ -858,14 +942,83 @@ else echo "$ac_t""no" 1>&6 fi +TCL_LIB="" +TCL_INCLUDE="" +tclconfig=NONE +# Check whether --with-tclconfig or --without-tclconfig was given. +if test "${with_tclconfig+set}" = set; then + withval="$with_tclconfig" + tclconfig=$withval +fi + +if test "x$tclconfig" = xNONE; then + saveprefix=${prefix} + if test "x$prefix" = xNONE; then +echo $ac_n "checking for prefix by $ac_c" 1>&6 +# Extract the first word of "tclsh", so it can be a program name with args. +set dummy tclsh; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:962: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$TCLSH" in + /*) + ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_TCLSH="$TCLSH" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_TCLSH="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +TCLSH="$ac_cv_path_TCLSH" +if test -n "$TCLSH"; then + echo "$ac_t""$TCLSH" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -n "$ac_cv_path_TCLSH"; then + prefix=`echo $ac_cv_path_TCLSH|sed 's%/[^/][^/]*//*[^/][^/]*$%%'` + fi +fi + + tclconfig=${prefix}/lib + prefix=${saveprefix} +fi +if test -r ${tclconfig}/tclConfig.sh; then + echo $ac_n "checking for Tcl""... $ac_c" 1>&6 +echo "configure:1004: checking for Tcl" >&5 + . ${tclconfig}/tclConfig.sh + TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS" + TCL_INCLUDE=-I${TCL_PREFIX}/include + SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS + SHLIB_LD=$TCL_SHLIB_LD + SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX + SHLIB_VERSION=$TCL_SHLIB_VERSION + echo "$ac_t""$TCL_VERSION" 1>&6 + ODEFS="-DHAVE_TCL_H=1" +fi checkBoth=0 echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:864: checking for connect" >&5 +echo "configure:1017: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -909,7 +1062,7 @@ fi if test "$ac_cv_func_connect" = "no"; then echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:913: checking for main in -lsocket" >&5 +echo "configure:1066: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -917,14 +1070,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -950,12 +1103,12 @@ if test "$checkBoth" = "1"; then oldLibs=$LIBS LIBS="$LIBS -lsocket -lnsl" echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:954: checking for accept" >&5 +echo "configure:1107: checking for accept" >&5 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_accept=yes" else @@ -1000,12 +1153,12 @@ fi fi echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:1004: checking for gethostbyname" >&5 +echo "configure:1157: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -1046,7 +1199,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:1050: checking for main in -lnsl" >&5 +echo "configure:1203: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1054,14 +1207,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1084,7 +1237,7 @@ fi fi echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6 -echo "configure:1088: checking for main in -lwrap" >&5 +echo "configure:1241: checking for main in -lwrap" >&5 ac_lib_var=`echo wrap'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1092,14 +1245,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lwrap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1120,12 +1273,12 @@ else fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1124: checking for ANSI C header files" >&5 +echo "configure:1277: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1133,8 +1286,8 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1290: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes @@ -1150,7 +1303,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1168,7 +1321,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1189,7 +1342,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1200,7 +1353,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1249,7 +1402,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -1328,7 +1481,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1348,9 +1501,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -1370,11 +1525,15 @@ s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@ODEFS@%$ODEFS%g +s%@TCL_INCLUDE@%$TCL_INCLUDE%g +s%@TCL_LIB@%$TCL_LIB%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@RANLIB@%$RANLIB%g +s%@TCLSH@%$TCLSH%g CEOF EOF diff --git a/configure.in b/configure.in index 4923260..2ef6c4d 100644 --- a/configure.in +++ b/configure.in @@ -1,16 +1,41 @@ -dnl Zebra Toolkit +dnl Zebra dnl (c) Index Data 1994-1999 dnl See the file LICENSE for details. -dnl $Id: configure.in,v 1.4 1999-04-22 14:26:38 adam Exp $ +dnl $Id: configure.in,v 1.5 1999-05-20 12:57:18 adam Exp $ AC_INIT(include/zebraver.h) dnl ------ Substitutions AC_SUBST(ODEFS) +AC_SUBST(DEFS) +AC_SUBST(TCL_INCLUDE) +AC_SUBST(TCL_LIB) dnl dnl ------ Checking programs AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_RANLIB +TCL_LIB="" +TCL_INCLUDE="" +tclconfig=NONE +AC_ARG_WITH(tclconfig, [ --with-tclconfig Path for tclConfig.sh], [tclconfig=$withval]) +if test "x$tclconfig" = xNONE; then + saveprefix=${prefix} + AC_PREFIX_PROGRAM(tclsh) + tclconfig=${prefix}/lib + prefix=${saveprefix} +fi +if test -r ${tclconfig}/tclConfig.sh; then + AC_MSG_CHECKING(for Tcl) + . ${tclconfig}/tclConfig.sh + TCL_LIB="$TCL_LIB_SPEC $TCL_LIBS" + TCL_INCLUDE=-I${TCL_PREFIX}/include + SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS + SHLIB_LD=$TCL_SHLIB_LD + SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX + SHLIB_VERSION=$TCL_SHLIB_VERSION + AC_MSG_RESULT($TCL_VERSION) + ODEFS="-DHAVE_TCL_H=1" +fi dnl dnl ----- Sockets checkBoth=0 diff --git a/include/recctrl.h b/include/recctrl.h index 1b646bd..15b7597 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.h,v $ - * Revision 1.28 1999-03-02 16:15:42 quinn + * Revision 1.29 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.28 1999/03/02 16:15:42 quinn * Added "tagsysno" and "tagrank" directives to zebra.cfg. * * Revision 1.27 1998/10/16 08:14:28 adam @@ -174,12 +177,13 @@ typedef struct recType *RecType; struct recType { - char *name; /* Name of record type */ - void (*init)(RecType recType); /* Init function - called once */ - void (*destroy)(RecType recType); /* Destroy function */ - int (*extract)(struct recExtractCtrl *ctrl); /* Extract proc */ - int (*retrieve)(struct recRetrieveCtrl *ctrl); /* Retrieve proc */ - void *clientData; /* data handle */ + char *name; /* Name of record type */ + void *(*init)(RecType recType); /* Init function - called once */ + void (*destroy)(void *clientData); /* Destroy function */ + int (*extract)(void *clientData, + struct recExtractCtrl *ctrl); /* Extract proc */ + int (*retrieve)(void *clientData, + struct recRetrieveCtrl *ctrl); /* Retrieve proc */ }; typedef struct recTypes *RecTypes; @@ -188,7 +192,8 @@ RecTypes recTypes_init (data1_handle dh); void recTypes_destroy (RecTypes recTypes); void recTypes_default_handlers (RecTypes recTypes); -RecType recType_byName (RecTypes rts, const char *name, char *subType); +RecType recType_byName (RecTypes rts, const char *name, char *subType, + void **clientDataP); int grs_extract_tree(struct recExtractCtrl *p, data1_node *n); diff --git a/index/Makefile.in b/index/Makefile.in index 38b5d84..0a4e8e0 100644 --- a/index/Makefile.in +++ b/index/Makefile.in @@ -1,7 +1,7 @@ # Copyright (C) 1995-1998, Index Data # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.6 1999-05-12 13:08:06 adam Exp $ +# $Id: Makefile.in,v 1.7 1999-05-20 12:57:18 adam Exp $ SHELL=/bin/sh @@ -10,6 +10,7 @@ CPP=@CPP@ RANLIB=@RANLIB@ CDEFS=@DEFS@ @ODEFS@ LIBS=@LIBS@ +TCL_LIB=@TCL_LIB@ YAZLIB=../../yaz/lib/libyaz.a YAZINC=-I../../yaz/z39.50 -I../../yaz/include @@ -17,12 +18,13 @@ YAZINC=-I../../yaz/z39.50 -I../../yaz/include #OSILIB=../../xtimosi/src/libmosi.a -lrfc INCLUDE=-I../include $(YAZINC) +TCL_INCLUDE=@TCL_INCLUDE@ TPROG1=zebraidx TPROG2=kdump TPROG3=zebrasrv TPROG4=hlvltest TPROG5=apitest -DEFS=$(CDEFS) $(INCLUDE) +DEFS=$(CDEFS) $(INCLUDE) $(TCL_INCLUDE) O1 = main.o dir.o dirs.o trav.o extract.o kinput.o kcompare.o \ symtab.o recindex.o recstat.o lockutil.o lockidx.o \ zinfo.o invstat.o sortidx.o compact.o @@ -42,7 +44,7 @@ $(TPROG1): $(O1) ../lib/dict.a ../lib/isam.a ../lib/isamc.a ../lib/recctrl.a \ $(CC) $(CFLAGS) -o $(TPROG1) $(O1) \ ../lib/dict.a ../lib/isam.a ../lib/isamc.a ../lib/recctrl.a \ ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ - $(YAZLIB) $(LIBS) + $(YAZLIB) $(TCL_LIB) $(LIBS) $(TPROG2): $(O2) $(CC) $(CFLAGS) -o $(TPROG2) $(O2) ../lib/zebrautl.a \ @@ -55,7 +57,7 @@ $(TPROG3): $(O3) \ $(CC) $(CFLAGS) -o $(TPROG3) $(O3) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ ../lib/isamc.a ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ - $(YAZLIB) $(OSILIB) $(LIBS) -lm + $(YAZLIB) $(OSILIB) $(TCL_LIB) $(LIBS) -lm $(TPROG4): $(O4) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ @@ -64,7 +66,7 @@ $(TPROG4): $(O4) \ $(CC) $(CFLAGS) -o $(TPROG4) $(O4) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ ../lib/isamc.a ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ - $(YAZLIB) $(OSILIB) $(LIBS) -lm + $(YAZLIB) $(OSILIB) $(TCL_LIB) $(LIBS) -lm $(TPROG5): $(O5) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ @@ -73,7 +75,7 @@ $(TPROG5): $(O5) \ $(CC) $(CFLAGS) -o $(TPROG5) $(O5) \ ../lib/rset.a ../lib/dict.a ../lib/isam.a ../lib/recctrl.a \ ../lib/isamc.a ../lib/bfile.a ../lib/dfa.a ../lib/zebrautl.a \ - $(YAZLIB) $(OSILIB) $(LIBS) -lm + $(YAZLIB) $(OSILIB) $(TCL_LIB) $(LIBS) -lm .c.o: diff --git a/index/extract.c b/index/extract.c index 0486bb6..d235a44 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.93 1999-05-15 14:36:38 adam + * Revision 1.94 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.93 1999/05/15 14:36:38 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.92 1999/03/09 16:27:49 adam @@ -1238,7 +1241,7 @@ void addSchema (struct recExtractCtrl *p, Odr_oid *oid) static int recordExtract (SYSNO *sysno, const char *fname, struct recordGroup *rGroup, int deleteFlag, struct file_read_info *fi, - RecType recType, char *subType) + RecType recType, char *subType, void *clientData) { RecordAttr *recordAttr; int r; @@ -1290,7 +1293,7 @@ static int recordExtract (SYSNO *sysno, const char *fname, logInfo.rGroup = rGroup; log_event_start (recordLogPreamble, &logInfo); - r = (*recType->extract)(&extractCtrl); + r = (*recType->extract)(clientData, &extractCtrl); log_event_start (NULL, NULL); @@ -1529,6 +1532,7 @@ int fileExtract (SYSNO *sysno, const char *fname, struct recordGroup rGroupM; struct recordGroup *rGroup = &rGroupM; struct file_read_info *fi; + void *clientData; memcpy (rGroup, rGroupP, sizeof(*rGroupP)); @@ -1568,7 +1572,8 @@ int fileExtract (SYSNO *sysno, const char *fname, if (!*rGroup->recordType) return 0; if (!(recType = - recType_byName (rGroup->recTypes, rGroup->recordType, subType))) + recType_byName (rGroup->recTypes, rGroup->recordType, subType, + &clientData))) { logf (LOG_WARN, "No such record type: %s", rGroup->recordType); return 0; @@ -1707,7 +1712,7 @@ int fileExtract (SYSNO *sysno, const char *fname, { file_begin (fi); r = recordExtract (sysno, fname, rGroup, deleteFlag, fi, - recType, subType); + recType, subType, clientData); } while (r && !sysno && fi->file_more); file_read_stop (fi); if (fd != -1) diff --git a/index/main.c b/index/main.c index ef92bb6..e97ae7c 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.64 1999-05-15 14:36:38 adam + * Revision 1.65 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.64 1999/05/15 14:36:38 adam * Updated dictionary. Implemented "compression" of dictionary. * * Revision 1.63 1999/03/09 16:27:49 adam @@ -549,6 +552,7 @@ int main (int argc, char **argv) else logf (LOG_WARN, "unknown option '-%s'", arg); } + recTypes_destroy (rGroupDef.recTypes); if (common_resource) { zebraIndexUnlock (); diff --git a/index/retrieve.c b/index/retrieve.c index 5e2ed20..eb2331a 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: retrieve.c,v $ - * Revision 1.8 1999-03-09 16:27:49 adam + * Revision 1.9 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.8 1999/03/09 16:27:49 adam * More work on SDRKit integration. * * Revision 1.7 1999/03/02 16:15:43 quinn @@ -115,6 +118,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, char subType[128]; struct fetch_control fc; RecordAttr *recordAttr; + void *clientData; rec = rec_get (zh->records, sysno); if (!rec) @@ -130,7 +134,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, *basenamep = odr_malloc (stream, strlen(basename)+1); strcpy (*basenamep, basename); - if (!(rt = recType_byName (zh->recTypes, file_type, subType))) + if (!(rt = recType_byName (zh->recTypes, file_type, subType, &clientData))) { logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type); return 14; @@ -240,7 +244,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, retrieveCtrl.diagnostic = 0; retrieveCtrl.dh = zh->dh; retrieveCtrl.res = zh->res; - (*rt->retrieve)(&retrieveCtrl); + (*rt->retrieve)(clientData, &retrieveCtrl); *output_format = retrieveCtrl.output_format; *rec_bufp = retrieveCtrl.rec_buf; *rec_lenp = retrieveCtrl.rec_len; diff --git a/isamc/isams.c b/isamc/isams.c index cb86a20..d844198 100644 --- a/isamc/isams.c +++ b/isamc/isams.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isams.c,v $ - * Revision 1.2 1999-05-15 14:35:48 adam + * Revision 1.3 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.2 1999/05/15 14:35:48 adam * Minor changes. * * Revision 1.1 1999/05/12 13:08:06 adam @@ -179,7 +182,7 @@ ISAMS_PP isams_pp_open (ISAMS is, ISAMS_P pos) { ISAMS_PP pp = xmalloc (sizeof(*pp)); - if (is->debug = 1) + if (is->debug > 1) logf (LOG_LOG, "isams: isams_pp_open pos=%ld", (long) pos); pp->is = is; pp->decodeClientData = (*is->method->code_start)(ISAMC_DECODE); diff --git a/recctrl/Makefile.in b/recctrl/Makefile.in index bfea303..bc8a805 100644 --- a/recctrl/Makefile.in +++ b/recctrl/Makefile.in @@ -1,7 +1,7 @@ # Copyright (C) 1995-1998, Index Data # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.2 1998-10-28 15:20:50 adam Exp $ +# $Id: Makefile.in,v 1.3 1999-05-20 12:57:18 adam Exp $ SHELL=/bin/sh @@ -15,7 +15,8 @@ YAZLIB=../../yaz/lib/libyaz.a YAZINC=-I../../yaz/z39.50 -I../../yaz/include INCLUDE=-I../include $(YAZINC) -DEFS=$(CDEFS) $(INCLUDE) +TCL_INCLUDE=@TCL_INCLUDE@ +DEFS=$(CDEFS) $(INCLUDE) $(TCL_INCLUDE) LIB=../lib/recctrl.a PO=recctrl.o recgrs.o sgmlread.o regxread.o marcread.o rectext.o diff --git a/recctrl/grsread.h b/recctrl/grsread.h index 00851ef..7ec6cbc 100644 --- a/recctrl/grsread.h +++ b/recctrl/grsread.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: grsread.h,v $ - * Revision 1.5 1999-02-02 14:51:26 adam + * Revision 1.6 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.5 1999/02/02 14:51:26 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.4 1997/09/17 12:19:21 adam @@ -28,6 +31,7 @@ #include struct grs_read_info { + void *clientData; int (*readf)(void *, char *, size_t); off_t (*seekf)(void *, off_t); off_t (*tellf)(void *); @@ -39,7 +43,15 @@ struct grs_read_info { data1_handle dh; }; -data1_node *grs_read_regx (struct grs_read_info *p); -data1_node *grs_read_sgml (struct grs_read_info *p); -data1_node *grs_read_marc (struct grs_read_info *p); +typedef struct recTypeGrs { + char *type; + void *(*init)(void); + void (*destroy)(void *clientData); + data1_node *(*read)(struct grs_read_info *p); +} *RecTypeGrs; + +extern RecTypeGrs recTypeGrs_sgml; +extern RecTypeGrs recTypeGrs_regx; +extern RecTypeGrs recTypeGrs_tcl; +extern RecTypeGrs recTypeGrs_marc; #endif diff --git a/recctrl/marcread.c b/recctrl/marcread.c index 49d724d..0edc5d4 100644 --- a/recctrl/marcread.c +++ b/recctrl/marcread.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: marcread.c,v $ - * Revision 1.6 1999-02-02 14:51:27 adam + * Revision 1.7 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.6 1999/02/02 14:51:27 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.5 1997/11/18 10:03:24 adam @@ -285,3 +288,21 @@ data1_node *grs_read_marc (struct grs_read_info *p) } return res_root; } + +static void *grs_init_marc() +{ + return 0; +} + +static void grs_destroy_marc(void *clientData) +{ +} + +static struct recTypeGrs marc_type = { + "marc", + grs_init_marc, + grs_destroy_marc, + grs_read_marc +}; + +RecTypeGrs recTypeGrs_marc = &marc_type; diff --git a/recctrl/recctrl.c b/recctrl/recctrl.c index cd4359b..4879f8f 100644 --- a/recctrl/recctrl.c +++ b/recctrl/recctrl.c @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994-1998, Index Data + * Copyright (C) 1994-1999, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: recctrl.c,v $ - * Revision 1.3 1998-10-16 08:14:36 adam + * Revision 1.4 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.3 1998/10/16 08:14:36 adam * Updated record control system. * * Revision 1.2 1996/10/29 14:03:16 adam @@ -44,6 +47,7 @@ struct recTypeEntry { RecType recType; struct recTypeEntry *next; int init_flag; + void *clientData; }; struct recTypes { @@ -66,7 +70,7 @@ void recTypes_destroy (RecTypes rts) for (rte = rts->entries; rte; rte = rte->next) if (rte->init_flag) - (*(rte->recType)->destroy)(rte->recType); + (*(rte->recType)->destroy)(rte->clientData); } void recTypes_add_handler (RecTypes rts, RecType rt) @@ -77,11 +81,13 @@ void recTypes_add_handler (RecTypes rts, RecType rt) rte->recType = rt; rte->init_flag = 0; + rte->clientData = 0; rte->next = rts->entries; rts->entries = rte; } -RecType recType_byName (RecTypes rts, const char *name, char *subType) +RecType recType_byName (RecTypes rts, const char *name, char *subType, + void **clientDataP) { struct recTypeEntry *rte; char *p; @@ -101,8 +107,10 @@ RecType recType_byName (RecTypes rts, const char *name, char *subType) if (!rte->init_flag) { rte->init_flag = 1; - (*(rte->recType)->init)(rte->recType); + rte->clientData = + (*(rte->recType)->init)(rte->recType); } + *clientDataP = rte->clientData; return rte->recType; } return 0; diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index b4ef25c..a8ed698 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: recgrs.c,v $ - * Revision 1.26 1999-03-02 16:15:44 quinn + * Revision 1.27 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.26 1999/03/02 16:15:44 quinn * Added "tagsysno" and "tagrank" directives to zebra.cfg. * * Revision 1.25 1999/02/18 15:01:26 adam @@ -187,19 +190,22 @@ #define GRS_MAX_WORD 512 -static data1_node *read_grs_type (struct grs_read_info *p, const char *type) +struct grs_handler { + RecTypeGrs type; + void *clientData; + int initFlag; + struct grs_handler *next; +}; + +struct grs_handlers { + struct grs_handler *handlers; +}; + +static data1_node *read_grs_type (struct grs_handlers *h, + struct grs_read_info *p, const char *type) { - static struct { - char *type; - data1_node *(*func)(struct grs_read_info *p); - } tab[] = { - { "sgml", grs_read_sgml }, - { "regx", grs_read_regx }, - { "marc", grs_read_marc }, - { NULL, NULL } - }; + struct grs_handler *gh = h->handlers; const char *cp = strchr (type, '.'); - int i; if (cp == NULL || cp == type) { @@ -208,20 +214,62 @@ static data1_node *read_grs_type (struct grs_read_info *p, const char *type) } else strcpy (p->type, cp+1); - for (i=0; tab[i].type; i++) + for (gh = h->handlers; gh; gh = gh->next) { - if (!memcmp (type, tab[i].type, cp-type)) - return (tab[i].func)(p); + if (!memcmp (type, gh->type->type, cp-type)) + { + data1_node *node; + if (!gh->initFlag) + { + gh->initFlag = 1; + gh->clientData = (*gh->type->init)(); + } + p->clientData = gh->clientData; + node = (gh->type->read)(p); + gh->clientData = p->clientData; + return node; + } } return NULL; } -static void grs_init(RecType recType) +static void grs_add_handler (struct grs_handlers *h, RecTypeGrs t) +{ + struct grs_handler *gh = malloc (sizeof(*gh)); + gh->next = h->handlers; + h->handlers = gh; + gh->initFlag = 0; + gh->clientData = 0; + gh->type = t; +} + +static void *grs_init(RecType recType) { + struct grs_handlers *h = malloc (sizeof(*h)); + h->handlers = 0; + + grs_add_handler (h, recTypeGrs_sgml); + grs_add_handler (h, recTypeGrs_regx); +#if HAVE_TCL_H + grs_add_handler (h, recTypeGrs_tcl); +#endif + grs_add_handler (h, recTypeGrs_marc); + return h; } -static void grs_destroy(RecType recType) +static void grs_destroy(void *clientData) { + struct grs_handlers *h = clientData; + struct grs_handler *gh = h->handlers, *gh_next; + while (gh) + { + gh_next = gh->next; + if (gh->initFlag) + (*gh->type->destroy)(gh->clientData); + free (gh); + gh = gh_next; + } + free (h); } static int dumpkeys(data1_node *n, struct recExtractCtrl *p, int level) @@ -349,13 +397,14 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) return dumpkeys(n, p, 0); } -static int grs_extract(struct recExtractCtrl *p) +static int grs_extract(void *clientData, struct recExtractCtrl *p) { data1_node *n; NMEM mem; struct grs_read_info gri; oident oe; int oidtmp[OID_SIZE]; + struct grs_handlers *h = clientData; mem = nmem_create (); gri.readf = p->readf; @@ -367,7 +416,7 @@ static int grs_extract(struct recExtractCtrl *p) gri.mem = mem; gri.dh = p->dh; - n = read_grs_type (&gri, p->subType); + n = read_grs_type (h, &gri, p->subType); if (!n) return -1; @@ -461,7 +510,7 @@ static int process_comp(data1_handle dh, data1_node *n, Z_RecordComposition *c) } } -static int grs_retrieve(struct recRetrieveCtrl *p) +static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) { data1_node *node = 0, *onode = 0; data1_node *dnew; @@ -470,6 +519,7 @@ static int grs_retrieve(struct recRetrieveCtrl *p) NMEM mem; struct grs_read_info gri; char *tagname; + struct grs_handlers *h = clientData; mem = nmem_create(); gri.readf = p->readf; @@ -482,7 +532,7 @@ static int grs_retrieve(struct recRetrieveCtrl *p) gri.dh = p->dh; logf (LOG_DEBUG, "grs_retrieve"); - node = read_grs_type (&gri, p->subType); + node = read_grs_type (h, &gri, p->subType); if (!node) { p->diagnostic = 14; diff --git a/recctrl/rectext.c b/recctrl/rectext.c index 4c27522..6d36db3 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rectext.c,v $ - * Revision 1.9 1998-10-16 08:14:38 adam + * Revision 1.10 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.9 1998/10/16 08:14:38 adam * Updated record control system. * * Revision 1.8 1998/05/20 10:12:27 adam @@ -67,11 +70,12 @@ #include #include "rectext.h" -static void text_init (RecType recType) +static void *text_init (RecType recType) { + return 0; } -static void text_destroy (RecType recType) +static void text_destroy (void *clientData) { } @@ -114,7 +118,7 @@ void buf_close (struct buf_info *fi) xfree (fi); } -static int text_extract (struct recExtractCtrl *p) +static int text_extract (void *clientData, struct recExtractCtrl *p) { char w[512]; RecWord recWord; @@ -144,7 +148,7 @@ static int text_extract (struct recExtractCtrl *p) return 0; } -static int text_retrieve (struct recRetrieveCtrl *p) +static int text_retrieve (void *clientData, struct recRetrieveCtrl *p) { int r, text_ptr = 0; static char *text_buf = NULL; diff --git a/recctrl/regxread.c b/recctrl/regxread.c index e34f896..74e1f5c 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -1,10 +1,13 @@ /* - * Copyright (C) 1994-1998, Index Data + * Copyright (C) 1994-1999, Index Data * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: regxread.c,v $ - * Revision 1.22 1998-11-03 16:07:13 adam + * Revision 1.23 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.22 1998/11/03 16:07:13 adam * Yet another fix. * * Revision 1.21 1998/11/03 15:43:39 adam @@ -165,6 +168,10 @@ #include #include "grsread.h" +#if HAVE_TCL_H +#include +#endif + #define REGX_DEBUG 0 #define F_WIN_EOF 2000000000 @@ -177,6 +184,7 @@ #define REGX_END 4 #define REGX_CODE 5 #define REGX_CONTEXT 6 +#define REGX_INIT 7 struct regxCode { char *str; @@ -210,9 +218,11 @@ struct lexContext { struct lexRule *rules; struct lexRuleInfo **fastRule; int ruleNo; + int initFlag; struct lexRuleAction *beginActionList; struct lexRuleAction *endActionList; + struct lexRuleAction *initActionList; struct lexContext *next; }; @@ -223,7 +233,6 @@ struct lexConcatBuf { }; struct lexSpec { - char *name; struct lexContext *context; @@ -234,6 +243,9 @@ struct lexSpec { int lineNo; NMEM m; data1_handle dh; +#if HAVE_TCL_H + Tcl_Interp *tcl_interp; +#endif void *f_win_fh; void (*f_win_ef)(void *, off_t); @@ -246,8 +258,19 @@ struct lexSpec { struct lexConcatBuf **concatBuf; int maxLevel; + data1_node **d1_stack; + int d1_level; + int stop_flag; + + int *arg_start; + int *arg_end; + int arg_no; + int ptr; }; +struct lexSpecs { + struct lexSpec *spec; +}; static char *f_win_get (struct lexSpec *spec, off_t start_pos, off_t end_pos, int *size) @@ -366,11 +389,13 @@ static struct lexContext *lexContextCreate (const char *name) p->name = xstrdup (name); p->ruleNo = 1; + p->initFlag = 0; p->dfa = lexSpecDFA (); p->rules = NULL; p->fastRule = NULL; p->beginActionList = NULL; p->endActionList = NULL; + p->initActionList = NULL; p->next = NULL; return p; } @@ -392,15 +417,19 @@ static void lexContextDestroy (struct lexContext *p) xfree (p); } -static struct lexSpec *lexSpecCreate (const char *name) +static struct lexSpec *lexSpecCreate (const char *name, data1_handle dh) { struct lexSpec *p; int i; - + p = xmalloc (sizeof(*p)); p->name = xmalloc (strlen(name)+1); strcpy (p->name, name); +#if HAVE_TCL_H + p->tcl_interp = 0; +#endif + p->dh = dh; p->context = NULL; p->context_stack_size = 100; p->context_stack = xmalloc (sizeof(*p->context_stack) * @@ -415,6 +444,8 @@ static struct lexSpec *lexSpecCreate (const char *name) p->concatBuf[i]->len = p->concatBuf[i]->max = 0; p->concatBuf[i]->buf = 0; } + p->d1_stack = xmalloc (sizeof(*p->d1_stack) * p->maxLevel); + p->d1_level = 0; return p; } @@ -440,9 +471,14 @@ static void lexSpecDestroy (struct lexSpec **pp) lexContextDestroy (lt); lt = lt_next; } +#if HAVE_TCL_H + if (p->tcl_interp) + Tcl_DeleteInterp (p->tcl_interp); +#endif xfree (p->name); xfree (p->f_win_buf); xfree (p->context_stack); + xfree (p->d1_stack); xfree (p); *pp = NULL; } @@ -511,6 +547,8 @@ static int readParseToken (const char **cpp, int *len) return REGX_BODY; else if (!strcmp (cmd, "context")) return REGX_CONTEXT; + else if (!strcmp (cmd, "init")) + return REGX_INIT; else { logf (LOG_WARN, "bad command %s", cmd); @@ -558,7 +596,10 @@ static int actionListMk (struct lexSpec *spec, const char *s, s++; break; case REGX_BEGIN: - logf (LOG_WARN, "cannot use begin here"); + logf (LOG_WARN, "cannot use BEGIN here"); + continue; + case REGX_INIT: + logf (LOG_WARN, "cannot use INIT here"); continue; case REGX_END: *ap = xmalloc (sizeof(**ap)); @@ -609,6 +650,10 @@ int readOneSpec (struct lexSpec *spec, const char *s) actionListDel (&spec->context->endActionList); actionListMk (spec, s, &spec->context->endActionList); break; + case REGX_INIT: + actionListDel (&spec->context->initActionList); + actionListMk (spec, s, &spec->context->initActionList); + break; case REGX_PATTERN: #if REGX_DEBUG logf (LOG_DEBUG, "rule %d %s", spec->context->ruleNo, s); @@ -712,13 +757,15 @@ int readFileSpec (struct lexSpec *spec) } if (errors) return -1; + return 0; } +#if 0 static struct lexSpec *curLexSpec = NULL; +#endif static void execData (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, const char *ebuf, int elen, int formatted_text) { struct data1_node *res, *parent; @@ -736,13 +783,13 @@ static void execData (struct lexSpec *spec, logf (LOG_DEBUG, "data (%d bytes)", elen); #endif - if (*d1_level <= 1) + if (spec->d1_level <= 1) return; - parent = d1_stack[*d1_level -1]; + parent = spec->d1_stack[spec->d1_level -1]; assert (parent); - if ((res = d1_stack[*d1_level]) && res->which == DATA1N_data) + if ((res = spec->d1_stack[spec->d1_level]) && res->which == DATA1N_data) org_len = res->u.data.len; else { @@ -766,43 +813,41 @@ static void execData (struct lexSpec *spec, res->root = parent->root; parent->last_child = res; - if (d1_stack[*d1_level]) - d1_stack[*d1_level]->next = res; + if (spec->d1_stack[spec->d1_level]) + spec->d1_stack[spec->d1_level]->next = res; else parent->child = res; - d1_stack[*d1_level] = res; + spec->d1_stack[spec->d1_level] = res; } - if (org_len + elen >= spec->concatBuf[*d1_level]->max) + if (org_len + elen >= spec->concatBuf[spec->d1_level]->max) { char *old_buf, *new_buf; - spec->concatBuf[*d1_level]->max = org_len + elen + 256; - new_buf = xmalloc (spec->concatBuf[*d1_level]->max); - if ((old_buf = spec->concatBuf[*d1_level]->buf)) + spec->concatBuf[spec->d1_level]->max = org_len + elen + 256; + new_buf = xmalloc (spec->concatBuf[spec->d1_level]->max); + if ((old_buf = spec->concatBuf[spec->d1_level]->buf)) { memcpy (new_buf, old_buf, org_len); xfree (old_buf); } - spec->concatBuf[*d1_level]->buf = new_buf; + spec->concatBuf[spec->d1_level]->buf = new_buf; } - assert (spec->concatBuf[*d1_level]); - memcpy (spec->concatBuf[*d1_level]->buf + org_len, ebuf, elen); + assert (spec->concatBuf[spec->d1_level]); + memcpy (spec->concatBuf[spec->d1_level]->buf + org_len, ebuf, elen); res->u.data.len += elen; } static void execDataP (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, const char *ebuf, int elen, int formatted_text) { - execData (spec, d1_stack, d1_level, ebuf, elen, formatted_text); + execData (spec, ebuf, elen, formatted_text); } -static void tagDataRelease (struct lexSpec *spec, - data1_node **d1_stack, int d1_level) +static void tagDataRelease (struct lexSpec *spec) { data1_node *res; - if ((res = d1_stack[d1_level]) && + if ((res = spec->d1_stack[spec->d1_level]) && res->which == DATA1N_data && res->u.data.what == DATA1I_text) { @@ -812,24 +857,23 @@ static void tagDataRelease (struct lexSpec *spec, res->u.data.data = nmem_malloc (spec->m, res->u.data.len); else res->u.data.data = res->lbuf; - memcpy (res->u.data.data, spec->concatBuf[d1_level]->buf, + memcpy (res->u.data.data, spec->concatBuf[spec->d1_level]->buf, res->u.data.len); } } static void variantBegin (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, const char *class_str, int class_len, const char *type_str, int type_len, const char *value_str, int value_len) { - struct data1_node *parent = d1_stack[*d1_level -1]; + struct data1_node *parent = spec->d1_stack[spec->d1_level -1]; char tclass[DATA1_MAX_SYMBOL], ttype[DATA1_MAX_SYMBOL]; data1_vartype *tp; int i; data1_node *res; - if (*d1_level == 0) + if (spec->d1_level == 0) { logf (LOG_WARN, "in variant begin. No record type defined"); return ; @@ -845,7 +889,8 @@ static void variantBegin (struct lexSpec *spec, ttype[type_len] = '\0'; #if REGX_DEBUG - logf (LOG_DEBUG, "variant begin %s %s (%d)", tclass, ttype, *d1_level); + logf (LOG_DEBUG, "variant begin %s %s (%d)", tclass, ttype, + spec->d1_level); #endif if (!(tp = @@ -863,27 +908,27 @@ static void variantBegin (struct lexSpec *spec, res->root = parent->root; parent->last_child = res; - if (d1_stack[*d1_level]) + if (spec->d1_stack[spec->d1_level]) { - tagDataRelease (spec, d1_stack, *d1_level); - d1_stack[*d1_level]->next = res; + tagDataRelease (spec); + spec->d1_stack[spec->d1_level]->next = res; } else parent->child = res; - d1_stack[*d1_level] = res; - d1_stack[++(*d1_level)] = NULL; + spec->d1_stack[spec->d1_level] = res; + spec->d1_stack[++(spec->d1_level)] = NULL; } - for (i = *d1_level-1; d1_stack[i]->which == DATA1N_variant; i--) - if (d1_stack[i]->u.variant.type == tp) + for (i = spec->d1_level-1; spec->d1_stack[i]->which == DATA1N_variant; i--) + if (spec->d1_stack[i]->u.variant.type == tp) { - *d1_level = i; + spec->d1_level = i; break; } #if REGX_DEBUG - logf (LOG_DEBUG, "variant node (%d)", *d1_level); + logf (LOG_DEBUG, "variant node (%d)", spec->d1_level); #endif - parent = d1_stack[*d1_level-1]; + parent = spec->d1_stack[spec->d1_level-1]; res = data1_mk_node (spec->dh, spec->m); res->parent = parent; res->which = DATA1N_variant; @@ -898,15 +943,15 @@ static void variantBegin (struct lexSpec *spec, res->u.variant.value = res->lbuf; parent->last_child = res; - if (d1_stack[*d1_level]) + if (spec->d1_stack[spec->d1_level]) { - tagDataRelease (spec, d1_stack, *d1_level); - d1_stack[*d1_level]->next = res; + tagDataRelease (spec); + spec->d1_stack[spec->d1_level]->next = res; } else parent->child = res; - d1_stack[*d1_level] = res; - d1_stack[++(*d1_level)] = NULL; + spec->d1_stack[spec->d1_level] = res; + spec->d1_stack[++(spec->d1_level)] = NULL; } static void tagStrip (const char **tag, int *len) @@ -923,17 +968,16 @@ static void tagStrip (const char **tag, int *len) } static void tagBegin (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, const char *tag, int len) { - struct data1_node *parent = d1_stack[*d1_level -1]; + struct data1_node *parent = spec->d1_stack[spec->d1_level -1]; data1_element *elem = NULL; data1_node *partag = get_parent_tag(spec->dh, parent); data1_node *res; data1_element *e = NULL; int localtag = 0; - if (*d1_level == 0) + if (spec->d1_level == 0) { logf (LOG_WARN, "in element begin. No record type defined"); return ; @@ -954,7 +998,7 @@ static void tagBegin (struct lexSpec *spec, res->u.tag.tag[len] = '\0'; #if REGX_DEBUG - logf (LOG_DEBUG, "begin tag %s (%d)", res->u.tag.tag, *d1_level); + logf (LOG_DEBUG, "begin tag %s (%d)", res->u.tag.tag, spec->d1_level); #endif if (parent->which == DATA1N_variant) return ; @@ -962,7 +1006,8 @@ static void tagBegin (struct lexSpec *spec, if (!(e = partag->u.tag.element)) localtag = 1; - elem = data1_getelementbytagname (spec->dh, d1_stack[0]->u.root.absyn, + elem = data1_getelementbytagname (spec->dh, + spec->d1_stack[0]->u.root.absyn, e, res->u.tag.tag); res->u.tag.element = elem; res->u.tag.node_selected = 0; @@ -971,36 +1016,36 @@ static void tagBegin (struct lexSpec *spec, res->root = parent->root; parent->last_child = res; - if (d1_stack[*d1_level]) + if (spec->d1_stack[spec->d1_level]) { - tagDataRelease (spec, d1_stack, *d1_level); - d1_stack[*d1_level]->next = res; + tagDataRelease (spec); + spec->d1_stack[spec->d1_level]->next = res; } else parent->child = res; - d1_stack[*d1_level] = res; - d1_stack[++(*d1_level)] = NULL; + spec->d1_stack[spec->d1_level] = res; + spec->d1_stack[++(spec->d1_level)] = NULL; } -static void tagEnd (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, int min_level, +static void tagEnd (struct lexSpec *spec, int min_level, const char *tag, int len) { tagStrip (&tag, &len); - while (*d1_level > min_level) + while (spec->d1_level > min_level) { - tagDataRelease (spec, d1_stack, *d1_level); - (*d1_level)--; - if (*d1_level == 0) + tagDataRelease (spec); + (spec->d1_level)--; + if (spec->d1_level == 0) break; - if ((d1_stack[*d1_level]->which == DATA1N_tag) && + if ((spec->d1_stack[spec->d1_level]->which == DATA1N_tag) && (!tag || - (strlen(d1_stack[*d1_level]->u.tag.tag) == (size_t) len && - !memcmp (d1_stack[*d1_level]->u.tag.tag, tag, len)))) + (strlen(spec->d1_stack[spec->d1_level]->u.tag.tag) == + (size_t) len && + !memcmp (spec->d1_stack[spec->d1_level]->u.tag.tag, tag, len)))) break; } #if REGX_DEBUG - logf (LOG_DEBUG, "end tag (%d)", *d1_level); + logf (LOG_DEBUG, "end tag (%d)", spec->d1_level); #endif } @@ -1072,7 +1117,6 @@ static int tryMatch (struct lexSpec *spec, int *pptr, int *mptr, } static int execTok (struct lexSpec *spec, const char **src, - int arg_no, int *arg_start, int *arg_end, const char **tokBuf, int *tokLen) { const char *s = *src; @@ -1087,16 +1131,17 @@ static int execTok (struct lexSpec *spec, const char **src, s++; while (*s >= '0' && *s <= '9') n = n*10 + (*s++ -'0'); - if (arg_no == 0) + if (spec->arg_no == 0) { *tokBuf = ""; *tokLen = 0; } else { - if (n >= arg_no) - n = arg_no-1; - *tokBuf = f_win_get (spec, arg_start[n], arg_end[n], tokLen); + if (n >= spec->arg_no) + n = spec->arg_no-1; + *tokBuf = f_win_get (spec, spec->arg_start[n], spec->arg_end[n], + tokLen); } } else if (*s == '\"') @@ -1143,32 +1188,235 @@ static char *regxStrz (const char *src, int len, char *str) return str; } -static int execCode (struct lexSpec *spec, - int arg_no, int *arg_start, int *arg_end, int *pptr, - struct regxCode *code, - data1_node **d1_stack, int *d1_level) +#if HAVE_TCL_H +static int cmd_tcl_begin (ClientData clientData, Tcl_Interp *interp, + int argc, char **argv) +{ + struct lexSpec *spec = clientData; + if (argc < 2) + return TCL_ERROR; + if (!strcmp(argv[1], "record") && argc == 3) + { + char *absynName = argv[2]; + data1_absyn *absyn; + +#if REGX_DEBUG + logf (LOG_DEBUG, "begin record %s", absynName); +#endif + if (!(absyn = data1_get_absyn (spec->dh, absynName))) + logf (LOG_WARN, "Unknown tagset: %s", absynName); + else + { + data1_node *res; + + res = data1_mk_node (spec->dh, spec->m); + res->which = DATA1N_root; + res->u.root.type = absynName; + res->u.root.absyn = absyn; + res->root = res; + + spec->d1_stack[spec->d1_level] = res; + spec->d1_stack[++(spec->d1_level)] = NULL; + } + } + else if (!strcmp(argv[1], "element") && argc == 3) + { + tagBegin (spec, argv[2], strlen(argv[2])); + } + else if (!strcmp (argv[1], "variant") && argc == 5) + { + variantBegin (spec, argv[2], strlen(argv[2]), + argv[3], strlen(argv[3]), + argv[4], strlen(argv[4])); + } + else if (!strcmp (argv[1], "context") && argc == 3) + { + struct lexContext *lc = spec->context; +#if REGX_DEBUG + logf (LOG_DEBUG, "begin context %s",argv[2]); +#endif + while (lc && strcmp (argv[2], lc->name)) + lc = lc->next; + if (lc) + { + spec->context_stack[++(spec->context_stack_top)] = lc; + } + else + logf (LOG_WARN, "unknown context %s", argv[2]); + } + else + return TCL_ERROR; + return TCL_OK; +} + +static int cmd_tcl_end (ClientData clientData, Tcl_Interp *interp, + int argc, char **argv) +{ + struct lexSpec *spec = clientData; + if (argc < 2) + return TCL_ERROR; + + if (!strcmp (argv[1], "record")) + { + while (spec->d1_level) + { + tagDataRelease (spec); + (spec->d1_level)--; + } +#if REGX_DEBUG + logf (LOG_DEBUG, "end record"); +#endif + spec->stop_flag = 1; + } + else if (!strcmp (argv[1], "element")) + { + int min_level = 1; + char *element = 0; + if (!strcmp(argv[2], "-record")) + { + min_level = 0; + if (argc == 4) + element = argv[3]; + } + else + { + if (argc == 3) + element = argv[2]; + } + tagEnd (spec, min_level, element, (element ? strlen(element) : 0)); + if (spec->d1_level == 0) + { +#if REGX_DEBUG + logf (LOG_DEBUG, "end element end records"); +#endif + spec->stop_flag = 1; + } + } + else if (!strcmp (argv[1], "context")) + { +#if REGX_DEBUG + logf (LOG_DEBUG, "end context"); +#endif + if (spec->context_stack_top) + (spec->context_stack_top)--; + } + else + return TCL_ERROR; + return TCL_OK; +} + +static int cmd_tcl_data (ClientData clientData, Tcl_Interp *interp, + int argc, char **argv) +{ + int argi = 1; + int textFlag = 0; + const char *element = 0; + struct lexSpec *spec = clientData; + + while (argi < argc) + { + if (!strcmp("-text", argv[argi])) + { + textFlag = 1; + argi++; + } + else if (!strcmp("-element", argv[argi])) + { + argi++; + if (argi < argc) + element = argv[argi++]; + } + else + break; + } + if (element) + tagBegin (spec, element, strlen(element)); + + while (argi < argc) + { + execData (spec, argv[argi], strlen(argv[argi]), textFlag); + argi++; + } + if (element) + tagEnd (spec, 1, NULL, 0); + return TCL_OK; +} + +static int cmd_tcl_unread (ClientData clientData, Tcl_Interp *interp, + int argc, char **argv) +{ + struct lexSpec *spec = clientData; + int argi = 1; + int offset = 0; + int no; + + while (argi < argc) + { + if (!strcmp("-offset", argv[argi])) + { + argi++; + if (argi < argc) + { + offset = atoi(argv[argi]); + argi++; + } + } + else + break; + } + if (argi != argc-1) + return TCL_ERROR; + no = atoi(argv[argi]); + if (no >= spec->arg_no) + no = spec->arg_no - 1; + spec->ptr = spec->arg_start[no] + offset; + return TCL_OK; +} + +static void execTcl (struct lexSpec *spec, struct regxCode *code) +{ + int i; + for (i = 0; i < spec->arg_no; i++) + { + char var_name[10], *var_buf; + int var_len, ch; + + sprintf (var_name, "%d", i); + var_buf = f_win_get (spec, spec->arg_start[i], spec->arg_end[i], + &var_len); + if (var_buf) + { + ch = var_buf[var_len]; + var_buf[var_len] = '\0'; + Tcl_SetVar (spec->tcl_interp, var_name, var_buf, 0); + var_buf[var_len] = ch; + } + } + Tcl_Eval (spec->tcl_interp, code->str); +} +/* HAVE_TCL_H */ +#endif + +static void execCode (struct lexSpec *spec, struct regxCode *code) { const char *s = code->str; int cmd_len, r; - int returnCode = 1; const char *cmd_str; - r = execTok (spec, &s, arg_no, arg_start, arg_end, &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); while (r) { char *p, ptmp[64]; if (r == 1) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); continue; } p = regxStrz (cmd_str, cmd_len, ptmp); if (!strcmp (p, "begin")) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) { logf (LOG_WARN, "missing keyword after 'begin'"); @@ -1177,11 +1425,10 @@ static int execCode (struct lexSpec *spec, p = regxStrz (cmd_str, cmd_len, ptmp); if (!strcmp (p, "record")) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; - if (*d1_level == 0) + if (spec->d1_level == 0) { static char absynName[64]; data1_absyn *absyn; @@ -1206,22 +1453,19 @@ static int execCode (struct lexSpec *spec, res->u.root.absyn = absyn; res->root = res; - d1_stack[*d1_level] = res; - d1_stack[++(*d1_level)] = NULL; + spec->d1_stack[spec->d1_level] = res; + spec->d1_stack[++(spec->d1_level)] = NULL; } } - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else if (!strcmp (p, "element")) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; - tagBegin (spec, d1_stack, d1_level, cmd_str, cmd_len); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + tagBegin (spec, cmd_str, cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else if (!strcmp (p, "variant")) { @@ -1231,40 +1475,35 @@ static int execCode (struct lexSpec *spec, const char *type_str = NULL; int value_len; const char *value_str = NULL; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; class_str = cmd_str; class_len = cmd_len; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; type_str = cmd_str; type_len = cmd_len; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) continue; value_str = cmd_str; value_len = cmd_len; - variantBegin (spec, d1_stack, d1_level, class_str, class_len, + variantBegin (spec, class_str, class_len, type_str, type_len, value_str, value_len); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else if (!strcmp (p, "context")) { if (r > 1) { struct lexContext *lc = spec->context; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); p = regxStrz (cmd_str, cmd_len, ptmp); #if REGX_DEBUG logf (LOG_DEBUG, "begin context %s", p); @@ -1277,8 +1516,7 @@ static int execCode (struct lexSpec *spec, logf (LOG_WARN, "unknown context %s", p); } - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else { @@ -1287,8 +1525,7 @@ static int execCode (struct lexSpec *spec, } else if (!strcmp (p, "end")) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) { logf (LOG_WARN, "missing keyword after 'end'"); @@ -1297,41 +1534,38 @@ static int execCode (struct lexSpec *spec, p = regxStrz (cmd_str, cmd_len, ptmp); if (!strcmp (p, "record")) { - int i; - for (i = *d1_level; i; --i) - tagDataRelease (spec, d1_stack, i); - *d1_level = 0; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + while (spec->d1_level) + { + tagDataRelease (spec); + (spec->d1_level)--; + } + r = execTok (spec, &s, &cmd_str, &cmd_len); #if REGX_DEBUG logf (LOG_DEBUG, "end record"); #endif - returnCode = 0; + spec->stop_flag = 1; } else if (!strcmp (p, "element")) { int min_level = 1; - while ((r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len)) == 3) + while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3) { if (cmd_len==7 && !memcmp ("-record", cmd_str, cmd_len)) min_level = 0; } if (r > 2) { - tagEnd (spec, d1_stack, d1_level, min_level, - cmd_str, cmd_len); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + tagEnd (spec, min_level, cmd_str, cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else - tagEnd (spec, d1_stack, d1_level, min_level, NULL, 0); - if (*d1_level == 0) + tagEnd (spec, min_level, NULL, 0); + if (spec->d1_level == 0) { #if REGX_DEBUG logf (LOG_DEBUG, "end element end records"); #endif - returnCode = 0; + spec->stop_flag = 1; } } @@ -1342,8 +1576,7 @@ static int execCode (struct lexSpec *spec, #endif if (spec->context_stack_top) (spec->context_stack_top)--; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else logf (LOG_WARN, "bad keyword '%s' after end", p); @@ -1354,15 +1587,13 @@ static int execCode (struct lexSpec *spec, int element_len; const char *element_str = NULL; - while ((r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len)) == 3) + while ((r = execTok (spec, &s, &cmd_str, &cmd_len)) == 3) { if (cmd_len==5 && !memcmp ("-text", cmd_str, cmd_len)) textFlag = 1; else if (cmd_len==8 && !memcmp ("-element", cmd_str, cmd_len)) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &element_str, &element_len); + r = execTok (spec, &s, &element_str, &element_len); if (r < 2) break; } @@ -1376,26 +1607,22 @@ static int execCode (struct lexSpec *spec, continue; } if (element_str) - tagBegin (spec, d1_stack, d1_level, element_str, element_len); + tagBegin (spec, element_str, element_len); do { - execData (spec, d1_stack, d1_level, cmd_str, cmd_len, - textFlag); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + execData (spec, cmd_str, cmd_len,textFlag); + r = execTok (spec, &s, &cmd_str, &cmd_len); } while (r > 1); if (element_str) - tagEnd (spec, d1_stack, d1_level, 1, NULL, 0); + tagEnd (spec, 1, NULL, 0); } else if (!strcmp (p, "unread")) { int no, offset; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r==3 && cmd_len == 7 && !memcmp ("-offset", cmd_str, cmd_len)) { - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); if (r < 2) { logf (LOG_WARN, "missing number after -offset"); @@ -1403,8 +1630,7 @@ static int execCode (struct lexSpec *spec, } p = regxStrz (cmd_str, cmd_len, ptmp); offset = atoi (p); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else offset = 0; @@ -1421,20 +1647,18 @@ static int execCode (struct lexSpec *spec, else { no = *cmd_str - '0'; - if (no >= arg_no) - no = arg_no - 1; - *pptr = arg_start[no] + offset; + if (no >= spec->arg_no) + no = spec->arg_no - 1; + spec->ptr = spec->arg_start[no] + offset; } - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else if (!strcmp (p, "context")) { if (r > 1) { struct lexContext *lc = spec->context; - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); p = regxStrz (cmd_str, cmd_len, ptmp); while (lc && strcmp (p, lc->name)) @@ -1445,36 +1669,26 @@ static int execCode (struct lexSpec *spec, logf (LOG_WARN, "unknown context %s", p); } - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } else { logf (LOG_WARN, "unknown code command '%.*s'", cmd_len, cmd_str); - r = execTok (spec, &s, arg_no, arg_start, arg_end, - &cmd_str, &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); continue; } if (r > 1) { logf (LOG_WARN, "ignoring token %.*s", cmd_len, cmd_str); do { - r = execTok (spec, &s, arg_no, arg_start, arg_end, &cmd_str, - &cmd_len); + r = execTok (spec, &s, &cmd_str, &cmd_len); } while (r > 1); } } - return returnCode; } -/* - * execAction: Execute action specified by 'ap'. Returns 0 if - * the pattern(s) associated by rule and code could be executed - * ok; returns 1 if code couldn't be executed. - */ static int execAction (struct lexSpec *spec, struct lexRuleAction *ap, - data1_node **d1_stack, int *d1_level, int start_ptr, int *pptr) { int sptr; @@ -1482,8 +1696,12 @@ static int execAction (struct lexSpec *spec, struct lexRuleAction *ap, int arg_end[20]; int arg_no = 1; + if (!ap) + return 1; arg_start[0] = start_ptr; arg_end[0] = *pptr; + spec->arg_start = arg_start; + spec->arg_end = arg_end; while (ap) { @@ -1521,9 +1739,19 @@ static int execAction (struct lexSpec *spec, struct lexRuleAction *ap, arg_no++; break; case REGX_CODE: - if (!execCode (spec, arg_no, arg_start, arg_end, pptr, - ap->u.code, d1_stack, d1_level)) - return 0; + spec->arg_no = arg_no; + spec->ptr = *pptr; +#if HAVE_TCL_H + if (spec->tcl_interp) + execTcl(spec, ap->u.code); + else + execCode (spec, ap->u.code); +#else + execCode (spec, ap->u.code); +#endif + *pptr = spec->ptr; + if (spec->stop_flag) + return 0; break; case REGX_END: arg_start[arg_no] = *pptr; @@ -1537,18 +1765,16 @@ static int execAction (struct lexSpec *spec, struct lexRuleAction *ap, } static int execRule (struct lexSpec *spec, struct lexContext *context, - data1_node **d1_stack, int *d1_level, int ruleNo, int start_ptr, int *pptr) { #if REGX_DEBUG logf (LOG_DEBUG, "exec rule %d", ruleNo); #endif return execAction (spec, context->fastRule[ruleNo]->actionList, - d1_stack, d1_level, start_ptr, pptr); + start_ptr, pptr); } -data1_node *lexNode (struct lexSpec *spec, - data1_node **d1_stack, int *d1_level, int *ptr) +data1_node *lexNode (struct lexSpec *spec, int *ptr) { struct lexContext *context = spec->context_stack[spec->context_stack_top]; struct DFA_state *state = context->dfa->states[0]; @@ -1576,14 +1802,13 @@ data1_node *lexNode (struct lexSpec *spec, int size; char *buf; buf = f_win_get (spec, skip_ptr, start_ptr, &size); - execDataP (spec, d1_stack, d1_level, buf, size, 0); + execDataP (spec, buf, size, 0); } /* restore pointer */ *ptr = last_ptr; /* execute rule */ - if (!execRule (spec, context, d1_stack, d1_level, - last_rule, start_ptr, ptr)) - break; + if (!execRule (spec, context, last_rule, start_ptr, ptr)) + break; /* restore skip pointer */ skip_ptr = *ptr; last_rule = 0; @@ -1594,7 +1819,7 @@ data1_node *lexNode (struct lexSpec *spec, int size; char *buf; buf = f_win_get (spec, skip_ptr, *ptr, &size); - execDataP (spec, d1_stack, d1_level, buf, size, 0); + execDataP (spec, buf, size, 0); } if (*ptr == F_WIN_EOF) break; @@ -1612,12 +1837,11 @@ data1_node *lexNode (struct lexSpec *spec, int size; char *buf; buf = f_win_get (spec, skip_ptr, start_ptr, &size); - execDataP (spec, d1_stack, d1_level, buf, size, 0); + execDataP (spec, buf, size, 0); } /* restore pointer */ *ptr = last_ptr; - if (!execRule (spec, context, d1_stack, d1_level, - last_rule, start_ptr, ptr)) + if (!execRule (spec, context, last_rule, start_ptr, ptr)) { if (spec->f_win_ef && *ptr != F_WIN_EOF) { @@ -1674,10 +1898,10 @@ static data1_node *lexRoot (struct lexSpec *spec, off_t offset, const char *context_name) { struct lexContext *lt = spec->context; - data1_node *d1_stack[128]; - int d1_level = 0; - int i, ptr = offset; + int ptr = offset; + spec->stop_flag = 0; + spec->d1_level = 0; spec->context_stack_top = 0; while (lt) { @@ -1691,48 +1915,137 @@ static data1_node *lexRoot (struct lexSpec *spec, off_t offset, return NULL; } spec->context_stack[spec->context_stack_top] = lt; - d1_stack[d1_level] = NULL; - if (lt->beginActionList) - execAction (spec, lt->beginActionList, d1_stack, &d1_level, 0, &ptr); - lexNode (spec, d1_stack, &d1_level, &ptr); - for (i = d1_level; i; --i) - tagDataRelease (spec, d1_stack, i); - if (lt->endActionList) - execAction (spec, lt->endActionList, d1_stack, &d1_level, ptr, &ptr); - return *d1_stack; + spec->d1_stack[spec->d1_level] = NULL; +#if 1 + if (!lt->initFlag) + { + lt->initFlag = 1; + execAction (spec, lt->initActionList, ptr, &ptr); + } +#endif + execAction (spec, lt->beginActionList, ptr, &ptr); + lexNode (spec, &ptr); + while (spec->d1_level) + { + tagDataRelease (spec); + (spec->d1_level)--; + } + execAction (spec, lt->endActionList, ptr, &ptr); + return spec->d1_stack[0]; +} + +void grs_destroy(void *clientData) +{ + struct lexSpecs *specs = clientData; + if (specs->spec) + { + lexSpecDestroy(&specs->spec); + } + xfree (specs); +} + +void *grs_init(void) +{ + struct lexSpecs *specs = xmalloc (sizeof(*specs)); + specs->spec = 0; + return specs; } data1_node *grs_read_regx (struct grs_read_info *p) { int res; + struct lexSpecs *specs = p->clientData; + struct lexSpec **curLexSpec = &specs->spec; #if REGX_DEBUG logf (LOG_DEBUG, "grs_read_regx"); #endif - if (!curLexSpec || strcmp (curLexSpec->name, p->type)) + if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type)) + { + if (*curLexSpec) + lexSpecDestroy (curLexSpec); + *curLexSpec = lexSpecCreate (p->type, p->dh); + res = readFileSpec (*curLexSpec); + if (res) + { + lexSpecDestroy (curLexSpec); + return NULL; + } + } + (*curLexSpec)->dh = p->dh; + if (!p->offset) + { + (*curLexSpec)->f_win_start = 0; + (*curLexSpec)->f_win_end = 0; + (*curLexSpec)->f_win_rf = p->readf; + (*curLexSpec)->f_win_sf = p->seekf; + (*curLexSpec)->f_win_fh = p->fh; + (*curLexSpec)->f_win_ef = p->endf; + (*curLexSpec)->f_win_size = 500000; + } + (*curLexSpec)->m = p->mem; + return lexRoot (*curLexSpec, p->offset, "main"); +} + +static struct recTypeGrs regx_type = { + "regx", + grs_init, + grs_destroy, + grs_read_regx +}; + +RecTypeGrs recTypeGrs_regx = ®x_type; + +#if HAVE_TCL_H +data1_node *grs_read_tcl (struct grs_read_info *p) +{ + int res; + struct lexSpecs *specs = p->clientData; + struct lexSpec **curLexSpec = &specs->spec; + +#if REGX_DEBUG + logf (LOG_DEBUG, "grs_read_tcl"); +#endif + if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type)) { - if (curLexSpec) - lexSpecDestroy (&curLexSpec); - curLexSpec = lexSpecCreate (p->type); - curLexSpec->dh = p->dh; - res = readFileSpec (curLexSpec); + Tcl_Interp *tcl_interp; + if (*curLexSpec) + lexSpecDestroy (curLexSpec); + *curLexSpec = lexSpecCreate (p->type, p->dh); + tcl_interp = (*curLexSpec)->tcl_interp = Tcl_CreateInterp(); + Tcl_CreateCommand (tcl_interp, "begin", cmd_tcl_begin, *curLexSpec, 0); + Tcl_CreateCommand (tcl_interp, "end", cmd_tcl_end, *curLexSpec, 0); + Tcl_CreateCommand (tcl_interp, "data", cmd_tcl_data, *curLexSpec, 0); + Tcl_CreateCommand (tcl_interp, "unread", cmd_tcl_unread, + *curLexSpec, 0); + res = readFileSpec (*curLexSpec); if (res) { - lexSpecDestroy (&curLexSpec); + lexSpecDestroy (curLexSpec); return NULL; } } - curLexSpec->dh = p->dh; + (*curLexSpec)->dh = p->dh; if (!p->offset) { - curLexSpec->f_win_start = 0; - curLexSpec->f_win_end = 0; - curLexSpec->f_win_rf = p->readf; - curLexSpec->f_win_sf = p->seekf; - curLexSpec->f_win_fh = p->fh; - curLexSpec->f_win_ef = p->endf; - curLexSpec->f_win_size = 500000; + (*curLexSpec)->f_win_start = 0; + (*curLexSpec)->f_win_end = 0; + (*curLexSpec)->f_win_rf = p->readf; + (*curLexSpec)->f_win_sf = p->seekf; + (*curLexSpec)->f_win_fh = p->fh; + (*curLexSpec)->f_win_ef = p->endf; + (*curLexSpec)->f_win_size = 500000; } - curLexSpec->m = p->mem; - return lexRoot (curLexSpec, p->offset, "main"); + (*curLexSpec)->m = p->mem; + return lexRoot (*curLexSpec, p->offset, "main"); } + +static struct recTypeGrs tcl_type = { + "tcl", + grs_init, + grs_destroy, + grs_read_tcl +}; + +RecTypeGrs recTypeGrs_tcl = &tcl_type; +#endif diff --git a/recctrl/sgmlread.c b/recctrl/sgmlread.c index d80bc0c..79e7e6f 100644 --- a/recctrl/sgmlread.c +++ b/recctrl/sgmlread.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: sgmlread.c,v $ - * Revision 1.5 1999-02-02 14:51:31 adam + * Revision 1.6 1999-05-20 12:57:18 adam + * Implemented TCL filter. Updated recctrl system. + * + * Revision 1.5 1999/02/02 14:51:31 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.4 1997/09/17 12:19:22 adam @@ -26,7 +29,29 @@ #include "grsread.h" -data1_node *grs_read_sgml (struct grs_read_info *p) +static data1_node *grs_read_sgml (struct grs_read_info *p) { + logf (LOG_LOG, "grs_read_sgml"); return data1_read_record (p->dh, p->readf, p->fh, p->mem); } + +static void *grs_init_sgml() +{ + logf (LOG_LOG, "grs_init_gsml"); + return 0; +} + +static void grs_destroy_sgml(void *clientData) +{ + logf (LOG_LOG, "grs_destroy_sgml"); +} + +static struct recTypeGrs sgml_type = { + "sgml", + grs_init_sgml, + grs_destroy_sgml, + grs_read_sgml +}; + +RecTypeGrs recTypeGrs_sgml = &sgml_type; +