Commit be686d9a authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Update configure and Makefile do detect netcgi2 package instead of netcgi1.

Use Netcgi 2 in dtd2cduce.
parent e661d988
......@@ -211,7 +211,7 @@ ifeq ($(PXP),true)
PACKAGES += $(PXP_PACK)
ifeq ($(CGI),true)
OBJECTS += runtime/cduce_pxp.cmo
PACKAGES += netcgi1
PACKAGES += netcgi2
ALL_TARGET += dtd2cduce
INSTALL_BINARIES += dtd2cduce
endif
......@@ -267,7 +267,7 @@ cduce_lib.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
dtd2cduce: tools/dtd2cduce.ml
@echo "Build $@"
$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi1" -linkpkg $^
$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
.PHONY: compute_depend
compute_depend: $(DEPEND_OCAMLDEP)
......
......@@ -211,7 +211,7 @@ let pxp = check_feature "pxp" (check_pkg "pxp")
let expat = check_feature "expat" (check_pkg "expat")
let curl = check_feature "curl" (check_pkg "curl")
let netclient = check_feature "netclient" (check_pkg "netclient")
let cgi = check_feature "cgi" (check_pkg "netcgi1")
let cgi = check_feature "cgi" (check_pkg "netcgi2")
let pxp_wlex = check_feature "pxp_wlex" (check_pkg "pxp-wlex-utf8")
let prefix = dir "prefix"
let bindir = dir ~def:(prefix^"/bin") "bindir"
......
......@@ -2,7 +2,7 @@ open Netcgi
exception Timeout
(* TODO:
(* TODO:
- clever factorizations of content model and attribute specifs
(e.g. type XHTML_inlien = [ ( Char | ... ) ])
- better pretty-printing
......@@ -20,11 +20,11 @@ let import_dtd ppf name src =
| Optional re -> Format.fprintf ppf "%a?" regexp re
| Repeated re -> Format.fprintf ppf "%a*" regexp re
| Repeated1 re -> Format.fprintf ppf "%a+" regexp re
| Seq (re1 :: res) ->
| Seq (re1 :: res) ->
Format.fprintf ppf "(@[%a" regexp re1;
List.iter (fun re -> Format.fprintf ppf "@ %a" regexp re) res;
Format.fprintf ppf "@])"
| Alt (re1 :: res) ->
| Alt (re1 :: res) ->
Format.fprintf ppf "(@[%a" regexp re1;
List.iter (fun re -> Format.fprintf ppf "@ | %a" regexp re) res;
Format.fprintf ppf "@])"
......@@ -34,32 +34,32 @@ let import_dtd ppf name src =
let content ppf = function
| Unspecified | Any -> Format.fprintf ppf "Any*"
| Empty -> Format.fprintf ppf ""
| Mixed l ->
(try
| Mixed l ->
(try
Hashtbl.find mixed_table l;
Format.fprintf ppf "MIXED:CACHED!"; raise Not_found
with Not_found ->
(* Hashtbl.add mixed_table l (); *)
let l = List.map
(function
let l = List.map
(function
| MPCDATA -> "Char"
| MChild s -> name s) l in
Format.fprintf ppf "( %s )*" (String.concat " | " l))
| Regexp r ->
(try
| Regexp r ->
(try
Hashtbl.find regexp_table r;
Format.fprintf ppf "REGEXP:CACHED!"; raise Not_found
with Not_found ->
(* Hashtbl.add regexp_table r (); *)
regexp ppf r
)
in
in
let att_type ppf = function
| A_enum l ->
| A_enum l ->
Format.fprintf ppf "(";
ignore
(List.fold_left
(fun first s ->
ignore
(List.fold_left
(fun first s ->
if not first then Format.fprintf ppf " | ";
Format.fprintf ppf "\"%s\"" s; false) true l);
Format.fprintf ppf ")"
......@@ -70,7 +70,7 @@ let import_dtd ppf name src =
(fun a ->
let (at,ad) = e # attribute a in
match ad with
| D_fixed s ->
| D_fixed s ->
Format.fprintf ppf " %s=\"%s\"" a s
| _ ->
Format.fprintf ppf " %s=%s%a"
......@@ -80,35 +80,35 @@ let import_dtd ppf name src =
)
(e # attribute_names)
in
let elt ppf e =
Format.fprintf ppf "type @[<2>%s =@ @[<3><%s%a>[@ @[%a@]@ ]@]@];;@\n"
let elt ppf e =
Format.fprintf ppf "type @[<2>%s =@ @[<3><%s%a>[@ @[%a@]@ ]@]@];;@\n"
(name (e # name))
(e # name)
attrib e
content (e # content_model)
in
in
let dtd =
let dtd =
parse_dtd_entity { default_config with encoding = `Enc_utf8 } src in
Format.fprintf ppf
Format.fprintf ppf
"(* This file has been automatically generated by dtd2cduce *)@\n";
List.iter (fun x -> elt ppf (dtd # element x)) (dtd # element_names)
let main (cgi : Netcgi.std_activation) =
let main (cgi : Netcgi.cgi_activation) =
try
cgi # set_header
~content_type:"text/plain; charset=\"iso-8859-1\""
();
let dtd = cgi # argument_value "dtd" in
let prefix = cgi # argument_value "prefix" in
import_dtd Format.str_formatter (fun s -> prefix ^ s)
import_dtd Format.str_formatter (fun s -> prefix ^ s)
(from_string dtd);
let res = Format.flush_str_formatter () in
cgi # output # output_string res;
cgi # output # commit_work();
with exn ->
cgi # output # rollback_work();
cgi # set_header
cgi # set_header
~content_type:"text/plain; charset=\"iso-8859-1\""
();
let s = Pxp_types.string_of_exn exn in
......@@ -124,12 +124,10 @@ let () =
let name s = Sys.argv.(1) ^ s in
import_dtd Format.std_formatter name (from_file Sys.argv.(2))
| 1 ->
let operating_type = Netcgi.buffered_transactional_optype in
let cgi = new Netcgi.std_activation ~operating_type () in
let output_type = Netcgi.buffered_transactional_outtype in
ignore (Unix.alarm 20);
Sys.set_signal Sys.sigalrm (Sys.Signal_handle (fun _ -> raise Timeout));
main cgi;
cgi # finalize ()
Netcgi_cgi.run ~output_type main
| _ ->
prerr_endline "Usage: dtd2cduce <prefix> <.dtd file>";
exit 2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment