- int rc, n;
- SaslRegexp_t *reg;
- struct berval bv, nbv;
-
- SaslRegexp = (SaslRegexp_t *) ch_realloc( (char *) SaslRegexp,
- (nSaslRegexp + 1) * sizeof(SaslRegexp_t) );
- reg = &( SaslRegexp[nSaslRegexp] );
- ber_str2bv( match, 0, 0, &bv );
- rc = dnNormalize2( NULL, &bv, &nbv );
- if ( rc ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "sasl", LDAP_LEVEL_ERR,
- "slap_sasl_regexp_config: \"%s\" could not be normalized.\n",
- match ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "SASL match pattern %s could not be normalized.\n",
- match, 0, 0 );
-#endif
- return( rc );
- }
- reg->sr_match = nbv.bv_val;
-
- ber_str2bv( replace, 0, 0, &bv );
- rc = dnNormalize2( NULL, &bv, &nbv );
- if ( rc ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "sasl", LDAP_LEVEL_ERR,
- "slap_sasl_regexp_config: \"%s\" could not be normalized.\n",
- replace ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "SASL replace pattern %s could not be normalized.\n",
- replace, 0, 0 );
-#endif
- return( rc );
- }
- reg->sr_replace = nbv.bv_val;
-
- /* Precompile matching pattern */
- rc = regcomp( ®->sr_workspace, reg->sr_match, REG_EXTENDED|REG_ICASE );
- if ( rc ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "sasl", LDAP_LEVEL_ERR,
- "slap_sasl_regexp_config: \"%s\" could not be compiled.\n",
- reg->sr_match ));
-#else
- Debug( LDAP_DEBUG_ANY,
- "SASL match pattern %s could not be compiled by regexp engine\n",
- reg->sr_match, 0, 0 );
-#endif
-
- return( LDAP_OPERATIONS_ERROR );
- }