Cari di RHE Linux 
    RHE Linux User Manual
Daftar Isi
(Sebelumnya) 22 : Chapter 11. Networking Ta ...23 : V2V Guide (Berikutnya)

SystemTap Tapset Reference

Chapter 14. Signal Tapset

probe::signal.send - Signal being sent to a process
probe::signal.send.return - Signal being sent to a process completed
probe::signal.checkperm - Check being performed on a sent signal
probe::signal.checkperm.return - Check performed on a sent signal completed
probe::signal.wakeup - Sleeping process being wakened for signal
probe::signal.check_ignored - Checking to see signal is ignored
probe::signal.check_ignored.return - Check to see signal is ignored completed
probe::signal.force_segv - Forcing send of SIGSEGV
probe::signal.force_segv.return - Forcing send of SIGSEGV complete
probe::signal.syskill - Sending kill signal to a process
probe::signal.syskill.return - Sending kill signal completed
probe::signal.sys_tkill - Sending a kill signal to a thread
probe::signal.systkill.return - Sending kill signal to a thread completed
probe::signal.sys_tgkill - Sending kill signal to a thread group
probe::signal.sys_tgkill.return - Sending kill signal to a thread group completed
probe::signal.send_sig_queue - Queuing a signal to a process
probe::signal.send_sig_queue.return - Queuing a signal to a process completed
probe::signal.pending - Examining pending signal
probe::signal.pending.return - Examination of pending signal completed
probe::signal.handle - Signal handler being invoked
probe::signal.handle.return - Signal handler invocation completed
probe::signal.do_action - Examining or changing a signal action
probe::signal.do_action.return - Examining or changing a signal action completed
probe::signal.procmask - Examining or changing blocked signals
probe::signal.procmask.return - Examining or changing blocked signals completed
probe::signal.flush - Flushing all pending signals for a task

This family of probe points is used to probe signal activities. It contains the following probe points:

Name

probe::signal.send - Signal being sent to a process

Synopsis

signal.send

Values

send2queue

Indicates whether the signal is sent to an existing sigqueue
name

The name of the function used to send out the signal
task

A task handle to the signal recipient
sinfo

The address of siginfo struct
si_code

Indicates the signal type
sig_name

A string representation of the signal
sig

The number of the signal
shared

Indicates whether the signal is shared by the thread group
sig_pid

The PID of the process receiving the signal
pid_name

The name of the signal recipient

Context

The signal's sender.

Name

probe::signal.send.return - Signal being sent to a process completed

Synopsis

signal.send.return

Values

retstr

The return value to either __group_send_sig_info, specific_send_sig_info, or send_sigqueue
send2queue

Indicates whether the sent signal was sent to an existing sigqueue
name

The name of the function used to send out the signal
shared

Indicates whether the sent signal is shared by the thread group.

Context

The signal's sender. (correct?)

Description

Possible __group_send_sig_info and specific_send_sig_info return values are as follows;

0 -- The signal is sucessfully sent to a process,

which means that

(1) the signal was ignored by the receiving process, (2) this is a non-RT signal and the system already has one queued, and (3) the signal was successfully added to the sigqueue of the receiving process.

-EAGAIN -- The sigqueue of the receiving process is overflowing, the signal was RT, and the signal was sent by a user using something other than kill.

Possible send_group_sigqueue and send_sigqueue return values are as follows;

0 -- The signal was either sucessfully added into the sigqueue of the receiving process, or a SI_TIMER entry is already queued (in which case, the overrun count will be simply incremented).

1 -- The signal was ignored by the receiving process.

-1 -- (send_sigqueue only) The task was marked exiting, allowing * posix_timer_event to redirect it to the group leader.

Name

probe::signal.checkperm - Check being performed on a sent signal

Synopsis

signal.checkperm

Values

name

Name of the probe point
task

A task handle to the signal recipient
sinfo

The address of the siginfo structure
si_code

Indicates the signal type
sig_name

A string representation of the signal
sig

The number of the signal
pid_name

Name of the process receiving the signal
sig_pid

The PID of the process receiving the signal

Name

probe::signal.checkperm.return - Check performed on a sent signal completed

Synopsis

signal.checkperm.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.wakeup - Sleeping process being wakened for signal

