(file) Return to browser.cgi CVS log (file) (dir) Up to [app-findlib-browser] / browser.cgi

Diff for /browser.cgi between version 1 and 9

version 1, Sun Jan 4 19:43:45 2004 UTC version 9, Mon Aug 2 00:59:07 2010 UTC
Line 1 
Line 1 
 #! /bin/sh  #! /bin/sh
 # (*  # (*
 exec /opt/godi/bin/ocaml "$0" "$@"  exec /opt/godi-3.11-ocamlnet3/bin/ocaml "$0" "$@"
 *) directory ".";;  *) directory ".";;
   
 (* $Id$  (* $Id$
Line 12 
Line 12 
 #require "findlib";;  #require "findlib";;
 #require "unix";;  #require "unix";;
 #require "str";;  #require "str";;
 #require "cgi";;  #require "netcgi2";;
   
 (*-CUT-*)  (*-CUT-*)
   
 (* ---------------------------------------------------------------------- *)  (* ---------------------------------------------------------------------- *)
   
 let args = lazy begin Cgi.parse_args() end;;  module type CGI = sig val cgi : Netcgi.cgi end
   
 let param n = List.assoc n (Lazy.force args);;  module Body(Cgi : CGI) = struct
   
     let cgi = Cgi.cgi
   
     let param n = (cgi # argument n) # value;;
   
     let print s = cgi # output # output_string s;;
   
     let cancel() = cgi # output # rollback_work();;
   
     let commit() = cgi # output # commit_work();;
   
 (* ---------------------------------------------------------------------- *)  (* ---------------------------------------------------------------------- *)
   
Line 78 
Line 88 
   
 (* ---------------------------------------------------------------------- *)  (* ---------------------------------------------------------------------- *)
   
 let outbuf = Buffer.create 50000;;    let escape_html =
       Netencoding.Html.encode ~in_enc:`Enc_iso88591 ()
 let print s = Buffer.add_string outbuf s;;  
   
 let cancel() = Buffer.clear outbuf;;  
   
 let commit() = Buffer.output_buffer stdout outbuf;;  
   
 (* ---------------------------------------------------------------------- *)  
   
 let escape_html s =  
   Str.global_substitute  
     (Str.regexp "<\\|>\\|&\\|\"")  
     (fun s ->  
       match Str.matched_string s with  
         "<" -> "&lt;"  
       | ">" -> "&gt;"  
       | "&" -> "&amp;"  
       | "\"" -> "&quot;"  
       | _ -> assert false)  
     s  
 ;;  ;;
   
   
Line 213 
Line 204 
   
   let pkg_url p =    let pkg_url p =
     "<a href=\"browser.cgi?" ^      "<a href=\"browser.cgi?" ^
     "pkg=" ^ Cgi.encode p ^          "pkg=" ^ Netencoding.Url.encode p ^
     "\">" ^      "\">" ^
     escape_html p ^      escape_html p ^
     "</a>"      "</a>"
Line 221 
Line 212 
   
   let mod_url p m =    let mod_url p m =
     "<a href=\"browser.cgi?" ^      "<a href=\"browser.cgi?" ^
     "pkg=" ^ Cgi.encode p ^          "pkg=" ^ Netencoding.Url.encode p ^
     "&mod=" ^ Cgi.encode m ^          "&mod=" ^ Netencoding.Url.encode m ^
     "\">" ^      "\">" ^
     escape_html m ^      escape_html m ^
     "</a>"      "</a>"
Line 230 
Line 221 
   
   let mod_url_hl p m hl =    let mod_url_hl p m hl =
     "<a href=\"browser.cgi?" ^      "<a href=\"browser.cgi?" ^
     "pkg=" ^ Cgi.encode p ^          "pkg=" ^ Netencoding.Url.encode p ^
     "&mod=" ^ Cgi.encode m ^          "&mod=" ^ Netencoding.Url.encode m ^
     "&hlight=" ^ Cgi.encode hl ^          "&hlight=" ^ Netencoding.Url.encode hl ^
     "\">" ^      "\">" ^
     escape_html m ^      escape_html m ^
     "</a>"      "</a>"
Line 240 
Line 231 
   
   (*** headline ***)    (*** headline ***)
   
   print "content-type: text/html\n\n";      cgi # set_header();
   print "<html><head><title>Objective Caml Packages</title></head>\n";    print "<html><head><title>Objective Caml Packages</title></head>\n";
   print "<body bgcolor=white>\n";    print "<body bgcolor=white>\n";
   print "<h1>Objective Caml Packages</h1>\n";    print "<h1>Objective Caml Packages</h1>\n";
Line 466 
Line 457 
   action()    action()
 with  with
   e ->    e ->
     print "content-type: text/html\n\n";          cgi # set_header();
     print "<html><body><h1>Software error</h1>\n";      print "<html><body><h1>Software error</h1>\n";
     print (Printexc.to_string e);      print (Printexc.to_string e);
     print "</body></html>\n";      print "</body></html>\n";
 end;  end;
 commit()  commit()
   end
   
   let () =
     Netcgi_cgi.run
       ~output_type:Netcgi.buffered_transactional_optype
       (fun cgi ->
          let module Cgi = struct let cgi = cgi end in
          let module B = Body(Cgi) in
          ()
       )


Legend:
Removed from v.1  
changed lines
  Added in v.9

SVN admin
Powered by
ViewCVS 1.0-dev