Sun Java System Portal Server 7.1 Developer's Guide

Attribute-Value Pair Routines

Attribute-value pairs contain an attribute and an associated value. The value often is a simple null-terminated string; however, the value can also be binary data. Attribute-value pairs are stored as SearchAVPair structures.

The important fields in a SearchAVPair structure are:

char *attribute;

Attribute string; ”\\0’ terminated

char *value;

Primary value; may be ”\\0’ terminated

size_t vsize;

Number of bytes (8 bits) for primary value

char **values;

Multiple values for multivalued attributes

size_t *vsizes;

The sizes for the values

int nvalues;

Number of values associated with attribute

int last_slot;

Last valid slot - array may contain holes

SearchAVPair_Create

NSAPI_PUBLIC SearchAVPair * SearchAVPair_Create
(char *a, char *v, int vsz);

Creates an AVPair structure with the given attribute a and value v. The value v is a buffer of vsz bytes.

SearchAVPair_Free

NSAPI_PUBLIC void SearchAVPair_Free(SearchAVPair *avp);

Frees the memory used by the given SearchAVPair structure

Search_Replace

NSAPI_PUBLIC int Search_Replace(Search *s, 
char *att, char *val, int valsz);

Replaces the value of an existing attribute att with a new value val of size valsz in the Searches.

Search_InsertStr

#define Search_InsertStr(search, attribute, value)

Inserts the given attribute with the given value into the search. 

Search_ReplaceStr

#define Search_ReplaceStr(search, attribute, value)

Replaces the existing value of the given attribute in the search with the given value. 

Search_Rename

NSAPI_PUBLIC int Search_Rename(Search *s, 
char *old_attr, char *new_attr);

Renames the given attribute to the given new name. 

Search_AttributeCompare

NSAPI_PUBLIC int Search_AttributeCompare
(const char *a1, const char *a2);

Compares two attribute names. Returns 0 (zero) if they are equal, or non-zero if they are different. Case (upper and lower) and trailing -s are ignored when comparing attribute names. The following table illustrates the results of comparing some attribute names.