Files
kcgi/man/khttp_printf.3
kristapsdz 6364df8f8c Merge support for khtml_printf provided by Tracey Emery, thanks! Patch
tweaked for correct manpage invocation.  Merging a simple HTML test at
the same time.

Fixes https://github.com/kristapsdz/kcgi/pull/82/files
2020-03-25 20:49:42 +00:00

96 lines
2.3 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 KHTTP_PRINTF 3
.Os
.Sh NAME
.Nm khttp_printf
.Nd put variable content for kcgi
.Sh LIBRARY
.Lb libkcgi
.Sh SYNOPSIS
.In sys/types.h
.In stdarg.h
.In stdint.h
.In kcgi.h
.Ft enum kcgi_err
.Fo khttp_printf
.Fa "struct kreq *req"
.Fa "const char *fmt"
.Fa "..."
.Fc
.Sh DESCRIPTION
Writes output according to the given
.Fa fmt
to a
.Xr kcgi 3
context
.Fa req
as allocated with
.Xr khttp_parse 3
or
.Xr khttp_fcgi_parse 3 .
The format is as for
.Xr printf 3 .
It should only be called after
.Xr khttp_body 3 .
.Pp
If
.Fa fmt
is
.Dv NULL ,
it does nothing and returns success.
.Pp
If
.Xr kcgi_writer_disable 3
has been previously invoked, this function will
.Xr abort 3 .
.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 SEE ALSO
.Xr kcgi 3 ,
.Xr kcgi_writer_disable 3 ,
.Xr khttp_body 3 ,
.Xr khttp_parse 3
.Sh AUTHORS
Written by
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .