@@@ bench man
[mLib] / codec / codec.3
index efc0b7e..6f2ccd8 100644 (file)
@@ -18,6 +18,44 @@ codec \- binary encoding and decoding
 .B "#include <mLib/base32.h>"
 .B "#include <mLib/hex.h>"
 
+.B "#define CDCF_LOWERC ..."
+.B "#define CDCF_IGNCASE ..."
+.B "#define CDCF_NOEQPAD ..."
+.B "#define CDCF_IGNEQPAD ..."
+.B "#define CDCF_IGNEQMID ..."
+.B "#define CDCF_IGNZPAD ..."
+.B "#define CDCF_IGNNEWL ..."
+.B "#define CDCF_IGNINVCH ..."
+.B "#define CDCF_IGNSPC ..."
+.B "#define CDCF_IGNJUNK ..."
+
+.ta 2n
+.B "enum {"
+.B "   CDCERR_OK = ...,"
+.B "   CDCERR_INVCH = ...,"
+.B "   CDCERR_INVEQPAD = ...,"
+.B "   CDCERR_INVZPAD = ..."
+.B "};"
+
+.B "typedef struct {"
+.B "   const char *name;"
+.ta 2n +\w'\fBcodec *(*encoder)('u
+.BI "  codec *(*encoder)(unsigned " flags ,
+.BI "          const char *" indent ", unsigned " maxlen );
+.BI "  codec *(*decoder)(unsigned " flags );
+.B "   ...\&"
+.B "} codec_class;"
+
+.B "typedef struct {"
+.B "   const codec_ops *ops;"
+.B "} codec;"
+
+.B "typedef struct {"
+.B "   const codec_class *c;"
+.BI "  int (*code)(codec *" c ", const void *" p ", size_t " sz ", dstr *" d );
+.BI "  void (*destroy)(codec *" c );
+.B "} codec_ops;"
+
 .B "codec_class null_codec_class;"
 .B "codec_class base64_class, file64_class, base64url_class;"
 .B "codec_class base32_class, base32hex_class;"
@@ -136,7 +174,7 @@ Ignore all `junk' in the input.  This should suppress almost all
 decoding errors.
 .PP
 If you do not set any of the
-.BR CDCF_IGN ...
+.BR CDCF_IGN ...\&
 flags, a decoder should only accept the exact encoding that the
 corresponding encoder would produce (with
 .I maxline
@@ -170,7 +208,7 @@ object.
 .TP
 .BI "int (*code)(codec *" c ", const void *" p ", size_t " sz ", dstr *" d ")"
 Encode or decode, using the codec
-.I c ,
+.IR c ,
 the data in the buffer at address
 .I p
 and continuing for