Document VIS_HTTPSTYLE:

VIS_HTTPSTYLE is a new encoding style for use in vis(), strvis() and
  strvisx() that escapes characters according to RFC 1808 (URI encoding).

Since decoding of these require different detection of start-points of
  escaped characters, VIS_HTTPSTYLE can be given as flag to unvis().
  unvis() will then properly decode URIs.

A new function appeared, strunvisx(): strunvisx() behaves similar as
  strunvis(), with one exception: It has an additional flag parameter,
  which is passed to unvis() to archive the effect I described above.
This commit is contained in:
Alexander Langer 2000-07-02 21:31:26 +00:00
parent 3b2b8a84d3
commit d8fa6babb4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62423
2 changed files with 34 additions and 4 deletions

View File

@ -47,11 +47,14 @@
.Fn unvis "char *cp" "int c" "int *astate" "int flag"
.Ft int
.Fn strunvis "char *dst" "const char *src"
.Ft int
.Fn strunvisx "char *dst" "const char *src" "int flag"
.Sh DESCRIPTION
The
.Fn unvis
and
.Fn unvis ,
.Fn strunvis
and
.Fn strunvisx
functions
are used to decode a visual representation of characters, as produced
by the
@ -89,6 +92,16 @@ equal to the size of
decoding).
.Pp
The
.Fn strunvisx
function does the same as the
.Fn strunvis
function, but it allows you to add a flag that specifies the style the string
.Ar src
is encoded with.
Currently, the only supported flag is
.Dv VIS_HTTPSTYLE .
.Pp
The
.Fn unvis
function
implements a state machine that can be used to decode an arbitrary
@ -126,10 +139,20 @@ unknown state. The decoder is placed into the starting state.
.Pp
When all bytes in the stream have been processed, call
.Fn unvis
one more time with flag set to
one more time with
.Ar flag
set to
.Dv UNVIS_END
to extract any remaining character (the character passed in is ignored).
.Pp
The
.Ar flag
argument is also used to specify the encoding style of the source.
If set to
.Dv VIS_HTTPSTYLE ,
.Fn unvis
will decode URI strings as specified in RFC 1808.
.Pp
The following code fragment illustrates a proper use of
.Fn unvis .
.Bd -literal -offset indent

View File

@ -162,7 +162,7 @@ All forms use the backslash character
to introduce a special
sequence; two backslashes are used to represent a real backslash.
These are the visual formats:
.Bl -tag -width VIS_CSTYLE
.Bl -tag -width VIS_HTTPSTYLE
.It (default)
Use an
.Ql M
@ -238,6 +238,13 @@ If
.Fa nextc
is an octal digit, the latter representation is used to
avoid ambiguity.
.It Dv VIS_HTTPSTYLE
Use URI encoding as described in RFC 1808.
The form is
.Ql %dd
where
.Em d
represents a hexadecimal digit.
.It Dv VIS_OCTAL
Use a three digit octal sequence. The form is
.Ql \eddd