From 1f31ace6cb771d7bf0b64091fba1d24c466ad4e5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Dec 2001 12:21:12 +0000 Subject: much better ADS error handling system (This used to be commit 05a90a28843e0d69183a49a76617c5f32817df16) --- source3/include/ads.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/include/ads.h') diff --git a/source3/include/ads.h b/source3/include/ads.h index 4a20d0e79f..884f2aa6ef 100644 --- a/source3/include/ads.h +++ b/source3/include/ads.h @@ -18,16 +18,26 @@ typedef struct { char *server_realm; } ADS_STRUCT; +/* there are 4 possible types of errors the ads subsystem can produce */ +enum ads_error_type {ADS_ERROR_KRB5, ADS_ERROR_GSS, + ADS_ERROR_LDAP, ADS_ERROR_SYSTEM}; + typedef struct { - /* Type of error returned by ads_connect: */ - /* True corresponds GSS API, False - LDAP */ - int error_type; - /* For error_type = False rc describes LDAP error */ + enum ads_error_type error_type; int rc; - /* For error_type = True rc and minor_status describe GSS API error */ + /* For error_type = ADS_ERROR_GSS minor_status describe GSS API error */ /* Where rc represents major_status of GSS API error */ int minor_status; -} ADS_RETURN_CODE; +} ADS_STATUS; + +/* macros to simplify error returning */ +#define ADS_ERROR(rc) ads_build_error(ADS_ERROR_LDAP, rc, 0); +#define ADS_ERROR_SYSTEM(rc) ads_build_error(ADS_ERROR_SYSTEM, rc, 0); +#define ADS_ERROR_KRB5(rc) ads_build_error(ADS_ERROR_KRB5, rc, 0); +#define ADS_ERROR_GSS(rc, minor) ads_build_error(ADS_ERROR_GSS, rc, minor); + +#define ADS_ERR_OK(status) ((status).rc == 0) +#define ADS_SUCCESS ADS_ERROR(0) /* time between reconnect attempts */ #define ADS_RECONNECT_TIME 5 -- cgit