Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

buf.h File Reference

General-purpose dynamic buffer include file. More...

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  _a_buf
 Buffer structure. More...


Typedefs

typedef _a_buf ABuf
 Buffer structure.


Functions

ABufbuf_new (unsigned int len)
 Allocate a new buffer.

ABufbuf_free (ABuf *buf)
 Free a buffer_handle_type.

ABufbuf_check (ABuf *buf, unsigned int len)
 Check that the buffer is at least 'len' bytes.

ABufbuf_strcat (ABuf *buf, char *s)
 append the string 's' to the buffer.

ABufbuf_strcpy (ABuf *buf, char *s)
 Copy the string 's' into the buffer, replacing whatever's there.

ABufbuf_str_shrinkbyone (ABuf *buf)
 Shrinks the char string in the buffer by one character.

ABufbuf_terminate (ABuf *buf)
 Ensure that the last char in the buffer contains '\0'.


Detailed Description

General-purpose dynamic buffer include file.

Author:
Darryl Luff

Definition in file buf.h.


Function Documentation

ABuf* buf_check ABuf   buf,
unsigned int    len
 

Check that the buffer is at least 'len' bytes.

If it is not at least 'len' bytes long, a new buffer is allocated. Returns a pointer to either the original or the new buffer. Always use:

 buf = buf_check(buf, len);
with this function, and never rely on the returned pointer being the same as the passed pointer.
Parameters:
buf  The original pointer. If NULL, a new buffer will be allocated.
len  The requested buffer size.
Returns:
Either the original buffer if it was large enough, or a new larger buffer.

Definition at line 112 of file buf.c.

References _a_buf::b_dat, _a_buf::b_len, buf_free(), and buf_new().

Referenced by buf_strcat(), buf_strcpy(), export_html_dialog_show(), my_DBform_to_url(), pg_DBform_to_url(), send_callback(), xp_DBform_to_url(), and xp_DBget_field_value_attrib().

ABuf* buf_free ABuf   buf
 

Free a buffer_handle_type.

Returns:
NULL pointer so you can use
 'buf = buf_free(buf);
to free the buffer and clear the variable in one line.

Definition at line 90 of file buf.c.

References _a_buf::b_dat.

Referenced by buf_check(), db_connect_dialog_reconnect(), disconnect_first(), export_as_html(), export_as_text(), export_text_dialog_create(), frm_save_file(), gui_load_query_from_file(), gui_send_query(), on_databaseDisconnect_activate(), on_queryImportDlgOkBtn_clicked(), query_add(), query_import_dialog_create(), query_save_dialog_create(), result_export(), send_callback(), and ws_save_file().

ABuf* buf_new unsigned int    len
 

Allocate a new buffer.

allocsize() is used to calculate the buffer size, so the returned buffer may be larger than the requested size.

Returns:
A pointer to the new buffer.
See also:
MINSIZE

Definition at line 74 of file buf.c.

References allocsize(), _a_buf::b_dat, and _a_buf::b_len.

Referenced by buf_check(), buf_strcat(), buf_strcpy(), db_connect_dialog_reconnect(), disconnect_first(), export_as_html(), export_as_text(), frm_save_file(), gui_load_query_from_file(), gui_send_query(), on_databaseDisconnect_activate(), on_queryImportDlgOkBtn_clicked(), query_add(), query_import_dialog_create(), result_export(), send_callback(), and ws_save_file().

ABuf* buf_str_shrinkbyone ABuf   buf
 

Shrinks the char string in the buffer by one character.

Parameters:
buf  The original buffer.
Returns:
The buffer.

Definition at line 187 of file buf.c.

References _a_buf::b_dat.

Referenced by frm_check_fields().

ABuf* buf_strcat ABuf   buf,
char *    s
 

append the string 's' to the buffer.

The buffer is reallocated if necessary.

 buf = buf_strcat(buf, "Hello");
Parameters:
buf  The original buffer
s  The string to append
Returns:
The new buffer

Definition at line 134 of file buf.c.

References _a_buf::b_dat, _a_buf::b_len, buf_check(), buf_new(), and buf_terminate().

Referenced by cfg_get_default_wsname(), db_connect_dialog_reconnect(), frm_check_fields(), frm_save_file(), get_rcname(), my_DBform_to_url(), pg_DBform_to_url(), query_import_dialog_create(), query_save_dialog_create(), send_callback(), ws_save_file(), xp_DBform_to_url(), xp_DBget_field_value_attrib(), and xp_DBget_field_value_content().

ABuf* buf_strcpy ABuf   buf,
char *    s
 

Copy the string 's' into the buffer, replacing whatever's there.

The buffer is reallocated if required.

 buf = buf_strcpy(buf, "Hello");
Parameters:
buf  The original buffer
s  The string to copy
Returns:
The new buffer.

Definition at line 158 of file buf.c.

References _a_buf::b_dat, _a_buf::b_len, buf_check(), buf_new(), and buf_terminate().

Referenced by cfg_get_default_wsname(), db_connect_dialog_reconnect(), frm_save_file(), my_DBform_to_url(), pg_DBform_to_url(), query_import_dialog_create(), query_save_dialog_create(), ws_save_file(), xp_DBget_field_value_attrib(), and xp_DBget_field_value_content().

ABuf* buf_terminate ABuf   buf
 

Ensure that the last char in the buffer contains '\0'.

Parameters:
buf  The original buffer.
Returns:
The buffer.

Definition at line 199 of file buf.c.

References _a_buf::b_dat, and _a_buf::b_len.

Referenced by buf_strcat(), and buf_strcpy().


Generated on Sun May 9 19:19:19 2004 for GtkSQL by doxygen1.2.18