-#ifndef USE_LDAP_DN_PARSING /* deprecated */
-#define INQUOTE 1
-#define OUTQUOTE 2
-
-static char **
-explode_name( const char *name, int notypes, int is_type )
-{
- const char *p, *q, *rdn;
- char **parts = NULL;
- int offset, state, have_equals, count = 0, endquote, len;
-
- /* safe guard */
- if(name == NULL) name = "";
-
- /* skip leading whitespace */
- while( ldap_utf8_isspace( name )) {
- LDAP_UTF8_INCR( name );
- }
-
- p = rdn = name;
- offset = 0;
- state = OUTQUOTE;
- have_equals=0;
-
- do {
- /* step forward */
- p += offset;
- offset = 1;
-
- switch ( *p ) {
- case '\\':
- if ( p[1] != '\0' ) {
- offset = LDAP_UTF8_OFFSET(++p);
- }
- break;
- case '"':
- if ( state == INQUOTE )
- state = OUTQUOTE;
- else
- state = INQUOTE;
- break;
- case '=':
- if( state == OUTQUOTE ) have_equals++;
- break;
- case '+':
- if (is_type == NAME_TYPE_LDAP_RDN)
- goto end_part;
- break;
- case '/':
- if (is_type == NAME_TYPE_DCE_DN)
- goto end_part;
- break;
- case ';':
- case ',':
- if (is_type == NAME_TYPE_LDAP_DN)
- goto end_part;
- break;
- case '\0':
- end_part:
- if ( state == OUTQUOTE ) {
- ++count;
- have_equals=0;
-
- if ( parts == NULL ) {
- if (( parts = (char **)LDAP_MALLOC( 8
- * sizeof( char *))) == NULL )
- return( NULL );
- } else if ( count >= 8 ) {
- if (( parts = (char **)LDAP_REALLOC( parts,
- (count+1) * sizeof( char *)))
- == NULL )
- return( NULL );
- }
-
- parts[ count ] = NULL;
- endquote = 0;
-
- if ( notypes ) {
- for ( q = rdn; q < p && *q != '='; ++q ) {
- /* EMPTY */;
- }
-
- if ( q < p ) {
- rdn = ++q;
- }
-
- if ( *rdn == '"' ) {
- ++rdn;
- }
-
- if ( p[-1] == '"' ) {
- endquote = 1;
- --p;
- }
- }
-
- len = p - rdn;
-
- if (( parts[ count-1 ] = (char *)LDAP_CALLOC( 1,
- len + 1 )) != NULL )
- {
- AC_MEMCPY( parts[ count-1 ], rdn, len );
-
- if( !endquote ) {
- /* skip trailing spaces */
- while( len > 0 && ldap_utf8_isspace(
- &parts[count-1][len-1] ) )
- {
- --len;
- }
- }
-
- parts[ count-1 ][ len ] = '\0';
- }
-
- /*
- * Don't forget to increment 'p' back to where
- * it should be. If we don't, then we will
- * never get past an "end quote."
- */
- if ( endquote == 1 )
- p++;
-
- rdn = *p ? &p[1] : p;
- while ( ldap_utf8_isspace( rdn ) )
- ++rdn;
- } break;
- }
- } while ( *p );
-
- return( parts );
-}
-#endif /* !USE_LDAP_DN_PARSING */
-