I'm trying to read a URI Extension Block of a Share from Tahoe-LAFS in Ada. It looks something like this:
codec_name:3:crs,codec_params:11:131073-3-10,crypttext_hash:32:..G.3u1~A..o;.w..k,..3.h....K.gk,crypttext_root_hash:32:.}...I3P..Z...A.....tkq.{..'...G,needed_shares:1:3,num_segments:2:52,segment_size:6:131073,share_root_hash:32:.Q>.hGmr.9^J..........size:7:6694675,tail_codec_params:9:9954-3-10,total_shares:2:10,
Now, I was trying to come up with a solution how to get it into a Record type, but I didn't succeed. I thought of a few:
- Get all the values into a Map(String)String and after that cast them into their actual types.
- Check for the first component of the value, and process it immediately with a switch case statement
You seem to have a string with the structure
where
fieldis structuredand
<value>is<length>characters long. This is easily parsed usingAda.Strings.Fixed.Indexfrom the standard library: