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