From 05b81e623d6dd3915bda483fdffdc53536f28fc6 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 6 Aug 2004 17:29:59 +0000 Subject: [PATCH] cleanup attr flags; provide a helper --- servers/slapd/proto-slap.h | 1 + servers/slapd/result.c | 27 ++++++++++++++++++--------- servers/slapd/slap.h | 16 ++++++++-------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b0343fa8f5..2f33629110 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -974,6 +974,7 @@ LDAP_SLAPD_F (int) slap_read_controls LDAP_P(( Operation *op, SlapReply *rs, LDAP_SLAPD_F (int) str2result LDAP_P(( char *s, int *code, char **matched, char **info )); LDAP_SLAPD_F (int) slap_map_api2result LDAP_P(( SlapReply *rs )); +LDAP_SLAPD_F (slap_mask_t) slap_attr_flags LDAP_P(( AttributeName *an )); LDAP_SLAPD_V( const struct berval ) slap_dummy_bv; diff --git a/servers/slapd/result.c b/servers/slapd/result.c index bedbc26a1d..8dfb871436 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -786,15 +786,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) /* FIXME: maybe we could se this flag at the operation level; * however, in principle the caller of send_search_entry() may * change the attribute list at each call */ - if ( rs->sr_attrs == NULL ) { - rs->sr_attr_flags = ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES ); - - } else { - rs->sr_attr_flags |= an_find( rs->sr_attrs, &AllOper ) ? - SLAP_OPATTRS_YES : SLAP_OPATTRS_NO; - rs->sr_attr_flags |= an_find( rs->sr_attrs, &AllUser ) ? - SLAP_USERATTRS_YES : SLAP_USERATTRS_NO; - } + rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs ); rc = backend_operational( op, rs ); if ( rc ) { @@ -1838,3 +1830,20 @@ slap_map_api2result( SlapReply *rs ) } } + +slap_mask_t +slap_attr_flags( AttributeName *an ) +{ + slap_mask_t flags = SLAP_ATTRS_UNDEFINED; + + if ( an == NULL ) { + flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES ); + + } else { + flags |= an_find( an, &AllOper ) ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO; + flags |= an_find( an, &AllUser ) ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO; + } + + return flags; +} + diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 0cedcf8fcc..e7d66dd85d 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1691,16 +1691,16 @@ typedef struct rep_extended_s { typedef struct rep_search_s { Entry *r_entry; - int r_attr_flags; -#define SLAP_ATTRS_UNDEFINED (0) -#define SLAP_OPATTRS_NO (0x01) -#define SLAP_OPATTRS_YES (0x02) -#define SLAP_USERATTRS_NO (0x10) -#define SLAP_USERATTRS_YES (0x20) + slap_mask_t r_attr_flags; +#define SLAP_ATTRS_UNDEFINED (0x00U) +#define SLAP_OPATTRS_NO (0x01U) +#define SLAP_OPATTRS_YES (0x02U) +#define SLAP_USERATTRS_NO (0x10U) +#define SLAP_USERATTRS_YES (0x20U) #define SLAP_OPATTRS_MASK(f) ( (f) & (SLAP_OPATTRS_NO|SLAP_OPATTRS_YES) ) -#define SLAP_OPATTRS(f) ( (f) & SLAP_OPATTRS_YES ) +#define SLAP_OPATTRS(f) ( ( (f) & SLAP_OPATTRS_YES ) == SLAP_OPATTRS_YES ) #define SLAP_USERATTRS_MASK(f) ( (f) & (SLAP_USERATTRS_NO|SLAP_USERATTRS_YES) ) -#define SLAP_USERATTRS(f) ( (f) & SLAP_USERATTRS_YES ) +#define SLAP_USERATTRS(f) ( ( (f) & SLAP_USERATTRS_YES ) == SLAP_USERATTRS_YES ) Attribute *r_operational_attrs; AttributeName *r_attrs; int r_nentries; -- 2.39.5