summaryrefslogtreecommitdiff
path: root/include/cddb
diff options
context:
space:
mode:
Diffstat (limited to 'include/cddb')
-rw-r--r--include/cddb/Makefile.am9
-rw-r--r--include/cddb/cddb.h97
-rw-r--r--include/cddb/cddb_cmd.h185
-rw-r--r--include/cddb/cddb_cmd_ni.h68
-rw-r--r--include/cddb/cddb_config.h37
-rw-r--r--include/cddb/cddb_config.h.in37
-rw-r--r--include/cddb/cddb_conn.h562
-rw-r--r--include/cddb/cddb_conn_ni.h178
-rw-r--r--include/cddb/cddb_disc.h450
-rw-r--r--include/cddb/cddb_error.h118
-rw-r--r--include/cddb/cddb_log.h87
-rw-r--r--include/cddb/cddb_log_ni.h59
-rw-r--r--include/cddb/cddb_net.h133
-rw-r--r--include/cddb/cddb_ni.h189
-rw-r--r--include/cddb/cddb_regex.h74
-rw-r--r--include/cddb/cddb_site.h248
-rw-r--r--include/cddb/cddb_track.h244
-rw-r--r--include/cddb/ll.h148
-rw-r--r--include/cddb/version.h12
-rw-r--r--include/cddb/version.h.in12
20 files changed, 2947 insertions, 0 deletions
diff --git a/include/cddb/Makefile.am b/include/cddb/Makefile.am
new file mode 100644
index 00000000..f6c2f70f
--- /dev/null
+++ b/include/cddb/Makefile.am
@@ -0,0 +1,9 @@
+
+pkgincludedir=$(includedir)/cddb
+pkginclude_HEADERS = cddb.h cddb_config.h cddb_disc.h cddb_track.h \
+ cddb_error.h cddb_conn.h cddb_cmd.h cddb_log.h \
+ version.h cddb_site.h
+noinst_HEADERS = cddb_ni.h cddb_regex.h cddb_conn_ni.h cddb_cmd_ni.h \
+ cddb_net.h cddb_log_ni.h ll.h
+
+EXTRA_DIST = version.h.in
diff --git a/include/cddb/cddb.h b/include/cddb/cddb.h
new file mode 100644
index 00000000..c46700a6
--- /dev/null
+++ b/include/cddb/cddb.h
@@ -0,0 +1,97 @@
+/*
+ $Id: cddb.h,v 1.14 2006/10/15 12:54:33 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_H
+#define CDDB_H 1
+
+#include <cddb/version.h>
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include <cddb/cddb_config.h>
+#include <cddb/cddb_error.h>
+#include <cddb/cddb_track.h>
+#include <cddb/cddb_disc.h>
+#include <cddb/cddb_site.h>
+#include <cddb/cddb_conn.h>
+#include <cddb/cddb_cmd.h>
+#include <cddb/cddb_log.h>
+
+
+/**
+ * \mainpage libCDDB, a C API for CDDB server access
+ */
+
+
+#define BIT(n) (1 << n)
+
+/**
+ * An enumeration of flags that influence the behaviour of the
+ * library. You can set or reset these flags using the
+ * #libcddb_set_flags and #libcddb_reset_flags functions.
+ */
+typedef enum {
+ CDDB_F_EMPTY_STR = BIT(0), /**< never return NULL pointer strings
+ (default), return an empty string
+ instead */
+ CDDB_F_NO_TRACK_ARTIST = BIT(1), /**< do not return the disc artist as the
+ track artist (default), return NULL
+ instead */
+} cddb_flag_t;
+
+/**
+ * Initializes the library. This is used to setup any globally used
+ * variables. The first time you create a new CDDB connection structure
+ * the library will automatically initialize itself. So, there is no
+ * need to explicitly call this function.
+ */
+void libcddb_init(void);
+
+/**
+ * Frees up any global (cross connection) resources. You should call
+ * this function before terminating your program. Using any library
+ * calls after shutting down are bound to give problems.
+ */
+void libcddb_shutdown(void);
+
+/**
+ * Set one or more flags that influence the library behvaiour
+ *
+ * @param flags A bitwise ORed set of values from #cddb_flag_t.
+ */
+void libcddb_set_flags(unsigned int flags);
+
+/**
+ * Reset one or more flags that influence the library behvaiour
+ *
+ * @param flags A bitwise ORed set of values from #cddb_flag_t.
+ */
+void libcddb_reset_flags(unsigned int flags);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_H */
diff --git a/include/cddb/cddb_cmd.h b/include/cddb/cddb_cmd.h
new file mode 100644
index 00000000..c5a01fef
--- /dev/null
+++ b/include/cddb/cddb_cmd.h
@@ -0,0 +1,185 @@
+/*
+ $Id: cddb_cmd.h,v 1.17 2006/10/15 08:58:51 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CMD_H
+#define CDDB_CMD_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/* --- accessing data on the CDDB server --- */
+
+
+/**
+ * Retrieve a disc record from the CDDB server. This function
+ * requires that the category and disc ID of the provided disc
+ * structure are valid.
+ *
+ * If nothing goes wrong, the function will return 1 and the error
+ * code will be reset to:
+ * - #CDDB_ERR_OK:
+ * If everything went as planned.
+ *
+ * If there is a problem with reading data from the CDDB server one of
+ * the following error codes will be set:
+ * - #CDDB_ERR_DATA_MISSING:
+ * If some required data is missing from the given disc
+ * structure to execute this command.
+ * - #CDDB_ERR_DISC_NOT_FOUND:
+ * If the requested disc is not known by the CDDB server.
+ * - #CDDB_ERR_SERVER_ERROR:
+ * If the server encountered an error while trying to process your
+ * request.
+ * - #CDDB_ERR_UNKNOWN:
+ * If the server specified an unknown response code. Please
+ * report this as a libcddb bug.
+ *
+ * When there are problems with the connection to the CDDB server one
+ * of the following error codes will be set:
+ * - #CDDB_ERR_UNKNOWN_HOST_NAME:
+ * If there was an error when resolving the host name of the CDDB
+ * server.
+ * - #CDDB_ERR_CONNECT:
+ * If a connection to the CDDB server could not be established.
+ * This can be due to incorrect data about the location of the
+ * server (host name, port).
+ * - #CDDB_ERR_NOT_CONNECTED:
+ * If something when wrong in the process and you got
+ * disconnected. Retrying might succeed (but no guarantees).
+ * - #CDDB_ERR_PERMISSION_DENIED:
+ * If the server is up and running but denied the connection.
+ * This can occur when the server is too highly loaded or the
+ * handshake information (user name, ...) is considered to be
+ * invalid.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ * @return 1 on succes, 0 on failure
+ */
+int cddb_read(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Query the CDDB database for a list of possible disc matches. This
+ * function requires that the disc ID and disc length of the provided
+ * disc structure are valid. The disc should also contain a number of
+ * tracks and for each track its frame offset on the CD should be
+ * valid.
+ *
+ * If there are multiple matches then only the first one will be
+ * returned by this function. For other matches you will have to use
+ * the #cddb_query_next function.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ *
+ * @return The number of matches found or -1 on error.
+ */
+int cddb_query(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Returns the next match in a CDDB query result set. This function
+ * should be used in conjunction with #cddb_query.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ */
+int cddb_query_next(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Perform a text search in the CDDB database. Instead of actually
+ * needing information about a real disc like in #cddb_query this
+ * function accept a string that is used for searching the database.
+ *
+ * If there are multiple matches then only the first one will be
+ * returned by this function. For other matches you will have to use
+ * the #cddb_search_next function.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ * @param str The search string
+ *
+ * @return The number of matches found or -1 on error.
+ */
+int cddb_search(cddb_conn_t *c, cddb_disc_t *disc, const char *str);
+
+/**
+ * Returns the next match in a CDDB search result set. This function
+ * should be used in conjunction with #cddb_search.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ */
+int cddb_search_next(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Perform a text search in the CDDB database. It uses the album
+ * command implemented on the freedb2.org servers. Either the album
+ * title or artist's name should be filled in, in the disc structure.
+ *
+ * If there are multiple matches then only the first one will be
+ * returned by this function. For other matches you will have to use
+ * the #cddb_album_next function.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ *
+ * @return The number of matches found or -1 on error.
+ */
+int cddb_album(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Returns the next match in a CDDB album result set. This function
+ * should be used in conjunction with #cddb_album.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ */
+int cddb_album_next(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Submit a new or updated disc to the CDDB database. This function
+ * requires that the disc ID, length, category, artist and title of
+ * the provided disc structure are valid. The disc should also
+ * contain a number of tracks and for each track its frame offset on
+ * the CD and title should be valid.
+ *
+ * @param c The CDDB connection structure.
+ * @param disc A non-null CDDB disc structure.
+ */
+int cddb_write(cddb_conn_t *c, cddb_disc_t *disc);
+
+/**
+ * Query the currently configured server for a list of mirrors.
+ * Accessing the list of mirror sites is done with the iterator
+ * functions #cddb_first_site and #cddb_next_site.
+ *
+ * @param c The CDDB connection structure.
+ */
+int cddb_sites(cddb_conn_t *c);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_CMD_H */
diff --git a/include/cddb/cddb_cmd_ni.h b/include/cddb/cddb_cmd_ni.h
new file mode 100644
index 00000000..4b02190a
--- /dev/null
+++ b/include/cddb/cddb_cmd_ni.h
@@ -0,0 +1,68 @@
+/*
+ $Id: cddb_cmd_ni.h,v 1.12 2006/10/15 08:59:20 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CMD_NI_H
+#define CDDB_CMD_NI_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+typedef enum {
+ CMD_HELLO = 0,
+ CMD_QUIT,
+ CMD_READ,
+ CMD_QUERY,
+ CMD_WRITE,
+ CMD_PROTO,
+ CMD_SITES,
+ CMD_SEARCH,
+ CMD_ALBUM,
+ /* dummy for array size */
+ CMD_LAST
+} cddb_cmd_t;
+
+
+/* --- utility functions --- */
+
+
+/**
+ * Will read in one line from the response input stream and parse both
+ * the code and message in that line. Errors will be signaled by
+ * returning -1.
+ *
+ * @param c the CDDB connection structure
+ * @param msg the CDDB response msg
+ * @return the CDDB response code or -1 on error
+ */
+int cddb_get_response_code(cddb_conn_t *c, char **msg);
+
+/**
+ */
+int cddb_send_cmd(cddb_conn_t *c, int cmd, ...);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_CMD_H */
diff --git a/include/cddb/cddb_config.h b/include/cddb/cddb_config.h
new file mode 100644
index 00000000..fd0d3769
--- /dev/null
+++ b/include/cddb/cddb_config.h
@@ -0,0 +1,37 @@
+/*
+ $Id: cddb_config.h.in,v 1.3 2005/03/11 21:29:29 airborne Exp $
+
+ Copyright (C) 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CONFIG_H
+#define CDDB_CONFIG_H 1
+
+/* Define if you have <unistd.h> and need it included.
+ On MacOS, <regex.h> needs this but that header doesn't
+ include it.
+*/
+#undef CDDB_NEED_UNISTD_H
+
+/* Define if you have <sys/socket.h> and need it included.
+ On MacOS, <cddb_net.h> needs this but that header doesn't
+ include it.
+*/
+#undef CDDB_NEED_SYS_SOCKET_H
+
+#endif /* CDDB_CONFIG_H */
diff --git a/include/cddb/cddb_config.h.in b/include/cddb/cddb_config.h.in
new file mode 100644
index 00000000..fd0d3769
--- /dev/null
+++ b/include/cddb/cddb_config.h.in
@@ -0,0 +1,37 @@
+/*
+ $Id: cddb_config.h.in,v 1.3 2005/03/11 21:29:29 airborne Exp $
+
+ Copyright (C) 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CONFIG_H
+#define CDDB_CONFIG_H 1
+
+/* Define if you have <unistd.h> and need it included.
+ On MacOS, <regex.h> needs this but that header doesn't
+ include it.
+*/
+#undef CDDB_NEED_UNISTD_H
+
+/* Define if you have <sys/socket.h> and need it included.
+ On MacOS, <cddb_net.h> needs this but that header doesn't
+ include it.
+*/
+#undef CDDB_NEED_SYS_SOCKET_H
+
+#endif /* CDDB_CONFIG_H */
diff --git a/include/cddb/cddb_conn.h b/include/cddb/cddb_conn.h
new file mode 100644
index 00000000..ada3cdda
--- /dev/null
+++ b/include/cddb/cddb_conn.h
@@ -0,0 +1,562 @@
+/*
+ $Id: cddb_conn.h,v 1.31 2009/03/01 03:28:07 jcaratzas Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CONN_H
+#define CDDB_CONN_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include <stdio.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#include "cddb/cddb_site.h"
+
+
+typedef enum {
+ CACHE_OFF = 0, /**< do not use local CDDB cache, network
+ only */
+ CACHE_ON, /**< use local CDDB cache, if possible */
+ CACHE_ONLY /**< only use local CDDB cache, no network
+ access */
+} cddb_cache_mode_t;
+
+/**
+ * Forward declaration of opaque structure used for character set
+ * conversions.
+ */
+typedef struct cddb_iconv_s *cddb_iconv_t;
+
+/**
+ * An opaque structure for keeping state about the connection to a
+ * CDDB server.
+ */
+typedef struct cddb_conn_s cddb_conn_t;
+
+/**
+ * Which fields to use for the full text search is defined by one or
+ * more of the constants below.
+ */
+typedef enum {
+ SEARCH_NONE = 0, /**< no fields */
+ SEARCH_ARTIST = 1, /**< artist name field */
+ SEARCH_TITLE = 2, /**< disc title field */
+ SEARCH_TRACK = 4, /**< track title field */
+ SEARCH_OTHER = 8, /**< other fields */
+ SEARCH_ALL = ~0, /**< all fields */
+} cddb_search_t;
+
+/**
+ * Macro to be used for building the category search bit-string from
+ * the values of #cddb_cat_t.
+ */
+#define SEARCHCAT(c) (1 << (c))
+
+
+/* --- construction / destruction --- */
+
+
+/**
+ * Creates a new CDDB connection structure. This structure will have
+ * to be passed to all libcddb functions. Default values will be used
+ * for the connection parameters allowing it to contact the CDDB
+ * server at freedb.org.
+ *
+ * @return The CDDB connection structure or NULL if something went wrong.
+ */
+cddb_conn_t *cddb_new(void);
+
+/**
+ * Free all resources associated with the given CDDB connection
+ * structure.
+ */
+void cddb_destroy(cddb_conn_t *c);
+
+
+/* --- getters & setters --- */
+
+
+/**
+ * Set the character set. By default the FreeDB server uses UTF-8 when
+ * providing CD data. When a character set is defined with this function
+ * any strings retrieved from or sent to the server will automatically be
+ * converted.
+ *
+ * @param c The connection structure.
+ * @param cs The character set that will be used.
+ * @return False if the specified character set is unknown, or no conversion
+ * from/to UTF-8 is available. True otherwise.
+ */
+int cddb_set_charset(cddb_conn_t *c, const char *cs);
+
+/**
+ * Change the size of the internal buffer.
+ *
+ * @param c The connection structure.
+ * @param size The new buffer size.
+ */
+void cddb_set_buf_size(cddb_conn_t *c, unsigned int size);
+
+/**
+ * Set all server details in one go through the use of a site structure. This
+ * function initializzes the server address, port, protocol and query path in
+ * case of HTTP.
+ *
+ * @see cddb_sites
+ * @see cddb_first_site
+ * @see cddb_next_site
+ *
+ * @param c The connection structure.
+ * @param site The site to use.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_set_site(cddb_conn_t *c, const cddb_site_t *site);
+
+/**
+ * Get the host name of the CDDB server that is currently being used.
+ *
+ * @see cddb_set_server_name
+ *
+ * @param c The connection structure.
+ * @return The server host name.
+ */
+const char *cddb_get_server_name(const cddb_conn_t *c);
+
+/**
+ * Set the host name of the CDDB server. The default value for the
+ * server is 'freedb.org'.
+ *
+ * @see cddb_get_server_name
+ *
+ * @param c The connection structure.
+ * @param server The server host name.
+ */
+void cddb_set_server_name(cddb_conn_t *c, const char *server);
+
+/**
+ * Get the port of the CDDB server that is currently being used.
+ *
+ * @see cddb_set_server_port
+ *
+ * @param c The connection structure.
+ * @return The server port.
+ */
+unsigned int cddb_get_server_port(const cddb_conn_t *c);
+
+/**
+ * Set the port of the CDDB server. The default value is 888.
+ *
+ * @see cddb_get_server_port
+ *
+ * @param c The connection structure.
+ * @param port The server port.
+ */
+void cddb_set_server_port(cddb_conn_t *c, int port);
+
+/**
+ * Get the network time out value (in seconds).
+ *
+ * @see cddb_set_timeout
+ *
+ * @param c The connection structure.
+ * @return The current time out in seconds.
+ */
+unsigned int cddb_get_timeout(const cddb_conn_t *c);
+
+/**
+ * Set the network time out value (in seconds). The default is 10
+ * seconds.
+ *
+ * @see cddb_get_timeout
+ *
+ * @param c The connection structure.
+ * @param t The new time out in seconds.
+ */
+void cddb_set_timeout(cddb_conn_t *c, unsigned int t);
+
+/**
+ * Get the URL path for querying a CDDB server through HTTP.
+ *
+ * @see cddb_set_http_path_query
+ *
+ * @param c The connection structure.
+ * @return The URL path.
+ */
+const char *cddb_get_http_path_query(const cddb_conn_t *c);
+
+/**
+ * Set the URL path for querying a CDDB server through HTTP. The
+ * default value is '/~cddb/cddb.cgi'.
+ *
+ * @see cddb_get_http_path_query
+ *
+ * @param c The connection structure.
+ * @param path The URL path.
+ */
+void cddb_set_http_path_query(cddb_conn_t *c, const char *path);
+
+/**
+ * Get the URL path for submitting to a CDDB server through HTTP.
+ *
+ * @see cddb_set_http_path_submit
+ *
+ * @param c The connection structure.
+ * @return The URL path.
+ */
+const char *cddb_get_http_path_submit(const cddb_conn_t *c);
+
+/**
+ * Set the URL path for submitting to a CDDB server through HTTP. The
+ * default value is '/~cddb/submit.cgi'.
+ *
+ * @see cddb_get_http_path_submit
+ *
+ * @param c The connection structure.
+ * @param path The URL path.
+ */
+void cddb_set_http_path_submit(cddb_conn_t *c, const char *path);
+
+/**
+ * Returns true if the HTTP protocol is currently enabled and false if
+ * CDDBP is enabled.
+ *
+ * @see cddb_http_enable
+ * @see cddb_http_disable
+ *
+ * @param c The CDDB connection structure.
+ * @return True or false.
+ */
+unsigned int cddb_is_http_enabled(const cddb_conn_t *c);
+
+/**
+ * Enable HTTP tunneling to connect to the CDDB server. By default
+ * this option is disabled.
+ *
+ * @see cddb_is_http_enabled
+ * @see cddb_http_disable
+ *
+ * @param c The CDDB connection structure.
+ */
+void cddb_http_enable(cddb_conn_t *c);
+
+/**
+ * Disable HTTP tunneling to connect to the CDDB server. By default this
+ * option is disabled.
+ *
+ * @see cddb_is_http_enabled
+ * @see cddb_http_enable
+ *
+ * @param c The CDDB connection structure.
+ */
+void cddb_http_disable(cddb_conn_t *c);
+
+/**
+ * Returns true if the proxy support is currently enabled and false if
+ * it is not. This fucntion does not check whether HTTP is enabled.
+ * So it is possible that true will be returned while in reality the
+ * CDDBP protocol is being used (no proxy support).
+ *
+ * @see cddb_http_proxy_enable
+ * @see cddb_http_proxy_disable
+ *
+ * @param c The CDDB connection structure.
+ * @return True or false.
+ */
+unsigned int cddb_is_http_proxy_enabled(const cddb_conn_t *c);
+
+/**
+ * Enable HTTP tunneling through an HTTP proxy server to connect to
+ * the CDDB server. The usage of an HTTP proxy implies normal HTTP
+ * tunneling instead of connecting directly to the CDDB server. By
+ * default this option is disabled.
+ *
+ * @see cddb_is_http_proxy_enabled
+ * @see cddb_http_proxy_disable
+ *
+ * @param c The CDDB connection structure.
+ */
+void cddb_http_proxy_enable(cddb_conn_t *c);
+
+/**
+ * Disable HTTP tunneling through an HTTP proxy server to connect to
+ * the CDDB server. By default this option is disabled.
+ *
+ * @see cddb_is_http_proxy_enabled
+ * @see cddb_http_proxy_enable
+ *
+ * @param c The CDDB connection structure.
+ */
+void cddb_http_proxy_disable(cddb_conn_t *c);
+
+/**
+ * Get the host name of the HTTP proxy server.
+ *
+ * @see cddb_set_http_proxy_server_name
+ *
+ * @param c The connection structure.
+ * @return The proxy server host name.
+ */
+const char *cddb_get_http_proxy_server_name(const cddb_conn_t *c);
+
+/**
+ * Set the host name of the HTTP proxy server. There is no default
+ * value.
+ *
+ * @see cddb_get_http_proxy_server_name
+ *
+ * @param c The connection structure.
+ * @param server The server host name.
+ */
+void cddb_set_http_proxy_server_name(cddb_conn_t *c, const char *server);
+
+/**
+ * Get the port of the HTTP proxy server.
+ *
+ * @see cddb_set_http_proxy_server_port
+ *
+ * @param c The connection structure.
+ * @return The proxy server port.
+ */
+unsigned int cddb_get_http_proxy_server_port(const cddb_conn_t *c);
+
+/**
+ * Set the port of the HTTP proxy server. The default value is 8080.
+ *
+ * @see cddb_get_http_proxy_server_port
+ *
+ * @param c The connection structure.
+ * @param port The server port.
+ */
+void cddb_set_http_proxy_server_port(cddb_conn_t *c, int port);
+
+/**
+ * Set the HTTP proxy user name which is used when Basic Authentication
+ * is required.
+ *
+ * @param c The connection structure.
+ * @param username The user name.
+ */
+void cddb_set_http_proxy_username(cddb_conn_t* c, const char* username);
+
+/**
+ * Get the HTTP proxy user name.
+ *
+ * @param c The connection structure.
+ * @return The user name.
+ */
+const char *cddb_get_http_proxy_username(const cddb_conn_t *c);
+
+/**
+ * Set the HTTP proxy password which is used when Basic Authentication
+ * is required.
+ *
+ * @param c The connection structure.
+ * @param passwd The password.
+ */
+void cddb_set_http_proxy_password(cddb_conn_t* c, const char* passwd);
+
+/**
+ * Get the HTTP proxy password.
+ *
+ * @param c The connection structure.
+ * @return The password.
+ */
+const char *cddb_get_http_proxy_password(const cddb_conn_t *c);
+
+/**
+ * Set the HTTP proxy user name and password in one go. These
+ * credentials are used when Basic Authentication is required. The
+ * advantage of using this function over setting the user name and
+ * password seperately is that the cleartext user name and password
+ * are not kept in memory longer than needed.
+ *
+ * @param c The connection structure.
+ * @param username The user name.
+ * @param passwd The password.
+ */
+void cddb_set_http_proxy_credentials(cddb_conn_t* c,
+ const char *username, const char* passwd);
+
+/**
+ * Get the error number returned by the last libcddb command.
+ *
+ * @param c The CDDB connection structure.
+ * @return The error number.
+ */
+cddb_error_t cddb_errno(const cddb_conn_t *c);
+
+/**
+ * Set the name and version of the client program overwriting the
+ * previous values. This function will make a copy of the provided
+ * strings. The defaults are 'libcddb' and the version number of the
+ * libcddb library in use. Both parameters must be valid strings. If
+ * any of teh strings is NULL, this fucntion will return without
+ * changing anything.
+ *
+ * @param c The connection structure.
+ * @param cname The name of the client program.
+ * @param cversion The version number of the client program.
+ */
+void cddb_set_client(cddb_conn_t *c, const char *cname, const char *cversion);
+
+/**
+ * Sets the user name and host name of the local machine. This
+ * function will parse out the user name and host name from the e-mail
+ * address.
+ *
+ * @param c The connection structure.
+ * @param email The e-mail address of the user.
+ */
+int cddb_set_email_address(cddb_conn_t *c, const char *email);
+
+/**
+ * Returns the current cache mode. This can be either on, off or
+ * cache only.
+ *
+ * @see CACHE_ON
+ * @see CACHE_ONLY
+ * @see CACHE_OFF
+ * @see cddb_cache_enable
+ * @see cddb_cache_only
+ * @see cddb_cache_disable
+ *
+ * @param c The connection structure.
+ */
+cddb_cache_mode_t cddb_cache_mode(const cddb_conn_t *c);
+
+/**
+ * Enable caching of CDDB entries locally. Caching is enabled by
+ * default. The cache directory can be changed with the
+ * cddb_cache_set_dir function.
+ *
+ * @see cddb_cache_mode
+ * @see cddb_cache_disable
+ * @see cddb_cache_only
+ *
+ * @param c The connection structure.
+ */
+void cddb_cache_enable(cddb_conn_t *c);
+
+/**
+ * Only use the local CDDB cache. Never contact a server to retrieve
+ * any data. The cache directory can be changed with the
+ * cddb_cache_set_dir function.
+ *
+ * @see cddb_cache_mode
+ * @see cddb_cache_enable
+ * @see cddb_cache_disable
+ *
+ * @param c The connection structure.
+ */
+void cddb_cache_only(cddb_conn_t *c);
+
+/**
+ * Disable caching of CDDB entries locally. All data will be fetched
+ * from a CDDB server everytime and the retrieved data will not be
+ * cached locally.
+ *
+ * @see cddb_cache_mode
+ * @see cddb_cache_enable
+ * @see cddb_cache_only
+ *
+ * @param c The connection structure.
+ */
+void cddb_cache_disable(cddb_conn_t *c);
+
+/**
+ * Return the directory currently being used for caching.
+ *
+ * @see cddb_cache_set_dir
+ *
+ * @param c The connection structure.
+ * @return The directory being used for caching.
+ */
+const char *cddb_cache_get_dir(const cddb_conn_t *c);
+
+/**
+ * Change the directory used for caching CDDB entries locally. The
+ * default location of the cached entries is a subdirectory
+ * (.cddbslave) of the user's home directory. If the first character
+ * of the directory is '~', then it will be expanded to the contents
+ * of $HOME.
+ *
+ * @see cddb_cache_get_dir
+ *
+ * @param c The connection structure.
+ * @param dir The directory to use for caching.
+ */
+int cddb_cache_set_dir(cddb_conn_t *c, const char *dir);
+
+/**
+ * Retrieve the first CDDB mirror site.
+ *
+ * @param c The connection structure.
+ * @return The first mirror site or NULL if not found.
+ */
+const cddb_site_t *cddb_first_site(cddb_conn_t *c);
+
+/**
+ * Retrieve the next CDDB mirror site.
+ *
+ * @param c The connection structure.
+ * @return The next mirror site or NULL if not found.
+ */
+const cddb_site_t *cddb_next_site(cddb_conn_t *c);
+
+/**
+ * Set the bit-string specifying which fields to examine when
+ * performing a text search. By default only the artist and disc
+ * title fields are searched.
+ *
+ * @param c The connection structure.
+ * @param fields A bitwise ORed set of values from #cddb_search_t.
+ */
+void cddb_search_set_fields(cddb_conn_t *c, unsigned int fields);
+
+/**
+ * Set the bit-string specifying which categories to examine when
+ * performing a text search. The #SEARCHCAT macro needs to be used to
+ * build the actual bit-string from individual categories. The
+ * #cddb_search_t values #SEARCH_NONE and #SEARCH_ALL are also valid.
+ * The example below shows some possible combinations. By default all
+ * categories are searched.
+ *
+ * @code
+ * unsigned int cats = SEARCHCAT(CDDB_CAT_ROCK) | SEARCHCAT(CDDB_CAT_MISC);
+ * unsigned int cats = SEARCH_ALL;
+ * unsigned int cats = SEARCH_NONE;
+ * @endcode
+ *
+ * @param c The connection structure.
+ * @param cats A bitwise ORed set of values from #SEARCHCAT(#cddb_cat_t).
+ */
+void cddb_search_set_categories(cddb_conn_t *c, unsigned int cats);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_CONN_H */
diff --git a/include/cddb/cddb_conn_ni.h b/include/cddb/cddb_conn_ni.h
new file mode 100644
index 00000000..6eddbdcf
--- /dev/null
+++ b/include/cddb/cddb_conn_ni.h
@@ -0,0 +1,178 @@
+/*
+ $Id: cddb_conn_ni.h,v 1.14 2005/08/03 18:27:19 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_CONN_NI_H
+#define CDDB_CONN_NI_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include "cddb_ni.h"
+#include "ll.h"
+
+
+/* --- type definitions */
+
+
+/** Actual definition of iconv structure. */
+struct cddb_iconv_s
+{
+ iconv_t cd_to_freedb; /**< character set conversion descriptor for
+ converting from user to FreeDB format */
+ iconv_t cd_from_freedb; /**< character set conversion descriptor for
+ converting from FreeDB to user format */
+};
+
+/** Actual definition of serach parameters structure. */
+typedef struct cddb_search_params_s
+{
+ unsigned int fields; /**< fields to search (cddb_search_t
+ bit string) */
+ unsigned int cats; /**< categories to search (cddb_cat_t
+ bit string) */
+} cddb_search_params_t;
+
+/** Actual definition of connection structure. */
+struct cddb_conn_s
+{
+ unsigned int buf_size; /**< maximum line/buffer size, defaults to 1024
+ (see DEFAULT_BUF_SIZE) */
+ char *line; /**< last line read */
+
+ int is_connected; /**< are we already connected to the server? */
+ struct sockaddr_in sa; /**< the socket address structure for
+ connecting to the CDDB server */
+ int socket; /**< the socket file descriptor */
+ char *server_name; /**< host name of the CDDB server, defaults
+ to 'freedb.org' (see DEFAULT_SERVER) */
+ int server_port; /**< port of the CDDB server, defaults to 888
+ (see DEFAULT_PORT) */
+ int timeout; /**< time out interval (in seconds) used during
+ network operations, defaults to 10 seconds
+ (see DEFAULT_TIMEOUT) */
+
+ char *http_path_query; /**< URL for querying the server through HTTP,
+ defaults to /~cddb/cddb.cgi'
+ (see DEFAULT_PATH_QUERY) */
+ char *http_path_submit; /**< URL for submitting to the server through HTTP,
+ defaults to /~cddb/submit.cgi'
+ (see DEFAULT_PATH_SUBMIT) */
+ int is_http_enabled; /**< use HTTP, disabled by default */
+
+ int is_http_proxy_enabled; /**< use HTTP through a proxy server,
+ disabled by default */
+ char *http_proxy_server; /**< host name of the HTTP proxy server */
+ int http_proxy_server_port; /**< port of the HTTP proxy server,
+ defaults to 8080 (see DEFAULT_PROXY_PORT) */
+ char *http_proxy_username; /**< HTTP proxy user name */
+ char *http_proxy_password; /**< HTTP proxy password */
+ char *http_proxy_auth; /**< Base64 encoded username:password */
+
+ FILE *cache_fp; /**< a file pointer to a cached CDDB entry or
+ NULL if no cached version is available */
+ cddb_cache_mode_t use_cache;/**< field to specify local CDDB cache behaviour,
+ enabled by default (CACHE_ON) */
+ char *cache_dir; /**< CDDB slave cache, defaults to
+ '~/.cddbslave' (see DEFAULT_CACHE) */
+ int cache_read; /**< read data from cached file instead of
+ from the network */
+
+ char *cname; /**< name of the client program, 'libcddb' by
+ default */
+ char *cversion; /**< version of the client program, current
+ libcddb version by default */
+ char *user; /**< user name supplied to CDDB server, defaults
+ to the value of the 'USER' environment
+ variable or 'anonymous' if undefined */
+ char *hostname; /**< host name of the local machine, defaults
+ to the value of the 'HOSTNAME' environment
+ variable or 'localhost' if undefined */
+
+ cddb_error_t errnum; /**< error number of last CDDB command */
+
+ list_t *query_data; /**< list to keep CDDB query results */
+ list_t *sites_data; /**< list to keep FreeDB mirror sites */
+ cddb_search_params_t srch; /**< parameters for text search */
+
+ cddb_iconv_t charset; /**< character set conversion settings */
+};
+
+
+/* --- getters & setters --- */
+
+
+#define cddb_cache_file(c) (c)->cache_fp
+
+
+/* --- connecting / disconnecting --- */
+
+
+int cddb_connect(cddb_conn_t *c);
+
+void cddb_disconnect(cddb_conn_t *c);
+
+
+/* --- miscellaneous --- */
+
+
+/**
+ * Clone proxy settings from source connection to destinaton
+ * connection.
+ */
+void cddb_clone_proxy(cddb_conn_t *dst, cddb_conn_t *src);
+
+
+/* --- error handling --- */
+
+
+/**
+ * Set the error number for the last libcddb command.
+ *
+ * @param c The CDDB connection structure.
+ * @param n The error number
+ */
+#define cddb_errno_set(c, n) (c)->errnum = n
+
+/**
+ * Set the error number for the last libcddb command. If this number
+ * is different from CDDB_ERR_OK, a message is also logged with the
+ * level specified.
+ *
+ * @param c The CDDB connection structure.
+ * @param n The error number
+ * @param l The log level
+ */
+#define cddb_errno_log(c, n, l) cddb_errno_set(c, n); cddb_log(l, cddb_error_str(n))
+
+#define cddb_errno_log_debug(c, n) cddb_errno_log(c, n, CDDB_LOG_DEBUG)
+#define cddb_errno_log_info(c, n) cddb_errno_log(c, n, CDDB_LOG_INFO)
+#define cddb_errno_log_warn(c, n) cddb_errno_log(c, n, CDDB_LOG_WARN)
+#define cddb_errno_log_error(c, n) cddb_errno_log(c, n, CDDB_LOG_ERROR)
+#define cddb_errno_log_crit(c, n) cddb_errno_log(c, n, CDDB_LOG_CRITICAL)
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_CONN_NI_H */
diff --git a/include/cddb/cddb_disc.h b/include/cddb/cddb_disc.h
new file mode 100644
index 00000000..7951ae96
--- /dev/null
+++ b/include/cddb/cddb_disc.h
@@ -0,0 +1,450 @@
+/*
+ $Id: cddb_disc.h,v 1.22 2007/08/07 03:12:53 jcaratzas Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_DISC_H
+#define CDDB_DISC_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include <cddb/cddb_track.h>
+
+
+/**
+ * The number of frames that fit into one second.
+ */
+#define FRAMES_PER_SECOND 75
+
+/**
+ * This macro converts an amount of frames into an amount of seconds.
+ */
+#define FRAMES_TO_SECONDS(f) ((f) / FRAMES_PER_SECOND)
+
+/**
+ * This macro converts an amount of seconds into an amount of frames.
+ */
+#define SECONDS_TO_FRAMES(s) ((s) * FRAMES_PER_SECOND)
+
+/**
+ * The different CDDB categories.
+ */
+typedef enum {
+ CDDB_CAT_DATA = 0, /**< data disc */
+ CDDB_CAT_FOLK, /**< folk music */
+ CDDB_CAT_JAZZ, /**< jazz music */
+ CDDB_CAT_MISC, /**< miscellaneous, use if no other
+ category matches */
+ CDDB_CAT_ROCK, /**< rock and pop music */
+ CDDB_CAT_COUNTRY, /**< country music */
+ CDDB_CAT_BLUES, /**< blues music */
+ CDDB_CAT_NEWAGE, /**< new age music */
+ CDDB_CAT_REGGAE, /**< reggae music */
+ CDDB_CAT_CLASSICAL, /**< classical music */
+ CDDB_CAT_SOUNDTRACK, /**< soundtracks */
+ CDDB_CAT_INVALID, /**< (internal) invalid category */
+ CDDB_CAT_LAST /**< (internal) category counter */
+} cddb_cat_t;
+
+/**
+ * String values for the CDDB categories.
+ */
+extern const char *CDDB_CATEGORY[CDDB_CAT_LAST];
+
+/**
+ * The CDDB disc structure. Contains all information associated with
+ * a full CD.
+ */
+typedef struct cddb_disc_s cddb_disc_t;
+
+
+/* --- construction / destruction */
+
+
+/**
+ * Creates a new CDDB disc structure.
+ *
+ * @return The CDDB disc structure or NULL if memory allocation failed.
+ */
+cddb_disc_t *cddb_disc_new(void);
+
+/**
+ * Free all resources associated with the given CDDB disc structure.
+ * The tracks will also be freed automatically.
+ *
+ * @param disc The CDDB disc structure.
+ */
+void cddb_disc_destroy(cddb_disc_t *disc);
+
+/**
+ * Creates a clone of the given disc.
+ *
+ * @param disc The CDDB disc structure.
+ */
+cddb_disc_t *cddb_disc_clone(const cddb_disc_t *disc);
+
+
+/* --- track manipulation */
+
+
+/**
+ * Add a new track to a disc. The track is added to the end of the
+ * existing list of tracks.
+ *
+ * @param disc The CDDB disc structure.
+ * @param track The CDDB track structure.
+ */
+void cddb_disc_add_track(cddb_disc_t *disc, cddb_track_t *track);
+
+/**
+ * Retrieves a numbered track from the disc. If there is no track
+ * with the given number, then NULL will be returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @param track_no The track number; starting at 0.
+ */
+cddb_track_t *cddb_disc_get_track(const cddb_disc_t *disc, int track_no);
+
+/**
+ * Returns the first track of the disc. If there is no such track
+ * then NULL will be returned. The internal track iterator will also
+ * be reset. This function should be called before the first call to
+ * cddb_disc_get_track_next.
+ *
+ * @see cddb_disc_get_track_next
+ *
+ * @param disc The CDDB disc structure.
+ */
+cddb_track_t *cddb_disc_get_track_first(cddb_disc_t *disc);
+
+/**
+ * Returns the next track on the disc and advances the internal track
+ * iterator. If there is no such track then NULL will be returned.
+ * This function should be called after calling
+ * cddb_disc_get_track_first.
+ *
+ * @see cddb_disc_get_track_first
+ *
+ * @param disc The CDDB disc structure.
+ */
+cddb_track_t *cddb_disc_get_track_next(cddb_disc_t *disc);
+
+
+/* --- setters / getters --- */
+
+
+/**
+ * Get the ID of the disc. If the disc is invalid or the disc ID is
+ * not yet initialized 0 will be returned.
+ *
+ * @param disc The CDDB disc structure.
+ */
+unsigned int cddb_disc_get_discid(const cddb_disc_t *disc);
+
+/**
+ * Set the ID of the disc. When the disc ID is not known yet, then it
+ * can be calculated with the cddb_disc_calc_discid function (which
+ * will automatically initialize the correct field in the disc
+ * structure).
+ *
+ * @see cddb_disc_calc_discid
+ *
+ * @param disc The CDDB disc structure.
+ * @param id The disc ID.
+ */
+void cddb_disc_set_discid(cddb_disc_t *disc, unsigned int id);
+
+/**
+ * Get the disc CDDB category ID. If the disc is invalid or no
+ * category is set then CDDB_CAT_INVALID will be returned. If you
+ * want a string representation of the category use the
+ * cddb_disc_get_category_str function.
+ *
+ * @see cddb_disc_set_category
+ * @see cddb_disc_get_category_str
+ * @see cddb_disc_set_category_str
+ * @see cddb_cat_t
+ * @see CDDB_CATEGORY
+ *
+ * @param disc The CDDB disc structure.
+ * @return The CDDB category ID.
+ */
+cddb_cat_t cddb_disc_get_category(const cddb_disc_t *disc);
+
+/**
+ * Set the disc CDDB category ID.
+ *
+ * @see cddb_disc_get_category
+ * @see cddb_disc_get_category_str
+ * @see cddb_disc_set_category_str
+ * @see cddb_cat_t
+ * @see CDDB_CATEGORY
+ *
+ * @param disc The CDDB disc structure.
+ * @param cat The CDDB category ID.
+ */
+void cddb_disc_set_category(cddb_disc_t *disc, cddb_cat_t cat);
+
+/**
+ * Get the disc CDDB category as a string. If no category is set for
+ * this disc then 'invalid' will be returned. If the disc structure
+ * is invalid NULL is returned. If you only want the ID of the
+ * category use the cddb_disc_get_category function.
+ *
+ * @see cddb_disc_get_category
+ * @see cddb_disc_set_category
+ * @see cddb_disc_set_category_str
+ *
+ * @param disc The CDDB disc structure.
+ * @return The CDDB category ID.
+ */
+const char *cddb_disc_get_category_str(cddb_disc_t *disc);
+
+/**
+ * Sets the category of the disc. If the specified category is
+ * an invalid CDDB category, then CDDB_CAT_MISC will be used.
+ *
+ * @see cddb_disc_get_category
+ * @see cddb_disc_set_category
+ * @see cddb_disc_get_category_str
+ * @see CDDB_CATEGORY
+ *
+ * @param disc The CDDB disc structure.
+ * @param cat The category string.
+ */
+void cddb_disc_set_category_str(cddb_disc_t *disc, const char *cat);
+
+/**
+ * Get the disc genre. If no genre is set for this disc then NULL
+ * will be returned. As opposed to the disc category, this field is
+ * not limited to a predefined set.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The disc genre.
+ */
+const char *cddb_disc_get_genre(const cddb_disc_t *disc);
+
+/**
+ * Set the disc genre. As opposed to the disc category, this field is
+ * not limited to a predefined set. If the disc already had a genre,
+ * then the memory for that string will be freed. The new genre will
+ * be copied into a new chunk of memory.
+ *
+ * @see cddb_disc_get_category_str
+ *
+ * @param disc The CDDB disc structure.
+ * @param genre The disc genre.
+ */
+void cddb_disc_set_genre(cddb_disc_t *disc, const char *genre);
+
+/**
+ * Get the disc length. If no length is set for this disc then 0 will
+ * be returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The disc length in seconds.
+ */
+unsigned int cddb_disc_get_length(const cddb_disc_t *disc);
+
+/**
+ * Set the disc length.
+ *
+ * @param disc The CDDB disc structure.
+ * @param l The disc length in seconds.
+ */
+void cddb_disc_set_length(cddb_disc_t *disc, unsigned int l);
+
+/**
+ * Get the revision number of the disc.
+ *
+ * @param disc The CDDB disc structure.
+ */
+unsigned int cddb_disc_get_revision(const cddb_disc_t *disc);
+
+/**
+ * Set the revision number of the disc.
+ *
+ * @param disc The CDDB disc structure.
+ * @param rev The revision number.
+ */
+void cddb_disc_set_revision(cddb_disc_t *disc, unsigned int rev);
+
+/**
+ * Get the year of publication for this disc. If no year is defined 0
+ * is returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The disc year.
+ */
+unsigned int cddb_disc_get_year(const cddb_disc_t *disc);
+
+/**
+ * Set the year of publication for this disc.
+ *
+ * @param disc The CDDB disc structure.
+ * @param y The disc year.
+ */
+void cddb_disc_set_year(cddb_disc_t *disc, unsigned int y);
+
+/**
+ * Get the number of tracks on the disc. If the disc is invalid -1 is
+ * returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The number of tracks.
+ */
+int cddb_disc_get_track_count(const cddb_disc_t *disc);
+
+/**
+ * Get the disc title. If the disc is invalid or no title is set then
+ * NULL will be returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The disc title.
+ */
+const char *cddb_disc_get_title(const cddb_disc_t *disc);
+
+/**
+ * Set the disc title. If the disc already had a title, then the
+ * memory for that string will be freed. The new title will be copied
+ * into a new chunk of memory. If the given title is NULL, then the
+ * title of the disc will be deleted.
+ *
+ * @param disc The CDDB disc structure.
+ * @param title The new disc title.
+ */
+void cddb_disc_set_title(cddb_disc_t *disc, const char *title);
+
+/**
+ * Append to the disc title. If the disc does not have a title yet,
+ * then a new one will be created from the given string, otherwise
+ * that string will be appended to the existing title.
+ *
+ * @param disc The CDDB disc structure.
+ * @param title Part of the disc title.
+ */
+void cddb_disc_append_title(cddb_disc_t *disc, const char *title);
+
+/**
+ * Get the disc artist name. If the disc is invalid or no artist is
+ * set then NULL will be returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The disc artist name.
+ */
+const char *cddb_disc_get_artist(const cddb_disc_t *disc);
+
+/**
+ * Set the disc artist name. If the disc already had an artist name,
+ * then the memory for that string will be freed. The new artist name
+ * will be copied into a new chunk of memory. If the given artist
+ * name is NULL, then the artist name of the disc will be deleted.
+ *
+ * @param disc The CDDB disc structure.
+ * @param artist The new disc artist name.
+ */
+void cddb_disc_set_artist(cddb_disc_t *disc, const char *artist);
+
+/**
+ * Append to the disc artist. If the disc does not have an artist
+ * yet, then a new one will be created from the given string,
+ * otherwise that string will be appended to the existing artist.
+ *
+ * @param disc The CDDB disc structure.
+ * @param artist Part of the artist name.
+ */
+void cddb_disc_append_artist(cddb_disc_t *disc, const char *artist);
+
+/**
+ * Get the extended disc data. If the disc is invalid or no extended
+ * data is set then NULL will be returned.
+ *
+ * @param disc The CDDB disc structure.
+ * @return The extended data.
+ */
+const char *cddb_disc_get_ext_data(const cddb_disc_t *disc);
+
+/**
+ * Set the extended data for the disc. If the disc already had
+ * extended data, then the memory for that string will be freed. The
+ * new extended data will be copied into a new chunk of memory. If
+ * the given extended data is NULL, then the existing data will be
+ * deleted.
+ *
+ * @param disc The CDDB disc structure.
+ * @param ext_data The new extended data.
+ */
+void cddb_disc_set_ext_data(cddb_disc_t *disc, const char *ext_data);
+
+/**
+ * Append to the extended disc data. If the disc does not have an
+ * extended data section yet, then a new one will be created from the
+ * given string, otherwise that string will be appended to the
+ * existing data.
+ *
+ * @param disc The CDDB disc structure.
+ * @param ext_data Part of the extended disc data.
+ */
+void cddb_disc_append_ext_data(cddb_disc_t *disc, const char *ext_data);
+
+
+/* --- miscellaneous */
+
+
+/**
+ * Copy all data from one disc to another. Any fields that are
+ * unavailable in the source disc structure will not result in a reset
+ * of the same field in the destination disc structure; e.g. if there
+ * is no title in the source disc, but there is one in the destination
+ * disc, then the destination's title will remain unchanged.
+ *
+ * @param dst The destination CDDB disc structure.
+ * @param src The source CDDB disc structure.
+ */
+void cddb_disc_copy(cddb_disc_t *dst, cddb_disc_t *src);
+
+/**
+ * Calculate the CDDB disc ID. To calculate a disc ID the provided
+ * disc needs to have its length set, and every track in the disc
+ * structure needs to have its frame offset initialized. The disc ID
+ * field will be set in the disc structure.
+ *
+ * @param disc The CDDB disc structure.
+ * @return A non-zero value if the calculation succeeded, zero
+ * otherwise.
+ */
+int cddb_disc_calc_discid(cddb_disc_t *disc);
+
+/**
+ * Prints information about the disc on stdout. This is just a
+ * debugging routine to display the structure's content.
+ *
+ * @param disc The CDDB disc structure.
+ */
+void cddb_disc_print(cddb_disc_t *disc);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_DISC_H */
diff --git a/include/cddb/cddb_error.h b/include/cddb/cddb_error.h
new file mode 100644
index 00000000..6e779900
--- /dev/null
+++ b/include/cddb/cddb_error.h
@@ -0,0 +1,118 @@
+/*
+ $Id: cddb_error.h,v 1.12 2005/05/29 08:11:04 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_ERROR_H
+#define CDDB_ERROR_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include <stdio.h>
+
+
+/**
+ * A list of error codes returned by various libcddb functions.
+ */
+typedef enum {
+
+ CDDB_ERR_OK = 0, /**< no error occurred */
+
+ /* --- general errors --- */
+
+ CDDB_ERR_OUT_OF_MEMORY, /**< out of memory */
+ CDDB_ERR_LINE_SIZE, /**< internal buffer too small */
+ CDDB_ERR_NOT_IMPLEMENTED, /**< feature not (yet) implemented */
+ CDDB_ERR_UNKNOWN, /**< problem unknown */
+
+ /* --- connection errors --- */
+
+ CDDB_ERR_SERVER_ERROR, /**< CDDB server error */
+ CDDB_ERR_UNKNOWN_HOST_NAME, /**< unknown host name */
+ CDDB_ERR_CONNECT, /**< connection error */
+ CDDB_ERR_PERMISSION_DENIED, /**< permission denied */
+ CDDB_ERR_NOT_CONNECTED, /**< not yet connected or connection
+ has been closed */
+
+ /* --- response parsing errors --- */
+
+ CDDB_ERR_UNEXPECTED_EOF, /**< unexpected end-of-file encountered */
+ CDDB_ERR_INVALID_RESPONSE, /**< invalid response data */
+ CDDB_ERR_DISC_NOT_FOUND, /**< no results found */
+
+ /* --- library errors --- */
+
+ CDDB_ERR_DATA_MISSING, /**< some data is missing for executing
+ a certain command */
+ CDDB_ERR_TRACK_NOT_FOUND, /**< specified track is not present */
+ CDDB_ERR_REJECTED, /**< posted data rejected */
+ CDDB_ERR_EMAIL_INVALID, /**< the e-mail address used when
+ submitting is invalid */
+
+ CDDB_ERR_INVALID_CHARSET, /**< invalid character set or unsupported
+ conversion */
+ CDDB_ERR_ICONV_FAIL, /**< character set conversion failed */
+
+ /* --- new errors added to back of list for backward compatibility --- */
+
+ CDDB_ERR_PROXY_AUTH, /**< proxy authentication failed */
+ CDDB_ERR_INVALID, /**< invalid input parameter(s) */
+
+ /* --- terminator --- */
+
+ CDDB_ERR_LAST
+} cddb_error_t;
+
+
+/* --- error handling --- */
+
+
+/**
+ * Returns a string representation of the CDDB error code.
+ *
+ * @return The error string
+ */
+const char *cddb_error_str(cddb_error_t errnum);
+
+/**
+ * Prints the error message associated with the current error number
+ * on the given stream.
+ *
+ * @param stream The stream
+ * @param errnum The error number
+ */
+void cddb_error_stream_print(FILE *stream, cddb_error_t errnum);
+
+/**
+ * Prints the error message associated with the current error number
+ * to stderr.
+ *
+ * @param errnum The error number
+ */
+void cddb_error_print(cddb_error_t errnum);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_ERROR_H */
diff --git a/include/cddb/cddb_log.h b/include/cddb/cddb_log.h
new file mode 100644
index 00000000..30fe7899
--- /dev/null
+++ b/include/cddb/cddb_log.h
@@ -0,0 +1,87 @@
+/*
+ $Id: cddb_log.h,v 1.4 2005/03/11 21:29:29 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_LOH_H
+#define CDDB_LOG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/**
+ * The different log levels supported by libcddb.
+ */
+typedef enum {
+ CDDB_LOG_DEBUG = 1, /**< Debug-level messages. */
+ CDDB_LOG_INFO, /**< Informational. */
+ CDDB_LOG_WARN, /**< Warning conditions. */
+ CDDB_LOG_ERROR, /**< Error conditions. */
+ CDDB_LOG_CRITICAL, /**< Critical conditions. */
+ CDDB_LOG_NONE = 99 /**< No log messages. */
+} cddb_log_level_t;
+
+
+/**
+ * This type defines the signature of a libcddb log handler. For
+ * every message being logged by libcddb, the handler will receive the
+ * log level and the message string.
+ *
+ * @see cddb_log_set_handler
+ * @see cddb_log_level_t
+ *
+ * @param level The log level.
+ * @param message The log message.
+ */
+typedef void (*cddb_log_handler_t)(cddb_log_level_t level, const char *message);
+
+/**
+ * Set a custom log handler for libcddb. The return value is the log
+ * handler being replaced. If the provided parameter is NULL, then
+ * the handler will be reset to the default handler.
+ *
+ * @see cddb_log_handler_t
+ *
+ * @param new_handler The new log handler.
+ * @return The previous log handler.
+ */
+cddb_log_handler_t cddb_log_set_handler(cddb_log_handler_t new_handler);
+
+/**
+ * Set the minimum log level. This function is only useful in
+ * conjunction with the default log handler. The default log handler
+ * will print any log messages that have a log level equal or higher
+ * than this minimum log level to stderr. By default the minimum log
+ * level is set to CDDB_LOG_WARN. This means that only warning, error
+ * and critical messages will be printed. You can silence the default
+ * log handler by setting the minimum log level to CDDB_LOG_NONE.
+ *
+ * @see cddb_log_level_t
+ *
+ * @param level The minimum log level.
+ */
+void cddb_log_set_level(cddb_log_level_t level);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_LOG_H */
diff --git a/include/cddb/cddb_log_ni.h b/include/cddb/cddb_log_ni.h
new file mode 100644
index 00000000..ea7727fc
--- /dev/null
+++ b/include/cddb/cddb_log_ni.h
@@ -0,0 +1,59 @@
+/*
+ $Id: cddb_log_ni.h,v 1.3 2005/03/11 21:29:29 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_LOH_NI_H
+#define CDDB_LOG_NI_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/**
+ */
+void cddb_log(cddb_log_level_t level, const char *format, ...);
+
+/**
+ */
+#define cddb_log_debug(...) cddb_log(CDDB_LOG_DEBUG, __VA_ARGS__)
+
+/**
+ */
+#define cddb_log_info(...) cddb_log(CDDB_LOG_INFO, __VA_ARGS__)
+
+/**
+ */
+#define cddb_log_warn(...) cddb_log(CDDB_LOG_WARN, __VA_ARGS__)
+
+/**
+ */
+#define cddb_log_error(...) cddb_log(CDDB_LOG_ERROR, __VA_ARGS__)
+
+/**
+ */
+#define cddb_log_crit(...) cddb_log(CDDB_LOG_CRITICAL, __VA_ARGS__)
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_LOG_NI_H */
diff --git a/include/cddb/cddb_net.h b/include/cddb/cddb_net.h
new file mode 100644
index 00000000..60c5464b
--- /dev/null
+++ b/include/cddb/cddb_net.h
@@ -0,0 +1,133 @@
+/*
+ $Id: cddb_net.h,v 1.11 2005/03/11 21:29:29 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_NET_H
+#define CDDB_NET_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include <stdarg.h>
+
+#if defined( UNDER_CE )
+# include <winsock.h>
+#elif defined( WIN32 )
+# include <winsock2.h>
+# include <ws2tcpip.h>
+#endif
+
+#include <cddb/cddb_ni.h>
+#include <cddb/cddb_config.h>
+
+#if defined(CDDB_NEED_SYS_SOCKET_H) || defined(HAVE_SYS_SOCKET_H)
+#include <sys/socket.h>
+#endif
+
+
+/* --- socket-based work-alikes --- */
+
+
+/**
+ * This function performs the same task as the standard fgets except
+ * for the fact that it might time-out if the socket read takes too
+ * long. In case of a time out, errno will be set to ETIMEDOUT.
+ *
+ * @param s The string buffer.
+ * @param size Size of the buffer.
+ * @param c The CDDB connection structure.
+ * @return The string that was read or NULL on error or EOF when no
+ * characters were read.
+ */
+char *sock_fgets(char *s, int size, cddb_conn_t *c);
+
+/**
+ * This function performs the same task as the standard fwrite except
+ * for the fact that it might time-out if the socket write takes too
+ * long. In case of a time out, errno will be set to ETIMEDOUT.
+ *
+ * @param ptr Pointer to data record.
+ * @param size Size of data record.
+ * @param nmemb The number of data records to write.
+ * @param c The CDDB connection structure.
+ * @return The number of records written.
+ */
+size_t sock_fwrite(const void *ptr, size_t size, size_t nmemb, cddb_conn_t *c);
+
+/**
+ * This function performs the same task as the standard fprintf except
+ * for the fact that it might time-out if the socket write takes too
+ * long. In case of a time out, errno will be set to ETIMEDOUT.
+ *
+ * @param c The CDDB connection structure.
+ * @param format Pointer to data record.
+ * @return The number of characters written.
+ */
+int sock_fprintf(cddb_conn_t *c, const char *format, ...);
+
+/**
+ * This function performs the same task as the standard vfprintf
+ * except for the fact that it might time-out if the socket write
+ * takes too long. In case of a time out, errno will be set to
+ * ETIMEDOUT.
+ *
+ * @param c The CDDB connection structure.
+ * @param format Pointer to data record.
+ * @param ap Variable argument list.
+ * @return The number of characters written.
+ */
+int sock_vfprintf(cddb_conn_t *c, const char *format, va_list ap);
+
+/* --- time-out enabled work-alikes --- */
+
+/**
+ * This function performs the same task as the standard gethostbyname
+ * except for the fact that it might time-out if the query takes too
+ * long. In case of a time out, errno will be set to ETIMEDOUT.
+ *
+ * @param hostname The hostname that needs to be resolved.
+ * @param timeout Number of seconds after which to time out.
+ * @return The host entity for given host name or NULL if not found or
+ * timed out (errno will be set).
+ */
+struct hostent *timeout_gethostbyname(const char *hostname, int timeout);
+
+/**
+ * This function performs the same task as the standard connect except
+ * for the fact that it might time-out if the connect takes too long.
+ * In case of a time out, errno will be set to ETIMEDOUT.
+ *
+ * @param sockfd The socket.
+ * @param addr The address to connect to.
+ * @param len The size of the address structure.
+ * @param timeout Number of seconds after which to time out.
+ * @return Zero on success, -1 on failure (errno will be set).
+ */
+int timeout_connect(int sockfd, const struct sockaddr *addr, size_t len,
+ int timeout);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_NET_H */
diff --git a/include/cddb/cddb_ni.h b/include/cddb/cddb_ni.h
new file mode 100644
index 00000000..d32fdc13
--- /dev/null
+++ b/include/cddb/cddb_ni.h
@@ -0,0 +1,189 @@
+/*
+ $Id: cddb_ni.h,v 1.32 2009/03/01 03:28:07 jcaratzas Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_NI_H
+#define CDDB_NI_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_ICONV_H
+# include <iconv.h>
+#else
+ typedef void *iconv_t; /* for code uniformity */
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#ifndef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#endif
+#endif
+
+#include "cddb/cddb_regex.h"
+#include "cddb/cddb.h"
+#include "cddb/cddb_conn_ni.h"
+#include "cddb/cddb_net.h"
+#include "cddb/cddb_cmd_ni.h"
+#include "cddb/cddb_log_ni.h"
+
+
+#define FALSE 0
+#define TRUE 1
+
+#define CHR_CR '\r'
+#define CHR_LF '\n'
+#define CHR_EOS '\0'
+#define CHR_SPACE ' '
+#define CHR_DOT '.'
+
+#define DEFAULT_BUF_SIZE 1024
+
+#define CLIENT_NAME PACKAGE
+#define CLIENT_VERSION VERSION
+
+#define DEFAULT_USER "anonymous"
+#define DEFAULT_HOST "localhost"
+#define DEFAULT_SERVER "freedb.org"
+#define DEFAULT_PORT 888
+#define DEFAULT_TIMEOUT 10
+#define DEFAULT_PATH_QUERY "/~cddb/cddb.cgi"
+#define DEFAULT_PATH_SUBMIT "/~cddb/submit.cgi"
+#define DEFAULT_CACHE ".cddbslave"
+#define DEFAULT_PROXY_PORT 8080
+
+#define DEFAULT_PROTOCOL_VERSION 6
+#define SERVER_CHARSET "UTF8"
+
+
+#define FREE_NOT_NULL(p) if (p) { free(p); p = NULL; }
+#define CONNECTION_OK(c) (c->socket != -1)
+#define STR_OR_NULL(s) ((s) ? s : "NULL")
+#define STR_OR_EMPTY(s) ((s) ? s : "")
+
+#define RETURN_STR_OR_EMPTY(s) \
+ return (!s && (libcddb_flags() & CDDB_F_EMPTY_STR)) ? "" : s
+
+#define ASSERT(cond, error) \
+ if (!(cond)) { return error; }
+#define ASSERT_NOT_NULL(ptr) \
+ ASSERT(ptr!=NULL, CDDB_ERR_INVALID)
+#define ASSERT_RANGE(num,lo,hi) \
+ ASSERT((num>=lo)&&(num<=hi), CDDB_ERR_INVALID)
+
+
+/* --- type definitions */
+
+
+/** Actual definition of track structure. */
+struct cddb_track_s
+{
+ int num; /**< track number on the disc */
+ int frame_offset; /**< frame offset of the track on the disc */
+ int length; /**< track length in seconds */
+ char *title; /**< track title */
+ char *artist; /**< (optional) track artist */
+ char *ext_data; /**< (optional) extended disc data */
+ struct cddb_track_s *prev; /**< pointer to previous track, or NULL */
+ struct cddb_track_s *next; /**< pointer to next track, or NULL */
+ struct cddb_disc_s *disc; /**< disc of which this is a track */
+};
+
+/** Actual definition of disc structure. */
+struct cddb_disc_s
+{
+ unsigned int revision; /**< revision number */
+ unsigned int discid; /**< four byte disc ID */
+ cddb_cat_t category; /**< CDDB category */
+ char *genre; /**< disc genre */
+ char *title; /**< disc title */
+ char *artist; /**< disc artist */
+ unsigned int length; /**< disc length in seconds */
+ unsigned int year; /**< (optional) disc year YYYY */
+ char *ext_data; /**< (optional) extended disc data */
+ int track_cnt; /**< number of tracks on the disc */
+ cddb_track_t *tracks; /**< pointer to the first track */
+ cddb_track_t *iterator; /**< track iterator */
+};
+
+
+/* --- global variables */
+
+
+/** Server connection used especially for text searches. */
+extern cddb_conn_t *cddb_search_conn;
+
+
+/* --- non-exported function prototypes */
+
+
+unsigned int libcddb_flags(void);
+
+/**
+ * Convert a string to a new character encoding according to the given
+ * conversion descriptor.
+ */
+int cddb_str_iconv(iconv_t cd, ICONV_CONST char *in, char **out);
+
+/**
+ * Converts all disc and track strings to user character encoding.
+ */
+int cddb_disc_iconv(iconv_t cd, cddb_disc_t *disc);
+
+/**
+ * Converts all track strings to user character encoding.
+ */
+int cddb_track_iconv(iconv_t cd, cddb_track_t *track);
+
+/**
+ * Converts all site strings to user character encoding.
+ */
+int cddb_site_iconv(iconv_t cd, cddb_site_t *site);
+
+/**
+ * Base64 encode the source string and write it to the destination
+ * buffer. The destination buffer should be large enough (= 4/3 of
+ * src string length).
+ */
+void cddb_b64_encode(char *dst, const char *src);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_NI_H */
diff --git a/include/cddb/cddb_regex.h b/include/cddb/cddb_regex.h
new file mode 100644
index 00000000..9b50e097
--- /dev/null
+++ b/include/cddb/cddb_regex.h
@@ -0,0 +1,74 @@
+/*
+ $Id: cddb_regex.h,v 1.14 2007/08/07 03:12:53 jcaratzas Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_REGEX_H
+#define CDDB_REGEX_H 1
+
+#ifdef HAVE_REGEX_H
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <cddb/cddb_config.h>
+#include <stdlib.h>
+
+#ifdef CDDB_NEED_UNISTD_H
+#include <unistd.h>
+#endif
+#include <sys/types.h> /* need for MacOS X */
+#include <regex.h>
+
+
+extern regex_t *REGEX_TRACK_FRAME_OFFSETS;
+extern regex_t *REGEX_TRACK_FRAME_OFFSET;
+extern regex_t *REGEX_DISC_LENGTH;
+extern regex_t *REGEX_DISC_REVISION;
+extern regex_t *REGEX_DISC_TITLE;
+extern regex_t *REGEX_DISC_YEAR;
+extern regex_t *REGEX_DISC_GENRE;
+extern regex_t *REGEX_DISC_EXT;
+extern regex_t *REGEX_TRACK_TITLE;
+extern regex_t *REGEX_TRACK_EXT;
+extern regex_t *REGEX_PLAY_ORDER;
+extern regex_t *REGEX_QUERY_MATCH;
+extern regex_t *REGEX_SITE;
+extern regex_t *REGEX_TEXT_SEARCH;
+
+
+void cddb_regex_init(void);
+
+void cddb_regex_destroy(void);
+
+int cddb_regex_get_int(const char *s, regmatch_t matches[], int idx);
+
+unsigned long cddb_regex_get_hex(const char *s, regmatch_t matches[], int idx);
+
+double cddb_regex_get_float(const char *s, regmatch_t matches[], int idx);
+
+char *cddb_regex_get_string(const char *s, regmatch_t matches[], int idx);
+
+
+#ifdef __cplusplus
+ }
+#endif
+#endif /* HAVE_REGEX_H */
+
+#endif /* CDDB_REGEX_H */
diff --git a/include/cddb/cddb_site.h b/include/cddb/cddb_site.h
new file mode 100644
index 00000000..9c48ac6c
--- /dev/null
+++ b/include/cddb/cddb_site.h
@@ -0,0 +1,248 @@
+/*
+ $Id: cddb_site.h,v 1.3 2005/06/15 16:08:28 airborne Exp $
+
+ Copyright (C) 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_SITE_H
+#define CDDB_SITE_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+#include "cddb/cddb_error.h"
+
+
+/* --- type and structure definitions */
+
+
+/**
+ * Enumeration defining the CDDB protocol supported by a specific
+ * site.
+ */
+typedef enum {
+ PROTO_UNKNOWN = 0, /**< Unknown protocol */
+ PROTO_CDDBP, /**< FreeDB custom protocol */
+ PROTO_HTTP /**< Command tunneling over HTTP */
+} cddb_protocol_t;
+
+/**
+ * The CDDB site structure. Contains all information about one
+ * particular CDDB server.
+ */
+typedef struct cddb_site_s cddb_site_t;
+
+
+/* --- construction / destruction */
+
+
+/**
+ * Creates a new CDDB site structure.
+ *
+ * @return The CDDB site structure or NULL if memory allocation failed.
+ */
+cddb_site_t *cddb_site_new(void);
+
+/**
+ * Free all resources associated with the given CDDB site structure.
+ *
+ * @param site The CDDB site structure.
+ */
+cddb_error_t cddb_site_destroy(cddb_site_t *site);
+
+/**
+ * Creates a clone of the given site.
+ *
+ * @param site The CDDB site structure.
+ */
+cddb_site_t *cddb_site_clone(cddb_site_t *site);
+
+
+/* --- setters / getters --- */
+
+
+/**
+ * Get the site's address.
+ *
+ * @param site The CDDB site structure.
+ * @param address The address of the server upon returning.
+ * @param port The port of the server upon returning.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_get_address(const cddb_site_t *site,
+ const char **address, unsigned int *port);
+
+/**
+ * Set the site's address. A copy of the address string is made. So the caller
+ * should free any memory associated with the input parameter.
+ *
+ * @param site The CDDB site structure.
+ * @param address The address of the server.
+ * @param port The port of the server.
+ * @return Error code: CDDB_ERR_OK, CDDB_ERR_INVALID or CDDB_ERR_OUT_OF_MEMORY.
+ */
+cddb_error_t cddb_site_set_address(cddb_site_t *site,
+ const char *address, unsigned int port);
+
+/**
+ * Get the protocol used by the site.
+ *
+ * @see cddb_protocol_t
+ *
+ * @param site The CDDB site structure.
+ * @return The protocol.
+ */
+cddb_protocol_t cddb_site_get_protocol(const cddb_site_t *site);
+
+/**
+ * Set the protocol used by the site.
+ *
+ * @see cddb_protocol_t
+ *
+ * @param site The CDDB site structure.
+ * @param proto The protocol.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_set_protocol(cddb_site_t *site, cddb_protocol_t proto);
+
+/**
+ * Get the query path in case the HTTP protocol is used.
+ *
+ * @param site The CDDB site structure.
+ * @param path The query path upon returning.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_get_query_path(const cddb_site_t *site,
+ const char **path);
+
+/**
+ * Set the query path in case the HTTP protocol is used. A copy of the path
+ * string is made. So the caller should free any memory associated with the
+ * input parameter.
+ *
+ * @param site The CDDB site structure.
+ * @param path The query path. A value of NULL deletes the current path.
+ * @return Error code: CDDB_ERR_OK, CDDB_ERR_INVALID or CDDB_ERR_OUT_OF_MEMORY.
+ */
+cddb_error_t cddb_site_set_query_path(cddb_site_t *site, const char *path);
+
+/**
+ * Get the submit path in case the HTTP protocol is used.
+ *
+ * @param site The CDDB site structure.
+ * @param path The submit path upon returning.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_get_submit_path(const cddb_site_t *site,
+ const char **path);
+
+/**
+ * Set the submit path in case the HTTP protocol is used. A copy of the path
+ * string is made. So the caller should free any memory associated with the
+ * input parameter.
+ *
+ * @param site The CDDB site structure.
+ * @param path The query path. A value of NULL deletes the current path.
+ * @return Error code: CDDB_ERR_OK, CDDB_ERR_INVALID or CDDB_ERR_OUT_OF_MEMORY.
+ */
+cddb_error_t cddb_site_set_submit_path(cddb_site_t *site, const char *path);
+
+/**
+ * Get the site's location.
+ *
+ * @param site The CDDB site structure.
+ * @param latitude Will contain the server's latitude upon returning.
+ * A positive number is used for the northern
+ * hemisphere, a negative one for the southern
+ * hemisphere.
+ * @param longitude Will contain the server's longitude upon returning.
+ * A positive number is used for the eastern
+ * hemisphere, a negative one for the western
+ * hemisphere.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_get_location(const cddb_site_t *site,
+ float *latitude, float *longitude);
+
+/**
+ * Set the site's location.
+ *
+ * @param site The CDDB site structure.
+ * @param latitude The server's latitude. Use a positive number for the
+ * northern hemisphere, a negative one for the southern
+ * hemisphere.
+ * @param longitude The server's longitude. Use a positive number for the
+ * eastern hemisphere, a negative one for the western
+ * hemisphere.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_set_location(cddb_site_t *site,
+ float latitude, float longitude);
+
+/**
+ * Get a description of the site.
+ *
+ * @param site The CDDB site structure.
+ * @param desc The description upon returning.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_get_description(const cddb_site_t *site,
+ const char **desc);
+
+/**
+ * Set a description for the site. A copy of the description string is made.
+ * So the caller should free any memory associated with the input parameter.
+ *
+ * @param site The CDDB site structure.
+ * @param desc The description. A value of NULL deletes the current
+ * description.
+ * @return Error code: CDDB_ERR_OK, CDDB_ERR_INVALID or CDDB_ERR_OUT_OF_MEMORY.
+ */
+cddb_error_t cddb_site_set_description(cddb_site_t *site, const char *desc);
+
+
+/* --- miscellaneous */
+
+
+/**
+ * Parses one line of data as returned by the sites command and
+ * populates the given structure.
+ *
+ * @param site The CDDB site structure.
+ * @param line The result line.
+ * @return True in case of success or false on failure.
+ */
+int cddb_site_parse(cddb_site_t *site, const char *line);
+
+/**
+ * Prints information about the site on stdout. This is just a
+ * debugging routine to display the structure's content.
+ *
+ * @param site The CDDB site structure.
+ * @return Error code: CDDB_ERR_OK or CDDB_ERR_INVALID.
+ */
+cddb_error_t cddb_site_print(const cddb_site_t *site);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_SITE_H */
diff --git a/include/cddb/cddb_track.h b/include/cddb/cddb_track.h
new file mode 100644
index 00000000..0f6ee0f9
--- /dev/null
+++ b/include/cddb/cddb_track.h
@@ -0,0 +1,244 @@
+/*
+ $Id: cddb_track.h,v 1.20 2006/10/15 06:51:11 airborne Exp $
+
+ Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CDDB_TRACK_H
+#define CDDB_TRACK_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/**
+ * The CDDB track structure. Contains all information associated with
+ * a single CD track. This structure will be used to populate the
+ * tracks linked list of the cddb_disc_s structure.
+ */
+typedef struct cddb_track_s cddb_track_t;
+
+
+/* --- construction / destruction */
+
+
+/**
+ * Creates a new CDDB track structure.
+ *
+ * @return The CDDB track structure or NULL if memory allocation failed.
+ */
+cddb_track_t *cddb_track_new(void);
+
+/**
+ * Free all resources associated with the given CDDB track structure.
+ * The linked list pointer (next) will not be touched. So you have to
+ * make sure that no other tracks are attached to this one before
+ * calling this function.
+ *
+ * @param track The CDDB track structure.
+ */
+void cddb_track_destroy(cddb_track_t *track);
+
+/**
+ * Creates a clone of the given track.
+ *
+ * @param track The CDDB track structure.
+ */
+cddb_track_t *cddb_track_clone(const cddb_track_t *track);
+
+
+/* --- getters & setters --- */
+
+
+/**
+ * Get the number of this track. This track number starts counting at
+ * 1. If the track is invalid or the track number is not defined -1
+ * will be returned.
+ *
+ * @param track The CDDB track structure.
+ * @return The track number.
+ */
+int cddb_track_get_number(const cddb_track_t *track);
+
+/**
+ * Get the frame offset of this track on the disc. If the track is
+ * invalid -1 will be returned.
+ *
+ * @param track The CDDB track structure.
+ * @return The frame offset.
+ */
+int cddb_track_get_frame_offset(const cddb_track_t *track);
+
+/**
+ * Set the frame offset of this track on the disc.
+ *
+ * @param track The CDDB track structure.
+ * @param offset The frame offset.
+ * @return The frame offset.
+ */
+void cddb_track_set_frame_offset(cddb_track_t *track, int offset);
+
+/**
+ * Get the length of the track in seconds. If the track length is not
+ * defined this routine will try to calculate it using the frame
+ * offsets of the tracks and the total disc length. These
+ * calculations will do no rounding to the nearest second. So it is
+ * possible that the sum off all track lengths does not add up to the
+ * actual disc length. If the length can not be calculated -1 will be
+ * returned.
+ *
+ * @param track The CDDB track structure.
+ * @return The track length.
+ */
+int cddb_track_get_length(cddb_track_t *track);
+
+/**
+ * Set the length of the track. If no frame offset is yet known for
+ * this track, and it is part of a disc, then the frame offset will be
+ * calculated.
+ *
+ * @param track The CDDB track structure.
+ * @param length The track length in seconds.
+ */
+void cddb_track_set_length(cddb_track_t *track, int length);
+
+/**
+ * Get the track title. If the track is invalid or no title is set
+ * for this track then NULL will be returned.
+ *
+ * @param track The CDDB track structure.
+ * @return The track title.
+ */
+const char *cddb_track_get_title(const cddb_track_t *track);
+
+/**
+ * Set the track title. If the track already had a title, then the
+ * memory for that string will be freed. The new title will be copied
+ * into a new chunk of memory. If the given title is NULL, then the
+ * title of the track will be deleted.
+ *
+ * @param track The CDDB track structure.
+ * @param title The new track title.
+ */
+void cddb_track_set_title(cddb_track_t *track, const char *title);
+
+/**
+ * Append to the track title. If the track does not have a title yet,
+ * then a new one will be created from the given string, otherwise
+ * that string will be appended to the existing title.
+ *
+ * @param track The CDDB track structure.
+ * @param title Part of the track title.
+ */
+void cddb_track_append_title(cddb_track_t *track, const char *title);
+
+/**
+ * Get the track artist name. If there is no track artist defined,
+ * the disc artist will be returned. NULL will be returned if neither
+ * is defined.
+ *
+ * @param track The CDDB track structure.
+ */
+const char *cddb_track_get_artist(cddb_track_t *track);
+
+/**
+ * Set the track artist name. If the track already had an artist
+ * name, then the memory for that string will be freed. The new
+ * artist name will be copied into a new chunk of memory. If the given artist
+ * name is NULL, then the artist name of the track will be deleted.
+ *
+ * @param track The CDDB track structure.
+ * @param artist The new track artist name.
+ */
+void cddb_track_set_artist(cddb_track_t *track, const char *artist);
+
+/**
+ * Append to the track artist. If the track does not have an artist
+ * yet, then a new one will be created from the given string,
+ * otherwise that string will be appended to the existing artist.
+ *
+ * @param track The CDDB track structure.
+ * @param artist Part of the artist name.
+ */
+void cddb_track_append_artist(cddb_track_t *track, const char *artist);
+
+/**
+ * Get the extended track data. If no extended data is set for this
+ * track then NULL will be returned.
+ *
+ * @param track The CDDB track structure.
+ * @return The extended data.
+ */
+const char *cddb_track_get_ext_data(cddb_track_t *track);
+
+/**
+ * Set the extended data for the track. If the track already had
+ * extended data, then the memory for that string will be freed. The
+ * new extended data will be copied into a new chunk of memory. If
+ * the given extended data is NULL, then the existing data will be
+ * deleted.
+ *
+ * @param track The CDDB track structure.
+ * @param ext_data The new extended data.
+ */
+void cddb_track_set_ext_data(cddb_track_t *track, const char *ext_data);
+
+/**
+ * Append to the extended track data. If the track does not have an
+ * extended data section yet, then a new one will be created from the
+ * given string, otherwise that string will be appended to the
+ * existing data.
+ *
+ * @param track The CDDB track structure.
+ * @param ext_data Part of the extended track data.
+ */
+void cddb_track_append_ext_data(cddb_track_t *track, const char *ext_data);
+
+
+/* --- miscellaneous */
+
+
+/**
+ * Copy all data from one track to another. Any fields that are
+ * unavailable in the source track structure will not result in a
+ * reset of the same field in the destination track structure; e.g. if
+ * there is no title in the source track, but there is one in the
+ * destination track, then the destination's title will remain
+ * unchanged.
+ *
+ * @param dst The destination CDDB track structure.
+ * @param src The source CDDB track structure.
+ */
+void cddb_track_copy(cddb_track_t *dst, cddb_track_t *src);
+
+/**
+ * Prints information about the track on stdout. This is just a
+ * debugging routine to display the structure's content. It is used
+ * by cddb_disc_print to print the contents of a complete disc.
+ *
+ * @param track The CDDB track structure.
+ */
+void cddb_track_print(cddb_track_t *track);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* CDDB_TRACK_H */
diff --git a/include/cddb/ll.h b/include/cddb/ll.h
new file mode 100644
index 00000000..9486e59f
--- /dev/null
+++ b/include/cddb/ll.h
@@ -0,0 +1,148 @@
+/*
+ $Id: ll.h,v 1.1 2005/05/29 08:24:04 airborne Exp $
+
+ Copyright (C) 2005 Kris Verbeeck <airborne@advalvas.be>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef LL_H
+#define LL_H 1
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/* --- type definitions */
+
+
+/**
+ * Linked list element.
+ */
+typedef struct elem_s elem_t;
+
+/**
+ * Linked list.
+ */
+typedef struct list_s list_t;
+
+/**
+ * Callback prototype for destroying element data.
+ */
+typedef void elem_destroy_cb(void *data);
+
+
+/* --- construction / destruction */
+
+
+/**
+ * Creates a new linked list.
+ *
+ * @param cb The callback used to destroy the element data or NULL if
+ * no further action is required.
+ * @return The linked list structure or NULL if memory allocation failed.
+ */
+list_t *list_new(elem_destroy_cb *cb);
+
+/**
+ * Free all resources associated with the given linked list. Embedded
+ * data will be freed by use of the callback registered at list
+ * creation.
+ *
+ * @param list The linked list.
+ */
+void list_destroy(list_t *list);
+
+/**
+ * Remove all elements from the list without destroying the list
+ * itself. Embedded data will be freed by use of the callback
+ * registered at list creation.
+ *
+ * @param list The linked list.
+ */
+void list_flush(list_t *list);
+
+
+/* --- list elements --- */
+
+/**
+ * Retrieves the data associated with a list element.
+ *
+ * @param elem The list element.
+ * @return The data associated with the element or NULL if the element
+ * was invalid.
+ */
+void *element_data(elem_t *elem);
+
+
+/* --- getters & setters --- */
+
+
+/**
+ * Append a new element to the end of the list.
+ *
+ * @param list The linked list.
+ * @param data The data to append to the list.
+ * @return The list element that was appended or NULL if memory
+ * allocation fails or the list is invalid.
+ */
+elem_t *list_append(list_t *list, void *data);
+
+/**
+ * Returns the number of elements in the list.
+ *
+ * @param list The linked list.
+ * @return The number of elements.
+ */
+int list_size(list_t *list);
+
+/**
+ * Returns the list element at the specified index or NULL if the
+ * index is invalid.
+ *
+ * @param list The linked list.
+ * @param idx The element index (first = 0).
+ * @return The element or NULL if not found.
+ */
+elem_t *list_get(list_t *list, int idx);
+
+/**
+ * Returns the first list element.
+ *
+ * @param list The linked list.
+ * @return The first element or NULL if the list is empty.
+ */
+elem_t *list_first(list_t *list);
+
+/**
+ * Returns the next list element. Before using this function you
+ * should call list_first to initialize the iterator.
+ *
+ * @param list The linked list.
+ * @return The next element or NULL if not found.
+ */
+elem_t *list_next(list_t *list);
+
+
+/* --- iteration */
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* LL_H */
diff --git a/include/cddb/version.h b/include/cddb/version.h
new file mode 100644
index 00000000..f72839b2
--- /dev/null
+++ b/include/cddb/version.h
@@ -0,0 +1,12 @@
+/* $Id: version.h.in,v 1.1 2005/04/08 01:49:35 rockyb Exp $ */
+/** \file version.h
+ *
+ * \brief A file containing the libcdio package version
+ * number (131) and OS build name.
+ */
+
+/*! CDDB_VERSION can as a string in programs to show what version is used. */
+#define CDDB_VERSION "1.3.2 i686-pc-linux-gnu"
+
+/*! LIBCDDB_VERSION_NUM can be used for testing in the C preprocessor */
+#define LIBCDDB_VERSION_NUM 131
diff --git a/include/cddb/version.h.in b/include/cddb/version.h.in
new file mode 100644
index 00000000..48d4c3fc
--- /dev/null
+++ b/include/cddb/version.h.in
@@ -0,0 +1,12 @@
+/* $Id: version.h.in,v 1.1 2005/04/08 01:49:35 rockyb Exp $ */
+/** \file version.h
+ *
+ * \brief A file containing the libcdio package version
+ * number (@LIBCDDB_VERSION_NUM@) and OS build name.
+ */
+
+/*! CDDB_VERSION can as a string in programs to show what version is used. */
+#define CDDB_VERSION "@VERSION@ @build@"
+
+/*! LIBCDDB_VERSION_NUM can be used for testing in the C preprocessor */
+#define LIBCDDB_VERSION_NUM @LIBCDDB_VERSION_NUM@