previous next top complete contents complete index framed top this page unframed
| base | extension | path | $composeFileName |
|---|---|---|---|
| "abc" | "msl" | "" | "abc.msl" |
| "a.b" | "c" | "xyz" | "xyz/a.b.c" |
| "xyz" | "" | "/foo" | "/foo/xyz" |
| pathPrefix | pathComponents | $composePath |
|---|---|---|
| "" | "" | "" |
| "" | "xyz" | "xyz" |
| "/" | "foo" | "/foo" |
| "/" | "foo" & eol & "bar" | "/foo/bar" |
Here are some sample results for $decomposePath(path,pathPrefix,pathComponents) on UNIX:
| path | pathPrefix | pathComponents |
|---|---|---|
| "" | "" | "" |
| "xyz" | "" | "xyz" |
| "/foo" | "/" | "foo" |
| "/foo/bar" | "/" | "foo" & eol & "bar" |
$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 buf; INTEGER 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.
MAINSAIL System-Specific User's Guides, Chapter 6