From d50eb2e9598e8c8ea1df2e9c541e226d255691cd Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 23 Feb 2002 23:47:37 +0000 Subject: [PATCH] C translator portability changes (ITS#1609) --- libraries/libldap/getdn.c | 10 +++++++--- servers/slapd/acl.c | 10 ++++++++-- servers/slapd/backglue.c | 8 ++++++-- servers/slapd/entry.c | 4 +++- servers/slapd/sets.c | 5 ++++- servers/slapd/tools/slapadd.c | 5 ++++- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index c162fe724a..e0d36154a6 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -601,11 +601,12 @@ ldap_dnfree( LDAPDN *dn ) int ldap_str2dn( LDAP_CONST char *str, LDAPDN **dn, unsigned flags ) { - struct berval bv = { 0, (char *)str }; + struct berval bv; assert( str ); bv.bv_len = strlen( str ); + bv.bv_val = (char *) str; return ldap_bv2dn( &bv, dn, flags ); } @@ -687,7 +688,9 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags ) for ( ; p < end; p++ ) { int err; - struct berval tmpbv = { bv->bv_len - ( p - str ), (char *)p }; + struct berval tmpbv; + tmpbv.bv_len = bv->bv_len - ( p - str ); + tmpbv.bv_val = (char *)p; err = ldap_bv2rdn( &tmpbv, &newRDN, (char **) &p, flags ); if ( err != LDAP_SUCCESS ) { @@ -815,12 +818,13 @@ int ldap_str2rdn( LDAP_CONST char *str, LDAPRDN **rdn, char **n_in, unsigned flags ) { - struct berval bv = { 0, (char *)str }; + struct berval bv; assert( str ); assert( str[ 0 ] != '\0' ); /* FIXME: is this required? */ bv.bv_len = strlen( str ); + bv.bv_val = (char *) str; return ldap_bv2rdn( &bv, rdn, n_in, flags ); } diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 4e7a8e2cdf..5182380843 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -845,10 +845,13 @@ acl_mask( if ( b->a_group_pat.bv_len && op->o_ndn.bv_len ) { char buf[1024]; - struct berval bv = { sizeof(buf) - 1, buf }; + struct berval bv; struct berval ndn = { 0, NULL }; int rc; + bv.bv_len = sizeof(buf) - 1; + bv.bv_val = buf; + /* b->a_group is an unexpanded entry name, expanded it should be an * entry with objectclass group* and we test to see if odn is one of * the values in the attribute group @@ -1823,9 +1826,12 @@ regex_matches( { regex_t re; char newbuf[512]; - struct berval bv = {sizeof(newbuf), newbuf}; + struct berval bv; int rc; + bv.bv_len = sizeof(newbuf); + bv.bv_val = newbuf; + if(str == NULL) str = ""; string_expand(&bv, pat, buf, matches); diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 61bdf574d5..4b0b49000f 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -296,8 +296,12 @@ glue_back_search ( long stoptime = 0; struct berval bv; glue_state gs = {0}; - slap_callback cb = {glue_back_response, glue_back_sresult, - glue_back_sendentry, &gs}; + slap_callback cb; + + cb.sc_response = glue_back_response; + cb.sc_sresult = glue_back_sresult; + cb.sc_sendentry = glue_back_sendentry; + cb.sc_private = &gs; gs.prevcb = op->o_callback; diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 7c01ac87a2..8094a09e8b 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -590,7 +590,9 @@ int entry_decode(struct berval *bv, Entry **e) a = NULL; while (i = entry_getlen(&ptr)) { - struct berval bv = { i, ptr }; + struct berval bv; + bv.bv_len = i; + bv.bv_val = ptr; if (a) { a->a_next = (Attribute *)bptr; } diff --git a/servers/slapd/sets.c b/servers/slapd/sets.c index b223ca3250..9d01b9c671 100644 --- a/servers/slapd/sets.c +++ b/servers/slapd/sets.c @@ -119,9 +119,12 @@ set_chase (SLAP_SET_GATHER gatherer, { BerVarray vals, nset; char attrstr[32]; - struct berval bv = {attr->bv_len, attrstr}; + struct berval bv; int i; + bv.bv_len = attr->bv_len; + bv.bv_val = attrstr; + if (set == NULL) return(ch_calloc(1, sizeof(struct berval))); diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index b6b05bdae7..d3ce99b9d2 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -53,7 +53,10 @@ main( int argc, char **argv ) while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) { Entry *e = str2entry( buf ); - struct berval bvtext = { textlen, textbuf }; + struct berval bvtext; + + bvtext.bv_len = textlen; + bvtext.bv_val = textbuf; if( e == NULL ) { fprintf( stderr, "%s: could not parse entry (line=%d)\n", -- 2.39.5