MAINSAIL System-Specific User's Guides, Chapter 6

previous   next   top   complete contents   complete index   framed top   this page unframed


6. System Information PROCEDUREs

6.1. $currentDirectory

$currentDirectory returns the full path name of the current directory (“.”). Symbolic links are expanded; i.e., even if a symbolic link was originally specified in the system call that connected to the current directory, the full directory name is returned. On some flavors, it is required that every directory in the current path be readable.

6.2. $homeDirectory

$homeDirectory returns the value of the HOME environment variable.

6.3. $directory (for UNIX Disk Files)

$directory returns the names of the files in the specified directory. If $fullPathNames is set, the directory name and a slash character are prefixed to each file name. $reportAllVersions is ignored. The files . and .. are not included in the directory listing.

6.4. Command Line and $programName

$programName is set to the first element of the argument vector argv. The command line is formed from the remaining elements, separated by spaces.

6.5. $fileInfo (for UNIX Disk Files)

Since UNIX does not provide the creation date and time of a file, $fileInfo sets the fields $createDate and $createTime of the CLASS $fileInfoCls to 0L.

6.6. $composeFileName Examples

Here are some sample results for $composeFileName(base,extension,"",path) on UNIX:

base extension path $composeFileName
"abc" "msl" "" "abc.msl"
"a.b" "c" "xyz" "xyz/a.b.c"
"xyz" "" "/foo" "/foo/xyz"

6.7. $composePath Examples

Here are some sample results for $composePath(pathPrefix,pathComponents) on UNIX:

pathPrefix pathComponents $composePath
"" "" ""
"" "xyz" "xyz"
"/" "foo" "/foo"
"/" "foo" & eol & "bar" "/foo/bar"

6.8. $decomposePath

When a STRING passed to $decomposePath is prefixed with a slash, i.e., is an absolute path name, then pathPrefix is /. If the path is relative (does not begin with /), then pathPrefix is the empty STRING.

Here are some sample results for $decomposePath(path,pathPrefix,pathComponents) on UNIX:

path pathPrefix pathComponents
"" "" ""
"xyz" "" "xyz"
"/foo" "/" "foo"
"/foo/bar" "/" "foo" & eol & "bar"

6.9. $decomposeFileName

In a file name containing no periods, $decomposeFileName considers the entire file name to be the base, so that:

$decomposeFileName("abc",base,extension)

yields base = "abc" and extension = "".

If a file name contains exactly one period, the base is the part before the period, and the extension the part after, so that:

$decomposeFileName("ab.c",base,extension)

results in base = "ab" and extension = "c".

If a file name contains multiple periods, the part after the last period is treated as the extension. Thus:

$decomposeFileName("a.b.c",base,extension)

leaves base = "a.b" and extension = "c".

Here are some sample results for $decomposeFileName(fileName,base,extension,devModStr,path) on UNIX:

fileName base extension path
"abc.msl" "abc" "msl" ""
"xyz/a.b.c" "a.b" "c" "xyz"
"/foo/xyz" "xyz" "" "/foo"

(devModStr is the empty STRING in each case).

6.10. $userID

$userID calls cuserid or getpwuid (or whatever equivalent call the particular UNIX flavor provides), if available; otherwise, it returns the user name found in /etc/passwd for the current user ID, as given by the UNIX call getuid.

If $login is specified, the user ID is the login ID; otherwise, it is the effective ID.

6.11. $cpuID

$cpuID is implemented on many UNIX systems, but the implementation depends on the system call available. On systems where $cpuID is not implemented, it returns the empty STRING.

On systems that provide the gethostid system call, $cpuID returns gethostid's return value, converted to a hexadecimal STRING.

On systems that provide the sysinfo system call, $cpuID returns the values obtained by passing the arguments SI_HW_PROVIDER and SI_HW_SERIAL to sysinfo, and concatenating the returned values, separated by a colon and a space.

On UNIX, if $cpuID would return the null STRING, it checks to see if $useAlternateCpuID ('H200) is set in the configuration bits. If so, then it returns whatever is produced by the FLI PROCEDURE $alternateCpuID. This PROCEDURE must be provided by the user in an FLI MODULE called $aCpuID, declared as follows:

MODULE $aCpuID (

INTEGER
PROCEDURE   $alternateCpuID
                        (
CHARADR bufINTEGER bufSize);

);

$alternateCpuID returns a NUL-terminated string no longer than bufSize at buf. $aCpuId should be compiled with the appropriate Foreign Call Compiler and linked with a MAINSAIL bootstrap in which the 'H200 bit is set in the CONFIGURATIONBITS command.

6.12. Exit Codes

The values $successExitCode and $failureExitCode are possible arguments to the system PROCEDURE $setExitCode. The exit code on UNIX is the value passed to the system call exit. $successExitCode is '0L and $failureExitCode is a LONG BITS value in which every bit is set.

6.13. $lookupEnvironmentVar and $getEnvironmentVars

Two PROCEDUREs for dealing with UNIX environment variables, $lookupEnvironmentVar and $getEnvironmentVars, examine the process's current environment variables.

The PROCEDURE $lookupEnvironmentVar finds the value of a specific environment variable. The interface of $lookupEnvironmentVar is:

BOOLEAN
PROCEDURE   $lookupEnvironmentVar
                        (
STRING key;
                         
PRODUCES OPTIONAL STRING val);

If key is currently a UNIX environment variable, $lookupEnvironmentVar sets val to the environment variable's value and returns TRUE. Otherwise, it sets val to the empty STRING and returns FALSE. Conventions for environment variables depend on the particular UNIX platform and are described in part 5 of the UNIX manual under environ. Typically, key does not contain a leading $, and the case of any alphabetic characters is important (e.g., HOME, not home).

The PROCEDURE $getEnvironmentVars creates a STRING ARRAY denoting the process's current environment variables. The interface of $getEnvironmentVars is:

BOOLEAN
PROCEDURE   $getEnvironmentVars
                        (
PRODUCES STRING ARRAY(1 TO *)
                             
environment;
                         
OPTIONAL PRODUCES STRING msg);

The ARRAY contains an element for each UNIX environment variable. Each STRING in the ARRAY has the form name=val, where name is the name of an environment variable and val is the environment variable's value. More information may be found in part 5 of the UNIX manuals under environ. If the process has no environment variables, the ARRAY is set to NULLARRAY.

$getEnvironmentVars returns TRUE if successful; if unsuccessful, it sets msg to a STRING describing the error and returns FALSE.

6.14. $environment

$environment is an inferior method of examining UNIX environment variables; you should probably use $lookupEnvironmentVar or $getEnvironmentVars instead. The $environment ARRAY reflects only the state of the process's environment variables at the time MAINSAIL was initialized. Subsequent changes to the process's environment variables are not reflected in the ARRAY, whereas they are reflected in the values produced by $lookupEnvironmentVar or $getEnvironmentVars.

$environment will continue to be supported for backwards compatibility, but users should be aware that its contents will be obsolete if the process subsequently changes the state of its environment variables.

The UNIX environment pointer array environ is made available to MAINSAIL programs on UNIX as the STRING ARRAY $environment, declared as:

STRING ARRAY(1 TO *) $environment;

Each STRING in the ARRAY has the form name=value. More information may be found in part 5 of the UNIX manuals under environ.


previous   next   top   complete contents   complete index   framed top   this page unframed

MAINSAIL System-Specific User's Guides, Chapter 6