Scroll to navigation

ggz.h(3) LibGGZ ggz.h(3)

NAME

ggz.h -

SYNOPSIS

#include <sys/types.h>

Defines


#define LIBGGZ_VERSION_MAJOR 0
#define LIBGGZ_VERSION_MINOR 0
#define LIBGGZ_VERSION_MICRO 11
#define LIBGGZ_VERSION_IFACE '3:1:1'
#define ggz__attribute(att)
Allow easy use of GCC's 'attribute' macro for debugging. #define _GGZFUNCTION_ __FUNCTION__
#define GGZ_MEM_DEBUG 'ggz_mem'
Debugging type for memory debugging. #define ggz_malloc(size) _ggz_malloc(size, _GGZFUNCTION_ ' in ' __FILE__, __LINE__)
Macro for memory allocation. #define ggz_realloc(mem, size) _ggz_realloc(mem, size, _GGZFUNCTION_ ' in ' __FILE__, __LINE__)
Macro for resizing previously allocated memory. #define ggz_free(mem) _ggz_free(mem, _GGZFUNCTION_ ' in ' __FILE__, __LINE__)
Macro for freeing memory previously allocated. #define ggz_strdup(string) _ggz_strdup(string, _GGZFUNCTION_ ' in ' __FILE__, __LINE__)
Macro for duplicating string. #define GGZ_CONF_DEBUG 'ggz_conf'
Debugging type for config-file debugging. #define GGZ_LIST_REPLACE_DUPS 0x00
Overwrite duplicate values on insert. #define GGZ_LIST_ALLOW_DUPS 0x01
Allow duplicate data entries to exist in the list. #define GGZ_SOCKET_DEBUG 'socket'
ggz_debug debugging type for Easysock debugging.

Typedefs


typedef int(* ggzEntryCompare )(const void *a, const void *b)
A function type for doing data comparison on two items in a GGZList. typedef void *(* ggzEntryCreate )(void *data)
A function type for creating a copy of a data item for insertion into a GGZList. typedef void(* ggzEntryDestroy )(void *data)
A function type to destroy an entry in a GGZList. typedef _GGZListEntry GGZListEntry
A single entry in a GGZList. typedef _GGZList GGZList
Simple doubly-linked list. typedef _GGZList GGZStack
Simple implementation of stacks using GGZList. typedef _GGZXMLElement GGZXMLElement
Object representing a single XML element. typedef void(* GGZDebugHandlerFunc )(int priority, const char *msg)
A callback function to handle debugging output. typedef _GGZFile GGZFile
Structure used internally by ggz_read_line(). typedef void(* ggzIOError )(const char *msg, const GGZIOType type, const int fd, const GGZDataType data)
An error function type. typedef void(* ggzIOExit )(int status)
An exit function type.

Enumerations


enum GGZConfType { GGZ_CONF_RDONLY = ((unsigned char) 0x01), GGZ_CONF_RDWR = ((unsigned char) 0x02), GGZ_CONF_CREATE = ((unsigned char) 0x04) }
Specifies the mode for opening a configuration file. enum GGZCheckType { GGZ_CHECK_NONE = 0x00, GGZ_CHECK_MEM = 0x01 }
What memory checks should we do? enum GGZIOType { GGZ_IO_CREATE, GGZ_IO_READ, GGZ_IO_WRITE, GGZ_IO_ALLOCATE }
An error type for the GGZ socket functions. enum GGZDataType { GGZ_DATA_NONE, GGZ_DATA_CHAR, GGZ_DATA_INT, GGZ_DATA_STRING, GGZ_DATA_FD }
A data type for the GGZ socket function error handler. enum GGZSockType { GGZ_SOCK_SERVER, GGZ_SOCK_CLIENT }
A socket type. enum GGZTLSType { GGZ_TLS_CLIENT, GGZ_TLS_SERVER }
TLS operation mode. enum GGZTLSVerificationType { GGZ_TLS_VERIFY_NONE, GGZ_TLS_VERIFY_PEER }
TLS verification type.

