Contenues dansTrouver plus de documentationRessources d'assistance comprises | Télécharger cet ouvrage au format PDF (1048 Ko)
Chapter 6 Mapping Data Types and FunctionsSun™ Java System Access Manager contains public data types and functions you can use for creating, destroying, and manipulating map objects. Reference summaries include a short description, syntax, parameters and returns. The code is contained in the <am_map.h> header file (located in the /AccessManager-base/SUNWam/include directory). The sample source am_policy_test.c (located in the /AccessManager-base/SUNWam/samples/csdk directory) demonstrates the basic usage of some of the basic mapping functions. This chapter contains the following sections: The Mapping API for CA map is an object that associates a key to a value. One key/value pair is an entry in the map. Maps are used by the policy API for C to return policy decision results from the Policy Service. They are also used to pass any environment variables to the Policy Service for evaluation. Mapping Data TypesThe mapping types defined in <am_map.h> are: am_map_tPointer to a map object consisting of key/value entry mappings. Syntax#include "am_map.h" typedef struct am_map *am_map_t; Membersam_map is an opaque structure with no accessible members. Memory ConcernsFree the allocated structure by calling am_map_destroy(). See am_map_destroy(). am_map_entry_iter_tPointer to an iterator for the entries in a map object. Syntax#include "am_map.h" typedef struct am_map_entry_iter *am_map_entry_iter_t; Membersam_map_entry_iter is an opaque structure with no accessible members. am_map_value_iter_tPointer to an iterator for the values in a map object associated with a specified key. Syntax#include "am_map.h" typedef struct am_map_value_iter *am_map_value_iter_t; Membersam_map_value_iter is an opaque structure with no accessible members. Mapping FunctionsThe mapping functions defined in <am_map.h> are: am_map_clear()Erases all of the entries in the specified map object. Syntax#include "am_map.h" AM_EXPORT am_status_t am_map_clear(am_map_t map); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_map_copy()Makes a copy of the specified map object. Detailsam_map_copy() creates a new instance of a am_map_t, copies all the elements from the specified source_map into it, and assigns to the new instance a pointer. It does not alter the contents of the original map object. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_copy(am_map_t source_map,
am_map_t *map_ptr);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
Memory ConcernsThe caller must destroy map_ptr after usage by calling am_map_destroy(). am_map_create()Creates a new, empty map object. Detailsam_map_create() creates an instance of a am_map_t and returns a pointer back to the caller. Syntax#include "am_map.h" AM_EXPORT am_status_t am_map_create(am_map_t *map_ptr); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_map_destroy()Destroys the specified map object. Syntax#include "am_map.h" AM_EXPORT void am_map_destroy(am_map_t map); ParametersThis function takes the following parameter:
ReturnsThis function does not return a value. Memory ConcernsThe pointer to the specified map object can not be freed before calling am_map_destroy(). This includes erroneously calling the system free(void *) function. am_map_entry_iter_destroy()Destroys the specified entry iterator. Syntax#include "am_map.h" AM_EXPORT void am_map_entry_iter_destroy(am_map_entry_iter_t entry_iter); ParametersThis function takes the following parameter:
ReturnsThis function does not return a value. am_map_entry_iter_get_first_value()Returns the first value assigned to the entry currently being referenced by the specified entry iterator. Syntax#include "am_map.h" AM_EXPORT const char * am_map_entry_iter_get_first_value(am_map_entry_iter_t entry_iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following:
Memory Concernsam_map_entry_iter_get_first_value() destroys the am_map_entry_iter_t passed to it. Because of this, don't call this function more than once on the same am_map_entry_iter_t. am_map_entry_iter_get_key()Returns the key assigned to the entry currently being referenced by the specified entry iterator. Syntax#include "am_map.h" AM_EXPORT const char * am_map_entry_iter_get_key(am_map_entry_iter_t entry_iter); ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values:
am_map_entry_iter_get_values()Returns a value iterator that can be used to sequence through the values assigned to the entry currently being referenced by the specified entry iterator. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_entry_iter_get_values(am_map_entry_iter_t entry_iter,
am_map_value_iter_t *value_iter_ptr);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
Memory ConcernsAfter using am_map_value_iter_t, the caller must call am_map_value_iter_destroy(). am_map_entry_iter_is_entry_valid()Determines if the entry currently being referenced by the specified entry iterator is valid. Syntax#include "am_map.h" AM_EXPORT boolean_t am_map_entry_iter_is_entry_valid(am_map_entry_iter_t entry_iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
am_map_entry_iter_next()Advances the specified entry iterator to the next entry in the map specified when the iterator was first created. Syntax#include "am_map.h" AM_EXPORT boolean_t am_map_entry_iter_next(am_map_entry_iter_t entry_iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
am_map_erase()Erases the entry, associated with the specified key, from the specified map object. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_erase(am_map_t map,
const char *key);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_map_find()Returns a value iterator that can sequence through all values associated with the specified key in the specified map object. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_find(am_map_t map,
const char *key,
am_map_value_iter_t *value_iter_ptr);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
Memory ConcernsAfter using value_iter_ptr, the caller must call am_map_value_iter_destroy(). am_map_find_first_value()Returns the first value associated with the specified key in the specified map object. Detailsam_map_find_first_value() takes a key and returns the first value associated with that key. Syntax#include "am_map.h"
AM_EXPORT const char *
am_map_find_first_value(am_map_t map,
const char *key);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values:
am_map_for_each()Returns a map iterator on a function pointer for the specified map object. Detailsam_map_for_each() will iterate over the list of key/value pairs and call each one. For every key in the map, a function can be invoked via the function pointer. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_for_each(am_map_t,
am_status_t (*func)(const char *key,
const char *value,
void **args),
void **args);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values:
am_map_get_entries()Returns an entry iterator object that can be used to enumerate all entries in the specified map. Detailsam_map_get_entries() returns a pointer to an entry iterator that can be used on the key/value pairs stored in the specified map object. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_get_entries(am_map_t map,
am_map_entry_iter_t *entry_iter_ptr);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
Memory ConcernsThe pointer to the iterator must have only one iterator assigned. am_map_entry_iter_destroy() must be called when finished to destroy the iterator instance. am_map_insert()Inserts a new key/value pair into the specified map. DetailsThe map does not retain any references to the provided key or value parameters. It makes copies of any strings it needs to store. Syntax#include "am_map.h"
AM_EXPORT am_status_t
am_map_insert(am_map_t map,
const char *key,
const char *value,
int replace);
ParametersThis function takes the following parameters:
ReturnsThis function returns one of the following values of the am_status_t enumeration (defined in the <am_types.h> header file):
am_map_size()Returns the number of entries in the specified map object. Syntax#include "am_map.h" AM_EXPORT size_t am_map_size(const am_map_t map); ParametersThis function takes the following parameter:
ReturnsThis function returns a value based on size_t defined in the standard <stddef.h> header file. The value reflects the number of entries in the specified map object. am_map_value_iter_destroy()Destroys the specified value iterator. Detailsam_map_value_iter_destroy() destroys the am_map_value_iter_t passed to it. The caller must be sure that this function is not called multiple times on the same am_map_value_iter_t. Syntax#include "am_map.h" AM_EXPORT void am_map_value_iter_destroy(am_map_value_iter_t iter); ParametersThis function takes the following parameter:
ReturnsThis function does not return a value. am_map_value_iter_get()Returns the value currently referenced by the specified value iterator. Syntax#include "am_map.h" AM_EXPORT const char * am_map_value_iter_get(am_map_value_iter_t iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values:
am_map_value_iter_is_value_valid()Determines if the specified value iterator references a valid value. Syntax#include "am_map.h" AM_EXPORT boolean_t am_map_value_iter_is_value_valid(am_map_value_iter_t iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
am_map_value_iter_next()Advances the specified value iterator to the next value associated with the key that was specified when the iterator was created. Syntax#include "am_map.h" AM_EXPORT boolean_t am_map_value_iter_next(am_map_value_iter_t iter); ParametersThis function takes the following parameter:
ReturnsThis function returns one of the following values of the boolean_t enumeration (defined in the standard <types.h> header file): Note – The code used is dependent on the server operating system.
|