} else if ( strcasecmp( argv[1], "attribute" ) == 0 ) {
map = &li->at_map;
} else {
- fprintf( stderr,
- "%s: line %d: syntax is \"map {objectclass | attribute} {<source> | *} [<dest> | *]\"\n",
+ fprintf( stderr, "%s: line %d: syntax is "
+ "\"map {objectclass | attribute} {<source> | *} "
+ "[<dest> | *]\"\n",
fname, lineno );
return( 1 );
}
fname, lineno );
}
- mapping = (struct ldapmapping *)ch_calloc( 2, sizeof(struct ldapmapping) );
+ mapping = (struct ldapmapping *)ch_calloc( 2,
+ sizeof(struct ldapmapping) );
if ( mapping == NULL ) {
fprintf( stderr,
"%s: line %d: out of memory\n",
mapping[1].dst = mapping->dst;
}
- if ( avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL
- || avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
+ if ( avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL ||
+ avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
{
fprintf( stderr,
"%s: line %d: duplicate mapping found (ignored)\n",
/* anything else */
} else {
- fprintf( stderr,
-"%s: line %d: unknown directive \"%s\" in ldap database definition (ignored)\n",
+ fprintf( stderr, "%s: line %d: unknown directive \"%s\" "
+ "in ldap database definition (ignored)\n",
fname, lineno, argv[0] );
}
return 0;
return( ( strcasecmp(map1->src.bv_val, map2->src.bv_val) == 0 ) ? -1 : 0 );
}
+void
+ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping **m )
+{
+ struct ldapmapping *mapping;
+
+ assert( m );
+
+ *m = NULL;
+
+ mapping = (struct ldapmapping *)ch_calloc( 2,
+ sizeof( struct ldapmapping ) );
+ if ( mapping == NULL ) {
+ return;
+ }
+
+ ber_str2bv( "objectclass", sizeof("objectclass")-1, 1, &mapping->src);
+ ber_dupbv( &mapping->dst, &mapping->src );
+ mapping[1].src = mapping->src;
+ mapping[1].dst = mapping->dst;
+
+ avl_insert( &lm->map, (caddr_t)mapping,
+ mapping_cmp, mapping_dup );
+ avl_insert( &lm->remap, (caddr_t)&mapping[1],
+ mapping_cmp, mapping_dup );
+ *m = mapping;
+}
+
void
ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
int remap )
in_quote = !in_quote;
if (q != NULL) {
plen = p - q;
- memcpy(s, q, plen);
+ AC_MEMCPY(s, q, plen);
s += plen;
q = NULL;
}
}
s += (long)nf;
}
- memcpy(s, m.bv_val, plen);
+ AC_MEMCPY(s, m.bv_val, plen);
s += plen;
*p = c;
q = NULL;
char **
ldap_back_map_attrs(
struct ldapmap *at_map,
- AttributeName *a,
+ AttributeName *an,
int remap
)
{
int i;
char **na;
- AttributeName *an;
struct berval mapped;
- if (a == NULL)
+ if (an == NULL)
return(NULL);
- for (i = 0, an=a; an; an=an->an_next, i++) {
+ for (i = 0; an[i].an_name.bv_val; i++) {
/* */
}
if (na == NULL)
return(NULL);
- for (i = 0, an=a; an; an=an->an_next) {
- ldap_back_map(at_map, &an->an_name, &mapped, remap);
+ for (i = 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++;
{
char *res;
- res = ch_calloc( sizeof( char ), strlen( s ) + 3 );
+ res = ch_calloc( sizeof( char ), strlen( s ) + sizeof("%1") );
sprintf( res, "%%1%s", s );
if ( normalize ) {
- char *out = dn_normalize( res + 2 );
+ char *out = dn_normalize( res + (sizeof("%1")-1) );
if ( out != res + 2 ) {
strcpy( res + 2, out );
free( out );
return 0;
}
#endif /* ENABLE_REWRITE */
-