ksgi

Форк
0
/
kjson_putnull.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 KJSON_PUTNULL 3
19
.Os
20
.Sh NAME
21
.Nm kjson_putnull ,
22
.Nm kjson_putnullp
23
.Nd put null content for kcgijson
24
.Sh LIBRARY
25
.Lb libkcgijson
26
.Sh SYNOPSIS
27
.In sys/types.h
28
.In stdarg.h
29
.In stdint.h
30
.In kcgi.h
31
.In kcgijson.h
32
.Ft enum kcgi_err
33
.Fo kjson_putnull
34
.Fa "struct kjsonreq *req"
35
.Fc
36
.Ft enum kcgi_err
37
.Fo kjson_putnullp
38
.Fa "struct kjsonreq *req"
39
.Fa "const char *name"
40
.Fc
41
.Sh DESCRIPTION
42
Write a
43
.Dv null
44
to a context
45
.Fa req
46
initialised with
47
.Xr khtml_open 3 .
48
.Pp
49
The
50
.Fn kjson_putnull
51
form is for array scopes and
52
.Fn kjson_putnullp
53
for objects.
54
.Pp
55
Passing a
56
.Dv NULL
57
value to
58
.Fa name
59
for
60
.Fn kjson_putnullp ,
61
is equivalent to calling
62
.Fn kjson_putnull .
63
.Sh RETURN VALUES
64
Returns an
65
.Ft enum kcgi_err
66
indicating the error state.
67
.Bl -tag -width -Ds
68
.It Dv KCGI_OK
69
Success (not an error).
70
.It Dv KCGI_ENOMEM
71
Internal memory allocation failure.
72
.It Dv KCGI_HUP
73
The output connection has been terminated.
74
For FastCGI connections, the current connection should be released with
75
.Xr khttp_free 3
76
and parse loop reentered.
77
.It Dv KCGI_FORM
78
The connection is still expecting headers with
79
.Xr khttp_head 3 .
80
Indicates that
81
.Xr khttp_body 3
82
did not return with success or was not invoked.
83
For FastCGI connections, the current connection should be released with
84
.Xr khttp_free 3
85
and parse loop reentered.
86
.It Dv KCGI_SYSTEM
87
Internal system error writing to the output stream.
88
.It Dv KCGI_WRITER
89
The incorrect form was used for the current scope, for example, an
90
array-type write within an object.
91
.El
92
.Sh EXAMPLES
93
The following outputs a simple JSON document.
94
It assumes
95
.Va r
96
is a
97
.Vt struct kreq
98
pointer.
99
For brevity, it does not do any error checking.
100
.Bd -literal -offset indent
101
khttp_head(r, kresps[KRESP_STATUS],
102
  "%s", khttps[KHTTP_200]);
103
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
104
  "%s", kmimetypes[KMIME_APP_JSON]);
105
khttp_body(r);
106
kjson_open(&req, r);
107
kjson_obj_open(&req);
108
kjson_putnullp(&req, "bar");
109
kjson_close(&req);
110
.Ed
111
.Sh SEE ALSO
112
.Xr kcgijson 3
113
.Sh AUTHORS
114
Written by
115
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
116

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

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

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

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