GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
KCGI_BUF_WRITE(3) FreeBSD Library Functions Manual KCGI_BUF_WRITE(3)

kcgi_buf_write
put binary data into a kcgi buffer

library “libkcgi”

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

enum kcgi_err
kcgi_buf_write(const char *buf, size_t sz, void *arg);

Appends binary data buf of size sz to arg, which is cast to a struct kcgi_buf *. Buffers must be initialised to zero with memset(3) prior to first use. The buffer will always be NUL-terminated. Does nothing if buf is NULL or sz is zero.

The struct kcgi_buf structure has the following fields:

char *buf
Buffer contents. This is always NUL-terminated, even if the data is binary. This buffer must be passed to free(3) after use.
size_t maxsz
Allocated buffer size.
size_t sz
Buffer current length not including the NUL terminator.
size_t growsz
Amount of “slop” space in the buffer if it's reallocated. If set to zero, defaults to 1 KB.

These functions return an enum kcgi_err indicating the error state: KCGI_OK for no error, KCGI_ENOMEM for an internal memory allocation failure.

The following creates a simple NUL-terminated buffer. It does not perform any error checking.
struct kcgi_buf buf;

memset(&buf, 0, sizeof(struct kcgi_buf));
kcgi_buf_write("xyzzy", 5, &buf);
puts(buf.buf); /* Emits "xyzzy" */
free(buf.buf);

kcgi_buf_printf(3), kcgi_buf_putc(3), kcgi_buf_puts(3)

Written by Kristaps Dzonsons <kristaps@bsd.lv>.
June 12, 2022 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.