util_errors.h revision 82a958e6592c4a4078e45b7197bbe4751b70f511
967e5f3c25249c779575864692935627004d3f9eChristian Maeder Copyright (C) 2012 Red Hat
f11f713bebd8e1e623a0a4361065df256033de47Christian Maeder This program is free software; you can redistribute it and/or modify
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu it under the terms of the GNU General Public License as published by
967e5f3c25249c779575864692935627004d3f9eChristian Maeder the Free Software Foundation; either version 3 of the License, or
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder (at your option) any later version.
89054b2b95a3f92e78324dc852f3d34704e2ca49Christian Maeder This program is distributed in the hope that it will be useful,
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
717686b54b9650402e2ebfbaadf433eab8ba5171Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
717686b54b9650402e2ebfbaadf433eab8ba5171Christian Maeder GNU General Public License for more details.
967e5f3c25249c779575864692935627004d3f9eChristian Maeder You should have received a copy of the GNU General Public License
967e5f3c25249c779575864692935627004d3f9eChristian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder Simo Sorce <ssorce@redhat.com>
967e5f3c25249c779575864692935627004d3f9eChristian Maeder * We define a specific number space so that we do not overlap with other
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder * generic errors returned by various libraries. This will make it easy
78eeae099616e255ccf2e5f9122387bb10c68338Christian Maeder * to have functions that double check that what was returned was a SSSD
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder * specific error where it matters. For example we may want to ensure some
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder * particularly sensitive paths only return SSSD sepcific errors as that
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder * will insure all error conditions have been explicitly dealt with,
ad187062b0009820118c1b773a232e29b879a2faChristian Maeder * and are not the result of assigning the wrong return result.
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder * Basic system errno errors can still be used, but when an error condition
551af0e4ba6d96bb24f3555f3b30ed648e22e34aChristian Maeder * does not properly map to a system error we should use a SSSD specific one
551af0e4ba6d96bb24f3555f3b30ed648e22e34aChristian Maeder/* never use ERR_INVALID, it is used for catching and returning
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder * information on invalid error numbers */
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder/* never use ERR_LAST, this represent the maximum error value available
51fb5d7edd9369c367dda2f8b15ddd6f8a146606Christian Maeder * and is used to validate error codes */
ceef5f7843a1f96fe5a62e0f6880e38b3d5f4708Christian Maeder#define SSSD_ERR_BASE(err) ((err) & ~ERR_MASK)
ceef5f7843a1f96fe5a62e0f6880e38b3d5f4708Christian Maeder#define SSSD_ERR_IDX(err) ((err) & ERR_MASK)
54ff63bb3b23ef18efbdc51b053a2ca6f348329aChristian Maeder ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) <= ERR_LAST))
ee93fb771fcf3000d73c8e2f2000adb4b9a5158cChristian Maeder/* Backwards compat */
ceef5f7843a1f96fe5a62e0f6880e38b3d5f4708Christian Maeder * @brief return a string descriing the error number like strerror()
ceef5f7843a1f96fe5a62e0f6880e38b3d5f4708Christian Maeder * @param error An errno_t number, can be a SSSD error or a system error
54ff63bb3b23ef18efbdc51b053a2ca6f348329aChristian Maeder * @return A statically allocated string.
67d92da5e9610aabad39055a16031154b4dc3748Christian Maeder#endif /* __SSSD_UTIL_ERRORS_H__ */