MODULE sca$report_validate IDENT "T4.0-2" !************************************************************************* ! * ! © 2000 BY * ! COMPAQ COMPUTER CORPORATION * ! © 2000 BY * ! ELECTRONIC DATA SYSTEMS LIMITED * ! * ! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED * ! ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE * ! INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER * ! COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY * ! OTHER PERSON. NO TITLE TO OR OWNERSHIP OF THE SOFTWARE IS HEREBY * ! TRANSFERRED. * ! * ! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE * ! AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY COMPAQ COMPUTER * ! CORPORATION OR EDS. * ! * ! NEITHER COMPAQ NOR EDS ASSUME ANY RESPONSIBILITY FOR THE USE OR * ! RELIABILITY OF THIS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY * ! COMPAQ. * ! * !************************************************************************* !+ ! Facility: ! SCA - Source Code Analyzer ! REPORT - Report Subfacility ! ! Abstract: ! This module contains routines that process (validate) REPORT parameters ! and qualifiers. !- PROCEDURE sca$report_validate_domain_query !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure validates SCA$REPORT_DOMAIN_QUERY. ! ! FORMAL PARAMETERS: ! ! None ! ! IMPLICIT INPUTS: ! ! SCA$REPORT_DOMAIN_QUERY ! ! The query to use as the domain for the report. !-- LOCAL sca_status, temp_name; ON_ERROR ! Catch "no such query" error and report the bad /DOMAIN value to the ! user. ! [sca$_noqueryexists] : IF NOT sca$report_invoked_via_portable THEN sca$do_command (sca$report_command_context, 'SET COMM LANG VMS'); ENDIF; temp_name := sca$report_domain_query; sca$report_domain_query := ''; sca$report_hard_error ('Query ' + temp_name + ' (from /DOMAIN qualifier) does not exist' ); ! Do normal cleanup for any other errors. ! [OTHERWISE] : IF NOT sca$report_invoked_via_portable THEN sca$do_command (sca$report_command_context, 'SET COMM LANG VMS'); ENDIF; sca$report_domain_query := ''; sca$report_common_error_cleanup('SCA$REPORT_VALIDATE_DOMAIN_QUERY'); ENDON_ERROR; ! Associate the query name SCA$REPORT_DOMAIN with the domain query, if one ! was specified on the command line. ! IF GET_INFO (sca$report_domain_query, 'TYPE') = UNSPECIFIED THEN sca$report_domain_query := ''; ENDIF; IF sca$report_domain_query <> '' THEN IF NOT sca$report_invoked_via_portable THEN sca$do_command (sca$report_command_context, 'SET COMM LANG PORT'); ENDIF; sca_status := sca$do_command (lse$sca_command_context, 'FIND -name SCA$REPORT_DOMAIN ' + '@' + sca$report_domain_query ); IF NOT sca$report_invoked_via_portable THEN sca$do_command (sca$report_command_context, 'SET COMM LANG VMS'); ENDIF; ENDIF; ENDPROCEDURE PROCEDURE sca$report_validate_implicit_parameters ( legal_targets, default_target, target_index; rest_of_line_flag) !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure validates the implicit parameters to a report routine. ! ! FORMAL PARAMETERS: ! ! legal_targets ! ! An array of integers that correspond to the legal targets for the ! current report. IN parameter. ! ! default_target ! ! The default target to use if /TARGET was not specified. IN parameter. ! ! target_index ! ! The value from legal_targets that corresponds to SCA$REPORT_TARGET. ! ! rest_of_line_flag ! ! A flag indicating whether or not rest_of_line parameters are allowed. ! If TRUE, they are allowed. If FALSE or UNSPECIFIED, they are not ! allowed. OPTIONAL parameter. ! ! IMPLICIT INPUTS: ! ! SCA$REPORT_DOMAIN_QUERY ! ! The query to use as the domain for the report. Validate that it ! either refers to a real query or is empty. ! ! SCA$REPORT_OUTPUT ! ! A string value that specifies the output file for this report. ! Check that it is a legal file name. ! ! SCA$REPORT_REST_OF_LINE ! ! A string value that contains the remainder of the LSE Command Line that ! invoked this report, as returned by the $REST_OF_LINE feature of the ! CLI. Check that rest-of-line is supported for this report. ! ! SCA$REPORT_TARGET ! ! A string value that indicates the type of output file to generate. ! Validate this string against the list of targets in legal_targets. !-- ON_ERROR [OTHERWISE] : sca$report_common_error_cleanup('SCA$REPORT_VALIDATE_IMPLICIT_PARAMETERS'); ENDON_ERROR; sca$report_validate_domain_query; sca$report_validate_rest_of_line (rest_of_line_flag); sca$report_validate_target (legal_targets, default_target, target_index); ! The output file must be validated after the target, since the target ! determines the default file type of the output file. ! sca$report_validate_output (target_index); ENDPROCEDURE PROCEDURE sca$report_validate_output (target_index) !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure validates SCA$REPORT_OUTPUT, and creates the output file ! name for the report. It applies the default "report-name.report-type", and ! lets TPU fill in the default disk and directory. ! ! FORMAL PARAMETERS: ! ! target_index ! ! The index corresponding to the target for the report. This must be one ! of the constants: ! sca$report_k_target_text ! sca$report_k_target_runoff ! sca$report_k_target_document ! sca$report_k_target_lsedit ! sca$report_k_target_help ! sca$report_k_target_other ! ! IMPLICIT INPUTS: ! ! SCA$REPORT_OUTPUT ! ! The value of the /OUTPUT qualifier, as a string. ! ! IMPLICIT OUTPUTS: ! ! SCA$REPORT_OUTPUT_FILE_NAME ! ! The parsed version of the file name, with defaults applied. ! ! EXCEPTIONS: ! ! If the result of parsing the filename is the error TPU$_PARSEFAIL, report ! the error and abort. !-- LOCAL temp_directory; ON_ERROR [tpu$_parsefail] : sca$report_hard_error ( MESSAGE_TEXT(sca$_badrptoutput, 0, sca$report_output) ); [OTHERWISE]: sca$report_common_error_cleanup('SCA$REPORT_VALIDATE_OUTPUT'); ENDON_ERROR; IF GET_INFO (sca$report_output, 'TYPE') = UNSPECIFIED THEN sca$report_output := ''; ENDIF; ! Parse SCA$REPORT_OUTPUT value. ! sca$report_output_file_name := FILE_PARSE( sca$report_output, sca$report_name + "." + sca$report_target_types{target_index}); ! Get the node, device, and directory portion of the output file name, ! so that the temporary files can go to that same directory. ! temp_directory := FILE_PARSE (sca$report_output_file_name, '', '', NODE, DEVICE, DIRECTORY); ! Build the work file name (only different from the final output file ! for TEXT format) and initialize its file spec to null. ! IF target_index = sca$report_k_target_text THEN sca$report_work_file_name := FILE_PARSE('.TMP1', sca$report_output_file_name, ''); ELSE sca$report_work_file_name := sca$report_output_file_name; ENDIF; sca$report_work_file_spec := ''; ! Build the temporary file name (used for dumping intermediate results, ! since we can't directly append the contents of a buffer to an existing ! file), and initialize its file spec to null. ! sca$report_temp_file_name := FILE_PARSE('.TMP', sca$report_output_file_name, ''); sca$report_temp_file_spec := ''; ENDPROCEDURE PROCEDURE sca$report_validate_rest_of_line (rest_of_line_flag) !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure validates SCA$REPORT_REST_OF_LINE. ! ! FORMAL PARAMETERS: ! ! rest_of_line_flag ! ! A flag indicating whether or not rest_of_line parameters are allowed. If ! TRUE, they are allowed. If FALSE or UNSPECIFIED, they are not allowed. ! ! IMPLICIT INPUTS: ! ! SCA$REPORT_REST_OF_LINE !-- ON_ERROR [OTHERWISE] : sca$report_common_error_cleanup('SCA$REPORT_VALIDATE_REST_OF_LINE'); ENDON_ERROR; IF (sca$report_rest_of_line <> "") AND (rest_of_line_flag <> TRUE) THEN sca$report_hard_error ("Too many parameters: " + sca$report_rest_of_line); ENDIF; ENDPROCEDURE PROCEDURE sca$report_validate_target (legal_targets, default_target, target_index) !++ ! FUNCTIONAL DESCRIPTION: ! ! This procedure validates SCA$REPORT_TARGET. ! ! FORMAL PARAMETERS: ! ! legal_targets ! ! An array containing an integer index for each legal target. The array ! is indexed by target names. For example, if TEXT is a legal target ! name, then legal_target{"TEXT"} is sca$report_k_target_text. The same ! integer value may occur more than once within legal_targets. For ! example, TEXT and TXT both map into SCA$REPORT_K_TARGET_TEXT. ! IN parameter. ! ! default_target ! ! The default target. This value is used if SCA$REPORT_TARGET is ! UNSPECIFIED or an empty string. ! ! target_index ! ! The target index corresponding to the /TARGET value. Unchanged if ! there is no match in legal_targets. OUT parameter. ! ! IMPLICIT INPUTS: ! ! SCA$REPORT_TARGET ! ! The value of the /TARGET parameter. ! ! IMPLICIT OUTPUTS: ! ! SCA$REPORT_TARGET ! ! Updated to be the default value if the default is taken. !-- LOCAL edited_target_name; ON_ERROR [OTHERWISE] : sca$report_common_error_cleanup('SCA$REPORT_VALIDATE_TARGET'); ENDON_ERROR; ! If no target was specified, default it. ! IF sca$report_target = tpu$k_unspecified THEN sca$report_target := default_target ELSE ! Strip the quotes from the target name. ! edited_target_name := SUBSTR (sca$report_target, 2, LENGTH (sca$report_target) - 2); sca$report_target := edited_target_name; IF get_info(sca$report_target, 'TYPE') = STRING THEN IF sca$report_target = '' THEN sca$report_target := default_target; ENDIF; ENDIF; ENDIF; ! Check whether the specified (or defaulted) target is legal for the ! current report. If not, report a hard error (and don't generate a ! report). ! IF legal_targets{sca$report_target} = TPU$K_UNSPECIFIED THEN sca$report_hard_error ('Unknown target: ' + sca$report_target) ELSE target_index := legal_targets{sca$report_target}; ENDIF; ENDPROCEDURE ENDMODULE