Slide 45 of 80
Notes:
- The “read_config” entry reads the config file (verified by “main” to exist) looking for a user.acct match. This entry defines the first parameter (arg1) to be the string “[jobname,]user.acct” from the JOB record returned by the read_jobcard entry. The second parameter (arg2) is defined to be the name of a CI string variable the will hold “” or the corresponding job queue name.
- These two arguments are easily extracted via word(…,1) and word(….,2). Note that one is the default parameter number for word().
- Input has been redirected to the configuration file.
- The WHILE loop stops if the entire config file has been read or on the first match. Based on this implementation, specific entries (specific [jobname,]user.acct) names should proceed generic, wildcarded names.
- The WHILE loop continues for empty (blank) records and comment (#) lines.
- A match is defined as: user.acct matches and if a jobname is present in the config file (and not simply “@”) the jobnames must match too. Wildcard support is easy with pmatch()!
- Line by line evaluation of this WHILE loop:
- decrement a counter that initially contains the number of records in the config file. When this counter is negative the file has been completely read.
- set the variable _str_rec to a record in the config file, after trimming all trailing and leading blanks, test if the result is empty and if so continue the while loop.
- if the _str_rec record starts with “#” then skip it since it is a comment record.
- if the second-to-last word in the record (this is the user.acct token -- second-to-last is used rather than first to handle an optional jobname which is terminated by a comma) doesn’t match the user.acct already extracted from the JOB card then continue the loop.
- if user.acct matches and the config record has a jobname (pos comma > 0) and the jobname is not “@” and the jobname doesn’t match the already extracted jobname from the JOB card then continue the loop.
- The loop ends when either all records have been read without a match, or there is a match. If the loop counter (_str_eof) is >= 0 then there was a match and the corresponding job queue name (last word in the config file record) is returned via arg2.