mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] Changes to mldonkey/src/networks/fileTP/fileTPGlobals


From: mldonkey-commits
Subject: [Mldonkey-commits] Changes to mldonkey/src/networks/fileTP/fileTPGlobals.ml
Date: Tue, 26 Jul 2005 19:16:50 -0400

Index: mldonkey/src/networks/fileTP/fileTPGlobals.ml
diff -u mldonkey/src/networks/fileTP/fileTPGlobals.ml:1.12 
mldonkey/src/networks/fileTP/fileTPGlobals.ml:1.13
--- mldonkey/src/networks/fileTP/fileTPGlobals.ml:1.12  Thu Jul  7 00:25:46 2005
+++ mldonkey/src/networks/fileTP/fileTPGlobals.ml       Tue Jul 26 23:16:48 2005
@@ -25,7 +25,7 @@
 open BasicSocket
 open Options
 open TcpBufferedSocket
-  
+
 open CommonOptions
 open CommonClient
 open CommonUser
@@ -35,52 +35,49 @@
 open CommonResult
 open CommonFile
 open CommonGlobals
-open CommonDownloads  
+open CommonDownloads
 open CommonNetwork
-  
+
 open FileTPTypes
 open FileTPOptions
 
-  
-  
-let network = new_network "FTP" "FileTP"  
+let network = new_network "FTP" "FileTP"
     [ ]
 
 let connection_manager = network.network_connection_manager
-  
+
   (*
-let (result_ops : result CommonResult.result_ops) = 
+let (result_ops : result CommonResult.result_ops) =
   CommonResult.new_result_ops network
     *)
 
-let (server_ops : server CommonServer.server_ops) = 
+let (server_ops : server CommonServer.server_ops) =
   CommonServer.new_server_ops network
 
-let (room_ops : server CommonRoom.room_ops) = 
+let (room_ops : server CommonRoom.room_ops) =
   CommonRoom.new_room_ops network
-  
-let (user_ops : user CommonUser.user_ops) = 
+
+let (user_ops : user CommonUser.user_ops) =
   CommonUser.new_user_ops network
-  
-let (file_ops : file CommonFile.file_ops) = 
+
+let (file_ops : file CommonFile.file_ops) =
   CommonFile.new_file_ops network
-  
-let (client_ops : client CommonClient.client_ops) = 
+
+let (client_ops : client CommonClient.client_ops) =
   CommonClient.new_client_ops network
 
 let as_client c = as_client c.client_client
-let as_file file = as_file file.file_file    
+let as_file file = as_file file.file_file
 let file_size file = file.file_file.impl_file_size
 let file_downloaded file = file_downloaded (as_file file)
 let file_age file = file.file_file.impl_file_age
 let file_fd file = file.file_file.impl_file_fd
 let file_disk_name file = file_disk_name (as_file file)
 let file_best_name file = file_best_name (as_file file)
-  
+
 let current_files = ref ([] : FileTPTypes.file list)
 
 let listen_sock = ref (None : TcpServerSocket.t option)
