From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 822B6BB84 for ; Tue, 11 Jul 2006 16:23:26 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6BENP6E013656 for ; Tue, 11 Jul 2006 16:23:26 +0200 Received: by ug-out-1314.google.com with SMTP id j3so3664579ugf for ; Tue, 11 Jul 2006 07:23:25 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=Su/dgv60XfyAFvJFkHZTbawc6nrQVUrvbXt6zZxu48ISrJqso03LcKwK0VFlgJxV6zjh4ImuqJjFiTh035ZAG8LMotbx4zMpdCTfdCMAVSinXGoWeQ96xrrrvlA03SSHSytptGCgncwpkhyx54av0et8iG1lhSZXtr6ORYXNaB0= Received: by 10.78.136.7 with SMTP id j7mr2169363hud; Tue, 11 Jul 2006 07:23:25 -0700 (PDT) Received: by 10.78.116.20 with HTTP; Tue, 11 Jul 2006 07:23:24 -0700 (PDT) Message-ID: Date: Tue, 11 Jul 2006 10:23:24 -0400 From: "Jonathan Hayward http://JonathansCorner.com" To: "Christophe TROESTLER" Subject: Re: [Caml-list] "Hello web" please Cc: caml-list@yquem.inria.fr In-Reply-To: <20060710.174800.180966261.Christophe.Troestler@umh.ac.be> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16959_31410365.1152627804694" References: <20060708.224756.70330795.Christophe.Troestler@umh.ac.be> <20060710.174800.180966261.Christophe.Troestler@umh.ac.be> X-j-chkmail-Score: MSGID : 44B3B45D.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44B3B45D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; usr:01 lib:01 ocaml:01 3.08.3:01 netcgi:01 netcgi:01 cmi:01 mli:01 jserv:01 cmi:01 mli:01 jserv:01 cmxa:01 syntax:01 syntax:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=DNS_FROM_RFC_ABUSE,HTML_40_50, HTML_MESSAGE,RCVD_BY_IP autolearn=disabled version=3.0.3 ------=_Part_16959_31410365.1152627804694 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I now have the script below. I was slightly surprised it didn't get an erro= r as I had it load /usr/lib/ocaml/3.08.3/cgi/netcgi.cma, and the directory contains: cgi.a netcgi_env.cmi netcgi_fcgi.mli netcgi_jserv.cmi cgi.cma netcgi_env.mli netcgi_jserv_ajp12.cmi netcgi_jserv.mli cgi.cmxa netcgi_fcgi_10.cmi netcgi_jserv_ajp12.mli netcgi.mli META netcgi_fcgi_10.mli netcgi_jserv_app.cmi netcgi_types.cmi netcgi.cmi netcgi_fcgi.cmi netcgi_jserv_app.mli netcgi_types.mli When I run it, I get a different and shorter error message: File "./demo.ml", line 35, characters 2-5: Syntax error The line in question is: | "1" -> "Yes" Is there some irritating little syntax error around line 35? -- #!/usr/bin/ocamlrun ocaml (* Change the directories as needed for your system. *) #directory "+pcre";; #load "pcre.cma";; #load "unix.cma";; #directory "+netstring";; #load "netstring.cma";; #directory "/usr/lib/ocaml/3.08.3/cgi/";; #load "netcgi.cma";; open Netcgi let text =3D Netencoding.Html.encode_from_latin1 (* This function encodes "<", ">", "&", double quotes, and Latin 1 characters as character entities. E.g. text "<" =3D "<", and text "=E4" =3D "ä" *) (* Normally you would use a template system instead of this *) let html_page (cgi:cgi) title html =3D let out =3D cgi#out_channel#output_string in out "\n"; out ("\n" ^ text title ^" \n"); out html; out "\n" let main (cgi:cgi) =3D cgi#set_header ~cache:`No_cache ~content_type:"text/html; charset=3D\"iso-8859-1\"" (); let foo =3D cgi#argument_value "foo" let html =3D match foo with | "1" -> "Yes" | "0" -> "No" | _ -> "Undefined" in html_page cgi foo html (* You can buffer or not the output. If buffered you can rollback (useful in case of error). You can replace Netcgi_cgi.run by another connector entry point (FCGI, SCGI, AJP, Apache mod). *) let () =3D let buffered _ ch =3D new Netchannels.buffered_trans_channel ch in Netcgi_cgi.run ~output_type:(`Transactional buffered) main --=20 ++ Jonathan Hayward, jonathan.hayward@pobox.com ** To see an award-winning website with stories, essays, artwork, ** games, and a four-dimensional maze, why not visit my home page? ** All of this is waiting for you at http://JonathansCorner.com ** If you'd like a Google Mail (gmail.com) account, please tell me! ------=_Part_16959_31410365.1152627804694 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I now have the script below. I was slightly surprised it didn't get an error as I had it load /usr/lib/ocaml/3.08.3/cgi/netcgi.cma, and the directory contains:

