version 1.9.2.1, 2005/08/25 17:05:42
|
version 1.9.2.2, 2005/08/29 18:26:11
|
Line 1
|
Line 1
|
/* valsort.c - sort attribute values */ |
/* valsort.c - sort attribute values */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/valsort.c,v 1.9 2005/08/25 04:56:09 hyc Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/valsort.c,v 1.11 2005/08/26 23:21:51 hyc Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2005 The OpenLDAP Foundation. |
* Copyright 2005 The OpenLDAP Foundation. |
Line 272 valsort_response( Operation *op, SlapRep
|
Line 272 valsort_response( Operation *op, SlapRep
|
valsort_info *vi; |
valsort_info *vi; |
Attribute *a; |
Attribute *a; |
|
|
/* We only want search responses */ |
/* If this is not a search response, or it is a syncrepl response, |
if ( rs->sr_type != REP_SEARCH ) return SLAP_CB_CONTINUE; |
* or the valsort control wants raw results, pass thru unmodified. |
|
*/ |
/* If this is a syncrepl response, pass thru unmodified */ |
if ( rs->sr_type != REP_SEARCH || |
if ( op->o_sync > SLAP_CONTROL_IGNORED ) return SLAP_CB_CONTINUE; |
( _SCM(op->o_sync) > SLAP_CONTROL_IGNORED ) || |
|
( op->o_ctrlflag[valsort_cid] & SLAP_CONTROL_DATA0)) |
|
return SLAP_CB_CONTINUE; |
|
|
on = (slap_overinst *) op->o_bd->bd_info; |
on = (slap_overinst *) op->o_bd->bd_info; |
vi = on->on_bi.bi_private; |
vi = on->on_bi.bi_private; |
Line 471 valsort_modify( Operation *op, SlapReply
|
Line 473 valsort_modify( Operation *op, SlapReply
|
} |
} |
|
|
static int |
static int |
|
valsort_db_open( |
|
BackendDB *be |
|
) |
|
{ |
|
return overlay_register_control( be, LDAP_CONTROL_VALSORT ); |
|
} |
|
|
|
static int |
valsort_destroy( |
valsort_destroy( |
BackendDB *be |
BackendDB *be |
) |
) |
Line 493 valsort_parseCtrl(
|
Line 503 valsort_parseCtrl(
|
SlapReply *rs, |
SlapReply *rs, |
LDAPControl *ctrl ) |
LDAPControl *ctrl ) |
{ |
{ |
if ( ctrl->ldctl_value.bv_len ) { |
ber_tag_t tag; |
rs->sr_text = "valSort control value not empty"; |
BerElementBuffer berbuf; |
|
BerElement *ber = (BerElement *)&berbuf; |
|
ber_int_t flag = 0; |
|
|
|
if ( ctrl->ldctl_value.bv_len == 0 ) { |
|
rs->sr_text = "valSort control value is empty (or absent)"; |
|
return LDAP_PROTOCOL_ERROR; |
|
} |
|
|
|
ber_init2( ber, &ctrl->ldctl_value, 0 ); |
|
if (( tag = ber_scanf( ber, "{b}", &flag )) == LBER_ERROR ) { |
|
rs->sr_text = "valSort control: flag decoding error"; |
return LDAP_PROTOCOL_ERROR; |
return LDAP_PROTOCOL_ERROR; |
} |
} |
|
|
op->o_ctrlflag[valsort_cid] = ctrl->ldctl_iscritical ? |
op->o_ctrlflag[valsort_cid] = ctrl->ldctl_iscritical ? |
SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; |
SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL; |
|
if ( flag ) |
|
op->o_ctrlflag[valsort_cid] |= SLAP_CONTROL_DATA0; |
|
|
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
Line 507 static slap_overinst valsort;
|
Line 531 static slap_overinst valsort;
|
|
|
int valsort_init() |
int valsort_init() |
{ |
{ |
int i, rc; |
int rc; |
|
|
valsort.on_bi.bi_type = "valsort"; |
valsort.on_bi.bi_type = "valsort"; |
valsort.on_bi.bi_db_destroy = valsort_destroy; |
valsort.on_bi.bi_db_destroy = valsort_destroy; |
|
valsort.on_bi.bi_db_open = valsort_db_open; |
|
|
valsort.on_bi.bi_op_add = valsort_add; |
valsort.on_bi.bi_op_add = valsort_add; |
valsort.on_bi.bi_op_modify = valsort_modify; |
valsort.on_bi.bi_op_modify = valsort_modify; |