static int mkfilter_service_byname(nssov_mapinfo *mi,struct berval *name, struct berval *protocol,struct berval *buf) { char buf2[1024],buf3[1024]; struct berval bv2 = {sizeof(buf2),buf2}; struct berval bv3 = {sizeof(buf3),buf3}; /* escape attributes */ if (nssov_escape(name,&bv2)) return -1; if (!BER_BVISNULL(protocol)) { if (nssov_escape(protocol,&bv3)) return -1; if (bv2.bv_len + mi->mi_filter.bv_len + mi->mi_attrs[0].an_desc->ad_cname.bv_len + bv3.bv_len + mi->mi_attrs[2].an_desc->ad_cname.bv_len + 9 > buf->bv_len ) return -1; buf->bv_len = snprintf(buf->bv_val, buf->bv_len, "(&%s(%s=%s)(%s=%s))", mi->mi_filter.bv_val, mi->mi_attrs[0].an_desc->ad_cname.bv_val, bv2.bv_val, mi->mi_attrs[2].an_desc->ad_cname.bv_val, bv3.bv_val ); } else { if (bv2.bv_len + mi->mi_filter.bv_len + mi->mi_attrs[0].an_desc->ad_cname.bv_len + 6 > buf->bv_len ) return -1; buf->bv_len = snprintf(buf->bv_val, buf->bv_len, "(&%s(%s=%s))", mi->mi_filter.bv_val, mi->mi_attrs[0].an_desc->ad_cname.bv_val, bv2.bv_val ); } return 0; }
/* create a search filter using a name that requires escaping */ int nssov_filter_byname(nssov_mapinfo *mi,int key,struct berval *name,struct berval *buf) { char buf2[1024]; struct berval bv2 = {sizeof(buf2),buf2}; /* escape attribute */ if (nssov_escape(name,&bv2)) return -1; /* build filter */ if (bv2.bv_len + mi->mi_filter.bv_len + mi->mi_attrs[key].an_desc->ad_cname.bv_len + 6 > buf->bv_len ) return -1; buf->bv_len = snprintf(buf->bv_val, buf->bv_len, "(&%s(%s=%s))", mi->mi_filter.bv_val, mi->mi_attrs[key].an_desc->ad_cname.bv_val, bv2.bv_val ); return 0; }