if ( argc < 3 || argc > 4 ) {
fprintf( stderr,
- "%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
+ "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return( 1 );
}
map = &li->at_map;
} else {
fprintf( stderr, "%s: line %d: syntax is "
- "\"map {objectclass | attribute} {<source> | *} "
- "[<dest> | *]\"\n",
+ "\"map {objectclass | attribute} [<local> | *] "
+ "{<foreign> | *}\"\n",
fname, lineno );
return( 1 );
}
- if ( strcasecmp( argv[2], "*" ) != 0 ) {
- src = argv[2];
- if ( argc < 4 )
- dst = "";
- else if ( strcasecmp( argv[3], "*" ) == 0 )
- dst = src;
- else
- dst = argv[3];
- } else {
- if ( argc < 4 ) {
- map->drop_missing = 1;
+ if ( strcmp( argv[2], "*" ) == 0 ) {
+ if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) {
+ map->drop_missing = ( argc < 4 );
return 0;
}
- if ( strcasecmp( argv[3], "*" ) == 0 ) {
- map->drop_missing = 0;
- return 0;
- }
-
- src = argv[3];
- dst = src;
+ src = dst = argv[3];
+ } else if ( argc < 4 ) {
+ src = "";
+ dst = argv[2];
+ } else {
+ src = argv[2];
+ dst = ( strcmp( argv[3], "*" ) == 0 ? src : argv[3] );
}
if ( ( map == &li->at_map )
}
ber_str2bv( src, 0, 1, &mapping->src );
ber_str2bv( dst, 0, 1, &mapping->dst );
- if ( *dst != 0 ) {
- mapping[1].src = mapping->dst;
- mapping[1].dst = mapping->src;
- } else {
- mapping[1].src = mapping->src;
- mapping[1].dst = mapping->dst;
- }
+ mapping[1].src = mapping->dst;
+ mapping[1].dst = mapping->src;
- if ( avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL ||
+ if ( (*src != '\0' &&
+ avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL) ||
avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
{
fprintf( stderr,
return 0;
}
- avl_insert( &map->map, (caddr_t)mapping,
- mapping_cmp, mapping_dup );
+ if ( *src != '\0' )
+ avl_insert( &map->map, (caddr_t)mapping,
+ mapping_cmp, mapping_dup );
avl_insert( &map->remap, (caddr_t)&mapping[1],
mapping_cmp, mapping_dup );
int remap
)
{
- int i;
+ int i, j;
char **na;
struct berval mapped;
if (na == NULL)
return(NULL);
- for (i = 0; an[i].an_name.bv_val; ) {
+ for (i = j = 0; an[i].an_name.bv_val; i++) {
ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
- if (mapped.bv_val != NULL) {
- na[i] = mapped.bv_val;
- i++;
- }
+ if (mapped.bv_val != NULL)
+ na[j++] = mapped.bv_val;
}
- na[i] = NULL;
+ if (j == 0 && i != 0)
+ na[j++] = LDAP_NO_ATTRS;
+ na[j] = NULL;
return(na);
}
if ( argc < 3 || argc > 4 ) {
fprintf( stderr,
- "%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
+ "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return 1;
}
map = &li->targets[ i ]->at_map;
} else {
fprintf( stderr,
- "%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
+ "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
fname, lineno );
return 1;
}
- if ( strcasecmp( argv[ 2 ], "*" ) != 0 ) {
- src = argv[ 2 ];
- if ( argc < 4 ) {
- dst = "";
- } else if ( strcasecmp( argv[ 3 ], "*" ) == 0 ) {
- dst = src;
- } else {
- dst = argv[ 3 ];
- }
- } else {
- if ( argc < 4 ) {
- map->drop_missing = 1;
- return 0;
- }
- if ( strcasecmp( argv[ 3 ], "*" ) == 0 ) {
- map->drop_missing = 0;
+ if ( strcmp( argv[ 2 ], "*" ) == 0 ) {
+ if ( argc < 4 || strcmp( argv[ 3 ], "*" ) == 0 ) {
+ map->drop_missing = ( argc < 4 );
return 0;
}
-
- src = argv[ 3 ];
- dst = src;
+ src = dst = argv[ 3 ];
+ } else if ( argc < 4 ) {
+ src = "";
+ dst = argv[ 2 ];
+ } else {
+ src = argv[ 2 ];
+ dst = ( strcmp( argv[ 3 ], "*" ) == 0 ? src : argv[ 3 ] );
}
if ( ( map == &li->targets[ i ]->at_map )
}
ber_str2bv( src, 0, 1, &mapping->src );
ber_str2bv( dst, 0, 1, &mapping->dst );
- if ( *dst != 0 ) {
- mapping[ 1 ].src = mapping->dst;
- mapping[ 1 ].dst = mapping->src;
- } else {
- mapping[ 1 ].src = mapping->src;
- mapping[ 1 ].dst = mapping->dst;
- }
+ mapping[ 1 ].src = mapping->dst;
+ mapping[ 1 ].dst = mapping->src;
- if ( avl_find( map->map, ( caddr_t )mapping,
- mapping_cmp ) != NULL
+ if ( (*src != '\0' &&
+ avl_find( map->map, ( caddr_t )mapping,
+ mapping_cmp ) != NULL)
|| avl_find( map->remap, ( caddr_t )&mapping[ 1 ],
mapping_cmp ) != NULL) {
fprintf( stderr,
return 0;
}
- avl_insert( &map->map, ( caddr_t )mapping,
- mapping_cmp, mapping_dup );
+ if ( *src != '\0' )
+ avl_insert( &map->map, ( caddr_t )mapping,
+ mapping_cmp, mapping_dup );
avl_insert( &map->remap, ( caddr_t )&mapping[ 1 ],
mapping_cmp, mapping_dup );