ksgi

Форк
0
/
kxml_write.3 
108 строк · 2.6 Кб
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 KXML_PUTS 3
19
.Os
20
.Sh NAME
21
.Nm kxml_write
22
.Nd put content data for kcgixml
23
.Sh LIBRARY
24
.Lb libkcgixml
25
.Sh SYNOPSIS
26
.In sys/types.h
27
.In stdarg.h
28
.In stdint.h
29
.In kcgi.h
30
.In kcgixml.h
31
.Ft enum kcgi_err
32
.Fo kxml_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 kxmlreq
46
initialised with
47
.Xr kxml_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 XML escaped.
57
.Sh RETURN VALUES
58
Returns an
59
.Ft enum kcgi_err
60
indicating the error state.
61
.Bl -tag -width -Ds
62
.It Dv KCGI_OK
63
Success (not an error).
64
.It Dv KCGI_ENOMEM
65
Internal memory allocation failure.
66
.It Dv KCGI_HUP
67
The output connection has been terminated.
68
For FastCGI connections, the current connection should be released with
69
.Xr khttp_free 3
70
and parse loop reentered.
71
.It Dv KCGI_FORM
72
The connection is still expecting headers with
73
.Xr khttp_head 3 .
74
Indicates that
75
.Xr khttp_body 3
76
did not return with success or was not invoked.
77
For FastCGI connections, the current connection should be released with
78
.Xr khttp_free 3
79
and parse loop reentered.
80
.It Dv KCGI_SYSTEM
81
Internal system error writing to the output stream.
82
.El
83
.Sh EXAMPLES
84
The following outputs a simple XML page.
85
It assumes
86
.Va r
87
is a
88
.Vt struct kreq
89
pointer.
90
For brevity, it does not do any error checking.
91
.Bd -literal -offset indent
92
const char *const elems[] =
93
  { "foo", "bar", "baz" };
94
khttp_head(r, kresps[KRESP_STATUS],
95
  "%s", khttps[KHTTP_200]);
96
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
97
  "%s", kmimetypes[KMIME_TEXT_XML]);
98
khttp_body(r);
99
kxml_open(&req, r, elems, 3);
100
kxml_push(&req, 0); /* foo */
101
kxml_puts(&req, "Hello, world");
102
kxml_close(&req);
103
.Ed
104
.Sh SEE ALSO
105
.Xr kcgixml 3
106
.Sh AUTHORS
107
Written by
108
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
109

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

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

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

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