MAINSAIL Utilities User's Guide, Chapter 19

previous   next   top   contents   index   framed top   this page unframed


19. LIB and LIBEX, File Library Device MODULE and Librarian

Temporary feature: subject to change

19.1. Introduction

19.1.1. Likely Changes

Some changes to LIB are likely in the future. In the descriptions of LIB and LIBEX, text between square brackets, [ and ], denotes features considered especially likely to change (but note that other features may change as well).

19.1.2. Motivation

LIB is a file librarian. It provides a portable, tree-structured name space for accessing files and directories. Each file or directory can be stored within its library's base file, or stored in a separate host file, but is accessed through the library.

For the purposes of LIB, the term “object” is used to refer to either a file or a directory. Note that this is different from the customary use of the word “object” in object-oriented terminology.

LIB can be used to overcome the open file limit (maximum number of active “file handles” or “file descriptors”) imposed by many operating systems, e.g., UNIX. For this purpose, the library files are stored within a library's base file. When these library files are opened, only one host operating system file handle is used: the file handle for the library's base file.

LIB can be used to supplement the flat file name space provided by certain operating systems with a more flexible tree-structured name space. For this purpose, the files can be stored either in a library's base file or separately in individual host files.

LIB provides file version numbers even when the underlying operating system does not support file version numbers.

LIB is not a database; it does not provide any capability for multiuser access and does not provide journaling or rollback capabilities normally associated with a database. XIDAK's database product, Orion, is more suitable than LIB for applications that need these capabilities.

[The results of more than one process simultaneously accessing a single library are undefined. In a future release this restriction may be partially lifted to allow multiple read-only accesses to a library.]

