Module rmox:utils - Utility routines for RMoX
Utility routines for RMoX. The file occam/occ_utils.occ provides a variety of utility PROCs and FUNCTIONs for use by other components.
Index
-
Process
args.start.end- Separates a command-line (using whitespace) into individual arguments -
Process
args.start.end.quote- Separates a command-line (using whitespace, and optionally quote-marks) into individual arguments -
Process
debug.out.string- Hard write a debug string -
Function
eqstr- Tests for equality between strings (byte arrays) -
Function
int.inrange- Forces an integer value into the given range -
Function
isalnum- Determines whether the given character is alphanumeric -
Function
isalpha- Determines whether the given character is a letter -
Function
isdigit- Determines whether the given character is a decimal digit -
Function
islower- Determines whether the given character is a lowercase letter -
Function
isupper- Determines whether the given character is an uppercase letter -
Process
mode.to.access.str- Converts a mode constant into a 10-byte string -
Operator
= ([]BYTE, []BYTE)- Provides equality operator between strings (byte arrays) -
Process
out.bit- Outputs one of two messages depending on set bits -
Process
out.bool- Outputs a boolean value ( TRUE or FALSE ) -
Process
out.g.justify.hex- Outputs an integer in hexadecimal (base-16) format, right justified -
Process
out.g.justify.int- Outputs an integer in decimal (base-10) format, right justified -
Process
out.hex- Outputs an integer in hexadecimal (base-16) format -
Process
out.hex.byte- Outputs a BYTE value in hexadecimal (base-16) format -
Process
out.int- Output an integer in decimal (base-10) format -
Process
out.int64- Outputs a 64-bit integer value in decimal (base-10) format -
Process
out.justify.hex- Outputs an integer in hexadecimal (base-16) format, right justified -
Process
out.justify.int- Outputs an integer in decimal (base-10) format, right justified -
Process
out.justify.int64- Outputs a 64-bit integer value in decimal (base-10) format, right justified -
Process
out.justify.string- Write a string to a BYTE output channel, justified to the specified length -
Process
out.string- Write a string to a BYTE output channel -
Process
out.string.ifmt- Write a string to the BYTE output channel containing integer formatting (INTs only) -
Function
parse.hex- Parses a hexadecimal (base-16) integer value -
Function
parse.int- Parses a decimal (base-10) integer value -
Function
parse.int64- Parses a decimal (base-10) 64-bit integer value -
Function
parse.real64- Parses a 64-bit floating point decimal value -
Process
rmox.connect.block.driver- Connects to a particular device driver -
Process
rmox.connect.driver- Connects to a particular device driver -
Process
rmox.connect.input.driver- Connects to a particular device driver -
Process
rmox.connect.output.driver- Connects to a particular device driver -
Process
rmox.connect.service- Connects to a particular service -
Process
rmox.connect.shared.block.driver- Connects to a particular device driver -
Process
rmox.connect.shared.driver- Connects to a particular device driver (shared) -
Process
rmox.connect.shared.input.driver- Connects to a particular device driver -
Process
rmox.connect.shared.output.driver- Connects to a particular device driver -
Process
rmox.connect.shared.service- Connects to a particular service -
Process
rmox.exec.app- Executes an application-style module -
Process
rmox.file.configurator- Acts as a server for a named configuration file -
Process
rmox.file.read.line- Reads a line of text from a file -
Process
rmox.kernel.driver- Accesses the driver-core from a kernel handle -
Process
rmox.kernel.log- Puts a message into the kernel log buffer -
Process
rmox.kernel.service- Accesses the service-core from a kernel handle -
Process
rmox.start.service- Starts a particular service
Declarations
rmox_utils.occ:39Process rmox.kernel.service
PROC rmox.kernel.service (SHARED CT.KERNEL! to.kernel, RESULT SHARED CT.SERVICE! result, BOOL ok)
Accesses the service-core from a kernel handle.
Parameters:
SHARED CT.KERNEL! |
to.kernel |
Connection to kernel. |
RESULT SHARED CT.SERVICE! |
result |
Returned connection to service-core. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:63Process rmox.connect.service
PROC rmox.connect.service (SHARED CT.SERVICE! to.service, VAL []BYTE name, RESULT MOBILE.CHAN result, BOOL ok)
Connects to a particular service.
Parameters:
SHARED CT.SERVICE! |
to.service |
Connection to service-core. |
VAL []BYTE |
name |
Service name. |
RESULT MOBILE.CHAN |
result |
Returned connection to service. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:123Process rmox.start.service
PROC rmox.start.service (SHARED CT.SERVICE! to.service, VAL []BYTE name, options, BOOL ok)
Starts a particular service.
Parameters:
SHARED CT.SERVICE! |
to.service |
Connection to service-core. |
VAL []BYTE |
name |
Service name. |
VAL []BYTE |
options |
Service options. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:151Process rmox.kernel.log
PROC rmox.kernel.log (SHARED CT.KERNEL! to.kernel, VAL []BYTE msg)
Puts a message into the kernel log buffer.
Parameters:
SHARED CT.KERNEL! |
to.kernel |
Connection to kernel. |
VAL []BYTE |
msg |
Message string (include newline if required). |
rmox_utils.occ:171Process rmox.kernel.driver
PROC rmox.kernel.driver (SHARED CT.KERNEL! to.kernel, RESULT SHARED CT.DRIVER! result, BOOL ok)
Accesses the driver-core from a kernel handle.
Parameters:
SHARED CT.KERNEL! |
to.kernel |
Connection to kernel. |
RESULT SHARED CT.DRIVER! |
result |
Returned connection to driver-core. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:195Process rmox.connect.driver
PROC rmox.connect.driver (SHARED CT.DRIVER! to.driver, VAL []BYTE name, RESULT MOBILE.CHAN result, BOOL ok)
Connects to a particular device driver.
Parameters:
SHARED CT.DRIVER! |
to.driver |
Connection to driver-core. |
VAL []BYTE |
name |
Driver name. |
RESULT MOBILE.CHAN |
result |
Returned connection to device driver. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:257Process rmox.connect.input.driver
PROC rmox.connect.input.driver (SHARED CT.DRIVER! to.driver, VAL []BYTE name, RESULT CT.INPUT! result, BOOL ok)
Connects to a particular device driver.
Parameters:
SHARED CT.DRIVER! |
to.driver |
Connection to driver-core. |
VAL []BYTE |
name |
Driver name. |
RESULT CT.INPUT! |
result |
Returned connection to device driver. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:317Process rmox.connect.output.driver
PROC rmox.connect.output.driver (SHARED CT.DRIVER! to.driver, VAL []BYTE name, RESULT CT.OUTPUT! result, BOOL ok)
Connects to a particular device driver.
Parameters:
SHARED CT.DRIVER! |
to.driver |
Connection to driver-core. |
VAL []BYTE |
name |
Driver name. |
RESULT CT.OUTPUT! |
result |
Returned connection to device driver. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:377Process rmox.connect.block.driver
PROC rmox.connect.block.driver (SHARED CT.DRIVER! to.driver, VAL []BYTE name, RESULT CT.BLOCK! result, BOOL ok)
Connects to a particular device driver.
Parameters:
SHARED CT.DRIVER! |
to.driver |
Connection to driver-core. |
VAL []BYTE |
name |
Driver name. |
RESULT CT.BLOCK! |
result |
Returned connection to device driver. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:447Process rmox.file.read.line
PROC rmox.file.read.line (CT.FILE! file, BOOL ok, RESULT BOOL at.eof, RESULT MOBILE []BYTE line)
Reads a line of text from a file. Leaves the file-offset at the start of the next line, or EOF. Newlines are stripped before the string is returned. Blank lines will be returned as zero-length strings. The at.eof flag is set to TRUE if an attempt is made to read at the end-of-file (line will be set to a zero-length string in this case).
Parameters:
CT.FILE! |
file |
File handle. |
BOOL |
ok |
Check and set success. |
RESULT BOOL |
at.eof |
Set if we have reached the end-of-file. |
RESULT MOBILE []BYTE |
line |
Line read from the file. |
rmox_utils.occ:1044Process rmox.file.configurator
PROC rmox.file.configurator (CT.CFG? svr, VAL []BYTE fname, SHARED CT.KERNEL! to.kernel, BOOL ok)
Acts as a server for a named configuration file.
Parameters:
CT.CFG? |
svr |
Server channel-end. |
VAL []BYTE |
fname |
Filename. |
SHARED CT.KERNEL! |
to.kernel |
Link to kernel. |
BOOL |
ok |
Check and set success. |
rmox_utils.occ:1097Process rmox.exec.app
PROC rmox.exec.app (VAL []BYTE path, args, SHARED CT.KERNEL! krnl, CHAN BYTE kyb?, scr!, BOOL ok, RESULT INT err)
Executes an application-style module. This runs the specified application to completion or error.
Parameters:
VAL []BYTE |
path |
Path to application module. |
VAL []BYTE |
args |
Command-line arguments. |
SHARED CT.KERNEL! |
krnl |
Kernel link. |
CHAN BYTE |
kyb |
Keyboard channel in. |
CHAN BYTE |
scr |
Screen channel out. |
BOOL |
ok |
Check and set success. |
RESULT INT |
err |
Specific error on failure. |
occ_utils.occ:384Process out.string
PROC out.string (VAL []BYTE str, CHAN BYTE out!)
Write a string to a BYTE output channel.
Parameters:
VAL []BYTE |
str |
String to write. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:396Process out.justify.string
PROC out.justify.string (VAL []BYTE str, VAL INT j, CHAN BYTE out!)
Write a string to a BYTE output channel, justified to the specified length.
Parameters:
VAL []BYTE |
str |
String to write. |
VAL INT |
j |
Width of field to output (text is left-justified). |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:417Process debug.out.string
PROC debug.out.string (VAL []BYTE str)
Hard write a debug string. This calls an external routine to write a message to the screen. This is primarily useful for debugging hardware I/O, particularly in the presence of hardware crashes. The specified string is written to the VGA text framebuffer.
Parameters:
VAL []BYTE |
str |
String to write. |
occ_utils.occ:428Process out.int
PROC out.int (VAL INT n, CHAN BYTE out!)
Output an integer in decimal (base-10) format.
Parameters:
VAL INT |
n |
Integer to output. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:477Process out.int64
PROC out.int64 (VAL INT64 n, CHAN BYTE out!)
Outputs a 64-bit integer value in decimal (base-10) format.
Parameters:
VAL INT64 |
n |
Value to output. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:528Process out.justify.int
PROC out.justify.int (VAL INT n, j, CHAN BYTE out!)
Outputs an integer in decimal (base-10) format, right justified.
Parameters:
VAL INT |
n |
Value to output. |
VAL INT |
j |
Justification (field width). |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:551Process out.justify.int64
PROC out.justify.int64 (VAL INT64 n, VAL INT j, CHAN BYTE out!)
Outputs a 64-bit integer value in decimal (base-10) format, right justified.
Parameters:
VAL INT64 |
n |
Value to output. |
VAL INT |
j |
Justification (field width). |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:577Process out.g.justify.int
PROC out.g.justify.int (VAL INT n, j, VAL BYTE c, CHAN BYTE out!)
Outputs an integer in decimal (base-10) format, right justified. This is similar to out.justify.int, but pads the output with the specified character, instead of spaces.
Parameters:
VAL INT |
n |
Value to output. |
VAL INT |
j |
Justification (field width). |
VAL BYTE |
c |
Character to pad with. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:599Process out.hex.byte
PROC out.hex.byte (VAL BYTE b, CHAN BYTE out!)
Outputs a BYTE value in hexadecimal (base-16) format.
Parameters:
VAL BYTE |
b |
Value to output. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:612Process out.hex
PROC out.hex (VAL INT n, CHAN BYTE out!)
Outputs an integer in hexadecimal (base-16) format.
Parameters:
VAL INT |
n |
Value to output. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:642Process out.justify.hex
PROC out.justify.hex (VAL INT n, j, CHAN BYTE out!)
Outputs an integer in hexadecimal (base-16) format, right justified.
Parameters:
VAL INT |
n |
Value to output. |
VAL INT |
j |
Justification (field width). |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:676Process out.g.justify.hex
PROC out.g.justify.hex (VAL INT n, j, VAL BYTE c, CHAN BYTE out!)
Outputs an integer in hexadecimal (base-16) format, right justified. This is similar to out.justify.hex, but pads the output with the specified character, instead of spaces.
Parameters:
VAL INT |
n |
Value to output. |
VAL INT |
j |
Justification (field width). |
VAL BYTE |
c |
Character to pad with. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:706Process out.bool
PROC out.bool (VAL BOOL b, CHAN BYTE out!)
Outputs a boolean value (TRUE or FALSE).
Parameters:
VAL BOOL |
b |
Value to output. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:723Process out.bit
PROC out.bit (VAL INT val, bits, VAL []BYTE true, false, CHAN BYTE out!)
Outputs one of two messages depending on set bits.
Parameters:
VAL INT |
val |
Value to test. |
VAL INT |
bits |
Bit mask to check for set bits (all bits set). |
VAL []BYTE |
true |
String output if all bits are set. |
VAL []BYTE |
false |
String output if one or more specified bits are not set. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:739Process out.string.ifmt
PROC out.string.ifmt (VAL []BYTE str, VAL []INT ivals, CHAN BYTE out!)
Write a string to the BYTE output channel containing integer formatting (INTs only). Note: this assumes some amount of correctness in the formatting string.
Parameters:
VAL []BYTE |
str |
String to write, e.g. "x=%d, flags=%8x*n". |
VAL []INT |
ivals |
Integer values. |
CHAN BYTE |
out |
Channel to write to. |
occ_utils.occ:816Function parse.int
INT, BOOL FUNCTION parse.int (VAL []BYTE str)
Parses a decimal (base-10) integer value.
Parameters:
VAL []BYTE |
str |
String to parse. |
Returns:
INT |
value Parsed integer value. | |
BOOL |
ok Indicates success or failure. |
occ_utils.occ:855Function parse.hex
INT, BOOL FUNCTION parse.hex (VAL []BYTE str)
Parses a hexadecimal (base-16) integer value.
Parameters:
VAL []BYTE |
str |
String to parse. |
Returns:
INT |
value Parsed integer value. | |
BOOL |
ok Indicates success or failure. |
occ_utils.occ:892Function parse.int64
INT64, BOOL FUNCTION parse.int64 (VAL []BYTE str)
Parses a decimal (base-10) 64-bit integer value.
Parameters:
VAL []BYTE |
str |
String to parse. |
Returns:
INT64 |
value Parsed 64-bit integer value. | |
BOOL |
ok Indicates success or failure. |
occ_utils.occ:927Function parse.real64
REAL64, BOOL FUNCTION parse.real64 (VAL []BYTE str)
Parses a 64-bit floating point decimal value.
Parameters:
VAL []BYTE |
str |
String to parse. |
Returns:
REAL64 |
value Parsed REAL64 value. |
|
BOOL |
ok Indicates success or failure. |
occ_utils.occ:968Function int.inrange
INT FUNCTION int.inrange (VAL INT val, min, max)
Forces an integer value into the given range.
Parameters:
VAL INT |
val |
Value to check. |
VAL INT |
min |
Minimum value (inclusive). |
VAL INT |
max |
Maximum value (inclusive). |
Returns:
INT |
value Value in range. |
occ_utils.occ:988Function isdigit
BOOL FUNCTION isdigit (VAL BYTE c)
Determines whether the given character is a decimal digit.
Parameters:
VAL BYTE |
c |
Character to check. |
Returns:
BOOL |
ok True if character is decimal digit. |
occ_utils.occ:996Function islower
BOOL FUNCTION islower (VAL BYTE c)
Determines whether the given character is a lowercase letter.
Parameters:
VAL BYTE |
c |
Character to check. |
Returns:
BOOL |
ok True if character is a lowercase letter. |
occ_utils.occ:1004Function isupper
BOOL FUNCTION isupper (VAL BYTE c)
Determines whether the given character is an uppercase letter.
Parameters:
VAL BYTE |
c |
Character to check. |
Returns:
BOOL |
ok True if character is an uppercase letter. |
occ_utils.occ:1012Function isalpha
BOOL FUNCTION isalpha (VAL BYTE c)
Determines whether the given character is a letter.
Parameters:
VAL BYTE |
c |
Character to check. |
Returns:
BOOL |
ok True if character is a letter. |
occ_utils.occ:1020Function isalnum
BOOL FUNCTION isalnum (VAL BYTE c)
Determines whether the given character is alphanumeric.
Parameters:
VAL BYTE |
c |
Character to check. |
Returns:
BOOL |
ok True if character is alphanumeric. |
occ_utils.occ:1030Operator = ([]BYTE, []BYTE)
BOOL FUNCTION "=" (VAL []BYTE s1, s2)
Provides equality operator between strings (byte arrays).
Parameters:
VAL []BYTE |
s1 |
First string. |
VAL []BYTE |
s2 |
Second string. |
Returns:
BOOL |
eq True if the strings are equal. |
occ_utils.occ:1051Function eqstr
BOOL FUNCTION eqstr (VAL []BYTE s1, s2)
Tests for equality between strings (byte arrays).
Parameters:
VAL []BYTE |
s1 |
First string. |
VAL []BYTE |
s2 |
Second string. |
Returns:
BOOL |
eq True if the strings are equal. |
occ_utils.occ:1067Process mode.to.access.str
PROC mode.to.access.str (VAL INT mode, [10]BYTE outstr)
Converts a mode constant into a 10-byte string.
Parameters:
VAL INT |
mode |
File mode (see MODE). |
[10]BYTE |
outstr |
String to write to. |
occ_utils.occ:1101Process args.start.end
PROC args.start.end (VAL []BYTE cmdline, MOBILE []ARG.POS arg.pos)
Separates a command-line (using whitespace) into individual arguments.
Parameters:
VAL []BYTE |
cmdline |
Command line string to separate. |
MOBILE []ARG.POS |
arg.pos |
Populated with starts and lengths of the individual arguments. |
occ_utils.occ:1164Process args.start.end.quote
PROC args.start.end.quote (VAL []BYTE cmdline, MOBILE []ARG.POS arg.pos, VAL BOOL dequote)
Separates a command-line (using whitespace, and optionally quote-marks) into individual arguments.
Parameters:
VAL []BYTE |
cmdline |
Command line string to separate. |
MOBILE []ARG.POS |
arg.pos |
Populated with starts and lengths of the individual arguments. |
VAL BOOL |
dequote |
Whether to de-quote arguments if present. |