int slap_sasl_regexp_rewrite_config(
		const char	*fname,
		int		lineno,
		const char	*match,
		const char	*replace,
		const char	*context )
{
	int	rc;
	char	*argvRule[] = { "rewriteRule", NULL, NULL, ":@", NULL };

	/* init at first call */
	if ( sasl_rwinfo == NULL ) {
		char *argvEngine[] = { "rewriteEngine", "on", NULL };
		char *argvContext[] = { "rewriteContext", NULL, NULL };

		/* initialize rewrite engine */
 		sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );

		/* switch on rewrite engine */
 		rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvEngine );
 		if (rc != LDAP_SUCCESS) {
			return rc;
		}

		/* create generic authid context */
		argvContext[1] = AUTHID_CONTEXT;
 		rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvContext );
 		if (rc != LDAP_SUCCESS) {
			return rc;
		}
	}

	argvRule[1] = (char *)match;
	argvRule[2] = (char *)replace;
 	rc = rewrite_parse( sasl_rwinfo, fname, lineno, 4, argvRule );

	return rc;
}
int slap_sasl_regexp_rewrite_config(
		const char	*fname,
		int		lineno,
		const char	*match,
		const char	*replace,
		const char	*context )
{
	int	rc;
	char	*argvRule[] = { "rewriteRule", NULL, NULL, ":@", NULL };

	 
	if ( sasl_rwinfo == NULL ) {
		char *argvEngine[] = { "rewriteEngine", "on", NULL };
		char *argvContext[] = { "rewriteContext", NULL, NULL };

		 
 		sasl_rwinfo = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );

		 
 		rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvEngine );
 		if (rc != LDAP_SUCCESS) {
			return rc;
		}

		 
		argvContext[1] = AUTHID_CONTEXT;
 		rc = rewrite_parse( sasl_rwinfo, fname, lineno, 2, argvContext );
 		if (rc != LDAP_SUCCESS) {
			return rc;
		}
	}

	argvRule[1] = (char *)match;
	argvRule[2] = (char *)replace;
 	rc = rewrite_parse( sasl_rwinfo, fname, lineno, 4, argvRule );

	return rc;
}