package hxd
Hexdump in OCaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
hxd-0.3.5.tbz
sha256=135235f7c12b4fdfc2a6f764fd08e9ab7eb438856e02c6e668d73ba89ce77443
sha512=8b55c2f619d9df5db78990f9c52462416a6da71f36d570ea2ad1b640605132cbb4dd3df078f041d5fde721d61baa6d6efb9a0163f738efaf4a429660a3a665a6
doc/src/hxd.string/hxd_string.ml.html
Source file hxd_string.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
open Hxd module Caml_scheduler = Make (struct type +'a t = 'a end) type error = Seek type flow = {mutable off: int; len: int} let caml = {bind= (fun x f -> f (Caml_scheduler.prj x)); return= Caml_scheduler.inj} let lseek = let lseek flow pos mode = let () = match mode with | `CUR -> flow.off <- flow.off + pos | `SET -> flow.off <- pos | `END -> flow.off <- flow.len - pos in if flow.off < 0 || flow.off >= flow.len then Caml_scheduler.inj (Error Seek) else Caml_scheduler.inj (Ok flow.off) in {lseek} let pp configuration ppf str = let ic = {off= 0; len= String.length str} in let recv flow buffer ~off ~len = let len = min len (flow.len - flow.off) in Bytes.blit_string str flow.off buffer off len ; flow.off <- flow.off + len ; Caml_scheduler.inj (Ok len) in let send _ _ ~off:_ ~len = Caml_scheduler.inj (Ok len) in let seek = `Absolute 0 in let res = generate configuration caml recv send ic () lseek seek ppf in match Caml_scheduler.prj res with Ok () -> () | Error Seek -> () let generate configuration str seek ppf = let ic = {off= 0; len= String.length str} in let oc = Buffer.create 16 in let recv flow buffer ~off ~len = let len = min len (flow.len - flow.off) in Bytes.blit_string str flow.off buffer off len ; flow.off <- flow.off + len ; Caml_scheduler.inj (Ok len) in let send buf buffer ~off ~len = Buffer.add_substring buf buffer off len ; Caml_scheduler.inj (Ok len) in let res = generate configuration caml recv send ic oc lseek seek ppf in match Caml_scheduler.prj res with | Ok () -> Ok (Buffer.contents oc) | Error Seek -> Error (`Msg "Index out of bounds") let null = Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) let to_hxd configuration str seek = generate configuration str seek null
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>