The CCA tool is a Perl script. Within the script are several major logical components. Each component represents a particular phase of analysis of the input C file. These major components are:
The next step is to read the input file and collect all of the conditional compilation logic. This task is performed by the process_file function. It quickly scans through the input file and builds a list containing all of the conditional logic in the file. For each line of conditional logic found, the line number is stored, and V(g) and V'(g) counters are incremented appropriately. The resulting list of conditional logic and related information is returned.
Before any further analysis is done, the verify_cclogic function is called to check the validity of the input file. It is passed the list of conditional logic built by the process_file function. It checks for syntax errors which may exist within the input file, and will gracefully exit with an explanation if one is found. Regardless of whether the user is concerned with finding errors in the input files, this is necessary because the graphical image generator will crash if there are errors in the conditional logic. There is nothing returned from this function.
If graphical output was requested on the command line, then after verify_cclogic finishes, assign_position is called. This function accepts the list of all the conditional code and the associated data. The purpose of this function is to determine in advance the X and Y positions of each symbol which will be displayed within the graph, along with the relative positions of logically adjacent symbols so that connecting lines can be drawn quickly. The list returned by assign_position contains all of the original data, along with additional positioning information for each line of conditional compilation code.
The enhanced list generated by assign_position is sent to the gen_image function, which writes PostScript code to the file specified by the user on the command line. The file generated by this function can then be printed by the user on a PostScript capable printer.
The gen_report function is called to generate the summary report. This function, according to the switches set by the user on the command line, outputs a text file summarizing the characteristics of the input file. Some of the characteristics, such as total lines of code and V(g) for the input file are passed in to gen_report. Other characteristics, such as summaries of the directives and expressions used, are computed within gen_report. This textual output is sent to an output file if one was specified on the command line or to STDOUT otherwise. There is nothing returned from this function.