Creating a preprocessor DLL


The Program Analyzer lets you call a preprocessor to perform pre-processing on your COBOL or PL/I program. If enabled, you can invoke and call the preprocessor immediately after each source record is read from the input program. The preprocessor can then change the record, delete the record, add records, or leave the record unchanged. All but the deleted records then go on to the parsing and analysis phase of the Program Analyzer. The source file on disk is not changed.

Compuware provides a sample preprocessor DLL written in C. Look for the file ANEXIT.C in the UserDataPath specified during the installation (which is available in the About dialog box). The preprocessor included with this product is provided for educational purposes only and serves only to illustrate how to construct a preprocessor. As a result, the functionality presented has been intentionally minimized to more clearly demonstrate the required interfaces. While you are encouraged to customize the preprocessor for your own purposes, Compuware will not support it, either in its original or modified forms.

Warning

Note

This functionality is not available for Assembler programs.

To create the DLL

To create a preprocessor DLL, create a DLL with the following exported function:

Win32 (Microsoft Visual C++):
__declspec(dllexport) short ANALYZEREXIT(short actionFlag, unsigned char *CobolRecord);

All addressing is in 32-bit mode.

To specify the action flag

The action Flag tells the preprocessor what to do. The possible values are:

  • 1 = Perform any necessary internal initialization. The address of CobolRecord for this case is zero.
  • 2 = Process this record. The address of CobolRecord points to the 80-byte COBOL record with the 81st byte null. The preprocessor can modify this storage before returning control to the Program Analyzer.
  • 3 = Perform any necessary termination processing. The address of CobolRecord for this case is zero.

To specify the return code

The preprocessor tells the Program Analyzer how to respond via the return code. The possible values are:

  • 0 = The requested action completed. This is valid for only initialization and termination calls (actionFlag 1 or 3).
  • 1 = Use this record and proceed to the next record in the input source file. The preprocessor may modify the COBOL record or leave it as is.
  • 2 = Use the record as returned; do not proceed to the next record, but instead call the preprocessor again, inserting the returned record into the source file. One or more records can be added in this way.
  • 3 = Do not use the record; proceed to the next record in the input source file. This is used to ignore records from the source file.
  • 4 = Use this record as returned, and do not invoke the preprocessor again except for the actionFlag=3 call. This was added for efficiency.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Compuware DevEnterprise Online Help