Commits

Anonymous committed fbf7740

binary written

Comments (0)

Files changed (1)

    throws exceptions: Not_supported | Unknown_type
    when more binaries  *)
 let decode_binary bin = 
-  let rec decode_list count local_bin list = 
-    if count=0 then Ok( list, local_bin )
-    else
-      begin match local_decode local_bin with
-	| Ok( term, remain )->
-	    decode_list (count-1) remain (term::list);
-	| More( length )->
-	    More( length );
-	| _-> 
-	    raise Unknown_type;
-      end
-  and local_decode local_bin = 
+  let local_decode local_bin = 
     let length = String.length local_bin in 
       (* see http://www.erlang.org/doc/apps/erts/erl_ext_dist.html for details*)
       begin match (String.get local_bin 0) with
 	    Ok( String( String.sub local_bin 3 (len+3) ),
 		String.sub local_bin (len+3) (length-len-3) );
 	| 'l' -> (* LIST_EXT *)
+	    raise Not_supported;
+	| 'm' -> (* BINARY_EXT *)
 	    let len = make_int32 (String.sub local_bin 1 5) in
-	      
-	    raise Unknown_type;
-	| 'm' -> (* BINARY_EXT *)
-	    raise Unknown_type;
+	    let data = String.sub local_bin 5 (len+5) in (* TODO: you'd better use Str.split *)
+	      Ok( Binary(data), 
+		  String.sub local_bin (len+5) (length-len-5));
 	| 'n' -> (* SMALL_BIG_EXT *)
 	    raise Unknown_type;
 	| 'o' -> (* LARGE_BIG_EXT *)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.