1 /*
2     $Id: cddb_error.h,v 1.12 2005/05/29 08:11:04 airborne Exp $
3 
4     Copyright (C) 2003, 2004, 2005 Kris Verbeeck <airborne@advalvas.be>
5 
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Library General Public
8     License as published by the Free Software Foundation; either
9     version 2 of the License, or (at your option) any later version.
10 
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     Library General Public License for more details.
15 
16     You should have received a copy of the GNU Library General Public
17     License along with this library; if not, write to the
18     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19     Boston, MA  02111-1307, USA.
20 */
21 
22 #ifndef CDDB_ERROR_H
23 #define CDDB_ERROR_H 1
24 
25 #ifdef __cplusplus
26     extern "C" {
27 #endif
28 
29 
30 #include <stdio.h>
31 
32 
33 /**
34  * A list of error codes returned by various libcddb functions.
35  */
36 typedef enum {
37 
38     CDDB_ERR_OK = 0,            /**< no error occurred */
39 
40     /* --- general errors --- */
41 
42     CDDB_ERR_OUT_OF_MEMORY,     /**< out of memory */
43     CDDB_ERR_LINE_SIZE,         /**< internal buffer too small */
44     CDDB_ERR_NOT_IMPLEMENTED,   /**< feature not (yet) implemented */
45     CDDB_ERR_UNKNOWN,           /**< problem unknown */
46 
47     /* --- connection errors --- */
48 
49     CDDB_ERR_SERVER_ERROR,      /**< CDDB server error */
50     CDDB_ERR_UNKNOWN_HOST_NAME, /**< unknown host name */
51     CDDB_ERR_CONNECT,           /**< connection error */
52     CDDB_ERR_PERMISSION_DENIED, /**< permission denied */
53     CDDB_ERR_NOT_CONNECTED,     /**< not yet connected or connection
54                                      has been closed */
55 
56     /* --- response parsing errors --- */
57 
58     CDDB_ERR_UNEXPECTED_EOF,    /**< unexpected end-of-file encountered */
59     CDDB_ERR_INVALID_RESPONSE,  /**< invalid response data */
60     CDDB_ERR_DISC_NOT_FOUND,    /**< no results found */
61 
62     /* --- library errors --- */
63 
64     CDDB_ERR_DATA_MISSING,      /**< some data is missing for executing
65                                      a certain command */
66     CDDB_ERR_TRACK_NOT_FOUND,   /**< specified track is not present */
67     CDDB_ERR_REJECTED,          /**< posted data rejected */
68     CDDB_ERR_EMAIL_INVALID,     /**< the e-mail address used when
69                                      submitting is invalid */
70 
71     CDDB_ERR_INVALID_CHARSET,   /**< invalid character set or unsupported
72                                      conversion */
73     CDDB_ERR_ICONV_FAIL,        /**< character set conversion failed */
74 
75     /* --- new errors added to back of list for backward compatibility --- */
76 
77     CDDB_ERR_PROXY_AUTH,        /**< proxy authentication failed */
78     CDDB_ERR_INVALID,           /**< invalid input parameter(s) */
79 
80     /* --- terminator --- */
81 
82     CDDB_ERR_LAST
83 } cddb_error_t;
84 
85 
86 /* --- error handling --- */
87 
88 
89 /**
90  * Returns a string representation of the CDDB error code.
91  *
92  * @return The error string
93  */
94 const char *cddb_error_str(cddb_error_t errnum);
95 
96 /**
97  * Prints the error message associated with the current error number
98  * on the given stream.
99  *
100  * @param stream The stream
101  * @param errnum The error number
102  */
103 void cddb_error_stream_print(FILE *stream, cddb_error_t errnum);
104 
105 /**
106  * Prints the error message associated with the current error number
107  * to stderr.
108  *
109  * @param errnum The error number
110  */
111 void cddb_error_print(cddb_error_t errnum);
112 
113 
114 #ifdef __cplusplus
115     }
116 #endif
117 
118 #endif /* CDDB_ERROR_H */
119