Chapter 4. System Namespaces and Class Library

Table 4.1. Qore Class List

Name

Description

File

For reading and writing files.

Dir

For handling of directories, listing files, and creating/removing subdirectories.

FtpClient

For communicating with FTP servers.

GetOpt

For processing command-line options.

Program

For parsing and executing application-embedded or user-supplied logic.

Socket

For communication with IPv4 sockets with and without TSL/SSL encryption.

TermIOS

Used when getting or setting terminal settings.

HTTPClient

For communication with HTTP servers with and without TSL/SSL encryption.

XmlRpclient

For communication using the XML-RPC protocol with and without TSL/SSL encryption.

JsonRpclient

For communication using the JSON-RPC protocol with and without TSL/SSL encryption.

SSLCertificate

For working with X.509 certificates.

SSLPrivateKey

For working with private key data.

SQL::Datasource

For working with databases; provides the user interface to qore DBI drivers.

SQL::DatasourcePool

Provides transparent per-thread, per-transaction Datasource connection pooling.

AutoGate

A helper class for the Gate class for exception-safe Gate handling.

AutoLock

A helper class for the Mutex class for exception-safe Mutex handling.

AutoReadLock

A helper class for the RWLock class for exception-safe read lock handling.

AutoWriteLock

A helper class for the RWLock class for exception-safe write lock handling.

Condition

For blocking a thread until a condition becomes true.

Counter

For blocking a thread until a counter becomes zero.

Gate

A reentrant thread lock.

Mutex

A simple thread lock.

Queue

A blocking, thread-safe queue class, useful for message passing (can also be used as a stack).

RMutex

DEPRECATED: A reentrant thread lock; use Gate instead.

RWLock

A read-write thread lock.

Sequence

A thread-safe integral counter.

XmlDoc

For analyzing and manipulating XML documents.

XmlNode

Gives information about XML data in an XML document.

XmlReader

For parsing or iterating through the elements of an XML document.


4.1. Qore Constants

The following constants are defined in the Qore namespace.

Table 4.2. Build and Version Constants

Key

Description

PlatformOS

The operating system used to build the Qore library.

PlatformCPU

The CPU used as a target for the Qore library build.

VersionString

The full version string for this version of the Qore library.

VersionMajor

An integer giving the Qore library's major version number.

VersionMinor

An integer giving the Qore library's minor version number.

VersionSub

An integer giving the Qore library's release version number.

Build

An integer giving the Qore library's subversion revision number.

BuildHost

A string giving information about the host used to compile the Qore library.

Compiler

The compiler used to build the Qore library.

CFLAGS

The compiler flags used to compile the Qore library.

LDFLAGS

The linker flags used to link the Qore library.


Table 4.3. Library Options

Name

Type

Description

HAVE_ATOMIC_OPERATIONS

Boolean

Indicates if the Qore library supports fast atomic reference counting

HAVE_STACK_GUARD

Boolean

Indicates if protection against stack overruns is provided

HAVE_RUNTIME_THREAD_STACK_TRACE

Boolean

Indicates if active thread stack tracing has been enabled as a debugging option and if the getAllThreadCallStacks() function is available.

HAVE_ROUND

Boolean

Indicates if the round() function is available.

HAVE_TIMEGM

Boolean

Indicates if the timegm() function is available.

HAVE_SETEUID

Boolean

Indicates if the seteuid() function is available.

HAVE_SETEGID

Boolean

Indicates if the setegid() function is available.

HAVE_PARSEXMLWITHRELAXNG

Boolean

Indicates if parseXMLWithRelaxNG() and XmlReader::relaxNGValidate() are available.

HAVE_PARSEXMLWITHSCHEMA

Boolean

Indicates if parseXMLWithSchema() and XmlReader::schemaValidate() are available.

HAVE_SHA224

Boolean

Indicates if the openssl library used to build the qore library supported the SHA224 algorithm and therefore if the SHA224() and SHA224_bin() functions are available.

HAVE_SHA256

Boolean

Indicates if the openssl library used to build the qore library supported the SHA256 algorithm and therefore if the SHA256() and SHA256_bin() functions are available.

HAVE_SHA384

Boolean

Indicates if the openssl library used to build the qore library supported the SHA384 algorithm and therefore if the SHA384() and SHA384_bin() functions are available.

HAVE_SHA512

Boolean

Indicates if the openssl library used to build the qore library supported the SHA512 algorithm and therefore if the SHA512() and SHA512_bin() functions are available.

HAVE_MDC2

Boolean

Indicates if the openssl library used to build the qore library supported the MDC2 algorithm and therefore if the MDC2() and MDC2_bin() functions are available.

HAVE_RC5

Boolean

Indicates if the openssl library used to build the qore library supported the RC5 encryption algorithm and therefore if the rc5_encrypt_cbc(), rc5_decrypt_cbc() and rc5_encrypt_cbc_to_string() functions are available.


Table 4.4. Boolean Constants in the Qore Namespace

Name

Type

Description

True

Boolean

True

False

Boolean

False


Table 4.5. I/O Constants in the Qore Namespace

Name

Type

Description

stdin

File Object

Standard input File object.

stdout

File Object

Standard output File object.

stderr

File Object

Standard error File object.


Table 4.6. Event Constants

Name

Value

Description

EVENT_PACKET_READ

1

Raised when a network packet is received.

EVENT_PACKET_SENT

2

Raised when a network packet is sent.

EVENT_HTTP_CONTENT_LENGTH

3

Raised when the HTTP "Content-Length" header is received.

EVENT_HTTP_CHUNKED_START

4

Raised when HTTP chunked data is about to be received.

EVENT_HTTP_CHUNKED_END

5

Raised when all HTTP chunked data has been received.

EVENT_HTTP_REDIRECT

6

Raised when an HTTP redirect message is received.

EVENT_CHANNEL_CLOSED

7

Raised when a socket is closed.

EVENT_DELETED

8

Raised when the object being monitored is deleted.

EVENT_FTP_SEND_MESSAGE

9

Raised immediately before an FTP control message is sent.

EVENT_FTP_MESSAGE_RECEIVED

10

Raised when an FTP reply is received on the control channel.

EVENT_HOSTNAME_LOOKUP

11

Raised when a hostname lookup is attempted.

EVENT_HOSTNAME_RESOLVED

12

Raised when a hostname lookup is resolved.

EVENT_HTTP_SEND_MESSAGE

13

Raised when an HTTP message is sent.

EVENT_HTTP_MESSAGE_RECEIVED

14

Raised when an HTTP message is received.

EVENT_HTTP_FOOTERS_RECEIVED

15

Raised when HTTP footers are received.

EVENT_HTTP_CHUNKED_DATA_RECEIVED

16

Raised when a block of HTTP chunked data is received.

EVENT_HTTP_CHUNK_SIZE

17

Raised when the next chunk size for HTTP chunked data is known.

EVENT_CONNECTING

18

Raised right before a socket connection attempt is made.

EVENT_CONNECTED

19

Raised when the socket connection has been established.

EVENT_START_SSL

20

Raised when socket SSL negotiation starts.

EVENT_SSL_ESTABLISHED

21

Raised when SSL communication has been negotiated and established.

EVENT_OPEN_FILE

22

Raised right before a file is opened.

EVENT_FILE_OPENED

23

Raised when a file has been successfully opened.

EVENT_DATA_READ

24

Raised when data has been read from a file.

EVENT_DATA_WRITTEN

25

Raised when data has been written to a file.

EVENT_MAP

Event Map Hash

This constant is a hash that maps event numbers to string descriptions as described in this table.


Table 4.7. Event Map Hash Constant

Key

String Value

EVENT_PACKET_READ ("1")

"PACKET_READ"

EVENT_PACKET_SENT ("2")

"PACKET_SENT"

EVENT_HTTP_CONTENT_LENGTH ("3")

"HTTP_CONTENT_LENGTH"

EVENT_HTTP_CHUNKED_START ("4")

"HTTP_CHUNKED_START"

EVENT_HTTP_CHUNKED_END ("5")

"HTTP_CHUNKED_END"

EVENT_HTTP_REDIRECT ("6")

"HTTP_REDIRECT"

EVENT_CHANNEL_CLOSED ("7")

"CHANNEL_CLOSED"

EVENT_DELETED ("8")

"DELETED"

EVENT_FTP_SEND_MESSAGE ("9")

"FTP_SEND_MESSAGE"

EVENT_FTP_MESSAGE_RECEIVED ("10")

"FTP_MESSAGE_RECEIVED"

EVENT_HOSTNAME_LOOKUP ("11")

"HOSTNAME_LOOKUP"

EVENT_HOSTNAME_RESOLVED ("12")

