SDDSlib
|
Provides buffering of text strings. More...
#include "mdb.h"
#include "buffer.h"
Go to the source code of this file.
Classes | |
struct | buffer_struct |
Macros | |
#define | DEBUG 0 |
Functions | |
void | create_buffer (char *name, int increment) |
Creates a new buffer with the specified name and slot increment. | |
void | add_to_buffer (char *name, char *string) |
Adds a string to the specified buffer. | |
void | clear_buffer (char *name) |
Clears all strings from the specified buffer. | |
void | fprintf_buffer (FILE *fp, char *format, char *name) |
Writes the contents of the specified buffer to a file using a specified format. | |
void | fputs_buffer (char *name, FILE *fp) |
struct buffer_struct * | find_buffer (char *name) |
int | buffer_exists (char *name) |
Checks if a buffer with the specified name exists. | |
Variables | |
struct buffer_struct * | buffers = NULL |
Provides buffering of text strings.
This file contains functions to create, manage, and manipulate buffers that store lines of text strings. Buffers can be dynamically created, added to, cleared, and printed to files.
Definition in file buffer.c.
void add_to_buffer | ( | char * | name, |
char * | string ) |
Adds a string to the specified buffer.
If the buffer does not have enough slots to store the new string, it will be expanded by the buffer's slot increment value.
name | The name of the buffer to add the string to. |
string | The string to add to the buffer. |
Definition at line 95 of file buffer.c.
int buffer_exists | ( | char * | name | ) |
void clear_buffer | ( | char * | name | ) |
Clears all strings from the specified buffer.
Frees all memory allocated for the strings in the buffer and resets the line count.
name | The name of the buffer to clear. |
Definition at line 123 of file buffer.c.
void create_buffer | ( | char * | name, |
int | increment ) |
Creates a new buffer with the specified name and slot increment.
If a buffer with the given name already exists, the function will terminate the program with an error message.
name | The name of the buffer to create. |
increment | The number of slots to allocate when expanding the buffer. If zero, defaults to 1. |
Definition at line 53 of file buffer.c.
struct buffer_struct * find_buffer | ( | char * | name | ) |
void fprintf_buffer | ( | FILE * | fp, |
char * | format, | ||
char * | name ) |
Writes the contents of the specified buffer to a file using a specified format.
Each line in the buffer is printed to the file according to the provided format string.
fp | The file pointer to write the buffer contents to. |
format | The format string to use with fprintf for each line. |
name | The name of the buffer to write. |
Definition at line 143 of file buffer.c.