Skip to content

Latest commit

 

History

History
838 lines (534 loc) · 36.3 KB

File metadata and controls

838 lines (534 loc) · 36.3 KB

src/minisql/client/console.ml

Home · Files

Provides minisql client console facilities for this project.

Package: minisql.client.console

Reachable from entry: yes

Imports

Declarations

appendSqlFragment

function appendSqlFragment(statements, source, startOffset, endOffset, hasToken)

Appends SQL fragment using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
statements dynamic statements value consumed by this operation.
source dynamic source value consumed by this operation.
startOffset dynamic startOffset value consumed by this operation.
endOffset dynamic endOffset value consumed by this operation.
hasToken dynamic hasToken value consumed by this operation.

View source

commandArgument

function commandArgument(line, prefix)

Implements command argument for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
line dynamic line value consumed by this operation.
prefix dynamic prefix value consumed by this operation.

View source

componentName

function componentName()

Performs the componentName operation for the minisql client console module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

CP_UTF8

const CP_UTF8 = 65001

Defines the cp utf8 constant used by the minisql client console module.

View source

disableQuickEdit

function disableQuickEdit()

Prevents accidental mouse selection from suspending a Windows console server. Redirected standard input and service processes have no console and are treated as already safe; a real console-mode update reports failures.

View source

ENABLE_ECHO_INPUT

const ENABLE_ECHO_INPUT = 4

Defines the enable echo input constant used by the minisql client console module.

View source

ENABLE_EXTENDED_FLAGS

const ENABLE_EXTENDED_FLAGS = 128

Defines the enable extended flags constant used by the minisql client console module.

View source

ENABLE_QUICK_EDIT_MODE

const ENABLE_QUICK_EDIT_MODE = 64

Defines the enable quick edit mode constant used by the minisql client console module.

View source

executeMeta

function executeMeta(activeClient, line)

Executes meta using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
activeClient dynamic activeClient value consumed by this operation.
line dynamic line value consumed by this operation.

View source

executeOnce

function executeOnce(activeClient, sqlText)

Executes once using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
activeClient dynamic activeClient value consumed by this operation.
sqlText dynamic sqlText value consumed by this operation.

View source

executeStatements

function executeStatements(activeClient, statements)

Executes statements using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
activeClient dynamic activeClient value consumed by this operation.
statements dynamic statements value consumed by this operation.

View source

fail

function fail(code, operation, message)

Performs the fail operation for the minisql client console module. Returns its result or propagates a structured error from validation or a dependency. Performs I/O through its file, transport, or storage dependencies.

Parameter Type Default Description
code dynamic code value consumed by this operation.
operation dynamic operation value consumed by this operation.
message dynamic Human-readable message associated with the operation.

View source

GetConsoleMode

extern function GetConsoleMode(handle as ptr, mode as bytes) from "kernel32.dll" symbol "GetConsoleMode" returns bool

Reads console-mode flags into mode and returns false on a Win32 error.

Parameter Type Default Description
handle ptr Native or runtime handle used by the operation.
mode bytes Mode selecting the requested behavior.

Returns: Native bool result produced by the call.

View source

GetStdHandle

extern function GetStdHandle(kind as i32) from "kernel32.dll" symbol "GetStdHandle" returns ptr

Returns the Windows standard-stream handle identified by kind; failure uses an invalid native handle.

Parameter Type Default Description
kind i32 kind value consumed by this operation.

Returns: Native ptr result produced by the call.

View source

INVALID_ARGUMENT

const INVALID_ARGUMENT = 9001

Defines the invalid argument constant used by the minisql client console module.

View source

IO_FAILURE

const IO_FAILURE = 9005

Defines the io failure constant used by the minisql client console module.

View source

isIdentifierByte

function isIdentifierByte(value, first)

Returns whether the supplied value satisfies the identifier byte condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.
first dynamic first value consumed by this operation.

View source

isImplemented

function isImplemented()

Returns whether implemented satisfies the condition required by the minisql client console module. Returns the computed value or operation status. Does not modify its inputs.

View source

isMetaCommand

function isMetaCommand(text)

Returns whether the supplied value satisfies the meta command condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

isSafeMetaIdentifier

function isSafeMetaIdentifier(value)

Returns whether the supplied value satisfies the safe meta identifier condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isScriptComment

function isScriptComment(line)

Returns whether the supplied value satisfies the script comment condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
line dynamic line value consumed by this operation.

View source

isSqlBatch

function isSqlBatch(value)

Returns whether the supplied value satisfies the SQL batch condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isWhitespaceByte

function isWhitespaceByte(value)

Returns whether the supplied value satisfies the whitespace byte condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

MAX_PASSWORD_UTF16_UNITS

const MAX_PASSWORD_UTF16_UNITS = 1024

Defines the max password utf16 units constant used by the minisql client console module.

View source

openAuthenticatedPrompt

function openAuthenticatedPrompt(address, port, username)

Opens authenticated prompt using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
address dynamic address value consumed by this operation.
port dynamic port value consumed by this operation.
username dynamic username value consumed by this operation.

View source

openTlsAuthenticatedPrompt

function openTlsAuthenticatedPrompt(address, port, serverName, username)

Prompts for a password and opens native TLS using Windows certificate trust.

Parameter Type Default Description
address dynamic address value consumed by this operation.
port dynamic port value consumed by this operation.
serverName dynamic serverName value consumed by this operation.
username dynamic username value consumed by this operation.

View source

openTlsPinnedAuthenticatedPrompt

function openTlsPinnedAuthenticatedPrompt(address, port, serverName, pinText, username)

Prompts for a password and opens native TLS using an exact leaf SHA-256 pin.