"HOSTNAME_RESOLVED"

EVENT_HTTP_SEND_MESSAGE ("13")

"HTTP_SEND_MESSAGE"

EVENT_HTTP_MESSAGE_RECEIVED ("14")

"HTTP_MESSAGE_RECEIVED"

EVENT_HTTP_FOOTERS_RECEIVED ("15")

"HTTP_FOOTERS_RECEIVED"

EVENT_HTTP_CHUNKED_DATA_RECEIVED ("16")

"HTTP_CHUNKED_DATA_RECEIVED"

EVENT_HTTP_CHUNK_SIZE ("17")

"HTTP_CHUNK_SIZE"

EVENT_CONNECTING ("18")

"CONNECTING"

EVENT_CONNECTED ("19")

"CONNECTED"

EVENT_START_SSL ("20")

"START_SSL"

EVENT_SSL_ESTABLISHED ("21")

"SSL_ESTABLISHED"

EVENT_OPEN_FILE ("22")

"OPEN_FILE"

EVENT_FILE_OPENED ("23")

"FILE_OPENED"

EVENT_DATA_READ ("24")

"DATA_READ"

EVENT_DATA_WRITTEN ("25")

"DATA_WRITTEN"


Table 4.8. Event Source Constants

Name

Description

SOURCE_SOCKET

For events raised from the Socket class.

SOURCE_HTTPCLIENT

For events raised from the HTTPClient class.

SOURCE_FTPCLIENT

For events raised from the FtpClient class.

SOURCE_FILE

For events raised from the File class.


Table 4.9. Network Address Type Constants

Name

Description

AF_INET

Designates an IPv4 network addresses.

AF_INET6

Designates an IPv6 network addresses.

AF_UNIX