-  
 
   (*
 let redirector_connected = ref false
@@ -91,24 +88,20 @@
 let files_by_uid = Hashtbl.create 13
 
 let clients_by_uid = Hashtbl.create 127
-let protos_by_name = Hashtbl.create 13  
-  
+let protos_by_name = Hashtbl.create 13
+
 let find_proto (name : string) =
   (Hashtbl.find protos_by_name name : tp_proto)
-  
-(***************************************************************
 
+(***************************************************************
 
              HOST SCHEDULER
 
-
 ****************************************************************)
-  
-  
-        
+
 let min_range_size = megabyte
 
-let set_file_size file size =  
+let set_file_size file size =
   lprintf "set_file_size\n";
   if file_size file = zero && size <> zero then begin
       lprintf "Setting SWARMER\n";
@@ -120,30 +113,30 @@
       file.file_file.impl_file_size <- size;
       let file_temp = Unix32.filename (file_fd file) in
       let kernel = Int64Swarmer.create_swarmer file_temp size min_range_size in
-      let swarmer = Int64Swarmer.create kernel (as_file file) 
+      let swarmer = Int64Swarmer.create kernel (as_file file)
           file_chunk_size in
-      file.file_swarmer <- Some swarmer;    
+      file.file_swarmer <- Some swarmer;
       lprintf "Swarmer set\n";
       Int64Swarmer.set_verified swarmer (fun _ _ ->
           file_must_update (as_file file);
       );
       (*
-      Int64Swarmer.set_writer swarmer (fun offset s pos len ->      
+      Int64Swarmer.set_writer swarmer (fun offset s pos len ->
 
 (*
       lprintf "DOWNLOADED: %d/%d/%d\n" pos len (String.length s);
       AnyEndian.dump_sub s pos len;
 *)
-          
-          if !!CommonOptions.buffer_writes then 
+
+          if !!CommonOptions.buffer_writes then
             Unix32.buffered_write_copy (file_fd file) offset s pos len
           else
             Unix32.write  (file_fd file) offset s pos len
       ) *)
     end
-    
-let new_file file_id file_name file_size = 
-  let file_temp = Filename.concat !!temp_directory 
+
+let new_file file_id file_name file_size =
+  let file_temp = Filename.concat !!temp_directory
       (Printf.sprintf "FileTP-%s" (Md4.to_string file_id)) in
   let t = Unix32.create_rw file_temp in
   let rec file = {
@@ -162,7 +155,7 @@
       impl_file_downloaded = zero;
       impl_file_val = file;
       impl_file_ops = file_ops;
-      impl_file_age = last_time ();          
+      impl_file_age = last_time ();
       impl_file_best_name = Filename.basename file_name;
     }
   in
@@ -173,15 +166,15 @@
   file
 
 exception FileFound of file
-  
+
 let new_file file_id file_name file_size =
   try
-    Hashtbl.find files_by_uid file_id 
+    Hashtbl.find files_by_uid file_id
   with _ ->
       let file = new_file file_id file_name file_size  in
       Hashtbl.add files_by_uid file_id file;
-      file    
-      
+      file
+
 let new_client proto hostname port =
   let key = (hostname,port) in
   try
@@ -190,14 +183,14 @@
       let rec c = {
           client_client = impl;
           client_sock = NoConnection;
-(*          client_name = name; 
+(*          client_name = name;
           client_kind = None; *)
           client_requests = [];
-(* 
-client_pos = Int32.zero; 
+(*
+client_pos = Int32.zero;
 client_error = false;
   *)
-  
+
           client_connection_control = new_connection_control (());
           client_downloads = [];
           client_hostname = hostname;
@@ -215,7 +208,7 @@
       new_client impl;
       Hashtbl.add clients_by_uid key c;
       c
-    
+
 let add_download file c url =
 (*  let r = new_result file.file_name (file_size file) in *)
 (*  add_source r c.client_user index; *)
@@ -223,7 +216,7 @@
   if not (List.memq c file.file_clients) then begin
       let chunks = [ Int64.zero, file_size file ] in
       (*
-      let bs = Int64Swarmer.register_uploader file.file_swarmer 
+      let bs = Int64Swarmer.register_uploader file.file_swarmer
         (Int64Swarmer.AvailableRanges chunks) in *)
       c.client_downloads <- c.client_downloads @ [{
           download_file = file;
@@ -241,22 +234,20 @@
         end;
     end
 
-let rec find_download file list = 
+let rec find_download file list =
   match list with
     [] -> raise Not_found
   | d :: tail ->
       if d.download_file == file then d else find_download file tail
 
-        
-let rec find_download_by_index index list = 
+let rec find_download_by_index index list =
   match list with
     [] -> raise Not_found
   | d :: tail ->
-      if d.download_url = index then 
+      if d.download_url = index then
         d
       else
         find_download_by_index index tail
-          
 
 let remove_download file list =
   let rec iter file list rev =
@@ -268,11 +259,11 @@
           iter file tail (d :: rev)
   in
   iter file list []
-  
+
 let file_state file = file_state (as_file file)
-  
+
 let file_num file =  file_num (as_file file)
-  
+
 let file_must_update file =
   file_must_update (as_file file)
 
@@ -280,14 +271,13 @@
 
 let set_client_state client state =
   CommonClient.set_client_state (as_client client) state
-  
+
 let set_client_disconnected client =
-  CommonClient.set_client_disconnected (as_client client) 
-  
-  
-let remove_file file = 
+  CommonClient.set_client_disconnected (as_client client)
+
+let remove_file file =
   Hashtbl.remove files_by_uid file.file_id;
-  current_files := List2.removeq file !current_files  
+  current_files := List2.removeq file !current_files
 
 let udp_sock = ref (None : UdpSocket.t option)
 
@@ -297,10 +287,9 @@
 
 let old_client_name = ref ""
 let ft_client_name = ref ""
-  
-  
-let client_name () = 
-  
+
+let client_name () =
+
   let name = !!global_login in
   if name != !old_client_name then  begin
       let len = String.length name in
@@ -309,7 +298,5 @@
       String2.replace_char !ft_client_name ' ' '_';
     end;
   !ft_client_name
-  
+
 let file_chunk_size = 307200
-  
-  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]