mirror of
https://github.com/bdnugget/kcgi.git
synced 2026-11-07 05:47:27 +00:00
102 lines
2.7 KiB
Plaintext
102 lines
2.7 KiB
Plaintext
.\" $Id$
|
|
.\"
|
|
.\" Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
|
|
.\"
|
|
.\" Permission to use, copy, modify, and distribute this software for any
|
|
.\" purpose with or without fee is hereby granted, provided that the above
|
|
.\" copyright notice and this permission notice appear in all copies.
|
|
.\"
|
|
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
.\"
|
|
.Dd $Mdocdate$
|
|
.Dt KHTML_ENTITY 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm khtml_entity
|
|
.Nd put named character entity content for kcgihtml
|
|
.Sh LIBRARY
|
|
.Lb libkcgihtml
|
|
.Sh SYNOPSIS
|
|
.In sys/types.h
|
|
.In stdarg.h
|
|
.In stdint.h
|
|
.In kcgi.h
|
|
.In kcgihtml.h
|
|
.Ft enum kcgi_err
|
|
.Fo khttp_entity
|
|
.Fa "struct kreq *req"
|
|
.Fa "enum entity v"
|
|
.Fc
|
|
.Sh DESCRIPTION
|
|
Writes a named character entity
|
|
.Fa v
|
|
to a context
|
|
.Fa req
|
|
initialised with
|
|
.Xr khtml_open 3 .
|
|
The value is formatted as
|
|
.Qq &#xNNNN; .
|
|
.Sh RETURN VALUES
|
|
Returns an
|
|
.Ft enum kcgi_err
|
|
indicating the error state.
|
|
.Bl -tag -width -Ds
|
|
.It Dv KCGI_OK
|
|
Success (not an error).
|
|
.It Dv KCGI_ENOMEM
|
|
Internal memory allocation failure.
|
|
.It Dv KCGI_HUP
|
|
The output connection has been terminated.
|
|
For FastCGI connections, the current connection should be released with
|
|
.Xr khttp_free 3
|
|
and parse loop reentered.
|
|
.It Dv KCGI_FORM
|
|
The connection is still expecting headers with
|
|
.Xr khttp_head 3 .
|
|
Indicates that
|
|
.Xr khttp_body 3
|
|
did not return with success or was not invoked.
|
|
For FastCGI connections, the current connection should be released with
|
|
.Xr khttp_free 3
|
|
and parse loop reentered.
|
|
.It Dv KCGI_SYSTEM
|
|
Internal system error writing to the output stream.
|
|
.El
|
|
.Sh EXAMPLES
|
|
The following outputs a simple HTML page.
|
|
It assumes
|
|
.Va r
|
|
is a
|
|
.Vt struct kreq
|
|
pointer.
|
|
For brevity, it does not do any error checking.
|
|
.Bd -literal -offset indent
|
|
khttp_head(r, kresps[KRESP_STATUS],
|
|
"%s", khttps[KHTTP_200]);
|
|
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
|
|
"%s", kmimetypes[KMIME_TEXT_HTML]);
|
|
khttp_body(r);
|
|
khtml_open(&req, r, 0);
|
|
khtml_elem(&req, KELEM_DOCTYPE);
|
|
khtml_elem(&req, KELEM_HTML);
|
|
khtml_elem(&req, KELEM_BODY);
|
|
khtml_elem(&req, KELEM_P);
|
|
khtml_puts(&req, "Hello");
|
|
khtml_ncr(&req, KENTITY_hellip); /* ... */
|
|
khtml_close(&req);
|
|
.Ed
|
|
.Sh SEE ALSO
|
|
.Xr kcgihtml 3
|
|
.Sh STANDARDS
|
|
The referenced HTML5 standard is
|
|
.Lk https://www.w3.org/TR/html52 HTML5.2 .
|
|
.Sh AUTHORS
|
|
Written by
|
|
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
|