LIB uses the MAINSAIL Structure Blaster. The Structure Blaster must be installed for LIB to function. Since LIB uses the Structure Blaster, the same compatibility restrictions apply to libraries with respect to MAINSAIL versions as apply to structure images stored in data files (see the MAINSAIL Structure Blaster User's Guide for details).

[While XIDAK will strive to make the format of libraries forward compatible, XIDAK reserves the right to change this format if XIDAK deems it necessary.]

19.2. General Concepts

19.2.1. Basic Definitions

19.2.2. The Base File

Each library is defined by a single host file, the base file for the library. This file always contains and stores the directory structure for the library and can optionally store files contained in the library.

Each base file contains a structure that implements a tree-structured name space for accessing objects, much like the tree-structured name space implemented by the UNIX file system for accessing files.

[The directory structure for a library is loaded from the library's base file into memory when the first library file contained in the library is opened, and kept in memory as long as any library file contained in the library is open. When all library files contained in the library are closed, the directory structure is rewritten in the base file if any changes have been made to the library.]

The base file for a library is kept open as long as any library file contained in the library is open and is closed when no library files contained in the library are open. Thus, the base file consumes only a single file handle.

If the library files are stored within the base file, then no additional file handles are required to access these files. One file handle is required to access each library file that is stored in a host file.

19.2.3. The Directory Structure

A directory consists of a set of objects. Each object has a name and is either a library file or another directory. Each object may have multiple versions, but all versions of the same object must be of the same type. The top-level directory is known as the “root directory” for the library.

Directories form a tree-structured name space. Objects are accessed by means of path names similar to those used in the UNIX operating system. A LIB path name consists of a sequence of directory names followed by an element name. The path name is interpreted by starting in the root directory and successively locating the directories named in the path.

19.2.4. Library File Name Syntax

Library files are accessed by means of a “fully qualified name”. The components of a fully qualified name for an example file name of (foo.lib)>/bar;3/baz;5/sample.msl;7 are:

Base File Name $devModBrk Path Name File (Leaf) Name Version
(foo.lib) > /bar;3/baz;5/ sample.msl ;7

The base file name must be enclosed in matching parentheses. It must be a MAINSAIL file name, i.e., a STRING that could be passed to the system PROCEDURE open.

The closing parenthesis following the base file name must be immediately followed by the $devModBrk character (usually >; see Section 22.11 of the MAINSAIL Language Manual) and a path name.

A path name always starts with a / and ends with a /. A path name is composed of a sequence of elements, each of which names a directory. Each directory name may optionally be followed by a ; followed by a version number. Directories are separated by /.

A fully qualified name may contain a (leaf) file name. The file name may optionally be followed by a version number separated by a ;.

Directory names and file names are case-insensitive, and are composed of any alphanumeric character followed by a sequence consisting of zero or more alphanumeric or punctuation characters (the allowed punctuation characters are “.”, “+”, and “-”).

The special name “..” names the parent directory of the currently connected directory and “/” names the root directory of the currently connected library (see Section 19.5.3).

Some commands also accept * to mean all objects in a specified directory, although * has not been uniformly implemented in this version of LIB.

19.2.5. Versions

Each object in a library, including directories, can have multiple versions, just as files can have multiple versions under the VAX/VMS operating system. A version number is a positive integer that specifies a distinct copy of the object (different versions do not share the same contents in any way).

A new version of a library file is created whenever the library file already exists and is opened for create, or is the destination for a ADD, COPY, or RENAME command, or whenever a file is opened with the LIB device MODULE and the create open bit is specified.

A new version of a directory is created whenever the directory already exists and is the destination of a MAKE, COPY, or RENAME command.

The number of old versions to keep may be specified on a per-directory basis by means of the CREATE, MAKE, or KEEP commands.

For objects open for input, if the version number is omitted, the highest existing version number is used.

19.2.6. Hard Delete Attribute

Associated with each directory is the “hard delete attribute”. If this attribute is set, deletions occur immediately, as under the UNIX operating system. If this attribute is clear, then deletions are deferred until the object is expunged.

19.2.7. Storage of Objects

Each library directory can have associated with it a host directory. If a host directory is associated with a library directory, then all library files contained in the library directory are actually stored in separate host files contained in the host directory. If a library directory has no host directory associated with it, then the library files contained in the library directory are stored within the library's base file.

If library files are stored within the base file they are protected from independent manipulation by host operating system commands (such as the host operating system's delete or rename commands), but this may lead to very large base files since the base file must be big enough to hold the library files and the image of the directory structure.

If the library files are stored as separate host files, they are not protected from independent manipulation by host operating system commands. This situation can lead to corruption of the library, but yields a small base file since the base file need be only large enough to hold the image of the directory structure.

[Currently, library files stored as separate host files are stored in the host directory using a host file name of the form zxxx.lfi, where xxx is a unique pattern generated by LIB. Host files with names of this form must not be independently manipulated or library corruption will result. The format of the host file name is subject to change.]

19.2.8. The lparms File

LIB maintains a parameters file, called lparms. This file stores definitions and other information from run to run.

If the host directory to which you are connected when running LIB contains no lparms file, then LIB looks for lparms on your home directory (as returned by the system PROCEDURE $homeDirectory). Then, if no lparms file exists on either of these directories, LIB creates one on the host directory to which you are connected when running LIB.

LIB maintains definitions made with the DEFINE command in lparms. These definitions are maintained in the form of DEFINE commands.

LIB updates the lparms file whenever the SAVE, EXPUNGE, or QUIT commands are executed, or whenever LIB is disposed, or MAINSAIL exited.

You may explicitly edit lparms to add LIB commands to be executed whenever LIB is initialized.

19.3. Device MODULE Interface

Since LIB is a device MODULE, the files stored in a library can be directly accessed by any MAINSAIL program through MAINSAIL's system PROCEDURE open. If a library file is opened for create and the library's base file does not exist and no host file exists with the same name as the name of the new library's base file, LIB automatically creates the base file.

[LIB does not currently support automatic creation of directories within a library; only the root directory is automatically created when the library's base file is created. All other directories must be explicitly created with the MAKE command. A future version of LIB may provide for automatic creation of directories.]

To open a library file from a program, use the fully qualified name of the library file prefixed by LIB, as shown in Example 19–1.

Example 19–1. How to Open a Library File from a Program
open(f,"lib(foo.lib)>/bar;3/baz;5/sample.msl;7",input);

To specify that an existing application, e.g., the MAINSAIL compiler, use a library file, use the standard device MODULE syntax as shown in Example 19–2.

Example 19–2. How to Specify a Library File to an Application
compile (? for help): lib(foo.lib)>/bar;3/baz;5/sample.msl;7<eol>

For example, Example 19–2 shows a library file used as input to the MAINSAIL compiler. There is no need to EXTRACT the source file from the library before compiling it. The output of the compiler could also be directed back into the library. This same syntax may be used to execute MODULEs contained in a library.

19.4. Program Interface

19.4.1. doCommandsInFile and doCommandsInString

Figure 19–3. doCommandsInFile and doCommandsInString
BOOLEAN
PROCEDURE   doCommandsInFile
                        (
POINTER(textFileuserCmdFile;
                         
OPTIONAL POINTER(textFile)
                             
userLogFile;
                         
OPTIONAL LONG BITS ctrlBits);

BOOLEAN
PROCEDURE   doCommandsInString
                        (
STRING userCmdString;
                         
PRODUCES OPTIONAL STRING
                             
userLogString;
                         
OPTIONAL LONG BITS ctrlBits);

[A MODULE that calls doCommandsInFile or doCommandsInString must include their declarations with the MAINSAIL directive shown in Figure 19–4. This directive may change or be eliminated in subsequent versions of LIB.]

Figure 19–4. Accessing LIB's Program Interface
SOURCEFILE "msl:libhdr";

Except for device MODULE functions, all LIB functions are invoked by executing the commands specified in Section 19.5. Commands can be executed by calling either doCommandsInFile or doCommandsInString.

Normally doCommandsInFile and doCommandsInString print LIB's herald each time they are called. If the suppressHerald bit is set in ctrlBits, the printing of LIB's herald is suppressed.

19.4.1.1. doCommandsInFile
doCommandsInFile reads the commands from userCmdFile and writes its output to userLogFile. If these parameters are omitted, cmdFile and logFile are used instead. doCommandsInFile processes commands until it hits end-of-file on userCmdFile or encounters an error condition when userCmdFile is not cmdFile. It returns TRUE if no errors were encountered, or FALSE if any error was encountered and userCmdFile is not cmdFile.
19.4.1.2. doCommandsInString
doCommandsInString reads the commands from userCmdString and writes its output to userLogString. If userCmdString contains more than one command, each command is separated from the one following it by an eol. doCommandsInString processes commands until it exhausts userCmdString or encounters an error condition. It returns TRUE if no errors were encountered, or FALSE if any error was encountered.

If useMemFiles is set in the ctrlBits parameter, the userCmdString is copied to a MEM file (see Chapter 22) and then doCommandsInFile is called with this MEM file as userCmdFile and another MEM file as userLogFile. This provides a way for doCommandsInString to provide input to MODULEs other than LIB that read input from cmdFile and write output to logFile. Upon return from doCommandsInFile, the contents of the userLogFile MEM file are converted to a STRING and produced as userLogString.

doCommandsInString normally fails if userLogString approaches 32K characters in length. If windowUserLogString is set in the ctrlBits parameter, the userLogString is “windowed”; a message is prepended, then a sliding window approximately 32K characters long is maintained that shows the most recent characters written to userLogString (older characters are discarded).

19.4.2. Exiting MAINSAIL and Disposing of LIB

When the system PROCEDURE exit is called or when LIB is disposed, LIB must make sure that the base files of all open modified libraries are updated.

When exiting, LIB waits until all FINAL PROCEDUREs have been called by MAINSAIL and then disconnects the source and destination directories, forces any open libraries closed, and updates the lparms file.

In addition to the processing it does during exit, LIB must force close all library files that are open whenever LIB is disposed. The actual information written to the disk for such files is undefined. This also means that application programs that use library files may attempt to do I/O on a file that was forced close by LIB. In general, disposing of LIB should be avoided.

19.4.3. Library Integrity

A library's base file is the ultimate repository for information contained in the library. During execution, however, LIB keeps the library's directory in memory. LIB writes file pages to the base file as necessary, but writes the directory to the base file only when the library is closed, when MAINSAIL is exited, LIB is disposed, or the SAVE, EXPUNGE, or QUIT command is executed.

This means that if a library is modified, but MAINSAIL is aborted before the directory is written to disk, the modifications are lost. The prior contents of the library should be preserved, however, because LIB is careful about how it updates the disk. It writes file pages and new directories only to disk pages that contained no active information in the prior directory, and only after writing the new directory updates the library's header page to point to the new directory disk image.

19.5. LIB Commands

All of LIB's functions, except for device MODULE functions, are implemented through “commands”. Commands can be executed by calling either doCommandsInFile or doCommandsInString (see Section 19.4.1).

Whenever a library file is specified in a command, it is specified by means of either a fully qualified name or a relative name that produces a fully qualified name when combined with the current directory connections. In general you should not include the LIB device MODULE prefix when specifying library files in commands.

In the following description of command syntax, the notation {s} means that s may either be omitted or specified exactly once. The notation {s}+ means that s must be specified one or more times.

19.5.1. Command Lines

doCommandsInFile and doCommandsInString both process lines of text containing commands, arguments to commands, and switch values. Command lines are broken up into words separated by blanks. The first word of a command line must be an unambiguous specification of a command. In general, only enough of a command need be specified to distinguish it from all other commands, but is recommended that in non-interactive situations the whole command be used so that the future addition of commands does not make the partial command ambiguous.

19.5.2. Switches

Certain commands, e.g., LS, accept “switches”, which are modifiers to govern the detailed operation of the command. Switch values are specified as single characters, or pairs of characters, within a word that must start with the character -. Case is ignored when interpreting switches. Switch words may appear as any word but the first on a command line and there may be multiple switch words on the same command line. [Switch syntax may change in future versions.]

19.5.2.1. Mode Switches

The switches shown in Table 19–5 may be applied to any command.

Table 19–5. Mode Switches
Switch Value Meaning
C Set confirmation mode for duration of command
NC Clear confirmation mode for duration of command
V Set verbose mode for duration of command
NV Clear verbose mode for duration of command

The C switch sets confirmation mode for the duration of the command regardless of the current confirmation mode setting. The setting of the current confirmation mode reverts to its previous value after the command terminates.

The NC switch clears confirmation mode for the duration of the command regardless of the current confirmation mode setting. The setting of the current confirmation mode reverts to its previous value after the command terminates.

The V switch sets verbose mode for the duration of the command regardless of the current verbose mode setting. The setting of the current verbose mode reverts to its previous value after the command terminates.

The NV switch clears verbose mode for the duration of the command regardless of the current verbose mode setting. The setting of the current verbose mode reverts to its previous value after the command terminates.

19.5.3. Connection Commands

LIB supports the notion of “connecting” to a directory. Connecting to a directory eliminates the need to supply the full path name to access objects contained in the directory. LIB supports the idea of separately connecting the source and destination of operations, so that, for example, you can copy files from one directory (the source) to a different directory (the destination) without having to type the full path name of either directory.

Whenever you connect to a directory in a particular library, that library's base file is opened. You cannot delete a library that contains a directory to which you are currently connected.

CONNECT, CD, SRCCONNECT, DSTCONNECT, and PWD Commands
CONNECT s Connect both source and destination to directory s.
CD s Same as CONNECT s.
SRCCONNECT s Connect source to directory s.
DSTCONNECT s Connect destination to directory s.
PWD Print current connections.

The CONNECT and CD commands perform the same function. They connect both the source and destination directories to the directory s. If the connection succeeds, then the named directory is known as the “connected directory” and the base file containing such directory is known as the “connected base file”.

If s is omitted, the current connections of both the source and destination directories are disconnected. If s is specified, then it can be either a fully qualified name, or a relative name, of a directory.

Any directory to which a connection is to be made must already exist, and be accessible, or the connection fails. Once connected, the associated library base file is left open until the connection is broken.

The SRCCONNECT command operates the same way as the CONNECT command, but affects only the source connection.

The DSTCONNECT command operates the same way as the CONNECT command, but affects only the destination connection.

The PWD command prints the current source and destination connections.

19.5.4. Definition Commands

Because fully qualified names can become quite long, LIB supports the notion of a “logical name”; a (typically) short string that can be used in place of another (typically) longer string.

DEFINE and UNDEFINE Commands
DEFINE s t Replace the prefix “s:” with “t:
UNDEFINE {s}+ Forget the definition of “s:

The DEFINE command defines a logical name. When two strings are specified, the first string is defined to be a logical name with the value of the second string. Whenever LIB is parsing a library file name and finds that the initial portion of such a name is a logical name, followed by the character “:”, the logical name and the “:” are stripped off and replaced by the logical name's definition.

If only one string is supplied, LIB prints the current definition (if any) of the logical name specified by the string. If no strings are supplied, LIB prints all logical name definitions.

For example, if the command DEFINE fl (foo.lib)>/ were given, then the name fl:baz would reference (foo.lib)>/baz. Such definitions are saved in the lparms file.

The UNDEFINE command undefines the logical name specified by the argument string(s).

19.5.5. Directory Information Commands

[The format and contents of the directory listing will likely change in future versions.]

DIRECTORY and LS Commands
DIRECTORY {s}+ Print directory information for s.
LS {s}+ Same as DIRECTORY {s}+.

The commands DIRECTORY and LS operate identically. They list directory information about the file or directory s.

19.5.5.1. Directory Information Command Switches
In addition to the switches specified in Table 19–5, the DIRECTORY and LS commands accept the switches shown in Table 19–6.

Table 19–6. DIRECTORY and LS Switches
Switch Value Meaning
D Select only deleted objects.
S Produce short listing.
L Produce long listing.

Normally DIRECTORY and LS produce a listing that contains only non-deleted objects. The D switch instead produces a listing that contains only deleted objects that have not yet been expunged.

Normally DIRECTORY and LS produce a listing, that contains a single line of information per object. For example:

ROOT;1           5:44:10 19-Oct-1986 greg    DSL      3
  
bar;1          5:00:59 19-Oct-1986 greg    DSL      1
  
sample.msl;1   4:32:30 19-Oct-1986 greg    FTL   3072

The S switch produces a short listing that gives only the name and version of each object. The L switch produces a long listing that contains almost all of the information LIB has about each object.

[All of the formats and information content of LS commands are subject to change.]

The normal listing produced by DIRECTORY and LS contains for each object:

Table 19–7. Directory Object Attributes
Position Meaning
123
D   Indicates that this is a directory object.
 H  Indicates that the hard delete attribute is set in this directory.
 S  Indicates that the hard delete attribute is cleared in this directory.
  L Indicates that files created in this directory will be stored within the library's base file.
  H Indicates that files created in this directory will be stored as separate host files.
The directory's size is indicated in terms of the number of files contained in the directory.

Table 19–8. File Object Attributes
Position Meaning
123
F   Indicates that this is a file object.
 D  Indicates that this is a data file.
 T  Indicates that this is a text file.
  L Indicates that this file is stored within the library's base file.
  H Indicates that this file is stored in a separate host file.
File sizes are listed in terms of storage units for data files, and characters for text files.

The short listing produced by DIRECTORY and LS, shown in Example 19–9, lists the name and version of each selected object.

Example 19–9. Short Listing Produced by DIRECTORY and LS
ROOT;1
  
bar;1
  
sample.msl;1

The long listing shown in Example 19–10 produced by DIRECTORY or LS includes the line produced by a normal DIRECTORY or LS plus a line showing the time, date, and user when the object was created, plus either a host directory name, for a directory object, or a host file name, for a file object. For directories, INF is printed if the directory will keep infinite versions of objects, or a number indicating how many versions of objects are kept.

For directories, the host directory name tells where host files are created whenever a library file is created in the library directory. If omitted, library files created within the directory are stored as part of the library's base file.

For files, the host file name specifies where the library file is stored. If omitted, the library file is stored as part of the library's base file.

Example 19–10. Long Listing Produced by DIRECTORY and LS
ROOT;1           5:44:10 19-Oct-1986 greg    DSL      3
             
INF 8:43:25 18-Oct-1986 greg
  
bar;1          5:00:59 19-Oct-1986 greg    DSL      1
               1 4:32:15 19-
Oct-1986 greg
  
sample.msl;1   4:32:30 19-Oct-1986 greg    FTL   3072
                 4:32:29 19-
Oct-1986 greg

19.5.6. Library Creation Command

CREATE Command
CREATE s {t} Create a library with file name s.

The CREATE command creates a new library with host file name s. By default the root directory of the newly created library has the hard delete attribute cleared and will keep infinite versions.

If t is not specified, files created in the root directory of s are stored within the library's base file. If t is specified, then it must be the full path name of a host directory in which LIB is to store files created in the root directory of s.

CREATE fails if the library is already open, e.g., if you are connected to a directory contained within it.

On operating systems that do not support version numbers, you are queried for confirmation to overwrite s if s currently exists and confirmation mode is set (see Section 19.5.15.1). If the host file contains a valid object library, all objects contained in the library are expunged before the base file is overwritten.

Table 19–11. CREATE Switches
Switch Value Meaning
H Set hard delete attribute in root directory
S Clear hard delete attribute in root directory
n Keep n versions in the root directory
I Keep infinite versions in new directory

In addition to the mode switches specified in Table 19–5, the CREATE command accepts the switches shown in Table 19–11.

The H switch specifies that the root directory of the newly created library should have the hard delete attribute set.

The S switch specifies that the root directory of the newly created library should have the soft delete attribute set. Since soft delete is the default, this switch is unnecessary, but is included for completeness and so that CREATE is parallel to MAKE.

A numeric switch value is treated as the number of of versions to keep in the newly created directory, while the I switch value specifies that an infinite number of versions should be kept in the newly created directory. If neither a numeric switch nor an I switch is specified, the newly created directory inherits the number of versions to keep from its parent.

Different versions of directories are completely separate objects; the sets of files in them are disjoint.

19.5.7. Directory Creation Commands

MAKE and MKDIR Commands
MAKE s {t} Make a new directory s on host directory t.
MKDIR s {t} Same as MAKE s {t}.

The MAKE and MKDIR commands operate identically. They create a new directory by the name of s. s may be either the full path name of a directory or a directory name relative to the current destination connection.

If t is specified, then it must be the full path name of a host directory in which LIB is to store files created in s. If t is not specified, then the directory s inherits from its parent where to store files created in s.

Table 19–12. MAKE Switches
Switch Value Meaning
H Set hard delete attribute in new directory
S Clear hard delete attribute in new directory
n Keep n versions in new directory
I Keep infinite versions in new directory

In addition to the mode switches specified in Table 19–5, the MAKE command accepts the switches shown in Table 19–12.

The H switch specifies that the newly created directory should have the hard delete attribute set instead of inheriting this attribute from its parent directory.

The S switch specifies that the newly created directory should have the hard delete attribute cleared instead of inheriting this attribute from its parent directory.

A numeric switch value is treated as the number of of versions to keep in the newly created directory, while the I switch value specifies that an infinite number of versions should be kept in the newly created directory. If neither a numeric switch or an I switch is specified, then the newly created directory inherits the number of versions to keep from its parent.

19.5.8. Host File Manipulation Commands

ADDTEXT, ADDDATA, and EXTRACT Commands
ADDTEXT s t Add host text file s as t.
ADDDATA s t Add host data file s as t.
EXTRACT s t From s, extract host file t.

The ADDTEXT command adds the host text file s to a library under the name t by copying the host file to the library file.

The ADDDATA command adds the host data file s to a library under the name t by copying the host file to the library file.

The EXTRACT command extracts the library file s into the host file t. On operating systems that do not support version numbers, you are queried for confirmation to overwrite t if t currently exists and the confirmation option is set (see Section 19.5.15.1).

19.5.9. Object Copying Commands

COPY and CP Commands
COPY s t Copy s to t.
CP s t Same as COPY s t.

The COPY and CP commands operate identically. They create a copy of object s with the name t. If s is a directory all objects in s are recursively copied. If an object named t of the same type already exists, a new version is created.

Objects can be copied across directories and libraries. Objects cannot be copied to a host file.

The modify date, time, and user of the copied object are identical to that of the original object, but that the create date, time, and user are those in effect when the copy operation is performed (this means the modify date and time may precede the create date and time).

19.5.10. Object Renaming Commands

RENAME and MV Commands
RENAME s t Rename s to t.
MV s t Same as RENAME s t.

The RENAME and MV commands operate identically. They change the name of object s to be object t. If an object name t of the same type already exists, a new version is created.

Objects can be renamed across directories and libraries. An object cannot be renamed to a host file. When an object is renamed across libraries it is equivalent to a copy followed by a delete. When an object is renamed within the same library, only the directory data structure is modified.

The modify date, time, and user of the renamed object are identical to that of the original object, but that the create date, time, and user are those in effect when the rename operation is performed.

19.5.11. Object Removal Commands

These commands remove objects from a library.

DELETE, RM, DROP, UNDELETE, and EXPUNGE Commands
DELETE {s}+ Mark s for deletion.
RM {s}+ Same as DELETE {s}+.
DROP {s}+ Mark old versions of s for deletion.
UNDELETE {s}+ Unmark s for deletion.
EXPUNGE {s}+ Expunge s.

The DELETE and RM commands operate identically. They mark the object s for deletion, and if the directory containing s has the hard delete attribute set, expunge it as well.

The DROP command deletes all versions of the object s except the highest-numbered version. [Future enhancements to LIB may make it necessary to retain certain older versions.] DROP does not expunge the deleted objects unless they are contained in a directory with the hard delete attribute.

If a DROP or DELETE is attempted on a non-empty directory, and the confirmation option is set, then you are queried for confirmation before dropping or deleting the directory.

The UNDELETE command unmarks the object s for deletion. This has an effect only if the directory containing s has the hard delete attribute cleared and if the object has not been expunged.

The EXPUNGE command expunges the object s from the library. Expunging an object removes it completely from the library so that it can never be recovered. When a library file stored as a host file is expunged, the host file storing the library file is deleted. Objects are automatically expunged by the DELETE, RM, and DROP commands for directories which have the hard delete attribute set.

The DROP, UNDELETE, and EXPUNGE commands accept * as an element name indicating “all”. For example, the command DROP foo/* drops old versions of all objects contained in the directory foo, whereas the command DROP foo drops old versions of the object foo. [In a future release more general wildcards may be supported by these commands.]

19.5.12. Deletion Control Commands

These commands manipulate the directory attributes to control soft and hard delete.

HARDDELETE and SOFTDELETE Commands
HARDDELETE s Perform hard deletes within directory s.
SOFTDELETE s Perform soft deletes within directory s.

The HARDDELETE command sets the hard delete attribute for the directory s and expunges s. Subsequent deletions from s immediately cause an expunge on the deleted object.

The SOFTDELETE command clears the hard delete attribute for the directory s. Subsequent deletions from s mark the object for deletion, but not expunge it. An explicit EXPUNGE command must be given before the object is actually expunged from the library. Objects marked for delete may be recovered with an UNDELETE command, if it is given before the object is expunged.

19.5.13. Version Control Command

KEEP Command
KEEP n {s}+ Keep n versions in directory s.

The KEEP command modifies how many versions are to be kept in directory s. n must be either a number, in which case n versions are kept, or an initial substring of INFINITE, in which case an infinite number of versions are kept. If a number is specified, KEEP drops any versions in excess of this number.

19.5.14. SAVE Command

SAVE Command
SAVE {s}+ Save library s.

The SAVE command updates library base files with the current state of their memory-resident directories and updates the lparms file. If s is specified, it must be the name of a library to be saved. If s is not specified, then all open modified libraries are saved.

19.5.15. Mode Commands

These commands affect the global operation of LIB; they control its “modes”.

19.5.15.1. Confirmation Commands
LIB implements the notion of a “confirmation mode”. When in confirmation mode, LIB queries you for confirmation before performing operations that you might not intend. For example, on operating systems that do not support version numbers for host files, when confirmation mode is set, you are asked for confirmation before extracting a library into a host file that already exists. When confirmation mode is cleared, such an EXTRACT overwrites the existing host file without querying you for confirmation.

CONFIRM and NOCONFIRM Commands
CONFIRM Set confirmation mode.
NOCONFIRM Clear confirmation mode.

The CONFIRM command sets confirmation mode. This is the default.

The NOCONFIRM command clears confirmation mode.

19.5.15.2. Verbosity Commands
LIB implements the notion of “verbose mode”, which is the default. When verbose mode is set, LIB prints verbose information about what it is doing. This is useful for novice users and when performing potentially dangerous operations. When this mode is cleared, LIB suppresses much of the information it prints when in verbose mode. This is often useful for expert users. [Currently LIB produces the same output regardless of whether verbose mode is set or cleared.]

VERBOSE and NOVERBOSE Commands
VERBOSE Set verbose mode.
NOVERBOSE Clear verbose mode.

The VERBOSE command sets verbose mode.

The NOVERBOSE command clears verbose mode.

19.5.16. Termination Commands

QUIT and EXIT Commands
QUIT Quit Object Librarian.
EXIT Exit to the operating system.

The QUIT command quits LIBEX, returning to whichever MODULE originally invoked LIBEX, e.g., MAINEX.

The EXIT command quits LIBEX and exits to the operating system through the MAINSAIL system PROCEDURE exit.

19.5.17. Input Redirection Commands

The READ command tells LIBEX to read its commands from the file s.

READ Command
READ s Execute LIB commands contained in file s.

19.5.18. MODULE Execution Command

The EXECUTE command executes an arbitrary MAINSAIL MODULE using the system PROCEDURE $invokeModule. Accordingly, s can be either the name of a MODULE or the name of a file containing the MODULE, and “,” can be appended to the name to enter MAINEX subcommand mode before executing the MODULE.

EXECUTE Command
EXECUTE s Execute MAINSAIL MODULE s.

If MAINEX subcommand mode is entered, or if the executed MODULE uses cmdFile and logFile, output is directed to logFile and input obtained from cmdFile, even if the EXECUTE command is issued from doCmdsInString. If doCmdsInString needs to supply information to be read by cmdFile, or record information written to logFile, then the useMemFiles bit must be set in the call to doCmdsInString.

19.5.19. Maintenance and Diagnostic Commands

These commands are primarily used by maintenance personnel and may change or cease to be supported in future versions without notice.

HEADER, PAGEMAP, PAGESUMMARY, and STATUS Commands
STATUS Print LIB's status.
PAGEMAP s Print a page map of library s.
PAGESUMMARY s Print a page summary of library s.
HEADER {s}+ Print library header page from host file s.

The STATUS command prints a summary of LIB's status. Currently this information includes a listing of all open libraries and the number of references to each. STATUS also prints the current connections and current mode settings.

The PAGEMAP command prints out a page map of the library s. The page map shows free pages, the pages occupied by the directory data structure, and the pages used for objects stored within the library's base file.

The PAGESUMMARY command prints a short summary of page usage in the base file of the library s, including the total number of pages, total number of free pages, number of trailing free pages, and number of pages occupied by the directory structure. The library s must not be open at the time the PAGESUMMARY command is given.

The HEADER command prints the library header page from the host file s. This information contains the consistency checking information LIB uses to make sure it has a base file as well as the major and minor MAINSAIL and LIB version numbers.

19.6. LIBEX

LIBEX is a MODULE used to invoke doCommandsInFile(cmdFile,logFile) from MAINEX. LIBEX is required because MAINEX unbinds the MODULEs it executes after they finish executing. LIB should not be unbound after returning from doCommandsInFile because files might still be open that are using it as a device MODULE. Thus, always invoke LIBEX from MAINEX; never directly invoke LIB from MAINEX.

19.6.1. Sample LIBEX Execution

Table 19–13 shows a sample execution of LIBEX, followed by access to files within a library from the compiler.

Table 19–13. LIBEX Execution
*libex<eol>
LIBVersion 1.2 Alpha Release (? for Help)
You invoke LIBEX from MAINEX.
LIBcr -nc foo.lib<eol>
Created library foo.lib
You create a library with a base file named foo.lib. Since a no-confirm switch was specified, if a host file named foo.lib that is not a valid library base file already exists, it is overwritten. If a valid library base file named foo.lib already exists, all objects it contains are expunged and the library deleted.
LIBdef fl (foo.lib)>/<eol>
Defined fl as (foo.lib)>/
You define a logical name to reference the root directory of foo.lib.
LIBcd fl:<eol>
Src connected to  (foo.lib)>/
Dst connected to  (foo.lib)>/
You connect to the root directory of foo.lib using the logical name “fl:”.
LIBls<eol>
ROOT;1            13:35:15 11-Mar-1987 greg     DSL      0
You get a directory listing of the root directory of foo.lib.
LIBaddt sample.msl sample.msl<eol>
Added text file sample.msl as (foo.lib)>/sample.msl;1
You add a host text file, sample.msl, to the root directory of foo.lib with the name sample.msl.
LIBsave<eol>
Saved foo.lib
You save all open modified libraries, at this point only foo.lib.
LIBcp sample.msl sample.msl<eol>
(
foo.lib)>/sample.msl;1 copied to (foo.lib)>/sample.msl;2
You copy the library file sample.msl to itself. Since the root directory is keeping infinite versions, a new copy of sample.msl is created and the prior version retained.
LIBmake bar<eol>
Made directory (foo.lib)>/bar;1/
You make a new directory, named bar, in the root directory of foo.lib. Since no switches were specified to the MAKE command, the new directory, bar, inherits all attributes of the root directory of foo.lib.
LIBcd bar<eol>
Src connected to  (foo.lib)>/bar;1/
Dst connected to  (foo.lib)>/bar;1/
You connect to the new directory bar.
LIBls<eol>
bar;1             13:35:17 11-Mar-1987 greg     DSL      0
You get a normal directory listing of the directory bar.
LIBls ..<eol>
ROOT;1            13:35:17 11-Mar-1987 greg     DSL      3
  
bar;1           13:35:17 11-Mar-1987 greg     DSL      0
  
sample.msl;2    13:35:16 11-Mar-1987 greg     FTL   2712
  
sample.msl;1    13:35:16 11-Mar-1987 greg     FTL   2712
You get a normal directory of the parent directory of bar (which is the root directory of foo.lib).
LIBcp ../sample.msl sample.msl<eol>
(
foo.lib)>/sample.msl;2 copied to
  (
foo.lib)>/bar;1/sample.msl;1
You copy the file sample.msl from the parent directory of bar to the directory bar under the name sample.msl.
LIBcd ..<eol>
Src connected to  (foo.lib)>/
Dst connected to  (foo.lib)>/
You connect to the parent of bar.
LIBdrop<eol>
Marked (foo.lib)>/sample.msl;1 for delete
You drop old versions of objects contained in the connected directory (which is the root directory of foo.lib). This marks the older version of sample.msl for deletion.
LIBls -ds<eol>
  
sample.msl;1
You get a long directory listing of files marked for deletion in the connected directory. This shows the older version of sample.msl deleted in the previous step.
LIBexp<eol> You expunge all files marked for deletion in the connected directory. This expunges the older version of sample.msl marked for deletion earlier.
LIBls -l<eol>
ROOT;1            13:35:18 11-Mar-1987 greg     DSL      3
              
INF 13:35:15 11-Mar-1987 greg
  
bar;1           13:35:18 11-Mar-1987 greg     DSL      1
              
INF 13:35:17 11-Mar-1987 greg
  
sample.msl;2    13:35:16 11-Mar-1987 greg     FTL   2712
                  13:35:17 11-
Mar-1987 greg
You get a long directory listing of the connected directory. This shows only one version of the text file sample.msl and the directory, bar.
LIBcp bar bar<eol>
(
foo.lib)>/bar;1/ copied to (foo.lib)>/bar;2/
You copy the directory bar to a new version of itself. This copy is recursive, so the new version of bar contains a copy of the text file sample.msl contained in the previous version of bar.
LIBls bar<eol>
bar;2             13:35:19 11-Mar-1987 greg     DSL      1
  
sample.msl;1    13:35:16 11-Mar-1987 greg     FTL   2712
You get a normal directory listing of bar.
LIBmake -1h baz tmp<eol>
Made directory (foo.lib)>/baz;1/
You make a new directory, named baz, in the currently connected directory. You have specified switches to set the hard delete attribute in baz, and keep only one version of objects contained in baz. You have also specified that files contained in baz be stored as separate host files in the host directory with relative host name tmp.
LIBcp sample.msl baz/sample.msl<eol>
(
foo.lib)>/sample.msl;2 copied to
  (
foo.lib)>/baz;1/sample.msl;1
You copy the text file sample.msl to the new directory baz. LIB has actually copied the contents of sample.msl to a unique file on the host directory tmp.
LIBcp sample.msl baz/sample.msl<eol>
Expunged (foo.lib)>/baz;1/sample.msl;1
(
foo.lib)>/sample.msl;2 copied to
  (
foo.lib)>/baz;1/sample.msl;2
You again copy sample.msl to baz. Since baz has the hard delete attribute set and is keeping only one version, the prior version of sample.msl is automatically deleted and expunged. As a result, a new unique file on the host directory tmp has been created, a copy from the prior host directory made, and then the prior copy deleted from tmp.
LIBls -l baz<eol>
baz;1             13:35:20 11-Mar-1987 greg     DHH      1
                1 13:35:19 11-
Mar-1987 greg     /tmp
  
sample.msl;2    13:35:20 11-Mar-1987 greg     FTH   2712
                  13:35:20 11-
Mar-1987 greg     /tmp/z8327.lfi
You get a long directory listing of baz, which shows that files contained in baz are stored in the host directory with the full path name of /tmp, and that the text file sample.msl contained in baz is stored in the host file /tmp/z8327.lfi.
LIBpwd<eol>
Src connected to  (foo.lib)>/
Dst connected to  (foo.lib)>/
You ask that the current connections be listed.
LIBexecute compil<eol>

MAINSAIL (RCompiler
Copyright (c) 1984 - 2002 by XIDAKInc., Point Arena,
 
CaliforniaUSA.
compile (? for help): lib>sample.msl,<eol>
output lib>sample.usp<eol>
<eol>
Opening intmod for $SYS from intlib(sys-usp.ilb)>sys-uspa
LIB(foo.lib)>/sample.msl;2 1 2
Objmod for SAMPLE stored on LIB(foo.lib)>/sample.usp;1
Intmod for SAMPLE not stored
compile (? for help): <eol>
Back from compil
You invoke the MAINSAIL compiler using LIB's EXECUTE command. You specify as the source file the library file (foo.lib)>/sample.msl and as the objmod file the library file (foo.lib)>/sample.usp. After the compilation is done, you quit the compiler and returns to LIBEX.
LIBexecute lib>sample.usp<eol>
Size of hash bucket131<eol>
Next key to be hashed (eol to stop): abc<eol>
36
Next key to be hashed (eol to stop): <eol>
Back from lib>sample.usp
You then invoke the MODULE contained in the library file (foo.lib)>/sample.usp.
LIB:  

19.7. Known Bugs and Problems in LIB

Caution should be used when exiting MAINSAIL or disposing of LIB when there are open modified libraries. LIB attempts to preserve the integrity of libraries, but there may be undetected circumstances that cause library corruption, particularly if LIB is disposed when there are open library files. Try to close explicitly all library files before exiting MAINSAIL or disposing of LIB.

previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Utilities User's Guide, Chapter 19