From d17988855a2e85dc2db641d11ce481c266038ef3 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 2 Feb 2006 18:57:10 +0000 Subject: [PATCH] reorganization continues ... --- DEVEL/.cvsignore | 7 + DEVEL/gdome_xslt/.cvsignore | 14 + DEVEL/gdome_xslt/AUTHORS | 3 + DEVEL/gdome_xslt/BUGS | 0 DEVEL/gdome_xslt/C++/.cvsignore | 2 + DEVEL/gdome_xslt/C++/Makefile.am | 1 + DEVEL/gdome_xslt/C++/gdome_xslt/.cvsignore | 3 + .../C++/gdome_xslt/GdomeSmartDOMXSLT.hh | 7 + .../gdome_xslt/GdomeSmartDOMXSLTStylesheet.cc | 131 ++ .../gdome_xslt/GdomeSmartDOMXSLTStylesheet.hh | 59 + DEVEL/gdome_xslt/C++/gdome_xslt/Makefile.am | 19 + DEVEL/gdome_xslt/C++/test/.cvsignore | 3 + DEVEL/gdome_xslt/C++/test/Makefile.am | 18 + DEVEL/gdome_xslt/C++/test/main.cc | 53 + DEVEL/gdome_xslt/C/.cvsignore | 2 + DEVEL/gdome_xslt/C/Makefile.am | 3 + DEVEL/gdome_xslt/C/gdome_xslt/.cvsignore | 4 + DEVEL/gdome_xslt/C/gdome_xslt/Makefile.am | 14 + DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.c | 239 ++ DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.h | 87 + DEVEL/gdome_xslt/C/test/.cvsignore | 4 + DEVEL/gdome_xslt/C/test/Makefile.am | 17 + DEVEL/gdome_xslt/C/test/test.c | 106 + DEVEL/gdome_xslt/ChangeLog | 0 DEVEL/gdome_xslt/LICENSE | 510 +++++ DEVEL/gdome_xslt/LICENSE-INRIA | 13 + DEVEL/gdome_xslt/Makefile.am | 16 + DEVEL/gdome_xslt/NEWS | 0 DEVEL/gdome_xslt/README | 0 DEVEL/gdome_xslt/configure.ac | 107 + DEVEL/gdome_xslt/debian/changelog | 227 ++ DEVEL/gdome_xslt/debian/compat | 1 + DEVEL/gdome_xslt/debian/control | 58 + DEVEL/gdome_xslt/debian/control.in | 58 + DEVEL/gdome_xslt/debian/copyright | 18 + DEVEL/gdome_xslt/debian/docs | 0 .../debian/libgdome2-xslt-dev.examples | 2 + .../debian/libgdome2-xslt-dev.install | 5 + .../debian/libgdome2-xslt-ocaml-dev.dirs | 1 + .../debian/libgdome2-xslt-ocaml-dev.dirs.in | 1 + .../debian/libgdome2-xslt-ocaml-dev.examples | 3 + .../debian/libgdome2-xslt-ocaml-dev.install | 3 + .../libgdome2-xslt-ocaml-dev.install.in | 3 + .../debian/libgdome2-xslt-ocaml.dirs | 1 + .../debian/libgdome2-xslt-ocaml.dirs.in | 1 + .../debian/libgdome2-xslt-ocaml.install | 1 + .../debian/libgdome2-xslt-ocaml.install.in | 1 + .../debian/libgdome2-xslt0c2a.install | 1 + DEVEL/gdome_xslt/debian/rules | 10 + DEVEL/gdome_xslt/gdome2-xslt-cpp-smart.pc.in | 14 + DEVEL/gdome_xslt/gdome2-xslt.pc.in | 14 + DEVEL/gdome_xslt/ocaml/.cvsignore | 2 + DEVEL/gdome_xslt/ocaml/Makefile.am | 1 + DEVEL/gdome_xslt/ocaml/gdome_xslt/.cvsignore | 23 + DEVEL/gdome_xslt/ocaml/gdome_xslt/.depend | 5 + DEVEL/gdome_xslt/ocaml/gdome_xslt/META.in | 4 + DEVEL/gdome_xslt/ocaml/gdome_xslt/Makefile.am | 114 + .../gdome_xslt/ocaml/gdome_xslt/gdome_xslt.ml | 59 + .../ocaml/gdome_xslt/gdome_xslt.mli | 59 + .../ocaml/gdome_xslt/gdome_xslt_init.ml | 41 + .../ocaml/gdome_xslt/gdome_xslt_init.mli | 37 + .../ocaml/gdome_xslt/i_gdome_xslt.ml | 58 + .../ocaml/gdome_xslt/ml_gdome_xslt.c | 186 ++ .../ocaml/gdome_xslt/ml_gdome_xslt.h | 40 + DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h | 54 + DEVEL/gdome_xslt/ocaml/test/.cvsignore | 8 + DEVEL/gdome_xslt/ocaml/test/Makefile.am | 25 + DEVEL/gdome_xslt/ocaml/test/test.ml | 79 + DEVEL/gdome_xslt/test_files/.cvsignore | 3 + DEVEL/gdome_xslt/test_files/Makefile.am | 1 + DEVEL/gdome_xslt/test_files/input.xml | 4 + .../gdome_xslt/test_files/output.xml.correct | 4 + DEVEL/gdome_xslt/test_files/stylesheet.xsl | 22 + DEVEL/gtkmathview-bonobo/.cvsignore | 18 + DEVEL/gtkmathview-bonobo/AUTHORS | 2 + DEVEL/gtkmathview-bonobo/ChangeLog | 0 DEVEL/gtkmathview-bonobo/LICENSE | 23 + DEVEL/gtkmathview-bonobo/Makefile.am | 20 + DEVEL/gtkmathview-bonobo/NEWS | 5 + DEVEL/gtkmathview-bonobo/README | 0 DEVEL/gtkmathview-bonobo/TODO | 21 + DEVEL/gtkmathview-bonobo/configure.ac | 112 + .../gtkmathview-bonobo.pc.in | 14 + DEVEL/gtkmathview-bonobo/idl/.cvsignore | 2 + DEVEL/gtkmathview-bonobo/idl/GtkMathView.idl | 105 + DEVEL/gtkmathview-bonobo/idl/Makefile.am | 5 + DEVEL/gtkmathview-bonobo/src/.cvsignore | 21 + .../src/GNOME_GtkMathView.server.in.in | 34 + DEVEL/gtkmathview-bonobo/src/Makefile.am | 68 + DEVEL/gtkmathview-bonobo/src/aux.cc | 302 +++ DEVEL/gtkmathview-bonobo/src/aux.h | 46 + DEVEL/gtkmathview-bonobo/src/control-data.c | 138 ++ DEVEL/gtkmathview-bonobo/src/control-data.h | 53 + .../gtkmathview-bonobo/src/control-factory.c | 431 ++++ .../gtkmathview-bonobo/src/control-factory.h | 34 + DEVEL/gtkmathview-bonobo/src/handlers.c | 245 +++ DEVEL/gtkmathview-bonobo/src/handlers.h | 41 + DEVEL/gtkmathview-bonobo/src/persist-file.c | 141 ++ DEVEL/gtkmathview-bonobo/src/persist-file.h | 61 + DEVEL/gtkmathview-bonobo/src/persist-stream.c | 221 ++ DEVEL/gtkmathview-bonobo/src/persist-stream.h | 59 + DEVEL/gtkmathview-bonobo/src/view.c | 361 +++ DEVEL/gtkmathview-bonobo/src/view.h | 53 + DEVEL/gtkmathview-bonobo/test/.cvsignore | 5 + DEVEL/gtkmathview-bonobo/test/Makefile.am | 25 + DEVEL/gtkmathview-bonobo/test/embedding.html | 41 + DEVEL/gtkmathview-bonobo/test/embedding.xml | 43 + DEVEL/gtkmathview-bonobo/test/main.c | 476 ++++ DEVEL/gtkmathview-bonobo/test/test.mml | 128 ++ .../test/testembedding.html | 17 + DEVEL/lablgtkmathview/.cvsignore | 10 + DEVEL/lablgtkmathview/.depend | 12 + DEVEL/lablgtkmathview/AUTHORS | 2 + DEVEL/lablgtkmathview/COPYING | 340 +++ DEVEL/lablgtkmathview/ChangeLog | 6 + DEVEL/lablgtkmathview/LICENSE | 22 + DEVEL/lablgtkmathview/META.in | 4 + DEVEL/lablgtkmathview/Makefile.in | 134 ++ DEVEL/lablgtkmathview/NEWS | 0 DEVEL/lablgtkmathview/README | 9 + DEVEL/lablgtkmathview/configure.in | 57 + DEVEL/lablgtkmathview/debian/changelog | 347 +++ DEVEL/lablgtkmathview/debian/compat | 1 + DEVEL/lablgtkmathview/debian/control | 27 + DEVEL/lablgtkmathview/debian/control.in | 27 + DEVEL/lablgtkmathview/debian/copyright | 21 + DEVEL/lablgtkmathview/debian/docs | 1 + .../debian/liblablgtkmathview-ocaml-dev.dirs | 1 + .../liblablgtkmathview-ocaml-dev.install | 7 + .../liblablgtkmathview-ocaml-dev.install.in | 7 + .../debian/liblablgtkmathview-ocaml.dirs | 1 + .../debian/liblablgtkmathview-ocaml.install | 1 + .../liblablgtkmathview-ocaml.install.in | 1 + DEVEL/lablgtkmathview/debian/rules | 68 + DEVEL/lablgtkmathview/gMathView.ml | 103 + DEVEL/lablgtkmathview/gMathView.mli | 108 + DEVEL/lablgtkmathview/gMathViewAux.ml | 281 +++ DEVEL/lablgtkmathview/gMathViewAux.mli | 78 + DEVEL/lablgtkmathview/gtkMathView.ml | 107 + DEVEL/lablgtkmathview/gtkMathView.props | 111 + DEVEL/lablgtkmathview/gtk_mathview.ml | 27 + DEVEL/lablgtkmathview/lablgtk/META.lablgtk | 6 + DEVEL/lablgtkmathview/ml_gtk_mathview.c | 271 +++ DEVEL/lablgtkmathview/test/.cvsignore | 1 + DEVEL/lablgtkmathview/test/Makefile.in | 20 + DEVEL/lablgtkmathview/test/t1.config | 3 + DEVEL/lablgtkmathview/test/test.ml | 397 ++++ DEVEL/lablgtkmathview/test/test.xml | 134 ++ DEVEL/lablgtksourceview/.cvsignore | 10 + DEVEL/lablgtksourceview/.depend | 11 + DEVEL/lablgtksourceview/ACKNOWLEDGEMENTS | 3 + DEVEL/lablgtksourceview/AUTHORS | 1 + DEVEL/lablgtksourceview/CHANGES | 4 + DEVEL/lablgtksourceview/COPYING | 510 +++++ DEVEL/lablgtksourceview/Changelog | 0 DEVEL/lablgtksourceview/LICENSE | 20 + DEVEL/lablgtksourceview/META.in | 5 + DEVEL/lablgtksourceview/Makefile.in | 145 ++ DEVEL/lablgtksourceview/NEWS | 0 DEVEL/lablgtksourceview/README | 42 + DEVEL/lablgtksourceview/configure.ac | 53 + DEVEL/lablgtksourceview/debian/changelog | 20 + DEVEL/lablgtksourceview/debian/compat | 1 + DEVEL/lablgtksourceview/debian/control | 29 + DEVEL/lablgtksourceview/debian/control.in | 29 + DEVEL/lablgtksourceview/debian/copyright | 18 + .../liblablgtksourceview-ocaml-dev.docs | 3 + .../liblablgtksourceview-ocaml-dev.install | 7 + .../liblablgtksourceview-ocaml-dev.install.in | 7 + .../debian/liblablgtksourceview-ocaml.install | 1 + .../liblablgtksourceview-ocaml.install.in | 1 + DEVEL/lablgtksourceview/debian/rules | 10 + DEVEL/lablgtksourceview/gSourceView.ml | 219 ++ DEVEL/lablgtksourceview/gSourceView.mli | 187 ++ DEVEL/lablgtksourceview/gtkSourceView.ml | 118 + DEVEL/lablgtksourceview/gtkSourceView.props | 40 + DEVEL/lablgtksourceview/gtk_sourceview.ml | 26 + DEVEL/lablgtksourceview/ml_gtk_sourceview.c | 126 ++ DEVEL/lablgtksourceview/test/.cvsignore | 3 + DEVEL/lablgtksourceview/test/Makefile.in | 23 + DEVEL/lablgtksourceview/test/test.lang | 128 ++ DEVEL/lablgtksourceview/test/test.ml | 99 + DEVEL/lablgtksourceview/test/test.txt | 211 ++ DEVEL/mathml_editor/.cvsignore | 16 + DEVEL/mathml_editor/.log | 21 + DEVEL/mathml_editor/AUTHORS | 2 + DEVEL/mathml_editor/BROWSE | 503 +++++ DEVEL/mathml_editor/BUGS | 0 DEVEL/mathml_editor/BUGS-GDOME2 | 4 + DEVEL/mathml_editor/ChangeLog | 55 + DEVEL/mathml_editor/LICENSE | 25 + DEVEL/mathml_editor/MODES | 25 + DEVEL/mathml_editor/Makefile.am | 31 + DEVEL/mathml_editor/Makefile.in | 438 ++++ DEVEL/mathml_editor/NEWS | 0 DEVEL/mathml_editor/PATTERNS | 196 ++ DEVEL/mathml_editor/README | 0 DEVEL/mathml_editor/TML.dtd | 66 + DEVEL/mathml_editor/TODO | 13 + DEVEL/mathml_editor/configure.ac | 187 ++ DEVEL/mathml_editor/debian/changelog | 114 + DEVEL/mathml_editor/debian/compat | 1 + DEVEL/mathml_editor/debian/control | 46 + DEVEL/mathml_editor/debian/copyright | 23 + DEVEL/mathml_editor/debian/docs | 7 + .../mathml_editor/debian/libeditex-dev.files | 5 + .../debian/libeditex-ocaml-dev.files | 3 + .../debian/libeditex-ocaml.files | 1 + DEVEL/mathml_editor/debian/libeditex0.files | 2 + DEVEL/mathml_editor/debian/rules | 74 + DEVEL/mathml_editor/dict/.cvsignore | 2 + DEVEL/mathml_editor/dict/Makefile.am | 2 + DEVEL/mathml_editor/dict/dictionary-basic.xml | 9 + DEVEL/mathml_editor/dict/dictionary-test.xml | 39 + DEVEL/mathml_editor/dict/dictionary-tex.xml | 378 ++++ DEVEL/mathml_editor/dict/dictionary.dtd | 23 + DEVEL/mathml_editor/doc/.cvsignore | 5 + DEVEL/mathml_editor/doc/spec.tex | 973 ++++++++ DEVEL/mathml_editor/editex.pc.in | 19 + DEVEL/mathml_editor/examples/.cvsignore | 2 + DEVEL/mathml_editor/examples/Makefile.am | 1 + DEVEL/mathml_editor/examples/abs.tex | 1 + DEVEL/mathml_editor/examples/big.tex | 1 + DEVEL/mathml_editor/ocaml/.cvsignore | 1 + DEVEL/mathml_editor/ocaml/.depend | 3 + DEVEL/mathml_editor/ocaml/META.in | 6 + DEVEL/mathml_editor/ocaml/Makefile.am | 90 + DEVEL/mathml_editor/ocaml/c_mathml_editor.cc | 224 ++ DEVEL/mathml_editor/ocaml/c_mathml_editor.h | 49 + DEVEL/mathml_editor/ocaml/i_mathml_editor.ml | 76 + DEVEL/mathml_editor/ocaml/mathml_editor.ml | 70 + DEVEL/mathml_editor/ocaml/mathml_editor.mli | 50 + DEVEL/mathml_editor/ocaml/ml_mathml_editor.c | 210 ++ DEVEL/mathml_editor/src/.cvsignore | 9 + DEVEL/mathml_editor/src/ALogger.hh | 53 + DEVEL/mathml_editor/src/AMathMLConsumer.hh | 38 + DEVEL/mathml_editor/src/AMathMLFactory.cc | 42 + DEVEL/mathml_editor/src/AMathMLFactory.hh | 47 + DEVEL/mathml_editor/src/APushLexer.hh | 46 + DEVEL/mathml_editor/src/APushParser.cc | 42 + DEVEL/mathml_editor/src/APushParser.hh | 57 + DEVEL/mathml_editor/src/BROWSE | 503 +++++ DEVEL/mathml_editor/src/CLoggerConsole.cc | 35 + DEVEL/mathml_editor/src/CLoggerConsole.hh | 40 + DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc | 145 ++ DEVEL/mathml_editor/src/CMathMLFactoryXSLT.hh | 47 + .../src/CMathMLFactoryXSLTDiff.cc | 102 + .../src/CMathMLFactoryXSLTDiff.hh | 46 + DEVEL/mathml_editor/src/Diff.cc | 393 ++++ DEVEL/mathml_editor/src/Diff.hh | 77 + DEVEL/mathml_editor/src/ILPushLexer.cc | 51 + DEVEL/mathml_editor/src/ILPushLexer.hh | 21 + DEVEL/mathml_editor/src/ITPushLexer.cc | 44 + DEVEL/mathml_editor/src/ITPushLexer.hh | 20 + DEVEL/mathml_editor/src/LPushLexer.cc | 382 ++++ DEVEL/mathml_editor/src/LPushLexer.hh | 65 + DEVEL/mathml_editor/src/Makefile.am | 57 + DEVEL/mathml_editor/src/Makefile.in | 431 ++++ DEVEL/mathml_editor/src/TDictionary.cc | 316 +++ DEVEL/mathml_editor/src/TDictionary.hh | 129 ++ DEVEL/mathml_editor/src/TDocument.cc | 213 ++ DEVEL/mathml_editor/src/TDocument.hh | 69 + DEVEL/mathml_editor/src/TListener.hh | 35 + DEVEL/mathml_editor/src/TNode.cc | 236 ++ DEVEL/mathml_editor/src/TNode.hh | 107 + DEVEL/mathml_editor/src/TPushLexer.cc | 207 ++ DEVEL/mathml_editor/src/TPushLexer.hh | 64 + DEVEL/mathml_editor/src/TPushParser.cc | 1952 +++++++++++++++++ DEVEL/mathml_editor/src/TPushParser.hh | 113 + DEVEL/mathml_editor/src/TToken.hh | 63 + DEVEL/mathml_editor/src/TTokenizer.cc | 69 + DEVEL/mathml_editor/src/TTokenizer.hh | 54 + DEVEL/mathml_editor/src/config.dirs.in | 3 + DEVEL/mathml_editor/src/dom.hh | 53 + DEVEL/mathml_editor/src/globals.hh | 33 + DEVEL/mathml_editor/src/timer.cc | 38 + DEVEL/mathml_editor/src/timer.hh | 31 + DEVEL/mathml_editor/test/.cvsignore | 5 + DEVEL/mathml_editor/test/Makefile.am | 21 + DEVEL/mathml_editor/test/Makefile.in | 396 ++++ DEVEL/mathml_editor/test/aux.cc | 261 +++ DEVEL/mathml_editor/test/editor.cc | 196 ++ DEVEL/mathml_editor/test/guiGTK.c | 649 ++++++ DEVEL/mathml_editor/test/guiGTK.h | 57 + DEVEL/mathml_editor/textomml/.cvsignore | 6 + DEVEL/mathml_editor/textomml/Makefile.am | 17 + DEVEL/mathml_editor/textomml/config.dirs.in | 1 + DEVEL/mathml_editor/textomml/main.cc | 192 ++ DEVEL/mathml_editor/xsl/.cvsignore | 2 + DEVEL/mathml_editor/xsl/Makefile.am | 2 + DEVEL/mathml_editor/xsl/d-xsl.xsl | 159 ++ DEVEL/mathml_editor/xsl/tml-litex.xsl | 158 ++ DEVEL/mathml_editor/xsl/tml-mmlp.xsl | 1160 ++++++++++ DEVEL/mathml_editor/xsl/tml-tex.xsl | 161 ++ DEVEL/mathml_editor/xsl/tml-texid.xsl | 123 ++ DEVEL/ocaml-http/.cvsignore | 8 + DEVEL/ocaml-http/.depend | 49 + DEVEL/ocaml-http/.ocamlinit | 5 + DEVEL/ocaml-http/INSTALL | 37 + DEVEL/ocaml-http/LICENSE | 483 ++++ DEVEL/ocaml-http/META.in | 8 + DEVEL/ocaml-http/Makefile | 137 ++ DEVEL/ocaml-http/Makefile.defs | 24 + DEVEL/ocaml-http/README | 4 + DEVEL/ocaml-http/TODO | 1 + DEVEL/ocaml-http/debian/changelog | 163 ++ DEVEL/ocaml-http/debian/compat | 1 + DEVEL/ocaml-http/debian/control | 23 + DEVEL/ocaml-http/debian/control.in | 23 + DEVEL/ocaml-http/debian/copyright | 15 + DEVEL/ocaml-http/debian/dirs | 1 + DEVEL/ocaml-http/debian/dirs.in | 1 + DEVEL/ocaml-http/debian/doc-base | 12 + DEVEL/ocaml-http/debian/docs | 2 + DEVEL/ocaml-http/debian/examples | 1 + DEVEL/ocaml-http/debian/rules | 20 + DEVEL/ocaml-http/doc/dot/.cvsignore | 2 + DEVEL/ocaml-http/doc/html/.cvsignore | 2 + DEVEL/ocaml-http/doc/latex/.cvsignore | 1 + DEVEL/ocaml-http/examples/.cvsignore | 18 + DEVEL/ocaml-http/examples/Makefile | 41 + DEVEL/ocaml-http/examples/always_ok_daemon.ml | 33 + DEVEL/ocaml-http/examples/basic_auth.ml | 50 + DEVEL/ocaml-http/examples/chdir.ml | 34 + DEVEL/ocaml-http/examples/client_address.ml | 42 + DEVEL/ocaml-http/examples/damned_recursion.ml | 51 + DEVEL/ocaml-http/examples/dump_args.ml | 48 + DEVEL/ocaml-http/examples/highlander.ml | 41 + DEVEL/ocaml-http/examples/oo_daemon.ml | 47 + DEVEL/ocaml-http/examples/threads.ml | 63 + DEVEL/ocaml-http/examples/timeout.ml | 31 + DEVEL/ocaml-http/examples/webfsd.ml | 50 + DEVEL/ocaml-http/http_common.ml | 162 ++ DEVEL/ocaml-http/http_common.mli | 80 + DEVEL/ocaml-http/http_constants.ml | 34 + DEVEL/ocaml-http/http_constants.mli | 43 + DEVEL/ocaml-http/http_daemon.ml | 501 +++++ DEVEL/ocaml-http/http_daemon.mli | 205 ++ DEVEL/ocaml-http/http_message.ml | 118 + DEVEL/ocaml-http/http_message.mli | 130 ++ DEVEL/ocaml-http/http_misc.ml | 146 ++ DEVEL/ocaml-http/http_misc.mli | 88 + DEVEL/ocaml-http/http_parser.ml | 160 ++ DEVEL/ocaml-http/http_parser.mli | 68 + DEVEL/ocaml-http/http_parser_sanity.ml | 115 + DEVEL/ocaml-http/http_parser_sanity.mli | 46 + DEVEL/ocaml-http/http_request.ml | 145 ++ DEVEL/ocaml-http/http_request.mli | 29 + DEVEL/ocaml-http/http_response.ml | 118 + DEVEL/ocaml-http/http_response.mli | 33 + DEVEL/ocaml-http/http_tcp_server.ml | 172 ++ DEVEL/ocaml-http/http_tcp_server.mli | 39 + DEVEL/ocaml-http/http_threaded_tcp_server.mli | 26 + DEVEL/ocaml-http/http_types.ml | 219 ++ DEVEL/ocaml-http/http_types.mli | 451 ++++ DEVEL/ocaml-http/http_user_agent.ml | 101 + DEVEL/ocaml-http/http_user_agent.mli | 53 + DEVEL/ocaml-http/mt/.cvsignore | 6 + .../ocaml-http/mt/http_threaded_tcp_server.ml | 23 + DEVEL/ocaml-http/non_mt/.cvsignore | 6 + .../non_mt/http_threaded_tcp_server.ml | 26 + metadata/.cvsignore | 6 + metadata/Makefile | 40 + metadata/README | 11 + metadata/dc/Makefile | 32 + metadata/dc/fill_db.pl | 53 + metadata/dc/sql/create_dc_tables.sql | 58 + metadata/dc/sql/drop_dc_tables.sql | 18 + metadata/extractor/.cvsignore | 4 + metadata/extractor/Makefile | 28 + metadata/extractor/README | 9 + metadata/extractor/meta_lex.l | 374 ++++ metadata/extractor/meta_lex_ind.l | 375 ++++ metadata/extractor/sthandler.c | 475 ++++ metadata/extractor/sthandler.h | 9 + metadata/extractor/sthandler_ind.c | 424 ++++ metadata/extractor/sthandler_ind.h | 8 + metadata/sql/create_mowgli_tables.mysql.sql | 61 + metadata/sql/create_mowgli_tables.sql | 29 + metadata/sql/drop_mowgli_tables.mysql.sql | 9 + metadata/sql/drop_mowgli_tables.sql | 6 + metadata/sql/fill_all_derived.sql | 64 + metadata/sql/fill_inconcl_aux.sql | 10 + metadata/sql/fill_no_concl_hyp.sql | 9 + metadata/sql/fill_no_hyp.sql | 15 + metadata/sql/rating.sql | 6 + 386 files changed, 32212 insertions(+) create mode 100644 DEVEL/.cvsignore create mode 100644 DEVEL/gdome_xslt/.cvsignore create mode 100644 DEVEL/gdome_xslt/AUTHORS create mode 100644 DEVEL/gdome_xslt/BUGS create mode 100644 DEVEL/gdome_xslt/C++/.cvsignore create mode 100644 DEVEL/gdome_xslt/C++/Makefile.am create mode 100644 DEVEL/gdome_xslt/C++/gdome_xslt/.cvsignore create mode 100644 DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLT.hh create mode 100644 DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.cc create mode 100644 DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.hh create mode 100644 DEVEL/gdome_xslt/C++/gdome_xslt/Makefile.am create mode 100644 DEVEL/gdome_xslt/C++/test/.cvsignore create mode 100644 DEVEL/gdome_xslt/C++/test/Makefile.am create mode 100644 DEVEL/gdome_xslt/C++/test/main.cc create mode 100644 DEVEL/gdome_xslt/C/.cvsignore create mode 100644 DEVEL/gdome_xslt/C/Makefile.am create mode 100644 DEVEL/gdome_xslt/C/gdome_xslt/.cvsignore create mode 100644 DEVEL/gdome_xslt/C/gdome_xslt/Makefile.am create mode 100644 DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.c create mode 100644 DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.h create mode 100644 DEVEL/gdome_xslt/C/test/.cvsignore create mode 100644 DEVEL/gdome_xslt/C/test/Makefile.am create mode 100644 DEVEL/gdome_xslt/C/test/test.c create mode 100644 DEVEL/gdome_xslt/ChangeLog create mode 100644 DEVEL/gdome_xslt/LICENSE create mode 100644 DEVEL/gdome_xslt/LICENSE-INRIA create mode 100644 DEVEL/gdome_xslt/Makefile.am create mode 100644 DEVEL/gdome_xslt/NEWS create mode 100644 DEVEL/gdome_xslt/README create mode 100644 DEVEL/gdome_xslt/configure.ac create mode 100644 DEVEL/gdome_xslt/debian/changelog create mode 100644 DEVEL/gdome_xslt/debian/compat create mode 100644 DEVEL/gdome_xslt/debian/control create mode 100644 DEVEL/gdome_xslt/debian/control.in create mode 100644 DEVEL/gdome_xslt/debian/copyright create mode 100644 DEVEL/gdome_xslt/debian/docs create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.examples create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.install create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs.in create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.examples create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install.in create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs.in create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install.in create mode 100644 DEVEL/gdome_xslt/debian/libgdome2-xslt0c2a.install create mode 100755 DEVEL/gdome_xslt/debian/rules create mode 100644 DEVEL/gdome_xslt/gdome2-xslt-cpp-smart.pc.in create mode 100644 DEVEL/gdome_xslt/gdome2-xslt.pc.in create mode 100644 DEVEL/gdome_xslt/ocaml/.cvsignore create mode 100644 DEVEL/gdome_xslt/ocaml/Makefile.am create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/.cvsignore create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/.depend create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/META.in create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/Makefile.am create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.ml create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.mli create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.ml create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.mli create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/i_gdome_xslt.ml create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.c create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.h create mode 100644 DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h create mode 100644 DEVEL/gdome_xslt/ocaml/test/.cvsignore create mode 100644 DEVEL/gdome_xslt/ocaml/test/Makefile.am create mode 100644 DEVEL/gdome_xslt/ocaml/test/test.ml create mode 100644 DEVEL/gdome_xslt/test_files/.cvsignore create mode 100644 DEVEL/gdome_xslt/test_files/Makefile.am create mode 100644 DEVEL/gdome_xslt/test_files/input.xml create mode 100644 DEVEL/gdome_xslt/test_files/output.xml.correct create mode 100644 DEVEL/gdome_xslt/test_files/stylesheet.xsl create mode 100644 DEVEL/gtkmathview-bonobo/.cvsignore create mode 100644 DEVEL/gtkmathview-bonobo/AUTHORS create mode 100644 DEVEL/gtkmathview-bonobo/ChangeLog create mode 100644 DEVEL/gtkmathview-bonobo/LICENSE create mode 100644 DEVEL/gtkmathview-bonobo/Makefile.am create mode 100644 DEVEL/gtkmathview-bonobo/NEWS create mode 100644 DEVEL/gtkmathview-bonobo/README create mode 100644 DEVEL/gtkmathview-bonobo/TODO create mode 100644 DEVEL/gtkmathview-bonobo/configure.ac create mode 100644 DEVEL/gtkmathview-bonobo/gtkmathview-bonobo.pc.in create mode 100644 DEVEL/gtkmathview-bonobo/idl/.cvsignore create mode 100644 DEVEL/gtkmathview-bonobo/idl/GtkMathView.idl create mode 100644 DEVEL/gtkmathview-bonobo/idl/Makefile.am create mode 100644 DEVEL/gtkmathview-bonobo/src/.cvsignore create mode 100644 DEVEL/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in create mode 100644 DEVEL/gtkmathview-bonobo/src/Makefile.am create mode 100644 DEVEL/gtkmathview-bonobo/src/aux.cc create mode 100644 DEVEL/gtkmathview-bonobo/src/aux.h create mode 100644 DEVEL/gtkmathview-bonobo/src/control-data.c create mode 100644 DEVEL/gtkmathview-bonobo/src/control-data.h create mode 100644 DEVEL/gtkmathview-bonobo/src/control-factory.c create mode 100644 DEVEL/gtkmathview-bonobo/src/control-factory.h create mode 100644 DEVEL/gtkmathview-bonobo/src/handlers.c create mode 100644 DEVEL/gtkmathview-bonobo/src/handlers.h create mode 100644 DEVEL/gtkmathview-bonobo/src/persist-file.c create mode 100644 DEVEL/gtkmathview-bonobo/src/persist-file.h create mode 100644 DEVEL/gtkmathview-bonobo/src/persist-stream.c create mode 100644 DEVEL/gtkmathview-bonobo/src/persist-stream.h create mode 100644 DEVEL/gtkmathview-bonobo/src/view.c create mode 100644 DEVEL/gtkmathview-bonobo/src/view.h create mode 100644 DEVEL/gtkmathview-bonobo/test/.cvsignore create mode 100644 DEVEL/gtkmathview-bonobo/test/Makefile.am create mode 100644 DEVEL/gtkmathview-bonobo/test/embedding.html create mode 100644 DEVEL/gtkmathview-bonobo/test/embedding.xml create mode 100644 DEVEL/gtkmathview-bonobo/test/main.c create mode 100644 DEVEL/gtkmathview-bonobo/test/test.mml create mode 100644 DEVEL/gtkmathview-bonobo/test/testembedding.html create mode 100644 DEVEL/lablgtkmathview/.cvsignore create mode 100644 DEVEL/lablgtkmathview/.depend create mode 100644 DEVEL/lablgtkmathview/AUTHORS create mode 100644 DEVEL/lablgtkmathview/COPYING create mode 100644 DEVEL/lablgtkmathview/ChangeLog create mode 100644 DEVEL/lablgtkmathview/LICENSE create mode 100644 DEVEL/lablgtkmathview/META.in create mode 100644 DEVEL/lablgtkmathview/Makefile.in create mode 100644 DEVEL/lablgtkmathview/NEWS create mode 100644 DEVEL/lablgtkmathview/README create mode 100644 DEVEL/lablgtkmathview/configure.in create mode 100644 DEVEL/lablgtkmathview/debian/changelog create mode 100644 DEVEL/lablgtkmathview/debian/compat create mode 100644 DEVEL/lablgtkmathview/debian/control create mode 100644 DEVEL/lablgtkmathview/debian/control.in create mode 100644 DEVEL/lablgtkmathview/debian/copyright create mode 100644 DEVEL/lablgtkmathview/debian/docs create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.dirs create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install.in create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.dirs create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install create mode 100644 DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install.in create mode 100755 DEVEL/lablgtkmathview/debian/rules create mode 100644 DEVEL/lablgtkmathview/gMathView.ml create mode 100644 DEVEL/lablgtkmathview/gMathView.mli create mode 100644 DEVEL/lablgtkmathview/gMathViewAux.ml create mode 100644 DEVEL/lablgtkmathview/gMathViewAux.mli create mode 100644 DEVEL/lablgtkmathview/gtkMathView.ml create mode 100644 DEVEL/lablgtkmathview/gtkMathView.props create mode 100644 DEVEL/lablgtkmathview/gtk_mathview.ml create mode 100644 DEVEL/lablgtkmathview/lablgtk/META.lablgtk create mode 100644 DEVEL/lablgtkmathview/ml_gtk_mathview.c create mode 100644 DEVEL/lablgtkmathview/test/.cvsignore create mode 100644 DEVEL/lablgtkmathview/test/Makefile.in create mode 100644 DEVEL/lablgtkmathview/test/t1.config create mode 100644 DEVEL/lablgtkmathview/test/test.ml create mode 100644 DEVEL/lablgtkmathview/test/test.xml create mode 100644 DEVEL/lablgtksourceview/.cvsignore create mode 100644 DEVEL/lablgtksourceview/.depend create mode 100644 DEVEL/lablgtksourceview/ACKNOWLEDGEMENTS create mode 100644 DEVEL/lablgtksourceview/AUTHORS create mode 100644 DEVEL/lablgtksourceview/CHANGES create mode 100644 DEVEL/lablgtksourceview/COPYING create mode 100644 DEVEL/lablgtksourceview/Changelog create mode 100644 DEVEL/lablgtksourceview/LICENSE create mode 100644 DEVEL/lablgtksourceview/META.in create mode 100644 DEVEL/lablgtksourceview/Makefile.in create mode 100644 DEVEL/lablgtksourceview/NEWS create mode 100644 DEVEL/lablgtksourceview/README create mode 100644 DEVEL/lablgtksourceview/configure.ac create mode 100644 DEVEL/lablgtksourceview/debian/changelog create mode 100644 DEVEL/lablgtksourceview/debian/compat create mode 100644 DEVEL/lablgtksourceview/debian/control create mode 100644 DEVEL/lablgtksourceview/debian/control.in create mode 100644 DEVEL/lablgtksourceview/debian/copyright create mode 100644 DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.docs create mode 100644 DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install create mode 100644 DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install.in create mode 100644 DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install create mode 100644 DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install.in create mode 100755 DEVEL/lablgtksourceview/debian/rules create mode 100644 DEVEL/lablgtksourceview/gSourceView.ml create mode 100644 DEVEL/lablgtksourceview/gSourceView.mli create mode 100644 DEVEL/lablgtksourceview/gtkSourceView.ml create mode 100644 DEVEL/lablgtksourceview/gtkSourceView.props create mode 100644 DEVEL/lablgtksourceview/gtk_sourceview.ml create mode 100644 DEVEL/lablgtksourceview/ml_gtk_sourceview.c create mode 100644 DEVEL/lablgtksourceview/test/.cvsignore create mode 100644 DEVEL/lablgtksourceview/test/Makefile.in create mode 100644 DEVEL/lablgtksourceview/test/test.lang create mode 100644 DEVEL/lablgtksourceview/test/test.ml create mode 100644 DEVEL/lablgtksourceview/test/test.txt create mode 100644 DEVEL/mathml_editor/.cvsignore create mode 100644 DEVEL/mathml_editor/.log create mode 100644 DEVEL/mathml_editor/AUTHORS create mode 100644 DEVEL/mathml_editor/BROWSE create mode 100644 DEVEL/mathml_editor/BUGS create mode 100644 DEVEL/mathml_editor/BUGS-GDOME2 create mode 100644 DEVEL/mathml_editor/ChangeLog create mode 100644 DEVEL/mathml_editor/LICENSE create mode 100644 DEVEL/mathml_editor/MODES create mode 100644 DEVEL/mathml_editor/Makefile.am create mode 100644 DEVEL/mathml_editor/Makefile.in create mode 100644 DEVEL/mathml_editor/NEWS create mode 100644 DEVEL/mathml_editor/PATTERNS create mode 100644 DEVEL/mathml_editor/README create mode 100644 DEVEL/mathml_editor/TML.dtd create mode 100644 DEVEL/mathml_editor/TODO create mode 100644 DEVEL/mathml_editor/configure.ac create mode 100644 DEVEL/mathml_editor/debian/changelog create mode 100644 DEVEL/mathml_editor/debian/compat create mode 100644 DEVEL/mathml_editor/debian/control create mode 100644 DEVEL/mathml_editor/debian/copyright create mode 100644 DEVEL/mathml_editor/debian/docs create mode 100644 DEVEL/mathml_editor/debian/libeditex-dev.files create mode 100644 DEVEL/mathml_editor/debian/libeditex-ocaml-dev.files create mode 100644 DEVEL/mathml_editor/debian/libeditex-ocaml.files create mode 100644 DEVEL/mathml_editor/debian/libeditex0.files create mode 100755 DEVEL/mathml_editor/debian/rules create mode 100644 DEVEL/mathml_editor/dict/.cvsignore create mode 100644 DEVEL/mathml_editor/dict/Makefile.am create mode 100644 DEVEL/mathml_editor/dict/dictionary-basic.xml create mode 100644 DEVEL/mathml_editor/dict/dictionary-test.xml create mode 100644 DEVEL/mathml_editor/dict/dictionary-tex.xml create mode 100644 DEVEL/mathml_editor/dict/dictionary.dtd create mode 100644 DEVEL/mathml_editor/doc/.cvsignore create mode 100644 DEVEL/mathml_editor/doc/spec.tex create mode 100644 DEVEL/mathml_editor/editex.pc.in create mode 100644 DEVEL/mathml_editor/examples/.cvsignore create mode 100644 DEVEL/mathml_editor/examples/Makefile.am create mode 100644 DEVEL/mathml_editor/examples/abs.tex create mode 100644 DEVEL/mathml_editor/examples/big.tex create mode 100644 DEVEL/mathml_editor/ocaml/.cvsignore create mode 100644 DEVEL/mathml_editor/ocaml/.depend create mode 100644 DEVEL/mathml_editor/ocaml/META.in create mode 100644 DEVEL/mathml_editor/ocaml/Makefile.am create mode 100644 DEVEL/mathml_editor/ocaml/c_mathml_editor.cc create mode 100644 DEVEL/mathml_editor/ocaml/c_mathml_editor.h create mode 100644 DEVEL/mathml_editor/ocaml/i_mathml_editor.ml create mode 100644 DEVEL/mathml_editor/ocaml/mathml_editor.ml create mode 100644 DEVEL/mathml_editor/ocaml/mathml_editor.mli create mode 100644 DEVEL/mathml_editor/ocaml/ml_mathml_editor.c create mode 100644 DEVEL/mathml_editor/src/.cvsignore create mode 100644 DEVEL/mathml_editor/src/ALogger.hh create mode 100644 DEVEL/mathml_editor/src/AMathMLConsumer.hh create mode 100644 DEVEL/mathml_editor/src/AMathMLFactory.cc create mode 100644 DEVEL/mathml_editor/src/AMathMLFactory.hh create mode 100644 DEVEL/mathml_editor/src/APushLexer.hh create mode 100644 DEVEL/mathml_editor/src/APushParser.cc create mode 100644 DEVEL/mathml_editor/src/APushParser.hh create mode 100644 DEVEL/mathml_editor/src/BROWSE create mode 100644 DEVEL/mathml_editor/src/CLoggerConsole.cc create mode 100644 DEVEL/mathml_editor/src/CLoggerConsole.hh create mode 100644 DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc create mode 100644 DEVEL/mathml_editor/src/CMathMLFactoryXSLT.hh create mode 100644 DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.cc create mode 100644 DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.hh create mode 100644 DEVEL/mathml_editor/src/Diff.cc create mode 100644 DEVEL/mathml_editor/src/Diff.hh create mode 100644 DEVEL/mathml_editor/src/ILPushLexer.cc create mode 100644 DEVEL/mathml_editor/src/ILPushLexer.hh create mode 100644 DEVEL/mathml_editor/src/ITPushLexer.cc create mode 100644 DEVEL/mathml_editor/src/ITPushLexer.hh create mode 100644 DEVEL/mathml_editor/src/LPushLexer.cc create mode 100644 DEVEL/mathml_editor/src/LPushLexer.hh create mode 100644 DEVEL/mathml_editor/src/Makefile.am create mode 100644 DEVEL/mathml_editor/src/Makefile.in create mode 100644 DEVEL/mathml_editor/src/TDictionary.cc create mode 100644 DEVEL/mathml_editor/src/TDictionary.hh create mode 100644 DEVEL/mathml_editor/src/TDocument.cc create mode 100644 DEVEL/mathml_editor/src/TDocument.hh create mode 100644 DEVEL/mathml_editor/src/TListener.hh create mode 100644 DEVEL/mathml_editor/src/TNode.cc create mode 100644 DEVEL/mathml_editor/src/TNode.hh create mode 100644 DEVEL/mathml_editor/src/TPushLexer.cc create mode 100644 DEVEL/mathml_editor/src/TPushLexer.hh create mode 100644 DEVEL/mathml_editor/src/TPushParser.cc create mode 100644 DEVEL/mathml_editor/src/TPushParser.hh create mode 100644 DEVEL/mathml_editor/src/TToken.hh create mode 100644 DEVEL/mathml_editor/src/TTokenizer.cc create mode 100644 DEVEL/mathml_editor/src/TTokenizer.hh create mode 100644 DEVEL/mathml_editor/src/config.dirs.in create mode 100644 DEVEL/mathml_editor/src/dom.hh create mode 100644 DEVEL/mathml_editor/src/globals.hh create mode 100644 DEVEL/mathml_editor/src/timer.cc create mode 100644 DEVEL/mathml_editor/src/timer.hh create mode 100644 DEVEL/mathml_editor/test/.cvsignore create mode 100644 DEVEL/mathml_editor/test/Makefile.am create mode 100644 DEVEL/mathml_editor/test/Makefile.in create mode 100644 DEVEL/mathml_editor/test/aux.cc create mode 100644 DEVEL/mathml_editor/test/editor.cc create mode 100644 DEVEL/mathml_editor/test/guiGTK.c create mode 100644 DEVEL/mathml_editor/test/guiGTK.h create mode 100644 DEVEL/mathml_editor/textomml/.cvsignore create mode 100644 DEVEL/mathml_editor/textomml/Makefile.am create mode 100644 DEVEL/mathml_editor/textomml/config.dirs.in create mode 100644 DEVEL/mathml_editor/textomml/main.cc create mode 100644 DEVEL/mathml_editor/xsl/.cvsignore create mode 100644 DEVEL/mathml_editor/xsl/Makefile.am create mode 100644 DEVEL/mathml_editor/xsl/d-xsl.xsl create mode 100644 DEVEL/mathml_editor/xsl/tml-litex.xsl create mode 100644 DEVEL/mathml_editor/xsl/tml-mmlp.xsl create mode 100644 DEVEL/mathml_editor/xsl/tml-tex.xsl create mode 100644 DEVEL/mathml_editor/xsl/tml-texid.xsl create mode 100644 DEVEL/ocaml-http/.cvsignore create mode 100644 DEVEL/ocaml-http/.depend create mode 100644 DEVEL/ocaml-http/.ocamlinit create mode 100644 DEVEL/ocaml-http/INSTALL create mode 100644 DEVEL/ocaml-http/LICENSE create mode 100644 DEVEL/ocaml-http/META.in create mode 100644 DEVEL/ocaml-http/Makefile create mode 100644 DEVEL/ocaml-http/Makefile.defs create mode 100644 DEVEL/ocaml-http/README create mode 100644 DEVEL/ocaml-http/TODO create mode 100644 DEVEL/ocaml-http/debian/changelog create mode 100644 DEVEL/ocaml-http/debian/compat create mode 100644 DEVEL/ocaml-http/debian/control create mode 100644 DEVEL/ocaml-http/debian/control.in create mode 100644 DEVEL/ocaml-http/debian/copyright create mode 100644 DEVEL/ocaml-http/debian/dirs create mode 100644 DEVEL/ocaml-http/debian/dirs.in create mode 100644 DEVEL/ocaml-http/debian/doc-base create mode 100644 DEVEL/ocaml-http/debian/docs create mode 100644 DEVEL/ocaml-http/debian/examples create mode 100755 DEVEL/ocaml-http/debian/rules create mode 100644 DEVEL/ocaml-http/doc/dot/.cvsignore create mode 100644 DEVEL/ocaml-http/doc/html/.cvsignore create mode 100644 DEVEL/ocaml-http/doc/latex/.cvsignore create mode 100644 DEVEL/ocaml-http/examples/.cvsignore create mode 100644 DEVEL/ocaml-http/examples/Makefile create mode 100644 DEVEL/ocaml-http/examples/always_ok_daemon.ml create mode 100644 DEVEL/ocaml-http/examples/basic_auth.ml create mode 100644 DEVEL/ocaml-http/examples/chdir.ml create mode 100644 DEVEL/ocaml-http/examples/client_address.ml create mode 100644 DEVEL/ocaml-http/examples/damned_recursion.ml create mode 100644 DEVEL/ocaml-http/examples/dump_args.ml create mode 100644 DEVEL/ocaml-http/examples/highlander.ml create mode 100644 DEVEL/ocaml-http/examples/oo_daemon.ml create mode 100644 DEVEL/ocaml-http/examples/threads.ml create mode 100644 DEVEL/ocaml-http/examples/timeout.ml create mode 100644 DEVEL/ocaml-http/examples/webfsd.ml create mode 100644 DEVEL/ocaml-http/http_common.ml create mode 100644 DEVEL/ocaml-http/http_common.mli create mode 100644 DEVEL/ocaml-http/http_constants.ml create mode 100644 DEVEL/ocaml-http/http_constants.mli create mode 100644 DEVEL/ocaml-http/http_daemon.ml create mode 100644 DEVEL/ocaml-http/http_daemon.mli create mode 100644 DEVEL/ocaml-http/http_message.ml create mode 100644 DEVEL/ocaml-http/http_message.mli create mode 100644 DEVEL/ocaml-http/http_misc.ml create mode 100644 DEVEL/ocaml-http/http_misc.mli create mode 100644 DEVEL/ocaml-http/http_parser.ml create mode 100644 DEVEL/ocaml-http/http_parser.mli create mode 100644 DEVEL/ocaml-http/http_parser_sanity.ml create mode 100644 DEVEL/ocaml-http/http_parser_sanity.mli create mode 100644 DEVEL/ocaml-http/http_request.ml create mode 100644 DEVEL/ocaml-http/http_request.mli create mode 100644 DEVEL/ocaml-http/http_response.ml create mode 100644 DEVEL/ocaml-http/http_response.mli create mode 100644 DEVEL/ocaml-http/http_tcp_server.ml create mode 100644 DEVEL/ocaml-http/http_tcp_server.mli create mode 100644 DEVEL/ocaml-http/http_threaded_tcp_server.mli create mode 100644 DEVEL/ocaml-http/http_types.ml create mode 100644 DEVEL/ocaml-http/http_types.mli create mode 100644 DEVEL/ocaml-http/http_user_agent.ml create mode 100644 DEVEL/ocaml-http/http_user_agent.mli create mode 100644 DEVEL/ocaml-http/mt/.cvsignore create mode 100644 DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml create mode 100644 DEVEL/ocaml-http/non_mt/.cvsignore create mode 100644 DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml create mode 100644 metadata/.cvsignore create mode 100644 metadata/Makefile create mode 100644 metadata/README create mode 100644 metadata/dc/Makefile create mode 100755 metadata/dc/fill_db.pl create mode 100644 metadata/dc/sql/create_dc_tables.sql create mode 100644 metadata/dc/sql/drop_dc_tables.sql create mode 100644 metadata/extractor/.cvsignore create mode 100644 metadata/extractor/Makefile create mode 100644 metadata/extractor/README create mode 100644 metadata/extractor/meta_lex.l create mode 100644 metadata/extractor/meta_lex_ind.l create mode 100644 metadata/extractor/sthandler.c create mode 100644 metadata/extractor/sthandler.h create mode 100644 metadata/extractor/sthandler_ind.c create mode 100644 metadata/extractor/sthandler_ind.h create mode 100644 metadata/sql/create_mowgli_tables.mysql.sql create mode 100644 metadata/sql/create_mowgli_tables.sql create mode 100644 metadata/sql/drop_mowgli_tables.mysql.sql create mode 100644 metadata/sql/drop_mowgli_tables.sql create mode 100644 metadata/sql/fill_all_derived.sql create mode 100644 metadata/sql/fill_inconcl_aux.sql create mode 100644 metadata/sql/fill_no_concl_hyp.sql create mode 100644 metadata/sql/fill_no_hyp.sql create mode 100644 metadata/sql/rating.sql diff --git a/DEVEL/.cvsignore b/DEVEL/.cvsignore new file mode 100644 index 000000000..c1fcbc4ae --- /dev/null +++ b/DEVEL/.cvsignore @@ -0,0 +1,7 @@ +*.cmo +*.cmx +*.cmi + +*.o +*.a + diff --git a/DEVEL/gdome_xslt/.cvsignore b/DEVEL/gdome_xslt/.cvsignore new file mode 100644 index 000000000..4d6980027 --- /dev/null +++ b/DEVEL/gdome_xslt/.cvsignore @@ -0,0 +1,14 @@ +gdome2-xslt-cpp-smart.pc +gdome2-xslt.pc +autom4te.cache +Makefile +Makefile.in +aclocal.m4 +config.h +config.h.in +config.log +config.status +configure +libtool +stamp-h +stamp-h.in diff --git a/DEVEL/gdome_xslt/AUTHORS b/DEVEL/gdome_xslt/AUTHORS new file mode 100644 index 000000000..834817f9e --- /dev/null +++ b/DEVEL/gdome_xslt/AUTHORS @@ -0,0 +1,3 @@ +Claudio Sacerdoti Coen +Stefano Zacchiroli +Luca Padovani diff --git a/DEVEL/gdome_xslt/BUGS b/DEVEL/gdome_xslt/BUGS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gdome_xslt/C++/.cvsignore b/DEVEL/gdome_xslt/C++/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/C++/Makefile.am b/DEVEL/gdome_xslt/C++/Makefile.am new file mode 100644 index 000000000..30e2ce870 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gdome_xslt test diff --git a/DEVEL/gdome_xslt/C++/gdome_xslt/.cvsignore b/DEVEL/gdome_xslt/C++/gdome_xslt/.cvsignore new file mode 100644 index 000000000..051d1bd50 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/gdome_xslt/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +.deps diff --git a/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLT.hh b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLT.hh new file mode 100644 index 000000000..97b8cc655 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLT.hh @@ -0,0 +1,7 @@ + +#ifndef __GdomeSmartDOMXSLT_hh__ +#define __GdomeSmartDOMXSLT_hh__ + +#include "GdomeSmartDOMXSLTStylesheet.hh" + +#endif // __GdomeSmartDOMXSLT_hh__ diff --git a/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.cc b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.cc new file mode 100644 index 000000000..330f8724e --- /dev/null +++ b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.cc @@ -0,0 +1,131 @@ +// This file is part of a XSLT engine working on Gdome documents. In fact, +// it just maps Gdome documents to libxml documents back and forth, and +// applies the transformation on libxml documents using libxlt. +// +// Copyright (C) 2002: Luca Padovani +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// For more information, please send an email to lpadovan@cs.unibo.it + +#include "config.h" + +#include +#include + +#include +#include + +#include "GdomeSmartDOMXSLTStylesheet.hh" + +namespace GdomeSmartDOMExt { + + XSLTStylesheet::XSLTStylesheet(const Document& doc) + { + assert(doc); + GdomeDocument* _doc = gdome_cast_doc(doc.gdome_object()); + assert(_doc); + stylesheet = processStylesheet(_doc); + GdomeException _exc = 0; + gdome_doc_unref(_doc, &_exc); + assert(_exc == 0); + } + + XSLTStylesheet::~XSLTStylesheet() + { + if (stylesheet) + { + xsltFreeStylesheet(stylesheet); + stylesheet = 0; + } + } + + Document + XSLTStylesheet::apply(const Document& source) const + { + std::vector< std::pair > noParams; + return apply(source, noParams); + } + + Document + XSLTStylesheet::apply(const Document& source, const std::vector< std::pair >& params) const + { + assert(source); + + char** _params = (char**) malloc(sizeof(char*) * (2 * params.size() + 1)); + for (unsigned i = 0; i < params.size(); i++) + { + std::string param = params[i].first; + _params[2 * i] = strdup(param.c_str()); + std::string value = params[i].second; + _params[2 * i + 1] = strdup(value.c_str()); + } + _params[2 * params.size()] = 0; + + GdomeDocument* _source = gdome_cast_doc(source.gdome_object()); + assert(_source); + GdomeDocument* _result = applyStylesheet(_source, stylesheet, const_cast(_params)); + + GdomeException _exc = 0; + gdome_doc_unref(_source, &_exc); + assert(_exc == 0); + + for (unsigned i = 0; i < 2 * params.size(); i++) free(_params[i]); + free(_params); + + Document result(_result); + gdome_doc_unref(_result, &_exc); + assert(_exc == 0); + + return result; + } + + void + XSLTStylesheet::save(const Document& doc, const std::string& filename) const + { + assert(doc); + GdomeException _exc = 0; + GdomeDocument* _doc = gdome_cast_doc(doc.gdome_object()); + assert(_doc); + if (saveResultToFilename(filename.c_str(), _doc, stylesheet, 0) < 0) throw SaveException(); + gdome_doc_unref(_doc, &_exc); + assert(_exc == 0); + } + + void + XSLTStylesheet::save(const Document& doc, FILE* f) const + { + assert(doc); + GdomeException _exc = 0; + GdomeDocument* _doc = gdome_cast_doc(doc.gdome_object()); + assert(_doc); + if (saveResultToFile(f, _doc, stylesheet) < 0) throw SaveException(); + gdome_doc_unref(_doc, &_exc); + assert(_exc == 0); + } + + void + XSLTStylesheet::save(const Document& doc, int fd) const + { + assert(doc); + GdomeException _exc = 0; + GdomeDocument* _doc = gdome_cast_doc(doc.gdome_object()); + assert(_doc); + if (saveResultToFd(fd, _doc, stylesheet) < 0) throw SaveException(); + gdome_doc_unref(_doc, &_exc); + assert(_exc == 0); + } + +} diff --git a/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.hh b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.hh new file mode 100644 index 000000000..1757f39a3 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/gdome_xslt/GdomeSmartDOMXSLTStylesheet.hh @@ -0,0 +1,59 @@ +// This file is part of a XSLT engine working on Gdome documents. In fact, +// it just maps Gdome documents to libxml documents back and forth, and +// applies the transformation on libxml documents using libxlt. +// +// Copyright (C) 2002: Luca Padovani +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// For more information, please send an email to lpadovan@cs.unibo.it + +#ifndef __GdomeSmartDOMXSLTStylesheet_hh__ +#define __GdomeSmartDOMXSLTStylesheet_hh__ + +#include +#include +#include + +#include "gdome_xslt.h" +#include + +namespace GdomeSmartDOMExt { + + using namespace GdomeSmartDOM; + + class XSLTStylesheet + { + public: + explicit XSLTStylesheet(const Document& doc); + ~XSLTStylesheet(); + + Document apply(const Document& source) const; + Document apply(const Document& source, const std::vector< std::pair >& params) const; + void save(const Document& result, const std::string& filename) const; + void save(const Document& result, FILE* f) const; + void save(const Document& result, int fd) const; + + class SaveException { }; + + private: + XSLTStylesheet(const XSLTStylesheet&); + + xsltStylesheet* stylesheet; + }; + +} + +#endif // __GdomeSmartDOMXSLTStylesheet_hh__ diff --git a/DEVEL/gdome_xslt/C++/gdome_xslt/Makefile.am b/DEVEL/gdome_xslt/C++/gdome_xslt/Makefile.am new file mode 100644 index 000000000..0e4b76e4e --- /dev/null +++ b/DEVEL/gdome_xslt/C++/gdome_xslt/Makefile.am @@ -0,0 +1,19 @@ + +lib_LTLIBRARIES = libgdome_xslt_cpp_smart.la + +libgdome_xslt_cpp_smart_la_LIBADD = $(top_builddir)/C/gdome_xslt/libgdome_xslt.la + +libgdome_xslt_cpp_smart_la_LDFLAGS = -version-info @VERSION_INFO@ + +libgdome_xslt_cpp_smart_la_SOURCES = \ + GdomeSmartDOMXSLTStylesheet.cc + +pkginclude_HEADERS = \ + GdomeSmartDOMXSLTStylesheet.hh \ + GdomeSmartDOMXSLT.hh + +INCLUDES = \ + $(GMETADOM_CFLAGS) \ + $(LIBXSLT_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/C/gdome_xslt diff --git a/DEVEL/gdome_xslt/C++/test/.cvsignore b/DEVEL/gdome_xslt/C++/test/.cvsignore new file mode 100644 index 000000000..051d1bd50 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/test/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +.deps diff --git a/DEVEL/gdome_xslt/C++/test/Makefile.am b/DEVEL/gdome_xslt/C++/test/Makefile.am new file mode 100644 index 000000000..12a08d07a --- /dev/null +++ b/DEVEL/gdome_xslt/C++/test/Makefile.am @@ -0,0 +1,18 @@ + +noinst_PROGRAMS = test + +test_SOURCES = main.cc + +LDADDS = \ + $(GMETADOM_LIBS) \ + $(LIBXSLT_LIBS) \ + $(top_builddir)/C++/gdome_xslt/libgdome_xslt_cpp_smart.la + +test_LDADD = $(LDADDS) + +INCLUDES = \ + $(GMETADOM_CFLAGS) \ + $(LIBXSLT_CFLAGS) \ + -I$(top_srcdir)/C/gdome_xslt \ + -I$(top_srcdir)/C++/gdome_xslt + diff --git a/DEVEL/gdome_xslt/C++/test/main.cc b/DEVEL/gdome_xslt/C++/test/main.cc new file mode 100644 index 000000000..0f5aa2d70 --- /dev/null +++ b/DEVEL/gdome_xslt/C++/test/main.cc @@ -0,0 +1,53 @@ +/* This file is a test for the XSLT engine working on Gdome documents. + * + * Copyright (C) 2002 Claudio Sacerdoti Coen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to + */ + +#include +#include +#include "GdomeSmartDOMXSLT.hh" + +namespace DOM = GdomeSmartDOM; +namespace DOMX = GdomeSmartDOMExt; + +#define OUTPUT_FILE "../../test_files/output.xml" +#define CORRECT_OUTPUT_FILE "../../test_files/output.xml.correct" + +int +main(void) +{ + int bytes; + DOM::DOMImplementation di; + std::vector< std::pair > params; + + params.push_back(std::make_pair(DOM::GdomeString("parameter1"), DOM::GdomeString("'value1'"))); + params.push_back(std::make_pair(DOM::GdomeString("parameter2"), DOM::GdomeString("'value2'"))); + params.push_back(std::make_pair(DOM::GdomeString("parameter3"), DOM::GdomeString("'value3'"))); + + DOM::Document input = di.createDocumentFromURI("../../test_files/input.xml"); + DOM::Document style = di.createDocumentFromURI("../../test_files/stylesheet.xsl"); + + DOMX::XSLTStylesheet style_libxslt(style); + DOM::Document output = style_libxslt.apply(input, params); + style_libxslt.save(output, OUTPUT_FILE); + + std::cout << "The test was successful iff " << OUTPUT_FILE << " is equal to " << CORRECT_OUTPUT_FILE << std::endl; + + return 0; +} diff --git a/DEVEL/gdome_xslt/C/.cvsignore b/DEVEL/gdome_xslt/C/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/gdome_xslt/C/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/C/Makefile.am b/DEVEL/gdome_xslt/C/Makefile.am new file mode 100644 index 000000000..7424d618c --- /dev/null +++ b/DEVEL/gdome_xslt/C/Makefile.am @@ -0,0 +1,3 @@ + +SUBDIRS = gdome_xslt test + diff --git a/DEVEL/gdome_xslt/C/gdome_xslt/.cvsignore b/DEVEL/gdome_xslt/C/gdome_xslt/.cvsignore new file mode 100644 index 000000000..572cf3ae5 --- /dev/null +++ b/DEVEL/gdome_xslt/C/gdome_xslt/.cvsignore @@ -0,0 +1,4 @@ +gdome_xslt.o +Makefile +Makefile.in +.deps diff --git a/DEVEL/gdome_xslt/C/gdome_xslt/Makefile.am b/DEVEL/gdome_xslt/C/gdome_xslt/Makefile.am new file mode 100644 index 000000000..b8e374ee3 --- /dev/null +++ b/DEVEL/gdome_xslt/C/gdome_xslt/Makefile.am @@ -0,0 +1,14 @@ + +lib_LTLIBRARIES = libgdome_xslt.la + +libgdome_xslt_la_LDFLAGS = -version-info @VERSION_INFO@ + +libgdome_xslt_la_SOURCES = gdome_xslt.c + +pkginclude_HEADERS = gdome_xslt.h + +INCLUDES = \ + $(GDOME_CFLAGS) \ + $(LIBXSLT_CFLAGS) \ + -I$(top_srcdir) + diff --git a/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.c b/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.c new file mode 100644 index 000000000..232f14b12 --- /dev/null +++ b/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.c @@ -0,0 +1,239 @@ +/* This file implements a XSLT engine working on Gdome documents. In fact, + * it just maps Gdome documents to libxml documents back and forth, and + * applyes the transformation on libxml documents using libxlt. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gdome_xslt.h" + +// Begin of Gdome internals exposed +typedef struct _Gdome_xml_Document Gdome_xml_Document; +struct _Gdome_xml_Document { + GdomeDocument super; + const GdomeDocumentVtab* vtab; + int refcnt; + xmlDocPtr n; + GdomeAccessType accessType; +}; + +GdomeNode* gdome_xml_n_mkref(xmlNode* n); +// End of Gdome internals exposed + +// Begin of the abstraction of Gdome internals. Uses the Gdome internals exposed +xmlDocPtr libxml_of_gdome(GdomeDocument* doc) +{ + return ((Gdome_xml_Document*)doc)->n; +} + +GdomeDocument* gdome_of_libxml(xmlDocPtr n) +{ + return (GdomeDocument*)gdome_xml_n_mkref((xmlNode*)n); +} +// End of the abstraction of Gdome internals. Uses the Gdome internals exposed. + + + +// From now on no Gdome internal should be used directly. + + /******************************/ + /* XSLT stylesheet Processing */ + /******************************/ + +xsltStylesheetPtr processStylesheet(GdomeDocument* style) +{ + xmlDocPtr style_copy; + xmlDocPtr style_libxml; + + if (style == NULL) { + return NULL; + } + style_libxml = libxml_of_gdome(style); + style_copy = xmlCopyDoc(style_libxml, 1); + style_copy->URL = xmlStrdup(style_libxml->URL); + + xsltSetGenericDebugFunc(NULL, NULL); + + return xsltParseStylesheetDoc(style_copy); +} + + /*******************************/ + /* XSLT stylesheet Application */ + /*******************************/ + +GdomeDocument* applyStylesheet(GdomeDocument* source, xsltStylesheetPtr + style_libxslt, const char** params) +{ + xmlDocPtr source_libxml; + xmlDocPtr output_libxml; + + if (source == NULL) return NULL; + source_libxml = libxml_of_gdome(source); + + xsltSetGenericDebugFunc(NULL, NULL); + + output_libxml = xsltApplyStylesheet(style_libxslt, source_libxml, + params); + + if (output_libxml == NULL) return NULL; + + return gdome_of_libxml(output_libxml); +} + + /******************/ + /* Results Output */ + /******************/ + +int saveResultToFilename (const char* name, GdomeDocument* result, + xsltStylesheetPtr style_libxslt, int compression) +{ + xmlDocPtr result_libxml; + + if (result == NULL) return -1; + result_libxml = libxml_of_gdome(result); + + xsltSetGenericDebugFunc(NULL, NULL); + + return xsltSaveResultToFilename(name, result_libxml, + style_libxslt, compression); +} + +int saveResultToFile (FILE* file, GdomeDocument* result, + xsltStylesheetPtr style_libxslt) +{ + xmlDocPtr result_libxml; + + if (result == NULL) return -1; + result_libxml = libxml_of_gdome(result); + + xsltSetGenericDebugFunc(NULL, NULL); + + return xsltSaveResultToFile(file, result_libxml, style_libxslt); +} + +int saveResultToFd (int fd, GdomeDocument* result, xsltStylesheetPtr + style_libxslt) +{ + xmlDocPtr result_libxml; + + if (result == NULL) return -1; + result_libxml = libxml_of_gdome(result); + + xsltSetGenericDebugFunc(NULL, NULL); + + return xsltSaveResultToFd(fd, result_libxml, style_libxslt); +} + + /**********************************************/ + /* Error and Debugging Callbacks Registration */ + /**********************************************/ + + /* max size of a single message passed to callbacks */ +#define MAX_MSG_SIZE 1024 +#define TRUNCATED_MSG "... TRUNCATED ..." +#define TRUNCATED_MSG_LEN strlen(TRUNCATED_MSG) + + /* ERROR callbacks */ + + /* user provided error callback, needs a string input */ +static gdomeXsltMsgCallback errorUserCallback = NULL; + + /* libxslt like error callback, ignore context, builds a string + * input for user provided error callback and invoke it */ +void gdomeXsltErrorCallback (void *ctx, const char *msg, ...) { + va_list args; + char buf[MAX_MSG_SIZE]; + + if (errorUserCallback == NULL) + return; + + va_start(args, msg); + if (vsnprintf(buf, MAX_MSG_SIZE, msg, args) > MAX_MSG_SIZE - 1) + { /* message truncated; write TRUNCATED_MSG on it */ + strncpy(buf+(strlen(buf) - TRUNCATED_MSG_LEN), + TRUNCATED_MSG, TRUNCATED_MSG_LEN); + } + va_end(args); + + (*errorUserCallback) (buf); + + return; +} + + /* set user provided error callback */ +void setErrorCallback (gdomeXsltMsgCallback callback) +{ + errorUserCallback = callback; + xsltSetGenericErrorFunc(NULL, + (callback == NULL ? NULL : gdomeXsltErrorCallback)); + + return; +} + + /* DEBUG callbacks */ + + /* user provided debug callback, needs a string input */ +static gdomeXsltMsgCallback debugUserCallback = NULL; + + /* libxslt like debug callback, ignore context, builds a string + * input for user provided debug callback and invoke it */ +void gdomeXsltDebugCallback (void *ctx, const char *msg, ...) { + va_list args; + char buf[MAX_MSG_SIZE]; + + if (debugUserCallback == NULL) + return; + + va_start(args, msg); + if (vsnprintf(buf, MAX_MSG_SIZE, msg, args) > MAX_MSG_SIZE - 1) + { /* message truncated; write TRUNCATED_MSG on it */ + strncpy(buf+(strlen(buf) - TRUNCATED_MSG_LEN), + TRUNCATED_MSG, TRUNCATED_MSG_LEN); + } + va_end(args); + + (*debugUserCallback) (buf); + + return; +} + + /* set user provided debug callback */ +void setDebugCallback (gdomeXsltMsgCallback callback) +{ + debugUserCallback = callback; + xsltSetGenericDebugFunc(NULL, + (callback == NULL ? NULL : gdomeXsltDebugCallback)); + + return; +} + diff --git a/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.h b/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.h new file mode 100644 index 000000000..383208770 --- /dev/null +++ b/DEVEL/gdome_xslt/C/gdome_xslt/gdome_xslt.h @@ -0,0 +1,87 @@ + +/* This file implements a XSLT engine working on Gdome documents. In fact, + * it just maps Gdome documents to libxml documents back and forth, and + * applies the transformation on libxml documents using libxlt. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + */ + +#ifndef __gdome_xslt_h__ +#define __gdome_xslt_h__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /******************************/ + /* XSLT stylesheet Processing */ + /******************************/ + +xsltStylesheetPtr processStylesheet (GdomeDocument* style); + + + /*******************************/ + /* XSLT stylesheet Application */ + /*******************************/ + +GdomeDocument* applyStylesheet (GdomeDocument* source, + xsltStylesheetPtr style_libxslt, + const char** params); + + /******************/ + /* Results Output */ + /******************/ + +int saveResultToFilename (const char* name, + GdomeDocument* result, + xsltStylesheetPtr style_libxslt, + int compression); +int saveResultToFile (FILE* file, + GdomeDocument* result, + xsltStylesheetPtr style_libxslt); +int saveResultToFd (int fd, + GdomeDocument* result, + xsltStylesheetPtr style_libxslt); + + /**********************************************/ + /* Error and Debugging Callbacks Registration */ + /**********************************************/ + +typedef void(*gdomeXsltMsgCallback)(const char *); + +void setErrorCallback (gdomeXsltMsgCallback callback); +void setDebugCallback (gdomeXsltMsgCallback callback); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __gdome_xslt_h__ */ diff --git a/DEVEL/gdome_xslt/C/test/.cvsignore b/DEVEL/gdome_xslt/C/test/.cvsignore new file mode 100644 index 000000000..87ed101b8 --- /dev/null +++ b/DEVEL/gdome_xslt/C/test/.cvsignore @@ -0,0 +1,4 @@ +test +.deps +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/C/test/Makefile.am b/DEVEL/gdome_xslt/C/test/Makefile.am new file mode 100644 index 000000000..e17047c15 --- /dev/null +++ b/DEVEL/gdome_xslt/C/test/Makefile.am @@ -0,0 +1,17 @@ + +noinst_PROGRAMS = test + +test_SOURCES = test.c + +LDADDS = \ + $(GDOME_LIBS) \ + $(LIBXSLT_LIBS) \ + $(top_builddir)/C/gdome_xslt/libgdome_xslt.la + +test_LDADD = $(LDADDS) + +INCLUDES = \ + $(GDOME_CFLAGS) \ + $(LIBXSLT_CFLAGS) \ + -I$(top_srcdir)/C/gdome_xslt + diff --git a/DEVEL/gdome_xslt/C/test/test.c b/DEVEL/gdome_xslt/C/test/test.c new file mode 100644 index 000000000..2f39ba87a --- /dev/null +++ b/DEVEL/gdome_xslt/C/test/test.c @@ -0,0 +1,106 @@ +/* This file is a test for the XSLT engine working on Gdome documents. + * + * Copyright (C) 2002 Claudio Sacerdoti Coen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to + */ + +#include +#include +#include +#include +#include + +#include "gdome_xslt.h" + +#define OUTPUT_FILE "../../test_files/output.xml" +#define CORRECT_OUTPUT_FILE "../../test_files/output.xml.correct" + +GdomeDocument* loadDocument(GdomeDOMImplementation *domimpl, char *uri) +{ + GdomeDocument *doc; + GdomeException exc; + + doc = gdome_di_createDocFromURI(domimpl, uri, GDOME_LOAD_PARSING, &exc); + if (doc == NULL) { + fprintf (stderr, + "DOMImplementation.createDocFromURI: failed\n\tException #%d\n", + exc); + } + + return doc; +} + +/* // old version: use gdome serialization +int saveDocument(GdomeDOMImplementation *domimpl, GdomeDocument* doc, char *uri) +{ + GdomeException exc; + + if (!gdome_di_saveDocToFile (domimpl, doc, uri, GDOME_SAVE_STANDARD, &exc)) { + fprintf (stderr, + "DOMImplementation.saveDocToFile: failed\n\tException #%d\n", + exc); + return 0; + } + + return 1; +} +*/ + + /* new version, use libxslt serialization */ +int saveDocument(char* fname, GdomeDocument* result, xsltStylesheetPtr style) { + return saveResultToFilename(fname, result, style, 0); +} + +int main(void) +{ + int bytes; + GdomeDOMImplementation *domimpl; + GdomeDocument *input; + GdomeDocument *style; + xsltStylesheetPtr style_libxslt; + GdomeDocument *output; + GdomeException exc; + const char* params[] = {"parameter1", "'value1'", + "parameter2", "'value2'", + "parameter3", "'value3'", + NULL}; + + domimpl = gdome_di_mkref(); + + if (!(input = loadDocument(domimpl, "../../test_files/input.xml"))) return 1; + if (!(style = loadDocument(domimpl, "../../test_files/stylesheet.xsl"))) return 1; + + style_libxslt = processStylesheet(style); + + output = applyStylesheet(input, style_libxslt, params); + +/* if (!(saveDocument(domimpl, output, "../../test_files/output.xml"))) return 1; */ + bytes = saveDocument("../../test_files/output.xml", output, style_libxslt); + + xsltFreeStylesheet(style_libxslt); + gdome_di_freeDoc (domimpl, input, &exc); + gdome_di_freeDoc (domimpl, style, &exc); + gdome_di_freeDoc (domimpl, output, &exc); + gdome_di_unref (domimpl, &exc); + + printf("The test was successful iff %s is equal to %s\n", + OUTPUT_FILE, + CORRECT_OUTPUT_FILE); + + return 0; +} diff --git a/DEVEL/gdome_xslt/ChangeLog b/DEVEL/gdome_xslt/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gdome_xslt/LICENSE b/DEVEL/gdome_xslt/LICENSE new file mode 100644 index 000000000..cf9b6b997 --- /dev/null +++ b/DEVEL/gdome_xslt/LICENSE @@ -0,0 +1,510 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. +^L + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes a de-facto standard. To achieve this, non-free programs must +be allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. +^L + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +^L + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +^L + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +^L + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. +^L + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +^L + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS +^L + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms +of the ordinary General Public License). + + To apply these terms, attach the following notices to the library. +It is safest to attach them to the start of each source file to most +effectively convey the exclusion of warranty; and each file should +have at least the "copyright" line and a pointer to where the full +notice is found. + + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the library, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James + Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/DEVEL/gdome_xslt/LICENSE-INRIA b/DEVEL/gdome_xslt/LICENSE-INRIA new file mode 100644 index 000000000..0fcaa957d --- /dev/null +++ b/DEVEL/gdome_xslt/LICENSE-INRIA @@ -0,0 +1,13 @@ +As a special exception to the GNU Library General Public License, you +may link, statically or dynamically, a "work that uses the Library" +with a publicly distributed version of the Library to produce an +executable file containing portions of the Library, and distribute +that executable file under terms of your choice, without any of the +additional requirements listed in clause 6 of the GNU Library General +Public License. By "a publicly distributed version of the Library", +we mean either the unmodified Library as distributed by INRIA, or a +modified version of the Library that is distributed under the +conditions defined in clause 3 of the GNU Library General Public +License. This exception does not however invalidate any other reasons +why the executable file might be covered by the GNU Library General +Public License. diff --git a/DEVEL/gdome_xslt/Makefile.am b/DEVEL/gdome_xslt/Makefile.am new file mode 100644 index 000000000..bb68b5e4b --- /dev/null +++ b/DEVEL/gdome_xslt/Makefile.am @@ -0,0 +1,16 @@ +DISTDIR = @PACKAGE@-@VERSION@ + +EXTRA_DIST = BUGS LICENSE aclocal.m4 debian gdome2-xslt.pc.in gdome2-xslt-cpp-smart.pc.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = gdome2-xslt.pc gdome2-xslt-cpp-smart.pc + +## SUBDIRS = C C++ test_files +SUBDIRS = C C++ ocaml test_files + +deb: dist + if [ -d $(DISTDIR)/ ]; then rm -rf $(DISTDIR); else true; fi + tar xvzf $(DISTDIR).tar.gz + (cd $(DISTDIR)/ && find . -type d -name CVS -exec rm -rf {} \; ; debuild) + rm -rf $(DISTDIR) + diff --git a/DEVEL/gdome_xslt/NEWS b/DEVEL/gdome_xslt/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gdome_xslt/README b/DEVEL/gdome_xslt/README new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gdome_xslt/configure.ac b/DEVEL/gdome_xslt/configure.ac new file mode 100644 index 000000000..7542923d1 --- /dev/null +++ b/DEVEL/gdome_xslt/configure.ac @@ -0,0 +1,107 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT +AC_CONFIG_SRCDIR([C/gdome_xslt/gdome_xslt.h]) + +PACKAGE=gdome2-xslt +VERSION=0.0.7 +VERSION_INFO=`echo $VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'` +AC_SUBST(VERSION_INFO) + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL + +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AM_PROG_LIBTOOL + +PKG_CHECK_MODULES(GDOME, gdome2 >= 0.7.0,, AC_MSG_ERROR(could not find Gdome2)) +AC_SUBST(GDOME_CFLAGS) +AC_SUBST(GDOME_LIBS) + +PKG_CHECK_MODULES(GMETADOM, gdome2-cpp-smart >= 0.1.8,, AC_MSG_ERROR(could not find GMetaDOM)) +AC_SUBST(GMETADOM_CFLAGS) +AC_SUBST(GMETADOM_LIBS) + +PKG_CHECK_MODULES(LIBXSLT, libxslt,, AC_MSG_ERROR(could not find libxslt)) +AC_SUBST(LIBXSLT_CFLAGS) +AC_SUBST(LIBXSLT_LIBS) + +AC_CHECK_PROG(HAVE_OCAMLC, ocamlc, yes, no) +if test $HAVE_OCAMLC = "no"; then + AC_MSG_ERROR(could not find ocamlc in PATH, please make sure ocaml is installed) +else + OCAMLC=ocamlc + OCAMLSTDLIBDIR="`ocamlc -where`" + OCAMLSTUBDIR="`ocamlc -where`/stublibs" + AC_SUBST(OCAMLC) + AC_SUBST(OCAMLSTDLIBDIR) + AC_SUBST(OCAMLSTUBDIR) +fi + +AC_CHECK_PROG(HAVE_OCAMLOPT, ocamlopt, yes, no) +if test $HAVE_OCAMLOPT = "no"; then + AC_MSG_WARN(ocaml native libraries won't be compiled since ocamlopt was not found) +else + OCAMLOPT=ocamlopt + AC_SUBST(OCAMLOPT) +fi +AM_CONDITIONAL(HAVE_OCAMLOPT_COND, test x$HAVE_OCAMLOPT = xyes) + +AC_CHECK_PROG(HAVE_OCAMLFIND, ocamlfind, yes, no) +if test $HAVE_OCAMLFIND = "no"; then + AC_MSG_ERROR(could not find ocamlfind in PATH, please make sure findlib is installed) +else + OCAMLFIND=ocamlfind + AC_SUBST(OCAMLFIND) +fi + +AC_CHECK_PROG(HAVE_OCAMLDEP, ocamldep, yes, no) +if test $HAVE_OCAMLDEP = "yes"; then + OCAMLDEP=ocamldep + AC_SUBST(OCAMLDEP) +fi + +AC_CHECK_PROG(HAVE_OCAMLMKLIB, ocamlmklib, yes, no) +if test $HAVE_OCAMLMKLIB = "no"; then + AC_MSG_ERROR(could not find ocamlmklib in PATH, please make sure ocamlmklib is installed) +else + OCAMLMKLIB=ocamlmklib + AC_SUBST(OCAMLMKLIB) +fi + +AC_MSG_CHECKING(for gdome2 ocaml binding) +ocamlfind query gdome2 || + AC_MSG_ERROR(gdome2 not installed (according to findlib)) +MLGDOME_CFLAGS="`$OCAMLFIND query -i-format gdome2`" +AC_SUBST(MLGDOME_CFLAGS) + +AC_MSG_CHECKING(for the ocaml library dir) +OCAML_LIB_DIR=`ocamlc -where` +AC_MSG_RESULT($OCAML_LIB_DIR) + +AC_CHECK_FILE(/usr/include/caml/mlvalues.h, + OCAML_INCLUDE_DIR=/usr/include/caml, + OCAML_INCLUDE_DIR=$OCAML_LIB_DIR/caml +) + +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) +AC_SUBST(OCAML_INCLUDE_DIR) + +AC_CONFIG_FILES([ + Makefile + C/Makefile + C/gdome_xslt/Makefile + C/test/Makefile + C++/gdome_xslt/Makefile + C++/test/Makefile + C++/Makefile + ocaml/Makefile + ocaml/gdome_xslt/Makefile + ocaml/gdome_xslt/META + ocaml/test/Makefile + gdome2-xslt.pc + gdome2-xslt-cpp-smart.pc + test_files/Makefile]) +AC_OUTPUT diff --git a/DEVEL/gdome_xslt/debian/changelog b/DEVEL/gdome_xslt/debian/changelog new file mode 100644 index 000000000..40ed12429 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/changelog @@ -0,0 +1,227 @@ +gdome2-xslt (0.0.7-3) unstable; urgency=low + + * Rebuilt against OCaml 3.09.1, bumped deps accordingly. + + -- Stefano Zacchiroli Sat, 7 Jan 2006 18:52:27 +0100 + +gdome2-xslt (0.0.7-2) unstable; urgency=low + + * ocaml 3.09 transition + * rebuild/renaming due to changed libstdc++ configuration + (closes: #339167) + * debian/* + - no longer hard coding of ocaml abi number anywhere + * debian/control + - bumped standards version + + -- Stefano Zacchiroli Wed, 23 Nov 2005 10:30:16 +0000 + +gdome2-xslt (0.0.7-1) unstable; urgency=low + + * New upstream release + - enable static linking of C/OCaml glue code + * debian/control + - bumped dependencies to gmetadom 0.2.3 + * debian/* + - ABI transition for gcc 4 + + -- Stefano Zacchiroli Thu, 7 Jul 2005 10:39:37 +0000 + +gdome2-xslt (0.0.6-8) unstable; urgency=low + + * debian/rules + - uses cdbs + * debian/control + - added build dependency on cdbs, bumped debhelper dependency as needed + + -- Stefano Zacchiroli Sun, 22 May 2005 23:46:24 +0200 + +gdome2-xslt (0.0.6-7) unstable; urgency=low + + * rebuilt against ocaml 3.08.3 + + -- Stefano Zacchiroli Sat, 26 Mar 2005 00:38:05 +0100 + +gdome2-xslt (0.0.6-6) unstable; urgency=medium + + * debian/control + - depend on ocaml-base-nox-3.08 instead of ocaml-base-3.08 since + this package doesn't directly need ocaml X libraries + + -- Stefano Zacchiroli Tue, 24 Aug 2004 12:25:28 +0200 + +gdome2-xslt (0.0.6-5) unstable; urgency=low + + * re-run autotools chain to get rid of spurious shared objects created + without .so suffixes + + -- Stefano Zacchiroli Tue, 27 Jul 2004 10:00:09 +0200 + +gdome2-xslt (0.0.6-4) unstable; urgency=low + + * rebuilt with ocaml 3.08 + * debian/control + - bumped ocaml deps to 3.08 + - bumped standards-version to 3.6.1.1 + - changed ocaml deps to ocaml-nox + - bumped gmetadom (ocaml part) versions to >= 0.2.1-3 (first version + rebuilt with ocaml 3.08) + + -- Stefano Zacchiroli Mon, 26 Jul 2004 16:47:13 +0200 + +gdome2-xslt (0.0.6-3) unstable; urgency=high + + * ocaml/gdome_xslt/Makefile.am + - use .o PIC objects from .libs directory + (should fix build failure on hppa) + * debian/control + - versione build dep on findlib to >= 0.8-5 + + -- Stefano Zacchiroli Tue, 21 Oct 2003 14:43:09 +0200 + +gdome2-xslt (0.0.6-2) unstable; urgency=low + + * Rebuilt against gmetadom 0.2.1, gdome2 0.8.1 (should link against glib2) + + -- Stefano Zacchiroli Fri, 10 Oct 2003 09:38:27 +0200 + +gdome2-xslt (0.0.6-1) unstable; urgency=low + + * ocaml binding + - wrapped XSLT stylesheet application in a blocking section so that + it can be interrupted by ocaml exceptions, signals, ... + * restructured/cleaned up Makefiles + + -- Stefano Zacchiroli Sat, 4 Oct 2003 17:09:37 +0200 + +gdome2-xslt (0.0.4-9) unstable; urgency=low + + * Rebuilt with ocaml 3.07 + + -- Stefano Zacchiroli Wed, 1 Oct 2003 14:18:19 +0200 + +gdome2-xslt (0.0.4-8) unstable; urgency=low + + * Rebuilt with ocaml 3.07beta2 + + -- Stefano Zacchiroli Mon, 22 Sep 2003 18:26:04 +0200 + +gdome2-xslt (0.0.4-7) unstable; urgency=low + + * rebuilt against gmetadom 0.1.10-3 + * debian/control + - strictly depends on gmetadom >= 0.1.10-3 (older version are buggy + on mips) + + -- Stefano Zacchiroli Mon, 14 Jul 2003 11:16:59 +0200 + +gdome2-xslt (0.0.4-6) unstable; urgency=low + + * debian/control + - bumped gmetadom dependencies to >= 0.1.10-2 (to ensure that .pc + is available) + + -- Stefano Zacchiroli Tue, 1 Jul 2003 10:14:14 +0200 + +gdome2-xslt (0.0.4-5) unstable; urgency=low + + * rebuilt using gmetadom 0.1.9 + * debian/control + - added build-dep on pkg-config + - bumped dependencies on gmetadom to 0.1.9 + - bumped standards-version to 3.5.10 + - changed section of -dev packages to libdevel + - added ${misc:Depends} + * debian/rules + - removed DH_COMPAT in favour of debian/compat + - removed dh_movefiles in favour of dh_install + - cosmetic changes + + -- Stefano Zacchiroli Thu, 19 Jun 2003 17:05:47 +0200 + +gdome2-xslt (0.0.4-4) unstable; urgency=low + + * Bugfix: ships also -config script + * Bumped Standards-Version to 3.5.9 + + -- Stefano Zacchiroli Thu, 20 Mar 2003 20:45:27 +0100 + +gdome2-xslt (0.0.4-3) unstable; urgency=low + + * Implemented "high" level functions to set handlers for libxslt error and + debugging messages: setErrorCallback, setDebugCallback (C flavour) + * Implemented binding for the above functions (OCaml flavour) + * Bugfix: installs also i_gdome_xslt.ml, gdome_xslt_init.o + + -- Stefano Zacchiroli Thu, 13 Mar 2003 18:07:22 +0100 + +gdome2-xslt (0.0.4-2) unstable; urgency=low + + * Bugfix: installs also i_gdome_xslt.cmi + + -- Stefano Zacchiroli Wed, 12 Mar 2003 18:28:27 +0100 + +gdome2-xslt (0.0.4-1) unstable; urgency=low + + * New release + * Added a new interface for apply method which requires no arguments + * Bumped gmetadom dependencies to 0.1.6 + * Removed << dependencies on gmetadom + * Bumpetd gdome2 version to 0.7.4 + + -- Stefano Zacchiroli Mon, 10 Mar 2003 17:50:42 +0100 + +gdome2-xslt (0.0.3-3) unstable; urgency=low + + * No longer use virtual dependencies on other ocaml libraries, reverted to + >=/<< dependencies approach + * Bumped dependencies on gmetadom to version 0.1.5 + + -- Stefano Zacchiroli Fri, 24 Jan 2003 13:10:22 +0100 + +gdome2-xslt (0.0.3-2) unstable; urgency=low + + * Use versioned ocaml standard library directory + * Changed deps and build-deps to ocaml-3.06-1 + * Source named changed to gdome2-xslt + * Moved OCaml .so stub in /stublibs + * Moved ocaml stuff in /usr/lib/ocaml/3.06 + * Ship also C and C++ flavours + * Added dep from libgdome2-xslt-ocaml to libgdome2-ocaml + * Added dep from libgdome2-xslt-ocaml-dev to libgdome2-ocaml-dev-0.1.4 + * Added build-dep to libgdome2-cpp-smart-dev + * Provided a better Description + * Bumped Standards-Version to 3.5.8 + * Better test for ocamlopt existence + + -- Stefano Zacchiroli Sun, 8 Dec 2002 16:09:56 +0100 + +libxslt-ocaml (0.0.2-1) unstable; urgency=low + + * Added serialization functions + + -- Stefano Zacchiroli Thu, 28 Nov 2002 17:59:29 +0100 + +libxslt-ocaml (0.0.1-3) unstable; urgency=low + + * Rebuilt with ocaml 3.06 (Closes: Bug#158225, Bug#158217) + * Upgraded Standards-Version to 3.5.6 + * Switched deps and build-deps to ocaml-3.06 and ocaml-base-3.06 + * Switched to debhelper 4 + + -- Stefano Zacchiroli Wed, 28 Aug 2002 11:09:04 +0200 + +libxslt-ocaml (0.0.1-2) unstable; urgency=low + + * Added -fPIC option when compiled some .o in order to succesfully build + also on HPPA (Closes: Bug#142485). + * Renamed binary packages to libgdome2-xslt-ocaml and -dev. + + -- Stefano Zacchiroli Fri, 12 Apr 2002 14:55:57 +0200 + +libxslt-ocaml (0.0.1-1) unstable; urgency=low + + * Initial Release. + + -- Stefano Zacchiroli Sat, 6 Apr 2002 13:00:49 +0200 + diff --git a/DEVEL/gdome_xslt/debian/compat b/DEVEL/gdome_xslt/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/DEVEL/gdome_xslt/debian/compat @@ -0,0 +1 @@ +4 diff --git a/DEVEL/gdome_xslt/debian/control b/DEVEL/gdome_xslt/debian/control new file mode 100644 index 000000000..baf781572 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/control @@ -0,0 +1,58 @@ +Source: gdome2-xslt +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>= 4.1.0), ocaml-nox (>= 3.09.1), ocaml-findlib (>= 1.1), libgdome2-ocaml-dev (>= 0.2.3-4), libgdome2-dev (>= 0.8.1), libxslt1-dev, libgdome2-cpp-smart-dev (>= 0.2.3-4), pkg-config, cdbs +Standards-Version: 3.6.2 + +Package: libgdome2-xslt0c2a +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Replaces: libgdome2-xslt0, libgdome2-xslt0c2 +Conflicts: libgdome2-xslt0, libgdome2-xslt0c2 +Description: Minimal XSLT processor working on GDome2 documents + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package includes shared libraries for the C implementation + and for the C++ bindings. + +Package: libgdome2-xslt-dev +Section: libdevel +Architecture: any +Depends: libgdome2-xslt0c2a (= ${Source-Version}), libxslt1-dev, libgdome2-dev (>= 0.8.1), libgdome2-cpp-smart-dev (>= 0.2.3-4), ${misc:Depends} +Description: Minimal XSLT processor working on GDome2 documents + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package includes development support files for the C + library and for its C++ bindings. + +Package: libgdome2-xslt-ocaml +Architecture: any +Depends: ocaml-base-nox-${F:OCamlABI}, libgdome2-ocaml (>= 0.2.3-4), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for a minimal GDome2 based XSLT processor + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package ships the OCaml language bindings for gdome2-xslt. + . + This package contains only the OCaml shared runtime stub libraries. + +Package: libgdome2-xslt-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, libgdome2-xslt-ocaml (= ${Source-Version}), libgdome2-ocaml-dev (>= 0.2.3-4), libxslt1-dev, libgdome2-dev (>= 0.8.1), ${misc:Depends} +Description: OCaml bindings for a minimal GDome2 based XSLT processor + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package ships the OCaml language bindings for gdome2-xslt. + . + This package contains OCaml development stuff for gdome2-xslt. + diff --git a/DEVEL/gdome_xslt/debian/control.in b/DEVEL/gdome_xslt/debian/control.in new file mode 100644 index 000000000..1624c32b6 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/control.in @@ -0,0 +1,58 @@ +Source: gdome2-xslt +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>= 4.1.0), ocaml-nox (>= @OCamlABI@), ocaml-findlib (>= 1.1), libgdome2-ocaml-dev (>= 0.2.3-4), libgdome2-dev (>= 0.8.1), libxslt1-dev, libgdome2-cpp-smart-dev (>= 0.2.3-4), pkg-config, cdbs +Standards-Version: 3.6.2 + +Package: libgdome2-xslt0c2a +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Replaces: libgdome2-xslt0, libgdome2-xslt0c2 +Conflicts: libgdome2-xslt0, libgdome2-xslt0c2 +Description: Minimal XSLT processor working on GDome2 documents + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package includes shared libraries for the C implementation + and for the C++ bindings. + +Package: libgdome2-xslt-dev +Section: libdevel +Architecture: any +Depends: libgdome2-xslt0c2a (= ${Source-Version}), libxslt1-dev, libgdome2-dev (>= 0.8.1), libgdome2-cpp-smart-dev (>= 0.2.3-4), ${misc:Depends} +Description: Minimal XSLT processor working on GDome2 documents + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package includes development support files for the C + library and for its C++ bindings. + +Package: libgdome2-xslt-ocaml +Architecture: any +Depends: ocaml-base-nox-${F:OCamlABI}, libgdome2-ocaml (>= 0.2.3-4), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for a minimal GDome2 based XSLT processor + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package ships the OCaml language bindings for gdome2-xslt. + . + This package contains only the OCaml shared runtime stub libraries. + +Package: libgdome2-xslt-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, libgdome2-xslt-ocaml (= ${Source-Version}), libgdome2-ocaml-dev (>= 0.2.3-4), libxslt1-dev, libgdome2-dev (>= 0.8.1), ${misc:Depends} +Description: OCaml bindings for a minimal GDome2 based XSLT processor + gdome2-xslt is a very small C library that implements a minimal + XSLT processor that can be used to apply XSLT stylesheets to + gdome2 documents. + . + This package ships the OCaml language bindings for gdome2-xslt. + . + This package contains OCaml development stuff for gdome2-xslt. + diff --git a/DEVEL/gdome_xslt/debian/copyright b/DEVEL/gdome_xslt/debian/copyright new file mode 100644 index 000000000..5cafed7bd --- /dev/null +++ b/DEVEL/gdome_xslt/debian/copyright @@ -0,0 +1,18 @@ +This package was debianized by Stefano Zacchiroli on +Sat, 6 Apr 2002 13:00:49 +0200. + +It was exported from the HELM CVS which is accesible using ViewCVS from: + http://www.cs.unibo.it/helm/ + +Upstream Author: + Claudio Sacerdoti Coen + +Copyright: + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + On a Debian GNU/Linux system, the LGPL can be found as + /usr/share/common-licenses/LGPL-2.1. diff --git a/DEVEL/gdome_xslt/debian/docs b/DEVEL/gdome_xslt/debian/docs new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.examples b/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.examples new file mode 100644 index 000000000..23610114a --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.examples @@ -0,0 +1,2 @@ +ocaml/test/test.ml +test_files/* diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.install b/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.install new file mode 100644 index 000000000..e82158cf4 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-dev.install @@ -0,0 +1,5 @@ +debian/tmp/usr/include/ +debian/tmp/usr/lib/*.a +debian/tmp/usr/lib/*.la +debian/tmp/usr/lib/*.so +debian/tmp/usr/lib/pkgconfig/ diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs new file mode 100644 index 000000000..14f5df548 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs @@ -0,0 +1 @@ +usr/lib/ocaml/3.09.1 diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs.in b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs.in new file mode 100644 index 000000000..92126d87b --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.dirs.in @@ -0,0 +1 @@ +usr/lib/ocaml/@OCamlABI@ diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.examples b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.examples new file mode 100644 index 000000000..354012c11 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.examples @@ -0,0 +1,3 @@ +C/test/test.c +C++/test/main.cc +test_files/* diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install new file mode 100644 index 000000000..814f477f4 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install @@ -0,0 +1,3 @@ +debian/tmp/usr/lib/ocaml/3.09.1/stublibs/*.owner +debian/tmp/usr/lib/ocaml/3.09.1/stublibs/lib*.so +debian/tmp/usr/lib/ocaml/3.09.1/gdome2-xslt/ diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install.in b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install.in new file mode 100644 index 000000000..4888ff757 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml-dev.install.in @@ -0,0 +1,3 @@ +debian/tmp/usr/lib/ocaml/@OCamlABI@/stublibs/*.owner +debian/tmp/usr/lib/ocaml/@OCamlABI@/stublibs/lib*.so +debian/tmp/usr/lib/ocaml/@OCamlABI@/gdome2-xslt/ diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs new file mode 100644 index 000000000..14f5df548 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs @@ -0,0 +1 @@ +usr/lib/ocaml/3.09.1 diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs.in b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs.in new file mode 100644 index 000000000..92126d87b --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.dirs.in @@ -0,0 +1 @@ +usr/lib/ocaml/@OCamlABI@ diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install new file mode 100644 index 000000000..e51260287 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/ocaml/3.09.1/stublibs/dll*.so diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install.in b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install.in new file mode 100644 index 000000000..b13996552 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt-ocaml.install.in @@ -0,0 +1 @@ +debian/tmp/usr/lib/ocaml/@OCamlABI@/stublibs/dll*.so diff --git a/DEVEL/gdome_xslt/debian/libgdome2-xslt0c2a.install b/DEVEL/gdome_xslt/debian/libgdome2-xslt0c2a.install new file mode 100644 index 000000000..79bbe2f02 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/libgdome2-xslt0c2a.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/*.so.* diff --git a/DEVEL/gdome_xslt/debian/rules b/DEVEL/gdome_xslt/debian/rules new file mode 100755 index 000000000..52a3e2ea3 --- /dev/null +++ b/DEVEL/gdome_xslt/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/autotools.mk + +OCAMLABI := $(shell ocamlc -version) +OFILES := $(patsubst %.in,%,$(shell ls debian/*.in)) +DEB_DH_GENCONTROL_ARGS = -- -VF:OCamlABI="$(OCAMLABI)" + +ocamlinit: + for f in $(OFILES); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done diff --git a/DEVEL/gdome_xslt/gdome2-xslt-cpp-smart.pc.in b/DEVEL/gdome_xslt/gdome2-xslt-cpp-smart.pc.in new file mode 100644 index 000000000..0046f27e7 --- /dev/null +++ b/DEVEL/gdome_xslt/gdome2-xslt-cpp-smart.pc.in @@ -0,0 +1,14 @@ +# This is a comment +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datadir=@datadir@ + +Name: Gdome2/XSLT C++ Binding +Description: API for applying XSLT stylesheets to Gdome2 documents +Version: @VERSION@ +Requires: gdome2 libxslt +Libs: @LIBXSLT_LIBS@ -L${libdir} -lgdome_xslt_cpp_smart +Cflags: @LIBXSLT_CFLAGS@ -I${includedir}/@PACKAGE@ + diff --git a/DEVEL/gdome_xslt/gdome2-xslt.pc.in b/DEVEL/gdome_xslt/gdome2-xslt.pc.in new file mode 100644 index 000000000..88df34a8d --- /dev/null +++ b/DEVEL/gdome_xslt/gdome2-xslt.pc.in @@ -0,0 +1,14 @@ +# This is a comment +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datadir=@datadir@ + +Name: Gdome2/XSLT C Binding +Description: API for applying XSLT stylesheets to Gdome2 documents +Version: @VERSION@ +Requires: gdome2 libxslt +Libs: @LIBXSLT_LIBS@ -L${libdir} -lgdome_xslt +Cflags: @LIBXSLT_CFLAGS@ -I${includedir}/@PACKAGE@ + diff --git a/DEVEL/gdome_xslt/ocaml/.cvsignore b/DEVEL/gdome_xslt/ocaml/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/ocaml/Makefile.am b/DEVEL/gdome_xslt/ocaml/Makefile.am new file mode 100644 index 000000000..30e2ce870 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gdome_xslt test diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/.cvsignore b/DEVEL/gdome_xslt/ocaml/gdome_xslt/.cvsignore new file mode 100644 index 000000000..68ade6c12 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/.cvsignore @@ -0,0 +1,23 @@ +META +Makefile +Makefile.in +config.cache +config.log +config.status +configure +gdome2-xslt.cma +gdome_xslt.cmi +gdome_xslt.cmo +gdome_xslt.cmx +gdome2-xslt.cmxa +gdome_xslt.o +gdome_xslt_init.cmi +gdome_xslt_init.cmo +gdome_xslt_init.cmx +gdome_xslt_init.o +i_gdome_xslt.cmi +i_gdome_xslt.cmo +i_gdome_xslt.cmx +i_gdome_xslt.o +ml_gdome_xslt.o +.deps diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/.depend b/DEVEL/gdome_xslt/ocaml/gdome_xslt/.depend new file mode 100644 index 000000000..519df4ba6 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/.depend @@ -0,0 +1,5 @@ +gdome_xslt.cmo: i_gdome_xslt.cmo gdome_xslt.cmi +gdome_xslt.cmx: i_gdome_xslt.cmx gdome_xslt.cmi +gdome_xslt_init.cmo: i_gdome_xslt.cmo gdome_xslt_init.cmi +gdome_xslt_init.cmx: i_gdome_xslt.cmx gdome_xslt_init.cmi +gdome_xslt.cmi: i_gdome_xslt.cmo diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/META.in b/DEVEL/gdome_xslt/ocaml/gdome_xslt/META.in new file mode 100644 index 000000000..e5c9b19a1 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/META.in @@ -0,0 +1,4 @@ +requires="gdome2" +version="@VERSION@" +archive(byte)="mlgdome2-xslt.cma gdome_xslt_init.cmo" +archive(native)="mlgdome2-xslt.cmxa gdome_xslt_init.cmx" diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/Makefile.am b/DEVEL/gdome_xslt/ocaml/gdome_xslt/Makefile.am new file mode 100644 index 000000000..4da9bef88 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/Makefile.am @@ -0,0 +1,114 @@ + +ARCHIVE = mlgdome2-xslt +PKGNAME = gdome2-xslt +OCAMLINSTALLDIR = $(DESTDIR)$(OCAMLSTDLIBDIR)/$(PKGNAME) +STUBSDIR = $(DESTDIR)$(OCAMLSTUBDIR) +OCAMLFLAGS = -I +gdome2 +OCAMLC = @OCAMLC@ ${OCAMLFLAGS} +OCAMLOPT = @OCAMLOPT@ ${OCAMLFLAGS} +OCAMLDEP = @OCAMLDEP@ +OCAML_CFLAGS = @OCAML_CFLAGS@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = ocamlmklib +DLL = dll$(ARCHIVE).so + +BUILT_SOURCES = x_gdome_xslt.c + +CLEANFILES = \ + $(ARCHIVE).cma $(ARCHIVE).cmxa $(ARCHIVE).a lib$(ARCHIVE).a $(DLL) \ + *.cmo *.cmx *.cmi $(BUILT_SOURCES) + +EXTRA_DIST = \ + META.in .depend \ + gdome_xslt.ml gdome_xslt.mli gdome_xslt_init.ml gdome_xslt_init.mli \ + i_gdome_xslt.ml \ + ocaml-io.h + +if HAVE_OCAMLOPT_COND +noinst_DATA = \ + $(ARCHIVE).cma $(DLL) $(ARCHIVE).cmxa $(ARCHIVE).a lib$(ARCHIVE).a \ + gdome_xslt_init.cmo gdome_xslt_init.cmx +else +noinst_DATA = \ + $(ARCHIVE).cma $(DLL) gdome_xslt_init.cmo lib$(ARCHIVE).a +endif + +noinst_LTLIBRARIES = libmlgdome2-xslt.la +C_SRC = ml_gdome_xslt.c x_gdome_xslt.c +libmlgdome2_xslt_la_SOURCES = $(C_SRC) + +O_S = $(C_SRC:%.c=.libs/%.o) +LO_S = $(O_S:%.o=%.lo) +CMA_DEPS = i_gdome_xslt.cmo gdome_xslt.cmo +CMXA_DEPS = $(CMA_DEPS:%.cmo=%.cmx) +SHARED_LIBS = $(LIBXSLT_LIBS) $(GDOME_LIBS) + +x_gdome_xslt.c: $(top_srcdir)/C/gdome_xslt/gdome_xslt.c + cp $< $@ + +$(ARCHIVE).cma: $(CMA_DEPS) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +$(ARCHIVE).cmxa: $(CMXA_DEPS) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +lib$(ARCHIVE).a $(DLL): $(O_S) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) + +INCLUDES = $(GDOME_CFLAGS) $(MLGDOME_CFLAGS) -I/usr/include/caml -I$(top_srcdir)/C/gdome_xslt + +BYTECODE_STUFF = \ + $(ARCHIVE).cma $(DLL) i_gdome_xslt.cmi i_gdome_xslt.ml gdome_xslt.cmi \ + gdome_xslt.mli gdome_xslt_init.cmi gdome_xslt_init.mli gdome_xslt_init.cmo \ + lib$(ARCHIVE).a +NATIVECODE_STUFF = \ + $(ARCHIVE).cmxa $(ARCHIVE).a gdome_xslt_init.cmx gdome_xslt_init.o +if HAVE_OCAMLOPT_COND +install-data-local: $(BYTECODE_STUFF) $(NATIVECODE_STUFF) +else +install-data-local: $(BYTECODE_STUFF) +endif + $(mkinstalldirs) $(OCAMLINSTALLDIR) $(STUBSDIR) + chmod -x $(DLL) + for i in $^; do \ + if [ "$$i" != "$(DLL)" ]; then \ + $(INSTALL_DATA) $$i $(OCAMLINSTALLDIR)/$$i; \ + fi \ + done + if [ "x$(OCAMLFIND)" != "x" ]; then \ + mv $(OCAMLINSTALLDIR) $(OCAMLINSTALLDIR).saved; \ + $(OCAMLFIND) install -destdir $(DESTDIR)$(OCAMLSTDLIBDIR)/ $(PKGNAME) META $(DLL); \ + $(INSTALL_DATA) $(OCAMLINSTALLDIR).saved/* $(OCAMLINSTALLDIR)/; \ + rm -rf $(OCAMLINSTALLDIR).saved/; \ + else \ + $(INSTALL_DATA) $(DLL) $(STUBSDIR); \ + fi + +uninstall-local: + if [ "x$(OCAMLFIND)" != "x" ]; then \ + $(OCAMLFIND) remove -destdir $(DESTDIR)$(OCAMLSTDLIBDIR)/ $(PKGNAME); \ + else \ + rm -rf $(OCAMLINSTALLDIR); \ + rm $(STUBSDIR)/$(DLL); \ + fi + rm $(STUBSDIR)/lib$(ARCHIVE).so + +#### OCaml only stuff from now on + +DEPOBJS = *.ml *.mli + +depend: + $(OCAMLDEP) $(DEPOBJS) > .depend + +%.cmi : $(srcdir)/%.mli + if test ! -e $(@:%.cmi=%.mli) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi + $(OCAMLC) -c $(@:%.cmi=%.mli) + +%.cmo : $(srcdir)/%.ml + if test ! -e $(@:%.cmo=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi + $(OCAMLC) -c $(@:%.cmo=%.ml) + +%.cmx %.o : $(srcdir)/%.ml + if test ! -e $(@:%.cmx=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi + $(OCAMLOPT) -c $(@:%.cmx=%.ml) + +include .depend + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.ml b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.ml new file mode 100644 index 000000000..b64a006b4 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.ml @@ -0,0 +1,59 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + *) + +let processStylesheet style = + I_gdome_xslt.processStylesheet style#as_Document +;; + +let applyStylesheet ~source ~stylesheet ~params = + let res = + I_gdome_xslt.applyStylesheet ~source:(source#as_Document) ~stylesheet + ~params + in + new Gdome.document res +;; + +let saveResultToChannel ~outchan ~result ~stylesheet = + I_gdome_xslt.saveResultToChannel + ~outchan + ~result:result#as_Document + ~stylesheet +;; + +let setErrorCallback = function + | None -> I_gdome_xslt.disableErrorCallback () + | Some (callback: string -> unit) -> + Callback.register "error_callback" callback; + I_gdome_xslt.enableErrorCallback () +;; +let setDebugCallback = function + | None -> I_gdome_xslt.disableDebugCallback () + | Some (callback: string -> unit) -> + Callback.register "debug_callback" callback; + I_gdome_xslt.enableDebugCallback () +;; + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.mli b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.mli new file mode 100644 index 000000000..8115457f3 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt.mli @@ -0,0 +1,59 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + *) + +(* processStylesheet stylesheet *) +(* Process a stylesheet so that it can be subsequently used *) +(* with applyStylesheet. *) +val processStylesheet: + Gdome.document -> + I_gdome_xslt.processed_stylesheet + +(* applyStylesheet source stylesheet params *) +(* Applies a processed stylesheet to a source document, using *) +(* the given list of parameters (couples name,value) *) +val applyStylesheet: + source: Gdome.document -> + stylesheet:I_gdome_xslt.processed_stylesheet -> + params:(string * string) list -> + Gdome.document + +(* output the result of a previous XSLT transformation to an *) +(* output channel *) +val saveResultToChannel: + outchan: out_channel -> + result: Gdome.document -> + stylesheet: I_gdome_xslt.processed_stylesheet -> + unit + +(** set error callback, that is a function invoked each time an error message is +generated. If None is passed, libxslt default error callback is used *) +val setErrorCallback: (string -> unit) option -> unit + +(** set debug callback, that is a function invoked each time a debugging message +is generated. If None is passed, libxslt default error callback is used *) +val setDebugCallback: (string -> unit) option -> unit + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.ml b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.ml new file mode 100644 index 000000000..e7da4e02d --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.ml @@ -0,0 +1,41 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + *) + +exception ProcessStylesheetException +exception ApplyStylesheetException + +let _ = + Callback.register_exception + "ProcessStylesheetException" ProcessStylesheetException +;; + +let _ = + Callback.register_exception + "ApplyStylesheetException" ApplyStylesheetException +;; + +I_gdome_xslt.setXsltMaxDepth 2000;; diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.mli b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.mli new file mode 100644 index 000000000..d3e6d670e --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/gdome_xslt_init.mli @@ -0,0 +1,37 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + *) + +(**************************** WARNING!!! ***********************************) +(*** ***) +(*** This file must always be linked with any code using gdome_xslt and ***) +(*** must be linked as the first file. It is responsible of initializing ***) +(*** the whole binding, registering some ocaml values to the C level. ***) +(*** ***) +(***************************************************************************) + +exception ProcessStylesheetException +exception ApplyStylesheetException diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/i_gdome_xslt.ml b/DEVEL/gdome_xslt/ocaml/gdome_xslt/i_gdome_xslt.ml new file mode 100644 index 000000000..6f686c482 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/i_gdome_xslt.ml @@ -0,0 +1,58 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + *) + +type processed_stylesheet + +external setXsltMaxDepth: + int -> + unit + = "setXsltMaxDepth" + +external processStylesheet: + [> `Document] GdomeT.t -> + processed_stylesheet + = "ml_processStylesheet" + +external applyStylesheet: + source: [> `Document] GdomeT.t -> + stylesheet: processed_stylesheet -> + params: (string * string) list -> + TDocument.t + = "ml_applyStylesheet" + +external saveResultToChannel: + outchan: out_channel -> + result: TDocument.t -> + stylesheet: processed_stylesheet -> + unit + = "ml_saveResultToChannel" + +external enableErrorCallback : unit -> unit = "ml_enableErrorCallback" +external disableErrorCallback : unit -> unit = "ml_disableErrorCallback" +external enableDebugCallback : unit -> unit = "ml_enableDebugCallback" +external disableDebugCallback : unit -> unit = "ml_disableDebugCallback" + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.c b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.c new file mode 100644 index 000000000..225698a79 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.c @@ -0,0 +1,186 @@ +/* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + */ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "ocaml-io.h" +#include "mlgdomevalue.h" +#include "gdome_xslt.h" + +xsltStylesheetPtr XsltStylesheetPtr_val(value); + +static void ml_xsltFreeStylesheet(value v) +{ + xsltFreeStylesheet(XsltStylesheetPtr_val(v)); +} + +xsltStylesheetPtr XsltStylesheetPtr_val(value v) +{ + CAMLparam1(v); + xsltStylesheetPtr res = *((xsltStylesheetPtr*) Data_custom_val(v)); + CAMLreturn(res); +} + +value Val_XsltStylesheetPtr(xsltStylesheetPtr obj) +{ + CAMLparam0(); + CAMLlocal1(v); + static struct custom_operations ops = { + "http://www.cs.unibo.it/helm/gdome_xslt/XsltStylesheetPtr", + ml_xsltFreeStylesheet, + custom_compare_default, + custom_hash_default, + custom_serialize_default, + custom_deserialize_default + }; + + v = alloc_custom(&ops, sizeof(xsltStylesheetPtr), 0, 1); + *((xsltStylesheetPtr*) Data_custom_val(v)) = obj; + + CAMLreturn(v); +} + +value ml_processStylesheet(value style) +{ + CAMLparam1(style); + xsltStylesheetPtr res; + res = processStylesheet(Document_val(style)); + if (res == NULL) { + value* excp; + excp = caml_named_value("ProcessStylesheetException"); + assert(excp != NULL); + raise_constant(*excp); + } + CAMLreturn(Val_XsltStylesheetPtr(res)); +} + +value setXsltMaxDepth(value depth) +{ + CAMLparam1(depth); + xsltMaxDepth = Int_val(depth); + CAMLreturn0; +} + +value ml_applyStylesheet(value source, value style, value params) +{ + CAMLparam3(source,style,params); + CAMLlocal1(list); + GdomeDocument* res; + int i; + const char** c_params; + + i = 0 ; list = params; + while(list != Val_int(0)) { + list = Field(list,1); + i++; + } + c_params = (const char **)malloc(sizeof(char *) * (i * 2 + 1)); + + i = 0; list = params; + while(list != Val_int(0)) { + c_params[i] = String_val(Field(Field(list,0),0)); + c_params[i+1] = String_val(Field(Field(list,0),1)); + list = Field(list,1); + i+=2; + } + c_params[i] = NULL; + enter_blocking_section(); + res = applyStylesheet(Document_val(source), + XsltStylesheetPtr_val(style), + c_params); + leave_blocking_section(); + free(c_params); + if (res == NULL) { + value* excp; + excp = caml_named_value("ApplyStylesheetException"); + assert(excp != NULL); + raise_constant(*excp); + } + CAMLreturn(Val_Document(res)); +} + +value ml_saveResultToChannel(value channel, + value result, + value stylesheet) +{ + CAMLparam3(channel, result, stylesheet); + + saveResultToFd((Channel(channel))->fd, + Document_val(result), + XsltStylesheetPtr_val(stylesheet)); + + CAMLreturn0; +} + + /* error callback handling */ + +static void ml_gdomeXsltErrorCallback(const char *msg) { + callback(*caml_named_value("error_callback"), copy_string(msg)); + + return; +} + +value ml_enableErrorCallback(value unit) { + CAMLparam1(unit); + setErrorCallback(ml_gdomeXsltErrorCallback); + CAMLreturn(Val_unit); +} + +value ml_disableErrorCallback(value unit) { + CAMLparam1(unit); + setErrorCallback(NULL); + CAMLreturn(Val_unit); +} + + /* debug callback handling */ + +static void ml_gdomeXsltDebugCallback(const char *msg) { + callback(*caml_named_value("debug_callback"), copy_string(msg)); + + return; +} + +value ml_enableDebugCallback(value unit) { + CAMLparam1(unit); + setDebugCallback(ml_gdomeXsltDebugCallback); + CAMLreturn(Val_unit); +} + +value ml_disableDebugCallback(value unit) { + CAMLparam1(unit); + setDebugCallback(NULL); + CAMLreturn(Val_unit); +} + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.h b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.h new file mode 100644 index 000000000..a173bc97f --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.h @@ -0,0 +1,40 @@ +/* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002: + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to {sacerdot,zack}@cs.unibo.it + */ + +xsltStylesheetPtr XsltStylesheetPtr_val(value); +value Val_XsltStylesheetPtr(xsltStylesheetPtr); + +value ml_processStylesheet(value style); +value ml_applyStylesheet(value source, value style, value params); + +value ml_saveResultToChannel(value channel, value result, value stylesheet); + +value ml_enableErrorCallback(value unit); +value ml_disableErrorCallback(value unit); +value ml_enableDebugCallback(value unit); +value ml_disableDebugCallback(value unit); + diff --git a/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h new file mode 100644 index 000000000..6ce9493c8 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h @@ -0,0 +1,54 @@ +/**********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ +/* */ +/* Copyright 1996 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file */ +/* ../../LICENSE-INRIA. */ +/* */ +/**********************************************************************/ + +/* Buffered input/output */ + +#ifndef __IO_H__ +#define __IO_H__ + +#ifndef IO_BUFFER_SIZE +#define IO_BUFFER_SIZE 4096 +#endif + +typedef long file_offset; + +struct channel { + int fd; /* Unix file descriptor */ + file_offset offset; /* Absolute position of fd in the file */ + char * end; /* Physical end of the buffer */ + char * curr; /* Current position in the buffer */ + char * max; /* Logical end of the buffer (for input) */ + void * mutex; /* Placeholder for mutex (for systhreads) */ + struct channel * next; /* Linear chaining of channels (flush_all) */ + int revealed; /* For Cash only */ + int old_revealed; /* For Cash only */ + int refcount; /* For flush_all and for Cash */ + char buff[IO_BUFFER_SIZE]; /* The buffer itself */ +}; + +/* For an output channel: + [offset] is the absolute position of the beginning of the buffer [buff]. + For an input channel: + [offset] is the absolute position of the logical end of the buffer, [max]. +*/ + +/* Functions and macros that can be called from C. Take arguments of + type struct channel *. No locking is performed. */ + +/* Extract a struct channel * from the heap object representing it */ + +#define Channel(v) (*((struct channel **) (Data_custom_val(v)))) + +#endif /* __IO_H__ */ + diff --git a/DEVEL/gdome_xslt/ocaml/test/.cvsignore b/DEVEL/gdome_xslt/ocaml/test/.cvsignore new file mode 100644 index 000000000..fb5d24d4f --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/test/.cvsignore @@ -0,0 +1,8 @@ +test.cmi +test.cmo +test.cmx +test.o +test +test.opt +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/ocaml/test/Makefile.am b/DEVEL/gdome_xslt/ocaml/test/Makefile.am new file mode 100644 index 000000000..95f83fa79 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/test/Makefile.am @@ -0,0 +1,25 @@ +REQUIRES = gdome2 +OCAMLFIND = @OCAMLFIND@ +OCAMLC = $(OCAMLFIND) @OCAMLC@ -package "$(REQUIRES)" +OCAMLOPT = $(OCAMLFIND) @OCAMLOPT@ -package "$(REQUIRES)" +CMA = $(top_builddir)/ocaml/gdome_xslt/mlgdome2-xslt.cma +CMXA = $(top_builddir)/ocaml/gdome_xslt/mlgdome2-xslt.cmxa +INIT_CMO = $(top_builddir)/ocaml/gdome_xslt/gdome_xslt_init.cmo +INIT_CMX = $(top_builddir)/ocaml/gdome_xslt/gdome_xslt_init.cmx +OCAMLC_FLAGS = -I $(top_builddir)/ocaml/gdome_xslt/ + +EXTRA_DIST = test.ml +CLEANFILES = test{,.o,.opt} test.cm[iox] + +if HAVE_OCAMLOPT_COND +noinst_DATA = test.opt test +else +noinst_DATA = test +endif + +test: test.ml $(CMA) $(INIT_CMO) + $(OCAMLC) -o $@ -linkpkg $(OCAMLC_FLAGS) $(CMA) $(INIT_CMO) $< + +test.opt: test.ml $(CMXA) $(INIT_CMX) + $(OCAMLOPT) -o $@ -linkpkg $(OCAMLC_FLAGS) $(CMXA) $(INIT_CMX) $< + diff --git a/DEVEL/gdome_xslt/ocaml/test/test.ml b/DEVEL/gdome_xslt/ocaml/test/test.ml new file mode 100644 index 000000000..4cd103435 --- /dev/null +++ b/DEVEL/gdome_xslt/ocaml/test/test.ml @@ -0,0 +1,79 @@ +(* This file is part of an ocaml binding of an XSLT engine working on Gdome + * documents. + * + * The code is largely based on the code of T.J. Mather's XML::GDOME::XSLT + * Perl module (http://kobesearch.cpan.org/search?dist=XML-GDOME-XSLT) + * + * Copyright (C) 2002 Claudio Sacerdoti Coen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please send an email to + *) + +let (output_file, + correct_output_file, + input_file, + stylesheet_file) = + ("../../test_files/output.xml", + "../../test_files/output.xml.correct", + "../../test_files/input.xml", + "../../test_files/stylesheet.xsl") +in +let domImpl = Gdome.domImplementation () in + let input = + domImpl#createDocumentFromURI ~uri:input_file () + and style = + domImpl#createDocumentFromURI ~uri:stylesheet_file () + in + (* First of all, let's try the exception handling machinery *) + let _ = + try + ignore (Gdome_xslt.processStylesheet input); + assert false (* previous line should rise an exception *) + with + Gdome_xslt_init.ProcessStylesheetException -> () + in + let pstyle = Gdome_xslt.processStylesheet style in + let output = + Gdome_xslt.applyStylesheet input pstyle + ["parameter1","'value1'" ; + "parameter2","'value2'" ; + "parameter3","'value3'" + ] + in +(* (* old version: use gdome serialization functions *) + let res = + domImpl#saveDocumentToFile ~doc:output ~name:output_file () + in + if not res then + prerr_endline ("Error saving to document " ^ output_file) + else + begin + Printf.printf + "The test was successful iff %s is equal to %s\n" + output_file + correct_output_file + end +*) + (* new version: use libxslt serialization functions *) + let outchan = open_out output_file in + Gdome_xslt.saveResultToChannel ~outchan ~result:output ~stylesheet:pstyle; + close_out outchan; + Printf.printf + "The test was successful iff %s is equal to %s\n" + output_file + correct_output_file +;; diff --git a/DEVEL/gdome_xslt/test_files/.cvsignore b/DEVEL/gdome_xslt/test_files/.cvsignore new file mode 100644 index 000000000..d1e494380 --- /dev/null +++ b/DEVEL/gdome_xslt/test_files/.cvsignore @@ -0,0 +1,3 @@ +output.xml +Makefile +Makefile.in diff --git a/DEVEL/gdome_xslt/test_files/Makefile.am b/DEVEL/gdome_xslt/test_files/Makefile.am new file mode 100644 index 000000000..ead191b52 --- /dev/null +++ b/DEVEL/gdome_xslt/test_files/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = input.xml output.xml.correct stylesheet.xsl diff --git a/DEVEL/gdome_xslt/test_files/input.xml b/DEVEL/gdome_xslt/test_files/input.xml new file mode 100644 index 000000000..b6ffa38fd --- /dev/null +++ b/DEVEL/gdome_xslt/test_files/input.xml @@ -0,0 +1,4 @@ + + + It works! + diff --git a/DEVEL/gdome_xslt/test_files/output.xml.correct b/DEVEL/gdome_xslt/test_files/output.xml.correct new file mode 100644 index 000000000..c4adda3d7 --- /dev/null +++ b/DEVEL/gdome_xslt/test_files/output.xml.correct @@ -0,0 +1,4 @@ + +value2value3value1 + It works! + diff --git a/DEVEL/gdome_xslt/test_files/stylesheet.xsl b/DEVEL/gdome_xslt/test_files/stylesheet.xsl new file mode 100644 index 000000000..ca4534e12 --- /dev/null +++ b/DEVEL/gdome_xslt/test_files/stylesheet.xsl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/gtkmathview-bonobo/.cvsignore b/DEVEL/gtkmathview-bonobo/.cvsignore new file mode 100644 index 000000000..d4b698b3a --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/.cvsignore @@ -0,0 +1,18 @@ +aclocal.m4 +config.h.in +Makefile.in +autom4te.cache +config.guess +config.sub +install-sh +mkinstalldirs +ltmain.sh +configure +depcomp +Makefile +config.h +config.log +config.status +libtool +stamp-h1 +gtkmathview-bonobo.pc diff --git a/DEVEL/gtkmathview-bonobo/AUTHORS b/DEVEL/gtkmathview-bonobo/AUTHORS new file mode 100644 index 000000000..c4b11a9bd --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/AUTHORS @@ -0,0 +1,2 @@ +Luca Padovani +Pouria Masoudi diff --git a/DEVEL/gtkmathview-bonobo/ChangeLog b/DEVEL/gtkmathview-bonobo/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gtkmathview-bonobo/LICENSE b/DEVEL/gtkmathview-bonobo/LICENSE new file mode 100644 index 000000000..d9bf0fad0 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/LICENSE @@ -0,0 +1,23 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + diff --git a/DEVEL/gtkmathview-bonobo/Makefile.am b/DEVEL/gtkmathview-bonobo/Makefile.am new file mode 100644 index 000000000..afa1ecdc2 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/Makefile.am @@ -0,0 +1,20 @@ +EXTRA_DIST = config.h.in +SUBDIRS = idl src test +CLEANFILES = core *.log *.eps + +pkgconfigdir = $(libdir)/pkgconfig +#pkgconfig_DATA=gtkmathview-bonobo.pc + +backup: + tar cvfz ../@PACKAGE@-@VERSION@-`date|tr ' ' '_'|tr ':' '_'`.tar.gz . + +cleanbak: + -rm -f `find . -name "*~"` + +lc: + @( \ + CFILES=`find . -name "*.c"`; \ + HFILES=`find . -name "*.h"`; \ + wc -l $$CFILES $$HFILES | tail -n 1 \ + ) + diff --git a/DEVEL/gtkmathview-bonobo/NEWS b/DEVEL/gtkmathview-bonobo/NEWS new file mode 100644 index 000000000..bbb294549 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/NEWS @@ -0,0 +1,5 @@ + +Tue, 15 Jul 2003 15:56:54 +0200 + + o The project formally starts + diff --git a/DEVEL/gtkmathview-bonobo/README b/DEVEL/gtkmathview-bonobo/README new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/gtkmathview-bonobo/TODO b/DEVEL/gtkmathview-bonobo/TODO new file mode 100644 index 000000000..8f1032a0c --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/TODO @@ -0,0 +1,21 @@ + +* remove shadow from plugin. This causes the plugin window to be dirty, + find out why + +* disable double buffering for the plugin with GTK+ API? + +* remove black border in upper and left corners of the plugin window + +* try to implement size negotiations with the plugin that sends javascript + to the browser. + +* access object's attribute and children. Jean claims he does + this already, but the code seems to access GLib properties only, + no external params + +* implement a size negotiation mechanism from the plugin using + javascript. The plugin understands its ID from the object element, + calculates the size and sends a URL with a javascript call to a function + that sets width, height attributes of the object element + + diff --git a/DEVEL/gtkmathview-bonobo/configure.ac b/DEVEL/gtkmathview-bonobo/configure.ac new file mode 100644 index 000000000..e30b55212 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/configure.ac @@ -0,0 +1,112 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(gtkmathview-bonobo, [0.0.3]) +AC_CONFIG_SRCDIR(src/GNOME_GtkMathView.server.in.in) +AM_INIT_AUTOMAKE($AC_PACKAGE_NAME, $AC_PACKAGE_VERSION) + +PACKAGE=$PACKAGE_NAME +VERSION=$PACKAGE_VERSION +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) + +GTKMATHVIEW_CONTROL_VERSION_INFO=`echo $VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'` +AC_SUBST(GTKMATHVIEW_CONTROL_VERSION_INFO) + +GTKMATHVIEW_API_VERSION="1.0" +AC_SUBST(GTKMATHVIEW_API_VERSION) +AC_DEFINE_UNQUOTED(MATH_VIEW_API_VERSION, "$GTKMATHVIEW_API_VERSION", [Version number of the API implemented]) + +AC_ARG_ENABLE( + profile, + [ --enable-profile[=ARG] include profiling information [default=no]], + profile=$enableval, + profile=no +) + +AC_ARG_ENABLE( + debug, + [ --enable-debug[=ARG] include debugging debug [default=yes]], + enable_debug=$enableval, + enable_debug=yes +) + +if test "x$enable_debug" = "xyes"; then + AC_DEFINE(ENABLE_DEBUG,,[Define to 1 if you want to enable validity checks while running]) +fi + +dnl AC_CONFIG_HEADERS([config.h]) +AM_CONFIG_HEADER(config.h) + +AH_TOP([ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef config_h +#define config_h +]) + +AH_BOTTOM([ +#endif /* config_h */ +]) + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_HEADER_STDC([]) + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) + +AM_PROG_LIBTOOL + +PKG_CHECK_MODULES(GTKMATHVIEW, gtkmathview >= 0.5.1) +AC_SUBST(GTKMATHVIEW_CFLAGS) +AC_SUBST(GTKMATHVIEW_LIBS) + +PKG_CHECK_MODULES(BONOBO, libbonobo-2.0) +AC_SUBST(BONOBO_CFLAGS) +AC_SUBST(BONOBO_LIBS) + +PKG_CHECK_MODULES(BONOBOUI, libbonoboui-2.0) +AC_SUBST(BONOBOUI_CFLAGS) +AC_SUBST(BONOBOUI_LIBS) + +PKG_CHECK_MODULES(GNOMEUI, libgnomeui-2.0) +AC_SUBST(GNOMEUI_CFLAGS) +AC_SUBST(GNOMEUI_LIBS) + +ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`" +AC_SUBST(ORBIT_IDL) + +BONOBO_IDL_INCLUDES="-I`$PKG_CONFIG --variable=idldir libbonobo-2.0` -I`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`" +AC_SUBST(BONOBO_IDL_INCLUDES) + +AC_CONFIG_FILES([ + Makefile + gtkmathview-bonobo.pc + idl/Makefile + src/Makefile + src/GNOME_GtkMathView.server.in + test/Makefile +]) +AC_OUTPUT diff --git a/DEVEL/gtkmathview-bonobo/gtkmathview-bonobo.pc.in b/DEVEL/gtkmathview-bonobo/gtkmathview-bonobo.pc.in new file mode 100644 index 000000000..aa9499612 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/gtkmathview-bonobo.pc.in @@ -0,0 +1,14 @@ +# This is a comment +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datadir=@datadir@ + +Name: GtkMathView-Bonobo +Description: Bonobo interfaces for GtkMathView +Version: @VERSION@ +Requires: gtkmathview libbonoboui-2.0 +Libs: @DOM_LIBS@ -L${libdir} -lgtkmathview-bonobo +Cflags: @DOM_CFLAGS@ -I${includedir}/@PACKAGE@ + diff --git a/DEVEL/gtkmathview-bonobo/idl/.cvsignore b/DEVEL/gtkmathview-bonobo/idl/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/idl/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/gtkmathview-bonobo/idl/GtkMathView.idl b/DEVEL/gtkmathview-bonobo/idl/GtkMathView.idl new file mode 100644 index 000000000..307c166c1 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/idl/GtkMathView.idl @@ -0,0 +1,105 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +module GNOME { + + module GtkMathView { + + typedef string element_id; + + interface View : Bonobo::Unknown { + + /** + * load: + * @uri: URI of a MathML document + * + * Loads the document at the specified URI in the component + * and displays it. If the load is successful returns @TRUE, + * @FALSE otherwise. + */ + boolean load (in string uri); + + /** + * unload: + * + * Unload any loaded document from the component + */ + void unload (); + + /** + * freeze: + * + * Freezes the component. Any modification to the document is + * not reflected by the view. + */ + void freeze (); + + /** + * thaw: + * + * Thaws the component. If the document was changed while the + * component was frozen, the view is updated. + */ + void thaw (); + + void setIdAttribute (in string ns, in string name); + void getIdAttribute (out string ns, out string name); + + void select (in element_id elem); + void unselect (in element_id elem); + boolean isSelected (in element_id elem); + + boolean elementCoords (in element_id elem, + out short x, out short y); + /** + * elementRectangle: + * @elem: ID of the element + * @x: x coordinate of the element + * @y: y coordinate of the element + * @width: width of the element + * @height: height of the element + * + * Returns the position and the size of the rectangle includes @elem + */ + boolean elementBoundingBox (in element_id elem, + out short width, out short height, out short depth); + + void getSize (out short width, out short height); + + void getTop (out short x, out short y); + void setTop (in short x, in short y); + + void setDefaultFontSize (in short size); + short getDefaultFontSize (); + + void setVerbosity (in short level); + short getVerbosity (); + + }; + + }; + +}; + diff --git a/DEVEL/gtkmathview-bonobo/idl/Makefile.am b/DEVEL/gtkmathview-bonobo/idl/Makefile.am new file mode 100644 index 000000000..14555d1e3 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/idl/Makefile.am @@ -0,0 +1,5 @@ + +idldir = $(datadir)/idl/bonobo-2.0 +idl_DATA = GtkMathView.idl + +EXTRA_DIST = $(idl_DATA) diff --git a/DEVEL/gtkmathview-bonobo/src/.cvsignore b/DEVEL/gtkmathview-bonobo/src/.cvsignore new file mode 100644 index 000000000..7bac46e25 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/.cvsignore @@ -0,0 +1,21 @@ +.deps +.libs +GNOME_GtkMathView.server +GNOME_GtkMathView.server.in +Makefile +Makefile.in +libgtkmathview-bonobo.la +control-factory.lo +control-data.lo +view.lo +aux.lo +handlers.lo +persist-file.lo +persist-stream.lo +GtkMathView-common.c +GtkMathView-common.lo +GtkMathView-skels.c +GtkMathView-skels.lo +GtkMathView-stubs.c +GtkMathView-stubs.lo +GtkMathView.h diff --git a/DEVEL/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in b/DEVEL/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in new file mode 100644 index 000000000..957c40004 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/gtkmathview-bonobo/src/Makefile.am b/DEVEL/gtkmathview-bonobo/src/Makefile.am new file mode 100644 index 000000000..92e6a9690 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/Makefile.am @@ -0,0 +1,68 @@ + +location = $(libdir)/libgtkmathview-bonobo.so +serverdir = $(libdir)/bonobo/servers +server_in_files = GNOME_GtkMathView.server.in.in + +IDL = $(top_srcdir)/idl/GtkMathView.idl + +IDL_GENERATED_C = \ + GtkMathView-common.c \ + GtkMathView-skels.c \ + GtkMathView-stubs.c + +IDL_GENERATED_H = \ + GtkMathView.h + +IDL_GENERATED = $(IDL_GENERATED_C) $(IDL_GENERATED_H) + +CLEANFILES = \ + $(server_in_files:.server.in.in=.server) \ + $(IDL_GENERATED) + +lib_LTLIBRARIES = libgtkmathview-bonobo.la + +libgtkmathview_bonobo_la_LIBADD = \ + $(GTKMATHVIEW_LIBS) \ + $(BONOBOUI_LIBS) \ + $(BONOBO_LIBS) + +libgtkmathview_bonobo_la_LDFLAGS = -version-info @GTKMATHVIEW_CONTROL_VERSION_INFO@ + +libgtkmathview_bonobo_la_SOURCES = \ + $(IDL_GENERATED_C) \ + control-data.c \ + control-factory.c \ + persist-file.c \ + persist-stream.c \ + aux.cc \ + handlers.c \ + view.c + +noinst_HEADERS = \ + control-data.h \ + control-factory.h \ + persist-file.h \ + persist-stream.h \ + handlers.h \ + view.h \ + aux.h + +pkginclude_HEADERS = \ + $(IDL_GENERATED_H) + +server_DATA = $(server_in_files:.server.in.in=.server) +$(server_in_files:.server.in.in=.server): $(server_in_files:.server.in.in=.server.in) Makefile + sed -e "s|\@GTKMATHVIEW_FACTORY_LOCATION\@|$(location)|g" $< >$@ + +view.c : $(VIEW_CORBA_GENERATED) + +$(IDL_GENERATED): $(IDL) + $(ORBIT_IDL) $(BONOBO_IDL_INCLUDES) $< + +EXTRA_DIST = $(server_DATA) + +INCLUDES = \ + $(BONOBOUI_CFLAGS) \ + $(BONOBO_CFLAGS) \ + $(GTKMATHVIEW_CFLAGS) + diff --git a/DEVEL/gtkmathview-bonobo/src/aux.cc b/DEVEL/gtkmathview-bonobo/src/aux.cc new file mode 100644 index 000000000..4ef531239 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/aux.cc @@ -0,0 +1,302 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include + +#include + +#include +#include + +#include + +#include "aux.h" + +#define MATHML_NS_URI "http://www.w3.org/1998/Math/MathML" + +namespace DOM = GdomeSmartDOM; + +static DOM::Element +findElementById(const DOM::Element& el, + const DOM::GdomeString& ns, const DOM::GdomeString& name, + const DOM::GdomeString& id) +{ + assert(el); + if (el.getAttributeNS(ns, name) == id) + return el; + else + for (DOM::Node p = el.get_firstChild(); p; p = p.get_nextSibling()) + if (p.get_nodeType() == DOM::Node::ELEMENT_NODE) + if (DOM::Element res = findElementById(p, ns, name, id)) + return res; + return DOM::Element(); +} + +static unsigned +getDepth(const DOM::Element& elem) +{ + unsigned length = 0; + DOM::Element p = elem; + + while (p) + { + p = p.get_parentNode(); + length++; + } + + return length; +} + +static DOM::Element +findCommonAncestor(const DOM::Element& first, const DOM::Element& last) +{ + if (!first || !last) return DOM::Element(0); + + DOM::Element p(first); + DOM::Element q(last); + + if (p != q) + { + unsigned pDepth = getDepth(p); + unsigned qDepth = getDepth(q); + + while (p && pDepth > qDepth) + { + p = p.get_parentNode(); + pDepth--; + } + + while (q && qDepth > pDepth) + { + q = q.get_parentNode(); + qDepth--; + } + + assert(pDepth == qDepth); + + while (p && q && p != q) + { + p = p.get_parentNode(); + q = q.get_parentNode(); + } + } + + return p; +} + +static void +findCommonSiblings(const DOM::Element& first, const DOM::Element& last, + DOM::Element& firstS, DOM::Element& lastS) +{ + DOM::Element p(first); + DOM::Element q(last); + + if (p != q) + { + unsigned pDepth = getDepth(p); + unsigned qDepth = getDepth(q); + + while (p && pDepth > qDepth) + { + p = p.get_parentNode(); + pDepth--; + } + + while (q && qDepth > pDepth) + { + q = q.get_parentNode(); + qDepth--; + } + + assert(pDepth == qDepth); + + while (p && q && p.get_parentNode() != q.get_parentNode()) + { + p = p.get_parentNode(); + q = q.get_parentNode(); + } + } + + firstS = p; + lastS = q; +} + +static DOM::Node +leftmostChild(const DOM::Node& node) +{ + if (!node) return node; + + DOM::Node firstChild = node.get_firstChild(); + if (!firstChild) return node; + + return leftmostChild(firstChild); +} + +static DOM::Node +rightmostChild(const DOM::Node& node) +{ + if (!node) return node; + + DOM::Node lastChild = node.get_lastChild(); + if (!lastChild) return node; + + return rightmostChild(lastChild); +} + +static DOM::Node +leftSibling(const DOM::Node& node) +{ + DOM::Node p = node; + + if (!p) return p; + + while (p.get_parentNode() && p.get_parentNode().get_firstChild() == p) + p = p.get_parentNode(); + + if (!p.get_parentNode()) return DOM::Node(0); + + DOM::Node prevSibling = p.get_previousSibling(); + assert(prevSibling); + + return rightmostChild(prevSibling); +} + +static DOM::Node +rightSibling(const DOM::Node& node) +{ + DOM::Node p = node; + + if (!p) return p; + + DOM::Node firstChild = p.get_firstChild(); + if (firstChild) return firstChild; + + while (p.get_parentNode() && p.get_parentNode().get_lastChild() == p) + p = p.get_parentNode(); + + if (!p.get_parentNode()) return DOM::Node(0); + + DOM::Node nextSibling = p.get_nextSibling(); + assert(nextSibling); + + return leftmostChild(nextSibling); +} + +extern "C" GdomeElement* +find_common_ancestor(GdomeElement* first, GdomeElement* last) +{ + DOM::Element p(first); + DOM::Element q(last); + return gdome_cast_el(findCommonAncestor(p, q).gdome_object()); +} + +extern "C" GdomeElement* +find_self_or_ancestor(GdomeElement* elem, const gchar* uri, const gchar* name) +{ + DOM::Element el(elem); + + while (el && (el.get_namespaceURI() != uri || el.get_localName() != name)) + el = el.get_parentNode(); + + return gdome_cast_el(el.gdome_object()); +} + +extern "C" void +action_toggle(GdomeElement* elem) +{ + DOM::Element el(elem); + if (el.get_namespaceURI() != MATHML_NS_URI || el.get_localName() != "maction") return; + + guint idx; + if (el.hasAttribute("selection")) + idx = atoi(std::string(el.getAttribute("selection")).c_str()); + else idx = 1; + + idx++; + + std::ostringstream os; + os << idx; + el.setAttribute("selection", os.str()); +} + +extern "C" void +find_common_siblings(GdomeElement* first, GdomeElement* last, + GdomeElement** firstS, GdomeElement** lastS) +{ + DOM::Element fs(0); + DOM::Element ls(0); + + findCommonSiblings(DOM::Element(first), DOM::Element(last), fs, ls); + + if (firstS != NULL) *firstS = gdome_cast_el(fs.gdome_object()); + if (lastS != NULL) *lastS = gdome_cast_el(ls.gdome_object()); +} + +static DOM::Element +findElementWithAttribute(const DOM::Element& elem, const std::string& name) +{ + DOM::Element el(elem); + while (el && !el.hasAttribute(name)) el = el.get_parentNode(); + return el; +} + +static DOM::Element +findElementWithAttributeNS(const DOM::Element& elem, const std::string& ns_uri, const std::string& name) +{ + DOM::Element el(elem); + while (el && !el.hasAttributeNS(ns_uri, name)) el = el.get_parentNode(); + return el; +} + +extern "C" GdomeElement* +find_element_with_id(GdomeElement* elem, GdomeDOMString* ns_uri, GdomeDOMString* name) +{ + assert(name != NULL); + DOM::Element el; + if (ns_uri != NULL) + el = findElementWithAttributeNS(DOM::Element(elem), DOM::GdomeString(ns_uri), DOM::GdomeString(name)); + else + el = findElementWithAttribute(DOM::Element(elem), DOM::GdomeString(name)); + return gdome_cast_el(el.gdome_object()); +} + +extern "C" GdomeDOMString* +find_hyperlink(GdomeElement* elem) +{ + DOM::Element el = findElementWithAttribute(DOM::Element(elem),"href"); + if (el) return el.getAttribute("href").gdome_str(); + else return NULL; +} + +extern "C" GdomeElement* +find_element_by_id(GdomeElement* root, GdomeDOMString* ns_uri, GdomeDOMString* name, + const gchar* id) +{ + DOM::Element el = findElementById(DOM::Element(root), + DOM::GdomeString(ns_uri), DOM::GdomeString(name), + DOM::GdomeString(id)); + return gdome_cast_el(el.gdome_object()); +} + diff --git a/DEVEL/gtkmathview-bonobo/src/aux.h b/DEVEL/gtkmathview-bonobo/src/aux.h new file mode 100644 index 000000000..e7cedd2cd --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/aux.h @@ -0,0 +1,46 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __aux_h__ +#define __aux_h__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + void action_toggle(GdomeElement*); + GdomeElement* find_common_ancestor(GdomeElement*, GdomeElement*); + GdomeElement* find_self_or_ancestor(GdomeElement*, const gchar*, const gchar*); + GdomeElement* find_element_with_id(GdomeElement*, GdomeDOMString*, GdomeDOMString*); + GdomeDOMString* find_hyperlink(GdomeElement*); + GdomeElement* find_element_by_id(GdomeElement*, GdomeDOMString*, GdomeDOMString*, + const gchar*); + +#ifdef __cplusplus +} +#endif + +#endif // __aux_h__ + diff --git a/DEVEL/gtkmathview-bonobo/src/control-data.c b/DEVEL/gtkmathview-bonobo/src/control-data.c new file mode 100644 index 000000000..d97d0fd2f --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/control-data.c @@ -0,0 +1,138 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include + +#include "control-data.h" + +GtkMathViewControlData* +gtk_math_view_control_data_new(BonoboControl* control, GtkMathView *math_view) +{ + GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1); + cd->control = control; /* we don't ref the control this is a weak pointer */ + cd->math_view = math_view; + gtk_widget_ref(GTK_WIDGET(math_view)); + cd->item_factory = NULL; + cd->semantic_selection = FALSE; + cd->first_selected = NULL; + cd->root_selected = NULL; + cd->id_ns_uri = gdome_str_mkref("http://www.cs.unibo.it/helm"); + cd->id_name = gdome_str_mkref("xref"); + cd->x = cd->y = 0; + return cd; +} + +void +gtk_math_view_control_data_destroy(GtkMathViewControlData* cd) +{ + GdomeException exc = 0; + cd->control = NULL; /* don't unref the control, see above */ + gtk_widget_unref(GTK_WIDGET(cd->math_view)); + cd->math_view = NULL; + if (cd->item_factory != NULL) + { + gtk_object_unref(cd->item_factory); + cd->item_factory = NULL; + } + if (cd->first_selected != NULL) + { + gdome_el_unref(cd->first_selected, &exc); + g_assert(exc == 0); + cd->first_selected = NULL; + } + if (cd->root_selected != NULL) + { + gdome_el_unref(cd->root_selected, &exc); + g_assert(exc == 0); + cd->root_selected = NULL; + } + if (cd->id_ns_uri != NULL) + { + gdome_str_unref(cd->id_ns_uri); + cd->id_ns_uri = NULL; + } + if (cd->id_name != NULL) + { + gdome_str_unref(cd->id_name); + cd->id_name = NULL; + } + g_free(cd); +} + +gchar* +gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData* cd) +{ + g_return_val_if_fail(cd != NULL, NULL); + return (cd->id_ns_uri != NULL) ? g_strdup(cd->id_ns_uri->str) : NULL; +} + +void +gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData* cd, const gchar* ns_uri) +{ + g_return_if_fail(cd != NULL); + if (cd->id_ns_uri != NULL) gdome_str_unref(cd->id_ns_uri); + cd->id_ns_uri = (ns_uri != NULL) ? gdome_str_mkref_dup(ns_uri) : NULL; +} + +gchar* +gtk_math_view_control_data_get_id_name(GtkMathViewControlData* cd) +{ + g_return_val_if_fail(cd != NULL, NULL); + return (cd->id_name != NULL) ? g_strdup(cd->id_name->str) : NULL; +} + +void +gtk_math_view_control_data_set_id_name(GtkMathViewControlData* cd, const gchar* name) +{ + g_return_if_fail(cd != NULL); + if (cd->id_name != NULL) gdome_str_unref(cd->id_name); + cd->id_name = (name != NULL) ? gdome_str_mkref_dup(name) : NULL; +} + +void +gtk_math_view_control_data_set_root_selected(GtkMathViewControlData* cd, GdomeElement* elem) +{ + g_return_if_fail(cd != NULL); + GdomeException exc = 0; + + gtk_math_view_freeze(cd->math_view); + + if (cd->root_selected != NULL) + { + gtk_math_view_unselect(cd->math_view, cd->root_selected); + gdome_el_unref(cd->root_selected, &exc); + g_assert(exc == 0); + } + + cd->root_selected = elem; + if (cd->root_selected != NULL) + { + gdome_el_ref(cd->root_selected, &exc); + g_assert(exc == 0); + gtk_math_view_select(cd->math_view, cd->root_selected); + } + + gtk_math_view_thaw(cd->math_view); +} diff --git a/DEVEL/gtkmathview-bonobo/src/control-data.h b/DEVEL/gtkmathview-bonobo/src/control-data.h new file mode 100644 index 000000000..46bc6cef7 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/control-data.h @@ -0,0 +1,53 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __control_data_h__ +#define __control_data_h__ + +#include +#include +#include + +typedef struct _GtkMathViewControlData +{ + BonoboControl* control; /* the control this data belongs to */ + GtkMathView* math_view; + GtkWidget* item_factory; + gboolean semantic_selection; + GdomeElement* first_selected; + GdomeElement* root_selected; + GdomeDOMString* id_ns_uri; + GdomeDOMString* id_name; + gint x; + gint y; +} GtkMathViewControlData; + +GtkMathViewControlData* gtk_math_view_control_data_new(BonoboControl*, GtkMathView*); +void gtk_math_view_control_data_destroy(GtkMathViewControlData*); +gchar* gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData*); +void gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData*, const gchar*); +gchar* gtk_math_view_control_data_get_id_name(GtkMathViewControlData*); +void gtk_math_view_control_data_set_id_name(GtkMathViewControlData*, const gchar*); +void gtk_math_view_control_data_set_root_selected(GtkMathViewControlData*, GdomeElement*); + +#endif // __control_data_h__ diff --git a/DEVEL/gtkmathview-bonobo/src/control-factory.c b/DEVEL/gtkmathview-bonobo/src/control-factory.c new file mode 100644 index 000000000..6d90bef3d --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/control-factory.c @@ -0,0 +1,431 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include +#include +#include + +#include "control-factory.h" +#include "control-data.h" +#include "persist-file.h" +#include "persist-stream.h" +#include "handlers.h" +#include "view.h" + +enum + { + MATH_VIEW_WIDTH, + MATH_VIEW_HEIGHT, + MATH_VIEW_TOP_X, + MATH_VIEW_TOP_Y, + MATH_VIEW_FONT_SIZE, + MATH_VIEW_VERBOSITY, + MATH_VIEW_ID_NS_URI, + MATH_VIEW_ID_NAME + } math_args; + +static void +activate_maction(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + GdomeElement* elem; + + g_return_if_fail(control_data != NULL); + + elem = gtk_math_view_get_element_at(control_data->math_view, control_data->x, control_data->y); + if (elem != NULL) + { + GdomeException exc = 0; + GdomeElement* action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction"); + if (action != NULL) + { + gtk_math_view_freeze(control_data->math_view); + action_toggle(action); + gtk_math_view_thaw(control_data->math_view); + gdome_el_unref(action, &exc); + g_assert(exc == 0); + } + gdome_el_unref(elem, &exc); + g_assert(exc == 0); + } +} + +static void +copy_link_address(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ +} + +static void +zoom_in(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + g_return_if_fail(control_data != NULL); + guint old_font_size = gtk_math_view_get_font_size(control_data->math_view); + gtk_math_view_set_font_size(control_data->math_view, old_font_size + 1); +} + +static void +zoom_out(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + g_return_if_fail(control_data != NULL); + guint old_font_size = gtk_math_view_get_font_size(control_data->math_view); + gtk_math_view_set_font_size(control_data->math_view, old_font_size - 1); +} + +static void +switch_semantic_selection(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + g_return_if_fail(control_data != NULL); + control_data->semantic_selection = !control_data->semantic_selection; + if (control_data->semantic_selection) + { + GdomeElement* elem = find_element_with_id(control_data->root_selected, + control_data->id_ns_uri, + control_data->id_name); + } +} + +/* +static void +copy_selected_markup(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + gchar* res = copy_markup(control_data->root_selected); + if (res != NULL) + { + set_clipboard(res); + g_free(res); + } +} +*/ + +static void +copy_selected_id(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ +} + +static void +select_parent(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + g_return_if_fail(control_data != NULL); + if (control_data->root_selected != NULL) + { + GdomeException exc = 0; + GdomeNode* parent_node = gdome_el_parentNode(control_data->root_selected, &exc); + g_assert(parent_node != NULL); + g_assert(exc == 0); + GdomeElement* parent = gdome_cast_el(parent_node); + gtk_math_view_control_data_set_root_selected(control_data, parent); + gdome_n_unref(parent_node, &exc); + g_assert(exc == 0); + } +} + +static void +deselect(GtkMathViewControlData* control_data, guint action, GtkWidget* widget) +{ + g_return_if_fail(control_data != NULL); + + if (control_data->root_selected != NULL) + { + gtk_math_view_unselect(control_data->math_view, control_data->root_selected); + control_data->root_selected = NULL; + } +} + +/* Our menu, an array of GtkItemFactoryEntry structures that defines each menu item */ +static GtkItemFactoryEntry menu_items[] = { + { "/Activate ", NULL, activate_maction, 0, "", GTK_STOCK_EXECUTE }, + { "/Copy Link Address", NULL, copy_link_address, 0, "", GTK_STOCK_COPY }, + /* { "/Jump To", NULL, NULL, 0, "", GTK_STOCK_JUMP_TO }, */ + { "/sep1", NULL, NULL, 0, "" }, + /* { "/Semantic Selection", NULL, switch_semantic_selection, 0, "" }, */ + /* { "/Copy Selected Markup", NULL, copy_selected_markup, 0, "" }, */ + /* { "/Copy Id", NULL, copy_selected_id, 0, "" }, */ + /* { "/Show Selected", NULL, NULL, 0, "" }, */ + { "/Select Parent", NULL, select_parent, 0, "" }, + { "/De-Select", NULL, deselect, 0, "", GTK_STOCK_CLEAR }, + { "/sep2", NULL, NULL, 0, "" }, + { "/Smaller", NULL, zoom_out, 0, "", GTK_STOCK_ZOOM_OUT }, + { "/Bigger", NULL, zoom_in, 0, "", GTK_STOCK_ZOOM_IN }, + /* { "/Properties...", NULL, NULL, 0, "", GTK_STOCK_PROPERTIES }, */ +}; + +static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); + +void +button_pressed_cb(GtkMathView* math_view, GdkEventButton* event, GtkMathViewControlData* control_data) +{ + g_return_if_fail(math_view != NULL); + g_return_if_fail(event != NULL); + g_return_if_fail(control_data != NULL); + + if (event->button == 3) + { +#if 0 + gtk_menu_popup (GTK_MENU(control_data->popup_menu), NULL, NULL, + NULL, event, event->button, event->time); +#endif + control_data->x = (gint) event->x; + control_data->y = (gint) event->y; + printf("data %d %d\n", control_data->x, control_data->y); + + gtk_item_factory_popup_with_data(control_data->item_factory, + NULL, NULL, event->x_root, event->y_root, + event->button, gtk_get_current_event_time()); + } +} + + +static void +get_prop(BonoboPropertyBag* bag, + BonoboArg* arg, + guint arg_id, + CORBA_Environment *ev, + gpointer user_data) +{ + GtkMathViewControlData* control_data = user_data; + g_assert(control_data != NULL); + + switch (arg_id) + { + case MATH_VIEW_WIDTH: + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_width(control_data->math_view)); + break; + case MATH_VIEW_HEIGHT: + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_height(control_data->math_view)); + break; + case MATH_VIEW_TOP_X: + { + guint top_x; + gtk_math_view_get_top(control_data->math_view, &top_x, NULL); + BONOBO_ARG_SET_INT(arg, top_x); + } + break; + case MATH_VIEW_TOP_Y: + { + guint top_y; + gtk_math_view_get_top(control_data->math_view, NULL, &top_y); + BONOBO_ARG_SET_INT(arg, top_y); + } + break; + case MATH_VIEW_FONT_SIZE: + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_font_size(control_data->math_view)); + break; + case MATH_VIEW_VERBOSITY: + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_log_verbosity(control_data->math_view)); + break; + case MATH_VIEW_ID_NS_URI: + { + gchar* id_ns_uri = gtk_math_view_control_data_get_id_ns_uri(control_data); + BONOBO_ARG_SET_STRING(arg, id_ns_uri); + g_free(id_ns_uri); + } + break; + case MATH_VIEW_ID_NAME: + { + gchar* id_name = gtk_math_view_control_data_get_id_name(control_data); + BONOBO_ARG_SET_STRING(arg, id_name); + g_free(id_name); + } + break; + default: + bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound); + break; + } +} + +static void +set_prop(BonoboPropertyBag* bag, + const BonoboArg* arg, + guint arg_id, + CORBA_Environment* ev, + gpointer user_data) +{ + GtkMathViewControlData *control_data = user_data; + g_assert(control_data != NULL); + + switch (arg_id) + { + case MATH_VIEW_TOP_X: + { + guint old_top_y; + gtk_math_view_get_top(control_data->math_view, NULL, &old_top_y); + gtk_math_view_set_top(control_data->math_view, BONOBO_ARG_GET_INT(arg), old_top_y); + } + break; + case MATH_VIEW_TOP_Y: + { + guint old_top_x; + gtk_math_view_get_top(control_data->math_view, &old_top_x, NULL); + gtk_math_view_set_top(control_data->math_view, BONOBO_ARG_GET_INT(arg), old_top_x); + } + break; + case MATH_VIEW_FONT_SIZE: + gtk_math_view_set_font_size(control_data->math_view, BONOBO_ARG_GET_INT(arg)); + break; + case MATH_VIEW_VERBOSITY: + gtk_math_view_set_log_verbosity(control_data->math_view, BONOBO_ARG_GET_INT(arg)); + break; + case MATH_VIEW_ID_NS_URI: + gtk_math_view_control_data_set_id_ns_uri(control_data, BONOBO_ARG_GET_STRING(arg)); + break; + case MATH_VIEW_ID_NAME: + gtk_math_view_control_data_set_id_name(control_data, BONOBO_ARG_GET_STRING(arg)); + break; + default: + bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound); + break; + } +} + +static void +control_destroy(BonoboObject *object, GtkMathViewControlData *cd) +{ + gtk_math_view_control_data_destroy(cd); +} + +static void +gtk_math_view_control_init(BonoboControl *control, GtkWidget *scrolled_window) +{ + GtkMathViewControlData *control_data; + GtkWidget *math_view; + GtkItemFactory *item_factory; + + Bonobo_UIContainer remote_ui_container; + BonoboUIComponent *ui_component; + + BonoboPropertyBag *prop_bag; + BonoboObject *persist_file; + BonoboObject *persist_stream; + BonoboEventSource *evs; + View* view; + + math_view = gtk_math_view_new(NULL,NULL); + gtk_widget_show(math_view); + + control_data = gtk_math_view_control_data_new(control, (GtkMathView*)math_view); + + g_signal_connect (control, "destroy", G_CALLBACK (control_destroy), control_data); + + /* Same as before but don't bother with the accelerators */ + control_data->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "
", NULL); + gtk_item_factory_create_items (control_data->item_factory, nmenu_items, menu_items, control_data); + /* control_data->popup_menu = gtk_item_factory_get_widget (control_data->item_factory, "
"); */ + /* gtk_widget_ref(control_data->popup_menu); */ + + evs = bonobo_event_source_new(); + bonobo_object_add_interface(BONOBO_OBJECT(control), BONOBO_OBJECT(evs)); + + gtk_container_add(GTK_CONTAINER (scrolled_window), GTK_WIDGET (control_data->math_view)); + + view = view_new(control_data); + bonobo_object_add_interface(BONOBO_OBJECT(control), BONOBO_OBJECT(view)); + + persist_file = gtk_math_view_persist_file_new(GTK_MATH_VIEW(math_view)); + bonobo_object_add_interface(BONOBO_OBJECT(control), persist_file); + + persist_stream = gtk_math_view_persist_stream_new(GTK_MATH_VIEW(math_view)); + bonobo_object_add_interface(BONOBO_OBJECT(control), persist_stream); + + prop_bag = bonobo_property_bag_new(get_prop, set_prop, control_data); + bonobo_control_set_properties(control, BONOBO_OBJREF(prop_bag), NULL); + + bonobo_property_bag_add(prop_bag, "width", + MATH_VIEW_WIDTH, BONOBO_ARG_INT, + NULL, + "Width of the view", 0); + bonobo_property_bag_add(prop_bag, "height", + MATH_VIEW_HEIGHT, BONOBO_ARG_INT, + NULL, + "Height of the view", 0); + bonobo_property_bag_add(prop_bag, "top-x", + MATH_VIEW_TOP_X, BONOBO_ARG_INT, + NULL, + "X coordinate of the top-left corner", 0); + bonobo_property_bag_add(prop_bag, "top-y", + MATH_VIEW_TOP_Y, BONOBO_ARG_INT, + NULL, + "Y coordinate of the top-left corner", 0); + bonobo_property_bag_add(prop_bag, "font-size", + MATH_VIEW_FONT_SIZE, BONOBO_ARG_INT, + NULL, + "Default font size", 0); + bonobo_property_bag_add(prop_bag,"verbosity", + MATH_VIEW_VERBOSITY, BONOBO_ARG_INT, + NULL, + "Verbosity level", 0); + bonobo_property_bag_add(prop_bag, "id-ns-uri", + MATH_VIEW_ID_NS_URI, BONOBO_ARG_STRING, + NULL, + "Namespace URI of ID attribute", 0); + bonobo_property_bag_add(prop_bag, "id-name", + MATH_VIEW_ID_NAME, BONOBO_ARG_STRING, + NULL, + "Name of ID attribute", 0); + + bonobo_object_unref(BONOBO_OBJECT(prop_bag)); + + g_signal_connect(control,"set_frame", G_CALLBACK(set_frame), control_data); + g_signal_connect(control_data->math_view, "button_press_event", G_CALLBACK (button_pressed_cb), + control_data); + g_signal_connect(control_data->math_view, "click", G_CALLBACK (click_cb), + control_data); + g_signal_connect(control_data->math_view, "select_begin", G_CALLBACK(select_begin_cb), + control_data); + g_signal_connect(control_data->math_view, "select_over", G_CALLBACK(select_over_cb), + control_data); + g_signal_connect(control_data->math_view, "select_end", G_CALLBACK(select_end_cb), + control_data); + g_signal_connect(control_data->math_view, "select_abort", G_CALLBACK(select_abort_cb), + control_data); +} + +static BonoboObject* +gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id, + gpointer closure) +{ + BonoboControl *control; + GtkWidget *scrolled_window; + + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + /* putting SHADOW_NONE screws the plugin window, how's that??? */ + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); + gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 0); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_widget_show_all (scrolled_window); + + control = bonobo_control_new(scrolled_window); + + if(control) + { + gtk_math_view_control_init(control,scrolled_window); + return BONOBO_OBJECT(control); + } + else + return NULL; +} + +BONOBO_ACTIVATION_SHLIB_FACTORY (CONTROL_FACTORY_ID, "GtkMathView Factory", + gtk_math_view_control_factory, NULL); + diff --git a/DEVEL/gtkmathview-bonobo/src/control-factory.h b/DEVEL/gtkmathview-bonobo/src/control-factory.h new file mode 100644 index 000000000..0d2e5a24d --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/control-factory.h @@ -0,0 +1,34 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __control_factory_h__ +#define __control_factory_h__ + +#include +#include +#include + +#define CONTROL_FACTORY_ID "OAFIID:GNOME_GtkMathView_Factory:" MATH_VIEW_API_VERSION +#define CONTROL_ID "OAFIID:GNOME_GtkMathView:" MATH_VIEW_API_VERSION + +#endif /* __control_factory_h__ */ diff --git a/DEVEL/gtkmathview-bonobo/src/handlers.c b/DEVEL/gtkmathview-bonobo/src/handlers.c new file mode 100644 index 000000000..4861b2f0b --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/handlers.c @@ -0,0 +1,245 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include "aux.h" +#include "handlers.h" + +static void +set_clipboard(GdomeDOMString* data) +{ + GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text(clipboard, data->str, gdome_str_length(data)); +} + +void +set_frame(BonoboControl *control, gpointer data) +{ +} + +static void +notify_browser(GtkMathViewControlData* control_data, const char* url) +{ + BonoboObject* evs = bonobo_object_query_local_interface(BONOBO_OBJECT(control_data->control), + "IDL:Bonobo/EventSource:1.0"); + if (evs != NULL) + { + BonoboArg* arg = bonobo_arg_new(BONOBO_ARG_STRING); + BONOBO_ARG_SET_STRING(arg, url); + bonobo_event_source_notify_listeners (evs, "URL", arg, NULL); + /* bonobo_arg_release(arg); */ + bonobo_object_unref(BONOBO_OBJECT(evs)); + } +} + +void +click_cb(GtkMathView* math_view, GdomeElement* elem, gint state, + GtkMathViewControlData* control_data) +{ + GdomeException exc = 0; + + g_return_if_fail(math_view != NULL); + g_return_if_fail(control_data != NULL); + + if (elem != NULL) + { + GdomeElement* action; + GdomeDOMString* href = find_hyperlink(elem); + + if (href != NULL) + { + /*gtk_math_view_load_uri(math_view,href->str);*/ + + notify_browser(control_data, href->str); + + //set_clipboard(href); + gdome_str_unref(href); + return; + } + + action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction"); + if (action != NULL) + { + gtk_math_view_freeze(math_view); + action_toggle(action); + gtk_math_view_thaw(math_view); + gdome_el_unref(action, &exc); + g_assert(exc == 0); + return; + } + } + + if (control_data->root_selected != NULL) + { + gtk_math_view_freeze(math_view); + gtk_math_view_unselect(math_view, control_data->root_selected); + gtk_math_view_thaw(math_view); + gdome_el_unref(control_data->root_selected, &exc); + g_assert(exc == 0); + control_data->root_selected = NULL; + } +} + +void +select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state, + GtkMathViewControlData* control_data) +{ + g_return_if_fail(math_view != NULL); + g_return_if_fail(control_data != NULL); + + if (elem != NULL) + { + GdomeException exc = 0; + gtk_math_view_freeze(math_view); + if (control_data->root_selected != NULL) + { + gtk_math_view_unselect(math_view, control_data->root_selected); + gdome_el_unref(control_data->root_selected, &exc); + g_assert(exc == 0); + control_data->root_selected = NULL; + } + + if (control_data->semantic_selection) + { + GdomeElement* new_elem = find_element_with_id(elem, control_data->id_ns_uri, control_data->id_name); + if (new_elem != NULL) + { + gdome_el_ref(new_elem, &exc); + g_assert(exc == 0); + } + control_data->first_selected = control_data->root_selected = new_elem; + } + else + { + gdome_el_ref(elem, &exc); + g_assert(exc == 0); + gdome_el_ref(elem, &exc); + g_assert(exc == 0); + control_data->first_selected = control_data->root_selected = elem; + } + + if (control_data->root_selected != NULL) + gtk_math_view_select(math_view, control_data->root_selected); + + gtk_math_view_thaw(math_view); + } +} + +void +select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state, + GtkMathViewControlData* control_data) +{ + g_return_if_fail(math_view != NULL); + g_return_if_fail(control_data != NULL); + + if (control_data->first_selected != NULL && elem != NULL) + { + GdomeException exc = 0; + + gtk_math_view_freeze(math_view); + + if (control_data->root_selected != NULL) + { + gtk_math_view_unselect(math_view, control_data->root_selected); + gdome_el_unref(control_data->root_selected, &exc); + g_assert(exc == 0); + control_data->root_selected = NULL; + } + + if (control_data->semantic_selection) + { + GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem); + if (new_root != NULL) + { + control_data->root_selected = find_element_with_id(new_root, control_data->id_ns_uri, control_data->id_name); + gdome_el_unref(new_root, &exc); + g_assert(exc == 0); + } + else + control_data->root_selected = NULL; + } + else + control_data->root_selected = find_common_ancestor(control_data->first_selected, elem); + + if (control_data->root_selected != NULL) + gtk_math_view_select(math_view, control_data->root_selected); + + gtk_math_view_thaw(math_view); + } +} + +void +select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state, + GtkMathViewControlData* control_data) +{ + g_return_if_fail(math_view != NULL); + g_return_if_fail(control_data != NULL); + + if (control_data->first_selected != NULL) + { + GdomeException exc = 0; + gdome_el_unref(control_data->first_selected, &exc); + g_assert(exc == 0); + control_data->first_selected = NULL; + + if (control_data->root_selected != NULL && control_data->semantic_selection) + { + GdomeException exc = 0; + GdomeDOMString* id = gdome_el_getAttributeNS(control_data->root_selected, + control_data->id_ns_uri, + control_data->id_name, &exc); + g_assert(exc == 0); + g_assert(id != NULL); + set_clipboard(id); + gdome_str_unref(id); + } + } +} + +void +select_abort_cb(GtkMathView* math_view, GtkMathViewControlData* control_data) +{ + GdomeException exc = 0; + + g_return_if_fail(math_view != NULL); + g_return_if_fail(control_data != NULL); + + if (control_data->first_selected != NULL) + { + gdome_el_unref(control_data->first_selected, &exc); + g_assert(exc == 0); + control_data->first_selected = NULL; + } + + if (control_data->root_selected != NULL) + { + gtk_math_view_freeze(math_view); + gtk_math_view_unselect(math_view, control_data->root_selected); + gtk_math_view_thaw(math_view); + gdome_el_unref(control_data->root_selected, &exc); + g_assert(exc == 0); + control_data->root_selected = NULL; + } +} + diff --git a/DEVEL/gtkmathview-bonobo/src/handlers.h b/DEVEL/gtkmathview-bonobo/src/handlers.h new file mode 100644 index 000000000..47eda64b3 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/handlers.h @@ -0,0 +1,41 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __handlers_h__ +#define __handlers_h__ + +#include +#include +#include + +#include "control-data.h" + +void set_frame(BonoboControl*, gpointer); +void button_pressed_cb(GtkMathView*, GdkEventButton*, GtkMathViewControlData*); +void click_cb(GtkMathView*, GdomeElement*, gint, GtkMathViewControlData*); +void select_begin_cb(GtkMathView*,GdomeElement*, gint, GtkMathViewControlData*); +void select_over_cb(GtkMathView*,GdomeElement*,gint, GtkMathViewControlData*); +void select_end_cb(GtkMathView*,GdomeElement*,gint, GtkMathViewControlData*); +void select_abort_cb(GtkMathView*, GtkMathViewControlData*); + +#endif // __handlers_h__ diff --git a/DEVEL/gtkmathview-bonobo/src/persist-file.c b/DEVEL/gtkmathview-bonobo/src/persist-file.c new file mode 100644 index 000000000..1d3fd36c6 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/persist-file.c @@ -0,0 +1,141 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include +#include +#include + +#include "persist-file.h" +#include "control-factory.h" + +static BonoboObjectClass *gtk_math_view_persist_file_parent_class; + +static void load_implementation(PortableServer_Servant servant,const gchar *path, + CORBA_Environment *ev); + +static void save_implementation(PortableServer_Servant servant,const gchar *path, + CORBA_Environment *ev); + +static void finalize(GObject *object) +{ + GtkMathViewPersistFile *file = GTK_MATH_VIEW_PERSIST_FILE(object); + + if (file->math_view) + { + g_object_unref(file->math_view); + file->math_view = NULL; + } + + G_OBJECT_CLASS(gtk_math_view_persist_file_parent_class)->finalize (object); +} + +static Bonobo_Persist_ContentTypeList * +get_content_types(BonoboPersist *persist,CORBA_Environment *ev) +{ + return bonobo_persist_generate_content_types(3, "application/mathml+xml", "text/mathml", "text/plain"); +} + +static void +gtk_math_view_persist_file_class_init(GtkMathViewPersistFileClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); + POA_Bonobo_PersistFile__epv *epv = &klass->epv; + + gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass); + + epv->load = load_implementation; + epv->save = save_implementation; + + object_class->finalize = finalize; + persist_class->get_content_types = get_content_types; +} + +GType +gtk_math_view_persist_file_get_type(void) +{ + static GType type = 0; + + if (!type) + { + GTypeInfo info = + { + sizeof(GtkMathViewPersistFileClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_math_view_persist_file_class_init, + NULL, /* class finalize */ + NULL, /* class_data */ + sizeof(GtkMathViewPersistFile), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL + }; + + type = bonobo_type_unique(BONOBO_TYPE_PERSIST, + POA_Bonobo_PersistFile__init,POA_Bonobo_PersistFile__fini, + G_STRUCT_OFFSET(GtkMathViewPersistFileClass, epv), + &info,"GtkMathViewPresistFile"); + } + + return type; +} + +BonoboObject * +gtk_math_view_persist_file_new(GtkMathView *math_view) +{ + BonoboObject *file; + + file = g_object_new(gtk_math_view_persist_file_get_type(),NULL); + bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID); + + g_object_ref(math_view); + GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view; + + return file; +} + +static void +load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev) +{ + gboolean result; + GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant)); + //fd = open(path, O_RDONLY); + + result = gtk_math_view_load_uri(file->math_view,path); + if(!result) + CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); + + bonobo_object_unref(BONOBO_OBJECT(file)); +} + +static void +save_implementation(PortableServer_Servant servant, + const gchar *path, + CORBA_Environment *ev) +{ + bonobo_exception_set(ev,"save_exception"); + bonobo_exception_add_handler_str("save_exception", + "Save option is not valid"); +} diff --git a/DEVEL/gtkmathview-bonobo/src/persist-file.h b/DEVEL/gtkmathview-bonobo/src/persist-file.h new file mode 100644 index 000000000..6f70e76ef --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/persist-file.h @@ -0,0 +1,61 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __GTK_MATH_VIEW_PERSIST_FILE_H__ +#define __GTK_MATH_VIEW_PERSIST_FILE_H__ + +#include +#include + +G_BEGIN_DECLS + +struct _GtkMathViewPersistFile; +typedef struct _GtkMathViewPersistFile GtkMathViewPersistFile; +typedef struct _GtkMathViewPersistFilePrivate GtkMathViewPersistFilePrivate; + +#define GTK_MATH_VIEW_TYPE_PERSIST_FILE (gtk_math_view_persist_file_get_type()) +#define GTK_MATH_VIEW_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_FILE, \ + GtkMathViewPersistFile)) +#define GTK_MATH_VIEW_IS_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object),\ + GTK_MATH_VIEW_TYPE_PERSIST_FILE)) +#define GTK_MATH_VIEW_IS_PERSIST_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ + GTK_MATH_VIEW_TYPE_PERSIST_FILE)) + +struct _GtkMathViewPersistFile +{ + BonoboPersist parent; + GtkMathView *math_view; +}; + +typedef struct +{ + BonoboPersistClass parent_class; + POA_Bonobo_PersistFile__epv epv; +} GtkMathViewPersistFileClass; + +GType gtk_math_view_persist_file_get_type(void); +BonoboObject *gtk_math_view_persist_file_new(GtkMathView *); + +G_END_DECLS + +#endif diff --git a/DEVEL/gtkmathview-bonobo/src/persist-stream.c b/DEVEL/gtkmathview-bonobo/src/persist-stream.c new file mode 100644 index 000000000..bef7d90cb --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/persist-stream.c @@ -0,0 +1,221 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#include +#include + +#include "persist-stream.h" +#include "control-factory.h" + +#define DEBUG0 + +static BonoboObjectClass *gtk_math_view_persist_stream_parent_class; + +static void load_implementation(PortableServer_Servant servant, + const Bonobo_Stream stream, + const CORBA_char *type, + CORBA_Environment *ev); + +static void save_implementation(PortableServer_Servant servant, + const Bonobo_Stream stream, + const CORBA_char *type, + CORBA_Environment *ev); + +static void finalize(GObject *object) +{ + GtkMathViewPersistStream *stream = GTK_MATH_VIEW_PERSIST_STREAM(object); + + if (stream->math_view != NULL) + { + g_object_unref(stream->math_view); + stream->math_view = NULL; + } + + G_OBJECT_CLASS(gtk_math_view_persist_stream_parent_class)->finalize(object); +} + +static Bonobo_Persist_ContentTypeList * +get_content_types(BonoboPersist *persist,CORBA_Environment *ev) +{ + return bonobo_persist_generate_content_types(2, "application/mathml+xml", "text/mathml"); +} + +static void +gtk_math_view_persist_stream_class_init(GtkMathViewPersistStreamClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); + POA_Bonobo_PersistStream__epv *epv = &klass->epv; + +#ifdef DEBUG + printf("persist stream class init\n"); +#endif + gtk_math_view_persist_stream_parent_class = g_type_class_peek_parent(klass); + + epv->load = load_implementation; + epv->save = save_implementation; + + object_class->finalize = finalize; + persist_class->get_content_types = get_content_types; +} + +GType +gtk_math_view_persist_stream_get_type(void) +{ + static GType type = 0; +#ifdef DEBUG + printf("persist stream get type\n"); +#endif + if (!type) + { + GTypeInfo info = + { + sizeof(GtkMathViewPersistStreamClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_math_view_persist_stream_class_init, + NULL, /*class finalize */ + NULL, /*class data */ + sizeof(GtkMathViewPersistStream), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL + }; + + type = bonobo_type_unique(BONOBO_TYPE_PERSIST, + POA_Bonobo_PersistStream__init,POA_Bonobo_PersistStream__fini, + G_STRUCT_OFFSET(GtkMathViewPersistStreamClass,epv), + &info,"GtkMathViewPersistStream"); + } + + return type; +} + +BonoboObject * +gtk_math_view_persist_stream_new(GtkMathView *math_view) +{ + BonoboObject *stream; + +#ifdef DEBUG + printf("persist stream new\n"); +#endif + stream = g_object_new(gtk_math_view_persist_stream_get_type(),NULL); + bonobo_persist_construct(BONOBO_PERSIST(stream),CONTROL_FACTORY_ID); + + g_object_ref(math_view); + GTK_MATH_VIEW_PERSIST_STREAM(stream)->math_view = math_view; + + return stream; +} + +static FILE* +create_tmp_file(GtkMathViewPersistStream *persist) +{ + FILE *tmpfile; + int fd; + + persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/gmvXXXXXX", NULL); + if ((fd = mkstemp(persist->tmp_path_name)) < 0) + { + g_free(persist->tmp_path_name), + persist->tmp_path_name = NULL; + return NULL; + } + + tmpfile = fdopen(fd, "w"); + if(!tmpfile) + { + close(fd); + return NULL; + } + + return tmpfile; +} + + +static void +load_implementation(PortableServer_Servant servant, + Bonobo_PersistStream stream, + const CORBA_char *type, + CORBA_Environment *ev) +{ + GtkMathViewPersistStream *persist = GTK_MATH_VIEW_PERSIST_STREAM (bonobo_object_from_servant (servant)); + Bonobo_Stream_iobuf *buffer; + GtkMathViewPersistStream *handle; + CORBA_long len_read; + gboolean result; + FILE *tmpfile; + +#ifdef DEBUG + printf("persist stream loading\n"); +#endif + + if (strcmp (type, "application/mathml+xml") != 0) + { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; + } + + tmpfile = create_tmp_file(persist); + do + { + Bonobo_Stream_read (stream, 4096, &buffer, ev); + if (ev->_major != CORBA_NO_EXCEPTION) + goto clean; + + len_read = buffer->_length; + + if (buffer->_buffer && len_read) + if (fwrite(buffer->_buffer, 1, len_read, tmpfile) != len_read) + { + CORBA_free (buffer); + goto clean; + } + + CORBA_free (buffer); + } while (len_read > 0); + + fclose(tmpfile); + + result = gtk_math_view_load_uri(persist->math_view,persist->tmp_path_name); + if(!result) + { + CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); + } + return ; + + clean: + fclose (tmpfile); + return; +} + +static void +save_implementation(PortableServer_Servant servant,const Bonobo_Stream stream,const CORBA_char *type,CORBA_Environment *ev) +{ + bonobo_exception_set(ev,"save_exception"); + bonobo_exception_add_handler_str("save_exception", + "Save option is not valid"); + return; +} diff --git a/DEVEL/gtkmathview-bonobo/src/persist-stream.h b/DEVEL/gtkmathview-bonobo/src/persist-stream.h new file mode 100644 index 000000000..848121436 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/persist-stream.h @@ -0,0 +1,59 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __GTK_MATH_VIEW_PERSIST_STREAM_H__ +#define __GTK_MATH_VIEW_PERSIST_STREAM_H__ + +#include +#include + +G_BEGIN_DECLS + +struct _GtkMathViewPersistStream; +typedef struct _GtkMathViewPersistStream GtkMathViewPersistStream; +typedef struct _GtkMathViewPersistStreamPrivate GtkMathViewPersistStreamPrivate; + +#define GTK_MATH_VIEW_TYPE_PERSIST_STREAM (gtk_math_view_persist_stream_get_type()) +#define GTK_MATH_VIEW_PERSIST_STREAM(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_STREAM,GtkMathViewPersistStream)) +#define GTK_MATH_VIEW_IS_PERSIST_STREAM(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), GTK_MATH_VIEW_TYPE_PERSIST_STREAM)) +#define GTK_MATH_VIEW_IS_PERSIST_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_MATH_VIEW_TYPE_PERSIST_STREAM)) + +struct _GtkMathViewPersistStream +{ + BonoboPersist parent; + GtkMathView *math_view; + gchar* tmp_path_name; +}; + +typedef struct +{ + BonoboPersistClass parent_class; + POA_Bonobo_PersistStream__epv epv; +} GtkMathViewPersistStreamClass; + +GType gtk_math_view_persist_stream_get_type(void); +BonoboObject *gtk_math_view_persist_stream_new(GtkMathView *); + +G_END_DECLS + +#endif diff --git a/DEVEL/gtkmathview-bonobo/src/view.c b/DEVEL/gtkmathview-bonobo/src/view.c new file mode 100644 index 000000000..068558d25 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/view.c @@ -0,0 +1,361 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#include + +#define HAVE_GMETADOM +#include + +#include "aux.h" +#include "view.h" + +static GObjectClass* view_parent_class; + +static void +view_object_finalize(GObject* object) +{ + View* view = VIEW(object); + /* free resources */ + view_parent_class->finalize(object); + return; +} + +static void +impl_view_freeze(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_freeze(view->control_data->math_view); + return; +} + +static void +impl_view_thaw(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_thaw(view->control_data->math_view); + return; +} + +static CORBA_boolean +impl_view_load(PortableServer_Servant servant, + const CORBA_char *uri, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + return gtk_math_view_load_uri(view->control_data->math_view, uri); +} + +static void +impl_view_unload(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_unload(view->control_data->math_view); +} + +static void +impl_view_setIdAttribute (PortableServer_Servant servant, + const CORBA_char *ns, + const CORBA_char *name, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_control_data_set_id_attribute(view->control_data, ns, name); +} + +static void +impl_view_getIdAttribute (PortableServer_Servant servant, + CORBA_string *ns, + CORBA_string *name, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + if (view->control_data->id_ns_uri != NULL) + *ns = CORBA_string_dup(view->control_data->id_ns_uri->str); + else + *ns = NULL; + + if (view->control_data->id_name != NULL) + *name = CORBA_string_dup(view->control_data->id_name); + else + *name = NULL; +} + +static void +impl_view_select(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gtk_math_view_select(view->control_data->math_view, el); + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } +} + +static void +impl_view_unselect(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gtk_math_view_unselect(view->control_data->math_view, el); + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } +} + +static CORBA_boolean +impl_view_isSelected(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + res = gtk_math_view_is_selected(view->control_data->math_view, el) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; +} + +static CORBA_boolean +impl_view_elementCoords(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_short *x, CORBA_short *y, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gint xx; + gint yy; + res = gtk_math_view_get_element_coords(view->control_data->math_view, el, &xx, &yy) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + *x = xx; + *y = yy; + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; +} + +static CORBA_boolean +impl_view_elementBoundingBox(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_short *width, CORBA_short *height, CORBA_short *depth, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gint w; + gint h; + gint d; + res = gtk_math_view_get_element_bounding_box(view->control_data->math_view, el, &w, &h, &d) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + *width = w; + *height = h; + *depth = d; + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; +} + +static void +impl_view_getSize(PortableServer_Servant servant, + CORBA_short *width, CORBA_short *height, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + *width = gtk_math_view_get_width(view->control_data->math_view); + *height = gtk_math_view_get_height(view->control_data->math_view); +} + +static void +impl_view_getTop(PortableServer_Servant servant, + CORBA_short *x, CORBA_short *y, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gint xx; + gint yy; + gtk_math_view_get_top(view->control_data->math_view, &xx, &yy); + *x = xx; + *y = yy; +} + +static void +impl_view_setTop (PortableServer_Servant servant, + CORBA_short x, CORBA_short y, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_top(view->control_data->math_view, x, y); +} + +static void +impl_view_setDefaultFontSize(PortableServer_Servant servant, + CORBA_short size, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_font_size(view->control_data->math_view, size); +} + +static short +impl_view_getDefaultFontSize(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + return gtk_math_view_get_font_size(view->control_data->math_view); +} + +static void +impl_view_setVerbosity(PortableServer_Servant servant, + const CORBA_short level, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_log_verbosity(view->control_data->math_view, level); +} + +static short +impl_view_getVerbosity(PortableServer_Servant servant, + CORBA_Environment *ev) +{ + View* view = VIEW (bonobo_object (servant)); + return gtk_math_view_get_log_verbosity(view->control_data->math_view); +} + +static void +view_class_init(ViewClass* klass) +{ + GObjectClass* object_class = (GObjectClass *) klass; + POA_GNOME_GtkMathView_View__epv* epv = &klass->epv; + + view_parent_class = g_type_class_peek_parent (klass); + object_class->finalize = view_object_finalize; + + epv->freeze = impl_view_freeze; + epv->thaw = impl_view_thaw; + epv->load = impl_view_load; + epv->unload = impl_view_unload; + epv->setIdAttribute = impl_view_setIdAttribute; + epv->getIdAttribute = impl_view_getIdAttribute; + epv->select = impl_view_select; + epv->unselect = impl_view_unselect; + epv->isSelected = impl_view_isSelected; + epv->elementCoords = impl_view_elementCoords; + epv->elementBoundingBox = impl_view_elementBoundingBox; + epv->getSize = impl_view_getSize; + epv->getTop = impl_view_getTop; + epv->setTop = impl_view_setTop; + epv->setDefaultFontSize = impl_view_setDefaultFontSize; + epv->getDefaultFontSize = impl_view_getDefaultFontSize; + epv->setVerbosity = impl_view_setVerbosity; + epv->getVerbosity = impl_view_getVerbosity; +} + +static void +view_init(View* view) +{ + /* do some initialization */ +} + +View* +view_new(GtkMathViewControlData* control_data) +{ + View* view; + g_return_val_if_fail(control_data != NULL, NULL); + view = g_object_new(VIEW_TYPE, NULL); + view->control_data = control_data; + return view; +} + +BONOBO_TYPE_FUNC_FULL (View, GNOME_GtkMathView_View, BONOBO_TYPE_OBJECT, view) + diff --git a/DEVEL/gtkmathview-bonobo/src/view.h b/DEVEL/gtkmathview-bonobo/src/view.h new file mode 100644 index 000000000..86394bec5 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/src/view.h @@ -0,0 +1,53 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ + +#ifndef __view_h__ +#define __view_h__ + +#include + +#include "GtkMathView.h" +#include "control-data.h" + +#define VIEW_TYPE (view_get_type()) +#define VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), VIEW_TYPE, View)) +#define VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), VIEW_TYPE, ViewClass)) +#define VIEW_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), VIEW_TYPE)) +#define VIEW_IS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VIEW_TYPE)) +#define VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VIEW_TYPE, ViewClass)) + +typedef struct { + BonoboObject parent; + GtkMathViewControlData* control_data; +} View; + +typedef struct { + BonoboObjectClass parent_class; + POA_GNOME_GtkMathView_View__epv epv; +} ViewClass; + +GType view_get_type(void); +View* view_new(GtkMathViewControlData*); + +#endif /* __view_h__ */ + diff --git a/DEVEL/gtkmathview-bonobo/test/.cvsignore b/DEVEL/gtkmathview-bonobo/test/.cvsignore new file mode 100644 index 000000000..46490baa4 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +viewer +Makefile +Makefile.in diff --git a/DEVEL/gtkmathview-bonobo/test/Makefile.am b/DEVEL/gtkmathview-bonobo/test/Makefile.am new file mode 100644 index 000000000..204ae3dfc --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/Makefile.am @@ -0,0 +1,25 @@ + +noinst_PROGRAMS = viewer + +viewer_SOURCES = \ + main.c \ + $(top_srcdir)/src/GtkMathView-common.c \ + $(top_srcdir)/src/GtkMathView-stubs.c + +viewer_LDADD = \ + $(BONOBOUI_LIBS) \ + $(BONOBO_LIBS) \ + $(GNOMEUI_LIBS) + +AM_CFLAGS = \ + -DPREFIX=\""$(prefix)"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DDATADIR=\""$(datadir)"\" \ + -DLIBDIR=\""$(datadir)"\" + +INCLUDES = \ + $(BONOBOUI_CFLAGS) \ + $(BONOBO_CFLAGS) \ + $(GNOMEUI_CFLAGS) \ + -I$(top_srcdir)/src + diff --git a/DEVEL/gtkmathview-bonobo/test/embedding.html b/DEVEL/gtkmathview-bonobo/test/embedding.html new file mode 100644 index 000000000..674012ff4 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/embedding.html @@ -0,0 +1,41 @@ + + + + + + + + + +

GtkMathView-Bonobo test page

+ + The embedded object should display a mathematical formula. +
+ + + + + x + 2 + + = + click for the answer + + + +
+ +
+ + + + + diff --git a/DEVEL/gtkmathview-bonobo/test/embedding.xml b/DEVEL/gtkmathview-bonobo/test/embedding.xml new file mode 100644 index 000000000..57fe49a87 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/embedding.xml @@ -0,0 +1,43 @@ + + + + + + + + + +

GtkMathView-Bonobo test page

+ + The embedded object should display a mathematical formula. +
+ + + + + x + 2 + + = + click for the answer + + + +
+ Size +
+ + + + + diff --git a/DEVEL/gtkmathview-bonobo/test/main.c b/DEVEL/gtkmathview-bonobo/test/main.c new file mode 100644 index 000000000..e737329ec --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/main.c @@ -0,0 +1,476 @@ +#include +#include +#include +#include + +#include "control-factory.h" +#include "GtkMathView.h" + +static GtkWidget *control; + +typedef enum{LOAD_STREAM,LOAD_FILE,NONE}FileSelectionOp; + +struct FileSelectionInfo { + BonoboWidget* control; + GtkWidget* widget; + + FileSelectionOp Operations; +}; + + +static struct FileSelectionInfo file_selection_info = { NULL, NULL,NONE}; + +static void +file_selection_destroy_cb (GtkWidget *widget,gpointer data) +{ + file_selection_info.widget = NULL; +} + + +static void +load_through_persist_file (const gchar *filename, + Bonobo_PersistFile pfile) +{ + CORBA_Environment ev; + CORBA_exception_init (&ev); + Bonobo_PersistFile_load (pfile, filename, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("Cannot load."); + CORBA_exception_free (&ev); +} + +static void +load_through_persist_stream(const gchar *filename, + Bonobo_PersistStream pstream) +{ + BonoboObject *stream = NULL; + CORBA_Environment ev; + CORBA_exception_init (&ev); + +#if 0 + stream = bonobo_stream_open ("fs", filename, + Bonobo_Storage_READ, 0); +#endif + + /*if (stream == NULL) + { + g_warning ("Couldn't load `%s'\n", filename); + } else*/ { + Bonobo_Stream corba_stream; + corba_stream = bonobo_object_corba_objref (stream); + Bonobo_Stream_truncate (corba_stream, 0, &ev); + Bonobo_PersistStream_load (pstream, corba_stream, "application/mathml+xml", &ev); + } + Bonobo_Unknown_unref (pstream, &ev); + CORBA_Object_release (pstream, &ev); + CORBA_exception_free (&ev); +} + +static void +file_selection_ok_cb (GtkWidget *widget, + gpointer data) +{ + CORBA_Object interface; + const gchar *interface_name; + CORBA_Environment ev; + + if (file_selection_info.Operations == LOAD_FILE) + interface_name = "IDL:Bonobo/PersistFile:1.0"; + else if(file_selection_info.Operations == LOAD_STREAM) + interface_name = "IDL:Bonobo/PersistStream:1.0"; + else printf("failed to get operation type\n"); + + CORBA_exception_init (&ev); + interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (file_selection_info.control), + interface_name, &ev); + CORBA_exception_free (&ev); + + if (interface == CORBA_OBJECT_NIL) + { + g_warning ("The Control does not seem to support `%s'.", interface_name); + } + else + { + const gchar *fname; + fname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selection_info.widget)); + switch (file_selection_info.Operations) { + case LOAD_STREAM: + load_through_persist_stream (fname, interface); + break; + case LOAD_FILE: + load_through_persist_file (fname, interface); + break; + } + } + + gtk_widget_destroy (file_selection_info.widget); +} + +static void +open_dialog (BonoboWindow *app, + FileSelectionOp operation) +{ + GtkWidget *widget; + BonoboWidget *control; + + control = BONOBO_WIDGET (bonobo_window_get_contents (app)); + + if (file_selection_info.widget != NULL) { + gdk_window_show (GTK_WIDGET (file_selection_info.widget)->window); + return; + } + + if(operation == LOAD_STREAM) + widget = gtk_file_selection_new(_("Open Stream....")); + if(operation == LOAD_FILE) + widget = gtk_file_selection_new (_("Open file...")); + + gtk_window_set_transient_for (GTK_WINDOW (widget), + GTK_WINDOW (app)); + + file_selection_info.widget = widget; + file_selection_info.control = control; + file_selection_info.Operations = operation; + + g_signal_connect_object (GTK_FILE_SELECTION (widget)->cancel_button, + "clicked", G_CALLBACK (gtk_widget_destroy), widget, G_CONNECT_AFTER); + + g_signal_connect (GTK_FILE_SELECTION (widget)->ok_button, "clicked", G_CALLBACK (file_selection_ok_cb), NULL); + + g_signal_connect (file_selection_info.widget, "destroy", G_CALLBACK (file_selection_destroy_cb), NULL); + + gtk_widget_show (file_selection_info.widget); +} + +/* "Open through persist file" dialog. */ +static void +open_through_persist_file_cb (GtkWidget *widget, + gpointer data) +{ + open_dialog (BONOBO_WINDOW (data), LOAD_FILE); +} + +static void +open_through_persist_stream_cb(GtkWidget *widget, + gpointer data) +{ + open_dialog(BONOBO_WINDOW(data), LOAD_STREAM); +} + +static void +test_view(GtkWidget* widget, gpointer data) +{ + CORBA_Object interface; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (bonobo_window_get_contents (BONOBO_WINDOW(data)))), + "IDL:GNOME/GtkMathView/View:1.0", &ev); + CORBA_exception_free (&ev); + + if (interface == CORBA_OBJECT_NIL) + { + g_warning ("The Control does not seem to support `View'."); + } + + CORBA_exception_init (&ev); + GNOME_GtkMathView_View_freeze(interface, &ev); + CORBA_exception_free (&ev); + + CORBA_exception_init (&ev); + GNOME_GtkMathView_View_thaw(interface, &ev); + CORBA_exception_free (&ev); + + CORBA_exception_init (&ev); + Bonobo_Unknown_unref (interface, &ev); + CORBA_Object_release (interface, &ev); + CORBA_exception_free (&ev); +} + +static void +exit_cb (GtkWidget *widget, + gpointer data) +{ + gtk_widget_destroy (GTK_WIDGET (data)); + bonobo_main_quit (); +} + +static void +get_size(GtkWidget *widget, + gpointer data) +{ + gint width,height; + BonoboWidget* control; + BonoboControlFrame* control_frame; + + Bonobo_PropertyBag prop_bag; + + control = BONOBO_WIDGET (bonobo_window_get_contents (BONOBO_WINDOW (data))); + control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL); + + width = bonobo_pbclient_get_long(prop_bag,"width",NULL); + height = bonobo_pbclient_get_long(prop_bag,"height",NULL); + + printf("Width: %d Height: %d\n",width,height); + + bonobo_object_release_unref (prop_bag,NULL); + +}; + +static void +get_top(GtkWidget *widget, + gpointer data) +{ + gint top_x,top_y; + BonoboWidget* control; + BonoboControlFrame* control_frame; + Bonobo_PropertyBag prop_bag; + + control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); + control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); + + top_x = bonobo_pbclient_get_long(prop_bag,"top-x",NULL); + top_y = bonobo_pbclient_get_long(prop_bag,"top-y",NULL); + + printf("Top X: %d ,Top Y: %d\n",top_x,top_y); + + bonobo_object_release_unref(prop_bag,NULL); +} + +static void +get_font_size(GtkWidget *widget, + gpointer data) +{ + gint font_size; + BonoboWidget* control; + BonoboControlFrame* control_frame; + Bonobo_PropertyBag prop_bag; + + control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); + control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); + + font_size = bonobo_pbclient_get_long(prop_bag,"font-size",NULL); + + printf("FontSize : %d\n",font_size); + + bonobo_object_release_unref(prop_bag,NULL); +} + +static void +get_verbosity(GtkWidget *widget, + gpointer data) +{ + gint verbosity; + BonoboWidget* control; + BonoboControlFrame* control_frame; + Bonobo_PropertyBag prop_bag; + + control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); + control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); + + verbosity = bonobo_pbclient_get_long(prop_bag,"verbosity",NULL); + + printf("Verbosity: %d\n",verbosity); + + bonobo_object_release_unref(prop_bag,NULL); +} + +static BonoboUIVerb verbs [] = { + BONOBO_UI_UNSAFE_VERB ("OpenFile", open_through_persist_file_cb), + BONOBO_UI_UNSAFE_VERB ("OpenStream", open_through_persist_stream_cb), + BONOBO_UI_UNSAFE_VERB ("TestView", test_view), + BONOBO_UI_UNSAFE_VERB ("Size", get_size), + BONOBO_UI_UNSAFE_VERB ("Top", get_top), + BONOBO_UI_UNSAFE_VERB ("Font Size", get_font_size), + BONOBO_UI_UNSAFE_VERB ("Verbosity", get_verbosity), + BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb), + BONOBO_UI_VERB_END +}; + +/* A dirty, non-translatable hack */ +static char ui [] = +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " + +" " + +" " + +" " +" " +" " +" " +" " +""; + +static int +app_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer dummy) +{ + gtk_widget_destroy (GTK_WIDGET (widget)); + bonobo_main_quit (); + + return FALSE; +} + +static guint +container_create (void) +{ + GtkWidget *win; + GtkWindow *window; + BonoboUIComponent *component; + BonoboUIContainer *container; + CORBA_Environment ev; + + + win = bonobo_window_new ("test-editor", + "GtkMathView Control Test"); + window = GTK_WINDOW (win); + + container = bonobo_window_get_ui_container (BONOBO_WINDOW (win)); + + g_signal_connect (window, "delete_event", G_CALLBACK (app_delete_cb), NULL); + + gtk_window_set_default_size (window, 600, 440); + gtk_window_set_resizable (window, TRUE); + + component = bonobo_ui_component_new ("test"); + bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (component)); + + bonobo_ui_component_set_container (component, BONOBO_OBJREF (container), NULL); + bonobo_ui_component_add_verb_list_with_data (component, verbs, win); + bonobo_ui_component_set_translate (component, "/", ui, NULL); + + control = bonobo_widget_new_control (CONTROL_ID, BONOBO_OBJREF (container)); + + if (control == NULL) + g_error ("Cannot get `%s'.", CONTROL_ID); + + bonobo_window_set_contents (BONOBO_WINDOW (win), control); + + gtk_widget_show_all (GTK_WIDGET (window)); + + CORBA_exception_init (&ev); + + return FALSE; +} + +static gint +load_file (const gchar *fname) +{ + CORBA_Object interface; + CORBA_Environment ev; + + printf ("loading: %s\n", fname); + CORBA_exception_init (&ev); + interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (control)), + "IDL:Bonobo/PersistFile:1.0", &ev); + CORBA_exception_free (&ev); + load_through_persist_file (fname, interface); + + return FALSE; +} + +static gint +load_file_stream(const gchar *fname) +{ + CORBA_Object interface; + CORBA_Environment ev; + + printf("loading with stream %s\n",fname); + CORBA_exception_init(&ev); + interface = Bonobo_Unknown_queryInterface(bonobo_widget_get_objref(BONOBO_WIDGET(control)), + "IDL:Bonobo/PersistStream:1.0",&ev); + + CORBA_exception_free(&ev); + load_through_persist_stream(fname,interface); + + return FALSE; +} + +/* +static void +install_property_bag_listener (BonoboWidget *control, BonoboWindow *bonobo_win) +{ + Bonobo_Listener corba_listener; + BonoboListener *listener; + BonoboControlFrame *control_frame; + CORBA_Environment ev; + Bonobo_PropertyBag prop_bag; + + CORBA_exception_init(&ev); + + control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); + if(!control_frame) + g_error("can't find control frame\n"); + + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL); + if(prop_bag == CORBA_OBJECT_NIL) + g_error("can't connect to property bag\n"); + + //connect a listener to the property bag + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn) width_changed, + "Bonobo/Property:change:width",NULL,bonobo_win); + + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)height_changed, + "Bonobo/Property:change:height",NULL,bonobo_win); + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_x_changed, + "Bonobo/Property:change:top-x",NULL,bonobo_win); + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_y_changed, + "Bonobo/Property:change:top-y",NULL,bonobo_win); + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_size_changed, + "Bonobo/Property:change:font-size",NULL,bonobo_win); + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)anti_aliasing_changed, + "Bonobo/Property:change:verbosity",NULL,bonobo_win); + bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_manager_changed, + "Bonobo/Property:change:font_manager",NULL,bonobo_win); + CORBA_exception_free(&ev); +}*/ + + +int +main (int argc, char **argv) +{ + gnome_program_init("test-editor", VERSION, LIBGNOMEUI_MODULE, argc, argv, + GNOME_PROGRAM_STANDARD_PROPERTIES, + GNOME_PARAM_HUMAN_READABLE_NAME, _("GtkMathView Test Container"), + NULL); + + bonobo_activate (); + + /* We can't make any CORBA calls unless we're in the main loop. So we + delay creating the container here. */ + gtk_idle_add ((GtkFunction) container_create, NULL); + if (argc > 1 && *argv [argc - 1] != '-') + gtk_idle_add ((GtkFunction) load_file, argv [argc - 1]); + + bonobo_activate (); + bonobo_main (); + + return bonobo_ui_debug_shutdown (); +} diff --git a/DEVEL/gtkmathview-bonobo/test/test.mml b/DEVEL/gtkmathview-bonobo/test/test.mml new file mode 100644 index 000000000..2436838bf --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/test.mml @@ -0,0 +1,128 @@ + + + + + + + + + a + + x + + + + b + + + + x + 2 + + + + + p + + x + + + + q + + + + ... + + d + x + = + + + a2 + + + ln + + + ( + + x2 + + + + p + + x + + + + q + + ) + + + + + + + + + + 2 + + b + + - + + a + + p + + + + + + 4 + + q + + - + + p + 2 + + + + + + + arctg + + + + + 2 + + x + + + + p + + + + + 4 + + q + + - + + p + 2 + + + + + + + + + c + + + go to Luca's home page + diff --git a/DEVEL/gtkmathview-bonobo/test/testembedding.html b/DEVEL/gtkmathview-bonobo/test/testembedding.html new file mode 100644 index 000000000..e894388d6 --- /dev/null +++ b/DEVEL/gtkmathview-bonobo/test/testembedding.html @@ -0,0 +1,17 @@ + + + + + + +

GtkMathView-Bonobo test page

+ +The embedded object should display a mathematical formula. +
+
+ +No viewer capable of displaying the test document installed. + + + + diff --git a/DEVEL/lablgtkmathview/.cvsignore b/DEVEL/lablgtkmathview/.cvsignore new file mode 100644 index 000000000..d018d8e04 --- /dev/null +++ b/DEVEL/lablgtkmathview/.cvsignore @@ -0,0 +1,10 @@ +*.cmi *.cmo *.cmx *.cma *.cmxa config.make config.cache config.log configure +Makefile +config.status +META +lablgtkmathview.spec +gtkMathViewProps.ml +ogtkMathViewProps.ml +aclocal.m4 +autom4te.cache +config.h.in diff --git a/DEVEL/lablgtkmathview/.depend b/DEVEL/lablgtkmathview/.depend new file mode 100644 index 000000000..23cd75664 --- /dev/null +++ b/DEVEL/lablgtkmathview/.depend @@ -0,0 +1,12 @@ +gMathViewAux.cmo: gMathView.cmi gMathViewAux.cmi +gMathViewAux.cmx: gMathView.cmx gMathViewAux.cmi +gMathView.cmo: gtkMathView.cmo gtk_mathview.cmo gMathView.cmi +gMathView.cmx: gtkMathView.cmx gtk_mathview.cmx gMathView.cmi +gtkMathView.cmo: gtkMathViewProps.cmo gtk_mathview.cmo +gtkMathView.cmx: gtkMathViewProps.cmx gtk_mathview.cmx +gtkMathViewProps.cmo: gtk_mathview.cmo +gtkMathViewProps.cmx: gtk_mathview.cmx +ogtkMathViewProps.cmo: gtkMathViewProps.cmo +ogtkMathViewProps.cmx: gtkMathViewProps.cmx +gMathViewAux.cmi: gMathView.cmi gtk_mathview.cmo +gMathView.cmi: gtk_mathview.cmo diff --git a/DEVEL/lablgtkmathview/AUTHORS b/DEVEL/lablgtkmathview/AUTHORS new file mode 100644 index 000000000..3598094a9 --- /dev/null +++ b/DEVEL/lablgtkmathview/AUTHORS @@ -0,0 +1,2 @@ +Luca Padovani +Claudio Sacerdoti Coen diff --git a/DEVEL/lablgtkmathview/COPYING b/DEVEL/lablgtkmathview/COPYING new file mode 100644 index 000000000..d60c31a97 --- /dev/null +++ b/DEVEL/lablgtkmathview/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/DEVEL/lablgtkmathview/ChangeLog b/DEVEL/lablgtkmathview/ChangeLog new file mode 100644 index 000000000..19ce76012 --- /dev/null +++ b/DEVEL/lablgtkmathview/ChangeLog @@ -0,0 +1,6 @@ +* 0.4.1 + - Upgraded to GtkMathView 0.4.[0,1] + +* 0.3.0 + - Upgraded to GtkMathView 0.3.0 + - Now based on the gmetadom (alias gdome2) binding to GDOMe Level 2 diff --git a/DEVEL/lablgtkmathview/LICENSE b/DEVEL/lablgtkmathview/LICENSE new file mode 100644 index 000000000..691e4e01c --- /dev/null +++ b/DEVEL/lablgtkmathview/LICENSE @@ -0,0 +1,22 @@ +(* Copyright (C) 2000-2003, Luca Padovani , + * Claudio Sacerdoti Coen . + * + * This file is part of lablgtkmathview, the Ocaml binding + * for the GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * For details, send a mail to the author. + *) diff --git a/DEVEL/lablgtkmathview/META.in b/DEVEL/lablgtkmathview/META.in new file mode 100644 index 000000000..d94e88f16 --- /dev/null +++ b/DEVEL/lablgtkmathview/META.in @@ -0,0 +1,4 @@ +requires="gdome2 lablgtk2" +version="@VERSION@" +archive(byte)="@PACKAGE@.cma" +archive(native)="@PACKAGE@.cmxa" diff --git a/DEVEL/lablgtkmathview/Makefile.in b/DEVEL/lablgtkmathview/Makefile.in new file mode 100644 index 000000000..26532c4a8 --- /dev/null +++ b/DEVEL/lablgtkmathview/Makefile.in @@ -0,0 +1,134 @@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +INCLUDEDIR = @OCAML_INCLUDE_DIR@ +PROPCC = @OCAML_LIB_DIR@/lablgtk2/propcc +PREFIX = +OBJECTS_C = ml_gtk_mathview.o +OBJECTS = gtkMathViewProps.cmo ogtkMathViewProps.cmo gtk_mathview.cmo gtkMathView.cmo gMathView.cmo gMathViewAux.cmo +OBJECTS_OPT = gtkMathViewProps.cmx ogtkMathViewProps.cmx gtkMathView.cmx gtk_mathview.cmx gMathView.cmx gMathViewAux.cmx +GENERATED_FILES = gtkMathViewProps.ml ogtkMathViewProps.ml +NULL = +INST = \ + META \ + gMathView.mli \ + gMathView.cmi \ + gtkMathView.cmi \ + gtk_mathview.cmi \ + gtkMathViewProps.cmi \ + ogtkMathViewProps.cmi \ + gMathViewAux.cmi \ + gMathViewAux.mli \ + $(NULL) +DIST_FILES = \ + Makefile.in configure.in gMathView.ml gMathView.mli \ + gMathViewAux.ml gMathViewAux.mli gtkMathView.ml \ + gtk_mathview.ml ml_gtk_mathview.c META.in .depend debian/ test/ \ + configure gtkMathView.props +DIST_DIR = $(PACKAGE)-$(VERSION) +DOC_FILES = AUTHORS COPYING ChangeLog NEWS README LICENSE +REQUIRES = gdome2 lablgtk2 +PREDICATES = +SHARED_LIBS = @GDOME_LIBS@ @GTKMATHVIEW_LIBS@ + +OCAMLFIND = ocamlfind +OCAMLC = $(OCAMLFIND) ocamlc +OCAMLOPT = $(OCAMLFIND) ocamlopt +OCAMLDEP = ocamldep +OCAMLMKLIB = ocamlmklib +OCAML_STUB_DIR = @OCAML_STUB_DIR@ + +ARCHIVE = $(PACKAGE) +DLL = dll$(ARCHIVE).so + +TESTDIR = ./test +TMPDIR = .test +TMPPKGDIR = $(TMPDIR)/$(PACKAGE) + +all: $(ARCHIVE).cma lib$(ARCHIVE).a $(DLL) +opt: $(ARCHIVE).cmxa $(ARCHIVE).a +test: $(TESTDIR)/test +test.opt: $(TESTDIR)/test.opt +world: all opt + +dist: + rm -rf $(DIST_DIR)/ + mkdir $(DIST_DIR)/ + cp -a $(DIST_FILES) $(DOC_FILES) $(DIST_DIR)/ + -find $(DIST_DIR) -name CVS -type d -exec rm -rf {} \; + -find $(DIST_DIR) -name .cvsignore -type f -exec rm {} \; + tar cvfz $(DIST_DIR).tar.gz $(DIST_DIR)/ + rm -rf $(DIST_DIR)/ + +deb: dist + if [ -d $(DIST_DIR)/ ]; then rm -rf $(DIST_DIR); else true; fi + tar xvzf $(DIST_DIR).tar.gz + (cd $(DIST_DIR)/ && debuild) + rm -rf $(DIST_DIR) + +$(GENERATED_FILES): gtkMathView.props + +ml_gtk_mathview.o: ml_gtk_mathview.c + gcc -c -I$(INCLUDEDIR) -fPIC `ocamlfind query -i-format lablgtk2` @GTKMATHVIEW_CFLAGS@ @GDOME_CFLAGS@ `ocamlfind query -i-format gdome2` $< + +.SUFFIXES: .cmo .cmi .cmx .ml .mli + +.ml.cmo: + $(OCAMLC) -package "$(REQUIRES)" -predicates "$(PREDICATES)" -c $< +.mli.cmi: + $(OCAMLC) -package "$(REQUIRES)" -predicates "$(PREDICATES)" -c $< +.ml.cmx: + $(OCAMLOPT) -package "$(REQUIRES)" -predicates "$(PREDICATES)" -c $< + +%Props.ml o%Props.ml: %.props $(PROPCC) + $(PROPCC) $< + +depend: *.ml *.mli $(GENERATED_FILES) + $(OCAMLDEP) *.ml *.mli >.depend +include .depend + +$(ARCHIVE).cma: $(OBJECTS) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +$(ARCHIVE).cmxa: $(OBJECTS_OPT) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +lib$(ARCHIVE).a $(DLL): $(OBJECTS_C) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) + +$(TESTDIR)/test: $(OBJECTS_C) $(ARCHIVE).cma $(TESTDIR)/test.ml + mkdir -p $(TMPPKGDIR) + cp $(OBJECTS_C) $(DLL) $(ARCHIVE).cma $(INST) $(TMPPKGDIR) + cd $(TESTDIR) ; export OCAMLPATH=../$(TMPDIR):$$OCAMLPATH ; make + rm -r $(TMPDIR) + +$(TESTDIR)/test.opt: $(OBJECTS_C) $(ARCHIVE).a $(ARCHIVE).cmxa $(TESTDIR)/test.ml + mkdir -p $(TMPPKGDIR) + cp $(OBJECTS_C) $(ARCHIVE).a $(ARCHIVE).cmxa $(INST) $(TMPPKGDIR) + cd $(TESTDIR) ; export OCAMLPATH=../$(TMPDIR):$$OCAMLPATH ; make opt + rm -r $(TMPDIR) + +install: + test ! -f $(ARCHIVE).cmxa || extra="$(ARCHIVE).a $(ARCHIVE).cmxa" ; \ + if [ "$(PREFIX)" = "" ]; then \ + $(OCAMLFIND) install \ + $(PACKAGE) $(ARCHIVE).cma lib$(ARCHIVE).a \ + $(DLL) $(INST) $$extra; \ + else \ + $(OCAMLFIND) install -ldconf /def/null -destdir $(PREFIX) \ + $(PACKAGE) $(ARCHIVE).cma lib$(ARCHIVE).a \ + $(DLL) $(INST) $$extra; \ + fi + +uninstall: + if [ "$(PREFIX)" = "" ]; then \ + ocamlfind remove $(PACKAGE); \ + else \ + ocamlfind remove -destdir $(PREFIX) $(PACKAGE); \ + fi + +clean: + rm -f *.[ao] *.cm[iaxo] *.cmxa *.so $(GENERATED_FILES) + cd $(TESTDIR) ; make clean + rm -rf $(TMPDIR) + +distclean: clean + rm -f config.log config.cache config.status Makefile META + cd $(TESTDIR) ; make distclean diff --git a/DEVEL/lablgtkmathview/NEWS b/DEVEL/lablgtkmathview/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/lablgtkmathview/README b/DEVEL/lablgtkmathview/README new file mode 100644 index 000000000..61c34d46e --- /dev/null +++ b/DEVEL/lablgtkmathview/README @@ -0,0 +1,9 @@ +This is the Ocaml binding for the GtkMathView widget. + +To compile and install: + + ./configure + make + make opt + make install + diff --git a/DEVEL/lablgtkmathview/configure.in b/DEVEL/lablgtkmathview/configure.in new file mode 100644 index 000000000..d4c16e55d --- /dev/null +++ b/DEVEL/lablgtkmathview/configure.in @@ -0,0 +1,57 @@ +AC_INIT(gMathView.ml) + +PACKAGE=lablgtkmathview + +LABLGTKMATHVIEW_MAJOR_VERSION=0 +LABLGTKMATHVIEW_MINOR_VERSION=7 +LABLGTKMATHVIEW_MICRO_VERSION=2 +LABLGTKMATHVIEW_VERSION=$LABLGTKMATHVIEW_MAJOR_VERSION.$LABLGTKMATHVIEW_MINOR_VERSION.$LABLGTKMATHVIEW_MICRO_VERSION +VERSION=$LABLGTKMATHVIEW_VERSION + +PKG_CHECK_MODULES(GDOME, gdome2 >= 0.7.0,, AC_MSG_ERROR(could not find Gdome2)) +AC_SUBST(GDOME_CFLAGS) +AC_SUBST(GDOME_LIBS) + +PKG_CHECK_MODULES(GTKMATHVIEW, gtkmathview-gmetadom >= 0.6.2,, AC_MSG_ERROR(could not find gtkmathview-gmetadom)) +AC_SUBST(GTKMATHVIEW_CFLAGS) +AC_SUBST(GTKMATHVIEW_LIBS) + +AC_CHECK_PROG(HAVE_OCAMLC, ocamlc, yes, no) +if test $HAVE_OCAMLC = "no"; then + AC_MSG_ERROR(could not find ocamlc in PATH, please make sure ocaml is installed) +fi + +AC_CHECK_PROG(HAVE_OCAMLFIND, ocamlfind, yes, no) +if test $HAVE_OCAMLFIND = "no"; then + AC_MSG_ERROR(could not find ocamlfind in PATH, please make sure findlib is installed) +fi + +AC_MSG_CHECKING("for gdome2") +ocamlfind query gdome2 || + AC_MSG_ERROR(gdome2 not installed (according to findlib)) + +AC_MSG_CHECKING("for lablgtk2") +ocamlfind query lablgtk2 || + AC_MSG_ERROR(lablgtk2 not installed (according to findlib)) + +AC_MSG_CHECKING("for the ocaml library dir") +OCAML_LIB_DIR=`ocamlc -where` +OCAML_STUB_DIR="$OCAML_LIB_DIR/stublibs" +AC_MSG_RESULT($OCAML_LIB_DIR) + +AC_CHECK_FILE(/usr/include/caml/mlvalues.h, + OCAML_INCLUDE_DIR=/usr/include/caml, + OCAML_INCLUDE_DIR=$OCAML_LIB_DIR/caml +) + +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) +AC_SUBST(OCAML_INCLUDE_DIR) +AC_SUBST(OCAML_LIB_DIR) +AC_SUBST(OCAML_STUB_DIR) + +AC_OUTPUT([ + test/Makefile + Makefile + META +]) diff --git a/DEVEL/lablgtkmathview/debian/changelog b/DEVEL/lablgtkmathview/debian/changelog new file mode 100644 index 000000000..2b3c7b897 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/changelog @@ -0,0 +1,347 @@ +lablgtkmathview (0.7.2-4) unstable; urgency=low + + * Rebuilt against OCaml 3.09.1, bumped deps accordingly. + * Bugfix: added debian/liblablgtkmathview.install.in, which was + missing, but contained hard coded ABI version instances + + -- Stefano Zacchiroli Sun, 8 Jan 2006 01:21:17 +0100 + +lablgtkmathview (0.7.2-3) unstable; urgency=low + + * rebuilt with ocaml 3.09 + * debian/* + - no longer hard coding of ocaml abi number anywhere + + -- Stefano Zacchiroli Wed, 23 Nov 2005 09:59:14 +0000 + +lablgtkmathview (0.7.2-2) unstable; urgency=low + + * debian/changelog + - reverted version format, '-debian_version' is back again + * debian/liblablgtkmathview-ocaml.install + - install .so in /stublibs/ + + -- Stefano Zacchiroli Sun, 25 Sep 2005 18:50:32 +0200 + +lablgtkmathview (0.7.2) unstable; urgency=low + + * new upstream release + - enable access to gtk events + - new methods bound: {set,get}_{t1_opaque_mode,t1_anti_aliased_mode} + - bound new GtkMathView method for loading configuration files + * debian/control + - bumped standards-version + - bumped deps on gmetadom and lablgtk2 + - removed useless build-dep on autoconf + + -- Stefano Zacchiroli Sun, 31 Jul 2005 21:00:42 +0200 + +lablgtkmathview (0.7.1-2) unstable; urgency=low + + * debian/control + - changed dep on gtkmathview to libgtkmathview0c2 + - bumped dep on gmetadom to 0.2.3 + + -- Stefano Zacchiroli Thu, 7 Jul 2005 14:15:44 +0000 + +lablgtkmathview (0.7.1-1) unstable; urgency=low + + * new upstream release + - enable static binding of C stubs + + -- Stefano Zacchiroli Wed, 15 Jun 2005 14:27:44 +0200 + +lablgtkmathview (0.7.0-1) unstable; urgency=low + + * new upstream release + - minor changes, removed some annoying debugging prints + * rebuilt against lablgtk2 2.4.0+2005.06.13-1 and gtkmathview 0.7.0 + + -- Stefano Zacchiroli Sat, 11 Jun 2005 12:38:44 +0200 + +lablgtkmathview (0.6.4-3) unstable; urgency=low + + * rebuilt with ocaml 3.08.3 and lablgtk2 2.4.0+2005.02.18 + + -- Stefano Zacchiroli Tue, 29 Mar 2005 10:43:44 +0200 + +lablgtkmathview (0.6.4-2) unstable; urgency=low + + * rebuilt with ocaml 3.08.2 and lablgtk2 2.4.0+2004.11.19-1 + + -- Stefano Zacchiroli Thu, 9 Dec 2004 16:21:36 +0100 + +lablgtkmathview (0.6.4-1) unstable; urgency=low + + * new upstream release + - bindings for gtkmathview 0.6.4 + + -- Stefano Zacchiroli Wed, 10 Nov 2004 14:20:10 +0100 + +lablgtkmathview (0.6.3-2) unstable; urgency=medium + + * debian/control + - depend on ocaml-base-nox-3.08 instead of ocaml-base-3.08 since + this package doesn't directly need ocaml X libraries + + -- Stefano Zacchiroli Tue, 24 Aug 2004 12:23:18 +0200 + +lablgtkmathview (0.6.3-1) unstable; urgency=low + + * new upstream release + - bindings for gtkmathview 0.6.3 + * rebuilt with ocaml 3.08 + * debian/control + - bumped ocaml deps to 3.08 + - bumped lablgtk deps to >= 2.4.0 + - bumped gdome deps to >= 0.2.1-3 (1st version rebuilt with 3.08) + - bumped gtkmathview deps to >= 0.6.3 (needed by this binding) + - bumped stadards version to 3.6.1.1 + + -- Stefano Zacchiroli Thu, 29 Jul 2004 11:51:56 +0200 + +lablgtkmathview (0.5.1-4) unstable; urgency=low + + * ported to latest lablgtk2 (2.2.0+20040113) cvs snapshot + * debian/control + - changed build-dep accordingly + + -- Stefano Zacchiroli Fri, 23 Jan 2004 13:44:11 +0100 + +lablgtkmathview (0.5.1-3) unstable; urgency=low + + * debian/control + - removed some dependencies that should be inherited from + libgtkmathview-dev (bugfix for newer libt1-dev) + - bumped standards version to 3.6.1.0 + + -- Stefano Zacchiroli Thu, 22 Jan 2004 12:54:47 +0100 + +lablgtkmathview (0.5.1-2) unstable; urgency=low + + * Rebuilt with lablgtk2 2.2.0 + * debian/control + - bumped ocaml-findlib dependencies to 0.8-5 + + -- Stefano Zacchiroli Mon, 13 Oct 2003 09:18:48 +0200 + +lablgtkmathview (0.5.1-1) unstable; urgency=low + + * New upstream release (transition to gtk2) + + -- Stefano Zacchiroli Fri, 10 Oct 2003 10:10:10 +0200 + +lablgtkmathview (0.4.3-4) unstable; urgency=low + + * Rebuild with ocaml 3.07 + * debian/autodebian.make and debian/*.in + An experiment! + Mainly I've added an indirection which permits to fill some autoconf + variable in debian/* files. In this way the ocaml version is + discovered automagically and doesn't need to be manually changed + each time a new ocaml version is released. Actually the only two + supported variables are @OCAML_STDLIB_DIR@ (actually expands to + "usr/lib/ocaml/3.07" via ocamlc -where) and @OCAML_STUBLIBS_DIR@ + (actually expands to "usr/lib/ocaml/3.07/stublibs") + + -- Stefano Zacchiroli Wed, 1 Oct 2003 22:48:51 +0200 + +lablgtkmathview (0.4.3-3) unstable; urgency=low + + * rebuilt against gmetadom 0.1.10-3 + * debian/control + - strictly depends on gmetadom >= 0.1.10-3 (older version are buggy + on mips) + + -- Stefano Zacchiroli Sat, 12 Jul 2003 14:14:31 +0200 + +lablgtkmathview (0.4.3-2) unstable; urgency=low + + * upstream changes + - fixed Makefile.in that still looked for gtkmathview-config + - selection flickering got rid of (by means of freeze/thaw) + - structural selection is no longer activated just before + semantic selection for single_selection_math_view + * debian/control + - bumped gmetadom dependencies to >= 0.1.10-2 (to ensure that .pc + file is available) + + -- Stefano Zacchiroli Tue, 1 Jul 2003 11:25:48 +0200 + +lablgtkmathview (0.4.3-1) unstable; urgency=low + + * Rebuild against gtkmathview 0.4.3 + * debian/control + - bumped standards version to 3.5.10 + - bumped dependencies on gtkmathview to 0.4.3 + - bumped dependencies on gmetadom to 0.1.9 + - added ${misc:Depends} + - changed section of -dev package to "libdevel" + - better short description + - added built-dep to pkg-config + * debian/rules + - removed DH_COMPAT in favour of debian/compat + - comsetic changes + - removed useless binary-indep target + - removed dh_movefiles in favour of dh_install + + -- Stefano Zacchiroli Thu, 19 Jun 2003 14:52:54 +0200 + +lablgtkmathview (0.4.1-1) unstable; urgency=low + + * Bugfix in some OCaml value allocations + * Binding for gtkmathview 0.4.1 + * Bumped dependencies to gtkmathview 0.4.1 + * Dropped << dependencies for ocaml libraries + * Bumped gmetadom dependencies to >= 0.1.6 + * Bumped gdome2 dependencies to >= 0.7.4 + + -- Stefano Zacchiroli Tue, 11 Mar 2003 21:18:29 +0100 + +lablgtkmathview (0.3.99-2) unstable; urgency=low + + * Bugfix: added dep on t1lib-dev from liblablgtkmathview-ocaml-dev + * Bugfix: added dep on libgtkmathview-dev (>= 0.4.0) from + liblablgtkmathview-ocaml-dev + + -- Stefano Zacchiroli Sat, 25 Jan 2003 10:24:53 +0100 + +lablgtkmathview (0.3.99-1) unstable; urgency=low + + * Binding to gtkmathview 0.4.0 (pre-release) + * Added module GMathViewAux which contains backward compatible + "single_selection_math_view" class + * Reverted to >=/<< dependencies for ocaml libraries + * Bumped dependencies on gmetadom to 0.1.5 + * Bumped dependencies on gtkmathview to 0.4.0 + * Added missing dependencies from liblablgtkmathview-ocaml-dev to + libgdome2-ocaml-dev + * Versioned dependencies on liblablgtk-ocaml-dev + + -- Stefano Zacchiroli Wed, 22 Jan 2003 14:23:30 +0100 + +lablgtkmathview (0.3.1-1) unstable; urgency=low + + * Binding to gtkmathview 0.3.1 + * debian/control + - bumped Standards Version to 3.5.8 + - deps and build deps to ocaml{,-base}-3.06-1 + * Moved lib stuff to /usr/lib/ocaml/3.06 + + -- Stefano Zacchiroli Tue, 7 Jan 2003 12:57:47 +0100 + +lablgtkmathview (0.3.0-10) unstable; urgency=low + + * Added dep on liblablgtk-ocaml{,-dev} respectively in + liblablgtkmathview-ocaml{,-dev} + + -- Stefano Zacchiroli Tue, 17 Sep 2002 11:58:14 +0200 + +lablgtkmathview (0.3.0-9) unstable; urgency=low + + * Removed useless dh_ocamlld invocation + * Fixed native code compilation shared object path (now looks for .so + in /usr/lib/ocaml/stublibs instead of + /usr/lib/ocaml/lablgtkmathview) + + -- Stefano Zacchiroli Thu, 29 Aug 2002 15:02:21 +0200 + +lablgtkmathview (0.3.0-8) unstable; urgency=low + + * Switched to debhelper 4 + * Added build dep on findlib (>= 0.7.1) + * Rebuilt against ocaml 3.06 (Closes: Bug#158256, Bug#158266) + * Changed deps and build-deps to ocaml-3.06 and ocaml-base-3.06 as + mandated by the new ocaml packaging policy + * Removed mention of lablgtkmathview from debian/control + * Added dep on ocaml-findlib + * Moved shared objects to /usr/lib/ocaml/stublibs + + -- Stefano Zacchiroli Sun, 7 Jul 2002 13:50:52 +0200 + +lablgtkmathview (0.3.0-7) unstable; urgency=low + + * Added -fPIC when compiling some .o in order to build on HPPA + (Closes: #142462) + + -- Stefano Zacchiroli Fri, 12 Apr 2002 14:31:47 +0200 + +lablgtkmathview (0.3.0-6) unstable; urgency=low + + * Added Build-Depends on t1lib-dev (Closes: Bug#140835). + + -- Stefano Zacchiroli Tue, 2 Apr 2002 10:11:25 +0200 + +lablgtkmathview (0.3.0-5) unstable; urgency=low + + * Added Build-Depends on libgdome2-cpp-smart-dev (Closes: Bug#140720). + + -- Stefano Zacchiroli Mon, 1 Apr 2002 09:00:03 +0200 + +lablgtkmathview (0.3.0-4) unstable; urgency=low + + * Added some .mli and .ml files that document the library interface. + * Added Depends: on libgdome2-ocaml, we haven't yet estabilished how to + interact with shlibs system for ocaml shared library that are installed in + /usr/lib/ocaml + + -- Stefano Zacchiroli Mon, 1 Apr 2002 00:17:41 +0200 + +lablgtkmathview (0.3.0-3) unstable; urgency=low + + * Rebuilt against gmetadom 0.3.0-4 and gtkmathview 0.3.0-2. + + -- Stefano Zacchiroli Tue, 26 Mar 2002 19:17:56 +0100 + +lablgtkmathview (0.3.0-2) unstable; urgency=low + + * Added build dep on libgdome2-dev + * Removed CVS stuff from source tarball + + -- Stefano Zacchiroli Fri, 15 Mar 2002 13:23:53 +0100 + +lablgtkmathview (0.3.0-1) unstable; urgency=low + + * New upstream release + * Renamed resulting package to liblablgtkmathview-ocaml-dev + * Changed build-depends to adhere to the new ocaml packages naming schema + (e.g. lablgtk -> liblablgtk-ocaml-dev) (Closes: Bug#138116) + * Split away shared library in liblablgtkmathview-ocaml package + + -- Stefano Zacchiroli Wed, 13 Mar 2002 18:53:50 +0100 + +lablgtkmathview (0.2.8-1) unstable; urgency=low + + * New upstream release + * Built with ocaml 3.04 and lablgtk 1.2.3 + * Removed useless build depends + + -- Stefano Zacchiroli Mon, 25 Feb 2002 18:18:25 +0100 + +lablgtkmathview (0.2.4-4) unstable; urgency=low + + * Rebuilt with libgtkmathview 0.2.7 + + -- Stefano Zacchiroli Tue, 4 Sep 2001 22:16:35 +0200 + +lablgtkmathview (0.2.4-3) unstable; urgency=low + + * Rebuilt with ocaml 3.02 and lablgtk 1.2.1 + + -- Stefano Zacchiroli Tue, 21 Aug 2001 15:20:05 +0200 + +lablgtkmathview (0.2.4-2) unstable; urgency=low + + * Added build-dep on libxml2-dev (closes: Bug#102715). + + -- Stefano Zacchiroli Fri, 29 Jun 2001 12:39:57 +0200 + +lablgtkmathview (0.2.4-1) unstable; urgency=low + + * Initial Release (closes: Bug#93105). + + -- Stefano Zacchiroli Wed, 4 Apr 2001 23:27:07 +0200 + +Local variables: +mode: debian-changelog +End: diff --git a/DEVEL/lablgtkmathview/debian/compat b/DEVEL/lablgtkmathview/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/compat @@ -0,0 +1 @@ +4 diff --git a/DEVEL/lablgtkmathview/debian/control b/DEVEL/lablgtkmathview/debian/control new file mode 100644 index 000000000..e52875552 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/control @@ -0,0 +1,27 @@ +Source: lablgtkmathview +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>> 4.0.0), ocaml-nox (>= 3.09.1), ocaml-findlib (>= 1.1), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgdome2-ocaml-dev (>= 0.2.3-5), libgtkmathview-dev (>= 0.7.5), pkg-config +Standards-Version: 3.6.2 + +Package: liblablgtkmathview-ocaml +Architecture: any +Section: libs +Depends: ocaml-base-nox-${F:OCamlABI}, liblablgtk2-ocaml (>= 2.6.0-2), libgdome2-ocaml (>= 0.2.3-5), libgtkmathview0c2a (>= 0.7.5), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for libgtkmathview, a GTK widget to render MathML + This is the Ocaml binding for the GtkMathView widget, that is + currently available in the libgtkmathview0 package. + . + This package contains only the shared runtime stub libraries. + +Package: liblablgtkmathview-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, liblablgtk2-ocaml-dev (>= 2.6.0-2), liblablgtkmathview-ocaml (= ${Source-Version}), ocaml-findlib, libgdome2-ocaml-dev (>= 0.2.3-5), libgtkmathview-dev (>= 0.7.5), ${misc:Depends} +Description: OCaml bindings for libgtkmathview, a GTK widget to render MathML + These are the Ocaml bindings for the GtkMathView widget, that is + currently available in the libgtkmathview0 package. + . + This package contains the development part of the lablgtkmathview package. + diff --git a/DEVEL/lablgtkmathview/debian/control.in b/DEVEL/lablgtkmathview/debian/control.in new file mode 100644 index 000000000..6d7d91869 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/control.in @@ -0,0 +1,27 @@ +Source: lablgtkmathview +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>> 4.0.0), ocaml-nox (>= @OCamlABI@), ocaml-findlib (>= 1.1), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgdome2-ocaml-dev (>= 0.2.3-5), libgtkmathview-dev (>= 0.7.5), pkg-config +Standards-Version: 3.6.2 + +Package: liblablgtkmathview-ocaml +Architecture: any +Section: libs +Depends: ocaml-base-nox-${F:OCamlABI}, liblablgtk2-ocaml (>= 2.6.0-2), libgdome2-ocaml (>= 0.2.3-5), libgtkmathview0c2a (>= 0.7.5), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for libgtkmathview, a GTK widget to render MathML + This is the Ocaml binding for the GtkMathView widget, that is + currently available in the libgtkmathview0 package. + . + This package contains only the shared runtime stub libraries. + +Package: liblablgtkmathview-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, liblablgtk2-ocaml-dev (>= 2.6.0-2), liblablgtkmathview-ocaml (= ${Source-Version}), ocaml-findlib, libgdome2-ocaml-dev (>= 0.2.3-5), libgtkmathview-dev (>= 0.7.5), ${misc:Depends} +Description: OCaml bindings for libgtkmathview, a GTK widget to render MathML + These are the Ocaml bindings for the GtkMathView widget, that is + currently available in the libgtkmathview0 package. + . + This package contains the development part of the lablgtkmathview package. + diff --git a/DEVEL/lablgtkmathview/debian/copyright b/DEVEL/lablgtkmathview/debian/copyright new file mode 100644 index 000000000..7ac39e1a9 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/copyright @@ -0,0 +1,21 @@ +This package was debianized by Stefano Zacchiroli on +Wed, 4 Apr 2001 23:27:07 +0200. + +It was packed from source obtained via cvs, with this CVSROOT: + :pserver:anonymous@phd.cs.unibo.it:/home/lpadovan/PHELM/ + +Authors: + Luca Padovani + Claudio Sacerdoti Coen + +Copyright: + + Copyright (C) 2000, Luca Padovani . + + This file is part of lablgtkmathview, the Ocaml binding + for the GtkMathView widget. + + lablgtkmathview is free software, you can redistribute it and/or modify + it under the terms of the GNU General Public License. You can find a + copy of the license in /usr/share/common-licenses/GPL. + diff --git a/DEVEL/lablgtkmathview/debian/docs b/DEVEL/lablgtkmathview/debian/docs new file mode 100644 index 000000000..e845566c0 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/docs @@ -0,0 +1 @@ +README diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.dirs b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.dirs new file mode 100644 index 000000000..7ba05d3c3 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.dirs @@ -0,0 +1 @@ +usr/lib/ocaml/3.09.0 diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install new file mode 100644 index 000000000..5a9f2278d --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install @@ -0,0 +1,7 @@ +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.a +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.cma +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.cmi +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.cmxa +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/META +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.ml +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.mli diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install.in b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install.in new file mode 100644 index 000000000..bcae88906 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml-dev.install.in @@ -0,0 +1,7 @@ +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.a +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.cma +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.cmi +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.cmxa +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/META +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.ml +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.mli diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.dirs b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.dirs new file mode 100644 index 000000000..2c3099109 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.dirs @@ -0,0 +1 @@ +usr/lib/ocaml/3.09.0/stublibs diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install new file mode 100644 index 000000000..a3e0aaf87 --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/ocaml/3.09.1/lablgtkmathview/*.so usr/lib/ocaml/3.09.1/stublibs/ diff --git a/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install.in b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install.in new file mode 100644 index 000000000..2879520fd --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/liblablgtkmathview-ocaml.install.in @@ -0,0 +1 @@ +debian/tmp/usr/lib/ocaml/@OCamlABI@/lablgtkmathview/*.so usr/lib/ocaml/@OCamlABI@/stublibs/ diff --git a/DEVEL/lablgtkmathview/debian/rules b/DEVEL/lablgtkmathview/debian/rules new file mode 100755 index 000000000..832767abb --- /dev/null +++ b/DEVEL/lablgtkmathview/debian/rules @@ -0,0 +1,68 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +OCAMLABI := $(shell ocamlc -version) +OCAMLLIBDIR := $(shell ocamlc -where) +OFILES := $(patsubst %.in,%,$(shell ls debian/*.in)) + +ocamlinit: + for f in $(OFILES); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done +configure: configure-stamp +configure-stamp: + dh_testdir + ./configure + + touch configure-stamp + +build: configure-stamp build-stamp +build-stamp: + dh_testdir + + $(MAKE) + if [ -x /usr/bin/ocamlopt ]; then $(MAKE) opt; else true; fi + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + -$(MAKE) distclean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + mkdir -p debian/tmp$(OCAMLLIBDIR) + $(MAKE) install PREFIX=debian/tmp$(OCAMLLIBDIR) + +binary-arch: build install + dh_install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installman + dh_installinfo + dh_installchangelogs ChangeLog + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol -- -VF:OCamlABI="$(OCAMLABI)" + dh_md5sums + dh_builddeb + +binary: binary-arch +.PHONY: build clean binary-arch binary install configure diff --git a/DEVEL/lablgtkmathview/gMathView.ml b/DEVEL/lablgtkmathview/gMathView.ml new file mode 100644 index 000000000..0ec81f3f9 --- /dev/null +++ b/DEVEL/lablgtkmathview/gMathView.ml @@ -0,0 +1,103 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +open Gaux +open Gtk_mathview +open Gobject +open Gtk +open GtkBase +open GtkMathView +open OgtkMathViewProps +open GObj + +exception ErrorLoadingFile of string;; +exception ErrorWritingFile of string;; +exception ErrorLoadingDOM;; + +let option_element_of_option = + function + None -> None + | Some v -> Some (new Gdome.element v) + +let option_document_of_option = + function + None -> None + | Some v -> Some (new Gdome.document v) + +class math_view_skel obj = object + inherit GObj.widget (obj : Gtk_mathview.math_view obj) + method event = new GObj.event_ops obj + method freeze = MathView.freeze obj + method thaw = MathView.thaw obj + method load_uri ~filename = + if not (MathView.load_uri obj ~filename) then raise (ErrorLoadingFile filename) + method load_root ~root = + if not (MathView.load_root obj ~root:((root : Gdome.element)#as_Element)) then + raise ErrorLoadingDOM + method unload = MathView.unload obj + method select element = MathView.select obj ((element : Gdome.element)#as_Element) + method unselect element = MathView.unselect obj ((element : Gdome.element)#as_Element) + method is_selected element = MathView.is_selected obj ((element : Gdome.element)#as_Element) + method get_element_at x y = option_element_of_option (MathView.get_element_at obj x y) + method get_document = option_document_of_option (MathView.get_document obj) + method structure_changed element = MathView.structure_changed obj ((element : Gdome.element)#as_Element) + method attribute_changed element ~name = MathView.attribute_changed obj ((element : Gdome.element)#as_Element) ((name : Gdome.domString)#as_DOMString) + method get_bounding_box = MathView.get_bounding_box obj + method get_size = MathView.get_size obj + method get_top = MathView.get_top obj + method set_top x y = MathView.set_top obj x y + method set_adjustments adj1 adj2 = MathView.set_adjustments obj (GData.as_adjustment adj1) (GData.as_adjustment adj2) + method get_adjustments = + let hadj, vadj = MathView.get_adjustments obj in + new GData.adjustment hadj, new GData.adjustment vadj + method get_buffer = MathView.get_buffer obj + method set_font_size = MathView.set_font_size obj + method get_font_size = MathView.get_font_size obj + method set_log_verbosity = MathView.set_log_verbosity obj + method get_log_verbosity = MathView.get_log_verbosity obj + method set_t1_opaque_mode = MathView.set_t1_opaque_mode obj + method get_t1_opaque_mode = MathView.get_t1_opaque_mode obj + method set_t1_anti_aliased_mode = MathView.set_t1_anti_aliased_mode obj + method get_t1_anti_aliased_mode = MathView.get_t1_anti_aliased_mode obj +end + +class math_view_signals obj = object + inherit GObj.widget_signals_impl obj + inherit math_view__g_meta_dom_sigs +end + +class math_view obj = object + inherit math_view_skel (obj : Gtk_mathview.math_view obj) + method connect = new math_view_signals obj +end + +let math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Widget.size_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new math_view (MathView.create p)) ~font_size ~log_verbosity)) [] + +let add_configuration_path = GtkMathView.add_configuration_path + diff --git a/DEVEL/lablgtkmathview/gMathView.mli b/DEVEL/lablgtkmathview/gMathView.mli new file mode 100644 index 000000000..d116c527d --- /dev/null +++ b/DEVEL/lablgtkmathview/gMathView.mli @@ -0,0 +1,108 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +exception ErrorLoadingFile of string +exception ErrorWritingFile of string +exception ErrorLoadingDOM + +class math_view_signals : + ([> `gtk | `mathview_gmetadom | `widget] as 'b) Gtk.obj -> + object ('a) + inherit GObj.widget_signals + val after: bool + val obj: 'b Gtk.obj + method click : + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id + method element_over : + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id + method select_begin : + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id + method select_over : + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id + method select_end : + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id + method select_abort : + callback:(unit -> unit) -> GtkSignal.id + end + +class math_view_skel : + (Gtk_mathview.math_view Gtk.obj as 'a)-> + object + inherit GObj.widget + val obj : 'a + method attribute_changed : Gdome.element -> name:Gdome.domString -> unit + method event : GObj.event_ops + method freeze : unit + method get_adjustments : GData.adjustment * GData.adjustment + method get_bounding_box : int * int * int + method get_buffer : Gdk.pixmap + method get_document : Gdome.document option + method get_element_at : int -> int -> Gdome.element option (* x, y *) + method get_font_size : int + method get_log_verbosity : int + method get_size : int * int + method get_t1_anti_aliased_mode : bool + method get_t1_opaque_mode : bool + method get_top : int * int + method is_selected : Gdome.element -> bool + method load_root : root:Gdome.element -> unit + method load_uri : filename:string -> unit + method select : Gdome.element -> unit + method set_adjustments : GData.adjustment -> GData.adjustment -> unit + method set_font_size : int -> unit + method set_log_verbosity : int -> unit + method set_top : int -> int -> unit + method set_t1_anti_aliased_mode : bool -> unit + method set_t1_opaque_mode : bool -> unit + method structure_changed : Gdome.element -> unit + method thaw : unit + method unload : unit + method unselect : Gdome.element -> unit + end + +class math_view : + Gtk_mathview.math_view Gtk.obj -> + object + inherit math_view_skel + method connect : math_view_signals + end + +val math_view : + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> + ?font_size:int -> + ?log_verbosity:int -> + ?width:int -> + ?height:int -> + ?packing:(GObj.widget -> unit) -> ?show:bool -> unit -> math_view + +(** {2 Global configuration for all math_view instances *) + + (** @param fname file name to be added to the list of configuration files read + * at initialization time. + * To be invoked before GTK initialization. *) +val add_configuration_path: string -> unit + diff --git a/DEVEL/lablgtkmathview/gMathViewAux.ml b/DEVEL/lablgtkmathview/gMathViewAux.ml new file mode 100644 index 000000000..45bc5d90c --- /dev/null +++ b/DEVEL/lablgtkmathview/gMathViewAux.ml @@ -0,0 +1,281 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +(* finds the common node ancestor of two nodes *) +let common_ancestor (first : Gdome.node) (last : Gdome.node) = + let rec path n = + match n#get_parentNode with + None -> [n] + | Some p -> n::(path p) + in + let rec last_common = + function + _, hd1::tl1, hd2::tl2 when hd1#isSameNode hd2 -> (last_common ((Some hd1),tl1,tl2)) + | Some e, _, _ -> e + | _,_,_ -> assert false + in + (last_common (None,(List.rev (path first)),(List.rev (path last)))) + +let same_element (e1 : Gdome.element option) (e2 : Gdome.element option) = + match e1, e2 with + None, None -> true + | Some e1, Some e2 when (e1 :> Gdome.node)#isSameNode (e2 :> Gdome.node) -> true + | _ -> false + +(* true if n1 is n2 or one of n2's descendants *) +let rec descendant_of (n1 : Gdome.node) (n2 : Gdome.node) = + if n1#isSameNode n2 then true + else + match n1#get_parentNode with + None -> false + | Some n1' -> descendant_of n1' n2 + +let remove_descendants_of (el : Gdome.element) = + let rec aux = + function + [] -> [] + | hd::tl when descendant_of (hd :> Gdome.node) (el :> Gdome.node) -> aux tl + | hd::tl -> hd::(aux tl) + in + aux + +(* mem el l = true if the node n is stored in the list l *) +let mem (el : Gdome.element) = + let rec mem_aux = + function + hd::_ when (hd :> Gdome.node)#isSameNode (el :> Gdome.node) -> true + | _::tl -> mem_aux tl + | _ -> false + in + mem_aux + +(* remove el l = l' where l' has the same nodes as l except that all + * the occurrences of n have been removed *) +let remove (el : Gdome.element) = + let rec remove_aux = + function + hd::tl when (hd :> Gdome.node)#isSameNode (el :> Gdome.node) -> + remove_aux tl + | hd::tl -> hd::(remove_aux tl) + | [] -> [] + in + remove_aux + +class single_selection_math_view_signals obj (set_selection_changed : (Gdome.element option -> unit) -> unit) = + object + inherit GMathView.math_view_signals obj + method selection_changed = set_selection_changed + end +;; + +class single_selection_math_view obj = + object(self) + inherit GMathView.math_view_skel obj + val mutable first_selected = None + val mutable root_selected = None + val mutable selection_changed = (fun _ -> ()) + + method set_selection elem = + self#freeze ; + begin + match root_selected with + None -> () + | Some e -> self#unselect e + end; + root_selected <- elem ; + begin + match elem with + None -> () + | Some e -> self#select e + end ; + self#thaw + + method get_selection = root_selected + + method connect = + new + single_selection_math_view_signals obj + (function f -> selection_changed <- f) + + method action_toggle (elem : Gdome.element) = + match elem#get_namespaceURI, elem#get_localName with + Some ns, Some ln + when + (ns#to_string = "http://www.w3.org/1998/Math/MathML" && ln#to_string = "maction") || + (ns#to_string = "http://helm.cs.unibo.it/2003/BoxML" && ln#to_string = "action") + -> + begin + let selection_attr = Gdome.domString "selection" in + let selection = + if elem#hasAttribute ~name:selection_attr then + int_of_string (elem#getAttribute ~name:selection_attr)#to_string + else + 1 + in + self#freeze ; + (* the widget will cast the index back into a valid range *) + elem#setAttribute ~name:selection_attr + ~value:(Gdome.domString (string_of_int (selection + 1))) ; + self#thaw ; + true + end + | _ -> + begin + match elem#get_parentNode with + Some p -> + begin + try + self#action_toggle (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> false + end + | None -> assert false (* every element has a parent *) + end + + initializer + selection_changed <- self#set_selection ; + + ignore + (self#connect#select_begin + (fun ((elem : Gdome.element option), _, _, _) -> + if not (same_element root_selected elem) then selection_changed elem ; + first_selected <- elem)) ; + + ignore + (self#connect#select_over + (fun ((elem : Gdome.element option), _, _, _) -> + let new_selected = + match first_selected, elem with + Some first', Some last' -> + (Some + (new Gdome.element_of_node + (common_ancestor (first' :> Gdome.node) (last' :> Gdome.node)))) + | _ -> None + in + if not (same_element root_selected new_selected) then + selection_changed new_selected)) ; + + ignore + (self#connect#select_end + (fun ((elem : Gdome.element option), _, _, _) -> first_selected <- None)) ; + + ignore + (self#connect#select_abort + (fun () -> + first_selected <- None ; + selection_changed None)) ; + + ignore (self#connect#click (fun _ -> self#set_selection None)) + end +;; + +let single_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Widget.size_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new single_selection_math_view + (GtkMathViewProps.MathView_GMetaDOM.create p)) ~font_size ~log_verbosity)) [] +;; + +class multi_selection_math_view_signals obj + (set_selection_changed : (Gdome.element option -> unit) -> unit) += + object + inherit GMathView.math_view_signals obj + method selection_changed = set_selection_changed + end +;; + +class multi_selection_math_view obj = + object(self) + inherit single_selection_math_view obj + val mutable selected : Gdome.element list = [] + + method remove_selection (elem : Gdome.element) = + if mem elem selected then + selected <- remove elem selected ; + self#unselect elem + + method remove_selections = + self#freeze ; + List.iter (fun e -> self#unselect e) selected ; + selected <- [] ; + begin + match self#get_selection with + None -> () + | Some e -> self#select e + end ; + self#thaw + + method add_selection (elem : Gdome.element) = + List.iter self#unselect selected ; + selected <- elem::(remove_descendants_of elem selected) ; + List.iter self#select selected + + method get_selections = selected + + method set_selection elem = + self#freeze ; + begin + match root_selected with + None -> () + | Some e -> self#unselect e ; List.iter (fun e -> self#select e) selected + end; + root_selected <- elem; + begin + match elem with + None -> () + | Some e -> self#select e + end ; + self#thaw + + initializer + ignore + (self#connect#select_begin + (fun (_,_,_,state) -> + if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then + self#remove_selections)) ; + + ignore + (self#connect#select_end + (fun (_,_,_,state) -> + if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then + self#remove_selections ; + match root_selected with + None -> () + | Some e -> self#set_selection None ; self#add_selection e)) ; + + ignore + (self#connect#click + (fun _ -> self#remove_selections)) + end + ;; + +let multi_selection_math_view ?hadjustment ?vadjustment ?font_size ?log_verbosity = + GtkBase.Widget.size_params ~cont:( + OgtkMathViewProps.pack_return + (fun p -> OgtkMathViewProps.set_params (new multi_selection_math_view + (GtkMathViewProps.MathView_GMetaDOM.create p)) ~font_size ~log_verbosity)) [] +;; diff --git a/DEVEL/lablgtkmathview/gMathViewAux.mli b/DEVEL/lablgtkmathview/gMathViewAux.mli new file mode 100644 index 000000000..299328733 --- /dev/null +++ b/DEVEL/lablgtkmathview/gMathViewAux.mli @@ -0,0 +1,78 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +class single_selection_math_view_signals : + ([> `gtk | `mathview_gmetadom | `widget] as 'b) Gtk.obj -> + ((Gdome.element option -> unit) -> unit) -> + object + inherit GMathView.math_view_signals + method selection_changed : (Gdome.element_of_node option -> unit) -> unit + end + +class single_selection_math_view : + Gtk_mathview.math_view Gtk.obj -> + object + inherit GMathView.math_view_skel + method connect : single_selection_math_view_signals + method get_selection : Gdome.element option + method set_selection : Gdome.element option -> unit + method action_toggle : Gdome.element -> bool + end + +val single_selection_math_view : + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> + ?font_size:int -> + ?log_verbosity:int -> + ?width:int -> + ?height:int -> + ?packing:(GObj.widget -> unit) -> + ?show:bool -> + unit -> + single_selection_math_view + +class multi_selection_math_view : + Gtk_mathview.math_view Gtk.obj -> + object + inherit single_selection_math_view + method remove_selection : Gdome.element -> unit + method remove_selections : unit + method add_selection : Gdome.element -> unit + method get_selections : Gdome.element list + end + +val multi_selection_math_view : + ?hadjustment:GData.adjustment -> + ?vadjustment:GData.adjustment -> + ?font_size:int -> + ?log_verbosity:int -> + ?width:int -> + ?height:int -> + ?packing:(GObj.widget -> unit) -> + ?show:bool -> + unit -> + multi_selection_math_view + diff --git a/DEVEL/lablgtkmathview/gtkMathView.ml b/DEVEL/lablgtkmathview/gtkMathView.ml new file mode 100644 index 000000000..0b9d45349 --- /dev/null +++ b/DEVEL/lablgtkmathview/gtkMathView.ml @@ -0,0 +1,107 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +open Gtk_mathview +open Gaux +open Gobject +open Gtk +open Tags +open GtkMathViewProps +open GtkBase + +external _gtkmathview_init : unit -> unit = "ml_gtk_mathview_init" +let () = _gtkmathview_init () + +external add_configuration_path : string -> unit = + "ml_gtk_math_view_add_configuration_path" + +module MathView = struct + include MathView_GMetaDOM + external freeze : [>`mathview_gmetadom] obj -> unit = + "ml_gtk_math_view_freeze" + external thaw : [>`mathview_gmetadom] obj -> unit = + "ml_gtk_math_view_thaw" + external load_uri : [>`mathview_gmetadom] obj -> filename:string -> bool = + "ml_gtk_math_view_load_uri" + external load_root : [>`mathview_gmetadom] obj -> root:[> `Element] GdomeT.t -> bool = + "ml_gtk_math_view_load_root" + external unload : [>`mathview_gmetadom] obj -> unit = + "ml_gtk_math_view_unload" + external select : + [>`mathview_gmetadom] obj -> [> `Element] GdomeT.t -> unit = + "ml_gtk_math_view_select" + external unselect : + [>`mathview_gmetadom] obj -> [> `Element] GdomeT.t -> unit = + "ml_gtk_math_view_unselect" + external is_selected : + [>`mathview_gmetadom] obj -> [> `Element] GdomeT.t -> bool = + "ml_gtk_math_view_is_selected" + external structure_changed : + [>`mathview_gmetadom] obj -> [> `Element] GdomeT.t -> unit = + "ml_gtk_math_view_structure_changed" + external attribute_changed : + [>`mathview_gmetadom] obj -> [> `Element] GdomeT.t -> name:TDOMString.t -> unit = + "ml_gtk_math_view_attribute_changed" + external get_bounding_box : + [>`mathview_gmetadom] obj -> (int * int * int) = + "ml_gtk_math_view_get_bounding_box" + external get_element_at : + [> `mathview_gmetadom] obj -> int -> int -> TElement.t option = + "ml_gtk_math_view_get_element_at" + external get_document : + [> `mathview_gmetadom] obj -> TDocument.t option = + "ml_gtk_math_view_get_document" + (* beginning of prop-like methods *) + external get_size : [>`mathview_gmetadom] obj -> int * int = + "ml_gtk_math_view_get_size" + external get_top : [>`mathview_gmetadom] obj -> (int * int) = + "ml_gtk_math_view_get_top" + external set_top : [>`mathview_gmetadom] obj -> int -> int -> unit = + "ml_gtk_math_view_set_top" + external set_adjustments : [>`mathview_gmetadom] obj -> Gtk.adjustment obj -> Gtk.adjustment obj -> unit = + "ml_gtk_math_view_set_adjustments" + external get_adjustments : [>`mathview_gmetadom] obj -> + Gtk.adjustment obj * Gtk.adjustment obj = + "ml_gtk_math_view_get_adjustments" + external get_buffer : [>`mathview_gmetadom] obj -> Gdk.pixmap = + "ml_gtk_math_view_get_buffer" + external set_font_size : [>`mathview_gmetadom] obj -> int -> unit = + "ml_gtk_math_view_set_font_size" + external get_font_size : [>`mathview_gmetadom] obj -> int = + "ml_gtk_math_view_get_font_size" + external set_log_verbosity : [>`mathview_gmetadom] obj -> int -> unit = + "ml_gtk_math_view_set_log_verbosity" + external get_log_verbosity : [>`mathview_gmetadom] obj -> int = + "ml_gtk_math_view_get_log_verbosity" + external set_t1_opaque_mode : [>`mathview_gmetadom] obj -> bool -> unit = + "ml_gtk_math_view_set_t1_opaque_mode" + external get_t1_opaque_mode : [>`mathview_gmetadom] obj -> bool = + "ml_gtk_math_view_get_t1_opaque_mode" + external set_t1_anti_aliased_mode : [>`mathview_gmetadom] obj -> bool -> unit = + "ml_gtk_math_view_set_t1_anti_aliased_mode" + external get_t1_anti_aliased_mode : [>`mathview_gmetadom] obj -> bool = + "ml_gtk_math_view_get_t1_anti_aliased_mode" +end diff --git a/DEVEL/lablgtkmathview/gtkMathView.props b/DEVEL/lablgtkmathview/gtkMathView.props new file mode 100644 index 000000000..d26050ce4 --- /dev/null +++ b/DEVEL/lablgtkmathview/gtkMathView.props @@ -0,0 +1,111 @@ +(* $Id$ *) + +prefix "Gtk" + +header { +open Gtk +open Gtk_mathview + +external gdome_element_of_boxed_option : + Gpointer.boxed option -> TElement.t = + "ml_gtk_math_view_gdome_element_of_boxed_option" +;; + +external gdome_element_option_of_boxed_option : + Gpointer.boxed option -> TElement.t option = + "ml_gtk_math_view_gdome_element_option_of_boxed_option" +;; + +external model_event_of_boxed_option : + Gpointer.boxed option -> TElement.t option * int * int * int = + "ml_gtk_math_view_model_event_of_boxed_option" + +let option_element_of_option = + function + None -> None + | Some v -> Some (new Gdome.element v) +;; + +let option_element_of_boxed_option x = + option_element_of_option (gdome_element_option_of_boxed_option x) +;; + +let model_event_of_boxed model_event = + let id,x,y,state = model_event_of_boxed_option model_event in + option_element_of_option id,x,y,state +;; + +let gdome_element_option_conv = + {Gobject.kind = `POINTER ; + Gobject.proj = + (function + `POINTER element -> option_element_of_boxed_option element + | _ -> failwith "gdome_element_option_conv") ; + Gobject.inj = + (function element -> assert false) + } + +let gtk_math_view_model_event_conv = + {Gobject.kind = `POINTER ; + Gobject.proj = + (function + `POINTER model_event -> model_event_of_boxed model_event + | _ -> failwith "gtk_math_view_model_event_conv") ; + Gobject.inj = + (function element -> assert false) + } +} + +oheader { + +let set_params self ~font_size ~log_verbosity = + begin + match font_size with + Some s -> self#set_font_size s + | None -> () + end ; + begin + match log_verbosity with + Some v -> self#set_log_verbosity v + | None -> () + end ; + self +;; + +let pack_return create p ?packing ?show () = + GObj.pack_return (create p) ~packing ~show +;; + +} + +conversions { + GdomeElement_option "gdome_element_option_conv" + GtkMathViewModelEvent "gtk_math_view_model_event_conv" +} + +classes { + GtkAdjustment "Gtk.adjustment obj" +} + + +class MathView_GMetaDOM type "math_view obj" set wrapsig : Widget { +(* + "width" gint : Read + "height" gint : Read + "top-x" gint : Read / Write / NoSet + "top-y" gint : Read / Write / NoSet + "hadjustment" GtkAdjustment : Read / Write / Construct + "vadjustment" GtkAdjustment : Read / Write / Construct + "buffer" GdkPixmap : Read + "drawing-area" GtkDrawingArea : Read + "font-size" guint : Read / Write / Construct + "log-verbosity" gint : Read / Write / Construct + "root-element" GdomeElement_option : Read +*) + signal click: GtkMathViewModelEvent + signal select_begin: GtkMathViewModelEvent + signal select_over: GtkMathViewModelEvent + signal select_end: GtkMathViewModelEvent + signal select_abort + signal element_over: GtkMathViewModelEvent +} diff --git a/DEVEL/lablgtkmathview/gtk_mathview.ml b/DEVEL/lablgtkmathview/gtk_mathview.ml new file mode 100644 index 000000000..3267176a0 --- /dev/null +++ b/DEVEL/lablgtkmathview/gtk_mathview.ml @@ -0,0 +1,27 @@ +(* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + *) + +type math_view = [Gtk.widget|`mathview_gmetadom] diff --git a/DEVEL/lablgtkmathview/lablgtk/META.lablgtk b/DEVEL/lablgtkmathview/lablgtk/META.lablgtk new file mode 100644 index 000000000..f70c5bec6 --- /dev/null +++ b/DEVEL/lablgtkmathview/lablgtk/META.lablgtk @@ -0,0 +1,6 @@ +requires="" +version="1.2.0" +archive(byte)="lablgtk.cma lablgnome.cma gtkInit.cmo" +archive(native)="lablgtk.cmxa lablgnome.cmxa gtkInit.cmx" +linkopts="" +directory="+lablgtk" diff --git a/DEVEL/lablgtkmathview/ml_gtk_mathview.c b/DEVEL/lablgtkmathview/ml_gtk_mathview.c new file mode 100644 index 000000000..5d36bc0c4 --- /dev/null +++ b/DEVEL/lablgtkmathview/ml_gtk_mathview.c @@ -0,0 +1,271 @@ +/* Copyright (C) 2000-2005, + * Luca Padovani + * Claudio Sacerdoti Coen + * Stefano Zacchiroli + * + * This file is part of lablgtkmathview, the Ocaml binding for the + * GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * For details, send a mail to the authors. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Init all */ + +CAMLprim value ml_gtk_mathview_init(value unit) +{ + /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_math_view_get_type(); + return Val_GType(t); +} + +#define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val) + +//##################################### +// +//#define FontManagerId_val(val) Int_val(val) +//#define Val_FontManagerId(val) Val_int(val) +// +///* As ML_1, but the result is optional */ +//#define OML_1(cname, conv1, conv) \ +//value ml_##cname (value arg1) { return Val_option_ptr((cname (conv1 (arg1))),conv); } +///* As ML_3, but the result is optional */ +#define OML_3(cname, conv1, conv2, conv3, conv) \ +value ml_##cname (value arg1, value arg2, value arg3) { return Val_option_ptr((cname (conv1 (arg1), conv2 (arg2), conv3 (arg3))),conv); } +///* As ML_2, but the second argument is optional */ +//#define ML_2O(cname, conv1, conv2, conv) \ +//value ml_##cname (value arg1, value arg2) \ +//{ return conv (cname (conv1(arg1), ptr_val_option(arg2,conv2))); } + +value Val_Element_ref(GdomeElement* elem) +{ + if (elem != NULL) + { + GdomeException exc = 0; + gdome_el_ref(elem, &exc); + g_assert(exc == 0); + } + return Val_Element(elem); +} + +ML_2 (gtk_math_view_structure_changed, GtkMathView_val, Element_val, Unit) +ML_3 (gtk_math_view_attribute_changed, GtkMathView_val, Element_val, DOMString_val, Unit) +/* OML_3 (gtk_math_view_get_element_at, GtkMathView_val, Int_val, Int_val, Val_Element) */ +ML_1 (gtk_math_view_freeze, GtkMathView_val, Unit) +ML_1 (gtk_math_view_thaw, GtkMathView_val, Unit) +ML_2 (gtk_math_view_load_uri, GtkMathView_val, String_val, Val_bool) +ML_2 (gtk_math_view_load_root, GtkMathView_val, Element_val, Val_bool) +ML_1 (gtk_math_view_unload, GtkMathView_val, Unit) +ML_2 (gtk_math_view_select, GtkMathView_val, Element_val, Unit) +ML_2 (gtk_math_view_unselect, GtkMathView_val, Element_val, Unit) +ML_2 (gtk_math_view_is_selected, GtkMathView_val, Element_val, Val_bool) +/* +ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink) +ML_1 (gtk_math_view_get_width, GtkMathView_val, Val_int) +ML_1 (gtk_math_view_get_height, GtkMathView_val, Val_int) +*/ +ML_3 (gtk_math_view_set_top, GtkMathView_val, Int_val, Int_val, Unit) +ML_3 (gtk_math_view_set_adjustments, GtkMathView_val, GtkAdjustment_val, GtkAdjustment_val, Unit) +/* +ML_1 (gtk_math_view_get_hadjustment, GtkMathView_val, Val_GtkWidget) +ML_1 (gtk_math_view_get_vadjustment, GtkMathView_val, Val_GtkWidget) +*/ +ML_1 (gtk_math_view_get_buffer, GtkMathView_val, Val_GdkPixmap) +ML_2 (gtk_math_view_set_font_size, GtkMathView_val, Int_val, Unit) +ML_1 (gtk_math_view_get_font_size, GtkMathView_val, Val_int) +ML_2 (gtk_math_view_set_log_verbosity, GtkMathView_val, Int_val, Unit) +ML_1 (gtk_math_view_get_log_verbosity, GtkMathView_val, Val_int) +ML_2 (gtk_math_view_set_t1_opaque_mode, GtkMathView_val, Bool_val, Unit) +ML_1 (gtk_math_view_get_t1_opaque_mode, GtkMathView_val, Val_bool) +ML_2 (gtk_math_view_set_t1_anti_aliased_mode, GtkMathView_val, Bool_val, Unit) +ML_1 (gtk_math_view_get_t1_anti_aliased_mode, GtkMathView_val, Val_bool) +ML_1 (gtk_math_view_add_configuration_path, String_val, Unit) + +value ml_gtk_math_view_get_element_at (value arg1, value arg2, value arg3) +{ + CAMLparam3(arg1, arg2, arg3); + CAMLlocal1 (result); + GdomeElement* el; + if (gtk_math_view_get_element_at(GtkMathView_val (arg1), Int_val(arg2), Int_val(arg3), &el, NULL, NULL)) + result = Val_option_ptr(el, Val_Element); + else + result = Val_unit; + CAMLreturn (result); +} + +value ml_gtk_math_view_get_document (value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1(result); + GdomeDocument* doc = gtk_math_view_get_document(GtkMathView_val (arg1)); + if (doc == NULL) + result = Val_unit; + else + result = Val_option_ptr(doc, Val_Document); + CAMLreturn (result); +} + +value ml_gtk_math_view_get_adjustments(value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1(result); + GtkAdjustment* hadj; + GtkAdjustment* vadj; + gtk_math_view_get_adjustments(GtkMathView_val (arg1), &hadj, &vadj); + result = alloc(2, 0); + Store_field(result, 0, Val_GtkWidget(hadj)); + Store_field(result, 1, Val_GtkWidget(vadj)); + CAMLreturn(result); +} + +value ml_gtk_math_view_get_size (value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1(result); + int width, height; + gtk_math_view_get_size(GtkMathView_val (arg1), &width, &height); + result = alloc(1, 0); + Store_field(result, 0, Val_int(width)); + Store_field(result, 1, Val_int(height)); + CAMLreturn (result); +} + +value ml_gtk_math_view_get_bounding_box (value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1(result); + int width, height, depth; + GtkMathViewBoundingBox gbox; + gtk_math_view_get_bounding_box(GtkMathView_val (arg1), &gbox); + result = alloc(3, 0); + Store_field(result, 0, Val_int(gbox.width)); + Store_field(result, 1, Val_int(gbox.height)); + Store_field(result, 2, Val_int(gbox.depth)); + CAMLreturn (result); +} + +value ml_gtk_math_view_get_top (value arg1) +{ + CAMLparam1(arg1); + CAMLlocal1(result); + int x, y; + gtk_math_view_get_top(GtkMathView_val (arg1), &x, &y); + result = alloc(2, 0); + Store_field(result, 0, Val_int(x)); + Store_field(result, 1, Val_int(y)); + CAMLreturn (result); +} + +/* +value ml_gtk_math_view_get_element_coords (value arg1, value arg2) +{ + CAMLparam2(arg1, arg2); + CAMLlocal1 (result); + int x, y; + gtk_math_view_get_element_coords(GtkMathView_val (arg1), Element_val(arg2), &x, &y); + result = alloc(2, 0); + Store_field(result, 0, Val_int(x)); + Store_field(result, 1, Val_int(y)); + CAMLreturn (result); +} +*/ + +value ml_gtk_math_view_gdome_element_of_boxed_option (value arg1) +{ + CAMLparam1(arg1); + + GdomeException exc = 0; + GdomeElement* nr = NULL; + CAMLlocal1 (res); + + if (arg1==Val_int(0)) { + assert(0); + } else { + nr = (GdomeElement*) Field(Field(arg1,0),1); + } + + res = Val_Element_ref(nr); + if (res==Val_int(0)) { + assert(0); + } + + CAMLreturn(res); +} + +value ml_gtk_math_view_gdome_element_option_of_boxed_option (value arg1) +{ + CAMLparam1(arg1); + + GdomeElement* nr; + CAMLlocal1 (valnr); + CAMLlocal1 (res); + + if (arg1==Val_int(0)) { + res=Val_unit; + } else { + GdomeException exc = 0; + GdomeElement* elem = (GdomeElement*) Field(Field(arg1,0),1); + assert(elem != NULL); + res = Val_option_ptr(elem, Val_Element_ref); + } + + CAMLreturn(res); +} + +value ml_gtk_math_view_model_event_of_boxed_option (value arg1) +{ + CAMLparam1(arg1); + GdomeElement* nr; + CAMLlocal1 (valnr); + CAMLlocal1 (res); + + assert(arg1 != Val_int(0)); + GtkMathViewModelEvent* event = (GtkMathViewModelEvent*) Field(Field(arg1,0),1); + res = alloc(4, 0); + Store_field(res, 0, Val_option_ptr(event->id, Val_Element_ref)); + Store_field(res, 1, Val_int(event->x)); + Store_field(res, 2, Val_int(event->y)); + Store_field(res, 3, Val_int(event->state)); + + CAMLreturn(res); +} + diff --git a/DEVEL/lablgtkmathview/test/.cvsignore b/DEVEL/lablgtkmathview/test/.cvsignore new file mode 100644 index 000000000..b95eb22fb --- /dev/null +++ b/DEVEL/lablgtkmathview/test/.cvsignore @@ -0,0 +1 @@ +*.cmo *.cmi *.cmx t1lib.log test test.opt test.ps test.o Makefile diff --git a/DEVEL/lablgtkmathview/test/Makefile.in b/DEVEL/lablgtkmathview/test/Makefile.in new file mode 100644 index 000000000..1b4d01991 --- /dev/null +++ b/DEVEL/lablgtkmathview/test/Makefile.in @@ -0,0 +1,20 @@ +PACKAGE = @PACKAGE@ lablgtk2.init +MLFLAGS = +OCAMLC = ocamlfind ocamlc $(MLFLAGS) +OCAMLOPT = ocamlfind ocamlopt $(MLFLAGS) +TMPDIR = .test + +all: test +opt: test.opt + +test: test.ml + $(OCAMLC) -package "$(PACKAGE)" -linkpkg -predicates "" -o $@ test.ml + +test.opt: test.ml + $(OCAMLOPT) -package "$(PACKAGE)" -linkpkg -predicates "" -o $@ test.ml + +clean: + rm -f *.cm[iox] *.o test test.opt t1lib.log test.ps + +distclean: + rm Makefile diff --git a/DEVEL/lablgtkmathview/test/t1.config b/DEVEL/lablgtkmathview/test/t1.config new file mode 100644 index 000000000..afb669e95 --- /dev/null +++ b/DEVEL/lablgtkmathview/test/t1.config @@ -0,0 +1,3 @@ +ENCODING=. +AFM=/usr/share/texmf/fonts/afm/ +TYPE1=/usr/share/texmf/fonts/type1/bluesky/cm/:/usr/X11R6/lib/X11/fonts/Type1/:. diff --git a/DEVEL/lablgtkmathview/test/test.ml b/DEVEL/lablgtkmathview/test/test.ml new file mode 100644 index 000000000..b0e584cae --- /dev/null +++ b/DEVEL/lablgtkmathview/test/test.ml @@ -0,0 +1,397 @@ +(* Copyright (C) 2000-2003, Luca Padovani , + * Claudio Sacerdoti Coen . + * + * This file is part of lablgtkmathview, the Ocaml binding + * for the GtkMathView widget. + * + * lablgtkmathview 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. + * + * lablgtkmathview is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with lablgtkmathview; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * For details, send a mail to the author. + *) + +(******************************************************************************) +(* Claudio Sacerdoti Coen *) +(* 25/09/2000 *) +(* *) +(* This is a simple test for the OCaml (LablGtk indeed) binding of the *) +(* MathView widget *) +(******************************************************************************) + +let helmns = Gdome.domString "http://www.cs.unibo.it/helm";; + +(* +let choose_selection mmlwidget (element : Gdome.element option) = + let module G = Gdome in + let rec aux element = + if element#hasAttributeNS + ~namespaceURI:Misc.helmns + ~localName:(G.domString "xref") + then + mmlwidget#set_selection (Some element) + else + try + match element#get_parentNode with + None -> assert false + (*CSC: OCAML DIVERGES! + | Some p -> aux (new G.element_of_node p) + *) + | Some p -> aux (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + prerr_endline + "******* trying to select above the document root ********" + in + match element with + Some x -> aux x + | None -> mmlwidget#set_selection None +;; +*) + +(* Callbacks *) +let selection_changed mathview (element : Gdome.element option) = + let rec aux element = + if element#hasAttributeNS + ~namespaceURI:helmns + ~localName:(Gdome.domString "xref") + then + mathview#set_selection (Some element) + else + try + match element#get_parentNode with + None -> mathview#set_selection None + | Some p -> aux (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + prerr_endline "******* trying to select above the document root ********" + in + print_endline ("selection_changed: " ^ + (match element with + None -> "selection_changed on nothing" + | Some element -> element#get_tagName#to_string + ) + ) ; + match element with + None -> () + | Some el -> aux el; + flush stdout +;; + +let element_over mathview ((element : Gdome.element option), _, _, _) = + print_endline ("element_over: " ^ + (match element with + None -> "element_over on nothing" + | Some element -> element#get_tagName#to_string + ) + ) ; + flush stdout +;; + +let rec jump (element : Gdome.element) = + let module G = Gdome in + let attr = (element#getAttribute ~name:(G.domString "href"))#to_string in + if attr = "" then + match element#get_parentNode with + Some p -> + begin + try + jump (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + print_string "jump: NO HREF FOR THIS NODE\n" ; + flush stdout ; + false + end + | None -> assert false (* every element has a parent *) + else + begin + print_endline ("jump: " ^ attr) ; + flush stdout ; + true + end +;; + +let rec action mathview (element : Gdome.element) = + let module G = Gdome in + if element#get_tagName#to_string = "m:maction" then + let selection = + if element#hasAttribute ~name:(G.domString "selection") then + int_of_string (element#getAttribute ~name:(G.domString "selection"))#to_string + else + 1 + in + mathview#freeze ; + (* the widget will cast the index back into a reasonable range *) + element#setAttribute ~name:(G.domString "selection") ~value:(G.domString (string_of_int (selection + 1))) ; + mathview#thaw ; + true + else + match element#get_parentNode with + Some p -> + begin + try + action mathview (new Gdome.element_of_node p) + with + GdomeInit.DOMCastException _ -> + print_string "action: NO MACTION FOUND\n" ; + flush stdout ; + false + end + | None -> assert false (* every element has a parent *) + +let click mathview ((element : Gdome.element option), _, _, _) = + let module G = Gdome in + match element with + None -> print_string "CLICKED ON NOTHING\n" ; flush stdout + | Some element -> + if not (jump element) then + if not (mathview#action_toggle element) then + () +;; + +let load_uri mathview () = + mathview#load_uri ~filename:"test.xml" ; + print_string "load: SEEMS TO WORK\n" ; + flush stdout +;; + +let get_document mathview () = + (match mathview#get_document with + | None -> print_string "no document loaded\n" + | Some doc -> + let name = "out.xml" in + ignore ((Gdome.domImplementation ())#saveDocumentToFile ~doc ~name ()); + print_string ("document loaded and saved to " ^ name ^ "\n")); + flush stdout +;; + +let load_doc mathview () = + mathview#load_root ~root:(((Gdome.domImplementation ())#createDocumentFromURI ~uri:"test.xml" ())#get_documentElement) ; + print_string "load from DOM: SEEMS TO WORK\n" ; + flush stdout +;; + +let test_get_selection mathview () = + let selection = + match mathview#get_selection with + Some element -> element#get_tagName#to_string + | None -> "no selection! but there are " ^ (string_of_int (List.length mathview#get_selections)) ^ " multiple selections!" + in + print_string ("selection: " ^ selection ^ "\n") ; + flush stdout +;; + +let test_set_selection mathview () = + begin + match mathview#get_selection with + Some element -> + begin + match element#get_parentNode with + Some p -> + begin + try + mathview#set_selection (Some (new Gdome.element_of_node p)); + print_string "set selection: SEEMS TO WORK\n" + with + GdomeInit.DOMCastException _ -> + print_string "EXCEPTION: no parent\n" + end + | None -> assert false (* every element has a parent *) + end + | None -> + mathview#set_selection None; + print_string "no selection\n" + end ; + flush stdout +;; + +let test_add_selection (mathview : GMathViewAux.multi_selection_math_view) () = + match mathview#get_selection with + Some e -> mathview#add_selection e + | None -> + begin + print_string "no selection to add\n" ; + flush stdout + end +;; + +let test_reset_selections (mathview : GMathViewAux.multi_selection_math_view) () = + mathview#set_selection None ; + mathview#remove_selections + +let select_over (mathview : GMathViewAux.multi_selection_math_view) = + (fun (_,_,_,state) -> + let c = function + | `SHIFT -> "shift" + | `LOCK -> "lock" + | `CONTROL -> "control" + | `MOD1 -> "mod1" + | _ -> "" + in + let msg = + String.concat "," + (List.filter (fun s -> s <> "") + (List.map c (Gdk.Convert.modifier state))) + in + if msg <> "" then begin + print_endline ("modifiers: " ^ msg); + flush stdout + end) + +let unload mathview () = + mathview#unload ; + print_string "unload: SEEMS TO WORK\n" ; + flush stdout +;; + +let get_size mathview () = + let width, height = mathview#get_size in + print_string ("width: " ^ string_of_int width ^ ", height: " ^ string_of_int height ^ "\n") ; + flush stdout +;; + +let get_top mathview () = + let (x,y) = mathview#get_top in + print_string ("top: ("^ string_of_int x ^ "," ^ string_of_int y ^ ")\n") ; + flush stdout +;; + +let set_top mathview () = + mathview#set_top 0 0; + print_string "set_top: SEEM TO WORK\n" ; + flush stdout +;; + +let set_adjustments mathview () = + let adj1 = GData.adjustment () in + let adj2 = GData.adjustment () in + mathview#set_adjustments adj1 adj2 ; + adj1#set_value ((adj1#lower +. adj1#upper) /. 2.0) ; + adj2#set_value ((adj2#lower +. adj2#upper) /. 2.0) ; + print_string "set_adjustments: SEEM TO WORK\n" ; + flush stdout +;; + +let get_adjustments mathview () = + let hadj, vadj = mathview#get_adjustments in + hadj#set_value ((hadj#lower +. hadj#upper) /. 2.0) ; + vadj#set_value ((vadj#lower +. vadj#upper) /. 2.0) ; + print_string "hadjustment: SEEM TO WORK\n" ; + flush stdout +;; + +let get_buffer mathview () = + let buffer = mathview#get_buffer in + Gdk.Draw.rectangle buffer (Gdk.GC.create buffer) ~x:0 ~y:0 + ~width:50 ~height:50 ~filled:true () ; + print_string "buffer: SEEMS TO WORK (hint: force the widget redrawing)\n"; + flush stdout +;; + +let set_font_size mathview () = + mathview#set_font_size 24 ; + print_string "set_font_size: FONT IS NOW 24\n" ; + flush stdout +;; + +let get_font_size mathview () = + print_string ("font_size: " ^ string_of_int (mathview#get_font_size) ^ "\n") ; + flush stdout +;; + +let set_log_verbosity mathview () = + mathview#set_log_verbosity 3 ; + print_string "set_log_verbosity: NOW IS 3\n" ; + flush stdout +;; + +let get_log_verbosity mathview () = + print_string ("log_verbosity: " ^ + string_of_int mathview#get_log_verbosity ^ + "\n") ; + flush stdout +;; + +let x_coord = ref 0 +;; + +(* +let get_element_at mathview () = + begin + match mathview#get_element_at !x_coord 10 with + None -> print_string ("there is no element at " ^ (string_of_int !x_coord) ^ " 10\n") + | Some e -> print_string ("at " ^ (string_of_int !x_coord) ^ " 10 found element " ^ (e#get_nodeName#to_string) ^ "\n") + end ; + x_coord := !x_coord + 10 ; + flush stdout +;; +*) + +let _ = (GtkMain.Main.init ()) +;; + +(* Widget creation *) +let main_window = GWindow.window ~title:"GtkMathView test" () in +let vbox = GPack.vbox ~packing:main_window#add () in +let sw = GBin.scrolled_window ~width:50 ~height:50 ~packing:vbox#pack () in +let mathview= GMathViewAux.multi_selection_math_view ~packing:sw#add ~width:50 ~height:50 () in +let table = GPack.table ~rows:6 ~columns:5 ~packing:vbox#pack () in +let button_load = GButton.button ~label:"load" ~packing:(table#attach ~left:1 ~top:0) () in +let button_unload = GButton.button ~label:"unload" ~packing:(table#attach ~left:2 ~top:0) () in +let button_get_document = GButton.button ~label:"get_document" ~packing:(table#attach ~left:1 ~top:1) () in +let button_selection = GButton.button ~label:"get_selection" ~packing:(table#attach ~left:3 ~top:0) () in +let button_set_selection = GButton.button ~label:"set_selection" ~packing:(table#attach ~left:4 ~top:0) () in +let button_add_selection = GButton.button ~label:"add_selection" ~packing:(table#attach ~left:3 ~top:3) () in +let button_reset_selections = GButton.button ~label:"reset_selections" ~packing:(table#attach ~left:4 ~top:3) () in +let button_get_size = GButton.button ~label:"get_size" ~packing:(table#attach ~left:0 ~top:1) () in +let button_get_top = GButton.button ~label:"get_top" ~packing:(table#attach ~left:2 ~top:1) () in +let button_set_top = GButton.button ~label:"set_top" ~packing:(table#attach ~left:3 ~top:1) () in +let button_set_adjustments = GButton.button ~label:"set_adjustments" ~packing:(table#attach ~left:4 ~top:1) () in +let button_get_adjustments = GButton.button ~label:"get_adjustments" ~packing:(table#attach ~left:0 ~top:2) () in +let button_get_buffer = GButton.button ~label:"get_buffer" ~packing:(table#attach ~left:2 ~top:2) () in +let button_set_font_size = GButton.button ~label:"set_font_size" ~packing:(table#attach ~left:4 ~top:2) () in +let button_get_font_size = GButton.button ~label:"get_font_size" ~packing:(table#attach ~left:0 ~top:3) () in +let button_set_log_verbosity = GButton.button ~label:"set_log_verbosity" ~packing:(table#attach ~left:0 ~top:4) () in +let button_get_log_verbosity = GButton.button ~label:"get_log_verbosity" ~packing:(table#attach ~left:1 ~top:4) () in +let button_load_dom = GButton.button ~label:"load from DOM" ~packing:(table#attach ~left:2 ~top:5) () in +(* let button_get_element_at = GButton.button ~label:"get_element_at" ~packing:(table#attach ~left:3 ~top:5) () in *) +(* Signals connection *) +ignore(button_load#connect#clicked (load_uri mathview)) ; +ignore(button_unload#connect#clicked (unload mathview)) ; +ignore(button_get_document#connect#clicked (get_document mathview)) ; +ignore(button_selection#connect#clicked (test_get_selection mathview)) ; +ignore(button_set_selection#connect#clicked (test_set_selection mathview)) ; +ignore(button_add_selection#connect#clicked (test_add_selection mathview)) ; +ignore(button_reset_selections#connect#clicked (test_reset_selections mathview)) ; +ignore(button_get_size#connect#clicked (get_size mathview)) ; +ignore(button_get_top#connect#clicked (get_top mathview)) ; +ignore(button_set_top#connect#clicked (set_top mathview)) ; +ignore(button_set_adjustments#connect#clicked (set_adjustments mathview)) ; +ignore(button_get_adjustments#connect#clicked (get_adjustments mathview)) ; +ignore(button_get_buffer#connect#clicked (get_buffer mathview)) ; +ignore(button_set_font_size#connect#clicked (set_font_size mathview)) ; +ignore(button_get_font_size#connect#clicked (get_font_size mathview)) ; +ignore(button_set_log_verbosity#connect#clicked (set_log_verbosity mathview)) ; +ignore(button_get_log_verbosity#connect#clicked (get_log_verbosity mathview)) ; +ignore(mathview#connect#click (click mathview)) ; +ignore(mathview#connect#selection_changed (selection_changed mathview)); +ignore(mathview#connect#element_over (element_over mathview)) ; +ignore(mathview#connect#select_over (select_over mathview)); +ignore(button_load_dom#connect#clicked (load_doc mathview)) ; +ignore(main_window#connect#destroy (fun _ -> GMain.quit ())); +(* ignore(button_get_element_at#connect#clicked (get_element_at mathview)) ; *) +(* Main Loop *) +main_window#show () ; +GMain.Main.main () +;; diff --git a/DEVEL/lablgtkmathview/test/test.xml b/DEVEL/lablgtkmathview/test/test.xml new file mode 100644 index 000000000..9f3d906a7 --- /dev/null +++ b/DEVEL/lablgtkmathview/test/test.xml @@ -0,0 +1,134 @@ + + + + + +]> + + + + + + + + It's a secret! + + + a + + x + + + + b + + + + + x + 2 + + + + + p + + x + + + + q + + + + d + x + = + + + a2 + + + ln + + + ( + + x2 + + + + p + + x + + + + q + + ) + + + + + + + + + + 2 + + b + + - + + a + + p + + + + + + 4 + + q + + - + + p + 2 + + + + + + + arctg + + + + + 2 + + x + + + + p + + + + + 4 + + q + + - + + p + 2 + + + + + + + + + c + + diff --git a/DEVEL/lablgtksourceview/.cvsignore b/DEVEL/lablgtksourceview/.cvsignore new file mode 100644 index 000000000..db7a2f88d --- /dev/null +++ b/DEVEL/lablgtksourceview/.cvsignore @@ -0,0 +1,10 @@ +*.cmi *.cmo *.cmx *.cma *.cmxa *.annot *.a *.o +aclocal.m4 +autom4te.cache +configure +config.status +config.log +Makefile +META +gtkSourceViewProps.ml +ogtkSourceViewProps.ml diff --git a/DEVEL/lablgtksourceview/.depend b/DEVEL/lablgtksourceview/.depend new file mode 100644 index 000000000..0a2ae9c53 --- /dev/null +++ b/DEVEL/lablgtksourceview/.depend @@ -0,0 +1,11 @@ +gSourceView.cmo: ogtkSourceViewProps.cmo gtk_sourceview.cmo gtkSourceView.cmo \ + gSourceView.cmi +gSourceView.cmx: ogtkSourceViewProps.cmx gtk_sourceview.cmx gtkSourceView.cmx \ + gSourceView.cmi +gtkSourceView.cmo: gtk_sourceview.cmo gtkSourceViewProps.cmo +gtkSourceView.cmx: gtk_sourceview.cmx gtkSourceViewProps.cmx +gtkSourceViewProps.cmo: gtk_sourceview.cmo +gtkSourceViewProps.cmx: gtk_sourceview.cmx +ogtkSourceViewProps.cmo: gtkSourceViewProps.cmo +ogtkSourceViewProps.cmx: gtkSourceViewProps.cmx +gSourceView.cmi: gtk_sourceview.cmo diff --git a/DEVEL/lablgtksourceview/ACKNOWLEDGEMENTS b/DEVEL/lablgtksourceview/ACKNOWLEDGEMENTS new file mode 100644 index 000000000..e97d934ad --- /dev/null +++ b/DEVEL/lablgtksourceview/ACKNOWLEDGEMENTS @@ -0,0 +1,3 @@ +Acknowledgments: +* Claudio Sacerdoti Coen, for introducing me to the insane world of binding GTK + widgets to OCaml diff --git a/DEVEL/lablgtksourceview/AUTHORS b/DEVEL/lablgtksourceview/AUTHORS new file mode 100644 index 000000000..4a3e9cc73 --- /dev/null +++ b/DEVEL/lablgtksourceview/AUTHORS @@ -0,0 +1 @@ +Stefano Zacchiroli diff --git a/DEVEL/lablgtksourceview/CHANGES b/DEVEL/lablgtksourceview/CHANGES new file mode 100644 index 000000000..aa9734692 --- /dev/null +++ b/DEVEL/lablgtksourceview/CHANGES @@ -0,0 +1,4 @@ + +July 8, 2005 + First public release (0.0.1) of LablGtkSourceView. + diff --git a/DEVEL/lablgtksourceview/COPYING b/DEVEL/lablgtksourceview/COPYING new file mode 100644 index 000000000..b124cf581 --- /dev/null +++ b/DEVEL/lablgtksourceview/COPYING @@ -0,0 +1,510 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes a de-facto standard. To achieve this, non-free programs must +be allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms +of the ordinary General Public License). + + To apply these terms, attach the following notices to the library. +It is safest to attach them to the start of each source file to most +effectively convey the exclusion of warranty; and each file should +have at least the "copyright" line and a pointer to where the full +notice is found. + + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the library, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James + Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/DEVEL/lablgtksourceview/Changelog b/DEVEL/lablgtksourceview/Changelog new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/lablgtksourceview/LICENSE b/DEVEL/lablgtksourceview/LICENSE new file mode 100644 index 000000000..cbe921b34 --- /dev/null +++ b/DEVEL/lablgtksourceview/LICENSE @@ -0,0 +1,20 @@ + +lablgtksourceview, OCaml binding for the GtkSourceView text widget + +Copyright (C) 2005 Stefano Zacchiroli + +This library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA + diff --git a/DEVEL/lablgtksourceview/META.in b/DEVEL/lablgtksourceview/META.in new file mode 100644 index 000000000..95128b906 --- /dev/null +++ b/DEVEL/lablgtksourceview/META.in @@ -0,0 +1,5 @@ +requires="lablgtk2" +version="@VERSION@" +archive(byte)="@PACKAGE@.cma" +archive(native)="@PACKAGE@.cmxa" +linkopts="" diff --git a/DEVEL/lablgtksourceview/Makefile.in b/DEVEL/lablgtksourceview/Makefile.in new file mode 100644 index 000000000..19dc0d19d --- /dev/null +++ b/DEVEL/lablgtksourceview/Makefile.in @@ -0,0 +1,145 @@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +INCLUDEDIR = @OCAML_INCLUDE_DIR@ +PROPCC = @OCAML_LIB_DIR@/lablgtk2/propcc +DESTDIR = +NULL = +C_OBJECTS = ml_gtk_sourceview.o +ML_OBJECTS = \ + gtkSourceViewProps.cmo \ + ogtkSourceViewProps.cmo \ + gtk_sourceview.cmo \ + gtkSourceView.cmo \ + gSourceView.cmo \ + $(NULL) +ML_OBJECTS_OPT = $(patsubst %.cmo,%.cmx,$(ML_OBJECTS)) +GENERATED_FILES = gtkSourceViewProps.ml ogtkSourceViewProps.ml +EXTRA_INST = \ + META \ + gSourceView.mli \ + gSourceView.cmi \ + gtkSourceView.cmi \ + gtk_sourceview.cmi \ + $(NULL) +DIST_FILES = \ + Makefile.in \ + configure \ + gSourceView.ml \ + gSourceView.mli \ + gtkSourceView.ml \ + gtk_sourceview.ml \ + ml_gtk_sourceview.c \ + META.in \ + .depend \ + debian/ \ + test/ \ + gtkSourceView.props \ + $(NULL) +DIST_DIR = $(PACKAGE)-$(VERSION) +EXTRA_DIST = ACKNOWLEDGEMENTS AUTHORS CHANGES COPYING LICENSE NEWS README +REQUIRES = lablgtk2 +SHARED_LIBS = @GTKSOURCEVIEW_LIBS@ +OCAMLFIND = ocamlfind +OCAMLC = $(OCAMLFIND) ocamlc -package "$(REQUIRES)" +OCAMLOPT = $(OCAMLFIND) ocamlopt -package "$(REQUIRES)" +OCAMLDEP = ocamldep +OCAMLMKLIB = ocamlmklib +OCAML_STUB_DIR = @OCAML_STUB_DIR@ +ARCHIVE = $(PACKAGE) +DLL = dll$(ARCHIVE).so +NATIVE = @HAVE_OCAMLOPT@ +TESTDIR = test +BYTE_INST = $(ARCHIVE).cma lib$(ARCHIVE).a $(C_OBJECTS) $(DLL) +OPT_INST = $(BYTE_INST) $(ARCHIVE).cmxa $(ARCHIVE).a + +ifeq ($(NATIVE),yes) +world: all opt +else +world: all +endif + +all: $(ARCHIVE).cma lib$(ARCHIVE).a $(DLL) $(TESTDIR)/test +opt: $(ARCHIVE).cmxa $(ARCHIVE).a $(TESTDIR)/test.opt + +test/test.opt: + $(MAKE) -C $(TESTDIR) test.opt +test/test: + $(MAKE) -C $(TESTDIR) test + +dist: distclean + rm -rf $(DIST_DIR)/ + mkdir -p $(DIST_DIR)/ + cp -a $(DIST_FILES) $(EXTRA_DIST) $(DIST_DIR)/ + -find $(DIST_DIR) -name CVS -type d -exec rm -rf {} \; + -find $(DIST_DIR) -name .cvsignore -type f -exec rm {} \; + tar cvfz $(DIST_DIR).tar.gz $(DIST_DIR)/ + rm -rf $(DIST_DIR)/ + +deb: dist + rm -rf $(DIST_DIR) + tar xvzf $(DIST_DIR).tar.gz + (cd $(DIST_DIR)/ && debuild) + rm -rf $(DIST_DIR) + +ml_gtk_sourceview.o: ml_gtk_sourceview.c + gcc -c -I$(INCLUDEDIR) -fPIC `$(OCAMLFIND) query -i-format lablgtk2` @GTKSOURCEVIEW_CFLAGS@ $< + +%.cmo: %.ml + $(OCAMLC) -c $< +%.cmi: %.mli + $(OCAMLC) -c $< +%.cmx: %.ml + $(OCAMLOPT) -c $< + +$(GENERATED_FILES): gtkSourceView.props +%Props.ml o%Props.ml: %.props + $(PROPCC) $< + +depend: *.ml *.mli $(GENERATED_FILES) + $(OCAMLDEP) *.ml *.mli >.depend +include .depend + +$(ARCHIVE).cma: $(ML_OBJECTS) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +$(ARCHIVE).cmxa: $(ML_OBJECTS_OPT) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) +lib$(ARCHIVE).a $(DLL): $(C_OBJECTS) + $(OCAMLMKLIB) -o $(ARCHIVE) $^ $(SHARED_LIBS) + +ifeq ($(DESTDIR),"") +INSTALLER = $(OCAMLFIND) install -ldconf /dev/null +UNINSTALLER = $(OCAMLFIND) remove -ldconf /dev/null +else +INSTALLER = $(OCAMLFIND) install -destdir $(DESTDIR) -ldconf /dev/null +UNINSTALLER = $(OCAMLFIND) remove -destdir $(DESTDIR) -ldconf /dev/null +install: world installmkdir +endif + +ifeq ($(NATIVE),yes) +install: installworld +else +install: installbyte +endif + +installbyte: + $(INSTALLER) $(PACKAGE) $(BYTE_INST) $(EXTRA_INST) +installworld: + $(INSTALLER) $(PACKAGE) $(OPT_INST) $(EXTRA_INST) + +installmkdir: + mkdir -p $(DESTDIR) + +uninstall: + $(UNINSTALLER) $(PACKAGE) + +clean: + rm -f *.[ao] *.cm[iaxo] *.cmxa *.so $(GENERATED_FILES) + make -C $(TESTDIR) clean + +distclean: clean + rm -f config.log config.cache config.status Makefile META + make -C $(TESTDIR) distclean + +.PHONY: world uninstall clean distclean test/test test/test.opt +.PHONY: install installmkdir installbyte installworld + diff --git a/DEVEL/lablgtksourceview/NEWS b/DEVEL/lablgtksourceview/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/lablgtksourceview/README b/DEVEL/lablgtksourceview/README new file mode 100644 index 000000000..71d6a5d88 --- /dev/null +++ b/DEVEL/lablgtksourceview/README @@ -0,0 +1,42 @@ + +LablGtkSourceView: OCaml bindings for GtkSourceView +--------------------------------------------------- + +LablGtkSourceView are the OCaml bindings for GtkSourceView, a GTK widget +which extends the standrd GTK text widgets implementing syntax +highlighting, automatic indentation, and other typical features of +source editors. + +Using LablGtkSourceView you can instantiate and use GtkSourceView +widgets in OCaml programs which use GTK through the LablGtk interface. + +LablGtkSourceView is freely distributed under the term of the GNU LGPL +(Lesser General Public License), see LICENSE and COPYING files for more +info. + +Requirements +------------ + +In order to build LablGtkSourceView from sources you need: + +* OCaml (http://caml.inria.fr/) +* Findlib (http://www.ocaml-programming.de/packages/) +* LablGTK (http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgtk.html) +* GtkSourceView (http://gtksourceview.sourceforge.net/) + +Once you have installed all of them, follow the usual procedure: + + ./configure + make world + make install + +Availability of ocamlopt is detected by ./configure, if you manually +want to choose what to build: + + make all # for building the bytecode part of the library + make opt # for the native code part + +-- +Stefano Zacchiroli +Sun, 31 Jul 2005 23:50:34 +0200 + diff --git a/DEVEL/lablgtksourceview/configure.ac b/DEVEL/lablgtksourceview/configure.ac new file mode 100644 index 000000000..bac74370d --- /dev/null +++ b/DEVEL/lablgtksourceview/configure.ac @@ -0,0 +1,53 @@ +AC_INIT(gSourceView.ml) + +PACKAGE="lablgtksourceview" + +MAJOR_VERSION="0" +MINOR_VERSION="0" +MICRO_VERSION="1" +VERSION="$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION" + +PKG_CHECK_MODULES([GTKSOURCEVIEW], [gtksourceview-1.0 >= 1.2.0]) + +AC_CHECK_PROG(HAVE_OCAMLFIND, ocamlfind, yes, no) +if test $HAVE_OCAMLFIND = "no"; then + AC_MSG_ERROR(could not find ocamlfind) +fi +FINDLIB_REQUIRES="lablgtk2" +for r in $FINDLIB_REQUIRES +do + AC_MSG_CHECKING(for $r ocaml library) + if ocamlfind query $r &> /dev/null; then + AC_MSG_RESULT(yes) + else + AC_MSG_ERROR(could not find $r ocaml library) + fi +done + +AC_MSG_CHECKING(for the ocaml library dir) +OCAML_LIB_DIR=`ocamlfind ocamlc -where` +AC_MSG_RESULT($OCAML_LIB_DIR) +OCAML_STUB_DIR="$OCAML_LIB_DIR/stublibs" + +AC_CHECK_FILE(/usr/include/caml/mlvalues.h, + OCAML_INCLUDE_DIR=/usr/include/caml, + AC_MSG_ERROR(could not find ocaml header files) +) + +AC_CHECK_PROG(HAVE_OCAMLOPT, ocamlopt, yes, no) + +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) +AC_SUBST(GTKSOURCEVIEW_CFLAGS) +AC_SUBST(GTKSOURCEVIEW_LIBS) +AC_SUBST(OCAML_LIB_DIR) +AC_SUBST(OCAML_STUB_DIR) +AC_SUBST(OCAML_INCLUDE_DIR) +AC_SUBST(HAVE_OCAMLOPT) + +AC_OUTPUT([ + test/Makefile + Makefile + META +]) + diff --git a/DEVEL/lablgtksourceview/debian/changelog b/DEVEL/lablgtksourceview/debian/changelog new file mode 100644 index 000000000..60dc444de --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/changelog @@ -0,0 +1,20 @@ +lablgtksourceview (0.0.1-3) unstable; urgency=low + + * Rebuilt against OCaml 3.09.1, bumped deps accordingly. + + -- Stefano Zacchiroli Sun, 8 Jan 2006 01:30:23 +0100 + +lablgtksourceview (0.0.1-2) unstable; urgency=low + + * rebuilt with ocaml 3.09 + * debian/* + - no longer hard coding of ocaml abi version anywhere + + -- Stefano Zacchiroli Wed, 23 Nov 2005 10:23:24 +0000 + +lablgtksourceview (0.0.1-1) unstable; urgency=low + + * Initial release (closes: bug#320716). + + -- Stefano Zacchiroli Mon, 1 Aug 2005 17:57:57 +0200 + diff --git a/DEVEL/lablgtksourceview/debian/compat b/DEVEL/lablgtksourceview/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/compat @@ -0,0 +1 @@ +4 diff --git a/DEVEL/lablgtksourceview/debian/control b/DEVEL/lablgtksourceview/debian/control new file mode 100644 index 000000000..dd06052bb --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/control @@ -0,0 +1,29 @@ +Source: lablgtksourceview +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>= 4.1.0), cdbs, ocaml-findlib, ocaml-nox (>= 3.09.1), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgtksourceview-dev (>= 1.2.0) +Standards-Version: 3.6.2 + +Package: liblablgtksourceview-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, ocaml-findlib, liblablgtksourceview-ocaml (= ${Source-Version}), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgtksourceview-dev (>= 1.2.0), ${misc:Depends} +Description: OCaml bindings for libgtksourceview, a source editor GTK widget + This is the OCaml binding for the GtkSourceView widget, a text widget that + extends the standard gtk+ 2.x text widget with syntax highlighting and other + features typical of a source editor. + . + This package contains the development part of the lablgtksourceview package. + +Package: liblablgtksourceview-ocaml +Architecture: any +Section: libs +Depends: ocaml-base-nox-${F:OCamlABI}, liblablgtk2-ocaml (>= 2.6.0-2), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for libgtksourceview, a source editor GTK widget + This is the OCaml binding for the GtkSourceView widget, a text widget that + extends the standard gtk+ 2.x text widget with syntax highlighting and other + features typical of a source editor. + . + This package contains the shared runtime stub libraries. + diff --git a/DEVEL/lablgtksourceview/debian/control.in b/DEVEL/lablgtksourceview/debian/control.in new file mode 100644 index 000000000..e87aaa957 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/control.in @@ -0,0 +1,29 @@ +Source: lablgtksourceview +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>= 4.1.0), cdbs, ocaml-findlib, ocaml-nox (>= @OCamlABI@), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgtksourceview-dev (>= 1.2.0) +Standards-Version: 3.6.2 + +Package: liblablgtksourceview-ocaml-dev +Architecture: any +Section: libdevel +Depends: ocaml-nox-${F:OCamlABI}, ocaml-findlib, liblablgtksourceview-ocaml (= ${Source-Version}), liblablgtk2-ocaml-dev (>= 2.6.0-2), libgtksourceview-dev (>= 1.2.0), ${misc:Depends} +Description: OCaml bindings for libgtksourceview, a source editor GTK widget + This is the OCaml binding for the GtkSourceView widget, a text widget that + extends the standard gtk+ 2.x text widget with syntax highlighting and other + features typical of a source editor. + . + This package contains the development part of the lablgtksourceview package. + +Package: liblablgtksourceview-ocaml +Architecture: any +Section: libs +Depends: ocaml-base-nox-${F:OCamlABI}, liblablgtk2-ocaml (>= 2.6.0-2), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings for libgtksourceview, a source editor GTK widget + This is the OCaml binding for the GtkSourceView widget, a text widget that + extends the standard gtk+ 2.x text widget with syntax highlighting and other + features typical of a source editor. + . + This package contains the shared runtime stub libraries. + diff --git a/DEVEL/lablgtksourceview/debian/copyright b/DEVEL/lablgtksourceview/debian/copyright new file mode 100644 index 000000000..694e73b30 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/copyright @@ -0,0 +1,18 @@ +This package was debianized by Stefano Zacchiroli on +Sat, 11 Jun 2005 12:19:09 +0200. + +It was downloaded from: + http://helm.cs.unibo.it/software/lablgtksourceview/ + +Author: + Stefano Zacchiroli + +Copyright: + + lablgtksourceview is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or (at your + option) any later version. + + On Debian systems a copy of the GNU Lesser General Public License verion 2.1 + can be found in /usr/share/common-licenses/LGPL-2.1 diff --git a/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.docs b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.docs new file mode 100644 index 000000000..e8d3b252a --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.docs @@ -0,0 +1,3 @@ +ACKNOWLEDGEMENTS +AUTHORS +README diff --git a/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install new file mode 100644 index 000000000..b4f781202 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install @@ -0,0 +1,7 @@ +debian/tmp/lablgtksourceview/*.a usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cma usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cmi usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cmxa usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/META usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.mli usr/lib/ocaml/3.09.1/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.o usr/lib/ocaml/3.09.1/lablgtksourceview/ diff --git a/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install.in b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install.in new file mode 100644 index 000000000..6ed27ecb0 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml-dev.install.in @@ -0,0 +1,7 @@ +debian/tmp/lablgtksourceview/*.a usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cma usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cmi usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.cmxa usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/META usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.mli usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ +debian/tmp/lablgtksourceview/*.o usr/lib/ocaml/@OCamlABI@/lablgtksourceview/ diff --git a/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install new file mode 100644 index 000000000..335703867 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install @@ -0,0 +1 @@ +debian/tmp/lablgtksourceview/*.so usr/lib/ocaml/3.09.1/stublibs/ diff --git a/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install.in b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install.in new file mode 100644 index 000000000..d140fb6c5 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/liblablgtksourceview-ocaml.install.in @@ -0,0 +1 @@ +debian/tmp/lablgtksourceview/*.so usr/lib/ocaml/@OCamlABI@/stublibs/ diff --git a/DEVEL/lablgtksourceview/debian/rules b/DEVEL/lablgtksourceview/debian/rules new file mode 100755 index 000000000..52a3e2ea3 --- /dev/null +++ b/DEVEL/lablgtksourceview/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/autotools.mk + +OCAMLABI := $(shell ocamlc -version) +OFILES := $(patsubst %.in,%,$(shell ls debian/*.in)) +DEB_DH_GENCONTROL_ARGS = -- -VF:OCamlABI="$(OCAMLABI)" + +ocamlinit: + for f in $(OFILES); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done diff --git a/DEVEL/lablgtksourceview/gSourceView.ml b/DEVEL/lablgtksourceview/gSourceView.ml new file mode 100644 index 000000000..251f76c59 --- /dev/null +++ b/DEVEL/lablgtksourceview/gSourceView.ml @@ -0,0 +1,219 @@ +(* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + *) + +open Gaux +open Gtk_sourceview +open Gobject +open Gtk +open GtkBase +open GtkSourceView +open OgtkSourceViewProps +open GObj + +let get_bool = function `BOOL x -> x | _ -> assert false +let bool x = `BOOL x +let get_uint = function `INT x -> x | _ -> assert false +let uint x = `INT x +let get_int = function `INT x -> x | _ -> assert false +let int x = `INT x +let get_gobject = function `OBJECT x -> x | _ -> assert false +let gobject x = `OBJECT (Some x) + +(** {2 GtkSourceLanguage} *) + +class source_language_signals obj' = +object (self) + inherit ['a] gobject_signals (obj' : [> Gtk_sourceview.source_language] obj) + inherit source_language_sigs +end + +class source_language (obj: Gtk_sourceview.source_language obj) = +object (self) + method as_source_language = obj + method connect = new source_language_signals obj + method misc = new gobject_ops obj + method get_name = SourceLanguage.get_name obj + method get_section = SourceLanguage.get_section obj + method get_escape_char = SourceLanguage.get_escape_char obj +end + +(** {2 GtkSourceLanguagesManager} *) + +class source_languages_manager + (obj: Gtk_sourceview.source_languages_manager obj) = +object (self) + method get_oid = Gobject.get_oid obj + method as_source_languages_manager = obj + method get_language_from_mime_type s = + match SourceLanguagesManager.get_language_from_mime_type obj s with + | None -> None + | Some obj -> Some (new source_language obj) + method lang_files_dirs = SourceLanguagesManager.get_lang_files_dirs obj +end + +(* let source_languages_manager ?lang_files_dirs () = + let properties = + match lang_files_dirs with + | None -> [] + | Some dirs -> + let list_obj = gslist_of_string_list dirs in + [Gobject.param + "lang-files-dirs" + (`OBJECT (Some list_obj))] + in + new source_languages_manager (SourceLanguagesManager.create properties) *) + +let source_languages_manager () = + new source_languages_manager (SourceLanguagesManager.create []) + +let source_language_from_file ?languages_manager fname = + let languages_manager = + match languages_manager with + | None -> source_languages_manager () + | Some lm -> lm + in + let manager_obj = languages_manager#as_source_languages_manager in + match SourceLanguage.new_from_file fname manager_obj with + | None -> None + | Some lang_obj -> Some (new source_language lang_obj) + +(** {2 GtkSourceBuffer} *) + +class source_buffer_signals obj' = +object + inherit ['a] gobject_signals (obj' : [> Gtk_sourceview.source_buffer] obj) + inherit GText.buffer_signals obj' + inherit source_buffer_sigs +end + +class source_buffer (obj: Gtk_sourceview.source_buffer obj) = +object (self) + inherit GText.buffer_skel obj + method connect = new source_buffer_signals obj + method misc = new gobject_ops obj + method check_brackets = get_bool (self#misc#get_property "check-brackets") + method set_check_brackets x = self#misc#set_property "check-brackets" (bool x) + method highlight = get_bool (self#misc#get_property "highlight") + method set_highlight x = self#misc#set_property "highlight" (bool x) + method max_undo_levels = get_int (self#misc#get_property "max-undo-levels") + method set_max_undo_levels x = + self#misc#set_property "max-undo-levels" (int x) + method language = + match get_gobject (self#misc#get_property "language") with + | None -> None + | Some obj -> + Some (new source_language (Gobject.try_cast obj "GtkSourceLanguage")) + method set_language (x: source_language) = + self#misc#set_property "language" (gobject x#as_source_language) + method escape_char = get_uint (self#misc#get_property "escape-char") + method set_escape_char x = self#misc#set_property "escape-char" (uint x) + method can_undo = SourceBuffer.can_undo obj + method can_redo = SourceBuffer.can_redo obj + method undo () = SourceBuffer.undo obj + method redo () = SourceBuffer.redo obj + method begin_not_undoable_action () = + SourceBuffer.begin_not_undoable_action obj + method end_not_undoable_action () = + SourceBuffer.end_not_undoable_action obj +end + +let source_buffer ?language ?text (* ?tag_table *) = + let language = + match language with + | None -> None + | Some source_language -> Some (source_language#as_source_language) + in + SourceBuffer.make_params [] ?language ~cont:(fun pl () -> + let buf = new source_buffer (SourceBuffer.create pl) in + (match text with + | None -> () + | Some text -> buf#set_text text); + buf) + + (* alias used below, needed because "source_buffer" is a name in scope *) +let source_buffer' = source_buffer + +(** {2 GtkSourceView} *) + +class source_view_signals obj' = +object + inherit widget_signals_impl (obj' : [> Gtk_sourceview.source_view] obj) + inherit GText.view_signals obj' + inherit source_view_sigs +end + +class source_view (obj': Gtk_sourceview.source_view obj) = +object (self) + inherit GText.view_skel obj' + val source_buf = + let buf_obj = + Gobject.try_cast (GtkText.View.get_buffer obj') "GtkSourceBuffer" + in + new source_buffer buf_obj + method source_buffer = source_buf + method connect = new source_view_signals obj' + method set_show_line_numbers x = + self#misc#set_property "show_line_numbers" (bool x) + method show_line_numbers = + get_bool (self#misc#get_property "show_line_numbers") + method set_show_line_markers x = + self#misc#set_property "show_line_markers" (bool x) + method show_line_markers = + get_bool (self#misc#get_property "show_line_markers") + method set_tabs_width x = self#misc#set_property "tabs_width" (uint x) + method tabs_width = get_uint (self#misc#get_property "tabs_width") + method set_auto_indent x = self#misc#set_property "auto_indent" (bool x) + method auto_indent = get_bool (self#misc#get_property "auto_indent") + method set_insert_spaces_instead_of_tabs x = + self#misc#set_property "insert_spaces_instead_of_tabs" (bool x) + method insert_spaces_instead_of_tabs = + get_bool (self#misc#get_property "insert_spaces_instead_of_tabs") + method set_show_margin x = self#misc#set_property "show_margin" (bool x) + method show_margin = get_bool (self#misc#get_property "show_margin") + method set_margin x = self#misc#set_property "margin" (uint x) + method margin = get_uint (self#misc#get_property "margin") + method set_smart_home_end x = self#misc#set_property "smart_home_end" (bool x) + method smart_home_end = get_bool (self#misc#get_property "smart_home_end") +end + +let source_view ?source_buffer = + SourceView.make_params [] ~cont:( + GtkText.View.make_params ~cont:( + GContainer.pack_container ~create:(fun pl -> + let obj = + match source_buffer with + | Some buf -> + SourceView.new_with_buffer + (Gobject.try_cast buf#as_buffer "GtkSourceBuffer") + | None -> SourceView.new_ () + in + Gobject.set_params (Gobject.try_cast obj "GtkSourceView") pl; + new source_view obj))) + +(** {2 Misc} *) + +let find_matching_bracket iter = + let iter = iter#copy in + if SourceViewMisc.find_matching_bracket iter#as_iter then + Some iter + else + None + diff --git a/DEVEL/lablgtksourceview/gSourceView.mli b/DEVEL/lablgtksourceview/gSourceView.mli new file mode 100644 index 000000000..746ddd77c --- /dev/null +++ b/DEVEL/lablgtksourceview/gSourceView.mli @@ -0,0 +1,187 @@ +(* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + *) + +open Gtk + +(** {2 GtkSourceLanguage} *) + +class source_language_signals: + ([> Gtk_sourceview.source_language ] as 'b) obj -> + object ('a) + inherit ['b] GObj.gobject_signals + method tag_style_changed: callback:(string -> unit) -> GtkSignal.id + end + +class source_language: + Gtk_sourceview.source_language obj -> + object + method as_source_language: Gtk_sourceview.source_language obj + method connect: source_language_signals + method get_escape_char: Glib.unichar + method get_name: string + method get_section: string + method misc: GObj.gobject_ops + end + +(** {2 GtkSourceLanguagesManager} *) + +class source_languages_manager: + Gtk_sourceview.source_languages_manager obj -> + object + method get_oid: int + method as_source_languages_manager: + Gtk_sourceview.source_languages_manager obj + method get_language_from_mime_type: string -> source_language option + method lang_files_dirs: string list + end + +val source_languages_manager: +(* ?lang_files_dirs:string list -> *) + unit -> + source_languages_manager + +val source_language_from_file: + ?languages_manager:source_languages_manager -> string -> + source_language option + +(** {2 GtkSourceBuffer} *) + +class source_buffer_signals: + ([> Gtk_sourceview.source_buffer ] as 'b) obj -> + object ('a) + inherit GText.buffer_signals + method can_redo: callback:(bool -> unit) -> GtkSignal.id + method can_undo: callback:(bool -> unit) -> GtkSignal.id + method highlight_updated: + callback:(Gtk.text_iter -> Gtk.text_iter -> unit) -> GtkSignal.id + method marker_updated: callback:(Gtk.text_iter -> unit) -> GtkSignal.id + end + +class source_buffer: + Gtk_sourceview.source_buffer obj -> + object + inherit GText.buffer_skel + method connect: source_buffer_signals + method misc: GObj.gobject_ops + method check_brackets: bool + method set_check_brackets: bool -> unit +(* method set_bracket_match_style: tag_style -> unit *) + method highlight: bool + method set_highlight: bool -> unit + method max_undo_levels: int + method set_max_undo_levels: int -> unit + method language: source_language option + method set_language: source_language -> unit + method escape_char: Glib.unichar + method set_escape_char: Glib.unichar -> unit + method can_undo: bool + method can_redo: bool + method undo: unit -> unit + method redo: unit -> unit + method begin_not_undoable_action: unit -> unit + method end_not_undoable_action: unit -> unit +(* method create_marker: name:char -> typ:char -> source_marker *) +(* method move_marker: source_marker -> Gtext.text_iter -> unit *) +(* method delete_marker: source_marker -> unit *) +(* method get_marker: name:char -> source_marker *) +(* method get_markers_in_region: + start:text_iter -> stop:text_iter -> source_marker list *) +(* method get_first_marker: unit -> source_marker *) +(* method get_last_marker: unit -> source_marker *) +(* method get_iter_at_marker: ... *) +(* method get_next_marker: unit -> source_marker *) +(* method get_prev_marker: unit -> source_marker *) + end + +val source_buffer: + ?language:source_language -> +(* ?tag_table:source_tag_table -> *) + ?text:string -> + ?check_brackets:bool -> + ?escape_char:int -> + ?highlight:bool -> + ?max_undo_levels:int -> + unit -> + source_buffer + +(** {2 GtkSourceView} *) + +class source_view_signals: + ([> Gtk_sourceview.source_view ] as 'b) obj -> + object ('a) + inherit GText.view_signals + method redo: callback:(unit -> unit) -> GtkSignal.id + method undo: callback:(unit -> unit) -> GtkSignal.id + end + +class source_view: + Gtk_sourceview.source_view obj -> + object + inherit GText.view_skel + val obj: Gtk_sourceview.source_view obj + method connect: source_view_signals + method source_buffer: source_buffer + method set_show_line_numbers: bool -> unit + method show_line_numbers: bool + method set_show_line_markers: bool -> unit + method show_line_markers: bool + method set_tabs_width: int -> unit + method tabs_width: int + method set_auto_indent: bool -> unit + method auto_indent: bool + method set_insert_spaces_instead_of_tabs: bool -> unit + method insert_spaces_instead_of_tabs: bool + method set_show_margin: bool -> unit + method show_margin: bool + method set_margin: int -> unit + method margin: int +(* method set_marker_pixbuf: GdkPixbuf.pixbuf -> unit *) +(* method marker_pixbuf: GdkPixbuf.pixbuf *) + method set_smart_home_end: bool -> unit + method smart_home_end: bool + end + +val source_view: + ?source_buffer:source_buffer -> + ?auto_indent:bool -> + ?insert_spaces_instead_of_tabs:bool -> + ?margin:int -> + ?show_line_markers:bool -> + ?show_line_numbers:bool -> + ?show_margin:bool -> + ?smart_home_end:bool -> + ?tabs_width:int -> + ?editable:bool -> + ?cursor_visible:bool -> + ?justification:GtkEnums.justification -> + ?wrap_mode:GtkEnums.wrap_mode -> + ?border_width:int -> + ?width:int -> + ?height:int -> + ?packing:(GObj.widget -> unit) -> + ?show:bool -> + unit -> + source_view + +(** {2 Misc} *) + +val find_matching_bracket: GText.iter -> GText.iter option + diff --git a/DEVEL/lablgtksourceview/gtkSourceView.ml b/DEVEL/lablgtksourceview/gtkSourceView.ml new file mode 100644 index 000000000..d9a16a58d --- /dev/null +++ b/DEVEL/lablgtksourceview/gtkSourceView.ml @@ -0,0 +1,118 @@ +(* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + *) + +open Gtk_sourceview +open Gaux +open Gobject +open Gtk +open Tags +open GtkSourceViewProps +open GtkBase + +(* external gslist_of_string_list: string list -> 'a obj = + "ml_gslist_of_string_list" *) + +external _gtk_source_language_init: unit -> unit = "ml_gtk_source_language_init" +external _gtk_source_languages_manager_init: unit -> unit = + "ml_gtk_source_languages_manager_init" +external _gtk_source_buffer_init: unit -> unit = "ml_gtk_source_buffer_init" +external _gtk_source_view_init: unit -> unit = "ml_gtk_source_view_init" + +let () = + _gtk_source_language_init (); + _gtk_source_languages_manager_init (); + _gtk_source_buffer_init (); + _gtk_source_view_init () + +module SourceLanguage = +struct + include SourceLanguage + external new_from_file: + string -> [>`sourcelanguagesmanager] obj -> source_language obj option + = + "ml__gtk_source_language_new_from_file" + external get_name: [>`sourcelanguage] obj -> string = + "ml_gtk_source_language_get_name" + external get_section: [>`sourcelanguage] obj -> string = + "ml_gtk_source_language_get_section" +(* external get_tags: [>`sourcelanguage] obj -> source_tag list *) + external get_escape_char: [>`sourcelanguage] obj -> Glib.unichar = + "ml_gtk_source_language_get_escape_char" +(* external get_mime_types: [>`sourcelanguage] obj -> string list *) +(* external set_mime_types: [>`sourcelanguage] obj -> string list -> unit *) +(* external get_style_scheme: [>`sourcelanguage] obj -> style_scheme *) +(* external set_style_char: [>`sourcelanguage] obj -> style_scheme -> unit *) +(* external get_tag_style: [>`sourcelanguage] obj -> tag_style *) +(* external set_tag_style: [>`sourcelanguage] obj -> string -> tag_style -> unit *) +(* external get_tag_default_style: [>`sourcelanguage] obj -> string -> tag_style *) +end + +module SourceLanguagesManager = +struct + include SourceLanguagesManager + external new_: unit -> source_languages_manager obj = + "ml_gtk_source_languages_manager_new" +(* external get_available_languages: + [>`sourcelanguagesmanager] obj -> source_language obj list + = "ml_gtk_source_languages_manager_get_available_languages" *) + external get_language_from_mime_type: + [>`sourcelanguagesmanager] obj -> string -> source_language obj option + = "ml_gtk_source_languages_manager_get_language_from_mime_type" + external get_lang_files_dirs: + [>`sourcelanguagesmanager] obj -> string list + = "ml_gtk_source_languages_manager_get_lang_files_dirs" +(* external set_lang_files_dirs: + [>`sourcelanguagesmanager] obj -> string list -> unit + = "ml_gtk_source_languages_manager_set_lang_files_dirs" *) +end + +module SourceBuffer = +struct + include SourceBuffer +(* external new_: unit -> source_buffer obj = "ml_gtk_source_buffer_new" *) +(* external new_with_buffer: [>`sourcelanguage] obj -> source_buffer obj = + "ml_gtk_source_buffer_new_with_language" *) + external can_undo: [>`sourcebuffer] obj -> bool = + "ml_gtk_source_buffer_can_undo" + external can_redo: [>`sourcebuffer] obj -> bool = + "ml_gtk_source_buffer_can_redo" + external undo: [>`sourcebuffer] obj -> unit = "ml_gtk_source_buffer_undo" + external redo: [>`sourcebuffer] obj -> unit = "ml_gtk_source_buffer_redo" + external begin_not_undoable_action: [>`sourcebuffer] obj -> unit = + "ml_gtk_source_buffer_begin_not_undoable_action" + external end_not_undoable_action: [>`sourcebuffer] obj -> unit = + "ml_gtk_source_buffer_end_not_undoable_action" +end + +module SourceView = +struct + include SourceView + external new_: unit -> source_view obj = "ml_gtk_source_view_new" + external new_with_buffer: [>`sourcebuffer] obj -> source_view obj = + "ml_gtk_source_view_new_with_buffer" +end + +module SourceViewMisc = +struct + external find_matching_bracket: text_iter -> bool = + "ml_gtk_source_iter_find_matching_bracket" +end + diff --git a/DEVEL/lablgtksourceview/gtkSourceView.props b/DEVEL/lablgtksourceview/gtkSourceView.props new file mode 100644 index 000000000..a8a6f6e93 --- /dev/null +++ b/DEVEL/lablgtksourceview/gtkSourceView.props @@ -0,0 +1,40 @@ + +prefix "Gtk" + +header { + open Gtk_sourceview +} + +class SourceLanguage type "source_language obj" set wrapsig : GObject { + signal tag_style_changed: string +} + +class SourceLanguagesManager type "source_languages_manager obj" set wrapsig : GObject { +(* "lang-files-dirs" gpointer : Read / Write / Construct Only *) +} + +class SourceBuffer type "source_buffer obj" set wrapsig : GObject { + "check-brackets" gboolean : Read / Write + "escape-char" guint : Read / Write + "highlight" gboolean : Read / Write + "language" GtkSourceLanguage : Read / Write + "max-undo-levels" gint : Read / Write + signal can_redo: gboolean + signal can_undo: gboolean + signal highlight_updated: GtkTextIter GtkTextIter + signal marker_updated: GtkTextIter +} + +class SourceView type "source_view obj" set wrapsig : Widget { + "auto-indent" gboolean : Read / Write + "insert-spaces-instead-of-tabs" gboolean : Read / Write + "margin" guint : Read / Write + "show-line-markers" gboolean : Read / Write + "show-line-numbers" gboolean : Read / Write + "show-margin" gboolean : Read / Write + "smart-home-end" gboolean : Read / Write + "tabs-width" guint : Read / Write + signal redo + signal undo +} + diff --git a/DEVEL/lablgtksourceview/gtk_sourceview.ml b/DEVEL/lablgtksourceview/gtk_sourceview.ml new file mode 100644 index 000000000..573195e19 --- /dev/null +++ b/DEVEL/lablgtksourceview/gtk_sourceview.ml @@ -0,0 +1,26 @@ +(* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + *) + +type source_view = [Gtk.text_view|`sourceview] +type source_buffer = [`textbuffer|`sourcebuffer] +type source_language = [`sourcelanguage] +type source_languages_manager = [`sourcelanguagesmanager] + diff --git a/DEVEL/lablgtksourceview/ml_gtk_sourceview.c b/DEVEL/lablgtksourceview/ml_gtk_sourceview.c new file mode 100644 index 000000000..965618d26 --- /dev/null +++ b/DEVEL/lablgtksourceview/ml_gtk_sourceview.c @@ -0,0 +1,126 @@ +/* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +CAMLprim value ml_gtk_source_language_init(value unit) +{ /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_source_language_get_type(); + return Val_GType(t); +} + +CAMLprim value ml_gtk_source_languages_manager_init(value unit) +{ /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_source_languages_manager_get_type(); + return Val_GType(t); +} + +CAMLprim value ml_gtk_source_buffer_init(value unit) +{ /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_source_buffer_get_type(); + return Val_GType(t); +} + +CAMLprim value ml_gtk_source_view_init(value unit) +{ /* Since these are declared const, must force gcc to call them! */ + GType t = gtk_source_view_get_type(); + return Val_GType(t); +} + +static gpointer string_val(value v) +{ + return String_val(v); +} + +GSList *ml_gslist_of_string_list(value list) +{ + GSList_val(list, string_val); +} + +/* CAMLprim value +ml_gtk_source_languages_manager_set_lang_files_dirs(GObject *obj, value list) +{ + GSList *gslist = ml_gslist_of_string_list(list); + g_object_set_property(obj, "lang-files-dirs", gslist); + return Val_unit; +} */ + +#define GtkSourceLanguage_val(val) check_cast(GTK_SOURCE_LANGUAGE,val) +#define GtkSourceLanguagesManager_val(val)\ + check_cast(GTK_SOURCE_LANGUAGES_MANAGER,val) +#define GtkSourceTagTable_val(val) check_cast(GTK_SOURCE_TAG_TABLE,val) +#define GtkSourceBuffer_val(val) check_cast(GTK_SOURCE_BUFFER,val) +#define GtkSourceView_val(val) check_cast(GTK_SOURCE_VIEW,val) +#define GtkTextIter_val(val) ((GtkTextIter*)MLPointer_val(val)) +#define Val_option_GtkAny(v) Val_option(v,Val_GtkAny) +#define string_list_of_GSList(l) Val_GSList(l, (value_in) Val_string) +/* #define GSList_of_string_list(l) GSList_val(l, String_val) */ +/* #define GSList_of_string_list(l) GSList_val(l, ml_string_val) */ + +ML_2 (_gtk_source_language_new_from_file, String_val, + GtkSourceLanguagesManager_val, Val_option_GtkAny) +ML_1 (gtk_source_language_get_name, GtkSourceLanguage_val, Val_string) +ML_1 (gtk_source_language_get_section, GtkSourceLanguage_val, Val_string) +ML_1 (gtk_source_language_get_escape_char, GtkSourceLanguage_val, Val_int) + +ML_0 (gtk_source_languages_manager_new, Val_GtkAny_sink) +ML_2 (gtk_source_languages_manager_get_language_from_mime_type, + GtkSourceLanguagesManager_val, String_val, + Val_option_GtkAny) +ML_1 (gtk_source_languages_manager_get_lang_files_dirs, + GtkSourceLanguagesManager_val, string_list_of_GSList) + +/* ML_0 (gtk_source_buffer_new, GtkSourceTagTable_val, Val_GtkAny_sink) */ +/* ML_1 (gtk_source_buffer_new_with_language, GtkSourceLanguage_val, + Val_GtkAny_sink) */ +ML_1 (gtk_source_buffer_can_undo, GtkSourceBuffer_val, Val_bool) +ML_1 (gtk_source_buffer_can_redo, GtkSourceBuffer_val, Val_bool) +ML_1 (gtk_source_buffer_undo, GtkSourceBuffer_val, Unit) +ML_1 (gtk_source_buffer_redo, GtkSourceBuffer_val, Unit) +ML_1 (gtk_source_buffer_begin_not_undoable_action, GtkSourceBuffer_val, Unit) +ML_1 (gtk_source_buffer_end_not_undoable_action, GtkSourceBuffer_val, Unit) + +ML_0 (gtk_source_view_new, Val_GtkWidget_sink) +ML_1 (gtk_source_view_new_with_buffer, GtkSourceBuffer_val, Val_GtkWidget_sink) + +ML_1 (gtk_source_iter_find_matching_bracket, GtkTextIter_val, Val_bool) + diff --git a/DEVEL/lablgtksourceview/test/.cvsignore b/DEVEL/lablgtksourceview/test/.cvsignore new file mode 100644 index 000000000..55e2b7e57 --- /dev/null +++ b/DEVEL/lablgtksourceview/test/.cvsignore @@ -0,0 +1,3 @@ +*.cmo *.cmi *.cmx *.o *.a *.cmxa *.cma +test test.opt +Makefile diff --git a/DEVEL/lablgtksourceview/test/Makefile.in b/DEVEL/lablgtksourceview/test/Makefile.in new file mode 100644 index 000000000..d4c5864bc --- /dev/null +++ b/DEVEL/lablgtksourceview/test/Makefile.in @@ -0,0 +1,23 @@ +PACKAGES = lablgtk2.init +PACKAGE = @PACKAGE@ +BUILDFLAGS = -package "$(PACKAGES)" -I ../ +LINKFLAGS = $(BUILDFLAGS) -linkpkg +OCAMLC = ocamlfind ocamlc +OCAMLOPT = ocamlfind ocamlopt +TMPDIR = .test + +all: test +opt: test.opt + +test: test.ml ../$(PACKAGE).cma + $(OCAMLC) $(LINKFLAGS) $(PACKAGE).cma -o $@ $< + +test.opt: test.ml ../$(PACKAGE).cmxa + $(OCAMLOPT) $(LINKFLAGS) $(PACKAGE).cmxa -o $@ $< + +clean: + rm -f *.cm[iox] *.[ao] *.cmxa test test.opt + +distclean: + rm Makefile + diff --git a/DEVEL/lablgtksourceview/test/test.lang b/DEVEL/lablgtksourceview/test/test.lang new file mode 100644 index 000000000..0478120ad --- /dev/null +++ b/DEVEL/lablgtksourceview/test/test.lang @@ -0,0 +1,128 @@ + + + + + \ + + + // + + + + /\* + \*/ + + + + ^[ \t]*#[ \t]*if[ \t]*0 + [ \t]*#[ \t]*(endif|else) + + + + " + " + + + + ^#[ \t]*(include|pragma) + \n + + + + asm + break + case + continue + default + do + else + for + fortran + goto + if + return + sizeof + switch + while + + + + _Bool + _Complex + _Imaginary + auto + char + const + double + enum + extern + float + int + inline + long + register + restrict + short + signed + static + struct + typedef + union + unsigned + void + volatile + + + + ' + ' + + + + \b([1-9][0-9]*|0)([Uu]([Ll]|LL|ll)?|([Ll]|LL|ll)[Uu]?)?\b + + + + \b([0-9]+[Ee][-]?[0-9]+|([0-9]*\.[0-9]+|[0-9]+\.)([Ee][-]?[0-9]+)?)[fFlL]? + + + + \b0[0-7]+([Uu]([Ll]|LL|ll)?|([Ll]|LL|ll)[Uu]?)?\b + + + + \b0[xX][0-9a-fA-F]+([Uu]([Ll]|LL|ll)?|([Ll]|LL|ll)[Uu]?)?\b + + + + NULL + TRUE + FALSE + MAX + MIN + __LINE__ + __DATA__ + __FILE__ + __func__ + __TIME__ + __STDC__ + + + + if + ifdef + ifndef + else + elif + define + endif + undef + error + pragma + line + + + diff --git a/DEVEL/lablgtksourceview/test/test.ml b/DEVEL/lablgtksourceview/test/test.ml new file mode 100644 index 000000000..d0e140249 --- /dev/null +++ b/DEVEL/lablgtksourceview/test/test.ml @@ -0,0 +1,99 @@ +(* + * lablgtksourceview, OCaml binding for the GtkSourceView text widget + * + * Copyright (C) 2005 Stefano Zacchiroli + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + *) + +open Printf + +let lang_mime_type = "text/x-c" +let lang_file = "test.lang" +let use_mime_type = false +let font_name = "Monospace 10" + +let print_lang lang = prerr_endline (sprintf "language: %s" lang#get_name) + +let print_lang_dirs languages_manager = + let i = ref 0 in + prerr_endline "lang_dirs:"; + List.iter + (fun dir -> incr i; prerr_endline (sprintf "%d: %s" !i dir)) + languages_manager#lang_files_dirs + +let win = GWindow.window ~title:"LablGtkSourceView test" () +let vbox = GPack.vbox ~packing:win#add () +let hbox = GPack.hbox ~packing:vbox#add () +let bracket_button = GButton.button ~label:"( ... )" ~packing:hbox#add () +let scrolled_win = GBin.scrolled_window ~packing:vbox#add () +let source_view = + GSourceView.source_view + ~auto_indent:true +(* ~insert_spaces_instead_of_tabs:true ~tabs_width:2 *) + ~show_line_numbers:true + ~margin:80 ~show_margin:true + ~smart_home_end:true + ~packing:scrolled_win#add ~height:500 ~width:650 + () +(* let languages_manager = + GSourceView.source_languages_manager ~lang_files_dirs:["/etc"] () *) +let languages_manager = GSourceView.source_languages_manager () + +let lang = + if use_mime_type then + match languages_manager#get_language_from_mime_type lang_mime_type with + | None -> failwith (sprintf "no language for %s" lang_mime_type) + | Some lang -> lang + else + match + GSourceView.source_language_from_file ~languages_manager lang_file + with + | None -> failwith (sprintf "can't load %s" lang_file) + | Some lang -> lang + +let matching_bracket () = + let iter = source_view#source_buffer#get_iter_at_mark `INSERT in + match GSourceView.find_matching_bracket iter with + | None -> prerr_endline "no matching bracket" + | Some iter -> + source_view#source_buffer#place_cursor iter; + source_view#misc#grab_focus () + +let _ = + let text = + let ic = open_in "test.txt" in + let size = in_channel_length ic in + let buf = String.create size in + really_input ic buf 0 size; + close_in ic; + buf + in + win#set_allow_shrink true; + source_view#misc#modify_font_by_name font_name; + print_lang_dirs languages_manager; + print_lang lang; + source_view#source_buffer#set_language lang; + source_view#source_buffer#set_highlight true; + source_view#source_buffer#set_text text; + ignore (win#connect#destroy (fun _ -> GMain.quit ())); + ignore (bracket_button#connect#clicked matching_bracket); +(* ignore (source_view#connect#move_cursor (fun _ _ ~extend -> + prerr_endline "move_cursor")); + ignore (source_view#connect#undo (fun _ -> prerr_endline "undo")); *) + win#show (); + GMain.Main.main () + diff --git a/DEVEL/lablgtksourceview/test/test.txt b/DEVEL/lablgtksourceview/test/test.txt new file mode 100644 index 000000000..083521327 --- /dev/null +++ b/DEVEL/lablgtksourceview/test/test.txt @@ -0,0 +1,211 @@ +/* CPU control. + * (C) 2001, 2002, 2003, 2004 Rusty Russell + * + * This code is licenced under the GPL. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for hotplug_path */ +#include +#include +#include + +/* This protects CPUs going up and down... */ +DECLARE_MUTEX(cpucontrol); + +static struct notifier_block *cpu_chain; + +/* Need to know about CPUs going up/down? */ +int register_cpu_notifier(struct notifier_block *nb) +{ + int ret; + + if ((ret = down_interruptible(&cpucontrol)) != 0) + return ret; + ret = notifier_chain_register(&cpu_chain, nb); + up(&cpucontrol); + return ret; +} +EXPORT_SYMBOL(register_cpu_notifier); + +void unregister_cpu_notifier(struct notifier_block *nb) +{ + down(&cpucontrol); + notifier_chain_unregister(&cpu_chain, nb); + up(&cpucontrol); +} +EXPORT_SYMBOL(unregister_cpu_notifier); + +#ifdef CONFIG_HOTPLUG_CPU +static inline void check_for_tasks(int cpu) +{ + struct task_struct *p; + + write_lock_irq(&tasklist_lock); + for_each_process(p) { + if (task_cpu(p) == cpu && (p->utime != 0 || p->stime != 0)) + printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d\ + (state = %ld, flags = %lx) \n", + p->comm, p->pid, cpu, p->state, p->flags); + } + write_unlock_irq(&tasklist_lock); +} + +/* Notify userspace when a cpu event occurs, by running '/sbin/hotplug + * cpu' with certain environment variables set. */ +static int cpu_run_sbin_hotplug(unsigned int cpu, const char *action) +{ + char *argv[3], *envp[5], cpu_str[12], action_str[32]; + int i; + + sprintf(cpu_str, "CPU=%d", cpu); + sprintf(action_str, "ACTION=%s", action); + /* FIXME: Add DEVPATH. --RR */ + + i = 0; + argv[i++] = hotplug_path; + argv[i++] = "cpu"; + argv[i] = NULL; + + i = 0; + /* minimal command environment */ + envp[i++] = "HOME=/"; + envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; + envp[i++] = cpu_str; + envp[i++] = action_str; + envp[i] = NULL; + + return call_usermodehelper(argv[0], argv, envp, 0); +} + +/* Take this CPU down. */ +static int take_cpu_down(void *unused) +{ + int err; + + /* Take offline: makes arch_cpu_down somewhat easier. */ + cpu_clear(smp_processor_id(), cpu_online_map); + + /* Ensure this CPU doesn't handle any more interrupts. */ + err = __cpu_disable(); + if (err < 0) + cpu_set(smp_processor_id(), cpu_online_map); + else + /* Force idle task to run as soon as we yield: it should + immediately notice cpu is offline and die quickly. */ + sched_idle_next(); + + return err; +} + +int cpu_down(unsigned int cpu) +{ + int err; + struct task_struct *p; + cpumask_t old_allowed, tmp; + + if ((err = lock_cpu_hotplug_interruptible()) != 0) + return err; + + if (num_online_cpus() == 1) { + err = -EBUSY; + goto out; + } + + if (!cpu_online(cpu)) { + err = -EINVAL; + goto out; + } + + /* Ensure that we are not runnable on dying cpu */ + old_allowed = current->cpus_allowed; + tmp = CPU_MASK_ALL; + cpu_clear(cpu, tmp); + set_cpus_allowed(current, tmp); + + p = __stop_machine_run(take_cpu_down, NULL, cpu); + if (IS_ERR(p)) { + err = PTR_ERR(p); + goto out_allowed; + } + + if (cpu_online(cpu)) + goto out_thread; + + /* Wait for it to sleep (leaving idle task). */ + while (!idle_cpu(cpu)) + yield(); + + /* This actually kills the CPU. */ + __cpu_die(cpu); + + /* Move it here so it can run. */ + kthread_bind(p, smp_processor_id()); + + /* CPU is completely dead: tell everyone. Too late to complain. */ + if (notifier_call_chain(&cpu_chain, CPU_DEAD, (void *)(long)cpu) + == NOTIFY_BAD) + BUG(); + + check_for_tasks(cpu); + + cpu_run_sbin_hotplug(cpu, "offline"); + +out_thread: + err = kthread_stop(p); +out_allowed: + set_cpus_allowed(current, old_allowed); +out: + unlock_cpu_hotplug(); + return err; +} +#else +static inline int cpu_run_sbin_hotplug(unsigned int cpu, const char *action) +{ + return 0; +} +#endif /*CONFIG_HOTPLUG_CPU*/ + +int __devinit cpu_up(unsigned int cpu) +{ + int ret; + void *hcpu = (void *)(long)cpu; + + if ((ret = down_interruptible(&cpucontrol)) != 0) + return ret; + + if (cpu_online(cpu) || !cpu_present(cpu)) { + ret = -EINVAL; + goto out; + } + ret = notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu); + if (ret == NOTIFY_BAD) { + printk("%s: attempt to bring up CPU %u failed\n", + __FUNCTION__, cpu); + ret = -EINVAL; + goto out_notify; + } + + /* Arch-specific enabling code. */ + ret = __cpu_up(cpu); + if (ret != 0) + goto out_notify; + if (!cpu_online(cpu)) + BUG(); + + /* Now call notifier in preparation. */ + notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu); + +out_notify: + if (ret != 0) + notifier_call_chain(&cpu_chain, CPU_UP_CANCELED, hcpu); +out: + up(&cpucontrol); + return ret; +} diff --git a/DEVEL/mathml_editor/.cvsignore b/DEVEL/mathml_editor/.cvsignore new file mode 100644 index 000000000..aa01254b1 --- /dev/null +++ b/DEVEL/mathml_editor/.cvsignore @@ -0,0 +1,16 @@ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.h +config.h.in +config.log +config.status +configure +editex-config +libtool +result.xml +stamp-h +stamp-h.in +t1lib.log +editex.pc diff --git a/DEVEL/mathml_editor/.log b/DEVEL/mathml_editor/.log new file mode 100644 index 000000000..3971d5a78 --- /dev/null +++ b/DEVEL/mathml_editor/.log @@ -0,0 +1,21 @@ +This is TeX, Version 3.14159 (Web2C 7.3.7) (format=tex 2002.8.9) 23 NOV 2002 18:34 +**$$\root 3 \of x+1$$ +(/usr/share/texmf/tex/latex/tools/.tex File ignored) +! Missing $ inserted. + + $ + + \mathchoice +\mathpalette #1#2->\mathchoice + {#1\displaystyle {#2}}{#1\textstyle {#2}}{#1\... +<*> $$\root 3 \of x + +1$$ +? + +* +! Emergency stop. +<*> $$\root 3 \of x+1$$ + +End of file on the terminal! + +No pages of output. diff --git a/DEVEL/mathml_editor/AUTHORS b/DEVEL/mathml_editor/AUTHORS new file mode 100644 index 000000000..7cec8397e --- /dev/null +++ b/DEVEL/mathml_editor/AUTHORS @@ -0,0 +1,2 @@ +Luca Padovani +Paolo Marinelli diff --git a/DEVEL/mathml_editor/BROWSE b/DEVEL/mathml_editor/BROWSE new file mode 100644 index 000000000..c14c1d2f5 --- /dev/null +++ b/DEVEL/mathml_editor/BROWSE @@ -0,0 +1,503 @@ +[ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "APushParser" () 0"src/APushParser.hh" "class APushParser +{" 75"src/APushParser.hh" ] +([ebrowse-ts [ebrowse-cs "TPushParser" () 0"src/TPushParser.hh" "class TPushParser :" 226"src/TPushParser.hh" ] +()([ebrowse-ms "buffer" () 0 () " std::list buffer;" 1306 2 () () 0] +[ebrowse-ms "cursor" () 0 () " TNode cursor;" 1363 2 () () 0] +[ebrowse-ms "doc" () 0 () " TDocument doc;" 1343 2 () () 0] +[ebrowse-ms "frames" () 0 () " std::stack frames;" 1278 2 () () 0] +[ebrowse-ms "nextId" () 0 () " unsigned nextId;" 1326 2 () () 0] +) +([ebrowse-ms "PRIME" () 4 () " std::string PRIME(void" 490 2 "src/TPushParser.cc" "TPushParser::PRIME()" 279] +[ebrowse-ms "TPushParser" () 0 () () 0 0 "src/TPushParser.cc" "TPushParser::TPushParser(const TDictionary& d) :" 58] +[ebrowse-ms "TPushParser" () 0 () " TPushParser(const class TDictionary&);" 275 0 () () 0] +[ebrowse-ms "advance" () 0 () " void advance(const" 1065 2 "src/TPushParser.cc" "TPushParser::advance(const" 13192] +[ebrowse-ms "do_active" () 0 () " void do_active(const" 916 2 "src/TPushParser.cc" "TPushParser::do_active(const" 5602] +[ebrowse-ms "do_align" () 0 () " void do_align(void" 624 2 "src/TPushParser.cc" "TPushParser::do_align()" 1530] +[ebrowse-ms "do_apostrophe" () 0 () " void do_apostrophe(void" 1042 2 "src/TPushParser.cc" "TPushParser::do_apostrophe()" 4611] +[ebrowse-ms "do_begin" () 0 () " void do_begin(void" 557 2 "src/TPushParser.cc" "TPushParser::do_begin()" 461] +[ebrowse-ms "do_comment" () 0 () " void do_comment(void" 954 2 "src/TPushParser.cc" "TPushParser::do_comment()" 5668] +[ebrowse-ms "do_control" () 0 () " void do_control(const" 980 2 "src/TPushParser.cc" "TPushParser::do_control(const" 6337] +[ebrowse-ms "do_cr" () 0 () " void do_cr(void" 1014 2 "src/TPushParser.cc" "TPushParser::do_cr()" 5708] +[ebrowse-ms "do_digit" () 0 () " void do_digit(const" 841 2 "src/TPushParser.cc" "TPushParser::do_digit(const" 4072] +[ebrowse-ms "do_end" () 0 () " void do_end(void" 578 2 "src/TPushParser.cc" "TPushParser::do_end()" 910] +[ebrowse-ms "do_eol" () 0 () " void do_eol(void" 645 2 "src/TPushParser.cc" "TPushParser::do_eol()" 2464] +[ebrowse-ms "do_letter" () 0 () " void do_letter(const" 804 2 "src/TPushParser.cc" "TPushParser::do_letter(const" 3902] +[ebrowse-ms "do_other" () 0 () " void do_other(const" 878 2 "src/TPushParser.cc" "TPushParser::do_other(const" 5303] +[ebrowse-ms "do_parameter" () 0 () " void do_parameter(const" 673 2 "src/TPushParser.cc" "TPushParser::do_parameter(const" 2546] +[ebrowse-ms "do_shift" () 0 () " void do_shift(void" 601 2 "src/TPushParser.cc" "TPushParser::do_shift()" 1487] +[ebrowse-ms "do_space" () 0 () " void do_space(const" 766 2 "src/TPushParser.cc" "TPushParser::do_space(const" 3794] +[ebrowse-ms "do_subscript" () 0 () " void do_subscript(void" 742 2 "src/TPushParser.cc" "TPushParser::do_subscript()" 2609] +[ebrowse-ms "do_superscript" () 0 () " void do_superscript(void" 715 2 "src/TPushParser.cc" "TPushParser::do_superscript()" 3204] +[ebrowse-ms "document" () 4 () " TDocument document(void" 432 0 () " TDocument document(void" 432] +[ebrowse-ms "isPrimes" () 4 () " bool isPrimes(const" 520 2 "src/TPushParser.cc" "TPushParser::isPrimes(const" 4445] +[ebrowse-ms "process" () 0 () " void process(const" 1096 2 "src/TPushParser.cc" "TPushParser::process(const" 8538] +[ebrowse-ms "push" () 1 () " virtual void push(const" 349 0 "src/TPushParser.cc" "TPushParser::push(const" 9379] +[ebrowse-ms "setCursor" () 1 () " virtual void setCursor(const" 390 0 "src/TPushParser.cc" "TPushParser::setCursor(const" 13865] +[ebrowse-ms "~TPushParser" () 1 () " virtual ~TPushParser()" 321 0 "src/TPushParser.cc" "TPushParser::~TPushParser()" 241] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TTokenizer" () 0"src/TTokenizer.hh" "class TTokenizer :" 173"src/TTokenizer.hh" ] +()([ebrowse-ms "tokens" () 0 () " std::list tokens;" 405 2 () () 0] +) +([ebrowse-ms "TTokenizer" () 0 () " TTokenizer(void) {" 221 0 () " TTokenizer(void) {" 221] +[ebrowse-ms "push" () 1 () " virtual void push(const" 316 2 "src/TTokenizer.cc" "TTokenizer::push(const" 471] +[ebrowse-ms "setCursor" () 1 () " virtual void setCursor(const" 357 2 () " virtual void setCursor(const" 357] +[ebrowse-ms "tokenize" () 0 () " std::vector tokenize(const" 265 0 "src/TTokenizer.cc" "TTokenizer::tokenize(const" 120] +) +() +() +() +() +()() +])() +([ebrowse-ms "APushParser" () 0 () " APushParser(void) {" 102 0 () " APushParser(void) {" 102] +[ebrowse-ms "push" () 9 () " virtual void push(const" 164 0 () () 0] +[ebrowse-ms "setCursor" () 9 () " virtual void setCursor(const" 209 0 () () 0] +[ebrowse-ms "~APushParser" () 1 () " virtual ~APushParser()" 133 0 () " virtual ~APushParser()" 133] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EmptyBuffer" "TLexerPush" 0"src/TLexerPush.hh" " class EmptyBuffer {" 271() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "unary_function" "std" 32() () 0() ] +([ebrowse-ts [ebrowse-cs "StringHash" "TDictionary" 0"src/TDictionary.hh" " struct StringHash :" 1160"src/TDictionary.hh" ] +()() +([ebrowse-ms "operator ()" () 4 () " { size_t operator()(const" 1238 0 () " { size_t operator()(const" 1238] +) +() +() +() +() +()() +])() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TObject" () 0"src/TObject.hh" "class TObject +{" 63"src/TObject.hh" ] +()() +([ebrowse-ms "TObject" () 0 () " TObject(void) {" 89 1 () " TObject(void) {" 89] +[ebrowse-ms "ref" () 4 () " void ref(coid" 162 0 () " void ref(coid" 162] +[ebrowse-ms "unref" () 4 () " void unref(void" 206 0 () " void unref(void" 206] +[ebrowse-ms "~TObject" () 1 () " virtual ~TObject()" 132 1 () " virtual ~TObject()" 132] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "std" () 0() () 0() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TLexerPush" () 0"src/TLexerPush.hh" "class TLexerPush +{" 59"src/TLexerPush.hh" ] +()([ebrowse-ms "state" () 0 () " State state;" 388 2 () () 0] +[ebrowse-ms "tokens" () 0 () " std::deque tokens;" 417 2 () () 0] +) +([ebrowse-ms "TLexerPush" () 0 () " TLexerPush(void);" 85 0 "src/TLexerPush.cc" "TLexerPush::TLexerPush() +{" 51] +[ebrowse-ms "ambiguous" () 4 () " bool ambiguous(void" 182 0 "src/TLexerPush.cc" "TLexerPush::ambiguous()" 576] +[ebrowse-ms "empty" () 4 () " bool empty(void" 240 0 "src/TLexerPush.cc" "TLexerPush::empty()" 447] +[ebrowse-ms "front" () 4 () " TToken front(void" 150 0 "src/TLexerPush.cc" "TLexerPush::front()" 338] +[ebrowse-ms "pending" () 4 () " bool pending(void" 212 0 "src/TLexerPush.cc" "TLexerPush::pending()" 510] +[ebrowse-ms "pop" () 0 () " TToken pop(void" 128 0 "src/TLexerPush.cc" "TLexerPush::pop()" 99] +[ebrowse-ms "push" () 0 () " void push(TChar" 108 0 "src/TLexerPush.cc" "TLexerPush::push(TChar" 664] +) +() +() +() +([ebrowse-ms "State" () 0 () " {" 303 2 () " {" 303] +) +()() +][ebrowse-ts [ebrowse-cs "TLexerPull" () 0() () 0"src/TLexerPull.cc" ] +()() +([ebrowse-ms "pop" () 0 () () 0 0 () "TLexerPull::pop(TCharStream" 94] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TDictionary" () 0"src/TDictionary.hh" "class TDictionary +{" 154"src/TDictionary.hh" ] +()([ebrowse-ms "entries" () 0 () " Dictionary entries;" 1560 2 () () 0] +) +([ebrowse-ms "TDictionary" () 0 () " TDictionary(void) {" 181 0 () " TDictionary(void) {" 181] +[ebrowse-ms "find" () 4 () " const Entry& find(const" 1107 0 "src/TDictionary.cc" "TDictionary::find(const" 3723] +[ebrowse-ms "load" () 0 () " void load(const" 1069 0 "src/TDictionary.cc" "TDictionary::load(const" 162] +[ebrowse-ms "~TDictionary" () 0 () " ~TDictionary()" 204 0 () " ~TDictionary()" 204] +) +() +() +() +([ebrowse-ms "Dictionary" () 0 () "ap< std::string, Entry, StringHash > Dictionary;" 1538 2 () () 0] +[ebrowse-ms "EntryClass" () 0 () " {" 301 0 () " {" 301] +[ebrowse-ms "Form" () 0 () " {" 228 0 () " {" 228] +) +()() +][ebrowse-ts [ebrowse-cs "DOM" () 0() () 0() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "APushLexer" () 0"src/APushLexer.hh" "class APushLexer +{" 72"src/APushLexer.hh" ] +([ebrowse-ts [ebrowse-cs "TPushLexer" () 0"src/TPushLexer.hh" "class TPushLexer :" 117"src/TPushLexer.hh" ] +()([ebrowse-ms "buffer" () 0 () " std::string buffer;" 483 2 () () 0] +[ebrowse-ms "state" () 0 () " State state;" 461 2 () () 0] +) +([ebrowse-ms "TPushLexer" () 0 () () 0 0 "src/TPushLexer.cc" "TPushLexer::TPushLexer(APushParser& p) :" 108] +[ebrowse-ms "TPushLexer" () 0 () " TPushLexer(class APushParser&);" 164 0 () () 0] +[ebrowse-ms "error" () 5 () " virtual bool error(void" 290 0 "src/TPushLexer.cc" "TPushLexer::error()" 2463] +[ebrowse-ms "push" () 1 () " virtual void push(char" 234 0 "src/TPushLexer.cc" "TPushLexer::push(char" 1180] +[ebrowse-ms "reset" () 1 () " virtual void reset(void" 262 0 "src/TPushLexer.cc" "TPushLexer::reset()" 176] +[ebrowse-ms "transaction" () 0 () " void transaction(char" 436 2 "src/TPushLexer.cc" "TPushLexer::transaction(char" 251] +[ebrowse-ms "~TPushLexer" () 1 () " virtual ~TPushLexer()" 203 0 () " virtual ~TPushLexer()" 203] +) +() +() +() +([ebrowse-ms "State" () 0 () " {" 327 2 () " {" 327] +) +()() +])() +([ebrowse-ms "APushLexer" () 0 () " APushLexer(class APushParser& p) :" 99 0 () " APushLexer(class APushParser& p) :" 99] +[ebrowse-ms "error" () 13 () " virtual bool error(void" 251 0 () () 0] +[ebrowse-ms "push" () 9 () " virtual void push(char" 187 0 () () 0] +[ebrowse-ms "reset" () 9 () " virtual void reset(void" 219 0 () () 0] +[ebrowse-ms "~APushLexer" () 1 () " virtual ~APushLexer()" 156 0 () " virtual ~APushLexer()" 156] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Ptr" () 32"src/Ptr.hh" "class Ptr +{" 1067"src/Ptr.hh" ] +()([ebrowse-ms "ptr" () 0 () " P* ptr;" 1797 2 () () 0] +) +([ebrowse-ms "P" () 4 () " operator P*()" 1487 0 () " operator P*()" 1487] +[ebrowse-ms "Ptr" () 0 () " Ptr(const Ptr& p) :" 1142 0 () " Ptr(const Ptr& p) :" 1142] +[ebrowse-ms "Ptr" () 0 () " Ptr(P* p = 0) :" 1083 0 () " Ptr(P* p = 0) :" 1083] +[ebrowse-ms "Q" () 36 () " template operator Ptr()" 1747 0 () " template operator Ptr()" 1747] +[ebrowse-ms "operator ->" () 4 () " P* operator->()" 1253 0 () " P* operator->()" 1253] +[ebrowse-ms "operator =" () 0 () " Ptr& operator=(const" 1316 0 () " Ptr& operator=(const" 1316] +[ebrowse-ms "~Ptr" () 0 () " ~Ptr()" 1202 0 () " ~Ptr()" 1202] +) +() +() +([ebrowse-ms "is_a" () 32 () " template friend bool is_a(const" 1659 0 () " template friend bool is_a(const" 1659] +[ebrowse-ms "smart_cast" () 32 () "emplate friend Ptr smart_cast(const" 1561 0 () "emplate friend Ptr smart_cast(const" 1561] +) +() +()() +][ebrowse-ts [ebrowse-cs "TToken" () 0"src/TToken.hh" "struct TToken +{" 80"src/TToken.hh" ] +()([ebrowse-ms "category" () 0 () " TCat category;" 627 0 () () 0] +[ebrowse-ms "value" () 0 () " std::string value;" 648 0 () () 0] +) +([ebrowse-ms "TToken" () 0 () " TToken(TCat c, const std::string& v) :" 438 0 () " TToken(TCat c, const std::string& v) :" 438] +[ebrowse-ms "TToken" () 0 () " TToken(TCat c, char ch) :" 366 0 () " TToken(TCat c, char ch) :" 366] +[ebrowse-ms "TToken" () 0 () " TToken(TCat c) :" 330 0 () " TToken(TCat c) :" 330] +[ebrowse-ms "operator ==" () 4 () " bool operator==(const" 517 0 () " bool operator==(const" 517] +) +() +() +() +([ebrowse-ms "TCat" () 0 () " {" 98 0 () " {" 98] +) +()() +][ebrowse-ts [ebrowse-cs "binary_function" "std" 32() () 0() ] +([ebrowse-ts [ebrowse-cs "StringEq" "TDictionary" 0"src/TDictionary.hh" " struct StringEq :" 1327() ] +()() +([ebrowse-ms "operator ()" () 4 () " { bool operator()(const" 1415 0 () () 0] +) +() +() +() +() +()() +])() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TNode" () 0"src/TNode.hh" "class TNode +{" 124"src/TNode.hh" ] +()([ebrowse-ms "node" () 0 () " DOM::Element node;" 2444 2 () () 0] +) +([ebrowse-ms "TNode" () 0 () " TNode(const TNode& n) :" 270 0 () " TNode(const TNode& n) :" 270] +[ebrowse-ms "TNode" () 0 () " TNode(void) :" 145 0 () " TNode(void) :" 145] +[ebrowse-ms "append" () 4 () " void append(const" 1667 0 "src/TNode.cc" "TNode::append(const" 2450] +[ebrowse-ms "append" () 4 () " void append(const" 1631 0 "src/TNode.cc" "TNode::append(const" 2348] +[ebrowse-ms "child" () 4 () " TNode child(unsigned" 592 0 "src/TNode.cc" "TNode::child(unsigned" 2874] +[ebrowse-ms "core" () 4 () " TNode core(void" 425 0 "src/TNode.cc" "TNode::core()" 1413] +[ebrowse-ms "empty" () 4 () " bool empty(void" 648 0 () " bool empty(void" 648] +[ebrowse-ms "first" () 4 () " TNode first(void" 480 0 "src/TNode.cc" "TNode::first()" 1075] +[ebrowse-ms "firstL" () 4 () " TNode firstL(void" 508 0 "src/TNode.cc" "TNode::firstL()" 1259] +[ebrowse-ms "get" () 4 () " std::string get(const" 1758 0 "src/TNode.cc" "TNode::get(const" 3007] +[ebrowse-ms "hasId" () 4 () " bool hasId(void" 1994 0 () " bool hasId(void" 1994] +[ebrowse-ms "insert" () 4 () " void insert(const" 1595 0 "src/TNode.cc" "TNode::insert(const" 2193] +[ebrowse-ms "is" () 4 () " bool is(const" 2055 0 () " bool is(const" 2055] +[ebrowse-ms "isC" () 4 () " bool isC(const" 2303 0 () " bool isC(const" 2303] +[ebrowse-ms "isC" () 4 () " bool isC(void" 2258 0 () " bool isC(void" 2258] +[ebrowse-ms "isG" () 4 () " bool isG(void" 2119 0 () " bool isG(void" 2119] +[ebrowse-ms "isSb" () 4 () " bool isSb(void" 2165 0 () " bool isSb(void" 2165] +[ebrowse-ms "isSp" () 4 () " bool isSp(void" 2212 0 () " bool isSp(void" 2212] +[ebrowse-ms "last" () 4 () " TNode last(void" 534 0 "src/TNode.cc" "TNode::last()" 736] +[ebrowse-ms "lastL" () 4 () " TNode lastL(void" 561 0 "src/TNode.cc" "TNode::lastL()" 922] +[ebrowse-ms "name" () 4 () " std::string name(void" 1863 0 () " std::string name(void" 1863] +[ebrowse-ms "nameC" () 4 () " std::string nameC(void" 1929 0 () " std::string nameC(void" 1929] +[ebrowse-ms "next" () 4 () " TNode next(void" 319 0 "src/TNode.cc" "TNode::next()" 63] +[ebrowse-ms "nextL" () 4 () " TNode nextL(void" 346 0 "src/TNode.cc" "TNode::nextL()" 247] +[ebrowse-ms "operator !=" () 4 () " bool operator!=(const" 1295 0 () " bool operator!=(const" 1295] +[ebrowse-ms "operator ==" () 4 () " bool operator==(const" 1227 0 () " bool operator==(const" 1227] +[ebrowse-ms "operator []" () 4 () " ProxyAttr operator[](const" 1422 0 () " ProxyAttr operator[](const" 1422] +[ebrowse-ms "operator []" () 4 () " TNode operator[](int" 1362 0 () " TNode operator[](int" 1362] +[ebrowse-ms "parent" () 4 () " TNode parent(void" 453 0 "src/TNode.cc" "TNode::parent()" 1587] +[ebrowse-ms "prepend" () 4 () " void prepend(const" 1718 0 "src/TNode.cc" "TNode::prepend(const" 2683] +[ebrowse-ms "prev" () 4 () " TNode prev(void" 372 0 "src/TNode.cc" "TNode::prev()" 396] +[ebrowse-ms "prevL" () 4 () " TNode prevL(void" 399 0 "src/TNode.cc" "TNode::prevL()" 588] +[ebrowse-ms "remove" () 4 () " void remove(void" 1529 0 "src/TNode.cc" "TNode::remove()" 1913] +[ebrowse-ms "replace" () 4 () " void replace(const" 1559 0 "src/TNode.cc" "TNode::replace(const" 2038] +[ebrowse-ms "set" () 4 () " void set(const" 1797 0 "src/TNode.cc" "TNode::set(const" 3109] +[ebrowse-ms "size" () 4 () " unsigned size(void" 621 0 "src/TNode.cc" "TNode::size()" 1749] +[ebrowse-ms "value" () 4 () " std::string value(void" 707 0 () " std::string value(void" 707] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Entry" "TDictionary" 0"src/TDictionary.hh" " struct Entry + {" 405"src/TDictionary.hh" ] +()([ebrowse-ms "cls" () 0 () " EntryClass cls;" 806 0 () () 0] +[ebrowse-ms "delimiter" () 0 () " unsigned delimiter : 1;" 909 0 () () 0] +[ebrowse-ms "embellishment" () 0 () " unsigned embellishment : 1;" 966 0 () () 0] +[ebrowse-ms "infix" () 0 () " unsigned infix : 8;" 830 0 () () 0] +[ebrowse-ms "leftOpen" () 0 () " unsigned leftOpen : 1;" 993 0 () () 0] +[ebrowse-ms "limits" () 0 () " unsigned limits : 1;" 934 0 () () 0] +[ebrowse-ms "pattern" () 0 () " std::vector pattern;" 597 0 () () 0] +[ebrowse-ms "postfix" () 0 () " unsigned postfix : 8;" 881 0 () () 0] +[ebrowse-ms "prefix" () 0 () " unsigned prefix : 8;" 855 0 () () 0] +[ebrowse-ms "rightOpen" () 0 () " unsigned rightOpen : 1;" 1021 0 () () 0] +[ebrowse-ms "table" () 0 () " unsigned table : 1;" 1045 0 () () 0] +[ebrowse-ms "value" () 0 () " std::string value;" 620 0 () () 0] +) +([ebrowse-ms "Entry" () 0 () " {" 420 0 () " {" 420] +[ebrowse-ms "defined" () 4 () " bool defined(void" 643 0 () " bool defined(void" 643] +[ebrowse-ms "hasArguments" () 4 () " bool hasArguments(void" 707 0 () " bool hasArguments(void" 707] +[ebrowse-ms "paramDelimited" () 4 () " bool paramDelimited(unsigned" 777 0 "src/TDictionary.cc" "TDictionary::Entry::paramDelimited(unsigned" 4012] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Frame" "TPushParser" 0"src/TPushParser.hh" " struct Frame + {" 1126"src/TPushParser.hh" ] +()([ebrowse-ms "entry" () 0 () " const TDictionary::Entry& entry;" 1226 0 () () 0] +[ebrowse-ms "pos" () 0 () " unsigned pos;" 1244 0 () () 0] +) +([ebrowse-ms "Frame" () 0 () " Frame(const TDictionary::Entry& e) :" 1142 0 () " Frame(const TDictionary::Entry& e) :" 1142] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TCharStream" () 0"src/TCharStream.hh" "class TCharStream +{" 94"src/TCharStream.hh" ] +([ebrowse-ts [ebrowse-cs "TCharStreamString" () 0"src/TCharStreamString.hh" "class TCharStreamString :" 120"src/TCharStreamString.hh" ] +()([ebrowse-ms "buffer" () 0 () " TString buffer;" 555 2 () () 0] +[ebrowse-ms "idx" () 0 () " unsigned long idx;" 536 2 () () 0] +) +([ebrowse-ms "TCharStreamString" () 0 () " TCharStreamString(const TString& s) :" 175 0 () " TCharStreamString(const TString& s) :" 175] +[ebrowse-ms "look" () 5 () " virtual TChar look(void" 343 0 () " virtual TChar look(void" 343] +[ebrowse-ms "more" () 5 () " virtual bool more(void" 275 0 () " virtual bool more(void" 275] +[ebrowse-ms "next" () 1 () " virtual TChar next(void" 439 0 () " virtual TChar next(void" 439] +[ebrowse-ms "~TCharStreamString" () 1 () " virtual ~TCharStreamString()" 243 0 () " virtual ~TCharStreamString()" 243] +) +() +() +() +() +()() +])() +([ebrowse-ms "TCharStream" () 0 () " TCharStream(void) {" 121 0 () " TCharStream(void) {" 121] +[ebrowse-ms "look" () 13 () " virtual TChar look(void" 222 0 () () 0] +[ebrowse-ms "more" () 13 () " virtual bool more(void" 184 0 () () 0] +[ebrowse-ms "next" () 9 () " virtual TChar next(void" 260 0 () () 0] +[ebrowse-ms "~TCharStream" () 1 () " virtual ~TCharStream()" 152 0 () " virtual ~TCharStream()" 152] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EmptyStream" "TCharStream" 0"src/TCharStream.hh" " class EmptyStream {" 289() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "*Globals*" () 0() () 0"src/APushLexer.hh" ] +()() +([ebrowse-ms "dispatch" () 0 "src/special.cc" "dispatch(const" 1012 0 "src/special.cc" "dispatch(const" 1012] +[ebrowse-ms "do_apostrophe" () 0 "src/special.cc" "do_apostrophe(const" 669 0 "src/special.cc" "do_apostrophe(const" 669] +[ebrowse-ms "do_bgroup" () 0 "src/special.cc" "do_bgroup(const" 149 0 "src/special.cc" "do_bgroup(const" 149] +[ebrowse-ms "do_control" () 0 "src/special.cc" "do_control(const" 711 0 "src/special.cc" "do_control(const" 711] +[ebrowse-ms "do_other" () 0 "src/special.cc" "do_other(const" 776 0 "src/special.cc" "do_other(const" 776] +[ebrowse-ms "finishG" () 0 "src/special.cc" "void finishG(const" 118 0 () () 0] +[ebrowse-ms "getCore" () 0 "src/domnav.cc" "getCore(const" 629 0 "src/domnav.cc" "getCore(const" 629] +[ebrowse-ms "getRightmostChild" () 0 "src/domnav.cc" "getRightmostChild(const" 37 0 "src/domnav.cc" "getRightmostChild(const" 37] +[ebrowse-ms "isDelimiter" () 0 "src/domnav.cc" "isDelimiter(const" 1716 0 "src/domnav.cc" "isDelimiter(const" 1716] +[ebrowse-ms "isFunction" () 0 "src/domnav.cc" "isFunction(const" 1879 0 "src/domnav.cc" "isFunction(const" 1879] +[ebrowse-ms "isGroup" () 0 "src/domnav.cc" "isGroup(const" 1214 0 "src/domnav.cc" "isGroup(const" 1214] +[ebrowse-ms "isInferred" () 0 "src/domnav.cc" "isInferred(const" 985 0 "src/domnav.cc" "isInferred(const" 985] +[ebrowse-ms "isMacro" () 0 "src/domnav.cc" "isMacro(const" 1085 0 "src/domnav.cc" "isMacro(const" 1085] +[ebrowse-ms "isOperator" () 0 "src/domnav.cc" "isOperator(const" 1553 0 "src/domnav.cc" "isOperator(const" 1553] +[ebrowse-ms "isPrimes" () 0 "src/domnav.cc" "isPrimes(const" 1451 0 "src/domnav.cc" "isPrimes(const" 1451] +[ebrowse-ms "isSb" () 0 "src/domnav.cc" "isSb(const" 1291 0 "src/domnav.cc" "isSb(const" 1291] +[ebrowse-ms "isSp" () 0 "src/domnav.cc" "isSp(const" 1369 0 "src/domnav.cc" "isSp(const" 1369] +[ebrowse-ms "isUnicodeAlpha" () 2 "src/dom.hh" "inline bool isUnicodeAlpha(TChar" 303 0 "src/dom.hh" "inline bool isUnicodeAlpha(TChar" 303] +[ebrowse-ms "isUnicodeDigit" () 2 "src/dom.hh" "inline bool isUnicodeDigit(TChar" 408 0 "src/dom.hh" "inline bool isUnicodeDigit(TChar" 408] +[ebrowse-ms "isUnicodeSpace" () 2 "src/dom.hh" "inline bool isUnicodeSpace(TChar" 198 0 "src/dom.hh" "inline bool isUnicodeSpace(TChar" 198] +[ebrowse-ms "main" () 0 "src/texlexer.cc" "main()" 51 0 "src/texlexer.cc" "main()" 51] +[ebrowse-ms "prevLinearSibling" () 0 "src/domnav.cc" "prevLinearSibling(const" 324 0 "src/domnav.cc" "prevLinearSibling(const" 324] +[ebrowse-ms "replace" () 0 "src/domnav.cc" "replace(const" 834 0 "src/domnav.cc" "replace(const" 834] +[ebrowse-ms "tokenize" () 0 "src/tokenizer.hh" "std::vector tokenize(const" 123 0 () () 0] +) +([ebrowse-ms "undefinedEntry" () 0 () () 0 0 "src/TDictionary.cc" "static TDictionary::Entry undefinedEntry;" 132] +) +() +([ebrowse-ms "Ptr_hh" () 512 () () 0 0 "src/Ptr.hh" "#define Ptr_hh +" 1036] +[ebrowse-ms "TML_NS_URI" () 512 () () 0 0 "src/globals.hh" "#define TML_NS_URI " 67] +[ebrowse-ms "XMLNS_NS_URI" () 512 () () 0 0 "src/globals.hh" "#define XMLNS_NS_URI " 123] +[ebrowse-ms "__APushLexer_hh__" () 512 () () 0 0 () "#define __APushLexer_hh__ +" 53] +[ebrowse-ms "__APushParser_hh__" () 512 () () 0 0 "src/APushParser.hh" "#define __APushParser_hh__ +" 55] +[ebrowse-ms "__TCharStreamString_hh__" () 512 () () 0 0 "src/TCharStreamString.hh" "#define __TCharStreamString_hh__ +" 67] +[ebrowse-ms "__TCharStream_hh__" () 512 () () 0 0 "src/TCharStream.hh" "#define __TCharStream_hh__ +" 55] +[ebrowse-ms "__TDictionary_hh__" () 512 () () 0 0 "src/TDictionary.hh" "#define __TDictionary_hh__ +" 55] +[ebrowse-ms "__TDocument_hh__" () 512 () () 0 0 "src/TDocument.hh" "#define __TDocument_hh__ +" 51] +[ebrowse-ms "__TNode_hh__" () 512 () () 0 0 "src/TNode.hh" "#define __TNode_hh__ +" 43] +[ebrowse-ms "__TObject_hh__" () 512 () () 0 0 "src/TObject.hh" "#define __TObject_hh__ +" 47] +[ebrowse-ms "__TPushLexer_hh__" () 512 () () 0 0 "src/TPushLexer.hh" "#define __TPushLexer_hh__ +" 53] +[ebrowse-ms "__TPushParser_hh__" () 512 () () 0 0 "src/TPushParser.hh" "#define __TPushParser_hh__ +" 55] +[ebrowse-ms "__TToken_hh__" () 512 () () 0 0 "src/TToken.hh" "#define __TToken_hh__ +" 45] +[ebrowse-ms "__TTokenizer_hh__" () 512 () () 0 0 "src/TTokenizer.hh" "#define __TTokenizer_hh__ +" 53] +[ebrowse-ms "__dom_hh__" () 512 () () 0 0 "src/dom.hh" "#define __dom_hh__ +" 39] +[ebrowse-ms "__globals_hh__" () 512 () () 0 0 "src/globals.hh" "#define __globals_hh__ +" 47] +[ebrowse-ms "__tokenzier_hh__" () 512 () () 0 0 "src/tokenizer.hh" "#define __tokenzier_hh__ +" 51] +) +([ebrowse-ms "TChar" () 0 () () 0 0 "src/dom.hh" "typedef DOM::Char32 TChar;" 131] +[ebrowse-ms "TString" () 0 () () 0 0 "src/dom.hh" "typedef DOM::UCS4String TString;" 164] +) +()() +][ebrowse-ts [ebrowse-cs "ProxyAttr" "TNode" 0"src/TNode.hh" " class ProxyAttr + {" 765"src/TNode.hh" ] +()([ebrowse-ms "name" () 0 () " std::string name;" 1155 2 () () 0] +[ebrowse-ms "node" () 0 () " DOM::Element node;" 1132 2 () () 0] +) +([ebrowse-ms "ProxyAttr" () 0 () "r(const DOM::Element& n, const std::string& s) :" 795 0 () "r(const DOM::Element& n, const std::string& s) :" 795] +[ebrowse-ms "operator =" () 0 () " ProxyAttr& operator=(const" 959 0 () " ProxyAttr& operator=(const" 959] +[ebrowse-ms "operator ==" () 0 () " bool operator==(const" 1040 0 () " bool operator==(const" 1040] +[ebrowse-ms "string" () 4 () " operator std::string()" 885 0 () " operator std::string()" 885] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EventListener" "DOM" 0() () 0() ] +([ebrowse-ts [ebrowse-cs "DOMSubtreeModifiedListener" "TDocument" 0"src/TDocument.hh" " class DOMSubtreeModifiedListener :" 1015"src/TDocument.hh" ] +()([ebrowse-ms "doc" () 0 () " TDocument doc;" 1247 2 () () 0] +) +([ebrowse-ms "DOMSubtreeModifiedListener" () 0 () "DOMSubtreeModifiedListener(const TDocument& d) :" 1092 0 () "DOMSubtreeModifiedListener(const TDocument& d) :" 1092] +[ebrowse-ms "handleEvent" () 1 () " virtual void handleEvent(const" 1202 0 () () 0] +[ebrowse-ms "~DOMSubtreeModifiedListener" () 1 () " virtual ~DOMSubtreeModifiedListener()" 1162 0 () " virtual ~DOMSubtreeModifiedListener()" 1162] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TDocument" () 0"src/TDocument.hh" "class TDocument :" 108"src/TDocument.hh" ] +()([ebrowse-ms "dirty" () 0 () " DOM::Element dirty;" 971 2 () () 0] +[ebrowse-ms "doc" () 0 () " DOM::Document doc;" 949 2 () () 0] +) +([ebrowse-ms "TDocument" () 0 () " TDocument(void);" 162 0 "src/TDocument.cc" "TDocument::TDocument() +{" 108] +[ebrowse-ms "create" () 4 () " TNode create(const" 202 0 "src/TDocument.cc" "TDocument::create(const" 789] +[ebrowse-ms "createC" () 4 () " TNode createC(const" 327 0 "src/TDocument.cc" "TDocument::createC(const" 1062] +[ebrowse-ms "createG" () 4 () " TNode createG(unsigned" 262 0 () " TNode createG(unsigned" 262] +[ebrowse-ms "createI" () 4 () " TNode createI(const" 461 0 () " TNode createI(const" 461] +[ebrowse-ms "createN" () 4 () " TNode createN(const" 561 0 () " TNode createN(const" 561] +[ebrowse-ms "createO" () 4 () " TNode createO(const" 661 0 () " TNode createO(const" 661] +[ebrowse-ms "createT" () 4 () " TNode createT(const" 384 0 "src/TDocument.cc" "TDocument::createT(const" 1197] +[ebrowse-ms "dirtyIdNode" () 4 () " TNode dirtyIdNode(void" 872 0 "src/TDocument.cc" "TDocument::dirtyIdNode()" 2081] +[ebrowse-ms "dirtyNode" () 4 () " TNode dirtyNode(void" 821 0 () " TNode dirtyNode(void" 821] +[ebrowse-ms "handleEvent" () 1 () " virtual void handleEvent(const" 1293 2 "src/TDocument.cc" "TDocument::handleEvent(const" 2348] +[ebrowse-ms "root" () 0 () " TNode root(void" 758 0 () " TNode root(void" 758] +[ebrowse-ms "serialize" () 4 () " void serialize(const" 904 0 "src/TDocument.cc" "TDocument::serialize(const" 637] +[ebrowse-ms "~TDocument" () 0 () " ~TDocument()" 179 0 "src/TDocument.cc" "TDocument::~TDocument()" 460] +) +() +([ebrowse-ms "findCommonAncestor" () 0 () " static DOM::Node findCommonAncestor(const" 1398 2 "src/TDocument.cc" "TDocument::findCommonAncestor(const" 1560] +[ebrowse-ms "nodeDepth" () 0 () " static unsigned nodeDepth(const" 1341 2 "src/TDocument.cc" "TDocument::nodeDepth(const" 1362] +) +() +() +()() +])() +() +() +() +() +() +()() +] \ No newline at end of file diff --git a/DEVEL/mathml_editor/BUGS b/DEVEL/mathml_editor/BUGS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/mathml_editor/BUGS-GDOME2 b/DEVEL/mathml_editor/BUGS-GDOME2 new file mode 100644 index 000000000..5f756359f --- /dev/null +++ b/DEVEL/mathml_editor/BUGS-GDOME2 @@ -0,0 +1,4 @@ + +* /usr/lib is given by gdome-config +* should optimize event propagation, remember only those nodes with + listeners diff --git a/DEVEL/mathml_editor/ChangeLog b/DEVEL/mathml_editor/ChangeLog new file mode 100644 index 000000000..95f5681b7 --- /dev/null +++ b/DEVEL/mathml_editor/ChangeLog @@ -0,0 +1,55 @@ +editex (0.0.4-3) unstable; urgency=low + + * Debugging printf commented out + + -- Claudio Sacerdoti Coen Fri, 07 Nov 2003 13:52:01 +0200 + +editex (0.0.4-2) unstable; urgency=low + + * Use .o objects from .libs directory so that they are PIC + (should fix build failure on hppa) + + -- Stefano Zacchiroli Tue, 21 Oct 2003 14:53:01 +0200 + +editex (0.0.4-1) unstable; urgency=low + + * New upstream release + * Rebuilt with ocaml 3.07, gmetadom 0.2.1, gtkmathview 0.5.1, + gdome-2xslt 0.0.6, lablgtk 1.2.6 + * Use debian/compat instead of DH_COMPAT + + -- Stefano Zacchiroli Fri, 10 Oct 2003 09:57:02 +0200 + +editex (0.0.3-2) unstable; urgency=low + + * Signed by me + * debian/control + - added ${misc:Depends} + - bumped standards-version to 3.5.10 + - bumped dependencies on gmetadom to 0.1.9 + - changed section of -dev package to libdevel + + -- Stefano Zacchiroli Wed, 25 Jun 2003 18:26:11 +0200 + +editex (0.0.3-1) unstable; urgency=low + + * New upstream release. + * Bug fix: tml-litex.xsl was not installed + * Bug fix: Makefile.ac did not use pkg-config to look for the existence + of the required packages (that, in the meantime, started using pkg-config) + As a result, the required packages were no longer detected by ./configure + + -- Claudio Sacerdoti Coen Thu, 19 Jun 2003 12:58:21 +0200 + +editex (0.0.2-1) unstable; urgency=low + + * New upstream release. + + -- Claudio Sacerdoti Coen Thu, 19 Jun 2003 12:58:21 +0200 + +editex (0.0.1-1) unstable; urgency=low + + * Initial Release. + + -- Stefano Zacchiroli Wed, 02 Apr 2003 15:53:25 +0200 + diff --git a/DEVEL/mathml_editor/LICENSE b/DEVEL/mathml_editor/LICENSE new file mode 100644 index 000000000..567f3dc4c --- /dev/null +++ b/DEVEL/mathml_editor/LICENSE @@ -0,0 +1,25 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + diff --git a/DEVEL/mathml_editor/MODES b/DEVEL/mathml_editor/MODES new file mode 100644 index 000000000..39032e3eb --- /dev/null +++ b/DEVEL/mathml_editor/MODES @@ -0,0 +1,25 @@ + +there are two basic syntactic modes: + +TeX mode: + +* any letter is an identifier by itself + +Program mode: + +* sequences of letters (and possibly other characters) + are collapsed into a single token. Id tokens are separated + by any other character not included in one of the collapsing + categories. + +The mode is a property of the parser. + +there are two basic semantic modes: + +math mode: + +* implicit operator is multiplication + +program mode: + +* implicit operator is function application diff --git a/DEVEL/mathml_editor/Makefile.am b/DEVEL/mathml_editor/Makefile.am new file mode 100644 index 000000000..aa15ecbef --- /dev/null +++ b/DEVEL/mathml_editor/Makefile.am @@ -0,0 +1,31 @@ +DISTDIR = @PACKAGE@-@VERSION@ + +EXTRA_DIST = BUGS LICENSE BUGS-GDOME2 MODES PATTERNS aclocal.m4 editex.pc.in debian +SUBDIRS = src test ocaml textomml xsl dict +CLEANFILES = core + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = editex.pc + +backup: + cd ..; tar cvfz @PACKAGE@-@VERSION@-`date|tr ' ' '_'|tr ':' '_'`.tar.gz @PACKAGE@ + +cleanbak: + -rm -f `find . -name "*~"` + +lc: + @( \ + CFILES=`find . -name "*.c"`; \ + HFILES=`find . -name "*.h"`; \ + CCFILES=`find . -name "*.cc"`; \ + HHFILES=`find . -name "*.hh"`; \ + ICCFILES=`find . -name "*.icc"`; \ + wc -l $$CFILES $$HFILES $$CCFILES $$HHFILES $$ICCFILES | tail -n 1 \ + ) + +deb: dist + if [ -d $(DISTDIR)/ ]; then rm -rf $(DISTDIR); else true; fi + tar xvzf $(DISTDIR).tar.gz + (cd $(DISTDIR)/ && rm -rf debian/CVS/ && debuild) + rm -rf $(DISTDIR) + diff --git a/DEVEL/mathml_editor/Makefile.in b/DEVEL/mathml_editor/Makefile.in new file mode 100644 index 000000000..b66feab8e --- /dev/null +++ b/DEVEL/mathml_editor/Makefile.in @@ -0,0 +1,438 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 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. + + +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 + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +EXTRA_DIST = BUGS LICENSE aclocal.m4 +SUBDIRS = src test ocaml textomml +CLEANFILES = core + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = editex.pc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = editex.pc +DATA = $(pkgconfig_DATA) + +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess config.h.in \ +config.sub configure configure.ac editex.pc.in install-sh ltmain.sh \ +missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.ac + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure.ac $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: +editex.pc: $(top_builddir)/config.status editex.pc.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) + @list='$(pkgconfig_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + fi; fi; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + list='$(pkgconfig_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: install-pkgconfigDATA +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: uninstall-pkgconfigDATA +uninstall: uninstall-recursive +all-am: Makefile $(DATA) config.h +all-redirect: all-recursive-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) + + +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +uninstall-pkgconfigDATA install-pkgconfigDATA install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +backup: + cd ..; tar cvfz @PACKAGE@-@VERSION@-`date|tr ' ' '_'|tr ':' '_'`.tar.gz @PACKAGE@ + +cleanbak: + -rm -f `find . -name "*~"` + +lc: + @( \ + CFILES=`find . -name "*.c"`; \ + HFILES=`find . -name "*.h"`; \ + CCFILES=`find . -name "*.cc"`; \ + HHFILES=`find . -name "*.hh"`; \ + ICCFILES=`find . -name "*.icc"`; \ + wc -l $$CFILES $$HFILES $$CCFILES $$HHFILES $$ICCFILES | tail -n 1 \ + ) + +# 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/DEVEL/mathml_editor/NEWS b/DEVEL/mathml_editor/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/mathml_editor/PATTERNS b/DEVEL/mathml_editor/PATTERNS new file mode 100644 index 000000000..0e5814d82 --- /dev/null +++ b/DEVEL/mathml_editor/PATTERNS @@ -0,0 +1,196 @@ + +identifier # + + insert(#) + +number # + + insert(#) + +\sqrt + + replace($, $) + +\root + + replace($, $) + +\of + + when (isa($.parent, "mrow") && isa($.parent.parent, "mroot")) + let mroot = $.parent.parent + if ($.prev and !$.prev.prev and !$.next) replace($.parent, $.prev) + replace(mroot.child[0], $) + +\underline + + insert([$, _]) + +\overline + + insert([$, ]) + +\cases + + replace($, {$) + +\matrix + + replace($, $) + +\over + + if isa($.parent, "mrow") + replace($.parent, [$.parent, $]) + + +_ if isa($.parent, "mrow") + if eq($.prev, null) + replace($, new(mmultiscripts, [ new mrow, $, new none ])) + elseif (isa($.prev, msub)) + let base = $.prev.children[0] + let script = $.prev.children[1] + replace($.rev, new(mmultiscripts, [ base, script, new none, $, new none ])) + elseif (isa($.prev, msup)) + let base = $.prev.children[0] + let script = $.prev.children[1] + replace($.prev, new(msubsup, [ base, $, script ])) + elseif (isa($.prev, msubsup)) + let base = $.prev.children[0] + let subscript = $.prev.children[1] + let superscript = $.prev.children[2] + replace($.prev, new(mmultiscripts, [ base, subscript, superscript, $, new none ])) + elseif isa($.prev, mmultiscripts) + if ($.prev.children[$.prev.children.size - 2] = null) + replace($.prev.children[$.prev.children.size - 2], $) + else + $.prev.children.append([$, new none]) + else + replace($.prev, new(msub, [ $.prev, $ ])) + else if isa($.parent, msub) and $.parent.children[1] = $ + let base = $.parent.children[0] + replace($.parent, new(munder, [ base, $ ])) + + +_, \sb (subscript) + + if parent.isa(mrow) + if cursor is first child then + sub = new mmultiscripts + parent.replace(cursor, sub); + sub.set_base(new mrow); + sub.set_subscript(cursor); + else + elem = element prior to cursor in parent + if elem.isa(msub) || elem.isa(msup) || elem.isa(mmultiscripts) then + append script to multiscript and/or replace single script with + multiscript + else if elem.isa(munder) || elem.isa(mover) || elem.isa(munderover) then + creates another munder + else + parent.replace(elem, sub); + sub.set_base(elem); + sub.set_subscript(cursor); + else if (parent.isa(msub) and cursor is subscript) or + change msub into a munder + cursor in same position + else + replace cursor with msub with empty base + +^, \sp (superscript) + + symmetric to subscript + +', \prime (prime) + + similar to superscript, but multiple prime superscripts should go + together in the same operator + +{ (group open) + + replace cursor with mrow, put cursor inside mrow + if cursor is inside a table, create a new table row and a new table cell + and put the cursor inside the cell + +} (group close) + + remove cursor from mrow + mrow.parent.advance(cursor, mrow) + if cursor inside a table cell then close table + +\over,\atop,\above (fraction) + + if cursor.parent.isa(mrow) then + frac = new mfrac + cursor.parent.parent.replace(mrow, frac) + numerator is current content of cursor.parent except for the cursor + itself. + set denominator to cursor + else + +\choose + + similar to fractions, but with stretchable parentheses around + +\sqrt + + parent.replace(cursor, new msqrt) + set new msqrt.base to cursor + +\root + + parent.replace(cursor, new mroot) + set empty base element + set root index to cursor + +\of + + check if cursor.parent is mroot (or mrow inside mroot index) + or and cursor is in index position. move the cursor to the base element + +\underline + + create munder element with stretchable horizontal line as underscript + substitute cursor with munder + move the cursor in the base element + +\overline + + symmetric + +accents (\hat) + + create an mover with accent=true and the operator has stretchy=false + +wide accents (\widehat) + + as accents, but mover has accent=false and the operator has stretchy=true + +\scriptstyle, ... + + create an appropriate mstyle, the cursor moves in. However, when the + subformula ends one has to skip the mstyle + +\cases + + create mrow with stretchable brace and emtpy table, put cursor inside + table + +\matrix + + create empty table, cursor inside table + +& + + check that cursor is inside a table cell + create a new cell next to it + +\cr + + check that cursor is inside a table cell inside a table row + create a new row + +\phantom + + create a mphantom element, cursor inside + diff --git a/DEVEL/mathml_editor/README b/DEVEL/mathml_editor/README new file mode 100644 index 000000000..e69de29bb diff --git a/DEVEL/mathml_editor/TML.dtd b/DEVEL/mathml_editor/TML.dtd new file mode 100644 index 000000000..74760bb45 --- /dev/null +++ b/DEVEL/mathml_editor/TML.dtd @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/TODO b/DEVEL/mathml_editor/TODO new file mode 100644 index 000000000..701ec4673 --- /dev/null +++ b/DEVEL/mathml_editor/TODO @@ -0,0 +1,13 @@ + +* add param node in the TML with the name of the parameter +* add space node? active node? +* add alt boolean to all deleting methods +* implement a mechanism that allows the definition of new macros +* add open-group close-group attributes in the dictionary and handle them +* implement macro completion + +BUGS +* $1\over{2}$ does not work + +* compare pure_subst/pure_diff/subst_diff performances + diff --git a/DEVEL/mathml_editor/configure.ac b/DEVEL/mathml_editor/configure.ac new file mode 100644 index 000000000..e1972fd90 --- /dev/null +++ b/DEVEL/mathml_editor/configure.ac @@ -0,0 +1,187 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(editex, [0.0.5]) +AC_CONFIG_SRCDIR(src/TToken.hh) +AM_INIT_AUTOMAKE($AC_PACKAGE_NAME, $AC_PACKAGE_VERSION) + +PACKAGE=$PACKAGE_NAME +VERSION=$PACKAGE_VERSION +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) + +EDITEX_VERSION_INFO=`echo $VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'` +AC_SUBST(EDITEX_VERSION_INFO) + +AC_ARG_ENABLE( + profile, + [ --enable-profile[=ARG] include profiling information [default=no]], + profile=$enableval, + profile=no +) + +AC_ARG_ENABLE( + debug, + [ --enable-debug[=ARG] include debugging debug [default=yes]], + enable_debug=$enableval, + enable_debug=yes +) + +if test "x$enable_debug" = "xyes"; then + AC_DEFINE(ENABLE_DEBUG,,[Define to 1 if you want to enable validity checks while running]) +fi + +GMETADOM_PREFIX="" +AC_ARG_WITH(gmetadom-prefix, + [ --with-gmetadom-prefix=[PFX] Specify location of gmetadom], + GMETADOM_PREFIX=$withval +) + +dnl AC_CONFIG_HEADERS([config.h]) +AM_CONFIG_HEADER(config.h) + +AH_TOP([ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2004 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef config_h +#define config_h +]) + +AH_BOTTOM([ +#endif /* config_h */ +]) + +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_HEADER_STDC([]) + +AC_LANG_PUSH(C++) +AC_CHECK_HEADERS(hash_map) +AC_CHECK_HEADERS(ext/hash_map) +AC_LANG_POP(C++) + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) + +AM_PROG_LIBTOOL + +dnl PKG_CHECK_MODULES(GLIB2, glib-2.0) +dnl AC_SUBST(GLIB2_CFLAGS) +dnl AC_SUBST(GLIB2_LIBS) + +PKG_CHECK_MODULES(GMETADOM,gdome2-cpp-smart) +AC_SUBST(GMETADOM_CFLAGS) +AC_SUBST(GMETADOM_LIBS) + +PKG_CHECK_MODULES(GDOMEXSLT,gdome2-xslt-cpp-smart) +AC_SUBST(GDOMEXSLT_CFLAGS) +AC_SUBST(GDOMEXSLT_LIBS) + +PKG_CHECK_MODULES(GTKMATHVIEW,gtkmathview-gmetadom) +AC_SUBST(GTKMATHVIEW_CFLAGS) +AC_SUBST(GTKMATHVIEW_LIBS) + +AC_CHECK_PROG(HAVE_OCAMLC, ocamlc, yes, no) +if test $HAVE_OCAMLC = "no"; then + AC_MSG_ERROR([could not find ocamlc in PATH, please make sure ocaml is installed]) +else + OCAMLC=ocamlc + OCAMLSTDLIBDIR="`ocamlc -where`" + OCAMLSTUBDIR="`ocamlc -where`/stublibs" + AC_SUBST(OCAMLC) + AC_SUBST(OCAMLSTDLIBDIR) + AC_SUBST(OCAMLSTUBDIR) +fi + +AC_CHECK_PROG(HAVE_OCAMLOPT, ocamlopt, yes, no) +if test $HAVE_OCAMLOPT = "no"; then + AC_MSG_WARN([ocaml native libraries won't be compiled since ocamlopt was not found]) +else + OCAMLOPT=ocamlopt + AC_SUBST(OCAMLOPT) +fi +AM_CONDITIONAL(HAVE_OCAMLOPT_COND, test x$HAVE_OCAMLOPT = xyes) + +AC_CHECK_PROG(HAVE_OCAMLFIND, ocamlfind, yes, no) +if test $HAVE_OCAMLFIND = "no"; then + AC_MSG_ERROR([could not find ocamlfind in PATH, please make sure findlib is installed]) +else + OCAMLFIND=ocamlfind + AC_SUBST(OCAMLFIND) +fi + +AC_CHECK_PROG(HAVE_OCAMLDEP, ocamldep, yes, no) +if test $HAVE_OCAMLDEP = "yes"; then + OCAMLDEP=ocamldep + AC_SUBST(OCAMLDEP) +fi + +AC_CHECK_PROG(HAVE_OCAMLMKLIB, ocamlmklib, yes, no) +if test $HAVE_OCAMLMKLIB = "no"; then + AC_MSG_ERROR([could not find ocamlmklib in PATH, please make sure ocamlmklib is installed]) +else + OCAMLMKLIB=ocamlmklib + AC_SUBST(OCAMLMKLIB) +fi +AM_CONDITIONAL(HAVE_SHAREDLIBS_COND, test x$enable_shared = xyes) + +AC_MSG_CHECKING(for gdome2 ocaml binding) +ocamlfind query gdome2 || + AC_MSG_ERROR(gdome2 not installed (according to findlib)) +MLGDOME_CFLAGS="`$OCAMLFIND query -i-format gdome2`" +AC_SUBST(MLGDOME_CFLAGS) + +AC_MSG_CHECKING(for the ocaml library dir) +OCAML_LIB_DIR=`ocamlc -where` +AC_MSG_RESULT($OCAML_LIB_DIR) + +AC_CHECK_FILE(/usr/include/caml/mlvalues.h, + OCAML_INCLUDE_DIR=/usr/include/caml, + OCAML_INCLUDE_DIR=$OCAML_LIB_DIR/caml +) + +AC_SUBST(OCAML_INCLUDE_DIR) + +if test $profile = yes; then + CFLAFS="$CFLAGS -O0 -pg" + CXXFLAGS="$CXXFLAGS -O0 -pg" + AC_DEFINE(ENABLE_PROFILE,,[Define to 1 to let the widget collect some information for profiling purposes]) +fi + +AC_CONFIG_FILES([ + Makefile + src/Makefile + src/config.dirs + test/Makefile + textomml/Makefile + textomml/config.dirs + ocaml/Makefile + ocaml/META + editex.pc + xsl/Makefile + dict/Makefile +]) +AC_OUTPUT diff --git a/DEVEL/mathml_editor/debian/changelog b/DEVEL/mathml_editor/debian/changelog new file mode 100644 index 000000000..5af2b5f80 --- /dev/null +++ b/DEVEL/mathml_editor/debian/changelog @@ -0,0 +1,114 @@ +editex (0.0.5-6) unstable; urgency=low + + * Rebuilt against ocaml 3.08.3 + + -- Stefano Zacchiroli Wed, 30 Mar 2005 09:08:25 +0200 + +editex (0.0.5-5) unstable; urgency=low + + * debian/control + - libeditex-ocaml depends on ocaml-base-nox-3.08 instead of + ocaml-base-3.08 since the ocaml part of this package does not + depend directly on ocaml X stuff + + -- Stefano Zacchiroli Wed, 25 Aug 2004 09:49:21 +0200 + +editex (0.0.5-4) unstable; urgency=low + + * ported to gtkmathview 0.6.3 + * debian/control + - bumped gtkmathview deps to >= 0.6.3 + + -- Stefano Zacchiroli Mon, 2 Aug 2004 11:24:00 +0200 + +editex (0.0.5-3) unstable; urgency=low + + * rebuilt with ocaml 3.08 + * debian/control + - bumped ocaml deps to 3.08 + - bumped standards-version to 3.6.1.1 + - changed ocaml deps to ocaml-nox + - bumped gmetadom (ocaml part) deps to >= 0.2.1-3 (1st version + rebuilt with ocaml 3.08) + - bumped gdome xslt (ocaml part) deps to >= 0.0.6-4 (1st version + rebuilt with ocaml 3.08) + - bumped gdome xslt (C/C++ part) deps to >= 0.0.6-5 (1st version + which fixes missing-.so bug) + + -- Stefano Zacchiroli Tue, 27 Jul 2004 09:11:35 +0200 + +editex (0.0.5-2) unstable; urgency=low + + * ocaml/Makefile.am + - the .o files to be used in the dll are now taken from the .libs + subdirectoy (which presumably contains the PIC code) + (Closes: Bug#239697) + + -- Stefano Zacchiroli Thu, 25 Mar 2004 12:43:39 +0100 + +editex (0.0.5-1) unstable; urgency=low + + * New upstream release + * debian/control + - depends on libt1-dev instead of t1lib-dev + - bumped t1 dependencies to >= 5.0.0 accordingly to gtkmathview + + -- Stefano Zacchiroli Tue, 23 Mar 2004 15:38:28 +0100 + +editex (0.0.4-3) unstable; urgency=low + + * debian/control + - depends on gtkmathview 0.5.2 (Closes: Bug#218409) + - bumped standards version + + -- Stefano Zacchiroli Wed, 12 Nov 2003 17:16:56 +0100 + +editex (0.0.4-2) unstable; urgency=low + + * Use .o objects from .libs directory so that they are PIC + (should fix build failure on hppa) + + -- Stefano Zacchiroli Tue, 21 Oct 2003 14:53:01 +0200 + +editex (0.0.4-1) unstable; urgency=low + + * New upstream release + * Rebuilt with ocaml 3.07, gmetadom 0.2.1, gtkmathview 0.5.1, + gdome-2xslt 0.0.6, lablgtk 1.2.6 + * Use debian/compat instead of DH_COMPAT + + -- Stefano Zacchiroli Fri, 10 Oct 2003 09:57:02 +0200 + +editex (0.0.3-2) unstable; urgency=low + + * Signed by me + * debian/control + - added ${misc:Depends} + - bumped standards-version to 3.5.10 + - bumped dependencies on gmetadom to 0.1.9 + - changed section of -dev package to libdevel + + -- Stefano Zacchiroli Wed, 25 Jun 2003 18:26:11 +0200 + +editex (0.0.3-1) unstable; urgency=low + + * New upstream release. + * Bug fix: tml-litex.xsl was not installed + * Bug fix: Makefile.ac did not use pkg-config to look for the existence + of the required packages (that, in the meantime, started using pkg-config) + As a result, the required packages were no longer detected by ./configure + + -- Claudio Sacerdoti Coen Thu, 19 Jun 2003 12:58:21 +0200 + +editex (0.0.2-1) unstable; urgency=low + + * New upstream release. + + -- Claudio Sacerdoti Coen Thu, 19 Jun 2003 12:58:21 +0200 + +editex (0.0.1-1) unstable; urgency=low + + * Initial Release. + + -- Stefano Zacchiroli Wed, 02 Apr 2003 15:53:25 +0200 + diff --git a/DEVEL/mathml_editor/debian/compat b/DEVEL/mathml_editor/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/DEVEL/mathml_editor/debian/compat @@ -0,0 +1 @@ +4 diff --git a/DEVEL/mathml_editor/debian/control b/DEVEL/mathml_editor/debian/control new file mode 100644 index 000000000..c87009e09 --- /dev/null +++ b/DEVEL/mathml_editor/debian/control @@ -0,0 +1,46 @@ +Source: editex +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>> 4.0.0), ocaml-nox-3.08.3, libgdome2-cpp-smart-dev (>= 0.2.1), libgdome2-ocaml-dev (>= 0.2.1-3), libgdome2-xslt-dev (>= 0.0.6-5), libgdome2-xslt-ocaml-dev (>= 0.0.6-4), ocaml-findlib, libgtkmathview-dev (>= 0.6.3), libgtk2.0-dev, libt1-dev (>= 5.0.0) +Standards-Version: 3.6.1.1 + +Package: libeditex0 +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: MathML editor based on TeX syntax + EdiTeX is a C library implementing a MathML editor based on TeX syntax. + . + This package includes the shared runtime objects. + +Package: libeditex-dev +Section: libdevel +Architecture: any +Depends: libeditex0 (= ${Source-Version}), libgdome2-cpp-smart-dev (>= 0.2.1), libgdome2-xslt-dev (>= 0.0.6-5), libgtk2.0-dev, libt1-dev (>= 5.0.0), ${misc:Depends} +Description: MathML editor based on TeX syntax + EdiTeX is a C library implementing a MathML editor based on TeX syntax. + . + This package includes the development files. + +Package: libeditex-ocaml +Section: libs +Architecture: any +Depends: ocaml-base-nox-3.08.3, libgdome2-ocaml (>= 0.2.1-3), libgdome2-xslt-ocaml (>= 0.0.6-4), ${shlibs:Depends}, ${misc:Depends} +Description: OCaml bindings to EdiTeX, a MathML editor based on TeX syntax + EdiTeX is a C library implementing a MathML editor based on TeX syntax. + . + This are the Objective CAML bindings to EdiTeX. + . + This package includes the OCaml shared runtime objects. + +Package: libeditex-ocaml-dev +Section: libdevel +Architecture: any +Depends: libeditex-ocaml (= ${Source-Version}), libgdome2-ocaml-dev (>= 0.2.1-3), libgdome2-xslt-ocaml-dev (>= 0.0.6-4), ocaml-findlib, ${misc:Depends} +Description: OCaml bindings to EdiTeX, a MathML editor based on TeX syntax + EdiTeX is a C library implementing a MathML editor based on TeX syntax. + . + This are the Objective CAML bindings to EdiTeX. + . + This package includes the OCaml development files. + diff --git a/DEVEL/mathml_editor/debian/copyright b/DEVEL/mathml_editor/debian/copyright new file mode 100644 index 000000000..310cde409 --- /dev/null +++ b/DEVEL/mathml_editor/debian/copyright @@ -0,0 +1,23 @@ +This package was debianized by Stefano Zacchiroli on +Thu, 20 Mar 2003 18:09:22 +0100. + +It was downloaded from: + + http://www.cs.unibo.it/cgi-bin/cvsweb/helm/DEVEL/mathml_editor/ + +Upstream Authors: + Luca Padovani + Paolo Marinelli + +Copyright: + + This library is distributed under the term of the GNU Lesser General + Public License (LGPL). + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + On a Debian GNU/Linux system, the LGPL can be found as + /usr/share/common-licenses/LGPL-2.1. diff --git a/DEVEL/mathml_editor/debian/docs b/DEVEL/mathml_editor/debian/docs new file mode 100644 index 000000000..4a84a8c2c --- /dev/null +++ b/DEVEL/mathml_editor/debian/docs @@ -0,0 +1,7 @@ +BUGS +BUGS-GDOME2 +MODES +NEWS +PATTERNS +README +TODO diff --git a/DEVEL/mathml_editor/debian/libeditex-dev.files b/DEVEL/mathml_editor/debian/libeditex-dev.files new file mode 100644 index 000000000..1d5afcf6e --- /dev/null +++ b/DEVEL/mathml_editor/debian/libeditex-dev.files @@ -0,0 +1,5 @@ +usr/lib/pkgconfig +usr/include +usr/lib/*.a +usr/lib/*.la +usr/lib/*.so diff --git a/DEVEL/mathml_editor/debian/libeditex-ocaml-dev.files b/DEVEL/mathml_editor/debian/libeditex-ocaml-dev.files new file mode 100644 index 000000000..98d36d2a3 --- /dev/null +++ b/DEVEL/mathml_editor/debian/libeditex-ocaml-dev.files @@ -0,0 +1,3 @@ +usr/lib/ocaml/3.08.3/mathml-editor +usr/lib/ocaml/3.08.3/stublibs/lib*.so +usr/lib/ocaml/3.08.3/stublibs/dll*.so.owner diff --git a/DEVEL/mathml_editor/debian/libeditex-ocaml.files b/DEVEL/mathml_editor/debian/libeditex-ocaml.files new file mode 100644 index 000000000..f4d1a9de0 --- /dev/null +++ b/DEVEL/mathml_editor/debian/libeditex-ocaml.files @@ -0,0 +1 @@ +usr/lib/ocaml/3.08.3/stublibs/dll*.so diff --git a/DEVEL/mathml_editor/debian/libeditex0.files b/DEVEL/mathml_editor/debian/libeditex0.files new file mode 100644 index 000000000..213e11b2f --- /dev/null +++ b/DEVEL/mathml_editor/debian/libeditex0.files @@ -0,0 +1,2 @@ +usr/lib/*.so.* +usr/share diff --git a/DEVEL/mathml_editor/debian/rules b/DEVEL/mathml_editor/debian/rules new file mode 100755 index 000000000..933fd24d2 --- /dev/null +++ b/DEVEL/mathml_editor/debian/rules @@ -0,0 +1,74 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +config.status: configure + dh_testdir + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info + +build: build-stamp +build-stamp: config.status + dh_testdir + + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + -$(MAKE) distclean +# ifneq "$(wildcard /usr/share/misc/config.sub)" "" +# cp -f /usr/share/misc/config.sub config.sub +# endif +# ifneq "$(wildcard /usr/share/misc/config.guess)" "" +# cp -f /usr/share/misc/config.guess config.guess +# endif + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp + dh_movefiles + +binary-arch: build install + dh_testdir -s + dh_testroot -s + dh_installchangelogs -s ChangeLog + dh_installdocs -s +# dh_installexamples -s +# dh_installinfo -s + dh_link -s + dh_strip -s + dh_compress -s + dh_fixperms -s + dh_makeshlibs -p libeditex0 + dh_installdeb -s + dh_shlibdeps -s + dh_gencontrol -s + dh_md5sums -s + dh_builddeb -s + +binary: binary-arch +.PHONY: build clean binary-arch binary install diff --git a/DEVEL/mathml_editor/dict/.cvsignore b/DEVEL/mathml_editor/dict/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/mathml_editor/dict/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/mathml_editor/dict/Makefile.am b/DEVEL/mathml_editor/dict/Makefile.am new file mode 100644 index 000000000..f4246e40c --- /dev/null +++ b/DEVEL/mathml_editor/dict/Makefile.am @@ -0,0 +1,2 @@ +pkgdata_DATA = dictionary-basic.xml dictionary-test.xml dictionary-tex.xml dictionary.dtd +EXTRA_DIST = dictionary-basic.xml dictionary-test.xml dictionary-tex.xml dictionary.dtd diff --git a/DEVEL/mathml_editor/dict/dictionary-basic.xml b/DEVEL/mathml_editor/dict/dictionary-basic.xml new file mode 100644 index 000000000..ed2e26461 --- /dev/null +++ b/DEVEL/mathml_editor/dict/dictionary-basic.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/DEVEL/mathml_editor/dict/dictionary-test.xml b/DEVEL/mathml_editor/dict/dictionary-test.xml new file mode 100644 index 000000000..3fcc05694 --- /dev/null +++ b/DEVEL/mathml_editor/dict/dictionary-test.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/dict/dictionary-tex.xml b/DEVEL/mathml_editor/dict/dictionary-tex.xml new file mode 100644 index 000000000..47995454f --- /dev/null +++ b/DEVEL/mathml_editor/dict/dictionary-tex.xml @@ -0,0 +1,378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/dict/dictionary.dtd b/DEVEL/mathml_editor/dict/dictionary.dtd new file mode 100644 index 000000000..3fefc71fe --- /dev/null +++ b/DEVEL/mathml_editor/dict/dictionary.dtd @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/DEVEL/mathml_editor/doc/.cvsignore b/DEVEL/mathml_editor/doc/.cvsignore new file mode 100644 index 000000000..44d749510 --- /dev/null +++ b/DEVEL/mathml_editor/doc/.cvsignore @@ -0,0 +1,5 @@ +spec.aux +spec.dvi +spec.log +spec.ps +*~ diff --git a/DEVEL/mathml_editor/doc/spec.tex b/DEVEL/mathml_editor/doc/spec.tex new file mode 100644 index 000000000..a9ccdc263 --- /dev/null +++ b/DEVEL/mathml_editor/doc/spec.tex @@ -0,0 +1,973 @@ +\documentclass[10pt]{article} + +\usepackage{a4wide} +\usepackage{palatino} +\usepackage{euler} +\usepackage{amssymb} +\usepackage{stmaryrd} +\usepackage{wasysym} + +\title{\EdiTeX: a MathML Editor Based on \TeX{} Syntax\\\small Description and Formal Specification} +\author{Paolo Marinelli\\Luca Padovani\\\small\{{\tt pmarinel},{\tt lpadovan}\}{\tt @cs.unibo.it}\\\small Department of Computer Science\\\small University of Bologna} +\date{} + +\newcommand{\EdiTeX}{Edi\TeX} + +\newcommand{\tmap}[1]{\llbracket#1\rrbracket} +\newcommand{\tadvance}{\vartriangle} +\newcommand{\tnext}{\rhd} +\newcommand{\G}{\texttt{g}} +\newcommand{\PNODE}{\texttt{p}} +\newcommand{\SNODE}{\texttt{s}} +\newcommand{\INODE}{\texttt{i}} +\newcommand{\NNODE}{\texttt{n}} +\newcommand{\ONODE}{\texttt{o}} +\newcommand{\CNODE}{\texttt{c}} +\newcommand{\TABLE}{\texttt{table}} +\newcommand{\SP}{\texttt{sp}} +\newcommand{\SB}{\texttt{sb}} +\newcommand{\CELL}{\texttt{cell}} +\newcommand{\ROW}{\texttt{row}} +\newcommand{\SLDROP}{\blacktriangleleft} +\newcommand{\NLDROP}{\vartriangleleft} +\newcommand{\RDROP}{\vartriangleright} + +\begin{document} + +\maketitle + +\section{Introduction} + +MathML~\cite{MathML1,MathML2,MathML2E} is an XML application for the +representation of mathematical expressions. As most XML applications, +MathML is unsuitable to be hand-written, except for the simplest +cases, because of its verbosity. In fact, the MathML specification +explicitly states that +\begin{quote} +``While MathML is human-readable, it is anticipated that, in all but +the simplest cases, authors will use equation editors, conversion +programs, and other specialized software tools to generate MathML'' +\end{quote} + +The statement about human readability of MathML is already too strong, +as the large number of mathematical symbols, operators, and +diacritical marks that are used in mathematical notation cause MathML +documents to make extensive use of Unicode characters that typically +are not in the ``visible'' range of common text editors. Such +characters may appear as entity references, whose name indicates +somehow the kind of symbol used, or character references or they are +directly encoded in the document encoding scheme (for instance, +UTF-8). + +It is thus obvious that authoring MathML documents assumes the +assistance of dedicated tools. As of today, such tools can be +classified into two main categories: +\begin{enumerate} + \item WYSIWYG (What You See Is What You Get) editors that allow the + author to see the formatted document on the screen as it is + composed; + \item conversion tools that generate MathML markup from different + sources, typically other markup languages for scientific + documents, such as \TeX. +\end{enumerate} + +While the former tools are certainly more appealing, especially to the +unexperienced user, as they give a direct visual feedback, the +existance of tools in the second category takes into account the large +availability of existing documents in \TeX{} format, and also the fact +that experienced or ``lazy'' users may continue to prefer the use of a +markup language other than MathML for editing, and generate MathML +only as a final step of the authoring process. The ``laziness'' is not +really intended as a way of being reluctant towards a new technology, +but rather as a justified convincement that WYSIWYG editors are ``nice +to look at'' but after all they may slow down the authoring process. +WYSIWYG editors often involve the use of menus, palettes of symbols, +and, in general, an extensive use of the pointing device (the mouse) +for completing most operations. The use of shortcuts is of little +help, as it implies very soon a challenging exercise for the fingers +and the mind. Moreover, authors \emph{cannot improve} their authoring +speed with time. On the other side, the gap between the syntax of any +markup language for mathematics and mathematical notation may be +relevant, especially for large, non-trivial formulas and authoring is +a re-iterated process in which the author repeadtedly types the markup +in the editor, compiles, and looks at the result inside a pre-viewer. + +\EdiTeX{} tries to synthesize the ``best of both worlds'' in a single +tool. The basic idea is that of creating a WYSIWYG editor in which +editing is achieved by typing \TeX{} markup as the author would do in +a text editor. The \TeX{} markup is tokenized and parsed on-the-fly +and a corresponding MathML representation is created and +displayed. This way, the author can see the rendered document as it +changes. The advantages of this approach can be summarized as follows: +\begin{itemize} + \item the document is rendered concurrently with the editing, the + user has an immediate feedback hence it is easier to spot errors; + \item the author types in a concrete (and likely familiar) syntax + improving the editing speed; + \item the usual WYSIWYG mechanisms are still available. In + particular, it is possible to select \emph{visually} a fragment of + the document that needs re-editing, or that was left behind for + subsequent editing. +\end{itemize} + +\paragraph{The Name of the Game:} there is no reference to MathML in +the name ``\EdiTeX.'' In fact, the architecture of the editor is not +tied to MathML markup. Although we focus on MathML editing, by +changing a completely modularized component of the editor it is +virtually possible to generate any other markup language. + +\paragraph{Acknowledgments.} Stephen M. Watt and Igor Rodionov for +their work on the \TeX{} to MathML conversion tool; Stan Devitt for an +illuminating discussion about the architecture of \TeX{} to XML +conversion tools; Claudio Sacerdoti Coen for the valuable feedback and +uncountable bug reports. + +\section{Architecture} + +\section{Customization} + +\subsection{Short and Long Identifiers} + +\subsection{The Dictionary} + +\subsection{Stylesheets and Trasformations} + +\subsection{Rendering} + +\section{XML Representation of \TeX{} Markup} + +\section{Tokens} + +The following tokens are defined: + +\begin{tabular}{lllp{0.5\textwidth}} + \textbf{\TeX{}} & \textbf{Notation} & \textbf{Node} & \textbf{Description} \\ +\hline + \verb+{+ & $\mathrm{begin}$ & \texttt{g} & Beginning of a group \\ + \verb+}+ & $\mathrm{end}$ & & End of a group \\ + \verb+$+ & $\$$ & \texttt{math} & Math shift \\ %$ \\ + & & & End-of-line \\ + \verb+#+$i$ & $p(i)$ & \texttt{p} & Parameter \\ + \verb+^+ & $\uparrow$ & \texttt{sp} & Superscript \\ + \verb+_+ & $\downarrow$ & \texttt{sb} & Subscript \\ + & $\square$ & & Space-like character that can be ignored \\ + & $s$ & \texttt{s} & Space-like character that may be significant \\ + letter & $i(v)$ & \texttt{i} & Identifier $v$ \\ + digit & $n(v)$ & \texttt{n} & Number $v$ \\ + other & $o(v)$ & \texttt{o} & Other character or operator $v$ \\ + \verb+~+ & $\sim$ & & Active character \\ + \verb+%+ & $\%$ & & Comment \\ + control & $c(v)\langle\alpha_1,\dots,\alpha_n\rangle$ & \texttt{c} & + Control sequence $v$ that expects the $\alpha_1,\dots,\alpha_n$ sequence of tokens. \\ + backspace & $\vartriangleleft$ & & \\ + backspace & $\blacktriangleleft$ & & \\ +\end{tabular} + +%% Some tokens are mapped directly into nodes of the TML tree. The following functions shows +%% the mapping: + +\begin{tabular}{r@{\quad$=$\quad}l} + $\tmap{\{}$ & \verb+g+ \\ + $\tmap{p(i)}$ & \verb+p[@index=+$i$\verb+]+ \\ + $\tmap{p_l(i)}$ & \verb+p[@index=+$i$\verb+][@left-open='1']+ \\ + $\tmap{p_r(i)}$ & \verb+p[@index=+$i$\verb+][@right-open='1']+ \\ + $\tmap{s}$ & \verb+s+ \\ + $\tmap{\uparrow}$ & \verb+sp+ \\ + $\tmap{\downarrow}$ & \verb+sb+ \\ + $\tmap{i(v)}$ & \verb+i[@value=+$v$\verb+]+ \\ + $\tmap{n(v)}$ & \verb+n[@value=+$v$\verb+]+ \\ + $\tmap{o(v)}$ & \verb+o[@value=+$v$\verb+]+ \\ + $\tmap{c(v)\langle\alpha_1,\dots,\alpha_n\rangle}$ & \verb+c[@name=+$v$\verb+][^+$\tmap{\alpha_1}\cdots\tmap{\alpha_n}$\verb+$]+\\ +\end{tabular} +%$ + +\section{Description and Semantics of the Pattern Language} + +%% \begin{eqnarray*} +%% \mathit{NodeTest} & ::= & \mathtt{*} \\ +%% & | & \mathit{ElementType} \\ +%% & | & \mathtt{<}~\mathit{ElementTypePattern}~\mathtt{>} \\[1ex] +%% \mathit{ElementTypePattern} & ::= & \mathtt{*} \\ +%% & | & \mathit{ElementType}~(\mathtt{|}~\mathit{ElementType})^* \\ +%% & | & \mathtt{!}\mathit{ElementType}~(\mathtt{|}~\mathit{ElementType})^*\\[1ex] +%% \mathit{NodePattern} & ::= & \mathit{NodeTest}~\mathit{AttributeQualifier}^*\\[1ex] +%% \mathit{AttributeQualifier} & ::= & \mathtt{[@}\mathit{AttributeTest}\mathtt{]}\\ +%% & | & \mathtt{[!@}\mathit{AttributeTest}\mathtt{]}\\[1ex] +%% \mathit{AttributeTest} & ::= & \mathit{AttributeName} \\ +%% & | & \mathit{AttributeName}\mathtt{='}\mathit{Text}\mathtt{'} +%% \end{eqnarray*} + +\begin{table} +\[ +\begin{array}{rcl@{\hspace{3em}}rcl@{\hspace{3em}}rcl} + C &::=& . & Q &::=& \langle*\rangle & P &::=& P'\#P' \\ + &|& .. & &|& \langle!*\rangle & &|& \cent P'\#P'\\ + &|& / & &|& \langle n_1\mid\cdots\mid n_k\rangle & &|& P'\#P'\$\\%$ + &|& Q & &|& \langle!n_1\mid\cdots\mid n_k\rangle & &|& \cent P'\#P'\$\\%$ + &|& (C) & &|& Q[@n] & & &\\ + &|& \{C:\Gamma\} & &|& Q[!@n] & P' &::=& \\ + &|& C\&C & &|& Q[@n=v] & &|& C\;P'\\ + &|& C\mid C & &|& Q[!@n=v] & & &\\ + &|& C+ & &|& Q[P] & & &\\ + &|& C? & &|& Q[!P] & & &\\ + &|& C* & & & & & &\\ + &|& C\;C & & & & & &\\ + &|& !C & & & & & &\\ +\end{array} +\] +\caption{Syntax of the regular context language. $n$, $n_i$ denote +names, $v$ denotes a string enclosed in single or double quotes} +\end{table} + + +\section{Insert Rules} + +\paragraph{Begin Group:} $\{$ + +\begin{description} + \item{\verb+table/cursor+}\\ + create a \texttt{row} node, create a \texttt{cell} node, create a \texttt{g} node, + append the cursor to the \texttt{g} node, append the \texttt{g} node to the \texttt{cell} node, + append the \texttt{cell} node to the \texttt{row} node, append the \texttt{row} node to the + \texttt{c} node + \item{\verb+cursor+} \\ create a \texttt{g} node, replace the cursor with the new \texttt{g} node, + append the cursor to the new \texttt{g} node +\end{description} + +% CASE: c/g[!@id]/cursor + +% CASE: c/cursor + +% ELSE: + +% do_begin: +% CASE: c[@table='1']/cursor +% ELSE: +% create a g node with id, replace the cursor with the fresh g and append +% the cursor as only child of it + +\paragraph{End Group:} $\}$ + +\begin{description} + \item{\verb+g[@id]/cursor+}\\ + remove the cursor, put $\tadvance$ after the \texttt{g} node + \item{\verb+row/cell/g/cursor+}\\ + remove the cursor, put $\tadvance$ after the \texttt{row} node + \item{\verb+math/g[!@id]/cursor+}\\ + ? + \item{\verb+cursor+}\\ + error ? +\end{description} + +\paragraph{Math Shift:} $\$$ + +\begin{description} + \item{\verb+tex/cursor+}\\ + create a \texttt{math} node, create a \texttt{g} node, append the \texttt{g} node + as child of the \texttt{math} node, append the cursor as child of the \texttt{g} node + \item{\verb+math[@display='1']/g[!@id][*#]/cursor+}\\ + append the cursor as last child of the \texttt{math} node + \item{\verb+math/g[!@id][*#]/cursor+}\\ + remove the cursor + \item{\verb+math[!display='1']/g[!@id]/cursor+}\\ + set \verb+display='1'+ in the \texttt{math} node + \item{\verb+math/g[!@id]+}\\ + append the cursor after the \texttt{math} node + \item{\verb+math/cursor+}\\ + remove the cursor + \item{\verb+cursor+} \\ + error ? +\end{description} + +% do_shift: +% CASE: tex/cursor +% create a math node. create a g node. append g as child of math. +% append the cursor as child of g +% CASE: math[@display='1']/g[!@id][*#]/cursor +% append the cursor as last child of math +% CASE: math/g[!@id][*#]/cursor +% remove the cursor. Editing is done +% CASE: math[!display='1']/g[!@id]/cursor +% set the display attribute to '1' +% CASE: math/g[!@id] +% append the cursor after math (?) +% CASE: math/cursor +% remove the cursor. Editing is done +% ELSE: +% error + +\paragraph{Align:} $\&$ + +\begin{description} + \item{\verb+g[@id]/cursor+}\\ + create a \texttt{row} node, create a \texttt{cell} node, create a \texttt{g} node, + append the cursor to the new \texttt{g} node, append the \texttt{cell} node to the + the \texttt{row} node ? + \item{\verb+row/cell/g/cursor+}\\ + create the \texttt{g} node, create the \texttt{cell} node, append the cursor + as child of the new \texttt{g} node, append the new \texttt{g} node to the new + \texttt{cell} node after the old \texttt{cell} node + \item{\verb+cursor+}\\ + error +\end{description} + +% do_align: +% CASE: g[@id]/cursor +% create a row node. create a cell node. create a g node. append the +% cursor to g, append the g to cell, append the cell to row, ??? +% CASE: row/cell/g/cursor +% create a g node. create a cell node. appent the cursor to g, +% append the g to cell, insert the new cell after the existing cell +% ELSE: +% error + +\paragraph{End-of-line:} + +% do_eol: +% ignored + +\paragraph{Parameter:} $p(i)$ +% do_parameter: +% ignored + +\paragraph{Superscript:} $\uparrow$ + +\begin{description} + \item{\verb+[^#]/cursor+}\\ + create a \SP{} node, create a \G{} node, replace the cursor with the \SP{} node, + append the \G{} node as first child of the \SP{} node, append the cursor as last + child of the \SP{} node + \item{\verb+[*#]/cursor+}\\ + create a \SP{} node, replace \texttt{*} with the \SP{} node, append \texttt{*} to + the \SP{} node, append cursor to the \SP{} node + \item{\verb+sp[^*#$][!@over='1']/cursor+}\\ %$ + set \verb+over='1'+ in the \SP{} node + \item{\verb+sp[^*#$][@over='1']/cursor+}\\ %$ + error + \item{\verb+cursor+}\\ + error ? +\end{description} +% do_superscript: +% CASE: g[^#]/cursor +% create sp node. create g node, replace cursor with sp, append g to sp, append cursor to sp +% CASE: g[*#]/cursor +% create sp node, replace * with sp, append * to sp, append cursor to sp +% CASE: sp[^*#$][!@over='1']/cursor +% set over='1' in sp node +% CASE: sp[^*#$][@over='1']/cursor +% error +% ELSE: +% error ? + +\paragraph{Subscript:} $\downarrow$ + +\begin{description} + \item{\verb+[^#]/cursor+}\\ + create a \SB{} node, create a \G{} node, replace the cursor with the \SB{} node, + append the \G{} node as first child of the \SB{} node, append the cursor as last + child of the \SB{} node + \item{\verb+[*#]/cursor+}\\ + create a \SB{} node, replace \texttt{*} with the \SB{} node, append \texttt{*} to + the \SB{} node, append cursor to the \SB{} node + \item{\verb+sb[^*#$][!@under='1']/cursor+}\\ %$ + set \verb+under='1'+ in the \SB{} node + \item{\verb+sb[^*#$][@under='1']/cursor+}\\ %$ + error + \item{\verb+cursor+}\\ + error ? +\end{description} +% do_subscript: +% CASE: g[^#]/cursor +% create sb node. create g node, replace cursor with sb, append g to sb, append cursor to sb +% CASE: g[*#]/cursor +% create sb node, replace * with sb, append * to sb, append cursor to sb +% CASE: sb[^*#$][!@under='1']/cursor +% set over='1' in sb node +% CASE: sb[^*#$][@under='1']/cursor +% error +% ELSE: +% error ? + +\paragraph{Ignorable space:} $\square$ + +% do_ignorable_space: +% do nothing? + +\paragraph{Space:} $s$ + +\begin{description} + \item{\verb+cursor+}\\ + create \SNODE{} node, replace cursor with the \SNODE{} node, append + $\tadvance$ after \SNODE{} node +\end{description} + +% do_space +% create s node, replace cursor with s, append \advance after s + +\paragraph{Identifier:} $i(v)$ + +\begin{description} + \item{\verb+cursor+}\\ + create an \INODE{}, set \verb+value=+$v$ in the \INODE{}, replace + cursor with \INODE{}, append $\tadvance$ after the \INODE{} node +\end{description} + +% do_identifier +% create i node, replace cursor with i, append \advance after i + +\paragraph{Number:} $n(v)$ + +\begin{description} + \item{\verb+cursor+}\\ + create an \NNODE{}, set \verb+value=+$v$ in the \NNODE{}, replace + cursor with \NNODE{}, append $\tadvance$ after the \NNODE{} node +\end{description} + +% do_number +% create n node, replace cursor with n, append \advance after n + +\paragraph{Apostrophe:} $o({}')$ + +\begin{description} + \item{\verb+[(sp[*#$]/g[o[@name='prime']$])#]/cursor+}\\ + create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{}, + append the \ONODE{} to the innermost \G{} node + \item{\verb+[(sb[^sp[^*#$]/g[o[@name='prime']]$])#]/cursor+}\\ + create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{}, + append the \ONODE{} to the innermost \G{} node + \item{\verb+[*#]/cursor+}\\ + create a \ONODE{} node, set \verb+name='prime'+ in the \ONODE{}, + create a \SP{} node, create a \G{} node, replace \texttt{*} with \SP{} node, + append the new \G{} node to the \SP{} node, append the \ONODE{} + node to the new \G{} node + \item{\verb+[^#]/cursor+}\\ + error? + \item{\verb+cursor+}\\ + cursor is not in a group, error? +\end{description} + +% do_apostrophe +% CASE: g[(sp[^*#$]/g[o[@name='prime']$])#]/cursor +% append a new o[@name='prime'] node to the inner g node +% CASE: g[(sb[^sp[^*#$]/g[o[@name='prime']]$])#]/cursor +% append a new o[@name='prime'] node to the inner g node +% CASE: g[*#]/cursor +% create sp node, create g node, replace * with sp, append * to sp, append g to sp, +% append a new o[@name='prime'[ node to the new g node +% CASE: g[^#]/cursor +% error? +% ELSE: +% cursor is not in a group, error? + +\paragraph{Other:} $o(v)$ + +create an \ONODE{}, set \verb+value=+$v$ in the \ONODE{}, replace +cursor with \ONODE{}, append $\tadvance$ after the \ONODE{} node + +% do_other +% create o node, replace cursor with o, append \advance after o + +\paragraph{Active:} $\sim$ + +% do_active: +% ignored ??? + +\paragraph{Comment:} $\%$ + +% do_comment: +% ignored ??? + +\paragraph{Begin Environment:} $c(\mathtt{begin})\langle\alpha_1,\dots,\alpha_n\rangle$ + +\paragraph{End Environment:} $c(\mathtt{end})\langle\rangle$ + +\paragraph{Left Delimiter:} $c(\mathtt{left})\langle\alpha\rangle$ + +\paragraph{Right Delimiter:} $c(\mathtt{right})\langle\alpha\rangle$ + +\paragraph{Carriage-Return:} $c(\mathtt{cr})\langle\rangle$ + +\begin{description} + \item{\verb+row/cell/g/cursor+}\\ + create a \ROW{} node, create a \CELL{} node, create a \G{} + node, append the cursor to the new \G{} node, append the new \G{} + node to the new \CELL{} node, append the new \CELL{} node to the + new \ROW{} node, insert the new \ROW{} node after the old \ROW{} node + \item{\verb+cursor+}\\ + ignored? +\end{description} + +% do_cr: +% CASE: row/cell/g/cursor +% create row node, create cell node, create g node, +% append cursor to g, append g to cell, append cell to row, +% insert new row after old row +% ELSE: +% ignored ??? + +\paragraph{Macro:} $c(v)\langle\alpha_1,\dots,\alpha_n\rangle$ + +\begin{description} + \item{\verb+/cursor+}\\ + create a \CNODE{} node with the children corresponding to the pattern + $\tmap{\alpha_1}$,\dots,$\tmap{\alpha_n}$, replace the cursor with + the new \CNODE{} node. put $\tnext$ as the first child of the new + \CNODE{} node + + \item{\verb+*/cursor+}\\ + create a \CNODE{} node with the children corresponding to the pattern + $\tmap{\alpha_1}$,\dots,$\tmap{\alpha_n}$, replace the cursor with + the new \CNODE{} node, put $\tnext$ as the first child of the new + \CNODE{} node. If $n\ne0$ emit a warning (the macro has arguments but + but the context wouldn't normally allow them to be entered) +\end{description} + +% do_macro: +% CASE: g/cursor +% create a c node with children corresponding to the pattern of the macro +% append \nextparam as first child of the macro + +\section{Left Drop Rules} + +\paragraph{Normal Left Drop:} $\NLDROP$ + +\begin{description} + + \item{\verb+cursor+}\\ + replace the cursor with the $\NLDROP$. + +\end{description} + +\paragraph{Special Left Drop:} $\SLDROP$ + +\begin{description} + + \item{\verb+cursor+}\\ + replace the cursor with the $\SLDROP$. + +\end{description} + +\section{Right Drop Rules} + +\begin{description} + + \item{\verb+cursor+}\\ + replace the cursor with the $\RDROP$. + +\end{description} + +\section{$\varepsilon$-rules} + +\paragraph{Nromal Left Drop} + +\begin{description} + + \item{\verb+math/g[^#]/+$\NLDROP$}\\ + repalce the $\NLDROP$ with the cursor. + + %************************************************************************************** + %****************************** epsilon-rules with \NLDROP **************************** + %************************************************************************************** + + %************** \NLDROP has neither preceding nor following nodes ******************** + + \item{\verb+math[^#$]/+$\NLDROP$}\\ + replace the $\NLDROP$ with the cursor. + + \item{\verb+g[^#$]/+$\NLDROP$}\\ + replace the \G{} node with the $\NLDROP$. + + % this rule is overridden by the two ones below + \item{\verb+c/p[^#$]/+$\NLDROP$}\\ + remove the $\NLDROP$ and insert it before the \PNODE{} node. + + \item{\verb+c[p[@left-open='1'][*]#$]/p[@right-open='1'][^#$]/+$\NLDROP$}\\ + replace the \CNODE{} node with the content of the first \PNODE{} node and insert the $\NLDROP$ after this content + + \item{\verb+c[p[@left-open='1'][!*]#$]/p[@right-open='1'][^#$]/+$\NLDROP$}\\ + replace the \CNODE{} node with the $\NLDROP$. + + \item{\verb+c[^#][!p(*)]/+$\NLDROP$}\\ + replace the \CNODE{} node with the $\NLDROP$. + + \item{\verb+cell[^#$]/+$\NLDROP$}\\ + replace the cell with the $\NLDROP_n$. + + \item{\verb+table[^#$]/+$\NLDROP$}\\ + replace the \TABLE{} node with the $\NLDROP$. + + %************************* \NLDROP has at least one preceding node ********************* + + % general rules + + % this rule should also handles the case where the \NLDROP is the third (and last) child of a script. + \item{\verb+*[*#]/+$\NLDROP$}\\ + remove the $\NLDROP$ and append it as the last child of its ex preceding brother. + + % this rule overrides the one above + \item{\verb+*[(i|n|o|s|c[!*])#]/+$\NLDROP$}\\ + remove the $\NLDROP$ and replace the token with the $\NLDROP_n$. + + % special rules + + \item{\verb+[^*#$]+/$\NLDROP$}\\ + replace the script node with its first child and insert the $\NLDROP$ after it. + + % this rule overrides the one above. + \item{\verb+[^g[!@id][!*]#$]/+$\NLDROP$}\\ + replace the script with the cursor. + + % this rule overrides the one above + \item{\verb+*[sp[!@id][^*g[!@id][^o[@name='prime']++\verb+o[@name='prime']$]]#]/+$\NLDROP$}\\ + remove the last \ONODE{} node and replace the $\NLDROP$ with the cursor.%$\NLDROP_n$. + + \item{\verb+*[sp[!@id][^*g[!@id][^o[@name='prime']$]]#]/+$\NLDROP$}\\ + replace the script with its first child and replace the $\NLDROP$ with the cursor.%$\NLDROP_n$. + + \item{\verb+c[(i|n|o|s|c[!*])#]/+$\NLDROP$}\\ + move the $\NLDROP$ before the delimiter. + + % this rule is true for both right-open and parameterized macros. + \item{\verb+c[p#]/+$\NLDROP$}\\ + move the $\NLDROP$ into the \PNODE{} node. + + %**************** \NLDROP has no preceding nodes, but has following nodes ************** + + % general rule + \item{\verb+*[^#*]/+$\NLDROP$}\\ + remove the $\NLDROP$ and insert it before its parent. + + % special rules + + % this rule is applicable to all macros. + \item{\verb+c[^#][p[*]]/+$\NLDROP$}\\ + remove the $\NLDROP$ and insert it before the \CNODE{} node. + +\end{description} + +\paragraph{Special Left Drop} + +\begin{description} + + %******************************************************************************************************** + %************************************ epsilon-rules with \SLDROP **************************************** + %******************************************************************************************************** + + \item{\verb+math/+$\SLDROP$}\\ + replace the $\SLDROP$ with the cursor. + + \item{\verb+math/g[^#]/+$\NLDROP$}\\ + replace the $\NLDROP$ with the cursor. + + %************************ \SLDROP has neither preceding nor following nodes ***************************** + + \item{\verb+g[^#$]/+$\SLDROP$}\\ + replace the \G{} node with the cursor. + + \item{\verb+c[p[@left-open='1'][*]#$]/p[@right-open='1'][^#$]/+$\SLDROP$}\\ + replace the \CNODE{} node with the content of the first \PNODE{} node and insert the cursor after this content + + \item{\verb+c[p[@left-open='1'][!*]#$]/p[@right-open='1'][^#$]/+$\SLDROP$}\\ + replace the \CNODE{} node with the cursor. + + \item{\verb+c/p[^#$]/+$\SLDROP$}\\ + remove the $\SLDROP$ and insert it before the \PNODE{} node. + + \item{\verb+c[^#][!p(*)]/+$\SLDROP$}\\ + replace the \CNODE{} node with the cursor. + + \item{\verb+cell[^#$]/+$\SLDROP$}\\ + replace the cell with the $\NLDROP_n$. + + \item{\verb+table[^#$]/+$\SLDROP$}\\ + replace the \TABLE{} node with the cursor. + + %*********************** \SLDROP has at least one preceding node *********************************** + + \item{\verb+*[sp[!@id][^*g[!@id][^o[@name='prime']++\verb+o[@name='prime']$]]#]/+$\SLDROP$}\\ + remove the last \ONODE{} node and replace the $\SLDROP$ with the cursor. + + \item{\verb+*[sp[!@id][^*g[!@id][^o[@name='prime']$]]#]/+$\SLDROP$}\\ + replace the script with its first child and replace the $\SLDROP$ with the cursor.%$\NLDROP_n$. + + \item{\verb+[^g[!@id][!*]#$]/+$\SLDROP$}\\ + replace the script with the cursor. + + % this rule is overridden by the three rules above. + \item{\verb+[^*#$]+/$\SLDROP$}\\ + replace the script node with its first child and insert the cursor after it. + + \item{\verb+c[(i|n|o|s|c[!*])#]/+$\SLDROP$}\\ + remove the $\SLDROP$ and insert the cursor before the delimiter. + + \item{\verb+c[p#(i|n|o|s|c[!*])]/+$\SLDROP$}\\ + remove the $\SLDROP$ and insert the cursor into the \PNODE{} node. + + \item{\verb+c[p[@right-open='1']#]+}\\ + remove the $\SLDROP$ and append the curor as last child of the \PNODE{} node. + + % this rule is overridden by the two ones above. + \item{\verb+c[p#]/+$\SLDROP$}\\ + move the $\SLDROP$ into the \PNODE{} node. + + \item{\verb+*[(i|n|o|s|c[!*])#]/+$\SLDROP$}\\ + remove the $\SLDROP$ and replace the token with the cursor. + + \item{\verb+*[table#]/+$\SLDROP$}\\ + remove the $\SLDROP$ and append the $\NLDROP_n$ as the last child of the \TABLE{} node. + + \item{\verb+*[c#]/+$\SLDROP$}\\ + move the $\SLDROP$ into the \CNODE{} node. + + \item{\verb+*[g#]/+$\SLDROP$}\\ + remove the $\SLDROP$ and append the cursor as the last child of the \G{} node. + + %********** \SLDROP has no preceding node, but has following ones ************** + + \item{\verb+c[^#p][p(*)]/+$\SLDROP$}\\ + remove the $\SLDROP$ and insert the cursor before the \CNODE{} node. + + % general rule + \item{\verb+*[^#*]/+$\SLDROP$}\\ + remove the $\SLDROP$ and insert the cursor before its parent. + +\end{description} + +\paragraph{Normalize Left Drop} + +\begin{description} + + %**************************************************************************************** + %***************************** epsilon-rules with \NLDROP_n ***************************** + %**************************************************************************************** + + \item{\verb+*[*#]/+$\NLDROP_n$}\\ + replace the $\NLDROP_n$ with the cursor. + + \item{\verb+row[cell#]/+$\NLDROP_n$}\\ + remove the $\NLDROP_n$ and append the cursor as the last child of the \CELL{} node. + + \item{\verb+row[^#$]/+$\NLDROP_n$}\\ + replace the \ROW{} node with the $\NLDROP_n$ + + \item{\verb+table[row#]/+$\NLDROP_n$}\\ + remove the $\NLDROP_n$ and append it as last child of the \ROW{} node. + + \item{\verb+table[^#$]/+$\NLDROP_n$}\\ + replace the \TABLE{} with the cursor.%$\NLDROP_n$. + + \item{\verb+g[@id][^#$]/+$\NLDROP_n$}\\ + replace the \G{} node with the $\NLDROP_n$. + + \item{$\NLDROP_n$}\\ + replace the $\NLDROP_n$ with the cursor. + +\end{description} + +\paragraph{Right Drop} + +\begin{description} + + %************************* \RDROP has at least a following node **************************************** + + \item{\verb+c[#(i|n|o|s|c[!*])]/+$\RDROP$}\\ + remove the $\RDROP$ and append it after the delimiter + + \item{\verb+*[#(i|n|o|s|c[!*])]/+$\RDROP$}\\ + remove the token and replace the $\RDROP$ with the cursor $\RDROP_n$. + + % this rule is overridden by those ones above. + \item{\verb+*[#*]/+$\RDROP$}\\ + remove the $\RDROP$ and append it as the first child of the following node. + + %************************** \RDROP has neither following nor preceding nodes ****************************** + + \item{\verb+c[#$][!p[*]]/+$\RDROP$}\\ + replace the \CNODE{} with the $\RDROP$. + + \item{\verb+p[^#$]/+$\RDROP$}\\ + move the $\RDROP$ after the \PNODE{} node. + + \item{\verb+g[^#$]/+$\RDROP$}\\ + replace the \G{} node with the $\RDROP$. + +\end{description} + +\paragraph{Normalize Right Drop} + +\begin{description} + + % at the moment it's the only rule, defined for this symbol. + \item{\verb+g[@id][^#$]/+$\RDROP_n$}\\ + replace the \G{} node with the $\RDROP_n$. + + \item{$\RDROP_n$}\\ + replace the $\RDROP$ with the cursor. + +\end{description} + +\paragraph{Advance} + +\begin{description} + \item{\verb+g/+$\tadvance$}\\ + replace $\tadvance$ with the cursor + + \item{\verb+p[#$]/+$\tadvance$}\\ %$ + put $\tadvance$ after the \PNODE{} node + + \item{\verb+c[#p]/+$\tadvance$} \\ + remove $\tadvance$, put the cursor as first child of the \PNODE{} node + + \item{\verb+c[#*]/+$\tadvance$} \\ %$ + replace $\tadvance$ with the cursor + + \item{\verb+c[#$]/+$\tadvance$} \\ %$ + move $\tadvance$ after the \CNODE{} node +\end{description} + +\paragraph{Next Parameter} + +\paragraph{Next Token} + +%% \begin{description} +%% \item{\verb+c[#p]/+$\tnext$} \\ +%% \end{description} + +% g[@id]/(c[#$][@right-open]/g[!@id][#$]/)+cursor } let p = cursor.parent() in remove; advance(p) + +% c/g[!@id]/cursor +% c/cursor +% */cursor { let g = new group in replace + +% g[@id][^#$]/cursor <= cursor.parent().replace(cursor) +% g[@id][^#$]/cursor <- cursor +% (!g[@id][^#$])[A#B]/(g[@id][^#$]/)+cursor <- (!g[@id][^#$])[A#B]/cursor + +\clearpage +\appendix +\section{Semantics of the Regular Context Language} + +\newcommand{\CSEM}[2]{\mathcal{C}\llbracket#1\rrbracket#2} +\newcommand{\QSEM}[2]{\mathcal{Q}\llbracket#1\rrbracket#2} +\newcommand{\TSEMUP}[2]{\mathcal{T}^\uparrow\llbracket#1\rrbracket#2} +\newcommand{\TSEMDOWN}[2]{\mathcal{T}_\downarrow\llbracket#1\rrbracket#2} +\newcommand{\NSEM}[2]{\mathcal{N}\llbracket#1\rrbracket#2} +\newcommand{\PSEM}[1]{\mathcal{P}\llbracket#1\rrbracket} +\newcommand{\LSEM}[2]{\mathcal{L}\llbracket#1\rrbracket#2} +\newcommand{\RSEM}[2]{\mathcal{R}\llbracket#1\rrbracket#2} +\newcommand{\FSEM}[2]{\mathcal{F}\llbracket#1\rrbracket(#2)} +\newcommand{\PARENT}[1]{\mathit{parent}(#1)} +\newcommand{\CHILDREN}[1]{\mathit{children}(#1)} +\newcommand{\CHILD}[1]{\mathit{child}(#1)} +\newcommand{\ANCESTORS}[1]{\mathit{ancestors}(#1)} +\newcommand{\DESCENDANTS}[1]{\mathit{descendants}(#1)} +\newcommand{\HASATTRIBUTE}[2]{\mathit{hasAttribute}(#1,#2)} +\newcommand{\HASNOATTRIBUTE}[2]{\mathit{hasNoAttribute}(#1,#2)} +\newcommand{\ATTRIBUTE}[2]{\mathit{attribute}(#1,#2)} +\newcommand{\ISELEMENT}[1]{\mathit{isElement}(#1)} +\newcommand{\NAME}[1]{\mathit{name}(#1)} +\newcommand{\PREV}[1]{\mathit{prev}(#1)} +\newcommand{\NEXT}[1]{\mathit{next}(#1)} +\newcommand{\PREDICATE}[1]{\mathit{predicate}(#1)} +\newcommand{\IFV}[3]{\begin{array}[t]{@{}l}\mathbf{if}~#1~\mathbf{then}\\\quad#2\\\mathbf{else}\\\quad#3\end{array}} +\newcommand{\IFH}[3]{\mathbf{if}~#1~\mathbf{then}~#2~\mathbf{else}~#3} +\newcommand{\TRUE}{\mathbf{true}} +\newcommand{\FALSE}{\mathbf{false}} +\newcommand{\FUN}[2]{\lambda#1.#2} +\newcommand{\LET}[3]{\mathbf{let}~#1=#2~\mathbf{in}~#3} +\newcommand{\REC}[2]{\mathbf{rec}~#1=#2} +\newcommand{\APPLY}[2]{(#1\;#2)} +\newcommand{\APPLYX}[3]{(#1\;#2\;#3)} +\newcommand{\AND}{\wedge} +\newcommand{\OR}{\vee} +\newcommand{\AAND}{\,\vec{\AND}\,} +\newcommand{\AOR}{\,\vec{\OR}\,} +\newcommand{\MATCH}[4]{\begin{array}[t]{@{}c@{~\to~}l@{}l@{}}\multicolumn{2}{@{}l@{}}{\mathbf{match}~#1~\mathbf{with}}\\\phantom{|}\quad\{#2\}\\|\quad\emptyset\end{array}} + +\[ +\begin{array}{rcl} + \CSEM{q}{x} &=& \{x_1\mid x_1\in\{x\} \wedge \QSEM{q}{x_1}\}\\ + \CSEM{..}{x} &=& \PARENT{x}\\ + \CSEM{/}{x} &=& \CHILDREN{x}\\ + \CSEM{c_1\;c_2}{x} &=& \CSEM{c_2}{\CSEM{c_1}{x}}\\ + \CSEM{(c)}{x} &=& \CSEM{c}{x}\\ + \CSEM{\{c:\alpha\}}{x} &=& \alpha(x,\CSEM{c}{x})\\ + \CSEM{c_1\&c_2}{x} &=& \CSEM{c_1}{x} \cap \CSEM{c_2}{x}\\ + \CSEM{c_1\mid c_2}{x} &=& \CSEM{c_1}{x} \cup \CSEM{c_2}{x}\\ + \CSEM{c+}{x} &=& \CSEM{c}{x} \cup \CSEM{c+}{\CSEM{c}{x}}\\ + \CSEM{c?}{x} &=& \{x\}\cup\CSEM{c}{x}\\ + \CSEM{c*}{x} &=& \CSEM{{c+}?}{x}\\[3ex] + \QSEM{c}{x} &=& \CSEM{c}{x}\ne\emptyset\\ + \QSEM{!c}{x} &=& \CSEM{c}{x}=\emptyset\\ + \QSEM{\langle*\rangle}{x} &=& \TRUE\\ + \QSEM{\langle n\rangle}{x} &=& \NAME{x}=n\\ + \QSEM{@n}{x} &=& \HASATTRIBUTE{x}{n}\\ + \QSEM{@n=v}{x} &=& \ATTRIBUTE{x}{n}=v\\ + \QSEM{[p_1\#p_2]}{x} &=& \LSEM{p_1}{\PREV{x}}\wedge\RSEM{p_2}{\NEXT{x}}\\[3ex] + \LSEM{}{\alpha} &=& \TRUE\\ + \LSEM{\cent}{\alpha} &=& \alpha=\emptyset\\ + \LSEM{p\;q}{\emptyset} &=& \FALSE\\ + \LSEM{p\;q}{\{x\}} &=& \QSEM{q}{x}\wedge\LSEM{p}{\PREV{x}}\\[3ex] + \RSEM{}{\alpha} &=& \TRUE\\ + \RSEM{\$}{\alpha} &=& \alpha=\emptyset\\ + \RSEM{q\;p}{\emptyset} &=& \FALSE\\ + \RSEM{q\;p}{\{x\}} &=& \QSEM{q}{x}\wedge\RSEM{p}{\NEXT{x}}\\[3ex] + \PREDICATE{q} &=& \TRUE\\ + \PREDICATE{..} &=& \FALSE\\ + \PREDICATE{/} &=& \FALSE\\ + \PREDICATE{c_1\;c_2} &=& \PREDICATE{c_1}\wedge\PREDICATE{c_2}\\ + \PREDICATE{(c)} &=& \PREDICATE{c}\\ + \PREDICATE{c_1\&c_2} &=& \PREDICATE{c_1}\wedge\PREDICATE{c_2}\\ + \PREDICATE{c_1\mid c_2} &=& \PREDICATE{c_1}\wedge\PREDICATE{c_2}\\ + \PREDICATE{c+} &=& \PREDICATE{c}\\ + \PREDICATE{c?} &=& \PREDICATE{c}\\ + \PREDICATE{c*} &=& \PREDICATE{c} +\end{array} +\] + +\[ +\begin{array}{rcl} + \PSEM{q} &=& \FUN{x}{\APPLY{\QSEM{q}{}}{x}} \\ + \PSEM{..} &=& \FUN{x}{\neg\APPLY{\mathit{null}}{\PARENT{x}}}\\ + \PSEM{/} &=& \FUN{x}{\neg\APPLY{\mathit{null}}{\CHILD{x}}}\\ + \PSEM{(c)} &=& \PSEM{c}\\ + \PSEM{\{c:\alpha\}} &=& \FUN{x}{\APPLY{\PSEM{c}}{x}\AAND\APPLY{\alpha}{x}}\\ + \PSEM{c_1\;c_2} &=& \IFV{\PREDICATE{c_1}}{\FUN{x}{(\PSEM{c_1}\;x)\wedge(\PSEM{c_2}\;x)}}{\FSEM{c_1}{\PSEM{c_2},\FUN{\_}{\FALSE}}}\\ + \PSEM{c_1\&c_2} &=& \IFV{\PREDICATE{c_1}\wedge\PREDICATE{c_2}}{\FUN{x}{(\PSEM{c_1}\;x)\wedge(\PSEM{c_2}\;x)}}{\FSEM{c_1\&c_2}{\FUN{\_}{\TRUE},\FUN{\_}{\FALSE}}}\\ + \PSEM{c_1\mid c_2} &=& \FUN{x}{(\PSEM{c_1}\;x)\vee(\PSEM{c_2}\;x)}\\ + \PSEM{c+} &=& \PSEM{c}\\ + \PSEM{c?} &=& \FUN{\_}{\TRUE}\\ + \PSEM{c*} &=& \FUN{\_}{\TRUE}\\[3ex] + \FSEM{q}{t,f} &=& \FUN{x}{(\APPLY{\PSEM{q}}{x}\AAND\APPLY{t}{x})\AOR\APPLY{f}{x}}\\ + \FSEM{..}{t,f} &=& \FUN{x}{\MATCH{\PARENT{x}}{y}{\APPLY{t}{y}}{\APPLY{f}{x}}}\\ +% \FSEM{/}{t,f} &=& \FUN{x}{(\vee_{y\in\CHILDREN{x}} \APPLY{t}{y})\AOR\APPLY{f}{x}}\\ + \FSEM{/}{t,f} &=& \FUN{x}{\APPLYX{\mathit{exists}}{t}{\CHILD{x}}\AOR\APPLY{f}{x}}\\ + \FSEM{(c)}{t,f} &=& \FSEM{c}{t,f}\\ + \FSEM{\{c:\alpha\}}{t,f} &=& \FSEM{c}{\FUN{x}{\PSEM{c}\AAND\APPLY{\alpha}{x}\AAND\APPLY{t}{x},f}}\\ + \FSEM{c_1\;c_2}{t,f} &=& \FUN{x}{\APPLY{\FSEM{c_1}{\FSEM{c_2}{t,\FUN{\_}{\APPLY{f}{x}}},f}}{x}}\\ + \FSEM{c_1\&c_2}{t,f} &=& \FUN{x}{\APPLY{\FSEM{c_1}{\FUN{y}{\APPLY{\FSEM{c_2}{\FUN{z}{(y=z)\AAND\APPLY{t}{z}},\FUN{\_}{\APPLY{f}{x}}}}{x}},f}}{x}}\\ + \FSEM{c_1\mid c_2}{t,f} &=& \FSEM{c_1}{t,\FSEM{c_2}{t,f}}\\ + \FSEM{c+}{t,f} &=& \FSEM{c}{\FSEM{c+}{t,t},f}\\ + \FSEM{c?}{t,f} &=& \FSEM{c}{t,t}\\ + \FSEM{c*}{t,f} &=& \FSEM{{c+}?}{t,f}\\[3ex] + \QSEM{c}{} &=& \PSEM{c}\\ + \QSEM{!c}{} &=& \FUN{x}{\neg\APPLY{\PSEM{c}}{x}}\\ + \QSEM{\langle*\rangle}{} &=& \FUN{\_}{\TRUE}\\ + \QSEM{\langle n\rangle}{} &=& \FUN{x}{\NAME{x}=n}\\ + \QSEM{@n}{} &=& \FUN{x}{\HASATTRIBUTE{x}{n}}\\ + \QSEM{@n=v}{} &=& \FUN{x}{\ATTRIBUTE{x}{n}=v}\\ + \QSEM{[p_1\#p_2]}{} &=& \FUN{x}{\APPLY{\LSEM{p_1}{}}{\PREV{x}}\wedge\APPLY{\RSEM{p_2}{}}{\NEXT{x}}}\\[3ex] + \LSEM{}{} &=& \FUN{\_}{\TRUE}\\ + \LSEM{\cent}{} &=& \mathit{null}\\ + \LSEM{p\;q}{} &=& \FUN{x}{\MATCH{x}{y}{\QSEM{q}{y}\AAND\APPLY{\LSEM{p}}{\PREV{y}}}{\FALSE}}\\ + \RSEM{}{} &=& \FUN{\_}{\TRUE}\\ + \RSEM{\$}{} &=& \mathit{null}\\ + \RSEM{p\;q}{} &=& \FUN{x}{\MATCH{x}{y}{\QSEM{q}{y}\AAND\APPLY{\RSEM{p}}{\NEXT{y}}}{\FALSE}}\\ + \mathit{null} &=& \FUN{x}{\MATCH{x}{\_}{\FALSE}{\TRUE}}\\ + \mathit{exists} &=& \FUN{t}{\REC{a}{\FUN{x}{\MATCH{x}{y}{\APPLY{t}{y}\AOR\APPLY{a}{\NEXT{x}}}{\FALSE}}}} +\end{array} +\] + + + +\end{document} diff --git a/DEVEL/mathml_editor/editex.pc.in b/DEVEL/mathml_editor/editex.pc.in new file mode 100644 index 000000000..9e2c91bf4 --- /dev/null +++ b/DEVEL/mathml_editor/editex.pc.in @@ -0,0 +1,19 @@ +# This is a comment +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datadir=@datadir@ + +pkgdatadir=${datadir}/editex +default_dictionary=${pkgdatadir}/dictionary-tex.xml +default_mathml_xsl=${pkgdatadir}/tml-mmlp.xsl +default_tex_xsl=${pkgdatadir}/tml-tex.xsl + +Name: EdiTeX +Description: An XML/MathML editor based on TeX/LaTeX syntax +Version: @VERSION@ +Requires: glib +Libs: -L${libdir} -leditex +Cflags: -I${includedir}/editex + diff --git a/DEVEL/mathml_editor/examples/.cvsignore b/DEVEL/mathml_editor/examples/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/mathml_editor/examples/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/mathml_editor/examples/Makefile.am b/DEVEL/mathml_editor/examples/Makefile.am new file mode 100644 index 000000000..8de82fb70 --- /dev/null +++ b/DEVEL/mathml_editor/examples/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = abs.tex big.tex diff --git a/DEVEL/mathml_editor/examples/abs.tex b/DEVEL/mathml_editor/examples/abs.tex new file mode 100644 index 000000000..6cd86a144 --- /dev/null +++ b/DEVEL/mathml_editor/examples/abs.tex @@ -0,0 +1 @@ +$|x|=\matrix{1&0\cr0&1}$ diff --git a/DEVEL/mathml_editor/examples/big.tex b/DEVEL/mathml_editor/examples/big.tex new file mode 100644 index 000000000..913a1a13c --- /dev/null +++ b/DEVEL/mathml_editor/examples/big.tex @@ -0,0 +1 @@ +$1+x+x^2+x^3+\cdots+x^n\over{\sqrt 1+y^{-1}+y^{-2}+y^{-3}+\cdots+y^{-m}}$ diff --git a/DEVEL/mathml_editor/ocaml/.cvsignore b/DEVEL/mathml_editor/ocaml/.cvsignore new file mode 100644 index 000000000..cf4c41a0a --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/.cvsignore @@ -0,0 +1 @@ +META Makefile Makefile.in *.cm[ioax] *.cmxa *.lo *.la .deps .libs diff --git a/DEVEL/mathml_editor/ocaml/.depend b/DEVEL/mathml_editor/ocaml/.depend new file mode 100644 index 000000000..ceb7476a9 --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/.depend @@ -0,0 +1,3 @@ +mathml_editor.cmo: i_mathml_editor.cmo mathml_editor.cmi +mathml_editor.cmx: i_mathml_editor.cmx mathml_editor.cmi +mathml_editor.cmi: i_mathml_editor.cmo diff --git a/DEVEL/mathml_editor/ocaml/META.in b/DEVEL/mathml_editor/ocaml/META.in new file mode 100644 index 000000000..f3fe7899a --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/META.in @@ -0,0 +1,6 @@ +requires="gdome2,gdome2-xslt" +version="@VERSION@" +archive(byte)="mlmathml-editor.cma" +archive(native)="mlmathml-editor.cmxa" +archive(byte,premethods)="i_mathml_editor.cmo mlmathml-editor.cma" +archive(native,premethods)="i_mathml_editor.cmx mlmathml-editor.cmxa" diff --git a/DEVEL/mathml_editor/ocaml/Makefile.am b/DEVEL/mathml_editor/ocaml/Makefile.am new file mode 100644 index 000000000..28982ba25 --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/Makefile.am @@ -0,0 +1,90 @@ +PKGNAME = mathml-editor +ARCHIVE = mlmathml-editor +REQUIRES = gdome2 gdome2-xslt +OCAMLFIND = @OCAMLFIND@ +OCAMLFLAGS = -I $(top_srcdir)/ocaml +OCAMLC = $(OCAMLFIND) @OCAMLC@ $(OCAMLFLAGS) -package "$(REQUIRES)" +OCAMLOPT = $(OCAMLFIND) @OCAMLOPT@ $(OCAMLFLAGS) -package "$(REQUIRES)" +OCAMLDEP = $(OCAMLFIND) @OCAMLDEP@ $(OCAMLFLAGS) -package "$(REQUIRES)" +if HAVE_SHAREDLIBS_COND +OCAMLMKLIBFLAGS = +else +OCAMLMKLIBFLAGS = -custom +endif +OCAMLMKLIB = @OCAMLMKLIB@ $(OCAMLMKLIBFLAGS) +DLL = dll$(ARCHIVE).so +OCAMLSTDLIBDIR = $(DESTDIR)/@OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = $(DESTDIR)/@OCAMLSTUBDIR@ +OCAMLINSTALLDIR = $(OCAMLSTDLIBDIR)/$(PKGNAME) +MODULES = i_mathml_editor mathml_editor +INIT = +CMI_S = $(MODULES:%=%.cmi) +CMO_S = $(MODULES:%=%.cmo) +CMX_S = $(MODULES:%=%.cmx) +O_S = ml_mathml_editor.o c_mathml_editor.o +LO_S = $(O_S:%.o=%.lo) +SHARED_LIBS = $(GMETADOM_LIBS) $(GDOMEXSLT_LIBS) -lmlgdome2-xslt -lmlgdome -lstdc++ -L$(top_builddir)/src/.libs/ -leditex +BYTE_STUFF = i_mathml_editor.cmi mathml_editor.cmi $(ARCHIVE).cma $(DLL) lib$(ARCHIVE).a +NATIVE_STUFF = $(ARCHIVE).cmxa $(ARCHIVE).a +BYTE_INSTALL_STUFF = $(BYTE_STUFF) META mathml_editor.mli +NATIVE_INSTALL_STUFF = $(NATIVE_STUFF) + +EXTRA_DIST = \ + META.in mathml_editor.ml mathml_editor.mli i_mathml_editor.ml \ + c_mathml_editor.h .depend + +if HAVE_OCAMLOPT_COND +noinst_DATA = $(BYTE_STUFF) $(NATIVE_STUFF) +else +noinst_DATA = $(BYTE_STUFF) +endif + +noinst_LTLIBRARIES = libmlmathml-editor.la +libmlmathml_editor_la_SOURCES = \ + c_mathml_editor.cc \ + ml_mathml_editor.c + +if HAVE_OCAMLOPT_COND +install-data-local: $(BYTE_INSTALL_STUFF) $(NATIVE_INSTALL_STUFF) +else +install-data-local: $(BYTE_INSTALL_STUFF) +endif + $(mkinstalldirs) $(OCAMLSTDLIBDIR) $(OCAMLSTUBDIR) + chmod -x $(DLL) + $(OCAMLFIND) install -destdir $(OCAMLSTDLIBDIR) $(PKGNAME) $^ + ln -fs $(DLL) $(OCAMLSTUBDIR)/lib$(ARCHIVE).so + +CLEANFILES = \ + $(ARCHIVE).{cma,cmxa,a} $(CMI_S) $(CMO_S) $(CMX_S) ml_mathml_editor.o \ + $(DLL) $(INIT).cm[iox] libmlmathml-editor.a + +INCLUDES = \ + $(GDOME_CFLAGS) $(MLGDOME_CFLAGS) \ + $(GMETADOM_CFLAGS) $(GDOMEXSLT_CFLAGS) \ + -I$(top_srcdir)/src + +$(ARCHIVE).cma: $(CMO_S) + $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMO_S) $(SHARED_LIBS) + +$(ARCHIVE).cmxa: $(CMX_S) + $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(CMX_S) $(SHARED_LIBS) + +$(DLL) $(ARCHIVE).a: $(O_S) + $(OCAMLMKLIB) -o $(ARCHIVE) -L@OCAMLSTUBDIR@ $(SHARED_LIBS) $(O_S:%.o=.libs/%.o) + +%.cmi: %.mli + $(OCAMLC) -c $< +%.cmo %.cmi: %.ml + $(OCAMLC) -c $< +%.cmx: %.ml %.cmi + $(OCAMLOPT) -c $< + +i_mathml_editor.cmo: i_mathml_editor.ml + $(OCAMLC) -c $< +i_mathml_editor.cmx: i_mathml_editor.ml + $(OCAMLOPT) -c $< + +depend: *.ml + $(OCAMLDEP) *.ml *.mli >.depend +include .depend + diff --git a/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc b/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc new file mode 100644 index 000000000..25759823b --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc @@ -0,0 +1,224 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include "ALogger.hh" +#include "TDictionary.hh" +#include "CMathMLFactoryXSLT.hh" +#include "TPushLexer.hh" +#include "LPushLexer.hh" +#include "TPushParser.hh" + +class CCallbackLogger : public ALogger +{ +public: + CCallbackLogger(void (*)(int, const char*, void*), void*); + virtual ~CCallbackLogger() { }; + +protected: + virtual void message(Level, const std::string&); + +private: + void (*callback)(int, const char*, void*); + void* user_data; +}; + +CCallbackLogger::CCallbackLogger(void (*cb)(int, const char*, void*), void* data) : callback(cb), user_data(data) +{ + assert(callback); +} + +void +CCallbackLogger::message(Level l, const std::string& s) +{ + assert(callback); + callback(l, s.c_str(), user_data); +} + +struct Editor +{ + Editor(const char*, const char*, const char*, void (*)(int, const char*, void*), void*, bool); + ~Editor(); + + ALogger* logger; + TDictionary* dictionary; + DOMX::XSLTStylesheet* tml_mml; + DOMX::XSLTStylesheet* tml_tex; + AMathMLFactory* factory; + TPushParser* parser; + APushLexer* lexer; +}; + +Editor::Editor(const char* dict_uri, const char* mml_uri, const char* tex_uri, + void (*cb)(int, const char*, void*), void* data, bool alt) +{ + assert(dict_uri); + assert(mml_uri); + assert(tex_uri); + assert(cb); + logger = new CCallbackLogger(cb, data); + dictionary = new TDictionary(*logger); + dictionary->load(dict_uri); + DOM::DOMImplementation di; + DOM::Document mml = di.createDocumentFromURI(mml_uri); + DOM::Document tex = di.createDocumentFromURI(tex_uri); + tml_mml = new DOMX::XSLTStylesheet(mml); + tml_tex = new DOMX::XSLTStylesheet(tex); + factory = new CMathMLFactoryXSLT(*logger, *tml_mml); + parser = new TPushParser(*logger, *factory, *dictionary); + if (alt) lexer = new LPushLexer(*logger, *parser); + else lexer = new TPushLexer(*logger, *parser); +} + +Editor::~Editor() +{ + delete lexer; + delete parser; + delete factory; + delete tml_tex; + delete tml_mml; + delete dictionary; + delete logger; +} + +extern "C" const char* +c_mathml_editor_get_default_dictionary_path() +{ + return TDictionary::getDefaultDictionaryPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_mathml_stylesheet_path() +{ + return AMathMLFactory::getDefaultMathMLStylesheetPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_tex_stylesheet_path() +{ + return AMathMLFactory::getDefaultTeXStylesheetPath().c_str(); +} + +extern "C" Editor* +c_mathml_editor_new(bool alt, + const char* dictionary_uri, + const char* tml_mml_uri, + const char* tml_tex_uri, + void (*log_message_cb)(int, const char*, void*), + void* user_data) +{ + return new Editor(dictionary_uri, tml_mml_uri, tml_tex_uri, log_message_cb, user_data, alt); +} + +extern "C" void +c_mathml_editor_destroy(Editor* editor) +{ + assert(editor); + delete editor; +} + +extern "C" int +c_mathml_editor_freeze(Editor* editor) +{ + assert(editor); + return editor->parser->freeze(); +} + +extern "C" int +c_mathml_editor_thaw(Editor* editor) +{ + assert(editor); + return editor->parser->thaw(); +} + +extern "C" void +c_mathml_editor_push(Editor* editor, char ch) +{ + assert(editor); + editor->lexer->push(ch); +} + +extern "C" void +c_mathml_editor_drop(Editor* editor, int alt) +{ + assert(editor); + editor->lexer->drop(alt != 0); +} + +extern "C" int +c_mathml_editor_cursor_hide(Editor* editor) +{ + assert(editor); + return editor->parser->hideCursor(); +} + +extern "C" int +c_mathml_editor_cursor_show(Editor* editor) +{ + assert(editor); + return editor->parser->showCursor(); +} + +extern "C" char* +c_mathml_editor_get_tex(const Editor* editor) +{ + assert(editor); + DOM::Document res = editor->tml_tex->apply(editor->parser->document()); + assert(res); + res.normalize(); + assert(res.get_firstChild() && res.get_firstChild().get_nodeName() == "#text"); + return strdup(std::string(res.get_firstChild().get_nodeValue()).c_str()); +} + +extern "C" void +c_mathml_editor_reset(Editor* editor) +{ + assert(editor); + editor->lexer->reset(); + editor->parser->reset(); +} + +extern "C" GdomeDocument* +c_mathml_editor_get_tml(const Editor* editor) +{ + assert(editor); + GdomeNode* n = editor->parser->document().cloneNode(true).gdome_object(); + GdomeDocument* doc = gdome_cast_doc(n); + assert(n && doc); + return doc; +} + +extern "C" GdomeDocument* +c_mathml_editor_get_mml(const Editor* editor) +{ + assert(editor); + GdomeNode* n = editor->factory->document().gdome_object(); + GdomeDocument* doc = gdome_cast_doc(n); + assert(n && doc); + return doc; +} + diff --git a/DEVEL/mathml_editor/ocaml/c_mathml_editor.h b/DEVEL/mathml_editor/ocaml/c_mathml_editor.h new file mode 100644 index 000000000..cb01155ad --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/c_mathml_editor.h @@ -0,0 +1,49 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __c_mathml_editor_h__ +#define __c_mathml_editor_h__ + +#include + +typedef struct Editor Editor; + +const char* c_mathml_editor_get_default_dictionary_path(void); +const char* c_mathml_editor_get_default_mathml_stylesheet_path(void); +const char* c_mathml_editor_get_default_tex_stylesheet_path(void); +Editor* c_mathml_editor_new(int, const char*, const char*, const char*, void (*)(int, const char*, void*), void*); +void c_mathml_editor_destroy(Editor*); +int c_mathml_editor_freeze(Editor*); +int c_mathml_editor_thaw(Editor*); +void c_mathml_editor_reset(Editor*); +void c_mathml_editor_push(Editor*, char); +void c_mathml_editor_drop(Editor*, int); +int c_mathml_editor_cursor_hide(Editor*); +int c_mathml_editor_cursor_show(Editor*); +char* c_mathml_editor_get_tex(const Editor*); +GdomeDocument* c_mathml_editor_get_tml(const Editor*); +GdomeDocument* c_mathml_editor_get_mml(const Editor*); + +#endif /* __c_mathml_editor_h__ */ diff --git a/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml b/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml new file mode 100644 index 000000000..d865898d6 --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/i_mathml_editor.ml @@ -0,0 +1,76 @@ +(* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + *) + +type t + +external get_default_dictionary_path : unit -> string + = "ml_mathml_editor_get_default_dictionary_path" + +external get_default_mathml_stylesheet_path : unit -> string + = "ml_mathml_editor_get_default_mathml_stylesheet_path" + +external get_default_tex_stylesheet_path : unit -> string + = "ml_mathml_editor_get_default_tex_stylesheet_path" + +external raw_create : + alt_lexer:bool -> + dictionary_uri: string -> + mml_uri: string -> + tml_uri: string -> + log:(int -> string -> unit) -> + t + = "ml_mathml_editor_new" +let create ?(alt_lexer=false) = raw_create ~alt_lexer + +external freeze : editor:t -> bool + = "ml_mathml_editor_freeze" + +external thaw : editor:t -> bool + = "ml_mathml_editor_thaw" + +external reset : editor:t -> unit + = "ml_mathml_editor_reset" + +external push : editor:t -> ch:char -> unit + = "ml_mathml_editor_push" + +external drop : editor:t -> alt:bool -> unit + = "ml_mathml_editor_drop" + +external cursor_hide : editor:t -> unit + = "ml_mathml_editor_cursor_hide" + +external cursor_show : editor:t -> unit + = "ml_mathml_editor_cursor_show" + +external get_tex : editor:t -> string + = "ml_mathml_editor_get_tex" + +external get_tml : editor:t -> TDocument.t + = "ml_mathml_editor_get_tml" + +external get_mml : editor:t -> TDocument.t + = "ml_mathml_editor_get_mml" + diff --git a/DEVEL/mathml_editor/ocaml/mathml_editor.ml b/DEVEL/mathml_editor/ocaml/mathml_editor.ml new file mode 100644 index 000000000..a49ea436e --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/mathml_editor.ml @@ -0,0 +1,70 @@ +(* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + *) + +let default_dictionary_path = I_mathml_editor.get_default_dictionary_path () +;; + +let default_mathml_stylesheet_path = I_mathml_editor.get_default_mathml_stylesheet_path () +;; + +let default_tex_stylesheet_path = I_mathml_editor.get_default_tex_stylesheet_path () +;; + +let create ?(alt_lexer=false) ~dictionary_uri ~mml_uri ~tml_uri ~log = + I_mathml_editor.create ~alt_lexer ~dictionary_uri ~mml_uri ~tml_uri ~log +;; + +let freeze = I_mathml_editor.freeze +;; + +let thaw = I_mathml_editor.thaw +;; + +let reset = I_mathml_editor.reset +;; + +let push = I_mathml_editor.push +;; + +let drop = I_mathml_editor.drop +;; + +let cursor_hide = I_mathml_editor.cursor_hide +;; + +let cursor_show = I_mathml_editor.cursor_show +;; + +let get_tex = I_mathml_editor.get_tex +;; + +let get_tml ~editor = + new Gdome.document (I_mathml_editor.get_tml ~editor) +;; + +let get_mml ~editor = + new Gdome.document (I_mathml_editor.get_mml ~editor) +;; + diff --git a/DEVEL/mathml_editor/ocaml/mathml_editor.mli b/DEVEL/mathml_editor/ocaml/mathml_editor.mli new file mode 100644 index 000000000..aa0278522 --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/mathml_editor.mli @@ -0,0 +1,50 @@ +(* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + *) + +val default_dictionary_path : string +val default_mathml_stylesheet_path : string +val default_tex_stylesheet_path : string + +val create : + ?alt_lexer:bool -> + dictionary_uri: string -> + mml_uri: string -> + tml_uri: string -> + log:(int -> string -> unit) -> I_mathml_editor.t + +val freeze : editor:I_mathml_editor.t -> bool +val thaw : editor:I_mathml_editor.t -> bool + +val reset : editor:I_mathml_editor.t -> unit +val push : editor:I_mathml_editor.t -> ch:char -> unit +val drop : editor:I_mathml_editor.t -> alt:bool -> unit + +val cursor_hide : editor:I_mathml_editor.t -> unit +val cursor_show : editor:I_mathml_editor.t -> unit + +val get_tex : editor:I_mathml_editor.t -> string +val get_tml : editor:I_mathml_editor.t -> Gdome.document +val get_mml : editor:I_mathml_editor.t -> Gdome.document + diff --git a/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c b/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c new file mode 100644 index 000000000..c74dfd01c --- /dev/null +++ b/DEVEL/mathml_editor/ocaml/ml_mathml_editor.c @@ -0,0 +1,210 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include +#include +#include + +#include "mlgdomevalue.h" + +#include "c_mathml_editor.h" + +typedef struct +{ + Editor* c_editor; + value callback; +} ml_Editor; + +ml_Editor* +Editor_val(value v) +{ + ml_Editor* editor = *((ml_Editor**) Data_custom_val(v)); + assert(editor != NULL); + return editor; +} + +static void +ml_mathml_editor_finalize(value v) +{ + ml_Editor* editor = Editor_val(v); + assert(editor); + + remove_global_root(&editor->callback); + c_mathml_editor_destroy(editor->c_editor); + free(editor); +} + +static void +ml_mathml_editor_log_callback(int level, const char* msg, void* user_data) +{ + ml_Editor* ml_editor = (ml_Editor*) user_data; + assert(ml_editor); + callback2(ml_editor->callback, Val_int(level), copy_string(msg)); +} + +value +ml_mathml_editor_get_default_dictionary_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_dictionary_path())); +} + +value +ml_mathml_editor_get_default_mathml_stylesheet_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_mathml_stylesheet_path())); +} + +value +ml_mathml_editor_get_default_tex_stylesheet_path(value unit) +{ + CAMLparam1(unit); + CAMLreturn(copy_string(c_mathml_editor_get_default_tex_stylesheet_path())); +} + +value +ml_mathml_editor_new(value alt, + value dictionary_uri, + value tml_mml_uri, + value tml_tex_uri, + value log_message_cb) +{ + static struct custom_operations ops = + { + "HELM/MathML Editor", + ml_mathml_editor_finalize, + custom_compare_default, + custom_hash_default, + custom_serialize_default, + custom_deserialize_default + }; + + value v = alloc_custom(&ops, sizeof(ml_Editor*), 0, 1); + ml_Editor** ml_editor_ref = (ml_Editor**) Data_custom_val(v); + ml_Editor* ml_editor = *ml_editor_ref = malloc(sizeof(ml_Editor)); + ml_editor->c_editor = c_mathml_editor_new(Bool_val(alt), + String_val(dictionary_uri), + String_val(tml_mml_uri), + String_val(tml_tex_uri), + ml_mathml_editor_log_callback, + (void*) ml_editor); + ml_editor->callback = log_message_cb; + register_global_root(&ml_editor->callback); + + return v; +} + +value +ml_mathml_editor_freeze(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + CAMLreturn(Val_bool(c_mathml_editor_freeze(editor->c_editor))); +} + +value +ml_mathml_editor_thaw(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + CAMLreturn(Val_bool(c_mathml_editor_thaw(editor->c_editor))); +} + +value +ml_mathml_editor_push(value v, value ch) +{ + CAMLparam2(v, ch); + ml_Editor* editor = Editor_val(v); + c_mathml_editor_push(editor->c_editor, Int_val(ch)); + CAMLreturn(Val_unit); +} + +value +ml_mathml_editor_drop(value v, value alt) +{ + CAMLparam2(v, alt); + ml_Editor* editor = Editor_val(v); + c_mathml_editor_drop(editor->c_editor, Bool_val(alt)); + CAMLreturn(Val_unit); +} + +value +ml_mathml_editor_cursor_hide(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + CAMLreturn(Val_bool(c_mathml_editor_cursor_hide(editor->c_editor))); +} + +value +ml_mathml_editor_cursor_show(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + CAMLreturn(Val_bool(c_mathml_editor_cursor_show(editor->c_editor))); +} + +value +ml_mathml_editor_get_tex(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + char* res = c_mathml_editor_get_tex(editor->c_editor); + CAMLlocal1(ml_res); + ml_res = copy_string(res); + free(res); + CAMLreturn(ml_res); +} + +value +ml_mathml_editor_reset(value v, value s) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + c_mathml_editor_reset(editor->c_editor); + CAMLreturn(Val_unit); +} + +value +ml_mathml_editor_get_tml(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + GdomeDocument* doc = c_mathml_editor_get_tml(editor->c_editor); + CAMLreturn(Val_Document(doc)); +} + +value +ml_mathml_editor_get_mml(value v) +{ + CAMLparam1(v); + ml_Editor* editor = Editor_val(v); + GdomeDocument* doc = c_mathml_editor_get_mml(editor->c_editor); + CAMLreturn(Val_Document(doc)); +} + diff --git a/DEVEL/mathml_editor/src/.cvsignore b/DEVEL/mathml_editor/src/.cvsignore new file mode 100644 index 000000000..332956c5c --- /dev/null +++ b/DEVEL/mathml_editor/src/.cvsignore @@ -0,0 +1,9 @@ +*~ +*.lo +*.o +*.la +.deps +.libs +Makefile +Makefile.in +config.dirs diff --git a/DEVEL/mathml_editor/src/ALogger.hh b/DEVEL/mathml_editor/src/ALogger.hh new file mode 100644 index 000000000..7843dbc88 --- /dev/null +++ b/DEVEL/mathml_editor/src/ALogger.hh @@ -0,0 +1,53 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __ALogger_hh__ +#define __ALogger_hh__ + +#include + +class ALogger +{ +public: + enum Level { Error, Warning, Info, Debug }; + + ALogger(void) { level = Error; } + virtual ~ALogger() { } + void debug(const std::string& msg) { if (level >= Debug) message(Debug, msg); } + void info(const std::string& msg) { if (level >= Info) message(Info, msg); } + void warning(const std::string& msg) { if (level >= Warning) message(Warning, msg); } + void error(const std::string& msg) { if (level >= Error) message(Error, msg); } + + Level verbosity(void) const { return level; } + void verbosity(Level lvl) { level = lvl; } + +protected: + virtual void message(Level, const std::string&) = 0; + +private: + Level level; +}; + +#endif // __ALogger_hh__ diff --git a/DEVEL/mathml_editor/src/AMathMLConsumer.hh b/DEVEL/mathml_editor/src/AMathMLConsumer.hh new file mode 100644 index 000000000..ee5e12690 --- /dev/null +++ b/DEVEL/mathml_editor/src/AMathMLConsumer.hh @@ -0,0 +1,38 @@ + +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __AMathMLConsumer_hh__ +#define __AMathMLConsumer_hh__ + +class AMathMLConsumer +{ +public: + AMathMLConsumer(void) { }; + virtual ~AMathMLConsumer() { }; + virtual void documentModified(const DOM::Document&) = 0; +}; + +#endif // __AMathMLConsumer_hh__ diff --git a/DEVEL/mathml_editor/src/AMathMLFactory.cc b/DEVEL/mathml_editor/src/AMathMLFactory.cc new file mode 100644 index 000000000..b9826352b --- /dev/null +++ b/DEVEL/mathml_editor/src/AMathMLFactory.cc @@ -0,0 +1,42 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include "config.dirs" +#include "AMathMLFactory.hh" + +std::string +AMathMLFactory::getDefaultMathMLStylesheetPath() +{ + return PKGDATADIR"/tml-mmlp.xsl"; +} + +std::string +AMathMLFactory::getDefaultTeXStylesheetPath() +{ + return PKGDATADIR"/tml-tex.xsl"; +} + diff --git a/DEVEL/mathml_editor/src/AMathMLFactory.hh b/DEVEL/mathml_editor/src/AMathMLFactory.hh new file mode 100644 index 000000000..f53b56408 --- /dev/null +++ b/DEVEL/mathml_editor/src/AMathMLFactory.hh @@ -0,0 +1,47 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __AMathMLFactory_hh__ +#define __AMathMLFactory_hh__ + +#include "dom.hh" + +class AMathMLFactory +{ +public: + AMathMLFactory(class ALogger& l) : logger(l) { }; + virtual ~AMathMLFactory() { }; + + static std::string getDefaultMathMLStylesheetPath(void); + static std::string getDefaultTeXStylesheetPath(void); + + virtual void documentModified(class TDocument&) = 0; + virtual DOM::Document document(void) const = 0; + +protected: + class ALogger& logger; +}; + +#endif // __AMathMLFactory_hh__ diff --git a/DEVEL/mathml_editor/src/APushLexer.hh b/DEVEL/mathml_editor/src/APushLexer.hh new file mode 100644 index 000000000..4a2940b4c --- /dev/null +++ b/DEVEL/mathml_editor/src/APushLexer.hh @@ -0,0 +1,46 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __APushLexer_hh__ +#define __APushLexer_hh__ + +class APushLexer +{ +public: + APushLexer(class ALogger& l, class APushParser& p) : logger(l), parser(p) { }; + virtual ~APushLexer() { }; + + virtual void push(char) = 0; + virtual void drop(bool) = 0; + virtual bool complete(void) = 0; + virtual void reset(void) = 0; + virtual bool error(void) const = 0; + +protected: + class ALogger& logger; + class APushParser& parser; +}; + +#endif // __APushLexer_hh__ diff --git a/DEVEL/mathml_editor/src/APushParser.cc b/DEVEL/mathml_editor/src/APushParser.cc new file mode 100644 index 000000000..6f843d508 --- /dev/null +++ b/DEVEL/mathml_editor/src/APushParser.cc @@ -0,0 +1,42 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include "APushParser.hh" +#include "AMathMLFactory.hh" + +bool +APushParser::freeze() +{ + return freeze_level++ == 0; +} + +bool +APushParser::thaw() +{ + if (freeze_level > 0) + return --freeze_level == 0; + else + return true; +} diff --git a/DEVEL/mathml_editor/src/APushParser.hh b/DEVEL/mathml_editor/src/APushParser.hh new file mode 100644 index 000000000..74cb18e3b --- /dev/null +++ b/DEVEL/mathml_editor/src/APushParser.hh @@ -0,0 +1,57 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __APushParser_hh__ +#define __APushParser_hh__ + +#include + +class APushParser +{ +public: + APushParser(class ALogger& l) : logger(l), factory(0), freeze_level(0) { }; + APushParser(class ALogger& l, class AMathMLFactory& f) : logger(l), factory(&f), freeze_level(0) { }; + virtual ~APushParser() { }; + + virtual void reset(void) = 0; + virtual void push(const class TToken&) = 0; + virtual std::string drop(bool) = 0; + virtual void setCursorHint(const std::string&) = 0; + virtual bool hideCursor(void) = 0; + virtual bool showCursor(void) = 0; + + virtual bool freeze(void); + virtual bool thaw(void); + bool frozen(void) const { return freeze_level > 0; }; + +protected: + class ALogger& logger; + class AMathMLFactory* factory; + +private: + unsigned freeze_level; +}; + +#endif // __APushParser_hh__ diff --git a/DEVEL/mathml_editor/src/BROWSE b/DEVEL/mathml_editor/src/BROWSE new file mode 100644 index 000000000..ddd9c4428 --- /dev/null +++ b/DEVEL/mathml_editor/src/BROWSE @@ -0,0 +1,503 @@ +[ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "APushParser" () 0"APushParser.hh" "class APushParser +{" 75"APushParser.hh" ] +([ebrowse-ts [ebrowse-cs "TPushParser" () 0"TPushParser.hh" "class TPushParser :" 226"TPushParser.hh" ] +()([ebrowse-ms "buffer" () 0 () " std::list buffer;" 1306 2 () () 0] +[ebrowse-ms "cursor" () 0 () " TNode cursor;" 1363 2 () () 0] +[ebrowse-ms "doc" () 0 () " TDocument doc;" 1343 2 () () 0] +[ebrowse-ms "frames" () 0 () " std::stack frames;" 1278 2 () () 0] +[ebrowse-ms "nextId" () 0 () " unsigned nextId;" 1326 2 () () 0] +) +([ebrowse-ms "PRIME" () 4 () " std::string PRIME(void" 490 2 "TPushParser.cc" "TPushParser::PRIME()" 279] +[ebrowse-ms "TPushParser" () 0 () () 0 0 "TPushParser.cc" "TPushParser::TPushParser(const TDictionary& d) :" 58] +[ebrowse-ms "TPushParser" () 0 () " TPushParser(const class TDictionary&);" 275 0 () () 0] +[ebrowse-ms "advance" () 0 () " void advance(const" 1065 2 "TPushParser.cc" "TPushParser::advance(const" 13192] +[ebrowse-ms "do_active" () 0 () " void do_active(const" 916 2 "TPushParser.cc" "TPushParser::do_active(const" 5602] +[ebrowse-ms "do_align" () 0 () " void do_align(void" 624 2 "TPushParser.cc" "TPushParser::do_align()" 1530] +[ebrowse-ms "do_apostrophe" () 0 () " void do_apostrophe(void" 1042 2 "TPushParser.cc" "TPushParser::do_apostrophe()" 4611] +[ebrowse-ms "do_begin" () 0 () " void do_begin(void" 557 2 "TPushParser.cc" "TPushParser::do_begin()" 461] +[ebrowse-ms "do_comment" () 0 () " void do_comment(void" 954 2 "TPushParser.cc" "TPushParser::do_comment()" 5668] +[ebrowse-ms "do_control" () 0 () " void do_control(const" 980 2 "TPushParser.cc" "TPushParser::do_control(const" 6337] +[ebrowse-ms "do_cr" () 0 () " void do_cr(void" 1014 2 "TPushParser.cc" "TPushParser::do_cr()" 5708] +[ebrowse-ms "do_digit" () 0 () " void do_digit(const" 841 2 "TPushParser.cc" "TPushParser::do_digit(const" 4072] +[ebrowse-ms "do_end" () 0 () " void do_end(void" 578 2 "TPushParser.cc" "TPushParser::do_end()" 910] +[ebrowse-ms "do_eol" () 0 () " void do_eol(void" 645 2 "TPushParser.cc" "TPushParser::do_eol()" 2464] +[ebrowse-ms "do_letter" () 0 () " void do_letter(const" 804 2 "TPushParser.cc" "TPushParser::do_letter(const" 3902] +[ebrowse-ms "do_other" () 0 () " void do_other(const" 878 2 "TPushParser.cc" "TPushParser::do_other(const" 5303] +[ebrowse-ms "do_parameter" () 0 () " void do_parameter(const" 673 2 "TPushParser.cc" "TPushParser::do_parameter(const" 2546] +[ebrowse-ms "do_shift" () 0 () " void do_shift(void" 601 2 "TPushParser.cc" "TPushParser::do_shift()" 1487] +[ebrowse-ms "do_space" () 0 () " void do_space(const" 766 2 "TPushParser.cc" "TPushParser::do_space(const" 3794] +[ebrowse-ms "do_subscript" () 0 () " void do_subscript(void" 742 2 "TPushParser.cc" "TPushParser::do_subscript()" 2609] +[ebrowse-ms "do_superscript" () 0 () " void do_superscript(void" 715 2 "TPushParser.cc" "TPushParser::do_superscript()" 3204] +[ebrowse-ms "document" () 4 () " TDocument document(void" 432 0 () " TDocument document(void" 432] +[ebrowse-ms "isPrimes" () 4 () " bool isPrimes(const" 520 2 "TPushParser.cc" "TPushParser::isPrimes(const" 4445] +[ebrowse-ms "process" () 0 () " void process(const" 1096 2 "TPushParser.cc" "TPushParser::process(const" 8538] +[ebrowse-ms "push" () 1 () " virtual void push(const" 349 0 "TPushParser.cc" "TPushParser::push(const" 9379] +[ebrowse-ms "setCursor" () 1 () " virtual void setCursor(const" 390 0 "TPushParser.cc" "TPushParser::setCursor(const" 13865] +[ebrowse-ms "~TPushParser" () 1 () " virtual ~TPushParser()" 321 0 "TPushParser.cc" "TPushParser::~TPushParser()" 241] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TTokenizer" () 0"TTokenizer.hh" "class TTokenizer :" 173"TTokenizer.hh" ] +()([ebrowse-ms "tokens" () 0 () " std::list tokens;" 405 2 () () 0] +) +([ebrowse-ms "TTokenizer" () 0 () " TTokenizer(void) {" 221 0 () " TTokenizer(void) {" 221] +[ebrowse-ms "push" () 1 () " virtual void push(const" 316 2 "TTokenizer.cc" "TTokenizer::push(const" 471] +[ebrowse-ms "setCursor" () 1 () " virtual void setCursor(const" 357 2 () " virtual void setCursor(const" 357] +[ebrowse-ms "tokenize" () 0 () " std::vector tokenize(const" 265 0 "TTokenizer.cc" "TTokenizer::tokenize(const" 120] +) +() +() +() +() +()() +])() +([ebrowse-ms "APushParser" () 0 () " APushParser(void) {" 102 0 () " APushParser(void) {" 102] +[ebrowse-ms "push" () 9 () " virtual void push(const" 164 0 () () 0] +[ebrowse-ms "setCursor" () 9 () " virtual void setCursor(const" 209 0 () () 0] +[ebrowse-ms "~APushParser" () 1 () " virtual ~APushParser()" 133 0 () " virtual ~APushParser()" 133] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EmptyBuffer" "TLexerPush" 0"TLexerPush.hh" " class EmptyBuffer {" 271() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "unary_function" "std" 32() () 0() ] +([ebrowse-ts [ebrowse-cs "StringHash" "TDictionary" 0"TDictionary.hh" " struct StringHash :" 1160"TDictionary.hh" ] +()() +([ebrowse-ms "operator ()" () 4 () " { size_t operator()(const" 1238 0 () " { size_t operator()(const" 1238] +) +() +() +() +() +()() +])() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TObject" () 0"TObject.hh" "class TObject +{" 63"TObject.hh" ] +()() +([ebrowse-ms "TObject" () 0 () " TObject(void) {" 89 1 () " TObject(void) {" 89] +[ebrowse-ms "ref" () 4 () " void ref(coid" 162 0 () " void ref(coid" 162] +[ebrowse-ms "unref" () 4 () " void unref(void" 206 0 () " void unref(void" 206] +[ebrowse-ms "~TObject" () 1 () " virtual ~TObject()" 132 1 () " virtual ~TObject()" 132] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "std" () 0() () 0() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TLexerPush" () 0"TLexerPush.hh" "class TLexerPush +{" 59"TLexerPush.hh" ] +()([ebrowse-ms "state" () 0 () " State state;" 388 2 () () 0] +[ebrowse-ms "tokens" () 0 () " std::deque tokens;" 417 2 () () 0] +) +([ebrowse-ms "TLexerPush" () 0 () " TLexerPush(void);" 85 0 "TLexerPush.cc" "TLexerPush::TLexerPush() +{" 51] +[ebrowse-ms "ambiguous" () 4 () " bool ambiguous(void" 182 0 "TLexerPush.cc" "TLexerPush::ambiguous()" 576] +[ebrowse-ms "empty" () 4 () " bool empty(void" 240 0 "TLexerPush.cc" "TLexerPush::empty()" 447] +[ebrowse-ms "front" () 4 () " TToken front(void" 150 0 "TLexerPush.cc" "TLexerPush::front()" 338] +[ebrowse-ms "pending" () 4 () " bool pending(void" 212 0 "TLexerPush.cc" "TLexerPush::pending()" 510] +[ebrowse-ms "pop" () 0 () " TToken pop(void" 128 0 "TLexerPush.cc" "TLexerPush::pop()" 99] +[ebrowse-ms "push" () 0 () " void push(TChar" 108 0 "TLexerPush.cc" "TLexerPush::push(TChar" 664] +) +() +() +() +([ebrowse-ms "State" () 0 () " {" 303 2 () " {" 303] +) +()() +][ebrowse-ts [ebrowse-cs "TLexerPull" () 0() () 0"TLexerPull.cc" ] +()() +([ebrowse-ms "pop" () 0 () () 0 0 () "TLexerPull::pop(TCharStream" 94] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TDictionary" () 0"TDictionary.hh" "class TDictionary +{" 154"TDictionary.hh" ] +()([ebrowse-ms "entries" () 0 () " Dictionary entries;" 1560 2 () () 0] +) +([ebrowse-ms "TDictionary" () 0 () " TDictionary(void) {" 181 0 () " TDictionary(void) {" 181] +[ebrowse-ms "find" () 4 () " const Entry& find(const" 1107 0 "TDictionary.cc" "TDictionary::find(const" 3723] +[ebrowse-ms "load" () 0 () " void load(const" 1069 0 "TDictionary.cc" "TDictionary::load(const" 162] +[ebrowse-ms "~TDictionary" () 0 () " ~TDictionary()" 204 0 () " ~TDictionary()" 204] +) +() +() +() +([ebrowse-ms "Dictionary" () 0 () "ap< std::string, Entry, StringHash > Dictionary;" 1538 2 () () 0] +[ebrowse-ms "EntryClass" () 0 () " {" 301 0 () " {" 301] +[ebrowse-ms "Form" () 0 () " {" 228 0 () " {" 228] +) +()() +][ebrowse-ts [ebrowse-cs "DOM" () 0() () 0() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "APushLexer" () 0"APushLexer.hh" "class APushLexer +{" 72"APushLexer.hh" ] +([ebrowse-ts [ebrowse-cs "TPushLexer" () 0"TPushLexer.hh" "class TPushLexer :" 117"TPushLexer.hh" ] +()([ebrowse-ms "buffer" () 0 () " std::string buffer;" 483 2 () () 0] +[ebrowse-ms "state" () 0 () " State state;" 461 2 () () 0] +) +([ebrowse-ms "TPushLexer" () 0 () () 0 0 "TPushLexer.cc" "TPushLexer::TPushLexer(APushParser& p) :" 108] +[ebrowse-ms "TPushLexer" () 0 () " TPushLexer(class APushParser&);" 164 0 () () 0] +[ebrowse-ms "error" () 5 () " virtual bool error(void" 290 0 "TPushLexer.cc" "TPushLexer::error()" 2463] +[ebrowse-ms "push" () 1 () " virtual void push(char" 234 0 "TPushLexer.cc" "TPushLexer::push(char" 1180] +[ebrowse-ms "reset" () 1 () " virtual void reset(void" 262 0 "TPushLexer.cc" "TPushLexer::reset()" 176] +[ebrowse-ms "transaction" () 0 () " void transaction(char" 436 2 "TPushLexer.cc" "TPushLexer::transaction(char" 251] +[ebrowse-ms "~TPushLexer" () 1 () " virtual ~TPushLexer()" 203 0 () " virtual ~TPushLexer()" 203] +) +() +() +() +([ebrowse-ms "State" () 0 () " {" 327 2 () " {" 327] +) +()() +])() +([ebrowse-ms "APushLexer" () 0 () " APushLexer(class APushParser& p) :" 99 0 () " APushLexer(class APushParser& p) :" 99] +[ebrowse-ms "error" () 13 () " virtual bool error(void" 251 0 () () 0] +[ebrowse-ms "push" () 9 () " virtual void push(char" 187 0 () () 0] +[ebrowse-ms "reset" () 9 () " virtual void reset(void" 219 0 () () 0] +[ebrowse-ms "~APushLexer" () 1 () " virtual ~APushLexer()" 156 0 () " virtual ~APushLexer()" 156] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Ptr" () 32"Ptr.hh" "class Ptr +{" 1067"Ptr.hh" ] +()([ebrowse-ms "ptr" () 0 () " P* ptr;" 1797 2 () () 0] +) +([ebrowse-ms "P" () 4 () " operator P*()" 1487 0 () " operator P*()" 1487] +[ebrowse-ms "Ptr" () 0 () " Ptr(const Ptr& p) :" 1142 0 () " Ptr(const Ptr& p) :" 1142] +[ebrowse-ms "Ptr" () 0 () " Ptr(P* p = 0) :" 1083 0 () " Ptr(P* p = 0) :" 1083] +[ebrowse-ms "Q" () 36 () " template operator Ptr()" 1747 0 () " template operator Ptr()" 1747] +[ebrowse-ms "operator ->" () 4 () " P* operator->()" 1253 0 () " P* operator->()" 1253] +[ebrowse-ms "operator =" () 0 () " Ptr& operator=(const" 1316 0 () " Ptr& operator=(const" 1316] +[ebrowse-ms "~Ptr" () 0 () " ~Ptr()" 1202 0 () " ~Ptr()" 1202] +) +() +() +([ebrowse-ms "is_a" () 32 () " template friend bool is_a(const" 1659 0 () " template friend bool is_a(const" 1659] +[ebrowse-ms "smart_cast" () 32 () "emplate friend Ptr smart_cast(const" 1561 0 () "emplate friend Ptr smart_cast(const" 1561] +) +() +()() +][ebrowse-ts [ebrowse-cs "TToken" () 0"TToken.hh" "struct TToken +{" 80"TToken.hh" ] +()([ebrowse-ms "category" () 0 () " TCat category;" 627 0 () () 0] +[ebrowse-ms "value" () 0 () " std::string value;" 648 0 () () 0] +) +([ebrowse-ms "TToken" () 0 () " TToken(TCat c, const std::string& v) :" 438 0 () " TToken(TCat c, const std::string& v) :" 438] +[ebrowse-ms "TToken" () 0 () " TToken(TCat c, char ch) :" 366 0 () " TToken(TCat c, char ch) :" 366] +[ebrowse-ms "TToken" () 0 () " TToken(TCat c) :" 330 0 () " TToken(TCat c) :" 330] +[ebrowse-ms "operator ==" () 4 () " bool operator==(const" 517 0 () " bool operator==(const" 517] +) +() +() +() +([ebrowse-ms "TCat" () 0 () " {" 98 0 () " {" 98] +) +()() +][ebrowse-ts [ebrowse-cs "binary_function" "std" 32() () 0() ] +([ebrowse-ts [ebrowse-cs "StringEq" "TDictionary" 0"TDictionary.hh" " struct StringEq :" 1327() ] +()() +([ebrowse-ms "operator ()" () 4 () " { bool operator()(const" 1415 0 () () 0] +) +() +() +() +() +()() +])() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TNode" () 0"TNode.hh" "class TNode +{" 124"TNode.hh" ] +()([ebrowse-ms "node" () 0 () " DOM::Element node;" 2444 2 () () 0] +) +([ebrowse-ms "TNode" () 0 () " TNode(const TNode& n) :" 270 0 () " TNode(const TNode& n) :" 270] +[ebrowse-ms "TNode" () 0 () " TNode(void) :" 145 0 () " TNode(void) :" 145] +[ebrowse-ms "append" () 4 () " void append(const" 1667 0 "TNode.cc" "TNode::append(const" 2450] +[ebrowse-ms "append" () 4 () " void append(const" 1631 0 "TNode.cc" "TNode::append(const" 2348] +[ebrowse-ms "child" () 4 () " TNode child(unsigned" 592 0 "TNode.cc" "TNode::child(unsigned" 2874] +[ebrowse-ms "core" () 4 () " TNode core(void" 425 0 "TNode.cc" "TNode::core()" 1413] +[ebrowse-ms "empty" () 4 () " bool empty(void" 648 0 () " bool empty(void" 648] +[ebrowse-ms "first" () 4 () " TNode first(void" 480 0 "TNode.cc" "TNode::first()" 1075] +[ebrowse-ms "firstL" () 4 () " TNode firstL(void" 508 0 "TNode.cc" "TNode::firstL()" 1259] +[ebrowse-ms "get" () 4 () " std::string get(const" 1758 0 "TNode.cc" "TNode::get(const" 3007] +[ebrowse-ms "hasId" () 4 () " bool hasId(void" 1994 0 () " bool hasId(void" 1994] +[ebrowse-ms "insert" () 4 () " void insert(const" 1595 0 "TNode.cc" "TNode::insert(const" 2193] +[ebrowse-ms "is" () 4 () " bool is(const" 2055 0 () " bool is(const" 2055] +[ebrowse-ms "isC" () 4 () " bool isC(const" 2303 0 () " bool isC(const" 2303] +[ebrowse-ms "isC" () 4 () " bool isC(void" 2258 0 () " bool isC(void" 2258] +[ebrowse-ms "isG" () 4 () " bool isG(void" 2119 0 () " bool isG(void" 2119] +[ebrowse-ms "isSb" () 4 () " bool isSb(void" 2165 0 () " bool isSb(void" 2165] +[ebrowse-ms "isSp" () 4 () " bool isSp(void" 2212 0 () " bool isSp(void" 2212] +[ebrowse-ms "last" () 4 () " TNode last(void" 534 0 "TNode.cc" "TNode::last()" 736] +[ebrowse-ms "lastL" () 4 () " TNode lastL(void" 561 0 "TNode.cc" "TNode::lastL()" 922] +[ebrowse-ms "name" () 4 () " std::string name(void" 1863 0 () " std::string name(void" 1863] +[ebrowse-ms "nameC" () 4 () " std::string nameC(void" 1929 0 () " std::string nameC(void" 1929] +[ebrowse-ms "next" () 4 () " TNode next(void" 319 0 "TNode.cc" "TNode::next()" 63] +[ebrowse-ms "nextL" () 4 () " TNode nextL(void" 346 0 "TNode.cc" "TNode::nextL()" 247] +[ebrowse-ms "operator !=" () 4 () " bool operator!=(const" 1295 0 () " bool operator!=(const" 1295] +[ebrowse-ms "operator ==" () 4 () " bool operator==(const" 1227 0 () " bool operator==(const" 1227] +[ebrowse-ms "operator []" () 4 () " ProxyAttr operator[](const" 1422 0 () " ProxyAttr operator[](const" 1422] +[ebrowse-ms "operator []" () 4 () " TNode operator[](int" 1362 0 () " TNode operator[](int" 1362] +[ebrowse-ms "parent" () 4 () " TNode parent(void" 453 0 "TNode.cc" "TNode::parent()" 1587] +[ebrowse-ms "prepend" () 4 () " void prepend(const" 1718 0 "TNode.cc" "TNode::prepend(const" 2683] +[ebrowse-ms "prev" () 4 () " TNode prev(void" 372 0 "TNode.cc" "TNode::prev()" 396] +[ebrowse-ms "prevL" () 4 () " TNode prevL(void" 399 0 "TNode.cc" "TNode::prevL()" 588] +[ebrowse-ms "remove" () 4 () " void remove(void" 1529 0 "TNode.cc" "TNode::remove()" 1913] +[ebrowse-ms "replace" () 4 () " void replace(const" 1559 0 "TNode.cc" "TNode::replace(const" 2038] +[ebrowse-ms "set" () 4 () " void set(const" 1797 0 "TNode.cc" "TNode::set(const" 3109] +[ebrowse-ms "size" () 4 () " unsigned size(void" 621 0 "TNode.cc" "TNode::size()" 1749] +[ebrowse-ms "value" () 4 () " std::string value(void" 707 0 () " std::string value(void" 707] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Entry" "TDictionary" 0"TDictionary.hh" " struct Entry + {" 405"TDictionary.hh" ] +()([ebrowse-ms "cls" () 0 () " EntryClass cls;" 806 0 () () 0] +[ebrowse-ms "delimiter" () 0 () " unsigned delimiter : 1;" 909 0 () () 0] +[ebrowse-ms "embellishment" () 0 () " unsigned embellishment : 1;" 966 0 () () 0] +[ebrowse-ms "infix" () 0 () " unsigned infix : 8;" 830 0 () () 0] +[ebrowse-ms "leftOpen" () 0 () " unsigned leftOpen : 1;" 993 0 () () 0] +[ebrowse-ms "limits" () 0 () " unsigned limits : 1;" 934 0 () () 0] +[ebrowse-ms "pattern" () 0 () " std::vector pattern;" 597 0 () () 0] +[ebrowse-ms "postfix" () 0 () " unsigned postfix : 8;" 881 0 () () 0] +[ebrowse-ms "prefix" () 0 () " unsigned prefix : 8;" 855 0 () () 0] +[ebrowse-ms "rightOpen" () 0 () " unsigned rightOpen : 1;" 1021 0 () () 0] +[ebrowse-ms "table" () 0 () " unsigned table : 1;" 1045 0 () () 0] +[ebrowse-ms "value" () 0 () " std::string value;" 620 0 () () 0] +) +([ebrowse-ms "Entry" () 0 () " {" 420 0 () " {" 420] +[ebrowse-ms "defined" () 4 () " bool defined(void" 643 0 () " bool defined(void" 643] +[ebrowse-ms "hasArguments" () 4 () " bool hasArguments(void" 707 0 () " bool hasArguments(void" 707] +[ebrowse-ms "paramDelimited" () 4 () " bool paramDelimited(unsigned" 777 0 "TDictionary.cc" "TDictionary::Entry::paramDelimited(unsigned" 4012] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "Frame" "TPushParser" 0"TPushParser.hh" " struct Frame + {" 1126"TPushParser.hh" ] +()([ebrowse-ms "entry" () 0 () " const TDictionary::Entry& entry;" 1226 0 () () 0] +[ebrowse-ms "pos" () 0 () " unsigned pos;" 1244 0 () () 0] +) +([ebrowse-ms "Frame" () 0 () " Frame(const TDictionary::Entry& e) :" 1142 0 () " Frame(const TDictionary::Entry& e) :" 1142] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TCharStream" () 0"TCharStream.hh" "class TCharStream +{" 94"TCharStream.hh" ] +([ebrowse-ts [ebrowse-cs "TCharStreamString" () 0"TCharStreamString.hh" "class TCharStreamString :" 120"TCharStreamString.hh" ] +()([ebrowse-ms "buffer" () 0 () " TString buffer;" 555 2 () () 0] +[ebrowse-ms "idx" () 0 () " unsigned long idx;" 536 2 () () 0] +) +([ebrowse-ms "TCharStreamString" () 0 () " TCharStreamString(const TString& s) :" 175 0 () " TCharStreamString(const TString& s) :" 175] +[ebrowse-ms "look" () 5 () " virtual TChar look(void" 343 0 () " virtual TChar look(void" 343] +[ebrowse-ms "more" () 5 () " virtual bool more(void" 275 0 () " virtual bool more(void" 275] +[ebrowse-ms "next" () 1 () " virtual TChar next(void" 439 0 () " virtual TChar next(void" 439] +[ebrowse-ms "~TCharStreamString" () 1 () " virtual ~TCharStreamString()" 243 0 () " virtual ~TCharStreamString()" 243] +) +() +() +() +() +()() +])() +([ebrowse-ms "TCharStream" () 0 () " TCharStream(void) {" 121 0 () " TCharStream(void) {" 121] +[ebrowse-ms "look" () 13 () " virtual TChar look(void" 222 0 () () 0] +[ebrowse-ms "more" () 13 () " virtual bool more(void" 184 0 () () 0] +[ebrowse-ms "next" () 9 () " virtual TChar next(void" 260 0 () () 0] +[ebrowse-ms "~TCharStream" () 1 () " virtual ~TCharStream()" 152 0 () " virtual ~TCharStream()" 152] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EmptyStream" "TCharStream" 0"TCharStream.hh" " class EmptyStream {" 289() ] +()() +() +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "*Globals*" () 0() () 0"APushLexer.hh" ] +()() +([ebrowse-ms "dispatch" () 0 "special.cc" "dispatch(const" 1012 0 "special.cc" "dispatch(const" 1012] +[ebrowse-ms "do_apostrophe" () 0 "special.cc" "do_apostrophe(const" 669 0 "special.cc" "do_apostrophe(const" 669] +[ebrowse-ms "do_bgroup" () 0 "special.cc" "do_bgroup(const" 149 0 "special.cc" "do_bgroup(const" 149] +[ebrowse-ms "do_control" () 0 "special.cc" "do_control(const" 711 0 "special.cc" "do_control(const" 711] +[ebrowse-ms "do_other" () 0 "special.cc" "do_other(const" 776 0 "special.cc" "do_other(const" 776] +[ebrowse-ms "finishG" () 0 "special.cc" "void finishG(const" 118 0 () () 0] +[ebrowse-ms "getCore" () 0 "domnav.cc" "getCore(const" 629 0 "domnav.cc" "getCore(const" 629] +[ebrowse-ms "getRightmostChild" () 0 "domnav.cc" "getRightmostChild(const" 37 0 "domnav.cc" "getRightmostChild(const" 37] +[ebrowse-ms "isDelimiter" () 0 "domnav.cc" "isDelimiter(const" 1716 0 "domnav.cc" "isDelimiter(const" 1716] +[ebrowse-ms "isFunction" () 0 "domnav.cc" "isFunction(const" 1879 0 "domnav.cc" "isFunction(const" 1879] +[ebrowse-ms "isGroup" () 0 "domnav.cc" "isGroup(const" 1214 0 "domnav.cc" "isGroup(const" 1214] +[ebrowse-ms "isInferred" () 0 "domnav.cc" "isInferred(const" 985 0 "domnav.cc" "isInferred(const" 985] +[ebrowse-ms "isMacro" () 0 "domnav.cc" "isMacro(const" 1085 0 "domnav.cc" "isMacro(const" 1085] +[ebrowse-ms "isOperator" () 0 "domnav.cc" "isOperator(const" 1553 0 "domnav.cc" "isOperator(const" 1553] +[ebrowse-ms "isPrimes" () 0 "domnav.cc" "isPrimes(const" 1451 0 "domnav.cc" "isPrimes(const" 1451] +[ebrowse-ms "isSb" () 0 "domnav.cc" "isSb(const" 1291 0 "domnav.cc" "isSb(const" 1291] +[ebrowse-ms "isSp" () 0 "domnav.cc" "isSp(const" 1369 0 "domnav.cc" "isSp(const" 1369] +[ebrowse-ms "isUnicodeAlpha" () 2 "dom.hh" "inline bool isUnicodeAlpha(TChar" 303 0 "dom.hh" "inline bool isUnicodeAlpha(TChar" 303] +[ebrowse-ms "isUnicodeDigit" () 2 "dom.hh" "inline bool isUnicodeDigit(TChar" 408 0 "dom.hh" "inline bool isUnicodeDigit(TChar" 408] +[ebrowse-ms "isUnicodeSpace" () 2 "dom.hh" "inline bool isUnicodeSpace(TChar" 198 0 "dom.hh" "inline bool isUnicodeSpace(TChar" 198] +[ebrowse-ms "main" () 0 "texlexer.cc" "main()" 51 0 "texlexer.cc" "main()" 51] +[ebrowse-ms "prevLinearSibling" () 0 "domnav.cc" "prevLinearSibling(const" 324 0 "domnav.cc" "prevLinearSibling(const" 324] +[ebrowse-ms "replace" () 0 "domnav.cc" "replace(const" 834 0 "domnav.cc" "replace(const" 834] +[ebrowse-ms "tokenize" () 0 "tokenizer.hh" "std::vector tokenize(const" 123 0 () () 0] +) +([ebrowse-ms "undefinedEntry" () 0 () () 0 0 "TDictionary.cc" "static TDictionary::Entry undefinedEntry;" 132] +) +() +([ebrowse-ms "Ptr_hh" () 512 () () 0 0 "Ptr.hh" "#define Ptr_hh +" 1036] +[ebrowse-ms "TML_NS_URI" () 512 () () 0 0 "globals.hh" "#define TML_NS_URI " 67] +[ebrowse-ms "XMLNS_NS_URI" () 512 () () 0 0 "globals.hh" "#define XMLNS_NS_URI " 123] +[ebrowse-ms "__APushLexer_hh__" () 512 () () 0 0 () "#define __APushLexer_hh__ +" 53] +[ebrowse-ms "__APushParser_hh__" () 512 () () 0 0 "APushParser.hh" "#define __APushParser_hh__ +" 55] +[ebrowse-ms "__TCharStreamString_hh__" () 512 () () 0 0 "TCharStreamString.hh" "#define __TCharStreamString_hh__ +" 67] +[ebrowse-ms "__TCharStream_hh__" () 512 () () 0 0 "TCharStream.hh" "#define __TCharStream_hh__ +" 55] +[ebrowse-ms "__TDictionary_hh__" () 512 () () 0 0 "TDictionary.hh" "#define __TDictionary_hh__ +" 55] +[ebrowse-ms "__TDocument_hh__" () 512 () () 0 0 "TDocument.hh" "#define __TDocument_hh__ +" 51] +[ebrowse-ms "__TNode_hh__" () 512 () () 0 0 "TNode.hh" "#define __TNode_hh__ +" 43] +[ebrowse-ms "__TObject_hh__" () 512 () () 0 0 "TObject.hh" "#define __TObject_hh__ +" 47] +[ebrowse-ms "__TPushLexer_hh__" () 512 () () 0 0 "TPushLexer.hh" "#define __TPushLexer_hh__ +" 53] +[ebrowse-ms "__TPushParser_hh__" () 512 () () 0 0 "TPushParser.hh" "#define __TPushParser_hh__ +" 55] +[ebrowse-ms "__TToken_hh__" () 512 () () 0 0 "TToken.hh" "#define __TToken_hh__ +" 45] +[ebrowse-ms "__TTokenizer_hh__" () 512 () () 0 0 "TTokenizer.hh" "#define __TTokenizer_hh__ +" 53] +[ebrowse-ms "__dom_hh__" () 512 () () 0 0 "dom.hh" "#define __dom_hh__ +" 39] +[ebrowse-ms "__globals_hh__" () 512 () () 0 0 "globals.hh" "#define __globals_hh__ +" 47] +[ebrowse-ms "__tokenzier_hh__" () 512 () () 0 0 "tokenizer.hh" "#define __tokenzier_hh__ +" 51] +) +([ebrowse-ms "TChar" () 0 () () 0 0 "dom.hh" "typedef DOM::Char32 TChar;" 131] +[ebrowse-ms "TString" () 0 () () 0 0 "dom.hh" "typedef DOM::UCS4String TString;" 164] +) +()() +][ebrowse-ts [ebrowse-cs "ProxyAttr" "TNode" 0"TNode.hh" " class ProxyAttr + {" 765"TNode.hh" ] +()([ebrowse-ms "name" () 0 () " std::string name;" 1155 2 () () 0] +[ebrowse-ms "node" () 0 () " DOM::Element node;" 1132 2 () () 0] +) +([ebrowse-ms "ProxyAttr" () 0 () "r(const DOM::Element& n, const std::string& s) :" 795 0 () "r(const DOM::Element& n, const std::string& s) :" 795] +[ebrowse-ms "operator =" () 0 () " ProxyAttr& operator=(const" 959 0 () " ProxyAttr& operator=(const" 959] +[ebrowse-ms "operator ==" () 0 () " bool operator==(const" 1040 0 () " bool operator==(const" 1040] +[ebrowse-ms "string" () 4 () " operator std::string()" 885 0 () " operator std::string()" 885] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "EventListener" "DOM" 0() () 0() ] +([ebrowse-ts [ebrowse-cs "DOMSubtreeModifiedListener" "TDocument" 0"TDocument.hh" " class DOMSubtreeModifiedListener :" 1015"TDocument.hh" ] +()([ebrowse-ms "doc" () 0 () " TDocument doc;" 1247 2 () () 0] +) +([ebrowse-ms "DOMSubtreeModifiedListener" () 0 () "DOMSubtreeModifiedListener(const TDocument& d) :" 1092 0 () "DOMSubtreeModifiedListener(const TDocument& d) :" 1092] +[ebrowse-ms "handleEvent" () 1 () " virtual void handleEvent(const" 1202 0 () () 0] +[ebrowse-ms "~DOMSubtreeModifiedListener" () 1 () " virtual ~DOMSubtreeModifiedListener()" 1162 0 () " virtual ~DOMSubtreeModifiedListener()" 1162] +) +() +() +() +() +()() +][ebrowse-ts [ebrowse-cs "TDocument" () 0"TDocument.hh" "class TDocument :" 108"TDocument.hh" ] +()([ebrowse-ms "dirty" () 0 () " DOM::Element dirty;" 971 2 () () 0] +[ebrowse-ms "doc" () 0 () " DOM::Document doc;" 949 2 () () 0] +) +([ebrowse-ms "TDocument" () 0 () " TDocument(void);" 162 0 "TDocument.cc" "TDocument::TDocument() +{" 108] +[ebrowse-ms "create" () 4 () " TNode create(const" 202 0 "TDocument.cc" "TDocument::create(const" 789] +[ebrowse-ms "createC" () 4 () " TNode createC(const" 327 0 "TDocument.cc" "TDocument::createC(const" 1062] +[ebrowse-ms "createG" () 4 () " TNode createG(unsigned" 262 0 () " TNode createG(unsigned" 262] +[ebrowse-ms "createI" () 4 () " TNode createI(const" 461 0 () " TNode createI(const" 461] +[ebrowse-ms "createN" () 4 () " TNode createN(const" 561 0 () " TNode createN(const" 561] +[ebrowse-ms "createO" () 4 () " TNode createO(const" 661 0 () " TNode createO(const" 661] +[ebrowse-ms "createT" () 4 () " TNode createT(const" 384 0 "TDocument.cc" "TDocument::createT(const" 1197] +[ebrowse-ms "dirtyIdNode" () 4 () " TNode dirtyIdNode(void" 872 0 "TDocument.cc" "TDocument::dirtyIdNode()" 2081] +[ebrowse-ms "dirtyNode" () 4 () " TNode dirtyNode(void" 821 0 () " TNode dirtyNode(void" 821] +[ebrowse-ms "handleEvent" () 1 () " virtual void handleEvent(const" 1293 2 "TDocument.cc" "TDocument::handleEvent(const" 2348] +[ebrowse-ms "root" () 0 () " TNode root(void" 758 0 () " TNode root(void" 758] +[ebrowse-ms "serialize" () 4 () " void serialize(const" 904 0 "TDocument.cc" "TDocument::serialize(const" 637] +[ebrowse-ms "~TDocument" () 0 () " ~TDocument()" 179 0 "TDocument.cc" "TDocument::~TDocument()" 460] +) +() +([ebrowse-ms "findCommonAncestor" () 0 () " static DOM::Node findCommonAncestor(const" 1398 2 "TDocument.cc" "TDocument::findCommonAncestor(const" 1560] +[ebrowse-ms "nodeDepth" () 0 () " static unsigned nodeDepth(const" 1341 2 "TDocument.cc" "TDocument::nodeDepth(const" 1362] +) +() +() +()() +])() +() +() +() +() +() +()() +] \ No newline at end of file diff --git a/DEVEL/mathml_editor/src/CLoggerConsole.cc b/DEVEL/mathml_editor/src/CLoggerConsole.cc new file mode 100644 index 000000000..0265f389d --- /dev/null +++ b/DEVEL/mathml_editor/src/CLoggerConsole.cc @@ -0,0 +1,35 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include "CLoggerConsole.hh" + +void +CLoggerConsole::message(Level l, const std::string& msg) +{ + const char* ls[] = { "Error", "Warning", "Info", "Debug" }; + std::cerr << "*** " << ls[l] << ": " << msg << std::endl; +} diff --git a/DEVEL/mathml_editor/src/CLoggerConsole.hh b/DEVEL/mathml_editor/src/CLoggerConsole.hh new file mode 100644 index 000000000..630f7cf32 --- /dev/null +++ b/DEVEL/mathml_editor/src/CLoggerConsole.hh @@ -0,0 +1,40 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __CLoggerConsole_hh__ +#define __CLoggerConsole_hh__ + +#include "ALogger.hh" + +class CLoggerConsole : public ALogger +{ +public: + CLoggerConsole(void) { }; + +protected: + virtual void message(Level, const std::string&); +}; + +#endif // __CLoggerConsole_hh__ diff --git a/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc b/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc new file mode 100644 index 000000000..888452030 --- /dev/null +++ b/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc @@ -0,0 +1,145 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include "dom.hh" +#include "TNode.hh" +#include "ALogger.hh" +#include "TDocument.hh" +#include "CMathMLFactoryXSLT.hh" +#include "AMathMLConsumer.hh" +#include + +CMathMLFactoryXSLT::CMathMLFactoryXSLT(ALogger& l, const DOMX::XSLTStylesheet& s) + : AMathMLFactory(l), style(s) +{ + DOM::DOMImplementation di; + DOM::DocumentType dt; + result = di.createDocument(MATHML_NS_URI, "m:math", dt); +} + +#if 1 +void +CMathMLFactoryXSLT::documentModified(TDocument& doc) +{ + std::vector< std::pair > dirtyId; + if (TNode dirty = doc.dirtyNode()) + if (result.get_documentElement().hasAttribute("xref")) + dirtyId.push_back(std::make_pair(DOM::GdomeString("id"), + DOM::GdomeString("'" + std::string(dirty["id"]) + "'"))); + DOM::Document res = style.apply(doc.document(), dirtyId); + assert(res); + //style.save(doc.document(), stdout); + + if (DOM::Element wrapper = res.get_documentElement()) + { + if (DOM::Element root = wrapper.get_firstChild()) + if (DOM::Element oldRoot = result.get_documentElement().get_firstChild()) + { + bool ok = subst(oldRoot, root.getAttribute("xref"), result.importNode(root, true)); + assert(ok); + doc.clearDirty(); + } + else + { + result.get_documentElement().appendChild(result.importNode(root, true)); + } + } + else + { + // Something wrong happened while applying the stylesheet. + DOM::Element root = result.get_documentElement(); + DOM::Node p = root.get_firstChild(); + while (p) { + DOM::Node next = p.get_nextSibling(); + root.removeChild(p); + p = next; + } + logger.error("The stylesheet produced an empty document"); + } + + //style.save(result, stdout); +} +#else +void +CMathMLFactoryXSLT::documentModified(TDocument& doc) +{ + DOM::Document res = style.apply(doc.document()); + assert(res); + + if (DOM::Element root = res.get_documentElement()) + { + DOM::Element newRoot = root.get_firstChild(); + assert(newRoot); + + if (DOM::Element oldSubRoot = result.get_documentElement().get_firstChild()) + { + result.get_documentElement().replaceChild(result.importNode(newRoot, true), oldSubRoot); + } + else + { + result.get_documentElement().appendChild(result.importNode(newRoot, true)); + } + } + else + { + // Something wrong happened while applying the stylesheet. + DOM::Element root = result.get_documentElement(); + DOM::Node p = root.get_firstChild(); + while (p) { + DOM::Node next = p.get_nextSibling(); + root.removeChild(p); + p = next; + } + logger.error("The stylesheet produced an empty document"); + } +} +#endif + +bool +CMathMLFactoryXSLT::subst(const DOM::Element& e1, const DOM::GdomeString& id, const DOM::Element& e2) +{ + assert(e1); + assert(e2); + if (e1.getAttribute("xref") == id) + { + DOM::Node parent = e1.get_parentNode(); + assert(parent); + parent.replaceChild(e2, e1); + return true; + } + else + { + DOM::Node p = e1.get_firstChild(); + while (p) + { + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling(); + if (p) + if (subst(p, id, e2)) return true; + else p = p.get_nextSibling(); + } + return false; + } +} + diff --git a/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.hh b/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.hh new file mode 100644 index 000000000..34d8fa984 --- /dev/null +++ b/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.hh @@ -0,0 +1,47 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __CMathMLFactoryXSLT_hh__ +#define __CMathMLFactoryXSLT_hh__ + +#include +#include "AMathMLFactory.hh" + +class CMathMLFactoryXSLT : public AMathMLFactory +{ +public: + CMathMLFactoryXSLT(class ALogger&, const class GdomeSmartDOMExt::XSLTStylesheet&); + + virtual void documentModified(class TDocument&); + virtual GdomeSmartDOM::Document document(void) const { return result; }; + +private: + static bool subst(const GdomeSmartDOM::Element&, const GdomeSmartDOM::GdomeString&, const GdomeSmartDOM::Element&); + + const class GdomeSmartDOMExt::XSLTStylesheet& style; + GdomeSmartDOM::Document result; +}; + +#endif // __CMathMLFactoryXSLT_hh__ diff --git a/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.cc b/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.cc new file mode 100644 index 000000000..456f383b4 --- /dev/null +++ b/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.cc @@ -0,0 +1,102 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include "dom.hh" +#include "timer.hh" +#include "Diff.hh" +#include "TNode.hh" +#include "TDocument.hh" +#include "CMathMLFactoryXSLTDiff.hh" +#include "AMathMLConsumer.hh" + +CMathMLFactoryXSLTDiff::CMathMLFactoryXSLTDiff(ALogger& l, const DOMX::XSLTStylesheet& s) + : AMathMLFactory(l), style(s) +{ + DOM::DOMImplementation di; + DOM::DocumentType dt; + result = di.createDocument(MATHML_NS_URI, "m:math", dt); +} + +void +CMathMLFactoryXSLTDiff::documentModified(TDocument& doc) +{ +#if 0 + std::vector< std::pair > dirtyId; + if (TNode dirty = doc.dirtyNode()) + if (false && result.get_documentElement().hasAttribute("xref")) + dirtyId.push_back(std::make_pair(DOM::GdomeString("id"), + DOM::GdomeString("'" + std::string(dirty["id"]) + "'"))); +#endif + long t0 = getTimer(); + DOM::Document res = style.apply(doc.document()); + long t1 = getTimer(); + assert(res); + //cout << "*** THE TEX DOCUMENT" << endl; + //style.save(doc.document(), stdout); + //std::cout << "*** THE CURRENT DOCUMENT:" << std::endl; + //if (result) style.save(result, stdout); + //std::cout << "*** THE NEW DOCUMENT:" << std::endl; + //style.save(res, stdout); + //std::cout << "*** THE DIFF:" << std::endl; + DOMX::Diff diff = DOMX::Diff::diff(result, res); + //style.save(diff.document(), stdout); + long t2 = getTimer(); + diff.patch(); + long t3 = getTimer(); + + //std::cout << "=== APPLY = " << (t1 - t0) / 1000 << " DIFF = " << (t2 - t1) / 1000 << " PATCH = " << (t3 - t2) / 1000 << std::endl; + + doc.clearDirty(); +} + +bool +CMathMLFactoryXSLTDiff::subst(const DOM::Element& e1, const DOM::GdomeString& id, const DOM::Element& e2) +{ + assert(e1); + assert(e2); + if (e1.getAttribute("xref") == id) + { + DOMX::Diff diff = DOMX::Diff::diff(e1, e2); + //style.save(diff.document(), stdout); + diff.patch(); + return true; + } + else + { + DOM::Node p = e1.get_firstChild(); + while (p) + { + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling(); + if (p) + if (subst(p, id, e2)) return true; + else p = p.get_nextSibling(); + } + return false; + } +} + diff --git a/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.hh b/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.hh new file mode 100644 index 000000000..75ebfc260 --- /dev/null +++ b/DEVEL/mathml_editor/src/CMathMLFactoryXSLTDiff.hh @@ -0,0 +1,46 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __CMathMLFactoryXSLTDiff_hh__ +#define __CMathMLFactoryXSLTDiff_hh__ + +#include "AMathMLFactory.hh" + +class CMathMLFactoryXSLTDiff : public AMathMLFactory +{ +public: + CMathMLFactoryXSLTDiff(class ALogger&, const DOMX::XSLTStylesheet&); + + virtual void documentModified(class TDocument&); + virtual DOM::Document document(void) const { return result; }; + +private: + bool subst(const DOM::Element& e1, const DOM::GdomeString& id, const DOM::Element& e2); + + const DOMX::XSLTStylesheet& style; + DOM::Document result; +}; + +#endif // __CMathMLFactoryXSLT_hh__ diff --git a/DEVEL/mathml_editor/src/Diff.cc b/DEVEL/mathml_editor/src/Diff.cc new file mode 100644 index 000000000..d8df81201 --- /dev/null +++ b/DEVEL/mathml_editor/src/Diff.cc @@ -0,0 +1,393 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include +#include +#include +#include + +#include "Diff.hh" + +namespace GdomeSmartDOMExt +{ + + Diff + Diff::diff(const Document& dest, const Document& source, flatNodeEq flatEq) + { + assert(dest); + assert(source); + assert(flatEq); + + return diff(dest.get_documentElement(), source.get_documentElement(), flatEq); + } + + Diff + Diff::diff(const Element& dest, const Element& source, flatNodeEq flatEq) + { + assert(dest); + assert(source); + assert(flatEq); + + DOMImplementation di; + Document doc = di.createDocument(DDIFF_NS_URI, "diff:doc", DocumentType()); + Element root = doc.get_documentElement(); + root.setAttributeNS(XMLNS_NS_URI, "xmlns:diff", DDIFF_NS_URI); + + Diff diff(dest, doc, flatEq); + if (Node d = diff.diffNodes(dest, source)) root.appendChild(d); + else root.appendChild(doc.createElementNS(DDIFF_NS_URI, "diff:same")); + + return diff; + } + + struct NodeEqPredicate : std::binary_function + { + NodeEqPredicate(Diff::flatNodeEq e) : eq(e) { }; + bool operator()(const Node& n1, const Node& n2) const { return eq(n1, n2); }; + + private: + Diff::flatNodeEq eq; + }; + + std::vector + collectProperAttributes(const Node& n) + { + assert(n); + NamedNodeMap map = n.get_attributes(); + unsigned len = map.get_length(); + + std::vector res; + res.reserve(len); + for (unsigned i = 0; i < len; i++) + { + Node attr = map.item(i); + assert(attr); + if (attr.get_nodeName() != "xmlns" && attr.get_prefix() != "xmlns") res.push_back(attr); + } + + return res; + } + + bool + Diff::defaultFlatNodeEq(const Node& n1, const Node& n2) + { + assert(n1); + assert(n2); + + unsigned nodeType = n1.get_nodeType(); + if (nodeType != n2.get_nodeType()) return false; + + GdomeString ns1 = n1.get_namespaceURI(); + GdomeString ns2 = n2.get_namespaceURI(); + if (ns1 != ns2) return false; + + switch (nodeType) + { + case Node::ATTRIBUTE_NODE: + if (!ns1.null()) + { + assert(!ns2.null()); + if (n1.get_localName() != n2.get_localName()) return false; + } + else + { + assert(ns2.null()); + if (n1.get_nodeName() != n2.get_nodeName()) return false; + } + // WARNING: fallback for checking node value + case Node::TEXT_NODE: + case Node::CDATA_SECTION_NODE: + if (n1.get_nodeValue() != n2.get_nodeValue()) return false; + return true; + case Node::ELEMENT_NODE: + { + //cout << "comparing: " << n1.get_nodeName() << " ? " << n2.get_nodeName() << endl; + if (!ns1.null()) + { + assert(!ns2.null()); + if (n1.get_localName() != n2.get_localName()) return false; + } + else + { + assert(ns2.null()); + if (n1.get_nodeName() != n2.get_nodeName()) return false; + } +#if 1 + std::vector m1 = collectProperAttributes(n1); + std::vector m2 = collectProperAttributes(n2); + if (m1.size() != m2.size()) return false; + + for (unsigned i = 0; i < m1.size(); i++) + { + std::vector::iterator p2 = std::find_if(m2.begin(), m2.end(), std::bind2nd(NodeEqPredicate(defaultFlatNodeEq), m1[i])); + if (p2 == m2.end()) return false; + } +#endif + } + return true; + default: + return true; + } + + } + + void + Diff::sameChunk(const Node& res, unsigned long n) const + { + assert(n > 0); + Element s = doc.createElementNS(DDIFF_NS_URI, "diff:same"); + if (n != 1) + { + std::ostringstream os; + os << n; + s.setAttribute("count", os.str()); + } + res.appendChild(s); + } + + Node + Diff::diffNodes(const Node& p1, const Node& p2) const + { + if (eq(p1, p2)) + { + Element m = doc.createElementNS(DDIFF_NS_URI, "diff:merge"); + if (diffChildren(p1, p2, m)) return m; + else return Node(); + } + else + { + Element r = doc.createElementNS(DDIFF_NS_URI, "diff:replace"); + r.appendChild(doc.importNode(p2, true)); + return r; + } + } + + bool + Diff::diffChildren(const Node& n1, const Node& n2, const Node& res) const + { + assert(n1); + assert(n2); + assert(res); + + Node p1 = n1.get_firstChild(); + Node p2 = n2.get_firstChild(); + bool same = true; + unsigned nSame = 0; + while (p1 && p2) + { + if (Node d = diffNodes(p1, p2)) + { + same = false; + if (nSame > 0) + { + sameChunk(res, nSame); + nSame = 0; + } + res.appendChild(d); + } + else + nSame++; + + p1 = p1.get_nextSibling(); + p2 = p2.get_nextSibling(); + } + + if (p1) + { + same = false; + if (nSame > 0) + { + sameChunk(res, nSame); + nSame = 0; + } + + unsigned nRemoved = 0; + while (p1) + { + nRemoved++; + p1 = p1.get_nextSibling(); + } + + if (nRemoved > 0) + { + Element r = doc.createElementNS(DDIFF_NS_URI, "diff:remove"); + if (nRemoved > 1) + { + std::ostringstream os; + os << nRemoved; + r.setAttribute("count", os.str()); + } + res.appendChild(r); + } + } + + if (p2) + { + same = false; + if (nSame > 0) + { + sameChunk(res, nSame); + nSame = 0; + } + + Element i = doc.createElementNS(DDIFF_NS_URI, "diff:insert"); + while (p2) + { + i.appendChild(doc.importNode(p2, true)); + p2 = p2.get_nextSibling(); + } + res.appendChild(i); + } + + return !same; + } + + static Node + getFirstElement(const Node& n) + { + Node p = n.get_firstChild(); + while (p && p.get_nodeType() != Node::ELEMENT_NODE) + p = p.get_nextSibling(); + return p; + } + + static Node + getNextElement(const Node& n) + { + Node p = n.get_nextSibling(); + while (p && p.get_nodeType() != Node::ELEMENT_NODE) + p = p.get_nextSibling(); + return p; + } + + void + Diff::patchRootNode(const Node& node, const Element& elem) const + { + GdomeString name = elem.get_localName(); + if (name == "same") + { + if (elem.hasAttribute("count")) + { + unsigned count; + std::istringstream is(elem.getAttribute("count")); + is >> count; + assert(count == 1); + } + } + else if (name == "replace") + { + Document d1 = node.get_ownerDocument(); + Node parent = node.get_parentNode(); + assert(parent); +#if 0 + /* the following patch is because of gdome2 bug that prevents from + * replacing the root element of a document. + */ + assert(!node.get_previousSibling()); + assert(!node.get_nextSibling()); + parent.removeChild(node); + parent.appendChild(d1.importNode(getFirstElement(elem), true)); +#endif + parent.replaceChild(d1.importNode(getFirstElement(elem), true), node); + } + else if (name == "merge") + patchChildren(node, elem); + else + assert(0); + } + + void + Diff::patchChildren(const Node& n1, const Element& e2) const + { + Node p1 = n1.get_firstChild(); + Element p2 = getFirstElement(e2); + while (p2) + { + GdomeString name = p2.get_localName(); + if (name == "same") + { + unsigned count = 1; + if (p2.hasAttribute("count")) + { + std::istringstream is(p2.getAttribute("count")); + is >> count; + } + while (count-- > 0) + { + if (!p1) throw BADDiff("too few nodes in original document (same)"); + p1 = p1.get_nextSibling(); + } + } + else if (name == "replace") + { + Document d1 = n1.get_ownerDocument(); + if (!p1) throw BADDiff("no node to replace in original document"); + Node next = p1.get_nextSibling(); + n1.replaceChild(d1.importNode(p2.get_firstChild(), true), p1); + p1 = next; + } + else if (name == "insert") + { + Document d1 = n1.get_ownerDocument(); + for (Node i = p2.get_firstChild(); i; i = i.get_nextSibling()) + n1.insertBefore(d1.importNode(i, true), p1); + } + else if (name == "merge") + { + if (!p1) throw BADDiff("no node to merge in original document"); + patchChildren(p1, p2); + p1 = p1.get_nextSibling(); + } + else if (name == "remove") + { + unsigned count = 1; + if (p2.hasAttribute("count")) + { + std::istringstream is(p2.getAttribute("count")); + is >> count; + } + while (count-- > 0) + { + if (!p1) throw BADDiff("too few nodes in original document (remove)"); + Node next = p1.get_nextSibling(); + n1.removeChild(p1); + p1 = next; + } + } + else + assert(0); + + p2 = getNextElement(p2); + } + } + + void + Diff::patch() const + { + patchRootNode(dest, getFirstElement(doc.get_documentElement())); + } + +} diff --git a/DEVEL/mathml_editor/src/Diff.hh b/DEVEL/mathml_editor/src/Diff.hh new file mode 100644 index 000000000..a047d6baa --- /dev/null +++ b/DEVEL/mathml_editor/src/Diff.hh @@ -0,0 +1,77 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __Diff_hh__ +#define __Diff_hh__ + +#include + +#define XMLNS_NS_URI "http://www.w3.org/2000/xmlns/" +#define DDIFF_NS_URI "http://helm.cs.unibo.it/2002/DDIFF" + +namespace GdomeSmartDOMExt +{ + + using namespace GdomeSmartDOM; + + class Diff + { + public: + typedef bool (*flatNodeEq)(const Node&, const Node&); + static bool defaultFlatNodeEq(const Node&, const Node&); + + private: + Diff(const Node& n, const Document& d, flatNodeEq e) : dest(n), doc(d), eq(e) { }; + + public: + static Diff diff(const Document&, const Document&, flatNodeEq = defaultFlatNodeEq); + static Diff diff(const Element&, const Element&, flatNodeEq = defaultFlatNodeEq); + + Document document(void) const { return doc; }; + Node node(void) const { return dest; }; + + void patch(void) const; + + struct BADDiff + { + BADDiff(const std::string& s) : msg(s) { }; + const std::string msg; + }; + + private: + Node diffNodes(const Node&, const Node&) const; + bool diffChildren(const Node&, const Node&, const Node&) const; + void sameChunk(const Node&, unsigned long) const; + void patchRootNode(const Node&, const Element&) const; + void patchChildren(const Node&, const Element&) const; + + Document doc; + Node dest; + flatNodeEq eq; + }; + +} + +#endif // __ddiff_hh__ diff --git a/DEVEL/mathml_editor/src/ILPushLexer.cc b/DEVEL/mathml_editor/src/ILPushLexer.cc new file mode 100644 index 000000000..b82b52e5c --- /dev/null +++ b/DEVEL/mathml_editor/src/ILPushLexer.cc @@ -0,0 +1,51 @@ + +#include +#include + +#include "ALogger.hh" +#include "TToken.hh" +#include "ILPushLexer.hh" +#include "APushParser.hh" +#include "TDictionary.hh" + +ILPushLexer::ILPushLexer(ALogger& l, APushParser& p, TDictionary& d) : LPushLexer(l, p), dictionary(d) +{ + state = ACCEPT; +} + +bool +ILPushLexer::complete() +{ + if (state == MACRO) + { + std::list complete_list; + std::string new_buffer = dictionary.complete(buffer, complete_list); + + if (!complete_list.size()) + { + // no matching macro + logger.warning("no known macro with `" + buffer + "' prefix"); + } + else if (complete_list.size() == 1) + { + // good! we have found the macro + buffer = new_buffer; + } + else + { + // we have more than one matching macro + logger.warning("ambiguous prefix `" + buffer + "'"); + for (std::list::const_iterator p = complete_list.begin(); + p != complete_list.end(); + p++) + { + logger.info("Candidate: " + *p); + } + buffer = new_buffer; + } + + displayCursor(); + return true; + } + else return false; +} diff --git a/DEVEL/mathml_editor/src/ILPushLexer.hh b/DEVEL/mathml_editor/src/ILPushLexer.hh new file mode 100644 index 000000000..1af6f93ea --- /dev/null +++ b/DEVEL/mathml_editor/src/ILPushLexer.hh @@ -0,0 +1,21 @@ + +#ifndef __ILPushLexer_hh__ +#define __ILPushLexer_hh__ + +#include + +#include "LPushLexer.hh" + +class ILPushLexer : public LPushLexer +{ +public: + ILPushLexer(class ALogger&, class APushParser&, class TDictionary&); + ~ILPushLexer(void) { }; + + virtual bool complete(void); + +protected: + class TDictionary& dictionary; +}; + +#endif diff --git a/DEVEL/mathml_editor/src/ITPushLexer.cc b/DEVEL/mathml_editor/src/ITPushLexer.cc new file mode 100644 index 000000000..b4d1b6c12 --- /dev/null +++ b/DEVEL/mathml_editor/src/ITPushLexer.cc @@ -0,0 +1,44 @@ +#include +#include + +#include "ALogger.hh" +#include "TToken.hh" +#include "ITPushLexer.hh" +#include "APushParser.hh" +#include "TDictionary.hh" + +ITPushLexer::ITPushLexer(ALogger& l, APushParser& p, TDictionary& d) : TPushLexer(l, p), dictionary(d) +{ + state = ACCEPT; +} + +bool +ITPushLexer::complete() +{ + if (state == MACRO) + { + std::list complete_list; + std::string new_buffer = dictionary.complete(buffer, complete_list); + + if (!complete_list.size()) + { + // no matching macro + logger.warning("wrong prefix: nothing to complete"); + } + else if (complete_list.size() == 1) + { + // good! we have found the macro + buffer = new_buffer; + } + else + { + // we have more than one matching macro + logger.warning("prefix not sufficient"); + buffer = new_buffer; + } + + displayCursor(); + return true; + } + else return false; +} diff --git a/DEVEL/mathml_editor/src/ITPushLexer.hh b/DEVEL/mathml_editor/src/ITPushLexer.hh new file mode 100644 index 000000000..5b5ace351 --- /dev/null +++ b/DEVEL/mathml_editor/src/ITPushLexer.hh @@ -0,0 +1,20 @@ + +#ifndef __ITPushLexer_hh__ +#define __ITPushLexer_hh__ + +#include + +#include "TPushLexer.hh" + +class ITPushLexer : public TPushLexer +{ +public: + ITPushLexer(class ALogger&, class APushParser&, class TDictionary&); + ~ITPushLexer(void) { }; + + virtual bool complete(void); +private: + class TDictionary& dictionary; +}; + +#endif diff --git a/DEVEL/mathml_editor/src/LPushLexer.cc b/DEVEL/mathml_editor/src/LPushLexer.cc new file mode 100644 index 000000000..a16801bf0 --- /dev/null +++ b/DEVEL/mathml_editor/src/LPushLexer.cc @@ -0,0 +1,382 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include +#include + +#include "ALogger.hh" +#include "TToken.hh" +#include "LPushLexer.hh" +#include "APushParser.hh" + +LPushLexer::LPushLexer(ALogger& l, APushParser& p) : APushLexer(l, p) +{ + state = ACCEPT; +} + +void +LPushLexer::reset() +{ + buffer.erase(); + state = ACCEPT; + + displayCursor(); +} + +void +LPushLexer::flush() +{ + push(-1); +} + +void +LPushLexer::transaction(char ch, State newState) +{ + switch (ch) + { + case '{': parser.push(TToken(TToken::BEGIN)); break; + case '}': parser.push(TToken(TToken::END)); break; + case '$': parser.push(TToken(TToken::SHIFT)); break; + case '&': parser.push(TToken(TToken::ALIGN)); break; + case '\n': + case '\r': parser.push(TToken(TToken::EOL, ch)); break; + case '^': parser.push(TToken(TToken::SUPERSCRIPT)); break; + case '_': parser.push(TToken(TToken::SUBSCRIPT)); break; + case '\t': parser.push(TToken(TToken::IGNORABLE_SPACE, ch)); break; + case ' ': parser.push(TToken(TToken::SPACE, ch)); break; + case '~': parser.push(TToken(TToken::ACTIVE, ch)); break; + case '%': parser.push(TToken(TToken::COMMENT)); break; + default: parser.push(TToken(TToken::OTHER, ch)); break; + } + state = newState; +} + +void +LPushLexer::push(char ch) +{ + switch (state) + { + case ACCEPT: + if (ch == '\\') state = ESCAPE; + else if (ch == '#') state = PARAMETER; + else if (ch == -1) ; + else if (isalpha(ch)) + { + buffer.push_back(ch); + state = IDENTIFIER; + } + else if (isdigit(ch)) + { + buffer.push_back(ch); + state = NUMBER; + } + else transaction(ch, ACCEPT); + break; + case ESCAPE: + if (isalpha(ch)) + { + buffer.push_back(ch); + state = MACRO; + } + else if (ch == -1) error(); + else if (isdigit(ch)) + { + // in this case, the previous '\' is ignored + buffer.push_back(ch); + state = NUMBER; + } + else + { + parser.push(TToken(TToken::CONTROL, ch)); + state = ACCEPT; + } + break; + case MACRO: + if (ch == '\\') + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ESCAPE; + } + else if (ch == '#') + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = PARAMETER; + } + else if (isalpha(ch)) + buffer.push_back(ch); + else if (ch == -1) + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ACCEPT; + } + else if (isspace(ch)) + { + // we don't call transaction, because a white space is useful to exit from the macro, + // without "side effect". It's the TeX syntax. + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ACCEPT; + } + else if (isdigit(ch)) + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + buffer.push_back(ch); + state = NUMBER; + } + else + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + transaction(ch, ACCEPT); + } + break; + case PARAMETER: + if (ch == -1) error(); + else + { + parser.push(TToken(TToken::PARAMETER, ch)); + state = ACCEPT; + } + break; + case IDENTIFIER: + if (ch == -1) + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + state = ACCEPT; + } + else if (isalpha(ch) || isdigit(ch)) + { + buffer.push_back(ch); + } + else if (ch == '\\') state = ESCAPED_CHARACTER; + else if (ch == '#') + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + state = PARAMETER; + } + else + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + transaction(ch, ACCEPT); + } + break; + case ESCAPED_CHARACTER: + if ((ch == '-') || (ch == '_') || (ch == '/')) + { + buffer.push_back(ch); + state = IDENTIFIER; + } + else if (isalpha(ch)) + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + buffer.push_back(ch); + state = MACRO; + } + else if (ch == -1) error(); + else if (isdigit(ch)) + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + buffer.push_back(ch); + state = NUMBER; + } + else + { + parser.push(TToken(TToken::LETTER, buffer)); + buffer.erase(); + parser.push(TToken(TToken::CONTROL, ch)); + state = ACCEPT; + } + break; + case NUMBER: + if (isdigit(ch)) buffer.push_back(ch); + else if (isalpha(ch)) + { + parser.push(TToken(TToken::DIGIT, buffer)); + buffer.erase(); + buffer.push_back(ch); + state = IDENTIFIER; + } + else if (ch == -1) + { + parser.push(TToken(TToken::DIGIT, buffer)); + buffer.erase(); + state = ACCEPT; + } + else if (ch == '\\') + { + parser.push(TToken(TToken::DIGIT, buffer)); + buffer.erase(); + state = ESCAPE; + } + else if (ch == '#') + { + parser.push(TToken(TToken::DIGIT, buffer)); + buffer.erase(); + state = PARAMETER; + } + else + { + parser.push(TToken(TToken::DIGIT, buffer)); + buffer.erase(); + transaction(ch, ACCEPT); + } + break; + default: + assert(0); + break; + } + + displayCursor(); + +} + +void +LPushLexer::drop(bool alt) +{ + std::string restore = ""; + + switch (state) + { + case ACCEPT: + { + restore = parser.drop(alt); + long bs_pos = restore.find('\\'); + if ((restore.length() > 0) && (bs_pos != std::string::npos)) + { + // in this case we have to control the blackslash's position + if (bs_pos == 0) + { + //logger.debug(restore); + buffer = std::string(restore, 1, restore.length() - 1); + state = (buffer.length() > 0) ? MACRO : ESCAPE; + } + else + { + assert(bs_pos == restore.length() - 1); + buffer = std::string(restore, 0, bs_pos); + state = ESCAPED_CHARACTER; + } + } + else if (restore.length() > 0 && isdigit(restore[0])) + { + buffer = restore; + state = NUMBER; + } + else if (restore.length() > 0 && isalpha(restore[0])) + { + buffer = restore; + state = IDENTIFIER; + } + } + break; +/* if (restore.length() > 0 && restore[0] == '\\') + { + logger.debug(restore); + buffer = std::string(restore, 1, restore.length() - 1); + state = (buffer.length() > 0) ? MACRO : ESCAPE; + } + else if (restore.length() > 0 && isdigit(restore[0])) + { + buffer = restore; + state = NUMBER; + } + else if (restore.length() > 0 && isalpha(restore[0])) + { + buffer = restore; + state = IDENTIFIER; + } + break;*/ + case ESCAPED_CHARACTER: + state = IDENTIFIER; + break; + case ESCAPE: + state = ACCEPT; + break; + case MACRO: + if (alt) buffer.erase(); + else buffer.erase(buffer.length() - 1, 1); + if (buffer.length() == 0) state = ESCAPE; + break; + case IDENTIFIER: + switch (buffer[buffer.length() - 1]) + { + case '-': + case '_': + buffer.erase(buffer.length() - 1, 1); + if (alt) state = ESCAPED_CHARACTER; + break; + default: + if (alt) buffer.erase(); + else buffer.erase(buffer.length() - 1, 1); + if (buffer.length() == 0) state = ACCEPT; + break; + } + break; + case NUMBER: + if (alt) buffer.erase(); + else buffer.erase(buffer.length() - 1, 1); + if (buffer.length() == 0) state = ACCEPT; + break; + case PARAMETER: + default: + //assert(0); + error(); + break; + } + + displayCursor(); + +} + +void +LPushLexer::displayCursor() +{ + switch (state) + { + case ESCAPE: parser.setCursorHint("\\"); break; + case ESCAPED_CHARACTER: parser.setCursorHint(buffer + "\\"); break; + case MACRO: parser.setCursorHint("\\" + buffer); break; + case PARAMETER: parser.setCursorHint("#"); break; + case IDENTIFIER: parser.setCursorHint(buffer); break; + case NUMBER: parser.setCursorHint(buffer); break; + default: parser.setCursorHint(""); break; + } +} + +bool +LPushLexer::error() const +{ + return false; +} diff --git a/DEVEL/mathml_editor/src/LPushLexer.hh b/DEVEL/mathml_editor/src/LPushLexer.hh new file mode 100644 index 000000000..a9f95e200 --- /dev/null +++ b/DEVEL/mathml_editor/src/LPushLexer.hh @@ -0,0 +1,65 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __LPushLexer_hh__ +#define __LPushLexer_hh__ + +#include + +#include "APushLexer.hh" + +class LPushLexer : public APushLexer +{ +public: + LPushLexer(class ALogger&, class APushParser&); + virtual ~LPushLexer() { }; + + virtual void push(char); + virtual void drop(bool); + virtual bool complete(void) {}; + virtual void reset(void); + virtual void flush(void); + virtual bool error(void) const; + +protected: + enum State + { + ACCEPT, + ESCAPE, + MACRO, + PARAMETER, + IDENTIFIER, + ESCAPED_CHARACTER, + NUMBER + }; + + void transaction(char, State); + void displayCursor(void); + + State state; + std::string buffer; +}; + +#endif // __LPushLexer_hh__ diff --git a/DEVEL/mathml_editor/src/Makefile.am b/DEVEL/mathml_editor/src/Makefile.am new file mode 100644 index 000000000..1f3a12ddf --- /dev/null +++ b/DEVEL/mathml_editor/src/Makefile.am @@ -0,0 +1,57 @@ + +lib_LTLIBRARIES = libeditex.la + +libeditex_la_LDFLAGS = -version-info @EDITEX_VERSION_INFO@ + +libeditex_la_LIBADD = \ + $(GMETADOM_LIBS) \ + $(GDOMEXSLT_LIBS) \ + -lstdc++ + +libeditex_la_SOURCES = \ + Diff.cc \ + CLoggerConsole.cc \ + ITPushLexer.cc \ + ILPushLexer.cc \ + TPushLexer.cc \ + LPushLexer.cc \ + APushParser.cc \ + TPushParser.cc \ + AMathMLFactory.cc \ + CMathMLFactoryXSLT.cc \ + CMathMLFactoryXSLTDiff.cc \ + TDictionary.cc \ + TDocument.cc \ + TNode.cc \ + TTokenizer.cc \ + timer.cc + +pkginclude_HEADERS = \ + Diff.hh \ + ALogger.hh \ + CLoggerConsole.hh \ + APushLexer.hh \ + APushParser.hh \ + AMathMLFactory.hh \ + AMathMLConsumer.hh \ + CMathMLFactoryXSLT.hh \ + CMathMLFactoryXSLTDiff.hh \ + TPushLexer.hh \ + LPushLexer.hh \ + ITPushLexer.hh \ + ILPushLexer.hh \ + TPushParser.hh \ + TTokenizer.hh \ + TDictionary.hh \ + TDocument.hh \ + TNode.hh \ + TListener.hh \ + TToken.hh \ + globals.hh \ + dom.hh \ + timer.hh + +INCLUDES = \ + $(GMETADOM_CFLAGS) \ + $(GDOMEXSLT_CFLAGS) + diff --git a/DEVEL/mathml_editor/src/Makefile.in b/DEVEL/mathml_editor/src/Makefile.in new file mode 100644 index 000000000..0863b0101 --- /dev/null +++ b/DEVEL/mathml_editor/src/Makefile.in @@ -0,0 +1,431 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 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. + + +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 + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +lib_LTLIBRARIES = libeditex.la + +libeditex_la_LDFLAGS = -version-info @EDITEX_VERSION_INFO@ + +libeditex_la_LDADDS = $(GMETADOM_LIBS) $(GDOMEXSLT_LIBS) + + +libeditex_la_SOURCES = Diff.cc CLoggerConsole.cc ITPushLexer.cc ILPushLexer.cc TPushLexer.cc LPushLexer.cc APushParser.cc TPushParser.cc CMathMLFactoryXSLT.cc CMathMLFactoryXSLTDiff.cc TDictionary.cc TDocument.cc TNode.cc TTokenizer.cc + + +pkginclude_HEADERS = Diff.hh ALogger.hh CLoggerConsole.hh APushLexer.hh APushParser.hh AMathMLFactory.hh AMathMLConsumer.hh CMathMLFactoryXSLT.hh CMathMLFactoryXSLTDiff.hh TPushLexer.hh LPushLexer.hh ITPushLexer.hh ILPushLexer.hh TPushParser.hh TTokenizer.hh TDictionary.hh TDocument.hh TNode.hh TListener.hh TToken.hh globals.hh dom.hh + + +INCLUDES = $(GMETADOM_CFLAGS) $(GDOMEXSLT_CFLAGS) + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +LIBS = @LIBS@ +libeditex_la_LIBADD = +libeditex_la_OBJECTS = Diff.lo CLoggerConsole.lo ITPushLexer.lo \ +ILPushLexer.lo TPushLexer.lo LPushLexer.lo APushParser.lo \ +TPushParser.lo CMathMLFactoryXSLT.lo CMathMLFactoryXSLTDiff.lo \ +TDictionary.lo TDocument.lo TNode.lo TTokenizer.lo +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(pkginclude_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/APushParser.P .deps/CLoggerConsole.P \ +.deps/CMathMLFactoryXSLT.P .deps/CMathMLFactoryXSLTDiff.P .deps/Diff.P \ +.deps/ILPushLexer.P .deps/ITPushLexer.P .deps/LPushLexer.P \ +.deps/TDictionary.P .deps/TDocument.P .deps/TNode.P .deps/TPushLexer.P \ +.deps/TPushParser.P .deps/TTokenizer.P +SOURCES = $(libeditex_la_SOURCES) +OBJECTS = $(libeditex_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libeditex.la: $(libeditex_la_OBJECTS) $(libeditex_la_DEPENDENCIES) + $(CXXLINK) -rpath $(libdir) $(libeditex_la_LDFLAGS) $(libeditex_la_OBJECTS) $(libeditex_la_LIBADD) $(LIBS) +.cc.o: + $(CXXCOMPILE) -c $< +.cc.obj: + $(CXXCOMPILE) -c `cygpath -w $<` +.cc.lo: + $(LTCXXCOMPILE) -c $< + +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgincludedir) + @list='$(pkginclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(pkginclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkgincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLTLIBRARIES +install-exec: install-exec-am + +install-data-am: install-pkgincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool uninstall-pkgincludeHEADERS \ +install-pkgincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# 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/DEVEL/mathml_editor/src/TDictionary.cc b/DEVEL/mathml_editor/src/TDictionary.cc new file mode 100644 index 000000000..25f6c9674 --- /dev/null +++ b/DEVEL/mathml_editor/src/TDictionary.cc @@ -0,0 +1,316 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include "dom.hh" +#include "config.dirs" +#include "TDictionary.hh" +#include "TTokenizer.hh" +#include "CLoggerConsole.hh" + +static TDictionary::Entry undefinedEntry; + +static std::string +getURIBase(const std::string& uri) +{ + std::string::size_type slash = uri.rfind('/'); + if (slash != std::string::npos) return uri.substr(0, slash + 1); + else return ""; +} + +static std::string +getURIName(const std::string& uri) +{ + std::string::size_type slash = uri.rfind('/'); + if (slash != std::string::npos) return uri.substr(slash + 1, uri.size()); + else return uri; +} + +std::string +TDictionary::getDefaultDictionaryPath() +{ + return PKGDATADIR"/dictionary-tex.xml"; +} + +void +TDictionary::load(const std::string& uri) +{ + load(getURIName(uri), getURIBase(uri)); +} + +void +TDictionary::load(const std::string& name, const std::string& base) +{ + logger.debug("Dictionary: loading `" + base + name + "'"); + + DOM::DOMImplementation di; + DOM::Document doc = di.createDocumentFromURI((base + name).c_str()); + assert(doc); + load(doc, base); +} + +void +TDictionary::load(const DOM::Document& doc, const std::string& base) +{ + assert(doc); + + DOM::Element root = doc.get_documentElement(); + assert(root); + + CLoggerConsole logger; + TTokenizer tokenizer(logger); + + for (DOM::Node p = root.get_firstChild(); p; p = p.get_nextSibling()) + if (p.get_nodeType() == DOM::Node::ELEMENT_NODE && p.get_nodeName() == "include") + { + DOM::Element el = p; + assert(el); + if (el.hasAttribute("href")) + { + // WARNING: this may result into an infinite loop! + std::string href = el.getAttribute("href"); + std::string newBase = getURIBase(href); + std::string newName = getURIName(href); + if (newBase != "") load(newName, newBase); + else load(newName, base); + } + else + logger.warning("Dictionary: include statement with no href attribute (ignored)"); + } + else if (p.get_nodeType() == DOM::Node::ELEMENT_NODE && p.get_nodeName() == "entry") + { + DOM::Element el = p; + assert(el); + assert(el.hasAttribute("name")); + + std::string name = el.getAttribute("name"); + if (entries.find(name) != entries.end()) + logger.info("Dictionary: `" + name + "' is being redefined"); + + Entry entry; + + if (el.hasAttribute("class")) + { + std::string cls = el.getAttribute("class"); + if (cls == "o") entry.cls = OPERATOR; + else if (cls == "i") entry.cls = IDENTIFIER; + else if (cls == "n") entry.cls == NUMBER; + else entry.cls = MACRO; + } + else + entry.cls = MACRO; + + if (el.hasAttribute("val")) + { + entry.value = el.getAttribute("val"); + if (entry.cls == MACRO) + logger.warning("Dictionary: `" + name + "' has a specified value, but is classified as macro"); + } + + if (el.hasAttribute("pattern")) + { + if (entry.cls != MACRO) + logger.warning("Dictionary: `" + name + "' has a specified pattern, but is not classified as macro"); + + std::string pattern = el.getAttribute("pattern"); + if (pattern == "{}") + entry.leftOpen = entry.rightOpen = 1; + else if (pattern == "{") + entry.leftOpen = 1; + else if (pattern == "}") + entry.rightOpen = 1; + else + entry.pattern = tokenizer.tokenize(pattern); + } + +#if 0 + if (el.hasAttribute("infix")) + { + std::istringstream is(el.getAttribute("infix")); + unsigned infix; + is >> infix; + entry.infix = infix; + if (!el.hasAttribute("prefix")) entry.prefix = infix; + if (!el.hasAttribute("postfix")) entry.postfix = infix; + } + + if (el.hasAttribute("prefix")) + { + std::istringstream is(el.getAttribute("prefix")); + unsigned prefix; + is >> prefix; + entry.prefix = prefix; + if (!el.hasAttribute("infix")) + { + entry.infix = prefix; + if (!el.hasAttribute("postfix")) entry.postfix = prefix; + } + } + + if (el.hasAttribute("postfix")) + { + std::istringstream is(el.getAttribute("postfix")); + unsigned postfix; + is >> postfix; + entry.postfix = postfix; + if (!el.hasAttribute("infix")) + { + entry.infix = postfix; + if (!el.hasAttribute("prefix")) entry.prefix = postfix; + } + } +#endif + + if (el.hasAttribute("limits")) + { + std::istringstream is(el.getAttribute("limits")); + unsigned limits; + is >> limits; + entry.limits = limits; + } + + if (el.hasAttribute("embellishment")) + { + std::istringstream is(el.getAttribute("embellishment")); + unsigned embellishment; + is >> embellishment; + entry.embellishment = embellishment; + } + + if (el.hasAttribute("delimiter")) + { + if (entry.cls != OPERATOR && !entry.embellishment) + logger.warning("Dictionary: `" + name + "' delimiter ignored for non-operator"); + + std::istringstream is(el.getAttribute("delimiter")); + unsigned delimiter; + is >> delimiter; + entry.delimiter = delimiter; + } + + if (el.hasAttribute("table")) + { + if (entry.cls != MACRO) + logger.warning("Dictionary: `" + name + "' table ignored for non-macro"); + + std::istringstream is(el.getAttribute("table")); + unsigned table; + is >> table; + entry.table = table; + } + + entries[name] = entry; + } +} + +const TDictionary::Entry& +TDictionary::find(const std::string& name) const +{ + Dictionary::const_iterator p = entries.find(name); + if (p != entries.end()) return (*p).second; + else + { + logger.warning("unknown entry `" + name + "'"); + return undefinedEntry; + } +} + +std::string +TDictionary::complete(const std::string prefix, std::list& complete_list) const +{ + bool no_match = true; + std::string new_prefix = ""; + for (Dictionary::const_iterator i = entries.begin(); i != entries.end(); i++) + { + if ((*i).first.find(prefix) == 0) + { + complete_list.push_front((*i).first); + if (no_match) + { + // it's the first match + no_match = false; + new_prefix = (*i).first; + } + else + { + // in this case, new_prefix has been set yet. + std::string s1 = (*i).first.substr(prefix.length()); // s1 is the high part of the matching string + std::string s2 = new_prefix.substr(prefix.length()); // s2 is the high part of new_prefix +#if 0 + long j = 0; // it's the number of common characters + while (s1[j] == s2[j]) j++; +#endif + std::string::const_iterator i1 = s1.begin(); + std::string::const_iterator i2 = s2.begin(); + while (i1 != s1.end() && i2 != s2.end() && *i1 == *i2) i1++, i2++; + new_prefix = prefix + s1.substr(0, i1 - s1.begin()); + //new_prefix = (j) ? prefix + s1.substr(0, i1 - s1.begin()) : prefix; + } + } + } + + return new_prefix; +} + +bool +TDictionary::Entry::paramDelimited(unsigned i) const +{ + assert(i < pattern.size()); + assert(pattern[i].category == TToken::PARAMETER); + // a parameter is delimited if it is NOT the last one + // AND the next argument is not a parameter + return i + 1 < pattern.size() && pattern[i + 1].category != TToken::PARAMETER; +} + +bool +TDictionary::Entry::lastDelimiter(unsigned i) const +{ + assert(i < pattern.size()); + assert(pattern[i].category != TToken::PARAMETER); + // a token is the last delimiter if it is the last token + // of the pattern or if the next token is a parameter) + return i + 1 == pattern.size() || pattern[i + 1].category == TToken::PARAMETER; +} + +unsigned +TDictionary::Entry::previousParam(unsigned i) const +{ + // this method return the position in the pattern of the + // parameter placed in a position preceding i. + // If no preceding i parameter present, the method return + // pattern.size(). + // To know the position of the last parameter, call this + // method with i == pattern.size() + unsigned j = i - 1; + + while (pattern[j].category != TToken::PARAMETER) + { + if (j) j--; + else return pattern.size(); + } + return j; +} diff --git a/DEVEL/mathml_editor/src/TDictionary.hh b/DEVEL/mathml_editor/src/TDictionary.hh new file mode 100644 index 000000000..4864630f9 --- /dev/null +++ b/DEVEL/mathml_editor/src/TDictionary.hh @@ -0,0 +1,129 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TDictionary_hh__ +#define __TDictionary_hh__ + +#include + +#include +#include +#if defined(HAVE_EXT_HASH_MAP) +#include +#elif defined(HAVE_HASH_MAP) +#include +#else +#error "no hash_map could be found" +#endif +#include + +#include "dom.hh" +#include "TToken.hh" + +class TDictionary +{ +public: + TDictionary(class ALogger& l) : logger(l) { }; + ~TDictionary() { }; + + enum Form + { + INFIX, + PREFIX, + POSTFIX + }; + + enum EntryClass + { + UNDEFINED, + MACRO, + OPERATOR, + IDENTIFIER, + NUMBER + }; + + struct Entry + { + Entry(void) + { + cls = UNDEFINED; + table = delimiter = limits = embellishment = leftOpen = rightOpen = 0; + }; + + std::vector pattern; + std::string value; + + bool defined(void) const { return cls != UNDEFINED; }; + bool hasArguments(void) const { return !pattern.empty(); }; + bool paramDelimited(unsigned) const; + bool lastDelimiter(unsigned) const; + unsigned previousParam(unsigned) const; + + EntryClass cls; + unsigned delimiter : 1; + unsigned limits : 1; + unsigned embellishment : 1; + unsigned leftOpen : 1; + unsigned rightOpen : 1; + unsigned table : 1; + }; + + static std::string getDefaultDictionaryPath(void); + + void load(const std::string&); + void load(const std::string&, const std::string&); + void load(const DOM::Document&, const std::string& = ""); + const Entry& find(const std::string&) const; + std::string complete(const std::string, std::list&) const; + +private: +#if defined(HAVE_EXT_HASH_MAP) + struct StringHash : public std::unary_function< std::string, size_t > + { size_t operator()(const std::string& s) const { return __gnu_cxx::hash()(s.c_str()); } }; +#elif defined(HAVE_HASH_MAP) + struct StringHash : public std::unary_function< std::string, size_t > + { size_t operator()(const std::string& s) const { return hash()(s.c_str()); } }; +#else +#error "no hash_map could be found" +#endif + +#if 0 + struct StringEq : public std::binary_function< std::string, std::string, bool > + { bool operator()(const std::string&, const class String*) const; }; +#endif + + class ALogger& logger; +#if defined(HAVE_EXT_HASH_MAP) + typedef __gnu_cxx::hash_map< std::string, Entry, StringHash > Dictionary; +#elif defined(HAVE_HASH_MAP) + typedef std::hash_map< std::string, Entry, StringHash > Dictionary; +#else +#error "no hash_map could be found" +#endif + Dictionary entries; +}; + +#endif // __TDictionary_hh__ + diff --git a/DEVEL/mathml_editor/src/TDocument.cc b/DEVEL/mathml_editor/src/TDocument.cc new file mode 100644 index 000000000..ca4878e6c --- /dev/null +++ b/DEVEL/mathml_editor/src/TDocument.cc @@ -0,0 +1,213 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include "globals.hh" +#include "dom.hh" +#include "TDocument.hh" + +TDocument::TDocument() +{ + DOM::DOMImplementation di; + DOM::DocumentType dt; + doc = di.createDocument(TML_NS_URI, "tml:tex", dt); + DOM::Element root = doc.get_documentElement(); + assert(root); + root.setAttributeNS(XMLNS_NS_URI, "xmlns:tml", TML_NS_URI); + + DOM::EventTarget et(doc); + assert(et); + et.addEventListener("DOMSubtreeModified", *this, false); +} + +TDocument::~TDocument() +{ + //DOM::Element root = doc.get_documentElement(); + DOM::EventTarget et(doc); + assert(doc); + et.removeEventListener("DOMSubtreeModified", *this, false); +} + +void +TDocument::reset() +{ + DOM::Element root = doc.createElementNS(TML_NS_URI, "tml:tex"); + root.setAttributeNS(XMLNS_NS_URI, "xmlns:tml", TML_NS_URI); + doc.replaceChild(root, doc.get_documentElement()); + clearDirty(); +} + +void +TDocument::serialize(const char* filename) const +{ + DOM::DOMImplementation di; + di.saveDocumentToFile(doc, filename, GDOME_SAVE_LIBXML_INDENT); +} + +std::string +TDocument::makeId(unsigned id) +{ + std::ostringstream os; + os << "I" << id; + return os.str(); +} + +TNode +TDocument::create(const std::string& name, unsigned id) const +{ + DOM::Element elem = doc.createElementNS(TML_NS_URI, "tml:" + name); + if (id > 0) elem.setAttribute("id", makeId(id)); + return elem; +} + +TNode +TDocument::createC(const std::string& name, unsigned id) const +{ + TNode m = create("c", id); + m["name"] = name; + return m; +} + +TNode +TDocument::createT(const std::string& name, const std::string& text, unsigned id) const +{ + TNode t = create(name, id); + t["val"] = text; + return t; +} + +unsigned +TDocument::nodeDepth(const DOM::Node& node) +{ + DOM::Node n = node; + + unsigned depth = 0; + while (n) + { + depth++; + n = n.get_parentNode(); + } + return depth; +} + +DOM::Node +TDocument::findCommonAncestor(const DOM::Node& node1, const DOM::Node& node2) +{ + DOM::Node n1 = node1; + DOM::Node n2 = node2; + + unsigned d1 = nodeDepth(n1); + unsigned d2 = nodeDepth(n2); + + // cout << "finding common ancestor " << d1 << " " << d2 << endl; + + while (d1 < d2) + { + assert(n2); + n2 = n2.get_parentNode(); + d2--; + } + + while (d1 > d2) + { + assert(n1); + n1 = n1.get_parentNode(); + d1--; + } + + while (n1 != n2) + { + assert(n1); + assert(n2); + n1 = n1.get_parentNode(); + n2 = n2.get_parentNode(); + } + + return n1; +} + +DOM::Node +TDocument::findIdNode(const DOM::Node& node) +{ + DOM::Node n = node; + while (n) + { + if (n.get_nodeType() == DOM::Node::ELEMENT_NODE) + { + DOM::Element el = n; + if (el.hasAttribute("id")) return el; + } + n = n.get_parentNode(); + } + + return DOM::Node(0); +} + +TNode +TDocument::getNodeByIdAux(const TNode& node, const std::string& id) +{ + if (node.hasId(id)) return node; + else + for (TNode p = node.first(); p; p = p.next()) + if (TNode res = getNodeByIdAux(p, id)) return res; + return TNode(); +} + +TNode +TDocument::getNodeById(unsigned id) const +{ + DOM::Element root = doc.get_documentElement(); + assert(root); + return getNodeByIdAux(root, makeId(id)); +} + +void +TDocument::handleEvent(const DOM::Event& ev) +{ + DOM::MutationEvent me(ev); + assert(me); + +#if 0 + if (dirty) + cout << "TDocument::handleEvent DIRTY BEFORE = " << dirty.getAttribute("id") << endl; + else + cout << "TDocument::handleEvent DIRTY BEFORE = (nil)" << endl; +#endif + + if (DOM::Node node = me.get_target()) + if (dirty) + dirty = findIdNode(findCommonAncestor(dirty, node)); + else + dirty = findIdNode(node); + else + assert(0); + +#if 0 + cout << "TDocument::handleEvent target = " << DOM::Node(me.get_target()).get_nodeName() << " DIRTY AFTER = " + << dirty.getAttribute("id") << " ME = " << DOM::Node(me.get_target()).get_nodeName() << endl; +#endif +} diff --git a/DEVEL/mathml_editor/src/TDocument.hh b/DEVEL/mathml_editor/src/TDocument.hh new file mode 100644 index 000000000..02d1dc38d --- /dev/null +++ b/DEVEL/mathml_editor/src/TDocument.hh @@ -0,0 +1,69 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TDocument_hh__ +#define __TDocument_hh__ + +#include "dom.hh" +#include "TNode.hh" + +class TDocument : private DOM::EventListener +{ +public: + TDocument(void); + ~TDocument(); + + void reset(void); + TNode create(const std::string&, unsigned = 0) const; + TNode createG(unsigned id = 0) const { return create("g", id); }; + TNode createC(const std::string&, unsigned = 0) const; + TNode createT(const std::string&, const std::string&, unsigned = 0) const; + TNode createI(const std::string& text, unsigned id = 0) const { return createT("i", text, id); }; + TNode createN(const std::string& text, unsigned id = 0) const { return createT("n", text, id); }; + TNode createO(const std::string& text, unsigned id = 0) const { return createT("o", text, id); }; + TNode createS(unsigned id = 0) const { return createT("s", "", id); }; + + DOM::Document document(void) const { return doc; }; + + TNode getNodeById(unsigned) const; + TNode root(void) { return doc.get_documentElement(); }; + TNode dirtyNode(void) const { return dirty; }; + void clearDirty(void) { dirty = DOM::Element(0); }; + + void serialize(const char*) const; + +private: + DOM::Document doc; + DOM::Element dirty; + + virtual void handleEvent(const DOM::Event&); + static std::string makeId(unsigned); + static TNode getNodeByIdAux(const TNode&, const std::string&); + static unsigned nodeDepth(const DOM::Node&); + static DOM::Node findCommonAncestor(const DOM::Node&, const DOM::Node&); + static DOM::Node findIdNode(const DOM::Node&); +}; + +#endif // __TDocument_hh__ diff --git a/DEVEL/mathml_editor/src/TListener.hh b/DEVEL/mathml_editor/src/TListener.hh new file mode 100644 index 000000000..16fea6d71 --- /dev/null +++ b/DEVEL/mathml_editor/src/TListener.hh @@ -0,0 +1,35 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TListener_hh__ +#define __TListener_hh__ + +class TListener +{ +public: + virtual void callback(TDocument&) = 0; +}; + +#endif // __TListener_hh__ diff --git a/DEVEL/mathml_editor/src/TNode.cc b/DEVEL/mathml_editor/src/TNode.cc new file mode 100644 index 000000000..3c67d9d60 --- /dev/null +++ b/DEVEL/mathml_editor/src/TNode.cc @@ -0,0 +1,236 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include "globals.hh" +#include "TNode.hh" +#include + +TNode +TNode::next() const +{ + assert(node); + DOM::Node p = node.get_nextSibling(); + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling(); + return p; +} + +TNode +TNode::nextL() const +{ + assert(node); + if (TNode n = next()) + if (n.isG()) return n.firstL(); + else return n; + else return TNode(); +} + +TNode +TNode::prev() const +{ + assert(node); + DOM::Node p = node.get_previousSibling(); + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling(); + return p; +} + +TNode +TNode::prevL() const +{ + assert(node); + if (TNode n = prev()) + if (n.isG()) return n.lastL(); + else return n; + else return TNode(); +} + +TNode +TNode::last() const +{ + assert(node); + DOM::Node p = node.get_lastChild(); + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling(); + return p; +} + +TNode +TNode::lastL() const +{ + assert(node); + if (TNode n = last()) + if (n.isG()) return n.lastL(); + else return n; + else + return TNode(); +} + +TNode +TNode::first() const +{ + assert(node); + DOM::Node p = node.get_firstChild(); + while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling(); + return p; +} + +TNode +TNode::firstL() const +{ + assert(node); + if (TNode n = first()) + if (n.isG()) return n.firstL(); + else return n; + else + return TNode(); +} + +TNode +TNode::core() const +{ + assert(node); + // check also if there is a macro embellishment (\not) + if (isSb() || isSp()) return first().core(); + else return *this; +} + +TNode +TNode::parent() const +{ + assert(node); + DOM::Node p = node.get_parentNode(); + assert(!p || p.get_nodeType() == DOM::Node::ELEMENT_NODE); + return p; +} + +unsigned +TNode::size() const +{ + assert(node); + unsigned size = 0; + TNode p = first(); + while (p) + { + p = p.next(); + size++; + } + + return size; +} + +void +TNode::remove() const +{ + assert(node); + DOM::Node parent = node.get_parentNode(); + parent.removeChild(node); +} + +void +TNode::replace(const TNode& newNode) const +{ + assert(node); + DOM::Node parent = node.get_parentNode(); + parent.replaceChild(newNode.node, node); +} + +void +TNode::replace(const TNode& first, const TNode& last) const +{ + assert(node); + assert(first); + + TNode p = first; + while (p != last) + { + TNode next = p.next(); + insert(p); + p = next; + } + remove(); +} + +void +TNode::insert(const TNode& newNode) const +{ + assert(node); + DOM::Node parent = node.get_parentNode(); + parent.insertBefore(newNode.node, node); +} + +void +TNode::append(const TNode& newNode) const +{ + assert(node); + node.appendChild(newNode.node); +} + +void +TNode::append(const TNode& first, const TNode& last) const +{ + assert(node); + assert(first); + assert(last); + + TNode p = first; + while (p != last) + { + TNode next = p.next(); + append(p); + p = next; + } +} + +void +TNode::prepend(const TNode& newNode) const +{ + assert(node); + DOM::Node parent = node.get_parentNode(); + parent.insertBefore(newNode.node, parent.get_firstChild()); +} + +#if 0 +#endif + +TNode +TNode::child(unsigned pos) const +{ + assert(node); + TNode p = first(); + while (p && pos-- > 0) p = p.next(); + return p; +} + +std::string +TNode::get(const std::string& name) const +{ + assert(node); + return node.getAttribute(name); +} + +void +TNode::set(const std::string& name, const std::string& value) const +{ + assert(node); + node.setAttribute(name, value); +} diff --git a/DEVEL/mathml_editor/src/TNode.hh b/DEVEL/mathml_editor/src/TNode.hh new file mode 100644 index 000000000..adbfe69a6 --- /dev/null +++ b/DEVEL/mathml_editor/src/TNode.hh @@ -0,0 +1,107 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TNode_hh__ +#define __TNode_hh__ + +#include "dom.hh" +#include "globals.hh" +#include "TDictionary.hh" + +class TNode +{ +public: + TNode(void) : node(0) { }; + TNode(const DOM::Node& n) : node(n) { }; + TNode(const DOM::Element& elem) : node(elem) { }; + TNode(const TNode& n) : node(n.node) { }; + + TNode next(void) const; + TNode nextL(void) const; + TNode prev(void) const; + TNode prevL(void) const; + TNode core(void) const; + TNode parent(void) const; + TNode first(void) const; + TNode firstL(void) const; + TNode last(void) const; + TNode lastL(void) const; + TNode child(unsigned) const; + unsigned size(void) const; + bool empty(void) const { return !first().node; }; + std::string value(void) const { return (*this)["val"]; }; + + class ProxyAttr + { + public: + ProxyAttr(const DOM::Element& n, const std::string& s) : node(n), name(s) { }; + operator std::string() const { return node.getAttribute(name); }; + ProxyAttr& operator=(const std::string& v) { node.setAttribute(name, v); }; + bool operator==(const std::string& v) const { return node.getAttribute(name) == v; }; + bool operator!=(const std::string& v) const { return node.getAttribute(name) != v; }; + private: + DOM::Element node; + std::string name; + }; + + operator bool() const { return node; }; + DOM::Element element(void) const { return node; }; + bool operator==(const TNode& n) const { return node == n.node; }; + bool operator!=(const TNode& n) const { return node != n.node; }; + TNode operator[](int i) const { return child(i); }; + ProxyAttr operator[](const char* s) const { return ProxyAttr(node, s); }; + + //void advance(const TNode&) const; + void remove(void) const; + void replace(const TNode&) const; + void replace(const TNode&, const TNode&) const; + void insert(const TNode&) const; + void append(const TNode&) const; + void append(const TNode&, const TNode&) const; + void prepend(const TNode&) const; + + std::string get(const std::string&) const; + void set(const std::string&, const std::string&) const; + + std::string name(void) const { return node.get_localName(); }; + std::string nameC(void) const { return node.getAttribute("name"); }; + bool hasId(void) const { return node.hasAttribute("id"); }; + bool hasId(const std::string& id) const { return node.getAttribute("id") == id; }; + bool is(const std::string& s) const { return name() == s; }; + bool isG(void) const { return is("g"); }; + bool isSb(void) const { return is("sb"); }; + bool isSp(void) const { return is("sp"); }; + bool isC(void) const { return is("c"); } + bool isC(const std::string& name) const + { return isC() && node.getAttribute("name") == name; }; + bool isT(void) const { return (is("o") || is("i") || is("n") || is("s")); }; + + friend class TDocument; + +private: + DOM::Element node; +}; + +#endif // __TNode_hh__ diff --git a/DEVEL/mathml_editor/src/TPushLexer.cc b/DEVEL/mathml_editor/src/TPushLexer.cc new file mode 100644 index 000000000..da15822c3 --- /dev/null +++ b/DEVEL/mathml_editor/src/TPushLexer.cc @@ -0,0 +1,207 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include +#include + +#include "TToken.hh" +#include "TPushLexer.hh" +#include "APushParser.hh" + +TPushLexer::TPushLexer(ALogger& l, APushParser& p) : APushLexer(l, p) +{ + state = ACCEPT; +} + +void +TPushLexer::reset() +{ + buffer.erase(); + state = ACCEPT; + + displayCursor(); +} + +void +TPushLexer::flush() +{ + push(-1); +} + +void +TPushLexer::transaction(char ch, State newState) +{ + switch (ch) + { + case '{': parser.push(TToken(TToken::BEGIN)); break; + case '}': parser.push(TToken(TToken::END)); break; + case '$': parser.push(TToken(TToken::SHIFT)); break; + case '&': parser.push(TToken(TToken::ALIGN)); break; + case '\n': + case '\r': parser.push(TToken(TToken::EOL, ch)); break; + case '^': parser.push(TToken(TToken::SUPERSCRIPT)); break; + case '_': parser.push(TToken(TToken::SUBSCRIPT)); break; + case '\t': + case ' ': parser.push(TToken(TToken::IGNORABLE_SPACE, ch)); break; + case '~': parser.push(TToken(TToken::ACTIVE, ch)); break; + case '%': parser.push(TToken(TToken::COMMENT)); break; + default: + if (isalpha(ch)) parser.push(TToken(TToken::LETTER, ch)); + else if (isdigit(ch)) parser.push(TToken(TToken::DIGIT, ch)); + else parser.push(TToken(TToken::OTHER, ch)); + break; + } + state = newState; +} + +void +TPushLexer::push(char ch) +{ + switch (state) + { + case ACCEPT: + if (ch == '\\') state = ESCAPE; + else if (ch == '#') state = PARAMETER; + else if (ch == -1) ; + else transaction(ch, ACCEPT); + break; + case ESCAPE: + if (isalpha(ch)) + { + buffer.push_back(ch); + state = MACRO; + } + else if (ch == -1) error(); + else + { + parser.push(TToken(TToken::CONTROL, ch)); + state = ACCEPT; + } + break; + case MACRO: + if (ch == '\\') + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ESCAPE; + } + else if (ch == '#') + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = PARAMETER; + } + else if (isalpha(ch)) + buffer.push_back(ch); + else if (ch == -1) + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + state = ACCEPT; + } + else + { + parser.push(TToken(TToken::CONTROL, buffer)); + buffer.erase(); + if (isspace(ch)) state = IGNORE_SPACE; + else transaction(ch, ACCEPT); + } + break; + case IGNORE_SPACE: + if (ch == '\\') state = ESCAPE; + else if (ch == '#') state = PARAMETER; + else if (isspace(ch)) ; + else if (ch == -1) state = ACCEPT; + else transaction(ch, ACCEPT); + break; + case PARAMETER: + if (ch == -1) error(); + else + { + parser.push(TToken(TToken::PARAMETER, ch)); + state = ACCEPT; + } + break; + default: + assert(0); + break; + } + + displayCursor(); + +} + +void +TPushLexer::drop(bool alt) +{ + std::string restore = ""; + + switch (state) + { + case ACCEPT: + case IGNORE_SPACE: + restore = parser.drop(alt); + if (restore.length() > 0 && restore[0] == '\\') + { + buffer = std::string(restore, 1, restore.length() - 1); + state = (buffer.length() > 0) ? MACRO : ESCAPE; + } + break; + case ESCAPE: + state = ACCEPT; + break; + case MACRO: + if (alt) buffer.erase(); + else buffer.erase(buffer.length() - 1, 1); + if (buffer.length() == 0) state = ESCAPE; + break; + case PARAMETER: + default: + assert(0); + break; + } + + displayCursor(); + +} + +void +TPushLexer::displayCursor() +{ + switch (state) + { + case ESCAPE: parser.setCursorHint("\\"); break; + case MACRO: parser.setCursorHint("\\" + buffer); break; + case PARAMETER: parser.setCursorHint("#"); break; + default: parser.setCursorHint(""); break; + } +} + +bool +TPushLexer::error() const +{ + return false; +} diff --git a/DEVEL/mathml_editor/src/TPushLexer.hh b/DEVEL/mathml_editor/src/TPushLexer.hh new file mode 100644 index 000000000..2aafd6ec9 --- /dev/null +++ b/DEVEL/mathml_editor/src/TPushLexer.hh @@ -0,0 +1,64 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TPushLexer_hh__ +#define __TPushLexer_hh__ + +#include + +#include "APushLexer.hh" + +class TPushLexer : public APushLexer +{ +public: + TPushLexer(class ALogger&, class APushParser&); + virtual ~TPushLexer() { }; + + virtual void push(char); + virtual void drop(bool); + virtual bool complete(void) { }; + virtual void reset(void); + virtual void flush(void); + virtual bool error(void) const; + +protected: + enum State + { + ACCEPT, + ESCAPE, + MACRO, + IGNORE_SPACE, + PARAMETER + }; + + void transaction(char, State); + void displayCursor(void); + + State state; + std::string buffer; + +}; + +#endif // __TPushLexer_hh__ diff --git a/DEVEL/mathml_editor/src/TPushParser.cc b/DEVEL/mathml_editor/src/TPushParser.cc new file mode 100644 index 000000000..0c96fe439 --- /dev/null +++ b/DEVEL/mathml_editor/src/TPushParser.cc @@ -0,0 +1,1952 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include "ALogger.hh" +#include "TPushParser.hh" +#include "AMathMLFactory.hh" + +TPushParser::TPushParser(ALogger& l, const TDictionary& d) : APushParser(l), dictionary(d) +{ + init(); +} + +TPushParser::TPushParser(ALogger& l, AMathMLFactory& f, const TDictionary& d) : APushParser(l, f), dictionary(d) +{ + init(); +} + +TPushParser::~TPushParser() +{ +} + +void +TPushParser::init() +{ + cursor = doc.create("cursor"); + cursor["visible"] = "1"; + hiddenCursor = 0; + reset(); +} + +void +TPushParser::reset() +{ + nextId = 1; + if (cursor.parent()) cursor.remove(); + cursor["val"] = ""; + doc.reset(); + doc.root().append(cursor); + if (factory && !frozen()) factory->documentModified(doc); +} + +TNode +TPushParser::PRIME() +{ + const TDictionary::Entry entry = dictionary.find("prime"); + if (entry.cls == TDictionary::OPERATOR) + { + TNode op = doc.createO(entry.value, nextId++); + op["name"] = "prime"; + return op; + } + else + { + TNode op = doc.createO("?", nextId++); + return op; + } +} + +bool +TPushParser::do_begin() +{ + TNode parent = cursor.parent(); + if (parent.isC() && dictionary.find(parent.nameC()).table) + { + TNode row = doc.create("row"); + TNode cell = doc.create("cell"); + TNode g = doc.createG(); + row.append(cell); + cell.append(g); + g.append(cursor); + parent.append(row); + } + else + { + TNode g = doc.createG(nextId++); + cursor.replace(g); + g.append(cursor); + } + return true; +} + +bool +TPushParser::correctBrace() +{ + // this method MUST be invoked when the cursor is child of a + // phantom group, which in turn is the last rightOpen MACRO's child. + // The only way to exit from a rightOpen MACRO is opening a group before + // inserting the MACRO and, once the MACRO is completely inserted, closing + // the group. + // This method return true if the condition above is true. False, otherwise. + assert(cursor.parent() && cursor.parent().isG() && !cursor.parent().hasId()); + TNode parent = cursor.parent(); + assert(parent.parent() && parent.parent().isC()); + assert(!frames.empty()); + Frame& frame = frames.top(); + assert(frame.entry.rightOpen); + assert(parent.parent().last() == parent); + + TNode c = parent.parent(); + bool stop = false; + bool ok = false; + TNode node = c.parent(); + do + { + if (node.isG() && node.hasId()) + { + // in this case, the rightOpen MACRO is a child of a group with id. + // So, the '}' is correct + ok = true; + stop = true; + } + else if (node.isG()) + { + // the MACRO is a phantom group's child. We have to control why we + // have this phantom group + TNode nodeParent = node.parent(); + if (nodeParent && nodeParent.isC()) + { + // we have to control the nature of this MACRO + const TDictionary::Entry& entry = dictionary.find(nodeParent.nameC()); + if (entry.rightOpen && node == nodeParent.last()) + { + // in this case we have to re-iterate the process + node = nodeParent.parent(); + } + else stop = true; + } + else stop = true; + } + else + { + // at the moment we assume that a MACRO cannot be child of an element other than a group + stop = true; + } + } + while (!stop); + + return ok; +} + +bool +TPushParser::do_end() +{ + TNode parent = cursor.parent(); + if (parent && parent.isG() && parent.hasId()) + { + // normal closing brace for an explicitly open group + cursor.remove(); + advance(parent); + return true; + } + else if (parent && parent.isG() && parent.parent() && parent.parent().is("cell")) + { + assert(!frames.empty()); + // closing brace for a structure in which & or \cr have been used + TNode row = parent.parent().parent(); + assert(row && row.is("row")); + assert(row.parent()); + advance(row); + return true; + } + else if (parent && parent.isG() && !parent.hasId() && parent.parent() && !parent.parent().is("math")) + { + // In this case, we have to control the cursor's grand parent. + TNode gparent = parent.parent(); + + if (gparent.isC() && gparent.last() == parent) + { + // a frame MUST be in the stack + assert(!frames.empty()); + + // we have to control the nature of this macro + if (frames.top().entry.rightOpen) + { + // in this case, the '}' character is the proper way to exit from the phantom group, and + // in particular, this character means that the user wants to exit from the MACRO. + // A rightOpen MACRO MUST be descendant of a group with Id. This '}' is the closing brace of this + // group. So, we have to control if this group exists. This groyp could exist, but this MACRO could + // be another MACRO's child, so we have to control this last MACRO recursively. This recurive control + // is done by the correctBrace method. + if (!correctBrace()) + { + // the '}' is not correct + logger.warning("nothing to close"); + return false; + } + else + { + cursor.remove(); + advance(parent); + return true; + } + } + else + { + logger.warning("ignored closing brace"); + return false; + } + } + else + { + // at the moment, a phantom group with the cursor inside can be a MACRO's child or a cell's child, and these cases + // are handled in other blocks of code. + logger.error("do_end: strange TML tree"); + return false; + } + } + else + { + // In this case, there is a redundant '}', so we can ignore it and + // emit an error + logger.warning("There is so no corresponding'{'"); + return false; + //assert(0); + } +} + +bool +TPushParser::do_shift() +{ + TNode parent = cursor.parent(); + assert(parent); + if (parent.is("tex")) + { + TNode math = doc.create("math", nextId++); + TNode g = doc.createG(); + cursor.replace(math); + math.append(g); + g.append(cursor); + return true; + } + else if (parent.isG() && !parent.hasId() && parent.parent() && parent.parent().is("math")) + { + if (cursor.prev()) + { + // there is something before the cursor, hence this is the + // closing math shift + if (parent.parent()["display"] != "1") + { + // one math shift is enough to close it + cursor.remove(); + return true; + } + else + { + // we need two closing math shifts + //cursor.remove(); ?? + parent.parent().append(cursor); + return true; // ??? + } + } + else if (parent.parent()["display"] != "1") + { + // there is nothing before the cursor, and the math is not + // in display mode, so this must be a double math shift + parent.parent()["display"] = "1"; + return true; + } + else + { + parent.parent().append(cursor); + return true; + } + } + else if (parent.is("math")) + { + cursor.remove(); + return true; + } + else + { + logger.warning("not allowed here"); + return false; + } +} + +bool +TPushParser::do_align() +{ + TNode parent = cursor.parent(); + if (parent && parent.isG() && parent.hasId()) + { + // alignment tab used for the first time inside a group + TNode row = doc.create("row"); + TNode cell = doc.create("cell"); + TNode g = doc.createG(); + row.append(cell); + cell.append(g); + g.append(parent.first(), cursor); + return true; + } + else if (parent && parent.isG() && parent.parent().is("cell")) + { + // alignment tab used within a cell + TNode oldCell = parent.parent(); + assert(oldCell && oldCell.is("cell")); + TNode row = oldCell.parent(); + assert(row && row.is("row")); + TNode cell = doc.create("cell"); + if (oldCell.next()) oldCell.next().insert(cell); + else row.append(cell); + TNode g = doc.createG(); + cell.append(g); + g.append(cursor); + return true; + } + else + { + logger.warning("alignment tab used outside matrix"); + return false; + } +} + +bool +TPushParser::do_eol() +{ + //if (cursor.parent()) cursor.remove(); + logger.warning("ignored token"); + return false; +} + +bool +TPushParser::do_parameter(const std::string& p) +{ + logger.warning("ignored token"); + return false; +} + +bool +TPushParser::do_subscript() +{ + TNode parent = cursor.parent(); + if (parent.isG()) + { + TNode prev = cursor.prev(); + if (!prev) + { + TNode elem = doc.create("sb", nextId++); + TNode g = doc.createG(); + cursor.replace(elem); + elem.append(g); + elem.append(cursor); + return true; + } + else + { + TNode elem = doc.create("sb", nextId++); + prev.replace(elem); + elem.append(prev); + elem.append(cursor); + return true; + } + } + else if (parent.isSb() && cursor == parent[1]) + { + if (parent["under"] == "1") + { + logger.warning("already under"); + return false; + } + else + { + parent["under"] = "1"; + return true; + } + } + else + { + logger.warning("ignored token"); + return false; + } +} + +bool +TPushParser::do_superscript() +{ + TNode parent = cursor.parent(); + if (parent.isG()) + { + TNode prev = cursor.prev(); + if (!prev) + { + TNode elem = doc.create("sp", nextId++); + TNode g = doc.createG(); + cursor.replace(elem); + elem.append(g); + elem.append(cursor); + return true; + } + else + { + TNode elem = doc.create("sp", nextId++); + prev.replace(elem); + elem.append(prev); + elem.append(cursor); + return true; + } + } + else if (parent.isSp() && cursor == parent[1]) + { + if (parent["over"] == "1") + { + logger.warning("already over"); + return false; + } + else + { + parent["over"] = "1"; + return true; + } + } + else + { + logger.warning("ignored token"); + return false; + } +} + +bool +TPushParser::do_ignorablespace(const std::string& s) +{ + // At the moment, do nothing +} + +bool +TPushParser::do_space(const std::string&) +{ + TNode elem = doc.createS(nextId++); + cursor.replace(elem); + advance(elem); + return true; +} + +bool +TPushParser::do_letter(const std::string& s) +{ + //TNode parent = cursor.parent(); + TNode elem = doc.createI(s, nextId++); + cursor.replace(elem); + advance(elem); + return true; +} + +bool +TPushParser::do_digit(const std::string& s) +{ + TNode elem = doc.createN(s, nextId++); + cursor.replace(elem); + advance(elem); + return true; +} + +bool +TPushParser::isPrimes(const TNode& node) const +{ + assert(node); + return node.isG() && node.last() && node.last().is("o") && node.last()["name"] == "prime"; +} + +bool +TPushParser::do_apostrophe() +{ + if (cursor.parent() && cursor.parent().isG()) + { + if (TNode prev = cursor.prev()) + { + if (prev.isSp() && prev[1] && isPrimes(prev[1])) + { + prev[1].append(PRIME()); + return true; + } + else if (prev.isSb() && prev[0] && + prev[0].isSp() && prev[0][1] && + isPrimes(prev[0][1])) + { + prev[0][1].append(PRIME()); + return true; + } + else + { + TNode elem = doc.create("sp"); + TNode g = doc.createG(); + prev.replace(elem); + elem.append(prev); + elem.append(g); + g.append(PRIME()); + return true; + } + } + else + { + // is it an error? + logger.warning("you have to insert an identifier before a ''"); + return false; + } + } + else + { + logger.warning("cursor has to be in a group"); + return false; + } +} + +bool +TPushParser::do_other(const std::string& s) +{ + switch (s[0]) + { + case '\'': + return do_apostrophe(); + break; + default: + /*cout << "TPushParser::do_other " << s << endl; + cout << "DOCUMENT: " << static_cast(cursor.element().get_ownerDocument()) << endl;*/ + TNode elem = doc.createT("o", s, nextId++); + cursor.replace(elem); + advance(elem); + return true; + break; + } +} + +bool +TPushParser::do_active(const std::string&) +{ + // ??? space? + logger.warning("ignored token"); + return false; +} + +bool +TPushParser::do_comment() +{ + // ??? + return false; +} + +bool +TPushParser::do_cr() +{ + TNode parent = cursor.parent(); + if (parent && parent.isG() && + parent.parent() && parent.parent().is("cell") && + parent.parent().parent() && parent.parent().parent().is("row")) + { + TNode oldRow = parent.parent().parent(); + assert(oldRow); + TNode table = oldRow.parent(); + assert(table); + TNode row = doc.create("row"); + TNode cell = doc.create("cell"); + TNode g = doc.createG(); + if (oldRow.next()) oldRow.next().insert(row); + else table.append(row); + row.append(cell); + cell.append(g); + g.append(cursor); + return true; + } + else + { + // at the moment, \cr can only be used inside a table + logger.warning("cr used outside a table"); + return false; + } +} + +bool +TPushParser::do_control(const std::string& name) +{ + if (name == "cr") return do_cr(); + else + { + TNode parent = cursor.parent(); + const TDictionary::Entry& entry = dictionary.find(name); + switch (entry.cls) + { + case TDictionary::IDENTIFIER: + { + TNode t = doc.createI(entry.value, nextId++); + t["name"] = name; + cursor.replace(t); + advance(t); + return true; + } + break; + case TDictionary::OPERATOR: + { + TNode t = doc.createO(entry.value, nextId++); + t["name"] = name; + cursor.replace(t); + advance(t); + return true; + } + break; + case TDictionary::NUMBER: + { + TNode t = doc.createN(entry.value, nextId++); + t["name"] = name; + cursor.replace(t); + advance(t); + return true; + } + break; + case TDictionary::MACRO: + { + if (parent.isG()) + { + TNode m = doc.createC(name, nextId++); + cursor.replace(m); + if (entry.leftOpen && entry.rightOpen) + { + assert(entry.pattern.empty()); + assert(parent.isG()); + TNode g1 = doc.createG(); + g1["left-open"] = "1"; + g1.append(parent.first(), m); + m.append(g1); + TNode g2 = doc.createG(); + g2.append(cursor); + m.append(g2); + frames.push(Frame(entry)); + } + else if (entry.leftOpen) + { + assert(parent.isG()); + TNode g = doc.createG(); + g["left-open"] = "1"; + g.append(parent.first(), m); + m.append(g); + advance(m); + } + else if (entry.rightOpen) + { + assert(entry.pattern.empty()); + assert(parent.isG()); + TNode g = doc.createG(); + g.append(cursor); + m.append(g); + frames.push(Frame(entry)); + } + else if (!entry.pattern.empty()) + { + frames.push(Frame(entry)); + if (entry.paramDelimited(0)) + { + TNode g = doc.createG(); + m.append(g); + g.append(cursor); + } + else + m.append(cursor); + } + else + { + // it's an empty macro + advance(m); + } + return true; + } + else if (!entry.pattern.size() && !entry.rightOpen && !entry.leftOpen) + { + // a macro with no arguments and no right open and no left open, can be child of anything + TNode m = doc.createC(name, nextId++); + cursor.replace(m); + advance(m); + return true; + } + else + { + // a macro with arguments or a rightOpen or leftOpen macro must be a group's child + logger.warning("ignored token: this macro should be in a group"); + return false; + } + } + break; + case TDictionary::UNDEFINED: + { + logger.warning("using undefined macro " + name); + TNode m = doc.createC(name, nextId++); + cursor.replace(m); + advance(m); + return true; + } + break; + default: + { + //assert(0); + logger.warning("ignored token"); + return false; + } + } + } +} + +std::string +TPushParser::drop_prev_token(bool special) +{ + assert(cursor.prev()); + assert(cursor.parent()); + TNode prev = cursor.prev(); + assert(prev.isT()); + + DOM::UCS4String ucs4val = prev.element().getAttribute("val"); + bool macro = prev.element().hasAttribute("name"); + std::string utf8name; + if (macro) utf8name = prev.element().getAttribute("name"); + + cursor.remove(); + prev.replace(cursor); + + if (cursor.parent().isC()) + { + // in this case we have removed an element of a MACRO. + // we can assert that this element was a non delimited argument + assert(!frames.empty()); + Frame& frame = frames.top(); + assert(frame.pos > 0); + frame.pos--; + } + + if ((ucs4val.length() > 1)) + { + if (!macro) + { + // in this case we can return the content of ucs4val, but we have + // to convert it in a utf8 + DOM::GdomeString gdsval(ucs4val); + std::string utf8val(gdsval); + switch (utf8val[utf8val.length() - 1]) + { + case '-': + case '_': + return (special) ? std::string(utf8val, 0, utf8val.length() - 1) + "\\" : std::string(utf8val, 0, utf8val.length() - 1); + default: return (special) ? "" : std::string(utf8val, 0, utf8val.length() - 1); + } + } + else + { + // in this case, the content of val could be in unicode, + // but we have the attribute name, which doesn't contain character not representable + // with a byte. + return (special) ? "\\" + utf8name : ""; + } + } + else if (macro && special) return "\\" + utf8name; + else return ""; +} + +std::string +TPushParser::drop_prev_script(bool special) +{ + // this method deletes an sp or an sb preceding the cursor + assert(cursor.prev()); + assert(cursor.parent()); + TNode prev = cursor.prev(); + assert(prev.is("sp") || prev.is("sb")); + cursor.remove(); + prev.append(cursor); + // we can invoke the drop_prev, because a sp (sb) MUST have two children + // but we cannot invoke do_drop_script because it assumes when called, the first + // child has been removed yet. + if (cursor.prev().isG() && !prev.hasId()) + { + // in this case, the user has inserted a sequence of '. + // Hence, we force a normal deletion, because the behavior must be the same + // for the two kind of deletion + return drop_prev(false); + } + else return drop_prev(special); +} + +std::string +TPushParser::drop_prev_group(bool special) +{ + assert(cursor.prev() && cursor.prev().isG()); + TNode parent = cursor.parent(); + TNode prev = cursor.prev(); + cursor.remove(); + prev.append(cursor); + + if (parent.isC() && prev.hasId()) + { + // this previous group is a macro's argument. Entering inside it means that + // this argument becomes incomplete. Hence, we have to decrement the member pos. + assert(!frames.empty()); + frames.top().pos--; + } + + if (special) return ""; + else + { + // a group could have no children, so the drop_prev is not appropriate + // so, this method is not equivalent to the one above + return do_drop(special); + } +} + +std::string +TPushParser::drop_prev_macro(bool special) +{ + assert(cursor.parent()); + assert(cursor.prev()); + TNode prev = cursor.prev(); + assert(prev.isC()); + + std::string macro_name = prev.nameC(); + + TNode parent = cursor.parent(); + + const TDictionary::Entry& entry = dictionary.find(prev["name"]); + + if (!entry.defined()) + { + // In this case, with a normal deletion, we completely remove the macro. + // With a special deletion, we remove the last character of the macro's name. + cursor.remove(); + prev.replace(cursor); + if (cursor.parent().isC()) + { + // we have removed a macro's child + assert(!frames.empty()); + frames.top().pos--; + } + if (special) return "\\" + macro_name.erase(macro_name.length() - 1, 1); // we remove the last char, because an undefined macro's name is visible + return ""; + } + else + { + // we start to remove a MACRO. Different actions must be taken, based on the nature + // of the MACRO. In some cases, we can't remove the MACRO immediately, in other + // cases it's correct. In the first set of cases, we have to update the stack, pushing + // a frame in it with a correct value of pos, in the + // second one, we must not push a frame in the stack + + if (entry.rightOpen) + { + // In this fragment of code we also handle the leftOpen && rightOpen MACRO. + // since the control element is rightOpen, the cursor should be placed after + // the last child of the control element's last child, and than, we try to remove something. + // A frame MUST be pushed in the stack, because we dont' know if the following actions + // will completely remove the MACRO. + frames.push(Frame(entry)); + + // Since the MACRO is rightOpen, the last child of the MACRO must be a phantom group + assert(prev.last().isG() && !prev.last().hasId()); + + cursor.remove(); + prev.last().append(cursor); + + if (special) return ""; + else + { + // the drop_prev is not appropriate, because the last child of the MACRO could have no children + return do_drop_phantom_group(special); + } + } + else if (entry.leftOpen) + { + // the leftOpen MACRO MUST have one and only one child, which MUST be a phantom group + // In this case, we do not have to push a frame in the stack, because we remove the + // MACRO immediately, substituting it with the content of the phantom group. + // We could remove the last child of the phantom group, but + // it's not clear if it's the correct behavior of the graphical deletion. + // At the moment, to give a standard behavior, we remove the last element. + // With a special deletion, we do not remove it. + assert(prev.first()); + assert(prev.first().isG()); + assert(prev.first() == prev.last()); + + TNode g = prev.first(); + if (g.size()) + { + // in this case, the phantom group has at least one child, so we can call the + // TNode::replace. + g.remove(); + prev.replace(g.first(), TNode()); + parent.append(cursor); + if (special) return "\\" + macro_name; + else return do_drop(special); + } + else + { + // otherwise, the phantom group has no children, so we remove it, also the MACRO. + cursor.remove(); + g.remove(); + prev.replace(cursor); + if (special) return "\\" + macro_name; + else + { + // Once removed this empty macro, we could try to remove something else. + // This would be justified by the fact that, generally, an empty macro gives no visual information + // about it. + return do_drop(special); // special is false + } + } + } + else if (!entry.pattern.empty()) + { + // we have to start to remove a MACRO which accepts arguments. + // If the MACRO accepts arguments, the MACRO has at least one child + assert(prev.size() >= 1); + + // Differnt actions must be taken, based on the nature of the last child + // of the MACRO. We have to distinguish the case in which it's a delimited argument, + // frome the one in which it's a not delimited argument. + if (prev.last().isG() && !prev.last().hasId()) + { + if (special) + { + // in this case, we have to start removing the last delimiter + frames.push(Frame(entry, entry.pattern.size() - 2)); + + cursor.remove(); + prev.last().append(cursor); + + std::string last_del = entry.pattern[entry.pattern.size() - 1].value; + + return "\\" + last_del; + } + else + { + // the last argument of the MACRO is a delimited argumet. We ideally remove + // the sequence of delimiters + cursor.remove(); + prev.last().append(cursor); + // we have to push a frame with a correct value of pos + assert(entry.previousParam(entry.pattern.size()) != entry.pattern.size()); + + unsigned sequence_length = entry.pattern.size() - entry.previousParam(entry.pattern.size()) - 1; + unsigned p = entry.pattern.size() - sequence_length - 1; + // now, p is the correct value of pos, and we can push the frame. + frames.push(Frame(entry, p)); + + // To give a standard behavior to the graphical deletion, we remove the last + // element of the macro. Since we are in a phantom group, we can invoke the + // do_drop_phantom_group(special). + return do_drop_phantom_group(special); + } + } + else + { + // in this case, the last child of the MACRO is not a delimited argument, so we try + // to remove it, but we have to take differnt actions if the MACRO is a table with rows or not. + cursor.remove(); + if (entry.table == 1 && prev.last().is("row")) + { + // in this case the cursor has to be appended to the group associated to + // the last cell of the last row of the table + assert(prev.last().last().is("cell") && prev.last().last().first().isG()); + prev.last().last().first().append(cursor); + + // we have to push a frame in the stack. Since tables has a pattern size = 1, we have to + // set pos at 0, because appending the cursor to the last cell means that this argument + // is not whole inserted. + // We don't call frames.push(Frame(entry)), because it incoditionaly set pos at 0. The + // following line is more general + frames.push(Frame(entry, entry.pattern.size() - 1)); + if (special) + { + // to type a table with rows and cells, the user had typed a + // "{", and to exit from it, the user had inserted a "}". + // Since we are in a special deletion, we just idealy remove the "}" + return ""; + } + else return do_drop_phantom_group(special); + } + else + { + // we push a frame in the stack with a correct value of member pos. + // This correct value is the size of the pattern - 1, because we have been started to delete + // a MACRO. It means that all of the MACRO's arguments have been inserted, but + frames.push(Frame(entry, entry.pattern.size())); + prev.append(cursor); + return drop_prev(special); + } + + } // end of the else of the if (prev.last().isG() && !prev.last().hasId()) + + } // end of if (!entry.pattern.empty()) + else + { + // if we are here, the MACRO preceding the cursor, is !(rightOpen || leftOpen), + // and has no pattern. It means that it has no children. + // We can replace it with the cursor + assert(prev.size() == 0); + cursor.remove(); + prev.replace(cursor); + if (cursor.parent().isC()) + { + // we have removed an empty macro, which was a non delimited argument of a macro. + // We have to decrement pos + assert(!frames.empty()); + frames.top().pos--; + } + + if (special) return "\\" + macro_name; + else return ""; + + // now we could start to remove something else. This behavior would be justified by the + // fact that, generally, an empty MACRO gives no visual information about it. + // To adopt this behavior, just remove the comment to the following instruction + // return do_drop(special); + } + } // end of defined MACRO + +} + +std::string +TPushParser::drop_prev(bool special) +{ + // if in this function, the prev of cursor does exist, also the parent and we want a graphical deletion. + + assert(cursor.prev()); + assert(cursor.parent()); + + TNode prev = cursor.prev(); + + if (prev.isT()) + { + return drop_prev_token(special); + } + else if (prev.isSp() || prev.isSb()) + { + return drop_prev_script(special); + } + else if (prev.isG()) + { + return drop_prev_group(special); + } + else if (prev.isC()) + { + // here, we also treat the case in which the MACRO is a table + return drop_prev_macro(special); + } + else + { + // not handled. Future cases... + return ""; + } + +} // end of method + +void +TPushParser::rgreplace_father() +{ + // this method MUST only be invoked, when the cursor + // is the only child of a group with id. This function + // replaces the group with the cursor. But if the new parent + // is a group with id and the cursor is the only child of the + // group, the new parent is replaced...and so on. + // r stands for recursive, g stands for graphical. + assert(cursor.parent()); + assert(cursor.parent().isG() && cursor.parent().hasId()); + + TNode parent = cursor.parent(); + + while (parent.isG() && parent.hasId() && (parent.first() == cursor)) + { + parent.replace(cursor); + parent = cursor.parent(); + } +} + +std::string +TPushParser::do_drop_script(bool special) +{ + // If we are here, the cursor is child of a script (sp or sb) and + // this means that a prev does exist and that there is one and only one + // element preceding the cursor. The sp's (or sb's) parent + // MUST NOT be a MACRO. + // The element preceding the cursor is the base of the script. + + assert(cursor.parent() && (cursor.parent().isSp() || cursor.parent().isSb())); + TNode parent = cursor.parent(); + + assert(parent.size() == 2); + assert(parent.parent() && !parent.parent().isC()); + + TNode prev = cursor.prev(); + cursor.remove(); + if (prev.isG() /*&& !prev.hasId()*/ && (prev.size() == 0)) + { + // in this case, the script's base is a group with no elements, so + // we have to remove the entire MACRO, replacing it with the cursor. + // This situation occurs when the user had typed something like this + // $....{}^ + // or this + // $^ + // or this + // $...{^ + // + if (special && prev.hasId()) + { + // in this case, the user has typed: ...{}^ + // hence we idealy remove the ^ + parent.replace(prev); + prev.parent().append(cursor); + return ""; + } + else if (!prev.hasId()) + { + // we idealy remove the ^, but the phantom group + // has to be removed, also + prev.remove(); + parent.replace(cursor); + return ""; + } + else + { + prev.remove(); + parent.replace(cursor); + + // since the script had no children, we can try to remove something else. + // Since we don't know who is cursor's parent, and who is cursor's preceding + // element, we invoke the do_drop() + return do_drop(special); + } + } + else + { + // in this case, the prev has to replace the script. + parent.replace(prev); + prev.parent().append(cursor); + // now prev have a preceding element + assert(cursor.parent().size() > 1); + + if (special) return ""; + else + { + // to give a standard behavior, we try to remove the element, which was + // the script's base. + return do_drop(special); + } + } + +} // end of method do_drop_script + +std::string +TPushParser::do_drop_macro(bool special) +{ + // If we are here, the cursor is a child of a MACRO and this means + // that there is an open frame for the control element + // and this element is closed at either side (no leftOpen no rightOpen) + // and the MACRO is waiting for a not delimited argument, so + // we can assert that frame.entry.pattern.size() >= 1 + assert(cursor.parent() && cursor.parent().isC()); + TNode parent = cursor.parent(); + + // this string is useful iff we have a special deletion. + std::string macro_name = parent.nameC(); + + assert(!frames.empty()); + Frame& frame = frames.top(); + assert(frame.entry.pattern.size() >= 1); + + // we have to take different actions, based on if a preceding element exists + // or not + TNode prev = cursor.prev(); + if (!prev) + { + // in this case, a prev does not exist, so the actions of deleting means + // that we have to remove the MACRO. So we have to pop the stack. + assert(frame.pos == 0); + + parent.replace(cursor); + frames.pop(); + + if (special) return "\\" + macro_name; + else + { + // Since the macro had no children and this is a graphical deletion, we try + // to remove something else + return do_drop(special); + } + } + else + { + // a prev does exist, we have to control if it's a delimited argument or not. + if (prev.isG() && !prev.hasId()) + { + // in this case, prev is a delimited argument, so we have + // to ideally remove the sequence of delimiters + Frame& frame = frames.top(); + assert(frame.pos > 1); + cursor.remove(); + prev.append(cursor); + assert(frame.entry.previousParam(frame.pos) != frame.entry.pattern.size()); + + if (special) + { + // in this case we have to start removing the last delimimeter. + // It means that we return in a situation where the user has not entirely + // inserted the delimited argument. So, we have to decrement frame.pos of + // two units: the delimiter and the actual argument + std::string last_del = frame.entry.pattern[frame.pos - 1].value; + frame.pos = frame.pos - 2; + return "\\" + last_del; + } + else + { + // these 3 lines of code update the member pos. + unsigned sequence_length = frame.pos - frame.entry.previousParam(frame.pos) - 1; + assert(sequence_length); + frame.pos = frame.pos - sequence_length - 1; + + // since it's a graphical deletion, we have to remove the current preceding element. + // We don't invoke the drop_prev(), because a do_drop_phantom_group is more general. + return do_drop_phantom_group(special); + } + } + else + { + // the prev is not a delimited argument, so we have to try to remove it. + // We "try", because the prev might be something that + // a simple deletion cannot remove completely + return drop_prev(special); + } + } + +} + +std::string +TPushParser::do_drop_groupId(bool special) +{ + // if we are here, the cursor's parent is a group with Id + assert(cursor.parent() && cursor.parent().isG() && cursor.parent().hasId()); + TNode parent = cursor.parent(); + + // we have to take different actions based on if the cursor has a preceding + // element or not + TNode prev = cursor.prev(); + if (prev) + { + // the cursor has a preceding element, so we try to remove it + if (special) return drop_prev(special); + else + { + std::string str = drop_prev(special); + + // We control if the group has to be removed, because the cursor + // might be the only element of the group. + // But we have to be careful, because drop_prev could change the TML tree + // more than we think...parent could no longer exist! + parent = cursor.parent(); + if ((parent.first() == cursor) && parent.isG() && parent.hasId()) + rgreplace_father(); + + return str; + } + } + else + { + // the cursor has no preceding elements, so we have to remove the + // group. + if (special) + { + parent.replace(cursor); + return ""; + } + else + { + rgreplace_father(); + // we have to re-start the process, because it' a graphical deletion + return do_drop(special); + } + } + +} // end of method do_drop_groupId() + +std::string +TPushParser::do_drop_phantom_group(bool special) +{ + // if we are here, the cursor MUST be a child of a + // phantom group. + assert(cursor.parent() && cursor.parent().isG() && !cursor.parent().hasId()); + + TNode parent = cursor.parent(); + + // now we have to control if the cursor has a preceding element or not + TNode prev = cursor.prev(); + if (prev) + { + if (parent.parent() && parent.parent().isC()) + { + // there is a frame in the stack + assert(!frames.empty()); + if (frames.top().entry.pattern.size()) + { + Frame& frame = frames.top(); + if (special) + { + // we are in a delimited argument. If the user has inserted a proper subset of the + // delimiters'sequence, we start to remove the previous delimiter. Start to remove + // a delimiter means that that delimiter must be removed from the count of inserted delimiters. + // It means that we have to decrement the member pos. + if (frame.entry.pattern[frame.pos].category != TToken::PARAMETER) + { + std::string del = frame.entry.pattern[frame.pos].value; + frame.pos--; + return "\\" + del; + } + } + else + { + // we are in a delimited argument. If the user has inserted a proper subset of the delimiters'sequence, + // we have to remove the portion the user has inserted. + while (frame.entry.pattern[frame.pos].category != TToken::PARAMETER) frame.pos--; + } + } + } + + // the cursor has a preceding element, so we try to remove it + std::string str = drop_prev(special); + + if (special) return str; + else + { + // now we have to control the parent, to handle the case of primes. But we have returned from a drop_prev(), which + // could change the TML tree. So not asssuming that cursor's parent is unchanged is convenient. + parent = cursor.parent(); + if (parent.isG() && !parent.hasId() && (parent.size() == 1) && parent.parent().isSp()) + { + // in this case the drop_prev has removed the only element preceding the cursor. + // Since the phantom group is an sp's child, the user has removed all \' in the + // phantom group. + // Now we have some possibilities: + // - we can replace the phantom group with the cursor, giving the user the chance to insert a new + // exponent + // - we can remove the phantom group and the sp element, recreating the state before the user inserted the first + // prime. + // At the moment we implement the second one. + assert(parent.parent().size() == 2); + TNode gparent = parent.parent(); + TNode base = gparent.first(); + cursor.remove(); + parent.remove(); + gparent.replace(base); + // now base's parent is no more gparent + base.parent().append(cursor); + + return str; + } + else if (parent.isG() && !parent.hasId() && parent.parent().isSp()) + { + // in this case we have to place the cursor after the sp element + cursor.remove(); + assert(parent.parent().parent()); + parent.parent().parent().append(cursor); + return str; + } + else return str; + } + } + else + { + // in this case the cursor is the only element of the phantom group, + // so we have to remove it. But, a phantom group has a special role, + // so we have to control the grand father of the cursor. + TNode gfather = parent.parent(); + if (!gfather) + { + // If here, the TML tree is in an inconsistent state + logger.error("TML tree in a inconsistent state"); + return ""; + } + else if (gfather.isC()) + { + // in this case the phantom group is child of a MACRO. + // We have to control the nature of this MACRO. + assert(!frames.empty()); + Frame& frame = frames.top(); + + // this variable is useful in a special deletion + std::string macro_name = gfather.nameC(); + + if (frame.entry.leftOpen && frame.entry.rightOpen) + { + // in this case, the cursor'parent is in the second and last child + // of the MACRO. We can assert that the grand father has two + // children, which are both phantom groups + assert(gfather.size() == 2); + assert((gfather.last() == parent) && (gfather.first().isG() && !gfather.first().hasId())); + assert(frame.pos == 0); + + TNode ggfather = gfather.parent(); + assert(ggfather); + cursor.remove(); + parent.remove(); + // we have to replace the gfather with the elements of its first child, but this group may have no + // children. + if (gfather.first().size()) + { + gfather.replace(gfather.first().first(), TNode()); + ggfather.append(cursor); + } + else + { + // in this case, the MACRO has to be replaced with the cursor + gfather.first().remove(); + gfather.replace(cursor); + } + // now we have the situation preceding the insertion of the leftOpen and rightOpen MACRO. + // this MACRO no longer exists. + frames.pop(); + + if (special) return "\\" + macro_name; + else + { + // to give a standard behavior to the graphical deletion, we call the do_drop. + return do_drop(special); + } + } + else if (frame.entry.rightOpen) + { + // the user has inserted a rightOpen MACRO, and now, this MACRO has no children (excluding the + // phantom group), so we remove the MACRO. + // We can assert that cursor's parent is the only child of the MACRO + assert(gfather.size() == 1); + assert(frame.pos == 0); + cursor.remove(); + parent.remove(); + gfather.replace(cursor); + + // now we have the situation preceding the rightOpen MACRO, so we have to pop the frame + frames.pop(); + + if (special) return "\\" + macro_name; + else + { + // to give a standard behavior to the graphical deletion, we call the do_drop. + return do_drop(special); + } + + } + else if (frame.entry.leftOpen) + { + // this situation will never occur. + logger.error("the parser has generated a wrong TML tree"); + return ""; + } + else if (!frame.entry.pattern.empty()) + { + // the MACRO accepts arguments, and the phantom group in which + // the cursor is, rappresents a delimited argument. + // We have to control if the cursor's parent has a preceding element, + // or not. + TNode uncle = parent.prev(); + if (!uncle) + { + // the parent is the only element of the MACRO. + // we can assert that frame.pos == 0. + // In this case we can replace the MACRO with the cursor + assert(frame.pos == 0); + cursor.remove(); + parent.remove(); + gfather.replace(cursor); + frames.pop(); + + if (special) return "\\" + macro_name; + else + { + // once we have replaced the empty macro with the cursor, we can remove + // something else + return do_drop(special); + } + } + else + { + // the parent has a preceding element. Now we have + // to control if the uncle is a delimited argument or not. + if (uncle.isG() && !uncle.hasId()) + { + // cursor's uncle is a delimited argument + cursor.remove(); + parent.remove(); + uncle.append(cursor); + if (special) + { + // we have to start removing the last delimiter of the delimited + // argument. + std::string last_del = frame.entry.pattern[frame.pos - 1].value; + frame.pos = frame.pos - 2; + return "\\" + last_del; + } + else + { + // the uncle is a delimited argument. So we have to ideally + // remove the sequence of delimiters. + assert(frame.pos > 1); + unsigned sequence_length = frame.pos - frame.entry.previousParam(frame.pos) - 1; + assert(frame.entry.previousParam(frame.pos) != frame.entry.pattern.size()); + assert(sequence_length); + // sequence_length is the length of the delimiters sequence which separates + // the current parameter and the previous parameter + frame.pos = frame.pos - sequence_length - 1; + + // once removed the sequnce of delimiters, we can start to remove the actual + // parameter. We can call the do_drop_phantom_group() because a delimited argument + // is always a phantom group's child + return do_drop_phantom_group(special); + } + } + else + { + // the uncle is a not delimited argument, so we try to remove it. + cursor.remove(); + parent.replace(cursor); + parent = cursor.parent(); // we update the parent (it should be the MACRO) + assert(parent.isC()); + + // now we try to remove the uncle (now it' the preceding element) + return drop_prev(special); + } + } // this is the else's end, that handles the case in which an uncle exists + } // end of if (!frame.entry.pattern.empty()) + else + { + // the entry has no arguments, is not rightOpen and is not leftOpen. + logger.error("TML tree in a strange state"); + return ""; + } + } // end of if (gfather.isC()) + else if (gfather.is("cell")) + { + // A table is a control sequence, so there is a frame in the stack + assert(!frames.empty()); + assert(frames.top().pos == 0); + assert(frames.top().entry.table == 1); + + // a cell MUST be a row's child, which in turn is a table's child + assert(gfather.parent() && gfather.parent().is("row") && gfather.parent().parent()); + + // this variable is useful to handle the special deletion + std::string table_name = gfather.parent().parent().nameC(); + + TNode row = gfather.parent(); + + // in this case the cell has no element, so the user wants to delete this cell. + TNode prev_cell = gfather.prev(); + cursor.remove(); + parent.remove(); + gfather.remove(); + // now the cell no longer exists + + if (!prev_cell) + { + // in this case, the cell was the only cell in the row. + // So, we assume that the user wants to delete the entire row. + TNode table = row.parent(); + TNode prev_row = row.prev(); + row.remove(); + + if (!prev_row) + { + if (special) + { + // Since there was a cell (and a row), the user has typed a "{" to + // We ideally remove this character. + table.append(cursor); + return ""; + } + else + { + // the row was the only child of the table. + // so we have to delete the entire table + assert(table.parent()); + TNode parent_table = table.parent(); + table.remove(); + frames.pop(); + parent_table.append(cursor); + return ""; + } + } + else + { + // there are other rows (one or more) + assert(prev_row.is("row")); + assert(prev_row.last()); + TNode last_cell = prev_row.last(); + assert(last_cell.is("cell")); + assert(last_cell.size() == 1); + assert(last_cell.first().isG() && !last_cell.first().hasId()); + last_cell.first().append(cursor); + // Since cells and rows are separated by spaces and CRs + // (and the user can see this spaces and CRs), a special deletion + // is equivalent to a normal deletion + return ""; + } + } // end of if (!prev_cell) + else + { + // being here means that there is a previous cell, + // so we append the cursor to group. + assert(prev_cell.size() == 1); + assert(prev_cell.first().isG() && !prev_cell.first().hasId()); + prev_cell.first().append(cursor); + return ""; + } + } // end of if (gfather.is("cell")) + else if (gfather.isSp()) + { + // we cannot be here because a phantom group can be a Sp child only + // in two cases. If the user has typed somethong like: + // $^ + // the cursor is not phantom group's child. + // If the user has typed somethong like + // ..'' + // In this case the sequence of ' is placed in a phantom group, + // which becomes the exponent of the script. But, the cursor is + // always outside the phantom group + logger.error("TML tree in a strange state"); + return ""; + } + else if (gfather.is("math")) + { + // in this case we ignore the user's will of deleting + // but we could also decide to remove the math mode. + logger.warning("nothing to delete"); + return ""; + } + else + { + // cursor's grand father is undefined + logger.error("TML tree is in an unknown state"); + return ""; + } + } // end of the else of the if (prev) + +} + + +std::string +TPushParser::do_drop(bool special) +{ + // we have to handle the case in wich the cursor has a parent or not + if (!cursor.parent()) + { + // it's not a good situation...at the moment we do not take actions + logger.error("TML tree not well structured"); + return ""; + } + else + { + // a parent exists. We have to take differnt actions, based on the nature of + // the parent + TNode parent = cursor.parent(); + if (parent.is("math")) + { + // we ca do two thing...we can remove the math mode (it implies controlling the display attribute), we can do nothing + // At the moment, the user's will of deleting is simply ignored + logger.warning("nothing to delete"); + return ""; + } + else if (parent.isG()) + { + // the cursor's parent is a group. We have to control if it's a phantom group or not + if (parent.hasId()) + { + return do_drop_groupId(special); + } + else + { + return do_drop_phantom_group(special); + } + } // end of parent is group + else if (parent.isC()) + { + return do_drop_macro(special); + } // end of parent is a MACRO + else if (parent.isSp() || parent.isSb()) + { + return do_drop_script(special); + } // end of parent is sp or sb + } // end of the else which consider the case in which parent exists + +} // end of method do_drop + +bool +TPushParser::process(const TToken& token) +{ + switch (token.category) + { + case TToken::BEGIN: return do_begin(); + case TToken::END: return do_end(); + case TToken::SHIFT: return do_shift(); + case TToken::ALIGN: return do_align(); + case TToken::EOL: return do_eol(); + case TToken::PARAMETER: return do_parameter(token.value); + case TToken::SUPERSCRIPT: return do_superscript(); + case TToken::SUBSCRIPT: return do_subscript(); + case TToken::IGNORABLE_SPACE: return do_ignorablespace(token.value); + case TToken::SPACE: return do_space(token.value); + case TToken::LETTER: return do_letter(token.value); + case TToken::DIGIT: return do_digit(token.value); + case TToken::OTHER: return do_other(token.value); + case TToken::ACTIVE: return do_active(token.value); + case TToken::COMMENT: return do_comment(); + case TToken::CONTROL: return do_control(token.value); + } +} + +void +TPushParser::push(const TToken& token) +{ + TNode parent = cursor.parent(); + // If the cursor has no parent then it is detached from the editing + // tree, which means this token will be ignored + + if (parent) + // If the parent is a phantom group and the grand-parent is a + // control sequence, there are two cases: + // a. we are parsing a delimited argument of a entry + // b. we are parsing a side of a right- or left-open entry + if (parent.isG() && !parent.hasId() && parent.parent().isC()) + { + // There must be an open frame, for the grand-parent is a control sequence + assert(!frames.empty()); + Frame& frame = frames.top(); + if (!frame.entry.pattern.empty()) + { + // The entry pattern is not empty. By our conventions this means + // the entry cannot be open at either end, hence we are parsing + // a delimited argument + assert(frame.pos + 1 < frame.entry.pattern.size()); + assert(frame.entry.pattern[frame.pos + 1].category != TToken::PARAMETER); + if (frame.entry.pattern[frame.pos + 1] == token) + { + // The token matches with a delimiter of the argument, + // hence we increment the frame.pos + frame.pos++; + + if (frame.entry.lastDelimiter(frame.pos)) + { + // this delimiter is the last one for the argumet, + // so the argument is completed + cursor.remove(); + advance(parent); + } + } + else + { + // Delimiter mismatch. + if (frame.entry.pattern[frame.pos].category != TToken::PARAMETER) + { + // in this case, there is a sequence of delimiters that delimitates + // the argument, and the user has correctly inserted a portion of this + // sequence, but now has inserted a wrong delimiter. + // Here, there are some possibilities: + // - ignore the token, and wait for the correct delimiter + // - ignore the token, wait for the correct delimiter and emit an error + // At the moment, we implement the second possibily + logger.warning("it's not the correct delimiter...you have to type '" + frame.entry.pattern[frame.pos + 1].value + "'"); + } + else + { + // in this case, the sequence of delimiters is composed of one + // delimiter. It means that we have to process the token + process(token); + } + } + } + else + { + // The entry pattern is empty, hence we are parsing a right-open + // entry. What happens if we actually are in the left side? + // This could happen only when re-editing an entered expression + // We'll see... + assert(frame.entry.rightOpen); + process(token); + } + } + else if (parent.isC()) + { + // We are parsing a non-delimited argument entry + // or a fixed token + Frame& frame = frames.top(); + assert(frame.pos < frame.entry.pattern.size()); + + if (frame.entry.pattern[frame.pos].category == TToken::PARAMETER) + { + // As by the TeX parsing rules of undelimited parameters, + // empty spaces are ignored + if ((token.category != TToken::SPACE) && (token.category != TToken::IGNORABLE_SPACE)) process(token); + } + else if (frame.entry.pattern[frame.pos] == token) + { + // The token has been accepted + frame.pos++; + if (frame.pos < frame.entry.pattern.size() && + frame.entry.paramDelimited(frame.pos)) + { + // If the next is a delimited argument we have to place + // the phantom group with the cursor inside + TNode g = doc.createG(); + cursor.replace(g); + g.append(cursor); + } + else + { + cursor.remove(); + advance(parent); + } + } + else + { + // There is a mismatch. Emit an error and ignore the token? + logger.warning("ignored token: " + token.value); + } + } + else + process(token); + else + { + logger.warning("ignored token"); + } + + if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc); +} + +std::string +TPushParser::drop(bool special) +{ + std::string str = do_drop(special); + if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc); + return str; +} + +void +TPushParser::advance(const TNode& node) +{ + assert(node); + + if (!node.parent()) + { + // this is an error + logger.error("wrong TML tree"); + } + else if (node.parent().isG()) + { + TNode next = node.next(); + if (next) next.insert(cursor); + else node.parent().append(cursor); + } + else if (node.parent().isC()) + { + assert(!frames.empty()); + if ((frames.top().pos + 1 == frames.top().entry.pattern.size()) || (frames.top().entry.pattern.empty())) + { + // we are here when we have a right open macro, or the inserted element is the last one + if (frames.top().entry.rightOpen) + { + // we have to remove the frame from the stack + frames.pop(); + advance(node.parent().parent()); + } + else + { + frames.pop(); + advance(node.parent()); + } + } + else if (frames.top().entry.paramDelimited(frames.top().pos + 1)) + { + // the next argument is delimited, so we have to create a phantom group + TNode g = doc.createG(); + g.append(cursor); + node.parent().append(g); + frames.top().pos++; + } + else + { + // the next argumet is not delimited, so we have to append the cursor + // to the MACRO + node.parent().append(cursor); + frames.top().pos++; + } + } + else advance(node.parent()); +} + +void +TPushParser::setCursorHint(const std::string& c) +{ + if (cursor["val"] != c) + { + cursor["val"] = c; + if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc); + } +} + +bool +TPushParser::hideCursor() +{ + if (hiddenCursor++ == 0) + { + cursor["visible"] = "0"; + if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc); + return true; + } + else + return false; +} + +bool +TPushParser::showCursor() +{ + if (hiddenCursor > 0 && --hiddenCursor == 0) + { + cursor["visible"] = "1"; + if (factory && doc.dirtyNode() && !frozen()) factory->documentModified(doc); + return true; + } + else + return false; +} + +bool +TPushParser::thaw() +{ + if (APushParser::thaw() && factory && doc.dirtyNode()) + { + factory->documentModified(doc); + return true; + } + else + return false; +} diff --git a/DEVEL/mathml_editor/src/TPushParser.hh b/DEVEL/mathml_editor/src/TPushParser.hh new file mode 100644 index 000000000..a94402fbf --- /dev/null +++ b/DEVEL/mathml_editor/src/TPushParser.hh @@ -0,0 +1,113 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TPushParser_hh__ +#define __TPushParser_hh__ + +#include +#include +#include "TToken.hh" +#include "APushParser.hh" +#include "TDictionary.hh" +#include "TDocument.hh" +#include "TNode.hh" + +class TPushParser : public APushParser +{ +public: + TPushParser(class ALogger&, const class TDictionary&); + TPushParser(class ALogger&, class AMathMLFactory&, const class TDictionary&); + virtual ~TPushParser(); + + virtual void reset(void); + virtual void push(const TToken&); + virtual std::string drop(bool); + virtual void setCursorHint(const std::string&); + virtual bool hideCursor(void); + virtual bool showCursor(void); + + virtual bool thaw(void); + + DOM::Document document(void) const { return doc.document().cloneNode(true); } + +private: + void init(void); + + TNode PRIME(void); + bool isPrimes(const TNode&) const; + + bool do_begin(void); + bool do_end(void); + bool do_shift(void); + bool do_align(void); + bool do_eol(void); + bool do_parameter(const std::string&); + bool do_superscript(void); + bool do_subscript(void); + bool do_ignorablespace(const std::string&); + bool do_space(const std::string&); + bool do_letter(const std::string&); + bool do_digit(const std::string&); + bool do_other(const std::string&); + bool do_active(const std::string&); + bool do_comment(void); + bool do_control(const std::string&); + + std::string drop_prev_token(bool); + std::string drop_prev_script(bool); + std::string drop_prev_group(bool); + std::string drop_prev_macro(bool); + std::string drop_prev(bool); + void rgreplace_father(void); + std::string do_drop_script(bool); + std::string do_drop_macro(bool); + std::string do_drop_groupId(bool); + std::string do_drop_phantom_group(bool); + std::string do_drop(bool); + + bool do_cr(void); + bool do_apostrophe(void); + void advance(const TNode&); + bool correctBrace(void); + + bool process(const TToken&); + + struct Frame + { + Frame(const TDictionary::Entry& e) : entry(e), pos(0) { }; + Frame(const TDictionary::Entry&e, unsigned p) : entry(e), pos(p) { }; + const TDictionary::Entry& entry; + unsigned pos; + }; + + std::stack frames; + unsigned nextId; + TDocument doc; + TNode cursor; + unsigned hiddenCursor; + const class TDictionary& dictionary; +}; + +#endif // __TPushParser_hh__ diff --git a/DEVEL/mathml_editor/src/TToken.hh b/DEVEL/mathml_editor/src/TToken.hh new file mode 100644 index 000000000..0ea74e551 --- /dev/null +++ b/DEVEL/mathml_editor/src/TToken.hh @@ -0,0 +1,63 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TToken_hh__ +#define __TToken_hh__ + +#include + +struct TToken +{ + enum TCat + { + BEGIN, + END, + SHIFT, + ALIGN, + EOL, + PARAMETER, + SUPERSCRIPT, + SUBSCRIPT, + IGNORABLE_SPACE, + SPACE, + LETTER, + DIGIT, + OTHER, + ACTIVE, + COMMENT, + CONTROL + }; + + TToken(TCat c) : category(c) { }; + TToken(TCat c, char ch) : category(c), value(std::string(1, ch)) { }; + TToken(TCat c, const std::string& v) : category(c), value(v) { }; + + bool operator==(const TToken& token) const { return category == token.category && value == token.value; }; + + TCat category; + std::string value; +}; + +#endif // __TToken_hh__ diff --git a/DEVEL/mathml_editor/src/TTokenizer.cc b/DEVEL/mathml_editor/src/TTokenizer.cc new file mode 100644 index 000000000..14eeaadb0 --- /dev/null +++ b/DEVEL/mathml_editor/src/TTokenizer.cc @@ -0,0 +1,69 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include "TTokenizer.hh" +#include "TPushLexer.hh" + +std::vector +TTokenizer::tokenize(const std::string& s) +{ + TPushLexer lexer(logger, *this); + + tokens.clear(); + for (std::string::const_iterator p = s.begin(); + p != s.end(); + p++) + lexer.push(*p); + + lexer.flush(); + + std::vector res; + res.reserve(tokens.size()); + copy(tokens.begin(), tokens.end(), back_inserter(res)); + + return res; +} + +void +TTokenizer::reset() +{ + assert(0); +} + +void +TTokenizer::push(const TToken& token) +{ + tokens.push_back(token); +} + +std::string +TTokenizer::drop(bool alt) +{ + assert(0); + return ""; +} diff --git a/DEVEL/mathml_editor/src/TTokenizer.hh b/DEVEL/mathml_editor/src/TTokenizer.hh new file mode 100644 index 000000000..f78acafe4 --- /dev/null +++ b/DEVEL/mathml_editor/src/TTokenizer.hh @@ -0,0 +1,54 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __TTokenizer_hh__ +#define __TTokenizer_hh__ + +#include +#include +#include + +#include "TToken.hh" +#include "APushParser.hh" + +class TTokenizer : private APushParser +{ +public: + TTokenizer(class ALogger& l) : APushParser(l) { }; + + std::vector tokenize(const std::string&); + +private: + virtual void reset(void); + virtual void push(const TToken&); + virtual std::string drop(bool = false); + virtual void setCursorHint(const std::string&) { }; + virtual bool hideCursor(void) { return false; }; + virtual bool showCursor(void) { return false; }; + + std::list tokens; +}; + +#endif // __TTokenizer_hh__ diff --git a/DEVEL/mathml_editor/src/config.dirs.in b/DEVEL/mathml_editor/src/config.dirs.in new file mode 100644 index 000000000..1ce2d0a5e --- /dev/null +++ b/DEVEL/mathml_editor/src/config.dirs.in @@ -0,0 +1,3 @@ + +#define PKGDATADIR "@prefix@/share/@PACKAGE@" + diff --git a/DEVEL/mathml_editor/src/dom.hh b/DEVEL/mathml_editor/src/dom.hh new file mode 100644 index 000000000..d09505fd5 --- /dev/null +++ b/DEVEL/mathml_editor/src/dom.hh @@ -0,0 +1,53 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __dom_hh__ +#define __dom_hh__ + +#include +#include + +namespace DOM = GdomeSmartDOM; +namespace DOMX = GdomeSmartDOMExt; + +typedef DOM::Char32 TChar; +typedef DOM::UCS4String TString; + +inline bool isUnicodeSpace(TChar ch) +{ + return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';; +} + +inline bool isUnicodeAlpha(TChar ch) +{ + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); +} + +inline bool isUnicodeDigit(TChar ch) +{ + return (ch >= '0' && ch <= '9'); +} + +#endif // __dom_hh__ diff --git a/DEVEL/mathml_editor/src/globals.hh b/DEVEL/mathml_editor/src/globals.hh new file mode 100644 index 000000000..3270a49ab --- /dev/null +++ b/DEVEL/mathml_editor/src/globals.hh @@ -0,0 +1,33 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __globals_hh__ +#define __globals_hh__ + +#define TML_NS_URI "http://helm.cs.unibo.it/2002/TML" +#define XMLNS_NS_URI "http://www.w3.org/2000/xmlns/" +#define MATHML_NS_URI "http://www.w3.org/1998/Math/MathML" + +#endif // __globals_hh__ diff --git a/DEVEL/mathml_editor/src/timer.cc b/DEVEL/mathml_editor/src/timer.cc new file mode 100644 index 000000000..d8b6119cd --- /dev/null +++ b/DEVEL/mathml_editor/src/timer.cc @@ -0,0 +1,38 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include + +#include "timer.hh" + +long +getTimer() +{ + struct timeval time; + gettimeofday(&time, 0); + return time.tv_sec * 1000000 + time.tv_usec; +} diff --git a/DEVEL/mathml_editor/src/timer.hh b/DEVEL/mathml_editor/src/timer.hh new file mode 100644 index 000000000..8737422e9 --- /dev/null +++ b/DEVEL/mathml_editor/src/timer.hh @@ -0,0 +1,31 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef __timer_hh__ +#define __timer_hh__ + +long getTimer(void); + +#endif // __timer_hh__ diff --git a/DEVEL/mathml_editor/test/.cvsignore b/DEVEL/mathml_editor/test/.cvsignore new file mode 100644 index 000000000..bdefc79b9 --- /dev/null +++ b/DEVEL/mathml_editor/test/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +editor diff --git a/DEVEL/mathml_editor/test/Makefile.am b/DEVEL/mathml_editor/test/Makefile.am new file mode 100644 index 000000000..edf73ee18 --- /dev/null +++ b/DEVEL/mathml_editor/test/Makefile.am @@ -0,0 +1,21 @@ + +noinst_PROGRAMS = editor + +editor_SOURCES = editor.cc guiGTK.c aux.cc + +noinst_HEADERS = guiGTK.h + +LDADDS = \ + $(GMETADOM_LIBS) \ + $(GDOMEXSLT_LIBS) \ + $(GTKMATHVIEW_LIBS) \ + $(top_builddir)/src/.libs/libeditex.a + +editor_LDADD = $(LDADDS) + +INCLUDES = \ + $(GMETADOM_CFLAGS) \ + $(GDOMEXSLT_CFLAGS) \ + $(GTKMATHVIEW_CFLAGS) \ + -I$(top_srcdir)/src + diff --git a/DEVEL/mathml_editor/test/Makefile.in b/DEVEL/mathml_editor/test/Makefile.in new file mode 100644 index 000000000..df6bac536 --- /dev/null +++ b/DEVEL/mathml_editor/test/Makefile.in @@ -0,0 +1,396 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 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. + + +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 + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EDITEX_VERSION_INFO = @EDITEX_VERSION_INFO@ +EXEEXT = @EXEEXT@ +GDOMEXSLT_CFLAGS = @GDOMEXSLT_CFLAGS@ +GDOMEXSLT_LIBS = @GDOMEXSLT_LIBS@ +GMETADOM_CFLAGS = @GMETADOM_CFLAGS@ +GMETADOM_LIBS = @GMETADOM_LIBS@ +GTKMATHVIEW_CFLAGS = @GTKMATHVIEW_CFLAGS@ +GTKMATHVIEW_LIBS = @GTKMATHVIEW_LIBS@ +HAVE_OCAMLC = @HAVE_OCAMLC@ +HAVE_OCAMLDEP = @HAVE_OCAMLDEP@ +HAVE_OCAMLFIND = @HAVE_OCAMLFIND@ +HAVE_OCAMLMKLIB = @HAVE_OCAMLMKLIB@ +HAVE_OCAMLOPT = @HAVE_OCAMLOPT@ +LDFLAGS = @LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MLGDOME_CFLAGS = @MLGDOME_CFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCAMLC = @OCAMLC@ +OCAMLDEP = @OCAMLDEP@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +OCAMLOPT = @OCAMLOPT@ +OCAMLSTDLIBDIR = @OCAMLSTDLIBDIR@ +OCAMLSTUBDIR = @OCAMLSTUBDIR@ +OCAML_INCLUDE_DIR = @OCAML_INCLUDE_DIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +noinst_PROGRAMS = editor + +editor_SOURCES = editor.cc guiGTK.c aux.cc + +noinst_HEADERS = guiGTK.h + +LDADDS = $(GMETADOM_LIBS) $(GDOMEXSLT_LIBS) $(GTKMATHVIEW_LIBS) $(top_builddir)/src/.libs/libeditex.a + + +editor_LDADD = $(LDADDS) + +INCLUDES = $(GMETADOM_CFLAGS) $(GDOMEXSLT_CFLAGS) $(GTKMATHVIEW_CFLAGS) -I$(top_srcdir)/src + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +noinst_PROGRAMS = editor$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +LIBS = @LIBS@ +editor_OBJECTS = editor.$(OBJEXT) guiGTK.$(OBJEXT) aux.$(OBJEXT) +editor_DEPENDENCIES = $(top_builddir)/src/.libs/libeditex.a +editor_LDFLAGS = +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/aux.P .deps/editor.P .deps/guiGTK.P +SOURCES = $(editor_SOURCES) +OBJECTS = $(editor_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +editor$(EXEEXT): $(editor_OBJECTS) $(editor_DEPENDENCIES) + @rm -f editor$(EXEEXT) + $(CXXLINK) $(editor_LDFLAGS) $(editor_OBJECTS) $(editor_LDADD) $(LIBS) +.cc.o: + $(CXXCOMPILE) -c $< +.cc.obj: + $(CXXCOMPILE) -c `cygpath -w $<` +.cc.lo: + $(LTCXXCOMPILE) -c $< + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = test + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu test/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstPROGRAMS distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ +clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# 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/DEVEL/mathml_editor/test/aux.cc b/DEVEL/mathml_editor/test/aux.cc new file mode 100644 index 000000000..bb17013fb --- /dev/null +++ b/DEVEL/mathml_editor/test/aux.cc @@ -0,0 +1,261 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include + +#include +#include +#include + +//#include "gmetadom.hh" + +namespace DOM = GdomeSmartDOM; + +static unsigned +getDepth(const DOM::Element& elem) +{ + unsigned length = 0; + DOM::Element p = elem; + + while (p) + { + p = p.get_parentNode(); + length++; + } + + return length; +} + +static DOM::Element +findCommonAncestor(const DOM::Element& first, const DOM::Element& last) +{ + assert(first); + assert(last); + + DOM::Element p(first); + DOM::Element q(last); + + if (p != q) + { + unsigned pDepth = getDepth(p); + unsigned qDepth = getDepth(q); + + while (p && pDepth > qDepth) + { + p = p.get_parentNode(); + pDepth--; + } + + while (q && qDepth > pDepth) + { + q = q.get_parentNode(); + qDepth--; + } + + assert(pDepth == qDepth); + + while (p && q && p != q) + { + p = p.get_parentNode(); + q = q.get_parentNode(); + } + } + + return p; +} + +static void +findCommonSiblings(const DOM::Element& first, const DOM::Element& last, + DOM::Element& firstS, DOM::Element& lastS) +{ + assert(first); + assert(last); + + DOM::Element p(first); + DOM::Element q(last); + + if (p != q) + { + unsigned pDepth = getDepth(p); + unsigned qDepth = getDepth(q); + + while (p && pDepth > qDepth) + { + p = p.get_parentNode(); + pDepth--; + } + + while (q && qDepth > pDepth) + { + q = q.get_parentNode(); + qDepth--; + } + + assert(pDepth == qDepth); + + while (p && q && p.get_parentNode() != q.get_parentNode()) + { + p = p.get_parentNode(); + q = q.get_parentNode(); + } + } + + firstS = p; + lastS = q; +} + +static DOM::Element +findElementWithRef(const DOM::Element& el) +{ + DOM::Element p = el; + while (p && !p.hasAttribute("xref")) p = p.get_parentNode(); + return p; +} + +static DOM::Node +leftmostChild(const DOM::Node& node) +{ + if (!node) return node; + + DOM::Node firstChild = node.get_firstChild(); + if (!firstChild) return node; + + return leftmostChild(firstChild); +} + +static DOM::Node +rightmostChild(const DOM::Node& node) +{ + if (!node) return node; + + DOM::Node lastChild = node.get_lastChild(); + if (!lastChild) return node; + + return rightmostChild(lastChild); +} + +static DOM::Node +leftSibling(const DOM::Node& node) +{ + DOM::Node p = node; + + if (!p) return p; + + while (p.get_parentNode() && p.get_parentNode().get_firstChild() == p) + p = p.get_parentNode(); + + if (!p.get_parentNode()) return DOM::Node(0); + + DOM::Node prevSibling = p.get_previousSibling(); + assert(prevSibling); + + return rightmostChild(prevSibling); +} + +static DOM::Node +rightSibling(const DOM::Node& node) +{ + DOM::Node p = node; + + if (!p) return p; + + DOM::Node firstChild = p.get_firstChild(); + if (firstChild) return firstChild; + + while (p.get_parentNode() && p.get_parentNode().get_lastChild() == p) + p = p.get_parentNode(); + + if (!p.get_parentNode()) return DOM::Node(0); + + DOM::Node nextSibling = p.get_nextSibling(); + assert(nextSibling); + + return leftmostChild(nextSibling); +} + +extern "C" GdomeElement* +find_common_ancestor(GdomeElement* first, GdomeElement* last) +{ + if (GdomeNode* n = findCommonAncestor(DOM::Element(first), DOM::Element(last)).gdome_object()) + { + GdomeElement* res = gdome_cast_el(n); + g_assert(res != NULL); + return res; + } + else + return NULL; +} + +extern "C" void +find_common_siblings(GdomeElement* first, GdomeElement* last, + GdomeElement** firstS, GdomeElement** lastS) +{ + DOM::Element fs(0); + DOM::Element ls(0); + + findCommonSiblings(DOM::Element(first), DOM::Element(last), fs, ls); + + if (firstS != NULL) *firstS = gdome_cast_el(fs.gdome_object()); + if (lastS != NULL) *lastS = gdome_cast_el(ls.gdome_object()); +} + +extern "C" GdomeElement* +find_element_with_ref(GdomeElement* elem) +{ + if (GdomeNode* n = findElementWithRef(DOM::Element(elem)).gdome_object()) + { + GdomeElement* res = gdome_cast_el(n); + g_assert(res != NULL); + return res; + } + else + return NULL; +} + +extern "C" GdomeElement* +find_common_ancestor_with_ref(GdomeElement* first, GdomeElement* last) +{ + if (GdomeNode* n = findElementWithRef(findCommonAncestor(DOM::Element(first), DOM::Element(last))).gdome_object()) + { + GdomeElement* res = gdome_cast_el(n); + g_assert(res != NULL); + return res; + } + else + return NULL; +} + +extern "C" void +delete_element(GdomeElement* elem) +{ + DOM::Element p(elem); + + DOM::Element parent = p.get_parentNode(); + assert(parent); + + parent.removeChild(p); +} + diff --git a/DEVEL/mathml_editor/test/editor.cc b/DEVEL/mathml_editor/test/editor.cc new file mode 100644 index 000000000..3efc17cee --- /dev/null +++ b/DEVEL/mathml_editor/test/editor.cc @@ -0,0 +1,196 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include + +#include "dom.hh" +#include "TPushParser.hh" +#include "timer.hh" + +#include "ILPushLexer.hh" +#include "TDictionary.hh" +#include "CLoggerConsole.hh" +#include "CMathMLFactoryXSLT.hh" +#include "CMathMLFactoryXSLTDiff.hh" +#include "AMathMLConsumer.hh" + +#include "guiGTK.h" + +extern void *parseMathMLFile(char *); + +struct Context +{ + /* + Context(const std::string& s, TPushLexer& l, TPushParser& p) : buffer(s), i(0), lexer(l), parser(p) { }; + */ + Context(const std::string& s, APushLexer& l, TPushParser& p, DOMX::XSLTStylesheet& ts) + : buffer(s), i(0), lexer(l), parser(p), texStyle(ts) { }; + + void send(void) + { + if (i < buffer.length()) lexer.push(buffer[i++]); + } + + std::string buffer; + unsigned i; + APushLexer& lexer; + TPushParser& parser; + DOMX::XSLTStylesheet& texStyle; +}; + +extern "C" void +edit_output_tex(Context* data) +{ + assert(data); + DOM::Document res = data->texStyle.apply(data->parser.document()); +#if 0 + res.normalize(); + DOM::Node c = res.get_firstChild(); + if (c) std::cout << "HEY, there is a child! " << c.get_nodeName() << " " << c.get_nodeValue() << std::endl; +#endif + //data->texStyle.save(res, stdout); +} + +extern "C" int +edit_timeout(Context* data) +{ + assert(data); + GUI_freeze(); + data->send(); + GUI_thaw(); + return 1; +} + +extern "C" void +edit_push_char(Context* context, gchar ch) +{ + assert(context != NULL); + long t0 = getTimer(); + GUI_freeze(); + std::cout << "*** SENDING " << ch << std::endl; + context->lexer.push(ch); + GUI_thaw(); + long t1 = getTimer(); + std::cout << "=== OVERALL TIME = " << (t1 - t0) / 1000 << std::endl; +} + +#include + +extern "C" void +edit_push_string(Context* context, const gchar* s) +{ + assert(context != NULL); + assert(s != NULL); +#if 0 +// GUI_freeze(); +// context->parser.freeze(); + for (unsigned i = 0; s[i]; i++) + { + GUI_freeze(); + context->lexer.push(s[i]); + GUI_thaw(); + usleep(100000); + usleep(100000); + } +// context->parser.thaw(); +// GUI_thaw(); +#endif + context->buffer = s; +} + +extern "C" void +edit_drop(Context* context, gboolean alt, gboolean control) +{ + // At the moment, the last parameter is not used, but it will + // be useful when we will handle the "fast" deletion + assert(context != NULL); + GUI_freeze(); + context->lexer.drop(alt); + GUI_thaw(); +} + +extern "C" void +edit_reset_tex(Context* context) +{ + assert(context != NULL); + GUI_freeze(); + context->lexer.reset(); + context->parser.reset(); + GUI_thaw(); +} + +extern "C" void +edit_complete(Context* context) +{ + assert(context != NULL); + GUI_freeze(); + if (!context->lexer.complete()) context->lexer.push('\t'); + GUI_thaw(); +} + +int +main(int argc, char* argv[]) +{ + CLoggerConsole logger; + logger.verbosity(ALogger::Debug); + + TDictionary dictionary(logger); + logger.info("loading the dictionary..."); + dictionary.load("./dict/dictionary-tex.xml"); + + logger.info("loading the stylesheet..."); + DOM::DOMImplementation di; + DOM::Document mmlStyleDoc = di.createDocumentFromURI("./xsl/tml-mmlp.xsl"); + DOMX::XSLTStylesheet mmlStyle(mmlStyleDoc); + + DOM::Document texStyleDoc = di.createDocumentFromURI("./xsl/tml-texid.xsl"); + DOMX::XSLTStylesheet texStyle(texStyleDoc); + + CMathMLFactoryXSLT factory(logger, mmlStyle); + TPushParser parser(logger, factory, dictionary); + ILPushLexer lexer(logger, parser, dictionary); + +#if 0 + lexer.push('$'); + lexer.push(' '); + assert(result); +#endif + +#if 0 + DOM::Document doc = parser.document().document(); + std::vector< std::pair > np; + result = style.apply(doc, np); + style.save(result, stdout); +#endif + + Context context("", lexer, parser, texStyle); + + GUI_init(&argc, &argv, "EditTeX", 500, 600, &context); + GUI_load_document(gdome_cast_doc(static_cast(factory.document()))); + GUI_run(); + GUI_uninit(); + GUI_unload_document(); + +} diff --git a/DEVEL/mathml_editor/test/guiGTK.c b/DEVEL/mathml_editor/test/guiGTK.c new file mode 100644 index 000000000..ce6c31ef2 --- /dev/null +++ b/DEVEL/mathml_editor/test/guiGTK.c @@ -0,0 +1,649 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include +#include +#include + +#include "guiGTK.h" + +#define XLINK_NS_URI "http://www.w3.org/1999/xlink" + +static GtkWidget* window; +static GtkWidget* main_area; +static GtkWidget* scrolled_area; + +static gpointer context = NULL; +static gchar* doc_name = NULL; +static GdomeElement* first_selected = NULL; +static GdomeElement* root_selected = NULL; + +static void create_widget_set(gpointer); +static GtkWidget* get_main_menu(void); +static void file_open(GtkWidget*, gpointer); +static void file_re_open(GtkWidget*, gpointer); +static void file_close(GtkWidget*, gpointer); +static void file_output_tex(GtkWidget*, gpointer); +static void options_set_font_size(GtkWidget*, gpointer); +static void options_change_font_size(GtkWidget*, gboolean); +static void options_verbosity(GtkWidget*, guint); +static void edit_delete_selection(GtkWidget*, gpointer); +static void edit_select_parent(GtkWidget*, gpointer); +static void edit_reset_selection(GtkWidget*, gpointer); +static void edit_reset(GtkWidget*, gpointer); +static void edit_insert(GtkWidget*, gpointer); +static void help_about(GtkWidget*, gpointer); + +static GtkItemFactoryEntry menu_items[] = { + { "/_File", NULL, NULL, 0, "" }, + { "/File/_Open...", "O", file_open, 0, NULL }, + { "/File/_Reopen", NULL, file_re_open, 0, NULL }, + { "/File/_Close", "W", file_close, 0, NULL }, + { "/File/Output _TeX", NULL, file_output_tex, 0, NULL }, + { "/File/sep1", NULL, NULL, 0, "" }, + { "/File/_Quit", "Q", gtk_main_quit, 0, NULL }, + + { "/_Edit", NULL, NULL, 0, "" }, + { "/Edit/Reset Selection", NULL, edit_reset_selection, 0, NULL }, + { "/Edit/Delete Selection", NULL, edit_delete_selection, 0, NULL }, + { "/Edit/Select Parent", NULL, edit_select_parent, 0, NULL }, + { "/Edit/sep1", NULL, NULL, 0, "" }, + { "/Edit/_Reset", NULL, edit_reset, 0, NULL }, + { "/Edit/Insert...", "I", edit_insert, 0, NULL }, + + { "/_Options", NULL, NULL, 0, "" }, + { "/Options/Default _Font Size", NULL, NULL, 0, "" }, + { "/Options/Default Font Size/Set...", NULL, options_set_font_size, 0, NULL }, + { "/Options/Default Font Size/sep1", NULL, NULL, 0, "" }, + { "/Options/Default Font Size/Larger", NULL, options_change_font_size, TRUE, NULL }, + { "/Options/Default Font Size/Smaller", NULL, options_change_font_size, FALSE, NULL }, + { "/Options/Verbosity", NULL, NULL, 0, "" }, + { "/Options/Verbosity/_Errors", NULL, options_verbosity, 0, "" }, + { "/Options/Verbosity/_Warnings", NULL, options_verbosity, 1, "/Options/Verbosity/Errors" }, + { "/Options/Verbosity/_Info", NULL, options_verbosity, 2, "/Options/Verbosity/Errors" }, + { "/Options/Verbosity/_Debug", NULL, options_verbosity, 3, "/Options/Verbosity/Errors" }, + + { "/_Help" , NULL, NULL, 0, "" }, + { "/Help/About...", NULL, help_about, 0, NULL } +}; + +static void +quick_message(const char* msg) +{ + GtkWidget* dialog; + GtkWidget* label; + GtkWidget* okay_button; + + /* Create the widgets */ + + dialog = gtk_dialog_new(); + label = gtk_label_new (msg); + okay_button = gtk_button_new_with_label("OK"); + + gtk_widget_set_usize(dialog, 300, 100); + + /* Ensure that the dialog box is destroyed when the user clicks ok. */ + + gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), dialog); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), + okay_button); + + /* Add the label, and show everything we've added to the dialog. */ + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label); + gtk_widget_show_all (dialog); +} + +static void +load_error_msg(const char* name) +{ + char* msg = g_strdup_printf("Could not load\n`%s'", name); + quick_message(msg); + g_free(msg); +} + +static guint edit_timeout_id; +extern void edit_timeout(gpointer); + +void +GUI_init(int* argc, char*** argv, char* title, guint width, guint height, gpointer c) +{ + gtk_init(argc, argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), title); + gtk_window_set_default_size(GTK_WINDOW(window), width, height); + gtk_signal_connect(GTK_OBJECT(window), "delete_event", (GtkSignalFunc) gtk_main_quit, NULL); + create_widget_set(context); + + gtk_widget_show(window); + + context = c; + /*edit_timeout_id = gtk_timeout_add(50, edit_timeout, context);*/ +} + +void +GUI_uninit() +{ + GdomeException exc = 0; + + if (first_selected != NULL) + { + gdome_el_unref(first_selected, &exc); + g_assert(exc == 0); + first_selected = NULL; + } + + if (root_selected != NULL) + { + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + root_selected = NULL; + } + + context = NULL; +} + +int +GUI_load_document(GdomeDocument* doc) +{ + GtkMathView* math_view; + + g_return_val_if_fail(doc != NULL, -1); + g_return_val_if_fail(main_area != NULL, -1); + g_return_val_if_fail(GTK_IS_MATH_VIEW(main_area), -1); + + math_view = GTK_MATH_VIEW(main_area); + + if (!gtk_math_view_load_document(math_view, doc)) return -1; + + return 0; +} + +void +GUI_freeze() +{ + gtk_math_view_freeze(GTK_MATH_VIEW(main_area)); +} + +void +GUI_thaw() +{ + gtk_math_view_thaw(GTK_MATH_VIEW(main_area)); +} + +void +GUI_unload_document() +{ + GtkMathView* math_view; + + g_return_if_fail(main_area != NULL); + g_return_if_fail(GTK_IS_MATH_VIEW(main_area)); + + math_view = GTK_MATH_VIEW(main_area); + + gtk_math_view_unload(math_view); + + if (doc_name != NULL) g_free(doc_name); + doc_name = NULL; +} + +void +GUI_run() +{ + gtk_main(); +} + +#if 0 +void +GUI_set_font_manager(FontManagerId id) +{ + gboolean t1; + GtkMathView* math_view; + + g_return_if_fail(id != FONT_MANAGER_UNKNOWN); + g_return_if_fail(main_area != NULL); + g_return_if_fail(GTK_IS_MATH_VIEW(main_area)); + + t1 = id == FONT_MANAGER_T1; + + math_view = GTK_MATH_VIEW(main_area); + + gtk_math_view_freeze(math_view); + + if (id != gtk_math_view_get_font_manager_type(math_view)) + gtk_math_view_set_font_manager_type(math_view, id); + + gtk_widget_set_sensitive(anti_aliasing(math_view, GTK_CHECK_MENU_ITEM(anti_aliasing_item)->active); + gtk_math_view_set_transparency(math_view, GTK_CHECK_MENU_ITEM(transparency_item)->active); + } + + gtk_math_view_thaw(math_view); +} +#endif + +static void +store_filename(GtkFileSelection* selector, GtkWidget* user_data) +{ + gchar* selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(user_data)); + if (selected_filename != NULL) + GUI_load_document(selected_filename); +} + +static void +file_close(GtkWidget* widget, gpointer data) +{ + GUI_unload_document(); +} + +static void +file_re_open(GtkWidget* widget, gpointer data) +{ + if (doc_name != NULL) { + GUI_load_document(doc_name); + } +} + +static void +file_open(GtkWidget* widget, gpointer data) +{ + GtkWidget* fs = gtk_file_selection_new("Open File"); + + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button), + "clicked", GTK_SIGNAL_FUNC (store_filename), (gpointer) fs); + + /* Ensure that the dialog box is destroyed when the user clicks a button. */ + + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button), + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) fs); + + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(fs)->cancel_button), + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) fs); + + /* Display that dialog */ + + gtk_widget_show (fs); +} + +static void +file_output_tex(GtkWidget* widget, gpointer data) +{ + g_assert(context != NULL); + edit_output_tex(context); +} + +#if 0 +static void +options_font_manager(GtkWidget* widget, FontManagerId id) +{ + g_return_if_fail(id != FONT_MANAGER_UNKNOWN); + GUI_set_font_manager(id); +} +#endif + +static void +options_verbosity(GtkWidget* widget, guint level) +{ + gtk_math_view_set_log_verbosity(GTK_MATH_VIEW(main_area), level); +} + +static void +edit_delete_selection(GtkWidget* widget, gpointer data) +{ + if (root_selected != NULL) + { + GdomeException exc; + gtk_math_view_freeze(GTK_MATH_VIEW(main_area)); + printf("about to remove element %p\n", root_selected); + delete_element(root_selected); + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + root_selected = NULL; + gtk_math_view_thaw(GTK_MATH_VIEW(main_area)); + } +} + +static void +edit_select_parent(GtkWidget* widget, gpointer data) +{ + if (root_selected != NULL) + { + GdomeException exc = 0; + GdomeElement* parent = gdome_n_parentNode(root_selected, &exc); + g_assert(exc == 0); + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + root_selected = parent; + /* gtk_math_view_set_selection(GTK_MATH_VIEW(main_area), root_selected); */ + } +} + +static void +edit_reset_selection(GtkWidget* widget, gpointer data) +{ + if (root_selected != NULL) + { + GdomeException exc = 0; + /* gtk_math_view_reset_selection(GTK_MATH_VIEW(main_area), root_selected); */ + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + root_selected = NULL; + } +} + +static void +edit_reset(GtkWidget* widget, gpointer data) +{ + g_assert(context != NULL); + edit_reset_tex(context); +} + +static void +insert_tex(GtkWidget* widget, GtkEntry* entry) +{ + gchar* text; + g_return_if_fail(entry != NULL); + + text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); + edit_push_string(context, text); + g_free(text); +} + +static void +edit_insert(GtkWidget* widget, gpointer data) +{ + GtkWidget* dialog; + GtkWidget* entry; + GtkWidget* ok; + GtkWidget* cancel; + + dialog = gtk_dialog_new(); + entry = gtk_entry_new(); + ok = gtk_button_new_with_label("OK"); + cancel = gtk_button_new_with_label("Cancel"); + + gtk_signal_connect (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (insert_tex), (gpointer) entry); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_signal_connect_object (GTK_OBJECT (cancel), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), 5); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), entry); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), ok); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), cancel); + + gtk_widget_show_all (dialog); +} + +static void +help_about(GtkWidget* widget, gpointer data) +{ + GtkWidget* dialog; + GtkWidget* label; + GtkWidget* ok; + + dialog = gtk_dialog_new(); + label = gtk_label_new("\n MathML Editor \n Copyright (C) 2003 Luca Padovani \n"); + ok = gtk_button_new_with_label("Close"); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), + ok); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label); + + gtk_widget_show_all (dialog); +} + +static void +change_default_font_size(GtkWidget* widget, GtkSpinButton* spin) +{ + g_return_if_fail(spin != NULL); + gtk_math_view_set_font_size( GTK_MATH_VIEW(main_area), gtk_spin_button_get_value_as_int(spin)); +} + +static void +options_change_font_size(GtkWidget* widget, gboolean larger) +{ + gfloat size = gtk_math_view_get_font_size (GTK_MATH_VIEW(main_area)); + if (larger) size = size / 0.71; + else size = size * 0.71; + if (size < 1) size = 1; + gtk_math_view_set_font_size (GTK_MATH_VIEW(main_area), (gint) size + 0.5); +} + +static void +options_set_font_size(GtkWidget* widget, gpointer data) +{ + GtkWidget* dialog; + GtkWidget* label; + GtkWidget* ok; + GtkWidget* cancel; + GtkWidget* spin; + GtkObject* adj; + + dialog = gtk_dialog_new(); + label = gtk_label_new("Default font size:"); + ok = gtk_button_new_with_label("OK"); + cancel = gtk_button_new_with_label("Cancel"); + + adj = gtk_adjustment_new (gtk_math_view_get_font_size (GTK_MATH_VIEW(main_area)), 1, 200, 1, 1, 1); + spin = gtk_spin_button_new (GTK_ADJUSTMENT(adj), 1, 0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin), TRUE); + + gtk_signal_connect (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (change_default_font_size), (gpointer) spin); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_signal_connect_object (GTK_OBJECT (ok), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_signal_connect_object (GTK_OBJECT (cancel), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), (gpointer) dialog); + + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), 5); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), ok); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), cancel); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), spin); + + gtk_widget_show_all (dialog); +} + +static void +select_begin(GtkMathView* math_view, GdomeElement* first, gint state) +{ + GdomeException exc = 0; + + g_return_if_fail(math_view != NULL); + g_return_if_fail(GTK_IS_MATH_VIEW(math_view)); + g_return_if_fail(first != NULL); + + gtk_math_view_freeze(math_view); + + if (root_selected != NULL) + { + gtk_math_view_unselect(math_view, root_selected); + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + } + + root_selected = first_selected = find_element_with_ref(first); + + if (root_selected != NULL) + { + gtk_math_view_select(math_view, root_selected); + gdome_el_ref(root_selected, &exc); + g_assert(exc == 0); + } + + gtk_math_view_thaw(math_view); +} + +static void +select_over(GtkMathView* math_view, GdomeElement* elem, gint state) +{ + GdomeElement* new_selected = NULL; + GdomeException exc = 0; + + g_return_if_fail(math_view != NULL); + g_return_if_fail(GTK_IS_MATH_VIEW(math_view)); + g_return_if_fail(elem != NULL); + + if (first_selected == NULL || elem == NULL) + new_selected = NULL; + else + new_selected = find_common_ancestor_with_ref(first_selected, elem); + + if (new_selected != root_selected) + { + gtk_math_view_freeze(math_view); + if (root_selected != NULL) + { + gtk_math_view_unselect(math_view, root_selected); + gdome_el_unref(root_selected, &exc); + g_assert(exc == 0); + } + root_selected = new_selected; + if (root_selected != NULL) + gtk_math_view_select(math_view, root_selected); + gtk_math_view_thaw(math_view); + } + else if (new_selected != NULL) + { + gdome_el_unref(new_selected, &exc); + g_assert(exc == 0); + } + +} + +static gboolean +key_press_event(gpointer c, + GdkEventKey* event, + GtkWidget* widget) +{ + g_return_val_if_fail(widget != NULL, FALSE); + g_return_val_if_fail(event != NULL, FALSE); + g_return_val_if_fail(context != NULL, FALSE); + + if (event->type != GDK_KEY_PRESS) return FALSE; + + switch (event->keyval) + { + case GDK_BackSpace: + edit_drop(context, event->state & GDK_MOD1_MASK, event->state & GDK_CONTROL_MASK); + break; + case GDK_Tab: + edit_complete(context); + break; + default: + if ((event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0 && event->keyval < 0x80) + edit_push_char(context, event->keyval); + return FALSE; + } + + return TRUE; +} + +static void +create_widget_set(gpointer context) +{ + GtkWidget* main_vbox; + GtkWidget* menu_bar; + + main_vbox = gtk_vbox_new(FALSE, 1); + gtk_container_border_width(GTK_CONTAINER(main_vbox), 1); + gtk_container_add(GTK_CONTAINER(window), main_vbox); + gtk_widget_show(main_vbox); + + menu_bar = get_main_menu(); + gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, TRUE, 0); + gtk_widget_show(menu_bar); + + main_area = gtk_math_view_new(NULL, NULL); + gtk_widget_show(main_area); + + //gtk_math_view_set_log_verbosity(GTK_MATH_VIEW(main_area), 3); + + gtk_signal_connect_object (GTK_OBJECT (main_area), + "select_begin", GTK_SIGNAL_FUNC (select_begin), + (gpointer) main_area); + + gtk_signal_connect_object (GTK_OBJECT (main_area), + "select_over", GTK_SIGNAL_FUNC (select_over), + (gpointer) main_area); + + gtk_signal_connect_object (GTK_OBJECT(window), + "key_press_event", GTK_SIGNAL_FUNC(key_press_event), + context); + + gtk_widget_add_events(GTK_WIDGET(main_area), GDK_KEY_PRESS_MASK); + + scrolled_area = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_area), + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + + gtk_widget_show(scrolled_area); + gtk_container_add(GTK_CONTAINER(scrolled_area), main_area); + gtk_box_pack_start(GTK_BOX(main_vbox), scrolled_area, TRUE, TRUE, 0); + + gtk_widget_show(main_vbox); +} + +GtkWidget* +get_main_menu() +{ + GtkItemFactory* item_factory; + GtkAccelGroup* accel_group; + GtkWidget* menu_item; + + gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); + + accel_group = gtk_accel_group_new(); + + item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "
", accel_group); + + gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL); + + gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); + + return gtk_item_factory_get_widget(item_factory, "
"); +} diff --git a/DEVEL/mathml_editor/test/guiGTK.h b/DEVEL/mathml_editor/test/guiGTK.h new file mode 100644 index 000000000..ee0ab347e --- /dev/null +++ b/DEVEL/mathml_editor/test/guiGTK.h @@ -0,0 +1,57 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#ifndef guiGTK_h +#define guiGTK_h + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + /* initGUI: some initialization stuff, creates the main window, sets it with a title */ + void GUI_init(int *, char ***, char *, guint, guint, gpointer); + void GUI_uninit(void); + + int GUI_load_document(GdomeDocument*); + int GUI_load_uri(const char*); + void GUI_unload_document(void); + void GUI_dump_entities(void); + + /* main: this is the main event loop, to be called when the program is ready to run */ + void GUI_run(void); + + void GUI_freeze(void); + void GUI_thaw(void); + +#ifdef __cplusplus +} +#endif + +#endif /* guiGTK_h */ diff --git a/DEVEL/mathml_editor/textomml/.cvsignore b/DEVEL/mathml_editor/textomml/.cvsignore new file mode 100644 index 000000000..c54770a84 --- /dev/null +++ b/DEVEL/mathml_editor/textomml/.cvsignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +textomml +config.dirs diff --git a/DEVEL/mathml_editor/textomml/Makefile.am b/DEVEL/mathml_editor/textomml/Makefile.am new file mode 100644 index 000000000..cd66658f5 --- /dev/null +++ b/DEVEL/mathml_editor/textomml/Makefile.am @@ -0,0 +1,17 @@ + +noinst_PROGRAMS = textomml + +textomml_SOURCES = main.cc + +LDADDS = \ + $(GMETADOM_LIBS) \ + $(GDOMEXSLT_LIBS) \ + $(top_builddir)/src/.libs/libeditex.a + +textomml_LDADD = $(LDADDS) + +INCLUDES = \ + $(GMETADOM_CFLAGS) \ + $(GDOMEXSLT_CFLAGS) \ + -I$(top_srcdir)/src + diff --git a/DEVEL/mathml_editor/textomml/config.dirs.in b/DEVEL/mathml_editor/textomml/config.dirs.in new file mode 100644 index 000000000..49791891b --- /dev/null +++ b/DEVEL/mathml_editor/textomml/config.dirs.in @@ -0,0 +1 @@ +#define PKGDATADIR "@prefix@/share/@PACKAGE@" diff --git a/DEVEL/mathml_editor/textomml/main.cc b/DEVEL/mathml_editor/textomml/main.cc new file mode 100644 index 000000000..9da0f0993 --- /dev/null +++ b/DEVEL/mathml_editor/textomml/main.cc @@ -0,0 +1,192 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ + +#include +#include +#include + +#include "dom.hh" +#include "TPushParser.hh" +#include "TPushLexer.hh" +#include "TDictionary.hh" +#include "CLoggerConsole.hh" +#include "CMathMLFactoryXSLT.hh" +#include "CMathMLFactoryXSLTDiff.hh" +#include "AMathMLConsumer.hh" + +#include "config.dirs" + +enum CommandLineOptionId { + OPTION_VERSION = 256, + OPTION_HELP, + OPTION_VERBOSE, + OPTION_DICTIONARY, + OPTION_TML_XSLT, + OPTION_XSLT +}; + +static std::string tml_xslt = PKGDATADIR"/tml-mmlp.xsl"; +static std::string dictionary = PKGDATADIR"/dictionary-tex.xml"; +static bool xslt = true; + +static bool +parseBoolean(const char* s, bool& res) +{ + assert(s != NULL); + if (!strcmp(s, "yes")) { + res = true; + return true; + } else if (!strcmp(s, "no")) { + res = false; + return true; + } + + return false; +} + +static void +printVersion() +{ + std::cout << "TeX to MathML converter " << VERSION << " - Luca Padovani (C) 2003" << std::endl + << "This program is covered by the GNU Lesser General Public Licence" << std::endl; +} + +static void +printHelp() +{ + static char* helpMsg = "\ +Usage: textomml [options] file\n\n\ + -V, --version Output version information\n\ + -h, --help This small usage guide\n\ + -v, --verbose[=0-3] Display messages\n\ + --dictionary= Full path of the dictionary\n\ + --tml-xslt= Full path of the XSLT stylesheet\n\ + --xslt[=yes|no] Enable/disable XSLT transformation (default='yes')\n\ +"; + + std::cout << helpMsg << std::endl; + exit(0); +} + +static void +parseError(const char* option) +{ + assert(option != NULL); + std::cerr << "error while parsing option `" << option << "'" << std::endl << std::endl; + printHelp(); +} + +int +main(int argc, char* argv[]) +{ + CLoggerConsole logger; + + while (TRUE) { + int option_index = 0; + static struct option long_options[] = + { + { "version", no_argument, NULL, OPTION_VERSION }, + { "help", no_argument, NULL, OPTION_HELP }, + { "verbose", optional_argument, NULL, OPTION_VERBOSE }, + { "dictionary", required_argument, NULL, OPTION_DICTIONARY }, + { "tml-xslt", required_argument, NULL, OPTION_TML_XSLT }, + { "xslt", optional_argument, NULL, OPTION_XSLT }, + + { NULL, no_argument, NULL, 0 } + }; + + int c = getopt_long(argc, argv, "Vhv::", long_options, &option_index); + + if (c == -1) break; + + switch (c) { + case OPTION_VERSION: + case 'V': + printVersion(); + break; + + case OPTION_HELP: + case 'h': + printHelp(); + break; + + case OPTION_VERBOSE: + case 'v': + if (optarg == NULL) logger.verbosity(ALogger::Warning); + else logger.verbosity(ALogger::Level(*optarg - '0')); + break; + + case OPTION_DICTIONARY: + dictionary = optarg; + break; + + case OPTION_TML_XSLT: + tml_xslt = optarg; + break; + + case OPTION_XSLT: + if (optarg == NULL) printHelp(); + else if (!parseBoolean(optarg, xslt)) parseError("xslt"); + break; + + case '?': + break; + + default: + std::cerr << "*** getopt returned `" << c << "' value" << std::endl; + break; + } + } + + TDictionary dict(logger); + logger.info("loading dictionary: `" + dictionary + "'"); + dict.load("dictionary-test.xml"); + + logger.info("loading stylesheet: `" + tml_xslt + "'"); + DOM::DOMImplementation di; + DOM::Document docStyle = di.createDocumentFromURI("./xsl/tml-mmlp.xsl"); + DOMX::XSLTStylesheet style(docStyle); + + CMathMLFactoryXSLT factory(logger, style); + TPushParser parser(logger, factory, dict); + TPushLexer lexer(logger, parser); + + if (optind < argc) + { + std::ifstream file(argv[optind]); + if (!file) + { + std::cerr << "can't open input file `" << argv[optind] << "'" << std::endl; + exit(1); + } + + parser.freeze(); + char ch; + while (file.get(ch)) lexer.push(ch); + parser.thaw(); + } + else + printHelp(); +} diff --git a/DEVEL/mathml_editor/xsl/.cvsignore b/DEVEL/mathml_editor/xsl/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/DEVEL/mathml_editor/xsl/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/DEVEL/mathml_editor/xsl/Makefile.am b/DEVEL/mathml_editor/xsl/Makefile.am new file mode 100644 index 000000000..283941298 --- /dev/null +++ b/DEVEL/mathml_editor/xsl/Makefile.am @@ -0,0 +1,2 @@ +pkgdata_DATA = d-xsl.xsl tml-mmlp.xsl tml-tex.xsl tml-litex.xsl tml-texid.xsl +EXTRA_DIST = d-xsl.xsl tml-mmlp.xsl tml-tex.xsl tml-litex.xsl tml-texid.xsl diff --git a/DEVEL/mathml_editor/xsl/d-xsl.xsl b/DEVEL/mathml_editor/xsl/d-xsl.xsl new file mode 100644 index 000000000..961989aeb --- /dev/null +++ b/DEVEL/mathml_editor/xsl/d-xsl.xsl @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /// CONTROL SEQUENCES /// + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/xsl/tml-litex.xsl b/DEVEL/mathml_editor/xsl/tml-litex.xsl new file mode 100644 index 000000000..a39c6f03b --- /dev/null +++ b/DEVEL/mathml_editor/xsl/tml-litex.xsl @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $$$$ + $$ + + + + + + \ + + + + + + + + + \ + + + + + + + + + \ + + + + + + + + + + + + + + + __ + + + _ + + + + + + + + ^^ + + + ^ + + + + + {} + + {} + + + + + + + \cr + + + + & + + + + + + \ + + + + + \ + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/xsl/tml-mmlp.xsl b/DEVEL/mathml_editor/xsl/tml-mmlp.xsl new file mode 100644 index 000000000..73d2ab049 --- /dev/null +++ b/DEVEL/mathml_editor/xsl/tml-mmlp.xsl @@ -0,0 +1,1160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + block + + block + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + − + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + I + + + + + + + + + + + + I + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ + + + + + + + + + + + + λ + + : + + . + + + + + + + + + + + + + ̸ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ̂ + + + + + + + + + + + + + ̂ + + + + + + + + + + + + + ̌ + + + + + + + + + + + + + ̃ + + + + + + + + + + + + + ̃ + > + + + + + + + + + + + + ́ + + + + + + + + + + + + + ̀ + > + + + + + + + + + + + + ̇ + + + + + + + + + + + + + ̈ + + + + + + + + + + + + + ̆ + + + + + + + + + + + + + ̄ + + + + + + + + + + + + + + + + + + + + + + + + + + ̅ + + + + + + + + + + + + + ̲ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + + + + ) + + + + + + + + + + + + { + + + + + } + + + + + + + + + + + + [ + + + + + ] + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + mod + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ( + + + + ) + + + + + + + + + + + + + + + + + + + + + + + ( + + + + + + ) + + + + + + + + + + + + + + + + + ???? + > + + + + + + + + + + + + ???? + + + + + + + + + + + + { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DEVEL/mathml_editor/xsl/tml-tex.xsl b/DEVEL/mathml_editor/xsl/tml-tex.xsl new file mode 100644 index 000000000..ea0a6b94e --- /dev/null +++ b/DEVEL/mathml_editor/xsl/tml-tex.xsl @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $$$$ + $$ + + + + + + \ + + + + {\rm } + + + + + + \ + + + + {\rm } + + + + + + \ + + + + + + + + + + + + + + + __ + + + _ + + + + + + + + ^^ + + + ^ + + + + + {} + + {} + + + + + + + \cr + + + + & + + + + + + \ + + + + + \ + + + + + + + + + + + {\rm } + + + + + diff --git a/DEVEL/mathml_editor/xsl/tml-texid.xsl b/DEVEL/mathml_editor/xsl/tml-texid.xsl new file mode 100644 index 000000000..20de507a4 --- /dev/null +++ b/DEVEL/mathml_editor/xsl/tml-texid.xsl @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + {\id{}{}} + + + + + + + + + + $${\id{}{}}$$ + ${\id{}{}}$ + + + + + + $$$$ + $$ + + + + + + \ + + + + + + + + + \ + + + + + + + + + \ + + + + + + + + + + + + + + __ + + + _ + + + + + + + + ^^ + + + ^ + + + + + {} + + + \cr + + + + & + + + + + + \ + + + + + \ + + + + + + diff --git a/DEVEL/ocaml-http/.cvsignore b/DEVEL/ocaml-http/.cvsignore new file mode 100644 index 000000000..391f4f58e --- /dev/null +++ b/DEVEL/ocaml-http/.cvsignore @@ -0,0 +1,8 @@ +*.cmi +*.cmo +*.cmx +*.cma +*.cmxa +*.o +*.a +*.deb diff --git a/DEVEL/ocaml-http/.depend b/DEVEL/ocaml-http/.depend new file mode 100644 index 000000000..7c4762fd1 --- /dev/null +++ b/DEVEL/ocaml-http/.depend @@ -0,0 +1,49 @@ +http_common.cmo: http_types.cmi http_constants.cmi http_common.cmi +http_common.cmx: http_types.cmx http_constants.cmx http_common.cmi +http_constants.cmo: http_constants.cmi +http_constants.cmx: http_constants.cmi +http_daemon.cmo: http_types.cmi http_tcp_server.cmi http_request.cmi \ + http_parser_sanity.cmi http_parser.cmi http_misc.cmi http_constants.cmi \ + http_common.cmi http_daemon.cmi +http_daemon.cmx: http_types.cmx http_tcp_server.cmx http_request.cmx \ + http_parser_sanity.cmx http_parser.cmx http_misc.cmx http_constants.cmx \ + http_common.cmx http_daemon.cmi +http_message.cmo: http_types.cmi http_parser_sanity.cmi http_misc.cmi \ + http_constants.cmi http_common.cmi http_message.cmi +http_message.cmx: http_types.cmx http_parser_sanity.cmx http_misc.cmx \ + http_constants.cmx http_common.cmx http_message.cmi +http_misc.cmo: http_types.cmi http_misc.cmi +http_misc.cmx: http_types.cmx http_misc.cmi +http_parser.cmo: http_types.cmi http_parser_sanity.cmi http_constants.cmi \ + http_common.cmi http_parser.cmi +http_parser.cmx: http_types.cmx http_parser_sanity.cmx http_constants.cmx \ + http_common.cmx http_parser.cmi +http_parser_sanity.cmo: http_types.cmi http_constants.cmi \ + http_parser_sanity.cmi +http_parser_sanity.cmx: http_types.cmx http_constants.cmx \ + http_parser_sanity.cmi +http_request.cmo: http_types.cmi http_parser.cmi http_misc.cmi \ + http_message.cmi http_common.cmi http_request.cmi +http_request.cmx: http_types.cmx http_parser.cmx http_misc.cmx \ + http_message.cmx http_common.cmx http_request.cmi +http_response.cmo: http_types.cmi http_misc.cmi http_message.cmi \ + http_daemon.cmi http_constants.cmi http_common.cmi http_response.cmi +http_response.cmx: http_types.cmx http_misc.cmx http_message.cmx \ + http_daemon.cmx http_constants.cmx http_common.cmx http_response.cmi +http_tcp_server.cmo: http_threaded_tcp_server.cmi http_tcp_server.cmi +http_tcp_server.cmx: http_threaded_tcp_server.cmi http_tcp_server.cmi +http_types.cmo: http_types.cmi +http_types.cmx: http_types.cmi +http_user_agent.cmo: http_parser.cmi http_misc.cmi http_common.cmi \ + http_user_agent.cmi +http_user_agent.cmx: http_parser.cmx http_misc.cmx http_common.cmx \ + http_user_agent.cmi +http_common.cmi: http_types.cmi +http_constants.cmi: http_types.cmi +http_daemon.cmi: http_types.cmi +http_message.cmi: http_types.cmi +http_parser.cmi: http_types.cmi +http_request.cmi: http_types.cmi +http_response.cmi: http_types.cmi +http_tcp_server.cmi: http_types.cmi +http_user_agent.cmi: http_types.cmi diff --git a/DEVEL/ocaml-http/.ocamlinit b/DEVEL/ocaml-http/.ocamlinit new file mode 100644 index 000000000..64694a213 --- /dev/null +++ b/DEVEL/ocaml-http/.ocamlinit @@ -0,0 +1,5 @@ +#use "topfind";; +#require "unix";; +#require "pcre";; +#require "netstring";; +#load "http.cma";; diff --git a/DEVEL/ocaml-http/INSTALL b/DEVEL/ocaml-http/INSTALL new file mode 100644 index 000000000..dc1a772e1 --- /dev/null +++ b/DEVEL/ocaml-http/INSTALL @@ -0,0 +1,37 @@ + +In order to build ocaml-http you will need: + + - the ocaml compiler + [ http://caml.inria.fr ] + + - findlib + [ http://www.ocaml-programming.de/packages/documentation/findlib/ ] + + - ocamlnet + [ http://sourceforge.net/projects/ocamlnet ] + + - pcre-ocaml + [ http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html ] + +To build the bytecode library: + + $ make all + +To build the nativecode library (only if you have an ocaml native code +compiler): + + $ make opt + +To install the built stuff in the OCaml standard library directory (as root): + + # make install + +To install the built stuff in another directory: + + $ make install DESTDIR=another_directory + +To build a debian package of the library (please note that to build a debian +package you will also need some additional stuff like debhelper, fakeroot, ...): + + $ fakeroot debian/rules binary + diff --git a/DEVEL/ocaml-http/LICENSE b/DEVEL/ocaml-http/LICENSE new file mode 100644 index 000000000..f1c4ea8c3 --- /dev/null +++ b/DEVEL/ocaml-http/LICENSE @@ -0,0 +1,483 @@ + + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + diff --git a/DEVEL/ocaml-http/META.in b/DEVEL/ocaml-http/META.in new file mode 100644 index 000000000..8c325462e --- /dev/null +++ b/DEVEL/ocaml-http/META.in @@ -0,0 +1,8 @@ +description = "OCaml HTTP daemon library" +version = "@DISTVERSION@" +requires = "unix,pcre,netstring" +requires(mt) = "unix,pcre,netstring,threads" +archive(byte) = "http.cma" +archive(native) = "http.cmxa" +archive(mt,byte) = "http_mt.cma" +archive(mt,native) = "http_mt.cmxa" diff --git a/DEVEL/ocaml-http/Makefile b/DEVEL/ocaml-http/Makefile new file mode 100644 index 000000000..572a7f258 --- /dev/null +++ b/DEVEL/ocaml-http/Makefile @@ -0,0 +1,137 @@ +include Makefile.defs + +MODULES = \ + http_constants http_types http_parser_sanity http_misc http_common \ + http_tcp_server http_parser http_message http_request http_daemon \ + http_response http_user_agent + +THREADED_SRV = http_threaded_tcp_server +MODULES_MT = $(patsubst http_tcp_server, mt/$(THREADED_SRV) http_tcp_server, $(MODULES)) +MODULES_NON_MT = $(patsubst http_tcp_server, non_mt/$(THREADED_SRV) http_tcp_server, $(MODULES)) +PUBLIC_MODULES = \ + http_types \ + http_common \ + http_message \ + http_request \ + http_daemon \ + http_response \ + http_user_agent +OCAMLDOC_STUFF = *.mli +DOCDIR = doc/html +DOTDIR = doc/dot +TEXDIR = doc/latex +DESTDIR = $(shell $(OCAMLFIND) printconf destdir) + +all: all_non_mt all_mt +opt: opt_non_mt opt_mt +all_non_mt: http.cma +opt_non_mt: http.cmxa +all_mt: http_mt.cma +opt_mt: http_mt.cmxa +world: all opt +doc: all $(DOCDIR)/index.html $(DOTDIR)/ocaml-http.ps $(TEXDIR)/ocaml-http.ps $(OCAMLDOC_STUFF) +$(DOCDIR)/index.html: + $(OCAMLDOC) -html -d $(DOCDIR) $(OCAMLDOC_STUFF) +$(TEXDIR)/ocaml-http.tex: $(OCAMLDOC_STUFF) + $(OCAMLDOC) -latex -o $@ $^ +$(TEXDIR)/ocaml-http.ps: $(TEXDIR)/ocaml-http.tex + cd $(TEXDIR); \ + latex ocaml-http; \ + latex ocaml-http; \ + dvips ocaml-http +$(DOTDIR)/ocaml-http.ps: $(DOTDIR)/ocaml-http.dot + $(DOT) -Tps $< > $@ +$(DOTDIR)/ocaml-http.dot: *.ml *.mli + $(OCAMLDOC) -dot -o $(DOTDIR)/ocaml-http.dot *.ml *.mli + +examples: + $(MAKE) -C examples/ +examples.opt: + $(MAKE) -C examples/ opt + +include .depend + +depend: + $(OCAMLDEP) *.ml *.mli > .depend + +%.cmi: %.mli + $(OCAMLC) -c $< +%.cmo: %.ml %.cmi + $(OCAMLC) -c $< +%.cmx: %.ml %.cmi + $(OCAMLOPT) -c $< + +non_mt/$(THREADED_SRV).cmo: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} non_mt/ + $(OCAMLC) -c $< +non_mt/$(THREADED_SRV).cmx: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} non_mt/ + $(OCAMLOPT) -c $< + +mt/$(THREADED_SRV).cmo: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} mt/ + $(OCAMLC) $(THREADS_FLAGS) -c $< +mt/$(THREADED_SRV).cmx: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} mt/ + $(OCAMLOPT) $(THREADS_FLAGS) -c $< + +http.cma: $(patsubst %,%.cmo,$(MODULES_NON_MT)) + $(OCAMLC) -a -o $@ $^ +http.cmxa: $(patsubst %,%.cmx,$(MODULES_NON_MT)) + $(OCAMLOPT) -a -o $@ $^ +http_mt.cma: $(patsubst %,%.cmo,$(MODULES_MT)) + $(OCAMLC) -a -o $@ $^ +http_mt.cmxa: $(patsubst %,%.cmx,$(MODULES_MT)) + $(OCAMLOPT) -a -o $@ $^ + +meta: META +META: META.in + cat META.in | sed -e 's/@DISTVERSION@/$(DISTVERSION)/' > META + +clean: + $(MAKE) -C examples/ clean + for d in . mt non_mt; do \ + rm -f $$d/*.cm[ioax] $$d/*.cmxa $$d/*.[ao] $$d/test{,.opt}; \ + done + rm -f {mt,non_mt}/$(THREADED_SRV).mli +docclean: + -rm -f \ + $(DOCDIR)/*.html $(DOCDIR)/*.css \ + $(DOTDIR)/*.dot $(DOTDIR)/*.ps \ + $(TEXDIR)/*.{dvi,ps,ps.gz,pdf,aux,log,out,toc,tmp,haux,sty,tex} +distclean: clean + $(MAKE) -C examples/ distclean + rm -f META +dist: distreal distrm +distdoc: all doc + if [ -d $(DISTDIR) ]; then rm -rf $(DISTDIR); else true; fi + mkdir -p $(DISTDIR)/doc/ + cp -r doc/html/ $(DISTDIR)/doc/ + cp doc/dot/ocaml-http.ps $(DISTDIR)/doc/modules.ps + cp doc/latex/ocaml-http.ps $(DISTDIR)/doc/ +distreal: distdoc distclean depend + for f in \ + $(patsubst %, %.ml, $(MODULES)) \ + $(patsubst %, %.mli, $(MODULES) $(THREADED_SRV)) \ + mt/ non_mt/ $(EXTRA_DIST) examples/ debian/; \ + do \ + cp -r $$f $(DISTDIR)/; \ + done + -find $(DISTDIR)/ -type d -name CVS -exec rm -rf {} \; + -find $(DISTDIR)/ -type f -name ".cvs*" -exec rm -f {} \; + tar cvzf $(DISTDIR).tar.gz $(DISTDIR)/ +distrm: + rm -rf $(DISTDIR)/ +deb: docclean distreal + (cd $(DISTDIR)/ && debuild) + rm -rf $(DISTDIR)/ +install: META + $(OCAMLFIND) install -destdir $(DESTDIR) $(PKGNAME) \ + $(patsubst %, %.mli, $(PUBLIC_MODULES)) \ + $(patsubst %, %.cmi, $(PUBLIC_MODULES)) \ + $(wildcard *.cma *.cmxa *.a) META + +.PHONY: \ + all opt world all_non_mt all_mt opt_non_mt opt_mt \ + examples examples.opt depend clean distclean dist \ + install meta doc deb distreal distrm diff --git a/DEVEL/ocaml-http/Makefile.defs b/DEVEL/ocaml-http/Makefile.defs new file mode 100644 index 000000000..4d9f7c5ca --- /dev/null +++ b/DEVEL/ocaml-http/Makefile.defs @@ -0,0 +1,24 @@ +PKGNAME = http +DISTVERSION = $(shell dpkg-parsechangelog | egrep '^Version: ' | sed 's/^Version: //' | sed 's/-.*//') + +DEBUG_FLAGS = +REQUIRES = unix str pcre netstring +COMMON_FLAGS = $(DEBUG_FLAGS) -pp camlp4o -package "$(REQUIRES)" +THREADS_FLAGS = -package threads -thread +OCAMLFIND = ocamlfind +OCAMLC = $(OCAMLFIND) ocamlc $(COMMON_FLAGS) +OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_FLAGS) +OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_FLAGS) +OCAMLDOC := \ + ocamldoc -stars \ + $(shell $(OCAMLFIND) query -i-format unix) \ + $(shell $(OCAMLFIND) query -i-format pcre) \ + $(shell $(OCAMLFIND) query -i-format netstring) +DOT = dot + +DISTNAME = ocaml-http +DISTDIR = $(DISTNAME)-$(DISTVERSION) +EXTRA_DIST = \ + INSTALL LICENSE README META.in Makefile Makefile.defs \ + .depend + diff --git a/DEVEL/ocaml-http/README b/DEVEL/ocaml-http/README new file mode 100644 index 000000000..1566b8e8b --- /dev/null +++ b/DEVEL/ocaml-http/README @@ -0,0 +1,4 @@ + +OCaml HTTP is a simple OCaml library for creating HTTP daemons, it is largely +inspired to the Perl's HTTP:: modules family. + diff --git a/DEVEL/ocaml-http/TODO b/DEVEL/ocaml-http/TODO new file mode 100644 index 000000000..7fc3c6bb6 --- /dev/null +++ b/DEVEL/ocaml-http/TODO @@ -0,0 +1 @@ +- support for HTTPS diff --git a/DEVEL/ocaml-http/debian/changelog b/DEVEL/ocaml-http/debian/changelog new file mode 100644 index 000000000..a341c9f7f --- /dev/null +++ b/DEVEL/ocaml-http/debian/changelog @@ -0,0 +1,163 @@ +ocaml-http (0.1.2-3) unstable; urgency=low + + * Rebuilt against OCaml 3.09.1, bumped deps accordingly. + + -- Stefano Zacchiroli Sun, 8 Jan 2006 13:13:07 +0100 + +ocaml-http (0.1.2-2) unstable; urgency=low + + * rebuilt with ocaml 3.09 + * debian/* + - no more hardcoding of ocaml abi version anywhere + * debian/rules + - use cdbs + + -- Stefano Zacchiroli Sat, 26 Nov 2005 20:28:26 +0100 + +ocaml-http (0.1.2-1) unstable; urgency=low + + * avoid exceptions for closing connection twice during finaliztion of + connection objects (thanks to Eric Strokes + for the patch) + + -- Stefano Zacchiroli Wed, 14 Sep 2005 18:03:40 +0200 + +ocaml-http (0.1.1-1) unstable; urgency=low + + * added ?default parameter to "param" method + * fixed bug in response status line parsing + * integrated patch for HTTP/1.1 persistent connections from + Eric Cooper : + - added support for persistent connections to http_daemon.ml: server + now loops until End_of_file (or any exception) occurs when trying + to parse the next request + * debian/control + - bumped pcre and ocamlnet dependencies + - bumped standards-version to 3.6.2 + + -- Stefano Zacchiroli Wed, 16 Mar 2005 09:24:07 +0100 + +ocaml-http (0.1.0-2) unstable; urgency=low + + * rebuilt against ocaml 3.08.3 + + -- Stefano Zacchiroli Tue, 29 Mar 2005 11:39:24 +0200 + +ocaml-http (0.1.0-1) unstable; urgency=low + + * first debian official package + + -- Stefano Zacchiroli Tue, 8 Feb 2005 22:45:54 +0100 + +ocaml-http (0.1.0) unstable; urgency=low + + * added "daemon specifications": a unified way of specifying daemons + behaviour including old parameters of Http_daemon.start together + with authentication requirements and exception handling + * added new way of building daemons starting from specifications, old + ways (e.g. Http_daemon.start) are now deprecated + * added sigpipe handling to avoid daemons dying for uncaught signals + * added exception handler (as part of a daemon specification), it can + be used to ensure that some code is execute before a process/thread + die for uncaught exception (e.g. unlocking a global mutex) + * added authentication requirements (as part of a daemon + specification): an handy way to specify required user name and + password for HTTP basic authentication + * added head_callback to Http_user_agent in order to have access to + response status and headers in HTTP requests + * changed license from GPL to LGPL + * improved ocamldoc documentation and debian packaging + + -- Stefano Zacchiroli Thu, 3 Feb 2005 23:08:14 +0100 + +ocaml-http (0.0.10) unstable; urgency=low + + * renamed Http_client module to Http_user_agent to avoid compatibility + issues with Netclient. Renamed that module functions removing + "http_" prefix (e.g., summarizing, Http_client.http_get -> + Http_user_agent.get) + * ported to ocaml 3.08 + * debian/control + - bumped standards version to 3.6.1.1 + - changed deps to ocaml 3.08 and -nox + + -- Stefano Zacchiroli Thu, 5 Aug 2004 15:06:49 +0200 + +ocaml-http (0.0.9) unstable; urgency=low + + * Added support for HTTP Basic authentication + * Restyled Http_daemon API so that correct invocations of them are + statically typechecked + * Added support for HEAD requests to Http_client + * ~addr parameter now support not only ip addresses but also hostnames + * debian/control + - bumped Standards-Version to 3.6.1.0 + * debian/rules + - moved debhelper compatibility level to debian/compat + + -- Stefano Zacchiroli Tue, 16 Dec 2003 18:01:41 +0100 + +ocaml-http (0.0.8) unstable; urgency=low + + * Added support for "ancient" HTTP requests which specify no HTTP + version + - 'version' method on message now has type 'version option' + * Http_daemon now use debugging prints from Http_common like other + modules + * Added debugging print of requests parse error + * Shutdown server socket on abnormal exit (actually: uncaught + exceptions or SIGTERM received) + * Added a lot of ocamldoc documentation + * Added minimal HTTP 1.0/1.1 client support + + -- Stefano Zacchiroli Fri, 10 Jan 2003 10:36:53 +0100 + +ocaml-http (0.0.7) unstable; urgency=low + + * Added support for POST requests + * Implemented a commont 'message' class from which 'request' and + 'response' inherit + * Changed constructor of 'request' objects, requests are now buildable + directly (and only) from an input channel + * Added client IP address information to Http_request.request class + * Added OO daemon interfaces ("daemon" and "connection" classes) + * Use Pcre to perform sanity test on headers instead of home made + parsing + * Callback functions can raise Http_types.Quit to have main daemon + quit + * Case-insensitive handling of header names + + -- Stefano Zacchiroli Wed, 25 Dec 2002 16:22:31 +0100 + +ocaml-http (0.0.6) unstable; urgency=low + + * Ship multithreaded and non multithreaded cm{x,}aS + * Added support for multiple binding of the same parameter in request + objects (new method 'paramAll') + * Added support for 'empty' bindings in query arguments (e.g. + "/foo?b=" or "/foo?b") + * Added some sanity checks + * Bumped Standards-Version to 3.5.8 + * Use versioned dependencies lib{pcre,ocamlnet}-ocaml-dev- + * Added 'Provides libhttp-ocaml-dev-' + * Removed GPL from debian/copyright, added reference to + /usr/share/common-licenses/GPL + + -- Stefano Zacchiroli Mon, 25 Nov 2002 11:04:49 +0100 + +ocaml-http (0.0.5) unstable; urgency=low + + * Fixed bug for HTTP encoded GET parameters which contain '?' or '&' + characters + * Added support for chdir in a given document root before starting + * Added support for multi threaded daemons + * Added a generic 'Http_daemon.respond' function + * Added 'toString' method to response objects + + -- Stefano Zacchiroli Fri, 22 Nov 2002 11:29:37 +0100 + +ocaml-http (0.0.3) unstable; urgency=low + + * First release. + + -- Stefano Zacchiroli Sun, 17 Nov 2002 17:41:41 +0100 diff --git a/DEVEL/ocaml-http/debian/compat b/DEVEL/ocaml-http/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/DEVEL/ocaml-http/debian/compat @@ -0,0 +1 @@ +4 diff --git a/DEVEL/ocaml-http/debian/control b/DEVEL/ocaml-http/debian/control new file mode 100644 index 000000000..1b42aa4e9 --- /dev/null +++ b/DEVEL/ocaml-http/debian/control @@ -0,0 +1,23 @@ +Source: ocaml-http +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>> 4.0.0), ocaml-nox (>= 3.09.1), ocaml-findlib (>= 1.1), libpcre-ocaml-dev (>= 5.10.1-2), libocamlnet-ocaml-dev (>= 1.1-8), cdbs +Standards-Version: 3.6.2 + +Package: libhttp-ocaml-dev +Architecture: any +Depends: ocaml-nox-${F:OCamlABI}, libpcre-ocaml-dev (>= 5.10.1-2), libocamlnet-ocaml-dev (>= 1.1-8) +Description: OCaml library for writing HTTP servers + OCaml HTTP is a library for the Objective Caml programming language, + used to build simple HTTP servers, largely inspired to Perl's + HTTP::Daemon module. + . + In order to implement an HTTP servers the programmer has to provide a + daemon specification which contains, among other parameters, a callback + function invoked by OCaml HTTP on well formed HTTP requests received. + HTTP responses could be sent over an out_channel connected with client + socket, accessible from the callback. + . + The library contains also facility functions that helps in creating + well formed HTTP responses and a tiny HTTP client. diff --git a/DEVEL/ocaml-http/debian/control.in b/DEVEL/ocaml-http/debian/control.in new file mode 100644 index 000000000..60b295bbf --- /dev/null +++ b/DEVEL/ocaml-http/debian/control.in @@ -0,0 +1,23 @@ +Source: ocaml-http +Section: devel +Priority: optional +Maintainer: Stefano Zacchiroli +Build-Depends: debhelper (>> 4.0.0), ocaml-nox (>= @OCamlABI@), ocaml-findlib (>= 1.1), libpcre-ocaml-dev (>= 5.10.1-2), libocamlnet-ocaml-dev (>= 1.1-8), cdbs +Standards-Version: 3.6.2 + +Package: libhttp-ocaml-dev +Architecture: any +Depends: ocaml-nox-${F:OCamlABI}, libpcre-ocaml-dev (>= 5.10.1-2), libocamlnet-ocaml-dev (>= 1.1-8) +Description: OCaml library for writing HTTP servers + OCaml HTTP is a library for the Objective Caml programming language, + used to build simple HTTP servers, largely inspired to Perl's + HTTP::Daemon module. + . + In order to implement an HTTP servers the programmer has to provide a + daemon specification which contains, among other parameters, a callback + function invoked by OCaml HTTP on well formed HTTP requests received. + HTTP responses could be sent over an out_channel connected with client + socket, accessible from the callback. + . + The library contains also facility functions that helps in creating + well formed HTTP responses and a tiny HTTP client. diff --git a/DEVEL/ocaml-http/debian/copyright b/DEVEL/ocaml-http/debian/copyright new file mode 100644 index 000000000..38cb08c98 --- /dev/null +++ b/DEVEL/ocaml-http/debian/copyright @@ -0,0 +1,15 @@ + +Author: Stefano Zacchiroli + +Copyright: + + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + OCaml HTTP is distributed under the term of the GNU Library General + Public License version 2, on Debian systems you can find a copy of the + license in: + + /usr/share/common-licenses/LGPL-2 + diff --git a/DEVEL/ocaml-http/debian/dirs b/DEVEL/ocaml-http/debian/dirs new file mode 100644 index 000000000..d85903676 --- /dev/null +++ b/DEVEL/ocaml-http/debian/dirs @@ -0,0 +1 @@ +/usr/lib/ocaml/3.09.1 diff --git a/DEVEL/ocaml-http/debian/dirs.in b/DEVEL/ocaml-http/debian/dirs.in new file mode 100644 index 000000000..330aaf420 --- /dev/null +++ b/DEVEL/ocaml-http/debian/dirs.in @@ -0,0 +1 @@ +/usr/lib/ocaml/@OCamlABI@ diff --git a/DEVEL/ocaml-http/debian/doc-base b/DEVEL/ocaml-http/debian/doc-base new file mode 100644 index 000000000..29b950dab --- /dev/null +++ b/DEVEL/ocaml-http/debian/doc-base @@ -0,0 +1,12 @@ +Document: ocaml-http +Title: OCaml HTTP API reference manual +Author: Stefano Zacchiroli +Abstract: API reference manual for OCaml HTTP, an Objective Caml library for writing HTTP servers +Section: Apps/Programming + +Format: HTML +Index: /usr/share/doc/libhttp-ocaml-dev/html/index.html +Files: /usr/share/doc/libhttp-ocaml-dev/html/* + +Format: PostScript +Files: /usr/share/doc/libhttp-ocaml-dev/ocaml-http.ps.gz diff --git a/DEVEL/ocaml-http/debian/docs b/DEVEL/ocaml-http/debian/docs new file mode 100644 index 000000000..2e098492d --- /dev/null +++ b/DEVEL/ocaml-http/debian/docs @@ -0,0 +1,2 @@ +README +doc/* diff --git a/DEVEL/ocaml-http/debian/examples b/DEVEL/ocaml-http/debian/examples new file mode 100644 index 000000000..6e72ae207 --- /dev/null +++ b/DEVEL/ocaml-http/debian/examples @@ -0,0 +1 @@ +examples/*.ml diff --git a/DEVEL/ocaml-http/debian/rules b/DEVEL/ocaml-http/debian/rules new file mode 100755 index 000000000..bde072744 --- /dev/null +++ b/DEVEL/ocaml-http/debian/rules @@ -0,0 +1,20 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/makefile.mk + +PKGNAME = libhttp-ocaml-dev + +OCAMLABI := $(shell ocamlc -version) +OCAMLLIBDIR := $(shell ocamlc -where) +OFILES := $(patsubst %.in,%,$(shell ls debian/*.in)) +HAVE_OCAMLOPT := $(shell test -x /usr/bin/ocamlopt && echo "yes") +DEB_DH_GENCONTROL_ARGS = -- -VF:OCamlABI="$(OCAMLABI)" +DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(CURDIR)/debian/$(PKGNAME)$(OCAMLLIBDIR) + +ocamlinit: + for f in $(OFILES); do sed -e 's/@OCamlABI@/$(OCAMLABI)/g' $$f.in > $$f; done + +ifeq ($(HAVE_OCAMLOPT),yes) +build/$(PKGNAME):: + $(MAKE) opt +endif diff --git a/DEVEL/ocaml-http/doc/dot/.cvsignore b/DEVEL/ocaml-http/doc/dot/.cvsignore new file mode 100644 index 000000000..269c66077 --- /dev/null +++ b/DEVEL/ocaml-http/doc/dot/.cvsignore @@ -0,0 +1,2 @@ +*.dot +*.ps diff --git a/DEVEL/ocaml-http/doc/html/.cvsignore b/DEVEL/ocaml-http/doc/html/.cvsignore new file mode 100644 index 000000000..d0098b437 --- /dev/null +++ b/DEVEL/ocaml-http/doc/html/.cvsignore @@ -0,0 +1,2 @@ +*.css +*.html diff --git a/DEVEL/ocaml-http/doc/latex/.cvsignore b/DEVEL/ocaml-http/doc/latex/.cvsignore new file mode 100644 index 000000000..01564af35 --- /dev/null +++ b/DEVEL/ocaml-http/doc/latex/.cvsignore @@ -0,0 +1 @@ +*.tex diff --git a/DEVEL/ocaml-http/examples/.cvsignore b/DEVEL/ocaml-http/examples/.cvsignore new file mode 100644 index 000000000..cf7440d52 --- /dev/null +++ b/DEVEL/ocaml-http/examples/.cvsignore @@ -0,0 +1,18 @@ +*.cmi +*.cmo +*.cmx +*.cma +*.cmxa +always_ok_daemon +basic_auth +chdir +client_address +damned_recursion +dont_fork +dump_args +highlander +obj_foo +oo_daemon +threads +timeout +webfsd diff --git a/DEVEL/ocaml-http/examples/Makefile b/DEVEL/ocaml-http/examples/Makefile new file mode 100644 index 000000000..9209563f6 --- /dev/null +++ b/DEVEL/ocaml-http/examples/Makefile @@ -0,0 +1,41 @@ +include ../Makefile.defs +OBJS_NON_MT = ../http.cma +OBJS_NON_MT_OPT = ../http.cmxa +OBJS_MT = ../http_mt.cma +OBJS_MT_OPT = ../http_mt.cmxa +EXAMPLES_FLAGS = -I .. -linkpkg + +EXAMPLES := \ + always_ok_daemon.ml \ + basic_auth.ml \ + chdir.ml \ + client_address.ml \ + damned_recursion.ml \ + dump_args.ml \ + highlander.ml \ + oo_daemon.ml \ + threads.ml \ + timeout.ml \ + webfsd.ml +EXAMPLES := $(patsubst %.ml,%,$(EXAMPLES)) + +all: $(EXAMPLES) +opt: $(patsubst %,%.opt,$(EXAMPLES)) +%: %.ml $(OBJS_NON_MT) + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_NON_MT) -o $@ $< +%.opt: %.ml $(OBJS_NON_MT_OPT) + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_NON_MT_OPT) -o $@ $< + +threads: threads.ml $(OBJS_MT) + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -o $@ $< +threads.opt: threads.ml $(OBJS_MT_OPT) + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -o $@ $< + +damned_recursion: damned_recursion.ml $(OBJS_MT) + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -o $@ $< +damned_recursion.opt: damned_recursion.ml $(OBJS_MT_OPT) + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -o $@ $< + +distclean: clean +clean: + -rm -f *.cm[ioax] *.o $(EXAMPLES) $(patsubst %,%.opt,$(EXAMPLES)) diff --git a/DEVEL/ocaml-http/examples/always_ok_daemon.ml b/DEVEL/ocaml-http/examples/always_ok_daemon.ml new file mode 100644 index 000000000..caa0d4516 --- /dev/null +++ b/DEVEL/ocaml-http/examples/always_ok_daemon.ml @@ -0,0 +1,33 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_types + + (* start an http daemon that alway respond with a 200 status code and an empty + content *) +let spec = + { Http_daemon.default_spec with + callback = (fun _ outchan -> Http_daemon.respond outchan); + port = 9999; + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/basic_auth.ml b/DEVEL/ocaml-http/examples/basic_auth.ml new file mode 100644 index 000000000..bdfb2b949 --- /dev/null +++ b/DEVEL/ocaml-http/examples/basic_auth.ml @@ -0,0 +1,50 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_types + +(* the easy way: specify authentication requirements within a daemon_spec *) +let spec = + { Http_daemon.default_spec with + (* requires basic authentication, username "foo", password "bar" *) + auth = Some ("my realm", `Basic ("foo", "bar")); + callback = (fun _ outchan -> Http_daemon.respond ~body:"secret" outchan); + port = 9999; + } + +(* +(* the hard^Wother way: manual handling of authorization *) +let callback req outchan = + match req#authorization with + | Some (`Basic (username, password)) + when username = "foo" && password = "bar" -> + Http_daemon.respond ~code:(`Code 200) ~body:"secret" outchan + | _ -> raise (Unauthorized "my secret site") + +let spec = + { Http_daemon.default_spec with + callback = callback; + port = 9999; + } +*) + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/chdir.ml b/DEVEL/ocaml-http/examples/chdir.ml new file mode 100644 index 000000000..bcba1ebc3 --- /dev/null +++ b/DEVEL/ocaml-http/examples/chdir.ml @@ -0,0 +1,34 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Printf +open Http_types + +let spec = + { Http_daemon.default_spec with + callback = (fun _ outchan -> + Http_daemon.respond ~body:(sprintf "%s\n" (Sys.getcwd ())) outchan); + port = 9999; + root_dir = Some "/etc"; + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/client_address.ml b/DEVEL/ocaml-http/examples/client_address.ml new file mode 100644 index 000000000..79d4ff836 --- /dev/null +++ b/DEVEL/ocaml-http/examples/client_address.ml @@ -0,0 +1,42 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Printf +open Http_types + +let callback req outchan = + let body = + sprintf + "Hi, this is your personal assistant, you are connected from %s:%d\n" + req#clientAddr + req#clientPort + in + let res = new Http_response.response ~body () in + Http_daemon.respond_with res outchan + +let spec = + { Http_daemon.default_spec with + callback = callback; + port = 9999 + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/damned_recursion.ml b/DEVEL/ocaml-http/examples/damned_recursion.ml new file mode 100644 index 000000000..be2e30629 --- /dev/null +++ b/DEVEL/ocaml-http/examples/damned_recursion.ml @@ -0,0 +1,51 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Printf +open Http_types + +let port = 9999 + +let callback (req: Http_types.request) outchan = + let i = int_of_string (req#param "x") in + let body = + match i with + | 0 -> "0" + | x when x > 0 -> + let data = + Http_user_agent.get (sprintf "http://127.0.0.1:%d/foo?x=%d" + port (x - 1)) + in + sprintf "%s %d" data x + | _ -> assert false + in + Http_daemon.respond ~code:(`Code 200) ~body outchan; + close_out outchan (* Http_user_agent relies on EOF, not Content-Length *) + +let spec = + { Http_daemon.default_spec with + callback = callback; + port = port; + mode = `Thread; + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/dump_args.ml b/DEVEL/ocaml-http/examples/dump_args.ml new file mode 100644 index 000000000..ab082112a --- /dev/null +++ b/DEVEL/ocaml-http/examples/dump_args.ml @@ -0,0 +1,48 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Printf +open Http_types + +let callback req outchan = + let str = + (sprintf "request path = %s\n" req#path) ^ + (sprintf "request GET params = %s\n" + (String.concat ";" + (List.map (fun (h,v) -> String.concat "=" [h;v]) req#params_GET))) ^ + (sprintf "request POST params = %s\n" + (String.concat ";" + (List.map (fun (h,v) -> String.concat "=" [h;v]) req#params_POST))) ^ + (sprintf "request ALL params = %s\n" + (String.concat ";" + (List.map (fun (h,v) -> String.concat "=" [h;v]) req#params))) ^ + (sprintf "request BODY = '%s'\n\n" req#body) + in + Http_daemon.respond ~code:(`Code 200) ~body: str outchan + +let spec = + { Http_daemon.default_spec with + callback = callback; + port = 9999; + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/highlander.ml b/DEVEL/ocaml-http/examples/highlander.ml new file mode 100644 index 000000000..d42445481 --- /dev/null +++ b/DEVEL/ocaml-http/examples/highlander.ml @@ -0,0 +1,41 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +(* test for fast rebinding of the tcp port *) + +open Printf +open Http_types + +let spec = + { Http_daemon.default_spec with + callback = (fun _ outchan -> Http_daemon.respond ~body:"foo" outchan); + port = 9999; + mode = `Single; + } + +let _ = + Sys.catch_break true; + while true do + try + Http_daemon.main spec; + with Sys.Break -> prerr_endline "RESURRECTION!!!!" + done + diff --git a/DEVEL/ocaml-http/examples/oo_daemon.ml b/DEVEL/ocaml-http/examples/oo_daemon.ml new file mode 100644 index 000000000..91197e3f7 --- /dev/null +++ b/DEVEL/ocaml-http/examples/oo_daemon.ml @@ -0,0 +1,47 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_daemon +open Http_response + + (* the simple way *) +let d = new daemon ~addr:"127.0.0.1" ~port:9999 () + +let _ = + while true do + let (req, conn) = d#getRequest in (* wait for valid request *) + conn#respond_with (new response ~body:"foo\n" ()); + conn#close + done + +(* + (* the hard^Wother way *) +let d = new daemon ~addr:"127.0.0.1" ~port:9999 () in +let _ = + while true do + let conn = d#accept in (* wait for client connection *) + (match conn#getRequest with + | None -> () (* invalid request received *) + | Some req -> conn#respond_with (new response ~body:"foo\n" ())); + conn#close (* close socket *) + done +*) + diff --git a/DEVEL/ocaml-http/examples/threads.ml b/DEVEL/ocaml-http/examples/threads.ml new file mode 100644 index 000000000..01f6dae4c --- /dev/null +++ b/DEVEL/ocaml-http/examples/threads.ml @@ -0,0 +1,63 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_types + +let m = Mutex.create () +let m_locked = ref true + +let critical f = + Mutex.lock m; + m_locked := true; + Lazy.force f; + m_locked := false; + Mutex.unlock m + + (** ocaml's Thread.unlock suspend the invoking process if the mutex is already + * unlocked, therefore we unlock it only if we know that it's currently locked + *) +let safe_unlock _ _ = if !m_locked then Mutex.unlock m + +let i = ref 10 +let dump_i outchan = + Http_daemon.respond ~body:(Printf.sprintf "i = %d\n" !i) outchan + +let callback req outchan = + match req#path with + | "/incr" -> critical (lazy (incr i; dump_i outchan; Unix.sleep 5)) + | "/decr" -> critical (lazy (decr i; dump_i outchan; Unix.sleep 5)) + | "/get" -> critical (lazy (dump_i outchan)) + | bad_request -> Http_daemon.respond_error outchan + +let spec = + { Http_daemon.default_spec with + port = 9999; + mode = `Thread; + callback = callback; + exn_handler = Some safe_unlock; + (** ocaml-http's default exn_handler is Pervasives.ignore. This means + * that threads holding the "m" mutex above may die without unlocking it. + * Using safe_unlock as an exception handler we ensure that "m" mutex is + * unlocked in case of exceptions (e.g. SIGPIPE) *) + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/timeout.ml b/DEVEL/ocaml-http/examples/timeout.ml new file mode 100644 index 000000000..d39f6be7a --- /dev/null +++ b/DEVEL/ocaml-http/examples/timeout.ml @@ -0,0 +1,31 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_types + +let spec = + { Http_daemon.default_spec with + callback = (fun _ outchan -> Http_daemon.respond ~body:"foo" outchan); + timeout = Some 10; + } + +let _ = Http_daemon.main spec + diff --git a/DEVEL/ocaml-http/examples/webfsd.ml b/DEVEL/ocaml-http/examples/webfsd.ml new file mode 100644 index 000000000..c7a984b03 --- /dev/null +++ b/DEVEL/ocaml-http/examples/webfsd.ml @@ -0,0 +1,50 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2004> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +open Http_types + +let def_port = 80 +let def_addr = "0.0.0.0" +let def_root = Sys.getcwd () + +let port = ref def_port +let addr = ref def_addr +let root = ref def_root +let argspec = + [ "-p", Arg.Int (fun p -> port := p), + "TCP port on which listen, default: " ^ string_of_int !port; + "-a", Arg.String (fun a -> addr := a), + "IP address on which listen, default: " ^ !addr; + "-r", Arg.String (fun r -> root := r), + "DocumentRoot, default: current working directory"; + ] + +let _ = + Arg.parse argspec (fun _ -> ()) ""; + let spec = + { Http_daemon.default_spec with + address = !addr; + port = !port; + root_dir = Some !root + } + in + Http_daemon.Trivial.main spec + diff --git a/DEVEL/ocaml-http/http_common.ml b/DEVEL/ocaml-http/http_common.ml new file mode 100644 index 000000000..affbdb23a --- /dev/null +++ b/DEVEL/ocaml-http/http_common.ml @@ -0,0 +1,162 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Http_types;; +open Printf;; + +let debug = ref false +let debug_print s = + if !debug then + prerr_endline (sprintf "[OCaml HTTP] DEBUG: %s" s) + +let http_version = Http_constants.version +let server_string = Http_constants.server_string + +let string_of_version = function + | `HTTP_1_0 -> "HTTP/1.0" + | `HTTP_1_1 -> "HTTP/1.1" + +let version_of_string = function + | "HTTP/1.0" -> `HTTP_1_0 + | "HTTP/1.1" -> `HTTP_1_1 + | invalid_version -> raise (Invalid_HTTP_version invalid_version) + +let string_of_method = function + | `GET -> "GET" + | `POST -> "POST" + +let method_of_string = function + | "GET" -> `GET + | "POST" -> `POST + | invalid_method -> raise (Invalid_HTTP_method invalid_method) + +let status_of_code = function + | 100 -> `Informational `Continue + | 101 -> `Informational `Switching_protocols + | 200 -> `Success `OK + | 201 -> `Success `Created + | 202 -> `Success `Accepted + | 203 -> `Success `Non_authoritative_information + | 204 -> `Success `No_content + | 205 -> `Success `Reset_content + | 206 -> `Success `Partial_content + | 300 -> `Redirection `Multiple_choices + | 301 -> `Redirection `Moved_permanently + | 302 -> `Redirection `Found + | 303 -> `Redirection `See_other + | 304 -> `Redirection `Not_modified + | 305 -> `Redirection `Use_proxy + | 307 -> `Redirection `Temporary_redirect + | 400 -> `Client_error `Bad_request + | 401 -> `Client_error `Unauthorized + | 402 -> `Client_error `Payment_required + | 403 -> `Client_error `Forbidden + | 404 -> `Client_error `Not_found + | 405 -> `Client_error `Method_not_allowed + | 406 -> `Client_error `Not_acceptable + | 407 -> `Client_error `Proxy_authentication_required + | 408 -> `Client_error `Request_time_out + | 409 -> `Client_error `Conflict + | 410 -> `Client_error `Gone + | 411 -> `Client_error `Length_required + | 412 -> `Client_error `Precondition_failed + | 413 -> `Client_error `Request_entity_too_large + | 414 -> `Client_error `Request_URI_too_large + | 415 -> `Client_error `Unsupported_media_type + | 416 -> `Client_error `Requested_range_not_satisfiable + | 417 -> `Client_error `Expectation_failed + | 500 -> `Server_error `Internal_server_error + | 501 -> `Server_error `Not_implemented + | 502 -> `Server_error `Bad_gateway + | 503 -> `Server_error `Service_unavailable + | 504 -> `Server_error `Gateway_time_out + | 505 -> `Server_error `HTTP_version_not_supported + | invalid_code -> raise (Invalid_code invalid_code) + +let code_of_status = function + | `Informational `Continue -> 100 + | `Informational `Switching_protocols -> 101 + | `Success `OK -> 200 + | `Success `Created -> 201 + | `Success `Accepted -> 202 + | `Success `Non_authoritative_information -> 203 + | `Success `No_content -> 204 + | `Success `Reset_content -> 205 + | `Success `Partial_content -> 206 + | `Redirection `Multiple_choices -> 300 + | `Redirection `Moved_permanently -> 301 + | `Redirection `Found -> 302 + | `Redirection `See_other -> 303 + | `Redirection `Not_modified -> 304 + | `Redirection `Use_proxy -> 305 + | `Redirection `Temporary_redirect -> 307 + | `Client_error `Bad_request -> 400 + | `Client_error `Unauthorized -> 401 + | `Client_error `Payment_required -> 402 + | `Client_error `Forbidden -> 403 + | `Client_error `Not_found -> 404 + | `Client_error `Method_not_allowed -> 405 + | `Client_error `Not_acceptable -> 406 + | `Client_error `Proxy_authentication_required -> 407 + | `Client_error `Request_time_out -> 408 + | `Client_error `Conflict -> 409 + | `Client_error `Gone -> 410 + | `Client_error `Length_required -> 411 + | `Client_error `Precondition_failed -> 412 + | `Client_error `Request_entity_too_large -> 413 + | `Client_error `Request_URI_too_large -> 414 + | `Client_error `Unsupported_media_type -> 415 + | `Client_error `Requested_range_not_satisfiable -> 416 + | `Client_error `Expectation_failed -> 417 + | `Server_error `Internal_server_error -> 500 + | `Server_error `Not_implemented -> 501 + | `Server_error `Bad_gateway -> 502 + | `Server_error `Service_unavailable -> 503 + | `Server_error `Gateway_time_out -> 504 + | `Server_error `HTTP_version_not_supported -> 505 + +let is_informational code = + match status_of_code code with + | `Informational _ -> true + | _ -> false + +let is_success code = + match status_of_code code with + | `Success _ -> true + | _ -> false + +let is_redirection code = + match status_of_code code with + | `Redirection _ -> true + | _ -> false + +let is_client_error code = + match status_of_code code with + | `Client_error _ -> true + | _ -> false + +let is_server_error code = + match status_of_code code with + | `Server_error _ -> true + | _ -> false + +let is_error code = is_client_error code || is_server_error code + diff --git a/DEVEL/ocaml-http/http_common.mli b/DEVEL/ocaml-http/http_common.mli new file mode 100644 index 000000000..6029a7031 --- /dev/null +++ b/DEVEL/ocaml-http/http_common.mli @@ -0,0 +1,80 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Common functionalities shared by other OCaml HTTP modules *) + +open Http_types;; + + (** whether debugging messages are enabled or not, can be changed at runtime + *) +val debug: bool ref + + (** print a string on stderr only if debugging is enabled *) +val debug_print: string -> unit + + (** see {!Http_constants.version} *) +val http_version: version + + (** see {!Http_constants.server_string} *) +val server_string: string + + (** pretty print an HTTP version *) +val string_of_version: version -> string + + (** parse an HTTP version from a string + @raise Invalid_HTTP_version if given string doesn't represent a supported HTTP + version *) +val version_of_string: string -> version + + (** pretty print an HTTP method *) +val string_of_method: meth -> string + + (** parse an HTTP method from a string + @raise Invalid_HTTP_method if given string doesn't represent a supported + method *) +val method_of_string: string -> meth + + (** converts an integer HTTP status to the corresponding status value + @raise Invalid_code if given integer isn't a valid HTTP status code *) +val status_of_code: int -> status + + (** converts an HTTP status to the corresponding integer value *) +val code_of_status: [< status] -> int + + (** @return true on "informational" status codes, false elsewhere *) +val is_informational: int -> bool + + (** @return true on "success" status codes, false elsewhere *) +val is_success: int -> bool + + (** @return true on "redirection" status codes, false elsewhere *) +val is_redirection: int -> bool + + (** @return true on "client error" status codes, false elsewhere *) +val is_client_error: int -> bool + + (** @return true on "server error" status codes, false elsewhere *) +val is_server_error: int -> bool + + (** @return true on "client error" and "server error" status code, false + elsewhere *) +val is_error: int -> bool + diff --git a/DEVEL/ocaml-http/http_constants.ml b/DEVEL/ocaml-http/http_constants.ml new file mode 100644 index 000000000..fa9f49536 --- /dev/null +++ b/DEVEL/ocaml-http/http_constants.ml @@ -0,0 +1,34 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +let version = `HTTP_1_1 ;; +let server_string = "OCaml HTTP Daemon" ;; +let crlf = "\r\n" ;; + +let default_addr = "0.0.0.0" +let default_auth = None +let default_callback = fun _ _ -> () +let default_mode = `Fork +let default_port = 80 +let default_root_dir = None +let default_exn_handler = Some (fun exn outchan -> ()) +let default_timeout = Some 300 + diff --git a/DEVEL/ocaml-http/http_constants.mli b/DEVEL/ocaml-http/http_constants.mli new file mode 100644 index 000000000..46db79067 --- /dev/null +++ b/DEVEL/ocaml-http/http_constants.mli @@ -0,0 +1,43 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Constants *) + + (** default HTTP version *) +val version: Http_types.version + + (** string returned as value of "Server:" response header *) +val server_string: string + + (** "\r\n" string *) +val crlf: string + + (** {2 daemon default values} *) + +val default_addr: string +val default_auth: (string * Http_types.auth_info) option +val default_callback: Http_types.request -> out_channel -> unit +val default_mode: Http_types.daemon_mode +val default_port: int +val default_root_dir: string option +val default_exn_handler: (exn -> out_channel -> unit) option +val default_timeout: int option + diff --git a/DEVEL/ocaml-http/http_daemon.ml b/DEVEL/ocaml-http/http_daemon.ml new file mode 100644 index 000000000..629d1286c --- /dev/null +++ b/DEVEL/ocaml-http/http_daemon.ml @@ -0,0 +1,501 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf + +open Http_common +open Http_types +open Http_constants +open Http_parser + +exception Http_daemon_failure of string + + (** send raw data on outchan, flushing it afterwards *) +let send_raw ~data outchan = + output_string outchan data; + flush outchan + +let send_CRLF = send_raw ~data:crlf + +let send_header ~header ~value = + Http_parser_sanity.heal_header (header, value); + send_raw ~data:(header ^ ": " ^ value ^ crlf) + +let send_headers ~headers outchan = + List.iter (fun (header, value) -> send_header ~header ~value outchan) headers + + (** internal: low level for send_status_line *) +let send_status_line' ~version code = + let status_line = + String.concat + " " + [ string_of_version version; + string_of_int code; + Http_misc.reason_phrase_of_code code ] + in + send_raw ~data:(status_line ^ crlf) + +let int_of_code = function + | `Code code -> code + | `Status status -> code_of_status status + +let send_status_line ?(version = http_version) ~(code: status_code) outchan = + send_status_line' ~version (int_of_code code) outchan + + (* FIXME duplication of code between this and response#addBasicHeaders *) +let send_basic_headers ?(version = http_version) ~(code: status_code) outchan = + send_status_line' ~version (int_of_code code) outchan; + send_headers + ~headers:["Date", Http_misc.date_822 (); "Server", server_string] + outchan + + (** internal: given a status code and an additional body return a string + representing an HTML document that explains the meaning of given status code. + Additional data can be added to the body via 'body' argument *) +let foo_body code body = + let reason_phrase = Http_misc.reason_phrase_of_code code in + sprintf +" + +%d %s + +

%d - %s

%s +" + code reason_phrase code reason_phrase body + + (** internal: send a fooish body explaining in HTML form the 'reason phrase' + of an HTTP response; body, if given, will be appended to the body *) +let send_foo_body code body = send_raw ~data:(foo_body code body) + + (* Warning: keep default values in sync with Http_response.response class *) +let respond ?(body = "") ?(headers = []) ?version ?(code = `Code 200) outchan = + send_basic_headers ?version ~code outchan; + send_headers ~headers outchan; + send_header "Content-Length" (string_of_int (String.length body)) outchan; + send_CRLF outchan; + send_raw ~data:body outchan + + (** internal: low level for respond_redirect, respond_error, ... + This function send a status line corresponding to a given code, some basic + headers, the additional headers (if given) and an HTML page containing the + reason phrase; if body is given it will be included in the body of the HTML + page *) +let send_empty_response + func_name ?(is_valid_status = fun _ -> true) ?(headers=[]) ?(body="") () = + fun ?version code outchan -> + if not (is_valid_status (int_of_code code)) then + failwith + (sprintf "'%d' isn't a valid status code for %s" + (int_of_code code) func_name) + else begin (* status code suitable for answering *) + let headers = + [ "Content-Type", "text/html; charset=iso-8859-1" ] @ headers + in + let body = (foo_body (int_of_code code) body) ^ body in + respond ?version ~code ~headers ~body outchan + end + +let respond_redirect + ~location ?body ?version ?(code = `Code 301) outchan + = + send_empty_response "Daemon.respond_redirect" ~is_valid_status:is_redirection + ~headers:["Location", location] ?body () ?version code outchan + +let respond_error ?body ?version ?(code = `Code 400) outchan = + send_empty_response "Daemon.respond_error" ~is_valid_status:is_error + ?body () ?version code outchan + +let respond_not_found ~url ?version outchan = + send_empty_response "Daemon.respond_not_found" () ?version (`Code 404) outchan + +let respond_forbidden ~url ?version outchan = + send_empty_response "Daemon.respond_permission_denied" () ?version + (`Code 403) outchan + +let respond_unauthorized ?version ?(realm = server_string) outchan = + let body = + sprintf "401 - Unauthorized - Authentication failed for realm \"%s\"" realm + in + respond ~headers:["WWW-Authenticate", sprintf "Basic realm=\"%s\"" realm] + ~code:(`Code 401) ~body outchan + +let send_file ~src outchan = + let buflen = 1024 in + let buf = String.make buflen ' ' in + + let (file, cleanup) = + match src with + | FileSrc fname -> (* if we open the file, we close it before returning *) + let f = open_in fname in + f, (fun () -> close_in f) + | InChanSrc inchan -> inchan, ignore + in + try + while true do + let bytes = input file buf 0 buflen in + if bytes = 0 then + raise End_of_file + else + output outchan buf 0 bytes + done; + assert false + with End_of_file -> + begin + flush outchan; + cleanup () + end + + (* TODO interface is too ugly to advertise this function in .mli *) + (** create a minimal HTML directory listing of a given directory and send it + over an out_channel, directory is passed as a dir_handle; name is the + directory name, used for pretty printing purposes; path is the opened dir + path, used to test its contents with stat *) +let send_dir_listing ~dir ~name ~path outchan = + fprintf outchan "\n%s\n\n" name; + let (dirs, files) = + List.partition (fun e -> Http_misc.is_directory (path ^ e)) (Http_misc.ls dir) + in + List.iter + (fun d -> fprintf outchan "%s/
\n" d d) + (List.sort compare dirs); + List.iter + (fun f -> fprintf outchan "%s
\n" f f) + (List.sort compare files); + fprintf outchan "\n"; + flush outchan + +let respond_file ~fname ?(version = http_version) outchan = + (** ASSUMPTION: 'fname' doesn't begin with a "/"; it's relative to the current + document root (usually the daemon's cwd) *) + let droot = Sys.getcwd () in (* document root *) + let path = droot ^ "/" ^ fname in (* full path to the desired file *) + if not (Sys.file_exists path) then (* file not found *) + respond_not_found ~url:fname outchan + else begin + try + if Http_misc.is_directory path then begin (* file found, is a dir *) + let dir = Unix.opendir path in + send_basic_headers ~version ~code:(`Code 200) outchan; + send_header "Content-Type" "text/html" outchan; + send_CRLF outchan; + send_dir_listing ~dir ~name:fname ~path outchan; + Unix.closedir dir + end else begin (* file found, is something else *) + let file = open_in fname in + send_basic_headers ~version ~code:(`Code 200) outchan; + send_header + ~header:"Content-Length" + ~value:(string_of_int (Http_misc.filesize fname)) + outchan; + send_CRLF outchan; + send_file ~src:(InChanSrc file) outchan; + close_in file + end + with + | Unix.Unix_error (Unix.EACCES, _, _) + | Sys_error _ -> + respond_forbidden ~url:fname ~version outchan + end + +let respond_with (res: Http_types.response) outchan = + res#serialize outchan; + flush outchan + + (** internal: this exception is raised after a malformed request has been read + by a serving process to signal main server (or itself if mode = `Single) to + skip to next request *) +exception Again;; + +let pp_parse_exc e = + sprintf "HTTP request parse error: %s" (Printexc.to_string e) + + (* given a Http_parser.parse_request like function, wrap it in a function that + do the same and additionally catch parsing exception sending HTTP error + messages back to client as needed. Returned function raises Again when it + encounter a parse error (name 'Again' is intended for future versions that + will support http keep alive signaling that a new request has to be parsed + from client) *) +let rec wrap_parse_request_w_safety parse_function inchan outchan = + (try + parse_function inchan + with + | (Malformed_request req) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 400) + ~body:("request 1st line format should be: " ^ + "'<method> <url> <version>'" ^ + "
\nwhile received request 1st line was:
\n" ^ req) + outchan; + raise Again + | (Invalid_HTTP_method meth) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 501) + ~body:("Method '" ^ meth ^ "' isn't supported (yet)") + outchan; + raise Again + | (Malformed_request_URI uri) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 400) ~body:("Malformed URL: '" ^ uri ^ "'") + outchan; + raise Again + | (Invalid_HTTP_version version) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 505) + ~body:("HTTP version '" ^ version ^ "' isn't supported (yet)") + outchan; + raise Again + | (Malformed_query query) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 400) + ~body:(sprintf "Malformed query string '%s'" query) outchan; + raise Again + | (Malformed_query_part (binding, query)) as e -> + debug_print (pp_parse_exc e); + respond_error ~code:(`Code 400) + ~body:(sprintf "Malformed query part '%s' in query '%s'" binding query) + outchan; + raise Again) + + (* wrapper around Http_parser.parse_request which catch parsing exceptions and + return error messages to client as needed + @param inchan in_channel from which read incoming requests + @param outchan out_channl on which respond with error messages if needed + *) +let safe_parse_request = wrap_parse_request_w_safety parse_request + + (* as above but for OO version (Http_parser.parse_request') *) +let safe_parse_request' = wrap_parse_request_w_safety (new Http_request.request) + +let chdir_to_document_root = function (* chdir to document root *) + | Some dir -> Sys.chdir dir + | None -> () + +let server_of_mode = function + | `Single -> Http_tcp_server.simple + | `Fork -> Http_tcp_server.fork + | `Thread -> Http_tcp_server.thread + + (* TODO what happens when a Quit exception is raised by a callback? Do other + callbacks keep on living until the end or are them all killed immediatly? + The right semantics should obviously be the first one *) + +let handle_manual_auth outchan f = + try + f () + with + | Unauthorized realm -> respond_unauthorized ~realm outchan + | Again -> () + +let handle_auth req spec outchan = + try + (match (spec.auth, req#authorization) with + | None, _ -> spec.callback req outchan (* no auth required *) + | Some (realm, `Basic (spec_username, spec_password)), + Some (`Basic (username, password)) + when (username = spec_username) && (password = spec_password) -> + (* auth ok *) + spec.callback req outchan + | Some (realm, _), _ -> raise (Unauthorized realm)) (* auth failure *) + with + | Unauthorized realm -> respond_unauthorized ~realm outchan + | Again -> () + + (* TODO support also chroot to 'root', not only chdir *) + (* TODO deprecated: remove from future versions *) + (* curried request *) +let start + ?(addr = default_addr) ?(port = default_port) + ?(timeout = default_timeout) ?(mode = default_mode) ?root callback + = + Http_misc.warn + "Http_daemon.start is deprecated in favour of Http_daemon.main and will be removed in future versions of the library"; + chdir_to_document_root root; + let sockaddr = Http_misc.build_sockaddr (addr, port) in + let daemon_callback inchan outchan = + handle_manual_auth outchan (fun () -> + let (path, parameters) = safe_parse_request inchan outchan in + callback path parameters outchan; + flush outchan); + in + try + (server_of_mode mode) ~sockaddr ~timeout daemon_callback + with Quit -> () + + (* OO request *) + (* TODO deprecated: remove from future versions *) +let start' + ?(addr = default_addr) ?(port = default_port) + ?(timeout = default_timeout) ?(mode = default_mode) ?root callback += + Http_misc.warn + "Http_daemon.start' is deprecated in favour of Http_daemon.main and will be removed in future versions of the library"; + chdir_to_document_root root; + let sockaddr = Http_misc.build_sockaddr (addr, port) in + let daemon_callback inchan outchan = + handle_manual_auth outchan (fun () -> + let req = safe_parse_request' inchan outchan in + callback req outchan; + flush outchan) + in + try + (server_of_mode mode) ~sockaddr ~timeout daemon_callback + with Quit -> () + +let main spec = + chdir_to_document_root spec.root_dir; + let sockaddr = Http_misc.build_sockaddr (spec.address, spec.port) in + let daemon_callback inchan outchan = + let next_req () = + try Some (safe_parse_request' inchan outchan) + with _ -> None + in + let rec loop n = + match next_req () with + | Some req -> + debug_print (sprintf "request #%d" n); + handle_auth req spec outchan; + flush outchan; + loop (n + 1) + | None -> + debug_print "server exiting"; + () + in + debug_print "server starting"; + try loop 1 + with exn -> + debug_print (sprintf "uncaught exception: %s" (Printexc.to_string exn)); + (match spec.exn_handler with + | Some f -> + debug_print "executing handler"; + f exn outchan + | None -> + debug_print "no handler given: re-raising"; + raise exn) + in + try + (server_of_mode spec.mode) ~sockaddr ~timeout:spec.timeout daemon_callback + with Quit -> () + +module Trivial = + struct + let heading_slash_RE = Pcre.regexp "^/" + + let trivial_callback req outchan = + let path = req#path in + if not (Pcre.pmatch ~rex:heading_slash_RE path) then + respond_error ~code:(`Code 400) outchan + else + respond_file ~fname:(Http_misc.strip_heading_slash path) outchan + + let callback = trivial_callback + + let main spec = main { spec with callback = trivial_callback } + end + + (** @param inchan input channel connected to client + @param outchan output channel connected to client + @param sockaddr client socket address *) +class connection inchan outchan sockaddr = + (* ASSUMPTION: inchan and outchan are channels built on top of the same + Unix.file_descr thus closing one of them will close also the other *) + let close' o = try o#close with Http_daemon_failure _ -> () in + object (self) + + initializer Gc.finalise close' self + + val mutable closed = false + + method private assertNotClosed = + if closed then + raise (Http_daemon_failure + "Http_daemon.connection: connection is closed") + + method getRequest = + self#assertNotClosed; + try + Some (safe_parse_request' inchan outchan) + with _ -> None + + method respond_with res = + self#assertNotClosed; + respond_with res outchan + + method close = + self#assertNotClosed; + close_in inchan; (* this close also outchan *) + closed <- true + + end + +class daemon ?(addr = "0.0.0.0") ?(port = 80) () = + object (self) + + val suck = + Http_tcp_server.init_socket (Http_misc.build_sockaddr (addr, port)) + + method accept = + let (cli_suck, cli_sockaddr) = Unix.accept suck in (* may block *) + let (inchan, outchan) = + (Unix.in_channel_of_descr cli_suck, Unix.out_channel_of_descr cli_suck) + in + new connection inchan outchan cli_sockaddr + + method getRequest = + let conn = self#accept in + match conn#getRequest with + | None -> + conn#close; + self#getRequest + | Some req -> (req, conn) + + end + +open Http_constants + +let default_spec = { + address = default_addr; + auth = default_auth; + callback = default_callback; + mode = default_mode; + port = default_port; + root_dir = default_root_dir; + exn_handler = default_exn_handler; + timeout = default_timeout; +} + +let daemon_spec + ?(address = default_addr) ?(auth = default_auth) + ?(callback = default_callback) ?(mode = default_mode) ?(port = default_port) + ?(root_dir = default_root_dir) ?(exn_handler = default_exn_handler) + ?(timeout = default_timeout) + () += + { default_spec with + address = address; + auth = auth; + callback = callback; + mode = mode; + port = port; + root_dir = root_dir; + exn_handler = exn_handler; + timeout = timeout; + } + diff --git a/DEVEL/ocaml-http/http_daemon.mli b/DEVEL/ocaml-http/http_daemon.mli new file mode 100644 index 000000000..59a408d87 --- /dev/null +++ b/DEVEL/ocaml-http/http_daemon.mli @@ -0,0 +1,205 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Main OCaml HTTP module. + Here you can find two set of functions: + - functions which let you start an HTTP Daemon (start* functions) + - facility functions which let you sent responses back to clients *) + + (** send a CRLF sequence on the given output channel, this is mandatory after + the last header was sent and before start sending the response body *) +val send_CRLF: out_channel -> unit + + (** send response status line, version is the http version used in response, + either code or status must be given (not both, not none) which represent the + HTTP response code, outchan is the output channel to which send status line *) +val send_status_line: + ?version:Http_types.version -> code:Http_types.status_code -> + out_channel -> + unit + + (** like send_status_line but additionally will also send "Date" and "Server" + standard headers *) +val send_basic_headers: + ?version: Http_types.version -> code:Http_types.status_code -> + out_channel -> + unit + + (** send an HTTP header on outchan *) +val send_header: header: string -> value: string -> out_channel -> unit + + (** as send_header, but for a list of pairs *) +val send_headers: headers:(string * string) list -> out_channel -> unit + +(* + (** send a file through an out_channel, file can be passed as an in_channel + (if 'file' is given) or as a file name (if 'name' is given) *) +val send_file: ?name:string -> ?file:in_channel -> out_channel -> unit +*) + (** send a file through an out_channel *) +val send_file: src:Http_types.file_source -> out_channel -> unit + + (** high level response function, respond on outchan sending: basic headers + (including Content-Length computed using 'body' argument), headers probided + via 'headers' argument, body given via 'body' argument. Default response + status is 200, default response HTTP version is Http_common.http_version *) +val respond: + ?body:string -> ?headers:(string * string) list -> + ?version:Http_types.version -> ?code:Http_types.status_code -> + out_channel -> + unit + + (** send a 404 (not found) HTTP response *) +val respond_not_found: + url:string -> ?version: Http_types.version -> out_channel -> unit + + (** send a 403 (forbidden) HTTP response *) +val respond_forbidden: + url:string -> ?version: Http_types.version -> out_channel -> unit + + (** send a "redirection" class response, optional body argument contains data + that will be displayed in the body of the response, default response status is + 301 (moved permanently), only redirection status are accepted by this + function, other values will raise Failure *) +val respond_redirect: + location:string -> ?body:string -> + ?version: Http_types.version -> ?code:Http_types.status_code -> + out_channel -> + unit + + (** respond with a 401 (Unauthorized) response asking for authentication + * against given realm (default is the server name) *) +val respond_unauthorized: + ?version: Http_types.version -> ?realm:string -> out_channel -> unit + + (** send an "error" response (i.e. 400 <= status < 600), optional body + argument as per send_redirect, default response status is 400 (bad request), + only error status are accepted by this function, other values will + raise Failure *) +val respond_error: + ?body:string -> + ?version: Http_types.version -> ?code:Http_types.status_code -> + out_channel -> + unit + + (** tipical static pages http daemon behaviour, if requested url is a file, + return it, it it is a directory return a directory listing of it *) +val respond_file: + fname:string -> ?version: Http_types.version -> out_channel -> unit + + (** respond using a prebuilt Http_types.response object *) +val respond_with: Http_types.response -> out_channel -> unit + + (** start an HTTP daemon + * @param spec specification of daemon behaviour + *) +val main: Http_types.daemon_spec -> unit + + (** default daemon specification: + * - listen on 0.0.0.0, port 80 + * - "always ok" callback (return an empty response, response code 200) + * - fork a child for each request + * - do not change to a root directory (i.e. keep cwd) + * - 300 seconds timeout + * - ignores exceptions + * - no authentication required *) +val default_spec: Http_types.daemon_spec + + (** currified daemon_spec constructor. Each parameter of this function + * corresponds to one field of Http_types.daemon_spec and defaults to the + * corresponding field of Http_daemon.default_spec *) +val daemon_spec: + ?address:string -> + ?auth:(string * Http_types.auth_info) option -> + ?callback:(Http_types.request -> out_channel -> unit) -> + ?mode:(Http_types.daemon_mode) -> + ?port:int -> + ?root_dir:string option -> + ?exn_handler:(exn -> out_channel -> unit) option -> + ?timeout:int option -> + unit -> + Http_types.daemon_spec + + (** starts an HTTP daemon (deprecated function) + * + * @deprecated This function will be removed in future versions, please switch + * to Http_daemon.main below. + * + * see {!Http_types.daemon_spec} for a detailed description of parameters + * + * @param addr like the "address" field of Http_types.daemon_spec, defaults to + * the wildcard address "0.0.0.0" + * @param port like the "port" field of Http_types.daemon_spec, defaults to 80 + * @param timeout like the "timeout" field of Http_types.daemon_spec, defaults + * to Some 300 + * @param mode like the "mode" field of Http_types.daemon_spec, defaults to + * `Fork + * @param root like the "root_dir" field of Http_types.daemon_spec, defaults to + * None + * @param callback functional version of the "callback" field of + * Http_types.daemon_spec. 1st argument is the request path, 2nd argument + * the decoded query string, 3rd argument an output channel connect to the + * client + *) +val start: + ?addr: string -> ?port: int -> + ?timeout: int option -> ?mode: Http_types.daemon_mode -> ?root: string -> + (string -> (string * string) list -> out_channel -> unit) -> + unit + + (** starts an HTTP daemon (deprecated function) + * + * @deprecated This function will be removed in future versions, please switch + * to Http_daemon.main below. + * + * parameters as per {!Http_daemon.start} except for the callback, in this case + * it behaves as the "callback" field of Http_types.daemon_spec + *) +val start': + ?addr: string -> ?port: int -> + ?timeout: int option -> ?mode: Http_types.daemon_mode -> ?root: string -> + (Http_types.request -> out_channel -> unit) -> + unit + + (** Object oriented interface to HTTP daemons. + * @param addr address on which daemon will listen for connections + * @param port port which daemon will bind + * see {!Http_types.daemon} *) +class daemon: + ?addr: string -> ?port: int -> + unit -> + Http_types.daemon + + (** Trivial static pages HTTP daemon. + * Daemons created using this module will serve directory indexes and files + * found starting from the working directory *) +module Trivial : + sig + (** callback function, exposed if you like to use it as a basis to define + a more powerful daemon *) + val callback : Http_types.request -> out_channel -> unit + + (** start the "trivial" HTTP daemon + * @param spec trivial HTTP daemon specification, "callback" field is + * ignored and set to the callback above *) + val main : Http_types.daemon_spec -> unit + end + diff --git a/DEVEL/ocaml-http/http_message.ml b/DEVEL/ocaml-http/http_message.ml new file mode 100644 index 000000000..5dc0f0472 --- /dev/null +++ b/DEVEL/ocaml-http/http_message.ml @@ -0,0 +1,118 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Http_common;; +open Http_constants;; +open Http_types;; +open Printf;; + + (* remove all bindings of 'name' from hashtbl 'tbl' *) +let rec hashtbl_remove_all tbl name = + if not (Hashtbl.mem tbl name) then + raise (Header_not_found name); + Hashtbl.remove tbl name; + if Hashtbl.mem tbl name then hashtbl_remove_all tbl name +;; + +class virtual message ~body ~headers ~version ~clisockaddr ~srvsockaddr = + + let ((cliaddr, cliport), (srvaddr, srvport)) = + (Http_misc.explode_sockaddr clisockaddr, + Http_misc.explode_sockaddr srvsockaddr) + in + + object (self) + + val _contentsBuf = Buffer.create 1024 + val _headers = Hashtbl.create 11 + val mutable _version: version option = version + + initializer + self#setBody body; + self#addHeaders headers + + method version = _version + method setVersion v = _version <- Some v + + method body = Buffer.contents _contentsBuf + method setBody c = + Buffer.clear _contentsBuf; + Buffer.add_string _contentsBuf c + method bodyBuf = _contentsBuf + method setBodyBuf b = + Buffer.clear _contentsBuf; + Buffer.add_buffer _contentsBuf b + method addBody s = Buffer.add_string _contentsBuf s + method addBodyBuf b = Buffer.add_buffer _contentsBuf b + + method addHeader ~name ~value = + let name = String.lowercase name in + Http_parser_sanity.heal_header (name, value); + Hashtbl.add _headers name value + method addHeaders = + List.iter (fun (name, value) -> self#addHeader ~name ~value) + method replaceHeader ~name ~value = + let name = String.lowercase name in + Http_parser_sanity.heal_header (name, value); + Hashtbl.replace _headers name value + method replaceHeaders = + List.iter (fun (name, value) -> self#replaceHeader ~name ~value) + method removeHeader ~name = + let name = String.lowercase name in + hashtbl_remove_all _headers name + method hasHeader ~name = + let name = String.lowercase name in + Hashtbl.mem _headers name + method header ~name = + if not (self#hasHeader name) then raise (Header_not_found name); + let name = String.lowercase name in + String.concat ", " (List.rev (Hashtbl.find_all _headers name)) + method headers = + List.rev + (Hashtbl.fold + (fun name _ headers -> (name, self#header ~name)::headers) + _headers + []) + + method clientSockaddr = clisockaddr + method clientAddr = cliaddr + method clientPort = cliport + + method serverSockaddr = srvsockaddr + method serverAddr = srvaddr + method serverPort = srvport + + method private virtual fstLineToString: string + method toString = + self#fstLineToString ^ (* {request,status} line *) + crlf ^ + (String.concat (* headers, crlf terminated *) + "" + (List.map (fun (h,v) -> h ^ ": " ^ v ^ crlf) self#headers)) ^ + (sprintf "Content-Length: %d" (String.length self#body)) ^ crlf ^ + crlf ^ + self#body (* body *) + method serialize outchan = + output_string outchan self#toString; + flush outchan + + end + diff --git a/DEVEL/ocaml-http/http_message.mli b/DEVEL/ocaml-http/http_message.mli new file mode 100644 index 000000000..0a30b3eec --- /dev/null +++ b/DEVEL/ocaml-http/http_message.mli @@ -0,0 +1,130 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Object Oriented representation of HTTP messages *) + +open Http_types;; + + (** OO representation of an HTTP message + @param entity body included in the message + @param headers message headers shipped with the message *) +class virtual message: + body: string -> headers: (string * string) list -> version: version option -> + clisockaddr: Unix.sockaddr -> srvsockaddr: Unix.sockaddr -> + object + + (** @return message HTTP version, it can be None because older version + of the HTTP protocol don't require HTTP version to be told between + message source and destination *) + method version: version option + + (** set message HTTP version *) + method setVersion: version -> unit + + (** @return message body *) + method body: string + + (** set message body *) + method setBody: string -> unit + + (** @return a Buffer.t connected to message body (Warning: changing this + buffer will change message body too) *) + method bodyBuf: Buffer.t + + (** set a new Buffer.t used to keep message body *) + method setBodyBuf: Buffer.t -> unit + + (** append a string to message body *) + method addBody: string -> unit + + (** append a whole buffer to message body *) + method addBodyBuf: Buffer.t -> unit + + (** {i header name comparison are performed in a case-insensitive manner + as required by RFC2616, actually the implementation works converting all + header names in lowercase} *) + + (** add an HTTP header + @param name header's name + @param value header's value *) + method addHeader: name:string -> value:string -> unit + + (** add a list of HTTP headers + @param headers a list of pairs: header_name, header_value *) + method addHeaders: (string * string) list -> unit + + (** like addHeader but replace previous definition of the same header *) + method replaceHeader: name:string -> value:string -> unit + + (** like addHeaders but replace previous definition of headers that were + already defined *) + method replaceHeaders: (string * string) list -> unit + + (** remove _all_ occurences of an HTTP header from the message + @param name name of the header to be removed *) + method removeHeader: name:string -> unit + + (** @return true if given header exists in message, false otherwise *) + method hasHeader: name:string -> bool + + (** @return value associated to a given header + @param name name of the header to lookup + @raise Header_not_found if given header wasn't defined in message *) + method header: name:string -> string + + (** @return the full set of headers defined for this message, the value + returned is an association list from headers name to headers value, an + header may occurs more that once in the list *) + method headers: (string * string) list + + + (** @return client Unix.sockaddr *) + method clientSockaddr: Unix.sockaddr + + (** @return client address pretty printed *) + method clientAddr: string + + (** @return client port *) + method clientPort: int + + (** @return server Unix.sockaddr *) + method serverSockaddr: Unix.sockaddr + + (** @return server address pretty printed *) + method serverAddr: string + + (** @return server port *) + method serverPort: int + + + (** @return for requests first request line, for responses first + response line. + User by derived requests and responses to implement toString method *) + method private virtual fstLineToString: string + + (** @return a string representation of the message *) + method toString: string + + (** serialize the message over an output channel *) + method serialize: out_channel -> unit + + end + diff --git a/DEVEL/ocaml-http/http_misc.ml b/DEVEL/ocaml-http/http_misc.ml new file mode 100644 index 000000000..abe6702c2 --- /dev/null +++ b/DEVEL/ocaml-http/http_misc.ml @@ -0,0 +1,146 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf + +open Http_types + +let date_822 () = + Netdate.mk_mail_date ~zone:Netdate.localzone (Unix.time ()) + +let is_directory name = + match Unix.lstat name with + | { Unix.st_kind = Unix.S_DIR } -> true + | _ -> false + +let filesize fname = (Unix.stat fname).Unix.st_size + +let strip_trailing_slash = + let rex = Pcre.regexp "/$" in + fun s -> Pcre.replace ~rex ~templ:"" s + +let strip_heading_slash = + let rex = Pcre.regexp "^/" in + fun s -> Pcre.replace ~rex ~templ:"" s + +let ls dir = + let rec ls' entries = + try ls' ((Unix.readdir dir)::entries) with End_of_file -> entries + in + ls' [] + +let string_explode s = + let rec string_explode' acc = function + | "" -> acc + | s -> string_explode' (s.[0] :: acc) (String.sub s 1 (String.length s - 1)) + in + List.rev (string_explode' [] s) + +let string_implode = List.fold_left (fun s c -> s ^ (String.make 1 c)) "" + +let reason_phrase_of_code = function + | 100 -> "Continue" + | 101 -> "Switching protocols" + | 200 -> "OK" + | 201 -> "Created" + | 202 -> "Accepted" + | 203 -> "Non authoritative information" + | 204 -> "No content" + | 205 -> "Reset content" + | 206 -> "Partial content" + | 300 -> "Multiple choices" + | 301 -> "Moved permanently" + | 302 -> "Found" + | 303 -> "See other" + | 304 -> "Not modified" + | 305 -> "Use proxy" + | 307 -> "Temporary redirect" + | 400 -> "Bad request" + | 401 -> "Unauthorized" + | 402 -> "Payment required" + | 403 -> "Forbidden" + | 404 -> "Not found" + | 405 -> "Method not allowed" + | 406 -> "Not acceptable" + | 407 -> "Proxy authentication required" + | 408 -> "Request time out" + | 409 -> "Conflict" + | 410 -> "Gone" + | 411 -> "Length required" + | 412 -> "Precondition failed" + | 413 -> "Request entity too large" + | 414 -> "Request URI too large" + | 415 -> "Unsupported media type" + | 416 -> "Requested range not satisfiable" + | 417 -> "Expectation failed" + | 500 -> "Internal server error" + | 501 -> "Not implemented" + | 502 -> "Bad gateway" + | 503 -> "Service unavailable" + | 504 -> "Gateway time out" + | 505 -> "HTTP version not supported" + | invalid_code -> raise (Invalid_code invalid_code) + +let build_sockaddr (addr, port) = + try + Unix.ADDR_INET ((Unix.gethostbyname addr).Unix.h_addr_list.(0), port) + with Not_found -> failwith ("OCaml-HTTP, can't resolve hostname: " ^ addr) + +let explode_sockaddr = function + | Unix.ADDR_INET (addr, port) -> (Unix.string_of_inet_addr addr, port) + | _ -> assert false (* can explode only inet address *) + +let peername_of_out_channel outchan = + Unix.getpeername (Unix.descr_of_out_channel outchan) +let peername_of_in_channel inchan = + Unix.getpeername (Unix.descr_of_in_channel inchan) +let sockname_of_out_channel outchan = + Unix.getsockname (Unix.descr_of_out_channel outchan) +let sockname_of_in_channel inchan = + Unix.getsockname (Unix.descr_of_in_channel inchan) + +let buf_of_inchan ?limit ic = + let buf = Buffer.create 10240 in + let tmp = String.make 1024 '\000' in + let rec buf_of_inchan' limit = + (match limit with + | None -> + let bytes = input ic tmp 0 1024 in + if bytes > 0 then begin + Buffer.add_substring buf tmp 0 bytes; + buf_of_inchan' None + end + | Some lim -> (* TODO what about using a single really_input call? *) + let bytes = input ic tmp 0 (min lim 1024) in + if bytes > 0 then begin + Buffer.add_substring buf tmp 0 bytes; + buf_of_inchan' (Some (lim - bytes)) + end) + in + (try buf_of_inchan' limit with End_of_file -> ()); + buf + +let list_assoc_all key pairs = + snd (List.split (List.filter (fun (k, v) -> k = key) pairs)) + +let warn msg = prerr_endline (sprintf "ocaml-http WARNING: %s" msg) +let error msg = prerr_endline (sprintf "ocaml-http ERROR: %s" msg) + diff --git a/DEVEL/ocaml-http/http_misc.mli b/DEVEL/ocaml-http/http_misc.mli new file mode 100644 index 000000000..b6e28e2bc --- /dev/null +++ b/DEVEL/ocaml-http/http_misc.mli @@ -0,0 +1,88 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Helpers and other not better classified functions which should not be +exposed in the final API *) + + (** @return the current date compliant to RFC 1123, which updates RFC 822 + zone info are retrieved from UTC *) +val date_822: unit -> string + + (** @return true if 'name' is a directory on the file system, false otherwise + *) +val is_directory: string -> bool + + (** @return the filesize of fname *) +val filesize: string -> int + + (** strip trailing '/', if any, from a string and @return the new string *) +val strip_trailing_slash: string -> string + + (** strip heading '/', if any, from a string and @return the new string *) +val strip_heading_slash: string -> string + + (** given a dir handle @return a list of entries contained *) +val ls: Unix.dir_handle -> string list + + (** explode a string in a char list *) +val string_explode: string -> char list + + (** implode a char list in a string *) +val string_implode: char list -> string + + (** given an HTTP response code return the corresponding reason phrase *) +val reason_phrase_of_code: int -> string + + (** build a Unix.sockaddr inet address from a string representation of an IP + address and a port number *) +val build_sockaddr: string * int -> Unix.sockaddr + + (** explode an _inet_ Unix.sockaddr address in a string representation of an + IP address and a port number *) +val explode_sockaddr: Unix.sockaddr -> string * int + + (** given an out_channel build on top of a socket, return peername related to + that socket *) +val peername_of_out_channel: out_channel -> Unix.sockaddr + + (** as above but works on in_channels *) +val peername_of_in_channel: in_channel -> Unix.sockaddr + + (** given an out_channel build on top of a socket, return sockname related to + that socket *) +val sockname_of_out_channel: out_channel -> Unix.sockaddr + + (** as above but works on in_channels *) +val sockname_of_in_channel: in_channel -> Unix.sockaddr + + (* TODO replace with Buffer.add_channel which does almost the same :-((( *) + (** reads from an input channel till it End_of_file and returns what has been + read; if limit is given returned buffer will contains at most first 'limit' + bytes read from input channel *) +val buf_of_inchan: ?limit: int -> in_channel -> Buffer.t + + (** like List.assoc but return all bindings of a given key instead of the + leftmost one only *) +val list_assoc_all: 'a -> ('a * 'b) list -> 'b list + +val warn: string -> unit (** print a warning msg to stderr. Adds trailing \n *) +val error: string -> unit (** print an error msg to stderr. Adds trailing \n *) + diff --git a/DEVEL/ocaml-http/http_parser.ml b/DEVEL/ocaml-http/http_parser.ml new file mode 100644 index 000000000..af371bb1e --- /dev/null +++ b/DEVEL/ocaml-http/http_parser.ml @@ -0,0 +1,160 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf;; + +open Http_common;; +open Http_types;; +open Http_constants;; + +let (bindings_sep, binding_sep, pieces_sep, header_sep) = + (Pcre.regexp "&", Pcre.regexp "=", Pcre.regexp " ", Pcre.regexp ":") +let header_RE = Pcre.regexp "([^:]*):(.*)" + +let url_decode url = Netencoding.Url.decode ~plus:true url + +let split_query_params query = + let bindings = Pcre.split ~rex:bindings_sep query in + match bindings with + | [] -> raise (Malformed_query query) + | bindings -> + List.map + (fun binding -> + match Pcre.split ~rex:binding_sep binding with + | [ ""; b ] -> (* '=b' *) + raise (Malformed_query_part (binding, query)) + | [ a; b ] -> (* 'a=b' *) (url_decode a, url_decode b) + | [ a ] -> (* 'a=' || 'a' *) (url_decode a, "") + | _ -> raise (Malformed_query_part (binding, query))) + bindings + + (** internal, used by generic_input_line *) +exception Line_completed;; + + (** given an input channel and a separator + @return a line read from it (like Pervasives.input_line) + line is returned only after reading a separator string; separator string isn't + included in the returned value + TODO what about efficiency?, input is performed char-by-char + *) +let generic_input_line ~sep ~ic = + let sep_len = String.length sep in + if sep_len < 1 then + failwith ("Separator '" ^ sep ^ "' is too short!") + else (* valid separator *) + let line = ref "" in + let sep_pointer = ref 0 in + try + while true do + if !sep_pointer >= String.length sep then (* line completed *) + raise Line_completed + else begin (* incomplete line: need to read more *) + let ch = input_char ic in + if ch = String.get sep !sep_pointer then (* next piece of sep *) + incr sep_pointer + else begin (* useful char *) + for i = 0 to !sep_pointer - 1 do + line := !line ^ (String.make 1 (String.get sep i)) + done; + sep_pointer := 0; + line := !line ^ (String.make 1 ch) + end + end + done; + assert false (* unreacheable statement *) + with Line_completed -> !line + +let patch_empty_path = function "" -> "/" | s -> s +let debug_dump_request path params = + debug_print + (sprintf + "recevied request; path: %s; params: %s" + path + (String.concat ", " (List.map (fun (n, v) -> n ^ "=" ^ v) params))) + +let parse_request_fst_line ic = + let request_line = generic_input_line ~sep:crlf ~ic in + debug_print (sprintf "HTTP request line (not yet parsed): %s" request_line); + try + (match Pcre.split ~rex:pieces_sep request_line with + | [ meth_raw; uri_raw ] -> (* ancient HTTP request line *) + (method_of_string meth_raw, (* method *) + Http_parser_sanity.url_of_string uri_raw, (* uri *) + None) (* no version given *) + | [ meth_raw; uri_raw; http_version_raw ] -> (* HTTP 1.{0,1} *) + (method_of_string meth_raw, (* method *) + Http_parser_sanity.url_of_string uri_raw, (* uri *) + Some (version_of_string http_version_raw)) (* version *) + | _ -> raise (Malformed_request request_line)) + with Malformed_URL url -> raise (Malformed_request_URI url) + +let parse_response_fst_line ic = + let response_line = generic_input_line ~sep:crlf ~ic in + debug_print (sprintf "HTTP response line (not yet parsed): %s" response_line); + try + (match Pcre.split ~rex:pieces_sep response_line with + | version_raw :: code_raw :: _ -> + (version_of_string version_raw, (* method *) + status_of_code (int_of_string code_raw)) (* status *) + | _ -> raise (Malformed_response response_line)) + with + | Malformed_URL _ | Invalid_code _ | Failure "int_of_string" -> + raise (Malformed_response response_line) + +let parse_path uri = patch_empty_path (String.concat "/" (Neturl.url_path uri)) +let parse_query_get_params uri = + try (* act on HTTP encoded URIs *) + split_query_params (Neturl.url_query ~encoded:true uri) + with Not_found -> [] + +let parse_headers ic = + (* consume also trailing "^\r\n$" line *) + let rec parse_headers' headers = + match generic_input_line ~sep:crlf ~ic with + | "" -> List.rev headers + | line -> + (let subs = + try + Pcre.extract ~rex:header_RE line + with Not_found -> raise (Invalid_header line) + in + let header = + try + subs.(1) + with Invalid_argument "Array.get" -> raise (Invalid_header line) + in + let value = + try + Http_parser_sanity.normalize_header_value subs.(2) + with Invalid_argument "Array.get" -> "" + in + Http_parser_sanity.heal_header (header, value); + parse_headers' ((header, value) :: headers)) + in + parse_headers' [] + +let parse_request ic = + let (meth, uri, version) = parse_request_fst_line ic in + let path = parse_path uri in + let query_get_params = parse_query_get_params uri in + debug_dump_request path query_get_params; + (path, query_get_params) + diff --git a/DEVEL/ocaml-http/http_parser.mli b/DEVEL/ocaml-http/http_parser.mli new file mode 100644 index 000000000..58e616bd7 --- /dev/null +++ b/DEVEL/ocaml-http/http_parser.mli @@ -0,0 +1,68 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** HTTP messages parsing *) + +open Http_types;; + + (** given an HTTP like query string (e.g. "name1=value1&name2=value2&...") + @return a list of pairs [("name1", "value1"); ("name2", "value2")] + @raise Malformed_query if the string isn't a valid query string + @raise Malformed_query_part if some piece of the query isn't valid + *) +val split_query_params: string -> (string * string) list + + (** parse 1st line of an HTTP request + @param inchan input channel from which parse request + @return a triple meth * url * version, meth is the HTTP method invoked, url is + the requested url, version is the HTTP version specified or None if no version + was specified + @raise Malformed_request if request 1st linst isn't well formed + @raise Malformed_request_URI if requested URI isn't well formed *) +val parse_request_fst_line: in_channel -> meth * Neturl.url * version option + + (** parse 1st line of an HTTP response + * @param inchan input channel from which parse response + * @raise Malformed_response if first line isn't well formed + *) +val parse_response_fst_line: in_channel -> version * status + + (** parse HTTP GET parameters from an URL; paramater which were passed with no + value (like 'x' in "/foo.cgi?a=10&x=&c=9") are returned associated with the + empty ("") string. + @return a list of pairs param_name * param_value *) +val parse_query_get_params: Neturl.url -> (string * string) list + + (** parse the base path (removing query string, fragment, ....) from an URL *) +val parse_path: Neturl.url -> string + + (** parse HTTP headers. Consumes also trailing CRLF at the end of header list + @param inchan input channel from which parse headers + @return a list of pairs header_name * header_value + @raise Invalid_header if a not well formed header is encountered *) +val parse_headers: in_channel -> (string * string) list + + (** given an input channel, reads from it a GET HTTP request and + @return a pair where path is a string representing the + requested path and query_params is a list of pairs (the GET + parameters) *) +val parse_request: in_channel -> string * (string * string) list + diff --git a/DEVEL/ocaml-http/http_parser_sanity.ml b/DEVEL/ocaml-http/http_parser_sanity.ml new file mode 100644 index 000000000..7fe08cf93 --- /dev/null +++ b/DEVEL/ocaml-http/http_parser_sanity.ml @@ -0,0 +1,115 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf + +open Http_types +open Http_constants + +(* +type url_syntax_option = + Url_part_not_recognized + | Url_part_allowed + | Url_part_required + +* (1) scheme://user:password@host:port/path;params?query#fragment +*) + +let request_uri_syntax = +{ + Neturl.url_enable_scheme = Neturl.Url_part_not_recognized; + url_enable_user = Neturl.Url_part_not_recognized; + url_enable_user_param = Neturl.Url_part_not_recognized; + url_enable_password = Neturl.Url_part_not_recognized; + url_enable_host = Neturl.Url_part_not_recognized; + url_enable_port = Neturl.Url_part_not_recognized; + url_enable_path = Neturl.Url_part_required; + url_enable_param = Neturl.Url_part_not_recognized; + url_enable_query = Neturl.Url_part_allowed; + url_enable_fragment = Neturl.Url_part_not_recognized; + url_enable_other = Neturl.Url_part_not_recognized; + url_accepts_8bits = false; + url_enable_relative = true; + url_is_valid = (fun _ -> true); +} + + (* convention: + foo_RE_raw is the uncompiled regexp matching foo + foo_RE is the compiled regexp matching foo + is_foo is the predicate over string matching foo + *) + +let separators_RE_raw = "()<>@,;:\\\\\"/\\[\\]?={} \t" +let ctls_RE_raw = "\\x00-\\x1F\\x7F" +let token_RE_raw = "[^" ^ separators_RE_raw ^ ctls_RE_raw ^ "]+" +let lws_RE_raw = "(\r\n)?[ \t]" +let quoted_string_RE_raw = "\"(([^\"])|(\\\\\"))*\"" +let text_RE_raw = "(([^" ^ ctls_RE_raw ^ "])|(" ^ lws_RE_raw ^ "))+" +let field_content_RE_raw = + sprintf + "^(((%s)|(%s)|(%s))|(%s))*$" + token_RE_raw + separators_RE_raw + quoted_string_RE_raw + text_RE_raw +(* + (* following RFC 2616 specifications *) +let field_value_RE_raw = "((" ^ field_content_RE_raw ^ ")|(" ^ lws_RE_raw^ "))*" +*) + (* smarter implementation: TEXT production is included in the regexp below *) +let field_value_RE_raw = + sprintf + "^((%s)|(%s)|(%s)|(%s))*$" + token_RE_raw + separators_RE_raw + quoted_string_RE_raw + lws_RE_raw + +let token_RE = Pcre.regexp ("^" ^ token_RE_raw ^ "$") +let field_value_RE = Pcre.regexp ("^" ^ field_value_RE_raw ^ "$") +let heading_lws_RE = Pcre.regexp (sprintf "^%s*" lws_RE_raw) +let trailing_lws_RE = Pcre.regexp (sprintf "%s*$" lws_RE_raw) + +let is_token s = Pcre.pmatch ~rex:token_RE s +let is_field_name = is_token +let is_field_value s = Pcre.pmatch ~rex:field_value_RE s + +let heal_header_name s = + if not (is_field_name s) then raise (Invalid_header_name s) else () + +let heal_header_value s = + if not (is_field_value s) then raise (Invalid_header_value s) else () + +let normalize_header_value s = + Pcre.replace ~rex:trailing_lws_RE + (Pcre.replace ~rex:heading_lws_RE s) + +let heal_header (name, value) = + heal_header_name name; + heal_header_value name + +let url_of_string s = + try + Neturl.url_of_string request_uri_syntax s + with Neturl.Malformed_URL -> raise (Malformed_URL s) + +let string_of_url = Neturl.string_of_url + diff --git a/DEVEL/ocaml-http/http_parser_sanity.mli b/DEVEL/ocaml-http/http_parser_sanity.mli new file mode 100644 index 000000000..a869f182f --- /dev/null +++ b/DEVEL/ocaml-http/http_parser_sanity.mli @@ -0,0 +1,46 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Sanity test functions related to HTTP message parsing *) + + (** @param name an HTTP header name + @raise Invalid_header_name if name isn't a valid HTTP header name *) +val heal_header_name: string -> unit + + (** @param value an HTTP header value + @raise Invalid_header_value if value isn't a valid HTTP header value *) +val heal_header_value: string -> unit + + (** @param header a pair header_name * header_value + @raise Invalid_header_name if name isn't a valid HTTP header name + @raise Invalid_header_value if value isn't a valid HTTP header value *) +val heal_header: string * string -> unit + + (** remove heading and/or trailing LWS sequences as per RFC2616 *) +val normalize_header_value: string -> string + + (** parse an URL from a string. + @raise Malformed_URL if an invalid URL is encountered *) +val url_of_string: string -> Neturl.url + + (** pretty print an URL *) +val string_of_url: Neturl.url -> string + diff --git a/DEVEL/ocaml-http/http_request.ml b/DEVEL/ocaml-http/http_request.ml new file mode 100644 index 000000000..cd2dcd165 --- /dev/null +++ b/DEVEL/ocaml-http/http_request.ml @@ -0,0 +1,145 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf;; + +open Http_common;; +open Http_types;; + +let debug_dump_request path params = + debug_print ("request path = " ^ path); + debug_print ( + sprintf"request params = %s" + (String.concat ";" + (List.map (fun (h,v) -> String.concat "=" [h;v]) params))) + +let auth_sep_RE = Pcre.regexp ":" +let basic_auth_RE = Pcre.regexp "^Basic\\s+" + +exception Fallback;; (* used internally by request class *) + +class request ic = + let (meth, uri, version) = Http_parser.parse_request_fst_line ic in + let uri_str = Neturl.string_of_url uri in + let path = Http_parser.parse_path uri in + let query_get_params = Http_parser.parse_query_get_params uri in + let (headers, body) = + (match version with + | None -> [], "" (* No version given, use request's 1st line only *) + | Some version -> (* Version specified, parse also headers and body *) + let headers = + List.map (* lowercase header names to ease lookups before having a + request object *) + (fun (h,v) -> (String.lowercase h, v)) + (Http_parser.parse_headers ic) (* trailing \r\n consumed! *) + in + let body = + (* TODO fallback on size defined in Transfer-Encoding if + Content-Length isn't defined *) + if meth = `POST then + Buffer.contents + (try (* read only Content-Length bytes *) + let limit_raw = + (try + List.assoc "content-length" headers + with Not_found -> raise Fallback) + in + let limit = + (try (* TODO supports only a maximum content-length of 1Gb *) + int_of_string limit_raw + with Failure "int_of_string" -> + raise (Invalid_header ("content-length: " ^ limit_raw))) + in + Http_misc.buf_of_inchan ~limit ic + with Fallback -> Http_misc.buf_of_inchan ic) (* read until EOF *) + else (* TODO empty body for methods other than POST, is ok? *) + "" + in + (headers, body)) + in + let query_post_params = + match meth with + | `POST -> + let ct = try List.assoc "content-type" headers with Not_found -> "" in + if ct = "application/x-www-form-urlencoded" then + Http_parser.split_query_params body + else [] + | _ -> [] + in + let params = query_post_params @ query_get_params in (* prefers POST params *) + let _ = debug_dump_request path params in + let (clisockaddr, srvsockaddr) = + (Http_misc.peername_of_in_channel ic, Http_misc.sockname_of_in_channel ic) + in + + object (self) + + inherit + Http_message.message ~body ~headers ~version ~clisockaddr ~srvsockaddr + + val params_tbl = + let tbl = Hashtbl.create (List.length params) in + List.iter (fun (n,v) -> Hashtbl.add tbl n v) params; + tbl + + method meth = meth + method uri = uri_str + method path = path + method param ?(meth: meth option) ?(default: string option) name = + try + (match meth with + | None -> Hashtbl.find params_tbl name + | Some `GET -> List.assoc name query_get_params + | Some `POST -> List.assoc name query_post_params) + with Not_found -> + (match default with + | None -> raise (Param_not_found name) + | Some value -> value) + method paramAll ?meth name = + (match (meth: meth option) with + | None -> List.rev (Hashtbl.find_all params_tbl name) + | Some `GET -> Http_misc.list_assoc_all name query_get_params + | Some `POST -> Http_misc.list_assoc_all name query_post_params) + method params = params + method params_GET = query_get_params + method params_POST = query_post_params + + method private fstLineToString = + let method_string = string_of_method self#meth in + match self#version with + | Some version -> + sprintf "%s %s %s" method_string self#uri (string_of_version version) + | None -> sprintf "%s %s" method_string self#uri + + method authorization: auth_info option = + try + let credentials = + Netencoding.Base64.decode + (Pcre.replace ~rex:basic_auth_RE (self#header "authorization")) + in + debug_print ("HTTP Basic auth credentials: " ^ credentials); + (match Pcre.split ~rex:auth_sep_RE credentials with + | [username; password] -> Some (`Basic (username, password)) + | l -> raise Exit) + with Header_not_found _ | Invalid_argument _ | Exit -> None + + end + diff --git a/DEVEL/ocaml-http/http_request.mli b/DEVEL/ocaml-http/http_request.mli new file mode 100644 index 000000000..23da0cc9b --- /dev/null +++ b/DEVEL/ocaml-http/http_request.mli @@ -0,0 +1,29 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Object Oriented representation of HTTP requests *) + +open Http_types;; + + (** OO representation of an HTTP request + @param inchan input channel from which parse an HTTP request *) +class request: in_channel -> Http_types.request + diff --git a/DEVEL/ocaml-http/http_response.ml b/DEVEL/ocaml-http/http_response.ml new file mode 100644 index 000000000..58308d307 --- /dev/null +++ b/DEVEL/ocaml-http/http_response.ml @@ -0,0 +1,118 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Http_types;; +open Http_constants;; +open Http_common;; +open Http_daemon;; +open Printf;; + +let status_line_RE = Pcre.regexp "^(HTTP/\\d\\.\\d) (\\d{3}) (.*)$" + +let anyize = function + | Some addr -> addr + | None -> Unix.ADDR_INET (Unix.inet_addr_any, -1) + +class response + (* Warning: keep default values in sync with Http_daemon.respond function *) + ?(body = "") ?(headers = []) ?(version = http_version) + ?clisockaddr ?srvsockaddr (* optional because response have to be easily + buildable in callback functions *) + ?(code = 200) ?status + () + = + + (** if no address were supplied for client and/or server, use a foo address + instead *) + let (clisockaddr, srvsockaddr) = (anyize clisockaddr, anyize srvsockaddr) in + + (* "version code reason_phrase" *) + object (self) + + (* note that response objects can't be created with a None version *) + inherit + Http_message.message + ~body ~headers ~version:(Some version) ~clisockaddr ~srvsockaddr + + val mutable _code = + match status with + | None -> code + | Some (s: Http_types.status) -> code_of_status s + val mutable _reason: string option = None + + method private getRealVersion = + match self#version with + | None -> + failwith ("Http_response.fstLineToString: " ^ + "can't serialize an HTTP response with no HTTP version defined") + | Some v -> string_of_version v + + method code = _code + method setCode c = + ignore (status_of_code c); (* sanity check on c *) + _code <- c + method status = status_of_code _code + method setStatus (s: Http_types.status) = _code <- code_of_status s + method reason = + match _reason with + | None -> Http_misc.reason_phrase_of_code _code + | Some r -> r + method setReason r = _reason <- Some r + method statusLine = + String.concat " " + [self#getRealVersion; string_of_int self#code; self#reason] + method setStatusLine s = + try + let subs = Pcre.extract ~rex:status_line_RE s in + self#setVersion (version_of_string subs.(1)); + self#setCode (int_of_string subs.(2)); + self#setReason subs.(3) + with Not_found -> + raise (Invalid_status_line s) + + method isInformational = is_informational _code + method isSuccess = is_success _code + method isRedirection = is_redirection _code + method isClientError = is_client_error _code + method isServerError = is_server_error _code + method isError = is_error _code + + (* FIXME duplication of code between this and send_basic_headers *) + method addBasicHeaders = + self#addHeader ~name:"Date" ~value:(Http_misc.date_822 ()); + self#addHeader ~name:"Server" ~value:server_string + + method contentType = self#header "Content-Type" + method setContentType t = self#replaceHeader "Content-Type" t + method contentEncoding = self#header "Content-Encoding" + method setContentEncoding e = self#replaceHeader "Content-Encoding" e + method date = self#header "Date" + method setDate d = self#replaceHeader "Date" d + method expires = self#header "Expires" + method setExpires t = self#replaceHeader "Expires" t + method server = self#header "Server" + method setServer s = self#replaceHeader "Server" s + + method private fstLineToString = + sprintf "%s %d %s" self#getRealVersion self#code self#reason + + end + diff --git a/DEVEL/ocaml-http/http_response.mli b/DEVEL/ocaml-http/http_response.mli new file mode 100644 index 000000000..694eb22c0 --- /dev/null +++ b/DEVEL/ocaml-http/http_response.mli @@ -0,0 +1,33 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Object Oriented representation of HTTP responses *) + +open Http_types;; + + (** OO representation of an HTTP response. *) +class response: + ?body:string -> ?headers:(string * string) list -> ?version: version -> + ?clisockaddr: Unix.sockaddr -> ?srvsockaddr: Unix.sockaddr -> + ?code:int -> ?status:Http_types.status -> + unit -> + Http_types.response + diff --git a/DEVEL/ocaml-http/http_tcp_server.ml b/DEVEL/ocaml-http/http_tcp_server.ml new file mode 100644 index 000000000..cbe01add1 --- /dev/null +++ b/DEVEL/ocaml-http/http_tcp_server.ml @@ -0,0 +1,172 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + + + (** raised when a client timeouts *) +exception Timeout + +let backlog = 10 + + (** if timeout is given (Some _) @return a new callback which establish + timeout_callback as callback for signal Sys.sigalrm and register an alarm + (expiring after timeout seconds) before invoking the real callback given. If + timeout is None, callback is returned unchanged. *) +let wrap_callback_w_timeout ~callback ~timeout ~timeout_callback = + match timeout with + | None -> callback + | Some timeout -> (* wrap callback setting an handler for ALRM signal and an + alarm that ring after timeout seconds *) + (fun inchan outchan -> + ignore (Sys.signal Sys.sigalrm (Sys.Signal_handle timeout_callback)); + ignore (Unix.alarm timeout); + callback inchan outchan) + + (* try to close nicely a socket *) +let shutdown_socket suck = + try + Unix.shutdown suck Unix.SHUTDOWN_ALL + with Unix.Unix_error(_, "shutdown", "") -> () + +let nice_unix_accept suck = + try + Unix.accept suck + with e -> (* clean up socket before exit *) + shutdown_socket suck; + raise e + +let init_socket sockaddr = + let suck = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in + (* shutdown socket on SIGTERM *) + ignore (Sys.signal Sys.sigterm + (Sys.Signal_handle + (fun _ -> shutdown_socket suck; exit 17))); + Unix.setsockopt suck Unix.SO_REUSEADDR true; + Unix.bind suck sockaddr; + Unix.listen suck backlog; + suck + +let init_callback callback timeout = + let timeout_callback signo = + if signo = Sys.sigalrm then + raise Timeout + in + wrap_callback_w_timeout ~callback ~timeout ~timeout_callback + + (** try to close an outchannel connected to a socket, ignore Sys_error since + * this probably means that socket is already closed (e.g. on sigpipe) *) +let try_close_out ch = try close_out ch with Sys_error _ -> () + + (** like Unix.establish_server, but shutdown sockets when receiving SIGTERM + and before exiting for an uncaught exception *) +let my_establish_server server_fun sockaddr = + let suck = init_socket sockaddr in + while true do + let (s, caller) = nice_unix_accept suck in + (** "double fork" trick, see {!Unix.establish_server} implementation *) + match Unix.fork() with + | 0 -> (* parent *) + (try + if Unix.fork () <> 0 then + exit 0; (* The son exits, the grandson works *) + let inchan = Unix.in_channel_of_descr s in + let outchan = Unix.out_channel_of_descr s in + server_fun inchan outchan; + try_close_out outchan; (* closes also inchan: socket is the same *) + exit 0 + with e -> + shutdown_socket suck; (* clean up socket before exit *) + raise e) + | child when (child > 0) -> (* child *) + Unix.close s; + ignore (Unix.waitpid [] child) (* Reclaim the son *) + | _ (* < 0 *) -> + failwith "Can't fork" + done + + (** tcp_server which forks a new process for each request *) +let fork ~sockaddr ~timeout callback = + let timeout_callback signo = + if signo = Sys.sigalrm then + exit 2 + in + my_establish_server + (wrap_callback_w_timeout ~callback ~timeout ~timeout_callback) + sockaddr + + (** tcp_server which doesn't fork, requests are server sequentially and in the + same address space of the calling process *) +let simple ~sockaddr ~timeout callback = + let suck = init_socket sockaddr in + let callback = init_callback callback timeout in + try + while true do + let (client, _) = Unix.accept suck in + (* client is now connected *) + let (inchan, outchan) = + (Unix.in_channel_of_descr client, Unix.out_channel_of_descr client) + in + (try + callback inchan outchan; + ignore (Unix.alarm 0) (* reset alarm *) + with Timeout -> ()); + try_close_out outchan (* this close also inchan: socket is the same *) + done + with e -> (* clean up socket before exit *) + shutdown_socket suck; + raise e + + (** tcp_server which creates a new thread for each request to be served *) +let thread ~sockaddr ~timeout callback = + let suck = init_socket sockaddr in + let callback = init_callback callback timeout in + let callback (i, o) = + (try + callback i o + with + | Timeout -> () + | e -> + try_close_out o; + raise e); + try_close_out o + in + while true do + let (client, _) = nice_unix_accept suck in + (* client is now connected *) + let (inchan, outchan) = + (Unix.in_channel_of_descr client, Unix.out_channel_of_descr client) + in + Http_threaded_tcp_server.serve callback (inchan, outchan) + done + + (** @param server an Http_types.tcp_server + * @return an Http_types.tcp_server which takes care of ignoring SIGPIPE during + * server execution and restoring previous handler when (if ever) the server + * returns *) +let handle_sigpipe server = + fun ~sockaddr ~timeout callback -> + let old_sigpipe_behavior = Sys.signal Sys.sigpipe Sys.Signal_ignore in + server ~sockaddr ~timeout callback; + ignore (Sys.signal Sys.sigpipe old_sigpipe_behavior) + +let simple = handle_sigpipe simple +let thread = handle_sigpipe thread +let fork = handle_sigpipe fork + diff --git a/DEVEL/ocaml-http/http_tcp_server.mli b/DEVEL/ocaml-http/http_tcp_server.mli new file mode 100644 index 000000000..e94f84f95 --- /dev/null +++ b/DEVEL/ocaml-http/http_tcp_server.mli @@ -0,0 +1,39 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** TCP servers used as low-levels for HTTP daemons *) + +(** {2 servers} *) + + (** single process server *) +val simple: Http_types.tcp_server + + (** multi threaded server *) +val thread: Http_types.tcp_server + + (** multi process server *) +val fork: Http_types.tcp_server + +(** {2 low level functions} *) + + (** initialize a passive socket listening on given Unix.sockaddr *) +val init_socket: Unix.sockaddr -> Unix.file_descr + diff --git a/DEVEL/ocaml-http/http_threaded_tcp_server.mli b/DEVEL/ocaml-http/http_threaded_tcp_server.mli new file mode 100644 index 000000000..6504f7e01 --- /dev/null +++ b/DEVEL/ocaml-http/http_threaded_tcp_server.mli @@ -0,0 +1,26 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Multithreaded part of Http_tcp_server *) + + (** serve an HTTP request for a multi threaded TCP server *) +val serve : ('a -> 'b) -> 'a -> unit + diff --git a/DEVEL/ocaml-http/http_types.ml b/DEVEL/ocaml-http/http_types.ml new file mode 100644 index 000000000..5c88b212e --- /dev/null +++ b/DEVEL/ocaml-http/http_types.ml @@ -0,0 +1,219 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Type definitions *) + +type version = [ `HTTP_1_0 | `HTTP_1_1 ] +type meth = [ `GET | `POST ] +type daemon_mode = [ `Single | `Fork | `Thread ] + +type tcp_server = + sockaddr:Unix.sockaddr -> timeout:int option -> + (in_channel -> out_channel -> unit) -> + unit + +type auth_info = + [ `Basic of string * string (* username, password *) + ] + +type informational_substatus = + [ `Continue + | `Switching_protocols + ] +type success_substatus = + [ `OK + | `Created + | `Accepted + | `Non_authoritative_information + | `No_content + | `Reset_content + | `Partial_content + ] +type redirection_substatus = + [ `Multiple_choices + | `Moved_permanently + | `Found + | `See_other + | `Not_modified + | `Use_proxy + | `Temporary_redirect + ] +type client_error_substatus = + [ `Bad_request + | `Unauthorized + | `Payment_required + | `Forbidden + | `Not_found + | `Method_not_allowed + | `Not_acceptable + | `Proxy_authentication_required + | `Request_time_out + | `Conflict + | `Gone + | `Length_required + | `Precondition_failed + | `Request_entity_too_large + | `Request_URI_too_large + | `Unsupported_media_type + | `Requested_range_not_satisfiable + | `Expectation_failed + ] +type server_error_substatus = + [ `Internal_server_error + | `Not_implemented + | `Bad_gateway + | `Service_unavailable + | `Gateway_time_out + | `HTTP_version_not_supported + ] +type informational_status = [ `Informational of informational_substatus ] +type success_status = [ `Success of success_substatus ] +type redirection_status = [ `Redirection of redirection_substatus ] +type client_error_status = [ `Client_error of client_error_substatus ] +type server_error_status = [ `Server_error of server_error_substatus ] +type error_status = + [ client_error_status + | server_error_status + ] +type status = + [ informational_status + | success_status + | redirection_status + | client_error_status + | server_error_status + ] + +type status_code = [ `Code of int | `Status of status ] + +type file_source = + | FileSrc of string + | InChanSrc of in_channel + +exception Invalid_header of string +exception Invalid_header_name of string +exception Invalid_header_value of string +exception Invalid_HTTP_version of string +exception Invalid_HTTP_method of string +exception Invalid_code of int +exception Malformed_URL of string +exception Malformed_query of string +exception Malformed_query_part of string * string +exception Malformed_request_URI of string +exception Malformed_request of string +exception Malformed_response of string +exception Param_not_found of string +exception Invalid_status_line of string +exception Header_not_found of string +exception Quit +exception Unauthorized of string + +class type message = object + method version: version option + method setVersion: version -> unit + method body: string + method setBody: string -> unit + method bodyBuf: Buffer.t + method setBodyBuf: Buffer.t -> unit + method addBody: string -> unit + method addBodyBuf: Buffer.t -> unit + method addHeader: name:string -> value:string -> unit + method addHeaders: (string * string) list -> unit + method replaceHeader: name:string -> value:string -> unit + method replaceHeaders: (string * string) list -> unit + method removeHeader: name:string -> unit + method hasHeader: name:string -> bool + method header: name:string -> string + method headers: (string * string) list + method clientSockaddr: Unix.sockaddr + method clientAddr: string + method clientPort: int + method serverSockaddr: Unix.sockaddr + method serverAddr: string + method serverPort: int + method toString: string + method serialize: out_channel -> unit + end + +class type request = object + inherit message + method meth: meth + method uri: string + method path: string + method param: ?meth:meth -> ?default:string -> string -> string + method paramAll: ?meth:meth -> string -> string list + method params: (string * string) list + method params_GET: (string * string) list + method params_POST: (string * string) list + method authorization: auth_info option + end + +class type response = object + inherit message + method code: int + method setCode: int -> unit + method status: status + method setStatus: status -> unit + method reason: string + method setReason: string -> unit + method statusLine: string + method setStatusLine: string -> unit + method isInformational: bool + method isSuccess: bool + method isRedirection: bool + method isClientError: bool + method isServerError: bool + method isError: bool + method addBasicHeaders: unit + method contentType: string + method setContentType: string -> unit + method contentEncoding: string + method setContentEncoding: string -> unit + method date: string + method setDate: string -> unit + method expires: string + method setExpires: string -> unit + method server: string + method setServer: string -> unit + end + +class type connection = + object + method getRequest: request option + method respond_with: response -> unit + method close: unit + end +class type daemon = + object + method accept: connection + method getRequest: request * connection + end + +type daemon_spec = { + address: string; + auth: (string * auth_info) option; + callback: request -> out_channel -> unit; + mode: daemon_mode; + port: int; + root_dir: string option; + exn_handler: (exn -> out_channel -> unit) option; + timeout: int option; +} + diff --git a/DEVEL/ocaml-http/http_types.mli b/DEVEL/ocaml-http/http_types.mli new file mode 100644 index 000000000..8d5832655 --- /dev/null +++ b/DEVEL/ocaml-http/http_types.mli @@ -0,0 +1,451 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Type definitions *) + + (** HTTP version, actually only 1.0 and 1.1 are supported. Note that + 'supported' here means only 'accepted inside a HTTP request line', no + different behaviours are actually implemented depending on HTTP version *) +type version = + [ `HTTP_1_0 + | `HTTP_1_1 + ] + + (** HTTP method, actually only GET and POST methods are supported *) +type meth = + [ `GET + | `POST + ] + + (** Daemon behaviour wrt request handling. `Single mode use a single process + to handle all requests, no request is served until a previous one has been + fully served. `Fork mode fork a new process for each request, the new process + will execute the callback function and then exit. `Thread mode create a new + thread for each request, the new thread will execute the callback function and + then exit, threads can communicate using standard OCaml Thread library. *) +type daemon_mode = [ `Single | `Fork | `Thread ] + + (** A TCP server is a function taking an address on which bind and listen for + connections, an optional timeout after which abort client connections and a + callback function which in turn takes an input and an output channel as + arguments. After receiving this argument a TCP server sits and waits for + connection, on each connection it apply the callback function to channels + connected to client. *) +type tcp_server = + sockaddr:Unix.sockaddr -> timeout:int option -> + (in_channel -> out_channel -> unit) -> + unit + + (** authentication information *) +type auth_info = + [ `Basic of string * string (* username, password *) +(* | `Digest of ... (* TODO digest authentication *) *) + ] + + (** @see "RFC2616" informational HTTP status *) +type informational_substatus = + [ `Continue + | `Switching_protocols + ] + + (** @see "RFC2616" success HTTP status *) +type success_substatus = + [ `OK + | `Created + | `Accepted + | `Non_authoritative_information + | `No_content + | `Reset_content + | `Partial_content + ] + + (** @see "RFC2616" redirection HTTP status *) +type redirection_substatus = + [ `Multiple_choices + | `Moved_permanently + | `Found + | `See_other + | `Not_modified + | `Use_proxy + | `Temporary_redirect + ] + + (** @see "RFC2616" client error HTTP status *) +type client_error_substatus = + [ `Bad_request + | `Unauthorized + | `Payment_required + | `Forbidden + | `Not_found + | `Method_not_allowed + | `Not_acceptable + | `Proxy_authentication_required + | `Request_time_out + | `Conflict + | `Gone + | `Length_required + | `Precondition_failed + | `Request_entity_too_large + | `Request_URI_too_large + | `Unsupported_media_type + | `Requested_range_not_satisfiable + | `Expectation_failed + ] + + (** @see "RFC2616" server error HTTP status *) +type server_error_substatus = + [ `Internal_server_error + | `Not_implemented + | `Bad_gateway + | `Service_unavailable + | `Gateway_time_out + | `HTTP_version_not_supported + ] + +type informational_status = [ `Informational of informational_substatus ] +type success_status = [ `Success of success_substatus ] +type redirection_status = [ `Redirection of redirection_substatus ] +type client_error_status = [ `Client_error of client_error_substatus ] +type server_error_status = [ `Server_error of server_error_substatus ] + +type error_status = + [ client_error_status + | server_error_status + ] + + (** HTTP status *) +type status = + [ informational_status + | success_status + | redirection_status + | client_error_status + | server_error_status + ] + +type status_code = [ `Code of int | `Status of status ] + + (** File sources *) +type file_source = + | FileSrc of string (** filename *) + | InChanSrc of in_channel (** input channel *) + + (** {2 Exceptions} *) + + (** invalid header encountered *) +exception Invalid_header of string + + (** invalid header name encountered *) +exception Invalid_header_name of string + + (** invalid header value encountered *) +exception Invalid_header_value of string + + (** unsupported or invalid HTTP version encountered *) +exception Invalid_HTTP_version of string + + (** unsupported or invalid HTTP method encountered *) +exception Invalid_HTTP_method of string + + (** invalid HTTP status code integer representation encountered *) +exception Invalid_code of int + + (** invalid URL encountered *) +exception Malformed_URL of string + + (** invalid query string encountered *) +exception Malformed_query of string + + (** invalid query string part encountered, arguments are parameter name and + parameter value *) +exception Malformed_query_part of string * string + + (** invalid request URI encountered *) +exception Malformed_request_URI of string + + (** malformed request received *) +exception Malformed_request of string + + (** malformed response received, argument is response's first line *) +exception Malformed_response of string + + (** a parameter you were looking for was not found *) +exception Param_not_found of string + + (** invalid HTTP status line encountered *) +exception Invalid_status_line of string + + (** an header you were looking for was not found *) +exception Header_not_found of string + + (** raisable by callbacks to make main daemon quit, this is the only + * 'clean' way to make start functions return *) +exception Quit + + (** raisable by callbacks to force a 401 (unauthorized) HTTP answer. + * This exception should be raised _before_ sending any data over given out + * channel. + * @param realm authentication realm (usually needed to prompt user) *) +exception Unauthorized of string + + (** {2 OO representation of HTTP messages} *) + + (** HTTP generic messages. See {! Http_message.message} *) +class type message = object + + method version: version option + method setVersion: version -> unit + + method body: string + method setBody: string -> unit + method bodyBuf: Buffer.t + method setBodyBuf: Buffer.t -> unit + method addBody: string -> unit + method addBodyBuf: Buffer.t -> unit + + method addHeader: name:string -> value:string -> unit + method addHeaders: (string * string) list -> unit + method replaceHeader: name:string -> value:string -> unit + method replaceHeaders: (string * string) list -> unit + method removeHeader: name:string -> unit + method hasHeader: name:string -> bool + method header: name:string -> string + method headers: (string * string) list + + method clientSockaddr: Unix.sockaddr + method clientAddr: string + method clientPort: int + + method serverSockaddr: Unix.sockaddr + method serverAddr: string + method serverPort: int + + method toString: string + method serialize: out_channel -> unit + + end + + (** HTTP requests *) +class type request = object + + (** an HTTP request is a flavour of HTTP message *) + inherit message + + (** @return request method *) + method meth: meth + + (** @return requested URI (including query string, fragment, ...) *) + method uri: string + + (** @return requested path *) + method path: string + + (** lookup a given parameter + @param meth if given restrict the lookup area (e.g. if meth = POST than + only parameters received via POST are searched), if not given both GET + and POST parameter are searched in an unspecified order (actually the + implementation prefers POST parameters but this is not granted, you've + been warned) + @param default if provided, this value will be returned in case no + parameter of that name is available instead of raising Param_not_found + @param name name of the parameter to lookup + @return value associated to parameter name + @raise Param_not_found if parameter name was not found *) + method param: ?meth:meth -> ?default:string -> string -> string + + (** like param above but return a list of values associated to given + parameter (a parameter could be defined indeed more than once: passed more + than once in a query string or passed both insider the url (the GET way) + and inside message body (the POST way)) *) + method paramAll: ?meth:meth -> string -> string list + + (** @return the list of all received parameters *) + method params: (string * string) list + + (** @return the list of all parameters received via GET *) + method params_GET: (string * string) list + + (** @return the list of all parameter received via POST *) + method params_POST: (string * string) list + + (** @return authorization information, if given by the client *) + method authorization: auth_info option + + end + + (** HTTP responses *) +class type response = object + + inherit message + + (** @return response code *) + method code: int + + (** set response code *) + method setCode: int -> unit + + (** @return response status *) + method status: status + + (** set response status *) + method setStatus: status -> unit + + (** @return reason string *) + method reason: string + + (** set reason string *) + method setReason: string -> unit + + (** @return status line *) + method statusLine: string + + (** set status line + @raise Invalid_status_line if an invalid HTTP status line was passed *) + method setStatusLine: string -> unit + + (** response is an informational one *) + method isInformational: bool + + (** response is a success one *) + method isSuccess: bool + + (** response is a redirection one *) + method isRedirection: bool + + (** response is a client error one *) + method isClientError: bool + + (** response is a server error one *) + method isServerError: bool + + (** response is either a client error or a server error response *) + method isError: bool + + (** add basic headers to response, see {!Http_daemon.send_basic_headers} + *) + method addBasicHeaders: unit + + (** facilities to access some frequently used headers *) + + (** @return Content-Type header value *) + method contentType: string + + (** set Content-Type header value *) + method setContentType: string -> unit + + (** @return Content-Encoding header value *) + method contentEncoding: string + + (** set Content-Encoding header value *) + method setContentEncoding: string -> unit + + (** @return Date header value *) + method date: string + + (** set Date header value *) + method setDate: string -> unit + + (** @return Expires header value *) + method expires: string + + (** set Expires header value *) + method setExpires: string -> unit + + (** @return Server header value *) + method server: string + + (** set Server header value *) + method setServer: string -> unit + + end + + (** {2 Daemon specification} *) + + (** daemon specification, describe the behaviour of an HTTP daemon. + * + * The default daemon specification is {!Http_daemon.default_spec} + *) +type daemon_spec = { + address: string; + (** @param address adress on which daemon will be listening, can be both a + * numeric address (e.g. "127.0.0.1") and an hostname (e.g. "localhost") *) + auth: (string * auth_info) option; + (** authentication requirements (currently only basic authentication is + * supported). If set to None no authentication is required. If set to Some + * ("realm", `Basic ("foo", "bar")), only clients authenticated with baisc + * authentication, for realm "realm", providing username "foo" and password + * "bar" are accepted; others are rejected with a 401 response code *) + callback: request -> out_channel -> unit; + (** function which will be called each time a correct HTTP request will be + * received. 1st callback argument is an Http_types.request object + * corresponding to the request received; 2nd argument is an output channel + * corresponding to the socket connected to the client *) + mode: daemon_mode; + (** requests handling mode, it can have three different values: + * - `Single -> all requests will be handled by the same process, + * - `Fork -> each request will be handled by a child process, + * - `Thread -> each request will be handled by a (new) thread *) + port: int; (** TCP port on which the daemon will be listening *) + root_dir: string option; + (** directory to which ocaml http will chdir before starting handling + * requests; if None, no chdir will be performed (i.e. stay in the current + * working directory) *) + exn_handler: (exn -> out_channel -> unit) option; + (** what to do when executing callback raises an exception. If None, the + * exception will be re-raised: in `Fork/`Thread mode the current + * process/thread will be terminated. in `Single mode the exception is + * ignored and the client socket closed. If Some callback, the callback will + * be executed before acting as per None; the callback is meant to perform + * some clean up actions, like releasing global mutexes in `Thread mode *) + timeout: int option; + (** timeout in seconds after which an incoming HTTP request will be + * terminated closing the corresponding TCP connection; None disable the + * timeout *) +} + + (** {2 OO representation of other HTTP entities} *) + + (** an HTTP connection from a client to a server *) +class type connection = + object + (** @return next request object, may block if client hasn't submitted any + request yet, may be None if client request was ill-formed *) + method getRequest: request option + + (** respond to client sending it a response *) + method respond_with: response -> unit + + (** close connection to client. Warning: this object can't be used any + longer after this method has been called *) + method close: unit + end + + (** an HTTP daemon *) +class type daemon = + object + (** @return a connection to a client, may block if no client has connected + yet *) + method accept: connection + + (** shortcut method, blocks until a client has submit a request and + return a pair request * connection *) + method getRequest: request * connection + end + diff --git a/DEVEL/ocaml-http/http_user_agent.ml b/DEVEL/ocaml-http/http_user_agent.ml new file mode 100644 index 000000000..f5317d685 --- /dev/null +++ b/DEVEL/ocaml-http/http_user_agent.ml @@ -0,0 +1,101 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +open Printf + +open Http_common + +exception Http_error of (int * string) (* code, body *) + +let http_scheme_RE = Pcre.regexp ~flags:[`CASELESS] "^http://" +let url_RE = Pcre.regexp "^([\\w.-]+)(:(\\d+))?(/.*)?$" + +let tcp_bufsiz = 4096 (* for TCP I/O *) + +let parse_url url = + try + let subs = + Pcre.extract ~rex:url_RE (Pcre.replace ~rex:http_scheme_RE url) + in + (subs.(1), + (if subs.(2) = "" then 80 else int_of_string subs.(3)), + (if subs.(4) = "" then "/" else subs.(4))) + with exc -> + failwith + (sprintf "Can't parse url: %s (exception: %s)" + url (Printexc.to_string exc)) + +let init_socket addr port = + let inet_addr = (Unix.gethostbyname addr).Unix.h_addr_list.(0) in + let sockaddr = Unix.ADDR_INET (inet_addr, port) in + let suck = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in + Unix.connect suck sockaddr; + let outchan = Unix.out_channel_of_descr suck in + let inchan = Unix.in_channel_of_descr suck in + (inchan, outchan) + +let submit_request kind url = + let (address, port, path) = parse_url url in + let (inchan, outchan) = init_socket address port in + let req_string = match kind with `GET -> "GET" | `HEAD -> "HEAD" in + output_string outchan (sprintf "%s %s HTTP/1.0\r\n" req_string path); + output_string outchan (sprintf "Host: %s\r\n\r\n" address); + flush outchan; + (inchan, outchan) + +let head url = + let (inchan, outchan) = submit_request `HEAD url in + let (_, status) = Http_parser.parse_response_fst_line inchan in + (match code_of_status status with + | 200 -> () + | code -> raise (Http_error (code, ""))); + let buf = Http_misc.buf_of_inchan inchan in + close_in inchan; (* close also outchan, same fd *) + Buffer.contents buf + +let get_iter ?(head_callback = fun _ _ -> ()) callback url = + let (inchan, outchan) = submit_request `GET url in + let buf = String.create tcp_bufsiz in + let (_, status) = Http_parser.parse_response_fst_line inchan in + (match code_of_status status with + | 200 -> () + | code -> raise (Http_error (code, ""))); + let headers = Http_parser.parse_headers inchan in + head_callback status headers; + (try + while true do + match input inchan buf 0 tcp_bufsiz with + | 0 -> raise End_of_file + | bytes when bytes = tcp_bufsiz -> (* buffer full, no need to slice it *) + callback buf + | bytes when bytes < tcp_bufsiz -> (* buffer not full, slice it *) + callback (String.sub buf 0 bytes) + | _ -> (* ( bytes < 0 ) || ( bytes > tcp_bufsiz ) *) + assert false + done + with End_of_file -> ()); + close_in inchan (* close also outchan, same fd *) + +let get ?head_callback url = + let buf = Buffer.create 10240 in + get_iter ?head_callback (Buffer.add_string buf) url; + Buffer.contents buf + diff --git a/DEVEL/ocaml-http/http_user_agent.mli b/DEVEL/ocaml-http/http_user_agent.mli new file mode 100644 index 000000000..79f2d696e --- /dev/null +++ b/DEVEL/ocaml-http/http_user_agent.mli @@ -0,0 +1,53 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002-2005> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation, 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA +*) + +(** Minimal implementation of an HTTP 1.0/1.1 client. Interface is similar to + * Gerd Stoplmann's Http_client module. Implementation is simpler and doesn't + * handle HTTP redirection, proxies, ecc. The only reason for the existence of + * this module is for performances and incremental elaboration of response's + * bodies *) + +open Http_types + +exception Http_error of (int * string) (* code, body *) + + (** @param head_callback optional calllback invoked on response's status and + * headers. If not provided no callback will be invoked + * @param url an HTTP url + * @return HTTP response's body + * @raise Http_error when response code <> 200 *) +val get: + ?head_callback:(status -> (string * string) list -> unit) -> + string -> + string + + (** as above but iter callback function on HTTP response's body instead of + * returning it as a string *) +val get_iter: + ?head_callback:(status -> (string * string) list -> unit) -> + (string -> unit) -> string -> + unit + + (** @param url an HTTP url + * @return HTTP HEAD raw response + * @raise Http_error when response code <> 200 *) +val head: string -> string + diff --git a/DEVEL/ocaml-http/mt/.cvsignore b/DEVEL/ocaml-http/mt/.cvsignore new file mode 100644 index 000000000..977cc04b5 --- /dev/null +++ b/DEVEL/ocaml-http/mt/.cvsignore @@ -0,0 +1,6 @@ +*.cmi +*.cmo +*.cmx +*.cma +*.cmxa +*.mli diff --git a/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml b/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml new file mode 100644 index 000000000..acdef6105 --- /dev/null +++ b/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml @@ -0,0 +1,23 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +let serve callback arg = ignore (Thread.create callback arg) + diff --git a/DEVEL/ocaml-http/non_mt/.cvsignore b/DEVEL/ocaml-http/non_mt/.cvsignore new file mode 100644 index 000000000..977cc04b5 --- /dev/null +++ b/DEVEL/ocaml-http/non_mt/.cvsignore @@ -0,0 +1,6 @@ +*.cmi +*.cmo +*.cmx +*.cma +*.cmxa +*.mli diff --git a/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml b/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml new file mode 100644 index 000000000..9c92d7112 --- /dev/null +++ b/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml @@ -0,0 +1,26 @@ + +(* + OCaml HTTP - do it yourself (fully OCaml) HTTP daemon + + Copyright (C) <2002> Stefano Zacchiroli + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) + +let serve _ _ = + failwith + ("Threaded server not supported by the non threaded version " ^ + "of ocaml-http, please link against http_mt.cm{,x}a") + diff --git a/metadata/.cvsignore b/metadata/.cvsignore new file mode 100644 index 000000000..2cde8a0b2 --- /dev/null +++ b/metadata/.cvsignore @@ -0,0 +1,6 @@ +all_objects.txt +constants_and_variables.txt +fill_db.sql +inductive_types.txt +log +tmp diff --git a/metadata/Makefile b/metadata/Makefile new file mode 100644 index 000000000..1485dfdbf --- /dev/null +++ b/metadata/Makefile @@ -0,0 +1,40 @@ +FILLDB=fill_db.sql +INDUCTIVETYPES=inductive_types.txt +CONSTANTSANDVARIABLES=constants_and_variables.txt +ALLOBJECTS=all_objects.txt +GETTERURL=http://mowgli.cs.unibo.it:58081 +DBCOMM=mysql -pbjIcRpru -u helmadmin mowgli +#DBCOMM=psql -q -U helm mowgli2 + +all: + @echo "try one of:" + @echo " make indexes" + @echo " make drop_tables" + @echo " make create_tables" + @echo " make $(FILLDB)" + @echo " make fill_db" + +$(FILLDB): + rm -f $(FILLDB) + time for i in `cat $(INDUCTIVETYPES)` ; do (cd tmp ; wget -t 1 -O downloaded.xml.gz "$(GETTERURL)/getxml?format=gz&uri=$$i") ; zcat tmp/downloaded.xml.gz > tmp/inductive_type.xml ; extractor/meta_ind $$i "tmp/inductive_type.xml" >> $(FILLDB) ; rm -f tmp/downloaded.xml.gz tmp/inductive_type.xml; done > log 2>&1 + time for i in `cat $(CONSTANTSANDVARIABLES)` ; do (cd tmp ; wget -t 1 -O downloaded.xml.gz "$(GETTERURL)/getxml?format=gz&uri=$$i" ; wget -t 1 -O downloaded_body.xml.gz "$(GETTERURL)/getxml?format=gz&uri=$$i.body"); zcat tmp/downloaded.xml.gz > tmp/type.xml ; zcat tmp/downloaded_body.xml.gz > tmp/body.xml ; extractor/meta $$i "tmp/body.xml" "tmp/type.xml" >> $(FILLDB) ; rm -f tmp/downloaded.xml.gz tmp/downloaded_body.xml.gz tmp/type.xml tmp/body.xml ; done > log 2>&1 + cat sql/fill_inconcl_aux.sql >> $@ + cat sql/fill_no_concl_hyp.sql >> $@ + +indexes: + wget "$(GETTERURL)/getalluris?format=txt" -O - | grep -v "\\.body$$" | grep -v "\\.types$$" | grep -v "\\.proof_tree$$" | sort > $(ALLOBJECTS) + cat $(ALLOBJECTS) | grep "\\.ind$$" > $(INDUCTIVETYPES) + cat $(ALLOBJECTS) | grep -v "\\.ind$$" > $(CONSTANTSANDVARIABLES) + +drop_tables: + #cat sql/drop_mowgli_tables.sql | $(DBCOMM) + cat sql/drop_mowgli_tables.mysql.sql | $(DBCOMM) + +create_tables: + #cat sql/create_mowgli_tables.sql | $(DBCOMM) + cat sql/create_mowgli_tables.mysql.sql | $(DBCOMM) + +fill_db: + cat $(FILLDB) | $(DBCOMM) + +.PHONY: all create_tables drop_tables fill_db indexes $(FILLDB) diff --git a/metadata/README b/metadata/README new file mode 100644 index 000000000..5e83286a2 --- /dev/null +++ b/metadata/README @@ -0,0 +1,11 @@ +To generate the metadata and refill the DB: + +make indexes +make fill_db.sql +make drop_tables +make create_tables +make fill_db +cd dc +make drop_tables +make create_tables +make fill_db diff --git a/metadata/dc/Makefile b/metadata/dc/Makefile new file mode 100644 index 000000000..c9a7c73d6 --- /dev/null +++ b/metadata/dc/Makefile @@ -0,0 +1,32 @@ + +SQL_DB = mowgli +SQL_DIR = sql +SQL_HOST = localhost +SQL_PASSWORD = bjIcRpru +SQL_USER = helmadmin +DC_DIR = /projects/helm/library/dc/ + +SQL_ENGINE = \ + mysql -h $(SQL_HOST) -u $(SQL_USER) --password=$(SQL_PASSWORD) $(SQL_DB) + +all: + @echo "try one of:" + @echo " make connect" + @echo " make create_tables" + @echo " make fill_db" + @echo " make drop_tables" + +connect: + $(SQL_ENGINE) + +create_tables: + $(SQL_ENGINE) < $(SQL_DIR)/create_dc_tables.sql + +fill_db: + find $(DC_DIR) -name "*.xml" -exec ./fill_db.pl {} \; | $(SQL_ENGINE) + +drop_tables: + $(SQL_ENGINE) < $(SQL_DIR)/drop_dc_tables.sql + +.PHONY: all connect create_tables fill_db drop_tables + diff --git a/metadata/dc/fill_db.pl b/metadata/dc/fill_db.pl new file mode 100755 index 000000000..fed21ee5a --- /dev/null +++ b/metadata/dc/fill_db.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w +use strict; + +use XML::Parser; + +my $skipped = 0; +my $open = 0; +my $content = ""; +my $uri = ""; + +sub handle_start($$@) { + my ($expat, $element, @attrs) = @_; + if ($skipped == 1) { + $uri = $attrs[1]; + $uri =~ s/'/''/g; + } + if ($skipped < 2) { $skipped++ ; } + else { + $open++; + $content = ""; + } +} + +sub handle_end($$) { + my ($expat,$element) = @_; + $open--; + if ($open >= 0) { + $content =~ s/'/''/g; + $element =~ s/(\w+):(\w+)/$1$2/; + my $query = "INSERT INTO $element VALUES ('$content','$uri');"; + print $query, "\n"; + } +} + +sub handle_char($$) { + my ($expat,$char) = @_; + if ($open >= 1) { + chomp($char); + $char =~ s/ +/ /g; + $char =~ s/^ //g; + $char =~ s/ $//g; + $content .= $char; + } +} + +my $p = new XML::Parser( + Handlers => + { Start => \&handle_start, + End => \&handle_end, + Char => \&handle_char}); + +$p->parsefile($ARGV[0]); + diff --git a/metadata/dc/sql/create_dc_tables.sql b/metadata/dc/sql/create_dc_tables.sql new file mode 100644 index 000000000..ca53c5b36 --- /dev/null +++ b/metadata/dc/sql/create_dc_tables.sql @@ -0,0 +1,58 @@ + +create table dccreator (value varchar(255), uri varchar(255)); +create table dcdate (value varchar(255), uri varchar(255)); +create table dcdescription (value varchar(255), uri varchar(255)); +create table dcformat (value varchar(255), uri varchar(255)); +create table dcidentifier (value varchar(255), uri varchar(255)); +create table dclanguage (value varchar(255), uri varchar(255)); +create table dcpublisher (value varchar(255), uri varchar(255)); +create table dcqRelationType (value varchar(255), uri varchar(255)); +create table dcrelation (value varchar(255), uri varchar(255)); +create table dcrights (value varchar(255), uri varchar(255)); +create table dcsource (value varchar(255), uri varchar(255)); +create table dcsubject (value varchar(255), uri varchar(255)); +create table dctitle (value varchar(255), uri varchar(255)); +create table hthResourceFormat (value varchar(255), uri varchar(255)); +create table hthcontact (value varchar(255), uri varchar(255)); +create table hthfirstVersion (value varchar(255), uri varchar(255)); +create table hthinstitution (value varchar(255), uri varchar(255)); +create table hthmodified (value varchar(255), uri varchar(255)); + +create index dccreator_index on dccreator (value); +create index dcdate_index on dcdate (value); +create index dcdescription_index on dcdescription (value); +create index dcformat_index on dcformat (value); +create index dcidentifier_index on dcidentifier (value); +create index dclanguage_index on dclanguage (value); +create index dcpublisher_index on dcpublisher (value); +create index dcqRelationType_index on dcqRelationType (value); +create index dcrelation_index on dcrelation (value); +create index dcrights_index on dcrights (value); +create index dcsource_index on dcsource (value); +create index dcsubject_index on dcsubject (value); +create index dctitle_index on dctitle (value); +create index hthResourceFormat_index on hthResourceFormat (value); +create index hthcontact_index on hthcontact (value); +create index hthfirstVersion_index on hthfirstVersion (value); +create index hthinstitution_index on hthinstitution (value); +create index hthmodified_index on hthmodified (value); + +create index dccreator_rev_index on dccreator (uri); +create index dcdate_rev_index on dcdate (uri); +create index dcdescription_rev_index on dcdescription (uri); +create index dcformat_rev_index on dcformat (uri); +create index dcidentifier_rev_index on dcidentifier (uri); +create index dclanguage_rev_index on dclanguage (uri); +create index dcpublisher_rev_index on dcpublisher (uri); +create index dcqRelationType_rev_index on dcqRelationType (uri); +create index dcrelation_rev_index on dcrelation (uri); +create index dcrights_rev_index on dcrights (uri); +create index dcsource_rev_index on dcsource (uri); +create index dcsubject_rev_index on dcsubject (uri); +create index dctitle_rev_index on dctitle (uri); +create index hthResourceFormat_rev_index on hthResourceFormat (uri); +create index hthcontact_rev_index on hthcontact (uri); +create index hthfirstVersion_rev_index on hthfirstVersion (uri); +create index hthinstitution_rev_index on hthinstitution (uri); +create index hthmodified_rev_index on hthmodified (uri); + diff --git a/metadata/dc/sql/drop_dc_tables.sql b/metadata/dc/sql/drop_dc_tables.sql new file mode 100644 index 000000000..d13a2a8ed --- /dev/null +++ b/metadata/dc/sql/drop_dc_tables.sql @@ -0,0 +1,18 @@ +drop table dccreator; +drop table dcdate; +drop table dcdescription; +drop table dcformat; +drop table dcidentifier; +drop table dclanguage; +drop table dcpublisher; +drop table dcqRelationType; +drop table dcrelation; +drop table dcrights; +drop table dcsource; +drop table dcsubject; +drop table dctitle; +drop table hthResourceFormat; +drop table hthcontact; +drop table hthfirstVersion; +drop table hthinstitution; +drop table hthmodified; diff --git a/metadata/extractor/.cvsignore b/metadata/extractor/.cvsignore new file mode 100644 index 000000000..1d5ca6be6 --- /dev/null +++ b/metadata/extractor/.cvsignore @@ -0,0 +1,4 @@ +meta +meta_ind +lex.yy.c +lex.yy_ind.c diff --git a/metadata/extractor/Makefile b/metadata/extractor/Makefile new file mode 100644 index 000000000..4b6f01aa8 --- /dev/null +++ b/metadata/extractor/Makefile @@ -0,0 +1,28 @@ +CC = gcc -Wall + +all: meta meta_ind + +meta: lex.yy.o sthandler.o + $(CC) lex.yy.o sthandler.o -lpq -o meta + +meta_ind: lex.yy_ind.o sthandler.o + $(CC) lex.yy_ind.o sthandler.o -lpq -o meta_ind + +lex.yy.c: meta_lex.l sthandler.h + flex meta_lex.l + +lex.yy_ind.c: meta_lex_ind.l sthandler.h + flex -olex.yy_ind.c meta_lex_ind.l + +sthandler.o: sthandler.c sthandler.h + +lex.yy.o: lex.yy.c sthandler.h + $(CC) -c lex.yy.c + +lex.yy_ind.o: lex.yy_ind.c sthandler.h + $(CC) -c lex.yy_ind.c + +clean: + -rm -f *.o + -rm -f lex.yy.c lex.yy_ind.c + -rm -f meta meta_ind diff --git a/metadata/extractor/README b/metadata/extractor/README new file mode 100644 index 000000000..6c9fe0bcb --- /dev/null +++ b/metadata/extractor/README @@ -0,0 +1,9 @@ +Note: + - LetIn e Variabili con corpo: da pensarci (capita solamente una 30ina + di volte... per ora!) Per il momento ci mettiamo una pezza. + - Variabili: non consideriamo l'occorrenza di una variabile come una + vera occorrenza (perche' puo' essere istanziata). In ogni caso c'e' + l'attributo @params che fornisce questa informazione. + - META e IMPLICIT non trattati + - CAST non considerati ==> di default vado in ricorsione sia sul tipo + che sul corpo diff --git a/metadata/extractor/meta_lex.l b/metadata/extractor/meta_lex.l new file mode 100644 index 000000000..c4c23e847 --- /dev/null +++ b/metadata/extractor/meta_lex.l @@ -0,0 +1,374 @@ + /******************************************************************/ + /* Copyright (C) 2000, HELM Team */ + /* */ + /* This file is part of HELM, an Hypertextual, Electronic */ + /* Library of Mathematics, developed at the Computer Science */ + /* Department, University of Bologna, Italy. */ + /* */ + /* HELM 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. */ + /* */ + /* HELM is distributed in the hope that it will be useful, */ + /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ + /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ + /* GNU General Public License for more details. */ + /* */ + /* You should have received a copy of the GNU General Public */ + /* License along with HELM; if not, write to the Free Software */ + /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */ + /* MA 02111-1307, USA. */ + /* */ + /* For details, see the HELM World-Wide-Web page, */ + /* http://cs.unibo.it/helm/. */ + /******************************************************************/ + + /***************************************************************/ + /* META_LEXAN */ + /* Automatic Metadata Extractor */ + /* First draft 11/12/2001, by Andrea Asperti */ + /* more bugs added by domenico lordi on mon 12/17/2001 */ + /***************************************************************/ + + /***************************************************************/ + /* 1. Inclusion of header files. */ + /***************************************************************/ + +%{ +#include +#include +#include +#include "sthandler.h" +%} + + /***************************************************************/ + /* 2. Constants and Variables Definitions */ + /***************************************************************/ + +%{ +#define NOWHERE 0 +#define CONST 1 +#define MUTIND 2 +#define MUTCONSTRUCT 3 +#define SORT 4 + +#define INBODY 0 +#define MAINHYP 1 +#define INHYP 2 +#define INCONCL 3 +#define MAINCONCL 4 +#define INTYPE 5 +#define NOTFOUND 6 + +#define HERE 0 +#define AFTER 1 + + +int where = NOWHERE; +int found = NOTFOUND; +int position = INBODY; +int first_child = HERE; +int skip = 0; // boolean to skip the insertion of a URI +int no_open_source = 0; +int spine_depth = 0; +int depth = 0; +int tmp_n; +char sep = '"'; +char *xpointer = "#xpointer(1/"; +char *uri; +char *tmp; + +void search(char *uri, int first_child, int position, int depth); +%} + + /***************************************************************/ + /* 3. Regular definitions. */ + /***************************************************************/ + +uri [^"]+ +digits [0-9]+ +value [^"]+ + + /***************************************************************/ + /* 4. Rules. */ + /***************************************************************/ + + +%% + +"]*">"(" "|\n)*""(" "|\n)*"" | +"" { + if (position == INHYP) + { + no_open_source--; + if (no_open_source == 0) + { + position = MAINHYP; + depth++; + first_child = HERE; + } + } + else if (position == MAINHYP) + { + position = INTYPE; + spine_depth++; + depth = 0; + first_child = HERE; + } + /* bug? first_child = HERE; */ + } + + +.|\n { + } + +" \n"); + exit(1); + } + + + /* initialize the symbol table */ + init_symbol_table(); + + // We process the body + if (!stat(argv[2],&buf)) + { + yyin = fopen(argv[2], "r"); + position = INBODY; + yylex(); + fclose(yyin); + } + + // We process the type + yyin = fopen(argv[3], "r"); + position = INTYPE; + first_child = HERE; + no_open_source = 0; + spine_depth = 0; + depth = 0; + yylex(); + fclose(yyin); + print_all(argv[1]); + poss = rindex(argv[1],'/'); + posd = rindex(argv[1],'.'); + name = (char *)malloc((posd - poss) * sizeof(char)); + strncpy(name, poss + 1, posd - poss - 1); + name[posd - poss - 1] = '\0'; + print_name(name,argv[1]); + free(name); + + return 0; +} + + +void search(uri,first_child,position,depth) +char *uri; +int first_child; +int position; +{ + if (position == MAINHYP) + { + if (first_child == HERE) + found = search_bucket(uri,MAINHYP,depth); + else + found = search_bucket(uri,INHYP,0); + } + else if (position == INCONCL) + { + if (first_child == HERE) + found = search_bucket(uri,MAINCONCL,depth); + else + found = search_bucket(uri,INCONCL,0); + } + + else + found = search_bucket(uri,position,depth); + /* + if (found == NOTFOUND) + fprintf(stderr,"here = %d, pos = %d, uri = %s\n", first_child,position, uri); */ +} +/* + (first_child == HERE) + { + if (position == MAINHYP) + found = search_bucket(uri,MAINHYP,depth); + else if (position == INCONCL) + found = search_bucket(uri,MAINCONCL,0); + else if (position == INHYP) + found = search_bucket(uri,INHYP,0); + if (found == NOTFOUND) + printf( "pos = %d, uri = %s\n", MAINCONCL, uri); + } + else if ((position == MAINHYP) && (first_child == AFTER)) + found = search_bucket(uri,INHYP,0); + else found = search_bucket(uri,position,0); + if (found == NOTFOUND) + printf( "pos = %d, uri = %s\n", position, uri); + } */ + +int yywrap() { + return 1; + } + + + + diff --git a/metadata/extractor/meta_lex_ind.l b/metadata/extractor/meta_lex_ind.l new file mode 100644 index 000000000..9f474bf85 --- /dev/null +++ b/metadata/extractor/meta_lex_ind.l @@ -0,0 +1,375 @@ + /******************************************************************/ + /* Copyright (C) 2000, HELM Team */ + /* */ + /* This file is part of HELM, an Hypertextual, Electronic */ + /* Library of Mathematics, developed at the Computer Science */ + /* Department, University of Bologna, Italy. */ + /* */ + /* HELM 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. */ + /* */ + /* HELM is distributed in the hope that it will be useful, */ + /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ + /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ + /* GNU General Public License for more details. */ + /* */ + /* You should have received a copy of the GNU General Public */ + /* License along with HELM; if not, write to the Free Software */ + /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */ + /* MA 02111-1307, USA. */ + /* */ + /* For details, see the HELM World-Wide-Web page, */ + /* http://cs.unibo.it/helm/. */ + /******************************************************************/ + + /***************************************************************/ + /* META_LEXAN */ + /* Automatic Metadata Extractor */ + /* First draft 11/12/2001, by Andrea Asperti */ + /* more bugs added by domenico lordi on mon 12/17/2001 */ + /***************************************************************/ + + /***************************************************************/ + /* 1. Inclusion of header files. */ + /***************************************************************/ + +%{ +#include +#include +#include +#include "sthandler.h" +%} + + /***************************************************************/ + /* 2. Constants and Variables Definitions */ + /***************************************************************/ + +%{ +#define NOWHERE 0 +#define CONST 1 +#define MUTIND 2 +#define MUTCONSTRUCT 3 +#define SORT 4 + +#define INBODY 0 +#define MAINHYP 1 +#define INHYP 2 +#define INCONCL 3 +#define MAINCONCL 4 +#define INTYPE 5 +#define NOTFOUND 6 + +#define HERE 0 +#define AFTER 1 + + +int where = NOWHERE; +int found = NOTFOUND; +int position = INBODY; +int first_child = HERE; +int skip = 0; // boolean to skip the insertion of a URI +int no_open_source =0; +int spine_depth = 0; +int depth = 0; +int tmp_n; +int inductive_type = 0; +int constructor = 0; +int deep_type = 0; +char sep = '"'; +char *xpointer = "#xpointer(1/"; +char *uri; +char *tmp; +char *source_uri; +char *source_uri_prefix; +int waiting_for_name = 0; + +void search(char *uri, int first_child, int position, int depth); +%} + + /***************************************************************/ + /* 3. Regular definitions. */ + /***************************************************************/ + +uri [^"]+ +digits [0-9]+ +value [^"]+ +id [a-zA-Z]([-_'a-zA-Z0-9])* + + /***************************************************************/ + /* 4. Rules. */ + /***************************************************************/ + + +%% + +"" { + print_all(source_uri); + /* print_file(); */ + } + +"" { print_all(source_uri); + /* print_file(); */ + } + +"" | +"" { + if (position == INHYP) + { + no_open_source--; + if (no_open_source == 0) + { + position = MAINHYP; + depth++; + first_child = HERE; + } + } + else if (position == MAINHYP) + { + position = INTYPE; + spine_depth++; + depth = 0; + first_child = HERE; + } + } + + +.|\n { + } + +" \n"); + exit(1); + } + + source_uri = malloc((sizeof('a')*2000)); + source_uri_prefix=argv[1]; + /* fprintf(stderr,"qua"); */ + yyin = fopen(argv[2], "r"); + yylex(); + + return 0; +} + +void search(uri,first_child,position,depth) +char *uri; +int first_child; +int position; +{ + if (position == MAINHYP) + { + if (first_child == HERE) + found = search_bucket(uri,MAINHYP,depth); + else + found = search_bucket(uri,INHYP,0); + } + else if (position == INCONCL) + { + if (first_child == HERE) + found = search_bucket(uri,MAINCONCL,depth); + else + found = search_bucket(uri,INCONCL,0); + } + + else + found = search_bucket(uri,position,depth); + /* if (found == NOTFOUND) + printf( "pos = %d, uri = %s\n", position, uri); */ +} + + +int yywrap() { + return 1; + } + + + + diff --git a/metadata/extractor/sthandler.c b/metadata/extractor/sthandler.c new file mode 100644 index 000000000..87e0d49c7 --- /dev/null +++ b/metadata/extractor/sthandler.c @@ -0,0 +1,475 @@ +/*********************************************************************/ +/* Copyright (C) 2000, HELM Team */ +/* */ +/* This file is part of HELM, an Hypertextual, Electronic */ +/* Library of Mathematics, developed at the Computer Science */ +/* Department, University of Bologna, Italy. */ +/* */ +/* HELM 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. */ +/* */ +/* HELM is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with HELM; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */ +/* MA 02111-1307, USA. */ +/* */ +/* For details, see the HELM World-Wide-Web page, */ +/* http://cs.unibo.it/helm/. */ + /*********************************************************************/ + +/****************************************************************/ +/* STHANDLER.C */ +/****************************************************************/ +/* This module supplies routines for symbol table handling. */ +/* - init_symbol_table(): it initializes the symbol table */ +/* to void. */ +/* - search_bucket(): it searches the symbol table for the */ +/* bucket containing a given identifier, and */ +/* inserts it if it is not present; */ +/****************************************************************/ +/* First draft 11/12/2001, by Andrea Asperti */ +/****************************************************************/ + +/****************************************************************/ +/* 1. Inclusion of header files. */ +/****************************************************************/ + +#include +#include +#include + +/****************************************************************/ +/* 2. Declarations */ +/****************************************************************/ + + +#define DICTSIZE 211 +#define HASH1 4 +#define HASH2 0xf0000000 +#define HASH3 28 +#define EOS '\0' + +#define INBODY 0 +#define MAINHYP 1 +#define INHYP 2 +#define INCONCL 3 +#define MAINCONCL 4 +#define INTYPE 5 +#define NOTFOUND 6 + +/****************************************************************/ +/* 3. Types. */ +/****************************************************************/ + +struct int_list { + int val; + struct int_list *next; + }; + +struct st_bucket { + char *id; + /* identifier */ + int main_depth; + struct int_list *depths; + struct st_bucket *next_st_bucket; + /* next bucket in the list */ + struct st_bucket *all_next; + /* all buckets in symbol + table are linked together */ + int pos[5]; + + }; + +struct st_bucket *dictionary[DICTSIZE]; + /* pointers to bucket lists */ + +/****************************************************************/ +/* 4. Local functions. */ +/****************************************************************/ +struct int_list *add(struct int_list *,int); +void allocate_bucket(struct st_bucket **st, char *id, int where); +void print_mainhyp(char *about, char *uri,struct int_list *l); +void print_mainconcl(char *about, char *uri, int depth); +void move_bucket(struct st_bucket *st, int dict_index); +void print_one(char *about, char *uri, int pos); +int hash_pjw(char *id); + +/* This function is copied from the file fe-exec.c of PostgreSQL. */ +/* Copyright (c) 1996-2003, PostgreSQL Global Development Group */ +/* Copyright (c) 1994, Regents of the University of California */ +size_t +PQescapeString(char *to, const char *from, size_t length) +{ + const char *source = from; + char *target = to; + size_t remaining = length; + + while (remaining > 0 && *source != '\0') + { + switch (*source) + { + case '\\': + *target++ = '\\'; + *target++ = '\\'; + break; + + case '\'': + *target++ = '\''; + *target++ = '\''; + break; + + default: + *target++ = *source; + break; + } + source++; + remaining--; + } + + /* Write the terminating NUL character. */ + *target = '\0'; + + return target - to; +} + + +/****************************************************************/ +/* 5. Definitions of functions to be exported. */ +/****************************************************************/ + +struct st_bucket *all; + + /* The following function initializes the symbol table to NULL */ +void init_symbol_table() +{ + int i; + + /* initialize the dictionary */ + for (i = 0; i < DICTSIZE; i++) + dictionary[i] = NULL; + all = NULL; +} + + /* The following function searches the symbol table for an identifier */ + /* and inserts it if it is not present. */ + /* The bucket associated with the given identifier */ + /* becomes the first one in its list. */ + +int search_bucket(id, where, depth) + char *id; + /* identifier */ + int where; + int depth; +{ + int dict_index; + /* value returned by the */ + /* hash function */ + struct st_bucket + *prev, + *curr; + + struct st_bucket *st; + + /* apply the hash function */ + dict_index = hash_pjw(id); + /* fprintf(stderr,"%d\n", dict_index); */ + + /* scan the bucket list indicated by the hash function */ + prev = curr = dictionary[dict_index]; + while ((curr != NULL) && (strcmp(id, curr->id))) + { + prev = curr; + curr = curr->next_st_bucket; + } + if (curr == NULL) + /* the identifier is not in the list */ + { + allocate_bucket(&st,id,where); + if (where == MAINCONCL) + st->main_depth = depth; + else if (where == MAINHYP) + st->depths = add(st->depths,depth); + move_bucket(st,dict_index); + return NOTFOUND; + } + else + /* + printf("uno=%s\n", id); + printf("st=%s\n", curr->id); fflush(stdout) */ + + /* the identifier is already in the list */ + { + /* st = curr; */ + curr->pos[where] = 1; + if (where >= 1) + curr->pos[INBODY] = 0; /* it will never be set again to 1 */ + if (where == MAINHYP) + curr->depths=add(curr->depths,depth); + else if (where == MAINCONCL) + curr->main_depth = depth; + if (prev != curr) + /* the identifier is not in the first position */ + { + prev->next_st_bucket = curr->next_st_bucket; + move_bucket(curr,dict_index); + }; + return where; + } +} + +void print_all(about,conn) + char *about; +{ + + int i; + struct st_bucket *curr; + curr = all; + while (curr != NULL) + { + for (i = 0; i < 5; ++i) + if ((curr->pos[i]) == 1) + { + if (i == MAINHYP) + print_mainhyp(about,curr->id,curr->depths); + else if (i == MAINCONCL) + print_mainconcl(about,curr->id,curr->main_depth); + else + print_one(about,curr->id,i); + } + curr = curr->all_next; + } +} + +void print_name(char *name, char *uri) +{ + size_t len = strlen(uri) + 1; + char *quri = malloc (sizeof(char) * len * 2); + PQescapeString(quri,uri,len); + len = strlen(name) + 1; + char *qname = malloc (sizeof(char) * len * 2); + PQescapeString(qname,name,len); + printf("INSERT INTO objectName VALUES ('%s', '%s');\n",quri,qname); + free(quri); + free(qname); +} + +/****************************************************************/ +/* 5. Definitions of functions local to the module. */ +/****************************************************************/ + +struct int_list *add(l,m) + struct int_list *l; + int m; +{ + struct int_list *curr; + /* scan the list looking for m */ + curr = l; + while ((curr != NULL) && (m != (curr->val))) + curr = curr->next; + if (curr == NULL) + /* m is not in the list */ + { + curr = (struct int_list *)malloc(sizeof(struct int_list)); + curr->val = m; + curr->next = l; + return curr; + } + else + return l; + +} + +void print_mainhyp(about,uri,l) + char *about; + char *uri; + struct int_list *l; +{ + struct int_list *curr; + curr = l; + if (!strcmp(uri,"Rel")) + { + /* scan the list */ + while (curr != NULL) + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + PQescapeString(qabout,about,len); + printf("INSERT INTO refRel VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d);\n",qabout,curr->val); + free(qabout); + curr = curr->next; + } + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + /* scan the list */ + while (curr != NULL) + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + PQescapeString(qabout,about,len); + printf("INSERT INTO refSort VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d, '%s');\n",qabout,curr->val,uri); + free(qabout); + curr = curr->next; + } + } + else + { + /* scan the list */ + while (curr != NULL) + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + char *quri; + PQescapeString(qabout,about,len); + len = strlen(uri) + 1; + quri = malloc (sizeof(char) * len * 2); + PQescapeString(quri,uri,len); + printf("INSERT INTO refObj VALUES ('%s', '%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d);\n",qabout,quri,curr->val); + free(qabout); + free(quri); + curr = curr->next; + } + } +} + +void print_mainconcl(about,uri,depth) + char *about; + char *uri; + int depth; + +{ + /* fprintf(stderr,"about = %s\n",about); */ + if (!strcmp(uri,"Rel")) + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + PQescapeString(qabout,about,len); + printf("INSERT INTO refRel VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d);\n",qabout,depth); + free(qabout); + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + PQescapeString(qabout,about,len); + printf("INSERT INTO refSort VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d, '%s');\n",qabout,depth,uri); + free(qabout); + } + else + { + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + char *quri; + PQescapeString(qabout,about,len); + len = strlen(uri) + 1; + quri = malloc (sizeof(char) * len * 2); + PQescapeString(quri,uri,len); + printf("INSERT INTO refObj VALUES ('%s', '%s','http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d);\n",qabout,quri,depth); + free(qabout); + free(quri); + } +} + +// dome: cambiata per usare il modello con position +void print_one(about,uri,pos) + char *about, + *uri; + int pos; +{ + char *position = (char *)malloc((sizeof('a')*20)); + size_t len = strlen(about) + 1; + char *qabout = malloc (sizeof(char) * len * 2); + char *quri; + PQescapeString(qabout,about,len); + len = strlen(uri) + 1; + quri = malloc (sizeof(char) * len * 2); + PQescapeString(quri,uri,len); + if (pos == INBODY) + position="InBody"; + else if (pos == MAINHYP) + position="MainHypothesis"; /* This should never happen */ + else if (pos == INHYP) + position="InHypothesis"; + else if (pos == INCONCL) + position="InConclusion"; + else if (pos == MAINCONCL) + position="MainConclusion"; /* This should never happen */ + printf("INSERT INTO refObj VALUES ('%s', '%s', \ + 'http://www.cs.unibo.it/helm/schemas/schema-helm#%s', NULL);\n",qabout,quri,position); + free(qabout); + free(quri); +} + + /* The following function allocates a bucket for an identifier. */ +void allocate_bucket(st, id, where) + struct st_bucket + **st; + /* pointer to the bucket to be */ + /* allocated */ + char *id; + /* identifier */ + int where; +{ + int i; + + *st = (struct st_bucket *)malloc(sizeof(struct st_bucket)); + (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1)); + strcpy((*st)->id,id); + (*st)->main_depth = 0; + (*st)->depths = NULL; + (*st)->next_st_bucket = NULL; + (*st)->all_next = all; + all = *st; + for (i = 0; i < 5; ++i) + (*st)->pos[i] = 0; + (*st)->pos[where] = 1; +} + + /* The following function moves a bucket to the head of the */ + /* list in which it lies. */ +void move_bucket(st, dict_index) + struct st_bucket + *st; + /* pointer to the bucket to */ + /* be moved */ + int dict_index; + /* index corresponding to */ + /* the list in which the */ + /* bucket lies */ +{ + st->next_st_bucket = dictionary[dict_index]; + dictionary[dict_index] = st; +} + + /* The following function implements Weinberger's hash function. */ +int +hash_pjw(id) + char *id; + /* identifier to be hashed */ +{ + unsigned h, + g; + + for (h = 0; *id != EOS; id++) + { + h = (h << HASH1) + (*id); + if ((g = h) & HASH2) + h = h ^ (g >> HASH3) ^ g; + } + return(h % DICTSIZE); +} + + + + + + diff --git a/metadata/extractor/sthandler.h b/metadata/extractor/sthandler.h new file mode 100644 index 000000000..f4e8284d5 --- /dev/null +++ b/metadata/extractor/sthandler.h @@ -0,0 +1,9 @@ +/****************************************************************/ +/* STHANDLER.H */ +/****************************************************************/ + + +extern void init_symbol_table(); +extern void print_all(char *); +extern void print_name(char *, char *); +extern int search_bucket(char *, int, int); diff --git a/metadata/extractor/sthandler_ind.c b/metadata/extractor/sthandler_ind.c new file mode 100644 index 000000000..ee035ef2a --- /dev/null +++ b/metadata/extractor/sthandler_ind.c @@ -0,0 +1,424 @@ +/*********************************************************************/ +/* Copyright (C) 2000, HELM Team */ +/* */ +/* This file is part of HELM, an Hypertextual, Electronic */ +/* Library of Mathematics, developed at the Computer Science */ +/* Department, University of Bologna, Italy. */ +/* */ +/* HELM 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. */ +/* */ +/* HELM is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with HELM; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */ +/* MA 02111-1307, USA. */ +/* */ +/* For details, see the HELM World-Wide-Web page, */ +/* http://cs.unibo.it/helm/. */ + /*********************************************************************/ + +/****************************************************************/ +/* STHANDLER.C */ +/****************************************************************/ +/* This module supplies routines for symbol table handling. */ +/* - init_symbol_table(): it initializes the symbol table */ +/* to void. */ +/* - search_bucket(): it searches the symbol table for the */ +/* bucket containing a given identifier, and */ +/* inserts it if it is not present; */ +/****************************************************************/ +/* First draft 11/12/2001, by Andrea Asperti */ +/****************************************************************/ + +/****************************************************************/ +/* 1. Inclusion of header files. */ +/****************************************************************/ + +#include +#include + +/****************************************************************/ +/* 2. Declarations */ +/****************************************************************/ + + +#define DICTSIZE 211 +#define HASH1 4 +#define HASH2 0xf0000000 +#define HASH3 24 +#define EOS '\0' + +#define INBODY 0 +#define MAINHYP 1 +#define INHYP 2 +#define INCONCL 3 +#define MAINCONCL 4 +#define INTYPE 5 +#define NOTFOUND 6 + +/****************************************************************/ +/* 3. Types. */ +/****************************************************************/ + +struct int_list { + int val; + struct int_list *next; + }; + +struct st_bucket { + char *id; + /* identifier */ + int main_depth; + struct int_list *depths; + struct st_bucket *next_st_bucket; + /* next bucket in the list */ + struct st_bucket *all_next; + /* all buckets in symbol + table are linked together */ + int pos[5]; + + }; + +struct st_bucket *dictionary[DICTSIZE]; + /* pointers to bucket lists */ + +/****************************************************************/ +/* 4. Local functions. */ +/****************************************************************/ +struct int_list *add(struct int_list *,int); +int hash_pjw(char *id); + +/****************************************************************/ +/* 5. Definitions of functions to be exported. */ +/****************************************************************/ + +struct st_bucket *all; + + /* The following function initializes the symbol table to NULL */ +void init_symbol_table() +{ + struct st_bucket *st; + int i; + + /* initialize the dictionary */ + for (i = 0; i < DICTSIZE; i++) + dictionary[i] = NULL; + all = NULL; +} + + /* The following function searches the symbol table for an identifier */ + /* and inserts it if it is not present. + /* The bucket associated with the given identifier */ + /* becomes the first one in its list. */ + +search_bucket(id, where, depth) + char *id; + /* identifier */ + int where; + int depth; +{ + int dict_index; + /* value returned by the */ + /* hash function */ + struct st_bucket + *prev, + *curr; + + struct st_bucket *st; + + /* apply the hash function */ + dict_index = hash_pjw(id); + /* fprintf(stderr,"%d\n", dict_index); fflush(stdout); */ + + /* scan the bucket list indicated by the hash function */ + prev = curr = dictionary[dict_index]; + while ((curr != NULL) && (strcmp(id, curr->id))) + { + prev = curr; + curr = curr->next_st_bucket; + } + if (curr == NULL) + /* the identifier is not in the list */ + { + allocate_bucket(&st,id,where); + if (where == MAINCONCL) + st->main_depth = depth; + else if (where == MAINHYP) + st->depths = add(st->depths,depth); + move_bucket(st,dict_index); + return NOTFOUND; + } + else + /* + fprintf(stderr,"uno=%s\n", id); + fprintf(stderr,"st=%s\n", curr->id); fflush(stdout) */ + + /* the identifier is already in the list */ + { + /* st = curr; */ + curr->pos[where] = 1; + if (where >= 1) + curr->pos[INBODY] = 0; /* it will never be set again to 1 */ + if (where == MAINHYP) + curr->depths=add(curr->depths,depth); + else if (where == MAINCONCL) + curr->main_depth = depth; + if (prev != curr) + /* the identifier is not in the first position */ + { + prev->next_st_bucket = curr->next_st_bucket; + move_bucket(curr, + dict_index); + }; + return where; + } +} + +print_all(about,out,outrel,outsort) + char *about; + FILE *out, + *outrel, + *outsort; +{ + + int i; + struct st_bucket *curr; + curr = all; + while (curr != NULL) + { + for (i = 0; i < 5; ++i) + if ((curr->pos[i]) == 1) + { + if (i == MAINHYP) + print_mainhyp(about,out,outrel,outsort,curr->id,curr->depths); + else if (i == MAINCONCL) + print_mainconcl(about,out,outrel,outsort,curr->id,curr->main_depth); + else + print_one(out,curr->id,i); + } + curr = curr->all_next; + } +} + + +/****************************************************************/ +/* 5. Definitions of functions local to the module. */ +/****************************************************************/ + +struct int_list *add(l,m) + struct int_list *l; + int m; +{ + struct int_list *curr; + /* scan the list looking for m */ + curr = l; + while ((curr != NULL) && (m != (curr->val))) + curr = curr->next; + if (curr == NULL) + /* m is not in the list */ + { + curr = (struct int_list *)malloc(sizeof(struct int_list)); + curr->val = m; + curr->next = l; + return curr; + } + else + return l; + +} + +print_mainhyp(about,out,outrel,outsort,uri,l) + char *about; + FILE *out, + *outrel, + *outsort; + char *uri; + struct int_list *l; +{ + struct int_list *curr; + curr = l; + if (!strcmp(uri,"Rel")) + { + /* scan the list */ + while (curr != NULL) + { + fprintf(outrel,"\t\n"); + fprintf(outrel,"\t\t"); + fprintf(outrel,"\n\t\t\t\t"); + fprintf(outrel,"\n\t\t\t\t%d",curr->val); + fprintf(outrel,"\n\t\t\n"); + fprintf(outrel,"\t\n"); + curr = curr->next; + } + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + /* scan the list */ + while (curr != NULL) + { + fprintf(outsort,"\t\n"); + fprintf(outsort,"\t\t"); + fprintf(outsort,"\n\t\t\t\t"); + fprintf(outsort,"\n\t\t\t\t",uri); + fprintf(outsort,"\n\t\t\t\t%d",curr->val); + fprintf(outsort,"\n\t\t\n"); + fprintf(outsort,"\t\n"); + curr = curr->next; + } + } + else + { + /* scan the list */ + while (curr != NULL) + { + fprintf(out,"\t\t"); + fprintf(out,"\n\t\t\t\t"); + fprintf(out,"\n\t\t\t\t%d",curr->val); + fprintf(out,"\n\t\t\t\t",uri); + fprintf(out,"\n\t\t\n"); + curr = curr->next; + } + } +} + +print_mainconcl(about,out,outrel,outsort,uri,depth) + char *about; + FILE *out, + *outrel, + *outsort; + char *uri; + int depth; + +{ + if (!strcmp(uri,"Rel")) + { + fprintf(outrel,"\t\n"); + fprintf(outrel,"\t\t"); + fprintf(outrel,"\n\t\t\t\t"); + fprintf(outrel,"\n\t\t\t\t%d",depth); + fprintf(outrel,"\n\t\t\n"); + fprintf(outrel,"\t\n"); + } + else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || + (!strcmp(uri,"Set"))) + { + fprintf(outsort,"\t\n"); + fprintf(outsort,"\t\t"); + fprintf(outsort,"\n\t\t\t\t"); + fprintf(outsort,"\n\t\t\t\t",uri); + fprintf(outsort,"\n\t\t\t\t%d",depth); + fprintf(outsort,"\n\t\t\n"); + fprintf(outsort,"\t\n"); + } + else + { + fprintf(out,"\t\t"); + fprintf(out,"\n\t\t\t\t"); + fprintf(out,"\n\t\t\t\t%d",depth); + fprintf(out,"\n\t\t\t\t",uri); + fprintf(out,"\n\t\t\n"); + } +} + +// dome: cambiata per usare il modello con position +print_one(out,uri,pos) + FILE *out; + char *uri; + int pos; +{ + fprintf(out,"\t\t"); + fprintf(out,"\n\t\t\t\t\n\t\t\t\t\n\t\t\n", uri); + +} + + /* The following function allocates a bucket for an identifier. */ +allocate_bucket(st, id, where) + struct st_bucket + **st; + /* pointer to the bucket to be */ + /* allocated */ + char *id; + /* identifier */ + int where; +{ + int i; + + *st = (struct st_bucket *)malloc(sizeof(struct st_bucket)); + (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1)); + strcpy((*st)->id,id); + (*st)->main_depth = 0; + (*st)->depths = NULL; + (*st)->next_st_bucket = NULL; + (*st)->all_next = all; + all = *st; + for (i = 0; i < 5; ++i) + (*st)->pos[i] = 0; + (*st)->pos[where] = 1; +} + + /* The following function moves a bucket to the head of the */ + /* list in which it lies. */ +move_bucket(st, dict_index) + struct st_bucket + *st; + /* pointer to the bucket to */ + /* be moved */ + int dict_index; + /* index corresponding to */ + /* the list in which the */ + /* bucket lies */ +{ + st->next_st_bucket = dictionary[dict_index]; + dictionary[dict_index] = st; +} + + /* The following function implements Weinberger's hash function. */ +int +hash_pjw(id) + char *id; + /* identifier to be hashed */ +{ + unsigned h, + g; + + for (h = 0; *id != EOS; id++) + { + h = (h << HASH1) + (*id); + if (g = h & HASH2) + h = h ^ (g >> HASH3) ^ g; + } + return(h % DICTSIZE); +} + + + + + + diff --git a/metadata/extractor/sthandler_ind.h b/metadata/extractor/sthandler_ind.h new file mode 100644 index 000000000..2536b0f60 --- /dev/null +++ b/metadata/extractor/sthandler_ind.h @@ -0,0 +1,8 @@ +/****************************************************************/ +/* STHANDLER.H */ +/****************************************************************/ + + +extern void init_symbol_table(); +extern void print_all(char *, FILE *, FILE *, FILE *); +extern int search_bucket(char *, int, int); diff --git a/metadata/sql/create_mowgli_tables.mysql.sql b/metadata/sql/create_mowgli_tables.mysql.sql new file mode 100644 index 000000000..228e787b8 --- /dev/null +++ b/metadata/sql/create_mowgli_tables.mysql.sql @@ -0,0 +1,61 @@ + +CREATE TABLE refObj ( + source varchar(255) binary not null, + h_occurrence varchar(255) binary not null, + h_position varchar(255) binary not null, + h_depth integer +); +CREATE TABLE refSort ( + source varchar(255) binary not null, + h_position varchar(255) binary not null, + h_depth integer not null, + h_sort varchar(255) binary not null +); +CREATE TABLE refRel ( + source varchar(255) binary not null, + h_position varchar(255) binary not null, + h_depth integer not null +); +CREATE TABLE objectName ( + source varchar(255) binary not null, + value varchar(255) binary not null +); +CREATE TABLE no_inconcl_aux ( + source varchar(255) binary unique not null, + no smallint(6) not null +); +CREATE TABLE no_concl_hyp ( + source varchar(255) binary unique not null, + no smallint(6) not null +); +CREATE TABLE no_hyp ( + source varchar(255) binary unique not null, + no smallint(6) not null +); +CREATE TABLE hits ( + source varchar(255) binary not null, + no integer not null +); +CREATE TABLE count ( + source varchar(255) binary unique not null, + conclusion smallint(6) not null, + hypothesis smallint(6) not null, + statement smallint(6) not null +); + +CREATE INDEX refObj_source ON refObj (source); +CREATE INDEX refObj_target ON refObj (h_occurrence); +CREATE INDEX refObj_position ON refObj (h_position); +CREATE INDEX refSort_source ON refSort (source); +CREATE INDEX objectName_value ON objectName (value); +CREATE INDEX no_inconcl_aux_source ON no_inconcl_aux (source); +CREATE INDEX no_inconcl_aux_no ON no_inconcl_aux (no); +CREATE INDEX no_concl_hyp_source ON no_concl_hyp (source); +CREATE INDEX no_concl_hyp_no ON no_concl_hyp (no); +CREATE INDEX no_hyp_no ON no_hyp (no); +CREATE INDEX no_hyp_source ON no_hyp (source); +CREATE INDEX owners_owner ON owners (owner); +CREATE INDEX owners_source ON owners (source); +CREATE INDEX hits_source ON hits (source); +CREATE INDEX hits_no ON hits (source); + diff --git a/metadata/sql/create_mowgli_tables.sql b/metadata/sql/create_mowgli_tables.sql new file mode 100644 index 000000000..2719f43a9 --- /dev/null +++ b/metadata/sql/create_mowgli_tables.sql @@ -0,0 +1,29 @@ + +CREATE TABLE refObj ( + source varchar(255), + h_occurrence varchar(255), + h_position varchar(255), + h_depth integer +); +CREATE TABLE refSort ( + source varchar(255), + h_position varchar(255), + h_depth integer, + h_sort varchar(255) +); +CREATE TABLE refRel ( + source varchar(255), + h_position varchar(255), + h_depth integer +); +CREATE TABLE objectName ( + source varchar(255), + value varchar(255) +); + +CREATE INDEX refObj_source ON refObj (source); +CREATE INDEX refObj_target ON refObj (h_occurrence); +CREATE INDEX refObj_position ON refObj (h_position); +CREATE INDEX refSort_source ON refSort (source); +CREATE INDEX objectName_value ON objectName (value); + diff --git a/metadata/sql/drop_mowgli_tables.mysql.sql b/metadata/sql/drop_mowgli_tables.mysql.sql new file mode 100644 index 000000000..2cc87e5fd --- /dev/null +++ b/metadata/sql/drop_mowgli_tables.mysql.sql @@ -0,0 +1,9 @@ +DROP TABLE refObj; +DROP TABLE refSort; +DROP TABLE refRel; +DROP TABLE objectName; +DROP TABLE no_inconcl_aux; +DROP TABLE no_concl_hyp; +DROP TABLE no_hyp; +DROP TABLE owners; +DROP TABLE count; diff --git a/metadata/sql/drop_mowgli_tables.sql b/metadata/sql/drop_mowgli_tables.sql new file mode 100644 index 000000000..070183db1 --- /dev/null +++ b/metadata/sql/drop_mowgli_tables.sql @@ -0,0 +1,6 @@ +DROP TABLE refObj; +DROP TABLE refSort; +DROP TABLE refRel; +DROP TABLE objectName; +DROP TABLE no_inconcl_aux; +DROP TABLE no_concl_hyp; diff --git a/metadata/sql/fill_all_derived.sql b/metadata/sql/fill_all_derived.sql new file mode 100644 index 000000000..708015b9a --- /dev/null +++ b/metadata/sql/fill_all_derived.sql @@ -0,0 +1,64 @@ +CREATE TABLE no_inconcl_aux_tmp ( + source varchar(255) binary unique not null, + no smallint(6) not null +); +CREATE TABLE no_concl_hyp_tmp ( + source varchar(255) binary unique not null, + no smallint(6) not null +); +CREATE TABLE no_hyp_tmp ( + source varchar(255) binary unique not null, + no smallint(6) not null +); + +INSERT INTO no_inconcl_aux_tmp +SELECT source, COUNT(h_occurrence) +FROM refObj +WHERE + h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion' + OR h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion' +GROUP BY source; + +INSERT IGNORE INTO no_inconcl_aux_tmp +SELECT source, 0 +FROM refObj +GROUP BY source; + +INSERT INTO no_concl_hyp_tmp +SELECT source, COUNT(DISTINCT h_occurrence) +FROM refObj +WHERE NOT (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InBody") +GROUP BY source; + +INSERT IGNORE INTO no_concl_hyp_tmp +SELECT source, 0 +FROM refObj +GROUP BY source; + +INSERT INTO no_hyp_tmp +SELECT source, COUNT(DISTINCT h_occurrence) +FROM refObj +WHERE (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis" + OR h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis") +GROUP BY source; + +INSERT IGNORE INTO no_hyp_tmp +SELECT source, 0 +FROM refObj +GROUP BY source; + +INSERT INTO count +SELECT no_hyp_tmp.source, + no_inconcl_aux_tmp.no, + no_hyp_tmp.no, + no_concl_hyp_tmp.no +FROM no_hyp_tmp, no_concl_hyp_tmp, no_inconcl_aux_tmp +WHERE no_hyp_tmp.source = no_concl_hyp_tmp.source AND + no_hyp_tmp.source = no_inconcl_aux_tmp.source; + +DROP TABLE no_hyp_tmp; +DROP TABLE no_inconcl_aux_tmp; +DROP TABLE no_concl_hyp_tmp; + + + diff --git a/metadata/sql/fill_inconcl_aux.sql b/metadata/sql/fill_inconcl_aux.sql new file mode 100644 index 000000000..50146e0fd --- /dev/null +++ b/metadata/sql/fill_inconcl_aux.sql @@ -0,0 +1,10 @@ + +-- table mapping sources to number of distinct constants occurring in conclusion +INSERT INTO no_inconcl_aux +SELECT source, COUNT(h_occurrence) +FROM refObj +WHERE + h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion' + OR h_position='http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion' +GROUP BY source; + diff --git a/metadata/sql/fill_no_concl_hyp.sql b/metadata/sql/fill_no_concl_hyp.sql new file mode 100644 index 000000000..3c82358a2 --- /dev/null +++ b/metadata/sql/fill_no_concl_hyp.sql @@ -0,0 +1,9 @@ + +-- table mapping sources to number of distinct constants occurring everywhere +-- except body +INSERT INTO no_concl_hyp +SELECT source, COUNT(DISTINCT h_occurrence) +FROM refObj +WHERE NOT (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InBody") +GROUP BY source; + diff --git a/metadata/sql/fill_no_hyp.sql b/metadata/sql/fill_no_hyp.sql new file mode 100644 index 000000000..b920e1ca8 --- /dev/null +++ b/metadata/sql/fill_no_hyp.sql @@ -0,0 +1,15 @@ + +-- table mapping sources to number of distinct constants occurring in hypothesis +INSERT INTO no_hyp +SELECT source, COUNT(DISTINCT h_occurrence) +FROM refObj +WHERE (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis" + OR h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis") +GROUP BY source; + +INSERT IGNORE INTO no_hyp +SELECT source, 0 +FROM refObj +WHERE NOT (h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis" + OR h_position="http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis") +GROUP BY source; diff --git a/metadata/sql/rating.sql b/metadata/sql/rating.sql new file mode 100644 index 000000000..b34a9fd08 --- /dev/null +++ b/metadata/sql/rating.sql @@ -0,0 +1,6 @@ + +INSERT INTO hits +SELECT h_occurrence, COUNT(source) +FROM refObj +GROUP BY h_occurrence; + -- 2.39.2