APPROVAL

Property

Value

Kind

Connection library

Type

Procedure (see below)

Read

Never

Write

Only in connection library declaration

Default

See below

Explanation

The APPROVAL attribute specifies a procedure that can prevent linkage from occurring if the matching library is unauthorized. Additionally, the APPROVAL procedure can select the connection number to be used.

The person who implements the library program is responsible for writing this procedure (hereafter referred to as the APPROVAL procedure).

If there is an APPROVAL procedure for a connection library, the APPROVAL procedure must be declared outside the connection block for that library.

The APPROVAL attribute can be assigned to the connection library on either side of a connection. That is, an APPROVAL attribute can be specified in a connection library declaration regardless of whether that connection library is to be used in READYCL or LINKLIBRARY functions.

If both ends of a connection specify APPROVAL procedures, then the APPROVAL procedure declared by the process requesting the LINKLIBRARY is executed first, followed by the APPROVAL procedure declared by the process that performed the READYCL. Both APPROVAL procedures can optionally select a connection index; each connection index applies to the side of the connection that executes the APPROVAL procedure.

If an error or fault occurs in an APPROVAL procedure, the system prevents the linkage from completing. However, neither the linking process nor the library being linked to incurs an error.

Default

If no APPROVAL procedure is specified, then permission for the linkage is granted and the operating system selects the connection to use for the linkage.

MYSELF Task Variable

Currently, when the MYSELF task variable is used inside an APPROVAL procedure, MYSELF refers to the process that initiated the linkage. This process is not necessarily the declarer of either library involved in the linkage.

Note: The meaning of the MYSELF task variable in APPROVAL procedures is subject to change in future software releases. Therefore, you should avoid using MYSELF in APPROVAL procedures. The OWNER parameter to the APPROVAL procedure is also a task variable, as defined later under this heading. In most cases, you can use OWNER for the same purposes as MYSELF (that is, for checking the USERCODE and other attributes of the other library process).

Direct Library Linkages

If a process uses direct linkage to link two libraries, the system does not execute the APPROVAL procedure for either library unless it is necessary to resolve the connection index. That is, the system executes the APPROVAL procedure for either library only if that library supports multiple connections and no connection index was specified in the LINKLIBRARY statement. For information about direct linkage, refer to Directly Linking Connection Libraries earlier in this section.

Initiating Library Linkages from the APPROVAL Procedure

In general, the system does not permit APPROVAL procedures to execute statements that cause a new library linkage to occur; such statements result in a failed linkage attempt. However, the system does permit APPROVAL procedures to link to certain system libraries such as GENERALSUPPORT and MCPSUPPORT. When a statement in an APPROVAL procedure links to a system library, the system does not execute any CHANGE or APPROVAL procedure that the linking process has declared for the system library itself.

Parameters and Return Value

The system passes parameters to the APPROVAL procedure that identify the other process involved in the linkage and the LIBPARAMETER, if any, specified by the linking process. The APPROVAL procedure returns a real result that indicates whether the linkage is to be allowed and, optionally, indicates which connection to use on the responding side.

The APPROVAL procedure must have the following form:

 REAL PROCEDURE APPROVAL (OWNER, LIBPAR, LEN, WAIT);
    VALUE        LEN, WAIT;
    TASK         OWNER;
    EBCDIC ARRAY LIBPAR[*];
    INTEGER      LEN;
    BOOLEAN      WAIT;

The APPROVAL procedure should read, but not modify, the procedure parameters. The following are the meanings of these parameters:

Parameter

Meaning

OWNER

The task variable of the process that declared the connection library process being linked to. For an APPROVAL procedure declared by the connection library that is being linked to, the OWNER parameter is the task variable of the process that declared the connection library that initiated the linkage.

The APPROVAL procedure can read (but cannot modify) the task attributes of this task variable.

LIBPAR

The LIBPARAMETER library attribute value of the requesting connection library.

LEN

The length of the LIBPARAMETER value in bytes.

WAIT

The value of the WAITFORFILE parameter of the LINKLIBRARY function. The APPROVAL procedure can use this information in cases where a delay is necessary before a linkage can be approved. In such a case,

  • If WAIT = TRUE, then the APPROVAL procedure should wait as long as necessary before deciding to approve the linkage.

  • If WAIT = FALSE, then the APPROVAL procedure should exit immediately and return an indication that the permission to link was denied.

The result of the APPROVAL procedure is composed of the following fields:

Field

Value and Meaning

[47:04]

Permission to link. This field must be assigned a nonzero value. The following are the possible values and their meanings:

1

Permission granted. The number of the connection to use is stored in field [38:39].

2

Permission granted. If the LINKLIBRARY statement specifies a connection index for this library, the connection with that index is used. Otherwise, the operating system selects the connection to use for the linkage, and increases the value of the CONNECTIONS attribute if necessary.

3

Permission denied. An error number is stored in field [38:39].

[38:39]

If field [47:04] = 1, this field stores the number of the connection to be used. The number specified must be of a connection that is not currently in use. If the LINKLIBRARY statement specifies a connection index for this library, the number specified in [38:39] must match the connection index specified in the LINKLIBRARY statement. This value must not exceed the value of the CONNECTIONS attribute.

If field [47:04] = 2, this field has no meaning.

If field [47:04] = 3, this field stores an error number. If the error number is a value from 501 to 1000, then the LINKLIBRARY function returns the negative of the error number to the linking process. If the error number falls outside this range, then LINKLIBRARY returns a value of –500.