DragonFly On-Line Manual Pages

Search: Section:  


CSB(3)                       cstringbuffer library                      CSB(3)

NAME

csb_buf, csb_cstring, csb_destroy, csb_getc, csb_length, csb_lock, csb_memorysize, csb_movebegin, csb_new, csb_new_withstring, csb_prealloc, csb_printf, csb_putc, csb_puts, csb_read, csb_rewind, csb_searchbackward, csb_searchforward, csb_seek, csb_strcat, csb_tellpos, csb_trunc, csb_ungetc, csb_unlock, csb_write - operations on a file-like string buffer.

SYNOPSIS

#include <csb.h> csb_buf* csb_new (void) csb_buf* csb_new_withstring (const char* string) void csb_destroy (csb_buf* buf) int csb_prealloc (csb_buf* buf, size_t length) int csb_putc (csb_buf* buf, char ch) int csb_getc (csb_buf* buf) int csb_puts (csb_buf* buf, const char* string) int csb_strcat (csb_buf* buf, const char* string) int csb_printf (csb_buf* buf, const char* fmt, ...) int csb_read (csb_buf* buf, void* data, size_t length) int csb_write (csb_buf* buf, const void* data, size_t length) void csb_ungetc (csb_buf* buf, char ch) size_t csb_length (csb_buf* buf) size_t csb_memorysize (csb_buf* buf) size_t csb_tellpos (csb_buf* buf) const char* csb_cstring (csb_buf* buf) void csb_rewind (csb_buf* buf) void csb_seek (csb_buf* buf, size_t pointer) void csb_lock(csb_buf* buf) void csb_unlock(csb_buf* buf) size_t csb_searchforward(csb_buf* buf, const char* string) size_t csb_searchbackward(csb_buf* buf, const char* string) int csb_trunc(csb_buf* buf) int csb_movebegin(csb_buf* buf)

DESCRIPTION

cStringBuffer is a helper library designed to help you manipulate strings. It lets you treat them as files, and perform file-like IO on them, making it easier to perform certain tasks. csb_new allocates a new string buffer. csb_new_withstring allocates a new string buffer and initialize it with the string parameter. csb_addchunk increases the size of the buffer by BUFFER_INCREMENT internally defined to be 1024 bytes. csb_destroy destroys the string buffer. csb_prealloc preallocates at least length bytes for the string. csb_putc prints character ch to the buffer. csb_getc returns the character from current position and advances the current position. csb_ungetc stuffs character ch back into buffer at the current position without destroying other data. csb_puts prints string to the buffer. csb_strcat concatenates string at the end of the buffer without regard to the file pointer. csb_write writes binary data of length to the buffer. csb_printf writes formatted output to the buffer. fmt and the rest of the arguments are the same as for printf(3) csb_read reads binary data of length from the string buffer. csb_length returns the length of the string in bytes. csb_memorysize returns the total number of bytes allocated in the buffer. csb_seek seeks to position in buffer. If pointer is greater than the length of the string, it will seek to the end. csb_rewind rewinds the file pointer to the beginning. csb_tellpos returns the position of the file pointer. csb_cstring returns pointer to string being stored. csb_lock locks buffer (for use in multithreaded applications) csb_unlock unlocks buffer (for use in multithreaded applications) csb_searchforward searches forward from the current position for the string passed as the second parameter csb_searchbackward same as csb_searchforward but in the opposite direction csb_trunc truncates buffer at current position csb_movebegin shifts current position to the beginning of the buffer

RETURN VALUE

csb_new and csb_new_withstring return the newly allocated buffer pointer, or NULL on failure. csb_getc returns the read character value. csb_read returns the number of bytes read or EOF if there are no more. csb_length and csb_memorysize return size in bytes. csb_tellpos returns the file pointer, as the offset into the string buffer. csb_cstring returns the string data pointer. All other functions return 1 on success and 0 on failure.

AUTHOR

cstringbuffer library was written by Mooneer Salem <mooneer@translator.cx> Linux 2004-07-12 CSB(3)

Search: Section: