ACSE/Presentation and ROSE Interface Programmer's Guide

Chapter 4 49
Programming Guide
2. Manage the A/P Environment
2. Manage the A/P Environment
The ACSE/Presentation environment contains the necessary information
to establish and maintain an association. The primitives used to identify
this information are called attributes. See Appendix A, “AP_ENV Table
of Attributes” which describes the states and whether or not particular
attributes can be written to or read from.
Three A/P calls are used to manage information in the A/P environment:
ap_init_env() establishes the environment and sets up default values
for many of the attributes. Note that the env_file variable in
ap_init_env() is ignored. Refer to the manpage for ap_env() for the
attribute default values.
ap_set_env() is used to change a value of the specified attribute. To
change a list of attributes, you must use multiple ap_set_env() calls
(one for each attribute changed)
ap_get_env() is used to read a value of a specified attribute.
When you use ap_get_env() for attributes which are stored as data
structures, memory is allocated for you. When you have finished using
the information from the data structure, must use ap_free() to free the
memory.
For memory allocated by your application, do not use ap_free().
Implement your own routines to free application-created memory
allocations.
A partial list of A/P attributes used that require allocating and
deallocating memory are: AP_PCDL, AP_PCDRL, and AP_LCL_PADDR.
Determine Initiator and Responder Roles
When you create your programs, decide which process will be initiating
and which one will be accepting associations.
By default, both processes may initiate and respond to a request. The
roles are set using the AP_ROLE_ALLOWED environment attribute.
However, when one process issues a connection request, it is established
as the initiator and may no longer receive connection indications. The
AP_ROLE_CURRENT is set to AP_INITIATOR.