Synopsis

signal.wakeup

Values

resume

Indicates whether to wake up a task in a STOPPED or TRACED state
state_mask

A string representation indicating the mask of task states to wake. Possible values are TASK_INTERRUPTIBLE, TASK_STOPPED, TASK_TRACED, and TASK_INTERRUPTIBLE.
pid_name

Name of the process to wake
sig_pid

The PID of the process to wake

Name

probe::signal.check_ignored - Checking to see signal is ignored

Synopsis

signal.check_ignored

Values

sig_name

A string representation of the signal
sig

The number of the signal
pid_name

Name of the process receiving the signal
sig_pid

The PID of the process receiving the signal

Name

probe::signal.check_ignored.return - Check to see signal is ignored completed

Synopsis

signal.check_ignored.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.force_segv - Forcing send of SIGSEGV

Synopsis

signal.force_segv

Values

name

Name of the probe point
sig_name

A string representation of the signal
sig

The number of the signal
pid_name

Name of the process receiving the signal
sig_pid

The PID of the process receiving the signal

Name

probe::signal.force_segv.return - Forcing send of SIGSEGV complete

Synopsis

signal.force_segv.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.syskill - Sending kill signal to a process

Synopsis

signal.syskill

Values

name

Name of the probe point
sig_name

A string representation of the signal
sig

The specific signal sent to the process
pid_name

The name of the signal recipient
sig_pid

The PID of the process receiving the signal

Name

probe::signal.syskill.return - Sending kill signal completed

Synopsis

signal.syskill.return

Values

None

Name

probe::signal.sys_tkill - Sending a kill signal to a thread

Synopsis

signal.sys_tkill

Values

name

Name of the probe point
sig_name

A string representation of the signal
sig

The specific signal sent to the process
pid_name

The name of the signal recipient
sig_pid

The PID of the process receiving the kill signal

Description

The tkill call is analogous to kill(2), except that it also allows a process within a specific thread group to be targeted. Such processes are targeted through their unique thread IDs (TID).

Name

probe::signal.systkill.return - Sending kill signal to a thread completed

Synopsis

signal.systkill.return

Values

retstr

The return value to either __group_send_sig_info,
name

Name of the probe point

Name

probe::signal.sys_tgkill - Sending kill signal to a thread group

Synopsis

signal.sys_tgkill

Values

name

Name of the probe point
sig_name

A string representation of the signal
sig

The specific kill signal sent to the process
tgid

The thread group ID of the thread receiving the kill signal
pid_name

The name of the signal recipient
sig_pid

The PID of the thread receiving the kill signal

Description

The tgkill call is similar to tkill, except that it also allows the caller to specify the thread group ID of the thread to be signalled. This protects against TID reuse.

Name

probe::signal.sys_tgkill.return - Sending kill signal to a thread group completed

Synopsis

signal.sys_tgkill.return

Values

retstr

The return value to either __group_send_sig_info,
name

Name of the probe point

Name

probe::signal.send_sig_queue - Queuing a signal to a process

Synopsis

signal.send_sig_queue

Values

sigqueue_addr

The address of the signal queue
name

Name of the probe point
sig_name

A string representation of the signal
sig

The queued signal
pid_name

Name of the process to which the signal is queued
sig_pid

The PID of the process to which the signal is queued

Name

probe::signal.send_sig_queue.return - Queuing a signal to a process completed

Synopsis

signal.send_sig_queue.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.pending - Examining pending signal

Synopsis

signal.pending

Values

name

Name of the probe point
sigset_size

The size of the user-space signal set
sigset_add

The address of the user-space signal set (sigset_t)

Description

This probe is used to examine a set of signals pending for delivery to a specific thread. This normally occurs when the do_sigpending kernel function is executed.

Name

probe::signal.pending.return - Examination of pending signal completed

Synopsis

signal.pending.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.handle - Signal handler being invoked

Synopsis

signal.handle

Values

regs

The address of the kernel-mode stack area
sig_code

The si_code value of the siginfo signal
name

Name of the probe point
sig_mode

Indicates whether the signal was a user-mode or kernel-mode signal
sinfo

The address of the siginfo table
sig_name

A string representation of the signal
oldset_addr

