]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/gdome_xslt/ocaml/gdome_xslt/ml_gdome_xslt.c
ocaml 3.09 transition
[helm.git] / helm / DEVEL / gdome_xslt / ocaml / gdome_xslt / ml_gdome_xslt.c
index e9af428a3bcb02fc5cee35825382f28feaee11d0..225698a7900ef6f43617fcd96f3727490792c09f 100644 (file)
@@ -4,7 +4,9 @@
  * 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 <sacerdot@cs.unibo.it>
+ * Copyright (C) 2002:
+ *     Claudio Sacerdoti Coen  <sacerdot@cs.unibo.it>
+ *     Stefano Zacchiroli      <zack@cs.unibo.it>
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,7 +22,7 @@
  * 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@cs.unibo.it>
+ * For more information, please send an email to {sacerdot,zack}@cs.unibo.it
  */
 
 #include <assert.h>
 #include <caml/memory.h>
 #include <caml/custom.h>
 #include <caml/callback.h>
+#include <caml/mlvalues.h>
 
 #include <libxslt/xsltconfig.h>
 #include <libxslt/imports.h>
 
+#include "ocaml-io.h"
 #include "mlgdomevalue.h"
 #include "gdome_xslt.h"
 
@@ -112,9 +116,11 @@ value ml_applyStylesheet(value source, value style, value params)
       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;
@@ -124,3 +130,57 @@ value ml_applyStylesheet(value source, value style, value params)
    }
    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);
+}
+