Remote Administration Daemon Developer Guide

Exit Print View

Updated: July 2014
 
 

Inspecting adr_name_t Type

adr_name_t types are immutable, so all operations on them are read-only. The two most common operations one needs to perform on an adr_name_t are obtaining the name's domain and obtaining the value associated with a particular key.

const char *adr_name_domain(const adr_name_t *name);
const char *adr_name_key(const adr_name_t *name, const char *key);

adr_name_domain returns name's reverse-dotted domain as a string. The string returned is part of name and therefore must not be modified or freed, and must not be accessed after the caller's reference on name has been released. Likewise, adr_name_key returns the value associated with key. The string returned by adr_name_key is subject to the same restrictions as the return value of adr_name_domain.

The two functions for comparing adr_name_t types are:

int adr_name_cmp(const adr_name_t *name1, const adr_name_t *name2);
 
boolean_t adr_name_match(const adr_pattern_t *pattern, const adr_name_t *name);
 

adr_name_cmp compares two adr_name_t types, returning 0 if the name1 and name2 are equal (that is, if the two names have the same domain, same names and the same keys, and each key has the same value on both names). It returns an integer less than 0 if name1 is less than name2, or and integer greater than 0 if name1 is greater than name2.

adr_name_match is a pattern-matching operation. The adr_name_t pattern is treated as a collection of attributes against which name is compared. adr_name_match returns B_TRUE if and only if the domains of name and pattern are equal, and every key present in pattern is present in name and has the same value. While an adr_name_t must have a domain and at least one key/value pair, pattern is permitted to have only a domain and no key/value pairs.