The address of the bitmask array of blocked signals
sig

The signal number that invoked the signal handler
ka_addr

The address of the k_sigaction table associated with the signal

Name

probe::signal.handle.return - Signal handler invocation completed

Synopsis

signal.handle.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.do_action - Examining or changing a signal action

Synopsis

signal.do_action

Values

sa_mask

The new mask of the signal
name

Name of the probe point
sig_name

A string representation of the signal
oldsigact_addr

The address of the old sigaction struct associated with the signal
sig

The signal to be examined/changed
sa_handler

The new handler of the signal
sigact_addr

The address of the new sigaction struct associated with the signal

Name

probe::signal.do_action.return - Examining or changing a signal action completed

Synopsis

signal.do_action.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.procmask - Examining or changing blocked signals

Synopsis

signal.procmask

Values

how

Indicates how to change the blocked signals; possible values are SIG_BLOCK=0 (for blocking signals), SIG_UNBLOCK=1 (for unblocking signals), and SIG_SETMASK=2 for setting the signal mask.
name

Name of the probe point
oldsigset_addr

The old address of the signal set (sigset_t)
sigset

The actual value to be set for sigset_t (correct?)
sigset_addr

The address of the signal set (sigset_t) to be implemented

Name

probe::signal.procmask.return - Examining or changing blocked signals completed

Synopsis

signal.procmask.return

Values

retstr

Return value as a string
name

Name of the probe point

Name

probe::signal.flush - Flushing all pending signals for a task

Synopsis

signal.flush

Values

name

Name of the probe point
task

The task handler of the process performing the flush
pid_name

The name of the process associated with the task performing the flush
sig_pid

The PID of the process associated with the task performing the flush

Chapter 15. Directory-entry (dentry) Tapset

function::d_name - get the dirent name
function::reverse_path_walk - get the full dirent path
function::task_dentry_path - get the full dentry path
function::d_path - get the full nameidata path

This family of functions is used to map kernel VFS directory entry pointers to file or full path names.

Name

function::d_name - get the dirent name

Synopsis

function d_name:string(dentry:long)

Arguments

dentry

Pointer to dentry.

Description

Returns the dirent name (path basename).

Name

function::reverse_path_walk - get the full dirent path

Synopsis

function reverse_path_walk:string(dentry:long)

Arguments

dentry

Pointer to dentry.

Description

Returns the path name (partial path to mount point).

Name

function::task_dentry_path - get the full dentry path

Synopsis

function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)

Arguments

task

task_struct pointer.
dentry

direntry pointer.
vfsmnt

vfsmnt pointer.

Description

Returns the full dirent name (full path to the root), like the kernel d_path function.

Name

function::d_path - get the full nameidata path

Synopsis

function d_path:string(nd:long)

Arguments

nd

Pointer to nameidata.

Description

Returns the full dirent name (full path to the root), like the kernel d_path function.

Chapter 16. Logging Tapset

function::log - Send a line to the common trace buffer.
function::warn - Send a line to the warning stream.
function::exit - Start shutting down probing script.
function::error - Send an error message.
function::ftrace - Send a message to the ftrace ring-buffer.

This family of functions is used to send simple message strings to various destinations.

Name

function::log - Send a line to the common trace buffer.

Synopsis

function log(msg:string)

Arguments

msg

The formatted message string.

General Syntax

log(msg:string)

Description

This function logs data. log sends the message immediately to staprun and to the bulk transport (relayfs) if it is being used. If the last character given is not a newline, then one is added. This function is not as effecient as printf and should be used only for urgent messages.

Name

function::warn - Send a line to the warning stream.

Synopsis

function warn(msg:string)

Arguments

msg

The formatted message string.

General Syntax

warn (msg:string)

Description

This function sends a warning message immediately to staprun. It is also sent over the bulk transport (relayfs) if it is being used. If the last characater is not a newline, the one is added.

Name

function::exit - Start shutting down probing script.

Synopsis

function exit()

Arguments

None

General Syntax

exit

Description

This only enqueues a request to start shutting down the script. New probes will not fire (except "end" probes), but all currently running ones may complete their work.

Name

function::error - Send an error message.

Synopsis

function error(msg:string)

Arguments

msg

The formatted message string.

Description

An implicit end-of-line is added. staprun prepends the string "ERROR:". Sending an error message aborts the currently running probe. Depending on the MAXERRORS parameter, it may trigger an exit.

Name

function::ftrace - Send a message to the ftrace ring-buffer.

Synopsis

function ftrace(msg:string)

Arguments

msg

The formatted message string.

Description

If the ftrace ring-buffer is configured & available, see /debugfs/tracing/trace for the message. Otherwise, the message may be quietly dropped. An implicit end-of-line is added.

Chapter 17. Random functions Tapset

function::randint - Return a random number between [0,n)

These functions deal with random number generation.

Name

function::randint - Return a random number between [0,n)

Synopsis

function randint:long(n:long)

Arguments

n

Number past upper limit of range, not larger than 2**20.

Chapter 18. String and data retrieving functions Tapset

function::kernel_string - Retrieves string from kernel memory.
function::kernel_string2 - Retrieves string from kernel memory with alternative error string.
function::kernel_string_n - Retrieves string of given length from kernel memory.
function::kernel_long - Retrieves a long value stored in kernel memory.
function::kernel_int - Retrieves an int value stored in kernel memory.
function::kernel_short - Retrieves a short value stored in kernel memory.
function::kernel_char - Retrieves a char value stored in kernel memory.
function::kernel_pointer - Retrieves a pointer value stored in kernel memory.
function::user_string - Retrieves string from user space.
function::user_string2 - Retrieves string from user space with alternative error string.
function::user_string_warn - Retrieves string from user space.
function::user_string_quoted - Retrieves and quotes string from user space.
function::user_string_n - Retrieves string of given length from user space.
function::user_string_n2 - Retrieves string of given length from user space.
function::user_string_n_warn - Retrieves string from user space.
function::user_string_n_quoted - Retrieves and quotes string from user space.
function::user_short - Retrieves a short value stored in user space.
function::user_short_warn - Retrieves a short value stored in user space.
function::user_int - Retrieves an int value stored in user space.
function::user_int_warn - Retrieves an int value stored in user space.
function::user_long - Retrieves a long value stored in user space.
function::user_long_warn - Retrieves a long value stored in user space.
function::user_char - Retrieves a char value stored in user space.
function::user_char_warn - Retrieves a char value stored in user space.

Functions to retrieve strings and other primitive types from the kernel or a user space programs based on addresses. All strings are of a maximum length given by MAXSTRINGLEN.

Name

function::kernel_string - Retrieves string from kernel memory.

Synopsis

function kernel_string:string(addr:long)

Arguments

addr

The kernel address to retrieve the string from.

General Syntax

kernel_string:string(addr:long)

Description

This function returns the null terminated C string from a given kernel memory address. Reports an error on string copy fault.

Name

function::kernel_string2 - Retrieves string from kernel memory with alternative error string.

Synopsis

function kernel_string2:string(addr:long,err_msg:string)

Arguments

addr

The kernel address to retrieve the string from.
err_msg

The error message to return when data isn't available.

General Syntax

kernel_string2:string(addr:long, err_msg:string)

Description

This function returns the null terminated C string from a given kernel memory address. Reports the given error message on string copy fault.

Name

function::kernel_string_n - Retrieves string of given length from kernel memory.

Synopsis

function kernel_string_n:string(addr:long,n:long)

Arguments

addr

The kernel address to retrieve the string from.
n

The maximum length of the string (if not null terminated).

General Syntax

kernel_string_n:string(addr:long, n:long)

Description

Returns the C string of a maximum given length from a given kernel memory address. Reports an error on string copy fault.

Name

function::kernel_long - Retrieves a long value stored in kernel memory.

Synopsis

function kernel_long:long(addr:long)

Arguments

addr

The kernel address to retrieve the long from.

General Syntax

kernel_long:long(addr:long)

Description

Returns the long value from a given kernel memory address. Reports an error when reading from the given address fails.

Name

function::kernel_int - Retrieves an int value stored in kernel memory.

Synopsis

function kernel_int:long(addr:long)

Arguments

addr

The kernel address to retrieve the int from.

Description

Returns the int value from a given kernel memory address. Reports an error when reading from the given address fails.

Name

function::kernel_short - Retrieves a short value stored in kernel memory.

Synopsis

function kernel_short:long(addr:long)

Arguments

addr

The kernel address to retrieve the short from.

General Syntax

kernel_short:long(addr:long)

Description

Returns the short value from a given kernel memory address. Reports an error when reading from the given address fails.

Name

function::kernel_char - Retrieves a char value stored in kernel memory.

Synopsis

function kernel_char:long(addr:long)

Arguments

addr

The kernel address to retrieve the char from.

General Syntax

kernel_char:long(addr:long)

Description

Returns the char value from a given kernel memory address. Reports an error when reading from the given address fails.

Name

function::kernel_pointer - Retrieves a pointer value stored in kernel memory.

Synopsis

function kernel_pointer:long(addr:long)

Arguments

addr

The kernel address to retrieve the pointer from.

General Syntax

kernel_pointer:long(addr:long)

Description

Returns the pointer value from a given kernel memory address. Reports an error when reading from the given address fails.

Name

function::user_string - Retrieves string from user space.

Synopsis

function user_string:string(addr:long)

Arguments

addr

The user space address to retrieve the string from.

General Syntax

user_string:string(addr:long)

Description

Returns the null terminated C string from a given user space memory address. Reports "<unknown>" on the rare cases when userspace data is not accessible.

Name

function::user_string2 - Retrieves string from user space with alternative error string.

Synopsis

function user_string2:string(addr:long,err_msg:string)

Arguments

addr

The user space address to retrieve the string from.
err_msg

The error message to return when data isn't available.

General Syntax

user_string2:string(addr:long, err_msg:string)

Description

Returns the null terminated C string from a given user space memory address. Reports the given error message on the rare cases when userspace data is not accessible.

Name

function::user_string_warn - Retrieves string from user space.

Synopsis

function user_string_warn:string(addr:long)

Arguments

addr

The user space address to retrieve the string from.

General Syntax

user_string_warn:string(addr:long)

Description

Returns the null terminated C string from a given user space memory address. Reports "<unknown>" on the rare cases when userspace data is not accessible and warns (but does not abort) about the failure.

Name

function::user_string_quoted - Retrieves and quotes string from user space.

Synopsis

function user_string_quoted:string(addr:long)

Arguments

addr

The user space address to retrieve the string from.

General Syntax

user_string_quoted:string(addr:long)

Description

Returns the null terminated C string from a given user space memory address where any ASCII characters that are not printable are replaced by the corresponding escape sequence in the returned string. Reports "NULL" for address zero. Returns "<unknown>" on the rare cases when userspace data is not accessible at the given address.

Name

function::user_string_n - Retrieves string of given length from user space.

Synopsis

function user_string_n:string(addr:long,n:long)

Arguments

addr

The user space address to retrieve the string from.
n

The maximum length of the string (if not null terminated).

General Syntax

user_string_n:string(addr:long, n:long)

Description

Returns the C string of a maximum given length from a given user space address. Returns "<unknown>" on the rare cases when userspace data is not accessible at the given address.

Name

function::user_string_n2 - Retrieves string of given length from user space.

Synopsis

function user_string_n2:string(addr:long,n:long,err_msg:string)

Arguments

addr

The user space address to retrieve the string from.
n

The maximum length of the string (if not null terminated).
err_msg

The error message to return when data isn't available.

General Syntax

user_string_n2:string(addr:long, n:long, err_msg:string)

Description

Returns the C string of a maximum given length from a given user space address. Returns the given error message string on the rare cases when userspace data is not accessible at the given address.

Name

function::user_string_n_warn - Retrieves string from user space.

Synopsis

function user_string_n_warn:string(addr:long,n:long)

Arguments

addr

The user space address to retrieve the string from.
n

The maximum length of the string (if not null terminated).

General Syntax

user_string_n_warn:string(addr:long, n:long)

Description

Returns up to n characters of a C string from a given user space memory address. Reports "<unknown>" on the rare cases when userspace data is not accessible and warns (but does not abort) about the failure.

Name

function::user_string_n_quoted - Retrieves and quotes string from user space.

Synopsis

function user_string_n_quoted:string(addr:long,n:long)

Arguments

