| cddb_conn.h | | cddb_conn.h | |
| /* | | /* | |
|
| $Id: cddb_conn.h,v 1.26 2005/05/07 09:16:21 airborne Exp $ | | $Id: cddb_conn.h,v 1.29 2005/07/09 08:29:19 airborne Exp $ | |
| | | | |
| Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | | Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| #ifndef CDDB_CONN_H | | #ifndef CDDB_CONN_H | |
| #define CDDB_CONN_H 1 | | #define CDDB_CONN_H 1 | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include <netinet/in.h> | | #include <netinet/in.h> | |
| | | | |
|
| #define CACHE_OFF 0 /**< do not use local CDDB cache, network | | #include "cddb/cddb_site.h" | |
| | | | |
| | | typedef enum { | |
| | | CACHE_OFF = 0, /**< do not use local CDDB cache, network | |
| only */ | | only */ | |
|
| #define CACHE_ON 1 /**< use local CDDB cache, if possible */ | | CACHE_ON, /**< use local CDDB cache, if possible */ | |
| #define CACHE_ONLY 2 /**< only use local CDDB cache, no network | | CACHE_ONLY /**< only use local CDDB cache, no network | |
| access */ | | access */ | |
|
| | | } cddb_cache_mode_t; | |
| | | | |
| /** | | /** | |
| * Forward declaration of opaque structure used for character set | | * Forward declaration of opaque structure used for character set | |
| * conversions. | | * conversions. | |
| */ | | */ | |
| typedef struct cddb_iconv_s *cddb_iconv_t; | | typedef struct cddb_iconv_s *cddb_iconv_t; | |
| | | | |
| /** | | /** | |
| * An opaque structure for keeping state about the connection to a | | * An opaque structure for keeping state about the connection to a | |
| * CDDB server. | | * CDDB server. | |
| */ | | */ | |
|
| typedef struct cddb_conn_s | | typedef struct cddb_conn_s cddb_conn_t; | |
| { | | | |
| 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 8 | | | |
| 88 | | | |
| (see DEFAULT_PORT) */ | | | |
| int timeout; /**< time out interval (in seconds) used du | | | |
| ring | | | |
| network operations, defaults to 10 sec | | | |
| onds | | | |
| (see DEFAULT_TIMEOUT) */ | | | |
| | | | |
| char *http_path_query; /**< URL for querying the server through HT | | | |
| TP, | | | |
| defaults to /~cddb/cddb.cgi' | | | |
| (see DEFAULT_PATH_QUERY) */ | | | |
| char *http_path_submit; /**< URL for submitting to the server throu | | | |
| gh 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_PO | | | |
| RT) */ | | | |
| 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 | | | |
| */ | | | |
| int use_cache; /**< field to specify local CDDB cache beha | | | |
| viour, | | | |
| 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, def | | | |
| aults | | | |
| to the value of the 'USER' environment | | | |
| variable or 'anonymous' if undefined * | | | |
| / | | | |
| char *hostname; /**< host name of the local machine, defaul | | | |
| ts | | | |
| to the value of the 'HOSTNAME' environ | | | |
| ment | | | |
| variable or 'localhost' if undefined * | | | |
| / | | | |
| | | | |
| cddb_error_t errnum; /**< error number of last CDDB command */ | | | |
| | | | |
| cddb_disc_t **query_data; /**< data structure to keep CDDB query resu | | | |
| lts */ | | | |
| int query_idx; /**< iterator index for query result set */ | | | |
| int query_cnt; /**< number of entries in query result set | | | |
| */ | | | |
| | | | |
| cddb_iconv_t charset; /**< character set conversion settings */ | | | |
| } cddb_conn_t; | | | |
| | | | |
| /* --- construction / destruction --- */ | | /* --- construction / destruction --- */ | |
| | | | |
| /** | | /** | |
| * Creates a new CDDB connection structure. This structure will have | | * Creates a new CDDB connection structure. This structure will have | |
| * to be passed to all libcddb functions. Default values will be used | | * to be passed to all libcddb functions. Default values will be used | |
| * for the connection parameters allowing it to contact the CDDB | | * for the connection parameters allowing it to contact the CDDB | |
| * server at freedb.org. | | * server at freedb.org. | |
| * | | * | |
| * @return The CDDB connection structure or NULL if something went wrong. | | * @return The CDDB connection structure or NULL if something went wrong. | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 82 | |
| /* --- getters & setters --- */ | | /* --- getters & setters --- */ | |
| | | | |
| /** | | /** | |
| * Set the character set. By default the FreeDB server uses UTF-8 when | | * 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 | | * providing CD data. When a character set is defined with this function | |
| * any strings retrieved from or sent to the server will automatically be | | * any strings retrieved from or sent to the server will automatically be | |
| * converted. | | * converted. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param cs The character set that will be used. | | * @param cs The character set that will be used. | |
|
| * @return FALSE if the specified character set is unknown, or no conversio | | * @return False if the specified character set is unknown, or no conversio | |
| n | | n | |
| * from/to UTF-8 is available. TRUE otherwise. | | * from/to UTF-8 is available. True otherwise. | |
| */ | | */ | |
| int cddb_set_charset(cddb_conn_t *c, const char *cs); | | int cddb_set_charset(cddb_conn_t *c, const char *cs); | |
| | | | |
| /** | | /** | |
| * Change the size of the internal buffer. | | * Change the size of the internal buffer. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param size The new buffer size. | | * @param size The new buffer size. | |
| */ | | */ | |
| void cddb_set_buf_size(cddb_conn_t *c, unsigned int 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. T | |
| | | his | |
| | | * 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. | | * Get the host name of the CDDB server that is currently being used. | |
| * | | * | |
| * @see cddb_set_server_name | | * @see cddb_set_server_name | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The server host name. | | * @return The server host name. | |
| */ | | */ | |
|
| #define cddb_get_server_name(c) (c)->server_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 | | * Set the host name of the CDDB server. The default value for the | |
| * server is 'freedb.org'. | | * server is 'freedb.org'. | |
| * | | * | |
| * @see cddb_get_server_name | | * @see cddb_get_server_name | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param server The server host name. | | * @param server The server host name. | |
| */ | | */ | |
| void cddb_set_server_name(cddb_conn_t *c, const char *server); | | void cddb_set_server_name(cddb_conn_t *c, const char *server); | |
| | | | |
| /** | | /** | |
| * Get the port of the CDDB server that is currently being used. | | * Get the port of the CDDB server that is currently being used. | |
| * | | * | |
| * @see cddb_set_server_port | | * @see cddb_set_server_port | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The server port. | | * @return The server port. | |
| */ | | */ | |
|
| #define cddb_get_server_port(c) (c)->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. | | * Set the port of the CDDB server. The default value is 888. | |
| * | | * | |
| * @see cddb_get_server_port | | * @see cddb_get_server_port | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param port The server port. | | * @param port The server port. | |
| */ | | */ | |
| void cddb_set_server_port(cddb_conn_t *c, int port); | | void cddb_set_server_port(cddb_conn_t *c, int port); | |
| | | | |
| /** | | /** | |
| * Get the network time out value (in seconds). | | * Get the network time out value (in seconds). | |
| * | | * | |
| * @see cddb_set_timeout | | * @see cddb_set_timeout | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The current time out in seconds. | | * @return The current time out in seconds. | |
| */ | | */ | |
|
| #define cddb_get_timeout(c) (c)->timeout | | unsigned int cddb_get_timeout(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Set the network time out value (in seconds). The default is 10 | | * Set the network time out value (in seconds). The default is 10 | |
| * seconds. | | * seconds. | |
| * | | * | |
| * @see cddb_get_timeout | | * @see cddb_get_timeout | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param t The new time out in seconds. | | * @param t The new time out in seconds. | |
| */ | | */ | |
|
| #define cddb_set_timeout(c, t) (c)->timeout = t | | void cddb_set_timeout(cddb_conn_t *c, unsigned int t); | |
| | | | |
| /** | | /** | |
| * Get the URL path for querying a CDDB server through HTTP. | | * Get the URL path for querying a CDDB server through HTTP. | |
| * | | * | |
| * @see cddb_set_http_path_query | | * @see cddb_set_http_path_query | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The URL path. | | * @return The URL path. | |
| */ | | */ | |
|
| #define cddb_get_http_path_query(c) (c)->http_path_query | | const char *cddb_get_http_path_query(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Set the URL path for querying a CDDB server through HTTP. The | | * Set the URL path for querying a CDDB server through HTTP. The | |
| * default value is '/~cddb/cddb.cgi'. | | * default value is '/~cddb/cddb.cgi'. | |
| * | | * | |
| * @see cddb_get_http_path_query | | * @see cddb_get_http_path_query | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param path The URL path. | | * @param path The URL path. | |
| */ | | */ | |
| void cddb_set_http_path_query(cddb_conn_t *c, const char *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. | | * Get the URL path for submitting to a CDDB server through HTTP. | |
| * | | * | |
| * @see cddb_set_http_path_submit | | * @see cddb_set_http_path_submit | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The URL path. | | * @return The URL path. | |
| */ | | */ | |
|
| #define cddb_get_http_path_submit(c) (c)->http_path_submit | | 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 | | * Set the URL path for submitting to a CDDB server through HTTP. The | |
| * default value is '/~cddb/submit.cgi'. | | * default value is '/~cddb/submit.cgi'. | |
| * | | * | |
| * @see cddb_get_http_path_submit | | * @see cddb_get_http_path_submit | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param path The URL path. | | * @param path The URL path. | |
| */ | | */ | |
| | | | |
| skipping to change at line 267 | | skipping to change at line 224 | |
| /** | | /** | |
| * Returns true if the HTTP protocol is currently enabled and false if | | * Returns true if the HTTP protocol is currently enabled and false if | |
| * CDDBP is enabled. | | * CDDBP is enabled. | |
| * | | * | |
| * @see cddb_http_enable | | * @see cddb_http_enable | |
| * @see cddb_http_disable | | * @see cddb_http_disable | |
| * | | * | |
| * @param c The CDDB connection structure. | | * @param c The CDDB connection structure. | |
| * @return True or false. | | * @return True or false. | |
| */ | | */ | |
|
| #define cddb_is_http_enabled(c) (c)->is_http_enabled | | unsigned int cddb_is_http_enabled(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Enable HTTP tunneling to connect to the CDDB server. By default | | * Enable HTTP tunneling to connect to the CDDB server. By default | |
| * this option is disabled. | | * this option is disabled. | |
| * | | * | |
| * @see cddb_is_http_enabled | | * @see cddb_is_http_enabled | |
| * @see cddb_http_disable | | * @see cddb_http_disable | |
| * | | * | |
| * @param c The CDDB connection structure. | | * @param c The CDDB connection structure. | |
| */ | | */ | |
| | | | |
| skipping to change at line 303 | | skipping to change at line 260 | |
| * it is not. This fucntion does not check whether HTTP is enabled. | | * 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 | | * So it is possible that true will be returned while in reality the | |
| * CDDBP protocol is being used (no proxy support). | | * CDDBP protocol is being used (no proxy support). | |
| * | | * | |
| * @see cddb_http_proxy_enable | | * @see cddb_http_proxy_enable | |
| * @see cddb_http_proxy_disable | | * @see cddb_http_proxy_disable | |
| * | | * | |
| * @param c The CDDB connection structure. | | * @param c The CDDB connection structure. | |
| * @return True or false. | | * @return True or false. | |
| */ | | */ | |
|
| #define cddb_is_http_proxy_enabled(c) (c)->is_http_proxy_enabled | | unsigned int cddb_is_http_proxy_enabled(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Enable HTTP tunneling through an HTTP proxy server to connect to | | * Enable HTTP tunneling through an HTTP proxy server to connect to | |
| * the CDDB server. The usage of an HTTP proxy implies normal HTTP | | * the CDDB server. The usage of an HTTP proxy implies normal HTTP | |
| * tunneling instead of connecting directly to the CDDB server. By | | * tunneling instead of connecting directly to the CDDB server. By | |
| * default this option is disabled. | | * default this option is disabled. | |
| * | | * | |
| * @see cddb_is_http_proxy_enabled | | * @see cddb_is_http_proxy_enabled | |
| * @see cddb_http_proxy_disable | | * @see cddb_http_proxy_disable | |
| * | | * | |
| | | | |
| skipping to change at line 337 | | skipping to change at line 294 | |
| void cddb_http_proxy_disable(cddb_conn_t *c); | | void cddb_http_proxy_disable(cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Get the host name of the HTTP proxy server. | | * Get the host name of the HTTP proxy server. | |
| * | | * | |
| * @see cddb_set_http_proxy_server_name | | * @see cddb_set_http_proxy_server_name | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The proxy server host name. | | * @return The proxy server host name. | |
| */ | | */ | |
|
| #define cddb_get_http_proxy_server_name(c) (c)->http_proxy_server | | 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 | | * Set the host name of the HTTP proxy server. There is no default | |
| * value. | | * value. | |
| * | | * | |
| * @see cddb_get_http_proxy_server_name | | * @see cddb_get_http_proxy_server_name | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param server The server host name. | | * @param server The server host name. | |
| */ | | */ | |
| void cddb_set_http_proxy_server_name(cddb_conn_t *c, const char *server); | | void cddb_set_http_proxy_server_name(cddb_conn_t *c, const char *server); | |
| | | | |
| /** | | /** | |
| * Get the port of the HTTP proxy server. | | * Get the port of the HTTP proxy server. | |
| * | | * | |
| * @see cddb_set_http_proxy_server_port | | * @see cddb_set_http_proxy_server_port | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The proxy server port. | | * @return The proxy server port. | |
| */ | | */ | |
|
| #define cddb_get_http_proxy_server_port(c) (c)->http_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. | | * Set the port of the HTTP proxy server. The default value is 8080. | |
| * | | * | |
| * @see cddb_get_http_proxy_server_port | | * @see cddb_get_http_proxy_server_port | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param port The server port. | | * @param port The server port. | |
| */ | | */ | |
| void cddb_set_http_proxy_server_port(cddb_conn_t *c, int port); | | void cddb_set_http_proxy_server_port(cddb_conn_t *c, int port); | |
| | | | |
| skipping to change at line 377 | | skipping to change at line 334 | |
| */ | | */ | |
| void cddb_set_http_proxy_server_port(cddb_conn_t *c, int 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 | | * Set the HTTP proxy user name which is used when Basic Authentication | |
| * is required. | | * is required. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param username The user name. | | * @param username The user name. | |
| */ | | */ | |
|
| | | | |
| void cddb_set_http_proxy_username(cddb_conn_t* c, const char* username); | | void cddb_set_http_proxy_username(cddb_conn_t* c, const char* username); | |
| | | | |
| /** | | /** | |
| * Get the HTTP proxy user name. | | * Get the HTTP proxy user name. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The user name. | | * @return The user name. | |
| */ | | */ | |
|
| | | const char *cddb_get_http_proxy_username(const cddb_conn_t *c); | |
| #define cddb_get_http_proxy_username(c) (c)->http_proxy_username | | | |
| | | | |
| /** | | /** | |
| * Set the HTTP proxy password which is used when Basic Authentication | | * Set the HTTP proxy password which is used when Basic Authentication | |
| * is required. | | * is required. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param passwd The password. | | * @param passwd The password. | |
| */ | | */ | |
|
| | | | |
| void cddb_set_http_proxy_password(cddb_conn_t* c, const char* passwd); | | void cddb_set_http_proxy_password(cddb_conn_t* c, const char* passwd); | |
| | | | |
| /** | | /** | |
| * Get the HTTP proxy password. | | * Get the HTTP proxy password. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The password. | | * @return The password. | |
| */ | | */ | |
|
| | | const char *cddb_get_http_proxy_password(const cddb_conn_t *c); | |
| #define cddb_get_http_proxy_password(c) (c)->http_proxy_password | | | |
| | | | |
| /** | | /** | |
| * Set the HTTP proxy user name and password in one go. These | | * Set the HTTP proxy user name and password in one go. These | |
| * credentials are used when Basic Authentication is required. The | | * credentials are used when Basic Authentication is required. The | |
| * advantage of using this function over setting the user name and | | * advantage of using this function over setting the user name and | |
| * password seperately is that the cleartext user name and password | | * password seperately is that the cleartext user name and password | |
| * are not kept in memory longer than needed. | | * are not kept in memory longer than needed. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param username The user name. | | * @param username The user name. | |
| | | | |
| skipping to change at line 428 | | skipping to change at line 381 | |
| */ | | */ | |
| void cddb_set_http_proxy_credentials(cddb_conn_t* c, | | void cddb_set_http_proxy_credentials(cddb_conn_t* c, | |
| const char *username, const char* pass
wd); | | const char *username, const char* pass
wd); | |
| | | | |
| /** | | /** | |
| * Get the error number returned by the last libcddb command. | | * Get the error number returned by the last libcddb command. | |
| * | | * | |
| * @param c The CDDB connection structure. | | * @param c The CDDB connection structure. | |
| * @return The error number. | | * @return The error number. | |
| */ | | */ | |
|
| #define cddb_errno(c) (c)->errnum | | cddb_error_t cddb_errno(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Set the name and version of the client program overwriting the | | * Set the name and version of the client program overwriting the | |
| * previous values. This function will make a copy of the provided | | * previous values. This function will make a copy of the provided | |
| * strings. The defaults are 'libcddb' and the version number of the | | * strings. The defaults are 'libcddb' and the version number of the | |
| * libcddb library in use. Both parameters must be valid strings. If | | * libcddb library in use. Both parameters must be valid strings. If | |
| * any of teh strings is NULL, this fucntion will return without | | * any of teh strings is NULL, this fucntion will return without | |
| * changing anything. | | * changing anything. | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| | | | |
| skipping to change at line 467 | | skipping to change at line 420 | |
| * | | * | |
| * @see CACHE_ON | | * @see CACHE_ON | |
| * @see CACHE_ONLY | | * @see CACHE_ONLY | |
| * @see CACHE_OFF | | * @see CACHE_OFF | |
| * @see cddb_cache_enable | | * @see cddb_cache_enable | |
| * @see cddb_cache_only | | * @see cddb_cache_only | |
| * @see cddb_cache_disable | | * @see cddb_cache_disable | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| */ | | */ | |
|
| #define cddb_cache_mode(c) (c)->use_cache | | cddb_cache_mode_t cddb_cache_mode(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Enable caching of CDDB entries locally. Caching is enabled by | | * Enable caching of CDDB entries locally. Caching is enabled by | |
| * default. The cache directory can be changed with the | | * default. The cache directory can be changed with the | |
| * cddb_cache_set_dir function. | | * cddb_cache_set_dir function. | |
| * | | * | |
| * @see cddb_cache_mode | | * @see cddb_cache_mode | |
| * @see cddb_cache_disable | | * @see cddb_cache_disable | |
| * @see cddb_cache_only | | * @see cddb_cache_only | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| */ | | */ | |
|
| #define cddb_cache_enable(c) (c)->use_cache = CACHE_ON | | void cddb_cache_enable(cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Only use the local CDDB cache. Never contact a server to retrieve | | * Only use the local CDDB cache. Never contact a server to retrieve | |
| * any data. The cache directory can be changed with the | | * any data. The cache directory can be changed with the | |
| * cddb_cache_set_dir function. | | * cddb_cache_set_dir function. | |
| * | | * | |
| * @see cddb_cache_mode | | * @see cddb_cache_mode | |
| * @see cddb_cache_enable | | * @see cddb_cache_enable | |
| * @see cddb_cache_disable | | * @see cddb_cache_disable | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| */ | | */ | |
|
| #define cddb_cache_only(c) (c)->use_cache = CACHE_ONLY | | void cddb_cache_only(cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Disable caching of CDDB entries locally. All data will be fetched | | * Disable caching of CDDB entries locally. All data will be fetched | |
| * from a CDDB server everytime and the retrieved data will not be | | * from a CDDB server everytime and the retrieved data will not be | |
| * cached locally. | | * cached locally. | |
| * | | * | |
| * @see cddb_cache_mode | | * @see cddb_cache_mode | |
| * @see cddb_cache_enable | | * @see cddb_cache_enable | |
| * @see cddb_cache_only | | * @see cddb_cache_only | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| */ | | */ | |
|
| #define cddb_cache_disable(c) (c)->use_cache = CACHE_OFF | | void cddb_cache_disable(cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Return the directory currently being used for caching. | | * Return the directory currently being used for caching. | |
| * | | * | |
| * @see cddb_cache_set_dir | | * @see cddb_cache_set_dir | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @return The directory being used for caching. | | * @return The directory being used for caching. | |
| */ | | */ | |
|
| #define cddb_cache_get_dir(c) (c)->cache_dir; | | const char *cddb_cache_get_dir(const cddb_conn_t *c); | |
| | | | |
| /** | | /** | |
| * Change the directory used for caching CDDB entries locally. The | | * Change the directory used for caching CDDB entries locally. The | |
| * default location of the cached entries is a subdirectory | | * default location of the cached entries is a subdirectory | |
| * (.cddbslave) of the user's home directory. If the first character | | * (.cddbslave) of the user's home directory. If the first character | |
| * of the directory is '~', then it will be expanded to the contents | | * of the directory is '~', then it will be expanded to the contents | |
| * of $HOME. | | * of $HOME. | |
| * | | * | |
| * @see cddb_cache_get_dir | | * @see cddb_cache_get_dir | |
| * | | * | |
| * @param c The connection structure. | | * @param c The connection structure. | |
| * @param dir The directory to use for caching. | | * @param dir The directory to use for caching. | |
| */ | | */ | |
| int cddb_cache_set_dir(cddb_conn_t *c, const char *dir); | | 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); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* CDDB_CONN_H */ | | #endif /* CDDB_CONN_H */ | |
| | | | |
End of changes. 28 change blocks. |
| 112 lines changed or deleted | | 63 lines changed or added | |
|
| cddb_disc.h | | cddb_disc.h | |
| /* | | /* | |
|
| $Id: cddb_disc.h,v 1.20 2005/03/11 21:29:29 airborne Exp $ | | $Id: cddb_disc.h,v 1.21 2005/07/09 08:32:48 airborne Exp $ | |
| | | | |
| Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | | Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 75 | |
| | | | |
| /** | | /** | |
| * String values for the CDDB categories. | | * String values for the CDDB categories. | |
| */ | | */ | |
| extern const char *CDDB_CATEGORY[CDDB_CAT_LAST]; | | extern const char *CDDB_CATEGORY[CDDB_CAT_LAST]; | |
| | | | |
| /** | | /** | |
| * The CDDB disc structure. Contains all information associated with | | * The CDDB disc structure. Contains all information associated with | |
| * a full CD. | | * a full CD. | |
| */ | | */ | |
|
| typedef struct cddb_disc_s | | typedef struct cddb_disc_s cddb_disc_t; | |
| { | | | |
| 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 */ | | | |
| int length; /**< disc length in seconds */ | | | |
| 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 */ | | | |
| } cddb_disc_t; | | | |
| | | | |
| /* --- construction / destruction */ | | /* --- construction / destruction */ | |
| | | | |
| /** | | /** | |
| * Creates a new CDDB disc structure. | | * Creates a new CDDB disc structure. | |
| * | | * | |
| * @return The CDDB disc structure or NULL if memory allocation failed. | | * @return The CDDB disc structure or NULL if memory allocation failed. | |
| */ | | */ | |
| cddb_disc_t *cddb_disc_new(void); | | cddb_disc_t *cddb_disc_new(void); | |
| | | | |
| | | | |
| skipping to change at line 112 | | skipping to change at line 99 | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| */ | | */ | |
| void cddb_disc_destroy(cddb_disc_t *disc); | | void cddb_disc_destroy(cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
| * Creates a clone of the given disc. | | * Creates a clone of the given disc. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| */ | | */ | |
|
| cddb_disc_t *cddb_disc_clone(cddb_disc_t *disc); | | cddb_disc_t *cddb_disc_clone(const cddb_disc_t *disc); | |
| | | | |
| /* --- track manipulation */ | | /* --- track manipulation */ | |
| | | | |
| /** | | /** | |
| * Add a new track to a disc. The track is added to the end of the | | * Add a new track to a disc. The track is added to the end of the | |
| * existing list of tracks. | | * existing list of tracks. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| */ | | */ | |
| void cddb_disc_add_track(cddb_disc_t *disc, cddb_track_t *track); | | 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 | | * Retrieves a numbered track from the disc. If there is no track | |
| * with the given number, then NULL will be returned. | | * with the given number, then NULL will be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param track_no The track number; starting at 0. | | * @param track_no The track number; starting at 0. | |
| */ | | */ | |
|
| cddb_track_t *cddb_disc_get_track(cddb_disc_t *disc, int track_no); | | 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 | | * Returns the first track of the disc. If there is no such track | |
| * then NULL will be returned. The internal track iterator will also | | * then NULL will be returned. The internal track iterator will also | |
| * be reset. This function should be called before the first call to | | * be reset. This function should be called before the first call to | |
| * cddb_disc_get_track_next. | | * cddb_disc_get_track_next. | |
| * | | * | |
| * @see cddb_disc_get_track_next | | * @see cddb_disc_get_track_next | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| | | | |
| skipping to change at line 161 | | skipping to change at line 148 | |
| * | | * | |
| * @see cddb_disc_get_track_first | | * @see cddb_disc_get_track_first | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| */ | | */ | |
| cddb_track_t *cddb_disc_get_track_next(cddb_disc_t *disc); | | cddb_track_t *cddb_disc_get_track_next(cddb_disc_t *disc); | |
| | | | |
| /* --- setters / getters --- */ | | /* --- setters / getters --- */ | |
| | | | |
| /** | | /** | |
|
| * Get the ID of the disc. If this disc ID is not yet initialized 0 | | * Get the ID of the disc. If the disc is invalid or the disc ID is | |
| * will be returned. | | * not yet initialized 0 will be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| */ | | */ | |
|
| #define cddb_disc_get_discid(disc) (disc)->discid | | 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 | | * 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 | | * can be calculated with the cddb_disc_calc_discid function (which | |
| * will automatically initialize the correct field in the disc | | * will automatically initialize the correct field in the disc | |
| * structure). | | * structure). | |
| * | | * | |
| * @see cddb_disc_calc_discid | | * @see cddb_disc_calc_discid | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param id The disc ID. | | * @param id The disc ID. | |
| */ | | */ | |
|
| #define cddb_disc_set_discid(disc, id) (disc)->discid = id | | void cddb_disc_set_discid(cddb_disc_t *disc, unsigned int id); | |
| | | | |
| /** | | /** | |
|
| * Get the disc CDDB category ID. If no category is set for this disc | | * Get the disc CDDB category ID. If the disc is invalid or no | |
| * then CDDB_CAT_INVALID will be returned. If you want a string | | * category is set then CDDB_CAT_INVALID will be returned. If you | |
| * representation of the category use the cddb_disc_get_category_str | | * want a string representation of the category use the | |
| * function. | | * cddb_disc_get_category_str function. | |
| * | | * | |
| * @see cddb_disc_set_category | | * @see cddb_disc_set_category | |
| * @see cddb_disc_get_category_str | | * @see cddb_disc_get_category_str | |
| * @see cddb_disc_set_category_str | | * @see cddb_disc_set_category_str | |
| * @see cddb_cat_t | | * @see cddb_cat_t | |
| * @see CDDB_CATEGORY | | * @see CDDB_CATEGORY | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The CDDB category ID. | | * @return The CDDB category ID. | |
| */ | | */ | |
|
| #define cddb_disc_get_category(disc) (disc)->category | | cddb_cat_t cddb_disc_get_category(const cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
| * Set the disc CDDB category ID. | | * Set the disc CDDB category ID. | |
| * | | * | |
| * @see cddb_disc_get_category | | * @see cddb_disc_get_category | |
| * @see cddb_disc_get_category_str | | * @see cddb_disc_get_category_str | |
| * @see cddb_disc_set_category_str | | * @see cddb_disc_set_category_str | |
| * @see cddb_cat_t | | * @see cddb_cat_t | |
| * @see CDDB_CATEGORY | | * @see CDDB_CATEGORY | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param cat The CDDB category ID. | | * @param cat The CDDB category ID. | |
| */ | | */ | |
|
| #define cddb_disc_set_category(disc, cat) (disc)->category = cat | | 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 | | * 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 | | * this disc then 'invalid' will be returned. If the disc structure | |
| * is invalid NULL is returned. If you only want the ID of the | | * is invalid NULL is returned. If you only want the ID of the | |
| * category use the cddb_disc_get_category function. | | * category use the cddb_disc_get_category function. | |
| * | | * | |
| * @see cddb_disc_get_category | | * @see cddb_disc_get_category | |
| * @see cddb_disc_set_category | | * @see cddb_disc_set_category | |
| * @see cddb_disc_set_category_str | | * @see cddb_disc_set_category_str | |
| | | | |
| skipping to change at line 249 | | skipping to change at line 236 | |
| void cddb_disc_set_category_str(cddb_disc_t *disc, const char *cat); | | 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 | | * 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 | | * will be returned. As opposed to the disc category, this field is | |
| * not limited to a predefined set. | | * not limited to a predefined set. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The disc genre. | | * @return The disc genre. | |
| */ | | */ | |
|
| #define cddb_disc_get_genre(disc) (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 | | * 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, | | * 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 | | * then the memory for that string will be freed. The new genre will | |
| * be copied into a new chunk of memory. | | * be copied into a new chunk of memory. | |
| * | | * | |
| * @see cddb_disc_get_category_str | | * @see cddb_disc_get_category_str | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| | | | |
| skipping to change at line 271 | | skipping to change at line 258 | |
| */ | | */ | |
| void cddb_disc_set_genre(cddb_disc_t *disc, const char *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 | | * Get the disc length. If no length is set for this disc then 0 will | |
| * be returned. | | * be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The disc length in seconds. | | * @return The disc length in seconds. | |
| */ | | */ | |
|
| #define cddb_disc_get_length(disc) (disc)->length | | unsigned int cddb_disc_get_length(const cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
| * Set the disc length. | | * Set the disc length. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param l The disc length in seconds. | | * @param l The disc length in seconds. | |
| */ | | */ | |
|
| #define cddb_disc_set_length(disc, l) (disc)->length = l | | void cddb_disc_set_length(cddb_disc_t *disc, unsigned int l); | |
| | | | |
| /** | | /** | |
| * Get the year of publication for this disc. If no year is defined 0 | | * Get the year of publication for this disc. If no year is defined 0 | |
| * is returned. | | * is returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The disc year. | | * @return The disc year. | |
| */ | | */ | |
|
| #define cddb_disc_get_year(disc) (disc)->year | | unsigned int cddb_disc_get_year(const cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
| * Set the year of publication for this disc. | | * Set the year of publication for this disc. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param y The disc year. | | * @param y The disc year. | |
| */ | | */ | |
|
| #define cddb_disc_set_year(disc, y) (disc)->year = y | | void cddb_disc_set_year(cddb_disc_t *disc, unsigned int y); | |
| | | | |
| /** | | /** | |
|
| * Get the number of tracks on the disc. | | * Get the number of tracks on the disc. If the disc is invalid -1 is | |
| | | * returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The number of tracks. | | * @return The number of tracks. | |
| */ | | */ | |
|
| #define cddb_disc_get_track_count(disc) (disc)->track_cnt | | int cddb_disc_get_track_count(const cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
|
| * Get the disc title. If no title is set for this disc then NULL | | * Get the disc title. If the disc is invalid or no title is set then | |
| * will be returned. | | * NULL will be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The disc title. | | * @return The disc title. | |
| */ | | */ | |
|
| #define cddb_disc_get_title(disc) (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 | | * 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 | | * 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 | | * into a new chunk of memory. If the given title is NULL, then the | |
| * title of the disc will be deleted. | | * title of the disc will be deleted. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param title The new disc title. | | * @param title The new disc title. | |
| */ | | */ | |
| | | | |
| skipping to change at line 337 | | skipping to change at line 325 | |
| * Append to the disc title. If the disc does not have a title yet, | | * 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 | | * then a new one will be created from the given string, otherwise | |
| * that string will be appended to the existing title. | | * that string will be appended to the existing title. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param title Part of the disc title. | | * @param title Part of the disc title. | |
| */ | | */ | |
| void cddb_disc_append_title(cddb_disc_t *disc, const char *title); | | void cddb_disc_append_title(cddb_disc_t *disc, const char *title); | |
| | | | |
| /** | | /** | |
|
| * Get the disc artist name. If no artist is set for this disc then | | * Get the disc artist name. If the disc is invalid or no artist is | |
| * NULL will be returned. | | * set then NULL will be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The disc artist name. | | * @return The disc artist name. | |
| */ | | */ | |
|
| #define cddb_disc_get_artist(disc) (disc)->artist | | const char *cddb_disc_get_artist(const cddb_disc_t *disc); | |
| | | | |
| /** | | /** | |
| * Set the disc artist name. If the disc already had an artist name, | | * 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 | | * 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 | | * 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. | | * name is NULL, then the artist name of the disc will be deleted. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param artist The new disc artist name. | | * @param artist The new disc artist name. | |
| */ | | */ | |
| | | | |
| skipping to change at line 367 | | skipping to change at line 355 | |
| * Append to the disc artist. If the disc does not have an 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, | | * yet, then a new one will be created from the given string, | |
| * otherwise that string will be appended to the existing artist. | | * otherwise that string will be appended to the existing artist. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param artist Part of the artist name. | | * @param artist Part of the artist name. | |
| */ | | */ | |
| void cddb_disc_append_artist(cddb_disc_t *disc, const char *artist); | | void cddb_disc_append_artist(cddb_disc_t *disc, const char *artist); | |
| | | | |
| /** | | /** | |
|
| * Get the extended disc data. If no extended data is set for this | | * Get the extended disc data. If the disc is invalid or no extended | |
| * disc then NULL will be returned. | | * data is set then NULL will be returned. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @return The extended data. | | * @return The extended data. | |
| */ | | */ | |
|
| #define cddb_disc_get_ext_data(disc) (disc)->ext_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 | | * Set the extended data for the disc. If the disc already had | |
| * extended data, then the memory for that string will be freed. The | | * 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 | | * 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 | | * the given extended data is NULL, then the existing data will be | |
| * deleted. | | * deleted. | |
| * | | * | |
| * @param disc The CDDB disc structure. | | * @param disc The CDDB disc structure. | |
| * @param ext_data The new extended data. | | * @param ext_data The new extended data. | |
| | | | |
End of changes. 23 change blocks. |
| 43 lines changed or deleted | | 31 lines changed or added | |
|
| cddb_track.h | | cddb_track.h | |
| /* | | /* | |
|
| $Id: cddb_track.h,v 1.18 2005/03/11 21:29:29 airborne Exp $ | | $Id: cddb_track.h,v 1.19 2005/07/09 08:31:32 airborne Exp $ | |
| | | | |
| Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | | Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be> | |
| | | | |
| This library is free software; you can redistribute it and/or | | This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Library General Public | | modify it under the terms of the GNU Library General Public | |
| License as published by the Free Software Foundation; either | | License as published by the Free Software Foundation; either | |
| version 2 of the License, or (at your option) any later version. | | version 2 of the License, or (at your option) any later version. | |
| | | | |
| This library is distributed in the hope that it will be useful, | | This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| Boston, MA 02111-1307, USA. | | Boston, MA 02111-1307, USA. | |
| */ | | */ | |
| | | | |
| #ifndef CDDB_TRACK_H | | #ifndef CDDB_TRACK_H | |
| #define CDDB_TRACK_H 1 | | #define CDDB_TRACK_H 1 | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| /* Forward declaration of the disc structure. */ | | | |
| struct cddb_disc_c; | | | |
| | | | |
| /** | | /** | |
| * The CDDB track structure. Contains all information associated with | | * The CDDB track structure. Contains all information associated with | |
| * a single CD track. This structure will be used to populate the | | * a single CD track. This structure will be used to populate the | |
| * tracks linked list of the cddb_disc_s structure. | | * tracks linked list of the cddb_disc_s structure. | |
| */ | | */ | |
|
| typedef struct cddb_track_s | | typedef struct cddb_track_s cddb_track_t; | |
| { | | | |
| 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 */ | | | |
| } cddb_track_t; | | | |
| | | | |
| /* --- construction / destruction */ | | /* --- construction / destruction */ | |
| | | | |
| /** | | /** | |
| * Creates a new CDDB track structure. | | * Creates a new CDDB track structure. | |
| * | | * | |
| * @return The CDDB track structure or NULL if memory allocation failed. | | * @return The CDDB track structure or NULL if memory allocation failed. | |
| */ | | */ | |
| cddb_track_t *cddb_track_new(void); | | cddb_track_t *cddb_track_new(void); | |
| | | | |
| | | | |
| skipping to change at line 74 | | skipping to change at line 60 | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| */ | | */ | |
| void cddb_track_destroy(cddb_track_t *track); | | void cddb_track_destroy(cddb_track_t *track); | |
| | | | |
| /** | | /** | |
| * Creates a clone of the given track. | | * Creates a clone of the given track. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| */ | | */ | |
|
| cddb_track_t *cddb_track_clone(cddb_track_t *track); | | cddb_track_t *cddb_track_clone(const cddb_track_t *track); | |
| | | | |
| /* --- getters & setters --- */ | | /* --- getters & setters --- */ | |
| | | | |
| /** | | /** | |
| * Get the number of this track. This track number starts counting at | | * Get the number of this track. This track number starts counting at | |
|
| * 1. If the track number is not defined -1 will be returned. | | * 1. If the track is invalid or the track number is not defined -1 | |
| | | * will be returned. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @return The track number. | | * @return The track number. | |
| */ | | */ | |
|
| #define cddb_track_get_number(track) (track)->num | | int cddb_track_get_number(const cddb_track_t *track); | |
| | | | |
| /** | | /** | |
|
| * Get the frame offset of this track on the disc. | | * 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. | | * @param track The CDDB track structure. | |
| * @return The frame offset. | | * @return The frame offset. | |
| */ | | */ | |
|
| #define cddb_track_get_frame_offset(track) (track)->frame_offset | | int cddb_track_get_frame_offset(const cddb_track_t *track); | |
| | | | |
| /** | | /** | |
| * Set the frame offset of this track on the disc. | | * Set the frame offset of this track on the disc. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @param offset The frame offset. | | * @param offset The frame offset. | |
| * @return The frame offset. | | * @return The frame offset. | |
| */ | | */ | |
|
| #define cddb_track_set_frame_offset(track, offset) (track)->frame_offset =
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 | | * 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 | | * defined this routine will try to calculate it using the frame | |
| * offsets of the tracks and the total disc length. These | | * offsets of the tracks and the total disc length. These | |
| * calculations will do no rounding to the nearest second. So it is | | * 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 | | * 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 | | * actual disc length. If the length can not be calculated -1 will be | |
| * returned. | | * returned. | |
| * | | * | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 117 | |
| * Set the length of the track. If no frame offset is yet known for | | * 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 | | * this track, and it is part of a disc, then the frame offset will be | |
| * calculated. | | * calculated. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @param length The track length in seconds. | | * @param length The track length in seconds. | |
| */ | | */ | |
| void cddb_track_set_length(cddb_track_t *track, int length); | | void cddb_track_set_length(cddb_track_t *track, int length); | |
| | | | |
| /** | | /** | |
|
| * Get the track title. If no title is set for this track then NULL | | * Get the track title. If the track is invalid or no title is set | |
| * will be returned. | | * for this track then NULL will be returned. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @return The track title. | | * @return The track title. | |
| */ | | */ | |
|
| #define cddb_track_get_title(track) (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 | | * 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 | | * 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 | | * into a new chunk of memory. If the given title is NULL, then the | |
| * title of the track will be deleted. | | * title of the track will be deleted. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @param title The new track title. | | * @param title The new track title. | |
| */ | | */ | |
| | | | |
| skipping to change at line 195 | | skipping to change at line 183 | |
| */ | | */ | |
| void cddb_track_append_artist(cddb_track_t *track, const char *artist); | | 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 | | * Get the extended track data. If no extended data is set for this | |
| * track then NULL will be returned. | | * track then NULL will be returned. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @return The extended data. | | * @return The extended data. | |
| */ | | */ | |
|
| #define cddb_track_get_ext_data(track) (track)->ext_data | | const char *cddb_track_get_ext_data(cddb_track_t *track); | |
| | | | |
| /** | | /** | |
| * Set the extended data for the track. If the track already had | | * Set the extended data for the track. If the track already had | |
| * extended data, then the memory for that string will be freed. The | | * 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 | | * 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 | | * the given extended data is NULL, then the existing data will be | |
| * deleted. | | * deleted. | |
| * | | * | |
| * @param track The CDDB track structure. | | * @param track The CDDB track structure. | |
| * @param ext_data The new extended data. | | * @param ext_data The new extended data. | |
| | | | |
End of changes. 12 change blocks. |
| 27 lines changed or deleted | | 14 lines changed or added | |
|