Functions


void * _ggz_malloc (const size_t size, const char *tag, int line)
Function to actually perform memory allocation. void * _ggz_realloc (const void *ptr, const size_t size, const char *tag, int line)
Function to perform memory reallocation. int _ggz_free (const void *ptr, const char *tag, int line)
Function to free allocated memory. char * _ggz_strdup (const char *ptr, const char *tag, int line)
Function to copy a string. int ggz_memory_check (void)
Check memory allocated against memory freed and display any discrepancies. void ggz_conf_cleanup (void)
Closes all open configuration files. void ggz_conf_close (int handle)
Closes one configuration file. int ggz_conf_parse (const char *path, const GGZConfType options)
Opens a configuration file and parses the variables so they can be retrieved with the access functions. int ggz_conf_commit (int handle)
Commits any changed variables to the configuration file. int ggz_conf_write_string (int handle, const char *section, const char *key, const char *value)
Writes a string value to a section and key in an open configuration file. int ggz_conf_write_int (int handle, const char *section, const char *key, int value)
Writes an integer value to a section and key in an open configuration file. int ggz_conf_write_list (int handle, const char *section, const char *key, int argc, char **argv)
Writes a list of string values to a section and key in an open configuration file. char * ggz_conf_read_string (int handle, const char *section, const char *key, const char *def)
Reads a string value from an open configuration file. int ggz_conf_read_int (int handle, const char *section, const char *key, int def)
Reads an integer value from an open configuration file. int ggz_conf_read_list (int handle, const char *section, const char *key, int *argcp, char ***argvp)
Reads a list of string values from an open configuration file. int ggz_conf_remove_section (int handle, const char *section)
This will remove an entire section and all its associated keys from a configuration file. int ggz_conf_remove_key (int handle, const char *section, const char *key)
This will remove a single key from a configuration file. int ggz_conf_get_sections (int handle, int *argcp, char ***argvp)
This function returns a list of all sections in a config file. int ggz_conf_get_keys (int handle, const char *section, int *argcp, char ***argvp)
This function returns a list of all keys within a section in a config file. GGZList * ggz_list_create (ggzEntryCompare compare_func, ggzEntryCreate create_func, ggzEntryDestroy destroy_func, int options)
Create a new GGZList. int ggz_list_insert (GGZList *list, void *data)
Insert data into a list. GGZListEntry * ggz_list_head (GGZList *list)
Get the first node of a list. GGZListEntry * ggz_list_tail (GGZList *list)
Get the last node of a list. GGZListEntry * ggz_list_next (GGZListEntry *entry)
Get the next node of a list. GGZListEntry * ggz_list_prev (GGZListEntry *entry)
Get the previous node of a list. void * ggz_list_get_data (GGZListEntry *entry)
Retrieve the data stored in a list entry. GGZListEntry * ggz_list_search (GGZList *list, void *data)
Search for a specified data item in the list. GGZListEntry * ggz_list_search_alt (GGZList *list, void *data, ggzEntryCompare compare_func)
Search for a specified data item in the list using a provided comparison function. void ggz_list_delete_entry (GGZList *list, GGZListEntry *entry)
Removes an entry from a list, calling a destructor if registered. void ggz_list_free (GGZList *list)
Free all resources associated with a list. int ggz_list_count (GGZList *list)
Get the length of the list. int ggz_list_compare_str (void *a, void *b)
Compare two character strings. void * ggz_list_create_str (void *data)
Copy a character string. void ggz_list_destroy_str (void *data)
Free a character string. GGZStack * ggz_stack_new (void)
Create a new stack. void ggz_stack_push (GGZStack *stack, void *data)
Push a data item onto the top of the stack. void * ggz_stack_pop (GGZStack *stack)
Pop the top item off of the stack. void * ggz_stack_top (GGZStack *stack)
Get the top item on the stack without popping it. void ggz_stack_free (GGZStack *stack)
Free the stack. GGZXMLElement * ggz_xmlelement_new (const char *tag, const char *const *attrs, void(*process)(), void(*free)())
Create a new GGZXMLElement element. void ggz_xmlelement_init (GGZXMLElement *element, const char *tag, const char *const *attrs, void(*process)(), void(*free)())
Initialize a GGZXMLElement. void ggz_xmlelement_set_data (GGZXMLElement *element, void *data)
Set ancillary data on a GGZXMLElement object. const char * ggz_xmlelement_get_tag (GGZXMLElement *element)
Get an XML element's name. const char * ggz_xmlelement_get_attr (GGZXMLElement *element, const char *attr)
Get the value of an attribute on XML element. void * ggz_xmlelement_get_data (GGZXMLElement *element)
Get the user-supplied data associated with an XML element. char * ggz_xmlelement_get_text (GGZXMLElement *element)
Get an XML element's content text. void ggz_xmlelement_add_text (GGZXMLElement *element, const char *text, int len)
Append a string to the element's content text. void ggz_xmlelement_free (GGZXMLElement *element)
Free the memory associated with an XML element. void ggz_debug_init (const char **types, const char *file)
Initialize and configure debugging for the program. GGZDebugHandlerFunc ggz_debug_set_func (GGZDebugHandlerFunc func)
Set the debug handler function. void ggz_debug_enable (const char *type)
Enable a specific type of debugging. void ggz_debug_disable (const char *type)
Disable a specific type of debugging. void ggz_debug (const char *type, const char *fmt,...) ggz__attribute((format(printf
Log a debugging message. void void ggz_log (const char *type, const char *fmt,...) ggz__attribute((format(printf
Log a notice message. void void void ggz_error_sys (const char *fmt,...) ggz__attribute((format(printf
Log a syscall error. void void void void ggz_error_sys_exit (const char *fmt,...) ggz__attribute((format(printf
Log a fatal syscall error. void void void void ggz__attribute ((noreturn))
void ggz_error_msg (const char *fmt,...) ggz__attribute((format(printf
Log an error message. void void ggz_error_msg_exit (const char *fmt,...) ggz__attribute((format(printf
Log a fatal error message. void ggz_debug_cleanup (GGZCheckType check)
Cleans up debugging state and prepares for exit. char * ggz_xml_escape (const char *str)
Escape XML characters in a text string. char * ggz_xml_unescape (const char *str)
Restore escaped XML characters into a text string. GGZFile * ggz_get_file_struct (int fdes)
Setup a file structure to use with ggz_read_line(). char * ggz_read_line (GGZFile *file)
Read a line of arbitrary length from a file. void ggz_free_file_struct (GGZFile *file)
Deallocate a file structure allocated via ggz_get_file_struct(). int ggz_strcmp (const char *s1, const char *s2)
String comparison function that is safe with NULLs. int ggz_strcasecmp (const char *s1, const char *s2)
Case-insensitive string comparison function that is safe with NULLs The function returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. int ggz_set_io_error_func (ggzIOError func)
Set the ggz/easysock error handling function. ggzIOError ggz_remove_io_error_func (void)
Remove the ggz/easysock error handling function. int ggz_set_io_exit_func (ggzIOExit func)
Set the ggz/easysock exit function. ggzIOExit ggz_remove_io_exit_func (void)
Remove the ggz/easysock exit function. unsigned int ggz_get_io_alloc_limit (void)
Get libggz's limit on memory allocation. unsigned int ggz_set_io_alloc_limit (const unsigned int limit)
Set libggz's limit on memory allocation. int ggz_init_network (void)
Initialize the network. int ggz_make_socket (const GGZSockType type, const unsigned short port, const char *server)
Make a socket connection. int ggz_make_socket_or_die (const GGZSockType type, const unsigned short port, const char *server)
Make a socket connection, exiting on error. int ggz_make_unix_socket (const GGZSockType type, const char *name)
Connect to a unix domain socket. int ggz_make_unix_socket_or_die (const GGZSockType type, const char *name)
Connect to a unix domain socket, exiting on error. int ggz_write_char (const int sock, const char data)
Write a character value to the given socket. void ggz_write_char_or_die (const int sock, const char data)
Write a character value to the given socket, exiting on error. int ggz_read_char (const int sock, char *data)
Read a character value from the given socket. void ggz_read_char_or_die (const int sock, char *data)
Read a character value from the given socket, exiting on error. int ggz_write_int (const int sock, const int data)
Write an integer to the socket in network byte order. void ggz_write_int_or_die (const int sock, const int data)
Write an integer to the socket, exiting on error. int ggz_read_int (const int sock, int *data)
Read an integer from the socket in network byte order. void ggz_read_int_or_die (const int sock, int *data)
Read an integer from the socket, exiting on error. int ggz_write_string (const int sock, const char *data)
Write a string to the given socket. void ggz_write_string_or_die (const int sock, const char *data)
Write a string to the given socket, exiting on error. int ggz_va_write_string (const int sock, const char *fmt,...) ggz__attribute((format(printf
Write a printf-style formatted string to the given socket. int void ggz_va_write_string_or_die (const int sock, const char *fmt,...) ggz__attribute((format(printf
Write a formatted string to the socket, exiting on error. int void int ggz_read_string (const int sock, char *data, const unsigned int len)
Read a string from the given socket. void ggz_read_string_or_die (const int sock, char *data, const unsigned int len)
Read a string from the given socket, exiting on error. int ggz_read_string_alloc (const int sock, char **data)
Read and allocate a string from the given socket. void ggz_read_string_alloc_or_die (const int sock, char **data)
Read and allocate string from the given socket, exiting on error. int ggz_write_fd (const int sock, int sendfd)
Write a file descriptor to the given (local) socket. int ggz_read_fd (const int sock, int *recvfd)
Read a file descriptor from the given (local) socket. int ggz_writen (const int sock, const void *vdata, size_t n)
Write a sequence of bytes to the socket. int ggz_readn (const int sock, void *data, size_t n)
Read a sequence of bytes from the socket. hash_t ggz_hash_create (const char *algo, const char *text)
Create a hash over a text. hash_t ggz_hmac_create (const char *algo, const char *text, const char *secret)
Create a HMAC hash over a text. char * ggz_base64_encode (const char *text, int length)
Encodes text to base64. char * ggz_base64_decode (const char *text, int length)
Decodes text from base64. void ggz_tls_init (const char *certfile, const char *keyfile, const char *password)
Initialize TLS support on the server side. int ggz_tls_support_query (void)
Check TLS support. int ggz_tls_enable_fd (int fdes, GGZTLSType whoami, GGZTLSVerificationType verify)
Enable TLS for a file descriptor. int ggz_tls_disable_fd (int fdes)
Disable TLS for a file descriptor. size_t ggz_tls_write (int fd, void *ptr, size_t n)
Write some bytes to a secured file descriptor. size_t ggz_tls_read (int fd, void *ptr, size_t n)
Read from a secured file descriptor.

Detailed Description

Author:

Brent M. Hendricks

Date:

Fri Nov 2 23:32:17 2001

Id.RS 4 ggz.h,v 1.59 2005/05/21 10:19:22 josef Exp


Header file for ggz components lib

Copyright (C) 2001 Brent Hendricks.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

Define Documentation

#define ggz__attribute(att)

Allow easy use of GCC's 'attribute' macro for debugging.

Under gcc, we use the __attribute__ macro to check variadic arguments, for instance to printf-style functions. Other compilers may be able to do something similar, but this is generally unnecessary since it's only realy purpose is to give warning messages when the developer compiles the code.

Author

Generated automatically by Doxygen for LibGGZ from the source code.

21 May 2005 Version 0.0.11