addr

The user space address to retrieve the string from.
n

The maximum length of the string (if not null terminated).

General Syntax

user_string_n_quoted:string(addr:long, n:long)

Description

Returns up to n characters of a C string from the given user space memory address where any ASCII characters that are not printable are replaced by the corresponding escape sequence in the returned string. Reports "NULL" for address zero. Returns "<unknown>" on the rare cases when userspace data is not accessible at the given address.

Name

function::user_short - Retrieves a short value stored in user space.

Synopsis

function user_short:long(addr:long)

Arguments

addr

The user space address to retrieve the short from.

General Syntax

user_short:long(addr:long)

Description

Returns the short value from a given user space address. Returns zero when user space data is not accessible.

Name

function::user_short_warn - Retrieves a short value stored in user space.

Synopsis

function user_short_warn:long(addr:long)

Arguments

addr

The user space address to retrieve the short from.

General Syntax

user_short_warn:long(addr:long)

Description

Returns the short value from a given user space address. Returns zero when user space and warns (but does not abort) about the failure.

Name

function::user_int - Retrieves an int value stored in user space.

Synopsis

function user_int:long(addr:long)

Arguments

addr

The user space address to retrieve the int from.

General Syntax

user_int:long(addr:long)

Description

Returns the int value from a given user space address. Returns zero when user space data is not accessible.

Name

function::user_int_warn - Retrieves an int value stored in user space.

Synopsis

function user_int_warn:long(addr:long)

Arguments

addr

The user space address to retrieve the int from.

General Syntax

user_ing_warn:long(addr:long)

Description

Returns the int value from a given user space address. Returns zero when user space and warns (but does not abort) about the failure.

Name

function::user_long - Retrieves a long value stored in user space.

Synopsis

function user_long:long(addr:long)

Arguments

addr

The user space address to retrieve the long from.

General Syntax

user_long:long(addr:long)

Description

Returns the long value from a given user space address. Returns zero when user space data is not accessible. Note that the size of the long depends on the architecture of the current user space task (for those architectures that support both 64/32 bit compat tasks).

Name

function::user_long_warn - Retrieves a long value stored in user space.

Synopsis

function user_long_warn:long(addr:long)

Arguments

addr

The user space address to retrieve the long from.

General Syntax

user_long_warn:long(addr:long)

Description

Returns the long value from a given user space address. Returns zero when user space and warns (but does not abort) about the failure. Note that the size of the long depends on the architecture of the current user space task (for those architectures that support both 64/32 bit compat tasks).

Name

function::user_char - Retrieves a char value stored in user space.

Synopsis

function user_char:long(addr:long)

Arguments

addr

The user space address to retrieve the char from.

General Syntax

user_char:long(addr:long)

Description

Returns the char value from a given user space address. Returns zero when user space data is not accessible.

Name

function::user_char_warn - Retrieves a char value stored in user space.

Synopsis

function user_char_warn:long(addr:long)

Arguments

addr

The user space address to retrieve the char from.

General Syntax

user_char_warn:long(addr:long)

Description

Returns the char value from a given user space address. Returns zero when user space and warns (but does not abort) about the failure.

Chapter 19. A collection of standard string functions

function::strlen - Returns the length of a string.
function::substr - Returns a substring.
function::stringat - Returns the char at a given position in the string.
function::isinstr - Returns whether a string is a substring of another string.
function::text_str - Escape any non-printable chars in a string.
function::text_strn - Escape any non-printable chars in a string.
function::tokenize - Return the next non-empty token in a string.
function::str_replace - str_replace Replaces all instances of a substring with another.
function::strtol - strtol - Convert a string to a long.
function::isdigit - Checks for a digit.

Functions to get the length, a substring, getting at individual characters, string seaching, escaping, tokenizing, and converting strings to longs.

Name

function::strlen - Returns the length of a string.

Synopsis

function strlen:long(s:string)

Arguments

s

the string

General Syntax

strlen: long (str:string)

Description

This function returns the length of the string, which can be zero up to MAXSTRINGLEN.

Name

function::substr - Returns a substring.

Synopsis

function substr:string(str:string,start:long,length:long)

Arguments

str

The string to take a substring from
start

Starting position. 0 = start of the string.
length

