Utility functions included in the user exits

Each exit includes a util.h header to perform the following functions. Ensure that each string passed to these functions ends with the end-of-text character \0, which corresponds to byte 0.
void *storageObtain(int size)
To allocate memory space under the 16MB line. It returns the address of the first byte of the returned storage. If an error occurs, it returns the value 0 and a WTO message is issued.
int storageRelease(void *storage, int size)
To free memory space. It returns the value 0. If an error occurs, it returns -1 and a WTO message is issued.
void trim(char *string[])
To remove the trailing blanks from the input string.
int outWTO(char *msgIn[])
To send a WTO message given in input. The maximum length of the message is 126 characters. It returns the length of the message that was sent.
void printStringSYSPRINT(char *msgIn[])
To edit the SYSPRINT data set and store a new text containing the input string. The string is split into multiple records.

This function supports only a SYSPRINT data set that is allocated with a record format (RECFM) equal to F, FB, V, VB, or U. If RECFM=U, the input message length cannot exceed the BLKSIZE value (whose maximum value is 32760).

void *openPSInput(char *ddnameIn[])
To open a sequential data set. The input parameter is the DD name of the data set. The function returns an address to the DCB. This function supports only a data set that is allocated with a record format (RECFM) equal to F or FB.

If an error occurs, it returns 0 and a WTO message is issued.

void *openPDSInput(char *ddnameIn[])
To open a partitioned data set. The input parameter is the DD name of the data set. The function returns an address to the DCB. This function supports only a data set that is allocated with a record format (RECFM) equal to F or FB.

If an error occurs, it returns 0 and a WTO message is issued.

char *readPS(void *DCB[])
To read a sequential data set. The input parameter is the address of a DCB. You can build the data control block (DCB) structure by using the openPSInput routine. It returns a buffer that contains the concatenation of all the records in the data set including the end-of-text character \0, which corresponds to byte 0. To release the returned buffer, ensure that you use the releaseBuffer routine before the control program ends.

This function supports only data set that is allocated with a record format (RECFM) equal to F or FB. If an error occurs, it returns 0 and a WTO message is issued.

char *readMemberPDS(void *DCB, char *memberIn[])
To read a member of a partitioned data set. The input parameters are the address of a data control block (DCB) and the name of the member. You can build the DCB structure by using the openPSInput routine. It returns a buffer that contains the concatenation of all the records in the member including the end-of-text character \0, which corresponds to byte 0. To release the returned buffer, ensure that you use the releaseBuffer routine before the control program ends.

This function supports only a data set that is allocated with a record format (RECFM) equal to F or FB. If an error occurs, it returns 0 and a WTO message is issued.

int closeDS(void *DCB)
To close a data set. The input parameter is the address of a data control block (DCB). The function returns 0 if no errors occur, otherwise it returns -1 and a WTO message is issued.
int releaseBuffer(char *buffer[])
To release a buffer. The input parameter is the address of the buffer that is returned by the readPS and readMemberPDS functions. The function returns 0 if no errors occur, otherwise it returns -1 and a WTO message is issued.
int submitJCL(char *ddINTRDR[], char *buffer[])
To submit a JCL to JES. The first input is the DD name of the Internal Reader, the second input is a buffer that contains the concatenation of all the records of the JCL. Each record must be 80 bytes including blanks, hence the ending buffer is n*80+1 long ,where n is the number of records, and the last byte is the end-of-string character.

It returns 0. If an error occurs while processing the JCL, it returns -1, the job is not submitted, and a WTO message is issued. After submitting the job, any error will be reported by a WTO message.

long long unsigned timeUsedCPU()
It returns the CPU time used by the task that called the exit (in microseconds). If an error occurs, it returns 0.