cgi.a   =     netcgi_env.cmi      netcgi_fcgi.mli         netcgi_jserv.cmi
cgi.cma     netcgi_env.mli     = ; netcgi_jserv_ajp12.cmi  netcgi_jserv.mli
cgi.cmxa    netcgi_fcgi_10.cmi  netcgi_jserv_ajp12.mli&= nbsp; netcgi.mli
META        netcgi_fcgi_10.mli  net= cgi_jserv_app.cmi    netcgi_types.cmi
netcgi.cmi  netcgi_fcgi.cmi     netcgi_jserv_app.m= li    netcgi_types.mli




When I run it, I get a different and shorter error message:

File "./demo.ml", line 35, characters 2-5:
Syntax error

The line in question is:

    | "1" -> "Yes"

Is there some irritating little syntax error around line 35?

--

#!/usr/bin/ocamlrun ocaml

(* Change the directories as needed for your system. *)
#directory "+pcre";;
#load "pcre.cma";;
#load "unix.cma";;
#directory "+netstring";;
#load "netstring.cma";;
#directory "/usr/lib/ocaml/3.08.3/cgi/";;
#load "netcgi.cma";;

open Netcgi

let text =3D Netencoding.Html.encode_from_latin1
  (* This function encodes "<", ">", "&= amp;", double quotes, and Latin 1
     characters as character entities.  E.g. text = "<" =3D "&lt;", and
     text "=E4" =3D "&auml;" *)=

(* Normally you would use a template system instead of this *)
let html_page (cgi:cgi) title html =3D
  let out =3D cgi#out_channel#output_string in
  out "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0//EN\&= quot; \
        \" http://www.w3.org/TR/REC-html40/strict.dtd\= ">\n";
  out ("<html>\n<head><title>" ^ text titl= e ^"</title></head>
<body>\n");
  out html;
  out "</body>\n</html>"

let main (cgi:cgi) =3D
  cgi#set_header
    ~cache:`No_cache
    ~content_type:"text/html; charset=3D\"iso-8859= -1\""
    ();
  let foo =3D cgi#argument_value "foo"
  let html =3D match foo with
    | "1" -> "Yes"
    | "0" -> "No"
    | _ -> "Undefined" in
  html_page cgi foo html

(* You can buffer or not the output.  If buffered you can rollback
   (useful in case of error). You can replace Netcgi_cgi.run by    another connector entry point (FCGI, SCGI, AJP, Apache mod). *= )
let () =3D
  let buffered _ ch =3D new Netchannels.buffered_trans_channel ch in   Netcgi_cgi.run ~output_type:(`Transactional buffered) main


--
++ Jonathan Hayward, jonathan.hayward@pobox.com
** To see an award-w= inning website with stories, essays, artwork,
** games, and a four-dimen= sional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail (= gmail.com) account, please tell me! ------=_Part_16959_31410365.1152627804694--