1 /* librepo - A library providing (libcURL like) API to downloading repository
2  * Copyright (C) 2012  Tomas Mlcoch
3  *
4  * Licensed under the GNU Lesser General Public License Version 2.1
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef __LR_RETURN_CODES_H__
22 #define __LR_RETURN_CODES_H__
23 
24 #include <glib.h>
25 
26 G_BEGIN_DECLS
27 
28 /** \defgroup   rcodes      Error/Return codes
29  *  \addtogroup rcodes
30  *  @{
31  */
32 
33 /** Librepo return/error codes
34  */
35 typedef enum {
36     LRE_OK, /*!<
37         (0) everything is ok */
38     LRE_BADFUNCARG, /*!<
39         (1) bad function argument */
40     LRE_BADOPTARG, /*!<
41         (2) bad argument of the option */
42     LRE_UNKNOWNOPT, /*!<
43         (3) library doesn't know the option */
44     LRE_CURLSETOPT, /*!<
45         (4) cURL doesn't know the option. Too old curl version? */
46     LRE_ALREADYUSEDRESULT, /*!<
47         (5) LrResult object is not clean */
48     LRE_INCOMPLETERESULT, /*!<
49         (6) LrResult doesn't contain all what is needed */
50     LRE_CURLDUP, /*!<
51         (7) cannot duplicate curl handle */
52     LRE_CURL, /*!<
53         (8) cURL error */
54     LRE_CURLM, /*!<
55         (9) cULR multi handle error */
56     LRE_BADSTATUS, /*!<
57         (10) HTTP or FTP returned status code which do not represent success
58         (file doesn't exists, etc.) */
59     LRE_TEMPORARYERR, /*!<
60         (11) some error that should be temporary and next try could work
61         (HTTP status codes 500, 502-504, operation timeout, ...) */
62     LRE_NOTLOCAL, /*!<
63         (12) URL is not a local address */
64     LRE_CANNOTCREATEDIR, /*!<
65         (13) cannot create a directory in output dir (already exists?) */
66     LRE_IO, /*!<
67         (14) input output error */
68     LRE_MLBAD, /*!<
69         (15) bad mirrorlist/metalink file (metalink doesn't contain needed
70         file, mirrorlist doesn't contain urls, ..) */
71     LRE_MLXML, /*!<
72         (16) metalink XML parse error */
73     LRE_BADCHECKSUM, /*!<
74         (17) bad checksum */
75     LRE_REPOMDXML, /*!<
76         (18) repomd XML parse error */
77     LRE_NOURL, /*!<
78         (19) usable URL not found */
79     LRE_CANNOTCREATETMP, /*!<
80         (20) cannot create tmp directory */
81     LRE_UNKNOWNCHECKSUM, /*!<
82         (21) unknown type of checksum is needed for verification */
83     LRE_BADURL, /*!<
84         (22) bad URL specified */
85     LRE_GPGNOTSUPPORTED, /*!<
86         (23) OpenPGP protocol is not supported */
87     LRE_GPGERROR, /*!<
88         (24) GPGME related error */
89     LRE_BADGPG, /*!<
90         (25) Bad GPG signature */
91     LRE_INCOMPLETEREPO, /*!<
92         (26) Repository metadata are not complete */
93     LRE_INTERRUPTED, /*!<
94         (27) Download was interrupted by signal.
95         Only if LRO_INTERRUPTIBLE option is enabled. */
96     LRE_SIGACTION, /*!<
97         (28) sigaction error */
98     LRE_ALREADYDOWNLOADED, /*!<
99         (29) File already exists and checksum is ok.*/
100     LRE_UNFINISHED, /*!<
101         (30) The download wasn't or cannot be finished. */
102     LRE_SELECT, /*!<
103         (31) select() call failed. */
104     LRE_OPENSSL, /*!<
105         (32) OpenSSL library related error. */
106     LRE_MEMORY, /*!<
107         (33) Cannot allocate more memory  */
108     LRE_XMLPARSER, /*!<
109         (34) XML parser error */
110     LRE_CBINTERRUPTED, /*!<
111         (35) Interrupted by user cb */
112     LRE_REPOMD, /*!<
113         (36) Error with repomd (bad content, missing expected values, ...) */
114     LRE_VALUE, /*!<
115         (37) Bad value (e.g. we are expecting bandwidth defined like '1024',
116         '1k', etc., but we got something like 'asdf', '1024S', etc.) */
117     LRE_NOTSET, /*!<
118         (38) Requested option/value is not set. Used for example in
119         lr_yum_repoconf_getinfo() */
120     LRE_FILE, /*!<
121         (39) File operation error (operation not permitted, filename too long,
122         no memory available, bad file descriptor, ...) */
123     LRE_KEYFILE, /*!<
124         (40) Key file error (unknown encoding, ill-formed, file not found,
125         key/group not found, ...) */
126     LRE_ZCK, /*!<
127         (41) Zchunk error (error reading zchunk file, ...) */
128     LRE_UNKNOWNERROR, /*!<
129         (xx) unknown error - sentinel of error codes enum */
130 } LrRc; /*!< Return codes */
131 
132 /** Converts LrRc return code to error string.
133  * @param rc        LrRc code
134  * @return          Error string
135  */
136 const char *lr_strerror(int rc);
137 
138 /** Error domains for GError */
139 #define LR_CHECKSUM_ERROR           lr_checksum_error_quark()
140 #define LR_DOWNLOADER_ERROR         lr_downloader_error_quark()
141 #define LR_FASTESTMIRROR_ERROR      lr_fastestmirror_error_quark()
142 #define LR_GPG_ERROR                lr_gpg_error_quark()
143 #define LR_HANDLE_ERROR             lr_handle_error_quark()
144 #define LR_METALINK_ERROR           lr_metalink_error_quark()
145 #define LR_MIRRORLIST_ERROR         lr_mirrorlist_error_quark()
146 #define LR_PACKAGE_DOWNLOADER_ERROR lr_package_downloader_error_quark()
147 #define LR_REPOCONF_ERROR           lr_repoconf_error_quark()
148 #define LR_REPOMD_ERROR             lr_repomd_error_quark()
149 #define LR_REPOUTIL_YUM_ERROR       lr_repoutil_yum_error_quark()
150 #define LR_RESULT_ERROR             lr_result_error_quark()
151 #define LR_XML_PARSER_ERROR         lr_xml_parser_error_quark()
152 #define LR_YUM_ERROR                lr_yum_error_quark()
153 
154 GQuark lr_checksum_error_quark(void);
155 GQuark lr_downloader_error_quark(void);
156 GQuark lr_fastestmirror_error_quark(void);
157 GQuark lr_gpg_error_quark(void);
158 GQuark lr_handle_error_quark(void);
159 GQuark lr_metalink_error_quark(void);
160 GQuark lr_mirrorlist_error_quark(void);
161 GQuark lr_package_downloader_error_quark(void);
162 GQuark lr_repoconf_error_quark(void);
163 GQuark lr_repomd_error_quark(void);
164 GQuark lr_repoutil_yum_error_quark(void);
165 GQuark lr_result_error_quark(void);
166 GQuark lr_xml_parser_error_quark(void);
167 GQuark lr_yum_error_quark(void);
168 
169 /** @} */
170 
171 G_END_DECLS
172 
173 #endif
174