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


Manual Reference Pages  -  STRING_BUF_LENGTH (3)

NAME

string_buf_input, string_buf_output, string_buf_content, string_buf_length - string buffer streams

CONTENTS

Library
Synopsis
Description
Return Values
Implementation Notes
See Also
History
Authors

LIBRARY

PDEL Library (libpdel, -lpdel)

SYNOPSIS


.In sys/types.h
.In stdio.h
.In pdel/io/string_fp.h FILE * string_buf_input const void *buf size_t len int copy FILE * string_buf_output const void *mtype char * string_buf_content FILE *fp int reset int string_buf_length FILE *fp

DESCRIPTION

These functions allow string buffers to be read and written as streams.

string_buf_input creates a read-only stream that reads from the buffer pointed to by buf having length len. If copy is non-zero, the contents of the buffer are copied and therefore buf doesn’t need to remain valid while the stream is open. Otherwise, the data pointed to by buf is not copied and must remain valid while the stream is open. fclose(3) should be used to close the stream.

string_buf_output creates a write-only stream that writes into an internal buffer that grows dynamically. fclose(3) should be used to close the stream; this also frees the internal buffer. The current buffer length is returned by string_buf_length.

string_buf_content returns the contents of the internal buffer. As with string_buf_length, the fp argument must be a stream created by string_buf_output. If reset is zero, then the internal buffer remains valid and the returned pointer should be treated as read-only and not be freed; it also becomes invalid with the next operation on the stream. If reset is non-zero, the current buffer contents are "detached" and returned by string_buf_content, and a new, empty internal buffer is created; in this case, the caller is responsible for eventually freeing the returned buffer, which is allocated with typed_mem(3) type mtype, and its contents remain valid until then.

In either case, the data returned by string_buf_content is guaranteed to have one additional ’\0’ byte appended. Therefore, it is always safe to treat this pointer as a normal C string. However, any ’\0’ bytes previously written to the stream will cause this string to appear truncated.

RETURN VALUES

string_buf_input, string_buf_output, and string_buf_content return NULL to indicate an error, with errno set appropriately.

Even if string_buf_content returns NULL, the stream will still need to be closed.

IMPLEMENTATION NOTES

string_buf_content and string_buf_length attempt to verify that the supplied stream was indeed created by string_buf_output. If they detect otherwise, an immediate assertion failure is generated.

SEE ALSO

base64(3), filter(3), fopen(3), libpdel(3), typed_mem(3)

HISTORY

The PDEL library was developed at Packet Design, LLC. http://www.packetdesign.com/

AUTHORS


.An Archie Cobbs Aq archie@freebsd.org
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 manServer 1.07.