Length of string to return.

General Syntax

substr:string (str:string, start:long, stop:long)

Description

Returns the substring of the up to the given length starting at the given start position and ending at given stop position.

Name

function::stringat - Returns the char at a given position in the string.

Synopsis

function stringat:long(str:string,pos:long)

Arguments

str

The string to fetch the character from.
pos

The position to get the character from. 0 = start of the string.

General Syntax

stringat:long(srt:string, pos:long)

Description

This function returns the character at a given position in the string or zero if thestring doesn't have as many characters.

Name

function::isinstr - Returns whether a string is a substring of another string.

Synopsis

function isinstr:long(s1:string,s2:string)

Arguments

s1

String to search in.
s2

Substring to find.

General syntax

isinstr:long (s1:string, s2:string)

Description

This function returns 1 if string s1 contains s2, otherwise zero.

Name

function::text_str - Escape any non-printable chars in a string.

Synopsis

function text_str:string(input:string)

Arguments

input

The string to escape.

General Syntax

text_str:string (input:string)

Description

This function accepts a string argument, and any ASCII characters that are not printable are replaced by the corresponding escape sequence in the returned string.

Name

function::text_strn - Escape any non-printable chars in a string.

Synopsis

function text_strn:string(input:string,len:long,quoted:long)

Arguments

input

The string to escape.
len

Maximum length of string to return. 0 means MAXSTRINGLEN.
quoted

Put double quotes around the string. If input string is truncated it will have "..." after the second quote.

General Syntax

text_strn:string (input:string, len:long, quoted:long)

Description

This function accepts a string of designated length, and any ASCII characters that are not printable are replaced by the corresponding escape sequence in the returned string.

Name

function::tokenize - Return the next non-empty token in a string.

Synopsis

function tokenize:string(input:string,delim:string)

Arguments

input

String to tokenize. If NULL, returns the next non-empty token in the string passed in the previous call to tokenize.
delim

Token delimiter. Set of characters that delimit the tokens.

General Syntax

tokenize:string (input:string, delim:string)

Description

This function returns the next non-empty token in the given input string, where the tokens are delimited by characters in the delim string. If the input string is non-NULL, it returns the first token. If the input string is NULL, it returns the next token in the string passed in the previous call to tokenize. If no delimiter is found, the entire remaining input string is returned. It returns NULL when no more tokens are available.

Name

function::str_replace - str_replace Replaces all instances of a substring with another.

Synopsis

function str_replace:string(prnt_str:string,srch_str:string,rplc_str:string)

Arguments

prnt_str

The string to search and replace in.
srch_str

The substring which is used to search in prnt_str string.
rplc_str

The substring which is used to replace srch_str.

General Syntax

str_replace:string(prnt_str:string, srch_str:string, rplc_str:string)

Description

This function returns the given string with substrings replaced.

Name

function::strtol - strtol - Convert a string to a long.

Synopsis

function strtol:long(str:string,base:long)

Arguments

str

String to convert.
base

The base to use

General Syntax

strtol:long (str:string, base:long)

Description

This function converts the string representation of a number to an integer. The base parameter indicates the number base to assume for the string (eg. 16 for hex, 8 for octal, 2 for binary).

Name

function::isdigit - Checks for a digit.

Synopsis

function isdigit:long(str:string)

Arguments

str

String to check.

General Syntax

isdigit:long(str:string)

Description

Checks for a digit (0 through 9) as the first character of a string. Returns non-zero if true, and a zero if false.

Chapter 20. Utility functions for using ansi control chars in logs

function::ansi_clear_screen - Move cursor to top left and clear screen.
function::ansi_set_color - Set the ansi Select Graphic Rendition mode.
function::ansi_set_color2 - Set the ansi Select Graphic Rendition mode.
function::ansi_set_color3 - Set the ansi Select Graphic Rendition mode.
function::ansi_reset_color - Resets Select Graphic Rendition mode.
function::ansi_new_line - Move cursor to new line.
function::ansi_cursor_move - Move cursor to new coordinates.
function::ansi_cursor_hide - Hides the cursor.
function::ansi_cursor_save - Saves the cursor position.
function::ansi_cursor_restore - Restores a previously saved cursor position.
function::ansi_cursor_show - Shows the cursor.

