The SupMisc
interface gathers together various constants and
procedures that are somehow associated with CVSup and/or CVS.
INTERFACESupMisc ; IMPORT Glob, GlobTree, IP, OSError, Pathname, Rd, RegEx, SupFileRec, TextSeq, Thread, Wr; IMPORT TCP; TYPE ExitCode = { Success, TransientFailure, Failure }; ThreadStatus = REF RECORD (* Returned by threads when they exit. *) status: ExitCode; message: TEXT := NIL; END; TextPredicateClosure = OBJECT METHODS matches(t: TEXT): BOOLEAN; END; CONST Port: IP.Port = 5999; CVSAttic = "Attic"; CVSAdmin = "CVSROOT"; CVSOptions = CVSAdmin & SlashText & "options"; RCSSuffix = ",v"; DefaultClientBase = "/usr/local/etc/cvsup"; DefaultClientCollDir = "sup"; DefaultServerBase = "/usr/local/etc/cvsup"; DefaultServerCollDir = "sup"; DefaultCompression = 1; (* Default compression level. *) SlashChar = '/'; SlashText = "/"; RootDir = SlashText; DevNull = "/dev/null"; ShellPath = "/bin/sh"; ListenTimeout = 75.0d0; EXCEPTION BadAddress; InvalidEscape; PROCEDURE AtticName(name: Pathname.T): Pathname.T;
Returns where the given file would be if it were in the Attic.
PROCEDURE IsBlankLine(t: TEXT): BOOLEAN;
Checks for a line containing only white space.
PROCEDURE Cat3(a, b, c: TEXT): TEXT;
Returns the concatenation of the 3 arguments.
PROCEDURE CatN(READONLY a: ARRAY OF TEXT): TEXT;
Concatenates all the elements of a
and returns the result.
PROCEDURE CatPath(p1, p2: Pathname.T): Pathname.T;
Pastes together two parts to make a pathname.
PROCEDURE CheckoutName(name: Pathname.T): Pathname.T;
Returns the name of the checked-out file corresponding to an RCS file.
PROCEDURE CommonLength(a, b: TEXT): CARDINAL;
Returns the length of the maximal common leading portion of two texts.
PROCEDURE CommonPathLength(a, b: Pathname.T): CARDINAL;
Returns the length of the common prefix of two pathnames, on a pathname component boundary.
PROCEDURE DecodeWS(t: TEXT): TEXT RAISES {InvalidEscape};
Returns a text with all the escaped characters of the original decoded.
See EncodeWS
for the escape conventions.
PROCEDURE EncodeWS(t: TEXT): TEXT;
Returns a text with all the white space characters of the original escaped as follows:\_ = space \t = tab \n = newline \r = carriage return \\ = backslash
PROCEDURE ExpandFilenames(prefix: Pathname.T; names: TextSeq.T): TextSeq.T;
Returns a new list of filenames, with wildcards expanded, and non-existent and overlapping files removed.
PROCEDURE FindFile(base: Pathname.T; searchPath: TEXT; file: Pathname.T): Pathname.T;
Searches each of the directories in the colon-separatedsearchPath
forfile
. Non-absolutesearchPath
entries are interpreted relative tobase
. Returns the resolved pathname, orNIL
if the file was not found. Always follows symbolic links.
PROCEDURE FilterPathList(searchPath: TEXT; cl: TextPredicateClosure): TEXT;
Filters a search path with elements separated by colons and returns a similar path list with only those elements selected by the given text predicate closure.
PROCEDURE GetCmdLine(rd: Rd.T): TEXT RAISES {Rd.EndOfFile, Rd.Failure, Thread.Alerted};
LikeRd.GetLine
except that it raisesRd.EndOfFile
if end of file is reached before the terminating newline.
PROCEDURE IsDirectory(name: Pathname.T): BOOLEAN;
ReturnsTRUE
ifname
exists and is a directory.
PROCEDURE IsRCS(p: Pathname.T): BOOLEAN;
Tests whether the given pathname represents an RCS file.
PROCEDURE LiveName(name: Pathname.T): Pathname.T;
Returns where the given file would be if it were not in the Attic.
PROCEDURE MakeDirectories(path: Pathname.T; umask := -1) RAISES {OSError.E};
Creates any needed directories leading up to the given filename, using the given umask or the system's umask value if unspecified. It is not an error if the directories already exist.
PROCEDURE NewConnector(addr: IP.Address; loPort, hiPort: IP.Port): TCP.Connector RAISES {IP.Error};
Creates a new connector, using a port in the given inclusive range.
PROCEDURE ParseHost(t: TEXT; VAR (*OUT*) res: IP.Address): BOOLEAN RAISES {IP.Error};
Parses a host name or dotted-quad. Returns TRUE on success, or FALSE if a name was given but it is unknown. If a name lookup fails for some other reason, raises IP.Error with IP.LookupFailure in the error list.
PROCEDURE ParseIPAddress(t: TEXT; netOK := FALSE): IP.Address RAISES {BadAddress};
Parses a dotted-quad. IfnetOK
isTRUE
, missing trailing components are treated as if they were 0.
PROCEDURE PathCompare(a, b: Pathname.T): [-1..1];
Compares two pathnames lexicographically, by applying Text.Compare
successively to corresponding components.
PROCEDURE PathLast(p: Pathname.T): Pathname.T;
Returns the last component of the given pathname.
PROCEDURE PathPrefix(p: Pathname.T): Pathname.T;
Returns everything except the last component of the given pathname.
PROCEDURE PatternMatch(pattern: TEXT; options := Glob.MatchOptions{}): GlobTree.T RAISES {RegEx.Error};
Returns aGlobTree.T
representing either a shell pattern or a regular expression, according to the following rules. If the first character ofpattern
is+
then that character is removed and the remainder of the pattern is treated as a regular expression. Otherwise, the pattern is treated as a shell pattern with the givenoptions
. All regular expressions are implicitly anchored at the beginning and end, as if they began with^
and ended with$
. The regular expression.*
and the shell pattern*
are specially recognized and evaluate toGlobTree.True
. Thus the caller can compare the result against thatGlobTree.True
to determine whether the pattern is the universal match.
PROCEDURE PutCmd(wr: Wr.T; cmd: TEXT; f0, f1, f2, f3, f4, f5, f6, f7, f8, f9: TEXT := NIL; more := FALSE; encode := FALSE) RAISES {Thread.Alerted, Wr.Failure};
Outputs the given command and argument fields, separated by spaces. By default, the command is terminated by a newline, but that can be suppressed by settingmore
to TRUE. Such an unterminated command can be continued by another call whosecmd
argument isNIL
.If
encode
is TRUE, then white space within the fields is escaped usingEncodeWS
.
PROCEDURE RCSName(name: Pathname.T): Pathname.T;
Returns the name of the RCS file corresponding to a checked-out file.
PROCEDURE ResolvePath(p1, p2: Pathname.T): Pathname.T;
Resolves pathnamep2
relative top1
. Ifp2
is absolute, it is returned unchanged. Otherwise,CatPath(p1, p2)
is returned.
PROCEDURE StatusFileName(sfr: SupFileRec.T): Pathname.T;
Returns the name of the client's checkouts
file for the given
collection. This is just a simple file name; the leading path is
not included.
PROCEDURE StatusFileSuffix(sfr: SupFileRec.T): TEXT;
Returns just the suffix of the client'scheckouts
file for the given collection. The leading.
, if any, is included.
PROCEDURE TempName(p: Pathname.T): Pathname.T;
Returns a name for a temporary file in the same directory as the given file.
END SupMisc.