Skip to content

Instantly share code, notes, and snippets.

View dinosaure's full-sized avatar

Calascibetta Romain dinosaure

View GitHub Profile
#include "minilzo.h"
#include <caml/bigarray.h>
#include <stdio.h>
#ifndef __unused
#define __unused(x) x __attribute__((unused))
#endif
#define __unit() value __unused(unit)
#include <stdio.h>
void shift(unsigned char *a, int size, int shift) {
int carry = 0 ;
while (shift--) {
carry = 0;
for (int i = size - 1; i >= 0; i--) {
int next = (a[i] & 1) ? 0x80 : 0 ;
let ( <.> ) f g = fun x -> f (g x)
module Buffer : sig
type 'a t = private bytes
and 'a rd = < rd : unit; .. > as 'a
and 'a wr = < wr : unit; .. > as 'a
and ro = < rd: unit; >
and rdwr = < rd: unit; wr: unit; >
open Mirage
let remote_k =
let doc = Key.Arg.info ~doc:"Remote git repository." ["r"; "remote"] in
Key.(create "remote" Arg.(opt string "https://github.com/roburio/udns.git" doc))
let dns_handler =
let packages = [
package "logs" ;
package "irmin-mirage";

Mr. MIME - Parse and generate emails

I'm glad to announce the first release of mrmime, a parser and a generator of emails. This library provides an OCaml way to analyze and craft an email. Then, the goal is to make the entire stack about email (such as SMTP or IMAP) to be able to provide then tools and unikernels around the email service.

In this article, we will show what is currently possible with mrmime and some others libraries around it and our next plan.

Mr. MIME - Parse and generate emails

I'm glad to announce the first release of mrmime, a parser and a generator of emails. This library provides an OCaml way to analyze and craft an email. Then, the goal is to make the entire stack about email (such as SMTP or IMAP) to be able to provide then tools and unikernels around the email service.

In this article, we will show what is currently possible with mrmime and some others libraries around it and our next plan.

diff --git a/deflate.c b/deflate.c
index 1ec7614..088d272 100644
--- a/deflate.c
+++ b/deflate.c
@@ -85,7 +85,7 @@ local block_state deflate_rle OF((deflate_state *s, int flush));
local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
+void flush_pending OF((z_streamp strm));
(* (c) Romain Calascibetta *)
let ( <.> ) f g = fun x -> f (g x)
module type S = sig
type 'a s
type ('r, 'a) t
val run : ('r, 'a) t -> ('a -> 'r s) -> 'r s
val map : ('r s -> 'r s) -> ('r, 'a) t -> ('r, 'a) t
type ('a, 'b) bigarray = ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t
external is_a_sub :
('a, 'b) bigarray -> int ->
('a, 'b) bigarray -> int -> bool = "caml_bigarray_is_a_sub" [@@noalloc]
external bigarray_physically_equal :
('a, 'b) bigarray ->
('a, 'b) bigarray -> bool = "caml_bigarray_physically_equal" [@@noalloc]
[@@@warning "-32"]
let () = Printexc.record_backtrace true
type t =
{ dims : int array
; memory : int * int } (* absolute position * absolute position *)
let ptr t = fst t.memory
let len t = snd t.memory - fst t.memory
let dims t = Array.length t.dims