Utility functions for logging using ansi control characters. This lets you manipulate the cursor position and character color output and attributes of log messages.

Name

function::ansi_clear_screen - Move cursor to top left and clear screen.

Synopsis

function ansi_clear_screen()

Arguments

None

General Syntax

ansi_clear_screen

Description

Sends ansi code for moving cursor to top left and then the ansi code for clearing the screen from the cursor position to the end.

Name

function::ansi_set_color - Set the ansi Select Graphic Rendition mode.

Synopsis

function ansi_set_color(fg:long)

Arguments

fg

Foreground color to set.

General Syntax

ansi_set_color(fh:long)

Description

Sends ansi code for Select Graphic Rendition mode for the given forground color. Black (30), Blue (34), Green (32), Cyan (36), Red (31), Purple (35), Brown (33), Light Gray (37).

Name

function::ansi_set_color2 - Set the ansi Select Graphic Rendition mode.

Synopsis

function ansi_set_color2(fg:long,bg:long)

Arguments

fg

Foreground color to set.
bg

Background color to set.

General Syntax

ansi_set_color2(fg:long, bg:long)

Description

Sends ansi code for Select Graphic Rendition mode for the given forground color, Black (30), Blue (34), Green (32), Cyan (36), Red (31), Purple (35), Brown (33), Light Gray (37) and the given background color, Black (40), Red (41), Green (42), Yellow (43), Blue (44), Magenta (45), Cyan (46), White (47).

Name

function::ansi_set_color3 - Set the ansi Select Graphic Rendition mode.

Synopsis

function ansi_set_color3(fg:long,bg:long,attr:long)

Arguments

fg

Foreground color to set.
bg

Background color to set.
attr

Color attribute to set.

General Syntax

ansi_set_color3(fg:long, bg:long, attr:long)

Description

Sends ansi code for Select Graphic Rendition mode for the given forground color, Black (30), Blue (34), Green (32), Cyan (36), Red (31), Purple (35), Brown (33), Light Gray (37), the given background color, Black (40), Red (41), Green (42), Yellow (43), Blue (44), Magenta (45), Cyan (46), White (47) and the color attribute All attributes off (0), Intensity Bold (1), Underline Single (4), Blink Slow (5), Blink Rapid (6), Image Negative (7).

Name

function::ansi_reset_color - Resets Select Graphic Rendition mode.

Synopsis

function ansi_reset_color()

Arguments

None

General Syntax

ansi_reset_color

Description

Sends ansi code to reset foreground, background and color attribute to default values.

Name

function::ansi_new_line - Move cursor to new line.

Synopsis

function ansi_new_line()

Arguments

None

General Syntax

ansi_new_line

Description

Sends ansi code new line.

Name

function::ansi_cursor_move - Move cursor to new coordinates.

Synopsis

function ansi_cursor_move(x:long,y:long)

Arguments

x

Row to move the cursor to.
y

Colomn to move the cursor to.

General Syntax

ansi_curos_move(x:long, y:long)

Description

Sends ansi code for positioning the cursor at row x and column y. Coordinates start at one, (1,1) is the top-left corner.

Name

function::ansi_cursor_hide - Hides the cursor.

Synopsis

function ansi_cursor_hide()

Arguments

None

General Syntax

ansi_cusor_hide

Description

Sends ansi code for hiding the cursor.

Name

function::ansi_cursor_save - Saves the cursor position.

Synopsis

function ansi_cursor_save()

Arguments

None

General Syntax

ansi_cursor_save

Description

Sends ansi code for saving the current cursor position.

Name

function::ansi_cursor_restore - Restores a previously saved cursor position.

Synopsis

function ansi_cursor_restore()

Arguments

None

General Syntax

ansi_cursor_restore

Description

Sends ansi code for restoring the current cursor position previously saved with ansi_cursor_save.

Name

function::ansi_cursor_show - Shows the cursor.

Synopsis

function ansi_cursor_show()

Arguments

None

General Syntax

ansi_cursor_show

Description

Sends ansi code for showing the cursor.
(Sebelumnya) 22 : Chapter 11. Networking Ta ...23 : V2V Guide (Berikutnya)