This software has been placed into the public domain by Digital
Equipment Corporation.
DISCLAIMER:
The information herein is subject to change without notice and should
not be construed as a commitment by Digital Equipment Corporation.
Digital Equipment Corporation assumes no responsibility for the use or
reliability of this software. This software is provided "as is,"
without any warranty of any kind, express or implied. Digital Equipment
Corporation will not be liable in any event for any damages including
any loss of data, profit, or savings, claims against the user by any
other party, or any other incidental or consequential damages arising
out of the use of, or inability to use, this software, even if Digital
Equipment Corporation is advised of the possibility of such damage.
DEFECT REPORTING AND SUGGESTIONS:
Please send reports of defects or suggestions for improvement directly
to the author:
Brian Hetrick
Digital Equipment Corporation
110 Spit Brook Road ZKO1-3/J10
Nashua NH 03062-2698
Do NOT file a Software Performance Report on this software, call the
Telephone Support Center regarding this software, contact your Digital
Field Office regarding this software, or use any other mechanism
provided for Digital's supported and warranted software.
FACILITY:
MS-DOS user utilities
ABSTRACT:
Manipulates attributes of files
ENVIRONMENT:
MS-DOS V2.0 or later compiled with Borland International's TURBO
Pascal V3.0 or later
AUTHOR: Brian Hetrick, CREATION DATE: 24 November 1986.
MODIFIED BY:
Brian Hetrick, 24-Nov-86: Version Y1.0-0
000 - Original creation of module.
Released to selected Easynet sites for beta test on 24 November
1986.
Brian Hetrick, 02-Dec-86: Version Y1.0-8
001 - Add Gn, Pn compiler directives for compilation on IBM PC clones.
002 - Modify IsPrefix routine to PrefixLength for command qualifiers
starting with same letter.
003 - Parse command qualifiers before and after parsing file spec, as
bad command qualifier with no file spec prompts for file spec
before detecting bad command qualifer.
004 - Add /CLEAR and /REMOVE synonyms for /RESET.
005 - Add help message if no command line given.
006 - Allow multiple wild card specs.
007 - Make path specifications absolute before reporting.
008 - List file names on left side of display.
Released to selected Easynet sites for beta test on 2 December
1986.
Brian Hetrick, 16-Dec-86: Version Y1.0-14
009 - Use CtlCTrap package to trap CTRL/C, as TURBO Pascal's CTRL/C
is not as desired. The undesired behavior (waiting for a Read
or ReadLn to abort the program) appears to occur only on MS-DOS
or PC-DOS V2.x. The PC-DOS specific TURBO Pascal had this un-
desired behavior all along, but MS-DOS generic TURBO Pascals be-
fore version 3.02A did not have this behavior on the Rainbow
(due to a bug in how the TURBO CTRL/C handler was set up), where
most testing occurred. The undesired behavior was noticed by a
beta test site using ATTRIB Y1.0-8, the first release compiled
with TURBO Pascal 3.02A, when it was impossible to CTRL/C out of
listings that were hit with the performance bug handled in edit
011.
010 - Construct print lines as a whole and omit trailing spaces. Add
the D- compiler directive and Flush (Output) to speed things up.
This also makes all program-generated text finally go to the MS-
-DOS standard output: even with Pn, TURBO will use IBM PC ROM
BIOS calls if the standard output is the console.
011 - Retain attribute from wild card lookup. This considerably
improves performance in highly fragmented directories.
012 - CTRL/C entered in response to the ReadLn in CLA.PAS does *NOT*
abort the program at least under PC-DOS V2.10. Apparently,
using the Gn,Pn,D- set of compiler directives entirely defeats
^C detection. So use the ^C package even for command line pars-
ing.
013 - Detect CTRL/Z entered in response to ReadLn in CLA.PAS.
014 - Reorder attributes in listing to put Arc and Dir, the most pop-
ular attributes, first.
Released to selected Easynet sites for beta test on 17 December
1986.
Brian Hetrick, 30-Jan-87: Version Y1.0-16
015 - Introduce /HELP switch to give long help message; if no command
line given, give short message and assume *.*. Remove prompting
for command parameters as there is now a 'reasonable' default.
016 - Make help text less dense, as it is now explicitly requested and
the user is presumably ready to deal with it.
Brian Hetrick, 30-Jan-87: Version 1.0
017 - Delete internal use only notice, copyright notice, etc., and set
version number to have no prefix or edit suffix, as will be re-
leased to DECUS Program Library.
Released to Easynet sites and DECUS Program Library 30 January
1987.
***********************************************************************)
{.PA}
(*
* INCLUDE FILES:
*)
StringToAdd.rt.v - The string to be appended to TargetString. {010}
TargetString.mt.r - The string to which StringToAdd is to be ap- {010}
pended. {010}
Sets the bit in an attribute mask designated by a keyword. The key-
word is any of ARCHIVE, HIDDEN, READ_ONLY, or SYSTEM, or any leading
abbreviation of one of these keywords.
FORMAL PARAMETERS:
Keyword.rt.v - The keyword designating an attribute.
AttributeMask.mg.r - The attribute mask in which the bit correspond-
ing to the keyword is to be set.
RETURN VALUE:
None.
IMPLICIT INPUTS:
None.
IMPLICIT OUTPUTS:
None.
SIDE EFFECTS:
If Keyword is not an abbreviation of one of the valid keywords, an
error mesage is written to the standard output and the program is
terminated.
Parses the value to the /SET or /RESET option. The syntax of these
values is:
keyword
(keyword[,keyword]...])
where 'keyword' is one of ARCHIVE, HIDDEN, READ_ONLY, or SYSTEM, or
a unique leading abbreviation of one of these.
FORMAL PARAMETERS:
ValueText.rt.v - The text of the value to be parsed.
AttributeMask.mg.r - The attribute mask in which the bits cor-
responding to the keywords are to be set.
RETURN VALUE:
None.
IMPLICIT INPUTS:
None.
IMPLICIT OUTPUTS:
None.
SIDE EFFECTS:
May write a message to the standard output and halt program execut-
ion under the following circumstances:
- ValueText consists only of '(';
- ValueText starts with '(' but does not end with ')';
- ValueText has ')' before the end of the string;
- ValueText has two adjacent commas.
The ATTRIB token is typed by the user but is not part of the command
line tail retained by MS-DOS, and so does not participate in this
parse.
Wildspec is a single path specification which may contain wild card
characters in the last component. Any single token not starting
with the option character is accepted in this position. This is not{003}
parsed by this routine. {003}
Option is one of:
/SET:value
/RESET:value or /CLEAR:value or /REMOVE:value {004}
/[NO]LOG
where 'value' is as accepted by the DoSetArgument routine above.
The keywords SET, CLEAR, REMOVE, and LOG may be abbreviated to any{004}
unique leading substring; the keywords RESET and REMOVE may be ab-{004}
breviated all the way to R, permitted in this case as they are syn-{004}
onyms. {004}
An equal sign (=) may be used in place of the colon.
FORMAL PARAMETERS:
None.
RETURN VALUE:
None.
IMPLICIT INPUTS:
The command line tail at CS:0080. [Actually, this is an implicit
input of the CLA package which this routine uses.]
ResetMask - The mask of attribute bits to be reset.
SetMask - The mask of attribute bits to be set.
IMPLICIT OUTPUTS:
OptionSpecifed - The flag determining whether any options were
specified on the command line.
ResetMask - The mask of attribute bits to be reset.
SetMask - The mask of attribute bits to be set.
SIDE EFFECTS:
May write a message to the standard output and terminate program
execution under the following circumstances:
- A null option (slash with no other characters) is present in the
command
- An unrecognized option (slash followed by something other than a
unique abbreviation of [NO]LOG, RESET, or SET) is present in the
command
- A value is specified with [NO]LOG
- No value is specified with RESET or SET
- The attributes specified with /SET and /RESET are not disjoint.
Delete (DummyArg, 1, 1);
IF Length (DummyArg) = 0
THEN
BEGIN
WriteLn ('Invalid null option');
Halt
END;
(*
* Extract the keyword
*)
SearchIndex := 1;
WHILE (SearchIndex <= Length (DummyArg)) AND
(DummyArg [SearchIndex] <> ':') AND
(DummyArg [SearchIndex] <> '=')
DO
SearchIndex := SearchIndex + 1;
Keyword := Copy (DummyArg, 1, SearchIndex - 1);
(*
* Delete all but the keyword value
*)
IF SearchIndex > Length (DummyArg)
THEN
SearchIndex := Length (DummyArg);
Delete (DummyArg, 1, SearchIndex);
(*
* Try to match the keyword to a possible keyword
*)
IF PrefixLength (Keyword, 'LOG') > 0 {002}
THEN
BEGIN
Logging := TRUE;
ValueType := 0
END
ELSE IF PrefixLength (Keyword, 'NOLOG') > 2 {002}
THEN
BEGIN
Logging := FALSE;
ValueType := 0
END
ELSE IF PrefixLength (Keyword, 'SET') > 0 {002}
THEN
BEGIN
TargetMask := Addr (SetMask);
ValueType := 1
END
ELSE IF (PrefixLength (Keyword, 'RESET') > 0) OR {004,002}
(PrefixLength (Keyword, 'CLEAR') > 0) OR {004}
(PrefixLength (Keyword, 'REMOVE') > 0) {004}
THEN
BEGIN
TargetMask := Addr (ResetMask);
ValueType := 1
END
ELSE IF PrefixLength (Keyword, 'HELP') > 0 {015}
THEN {015}
BEGIN {015}
HelpDesired := TRUE; {015}
ValueType := 0 {015}
END {015}
ELSE IF PrefixLength (Keyword, 'NOHELP') > 2 {015}
THEN {015}
BEGIN {015}
HelpDesired := FALSE; {015}
ValueType := 0 {015}
END {015}
ELSE
BEGIN
WriteLn ('Invalid switch: "', Keyword, '"');
Halt
END;
(*
* Parse the switch value
*)
IF ValueType = 0
THEN
BEGIN
IF Length (DummyArg) > 0
THEN
BEGIN
WriteLn ('/LOG switch does not take value');
Halt
END
END
ELSE
BEGIN
IF Length (DummyArg) = 0
THEN
BEGIN
WriteLn ('/SET and /RESET require value');
Halt
END;
DoSetArgument (DummyArg, TargetMask ^)
END;
(* {005}
* Note option parsed {005}
*) {005}
OptionSpecified := TRUE; {005}
(*
* Get next switch
*)
DummyArg := CommandLineArgument ('', '', TRUE)
END;
(*
* Check for non-interference of set and reset masks
*)
IF (SetMask AND ResetMask) <> 0
THEN
BEGIN
WriteLn ('Same attribute specified for both /SET and /RESET');
Halt
Logging - The flag showing whether attribute messages are to be
written to the standard output.
ResetMask - The mask of attribute bits to be reset in the files sel-
ected by WildSpec.
SetMask - The mask of attribute bits to be set in the files select-
ed by WildSpec.
IMPLICIT OUTPUTS:
None.
SIDE EFFECTS:
May write messages to the standard output.
May modify attributes of files.