diff options
Diffstat (limited to 'apps/console/diatheke')
-rw-r--r-- | apps/console/diatheke/Makefile.in | 386 | ||||
-rwxr-xr-x | apps/console/diatheke/cgi/diatheke.pl | 467 | ||||
-rw-r--r-- | apps/console/diatheke/corediatheke.cpp | 427 | ||||
-rw-r--r-- | apps/console/diatheke/corediatheke.h | 39 | ||||
-rw-r--r-- | apps/console/diatheke/diafiltmgr.h | 44 | ||||
-rw-r--r-- | apps/console/diatheke/diatheke.cpp | 213 | ||||
-rw-r--r-- | apps/console/diatheke/diathekemgr.cpp | 107 | ||||
-rw-r--r-- | apps/console/diatheke/gbfcgi.cpp | 138 | ||||
-rw-r--r-- | apps/console/diatheke/gbfcgi.h | 33 | ||||
-rw-r--r-- | apps/console/diatheke/thmlcgi.cpp | 192 | ||||
-rw-r--r-- | apps/console/diatheke/thmlcgi.h | 33 |
11 files changed, 2079 insertions, 0 deletions
diff --git a/apps/console/diatheke/Makefile.in b/apps/console/diatheke/Makefile.in new file mode 100644 index 0000000..b2ea29a --- /dev/null +++ b/apps/console/diatheke/Makefile.in @@ -0,0 +1,386 @@ +# Makefile.in generated by automake 1.6.2 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CURL_CFLAGS = @CURL_CFLAGS@ +CURL_CONFIG = @CURL_CONFIG@ +CURL_LIBS = @CURL_LIBS@ +CXX = @CXX@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +GENCCODE = @GENCCODE@ +GENCMN = @GENCMN@ +GENRB = @GENRB@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +PKGDATA = @PKGDATA@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +dir_confdef = @dir_confdef@ +enable_debug = @enable_debug@ +enable_profile = @enable_profile@ +install_sh = @install_sh@ +target_cpu = @target_cpu@ +target_mingw32 = @target_mingw32@ +target_os = @target_os@ +target_system = @target_system@ +target_vendor = @target_vendor@ +with_conf = @with_conf@ +with_icu = @with_icu@ +with_zlib = @with_zlib@ +AUTOMAKE_OPTIONS = 1.6 + +INCLUDES = -I$(top_srcdir)/include + +bin_PROGRAMS = diatheke +diatheke_SOURCES = diatheke.cpp corediatheke.cpp diathekemgr.cpp \ + diafiltmgr.cpp thmlcgi.cpp gbfcgi.cpp + +diatheke_LDADD = -L$(top_builddir)/lib -lsword +subdir = apps/console/diatheke +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = diatheke$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +am_diatheke_OBJECTS = diatheke.$(OBJEXT) corediatheke.$(OBJEXT) \ + diathekemgr.$(OBJEXT) diafiltmgr.$(OBJEXT) thmlcgi.$(OBJEXT) \ + gbfcgi.$(OBJEXT) +diatheke_OBJECTS = $(am_diatheke_OBJECTS) +diatheke_DEPENDENCIES = +diatheke_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/corediatheke.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/diafiltmgr.Po ./$(DEPDIR)/diatheke.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/diathekemgr.Po ./$(DEPDIR)/gbfcgi.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/thmlcgi.Po +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXFLAGS = @CXXFLAGS@ +DIST_SOURCES = $(diatheke_SOURCES) +DIST_COMMON = README Makefile.am Makefile.in +SOURCES = $(diatheke_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu apps/console/diatheke/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + p1=`echo "$$p1" | sed -e 's,^.*/,,'`; \ + f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + f=`echo "$$f" | sed -e 's,^.*/,,'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +diatheke$(EXEEXT): $(diatheke_OBJECTS) $(diatheke_DEPENDENCIES) + @rm -f diatheke$(EXEEXT) + $(CXXLINK) $(diatheke_LDFLAGS) $(diatheke_OBJECTS) $(diatheke_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corediatheke.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diafiltmgr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diatheke.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diathekemgr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gbfcgi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thmlcgi.Po@am__quote@ + +distclean-depend: + -rm -rf ./$(DEPDIR) + +.cpp.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + +.cpp.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(CXXCOMPILE) -c -o $@ `cygpath -w $<` + +.cpp.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< +CXXDEPMODE = @CXXDEPMODE@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +.PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-binPROGRAMS install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool tags uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/apps/console/diatheke/cgi/diatheke.pl b/apps/console/diatheke/cgi/diatheke.pl new file mode 100755 index 0000000..1d3de91 --- /dev/null +++ b/apps/console/diatheke/cgi/diatheke.pl @@ -0,0 +1,467 @@ +#!/usr/bin/perl + +# Typical Linux/Unix settings +$err = "2> /dev/null"; +$sword_path = "/home/sword"; # SWORD_PATH environment variable you want to use +$diatheke = "nice /usr/bin/diatheke"; # location of diatheke command line program + +# Typical Windows settings +#$err = ""; +#$sword_path = "C:\\Program Files\\CrossWire\\The SWORD Project"; # SWORD_PATH environment variable you want to use +#$diatheke = "$sword_path\\diatheke.exe"; # location of diatheke command line program + +$cgiurl = "http:\/\/bible.gotjesus.org\/cgi-bin"; + +$scriptname = "diatheke.pl"; +$defaultfontface = "Times New Roman, Times, Roman, serif"; # default font name +$maxverses = 50; # maximum number of verses diatheke will return per query (prevents people from asking for Gen1:1-Rev22:21) +$defaultbook = "KJV"; # book to query when none is selected, but a verse/search is entered +$deflocale = "abbr"; # this is just the default for cases where user has not selected a locale and his browser does not reveal one -- you can also set locale using locale=<locale> in the GET URL + +############################################################################### +## You should not need to edit anything below this line. +## Unless you want to modify functionality of course. :) +############################################################################### + +$version = "4.2"; + +sub plussifyaddress { + ($p_ver = @_[0]) =~ tr/ /+/; + $p_newline = "<a href=\"$scriptname?verse=$p_ver&@_[1]=on\">"; + return $p_newline; +} + +sub urlvers { + $u_verse = @_[0]; + $u_version = @_[1]; + $u_oldverse = $u_verse; + $u_verse =~ tr/ /+/; + $u_newline = "<a href=\"$scriptname?verse=$u_verse&$u_version=on\">$u_oldverse</a>"; + return $u_newline; +} + +$ENV{'SWORD_PATH'} = $sword_path; + +print "Content-type: text/html\n\n"; + + +if ($ENV{'HTTP_COOKIE'}) { + + $cookie = $ENV{'HTTP_COOKIE'}; + $cookie =~ s/\; /=/g; + %cookiedata = split(/=/, $cookie); + + $defversion = $cookiedata{DEFTRANS}; + $locale = $cookiedata{LOCALE}; +} + +if ($defversion eq "") { + $defversion = 'KJV'; +} +if ($locale eq "") { + $locale = $ENV{'HTTP_ACCEPT_LANGUAGE'}; + $locale =~ s/(..).*/$1/; + if ($locale eq "") { + $locale = $deflocale; + } + elsif ($locale eq "en") { + $locale = "abbr"; + } +} + +$hostname = $ENV{'REMOTE_ADDR'}; +@values = split(/\&/,$ENV{'QUERY_STRING'}); +$n = 0; +$palm = 0; + +$latinxlit = ""; + +$optionfilters = ""; +$debug=0; +foreach $i (@values) { + ($varname, $mydata) = split(/=/,$i); + if ($varname ne "Submit" && $varname ne "lookup") { + if ($varname eq "verse") { + $verse = $mydata; + $verse =~ tr/+/ /; + $verse =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + } + elsif ($varname eq "search" && $mydata ne "" && $mydata ne "off") { + $search = "-s $mydata"; + } + + elsif ($varname eq "strongs") { + $optionfilters .= "n"; + } + elsif ($varname eq "footnotes") { + $optionfilters .= "f"; + } + elsif ($varname eq "headings") { + $optionfilters .= "h"; + } + elsif ($varname eq "morph") { + $optionfilters .= "m"; + } + elsif ($varname eq "hebcant") { + $optionfilters .= "c"; + } + elsif ($varname eq "hebvowels") { + $optionfilters .= "v"; + } + elsif ($varname eq "grkacc") { + $optionfilters .= "a"; + } + elsif ($varname eq "lemmas") { + $optionfilters .= "l"; + } + elsif ($varname eq "scriprefs") { + $optionfilters .= "s"; + } + elsif ($varname eq "arshape") { + $optionfilters .= "r"; + } + elsif ($varname eq "bidi") { + $optionfilters .= "b"; + } + + elsif ($varname eq "latinxlit") { + $latinxlit = "-t Latin"; + } + + elsif ($varname eq "palm") { + $palm = 1; + } + elsif ($varname eq "debug") { + $debug = 1; + } + elsif ($varname eq "locale") { + $locale = $mydata; + } + elsif ($varname eq "maxverses") { + $maxverses = $mydata; + } + elsif ($mydata eq "on" || $mydata eq "ON") { + $versions[$n] = $varname; + $n++; + } + } +} +if ($optionfilters ne "") { + $optionfilters = "-o " . $optionfilters; +} + + + +if ($n == 0) { + $versions[0] = $defaultbook; + $n++; +} + +if ($verse eq "") { + + @versionlist = `$diatheke -b system -k modulelist $err`; + @versionlist2 = @versionlist; + @localelist = `$diatheke -b system -k localelist $err`; + + print <<DEF1; +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Diatheke Online Bible</title> +</head> + +<body> + +<form method="get" action="$scriptname"> + <p /><input type="radio" name="search" checked value="" /><font face="Arial, Helvetica, sans-serif">Verse/Commentary Lookup + Verse or Search key:</font><input type="text" name="verse" size="20"><input type="submit" name="Submit" value="Submit"><input type="reset" name="Reset" value="Reset"><br /> + <input type="radio" name="search" value="phrase" /><font face="Arial, Helvetica, sans-serif">Phrase Search</font><br /> + <input type="radio" name="search" value="multiword" /><font face="Arial, Helvetica, sans-serif">Multiple Word Search</font><br /> + <input type="radio" name="search" value="regex" /><font face="Arial, Helvetica, sans-serif">Regular Expression Search</font><br /> + <table width="100%" border="0"> + <tr> + <td width="50%"> + <input type="checkbox" name="strongs" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Strong's Numbers</font></td> + <td width="50%"> + <input type="checkbox" name="headings" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Section Headings</font></td> + </tr> + <tr> + <td width="50%"> + <input type="checkbox" name="footnotes" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Footnotes</font></td> + <td width="50%"> + <input type="checkbox" name="scriprefs" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Scripture Cross-References</font></td> + </tr> + <tr> + <td width="50%"> + <input type="checkbox" name="morph" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Morphology</font></td> + <td width="50%"> + <input type="checkbox" name="hebvowels" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Hebrew Vowels</font></td> + </tr> + <tr> + <td width="50%"> + <input type="checkbox" name="lemmas" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Lemmas</font></td> + <td width="50%"> + <input type="checkbox" name="hebcant" value="on"> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Hebrew Cantillation + Marks </font></td> + </tr> + <tr> + <td width="50%"> + <input type="checkbox" name="latinxlit" value="on"> + <font face="Arial, Helvetica, sans-serif" size="-1">Latin Transliterate</font> + </td> + <td width="50%"> + <input type="checkbox" name="grkacc" value="on" checked> + <font size="-1" face="Arial, Helvetica, sans-serif">Show Greek Accents</font> + </td> + </tr> + </table> + <br /> + <table BORDER="0" WIDTH="100%"> +DEF1 + + foreach $line (@versionlist) { + chomp($line); + + if ($line eq "Biblical Texts:") { + print "<tr><td><font face=$defaultfontface><b>Biblical Texts:</b></font><br /></td></tr>"; + } + elsif ($line eq "Commentaries:") { + print "<tr><td><font face=$defaultfontface><b>Commentaries:</b></font></td></tr>"; + } + elsif ($line eq "Dictionaries:") { + print "<tr><td><font face=$defaultfontface><b>Dictionaries & Lexica:</b></font></td></tr>"; + } + else { + $line =~ s/([^:]+) : (.+)/<tr><td><input type=\"checkbox\" name=\"$1\" value=\"on\"><font size=\"-1\" face=$defaultfontface>$2 ($1)<\/font><\/td><\/tr>/; + print "$line\n"; + } + + } + + print <<DEF2; + </table> +</form> + +<form method="get" action="dia-def.pl"> + Select default Bible version for cross-references: <select name="defversion" size="1"> + +DEF2 + + $biblesflag = 1; + foreach $line (@versionlist2) { + if ($biblesflag == 1) { + chomp ($line); + if ($line eq "Biblical Texts:") { + } + elsif ($line eq "Commentaries:") { + $biblesflag = 0; + } + else { + $line =~ s/([^:]+) : (.+)/<option value=\"$1\">$2 ($1)<\/option>/; + print "$line\n"; + } + } + } + + print <<DEF3; +</select><input type="submit" name="Submit" value="Submit"></form><br/><form method="get" action="dia-def.pl">Select locale: +<select name="locale" size="1"><option value="">browser default</option> +<option value="en">en</option> +DEF3 + foreach $line (@localelist) { + chomp($line); + print "<option value=\"$line\">$line<\/option>"; + } +print <<DEF4 +</select> +<input type="submit" name="Submit" value="Submit"> +</form> +</body> +</html> +DEF4 + +} +else { + + + +if ($palm == 0) { +print <<END; + +<html><head> +<title>Diatheke Interlinear Bible</title> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta name="palmcomputingplatform" content="true"> +<meta name="historylisttext" content="Diatheke"> +<style type="text/css"> +#divBottom{position:absolute; visibility:hidden; font-family:arial,helvetica; height:30; width:100; font-size:10pt; font-weight:bold} +A:link, A:visited, A:active{text-decoration: none} +</style> +<script type="text/javascript" language="JavaScript"> +/******************************************************************************** +Copyright (C) 1999 Thomas Brattli +This script is made by and copyrighted to Thomas Brattli at www.bratta.com +Visit for more great scripts. This may be used freely as long as this msg is intact! +I will also appriciate any links you could give me. +********************************************************************************/ +//Default browsercheck, added to all scripts! +function checkBrowser(){ + this.ver=navigator.appVersion; + this.dom=document.getElementById?1:0; + this.ie5=( (this.ver.indexOf("MSIE 6")>-1 || this.ver.indexOf("MSIE 5")>-1) && this.dom)?1:0; + this.ie4=(document.all && !this.dom)?1:0; + this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; + this.ns4=(document.layers && !this.dom)?1:0; + this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5); + return this; +} +bw=new checkBrowser() +/******************************************************************************** +Remeber to set the look of the divBottom layer in the stylesheet (if you wan't +another font or something) +********************************************************************************/ +/*Set these values, gright for how much from the right you wan't the layer to go +and gbottom for how much from the bottom you want it*/ +var gright=160 +var gbottom=80 + + + +/******************************************************************************** +Constructing the ChangeText object +********************************************************************************/ +function makeObj(obj,nest){ + nest=(!nest) ? '':'document.'+nest+'.'; + this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0; + this.moveIt=b_moveIt; +} +function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y} + +/******************************************************************************** +Initilizing the page, getting height and width to moveto and calls the +object constructor +********************************************************************************/ + function geoInit(){ + oGeo=new makeObj('divBottom'); + pageWidth=(bw.ie4 || bw.ie5)?document.body.offsetWidth-4:innerWidth; + pageHeight=(bw.ie4 || bw.ie5)?document.body.offsetHeight-2:innerHeight; + checkIt(); + // sets the resize handler. + onresize=resized; + if(bw.ie4 || bw.ie5) window.onscroll=checkIt; + // shows the div + oGeo.css.visibility='visible'; + } +/******************************************************************************** +This function executes onscroll in ie and every 30 millisecond in ns +and checks if the user have scrolled, and if it has it moves the layer. +********************************************************************************/ +function checkIt(){ + if(bw.ie4 || bw.ie5) oGeo.moveIt(document.body.scrollLeft +pageWidth-gright,document.body.scrollTop+pageHeight-gbottom); + else if(bw.ns4){ + oGeo.moveIt(window.pageXOffset+pageWidth-gright, window.pageYOffset+pageHeight-gbottom); + setTimeout('checkIt()',30); + } +} + +//Adds a onresize event handler to handle the resizing of the window. +function resized(){ + pageWidth=(bw.ie4 || bw.ie5)?document.body.offsetWidth-4:innerWidth; + pageHeight=(bw.ie4 || bw.ie5)?document.body.offsetHeight-2:innerHeight; + if(bw.ie4 || bw.ie5) checkIt() +} + + +//Calls the geoInit onload +if(bw.bw && !bw.ns5) onload=geoInit; + +//Here we will write the div out so that lower browser won't see it.' +if(bw.bw && !bw.ns5) document.write('<div id="divBottom"><table><tr><td align="center">Powered by<br /><img src="http://www.crosswire.org/sword/pbsword.gif"><br /><a href="http://www.crosswire.org/">www.crosswire.org</td></tr></table></div>') +</script> + +</head> + +<body bgcolor="#FFFFFF"><font face="$defaultfontface"> + +END +} +else { +print <<END + +<html><head> +<title>HANDiatheke</title> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta name="palmcomputingplatform" content="true"> +<meta name="historylisttext" content="HANDiatheke"> +</head> +<body bgcolor="#FFFFFF"><font face="$defaultfontface"> +END +} +for ($i = 0; $i < $n; $i++) { + + $line = "$diatheke $search $optionfilters $latinxlit -l $locale -m $maxverses -f cgi -b $versions[$i] -k \"$verse\" $err"; + + if ($debug) { + print "command line: $line\n<br />"; + } + $line = `$line`; + + chomp($line); + + $line =~ s/!DIATHEKE_URL!/$scriptname\?/g; + +# Parse and link to Strong's references if present + + $info = `$diatheke -b info -k $versions[$i] $err`; + $info =~ /([^\;]+)\;([^\;]+)/; + $format = $1; + $type = $2; + + if ($versions[$i] eq "StrongsHebrew") { + $line =~ s/(see HEBREW for )([0-9]+)/<a href=\"$scriptname?verse=$2&StrongsHebrew=on\">$1$2\<\/a\>/g; + } + elsif($versions[$i] eq "StrongsGreek") { + $line =~ s/(see GREEK for )([0-9]+)/<a href=\"$scriptname?verse=$2&StrongsGreek=on\">$1$2\<\/a\>/g; + } + #case for searches + elsif($search ne "") { + $line =~ s/<entry>([^<]+)<\/entry>/urlvers($1, $versions[$i])/eg; + } + #case for non-ThML, non-Bible texts + elsif($type ne "Biblical Texts") { + $book = $verse; + $book =~ s/^([A-Za-z0-9]+) [0-9]+:[0-9]+.*/$1/; + $chapter = $verse; + $chapter =~ s/[A-Za-z0-9]+ ([0-9]+):[0-9]+.*/$1/; + $line =~ s/\#*([1-9]*[A-Z][a-z]+\.*) ([0-9]+):([0-9]+-*,*[0-9]*)\|*/<a href=\"$scriptname?verse=$1+$2%3A$3&$defversion=on\">$1 $2:$3\<\/a\>/g; + $line =~ s/\#([0-9]+):([0-9]+-*,*[0-9]*)\|*/<a href=\"$scriptname?verse=$book+$1%3A$2&$defversion=on\">$book $1:$2\<\/a\>/g; + $line =~ s/\#([0-9]+-*,*[0-9]*)\|*/<a href=\"$scriptname?verse=$book+$chapter%3A$1&$defversion=on\">$book $chapter:$1\<\/a\>/g; + } + + if ($locale ne "abbr") { + $line =~ s/href=\"$scriptname([^\"]+)\"/href=\"$scriptname$1&locale=$locale\"/g; + } + if ($palm == 1) { + $line =~ s/href=\"$scriptname([^\"]+)\"/href=\"$cgiurl\/$scriptname$1&palm=on\"/g; + } + + print "$line <br /><br />\n"; +} + +if ($palm == 1) { + print "<hr>Powered by Diatheke (http:\/\/www.gotjesus.org\/sword\/diatheke) and the SWORD Project (http:\/\/www.crosswire.org\/sword)."; +} + +print "<br /><br /><br /><br /></font></body></html>"; + +} + + diff --git a/apps/console/diatheke/corediatheke.cpp b/apps/console/diatheke/corediatheke.cpp new file mode 100644 index 0000000..6d091b8 --- /dev/null +++ b/apps/console/diatheke/corediatheke.cpp @@ -0,0 +1,427 @@ +// Diatheke 4.2 by Chris Little <chrislit@crosswire.org> +// Copyright 1999-2002 by CrossWire Bible Society +// http://www.crosswire.org/sword/diatheke +// Licensed under GNU General Public License (GPL) +// see accompanying LICENSE file for license details + +#include "corediatheke.h" +#include <iostream> +#include <string> +#include <list> + +void systemquery(const char * key, ostream* output){ + DiathekeMgr manager; + ModMap::iterator it; + + SWModule *target; + + bool types = false, descriptions = false, names = false; + + if (!stricmp(key, "localelist")) { + static LocaleMgr lm = LocaleMgr::systemLocaleMgr; + list<string> loclist = lm.getAvailableLocales(); + list<string>::iterator li = loclist.begin(); + for (;li != loclist.end(); li++) { + *output << li->c_str() << endl; + } + } + else if (!stricmp(key, "modulelist")) { + types = true; + descriptions = true; + names = true; + } + else if (!stricmp(key, "modulelistnames")) { + names = true; + } + else if (!stricmp(key, "modulelistdescriptions")) { + descriptions = true; + } + + + if (types || descriptions || names) { + if (types) *output << "Biblical Texts:\n"; + for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) { + target = it->second; + if (!strcmp(target->Type(), "Biblical Texts")) { + if (names) *output << target->Name(); + if (names && descriptions) *output << " : "; + if (descriptions) *output << target->Description(); + *output << endl; + } + } + if (types) *output << "Commentaries:\n"; + for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) { + target = it->second; + if (!strcmp(target->Type(), "Commentaries")) { + if (names) *output << target->Name(); + if (names && descriptions) *output << " : "; + if (descriptions) *output << target->Description(); + *output << endl; + } + } + if (types) *output << "Dictionaries:\n"; + for (it = manager.Modules.begin(); it != manager.Modules.end(); it++) { + target = it->second; + if (!strcmp(target->Type(), "Lexicons / Dictionaries")) { + if (names) *output << target->Name(); + if (names && descriptions) *output << " : "; + if (descriptions) *output << target->Description(); + *output << endl; + } + } + } +} + +void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAIN, unsigned char outputencoding = ENC_UTF8, unsigned long optionfilters = 0, unsigned char searchtype = ST_NONE, const char *text = 0, const char *locale = 0, const char *ref = 0, ostream* output = &cout, const char *script = 0, signed short variants = 0) { + static DiathekeMgr manager; + + ModMap::iterator it; + ListKey listkey; + SectionMap::iterator sit; + ConfigEntMap::iterator eit; + + SWModule * target; + char *font = 0; + char inputformat = 0; + string encoding; + char querytype = 0; + + if (locale) { + LocaleMgr::systemLocaleMgr.setDefaultLocaleName(locale); + } + VerseKey vk; + + //deal with queries to "system" + if (!stricmp(text, "system")) { + querytype = QT_SYSTEM; + systemquery(ref, output); + } + if (!strnicmp(text, "info", 4)) { + querytype = QT_INFO; + text = ref; + } + //otherwise, we have a real book + it = manager.Modules.find(text); + if (it == manager.Modules.end()) { //book not found + return; + } + target = (*it).second; + + manager.Markup(outputformat); + manager.Encoding(outputencoding); + manager.bidi = ((OP_BIDI & optionfilters) == OP_BIDI); + manager.shape = ((OP_ARSHAPE & optionfilters) == OP_ARSHAPE); + + if ((sit = manager.config->Sections.find((*it).second->Name())) != manager.config->Sections.end()) { + if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) { + if (!stricmp((char *)(*eit).second.c_str(), "GBF")) + inputformat = FMT_GBF; + else if (!stricmp((char *)(*eit).second.c_str(), "ThML")) + inputformat = FMT_THML; + } + encoding = ((eit = (*sit).second.find("Encoding")) != (*sit).second.end()) ? (*eit).second : (string)""; + } + + + if (querytype == QT_INFO) { + switch (inputformat) { + case FMT_THML : + *output << "ThML"; + break; + case FMT_GBF : + *output << "GBF"; + break; + default: + *output << "Other"; + } + *output << ";"; + *output << target->Type(); + *output << ";"; + return; + } + + if (searchtype) + querytype = QT_SEARCH; + else if (!strcmp(target->Type(), "Biblical Texts")) + querytype = QT_BIBLE; + else if (!strcmp(target->Type(), "Commentaries")) + querytype = QT_COMM; + else if (!strcmp(target->Type(), "Lexicons / Dictionaries")) + querytype = QT_LD; + + if (optionfilters & OP_FOOTNOTES) + manager.setGlobalOption("Footnotes","On"); + else + manager.setGlobalOption("Footnotes","Off"); + if (optionfilters & OP_HEADINGS) + manager.setGlobalOption("Headings","On"); + else + manager.setGlobalOption("Headings","Off"); + if (optionfilters & OP_STRONGS) + manager.setGlobalOption("Strong's Numbers","On"); + else + manager.setGlobalOption("Strong's Numbers","Off"); + if (optionfilters & OP_MORPH) + manager.setGlobalOption("Morphological Tags","On"); + else + manager.setGlobalOption("Morphological Tags","Off"); + if (optionfilters & OP_CANTILLATION) + manager.setGlobalOption("Hebrew Cantillation","On"); + else + manager.setGlobalOption("Hebrew Cantillation","Off"); + if (optionfilters & OP_HEBREWPOINTS) + manager.setGlobalOption("Hebrew Vowel Points","On"); + else + manager.setGlobalOption("Hebrew Vowel Points","Off"); + if (optionfilters & OP_GREEKACCENTS) + manager.setGlobalOption("Greek Accents","On"); + else + manager.setGlobalOption("Greek Accents","Off"); + if (optionfilters & OP_LEMMAS) + manager.setGlobalOption("Lemmas","On"); + else + manager.setGlobalOption("Lemmas","Off"); + if (optionfilters & OP_SCRIPREF) + manager.setGlobalOption("Scripture Cross-References","On"); + else + manager.setGlobalOption("Scripture Cross-References","Off"); + + if (optionfilters & OP_VARIANTS && variants) { + if (variants == -1) + manager.setGlobalOption("Variants", "All Readings"); + else if (variants == 1) + manager.setGlobalOption("Variants", "Secondary Readings"); + } + else + manager.setGlobalOption("Transliteration", "Primary Readings"); + +#ifdef _ICU_ + if (optionfilters & OP_TRANSLITERATOR && script) + manager.setGlobalOption("Transliteration", script); + else + manager.setGlobalOption("Transliteration", "Off"); +#endif + + if (querytype == QT_SEARCH) { + + //this test is just to determine if we've got SWKeys or VerseKeys + if (!strcmp(target->Type(), "Biblical Texts")) + querytype = QT_BIBLE; + else if (!strcmp(target->Type(), "Commentaries")) + querytype = QT_BIBLE; + else if (!strcmp(target->Type(), "Lexicons / Dictionaries")) + querytype = QT_LD; + + //do search stuff + searchtype = 1 - searchtype; + if (querytype == QT_BIBLE) { + *output << "Verses containing \""; + } + else *output << "Entries containing \""; + *output << ref; + *output << "\"-- "; + + listkey = target->Search(ref, searchtype); + + if (strlen((const char*)listkey)) { + if (!listkey.Error()) { + if (outputformat == FMT_CGI) *output << "<entry>"; + if (querytype == QT_BIBLE) { + vk = listkey; + *output << (const char *)vk; + } + else *output << (const char *)listkey; + if (outputformat == FMT_CGI) *output << "</entry>"; + } + listkey++; + while (!listkey.Error()) { + *output << " ; "; + if (outputformat == FMT_CGI) *output << "<entry>"; + if (querytype == QT_BIBLE) { + vk = listkey; + *output << (const char *)vk; + } + else *output << (const char *)listkey; + if (outputformat == FMT_CGI) *output << "</entry>"; + listkey++; + } + *output << " -- "; + + char *temp = new char[10]; + sprintf(temp, "%u", listkey.Count()); + *output << temp; + delete [] temp; + + *output << " matches total ("; + *output << target->Name(); + *output << ")\n"; + } + else { + *output << "none ("; + *output << target->Name(); + *output << ")\n"; + } + } + + else if (querytype == QT_LD) { + //do dictionary stuff + + target->SetKey(ref); + + const char * text = (const char *) *target; + + if (outputformat == FMT_RTF) { + *output << "{\\rtf1\\ansi{\\fonttbl{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}{\\f1\\fdecor\\fprq2 "; + if (font) + *output << font; + else + *output << "Times New Roman"; + *output << ";}}"; + } + else if (outputformat == FMT_HTML) { + *output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"; + } + + if (strlen(text)) { + *output << (char*)target->KeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": <font face=\""; + *output << font; + *output << "\">"; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } + *output << text; + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << "</font>"; + } + else if (outputformat == FMT_RTF) { + *output << "}"; + } + + *output << "("; + *output << target->Name(); + *output << ")\n"; + } + + if (outputformat == FMT_RTF) { + *output << "}"; + } + + } + + else if (querytype == QT_BIBLE || querytype == QT_COMM) { + //do commentary/Bible stuff + + if ((sit = manager.config->Sections.find((*it).second->Name())) != manager.config->Sections.end()) { + if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) { + font = (char *)(*eit).second.c_str(); + if (strlen(font) == 0) font = 0; + } + } + + listkey = vk.ParseVerseList(ref, "Gen1:1", true); + int i; + + if (outputformat == FMT_RTF) { + *output << "{\\rtf1\\ansi{\\fonttbl{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}{\\f1\\fdecor\\fprq2 "; + if (font) + *output << font; + else + *output << "Times New Roman"; + *output << ";}{\\f7\\froman\\fcharset2\\fprq2 Symbol;}}"; + } + else if (outputformat == FMT_HTML) { + *output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"; + } + + for (i = 0; i < listkey.Count() && maxverses; i++) { + VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i)); + if (element) { + target->Key(element->LowerBound()); + vk = element->UpperBound(); + while (maxverses && target->Key() <= vk) { + *output << (char*)target->KeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": <font face=\""; + *output << font; + *output << "\">"; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } + *output << (const char*)*target; + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << "</font>"; + } + else if (outputformat == FMT_RTF) { + *output << "}"; + } + + if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) + *output << "<br />"; + else if (outputformat == FMT_RTF) + *output << "\\par "; + else if (outputformat == FMT_GBF) + *output << "<CM>"; + + *output << "\n"; + + if (target->Key() == vk) + break; + maxverses--; + (*target)++; + } + } + else { + target->Key(*listkey.GetElement(i)); + *output << (char*)target->KeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": <font face=\""; + *output << font; + *output << "\">"; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } + *output << (const char*)*target; + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << "</font>"; + } + else if (outputformat == FMT_RTF) { + *output << "}"; + } + + if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) + *output << "<br />"; + else if (outputformat == FMT_RTF) + *output << "\\par "; + else if (outputformat == FMT_GBF) + *output << "<CM>"; + + *output << "\n"; + maxverses--; + } + } + + *output << "("; + *output << target->Name(); + *output << ")\n"; + + if (outputformat == FMT_RTF) { + *output << "}"; + } + + } +} + diff --git a/apps/console/diatheke/corediatheke.h b/apps/console/diatheke/corediatheke.h new file mode 100644 index 0000000..b265053 --- /dev/null +++ b/apps/console/diatheke/corediatheke.h @@ -0,0 +1,39 @@ +// Diatheke 4.2 by Chris Little <chrislit@crosswire.org> +// Copyright 1999-2002 by CrossWire Bible Society http://www.crosswire.org +// Licensed under GNU General Public License (GPL) +// see accompanying LICENSE file for license details + +#include <stdio.h> + +#include "diathekemgr.h" +#include <localemgr.h> + +#define QT_BIBLE 1 +#define QT_COMM 2 +#define QT_LD 3 +#define QT_SEARCH 4 +#define QT_SYSTEM 5 +#define QT_INFO 6 + +#define OP_NONE 0 +#define OP_STRONGS 1 +#define OP_FOOTNOTES 2 +#define OP_HEADINGS 4 +#define OP_MORPH 8 +#define OP_CANTILLATION 16 +#define OP_HEBREWPOINTS 32 +#define OP_GREEKACCENTS 64 +#define OP_TRANSLITERATOR 128 +#define OP_LEMMAS 256 +#define OP_SCRIPREF 512 +#define OP_ARSHAPE 1024 +#define OP_BIDI 2048 +#define OP_VARIANTS 4096 + +#define ST_NONE 0 +#define ST_REGEX 1 //0 +#define ST_PHRASE 2 // -1 +#define ST_MULTIWORD 3 // -2 + +int hasalpha (char * string); +void doquery(unsigned long maxverses, unsigned char outputformat, unsigned char outputencoding, unsigned long optionfilters, unsigned char searchtype, const char *text, const char *locale, const char *ref, ostream* output, const char* script, signed short variants); diff --git a/apps/console/diatheke/diafiltmgr.h b/apps/console/diatheke/diafiltmgr.h new file mode 100644 index 0000000..cb04fff --- /dev/null +++ b/apps/console/diatheke/diafiltmgr.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * diafiltmgr.h + * + * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) + * CrossWire Bible Society + * P. O. Box 2528 + * Tempe, AZ 85280-2528 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#ifndef DIAFILTMGR_H +#define DIAFILTMGR_H + +#define FMT_CGI 127 + +#include <encfiltmgr.h> + +class SWDLLEXPORT DiathekeFilterMgr : public EncodingFilterMgr { +protected: + SWFilter* fromthml; + SWFilter* fromgbf; + SWFilter* fromplain; + SWFilter* fromosis; + + char markup; + + void CreateFilters(char markup); +public: + DiathekeFilterMgr(char markup = FMT_THML, char encoding = ENC_UTF8); + ~DiathekeFilterMgr(); + char Markup(char m = FMT_UNKNOWN); + virtual void AddRenderFilters(SWModule *module, ConfigEntMap §ion); +}; + +#endif diff --git a/apps/console/diatheke/diatheke.cpp b/apps/console/diatheke/diatheke.cpp new file mode 100644 index 0000000..f423e6b --- /dev/null +++ b/apps/console/diatheke/diatheke.cpp @@ -0,0 +1,213 @@ +// Diatheke 4.2 by Chris Little <chrislit@crosswire.org> +// Copyright 1999-2002 by CrossWire Bible Society +// http://www.crosswire.org/sword/diatheke +// Licensed under GNU General Public License (GPL) +// see accompanying LICENSE file for license details + +#include "corediatheke.h" +#include "diathekemgr.h" +#include "diafiltmgr.h" +#include <iostream> + +#define RQ_REF 1 +#define RQ_BOOK 2 + +void printsyntax() { + //if we got this far without exiting, something went wrong, so print syntax + fprintf (stderr, "Diatheke command-line SWORD frontend Version 4.2\n"); + fprintf (stderr, "Copyright 1999-2002 by the CrossWire Bible Society\n"); + fprintf (stderr, "http://www.crosswire.org/sword/diatheke/\n"); + fprintf (stderr, "usage: \n "); + fprintf (stderr, "diatheke <-b book> [-s search_type] [-o option_filters]\n"); + fprintf (stderr, "[-m maximum_verses] [-f output_format] [-l locale]\n"); + fprintf (stderr, "[-e output_encoding] [-t script] [-v variant#(-1=all|0|1)]\n"); + fprintf (stderr, "<-k query_key>\n"); + fprintf (stderr, "\n"); + fprintf (stderr, "If <book> is \"system\" you may use these system keys: \"modulelist\",\n"); + fprintf (stderr, "\"modulelistnames\", and \"localelist\"."); + fprintf (stderr, "\n"); + fprintf (stderr, "Valid search_type values are: regex, multiword, and phrase(def).\n"); + fprintf (stderr, "Valid option_filters values are: n (Strong's numbers),\n"); + fprintf (stderr, " f (Footnotes), m (Morphology), h (Section Headings),\n"); + fprintf (stderr, " c (Cantillation), v (Hebrew Vowels), a (Greek Accents),\n"); + fprintf (stderr, " l (Lemmas), s (Scripture Crossrefs), r (Arabic Shaping,\n"); + fprintf (stderr, " b (Bi-Directional Reordering)\n"); + + fprintf (stderr, "Maximum verses may be any integer value\n"); + fprintf (stderr, "Valid output_format values are: GBF, ThML, RTF, HTML, OSIS, CGI, and plain (def)\n"); + fprintf (stderr, "Valid output_encoding values are: Latin1, UTF8 (def), UTF16, HTML, and RTF\n"); + fprintf (stderr, "Valid locale values depend on installed locales. en is default.\n"); + fprintf (stderr, "The query_key must be the last argument because all following\n"); + fprintf (stderr, " arguments are added to the key.\n"); +} + +int main(int argc, char **argv) +{ + int maxverses = -1; + unsigned char outputformat = FMT_PLAIN, searchtype = ST_NONE, outputencoding = ENC_UTF8; + unsigned long optionfilters = OP_NONE; + char *text = 0, *locale = 0, *ref = 0, *script = 0; + signed short variants = 0; + + char runquery = 0; // used to check that we have enough arguments to perform a legal query + // (a querytype & text = 1 and a ref = 2) + + for (int i = 1; i < argc; i++) { + if (!stricmp("-b", argv[i])) { + if (i+1 <= argc) { + text = argv[i+1]; + i++; + runquery |= RQ_BOOK; + } + } + else if (!stricmp("-s", argv[i])) { + if (i+1 <= argc) { + if (!stricmp("phrase", argv[i+1])) { + searchtype = ST_PHRASE; + i++; + } + else if (!stricmp("regex", argv[i+1])) { + searchtype = ST_REGEX; + i++; + } + else if (!stricmp("multiword", argv[i+1])) { + searchtype = ST_MULTIWORD; + i++; + } + else i++; + } + } + else if (!stricmp("-l", argv[i])) { + if (i+1 <= argc) { + locale = argv[i+1]; + i++; + } + } + else if (!stricmp("-m", argv[i])) { + if (i+1 <= argc) { + maxverses = atoi(argv[i+1]); + i++; + } + } + else if (!stricmp("-o", argv[i])) { + if (i+1 <= argc) { + if (strchr(argv[i+1], 'f')) + optionfilters |= OP_FOOTNOTES; + if (strchr(argv[i+1], 'n')) + optionfilters |= OP_STRONGS; + if (strchr(argv[i+1], 'h')) + optionfilters |= OP_HEADINGS; + if (strchr(argv[i+1], 'm')) + optionfilters |= OP_MORPH; + if (strchr(argv[i+1], 'c')) + optionfilters |= OP_CANTILLATION; + if (strchr(argv[i+1], 'v')) + optionfilters |= OP_HEBREWPOINTS; + if (strchr(argv[i+1], 'a')) + optionfilters |= OP_GREEKACCENTS; + if (strchr(argv[i+1], 'l')) + optionfilters |= OP_LEMMAS; + if (strchr(argv[i+1], 's')) + optionfilters |= OP_SCRIPREF; + if (strchr(argv[i+1], 'r')) + optionfilters |= OP_ARSHAPE; + if (strchr(argv[i+1], 'b')) + optionfilters |= OP_BIDI; + i++; + } + } + else if (!stricmp("-f", argv[i])) { + if (i+1 <= argc) { + if (!stricmp("thml", argv[i+1])) { + outputformat = FMT_THML; + i++; + } + else if (!stricmp("cgi", argv[i+1])) { + outputformat = FMT_CGI; + i++; + } + else if (!stricmp("gbf", argv[i+1])) { + outputformat = FMT_GBF; + i++; + } + else if (!stricmp("html", argv[i+1])) { + outputformat = FMT_HTML; + i++; + } + else if (!stricmp("rtf", argv[i+1])) { + outputformat = FMT_RTF; + i++; + } + else if (!stricmp("osis", argv[i+1])) { + outputformat = FMT_OSIS; + i++; + } + else i++; + } + } + else if (!stricmp("-e", argv[i])) { + if (i+1 <= argc) { + if (!stricmp("utf8", argv[i+1])) { + outputencoding = ENC_UTF8; + i++; + } + else if (!stricmp("rtf", argv[i+1])) { + outputencoding = ENC_RTF; + i++; + } + else if (!stricmp("html", argv[i+1])) { + outputencoding = ENC_HTML; + i++; + } + else if (!stricmp("latin1", argv[i+1])) { + outputencoding = ENC_LATIN1; + i++; + } + else if (!stricmp("utf16", argv[i+1])) { + outputencoding = ENC_UTF16; + i++; + } + else i++; + } + } + else if (!stricmp("-k", argv[i])) { + i++; + if (i < argc) { + string key = argv[i]; + i++; + for (; i < argc; i++) + key = key + " " + argv[i]; + ref = new char[key.length() + 1]; + strcpy (ref, key.c_str()); + if (strlen(ref)) + runquery |= RQ_REF; + } + } + else if (!stricmp("-v", argv[i])) { + if (i+1 <= argc) { + variants = atoi(argv[i+1]); + optionfilters |= OP_VARIANTS; + i++; + } + } +#ifdef _ICU_ + else if (!stricmp("-t", argv[i])) { + if (i+1 <= argc) { + script = argv[i+1]; + optionfilters |= OP_TRANSLITERATOR; + i++; + } + } +#endif + } + + + if (runquery == (RQ_BOOK | RQ_REF)) + { + doquery(maxverses, outputformat, outputencoding, optionfilters, searchtype, text, locale, ref, &cout, script, variants); + } + else + printsyntax(); + + return 0; +} diff --git a/apps/console/diatheke/diathekemgr.cpp b/apps/console/diatheke/diathekemgr.cpp new file mode 100644 index 0000000..87f9102 --- /dev/null +++ b/apps/console/diatheke/diathekemgr.cpp @@ -0,0 +1,107 @@ +//--------------------------------------------------------------------------- +#include <thmlplain.h> +#include <gbfplain.h> +#include <thmlgbf.h> +#include <gbfthml.h> +#include <thmlhtml.h> +#include <gbfhtml.h> +#include <plainhtml.h> +#include <thmlhtmlhref.h> +#include <gbfhtmlhref.h> +#include <thmlrtf.h> +#include <gbfrtf.h> + +#include <swconfig.h> +#include "diafiltmgr.h" + +#ifdef _ICU_ +#include <utf8arshaping.h> +#include <utf8bidireorder.h> +#include <utf8transliterator.h> +#endif + +#ifdef WIN32 +#include <windows.h> +#endif + +#include "diathekemgr.h" +#include "gbfcgi.h" +#include "thmlcgi.h" + +//--------------------------------------------------------------------------- +DiathekeMgr::DiathekeMgr (SWConfig * iconfig, SWConfig * isysconfig, bool autoload, char enc, char mark, bool ibidi, bool ishape) + : SWMgr(iconfig, isysconfig, autoload, new DiathekeFilterMgr(mark, enc)) +{ + bidi = ibidi; + shape = ishape; + +#ifdef _ICU_ + arshaping = new UTF8arShaping(); + bidireorder = new UTF8BiDiReorder(); + transliterator = new UTF8Transliterator(); +#endif + Load(); + +#ifdef WIN32 + OSVERSIONINFO osvi; + memset (&osvi, 0, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + platformID = osvi.dwPlatformId; +#endif + +} + + +DiathekeMgr::~DiathekeMgr() +{ +#ifdef _ICU_ + if (arshaping) + delete arshaping; + if (bidireorder) + delete bidireorder; + if (transliterator) + delete transliterator; +#endif +} + + +void DiathekeMgr::AddRenderFilters(SWModule *module, ConfigEntMap §ion) +{ + string lang; + bool rtl; + ConfigEntMap::iterator entry; + + lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (string)"en"; + rtl = ((entry = section.find("Direction")) != section.end()) ? ((*entry).second == "RtoL") : false; + +#ifdef _ICU_ + if (shape && !strnicmp(lang.c_str(), "ar", 2)) { + module->AddRenderFilter(arshaping); + } + if (bidi && rtl) { + module->AddRenderFilter(bidireorder); + } +#endif + SWMgr::AddRenderFilters(module, section); +} + +signed char DiathekeMgr::Load () { + signed char retval = SWMgr::Load(); +#ifdef _ICU_ + optionFilters.insert(FilterMap::value_type("UTF8Transliterator", transliterator)); + options.push_back(transliterator->getOptionName()); +#endif + return retval; +}; + +void DiathekeMgr::AddGlobalOptions (SWModule * module, ConfigEntMap & section, + ConfigEntMap::iterator start, + ConfigEntMap::iterator end) { + + SWMgr::AddGlobalOptions(module, section, start, end); +#ifdef _ICU_ + module->AddOptionFilter(transliterator); +#endif +}; + diff --git a/apps/console/diatheke/gbfcgi.cpp b/apps/console/diatheke/gbfcgi.cpp new file mode 100644 index 0000000..1bcd176 --- /dev/null +++ b/apps/console/diatheke/gbfcgi.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + gbfcgi.cpp - GBF to Diatheke/CGI format + ------------------- + begin : 2001-11-12 + copyright : 2001 by CrossWire Bible Society + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include "gbfcgi.h" + +GBFCGI::GBFCGI() { + setTokenStart("<"); + setTokenEnd(">"); + + setTokenCaseSensitive(true); + + addTokenSubstitute("Rf", ")</small></font>"); + addTokenSubstitute("FI", "<i>"); // italics begin + addTokenSubstitute("Fi", "</i>"); + addTokenSubstitute("FB", "<n>"); // bold begin + addTokenSubstitute("Fb", "</n>"); + addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin + addTokenSubstitute("Fr", "</font>"); + addTokenSubstitute("FU", "<u>"); // underline begin + addTokenSubstitute("Fu", "</u>"); + addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin + addTokenSubstitute("Fo", "</cite>"); + addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin + addTokenSubstitute("Fs", "</sup>"); + addTokenSubstitute("FV", "<sub>"); // Subscript begin + addTokenSubstitute("Fv", "</sub>"); + addTokenSubstitute("TT", "<big>"); // Book title begin + addTokenSubstitute("Tt", "</big>"); + addTokenSubstitute("PP", "<cite>"); // poetry begin + addTokenSubstitute("Pp", "</cite>"); + addTokenSubstitute("Fn", "</font>"); // font end + addTokenSubstitute("CL", "<br />"); // new line + addTokenSubstitute("CM", "<br />"); // paragraph + addTokenSubstitute("CG", ">"); // ??? + addTokenSubstitute("CT", "<"); // ??? + addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin + addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin + addTokenSubstitute("JL", "</div>"); // align end + +} + + +bool GBFCGI::handleToken(char **buf, const char *token, DualStringMap &userData) { + unsigned long i; + if (!substituteToken(buf, token)) { + if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers + pushString(buf, " <small><em><<a href=\"!DIATHEKE_URL!"); + if (token[1] == 'H') { + pushString(buf, "BDB"); + } + else if (token[1] == 'G') { + pushString(buf, "Thayer"); + } + pushString(buf, "=on&verse="); + for (i = 2; i < strlen(token); i++) + *(*buf)++ = token[i]; + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + for (i = 2; i < strlen(token); i++) + *(*buf)++ = token[i]; + pushString(buf, "</a>></em></small>"); + } + + else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense + pushString(buf, " <small><em><<a href=\"!DIATHEKE_URL!"); + if (token[2] == 'H') { + pushString(buf, "BDB"); + } + else if (token[2] == 'G') { + pushString(buf, "Thayer"); + } + pushString(buf, "=on&verse="); + for (i = 3; i < strlen(token); i++) + *(*buf)++ = token[i]; + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + for (i = 3; i < strlen(token); i++) + *(*buf)++ = token[i]; + pushString(buf, "</a>></em></small>"); + } + + else if (!strncmp(token, "WT", 2)) { // morph tags + pushString(buf, " <small><em>(<a href=\"!DIATHEKE_URL!Packard=on&verse="); + for (i = 1; i < strlen(token); i++) + *(*buf)++ = token[i]; + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + for (i = 1; i < strlen(token); i++) + *(*buf)++ = token[i]; + pushString(buf, "</a>)</em></small>"); + } + + else if (!strncmp(token, "RB", 2)) { + pushString(buf, "<i>"); + userData["hasFootnotePreTag"] = "true"; + } + + else if (!strncmp(token, "RF", 2)) { + if(userData["hasFootnotePreTag"] == "true") { + userData["hasFootnotePreTag"] = "false"; + pushString(buf, "</i> "); + } + pushString(buf, "<font color=\"#800000\"><small> ("); + } + + else if (!strncmp(token, "FN", 2)) { + pushString(buf, "<font face=\""); + for (i = 2; i < strlen(token); i++) + *(*buf)++ = token[i]; + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + } + + else if (!strncmp(token, "CA", 2)) { // ASCII value + *(*buf)++ = (char)atoi(&token[2]); + } + + else { + return false; + } + } + return true; +} diff --git a/apps/console/diatheke/gbfcgi.h b/apps/console/diatheke/gbfcgi.h new file mode 100644 index 0000000..51b0d6c --- /dev/null +++ b/apps/console/diatheke/gbfcgi.h @@ -0,0 +1,33 @@ +/*-************************************************************************* + gbfcgi.h - description + ------------------- + begin : 2001-11-12 + copyright : 2001 by CrossWire Bible Society + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef GBFCGI_H +#define GBFCGI_H + +#include <swbasicfilter.h> + +#include <defs.h> + +/** this filter converts GBF text to Diatheke/CGI format + */ +class SWDLLEXPORT GBFCGI : public SWBasicFilter { +protected: + virtual bool handleToken(char **buf, const char *token, DualStringMap &userData); +public: + GBFCGI (); +}; + +#endif diff --git a/apps/console/diatheke/thmlcgi.cpp b/apps/console/diatheke/thmlcgi.cpp new file mode 100644 index 0000000..2bb7720 --- /dev/null +++ b/apps/console/diatheke/thmlcgi.cpp @@ -0,0 +1,192 @@ +/*************************************************************************** + thmlcgi.cpp - ThML to Diatheke/CGI format + ------------------- + begin : 2001-11-12 + copyright : 2001 by CrossWire Bible Society + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <stdlib.h> +#include <string.h> +#include "thmlcgi.h" + +ThMLCGI::ThMLCGI() { + setTokenStart("<"); + setTokenEnd(">"); + + setTokenCaseSensitive(true); + + addTokenSubstitute("note", " <font color=\"#008000\"><small>("); + addTokenSubstitute("/note", ")</small></font> "); +} + + +bool ThMLCGI::handleToken(char **buf, const char *token, DualStringMap &userData) { + unsigned long i; + if (!substituteToken(buf, token)) { + // manually process if it wasn't a simple substitution + if (!strncmp(token, "sync ", 5)) { + pushString(buf, "<a href=\"!DIATHEKE_URL!"); + char* pbuf; + char typ[32]; typ[0] = 0; + char val[32]; val[0] = 0; + char cls[32]; cls[0] = 0; + for (unsigned int j = 5; j < strlen(token); j++) { + if (!strncmp(token+j, "type=\"", 6)) { + pbuf = typ; + j += 6; + for (;token[j] != '\"'; j++) + *(pbuf)++ = token[j]; + *(pbuf) = 0; + } + else if (!strncmp(token+j, "value=\"", 7)) { + pbuf = val; + j += 7; + for (;token[j] != '\"'; j++) + *(pbuf)++ = token[j]; + *(pbuf) = 0; + } + else if (!strncmp(token+j, "class=\"", 7)) { + pbuf = cls; + j += 7; + for (;token[j] != '\"'; j++) + *(pbuf)++ = token[j]; + *(pbuf) = 0; + } + } + if (*cls && *val) { + pushString(buf, "%s=on&verse=%s", cls, val); + } + else if (*typ && *val) { + if (!strnicmp(typ, "Strongs", 7)) { + if (*val == 'G') { + pushString(buf, "Thayer=on&verse=%s", val + 1); + } + else if (*val == 'H') { + pushString(buf, "BDB=on&verse=%s", val + 1); + } + } + + else if (!strnicmp(typ, "Morph", 5)) { + if (*val == 'G') { + pushString(buf, "Thayer=on&verse=%s", val + 1); + } + else if (*val == 'H') { + pushString(buf, "BDB=on&verse=%s", val + 1); + } + else { + pushString(buf, "Packard=on&verse=%s", val); + } + } + else { + pushString(buf, "%s=on&verse=%s", typ, val); + } + } + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + + if (*val) { + pushString(buf, val); + } + pushString(buf, "</a>"); + } + + else if (!strncmp(token, "scripRef p", 10) || !strncmp(token, "scripRef v", 10)) { + userData["inscriptRef"] = "true"; + pushString(buf, "<a href=\"!DIATHEKE_URL!"); + for (i = 9; i < strlen(token); i++) { + if (!strncmp(token+i, "version=\"", 9)) { + i += 9; + for (;token[i] != '\"'; i++) + *(*buf)++ = token[i]; + pushString(buf, "=on&"); + } + if (!strncmp(token+i, "passage=\"", 9)) { + i += 9; + pushString(buf, "verse="); + for (;token[i] != '\"'; i++) { + if (token[i] == ' ') *(*buf)++ = '+'; + else *(*buf)++ = token[i]; + } + *(*buf)++ = '&'; + } + } + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + } + + // we're starting a scripRef like "<scripRef>John 3:16</scripRef>" + else if (!strcmp(token, "scripRef")) { + userData["inscriptRef"] = "false"; + // let's stop text from going to output + userData["suspendTextPassThru"] = "true"; + } + + // we've ended a scripRef + else if (!strcmp(token, "/scripRef")) { + if (userData["inscriptRef"] == "true") { // like "<scripRef passage="John 3:16">John 3:16</scripRef>" + userData["inscriptRef"] = "false"; + pushString(buf, "</a>"); + } + + else { // like "<scripRef>John 3:16</scripRef>" + pushString(buf, "<a href=\"!DIATHEKE_URL!verse="); + + char* vref = (char*)userData["lastTextNode"].c_str(); + while (*vref) { + if (*vref == ' ') *(*buf)++ = '+'; + else *(*buf)++ = *vref; + vref++; + } + *(*buf)++ = '\"'; + *(*buf)++ = '>'; + pushString(buf, userData["lastTextNode"].c_str()); + // let's let text resume to output again + userData["suspendTextPassThru"] = "false"; + pushString(buf, "</a>"); + } + } + + else if (!strncmp(token, "div class=\"sechead\"", 19)) { + userData["SecHead"] = "true"; + pushString(buf, "<br /><b><i>"); + } + else if (!strncmp(token, "div class=\"title\"", 19)) { + userData["SecHead"] = "true"; + pushString(buf, "<br /><b><i>"); + } + else if (!strncmp(token, "/div", 4)) { + if (userData["SecHead"] == "true") { + pushString(buf, "</i></b><br />"); + userData["SecHead"] = "false"; + } + } + + else if(!strncmp(token, "note", 4)) { + pushString(buf, " <small><font color=\"#008000\">{"); + } + + else { + *(*buf)++ = '<'; + for (i = 0; i < strlen(token); i++) + *(*buf)++ = token[i]; + *(*buf)++ = '>'; + //return false; // we still didn't handle token + } + } + return true; +} + + + + + + diff --git a/apps/console/diatheke/thmlcgi.h b/apps/console/diatheke/thmlcgi.h new file mode 100644 index 0000000..c164f0d --- /dev/null +++ b/apps/console/diatheke/thmlcgi.h @@ -0,0 +1,33 @@ +/*************************************************************************** + thmlcgi.h - description + ------------------- + begin : 2001-11-12 + copyright : 2001 by CrossWire Bible Society + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef THMLCGI_H +#define THMLCGI_H + +#include <swbasicfilter.h> + +#include <defs.h> + +/** this filter converts ThML text to Diatheke/CGI format + */ +class SWDLLEXPORT ThMLCGI : public SWBasicFilter { +protected: + virtual bool handleToken(char **buf, const char *token, DualStringMap &userData); +public: + ThMLCGI(); +}; + +#endif |