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