Chapter I. ZZZ Server

ZZZ Server is a socket and http multiuser server implemented for different operating systems - Windows, Mac OS X, Linux (including for Raspberry PI). It can be accessed through a browser or other applications written on different programming languages. There are variants that support TLS encrypted connections, which will not be considered in the current edition of the book.

System requirements:

Self-application - does not require the installation of additional software.

Command line

Sample command line:

For Windows

ZZZServer.exe -p 80 -s 100

ZZZServer.exe - startup file

For Linux or for Mac OS X

./ZZZServer -p 80 -s 100

ZZZServer - startup file

-p 80 – 80 is the port number on which the server is listening.

-s 100 – 100 is the maximum number of program steps to be implemented by server for the active client before moving to the next.

Description of other parameters set by the command line at ZZZ Server startup:

-p - sets the number of the port, on which listens server the default value is 3333;

-d - sets the directory for a served documents the default value is www;

-c - maximum number of clients simultaneously processed by the server, default value is 100;

-s - the maximum number of program steps that the server performs for the active client before moving to the next, default value is 30;

-h - outputs help information;

-l - sets the beginning of the log file names, may include a folder name, but if the folder does not exist does not create it. By default, it does not make log files;

-lf - sets the time format to the name of the log files. Default is -%Y-%m-%d-%H.log;

Possible format codes are:

-ban - prohibits various activities:

-ban base create - prohibits the creation of new bases. Useful when the server should only work with pre-created databases;

-ban base write - except that it prohibits the creation of new bases, prohibits and writing in existing databases managed by the server. Allows only read from the bases. Useful in reference systems or when the contents of the bases must remain unchanged;

The following options are not recommended to be included for the ZZZ Server, which is visible on the Internet.

-system - allowing system commands by default is off;

-write - allows commands for files writing by default is off.

Selecting a folder from which the ZZZ Server reads does through the configuration file zzzserver.cfg.

It should be located in the server's work folder and contains consecutive rows with a host name followed by the equal sign and folder name.

The host name may end with a colon and a port number.

For hosts not specified in the configuration file, hosts that serve the server are used the default folder www or specified with the option -d from the command line.

In this way, one ZZZ Server can serve multiple hosts.

One example zzzserver.cfg file is as follows:

kasovbon.zzz.bg=wwwkasovbon
www.kasovbon.zzz.bg=wwwkasovbon

Managing language

The control language is a TTM implementation with built-in commands to manage ZZZ bases, connect to other servers, and work with "live" objects.

The TTM language is a recursive functional macro language (similar to Lisp) that can be used in artificial intelligence systems.

General

The TTM language interpreter processes a text sequence in the following simple way:
The following TTM program displays the message ‘Hello World from ZZZ Server!’

The command cout pulls a string.

Commands

The syntax of commands is:

#[command;parameter1;parameter2;...;parameterN] - active command, ie. the result is interpreted again

##[command;parameter1;parameter2;...;parameterN] - Passive command, ie. the result is returned without being interpreted

The number of parameters is unlimited, if the parameter has a semicolon it must be enclosed in square brackets.

