ksgi

Форк
0
/
khtml_write.3 
115 строк · 2.8 Кб
1
.\"	$Id$
2
.\"
3
.\" Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
4
.\"
5
.\" Permission to use, copy, modify, and distribute this software for any
6
.\" purpose with or without fee is hereby granted, provided that the above
7
.\" copyright notice and this permission notice appear in all copies.
8
.\"
9
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
.\"
17
.Dd $Mdocdate$
18
.Dt KHTML_WRITE 3
19
.Os
20
.Sh NAME
21
.Nm khtml_write
22
.Nd put content data for kcgihtml
23
.Sh LIBRARY
24
.Lb libkcgihtml
25
.Sh SYNOPSIS
26
.In sys/types.h
27
.In stdarg.h
28
.In stdint.h
29
.In kcgi.h
30
.In kcgihtml.h
31
.Ft enum kcgi_err
32
.Fo khtml_write
33
.Fa "const char *buf"
34
.Fa "size_t sz"
35
.Fa "void *arg"
36
.Fc
37
.Sh DESCRIPTION
38
Writes binary data
39
.Fa buf
40
of length
41
.Fa sz
42
to a context
43
.Fa arg ,
44
a
45
.Vt struct khtmlreq
46
initialised with
47
.Xr khtml_open 3
48
and passed as an opaque pointer.
49
If
50
.Fa buf
51
is
52
.Dv NULL
53
or
54
.Fa sz
55
is zero, does nothing and returns success.
56
All of the content is HTML escaped, for example, the left-angle bracket
57
.Qq <
58
is rendered as
59
.Qq &lt; .
60
.Sh RETURN VALUES
61
Returns an
62
.Ft enum kcgi_err
63
indicating the error state.
64
.Bl -tag -width -Ds
65
.It Dv KCGI_OK
66
Success (not an error).
67
.It Dv KCGI_ENOMEM
68
Internal memory allocation failure.
69
.It Dv KCGI_HUP
70
The output connection has been terminated.
71
For FastCGI connections, the current connection should be released with
72
.Xr khttp_free 3
73
and parse loop reentered.
74
.It Dv KCGI_FORM
75
The connection is still expecting headers with
76
.Xr khttp_head 3 .
77
Indicates that
78
.Xr khttp_body 3
79
did not return with success or was not invoked.
80
For FastCGI connections, the current connection should be released with
81
.Xr khttp_free 3
82
and parse loop reentered.
83
.It Dv KCGI_SYSTEM
84
Internal system error writing to the output stream.
85
.El
86
.Sh EXAMPLES
87
The following outputs a simple HTML page.
88
It assumes
89
.Va r
90
is a
91
.Vt struct kreq
92
pointer.
93
For brevity, it does not do any error checking.
94
.Bd -literal -offset indent
95
khttp_head(r, kresps[KRESP_STATUS],
96
  "%s", khttps[KHTTP_200]);
97
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
98
  "%s", kmimetypes[KMIME_TEXT_HTML]);
99
khttp_body(r);
100
khtml_open(&req, r, 0);
101
khtml_elem(&req, KELEM_DOCTYPE);
102
khtml_elem(&req, KELEM_HTML);
103
khtml_elem(&req, KELEM_BODY);
104
khtml_elem(&req, KELEM_P);
105
khtml_write("Hello, world.", 13, &req);
106
khtml_close(&req);
107
.Ed
108
.Sh SEE ALSO
109
.Xr kcgihtml 3
110
.Sh STANDARDS
111
The referenced HTML5 standard is
112
.Lk https://www.w3.org/TR/html52 HTML5.2 .
113
.Sh AUTHORS
114
Written by
115
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
116

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.