[Pkg-ocaml-maint-commits] r2953 - in /trunk/projects/approx/trunk: Makefile control_file.ml internet.mli netif.mli server.ml util.ml util.mli

ecc-guest at users.alioth.debian.org ecc-guest at users.alioth.debian.org
Tue Jul 18 02:57:45 UTC 2006


Author: ecc-guest
Date: Tue Jul 18 02:57:43 2006
New Revision: 2953

URL: http://svn.debian.org/wsvn/?sc=1&rev=2953
Log:
minor renaming and code reorganization

Added:
    trunk/projects/approx/trunk/internet.mli
      - copied, changed from r2647, trunk/projects/approx/trunk/netif.mli
Removed:
    trunk/projects/approx/trunk/netif.mli
Modified:
    trunk/projects/approx/trunk/Makefile
    trunk/projects/approx/trunk/control_file.ml
    trunk/projects/approx/trunk/server.ml
    trunk/projects/approx/trunk/util.ml
    trunk/projects/approx/trunk/util.mli

Modified: trunk/projects/approx/trunk/Makefile
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/Makefile?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/Makefile (original)
+++ trunk/projects/approx/trunk/Makefile Tue Jul 18 02:57:43 2006
@@ -7,7 +7,7 @@
 export OCAMLFLAGS = -warn-error A
 
 define PROJ_server
-    SOURCES = util.ml config.ml default_config.ml log.ml url.ml control_file.ml release.ml ifaddr.c netif.mli server.ml version.ml approx.ml
+    SOURCES = util.ml config.ml default_config.ml log.ml url.ml control_file.ml release.ml ifaddr.c internet.mli server.ml version.ml approx.ml
     INCDIRS = +pcre +syslog +netstring +cgi +nethttpd
     LIBS = unix pcre syslog netstring cgi nethttpd
     RESULT = approx

Modified: trunk/projects/approx/trunk/control_file.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/control_file.ml?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/control_file.ml (original)
+++ trunk/projects/approx/trunk/control_file.ml Tue Jul 18 02:57:43 2006
@@ -67,31 +67,6 @@
   in
   loop init
 
-(* Return a channel for reading a compressed file.
-   We decompress it to a temporary file first,
-   rather than reading from a pipe or using the CamlZip library,
-   so that we detect corrupted files before partially processing them.
-   This is also significantly faster than using CamlZip. *)
-
-let decompressors =
-  [ "gz", "gunzip --stdout";
-    "bz2", "bunzip2 --stdout" ]
-
-let decompress prog file =
-  let tmp = Filename.temp_file "approx" "" in
-  let cmd = Printf.sprintf "%s %s > %s" prog file tmp in
-  unwind_protect
-    (fun () ->
-      if Sys.command cmd = 0 then open_in tmp
-      else failwith "decompress")
-    (fun () ->
-      Sys.remove tmp)
-
-let open_file file =
-  match extension file with
-  | Some ext -> decompress (List.assoc ext decompressors) file
-  | None -> open_in file
-
 let fold f init file = with_channel open_file file (read f init)
 
 let iter proc = fold (fun () p -> proc p) ()

Copied: trunk/projects/approx/trunk/internet.mli (from r2647, trunk/projects/approx/trunk/netif.mli)
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/internet.mli?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/netif.mli (original)
+++ trunk/projects/approx/trunk/internet.mli Tue Jul 18 02:57:43 2006
@@ -1,1 +1,2 @@
-external inet_addr_of_interface : string -> Unix.inet_addr = "inet_addr_of_interface"
+external address_of_interface : string -> Unix.inet_addr =
+    "inet_addr_of_interface"

Modified: trunk/projects/approx/trunk/server.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/server.ml?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/server.ml (original)
+++ trunk/projects/approx/trunk/server.ml Tue Jul 18 02:57:43 2006
@@ -36,7 +36,7 @@
   setsockopt sock SO_REUSEADDR true;
   let addr =
     if interface = "any" then inet_addr_any
-    else Netif.inet_addr_of_interface interface
+    else Internet.address_of_interface interface
   in
   bind sock (ADDR_INET (addr, port));
   listen sock 10;

Modified: trunk/projects/approx/trunk/util.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/util.ml?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/util.ml (original)
+++ trunk/projects/approx/trunk/util.ml Tue Jul 18 02:57:43 2006
@@ -57,6 +57,31 @@
     (fun () -> f chan)
     (fun () -> close_in chan)
 
+(* Return a channel for reading a possibly compressed file.
+   We decompress it to a temporary file first,
+   rather than reading from a pipe or using the CamlZip library,
+   so that we detect corrupted files before partially processing them.
+   This is also significantly faster than using CamlZip. *)
+
+let decompressors =
+  [ "gz", "gunzip --stdout";
+    "bz2", "bunzip2 --stdout" ]
+
+let decompress prog file =
+  let tmp = Filename.temp_file "approx" "" in
+  let cmd = Printf.sprintf "%s %s > %s" prog file tmp in
+  unwind_protect
+    (fun () ->
+      if Sys.command cmd = 0 then open_in tmp
+      else failwith "decompress")
+    (fun () ->
+      Sys.remove tmp)
+
+let open_file file =
+  match extension file with
+  | Some ext -> decompress (List.assoc ext decompressors) file
+  | None -> open_in file
+
 let rec treewalk proc path =
   let visit name =
     let path = path ^/ name in

Modified: trunk/projects/approx/trunk/util.mli
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/util.mli?rev=2953&op=diff
==============================================================================
--- trunk/projects/approx/trunk/util.mli (original)
+++ trunk/projects/approx/trunk/util.mli Tue Jul 18 02:57:43 2006
@@ -50,6 +50,10 @@
 
 val with_channel : ('a -> in_channel) -> 'a -> (in_channel -> 'b) -> 'b
 
+(* Open a file for input, decompressing it if necessary *)
+
+val open_file : string -> in_channel
+
 (* Applying a procedure to each non-directory below a given path
    in the filesystem tree *)
 




More information about the Pkg-ocaml-maint-commits mailing list