nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
#ifndef BUFFER_H
#define BUFFER_H
//*****************************************************************************
//
// buffer.h
//
// The buffer datastructure is a string-like thing of infinite length. Contains
// some basic utilities for interacting with it.
//
//*****************************************************************************

typedef struct buffer_data BUFFER;

// allocate/deallocate a buffer. start capacity must be supplied, but the
// buffer can grow indefinitely.
BUFFER *newBuffer(int start_capacity);
void deleteBuffer(BUFFER *buf);

// concatinate the text to the end of the buffer
void        bufferCat   (BUFFER *buf, const char *txt);
void        bufferCatCh (BUFFER *buf, const char ch);

// clear the buffer's contents
void bufferClear(BUFFER *buf);

// copy the contents of one buffer to another
void bufferCopyTo(BUFFER *from, BUFFER *to);

// return a copy of the buffer
BUFFER *bufferCopy(BUFFER *buf);

// return the string contents of the buffer
const char *bufferString(BUFFER *buf);

// return the length of the buffer's contents
int bufferLength(BUFFER *buf);

// do a formatted print onto the buffer (concats it)
int bprintf(BUFFER *buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));

// bprintf with a variable list and format supplied
int vbprintf(BUFFER *buf, const char *fmt, va_list va);

// replace 'a' with 'b'. Return back how many occurences were replaced. If
// all is FALSE, then only the first occurence is replaced.
int bufferReplace(BUFFER *buf, const char *a, const char *b, int all);

// insert the line into the string at the specified place. If the line was
// inserted, return TRUE. Otherwise, return FALSE.
int bufferInsert(BUFFER *buf, const char *newline, int line);

// delete the specified line. Return TRUE if successful and FALSE otherwise
int bufferRemove(BUFFER *buf, int line);

// replace the given line number with the new information. Return TRUE if
// successful and FALSE otherwise.
int bufferReplaceLine(BUFFER *buf, const char *newline, int line);

// format a string with the given arguments
void bufferFormat(BUFFER *buf, int max_width, int indent);

// format our buffer to be a viable Python string
void bufferFormatPy(BUFFER *buf);

// format our buffer to be a C string from a Python string
void bufferFormatFromPy(BUFFER *buf);

#endif // BUFFER_H