APPROVAL Procedure
Connection libraries can optionally include a procedure to determine whether any given process should be permitted to link to the library. This procedure is called the APPROVAL procedure. If there is an APPROVAL procedure, you must include an APPROVAL attribute assignment in the connection library declaration. The APPROVAL attribute specifies the name of the procedure to be used as the APPROVAL procedure. The APPROVAL procedure itself must be declared outside the connection library.
Dual APPROVAL Procedures
When a connection library attempts to link to another connection library, there can be two different APPROVAL procedures involved. Each connection library program can contain its own APPROVAL procedure, and each connection library declaration can contain its own APPROVAL attribute assignment. The APPROVAL procedure declared by the requesting library process is executed before the APPROVAL procedure declared by the responding library process.
Parameters to the APPROVAL Procedure
The system passes parameters to the APPROVAL procedure including the task variable of the process that declared the matching library and the LIBPARAMETER attribute specified by the matching process, if any. The APPROVAL procedure can read the task attributes and the LIBPARAMETER value. The APPROVAL procedure then returns a real value indicating whether linkage is permitted. The APPROVAL procedure for either library can also select which connection to use for that end of the linkage. If the APPROVAL procedure does not permit linkage, then the system does not link the two processes together.
For a description of the APPROVAL procedure, refer to the discussion of the APPROVAL library attribute under Using Library Attributes later in this section.
APPROVAL Procedure Example
The following ALGOL example declares and readies a connection library, CL1. The APPROVAL procedure in the example ensures that only processes with a given usercode are allowed to link to the connection library:
TYPE CONNECTION BLOCK TEST1;
BEGIN
PROCEDURE PROC1;
BEGIN
% Procedure body statements
END;
EXPORT PROC1;
END;
REAL PROCEDURE CL1_APPROV (OWNER, LIBPAR, LEN, WAIT);
VALUE LEN, WAIT;
TASK OWNER;
EBCDIC ARRAY LIBPAR[*];
INTEGER LEN;
BOOLEAN WAIT;
BEGIN
EBCDIC ARRAY UC[0:17];
REPLACE UC BY OWNER.USERCODE;
IF UC = “TRUSTME.” THEN
CL1_APPROV.[47:4]:= 2 % Allow linkage; MCP chooses connection.
ELSE
BEGIN
CL1_APPROV.[47:4]:= 3; % Forbid linkage
CL1_APPROV.[38:39]:= 510; % Notify that a bad usercode was used.
% Meaning of this value is established
% by convention between the applications.
END;
END;
TEST1 LIBRARY CL1 (INTERFACENAME=“CLTEST.”, CONNECTIONS = 10,
APPROVAL = CL1_APPROV);
RYRSLT:=READYCL (CL1);
