static char progname[ BUFSIZ ];
tester_t progtype;
-#define TESTER_SERVER_LAST (LDAP_OTHER + 1)
-#define TESTER_CLIENT_LAST (- LDAP_REFERRAL_LIMIT_EXCEEDED + 1)
-static int ignore_server[ TESTER_SERVER_LAST ];
-static int ignore_client[ TESTER_CLIENT_LAST ];
+/*
+ * ignore_count[] is indexed by result code:
+ * negative for OpenLDAP client-side errors, positive for protocol codes.
+ */
+#define TESTER_CLIENT_FIRST LDAP_REFERRAL_LIMIT_EXCEEDED /* negative */
+#define TESTER_SERVER_LAST LDAP_OTHER
+static int ignore_base [ -TESTER_CLIENT_FIRST + TESTER_SERVER_LAST + 1 ];
+#define ignore_count (ignore_base - TESTER_CLIENT_FIRST)
-static struct {
- char *name;
+static const struct {
+ const char *name;
int err;
} ignore_str2err[] = {
{ "OPERATIONS_ERROR", LDAP_OPERATIONS_ERROR },
if ( strcmp( err, "ALL" ) == 0 ) {
for ( i = 0; ignore_str2err[ i ].name != NULL; i++ ) {
- int err = ignore_str2err[ i ].err;
-
- if ( err > 0 ) {
- ignore_server[ err ] = 1;
-
- } else if ( err < 0 ) {
- ignore_client[ -err ] = 1;
- }
+ ignore_count[ ignore_str2err[ i ].err ] = 1;
}
+ ignore_count[ LDAP_SUCCESS ] = 0;
return 0;
}
if ( strcmp( err, ignore_str2err[ i ].name ) == 0 ) {
int err = ignore_str2err[ i ].err;
- if ( err > 0 ) {
- ignore_server[ err ] = ignore;
-
- } else if ( err < 0 ) {
- ignore_client[ -err ] = ignore;
+ if ( err != LDAP_SUCCESS ) {
+ ignore_count[ err ] = ignore;
}
return err;
{
int rc = 1;
- if ( err > 0 ) {
- if ( err < TESTER_SERVER_LAST ) {
- rc = ignore_server[ err ];
- if ( rc > 0 ) {
- ignore_server[ err ]++;
-
- } else if ( rc < 0 ) {
- ignore_server[ err ]--;
- }
- }
-
- } else if ( err < 0 ) {
- if ( -err < TESTER_CLIENT_LAST ) {
- rc = ignore_client[ -err ];
- if ( rc > 0 ) {
- ignore_client[ -err ]++;
-
- } else if ( rc < 0 ) {
- ignore_client[ -err ]--;
- }
+ if ( err && TESTER_CLIENT_FIRST <= err && err <= TESTER_SERVER_LAST ) {
+ rc = ignore_count[ err ];
+ if ( rc != 0 ) {
+ ignore_count[ err ] = rc + (rc > 0 ? 1 : -1);
}
}
{
fprintf( stderr, "%s: %s\n", progname, msg );
}
-