Slide 38 of 80
Notes:
- this is the “process_listf” entry routine. It is invoked with input redirected to the output of a LISTFILE,6 command.
- the while loop reads each record in the input file, tests to ensure the file could be a legitimate script or program file, and symbolic links are resolved.
- the input() function reads each filename in the input file, after which, trailing and leading blanks are trimmed. The _wh_tok variable is set to this trimmed value. The finfo() function is called, passed this same trimmed name, to obtain the formatted file code, which is stored in the _wh_fc variable. If the file code is blank (“”) it is arbitrarily set to “script”. All of this is done is a single command line.
- if the EOF is positive and the file code is “script” then the script tests to see if the name might be the name of a symbolic link.
- if FINFO returns “symlink” for the file type then the target of the link is retrieved. This is done using a small MSG file and I/O redirection, as follows: 1) a LISTFILE,7 is written to the MSG file, 2) if the LISTFILE is successful the MSG file is read (all reads are destructive), 3) the first four records in the MSG file can be discarded, done by reading them and ignoring the input, 4) the last word/token in the fifth record contains the name of the target of the symlink, which is extracted, and has “-->” prepended to enhance the final output. The “-->” strings need a “!” to escape the meaning of “>”, which if not done, causes the following ECHO statement to perform output redirection.