@@@ man wip
[mLib] / codec / url.3
index c3b4e98..9e8e880 100644 (file)
@@ -22,14 +22,15 @@ url \- manipulation of form-urlencoded strings
 .nf
 .B "#include <mLib/url.h>"
 
+.ta 2n
 .B "typedef struct {"
-.B "\h'4n'unsigned f;"
-.B "\h'4n'..."
+.B "   unsigned f;"
+.B "   ..."
 .B "} url_ectx;"
 
 .B "typedef struct {"
-.B "\h'4n'unsigned f;"
-.B "\h'4n'..."
+.B "   unsigned f;"
+.B "   ..."
 .B "} url_dctx;"
 
 .B "#define URLF_STRICT ..."
@@ -37,9 +38,9 @@ url \- manipulation of form-urlencoded strings
 .B "#define URLF_SEMI ..."
 
 .BI "void url_initenc(url_ectx *" ctx );
-.ds mT \fBvoid url_enc(
-.BI "\*(mTurl_ectx *" ctx ", dstr *" d ,
-.BI "\h'\w'\*(mT'u'const char *" name ", const char *" value );
+.ta \w'\fBvoid url_enc('u
+.BI "void url_enc(url_ectx *" ctx ", dstr *" d ,
+.BI "  const char *" name ", const char *" value );
 
 .BI "void url_initdec(url_dctx *" ctx ", const char *" p );
 .BI "int url_dec(url_dctx *" ctx ", dstr *" n ", dstr *" v );
@@ -143,6 +144,7 @@ its use.)
 The example code below demonstrates converting between a symbol table
 and a urlencoded representation.  The code is untested.
 .VS
+.ta 2n +2n
 #include <stdlib.h>
 #include <mLib/alloc.h>
 #include <mLib/dstr.h>
@@ -150,37 +152,36 @@ and a urlencoded representation.  The code is untested.
 #include <mLib/url.h>
 
 typedef struct {
-  sym_base _b;
-  char *v;
+       sym_base _b;
+       char *v;
 } val;
 
 void decode(sym_table *t, const char *p)
 {
-  url_dctx c;
-  dstr n = DSTR_INIT, v = DSTR_INIT;
+       url_dctx c;
+       dstr n = DSTR_INIT, v = DSTR_INIT;
+       val *vv;
+       unsigned f;
 
-  for (url_initdec(&c, p); url_dec(&c, &n, &v); ) {
-    unsigned f;
-    val *vv = sym_find(t, n.buf, -1, sizeof(*vv), &f);
-    if (f)
-      free(vv->v);
-    vv->v = xstrdup(v.buf);
-    DRESET(&n);
-    DRESET(&v);
-  }
-  dstr_destroy(&n);
-  dstr_destroy(&v);
+       for (url_initdec(&c, p); url_dec(&c, &n, &v); ) {
+               vv = sym_find(t, n.buf, -1, sizeof(*vv), &f);
+               if (f) free(vv->v);
+               vv->v = xstrdup(v.buf);
+               DRESET(&n);
+               DRESET(&v);
+       }
+       dstr_destroy(&n); dstr_destroy(&v);
 }
 
 void encode(sym_table *t, dstr *d)
 {
-  sym_iter i;
-  url_ectx c;
-  val *v;
+       sym_iter i;
+       url_ectx c;
+       val *v;
 
-  url_initenc(&c);
-  for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; )
-    url_enc(&c, d, SYM_NAME(v), v->v);
+       url_initenc(&c);
+       for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; )
+               url_enc(&c, d, SYM_NAME(v), v->v);
 }
 .VE
 .SH "SEE ALSO"