#include <stdio.h>
#include <sys/types.h>
+#include "ac/string.h"
#include "slap.h"
#include "ldap_pvt.h"
*/
struct berval concat;
struct berval values[] = {
- { sizeof( "'%'" ) - 1, "'%'" },
- { sizeof( "?" ) - 1, "?" },
- { 0, NULL }
+ BER_BVC( "'%'" ),
+ BER_BVC( "?" ),
+ BER_BVNULL
};
struct berbuf bb = BB_NULL;
backsql_strfcat( &bb, "blbbb",
&si->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn) LIKE " ) - 1,
+ (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE " ),
"(ldap_entries.dn) LIKE ",
&si->upper_func_open,
&concat,
*/
backsql_strfcat( &bb, "lb",
- (ber_len_t)sizeof( "ldap_entries.dn LIKE " ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.dn LIKE " ),
"ldap_entries.dn LIKE ",
&concat );
}
backsql_strfcat( &bb, "blbl",
&si->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn)=" ) - 1,
+ (ber_len_t)STRLENOF( "(ldap_entries.dn)=" ),
"(ldap_entries.dn)=",
&si->upper_func,
- (ber_len_t)sizeof( "(?)" ) - 1, "(?)" );
+ (ber_len_t)STRLENOF( "(?)" ), "(?)" );
} else {
*/
backsql_strfcat( &bb, "l",
- (ber_len_t)sizeof( "ldap_entries.dn=?" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.dn=?" ),
"ldap_entries.dn=?");
}
backsql_strfcat( &bb, "sbl",
backsql_id_query,
&si->upper_func,
- (ber_len_t)sizeof( "(dn)=?" ) - 1, "(dn)=?" );
+ (ber_len_t)STRLENOF( "(dn)=?" ), "(dn)=?" );
} else {
backsql_strfcat( &bb, "sblbcb",
backsql_id_query,
&si->upper_func,
- (ber_len_t)sizeof( "(dn)=" ) - 1, "(dn)=",
+ (ber_len_t)STRLENOF( "(dn)=" ), "(dn)=",
&si->upper_func_open,
'?',
&si->upper_func_close );
struct berbuf bb = BB_NULL;
backsql_strfcat( &bb, "lblblblbcbl",
- (ber_len_t)sizeof( "SELECT " ) - 1, "SELECT ",
+ (ber_len_t)STRLENOF( "SELECT " ), "SELECT ",
&at_map->bam_sel_expr,
- (ber_len_t)sizeof( " AS " ) - 1, " AS ",
+ (ber_len_t)STRLENOF( " AS " ), " AS ",
&at_map->bam_ad->ad_cname,
- (ber_len_t)sizeof( " FROM " ) - 1, " FROM ",
+ (ber_len_t)STRLENOF( " FROM " ), " FROM ",
&at_map->bam_from_tbls,
- (ber_len_t)sizeof( " WHERE " ) - 1, " WHERE ",
+ (ber_len_t)STRLENOF( " WHERE " ), " WHERE ",
&oc_map->bom_keytbl,
'.',
&oc_map->bom_keycol,
- (ber_len_t)sizeof( "=?" ) - 1, "=?" );
+ (ber_len_t)STRLENOF( "=?" ), "=?" );
if ( at_map->bam_join_where.bv_val != NULL ) {
backsql_strfcat( &bb, "lb",
- (ber_len_t)sizeof( " AND ") - 1, " AND ",
+ (ber_len_t)STRLENOF( " AND " ), " AND ",
&at_map->bam_join_where );
}
bb.bb_val.bv_len = 0;
bb.bb_len = 0;
backsql_strfcat( &bb, "lbcbll",
- (ber_len_t)sizeof( "ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entries.keyval=" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entries.keyval=" ),
"ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entries.keyval=",
&oc_map->bom_keytbl,
'.',
&oc_map->bom_keycol,
- (ber_len_t)sizeof( " and ldap_entries.oc_map_id=" ) - 1,
+ (ber_len_t)STRLENOF( " and ldap_entries.oc_map_id=" ),
" and ldap_entries.oc_map_id=",
slen, s );
bb.bb_val.bv_len = 0;
bb.bb_len = 0;
backsql_strfcat( &bb, "lbcbll",
- (ber_len_t)sizeof( "ldap_entries.id=ldap_referrals.entry_id and ldap_entries.keyval=" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.id=ldap_referrals.entry_id and ldap_entries.keyval=" ),
"ldap_entries.id=ldap_referrals.entry_id and ldap_entries.keyval=",
&oc_map->bom_keytbl,
'.',
&oc_map->bom_keycol,
- (ber_len_t)sizeof( " and ldap_entries.oc_map_id=" ) - 1,
+ (ber_len_t)STRLENOF( " and ldap_entries.oc_map_id=" ),
" and ldap_entries.oc_map_id=",
slen, s );
switch ( op ) {
case LDAP_FILTER_AND:
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( " AND " ) - 1,
+ (ber_len_t)STRLENOF( " AND " ),
" AND " );
break;
case LDAP_FILTER_OR:
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( " OR " ) - 1,
+ (ber_len_t)STRLENOF( " OR " ),
" OR " );
break;
}
backsql_strfcat( &bsi->bsi_flt_where,
"bl",
&at->bam_sel_expr_u,
- (ber_len_t)sizeof( " LIKE '" ) - 1,
+ (ber_len_t)STRLENOF( " LIKE '" ),
" LIKE '" );
} else {
backsql_strfcat( &bsi->bsi_flt_where, "bl",
&at->bam_sel_expr,
- (ber_len_t)sizeof( " LIKE '" ) - 1, " LIKE '" );
+ (ber_len_t)STRLENOF( " LIKE '" ), " LIKE '" );
}
if ( f->f_sub_initial.bv_val != NULL ) {
* like '%attributeName=value%'"
*/
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
+ (ber_len_t)STRLENOF( "1=1" ), "1=1" );
bsi->bsi_status = LDAP_SUCCESS;
rc = 1;
goto done;
case LDAP_FILTER_PRESENT:
filter_oc_success:;
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
+ (ber_len_t)STRLENOF( "1=1" ), "1=1" );
bsi->bsi_status = LDAP_SUCCESS;
rc = 1;
goto done;
* candidate.
*/
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
+ (ber_len_t)STRLENOF( "1=1" ), "1=1" );
if ( ad == slap_schema.si_ad_hasSubordinates ) {
/*
* instruct candidate selection algorithm
/* search anyway; other parts of the filter
* may succeeed */
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
+ (ber_len_t)STRLENOF( "1=1" ), "1=1" );
bsi->bsi_status = LDAP_SUCCESS;
rc = 1;
goto done;
/* if more definitions of the same attr, apply */
if ( vat[i]->bam_next ) {
backsql_strfcat( &bsi->bsi_flt_where, "l",
- sizeof( " OR " ) - 1, " OR " );
+ STRLENOF( " OR " ), " OR " );
vat[i] = vat[i]->bam_next;
goto next;
}
i++;
if ( vat[i] ) {
backsql_strfcat( &bsi->bsi_flt_where, "l",
- sizeof( " OR " ) - 1, " OR " );
+ STRLENOF( " OR " ), " OR " );
goto next;
}
backsql_strfcat( &bsi->bsi_flt_where, "cbl",
'(', /* ) */
&at->bam_sel_expr_u,
- (ber_len_t)sizeof( "='" ) - 1,
+ (ber_len_t)STRLENOF( "='" ),
"='" );
start = bsi->bsi_flt_where.bb_val.bv_len;
backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
'(', /* ) */
&at->bam_sel_expr,
- (ber_len_t)sizeof( "='" ) - 1, "='",
+ (ber_len_t)STRLENOF( "='" ), "='",
filter_value,
(ber_len_t)sizeof( /* (' */ "')" ) - 1,
/* (' */ "')" );
backsql_strfcat( &bsi->bsi_flt_where, "cbl",
'(', /* ) */
&at->bam_sel_expr_u,
- (ber_len_t)sizeof( " LIKE '%" ) - 1,
+ (ber_len_t)STRLENOF( " LIKE '%" ),
" LIKE '%" );
start = bsi->bsi_flt_where.bb_val.bv_len;
backsql_strfcat( &bsi->bsi_flt_where, "cblbl",
'(', /* ) */
&at->bam_sel_expr,
- (ber_len_t)sizeof( " LIKE '%" ) - 1,
+ (ber_len_t)STRLENOF( " LIKE '%" ),
" LIKE '%",
filter_value,
(ber_len_t)sizeof( /* (' */ "%')" ) - 1,
if ( at->bam_join_where.bv_val != NULL
&& strstr( bsi->bsi_join_where.bb_val.bv_val, at->bam_join_where.bv_val ) == NULL ) {
backsql_strfcat( &bsi->bsi_join_where, "lb",
- (ber_len_t)sizeof( " AND " ) - 1, " AND ",
+ (ber_len_t)STRLENOF( " AND " ), " AND ",
&at->bam_join_where );
}
/* unhandled filter type; should not happen */
assert( 0 );
backsql_strfcat( &bsi->bsi_flt_where, "l",
- (ber_len_t)sizeof( "1=1" ) - 1, "1=1" );
+ (ber_len_t)STRLENOF( "1=1" ), "1=1" );
break;
}
bsi->bsi_flt_where.bb_len = 0;
backsql_strfcat( &bsi->bsi_sel, "lbcbc",
- (ber_len_t)sizeof( "SELECT DISTINCT ldap_entries.id," ) - 1,
+ (ber_len_t)STRLENOF( "SELECT DISTINCT ldap_entries.id," ),
"SELECT DISTINCT ldap_entries.id,",
&bsi->bsi_oc->bom_keytbl,
'.',
'\'' );
}
backsql_strfcat( &bsi->bsi_sel, "l",
- (ber_len_t)sizeof( " AS objectClass,ldap_entries.dn AS dn" ) - 1,
+ (ber_len_t)STRLENOF( " AS objectClass,ldap_entries.dn AS dn" ),
" AS objectClass,ldap_entries.dn AS dn" );
backsql_strfcat( &bsi->bsi_from, "lb",
- (ber_len_t)sizeof( " FROM ldap_entries," ) - 1,
+ (ber_len_t)STRLENOF( " FROM ldap_entries," ),
" FROM ldap_entries,",
&bsi->bsi_oc->bom_keytbl );
backsql_strfcat( &bsi->bsi_join_where, "lbcbl",
- (ber_len_t)sizeof( " WHERE " ) - 1, " WHERE ",
+ (ber_len_t)STRLENOF( " WHERE " ), " WHERE ",
&bsi->bsi_oc->bom_keytbl,
'.',
&bsi->bsi_oc->bom_keycol,
- (ber_len_t)sizeof( "=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND " ) - 1,
+ (ber_len_t)STRLENOF( "=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND " ),
"=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND " );
switch ( bsi->bsi_scope ) {
if ( BACKSQL_CANUPPERCASE( bi ) ) {
backsql_strfcat( &bsi->bsi_join_where, "bl",
&bi->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn)=?" ) - 1,
+ (ber_len_t)STRLENOF( "(ldap_entries.dn)=?" ),
"(ldap_entries.dn)=?" );
} else {
backsql_strfcat( &bsi->bsi_join_where, "l",
- (ber_len_t)sizeof( "ldap_entries.dn=?" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.dn=?" ),
"ldap_entries.dn=?" );
}
break;
if ( BACKSQL_CANUPPERCASE( bi ) ) {
backsql_strfcat( &bsi->bsi_join_where, "bl",
&bi->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn) LIKE ?" ) - 1,
+ (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE ?" ),
"(ldap_entries.dn) LIKE ?" );
} else {
backsql_strfcat( &bsi->bsi_join_where, "l",
- (ber_len_t)sizeof( "ldap_entries.dn LIKE ?" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.dn LIKE ?" ),
"ldap_entries.dn LIKE ?" );
}
break;
case LDAP_SCOPE_ONELEVEL:
backsql_strfcat( &bsi->bsi_join_where, "l",
- (ber_len_t)sizeof( "ldap_entries.parent=?" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.parent=?" ),
"ldap_entries.parent=?" );
break;
if ( BACKSQL_CANUPPERCASE( bi ) ) {
backsql_strfcat( &bsi->bsi_join_where, "bl",
&bi->upper_func,
- (ber_len_t)sizeof( "(ldap_entries.dn) LIKE ?" ) - 1,
+ (ber_len_t)STRLENOF( "(ldap_entries.dn) LIKE ?" ),
"(ldap_entries.dn) LIKE ?" );
} else {
backsql_strfcat( &bsi->bsi_join_where, "l",
- (ber_len_t)sizeof( "ldap_entries.dn LIKE ?" ) - 1,
+ (ber_len_t)STRLENOF( "ldap_entries.dn LIKE ?" ),
"ldap_entries.dn LIKE ?" );
}
&bsi->bsi_sel.bb_val,
&bsi->bsi_from.bb_val,
&bsi->bsi_join_where.bb_val,
- (ber_len_t)sizeof( " AND " ) - 1, " AND ",
+ (ber_len_t)STRLENOF( " AND " ), " AND ",
&bsi->bsi_flt_where.bb_val );
*query = bb.bb_val;