Designates a local socket file name (interchangeable with AF_LOCAL.

AF_LOCAL

POSIX synonym for AF_UNIX; designates a local socket file name.


Table 4.10. Terminal Attributes Local Mode Constants

Name

Description

ECHOKE

visual erase for line kill

ECHOE

visually erase chars

ECHO

enable echoing

ECHONL

echo NL even if ECHO is off

ECHOPRT

visual erase mode for hardcopy

ISIG

enable signals INTR, QUIT, [D]SUSP

ICANON

canonicalize input lines

IEXTEN

enable DISCARD and LNEXT

TOSTOP

stop background jobs from output

FLUSHO

output being flushed (state)

PENDIN

retype pending input (state)

NOFLSH

don't flush after interrupt

ALTWERASE

use alternate WERASE algorithm (this constant is only available on some systems; do not use in portable programs)

EXTPROC

external processing (this constant is only available on some systems; do not use in portable programs)

NOKERNINFO

no kernel output from VSTATUS (this constant is only available on some systems; do not use in portable programs)


Table 4.11. Terminal Attributes Control Mode Constants

Name

Description

CSIZE

character size mask

CS5

5 bits (pseudo)

CS6

6 bits

CS7

7 bits

CS8

8 bits

CSTOPB

send 2 stop bits

CREAD

enable receiver

PARENB

parity enable

PARODD

odd parity, else even

HUPCL

hang up on last close

CLOCAL

ignore modem status lines

CCTS_OFLOW

CTS flow control of output (this constant is only available on some systems; do not use in portable programs)

CRTSCTS

same as CCTS_OFLOW (this constant is only available on some systems; do not use in portable programs)

CRTS_IFLOW

RTS flow control of input (this constant is only available on some systems; do not use in portable programs)

MDMBUF

flow control output via Carrier (this constant is only available on some systems; do not use in portable programs)


Table 4.12. Terminal Attributes Output Mode Constants

Name

Description

OPOST

enable following output processing

ONLCR

map NL to CR-NL (ala CRMOD)

OCRNL

map CR to NL

ONOCR

No CR output at column 0

ONLRET

NL performs CR function

OXTABS

expand tabs to spaces (this constant is only available on some systems; do not use in portable programs)

ONOEOT

discard EOT's ctrl-D on output (this constant is only available on some systems; do not use in portable programs)

OLCUC

translate lower case to upper case (this constant is only available on some systems; do not use in portable programs)


Table 4.13. Terminal Attributes Input Mode Constants

Name

Description

IGNBRK

ignore BREAK condition

BRKINT

map BREAK to SIGINTR

IGNPAR

ignore (discard) parity errors

PARMRK

mark parity and framing errors

INPCK

enable checking of parity errors

ISTRIP

strip 8th bit off chars

INLCR

map NL into CR

IGNCR

ignore CR

ICRNL

map CR to NL (ala CRMOD)

IXON

enable output flow control

IXOFF

enable input flow control

IXANY

any char will restart after stop

IMAXBEL

ring bell on input queue full

IUCLC

translate upper case to lower case (this constant is only available on some systems; do not use in portable programs)


Table 4.14. Terminal Attributes Control Character Constants

Name

Special Character

Default Value

VEOF

EOF

^D

VEOL

EOL

_POSIX_VDISABLE

VEOL2

EOL2

_POSIX_VDISABLE

VERASE

ERASE

^? `177'

VWERASE

WERASE

^W

VKILL

KILL

^U

VINTR

INTR

^C

VQUIT

QUIT

^\ `34'

VSUSP

SUSP

^Z

VSTART

START

^Q

VSTOP

STOP

^S

VLNEXT

LNEXT

^V

VMIN

n/a

1

VTIME

n/a

0

VREPRINT

REPRINT

^R (this constant is only available on some systems; do not use in portable programs)

VDSUSP

DSUSP

^Y (this constant is only available on some systems; do not use in portable programs)

VDISCARD

DISCARD

^O (this constant is only available on some systems; do not use in portable programs)

VSTATUS

n/a

^T (this constant is only available on some systems; do not use in portable programs)


The X509_VerificationReasons_Hash is a constant in the Qore namespace that maps verfication code strings (as returned from FtpClient::verifyPeerCertificate() and Socket::verifyPeerCertificate()) to textual descriptions.

Table 4.15. X506_VerificationReasons Hash

Key

Value

X509_V_OK

OK

X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT

Unable to get issuer certificate

X509_V_ERR_UNABLE_TO_GET_CRL

Unable to get certificate CRL

X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE

Unable to decrypt certificate's signature. This means that the actual signature value could not be determined rather than it not matching the expected value; this is only meaningful for RSA

X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE

Unable to decrypt CRL's signature

X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY

Unable to decode issuer public key (SubjectPublicKeyInfo)

X509_V_ERR_CERT_SIGNATURE_FAILURE

Certificate signature failure; the signature of the certificate is invalid

X509_V_ERR_CRL_SIGNATURE_FAILURE

CRL signature failure; the signature of the certificate is invalid

X509_V_ERR_CERT_NOT_YET_VALID

Certificate is not yet valid

X509_V_ERR_CERT_HAS_EXPIRED

Certificate has expired

X509_V_ERR_CRL_NOT_YET_VALID

CRL is not yet valid

X509_V_ERR_CRL_HAS_EXPIRED

CRL has expired

X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD

Format error in certificate's notBefore field (invalid time)

X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD

Format error in certificate's notAfter field (invalid time)

X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD

Format error in CRL's lastUpdate field (invalid time)

X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD

Format error in CRL's nextUpdate field (invalid time)

X509_V_ERR_OUT_OF_MEM

Out of memory error

X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT

Certificate is self-signed and cannot be found in the trusted list

X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN

Self signed certificate in certificate chain

X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY

Unable to get local issuer certificate. This normally means the list of trusted certificates is not complete

X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE

Unable to verify the first certificate

X509_V_ERR_CERT_CHAIN_TOO_LONG

Certificate chain too long

X509_V_ERR_CERT_REVOKED

Certificate has been revoked

X509_V_ERR_INVALID_CA

Invalid CA certificate

X509_V_ERR_PATH_LENGTH_EXCEEDED

The basicConstraints pathlength parameter has been exceeded

X509_V_ERR_INVALID_PURPOSE

The certificate cannot be used for the specified purpose

X509_V_ERR_CERT_UNTRUSTED

Root CA is not marked as trusted for the specified purpose

X509_V_ERR_CERT_REJECTED

Root CA is marked to reject the specified purpose

X509_V_ERR_SUBJECT_ISSUER_MISMATCH

The current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate

X509_V_ERR_AKID_SKID_MISMATCH

The current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier of the current certificate

X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH

Issuer name and serial number of candidate certificate do not match the authority key identifier of the current certificate

X509_V_ERR_KEYUSAGE_NO_CERTSIGN

The keyUsage extension does not permit certificate signing

X509_V_ERR_APPLICATION_VERIFICATION

Verification failure


The following gives a list of signal constants that may be present in Qore. Signal constants and their values are system-dependent; only signals that the host system defines will be present in Qore, therefore not all of the signals in the following list will be present in any given version of Qore.

Table 4.16. Signal Constants in the Qore Namespace

Name

Description

SIGHUP

Hangup signal.

SIGINT

Interrupt signal.

SIGQUIT

Quit signal.

SIGILL

Illegal instruction signal.

SIGTRAP

Trace trap signal.

SIGABRT

Abort signal.

SIGPOLL

Pollable event signal.

SIGIOT

Synonym for SIBABRT

SIGEMT

EMT instruction signal.

SIGFPE

Floating-point exception signal.

SIGKILL

Kill signal (cannot be caught)

SIGBUS

Bus error signal.

SIGSEGV

Segmentation violation signal.

SIGSYS

Bad arugment to a system call.

SIGPIPE

Write on pipe with no reader (this signal is always ignored in Qore).

SIGALRM

Alarm clock signal.

SIGTERM

Software termination signal.

SIGURG

Urgent condition on I/O channel.

SIGSTOP

Sendable stop signal (not from tty).

SIGTSTP

Stop signal from tty.

SIGCONT

Continue a stopped process.

SIGCHLD

To parent on child stop or exit.

SIGTTIN

To reader's process group on background tty read.

SIGTTOU

To writer's process group on background tty write.

SIGIO

Input/Output possible signal.

SIGXCPU

Exceeded CPU time limit.

SIGXFSZ

Exceeded file size limit.

SIGVTALRM

Virtual time alarm signal.

SIGPROF

Profiling time alarm signal.

SIGWINCH

Window size changes signal.

SIGINFO

Information request signal.

SIGUSR1

User-defined signal 1.

SIGUSR2

User-defined signal 2.

SIGSTKFLT

Stack fault on coprocessor.

SIGCLD

Synonym for SIGCHLD on some systems.

SIGPWR

Power failure signal.

SIGLOST

Resource (ex: file lock) lost signal.

SIGWAITING

(Solaris) Waiting signal.

SIGLWP

(Solaris) Light-weight process (thread) signal.

SIGFREEZE

(Solaris) Checkpoint freeze signal.

SIGTHAW

(Solaris) Checkpoint freeze thaw signal.

SIGCANCEL

(Solaris) Cancel signal.

SIGXRES

(Solaris) Resource control exceeded.

SIGJVM1

(Solaris) Java virtual machine 1 signal.

SIGJVM2

(Solaris) Java virtual machine 2 signal.


There are two special system-specific constants mapping signal names to signal number and vice-versa as given in the following table.

Table 4.17. Signal Mapping Hash Constants in the Qore Namespace

Name

Description

SignalToName

A hash mapping signal numbers to signal names (ex: SignalToName."1" gives the signal name corresponding to signal number 1).

NameToSignal

A hash mapping signal names to signal numbers (ex: NameToSignal."SIGINT" gives the signal number corresponding to "SIGINT").


The Err namespace contains error constants, returned by the errno() function.

Table 4.18. Error Constants in the Err Namespace

Name

Type

Description

Err::*

Integer

System-dependent integer ERRNO constants (ex: ENOMEM, etc)


Table 4.19. Exception Constants in the Qore Namespace

Name

Type

Description

ET_System

String

Exception Type System: used for system exceptions.

ET_User

String

Exception Type User: used for user exceptions (thrown using the throw statement.

CT_User

Integer

Call Type User: used for user function/method calls in a call stack.

CT_Builtin

Integer

Call Type Builtin: used for builtin function/method calls in a call stack.

CT_NewThread

Integer

Call Type New Thread: used in a call stack when a new thread is started with the background expression.

CT_Rethrow

Integer

Call Type Rethrow: a marker for a rethrown exception in a call stack.


Table 4.20. Regular Expression Option Constants in the Qore Namespace

Name

Type and Value

Description

RE_Caseless

Integer: 1

Ignores case when matching regular expressions, equivalent to /i

RE_MultiLine

Integer: 2

makes start-of-line (^) or end-of-line ($) match after or before any newline in the subject string, equivalent to /m

RE_DotAll

Integer: 4

makes a dot (.) match a newline character, equivalent to /s

RE_Extended

Integer: 8

ignores whitespace characters and enables comments prefixed by #, equivalent to /x