/* figure out how big the string is */
size = 1; /* nul-term */
for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
- size += strlen(ludp->lud_scheme) + strlen(ludp->lud_host);
- if (strchr(ludp->lud_host, ':')) /* will add [ ] below */
- size += 2;
+ size += strlen(ludp->lud_scheme);
+ if ( ludp->lud_host ) {
+ size += strlen(ludp->lud_host);
+ /* will add [ ] below */
+ if (strchr(ludp->lud_host, ':'))
+ size += 2;
+ }
size += sizeof(":/// ");
if (ludp->lud_port != 0) {
p = s;
for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
- p += sprintf(p,
- strchr(ludp->lud_host, ':') ? "%s://[%s]" : "%s://%s",
- ludp->lud_scheme, ludp->lud_host);
+ p += sprintf(p, "%s://", ludp->lud_scheme);
+ if ( ludp->lud_host ) {
+ p += sprintf(p, strchr(ludp->lud_host, ':')
+ ? "[%s]" : "%s", ludp->lud_host);
+ }
if (ludp->lud_port != 0)
p += sprintf(p, ":%d", ludp->lud_port);
*p++ = '/';
#include "slap.h"
#include "../back-ldap/back-ldap.h"
+#include "../../../libraries/libldap/ldap-int.h"
#include "back-meta.h"
static struct metatarget *
#if 0
int j;
#endif /* uncomment if uri MUST be a branch of suffix */
- LDAPURLDesc *ludp;
- char *last;
+ LDAPURLDesc *ludp, *tmpludp;
struct berval dn;
int rc;
/*
* uri MUST be legal!
*/
- if ( ldap_url_parse( argv[ 1 ], &ludp ) != LDAP_SUCCESS ) {
+ if ( ldap_url_parselist( &ludp, argv[ 1 ] ) != LDAP_SUCCESS ) {
fprintf( stderr,
"%s: line %d: unable to parse URI"
" in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
return( 1 );
}
- li->targets[ i ]->uri = ch_strdup( argv[ 1 ] );
- last = strstr( li->targets[ i ]->uri, ludp->lud_dn );
- assert( last != NULL );
- last[ 0 ] = '\0';
+ ludp->lud_dn[ 0 ] = '\0';
+
+ for ( tmpludp = ludp->lud_next; tmpludp; tmpludp = tmpludp->lud_next ) {
+ if ( tmpludp->lud_dn != NULL && tmpludp->lud_dn[ 0 ] != '\0' ) {
+ fprintf( stderr, "%s: line %d: "
+ "multiple URIs must have no DN part\n",
+ fname, lineno, argv[ 1 ] );
+ return( 1 );
+
+ }
+ }
+
+ li->targets[ i ]->uri = ldap_url_list2urls( ludp );
+ ldap_free_urllist( ludp );
+ if ( li->targets[ i ]->uri == NULL) {
+ fprintf( stderr, "%s: line %d: no memory?\n",
+ fname, lineno );
+ return( 1 );
+ }
/*
* uri MUST be a branch of suffix!
}
}
#endif
-
- ldap_free_urldesc( ludp );
#if 0
fprintf(stderr, "%s: line %d: URI \"%s\", suffix \"%s\"\n",