Parameter Type Default Description
address dynamic address value consumed by this operation.
port dynamic port value consumed by this operation.
serverName dynamic serverName value consumed by this operation.
pinText dynamic pinText value consumed by this operation.
username dynamic username value consumed by this operation.

View source

printQueryResponse

function printQueryResponse(response)

Prints query response using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
response dynamic response value consumed by this operation.

View source

printShellHelp

function printShellHelp()

Prints shell help using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

rawText

function rawText(source, offset, count)

Implements raw text for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
source dynamic source value consumed by this operation.
offset dynamic Zero-based offset at which processing starts.
count dynamic Number of items or units to process.

View source

ReadConsoleW

extern function ReadConsoleW(handle as ptr, buffer as bytes, count as u32, readOut as bytes, control as ptr) from "kernel32.dll" symbol "ReadConsoleW" returns bool

Reads UTF-16 console input into buffer, reporting the unit count through readOut.

Parameter Type Default Description
handle ptr Native or runtime handle used by the operation.
buffer bytes Buffer that receives or supplies the operation data.
count u32 Number of items or units to process.
readOut bytes readOut value consumed by this operation.
control ptr control value consumed by this operation.

Returns: Native bool result produced by the call.

View source

readPassword

function readPassword(prompt)

Reads password using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
prompt dynamic prompt value consumed by this operation.

View source

readPasswordConfirmed

function readPasswordConfirmed(prompt, confirmationPrompt)

Reads password confirmed using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
prompt dynamic prompt value consumed by this operation.
confirmationPrompt dynamic confirmationPrompt value consumed by this operation.

View source

runScript

function runScript(activeClient, path)

Runs script using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Performs I/O through its file, transport, or storage dependencies.

Parameter Type Default Description
activeClient dynamic activeClient value consumed by this operation.
path dynamic Path of the file or directory used by the operation.

View source

runShell

function runShell(activeClient, prompt)

Runs shell using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
activeClient dynamic activeClient value consumed by this operation.
prompt dynamic prompt value consumed by this operation.

View source

scanSqlBatch

function scanSqlBatch(text, finalInput)

Split complete SQL statements without treating semicolons inside quoted strings, quoted identifiers or comments as terminators. When finalInput is false, an incomplete suffix is returned for the interactive continuation prompt. When finalInput is true, a final statement may omit its semicolon. Scans SQL batch using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.
finalInput dynamic finalInput value consumed by this operation.

View source

SetConsoleMode

extern function SetConsoleMode(handle as ptr, mode as u32) from "kernel32.dll" symbol "SetConsoleMode" returns bool

Replaces console-mode flags and returns false on a Win32 error.

Parameter Type Default Description
handle ptr Native or runtime handle used by the operation.
mode u32 Mode selecting the requested behavior.

Returns: Native bool result produced by the call.

View source

splitLines

function splitLines(text)

Implements split lines for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

splitSqlStatements

function splitSqlStatements(text)

Implements split SQL statements for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

startsWithBytes

function startsWithBytes(text, first, second)

Implements starts with bytes for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.
first dynamic first value consumed by this operation.
second dynamic second value consumed by this operation.

View source

startsWithText

function startsWithText(text, prefix)

Implements starts with text for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.
prefix dynamic prefix value consumed by this operation.

View source

STD_INPUT_HANDLE

const STD_INPUT_HANDLE = -10

Defines the std input handle constant used by the minisql client console module.

View source

STD_OUTPUT_HANDLE

const STD_OUTPUT_HANDLE = -11

Defines the std output handle constant used by the minisql client console module.

View source

targetMilestone

function targetMilestone()

Performs the targetMilestone operation for the minisql client console module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

trimAscii

function trimAscii(text)

Implements trim ascii for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

utf16PasswordToUtf8

function utf16PasswordToUtf8(wide, units)

Implements utf16 password to UTF-8 for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
wide dynamic wide value consumed by this operation.
units dynamic units value consumed by this operation.

View source

WC_ERR_INVALID_CHARS

const WC_ERR_INVALID_CHARS = 128

Defines the wc err invalid chars constant used by the minisql client console module.

View source

WideCharToMultiByte

extern function WideCharToMultiByte(codePage as u32, flags as u32, wideText as bytes, wideCount as i32, output as bytes, outputCount as i32, defaultChar as ptr, usedDefault as ptr) from "kernel32.dll" symbol "WideCharToMultiByte" returns i32

Converts UTF-16 units to the requested code page; returns bytes written or zero on failure.

Parameter Type Default Description
codePage u32 codePage value consumed by this operation.
flags u32 Bit flags controlling the operation.
wideText bytes wideText value consumed by this operation.
wideCount i32 Number of wide to process.
output bytes Output collection or buffer populated by the operation.
outputCount i32 Number of output to process.
defaultChar ptr defaultChar value consumed by this operation.
usedDefault ptr usedDefault value consumed by this operation.

Returns: Native i32 result produced by the call.

View source

wipePassword

function wipePassword(passwordBytes)

Implements wipe password for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
passwordBytes dynamic passwordBytes value consumed by this operation.

View source

WriteConsoleW

extern function WriteConsoleW(handle as ptr, text as wstr, count as u32, writtenOut as bytes, reserved as ptr) from "kernel32.dll" symbol "WriteConsoleW" returns bool

Writes UTF-16 console text and reports the unit count through writtenOut.

Parameter Type Default Description
handle ptr Native or runtime handle used by the operation.
text wstr Text consumed by the operation.
count u32 Number of items or units to process.
writtenOut bytes writtenOut value consumed by this operation.
reserved ptr reserved value consumed by this operation.

Returns: Native bool result produced by the call.

View source

writePrompt

function writePrompt(outputHandle, prompt)

Writes prompt using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
outputHandle dynamic outputHandle value consumed by this operation.
prompt dynamic prompt value consumed by this operation.

View source