The description of the commands is as follows: command name, command action, parameters, if any, for example use in active mode (similar use in passive mode, then there is a command in front of the command has ##).

ATTENTION:
You can execute the commands by pressing the button [Run] under the sample program code.

Basic commands

cout+

Turn on tracing.

No parameters.

cout-

Turn off tracing.

No parameters.

=

Defines a global string.

The first parameter is the name of the variable in which the string is remembered, and the second is the string itself.

.=

Defines a string for the corresponding area of vision.

The first parameter is the name of the variable in which the string is remembered, and the second is the string itself.
It is recommended to use the current function to use = wherever possible, especially when working with classes!

.v

Sets the visibility level.

The first parameter is the level as a number.

.^

Reads the level of visibility.

.+

Increases level of visibility by unit.

.-

Reduces level of visibility by unit.

cout

Prints a string on the console and outputs it to the resulting buffer.

The function has one parameter - a text string to be displayed.

out

Returns a string to the resulting buffer without printing it on the console.

The function has one parameter - the string to be displayed.
This feature is faster than cout because it does not waste time for printing on the console!

+

Collect two numbers with double precision.

The first and second parameters are collections.
The third non-mandatory parameter is decimal precision, which is 17 by default.

-

Removes two numbers with double precision.

The first parameter is the diminutive, the second diminator.
The third non-mandatory parameter is decimal precision, which is 17 by default.

*

Multiplies two numbers with double precision.

The first and second parameters are multipliers.
The third non-mandatory parameter is decimal precision, which is 17 by default.

/

Delivers two numbers with double precision.

The first parameter is divisible and the second is the divisor.
The third non-mandatory parameter is decimal precision, which is 17 by default.

==

Compares the first two parameters as strings and if they are equal - performs the third, if different - the fourth.

==n

Compares the first two parameters as numbers and if they are equal - performs the third, if different - the fourth.

>=

Compares the first two parameters as strings and if the first one is larger or equal to the second - performs the third, otherwise executes the fourth.

>=n

Compares the first two parameters as numbers and if the first one is larger or equal to the second - performs the third, otherwise executes the fourth.

=.

Segments a string

Used to segment a string defined by the = command to replace the text in the defined string with the relevant parameters of the command and numbers them according to their sequence.

#[...]

Executes a string defined by = replacing the parameters segmented with =.

##[...]

Returns a string defined by =

is

Replaces the text in the first parameter that matches the second parameter with the text of the third

ˆ.

Reads another string from a string defined by =.

The first parameter is the name of the defined string.
The second parameter is the result of a failure.

=x

Deletes the string name defined by =

=x..

Deletes all string names defined with =

x*v

Position the pointer to the current symbol at the beginning of a segment with a specified name

The first parameter is the name of the string containing the segment.
The second parameter is the segment name, after which we have to position the pointer to the current symbol.
The third parameter is the result if there are no more segments.

*0

Position the pointer to the current symbol at the beginning of a string defined by =

ta

Compares two UNICODE strings and determines if the first is greater than or equal to the second one in alphabetical order

chr

Converts a number to a unicode

tcn

Converts a unicode character to a hexadecimal number

ˆ..

Reads the n symbol from a string defined by = or if the end of a string is reached returns the last parameter (#[ˆ..;name;n;{after end}])

ˆ(..*

Reads a string defined by a = string from its start to the directory

ˆ*..)

Reads a string defined by = from the directory to the end of it

Reads a pointer defined by a = string

*v

Sets the pointer to a string defined by =

(..)

Returns the length in characters to a string defined by =

(.)

Returns the string length in symbols

trf

Replaces the first encounter with the second one

ts

Copies a segment between two strings of a string defined by =

tt

Test for availability of text in a string defined by =

ttc

Test for availability of text in a string defined by =, no matter uppercase and lowercase

|

Performs OR between two integers

&

Performs AND between two integers

~

Performs EXCLUSIVE OR over its argument

ln

Displays a list of defined names with = listed names are divided by the specified parameter (list named)

existsf

Checks for the presence of a defined name

df

Deletes a file (delete file)

It only works if the -write option is enabled from the command line of the PST server!
The first parameter is the file name.
The second parameter is the result of a failure.

oi

Opens a file to read (open input)

The first parameter is a descriptor of the file.
The second parameter is the file name.
The third parameter is the result of failure.

oo

Opens a file for writing (open output)

It only works if the -write option is enabled from the command line of the PST server!
The first parameter is a descriptor of the file.
The second parameter is the file name.
The third parameter is the result of failure.

oa

Opens a file for appending (open append)

It only works if the -write option is enabled from the command line of the PST server!
The first parameter is a descriptor of the file.
The second parameter is the file name.
The third parameter is the result of failure.

cf

Closes a file (close file)

The first parameter is a descriptor of the file.

frs

Reads string from file to default meta symbol (file read string)

frc

Reads a symbol from file (file read char)

fcm

Changes the default meta symbol (file change meta)

fps

Stores a string in a file (file print string)

load

Loads a file as on active call interpreting it

The first parameter is the file name.
The second parameter is the result of a failure.

system

Performs a command from the operating system

Works only if option -system is on from the command line of ZZZ Server!
The first parameter is the command along with its parameters.

s2us

Converts a string to a string with unicode codes (string to unicode string)

#

Used to insert comments (null command)

exit

Stop interpreting

Additional useful features

fmtl

Formats a long integer using a standard string formatting as in sprintf from C/C++

The first parameter is the format string.
The second parameter is the number to be formatted.

refmtl

Reformats a long integer using a command string formatting as in sprintf from C/C++.

With this command, for example, one number can be quickly converted from 16-bit to 10-bit.
The first two parameters are formatting strings.
The third parameter is the number to be reformatted.

fmtd

Forms a real, double number using a command string formatting as in sprintf from C/C++

The first parameter is the format string.
The second parameter is the number to be formatted.

getTime

Returns the number of milliseconds from January 1, 1970., 00:00:00 GMT

fmtTime

Formats time

The first parameter is the format string.
The second parameter is the time in milliseconds.

getFileTime

Returns the time since the last modification of a file, in milliseconds

The first parameter is the path to the file.

getFileSize

Returns the file size

The first parameter is the path to the file.

outLoadBinary

Returns a file in binary format

The first parameter is the path to the file.
The second parameter is the result that returns in the event of an error.

base64LoadBinary

Encodes a file in base64

The first parameter is the path to the file.
The second parameter is the result that returns in the event of an error.

base64SaveBinary

Records a binary file by decoding it from base64

Works only if option is on -write from the command line of the ZZZ Server!
The first parameter is the path to the file.
The second parameter is the content encoded in base64.

^UID

Returns a unique identifier

BuffersGetState

Returns information about file buffering from the server

RegEx

Applies a regular expression to a string

The first parameter is the regular expression.
The second parameter is a string to be applied to.
The third optional parameter is IGNORE_CASE, at any other value, distinguishes between upper and lower case.
The fourth non-mandatory parameter is the beginning of a defined name in which to remember the matches found.
The fifth optional parameter is the maximum number of matches.

Returns a number greater than 0 when it is successful.
Returns defined names with open matches starting with the specified name from the fourth parameter and ending with an index of 0 to the number of matches found, not greater than the fifth parameter.

MD5

Calculates a checksum MD5

The first parameter is the string for which the checksum is calculated.

Returns the calculated checksum.

SHA1

Calculates checksum SHA1

The first parameter is the string for which the checksum is calculated.

Returns the calculated checksum.

SHA256

Calculates checksum SHA256

The first parameter is the string for which the checksum is calculated.

Returns the calculated checksum.

outBase64Decode

Adds the base64 decoding result of the first parameter to the output buffer

The first parameter is a string encoded in base64 to be decoded.

When successful, it returns the length of the decode result.

rand

Generates a random number in a set interval and start value

The first parameter is the interval - integer.
The second parameter is the start value.

append

Adds a string to a defined string

The first parameter is the name of the defined string.
The second parameter is the string added

lShiftBits

Moves the bits of the assigned number to the left

The first parameter is the number.
The second parameter is the offset in the range 0 to 63.

rShiftBits

Moves the bits of the assigned number to the right

The first parameter is the number.
The second parameter is the offset in the range 0 to 63.
  • countBits - 82
  • countBits

    Determines the number of raised bits in a number

    The first parameter is the number.